@theokit/di-agent 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -47,16 +47,17 @@ function readAutoSummarizeMetadata(target) {
47
47
  __name(readAutoSummarizeMetadata, "readAutoSummarizeMetadata");
48
48
  function Cron(options) {
49
49
  return (target, propertyKey, _descriptor) => {
50
- const metadata = {
50
+ const existing = Reflect.getMetadata(METADATA_KEYS.CRON, target.constructor) ?? /* @__PURE__ */ new Map();
51
+ existing.set(propertyKey, {
51
52
  ...options,
52
53
  methodKey: propertyKey
53
- };
54
- Reflect.defineMetadata(METADATA_KEYS.CRON, metadata, target.constructor);
54
+ });
55
+ Reflect.defineMetadata(METADATA_KEYS.CRON, existing, target.constructor);
55
56
  };
56
57
  }
57
58
  __name(Cron, "Cron");
58
59
  function readCronMetadata(target) {
59
- return Reflect.getMetadata(METADATA_KEYS.CRON, target);
60
+ return Reflect.getMetadata(METADATA_KEYS.CRON, target) ?? /* @__PURE__ */ new Map();
60
61
  }
61
62
  __name(readCronMetadata, "readCronMetadata");
62
63
  function EvalDecorator(options = {}) {
@@ -71,16 +72,17 @@ function readEvalDecoratorMetadata(target) {
71
72
  __name(readEvalDecoratorMetadata, "readEvalDecoratorMetadata");
72
73
  function Hitl(options) {
73
74
  return (target, propertyKey, _descriptor) => {
74
- const metadata = {
75
+ const existing = Reflect.getMetadata(METADATA_KEYS.HITL, target.constructor) ?? /* @__PURE__ */ new Map();
76
+ existing.set(propertyKey, {
75
77
  ...options,
76
78
  methodKey: propertyKey
77
- };
78
- Reflect.defineMetadata(METADATA_KEYS.HITL, metadata, target.constructor);
79
+ });
80
+ Reflect.defineMetadata(METADATA_KEYS.HITL, existing, target.constructor);
79
81
  };
80
82
  }
81
83
  __name(Hitl, "Hitl");
82
84
  function readHitlMetadata(target) {
83
- return Reflect.getMetadata(METADATA_KEYS.HITL, target);
85
+ return Reflect.getMetadata(METADATA_KEYS.HITL, target) ?? /* @__PURE__ */ new Map();
84
86
  }
85
87
  __name(readHitlMetadata, "readHitlMetadata");
86
88
  function MemoryScopeDecorator(options) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tokens.ts","../src/agent-provider.ts","../src/decorators/auth.ts","../src/decorators/auto-summarize.ts","../src/decorators/cron.ts","../src/decorators/eval-decorator.ts","../src/decorators/hitl.ts","../src/decorators/memory-scope.ts","../src/decorators/reranker.ts","../src/decorators/retriever.ts","../src/decorators/squad.ts","../src/decorators/step.ts","../src/decorators/sub-agent.ts","../src/decorators/subscription.ts","../src/decorators/text-splitter.ts","../src/decorators/tool.ts","../src/decorators/use-sandbox.ts","../src/decorators/workflow.ts","../src/inject-agent.ts","../src/workflow-builder.ts"],"names":["AGENT_TOKEN","createAgentProvider","options","provide","useFactory","factory","scope","Scope","REQUEST","Auth","target","Reflect","defineMetadata","METADATA_KEYS","AUTH","readAuthMetadata","getMetadata","DEFAULTS","triggerFraction","keepNewest","AutoSummarize","resolved","AUTO_SUMMARIZE","readAutoSummarizeMetadata","Cron","propertyKey","_descriptor","metadata","methodKey","CRON","readCronMetadata","EvalDecorator","EVAL","readEvalDecoratorMetadata","Hitl","HITL","readHitlMetadata","MemoryScopeDecorator","existing","MEMORY_SCOPE","Map","set","readMemoryScopeMetadata","Reranker","RERANKER","readRerankerMetadata","Retriever","RETRIEVER","readRetrieverMetadata","Squad","SQUAD","readSquadMetadata","Step","STEP","readStepMetadata","SubAgent","SUBAGENT","readSubAgentMetadata","Subscription","SUBSCRIPTION","readSubscriptionMetadata","TextSplitter","TEXT_SPLITTER","readTextSplitterMetadata","Tool","TOOL","readToolMetadata","UseSandbox","SANDBOX","readSandboxMetadata","Workflow","WORKFLOW","readWorkflowMetadata","InjectAgent","Inject","buildWorkflow","instance","ctor","meta","size","Error","name","steps","resolveSteps","validateAfterTargets","ordered","topoSort","builder","create","s","then","fn","id","input","run","commit","key","m","k","String","method","after","call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K,MAAAA,CAAOxB,EAAEO,GAAG,CAAA;AACrBU,IAAAA,MAAAA,CAAOI,GAAAA,CAAIrB,EAAEO,GAAG,CAAA;AAChBX,IAAAA,OAAAA,CAAQ6B,KAAKzB,CAAAA,CAAAA;EACf,CAAA,EAbc,OAAA,CAAA;AAed,EAAA,KAAA,MAAWA,CAAAA,IAAKP,KAAAA,CAAMqB,MAAAA,EAAM,QAAUd,CAAAA,CAAAA;AACtC,EAAA,OAAOJ,OAAAA;AACT;AAtBSC,MAAAA,CAAAA,QAAAA,EAAAA,UAAAA,CAAAA","file":"index.js","sourcesContent":["/**\n * Token used by `@InjectAgent()` to look up the Agent provider. Importing\n * this directly (instead of using the decorator) lets you register a\n * custom factory under the same token.\n */\nexport const AGENT_TOKEN = \"@theokit/di-agent:Agent\";\n","import { type FactoryProvider, Scope } from \"@theokit/di\";\n\nimport { AGENT_TOKEN } from \"./tokens.js\";\n\n/**\n * Options accepted by `createAgentProvider()`. Mirrors the public\n * `AgentOptions` from `@theokit/sdk` but kept structural so this package\n * does not have a hard import dependency on the SDK's type tree.\n *\n * The factory `async () => Agent.create(options)` is provided by the\n * consumer (see `createAgentProvider` below). This package supplies the\n * scope + token wiring.\n */\nexport interface CreateAgentProviderOptions<TAgent> {\n /**\n * Factory function that produces a fresh Agent per REQUEST.\n * Typically `() => Agent.create({...})` from `@theokit/sdk`.\n */\n factory: () => TAgent | Promise<TAgent>;\n /**\n * Override the scope. Default is `REQUEST` (the wedge — one isolated\n * Agent per HTTP request). Override to `SINGLETON` for CLI / cron /\n * single-tenant scenarios where a shared Agent is desirable.\n */\n scope?: Scope;\n}\n\n/**\n * Build a `FactoryProvider` that materializes an Agent on demand.\n *\n * @example\n * import { Agent } from \"@theokit/sdk\";\n * import { Module } from \"@theokit/di\";\n * import { createAgentProvider } from \"@theokit/di-agent\";\n *\n * @Module({\n * providers: [\n * createAgentProvider({\n * factory: () => Agent.create({ apiKey: process.env.OPENROUTER_API_KEY!, model: { id: \"openai/gpt-4o-mini\" } }),\n * }),\n * ],\n * })\n * class AppModule {}\n */\nexport function createAgentProvider<TAgent>(\n options: CreateAgentProviderOptions<TAgent>,\n): FactoryProvider<TAgent> {\n return {\n provide: AGENT_TOKEN,\n useFactory: () => options.factory(),\n scope: options.scope ?? Scope.REQUEST,\n };\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface AuthOptions {\n providers?: string[];\n sessionConfig?: unknown;\n}\n\nexport function Auth(options: AuthOptions = {}): ClassDecorator {\n return (target: Function) => {\n Reflect.defineMetadata(METADATA_KEYS.AUTH, options, target);\n };\n}\n\nexport function readAuthMetadata(target: Function): AuthOptions | undefined {\n return Reflect.getMetadata(METADATA_KEYS.AUTH, target) as AuthOptions | undefined;\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface AutoSummarizeOptions {\n triggerFraction?: number;\n keepNewest?: number;\n model?: string;\n}\n\nconst DEFAULTS: Required<Omit<AutoSummarizeOptions, \"model\">> = {\n triggerFraction: 0.85,\n keepNewest: 4,\n};\n\nexport function AutoSummarize(options: AutoSummarizeOptions = {}): ClassDecorator {\n return (target: Function) => {\n const resolved = { ...DEFAULTS, ...options };\n Reflect.defineMetadata(METADATA_KEYS.AUTO_SUMMARIZE, resolved, target);\n };\n}\n\nexport function readAutoSummarizeMetadata(\n target: abstract new (...args: never) => unknown,\n): (Required<Omit<AutoSummarizeOptions, \"model\">> & { model?: string }) | undefined {\n return Reflect.getMetadata(METADATA_KEYS.AUTO_SUMMARIZE, target) as\n | (Required<Omit<AutoSummarizeOptions, \"model\">> & { model?: string })\n | undefined;\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface CronOptions {\n schedule: string;\n timezone?: string;\n}\n\nexport interface CronMetadata extends CronOptions {\n methodKey: string | symbol;\n}\n\nexport function Cron(options: CronOptions): MethodDecorator {\n return (target: object, propertyKey: string | symbol, _descriptor: PropertyDescriptor) => {\n const metadata: CronMetadata = { ...options, methodKey: propertyKey };\n Reflect.defineMetadata(METADATA_KEYS.CRON, metadata, target.constructor);\n };\n}\n\nexport function readCronMetadata(\n target: abstract new (...args: never) => unknown,\n): CronMetadata | undefined {\n return Reflect.getMetadata(METADATA_KEYS.CRON, target) as CronMetadata | undefined;\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface EvalOptions {\n name?: string;\n scorers?: unknown[];\n dataset?: unknown;\n}\n\nexport function EvalDecorator(options: EvalOptions = {}): ClassDecorator {\n return (target: Function) => {\n Reflect.defineMetadata(METADATA_KEYS.EVAL, options, target);\n };\n}\n\nexport function readEvalDecoratorMetadata(target: Function): EvalOptions | undefined {\n return Reflect.getMetadata(METADATA_KEYS.EVAL, target) as EvalOptions | undefined;\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface HitlOptions {\n tools: string[];\n timeoutMs?: number;\n}\n\nexport interface HitlMetadata extends HitlOptions {\n methodKey: string | symbol;\n}\n\nexport function Hitl(options: HitlOptions): MethodDecorator {\n return (target: object, propertyKey: string | symbol, _descriptor: PropertyDescriptor) => {\n const metadata: HitlMetadata = { ...options, methodKey: propertyKey };\n Reflect.defineMetadata(METADATA_KEYS.HITL, metadata, target.constructor);\n };\n}\n\nexport function readHitlMetadata(\n target: abstract new (...args: never) => unknown,\n): HitlMetadata | undefined {\n return Reflect.getMetadata(METADATA_KEYS.HITL, target) as HitlMetadata | undefined;\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface MemoryScopeOptions {\n path: string;\n}\n\nexport function MemoryScopeDecorator(options: MemoryScopeOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, MemoryScopeOptions> =\n Reflect.getMetadata(METADATA_KEYS.MEMORY_SCOPE, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.MEMORY_SCOPE, existing, target.constructor);\n };\n}\n\nexport function readMemoryScopeMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, MemoryScopeOptions> {\n return Reflect.getMetadata(METADATA_KEYS.MEMORY_SCOPE, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface RerankerOptions {\n provider?: string;\n model?: string;\n topN?: number;\n}\n\nexport function Reranker(options: RerankerOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, RerankerOptions> =\n Reflect.getMetadata(METADATA_KEYS.RERANKER, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.RERANKER, existing, target.constructor);\n };\n}\n\nexport function readRerankerMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, RerankerOptions> {\n return Reflect.getMetadata(METADATA_KEYS.RERANKER, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface RetrieverOptions {\n topK?: number;\n threshold?: number;\n}\n\nexport function Retriever(options: RetrieverOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, RetrieverOptions> =\n Reflect.getMetadata(METADATA_KEYS.RETRIEVER, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.RETRIEVER, existing, target.constructor);\n };\n}\n\nexport function readRetrieverMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, RetrieverOptions> {\n return Reflect.getMetadata(METADATA_KEYS.RETRIEVER, target) ?? new Map();\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/**\n * Metadata captured by the `@Squad()` property decorator. Declares a sequential\n * agent team by referencing the agent property names that compose it. Mirrors\n * the `@theokit/sdk` `createSquad` factory (decorator mandate — every agentic\n * capability ships a decorator alongside the factory).\n */\nexport interface SquadMetadata {\n /** Agent property names (or ids) that run in order. */\n agents: string[];\n /** Orchestration process. Default (omitted) = `\"sequential\"`. */\n process?: \"sequential\" | \"hierarchical\";\n /** Optional squad name. */\n name?: string;\n}\n\n/**\n * `@Squad(metadata)` — declare a sequential agent team on a property. The DI\n * container / agent provider materializes it into a `createSquad(...)` at wiring\n * time.\n */\nexport function Squad(metadata: SquadMetadata): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, SquadMetadata> =\n Reflect.getMetadata(METADATA_KEYS.SQUAD, target.constructor) ?? new Map();\n existing.set(propertyKey, metadata);\n Reflect.defineMetadata(METADATA_KEYS.SQUAD, existing, target.constructor);\n };\n}\n\n/** Read `@Squad()` metadata off a class constructor. */\nexport function readSquadMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, SquadMetadata> {\n return Reflect.getMetadata(METADATA_KEYS.SQUAD, target) ?? new Map();\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/**\n * Metadata captured by the `@Step()` method decorator. Declares one step of a\n * decorator-driven workflow and its single upstream dependency. Compiled into\n * a `@theokit/sdk` `Workflow` by `buildWorkflow` (decorator mandate — every\n * agentic capability ships a decorator alongside the factory/builder).\n */\nexport interface StepMetadata {\n /**\n * Method name of the upstream step this step runs after. Omitted = entry\n * step (receives the workflow input). MVP supports a single dependency\n * (linear chain); branching/fan-out stays the imperative `Workflow` surface.\n */\n after?: string;\n /** Optional step id (defaults to the method name). */\n name?: string;\n}\n\n/**\n * `@Step(metadata?)` — mark a class method as a workflow step. The method\n * receives the upstream step's return value (or the workflow input for an\n * entry step) and returns this step's output.\n */\nexport function Step(metadata: StepMetadata = {}): MethodDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, StepMetadata> =\n Reflect.getMetadata(METADATA_KEYS.STEP, target.constructor) ?? new Map();\n existing.set(propertyKey, metadata);\n Reflect.defineMetadata(METADATA_KEYS.STEP, existing, target.constructor);\n };\n}\n\n/** Read `@Step()` metadata off a class constructor (insertion-ordered). */\nexport function readStepMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, StepMetadata> {\n return Reflect.getMetadata(METADATA_KEYS.STEP, target) ?? new Map();\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface SubAgentOptions {\n name: string;\n description: string;\n instructions: string;\n model?: string;\n maxDelegationDepth?: number;\n}\n\nexport function SubAgent(options: SubAgentOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, SubAgentOptions> =\n Reflect.getMetadata(METADATA_KEYS.SUBAGENT, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.SUBAGENT, existing, target.constructor);\n };\n}\n\nexport function readSubAgentMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, SubAgentOptions> {\n return Reflect.getMetadata(METADATA_KEYS.SUBAGENT, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface SubscriptionOptions {\n name: string;\n transport?: string;\n}\n\nexport function Subscription(options: SubscriptionOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, SubscriptionOptions> =\n Reflect.getMetadata(METADATA_KEYS.SUBSCRIPTION, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.SUBSCRIPTION, existing, target.constructor);\n };\n}\n\nexport function readSubscriptionMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, SubscriptionOptions> {\n return Reflect.getMetadata(METADATA_KEYS.SUBSCRIPTION, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface TextSplitterOptions {\n strategy?: string;\n chunkSize?: number;\n overlap?: number;\n}\n\nexport function TextSplitter(options: TextSplitterOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, TextSplitterOptions> =\n Reflect.getMetadata(METADATA_KEYS.TEXT_SPLITTER, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.TEXT_SPLITTER, existing, target.constructor);\n };\n}\n\nexport function readTextSplitterMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, TextSplitterOptions> {\n return Reflect.getMetadata(METADATA_KEYS.TEXT_SPLITTER, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface ToolOptions {\n name: string;\n description: string;\n inputSchema?: unknown;\n}\n\nexport function Tool(options: ToolOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, ToolOptions> =\n Reflect.getMetadata(METADATA_KEYS.TOOL, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.TOOL, existing, target.constructor);\n };\n}\n\nexport function readToolMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, ToolOptions> {\n return Reflect.getMetadata(METADATA_KEYS.TOOL, target) ?? new Map();\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface UseSandboxOptions {\n backend?: \"local\" | \"docker\" | string;\n workDir?: string;\n timeoutMs?: number;\n}\n\nexport function UseSandbox(options: UseSandboxOptions = {}): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, UseSandboxOptions> =\n Reflect.getMetadata(METADATA_KEYS.SANDBOX, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.SANDBOX, existing, target.constructor);\n };\n}\n\nexport function readSandboxMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, UseSandboxOptions> {\n return Reflect.getMetadata(METADATA_KEYS.SANDBOX, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nexport interface WorkflowOptions {\n name?: string;\n retryPolicy?: unknown;\n inputSchema?: unknown;\n outputSchema?: unknown;\n}\n\nexport function Workflow(options: WorkflowOptions = {}): ClassDecorator {\n return (target: Function) => {\n Reflect.defineMetadata(METADATA_KEYS.WORKFLOW, options, target);\n };\n}\n\nexport function readWorkflowMetadata(target: Function): WorkflowOptions | undefined {\n return Reflect.getMetadata(METADATA_KEYS.WORKFLOW, target) as WorkflowOptions | undefined;\n}\n","import { Inject } from \"@theokit/di\";\n\nimport { AGENT_TOKEN } from \"./tokens.js\";\n\n/**\n * Parameter decorator — injects the REQUEST-scoped Agent into a constructor.\n * Equivalent to `@Inject(AGENT_TOKEN)` but documents intent.\n *\n * @example\n * @Injectable()\n * class ChatController {\n * constructor(@InjectAgent() private readonly agent: Agent) {}\n *\n * async chat(message: string) {\n * return this.agent.send(message);\n * }\n * }\n */\nexport function InjectAgent(): ParameterDecorator {\n return Inject(AGENT_TOKEN);\n}\n","/**\n * `buildWorkflow` — compile a `@Step`-decorated class instance into a\n * `@theokit/sdk` `Workflow`.\n *\n * This is the materializer/bridge for the decorator-driven workflow authoring\n * surface (cross-val Gap 2). It COMPOSES the existing `Workflow` engine — it\n * adds no orchestration logic of its own (same principle as `createSquad`).\n * Steps are topologically ordered by their single `after` dependency into a\n * linear `Workflow.then(...)` chain; each step's return value is threaded into\n * the next step. Branching/fan-out remains the imperative `Workflow` surface.\n *\n * NOTE: this module (unlike the metadata-only decorators) imports the\n * `@theokit/sdk` peer dependency — it is the bridge layer.\n */\n\nimport { fn, Workflow } from \"@theokit/sdk/workflow\";\nimport { readStepMetadata, type StepMetadata } from \"./decorators/step.js\";\nimport { readWorkflowMetadata } from \"./decorators/workflow.js\";\n\ninterface ResolvedStep {\n key: string;\n id: string;\n after?: string;\n run: (input: unknown) => unknown;\n}\n\n/**\n * Build a `Workflow` from a `@Step`-decorated instance. Validates the step\n * graph (fail-fast) before constructing the workflow.\n *\n * @throws Error when there are no `@Step` methods, an `after` references an\n * unknown step, or the `after` graph contains a cycle.\n */\nexport function buildWorkflow(instance: object): Workflow {\n const ctor = instance.constructor as abstract new (...args: never) => unknown;\n const meta = readStepMetadata(ctor);\n if (meta.size === 0) {\n throw new Error(`buildWorkflow: class \"${instance.constructor.name}\" has no @Step methods`);\n }\n\n const steps = resolveSteps(instance, meta);\n validateAfterTargets(steps);\n const ordered = topoSort(steps);\n\n const name = readWorkflowMetadata(instance.constructor as Function)?.name ?? \"workflow\";\n let builder = Workflow.create({ name });\n for (const s of ordered) {\n builder = builder.then(fn(s.id, (input: unknown) => s.run(input)));\n }\n return builder.commit();\n}\n\n/** Resolve each `@Step` method into a runnable {@link ResolvedStep}. */\nfunction resolveSteps(\n instance: object,\n meta: ReadonlyMap<string | symbol, StepMetadata>,\n): Map<string, ResolvedStep> {\n const steps = new Map<string, ResolvedStep>();\n for (const [key, m] of meta) {\n const k = String(key);\n const method = (instance as Record<string, unknown>)[k];\n if (typeof method !== \"function\") {\n throw new Error(`buildWorkflow: @Step \"${k}\" is not a method`);\n }\n steps.set(k, {\n key: k,\n id: m.name ?? k,\n after: m.after,\n run: (input: unknown) => (method as (i: unknown) => unknown).call(instance, input),\n });\n }\n return steps;\n}\n\n/** Fail-fast if any `after` references a step that does not exist. */\nfunction validateAfterTargets(steps: Map<string, ResolvedStep>): void {\n for (const s of steps.values()) {\n if (s.after !== undefined && !steps.has(s.after)) {\n throw new Error(\n `buildWorkflow: @Step \"${s.key}\" declares after: \"${s.after}\" which is not a known @Step (unknown upstream)`,\n );\n }\n }\n}\n\n/**\n * Topologically order steps by their single `after` dependency. Entry steps\n * (no `after`) come first in declaration order; each dependent follows its\n * upstream. Throws on a cycle.\n */\nfunction topoSort(steps: Map<string, ResolvedStep>): ResolvedStep[] {\n const ordered: ResolvedStep[] = [];\n const placed = new Set<string>();\n const visiting = new Set<string>();\n\n const visit = (s: ResolvedStep): void => {\n if (placed.has(s.key)) return;\n if (visiting.has(s.key)) {\n throw new Error(`buildWorkflow: cycle detected in @Step \"after\" graph at \"${s.key}\"`);\n }\n visiting.add(s.key);\n if (s.after !== undefined) {\n const up = steps.get(s.after);\n if (up !== undefined) visit(up);\n }\n visiting.delete(s.key);\n placed.add(s.key);\n ordered.push(s);\n };\n\n for (const s of steps.values()) visit(s);\n return ordered;\n}\n"]}
1
+ {"version":3,"sources":["../src/tokens.ts","../src/agent-provider.ts","../src/decorators/auth.ts","../src/decorators/auto-summarize.ts","../src/decorators/cron.ts","../src/decorators/eval-decorator.ts","../src/decorators/hitl.ts","../src/decorators/memory-scope.ts","../src/decorators/reranker.ts","../src/decorators/retriever.ts","../src/decorators/squad.ts","../src/decorators/step.ts","../src/decorators/sub-agent.ts","../src/decorators/subscription.ts","../src/decorators/text-splitter.ts","../src/decorators/tool.ts","../src/decorators/use-sandbox.ts","../src/decorators/workflow.ts","../src/inject-agent.ts","../src/workflow-builder.ts"],"names":["AGENT_TOKEN","createAgentProvider","options","provide","useFactory","factory","scope","Scope","REQUEST","Auth","target","Reflect","defineMetadata","METADATA_KEYS","AUTH","readAuthMetadata","getMetadata","DEFAULTS","triggerFraction","keepNewest","AutoSummarize","resolved","AUTO_SUMMARIZE","readAutoSummarizeMetadata","Cron","propertyKey","_descriptor","existing","CRON","Map","set","methodKey","readCronMetadata","EvalDecorator","EVAL","readEvalDecoratorMetadata","Hitl","HITL","readHitlMetadata","MemoryScopeDecorator","MEMORY_SCOPE","readMemoryScopeMetadata","Reranker","RERANKER","readRerankerMetadata","Retriever","RETRIEVER","readRetrieverMetadata","Squad","metadata","SQUAD","readSquadMetadata","Step","STEP","readStepMetadata","SubAgent","SUBAGENT","readSubAgentMetadata","Subscription","SUBSCRIPTION","readSubscriptionMetadata","TextSplitter","TEXT_SPLITTER","readTextSplitterMetadata","Tool","TOOL","readToolMetadata","UseSandbox","SANDBOX","readSandboxMetadata","Workflow","WORKFLOW","readWorkflowMetadata","InjectAgent","Inject","buildWorkflow","instance","ctor","meta","size","Error","name","steps","resolveSteps","validateAfterTargets","ordered","topoSort","builder","create","s","then","fn","id","input","run","commit","key","m","k","String","method","after","call","values","undefined","has","placed","Set","visiting","visit","add","up","get","delete","push"],"mappings":";;;;;;;;AAKO,IAAMA,WAAAA,GAAc;;;ACuCpB,SAASC,oBACdC,OAAAA,EAA2C;AAE3C,EAAA,OAAO;IACLC,OAAAA,EAASH,WAAAA;IACTI,UAAAA,kBAAY,MAAA,CAAA,MAAMF,OAAAA,CAAQG,OAAAA,EAAO,EAArB,YAAA,CAAA;IACZC,KAAAA,EAAOJ,OAAAA,CAAQI,SAASC,KAAAA,CAAMC;AAChC,GAAA;AACF;AARgBP,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA;AC1BT,SAASQ,IAAAA,CAAKP,OAAAA,GAAuB,EAAC,EAAC;AAC5C,EAAA,OAAO,CAACQ,MAAAA,KAAAA;AACNC,IAAAA,OAAAA,CAAQC,cAAAA,CAAeC,aAAAA,CAAcC,IAAAA,EAAMZ,OAAAA,EAASQ,MAAAA,CAAAA;AACtD,EAAA,CAAA;AACF;AAJgBD,MAAAA,CAAAA,IAAAA,EAAAA,MAAAA,CAAAA;AAUT,SAASM,iBAAiBL,MAAAA,EAAsB;AACrD,EAAA,OAAOC,OAAAA,CAAQK,WAAAA,CAAYH,aAAAA,CAAcC,IAAAA,EAAMJ,MAAAA,CAAAA;AACjD;AAFgBK,MAAAA,CAAAA,gBAAAA,EAAAA,kBAAAA,CAAAA;ACbhB,IAAME,QAAAA,GAA0D;EAC9DC,eAAAA,EAAiB,IAAA;EACjBC,UAAAA,EAAY;AACd,CAAA;AAYO,SAASC,aAAAA,CAAclB,OAAAA,GAAgC,EAAC,EAAC;AAC9D,EAAA,OAAO,CAACQ,M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AAAA,CAAIhB,CAAAA,CAAEO,GAAG,CAAA,EAAG;AACvB,MAAA,MAAM,IAAIhB,KAAAA,CAAM,CAAA,yDAAA,EAA4DS,CAAAA,CAAEO,GAAG,CAAA,CAAA,CAAG,CAAA;AACtF,IAAA;AACAY,IAAAA,QAAAA,CAASE,GAAAA,CAAIrB,EAAEO,GAAG,CAAA;AAClB,IAAA,IAAIP,CAAAA,CAAEY,UAAUG,MAAAA,EAAW;AACzB,MAAA,MAAMO,EAAAA,GAAK7B,KAAAA,CAAM8B,GAAAA,CAAIvB,CAAAA,CAAEY,KAAK,CAAA;AAC5B,MAAA,IAAIU,EAAAA,KAAOP,MAAAA,EAAWK,KAAAA,CAAME,EAAAA,CAAAA;AAC9B,IAAA;AACAH,IAAAA,QAAAA,CAASK,MAAAA,CAAOxB,EAAEO,GAAG,CAAA;AACrBU,IAAAA,MAAAA,CAAOI,GAAAA,CAAIrB,EAAEO,GAAG,CAAA;AAChBX,IAAAA,OAAAA,CAAQ6B,KAAKzB,CAAAA,CAAAA;EACf,CAAA,EAbc,OAAA,CAAA;AAed,EAAA,KAAA,MAAWA,CAAAA,IAAKP,KAAAA,CAAMqB,MAAAA,EAAM,QAAUd,CAAAA,CAAAA;AACtC,EAAA,OAAOJ,OAAAA;AACT;AAtBSC,MAAAA,CAAAA,QAAAA,EAAAA,UAAAA,CAAAA","file":"index.js","sourcesContent":["/**\n * Token used by `@InjectAgent()` to look up the Agent provider. Importing\n * this directly (instead of using the decorator) lets you register a\n * custom factory under the same token.\n */\nexport const AGENT_TOKEN = \"@theokit/di-agent:Agent\";\n","import { type FactoryProvider, Scope } from \"@theokit/di\";\n\nimport { AGENT_TOKEN } from \"./tokens.js\";\n\n/**\n * Options accepted by `createAgentProvider()`. Mirrors the public\n * `AgentOptions` from `@theokit/sdk` but kept structural so this package\n * does not have a hard import dependency on the SDK's type tree.\n *\n * The factory `async () => Agent.create(options)` is provided by the\n * consumer (see `createAgentProvider` below). This package supplies the\n * scope + token wiring.\n */\nexport interface CreateAgentProviderOptions<TAgent> {\n /**\n * Factory function that produces a fresh Agent per REQUEST.\n * Typically `() => Agent.create({...})` from `@theokit/sdk`.\n */\n factory: () => TAgent | Promise<TAgent>;\n /**\n * Override the scope. Default is `REQUEST` (the wedge — one isolated\n * Agent per HTTP request). Override to `SINGLETON` for CLI / cron /\n * single-tenant scenarios where a shared Agent is desirable.\n */\n scope?: Scope;\n}\n\n/**\n * Build a `FactoryProvider` that materializes an Agent on demand.\n *\n * @example\n * import { Agent } from \"@theokit/sdk\";\n * import { Module } from \"@theokit/di\";\n * import { createAgentProvider } from \"@theokit/di-agent\";\n *\n * @Module({\n * providers: [\n * createAgentProvider({\n * factory: () => Agent.create({ apiKey: process.env.OPENROUTER_API_KEY!, model: { id: \"openai/gpt-4o-mini\" } }),\n * }),\n * ],\n * })\n * class AppModule {}\n */\nexport function createAgentProvider<TAgent>(\n options: CreateAgentProviderOptions<TAgent>,\n): FactoryProvider<TAgent> {\n return {\n provide: AGENT_TOKEN,\n useFactory: () => options.factory(),\n scope: options.scope ?? Scope.REQUEST,\n };\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nimport type { DecoratedClass } from \"./decorated-class.js\";\n\n/** What {@link Auth} declares: the identity `providers` this agent accepts, and any transport\n * `sessionConfig` they need. */\nexport interface AuthOptions {\n providers?: string[];\n sessionConfig?: unknown;\n}\n\n/**\n * Declare how an agent class authenticates the caller.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function Auth(options: AuthOptions = {}): ClassDecorator {\n return (target) => {\n Reflect.defineMetadata(METADATA_KEYS.AUTH, options, target);\n };\n}\n\n/** The `@Auth` of a class, or `undefined` when it has none.\n *\n * Class decorators are singular by nature, so this returns one object or `undefined` — unlike the\n * property and method decorators, which accumulate into a map. */\nexport function readAuthMetadata(target: DecoratedClass): AuthOptions | undefined {\n return Reflect.getMetadata(METADATA_KEYS.AUTH, target) as AuthOptions | undefined;\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nimport type { DecoratedClass } from \"./decorated-class.js\";\n\n/** What {@link AutoSummarize} declares: the `triggerFraction` of the context window that starts a\n * summarisation, how many recent turns to `keepNewest` verbatim, and optionally which `model`\n * writes the summary. */\nexport interface AutoSummarizeOptions {\n triggerFraction?: number;\n keepNewest?: number;\n model?: string;\n}\n\nconst DEFAULTS: Required<Omit<AutoSummarizeOptions, \"model\">> = {\n triggerFraction: 0.85,\n keepNewest: 4,\n};\n\n/**\n * Declare that a conversation is summarised automatically as it approaches the context limit, so\n * it can continue past the point where it would otherwise be truncated.\n *\n * Defaults are resolved at decoration time, so a reader of the metadata sees real values rather\n * than having to know them.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function AutoSummarize(options: AutoSummarizeOptions = {}): ClassDecorator {\n return (target) => {\n const resolved = { ...DEFAULTS, ...options };\n Reflect.defineMetadata(METADATA_KEYS.AUTO_SUMMARIZE, resolved, target);\n };\n}\n\n/** The `@AutoSummarize` of a class with its defaults resolved, or `undefined` when it has none.\n *\n * Class decorators are singular by nature, so this returns one object or `undefined` — unlike the\n * property and method decorators, which accumulate into a map. */\nexport function readAutoSummarizeMetadata(\n target: DecoratedClass,\n): (Required<Omit<AutoSummarizeOptions, \"model\">> & { model?: string }) | undefined {\n return Reflect.getMetadata(METADATA_KEYS.AUTO_SUMMARIZE, target) as\n | (Required<Omit<AutoSummarizeOptions, \"model\">> & { model?: string })\n | undefined;\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/** What {@link Cron} declares: the `schedule` as a cron expression and the `timezone` it is read\n * in. The expression is stored verbatim and never parsed here, so a malformed one surfaces\n * wherever it is eventually scheduled. */\nexport interface CronOptions {\n schedule: string;\n timezone?: string;\n}\n\n/** A stored `@Cron`, with the method it was applied to. The map is already keyed by that method;\n * `methodKey` repeats it so an entry read on its own still says what it schedules. */\nexport interface CronMetadata extends CronOptions {\n methodKey: string | symbol;\n}\n\n/**\n * `@Cron(options)` — declare a scheduled routine on a method.\n *\n * Accumulates per method, keyed by the method name, so a class may schedule as many\n * routines as it has methods. It used to keep a single object per class, which meant a\n * second `@Cron` on the same class silently discarded the first (#6).\n */\nexport function Cron(options: CronOptions): MethodDecorator {\n return (target: object, propertyKey: string | symbol, _descriptor: PropertyDescriptor) => {\n const existing: Map<string | symbol, CronMetadata> =\n Reflect.getMetadata(METADATA_KEYS.CRON, target.constructor) ?? new Map();\n existing.set(propertyKey, { ...options, methodKey: propertyKey });\n Reflect.defineMetadata(METADATA_KEYS.CRON, existing, target.constructor);\n };\n}\n\n/** Read `@Cron()` metadata off a class constructor, keyed by method (insertion-ordered). */\nexport function readCronMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, CronMetadata> {\n return Reflect.getMetadata(METADATA_KEYS.CRON, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nimport type { DecoratedClass } from \"./decorated-class.js\";\n\n/** What {@link EvalDecorator} declares: the evaluation's `name`, the `scorers` that judge a run,\n * and the `dataset` it runs against. */\nexport interface EvalOptions {\n name?: string;\n scorers?: unknown[];\n dataset?: unknown;\n}\n\n/**\n * Declare an agent class as the subject of an evaluation.\n *\n * Named `EvalDecorator` rather than `Eval` because `eval` is a reserved word in strict mode, and\n * an export nobody can import under its own name is worse than a longer one.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function EvalDecorator(options: EvalOptions = {}): ClassDecorator {\n return (target) => {\n Reflect.defineMetadata(METADATA_KEYS.EVAL, options, target);\n };\n}\n\n/** The `@EvalDecorator` of a class, or `undefined` when it has none.\n *\n * Class decorators are singular by nature, so this returns one object or `undefined` — unlike the\n * property and method decorators, which accumulate into a map. */\nexport function readEvalDecoratorMetadata(target: DecoratedClass): EvalOptions | undefined {\n return Reflect.getMetadata(METADATA_KEYS.EVAL, target) as EvalOptions | undefined;\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/** What {@link Hitl} declares: the `tools` whose invocation needs a human decision, and the\n * `timeoutMs` after which waiting stops. */\nexport interface HitlOptions {\n tools: string[];\n timeoutMs?: number;\n}\n\n/** A stored `@Hitl`, with the method it was applied to. The map is already keyed by that method;\n * `methodKey` repeats it so an entry read on its own still says what it guards. */\nexport interface HitlMetadata extends HitlOptions {\n methodKey: string | symbol;\n}\n\n/**\n * `@Hitl(options)` — declare a human-in-the-loop approval handler on a method.\n *\n * Accumulates per method, keyed by the method name, so a class may declare as many\n * handlers as it has methods. It used to keep a single object per class, which meant a\n * second `@Hitl` on the same class silently discarded the first (#6).\n */\nexport function Hitl(options: HitlOptions): MethodDecorator {\n return (target: object, propertyKey: string | symbol, _descriptor: PropertyDescriptor) => {\n const existing: Map<string | symbol, HitlMetadata> =\n Reflect.getMetadata(METADATA_KEYS.HITL, target.constructor) ?? new Map();\n existing.set(propertyKey, { ...options, methodKey: propertyKey });\n Reflect.defineMetadata(METADATA_KEYS.HITL, existing, target.constructor);\n };\n}\n\n/** Read `@Hitl()` metadata off a class constructor, keyed by method (insertion-ordered). */\nexport function readHitlMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, HitlMetadata> {\n return Reflect.getMetadata(METADATA_KEYS.HITL, target) ?? new Map();\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/** What {@link MemoryScopeDecorator} declares: the `path` naming this scope's place in the\n * memory hierarchy. */\nexport interface MemoryScopeOptions {\n path: string;\n}\n\n/**\n * Declare the memory scope a property reads and writes, so sibling scopes stay isolated from\n * each other while a child can still see its parent.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function MemoryScopeDecorator(options: MemoryScopeOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, MemoryScopeOptions> =\n Reflect.getMetadata(METADATA_KEYS.MEMORY_SCOPE, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.MEMORY_SCOPE, existing, target.constructor);\n };\n}\n\n/** Every `@MemoryScopeDecorator` on a class, keyed by the property it was applied to. */\nexport function readMemoryScopeMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, MemoryScopeOptions> {\n return Reflect.getMetadata(METADATA_KEYS.MEMORY_SCOPE, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/** What {@link Reranker} declares: which provider and model score the candidates, and how many\n * survive (`topN`). */\nexport interface RerankerOptions {\n provider?: string;\n model?: string;\n topN?: number;\n}\n\n/**\n * Declare a property as the reranking step that reorders what a retriever returned.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function Reranker(options: RerankerOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, RerankerOptions> =\n Reflect.getMetadata(METADATA_KEYS.RERANKER, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.RERANKER, existing, target.constructor);\n };\n}\n\n/** Every `@Reranker` on a class, keyed by the property it was applied to. */\nexport function readRerankerMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, RerankerOptions> {\n return Reflect.getMetadata(METADATA_KEYS.RERANKER, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/** What {@link Retriever} declares: how many passages to return (`topK`) and the minimum score\n * a passage needs to be worth returning at all (`threshold`). */\nexport interface RetrieverOptions {\n topK?: number;\n threshold?: number;\n}\n\n/**\n * Declare a property as the retrieval step of a RAG pipeline.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function Retriever(options: RetrieverOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, RetrieverOptions> =\n Reflect.getMetadata(METADATA_KEYS.RETRIEVER, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.RETRIEVER, existing, target.constructor);\n };\n}\n\n/** Every `@Retriever` on a class, keyed by the property it was applied to. */\nexport function readRetrieverMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, RetrieverOptions> {\n return Reflect.getMetadata(METADATA_KEYS.RETRIEVER, target) ?? new Map();\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/**\n * Metadata captured by the `@Squad()` property decorator. Declares a sequential\n * agent team by referencing the agent property names that compose it. Mirrors\n * the `@theokit/sdk` `createSquad` factory (decorator mandate — every agentic\n * capability ships a decorator alongside the factory).\n */\nexport interface SquadMetadata {\n /** Agent property names (or ids) that run in order. */\n agents: string[];\n /** Orchestration process. Default (omitted) = `\"sequential\"`. */\n process?: \"sequential\" | \"hierarchical\";\n /** Optional squad name. */\n name?: string;\n}\n\n/**\n * `@Squad(metadata)` — declare a sequential agent team on a property. The DI\n * container / agent provider materializes it into a `createSquad(...)` at wiring\n * time.\n */\nexport function Squad(metadata: SquadMetadata): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, SquadMetadata> =\n Reflect.getMetadata(METADATA_KEYS.SQUAD, target.constructor) ?? new Map();\n existing.set(propertyKey, metadata);\n Reflect.defineMetadata(METADATA_KEYS.SQUAD, existing, target.constructor);\n };\n}\n\n/** Read `@Squad()` metadata off a class constructor. */\nexport function readSquadMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, SquadMetadata> {\n return Reflect.getMetadata(METADATA_KEYS.SQUAD, target) ?? new Map();\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/**\n * Metadata captured by the `@Step()` method decorator. Declares one step of a\n * decorator-driven workflow and its single upstream dependency. Compiled into\n * a `@theokit/sdk` `Workflow` by `buildWorkflow` (decorator mandate — every\n * agentic capability ships a decorator alongside the factory/builder).\n */\nexport interface StepMetadata {\n /**\n * Method name of the upstream step this step runs after. Omitted = entry\n * step (receives the workflow input). MVP supports a single dependency\n * (linear chain); branching/fan-out stays the imperative `Workflow` surface.\n */\n after?: string;\n /** Optional step id (defaults to the method name). */\n name?: string;\n}\n\n/**\n * `@Step(metadata?)` — mark a class method as a workflow step. The method\n * receives the upstream step's return value (or the workflow input for an\n * entry step) and returns this step's output.\n */\nexport function Step(metadata: StepMetadata = {}): MethodDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, StepMetadata> =\n Reflect.getMetadata(METADATA_KEYS.STEP, target.constructor) ?? new Map();\n existing.set(propertyKey, metadata);\n Reflect.defineMetadata(METADATA_KEYS.STEP, existing, target.constructor);\n };\n}\n\n/** Read `@Step()` metadata off a class constructor (insertion-ordered). */\nexport function readStepMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, StepMetadata> {\n return Reflect.getMetadata(METADATA_KEYS.STEP, target) ?? new Map();\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/** What {@link SubAgent} declares: how the parent agent describes the delegate when deciding\n * whether to hand work over, and optionally which model it runs on and how deep delegation may\n * nest before it stops. */\nexport interface SubAgentOptions {\n name: string;\n description: string;\n instructions: string;\n model?: string;\n maxDelegationDepth?: number;\n}\n\n/**\n * Declare a property as a subagent this one may delegate to, exposed to the parent as a tool.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function SubAgent(options: SubAgentOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, SubAgentOptions> =\n Reflect.getMetadata(METADATA_KEYS.SUBAGENT, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.SUBAGENT, existing, target.constructor);\n };\n}\n\n/** Every `@SubAgent` on a class, keyed by the property it was applied to. */\nexport function readSubAgentMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, SubAgentOptions> {\n return Reflect.getMetadata(METADATA_KEYS.SUBAGENT, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/** What {@link Subscription} declares: the event `name` to listen for, and optionally the\n * `transport` it arrives on. */\nexport interface SubscriptionOptions {\n name: string;\n transport?: string;\n}\n\n/**\n * Declare a property as a subscription to an event stream.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function Subscription(options: SubscriptionOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, SubscriptionOptions> =\n Reflect.getMetadata(METADATA_KEYS.SUBSCRIPTION, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.SUBSCRIPTION, existing, target.constructor);\n };\n}\n\n/** Every `@Subscription` on a class, keyed by the property it was applied to. */\nexport function readSubscriptionMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, SubscriptionOptions> {\n return Reflect.getMetadata(METADATA_KEYS.SUBSCRIPTION, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/** What {@link TextSplitter} declares: the splitting `strategy`, the target `chunkSize`, and how\n * much `overlap` consecutive chunks share so a passage split mid-sentence is still retrievable\n * from either side. */\nexport interface TextSplitterOptions {\n strategy?: string;\n chunkSize?: number;\n overlap?: number;\n}\n\n/**\n * Declare a property as the step that breaks documents into indexable chunks.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function TextSplitter(options: TextSplitterOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, TextSplitterOptions> =\n Reflect.getMetadata(METADATA_KEYS.TEXT_SPLITTER, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.TEXT_SPLITTER, existing, target.constructor);\n };\n}\n\n/** Every `@TextSplitter` on a class, keyed by the property it was applied to. */\nexport function readTextSplitterMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, TextSplitterOptions> {\n return Reflect.getMetadata(METADATA_KEYS.TEXT_SPLITTER, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/** What {@link Tool} declares about one tool: the name and description an agent sees when\n * choosing it, and optionally the schema its input must match. */\nexport interface ToolOptions {\n name: string;\n description: string;\n inputSchema?: unknown;\n}\n\n/**\n * Declare a property as a tool an agent may call.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function Tool(options: ToolOptions): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, ToolOptions> =\n Reflect.getMetadata(METADATA_KEYS.TOOL, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.TOOL, existing, target.constructor);\n };\n}\n\n/** Every `@Tool` on a class, keyed by the property it was applied to. Empty map when there are\n * none — a class with no tools is ordinary, not an error. */\nexport function readToolMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, ToolOptions> {\n return Reflect.getMetadata(METADATA_KEYS.TOOL, target) ?? new Map();\n}\n","import \"reflect-metadata\";\n\nimport { METADATA_KEYS } from \"@theokit/di\";\n\n/** What {@link UseSandbox} declares: which `backend` isolates the execution, the `workDir` it\n * starts in, and the `timeoutMs` after which it is abandoned. */\nexport interface UseSandboxOptions {\n backend?: \"local\" | \"docker\" | string;\n workDir?: string;\n timeoutMs?: number;\n}\n\n/**\n * Declare that a property's work runs inside a sandbox rather than in this process.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function UseSandbox(options: UseSandboxOptions = {}): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const existing: Map<string | symbol, UseSandboxOptions> =\n Reflect.getMetadata(METADATA_KEYS.SANDBOX, target.constructor) ?? new Map();\n existing.set(propertyKey, options);\n Reflect.defineMetadata(METADATA_KEYS.SANDBOX, existing, target.constructor);\n };\n}\n\n/** Every `@UseSandbox` on a class, keyed by the property it was applied to. */\nexport function readSandboxMetadata(\n target: abstract new (...args: never) => unknown,\n): ReadonlyMap<string | symbol, UseSandboxOptions> {\n return Reflect.getMetadata(METADATA_KEYS.SANDBOX, target) ?? new Map();\n}\n","import \"reflect-metadata\";\nimport { METADATA_KEYS } from \"@theokit/di\";\n\nimport type { DecoratedClass } from \"./decorated-class.js\";\n\n/** What {@link Workflow} declares about a workflow class: its `name`, an optional `retryPolicy`,\n * and the schemas its input and output are expected to match. */\nexport interface WorkflowOptions {\n name?: string;\n retryPolicy?: unknown;\n inputSchema?: unknown;\n outputSchema?: unknown;\n}\n\n/**\n * Mark a class as a workflow.\n *\n * This is the class-level marker only. The steps are declared with `@Step` on the methods, and\n * `buildWorkflow` compiles the two together into a runnable `@theokit/sdk` Workflow — which makes\n * it the one decorator in this package with a consumer that ships here.\n *\n * Records metadata only. Nothing in this package acts on it — the runtime that does lives in\n * `@theokit/sdk`, which is what lets the declaration and the execution version independently.\n */\nexport function Workflow(options: WorkflowOptions = {}): ClassDecorator {\n return (target) => {\n Reflect.defineMetadata(METADATA_KEYS.WORKFLOW, options, target);\n };\n}\n\n/** The `@Workflow` of a class, or `undefined` when it has none.\n *\n * Class decorators are singular by nature, so this returns one object or `undefined` — unlike the\n * property and method decorators, which accumulate into a map. */\nexport function readWorkflowMetadata(target: DecoratedClass): WorkflowOptions | undefined {\n return Reflect.getMetadata(METADATA_KEYS.WORKFLOW, target) as WorkflowOptions | undefined;\n}\n","import { Inject } from \"@theokit/di\";\n\nimport { AGENT_TOKEN } from \"./tokens.js\";\n\n/**\n * Parameter decorator — injects the REQUEST-scoped Agent into a constructor.\n * Equivalent to `@Inject(AGENT_TOKEN)` but documents intent.\n *\n * @example\n * @Injectable()\n * class ChatController {\n * constructor(@InjectAgent() private readonly agent: Agent) {}\n *\n * async chat(message: string) {\n * return this.agent.send(message);\n * }\n * }\n */\nexport function InjectAgent(): ParameterDecorator {\n return Inject(AGENT_TOKEN);\n}\n","/**\n * `buildWorkflow` — compile a `@Step`-decorated class instance into a\n * `@theokit/sdk` `Workflow`.\n *\n * This is the materializer/bridge for the decorator-driven workflow authoring\n * surface. It COMPOSES the existing `Workflow` engine — it\n * adds no orchestration logic of its own (same principle as `createSquad`).\n * Steps are topologically ordered by their single `after` dependency into a\n * linear `Workflow.then(...)` chain; each step's return value is threaded into\n * the next step. Branching/fan-out remains the imperative `Workflow` surface.\n *\n * NOTE: this module (unlike the metadata-only decorators) imports the\n * `@theokit/sdk` peer dependency — it is the bridge layer.\n */\n\nimport { fn, Workflow } from \"@theokit/sdk/workflow\";\nimport type { DecoratedClass } from \"./decorators/decorated-class.js\";\nimport { readStepMetadata, type StepMetadata } from \"./decorators/step.js\";\nimport { readWorkflowMetadata } from \"./decorators/workflow.js\";\n\ninterface ResolvedStep {\n key: string;\n id: string;\n after?: string;\n run: (input: unknown) => unknown;\n}\n\n/**\n * Build a `Workflow` from a `@Step`-decorated instance. Validates the step\n * graph (fail-fast) before constructing the workflow.\n *\n * @throws Error when there are no `@Step` methods, an `after` references an\n * unknown step, or the `after` graph contains a cycle.\n */\nexport function buildWorkflow(instance: object): Workflow {\n const ctor = instance.constructor as DecoratedClass;\n const meta = readStepMetadata(ctor);\n if (meta.size === 0) {\n throw new Error(`buildWorkflow: class \"${instance.constructor.name}\" has no @Step methods`);\n }\n\n const steps = resolveSteps(instance, meta);\n validateAfterTargets(steps);\n const ordered = topoSort(steps);\n\n const name = readWorkflowMetadata(instance.constructor as DecoratedClass)?.name ?? \"workflow\";\n let builder = Workflow.create({ name });\n for (const s of ordered) {\n builder = builder.then(fn(s.id, (input: unknown) => s.run(input)));\n }\n return builder.commit();\n}\n\n/** Resolve each `@Step` method into a runnable {@link ResolvedStep}. */\nfunction resolveSteps(\n instance: object,\n meta: ReadonlyMap<string | symbol, StepMetadata>,\n): Map<string, ResolvedStep> {\n const steps = new Map<string, ResolvedStep>();\n for (const [key, m] of meta) {\n const k = String(key);\n const method = (instance as Record<string, unknown>)[k];\n if (typeof method !== \"function\") {\n throw new Error(`buildWorkflow: @Step \"${k}\" is not a method`);\n }\n steps.set(k, {\n key: k,\n id: m.name ?? k,\n after: m.after,\n run: (input: unknown) => (method as (i: unknown) => unknown).call(instance, input),\n });\n }\n return steps;\n}\n\n/** Fail-fast if any `after` references a step that does not exist. */\nfunction validateAfterTargets(steps: Map<string, ResolvedStep>): void {\n for (const s of steps.values()) {\n if (s.after !== undefined && !steps.has(s.after)) {\n throw new Error(\n `buildWorkflow: @Step \"${s.key}\" declares after: \"${s.after}\" which is not a known @Step (unknown upstream)`,\n );\n }\n }\n}\n\n/**\n * Topologically order steps by their single `after` dependency. Entry steps\n * (no `after`) come first in declaration order; each dependent follows its\n * upstream. Throws on a cycle.\n */\nfunction topoSort(steps: Map<string, ResolvedStep>): ResolvedStep[] {\n const ordered: ResolvedStep[] = [];\n const placed = new Set<string>();\n const visiting = new Set<string>();\n\n const visit = (s: ResolvedStep): void => {\n if (placed.has(s.key)) return;\n if (visiting.has(s.key)) {\n throw new Error(`buildWorkflow: cycle detected in @Step \"after\" graph at \"${s.key}\"`);\n }\n visiting.add(s.key);\n if (s.after !== undefined) {\n const up = steps.get(s.after);\n if (up !== undefined) visit(up);\n }\n visiting.delete(s.key);\n placed.add(s.key);\n ordered.push(s);\n };\n\n for (const s of steps.values()) visit(s);\n return ordered;\n}\n"]}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@theokit/di-agent",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Agent-first DI integration for @theokit/di. Ships @InjectAgent() decorator + createAgentProvider() helper that produces a REQUEST-scoped Agent factory — so every HTTP request gets an isolated @theokit/sdk Agent automatically.",
5
5
  "license": "Apache-2.0",
6
- "homepage": "https://github.com/usetheo/theokit-sdk#readme",
7
- "bugs": "https://github.com/usetheo/theokit-sdk/issues",
6
+ "homepage": "https://github.com/usetheokit/theokit-di#readme",
7
+ "bugs": "https://github.com/usetheokit/theokit-di/issues",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/usetheo/theokit-sdk.git",
10
+ "url": "git+https://github.com/usetheokit/theokit-di.git",
11
11
  "directory": "packages/di-agent"
12
12
  },
