@inquir/compute
v0.1.1
Published
Workspace-first SDK for Inquir Compute assets.
Downloads
97
Readme
@inquir/compute
Workspace-first SDK for defining, discovering, generating, and running Inquir Compute assets.
Install
npm install @inquir/compute zodWhat It Includes
defineFunction()anddefinePipeline()for code-first assets.loadConfig()forinquir.config.json.discoverAssets()for workspace asset scanning.generateCodegenArtifacts()/generateAndWriteCodegenArtifacts()for typed client +registry.json.runLocally()for local function execution/debug harness.- HTTP transport helpers (
createClient,invokeRemote, deploy/list helpers).
Concepts
- Function: a single compute unit with typed input/output (Zod schemas). Created with
defineFunction(). Discovered by file pattern, run locally viarunLocally(), deployed and invoked remotely via the transport helpers. - Pipeline: a declarative DAG of functions created with
definePipeline(). Included in the codegen registry; orchestration is handled server-side. - Client: the generated
client.ts(fromgenerateAndWriteCodegenArtifacts()). Provides a type-safecreateClient()factory that wrapsinvokeRemote()with your asset's I/O types. - Source of truth: local files on disk.
registry.jsonis derived — rebuild it withgenerateAndWriteCodegenArtifacts()whenever sources change. - Local ↔ remote link: remote functions store
linkedLocalName(local asset name) andsourceHash. Compare hashes to detect drift.
Quick Example
import { defineFunction } from '@inquir/compute';
import { z } from 'zod';
export const hello = defineFunction(
{
name: 'hello',
input: z.object({ name: z.string().optional() }),
output: z.object({ message: z.string() }),
},
async (input) => ({ message: `Hello, ${input.name ?? 'world'}` })
);Minimal Workspace Config
Create inquir.config.json:
{
"functionsDir": "inquir/functions",
"pipelinesDir": "inquir/pipelines",
"generatedDir": ".inquir/generated"
}Discovery + Codegen
import { discoverAssets, generateAndWriteCodegenArtifacts, loadConfig } from '@inquir/compute';
const config = loadConfig(process.cwd());
const registry = await discoverAssets(config);
await generateAndWriteCodegenArtifacts(config.absoluteGeneratedDir, registry);This generates:
.inquir/generated/client.ts.inquir/generated/registry.json
registry.json includes stable metadata such as name, kind, sourceHash, and assetRoot.
Local Run
import { runLocally } from '@inquir/compute';
const result = await runLocally(
{
kind: 'function',
name: 'hello',
filePath: '/abs/path/inquir/functions/hello/index.ts',
exportName: 'hello',
},
{ name: 'World' }
);Remote Invoke (Transport)
import { createClient, invokeRemote } from '@inquir/compute';
const client = createClient({ baseUrl: 'http://localhost:3000', apiKey: process.env.INQUIR_API_KEY });
const response = await invokeRemote(client, 'hello', { name: 'World' });