@theokit/sdk 2.22.0 → 2.24.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 +52 -0
- package/dist/a2a/index.cjs +43 -15
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +43 -15
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/subagent.d.cts +27 -2
- package/dist/a2a/subagent.d.ts +27 -2
- package/dist/{cron-Bpt_1khA.d.cts → cron-Bd2oRD7A.d.cts} +1 -1
- package/dist/{cron-7CruUd_0.d.ts → cron-vjod0qVQ.d.ts} +1 -1
- package/dist/cron.cjs +3 -1
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +3 -1
- package/dist/cron.js.map +1 -1
- package/dist/define-tool.d.ts +33 -20
- package/dist/{errors-CkCaIqVP.d.cts → errors-DIKBXffg.d.cts} +1 -1
- package/dist/{errors-BuwwkrAk.d.ts → errors-DRS-kqOK.d.ts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +3 -1
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +3 -1
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -26
- package/dist/index.d.ts +37 -26
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/{run-CrIulPF7.d.cts → run-Cr0C6cOM.d.cts} +17 -0
- package/dist/{run-CrIulPF7.d.ts → run-Cr0C6cOM.d.ts} +17 -0
- package/dist/types/run.d.ts +17 -0
- package/dist/workflow.cjs +37 -0
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +47 -1
- package/dist/workflow.d.ts +47 -1
- package/dist/workflow.js +37 -2
- package/dist/workflow.js.map +1 -1
- package/package.json +3 -3
package/dist/a2a/subagent.d.cts
CHANGED
|
@@ -25,6 +25,12 @@ export interface MessageFilterArgs {
|
|
|
25
25
|
export interface DelegationStartContext {
|
|
26
26
|
input: string;
|
|
27
27
|
name: string;
|
|
28
|
+
/**
|
|
29
|
+
* SE15 — 1-based count of times THIS subagent tool has been invoked (a
|
|
30
|
+
* per-`defineSubAgent`-instance counter). Incremented before this hook runs;
|
|
31
|
+
* a rejected delegation still counts. Enables reject-after-N patterns.
|
|
32
|
+
*/
|
|
33
|
+
iteration: number;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
36
|
* Decision returned from {@link SubAgentSpec.onDelegationStart}. Discriminated on
|
|
@@ -37,6 +43,8 @@ export type DelegationStartDecision = {
|
|
|
37
43
|
} | {
|
|
38
44
|
proceed?: true;
|
|
39
45
|
modifiedInput?: string;
|
|
46
|
+
/** SE13 — cap the child's iteration count (forwarded as `SendOptions.maxIterations`). */
|
|
47
|
+
modifiedMaxSteps?: number;
|
|
40
48
|
};
|
|
41
49
|
/** Context passed to {@link SubAgentSpec.onDelegationComplete} after the child settles. */
|
|
42
50
|
export interface DelegationCompleteContext {
|
|
@@ -46,7 +54,15 @@ export interface DelegationCompleteContext {
|
|
|
46
54
|
result?: string;
|
|
47
55
|
/** The error the child threw (present on failure); the error is still re-thrown. */
|
|
48
56
|
error?: unknown;
|
|
57
|
+
/** SE15 — the same 1-based iteration this delegation's `onDelegationStart` saw. */
|
|
58
|
+
iteration: number;
|
|
49
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* The return of a delegation hook: a decision, a promise of one, or nothing —
|
|
62
|
+
* `void` lets a side-effect-only callback (`(ctx) => { log(ctx) }`) type-check,
|
|
63
|
+
* which is the common case (mirrors Mastra's `async ctx => { ... }` hooks).
|
|
64
|
+
*/
|
|
65
|
+
type DelegationHookResult<T> = T | void | Promise<T | void>;
|
|
50
66
|
/** Decision returned from {@link SubAgentSpec.onDelegationComplete}. */
|
|
51
67
|
export interface DelegationCompleteDecision {
|
|
52
68
|
/** Appended to the child's result string. */
|
|
@@ -65,7 +81,7 @@ export interface SubAgentSpec {
|
|
|
65
81
|
* result), or `{ modifiedInput }` to rewrite the delegated prompt. A throwing
|
|
66
82
|
* hook surfaces (never silently swallowed).
|
|
67
83
|
*/
|
|
68
|
-
onDelegationStart?: (ctx: DelegationStartContext) =>
|
|
84
|
+
onDelegationStart?: (ctx: DelegationStartContext) => DelegationHookResult<DelegationStartDecision>;
|
|
69
85
|
/**
|
|
70
86
|
* SE11 — called after the delegation settles. On success `ctx.result` is set
|
|
71
87
|
* and an optional `{ feedback }` is appended to it. On failure `ctx.error` is
|
|
@@ -73,7 +89,7 @@ export interface SubAgentSpec {
|
|
|
73
89
|
* from this hook on the error path is suppressed so it cannot mask the
|
|
74
90
|
* delegation's real failure (on the success path a throw does propagate).
|
|
75
91
|
*/
|
|
76
|
-
onDelegationComplete?: (ctx: DelegationCompleteContext) =>
|
|
92
|
+
onDelegationComplete?: (ctx: DelegationCompleteContext) => DelegationHookResult<DelegationCompleteDecision>;
|
|
77
93
|
/**
|
|
78
94
|
* SE12 — opt-in parent-context forwarding. When set, the supervisor transcript
|
|
79
95
|
* (`ctx.messages`, a read-only text projection) is passed to this filter and the
|
|
@@ -84,6 +100,14 @@ export interface SubAgentSpec {
|
|
|
84
100
|
* `onDelegationStart`); the delegation surfaces as a tool error.
|
|
85
101
|
*/
|
|
86
102
|
messageFilter?: (args: MessageFilterArgs) => readonly ToolContextMessage[];
|
|
103
|
+
/**
|
|
104
|
+
* SE14 — opt-in subagent result-context control. When `true`, the child's
|
|
105
|
+
* completed tool-call results (name + result) are appended to the delegation
|
|
106
|
+
* payload returned to the supervisor, inside a `<subagent-tool-results>` block.
|
|
107
|
+
* When absent/`false` the delegation returns the child's final text only —
|
|
108
|
+
* text-only stays the default (Mastra's scoped posture). See ADR 0006.
|
|
109
|
+
*/
|
|
110
|
+
includeToolResults?: boolean;
|
|
87
111
|
}
|
|
88
112
|
export declare class MaxDelegationDepthError extends Error {
|
|
89
113
|
readonly currentDepth: number;
|
|
@@ -92,3 +116,4 @@ export declare class MaxDelegationDepthError extends Error {
|
|
|
92
116
|
constructor(currentDepth: number, maxDepth: number);
|
|
93
117
|
}
|
|
94
118
|
export declare function defineSubAgent(spec: SubAgentSpec, _parentDepth?: number): CustomTool;
|
|
119
|
+
export {};
|
package/dist/a2a/subagent.d.ts
CHANGED
|
@@ -25,6 +25,12 @@ export interface MessageFilterArgs {
|
|
|
25
25
|
export interface DelegationStartContext {
|
|
26
26
|
input: string;
|
|
27
27
|
name: string;
|
|
28
|
+
/**
|
|
29
|
+
* SE15 — 1-based count of times THIS subagent tool has been invoked (a
|
|
30
|
+
* per-`defineSubAgent`-instance counter). Incremented before this hook runs;
|
|
31
|
+
* a rejected delegation still counts. Enables reject-after-N patterns.
|
|
32
|
+
*/
|
|
33
|
+
iteration: number;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
36
|
* Decision returned from {@link SubAgentSpec.onDelegationStart}. Discriminated on
|
|
@@ -37,6 +43,8 @@ export type DelegationStartDecision = {
|
|
|
37
43
|
} | {
|
|
38
44
|
proceed?: true;
|
|
39
45
|
modifiedInput?: string;
|
|
46
|
+
/** SE13 — cap the child's iteration count (forwarded as `SendOptions.maxIterations`). */
|
|
47
|
+
modifiedMaxSteps?: number;
|
|
40
48
|
};
|
|
41
49
|
/** Context passed to {@link SubAgentSpec.onDelegationComplete} after the child settles. */
|
|
42
50
|
export interface DelegationCompleteContext {
|
|
@@ -46,7 +54,15 @@ export interface DelegationCompleteContext {
|
|
|
46
54
|
result?: string;
|
|
47
55
|
/** The error the child threw (present on failure); the error is still re-thrown. */
|
|
48
56
|
error?: unknown;
|
|
57
|
+
/** SE15 — the same 1-based iteration this delegation's `onDelegationStart` saw. */
|
|
58
|
+
iteration: number;
|
|
49
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* The return of a delegation hook: a decision, a promise of one, or nothing —
|
|
62
|
+
* `void` lets a side-effect-only callback (`(ctx) => { log(ctx) }`) type-check,
|
|
63
|
+
* which is the common case (mirrors Mastra's `async ctx => { ... }` hooks).
|
|
64
|
+
*/
|
|
65
|
+
type DelegationHookResult<T> = T | void | Promise<T | void>;
|
|
50
66
|
/** Decision returned from {@link SubAgentSpec.onDelegationComplete}. */
|
|
51
67
|
export interface DelegationCompleteDecision {
|
|
52
68
|
/** Appended to the child's result string. */
|
|
@@ -65,7 +81,7 @@ export interface SubAgentSpec {
|
|
|
65
81
|
* result), or `{ modifiedInput }` to rewrite the delegated prompt. A throwing
|
|
66
82
|
* hook surfaces (never silently swallowed).
|
|
67
83
|
*/
|
|
68
|
-
onDelegationStart?: (ctx: DelegationStartContext) =>
|
|
84
|
+
onDelegationStart?: (ctx: DelegationStartContext) => DelegationHookResult<DelegationStartDecision>;
|
|
69
85
|
/**
|
|
70
86
|
* SE11 — called after the delegation settles. On success `ctx.result` is set
|
|
71
87
|
* and an optional `{ feedback }` is appended to it. On failure `ctx.error` is
|
|
@@ -73,7 +89,7 @@ export interface SubAgentSpec {
|
|
|
73
89
|
* from this hook on the error path is suppressed so it cannot mask the
|
|
74
90
|
* delegation's real failure (on the success path a throw does propagate).
|
|
75
91
|
*/
|
|
76
|
-
onDelegationComplete?: (ctx: DelegationCompleteContext) =>
|
|
92
|
+
onDelegationComplete?: (ctx: DelegationCompleteContext) => DelegationHookResult<DelegationCompleteDecision>;
|
|
77
93
|
/**
|
|
78
94
|
* SE12 — opt-in parent-context forwarding. When set, the supervisor transcript
|
|
79
95
|
* (`ctx.messages`, a read-only text projection) is passed to this filter and the
|
|
@@ -84,6 +100,14 @@ export interface SubAgentSpec {
|
|
|
84
100
|
* `onDelegationStart`); the delegation surfaces as a tool error.
|
|
85
101
|
*/
|
|
86
102
|
messageFilter?: (args: MessageFilterArgs) => readonly ToolContextMessage[];
|
|
103
|
+
/**
|
|
104
|
+
* SE14 — opt-in subagent result-context control. When `true`, the child's
|
|
105
|
+
* completed tool-call results (name + result) are appended to the delegation
|
|
106
|
+
* payload returned to the supervisor, inside a `<subagent-tool-results>` block.
|
|
107
|
+
* When absent/`false` the delegation returns the child's final text only —
|
|
108
|
+
* text-only stays the default (Mastra's scoped posture). See ADR 0006.
|
|
109
|
+
*/
|
|
110
|
+
includeToolResults?: boolean;
|
|
87
111
|
}
|
|
88
112
|
export declare class MaxDelegationDepthError extends Error {
|
|
89
113
|
readonly currentDepth: number;
|
|
@@ -92,3 +116,4 @@ export declare class MaxDelegationDepthError extends Error {
|
|
|
92
116
|
constructor(currentDepth: number, maxDepth: number);
|
|
93
117
|
}
|
|
94
118
|
export declare function defineSubAgent(spec: SubAgentSpec, _parentDepth?: number): CustomTool;
|
|
119
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CustomTool, M as ModelSelection, Z as SDKUserMessage, $ as SendOptions, b as Run, G as GenerateOptions, j as GenerateRunResult, F as RunToCompletionOptions, H as RunToCompletionResult, S as SDKMessage, a6 as StreamToCompletionResult, a as McpServerConfig } from './run-
|
|
1
|
+
import { C as CustomTool, M as ModelSelection, Z as SDKUserMessage, $ as SendOptions, b as Run, G as GenerateOptions, j as GenerateRunResult, F as RunToCompletionOptions, H as RunToCompletionResult, S as SDKMessage, a6 as StreamToCompletionResult, a as McpServerConfig } from './run-Cr0C6cOM.cjs';
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CustomTool, M as ModelSelection, Z as SDKUserMessage, $ as SendOptions, b as Run, G as GenerateOptions, j as GenerateRunResult, F as RunToCompletionOptions, H as RunToCompletionResult, S as SDKMessage, a6 as StreamToCompletionResult, a as McpServerConfig } from './run-
|
|
1
|
+
import { C as CustomTool, M as ModelSelection, Z as SDKUserMessage, $ as SendOptions, b as Run, G as GenerateOptions, j as GenerateRunResult, F as RunToCompletionOptions, H as RunToCompletionResult, S as SDKMessage, a6 as StreamToCompletionResult, a as McpServerConfig } from './run-Cr0C6cOM.js';
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/cron.cjs
CHANGED
|
@@ -13307,6 +13307,7 @@ function levenshtein(a, b) {
|
|
|
13307
13307
|
}
|
|
13308
13308
|
|
|
13309
13309
|
// src/internal/runtime/local-agent/real-local-run.ts
|
|
13310
|
+
init_async_local_storage();
|
|
13310
13311
|
function createRealLocalRun(options) {
|
|
13311
13312
|
const { userText, id, startTime } = prepareRunContext(options.message);
|
|
13312
13313
|
const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
|
|
@@ -13418,6 +13419,7 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
13418
13419
|
...options.onStep !== void 0 ? { onStep: options.onStep } : {},
|
|
13419
13420
|
...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
|
|
13420
13421
|
...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
|
|
13422
|
+
...options.sendOptions.activeTools !== void 0 ? { activeTools: options.sendOptions.activeTools } : {},
|
|
13421
13423
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
13422
13424
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
13423
13425
|
...buildCustomToolsInput(
|
|
@@ -13548,7 +13550,7 @@ var RealLocalRun = class extends FixtureRunBase {
|
|
|
13548
13550
|
}
|
|
13549
13551
|
async executeAgentLoop(inputs) {
|
|
13550
13552
|
try {
|
|
13551
|
-
const output = await runAgentLoop(inputs);
|
|
13553
|
+
const output = inputs.activeTools !== void 0 ? await withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : await runAgentLoop(inputs);
|
|
13552
13554
|
this.applyAgentLoopOutput(output);
|
|
13553
13555
|
this.transitionTo(output.finalStatus);
|
|
13554
13556
|
} catch (cause) {
|