stitchkit 0.68.10 → 0.69.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/README.md +30 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +155 -0
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-files.d.ts +3 -0
- package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-paths.d.ts +19 -0
- package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-search-patch.d.ts +3 -0
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-shell.d.ts +3 -0
- package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tools.d.ts +17 -0
- package/dist/agent-runtime/coding-tools.d.ts.map +1 -0
- package/dist/agent-runtime/compaction.d.ts +2 -0
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/contained-files.d.ts +31 -0
- package/dist/agent-runtime/contained-files.d.ts.map +1 -0
- package/dist/agent-runtime/control-schema.d.ts +1074 -0
- package/dist/agent-runtime/control-schema.d.ts.map +1 -0
- package/dist/agent-runtime/conversations.d.ts +128 -0
- package/dist/agent-runtime/conversations.d.ts.map +1 -0
- package/dist/agent-runtime/event-schema.d.ts +96 -0
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/harness-contract.d.ts +169 -0
- package/dist/agent-runtime/harness-contract.d.ts.map +1 -0
- package/dist/agent-runtime/harness-control.d.ts +25 -0
- package/dist/agent-runtime/harness-control.d.ts.map +1 -0
- package/dist/agent-runtime/harness-file-resources.d.ts +33 -0
- package/dist/agent-runtime/harness-file-resources.d.ts.map +1 -0
- package/dist/agent-runtime/harness-resources.d.ts +5 -0
- package/dist/agent-runtime/harness-resources.d.ts.map +1 -0
- package/dist/agent-runtime/harness.d.ts +12 -0
- package/dist/agent-runtime/harness.d.ts.map +1 -0
- package/dist/agent-runtime/history.d.ts +2 -0
- package/dist/agent-runtime/history.d.ts.map +1 -1
- package/dist/agent-runtime/models.d.ts +199 -0
- package/dist/agent-runtime/models.d.ts.map +1 -1
- package/dist/agent-runtime/prompt.d.ts +2 -0
- package/dist/agent-runtime/prompt.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +11 -3
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schemas.d.ts +49 -0
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite.d.ts +2 -0
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver.d.ts +61 -212
- package/dist/agent-runtime/store-driver.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +368 -1
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +12 -1
- package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-status.d.ts +8 -0
- package/dist/agent-runtime/terminal-status.d.ts.map +1 -1
- package/dist/agent-runtime-browser.d.ts +1 -0
- package/dist/agent-runtime-browser.d.ts.map +1 -1
- package/dist/agent-runtime-browser.js +217 -1
- package/dist/agent-runtime-coding-tools.d.ts +2 -0
- package/dist/agent-runtime-coding-tools.d.ts.map +1 -0
- package/dist/agent-runtime-coding-tools.js +706 -0
- package/dist/agent-runtime-harness.d.ts +2 -0
- package/dist/agent-runtime-harness.d.ts.map +1 -0
- package/dist/agent-runtime-harness.js +700 -0
- package/dist/agent-runtime-openrouter.d.ts +14 -1
- package/dist/agent-runtime-openrouter.d.ts.map +1 -1
- package/dist/agent-runtime-openrouter.js +211 -0
- package/dist/agent-runtime-sqlite-bun.js +4 -3
- package/dist/agent-runtime-sqlite-node.js +4 -3
- package/dist/agent-runtime.d.ts +5 -3
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/agent-runtime.js +106 -2580
- package/dist/application/diagnostic-journal-contract.d.ts +164 -0
- package/dist/application/diagnostic-journal-contract.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-manager.d.ts +12 -0
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-storage.d.ts +29 -0
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -0
- package/dist/application/diagnostic-journal.d.ts +11 -0
- package/dist/application/diagnostic-journal.d.ts.map +1 -0
- package/dist/application.d.ts +2 -0
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +561 -17
- package/dist/browser/socket-io.d.ts +8 -2
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/cli.js +8 -6
- package/dist/{index-8vpzxg55.js → index-10gbbbaa.js} +103 -2
- package/dist/index-3eqrkqhg.js +2565 -0
- package/dist/{index-hcx9yypn.js → index-444747ww.js} +7 -7
- package/dist/{index-557by2db.js → index-7b188kmz.js} +15 -0
- package/dist/{index-hxh98zbm.js → index-d1jsvkyk.js} +1 -1
- package/dist/index-es0h4w26.js +63 -0
- package/dist/{index-grgvpbch.js → index-gqdfpv4n.js} +4 -2
- package/dist/{index-bt5179zb.js → index-h7ctj1kp.js} +5 -3
- package/dist/{index-y2ctppmg.js → index-h8vn1jcr.js} +7 -73
- package/dist/{index-hqza5nde.js → index-hsabxjz0.js} +78 -77
- package/dist/index-kg9xx84n.js +73 -0
- package/dist/{index-hb0mncmj.js → index-kxxyvkka.js} +2 -2
- package/dist/{index-2t6zt5cg.js → index-mbxds404.js} +7 -5
- package/dist/{index-f24xg2cw.js → index-p1be103g.js} +1 -1
- package/dist/{index-xyvxez9r.js → index-q7gdep2c.js} +5 -5
- package/dist/{index-t23p2b68.js → index-t4dpby6e.js} +1 -1
- package/dist/index-tg3m2ec5.js +157 -0
- package/dist/index-v3dpzpjw.js +92 -0
- package/dist/{index-eqqyd9v8.js → index-wwst0td5.js} +2 -46
- package/dist/{index-ysphyxax.js → index-x1th9s8c.js} +23 -2
- package/dist/index-xxsq3ca1.js +51 -0
- package/dist/{index-22tjt2rk.js → index-zh459sfj.js} +1 -1
- package/dist/index.js +183 -11
- package/dist/internal/ai-sdk-typed.d.ts +14 -0
- package/dist/internal/ai-sdk-typed.d.ts.map +1 -0
- package/dist/node.js +6 -6
- package/dist/observability/index.js +4 -4
- package/dist/realtime/index.d.ts +1 -1
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/request.d.ts +30 -0
- package/dist/realtime/request.d.ts.map +1 -1
- package/dist/remote.js +6 -6
- package/dist/server/index.js +10 -10
- package/dist/testing.js +6 -6
- package/dist/tool-invoker.js +6 -5
- package/dist/tools.js +21 -17
- package/llms-full.txt +385 -24
- package/package.json +10 -2
- package/dist/{index-pgsyp3xh.js → index-x18ndp4p.js} +3 -3
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
contextContributionDelta,
|
|
3
3
|
mergeContextContribution,
|
|
4
4
|
prepareContextContribution
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-d1jsvkyk.js";
|
|
6
6
|
import {
|
|
7
7
|
base64UrlToBytes,
|
|
8
8
|
bytesToBase64Url,
|
|
9
9
|
isUnsafeKey,
|
|
10
10
|
safeJsonParse
|
|
11
|
-
} from "./index-
|
|
12
|
-
import {
|
|
13
|
-
isRecord
|
|
14
|
-
} from "./index-qyrqwr4c.js";
|
|
11
|
+
} from "./index-x18ndp4p.js";
|
|
15
12
|
import {
|
|
16
13
|
forbidden,
|
|
17
14
|
unauthorized
|
|
18
15
|
} from "./index-0w9abg87.js";
|
|
16
|
+
import {
|
|
17
|
+
isRecord
|
|
18
|
+
} from "./index-qyrqwr4c.js";
|
|
19
19
|
|
|
20
20
|
// src/server/middleware/cookies.ts
|
|
21
21
|
function parseCookies(header) {
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// src/agent-runtime/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var AgentModelCapabilitySchema = z.enum(["tools", "vision", "reasoning", "files"]);
|
|
4
|
+
var AgentModelDescriptorSchema = z.object({
|
|
5
|
+
provider: z.string().min(1),
|
|
6
|
+
modelId: z.string().min(1),
|
|
7
|
+
contextWindow: z.int().positive(),
|
|
8
|
+
capabilities: z.array(AgentModelCapabilitySchema),
|
|
9
|
+
observedAt: z.iso.datetime({ offset: true }).optional(),
|
|
10
|
+
source: z.string().min(1).optional(),
|
|
11
|
+
availability: z.enum(["available", "unavailable"]).optional()
|
|
12
|
+
});
|
|
13
|
+
var AgentModelRegistrySnapshotSchema = z.object({
|
|
14
|
+
schemaVersion: z.literal(1),
|
|
15
|
+
source: z.string().min(1),
|
|
16
|
+
observedAt: z.iso.datetime({ offset: true }),
|
|
17
|
+
models: z.record(z.string().min(1), AgentModelDescriptorSchema)
|
|
18
|
+
});
|
|
19
|
+
var AgentModelPriceSchema = z.object({
|
|
20
|
+
currency: z.string().length(3),
|
|
21
|
+
inputPerToken: z.string().regex(/^\d+(?:\.\d+)?$/).optional(),
|
|
22
|
+
outputPerToken: z.string().regex(/^\d+(?:\.\d+)?$/).optional()
|
|
23
|
+
}).strict();
|
|
24
|
+
var AgentModelMetricSchema = z.object({
|
|
25
|
+
metric: z.string().min(1),
|
|
26
|
+
value: z.number(),
|
|
27
|
+
unit: z.enum(["index", "elo", "percent", "milliseconds"]),
|
|
28
|
+
source: z.string().min(1),
|
|
29
|
+
observedAt: z.iso.datetime({ offset: true })
|
|
30
|
+
}).strict();
|
|
31
|
+
var AgentModelPopularitySchema = z.object({
|
|
32
|
+
rank: z.int().positive(),
|
|
33
|
+
window: z.literal("week"),
|
|
34
|
+
source: z.string().min(1),
|
|
35
|
+
observedAt: z.iso.datetime({ offset: true })
|
|
36
|
+
}).strict();
|
|
37
|
+
var AgentModelCatalogEntrySchema = z.object({
|
|
38
|
+
id: z.string().min(1),
|
|
39
|
+
name: z.string().min(1),
|
|
40
|
+
descriptor: AgentModelDescriptorSchema,
|
|
41
|
+
description: z.string().optional(),
|
|
42
|
+
price: AgentModelPriceSchema.optional(),
|
|
43
|
+
popularity: AgentModelPopularitySchema.optional(),
|
|
44
|
+
metrics: z.array(AgentModelMetricSchema)
|
|
45
|
+
}).strict();
|
|
46
|
+
var AgentModelCatalogSchema = z.object({
|
|
47
|
+
schemaVersion: z.literal(1),
|
|
48
|
+
source: z.string().min(1),
|
|
49
|
+
observedAt: z.iso.datetime({ offset: true }),
|
|
50
|
+
completeness: z.enum(["complete", "partial"]),
|
|
51
|
+
models: z.array(AgentModelCatalogEntrySchema),
|
|
52
|
+
diagnostics: z.array(z.string())
|
|
53
|
+
}).strict();
|
|
54
|
+
var AgentModelSelectionSchema = z.object({
|
|
55
|
+
modelId: z.string().min(1),
|
|
56
|
+
selectedAt: z.iso.datetime({ offset: true })
|
|
57
|
+
}).strict();
|
|
58
|
+
var AgentModelSearchInputSchema = z.object({ query: z.string().max(256).default(""), limit: z.int().positive().max(200) }).strict();
|
|
59
|
+
var AgentModelSearchResultSchema = z.object({
|
|
60
|
+
models: z.array(AgentModelCatalogEntrySchema),
|
|
61
|
+
total: z.int().nonnegative(),
|
|
62
|
+
truncated: z.boolean()
|
|
63
|
+
}).strict();
|
|
64
|
+
function searchAgentModelCatalog(catalog, rawInput) {
|
|
65
|
+
const input = AgentModelSearchInputSchema.parse(rawInput);
|
|
66
|
+
const terms = input.query.toLocaleLowerCase().trim().split(/\s+/).filter(Boolean);
|
|
67
|
+
const matches = catalog.models.filter((model) => {
|
|
68
|
+
const searchable = `${model.id}
|
|
69
|
+
${model.name}
|
|
70
|
+
${model.description ?? ""}`.toLocaleLowerCase();
|
|
71
|
+
return terms.every((term) => searchable.includes(term));
|
|
72
|
+
});
|
|
73
|
+
return AgentModelSearchResultSchema.parse({
|
|
74
|
+
models: matches.slice(0, input.limit),
|
|
75
|
+
total: matches.length,
|
|
76
|
+
truncated: matches.length > input.limit
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function createMemoryAgentModelSelectionStore() {
|
|
80
|
+
const selections = new Map;
|
|
81
|
+
return {
|
|
82
|
+
load: (conversationId) => selections.get(conversationId),
|
|
83
|
+
save(conversationId, rawSelection) {
|
|
84
|
+
selections.set(conversationId, AgentModelSelectionSchema.parse(rawSelection));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function defineModelRegistry(config) {
|
|
89
|
+
const descriptors = new Map;
|
|
90
|
+
for (const key in config.models) {
|
|
91
|
+
const declaration = config.models[key];
|
|
92
|
+
if (declaration)
|
|
93
|
+
descriptors.set(key, AgentModelDescriptorSchema.parse(declaration));
|
|
94
|
+
}
|
|
95
|
+
const descriptor = (key) => {
|
|
96
|
+
const found = descriptors.get(key);
|
|
97
|
+
if (!found)
|
|
98
|
+
throw new Error(`Unknown agent model: ${key}`);
|
|
99
|
+
return found;
|
|
100
|
+
};
|
|
101
|
+
const supports = (key, capabilities) => {
|
|
102
|
+
const available = new Set(descriptor(key).capabilities);
|
|
103
|
+
return capabilities.every((capability) => available.has(capability));
|
|
104
|
+
};
|
|
105
|
+
const preflight = (key, required = []) => {
|
|
106
|
+
const selected = descriptor(key);
|
|
107
|
+
if (selected.availability === "unavailable") {
|
|
108
|
+
throw new Error(`Agent model ${key} is unavailable`);
|
|
109
|
+
}
|
|
110
|
+
if (!supports(key, required)) {
|
|
111
|
+
throw new Error(`Agent model ${key} does not satisfy required capabilities`);
|
|
112
|
+
}
|
|
113
|
+
if (!config.providers[selected.provider]) {
|
|
114
|
+
throw new Error(`Unknown agent model provider: ${selected.provider}`);
|
|
115
|
+
}
|
|
116
|
+
return selected;
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
keys: () => [...descriptors.keys()],
|
|
120
|
+
descriptor,
|
|
121
|
+
supports,
|
|
122
|
+
preflight,
|
|
123
|
+
resolve(key, required = []) {
|
|
124
|
+
const selected = preflight(key, required);
|
|
125
|
+
const provider = config.providers[selected.provider];
|
|
126
|
+
if (!provider)
|
|
127
|
+
throw new Error(`Unknown agent model provider: ${selected.provider}`);
|
|
128
|
+
return {
|
|
129
|
+
descriptor: selected,
|
|
130
|
+
model: provider.create(selected.modelId),
|
|
131
|
+
...provider.normalizeUsage && { normalizeUsage: provider.normalizeUsage }
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
snapshot(input) {
|
|
135
|
+
return AgentModelRegistrySnapshotSchema.parse({
|
|
136
|
+
schemaVersion: 1,
|
|
137
|
+
source: input.source,
|
|
138
|
+
observedAt: input.observedAt,
|
|
139
|
+
models: Object.fromEntries(descriptors.entries())
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function validateAgentModelSnapshot(input, policy) {
|
|
145
|
+
if (!Number.isSafeInteger(policy.maxAgeMs) || policy.maxAgeMs < 0) {
|
|
146
|
+
throw new TypeError("maxAgeMs must be a non-negative safe integer");
|
|
147
|
+
}
|
|
148
|
+
const snapshot = AgentModelRegistrySnapshotSchema.parse(input);
|
|
149
|
+
const now = policy.now?.() ?? new Date;
|
|
150
|
+
const age = now.getTime() - new Date(snapshot.observedAt).getTime();
|
|
151
|
+
if (age < 0 || age > policy.maxAgeMs) {
|
|
152
|
+
throw new Error(`Agent model snapshot from ${snapshot.source} is stale`);
|
|
153
|
+
}
|
|
154
|
+
return snapshot;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export { AgentModelCapabilitySchema, AgentModelDescriptorSchema, AgentModelRegistrySnapshotSchema, AgentModelPriceSchema, AgentModelMetricSchema, AgentModelPopularitySchema, AgentModelCatalogEntrySchema, AgentModelCatalogSchema, AgentModelSelectionSchema, AgentModelSearchInputSchema, AgentModelSearchResultSchema, searchAgentModelCatalog, createMemoryAgentModelSelectionStore, defineModelRegistry, validateAgentModelSnapshot };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// src/agent-runtime/contained-files.ts
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { lstat, open, readdir, realpath } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
async function readContainedUtf8File(absolute, maxBytes) {
|
|
6
|
+
const handle = await open(absolute, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
7
|
+
try {
|
|
8
|
+
const metadata = await handle.stat();
|
|
9
|
+
if (!metadata.isFile())
|
|
10
|
+
throw new Error("Contained path is not a regular file");
|
|
11
|
+
if (metadata.size > maxBytes)
|
|
12
|
+
throw new Error("Contained file exceeds byte budget");
|
|
13
|
+
const buffer = Buffer.alloc(metadata.size);
|
|
14
|
+
let offset = 0;
|
|
15
|
+
while (offset < buffer.byteLength) {
|
|
16
|
+
const { bytesRead } = await handle.read(buffer, offset, buffer.byteLength - offset, offset);
|
|
17
|
+
if (bytesRead === 0)
|
|
18
|
+
break;
|
|
19
|
+
offset += bytesRead;
|
|
20
|
+
}
|
|
21
|
+
if (offset !== metadata.size)
|
|
22
|
+
throw new Error("Contained file changed while being read");
|
|
23
|
+
return {
|
|
24
|
+
text: new TextDecoder("utf-8", { fatal: true }).decode(buffer),
|
|
25
|
+
bytes: offset,
|
|
26
|
+
mode: metadata.mode
|
|
27
|
+
};
|
|
28
|
+
} finally {
|
|
29
|
+
await handle.close();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function inside(root, target) {
|
|
33
|
+
const relative = path.relative(root, target);
|
|
34
|
+
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
35
|
+
}
|
|
36
|
+
async function walkContainedFiles(input) {
|
|
37
|
+
const scan = await scanContainedFiles({ ...input, symlinks: "refuse" });
|
|
38
|
+
if (scan.truncated)
|
|
39
|
+
throw new Error("Contained file traversal exceeded its bounds");
|
|
40
|
+
return scan.files;
|
|
41
|
+
}
|
|
42
|
+
async function scanContainedFiles(input) {
|
|
43
|
+
const root = await realpath(input.root);
|
|
44
|
+
const files = [];
|
|
45
|
+
let truncated = false;
|
|
46
|
+
let skippedDirectories = 0;
|
|
47
|
+
let skippedSymlinks = 0;
|
|
48
|
+
const visit = async (directory, depth) => {
|
|
49
|
+
if (truncated)
|
|
50
|
+
return;
|
|
51
|
+
if (depth > input.maxDepth) {
|
|
52
|
+
truncated = true;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
56
|
+
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
const absolute = path.join(directory, entry.name);
|
|
59
|
+
const metadata = await lstat(absolute);
|
|
60
|
+
if (metadata.isSymbolicLink()) {
|
|
61
|
+
if (input.symlinks === "refuse") {
|
|
62
|
+
throw new Error(`Contained file traversal refuses symlink: ${path.relative(root, absolute)}`);
|
|
63
|
+
}
|
|
64
|
+
skippedSymlinks += 1;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (metadata.isDirectory()) {
|
|
68
|
+
const relative = path.relative(root, absolute);
|
|
69
|
+
if (input.excludeDirectory?.(relative)) {
|
|
70
|
+
skippedDirectories += 1;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
await visit(absolute, depth + 1);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (!metadata.isFile())
|
|
77
|
+
continue;
|
|
78
|
+
const resolved = await realpath(absolute);
|
|
79
|
+
if (!inside(root, resolved))
|
|
80
|
+
throw new Error("Contained file traversal escaped root");
|
|
81
|
+
if (files.length >= input.maxFiles) {
|
|
82
|
+
truncated = true;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
files.push({ absolute: resolved, relative: path.relative(root, resolved) });
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
await visit(root, 0);
|
|
89
|
+
return { files, truncated, skippedDirectories, skippedSymlinks };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { readContainedUtf8File, walkContainedFiles, scanContainedFiles };
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./index-y2ctppmg.js";
|
|
4
|
-
import {
|
|
5
|
-
projectRuntimeTool,
|
|
6
|
-
projectToolSurface
|
|
2
|
+
projectRuntimeTool
|
|
7
3
|
} from "./index-22by16v6.js";
|
|
8
4
|
|
|
9
5
|
// src/tools/runtime-tool.ts
|
|
@@ -87,44 +83,4 @@ function runtimeToolMountable(definition, assertName = true) {
|
|
|
87
83
|
};
|
|
88
84
|
}
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
function collectToolSurface({
|
|
92
|
-
surface,
|
|
93
|
-
transport,
|
|
94
|
-
assertUniqueNames = true,
|
|
95
|
-
...collectConfig
|
|
96
|
-
}) {
|
|
97
|
-
const entries = [];
|
|
98
|
-
const append = (entry) => {
|
|
99
|
-
entries.push(entry);
|
|
100
|
-
};
|
|
101
|
-
for (const projected of projectToolSurface(surface, transport, {
|
|
102
|
-
extend: collectConfig.extend,
|
|
103
|
-
flattenUnionInput: collectConfig.flattenUnionInput,
|
|
104
|
-
assertNames: collectConfig.assertNames,
|
|
105
|
-
assertUniqueNames
|
|
106
|
-
})) {
|
|
107
|
-
if (projected.kind === "contract") {
|
|
108
|
-
const mountable = contractToolMountable(projected, collectConfig.extend);
|
|
109
|
-
append({
|
|
110
|
-
kind: "contract",
|
|
111
|
-
service: projected.serviceName,
|
|
112
|
-
action: mountable.method.key,
|
|
113
|
-
mountable,
|
|
114
|
-
projection: projected
|
|
115
|
-
});
|
|
116
|
-
} else {
|
|
117
|
-
append({
|
|
118
|
-
kind: "runtime",
|
|
119
|
-
service: projected.serviceName,
|
|
120
|
-
action: projected.action,
|
|
121
|
-
mountable: runtimeToolMountable(projected.source, false),
|
|
122
|
-
definition: projected.source,
|
|
123
|
-
projection: projected
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return entries;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export { defineRuntimeTool, createRuntimeToolFactory, collectToolSurface };
|
|
86
|
+
export { defineRuntimeTool, createRuntimeToolFactory, runtimeToolMountable };
|
|
@@ -44,6 +44,19 @@ var AgentToolResultPartSchema = z.object({
|
|
|
44
44
|
outcome: z.enum(["success", "error", "interrupted"]),
|
|
45
45
|
output: z.json().optional()
|
|
46
46
|
});
|
|
47
|
+
var AgentToolApprovalRequestPartSchema = z.object({
|
|
48
|
+
type: z.literal("tool-approval-request"),
|
|
49
|
+
approvalId: z.string().min(1),
|
|
50
|
+
callId: z.string().min(1),
|
|
51
|
+
isAutomatic: z.boolean().optional(),
|
|
52
|
+
signature: z.string().min(1).optional()
|
|
53
|
+
});
|
|
54
|
+
var AgentToolApprovalResponsePartSchema = z.object({
|
|
55
|
+
type: z.literal("tool-approval-response"),
|
|
56
|
+
approvalId: z.string().min(1),
|
|
57
|
+
approved: z.boolean(),
|
|
58
|
+
reason: z.string().min(1).optional()
|
|
59
|
+
});
|
|
47
60
|
var AgentOpaquePartSchema = z.object({
|
|
48
61
|
type: z.literal("provider"),
|
|
49
62
|
envelope: AgentProviderEnvelopeSchema
|
|
@@ -59,10 +72,18 @@ var AgentMessagePartSchema = z.discriminatedUnion("type", [
|
|
|
59
72
|
AgentSourcePartSchema,
|
|
60
73
|
AgentToolCallPartSchema,
|
|
61
74
|
AgentToolResultPartSchema,
|
|
75
|
+
AgentToolApprovalRequestPartSchema,
|
|
76
|
+
AgentToolApprovalResponsePartSchema,
|
|
62
77
|
AgentOpaquePartSchema,
|
|
63
78
|
AgentControlPartSchema
|
|
64
79
|
]);
|
|
65
|
-
var AgentMessageRoleSchema = z.enum([
|
|
80
|
+
var AgentMessageRoleSchema = z.enum([
|
|
81
|
+
"user",
|
|
82
|
+
"assistant",
|
|
83
|
+
"tool",
|
|
84
|
+
"system",
|
|
85
|
+
"summary"
|
|
86
|
+
]);
|
|
66
87
|
var AgentMessageStatusSchema = z.enum([
|
|
67
88
|
"committed",
|
|
68
89
|
"streaming",
|
|
@@ -256,4 +277,4 @@ var AgentRunMetricsSchema = z.object({
|
|
|
256
277
|
ttftMs: z.number().nonnegative().optional()
|
|
257
278
|
});
|
|
258
279
|
|
|
259
|
-
export { AgentRecordIdSchema, AgentRecordVersionSchema, AgentTimestampSchema, AgentJsonObjectSchema, AgentProviderEnvelopeSchema, AgentTextPartSchema, AgentReasoningPartSchema, AgentFilePartSchema, AgentSourcePartSchema, AgentToolCallPartSchema, AgentToolResultPartSchema, AgentOpaquePartSchema, AgentControlPartSchema, AgentMessagePartSchema, AgentMessageRoleSchema, AgentMessageStatusSchema, AgentMessageSchema, AgentAssistantPlaceholderSchema, AgentRunStateSchema, AgentRunQueuePrioritySchema, AgentTerminalReasonSchema, runStateForTerminalReason, AgentProvenanceSchema, AgentUsageValueSchema, AgentCostValueSchema, AgentUsageSchema, AgentRunSchema, AgentSnapshotSchema, AgentRunMetricsSchema };
|
|
280
|
+
export { AgentRecordIdSchema, AgentRecordVersionSchema, AgentTimestampSchema, AgentJsonObjectSchema, AgentProviderEnvelopeSchema, AgentTextPartSchema, AgentReasoningPartSchema, AgentFilePartSchema, AgentSourcePartSchema, AgentToolCallPartSchema, AgentToolResultPartSchema, AgentToolApprovalRequestPartSchema, AgentToolApprovalResponsePartSchema, AgentOpaquePartSchema, AgentControlPartSchema, AgentMessagePartSchema, AgentMessageRoleSchema, AgentMessageStatusSchema, AgentMessageSchema, AgentAssistantPlaceholderSchema, AgentRunStateSchema, AgentRunQueuePrioritySchema, AgentTerminalReasonSchema, runStateForTerminalReason, AgentProvenanceSchema, AgentUsageValueSchema, AgentCostValueSchema, AgentUsageSchema, AgentRunSchema, AgentSnapshotSchema, AgentRunMetricsSchema };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runtimeToolMountable
|
|
3
|
+
} from "./index-wwst0td5.js";
|
|
4
|
+
import {
|
|
5
|
+
contractToolMountable
|
|
6
|
+
} from "./index-kg9xx84n.js";
|
|
7
|
+
import {
|
|
8
|
+
projectToolSurface
|
|
9
|
+
} from "./index-22by16v6.js";
|
|
10
|
+
|
|
11
|
+
// src/tools/surface.ts
|
|
12
|
+
function collectToolSurface({
|
|
13
|
+
surface,
|
|
14
|
+
transport,
|
|
15
|
+
assertUniqueNames = true,
|
|
16
|
+
...collectConfig
|
|
17
|
+
}) {
|
|
18
|
+
const entries = [];
|
|
19
|
+
const append = (entry) => {
|
|
20
|
+
entries.push(entry);
|
|
21
|
+
};
|
|
22
|
+
for (const projected of projectToolSurface(surface, transport, {
|
|
23
|
+
extend: collectConfig.extend,
|
|
24
|
+
flattenUnionInput: collectConfig.flattenUnionInput,
|
|
25
|
+
assertNames: collectConfig.assertNames,
|
|
26
|
+
assertUniqueNames
|
|
27
|
+
})) {
|
|
28
|
+
if (projected.kind === "contract") {
|
|
29
|
+
const mountable = contractToolMountable(projected, collectConfig.extend);
|
|
30
|
+
append({
|
|
31
|
+
kind: "contract",
|
|
32
|
+
service: projected.serviceName,
|
|
33
|
+
action: mountable.method.key,
|
|
34
|
+
mountable,
|
|
35
|
+
projection: projected
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
append({
|
|
39
|
+
kind: "runtime",
|
|
40
|
+
service: projected.serviceName,
|
|
41
|
+
action: projected.action,
|
|
42
|
+
mountable: runtimeToolMountable(projected.source, false),
|
|
43
|
+
definition: projected.source,
|
|
44
|
+
projection: projected
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return entries;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { collectToolSurface };
|