@vendoai/agent 0.4.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/LICENSE +202 -0
- package/README.md +26 -0
- package/dist/agent.d.ts +62 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +443 -0
- package/dist/agent.js.map +1 -0
- package/dist/capability-miss.d.ts +24 -0
- package/dist/capability-miss.d.ts.map +1 -0
- package/dist/capability-miss.js +133 -0
- package/dist/capability-miss.js.map +1 -0
- package/dist/ids.d.ts +6 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +9 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/pack.d.ts +37 -0
- package/dist/pack.d.ts.map +1 -0
- package/dist/pack.js +225 -0
- package/dist/pack.js.map +1 -0
- package/dist/prompt.d.ts +8 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +43 -0
- package/dist/prompt.js.map +1 -0
- package/dist/runner.d.ts +20 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +114 -0
- package/dist/runner.js.map +1 -0
- package/dist/test-helpers.d.ts +55 -0
- package/dist/test-helpers.d.ts.map +1 -0
- package/dist/test-helpers.js +230 -0
- package/dist/test-helpers.js.map +1 -0
- package/dist/threads.d.ts +48 -0
- package/dist/threads.d.ts.map +1 -0
- package/dist/threads.js +251 -0
- package/dist/threads.js.map +1 -0
- package/dist/tool-pack.d.ts +41 -0
- package/dist/tool-pack.d.ts.map +1 -0
- package/dist/tool-pack.js +17 -0
- package/dist/tool-pack.js.map +1 -0
- package/dist/tool-search.d.ts +72 -0
- package/dist/tool-search.d.ts.map +1 -0
- package/dist/tool-search.js +135 -0
- package/dist/tool-search.js.map +1 -0
- package/dist/tools.d.ts +22 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +151 -0
- package/dist/tools.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,kBAAkB;AAClB,wBAAgB,YAAY,IAAI,QAAQ,CAEvC;AAED,iBAAiB;AACjB,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
|
package/dist/ids.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** 03-agent §5 */
|
|
2
|
+
export function mintThreadId() {
|
|
3
|
+
return `thr_${globalThis.crypto.randomUUID().replaceAll("-", "")}`;
|
|
4
|
+
}
|
|
5
|
+
/** 01-core §7 */
|
|
6
|
+
export function mintAuditId() {
|
|
7
|
+
return `aud_${globalThis.crypto.randomUUID().replaceAll("-", "")}`;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ids.js.map
|
package/dist/ids.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.js","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAEA,kBAAkB;AAClB,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;AACrE,CAAC;AAED,iBAAiB;AACjB,MAAM,UAAU,WAAW;IACzB,OAAO,OAAO,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;AACrE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createAgent } from "./agent.js";
|
|
2
|
+
export type { VendoAgent } from "./agent.js";
|
|
3
|
+
export type { CapabilityMissConfig } from "./capability-miss.js";
|
|
4
|
+
export { buildVendoToolPack, type VendoPackExecuteOptions, type VendoPackTool, type VendoToolPackCoreOptions, } from "./pack.js";
|
|
5
|
+
export { VENDO_CREATE_APP_TOOL, VENDO_DELEGATE_TOOL, VENDO_TOOL_PACK_PREFIX, type VendoDelegateResult, type VendoToolPackFilter, type VendoToolPackOptions, } from "./tool-pack.js";
|
|
6
|
+
export type { ToolSearchConfig, ToolSearchFn, ToolSearchMatch } from "./tool-search.js";
|
|
7
|
+
export type { Thread, ThreadSummary } from "./threads.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,wBAAwB,GAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxF,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,OAAO,EACL,kBAAkB,GAInB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GAIvB,MAAM,gBAAgB,CAAC"}
|
package/dist/pack.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type AgentRunner, type Json, type RunContext, type ToolRegistry } from "@vendoai/core";
|
|
2
|
+
import { type VendoToolPackFilter } from "./tool-pack.js";
|
|
3
|
+
export interface VendoToolPackCoreOptions extends VendoToolPackFilter {
|
|
4
|
+
/** The guard-bound registry (guard.bind(actions)) — the pack never wraps an
|
|
5
|
+
* unbound registry; parking, grants, breakers, and audit all live in the
|
|
6
|
+
* binding's execute path. */
|
|
7
|
+
registry: ToolRegistry;
|
|
8
|
+
/** Backs `vendo_delegate` (the umbrella passes `agent.asRunner()`). */
|
|
9
|
+
runner: AgentRunner;
|
|
10
|
+
}
|
|
11
|
+
/** How a pack tool is executed by a format shim. `ctx` is per-call because the
|
|
12
|
+
* Mastra shim resolves its principal lazily from the framework's request
|
|
13
|
+
* context; the AI SDK shim closes one request-scoped ctx over every call. */
|
|
14
|
+
export interface VendoPackExecuteOptions {
|
|
15
|
+
ctx: RunContext;
|
|
16
|
+
/** The host loop's tool-call id, for audit continuity; unset mints one. */
|
|
17
|
+
callId?: string;
|
|
18
|
+
}
|
|
19
|
+
/** One framework-neutral pack tool: final `vendo_*` name, the descriptor's
|
|
20
|
+
* JSON-Schema input, and a guarded execute returning either a versioned
|
|
21
|
+
* envelope (`vendo/app-ref@1`, `vendo/approval-ref@1`) or plain data. */
|
|
22
|
+
export interface VendoPackTool {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
inputSchema: Json;
|
|
26
|
+
execute(input: unknown, options: VendoPackExecuteOptions): Promise<unknown>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build the pack: every registered host tool guard-wrapped under `vendo_`,
|
|
30
|
+
* plus the two built-ins. Vendo-internal registry tools (names already under
|
|
31
|
+
* `vendo_` — the apps runtime's `vendo_apps_*`, doctor probes) are never
|
|
32
|
+
* double-wrapped: the pack's door to app creation is `vendo_create_app`, and
|
|
33
|
+
* in-app interaction rides the wire, not the host loop. `include`/`exclude`
|
|
34
|
+
* match FINAL namespaced names exactly; exclude wins.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildVendoToolPack(options: VendoToolPackCoreOptions): Promise<VendoPackTool[]>;
|
|
37
|
+
//# sourceMappingURL=pack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../src/pack.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,UAAU,EAGf,KAAK,YAAY,EAKlB,MAAM,eAAe,CAAC;AACvB,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,gBAAgB,CAAC;AAexB,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IACnE;;kCAE8B;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,uEAAuE;IACvE,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;8EAE8E;AAC9E,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,UAAU,CAAC;IAChB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;0EAE0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,IAAI,CAAC;IAClB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7E;AAqMD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAiBpG"}
|
package/dist/pack.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { VENDO_APPS_CREATE_TOOL, VENDO_APPROVAL_REF_KIND, VENDO_APP_REF_KIND, VENDO_VIEW_STREAM, canonicalJson, } from "@vendoai/core";
|
|
2
|
+
import { VENDO_CREATE_APP_TOOL, VENDO_DELEGATE_TOOL, VENDO_TOOL_PACK_PREFIX, } from "./tool-pack.js";
|
|
3
|
+
/**
|
|
4
|
+
* Existing-agents seam — the framework-neutral tool pack a BYO agent loop gets
|
|
5
|
+
* (frozen contract: docs/superpowers/specs/2026-07-20-existing-agents-contracts.md §2).
|
|
6
|
+
* A promotion of the guard-bound wrapping Vendo's own loop uses (tools.ts):
|
|
7
|
+
* every pack tool executes through the SAME guard-bound registry, so no tool
|
|
8
|
+
* reachable from a BYO loop has an unguarded route. The umbrella's `./ai-sdk`
|
|
9
|
+
* and `./mastra` subpaths are thin format shims over this core.
|
|
10
|
+
*/
|
|
11
|
+
const DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
|
12
|
+
const TITLE_CAP = 80;
|
|
13
|
+
const SUMMARY_CAP = 500;
|
|
14
|
+
function mintCallId() {
|
|
15
|
+
return `call_${globalThis.crypto.randomUUID()}`;
|
|
16
|
+
}
|
|
17
|
+
function executionError() {
|
|
18
|
+
return {
|
|
19
|
+
status: "error",
|
|
20
|
+
error: { code: "execution", message: "Tool execution failed." },
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** One human-readable line describing what is waiting — the tool descriptor
|
|
24
|
+
* plus the guard's inputPreview vocabulary (`<tool> <canonical args>`). */
|
|
25
|
+
function approvalSummary(descriptor, args) {
|
|
26
|
+
let preview;
|
|
27
|
+
try {
|
|
28
|
+
preview = canonicalJson(args);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
preview = "";
|
|
32
|
+
}
|
|
33
|
+
const summary = `Awaiting user approval: ${descriptor.description || descriptor.name} — ${descriptor.name} ${preview}`
|
|
34
|
+
.replace(/\s+/g, " ")
|
|
35
|
+
.trim();
|
|
36
|
+
return summary.length > SUMMARY_CAP ? `${summary.slice(0, SUMMARY_CAP - 1)}…` : summary;
|
|
37
|
+
}
|
|
38
|
+
function approvalRef(approvalId, descriptor, args) {
|
|
39
|
+
return { kind: VENDO_APPROVAL_REF_KIND, approvalId, summary: approvalSummary(descriptor, args) };
|
|
40
|
+
}
|
|
41
|
+
/** The embed-chrome title known at fast-return time: the prompt itself,
|
|
42
|
+
* collapsed to one line and capped. */
|
|
43
|
+
function titleFromPrompt(prompt) {
|
|
44
|
+
const collapsed = typeof prompt === "string" ? prompt.replace(/\s+/g, " ").trim() : "";
|
|
45
|
+
if (collapsed.length === 0)
|
|
46
|
+
return "Vendo app";
|
|
47
|
+
return collapsed.length > TITLE_CAP ? `${collapsed.slice(0, TITLE_CAP - 1)}…` : collapsed;
|
|
48
|
+
}
|
|
49
|
+
function appRefFromDocument(output, fallbackTitle) {
|
|
50
|
+
const document = typeof output === "object" && output !== null
|
|
51
|
+
? output
|
|
52
|
+
: undefined;
|
|
53
|
+
if (typeof document?.id !== "string" || !document.id.startsWith("app_"))
|
|
54
|
+
return null;
|
|
55
|
+
return {
|
|
56
|
+
kind: VENDO_APP_REF_KIND,
|
|
57
|
+
appId: document.id,
|
|
58
|
+
title: typeof document.name === "string" && document.name.length > 0 ? document.name : fallbackTitle,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async function guardedExecute(registry, call, ctx) {
|
|
62
|
+
try {
|
|
63
|
+
return await registry.execute(call, ctx);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return executionError();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Envelope-or-plain-data mapping shared by every pack tool: parking returns
|
|
70
|
+
* the approval ref (no throw, no block — §2); a clean run returns the output
|
|
71
|
+
* the way any tool output reads; error/blocked outcomes pass through as plain
|
|
72
|
+
* data the model can act on. */
|
|
73
|
+
function mapOutcome(outcome, descriptor, args) {
|
|
74
|
+
if (outcome.status === "pending-approval")
|
|
75
|
+
return approvalRef(outcome.approvalId, descriptor, args);
|
|
76
|
+
if (outcome.status === "ok")
|
|
77
|
+
return outcome.output;
|
|
78
|
+
return outcome;
|
|
79
|
+
}
|
|
80
|
+
function applyFilter(names, filter) {
|
|
81
|
+
const included = filter.include === undefined
|
|
82
|
+
? new Set(names)
|
|
83
|
+
: new Set(names.filter((name) => filter.include.includes(name)));
|
|
84
|
+
for (const name of filter.exclude ?? [])
|
|
85
|
+
included.delete(name);
|
|
86
|
+
return included;
|
|
87
|
+
}
|
|
88
|
+
function wrapHostTool(registry, descriptor) {
|
|
89
|
+
return {
|
|
90
|
+
name: `${VENDO_TOOL_PACK_PREFIX}${descriptor.name}`,
|
|
91
|
+
description: descriptor.description,
|
|
92
|
+
inputSchema: structuredClone(descriptor.inputSchema),
|
|
93
|
+
async execute(input, options) {
|
|
94
|
+
const call = { id: options.callId ?? mintCallId(), tool: descriptor.name, args: input };
|
|
95
|
+
const outcome = await guardedExecute(registry, call, options.ctx);
|
|
96
|
+
return mapOutcome(outcome, descriptor, input);
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** `vendo_create_app` — generate UI, returning fast: the FIRST streamed view
|
|
101
|
+
* part already carries the app's permanent id, so the app-ref envelope goes
|
|
102
|
+
* back to the loop while the build keeps streaming over the wire. Without a
|
|
103
|
+
* streamed part the finished document supplies the ref. */
|
|
104
|
+
function createAppTool(registry, descriptor) {
|
|
105
|
+
return {
|
|
106
|
+
name: VENDO_CREATE_APP_TOOL,
|
|
107
|
+
description: "Create a Vendo app (generated UI) from a natural-language prompt. Returns fast with a vendo/app-ref@1 envelope; the build streams to the host's embed over the Vendo wire, so never wait for or report on build completion.",
|
|
108
|
+
inputSchema: {
|
|
109
|
+
$schema: DRAFT_2020_12,
|
|
110
|
+
type: "object",
|
|
111
|
+
properties: { prompt: { type: "string", minLength: 1 } },
|
|
112
|
+
required: ["prompt"],
|
|
113
|
+
additionalProperties: false,
|
|
114
|
+
},
|
|
115
|
+
async execute(input, options) {
|
|
116
|
+
const args = input;
|
|
117
|
+
const fallbackTitle = titleFromPrompt(args?.prompt);
|
|
118
|
+
const call = {
|
|
119
|
+
id: options.callId ?? mintCallId(),
|
|
120
|
+
tool: VENDO_APPS_CREATE_TOOL,
|
|
121
|
+
args: input,
|
|
122
|
+
};
|
|
123
|
+
let resolveFast;
|
|
124
|
+
const fast = new Promise((resolve) => { resolveFast = resolve; });
|
|
125
|
+
Object.defineProperty(call, VENDO_VIEW_STREAM, {
|
|
126
|
+
value: (update) => {
|
|
127
|
+
const appId = update?.part?.appId;
|
|
128
|
+
if (typeof appId === "string" && appId.startsWith("app_")) {
|
|
129
|
+
resolveFast({ kind: VENDO_APP_REF_KIND, appId, title: fallbackTitle });
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
const settled = guardedExecute(registry, call, options.ctx).then((outcome) => {
|
|
134
|
+
if (outcome.status === "ok") {
|
|
135
|
+
return appRefFromDocument(outcome.output, fallbackTitle) ?? outcome.output;
|
|
136
|
+
}
|
|
137
|
+
return mapOutcome(outcome, descriptor, input);
|
|
138
|
+
});
|
|
139
|
+
// The build may still be streaming when the fast ref wins the race; its
|
|
140
|
+
// completion (and any late failure) belongs to the wire, not this call.
|
|
141
|
+
settled.catch(() => undefined);
|
|
142
|
+
return Promise.race([fast, settled]);
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/** `vendo_delegate` — whole-task delegation through the same AgentRunner seam
|
|
147
|
+
* automations ride. The delegated run executes over THIS registry (guard-bound),
|
|
148
|
+
* and everything envelope-worthy it produces comes back as refs. */
|
|
149
|
+
function delegateTool(registry, runner) {
|
|
150
|
+
return {
|
|
151
|
+
name: VENDO_DELEGATE_TOOL,
|
|
152
|
+
description: "Delegate a whole task to Vendo's own agent. Runs to completion server-side and returns { status, summary, refs } — refs carry vendo/app-ref@1 / vendo/approval-ref@1 envelopes for anything the run produced.",
|
|
153
|
+
inputSchema: {
|
|
154
|
+
$schema: DRAFT_2020_12,
|
|
155
|
+
type: "object",
|
|
156
|
+
properties: { task: { type: "string", minLength: 1 } },
|
|
157
|
+
required: ["task"],
|
|
158
|
+
additionalProperties: false,
|
|
159
|
+
},
|
|
160
|
+
async execute(input, options) {
|
|
161
|
+
const task = input?.task;
|
|
162
|
+
const refs = [];
|
|
163
|
+
const descriptorsByName = registry.descriptors().then((descriptors) => new Map(descriptors.map((descriptor) => [descriptor.name, descriptor])));
|
|
164
|
+
descriptorsByName.catch(() => undefined);
|
|
165
|
+
const capturing = {
|
|
166
|
+
descriptors: () => registry.descriptors(),
|
|
167
|
+
async execute(call, runCtx) {
|
|
168
|
+
const outcome = await registry.execute(call, runCtx);
|
|
169
|
+
if (call.tool === VENDO_APPS_CREATE_TOOL && outcome.status === "ok") {
|
|
170
|
+
const ref = appRefFromDocument(outcome.output, titleFromPrompt(call.args?.prompt));
|
|
171
|
+
if (ref !== null)
|
|
172
|
+
refs.push(ref);
|
|
173
|
+
}
|
|
174
|
+
else if (outcome.status === "pending-approval") {
|
|
175
|
+
const descriptor = (await descriptorsByName.catch(() => undefined))?.get(call.tool)
|
|
176
|
+
?? { name: call.tool, description: "", inputSchema: {}, risk: "write" };
|
|
177
|
+
refs.push(approvalRef(outcome.approvalId, descriptor, call.args));
|
|
178
|
+
}
|
|
179
|
+
return outcome;
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
try {
|
|
183
|
+
const report = await runner({ prompt: typeof task === "string" ? task : "", tools: capturing }, options.ctx);
|
|
184
|
+
const result = { status: report.status, summary: report.summary, refs };
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
const result = {
|
|
189
|
+
status: "error",
|
|
190
|
+
summary: "The delegated run could not be completed.",
|
|
191
|
+
refs,
|
|
192
|
+
};
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Build the pack: every registered host tool guard-wrapped under `vendo_`,
|
|
200
|
+
* plus the two built-ins. Vendo-internal registry tools (names already under
|
|
201
|
+
* `vendo_` — the apps runtime's `vendo_apps_*`, doctor probes) are never
|
|
202
|
+
* double-wrapped: the pack's door to app creation is `vendo_create_app`, and
|
|
203
|
+
* in-app interaction rides the wire, not the host loop. `include`/`exclude`
|
|
204
|
+
* match FINAL namespaced names exactly; exclude wins.
|
|
205
|
+
*/
|
|
206
|
+
export async function buildVendoToolPack(options) {
|
|
207
|
+
const descriptors = await options.registry.descriptors();
|
|
208
|
+
const byName = new Map();
|
|
209
|
+
for (const descriptor of descriptors) {
|
|
210
|
+
if (descriptor.name.startsWith(VENDO_TOOL_PACK_PREFIX))
|
|
211
|
+
continue;
|
|
212
|
+
const tool = wrapHostTool(options.registry, descriptor);
|
|
213
|
+
byName.set(tool.name, tool);
|
|
214
|
+
}
|
|
215
|
+
// Built-ins land last: a host tool whose namespaced name collides with one
|
|
216
|
+
// can never shadow the pack's own doors.
|
|
217
|
+
const appsCreate = descriptors.find((descriptor) => descriptor.name === VENDO_APPS_CREATE_TOOL);
|
|
218
|
+
if (appsCreate !== undefined) {
|
|
219
|
+
byName.set(VENDO_CREATE_APP_TOOL, createAppTool(options.registry, appsCreate));
|
|
220
|
+
}
|
|
221
|
+
byName.set(VENDO_DELEGATE_TOOL, delegateTool(options.registry, options.runner));
|
|
222
|
+
const included = applyFilter([...byName.keys()], options);
|
|
223
|
+
return [...byName.values()].filter((tool) => included.has(tool.name));
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=pack.js.map
|
package/dist/pack.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack.js","sourceRoot":"","sources":["../src/pack.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GAWd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GAGvB,MAAM,gBA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ChG,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAChF,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
package/dist/prompt.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Guard, RunContext } from "@vendoai/core";
|
|
2
|
+
/** 03-agent §3: company directions are mandatory policy context and fail closed. */
|
|
3
|
+
export declare function assembleSystemPrompt(guard: Guard, ctx: RunContext, system?: {
|
|
4
|
+
product?: string;
|
|
5
|
+
catalog?: string;
|
|
6
|
+
instructions?: string;
|
|
7
|
+
}, capabilityMiss?: boolean): Promise<string>;
|
|
8
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAuBvD,oFAAoF;AACpF,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,UAAU,EACf,MAAM,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EACtE,cAAc,UAAQ,GACrB,OAAO,CAAC,MAAM,CAAC,CAqBjB"}
|
package/dist/prompt.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const OPERATING_PROMPT = `You are Vendo's agent.
|
|
2
|
+
Act through the host's available tools on behalf of the signed-in user.
|
|
3
|
+
Stay within the user's request and use the authority available in this context.
|
|
4
|
+
Ask for approval whenever the guard requires it.
|
|
5
|
+
If a call is blocked, explain the constraint and adapt your approach.
|
|
6
|
+
If a call is queued for approval, say what is pending and continue where useful.
|
|
7
|
+
Never claim a tool ran unless its result confirms that it did.
|
|
8
|
+
Never invent tool outputs, records, or side effects.
|
|
9
|
+
For away runs, clearly state what completed and what was left pending.`;
|
|
10
|
+
const CAPABILITY_MISS_PROMPT = `When the user's ask cannot be fulfilled:
|
|
11
|
+
- If no available tool can perform it, call vendo_report_capability_miss with kind "no-matching-tool" before replying.
|
|
12
|
+
- If you explicitly give up after trying available approaches, call vendo_report_capability_miss with kind "agent-give-up" before replying.
|
|
13
|
+
- List only tool names you actually considered. Do not call the reporter for a pending approval or a policy-blocked call.
|
|
14
|
+
Repeated failures are detected automatically; if the reporter says the miss was already recorded, do not call it again.`;
|
|
15
|
+
// 03-agent §3 item (4): the catalog+theme summary rides only where generated
|
|
16
|
+
// trees can actually render — the chat surface and the app venue. Away
|
|
17
|
+
// automation runs and the MCP door get no component vocabulary.
|
|
18
|
+
const TREE_VENUES = new Set(["chat", "app"]);
|
|
19
|
+
/** 03-agent §3: company directions are mandatory policy context and fail closed. */
|
|
20
|
+
export async function assembleSystemPrompt(guard, ctx, system, capabilityMiss = false) {
|
|
21
|
+
const sections = [OPERATING_PROMPT];
|
|
22
|
+
if (capabilityMiss)
|
|
23
|
+
sections.push(CAPABILITY_MISS_PROMPT);
|
|
24
|
+
const product = system?.product?.trim();
|
|
25
|
+
if (product)
|
|
26
|
+
sections.push(`Product\n${product}`);
|
|
27
|
+
const directions = (await guard.directions(ctx))
|
|
28
|
+
.map((direction) => direction.trim())
|
|
29
|
+
.filter(Boolean);
|
|
30
|
+
if (directions.length > 0) {
|
|
31
|
+
sections.push(`Directions\n${directions.map((direction) => `- ${direction}`).join("\n")}`);
|
|
32
|
+
}
|
|
33
|
+
// 03-agent §3 item (4) — the umbrella assembles the summary (AGENT-1); the
|
|
34
|
+
// agent places it, venue-gated.
|
|
35
|
+
const catalog = system?.catalog?.trim();
|
|
36
|
+
if (catalog && TREE_VENUES.has(ctx.venue))
|
|
37
|
+
sections.push(catalog);
|
|
38
|
+
const instructions = system?.instructions?.trim();
|
|
39
|
+
if (instructions)
|
|
40
|
+
sections.push(instructions);
|
|
41
|
+
return sections.join("\n\n");
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAEA,MAAM,gBAAgB,GAAG;;;;;;;;uEAQ8C,CAAC;AAExE,MAAM,sBAAsB,GAAG;;;;wHAIyF,CAAC;AAEzH,6EAA6E;AAC7E,uEAAuE;AACvE,gEAAgE;AAChE,MAAM,WAAW,GAAqC,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAE/E,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAAY,EACZ,GAAe,EACf,MAAsE,EACtE,cAAc,GAAG,KAAK;IAEtB,MAAM,QAAQ,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACpC,IAAI,cAAc;QAAE,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACxC,IAAI,OAAO;QAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;IAElD,MAAM,UAAU,GAAG,CAAC,MAAM,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SAC7C,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;SACpC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,QAAQ,CAAC,IAAI,CAAC,eAAe,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7F,CAAC;IAED,2EAA2E;IAC3E,gCAAgC;IAChC,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACxC,IAAI,OAAO,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAElE,MAAM,YAAY,GAAG,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAClD,IAAI,YAAY;QAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type AgentRunner, type Guard } from "@vendoai/core";
|
|
2
|
+
import { type LanguageModel } from "ai";
|
|
3
|
+
import { type CapabilityMissConfig } from "./capability-miss.js";
|
|
4
|
+
/** 03-agent §2 */
|
|
5
|
+
export interface RunnerConfig {
|
|
6
|
+
model: LanguageModel;
|
|
7
|
+
guard: Guard;
|
|
8
|
+
system?: {
|
|
9
|
+
product?: string;
|
|
10
|
+
instructions?: string;
|
|
11
|
+
};
|
|
12
|
+
context?: {
|
|
13
|
+
maxOutputTokens?: number;
|
|
14
|
+
toolOutputCap?: number;
|
|
15
|
+
};
|
|
16
|
+
capabilityMiss?: CapabilityMissConfig;
|
|
17
|
+
}
|
|
18
|
+
/** 03-agent §2 */
|
|
19
|
+
export declare function createRunner(config: RunnerConfig): AgentRunner;
|
|
20
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,KAAK,EAIX,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,IAAI,CAAC;AAIZ,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAE9B,kBAAkB;AAClB,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,OAAO,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,cAAc,CAAC,EAAE,oBAAoB,CAAC;CACvC;AAeD,kBAAkB;AAClB,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAsG9D"}
|
package/dist/runner.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { VendoError, } from "@vendoai/core";
|
|
2
|
+
import { generateText, stepCountIs, } from "ai";
|
|
3
|
+
import { mintAuditId } from "./ids.js";
|
|
4
|
+
import { assembleSystemPrompt } from "./prompt.js";
|
|
5
|
+
import { buildAgentTools } from "./tools.js";
|
|
6
|
+
import { createCapabilityMissDetector, scrubCapabilityMissText, } from "./capability-miss.js";
|
|
7
|
+
function fallbackSummary(status, calls) {
|
|
8
|
+
if (status === "error")
|
|
9
|
+
return "The run could not be completed.";
|
|
10
|
+
if (status === "stopped")
|
|
11
|
+
return "The run stopped after reaching its tool-call budget.";
|
|
12
|
+
const pending = calls.filter((entry) => entry.outcome === "pending-approval").length;
|
|
13
|
+
if (pending > 0)
|
|
14
|
+
return `The run completed with ${pending} tool call${pending === 1 ? "" : "s"} pending approval.`;
|
|
15
|
+
return `The run completed with ${calls.length} tool call${calls.length === 1 ? "" : "s"}.`;
|
|
16
|
+
}
|
|
17
|
+
/** 03-agent §2 */
|
|
18
|
+
export function createRunner(config) {
|
|
19
|
+
return async (task, ctx) => {
|
|
20
|
+
const cap = task.budget?.maxToolCalls ?? 20;
|
|
21
|
+
if (!Number.isInteger(cap) || cap < 1) {
|
|
22
|
+
throw new VendoError("validation", "maxToolCalls must be a positive integer");
|
|
23
|
+
}
|
|
24
|
+
const awayCtx = { ...ctx, presence: "away" };
|
|
25
|
+
const recorded = [];
|
|
26
|
+
let startedCalls = 0;
|
|
27
|
+
let refusedCall = false;
|
|
28
|
+
let report;
|
|
29
|
+
try {
|
|
30
|
+
const system = await assembleSystemPrompt(config.guard, awayCtx, config.system, config.capabilityMiss !== undefined);
|
|
31
|
+
const missDetector = config.capabilityMiss === undefined
|
|
32
|
+
? undefined
|
|
33
|
+
: createCapabilityMissDetector({
|
|
34
|
+
config: config.capabilityMiss,
|
|
35
|
+
ctx: awayCtx,
|
|
36
|
+
intent: scrubCapabilityMissText(task.prompt),
|
|
37
|
+
});
|
|
38
|
+
const tools = await buildAgentTools({
|
|
39
|
+
registry: task.tools,
|
|
40
|
+
ctx: awayCtx,
|
|
41
|
+
toolOutputCap: config.context?.toolOutputCap,
|
|
42
|
+
gate: () => {
|
|
43
|
+
if (startedCalls >= cap) {
|
|
44
|
+
refusedCall = true;
|
|
45
|
+
return {
|
|
46
|
+
status: "error",
|
|
47
|
+
error: {
|
|
48
|
+
code: "budget-exhausted",
|
|
49
|
+
message: "Tool-call budget exhausted",
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
startedCalls += 1;
|
|
54
|
+
return undefined;
|
|
55
|
+
},
|
|
56
|
+
onCall: (call) => {
|
|
57
|
+
const entry = { call, outcome: "error" };
|
|
58
|
+
recorded.push(entry);
|
|
59
|
+
const finishMissCall = missDetector?.onCall(call);
|
|
60
|
+
return (outcome) => {
|
|
61
|
+
entry.outcome = outcome.status;
|
|
62
|
+
finishMissCall?.(outcome);
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
missDetector?.attach(tools);
|
|
67
|
+
const toolCallCap = ({ steps }) => steps.reduce((count, step) => count + step.toolCalls.length, 0) >= cap;
|
|
68
|
+
const result = await generateText({
|
|
69
|
+
model: config.model,
|
|
70
|
+
system,
|
|
71
|
+
prompt: task.prompt,
|
|
72
|
+
tools,
|
|
73
|
+
stopWhen: [stepCountIs(cap), toolCallCap],
|
|
74
|
+
maxOutputTokens: config.context?.maxOutputTokens,
|
|
75
|
+
abortSignal: task.abortSignal,
|
|
76
|
+
});
|
|
77
|
+
const status = refusedCall || (result.finishReason === "tool-calls" && recorded.length >= cap)
|
|
78
|
+
? "stopped"
|
|
79
|
+
: "ok";
|
|
80
|
+
report = {
|
|
81
|
+
status,
|
|
82
|
+
summary: result.text.trim() || fallbackSummary(status, recorded),
|
|
83
|
+
toolCalls: recorded,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
const stopped = task.abortSignal?.aborted === true;
|
|
88
|
+
report = {
|
|
89
|
+
status: stopped ? "stopped" : "error",
|
|
90
|
+
summary: stopped ? "The run was stopped." : fallbackSummary("error", recorded),
|
|
91
|
+
toolCalls: recorded,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
await config.guard.report({
|
|
96
|
+
id: mintAuditId(),
|
|
97
|
+
at: new Date().toISOString(),
|
|
98
|
+
kind: "run",
|
|
99
|
+
principal: awayCtx.principal,
|
|
100
|
+
venue: awayCtx.venue,
|
|
101
|
+
presence: awayCtx.presence,
|
|
102
|
+
appId: awayCtx.appId,
|
|
103
|
+
trigger: awayCtx.trigger,
|
|
104
|
+
outcome: undefined,
|
|
105
|
+
detail: { status: report.status, toolCallCount: report.toolCalls.length },
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// A reporting failure cannot change the completed run's result.
|
|
110
|
+
}
|
|
111
|
+
return report;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAOX,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY,EACZ,WAAW,GAIZ,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,GAExB,MAAM,sBAAsB,CAAC;AAgB9B,SAAS,eAAe,CAAC,MAAgC,EAAE,KAAqB;IAC9E,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,iCAAiC,CAAC;IACjE,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,sDAAsD,CAAC;IACxF,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,kBAAkB,CAAC,CAAC,MAAM,CAAC;IACrF,IAAI,OAAO,GAAG,CAAC;QAAE,OAAO,0BAA0B,OAAO,aAAa,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC;IACnH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AE,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE;aAC1E,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,gEAAgE;QAClE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ApprovalId, ApprovalRequest, AuditEvent, Guard, Json, RunContext, ToolCall, ToolDescriptor, ToolRegistry } from "@vendoai/core";
|
|
2
|
+
import type { UIMessage } from "ai";
|
|
3
|
+
import { MockLanguageModelV3 } from "ai/test";
|
|
4
|
+
type LanguageModelV3Prompt = Parameters<MockLanguageModelV3["doStream"]>[0]["prompt"];
|
|
5
|
+
type LanguageModelV3StreamPart = Awaited<ReturnType<MockLanguageModelV3["doStream"]>>["stream"] extends ReadableStream<infer Part> ? Part : never;
|
|
6
|
+
export declare const ZERO_USAGE: {
|
|
7
|
+
readonly inputTokens: {
|
|
8
|
+
readonly total: 0;
|
|
9
|
+
readonly noCache: 0;
|
|
10
|
+
readonly cacheRead: 0;
|
|
11
|
+
readonly cacheWrite: 0;
|
|
12
|
+
};
|
|
13
|
+
readonly outputTokens: {
|
|
14
|
+
readonly total: 0;
|
|
15
|
+
readonly text: 0;
|
|
16
|
+
readonly reasoning: 0;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare function textTurn(text: string, id?: string): LanguageModelV3StreamPart[];
|
|
20
|
+
export declare function toolCallTurn(toolName: string, input: unknown, toolCallId?: string): LanguageModelV3StreamPart[];
|
|
21
|
+
export type ScriptedModel = MockLanguageModelV3 & {
|
|
22
|
+
prompts: LanguageModelV3Prompt[];
|
|
23
|
+
/** The tool names offered to the model on each call, in order — i.e. the
|
|
24
|
+
* effective loadout after `activeTools`/`prepareStep` filtering (ENG-252). */
|
|
25
|
+
toolNamesPerCall: string[][];
|
|
26
|
+
};
|
|
27
|
+
export declare function scriptedModel(turns: LanguageModelV3StreamPart[][]): ScriptedModel;
|
|
28
|
+
export type TestGuard = Guard & {
|
|
29
|
+
events: AuditEvent[];
|
|
30
|
+
directionValues: string[];
|
|
31
|
+
/** AGENT-6: approval ids resolved through abandonApprovals, in call order. */
|
|
32
|
+
abandoned: ApprovalId[];
|
|
33
|
+
decide(approvalId: ApprovalId, approved: boolean): void;
|
|
34
|
+
pending(): ApprovalRequest[];
|
|
35
|
+
};
|
|
36
|
+
export declare function testGuard(policy: Record<string, "run" | "ask" | "block">, directions?: string[]): TestGuard;
|
|
37
|
+
export interface TestToolImplementation {
|
|
38
|
+
descriptor: ToolDescriptor;
|
|
39
|
+
execute(args: Json, ctx: RunContext, call: ToolCall): Json | Promise<Json>;
|
|
40
|
+
}
|
|
41
|
+
export type BoundRegistry = ToolRegistry & {
|
|
42
|
+
invocations: Record<string, number>;
|
|
43
|
+
};
|
|
44
|
+
export declare function boundRegistry(implementations: Record<string, TestToolImplementation>, guard: Guard): BoundRegistry;
|
|
45
|
+
export { memoryStoreAdapter as memoryStore } from "@vendoai/core/conformance";
|
|
46
|
+
export declare function readSse(response: Response): Promise<{
|
|
47
|
+
rawFrames: string[];
|
|
48
|
+
parts: Array<Record<string, unknown>>;
|
|
49
|
+
}>;
|
|
50
|
+
export declare function ctx(overrides?: Partial<RunContext>): RunContext;
|
|
51
|
+
/** A minimal single-text-part user UIMessage — the shape every suite feeds stream(). */
|
|
52
|
+
export declare function userMessage(id: string, text: string): UIMessage;
|
|
53
|
+
/** The first assembled UIMessage part of a given type (e.g. "data-vendo-view"). */
|
|
54
|
+
export declare function partOfType(message: UIMessage, type: string): Record<string, unknown> | undefined;
|
|
55
|
+
//# sourceMappingURL=test-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../src/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACV,KAAK,E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