@theokit/di-agent 0.5.0 → 0.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c1326ba: Add `createAgentBoundary({ factory })`, whose `withAgent(seed, work)` opens a request scope seeded
8
+ with `seed`, builds one agent from it and disposes it when `work` settles. `createAgentProvider`
9
+ gains a seeded form (`factory: (seed) => ...` with a `container`). The `@theokit/di` peer range is
10
+ now `>=0.3.0 <0.4`, the first release with `requestSeed` (usetheokit/theokit-di#81).
11
+
3
12
  ## 0.5.0
4
13
 
5
14
  ### Minor Changes
package/README.md CHANGED
@@ -51,6 +51,25 @@ await container.runInRequest(async () => {
51
51
  });
52
52
  ```
53
53
 
54
+ ## One agent per request: `createAgentBoundary`
55
+
56
+ The default way to get one agent per request, built from that request's data:
57
+
58
+ ```ts
59
+ import { createAgentBoundary } from "@theokit/di-agent";
60
+
61
+ const boundary = createAgentBoundary({
62
+ factory: (message: string) => Agent.create({ /* built from the request */ }),
63
+ });
64
+
65
+ const reply = await boundary.withAgent("hello", (agent) => agent.send("hi"));
66
+ ```
67
+
68
+ `factory` runs once per `withAgent` call, inside its request scope. Any REQUEST-scoped provider
69
+ resolved from the same container inside `work` shares that agent and can read the seed with
70
+ `container.requestSeed()`. An agent with a `dispose()` method is disposed when `work` settles.
71
+ Pass `container` to register into your own container (before it first resolves anything).
72
+
54
73
  ## The decorators record; they do not execute
55
74
 
56
75
  `@Tool`, `@SubAgent`, `@Squad`, `@Workflow`, `@Step`, `@Cron`, `@Hitl`, `@Retriever`, `@Reranker`
package/dist/index.cjs CHANGED
@@ -12,13 +12,29 @@ var AGENT_TOKEN = "@theokit/di-agent:Agent";
12
12
 
13
13
  // src/agent-provider.ts
14
14
  function createAgentProvider(options) {
15
+ const { container } = options;
15
16
  return {
16
17
  provide: AGENT_TOKEN,
17
- useFactory: /* @__PURE__ */ __name(() => options.factory(), "useFactory"),
18
+ useFactory: /* @__PURE__ */ __name(() => container === void 0 ? options.factory() : options.factory(container.requestSeed()), "useFactory"),
18
19
  scope: options.scope ?? di.Scope.REQUEST
19
20
  };
20
21
  }
21
22
  __name(createAgentProvider, "createAgentProvider");
23
+
24
+ // src/agent-boundary.ts
25
+ function createAgentBoundary(options) {
26
+ const container = options.container ?? new di.Container();
27
+ container.register(createAgentProvider({
28
+ factory: options.factory,
29
+ container
30
+ }));
31
+ return {
32
+ withAgent: /* @__PURE__ */ __name((seed, work) => container.runInRequest(async () => work(await container.resolveAsync(AGENT_TOKEN)), {
33
+ seed
34
+ }), "withAgent")
35
+ };
36
+ }
37
+ __name(createAgentBoundary, "createAgentBoundary");
22
38
  function Auth(options = {}) {
23
39
  return (target) => {
24
40
  Reflect.defineMetadata(di.METADATA_KEYS.AUTH, options, target);
@@ -308,6 +324,7 @@ exports.Tool = Tool;
308
324
  exports.UseSandbox = UseSandbox;
309
325
  exports.Workflow = Workflow;
310
326
  exports.buildWorkflow = buildWorkflow;
327
+ exports.createAgentBoundary = createAgentBoundary;
311
328
  exports.createAgentProvider = createAgentProvider;
312
329
  exports.readAuthMetadata = readAuthMetadata;
313
330
  exports.readAutoSummarizeMetadata = readAutoSummarizeMetadata;
@@ -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","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,QAAAA,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,gBA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AWA,CAAAA,IAAKP,KAAAA,CAAMqB,MAAAA,EAAM,QAAUd,CAAAA,CAAAA;AACtC,EAAA,OAAOJ,OAAAA;AACT;AAtBSC,MAAAA,CAAAA,QAAAA,EAAAA,UAAAA,CAAAA","file":"index.cjs","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"]}
1
+ {"version":3,"sources":["../src/tokens.ts","../src/agent-provider.ts","../src/agent-boundary.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","container","provide","useFactory","undefined","factory","requestSeed","scope","Scope","REQUEST","createAgentBoundary","Container","register","withAgent","seed","work","runInRequest","resolveAsync","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","has","placed","Set","visiting","visit","add","up","get","delete","push"],"mappings":";;;;;;;;;;AAKO,IAAMA,WAAAA,GAAc;;;ACyDpB,SAASC,oBACdC,OAAAA,EAAiG;AAEjG,EAAA,MAAM,EAAEC,WAAS,GAAKD,OAAAA;AACtB,EAAA,OAAO;IACLE,OAAAA,EAASJ,WAAAA;IACTK,UAAAA,kBAAY,MAAA,CAAA,MACVF,SAAAA,KAAcG,MAAAA,GACTJ,OAAAA,CAAQK,OAAAA,EAAO,GACfL,OAAAA,CAAQK,OAAAA,CAAuCJ,SAAAA,CAAUK,WAAAA,EAAW,CAAA,EAH/D,YAAA,CAAA;IAIZC,KAAAA,EAAOP,OAAAA,CAAQO,SAASC,QAAAA,CAAMC;AAChC,GAAA;AACF;AAZgBV,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA;;;ACjCT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,EAAG;AACvB,IAAA,IAAIW,QAAAA,CAASH,GAAAA,CAAIf,CAAAA,CAAEO,GAAG,CAAA,EAAG;AACvB,MAAA,MAAM,IAAIhB,KAAAA,CAAM,CAAA,yDAAA,EAA4DS,CAAAA,CAAEO,GAAG,CAAA,CAAA,CAAG,CAAA;AACtF,IAAA;AACAW,IAAAA,QAAAA,CAASE,GAAAA,CAAIpB,EAAEO,GAAG,CAAA;AAClB,IAAA,IAAIP,CAAAA,CAAEY,UAAU1G,MAAAA,EAAW;AACzB,MAAA,MAAMmH,EAAAA,GAAK5B,KAAAA,CAAM6B,GAAAA,CAAItB,CAAAA,CAAEY,KAAK,CAAA;AAC5B,MAAA,IAAIS,EAAAA,KAAOnH,MAAAA,EAAWiH,KAAAA,CAAME,EAAAA,CAAAA;AAC9B,IAAA;AACAH,IAAAA,QAAAA,CAASK,MAAAA,CAAOvB,EAAEO,GAAG,CAAA;AACrBS,IAAAA,MAAAA,CAAOI,GAAAA,CAAIpB,EAAEO,GAAG,CAAA;AAChBX,IAAAA,OAAAA,CAAQ4B,KAAKxB,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.cjs","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 Container, 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 * Options for the seeded form: the factory receives the seed the active\n * request was opened with (`runInRequest(cb, { seed })`). A factory provider\n * gets no container, so the container that opens the request is passed here.\n */\nexport interface CreateSeededAgentProviderOptions<TSeed, TAgent> {\n factory: (seed: TSeed) => TAgent | Promise<TAgent>;\n /** The container whose `runInRequest(cb, { seed })` carries the seed. */\n container: Container;\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<TSeed, TAgent>(\n options: CreateSeededAgentProviderOptions<TSeed, TAgent>,\n): FactoryProvider<TAgent>;\nexport function createAgentProvider<TAgent>(\n options: CreateAgentProviderOptions<TAgent>,\n): FactoryProvider<TAgent>;\nexport function createAgentProvider(\n options: CreateAgentProviderOptions<unknown> | CreateSeededAgentProviderOptions<unknown, unknown>,\n): FactoryProvider<unknown> {\n const { container } = options as { container?: Container };\n return {\n provide: AGENT_TOKEN,\n useFactory: () =>\n container === undefined\n ? (options.factory as () => unknown)()\n : (options.factory as (seed: unknown) => unknown)(container.requestSeed()),\n scope: options.scope ?? Scope.REQUEST,\n };\n}\n","import { Container } from \"@theokit/di\";\n\nimport { createAgentProvider } from \"./agent-provider.js\";\nimport { AGENT_TOKEN } from \"./tokens.js\";\n\n/** Options for `createAgentBoundary()`. */\nexport interface AgentBoundaryOptions<TSeed, TAgent> {\n /** Called once per `withAgent` call, inside its request scope. */\n readonly factory: (seed: TSeed) => TAgent | Promise<TAgent>;\n /**\n * Optional container to register into; default a new Container. It must\n * still accept registrations (not yet resolved from) when the boundary is created.\n */\n readonly container?: Container;\n}\n\n/** A request boundary that builds one seeded agent per `withAgent` call. */\nexport interface AgentBoundary<TSeed, TAgent> {\n /**\n * Opens a request scope seeded with `seed`, builds the agent in it and runs\n * `work`. REQUEST-scoped providers resolved from the same container inside\n * `work` share the agent and can read the seed with `requestSeed()`.\n * Request-scoped instances (including a disposable agent) are disposed when\n * `work` settles, on success and on throw.\n */\n withAgent<R>(seed: TSeed, work: (agent: TAgent) => R | Promise<R>): Promise<R>;\n}\n\n/** One seeded agent per request: the default way to use `createAgentProvider`. */\nexport function createAgentBoundary<TSeed, TAgent>(\n options: AgentBoundaryOptions<TSeed, TAgent>,\n): AgentBoundary<TSeed, TAgent> {\n const container = options.container ?? new Container();\n container.register(createAgentProvider<TSeed, TAgent>({ factory: options.factory, container }));\n return {\n withAgent: (seed, work) =>\n container.runInRequest(async () => work(await container.resolveAsync<TAgent>(AGENT_TOKEN)), {\n seed,\n }),\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/dist/index.d.cts CHANGED
@@ -1,6 +1,30 @@
1
- import { Scope, FactoryProvider } from '@theokit/di';
1
+ import { Container, Scope, FactoryProvider } from '@theokit/di';
2
2
  import { Workflow as Workflow$1 } from '@theokit/sdk/workflow';
3
3
 
4
+ /** Options for `createAgentBoundary()`. */
5
+ interface AgentBoundaryOptions<TSeed, TAgent> {
6
+ /** Called once per `withAgent` call, inside its request scope. */
7
+ readonly factory: (seed: TSeed) => TAgent | Promise<TAgent>;
8
+ /**
9
+ * Optional container to register into; default a new Container. It must
10
+ * still accept registrations (not yet resolved from) when the boundary is created.
11
+ */
12
+ readonly container?: Container;
13
+ }
14
+ /** A request boundary that builds one seeded agent per `withAgent` call. */
15
+ interface AgentBoundary<TSeed, TAgent> {
16
+ /**
17
+ * Opens a request scope seeded with `seed`, builds the agent in it and runs
18
+ * `work`. REQUEST-scoped providers resolved from the same container inside
19
+ * `work` share the agent and can read the seed with `requestSeed()`.
20
+ * Request-scoped instances (including a disposable agent) are disposed when
21
+ * `work` settles, on success and on throw.
22
+ */
23
+ withAgent<R>(seed: TSeed, work: (agent: TAgent) => R | Promise<R>): Promise<R>;
24
+ }
25
+ /** One seeded agent per request: the default way to use `createAgentProvider`. */
26
+ declare function createAgentBoundary<TSeed, TAgent>(options: AgentBoundaryOptions<TSeed, TAgent>): AgentBoundary<TSeed, TAgent>;
27
+
4
28
  /**
5
29
  * Options accepted by `createAgentProvider()`. Mirrors the public
6
30
  * `AgentOptions` from `@theokit/sdk` but kept structural so this package
@@ -23,6 +47,17 @@ interface CreateAgentProviderOptions<TAgent> {
23
47
  */
24
48
  scope?: Scope;
25
49
  }
50
+ /**
51
+ * Options for the seeded form: the factory receives the seed the active
52
+ * request was opened with (`runInRequest(cb, { seed })`). A factory provider
53
+ * gets no container, so the container that opens the request is passed here.
54
+ */
55
+ interface CreateSeededAgentProviderOptions<TSeed, TAgent> {
56
+ factory: (seed: TSeed) => TAgent | Promise<TAgent>;
57
+ /** The container whose `runInRequest(cb, { seed })` carries the seed. */
58
+ container: Container;
59
+ scope?: Scope;
60
+ }
26
61
  /**
27
62
  * Build a `FactoryProvider` that materializes an Agent on demand.
28
63
  *
@@ -40,6 +75,7 @@ interface CreateAgentProviderOptions<TAgent> {
40
75
  * })
41
76
  * class AppModule {}
42
77
  */
78
+ declare function createAgentProvider<TSeed, TAgent>(options: CreateSeededAgentProviderOptions<TSeed, TAgent>): FactoryProvider<TAgent>;
43
79
  declare function createAgentProvider<TAgent>(options: CreateAgentProviderOptions<TAgent>): FactoryProvider<TAgent>;
44
80
 
45
81
  /**
@@ -428,4 +464,4 @@ declare const AGENT_TOKEN = "@theokit/di-agent:Agent";
428
464
  */
429
465
  declare function buildWorkflow(instance: object): Workflow$1;
430
466
 
431
- export { AGENT_TOKEN, Auth, type AuthOptions, AutoSummarize, type AutoSummarizeOptions, type CreateAgentProviderOptions, Cron, type CronMetadata, type CronOptions, type DecoratedClass, EvalDecorator, type EvalOptions, Hitl, type HitlMetadata, type HitlOptions, InjectAgent, MemoryScopeDecorator, type MemoryScopeOptions, Reranker, type RerankerOptions, Retriever, type RetrieverOptions, Squad, type SquadMetadata, Step, type StepMetadata, SubAgent, type SubAgentOptions, Subscription, type SubscriptionOptions, TextSplitter, type TextSplitterOptions, Tool, type ToolOptions, UseSandbox, type UseSandboxOptions, Workflow, type WorkflowOptions, buildWorkflow, createAgentProvider, readAuthMetadata, readAutoSummarizeMetadata, readCronMetadata, readEvalDecoratorMetadata, readHitlMetadata, readMemoryScopeMetadata, readRerankerMetadata, readRetrieverMetadata, readSandboxMetadata, readSquadMetadata, readStepMetadata, readSubAgentMetadata, readSubscriptionMetadata, readTextSplitterMetadata, readToolMetadata, readWorkflowMetadata };
467
+ export { AGENT_TOKEN, type AgentBoundary, type AgentBoundaryOptions, Auth, type AuthOptions, AutoSummarize, type AutoSummarizeOptions, type CreateAgentProviderOptions, type CreateSeededAgentProviderOptions, Cron, type CronMetadata, type CronOptions, type DecoratedClass, EvalDecorator, type EvalOptions, Hitl, type HitlMetadata, type HitlOptions, InjectAgent, MemoryScopeDecorator, type MemoryScopeOptions, Reranker, type RerankerOptions, Retriever, type RetrieverOptions, Squad, type SquadMetadata, Step, type StepMetadata, SubAgent, type SubAgentOptions, Subscription, type SubscriptionOptions, TextSplitter, type TextSplitterOptions, Tool, type ToolOptions, UseSandbox, type UseSandboxOptions, Workflow, type WorkflowOptions, buildWorkflow, createAgentBoundary, createAgentProvider, readAuthMetadata, readAutoSummarizeMetadata, readCronMetadata, readEvalDecoratorMetadata, readHitlMetadata, readMemoryScopeMetadata, readRerankerMetadata, readRetrieverMetadata, readSandboxMetadata, readSquadMetadata, readStepMetadata, readSubAgentMetadata, readSubscriptionMetadata, readTextSplitterMetadata, readToolMetadata, readWorkflowMetadata };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,30 @@
1
- import { Scope, FactoryProvider } from '@theokit/di';
1
+ import { Container, Scope, FactoryProvider } from '@theokit/di';
2
2
  import { Workflow as Workflow$1 } from '@theokit/sdk/workflow';
3
3
 
4
+ /** Options for `createAgentBoundary()`. */
5
+ interface AgentBoundaryOptions<TSeed, TAgent> {
6
+ /** Called once per `withAgent` call, inside its request scope. */
7
+ readonly factory: (seed: TSeed) => TAgent | Promise<TAgent>;
8
+ /**
9
+ * Optional container to register into; default a new Container. It must
10
+ * still accept registrations (not yet resolved from) when the boundary is created.
11
+ */
12
+ readonly container?: Container;
13
+ }
14
+ /** A request boundary that builds one seeded agent per `withAgent` call. */
15
+ interface AgentBoundary<TSeed, TAgent> {
16
+ /**
17
+ * Opens a request scope seeded with `seed`, builds the agent in it and runs
18
+ * `work`. REQUEST-scoped providers resolved from the same container inside
19
+ * `work` share the agent and can read the seed with `requestSeed()`.
20
+ * Request-scoped instances (including a disposable agent) are disposed when
21
+ * `work` settles, on success and on throw.
22
+ */
23
+ withAgent<R>(seed: TSeed, work: (agent: TAgent) => R | Promise<R>): Promise<R>;
24
+ }
25
+ /** One seeded agent per request: the default way to use `createAgentProvider`. */
26
+ declare function createAgentBoundary<TSeed, TAgent>(options: AgentBoundaryOptions<TSeed, TAgent>): AgentBoundary<TSeed, TAgent>;
27
+
4
28
  /**
5
29
  * Options accepted by `createAgentProvider()`. Mirrors the public
6
30
  * `AgentOptions` from `@theokit/sdk` but kept structural so this package
@@ -23,6 +47,17 @@ interface CreateAgentProviderOptions<TAgent> {
23
47
  */
24
48
  scope?: Scope;
25
49
  }
50
+ /**
51
+ * Options for the seeded form: the factory receives the seed the active
52
+ * request was opened with (`runInRequest(cb, { seed })`). A factory provider
53
+ * gets no container, so the container that opens the request is passed here.
54
+ */
55
+ interface CreateSeededAgentProviderOptions<TSeed, TAgent> {
56
+ factory: (seed: TSeed) => TAgent | Promise<TAgent>;
57
+ /** The container whose `runInRequest(cb, { seed })` carries the seed. */
58
+ container: Container;
59
+ scope?: Scope;
60
+ }
26
61
  /**
27
62
  * Build a `FactoryProvider` that materializes an Agent on demand.
28
63
  *
@@ -40,6 +75,7 @@ interface CreateAgentProviderOptions<TAgent> {
40
75
  * })
41
76
  * class AppModule {}
42
77
  */
78
+ declare function createAgentProvider<TSeed, TAgent>(options: CreateSeededAgentProviderOptions<TSeed, TAgent>): FactoryProvider<TAgent>;
43
79
  declare function createAgentProvider<TAgent>(options: CreateAgentProviderOptions<TAgent>): FactoryProvider<TAgent>;
44
80
 
45
81
  /**
@@ -428,4 +464,4 @@ declare const AGENT_TOKEN = "@theokit/di-agent:Agent";
428
464
  */
429
465
  declare function buildWorkflow(instance: object): Workflow$1;
430
466
 
431
- export { AGENT_TOKEN, Auth, type AuthOptions, AutoSummarize, type AutoSummarizeOptions, type CreateAgentProviderOptions, Cron, type CronMetadata, type CronOptions, type DecoratedClass, EvalDecorator, type EvalOptions, Hitl, type HitlMetadata, type HitlOptions, InjectAgent, MemoryScopeDecorator, type MemoryScopeOptions, Reranker, type RerankerOptions, Retriever, type RetrieverOptions, Squad, type SquadMetadata, Step, type StepMetadata, SubAgent, type SubAgentOptions, Subscription, type SubscriptionOptions, TextSplitter, type TextSplitterOptions, Tool, type ToolOptions, UseSandbox, type UseSandboxOptions, Workflow, type WorkflowOptions, buildWorkflow, createAgentProvider, readAuthMetadata, readAutoSummarizeMetadata, readCronMetadata, readEvalDecoratorMetadata, readHitlMetadata, readMemoryScopeMetadata, readRerankerMetadata, readRetrieverMetadata, readSandboxMetadata, readSquadMetadata, readStepMetadata, readSubAgentMetadata, readSubscriptionMetadata, readTextSplitterMetadata, readToolMetadata, readWorkflowMetadata };
467
+ export { AGENT_TOKEN, type AgentBoundary, type AgentBoundaryOptions, Auth, type AuthOptions, AutoSummarize, type AutoSummarizeOptions, type CreateAgentProviderOptions, type CreateSeededAgentProviderOptions, Cron, type CronMetadata, type CronOptions, type DecoratedClass, EvalDecorator, type EvalOptions, Hitl, type HitlMetadata, type HitlOptions, InjectAgent, MemoryScopeDecorator, type MemoryScopeOptions, Reranker, type RerankerOptions, Retriever, type RetrieverOptions, Squad, type SquadMetadata, Step, type StepMetadata, SubAgent, type SubAgentOptions, Subscription, type SubscriptionOptions, TextSplitter, type TextSplitterOptions, Tool, type ToolOptions, UseSandbox, type UseSandboxOptions, Workflow, type WorkflowOptions, buildWorkflow, createAgentBoundary, createAgentProvider, readAuthMetadata, readAutoSummarizeMetadata, readCronMetadata, readEvalDecoratorMetadata, readHitlMetadata, readMemoryScopeMetadata, readRerankerMetadata, readRetrieverMetadata, readSandboxMetadata, readSquadMetadata, readStepMetadata, readSubAgentMetadata, readSubscriptionMetadata, readTextSplitterMetadata, readToolMetadata, readWorkflowMetadata };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Scope, METADATA_KEYS, Inject } from '@theokit/di';
1
+ import { Scope, Container, METADATA_KEYS, Inject } from '@theokit/di';
2
2
  import 'reflect-metadata';
3
3
  import { Workflow as Workflow$1, fn } from '@theokit/sdk/workflow';
4
4
 
@@ -10,13 +10,29 @@ var AGENT_TOKEN = "@theokit/di-agent:Agent";
10
10
 
11
11
  // src/agent-provider.ts
12
12
  function createAgentProvider(options) {
13
+ const { container } = options;
13
14
  return {
14
15
  provide: AGENT_TOKEN,
15
- useFactory: /* @__PURE__ */ __name(() => options.factory(), "useFactory"),
16
+ useFactory: /* @__PURE__ */ __name(() => container === void 0 ? options.factory() : options.factory(container.requestSeed()), "useFactory"),
16
17
  scope: options.scope ?? Scope.REQUEST
17
18
  };
18
19
  }
19
20
  __name(createAgentProvider, "createAgentProvider");
21
+
22
+ // src/agent-boundary.ts
23
+ function createAgentBoundary(options) {
24
+ const container = options.container ?? new Container();
25
+ container.register(createAgentProvider({
26
+ factory: options.factory,
27
+ container
28
+ }));
29
+ return {
30
+ withAgent: /* @__PURE__ */ __name((seed, work) => container.runInRequest(async () => work(await container.resolveAsync(AGENT_TOKEN)), {
31
+ seed
32
+ }), "withAgent")
33
+ };
34
+ }
35
+ __name(createAgentBoundary, "createAgentBoundary");
20
36
  function Auth(options = {}) {
21
37
  return (target) => {
22
38
  Reflect.defineMetadata(METADATA_KEYS.AUTH, options, target);
@@ -287,6 +303,6 @@ function topoSort(steps) {
287
303
  }
288
304
  __name(topoSort, "topoSort");
289
305
 
290
- export { AGENT_TOKEN, Auth, AutoSummarize, Cron, EvalDecorator, Hitl, InjectAgent, MemoryScopeDecorator, Reranker, Retriever, Squad, Step, SubAgent, Subscription, TextSplitter, Tool, UseSandbox, Workflow, buildWorkflow, createAgentProvider, readAuthMetadata, readAutoSummarizeMetadata, readCronMetadata, readEvalDecoratorMetadata, readHitlMetadata, readMemoryScopeMetadata, readRerankerMetadata, readRetrieverMetadata, readSandboxMetadata, readSquadMetadata, readStepMetadata, readSubAgentMetadata, readSubscriptionMetadata, readTextSplitterMetadata, readToolMetadata, readWorkflowMetadata };
306
+ export { AGENT_TOKEN, Auth, AutoSummarize, Cron, EvalDecorator, Hitl, InjectAgent, MemoryScopeDecorator, Reranker, Retriever, Squad, Step, SubAgent, Subscription, TextSplitter, Tool, UseSandbox, Workflow, buildWorkflow, createAgentBoundary, createAgentProvider, readAuthMetadata, readAutoSummarizeMetadata, readCronMetadata, readEvalDecoratorMetadata, readHitlMetadata, readMemoryScopeMetadata, readRerankerMetadata, readRetrieverMetadata, readSandboxMetadata, readSquadMetadata, readStepMetadata, readSubAgentMetadata, readSubscriptionMetadata, readTextSplitterMetadata, readToolMetadata, readWorkflowMetadata };
291
307
  //# sourceMappingURL=index.js.map
292
308
  //# sourceMappingURL=index.js.map
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","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;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ASE,SAASJ,KAAAA,EAAgC;AAChD,EAAA,MAAMG,UAA0B,EAAA;AAChC,EAAA,MAAMqB,MAAAA,uBAAaC,GAAAA,EAAAA;AACnB,EAAA,MAAMC,QAAAA,uBAAeD,GAAAA,EAAAA;AAErB,EAAA,MAAME,KAAAA,2BAASpB,CAAAA,KAAAA;AACb,IAAA,IAAIiB,MAAAA,CAAOD,GAAAA,CAAIhB,CAAAA,CAAEO,GAAG,CAAA,EAAG;AACvB,IAAA,IAAIY,QAAAA,CAASH,GAAAA,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"]}
1
+ {"version":3,"sources":["../src/tokens.ts","../src/agent-provider.ts","../src/agent-boundary.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","container","provide","useFactory","undefined","factory","requestSeed","scope","Scope","REQUEST","createAgentBoundary","Container","register","withAgent","seed","work","runInRequest","resolveAsync","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","has","placed","Set","visiting","visit","add","up","get","delete","push"],"mappings":";;;;;;;;AAKO,IAAMA,WAAAA,GAAc;;;ACyDpB,SAASC,oBACdC,OAAAA,EAAiG;AAEjG,EAAA,MAAM,EAAEC,WAAS,GAAKD,OAAAA;AACtB,EAAA,OAAO;IACLE,OAAAA,EAASJ,WAAAA;IACTK,UAAAA,kBAAY,MAAA,CAAA,MACVF,SAAAA,KAAcG,MAAAA,GACTJ,OAAAA,CAAQK,OAAAA,EAAO,GACfL,OAAAA,CAAQK,OAAAA,CAAuCJ,SAAAA,CAAUK,WAAAA,EAAW,CAAA,EAH/D,YAAA,CAAA;IAIZC,KAAAA,EAAOP,OAAAA,CAAQO,SAASC,KAAAA,CAAMC;AAChC,GAAA;AACF;AAZgBV,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA;;;ACjCT,SAASW,oBACdV,OAAAA,EAA4C;AAE5C,EAAA,MAAMC,SAAAA,GAAYD,OAAAA,CAAQC,SAAAA,IAAa,IAAIU,SAAAA,EAAAA;AAC3CV,EAAAA,SAAAA,CAAUW,SAASb,mBAAAA,CAAmC;AAAEM,IAAAA,OAAAA,EAASL,OAAAA,CAAQK,OAAAA;AAASJ,IAA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AAIP,CAAAA,CAAEY,UAAU1G,MAAAA,EAAW;AACzB,MAAA,MAAMmH,EAAAA,GAAK5B,KAAAA,CAAM6B,GAAAA,CAAItB,CAAAA,CAAEY,KAAK,CAAA;AAC5B,MAAA,IAAIS,EAAAA,KAAOnH,MAAAA,EAAWiH,KAAAA,CAAME,EAAAA,CAAAA;AAC9B,IAAA;AACAH,IAAAA,QAAAA,CAASK,MAAAA,CAAOvB,EAAEO,GAAG,CAAA;AACrBS,IAAAA,MAAAA,CAAOI,GAAAA,CAAIpB,EAAEO,GAAG,CAAA;AAChBX,IAAAA,OAAAA,CAAQ4B,KAAKxB,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 Container, 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 * Options for the seeded form: the factory receives the seed the active\n * request was opened with (`runInRequest(cb, { seed })`). A factory provider\n * gets no container, so the container that opens the request is passed here.\n */\nexport interface CreateSeededAgentProviderOptions<TSeed, TAgent> {\n factory: (seed: TSeed) => TAgent | Promise<TAgent>;\n /** The container whose `runInRequest(cb, { seed })` carries the seed. */\n container: Container;\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<TSeed, TAgent>(\n options: CreateSeededAgentProviderOptions<TSeed, TAgent>,\n): FactoryProvider<TAgent>;\nexport function createAgentProvider<TAgent>(\n options: CreateAgentProviderOptions<TAgent>,\n): FactoryProvider<TAgent>;\nexport function createAgentProvider(\n options: CreateAgentProviderOptions<unknown> | CreateSeededAgentProviderOptions<unknown, unknown>,\n): FactoryProvider<unknown> {\n const { container } = options as { container?: Container };\n return {\n provide: AGENT_TOKEN,\n useFactory: () =>\n container === undefined\n ? (options.factory as () => unknown)()\n : (options.factory as (seed: unknown) => unknown)(container.requestSeed()),\n scope: options.scope ?? Scope.REQUEST,\n };\n}\n","import { Container } from \"@theokit/di\";\n\nimport { createAgentProvider } from \"./agent-provider.js\";\nimport { AGENT_TOKEN } from \"./tokens.js\";\n\n/** Options for `createAgentBoundary()`. */\nexport interface AgentBoundaryOptions<TSeed, TAgent> {\n /** Called once per `withAgent` call, inside its request scope. */\n readonly factory: (seed: TSeed) => TAgent | Promise<TAgent>;\n /**\n * Optional container to register into; default a new Container. It must\n * still accept registrations (not yet resolved from) when the boundary is created.\n */\n readonly container?: Container;\n}\n\n/** A request boundary that builds one seeded agent per `withAgent` call. */\nexport interface AgentBoundary<TSeed, TAgent> {\n /**\n * Opens a request scope seeded with `seed`, builds the agent in it and runs\n * `work`. REQUEST-scoped providers resolved from the same container inside\n * `work` share the agent and can read the seed with `requestSeed()`.\n * Request-scoped instances (including a disposable agent) are disposed when\n * `work` settles, on success and on throw.\n */\n withAgent<R>(seed: TSeed, work: (agent: TAgent) => R | Promise<R>): Promise<R>;\n}\n\n/** One seeded agent per request: the default way to use `createAgentProvider`. */\nexport function createAgentBoundary<TSeed, TAgent>(\n options: AgentBoundaryOptions<TSeed, TAgent>,\n): AgentBoundary<TSeed, TAgent> {\n const container = options.container ?? new Container();\n container.register(createAgentProvider<TSeed, TAgent>({ factory: options.factory, container }));\n return {\n withAgent: (seed, work) =>\n container.runInRequest(async () => work(await container.resolveAsync<TAgent>(AGENT_TOKEN)), {\n seed,\n }),\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,6 +1,6 @@
1
1
  {
2
2
  "name": "@theokit/di-agent",
3
- "version": "0.5.0",
3
+ "version": "0.6.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
6
  "homepage": "https://github.com/usetheokit/theokit-di#readme",
@@ -44,7 +44,7 @@
44
44
  "Theo"
45
45
  ],
46
46
  "peerDependencies": {
47
- "@theokit/di": ">=0.1.1 <0.3",
47
+ "@theokit/di": ">=0.3.0 <0.4",
48
48
  "@theokit/sdk": ">=4.0.1 <6",
49
49
  "reflect-metadata": "^0.2.0"
50
50
  },
@@ -58,7 +58,7 @@
58
58
  "unplugin-swc": "^1.5.9",
59
59
  "vitest": "^4.1.8",
60
60
  "zod": "^4.0.0",
61
- "@theokit/di": "0.2.1"
61
+ "@theokit/di": "0.3.1"
62
62
  },
63
63
  "publishConfig": {
64
64
  "access": "public",