13
13
  "type": "module",
@@ -43,27 +43,31 @@
43
43
  "Theo"
44
44
  ],
45
45
  "peerDependencies": {
46
- "@theokit/di": "^0.1.0-next.0",
46
+ "@theokit/di": "^0.1.0-next.0 || ^0.2.0",
47
47
  "@theokit/sdk": "^1.3.0",
48
48
  "reflect-metadata": "^0.2.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@swc/core": "^1.15.40",
52
+ "@theokit/sdk": "^1.9.0",
52
53
  "reflect-metadata": "^0.2.0",
53
54
  "tsup": "^8.5.0",
55
+ "typedoc": "^0.28.19",
54
56
  "typescript": "^5.8.0",
55
57
  "unplugin-swc": "^1.5.9",
56
58
  "vitest": "^4.1.8",
57
- "@theokit/di": "0.1.1",
58
- "@theokit/sdk": "1.9.0"
59
+ "zod": "^4.0.0",
60
+ "@theokit/di": "0.2.0"
59
61
  },
60
62
  "publishConfig": {
61
- "access": "public"
63
+ "access": "public",
64
+ "provenance": true
62
65
  },
63
66
  "scripts": {
64
67
  "build": "tsup",
65
68
  "typecheck": "tsc --noEmit",
66
69
  "test": "vitest run --passWithNoTests",
67
- "test:coverage": "vitest run --coverage --passWithNoTests"
70
+ "test:coverage": "vitest run --coverage --passWithNoTests",
71
+ "docs:json": "typedoc --options typedoc.json"
68
72
  }
69
73
  }