stitchkit 0.111.1 → 0.111.3
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 +17 -0
- package/dist/application/diagnostic-journal-contract.d.ts +1 -1
- package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
- package/dist/entrypoints/agent-runtime/harness.js +6 -6
- package/dist/entrypoints/agent-runtime/sandbox.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +5 -5
- package/dist/entrypoints/agent-runtime/sqlite/node.js +5 -5
- package/dist/entrypoints/agent-runtime/testing.js +5 -5
- package/dist/entrypoints/agent-runtime.js +12 -12
- package/dist/entrypoints/application/diagnostic-journal.js +1 -1
- package/dist/entrypoints/application/directory-inbox.js +3 -3
- package/dist/entrypoints/cli/publish.js +2 -2
- package/dist/entrypoints/cli.js +8 -8
- package/dist/entrypoints/files.js +2 -2
- package/dist/entrypoints/process.d.ts +1 -0
- package/dist/entrypoints/process.d.ts.map +1 -1
- package/dist/entrypoints/process.js +76 -1
- package/dist/entrypoints/server.js +3 -3
- package/dist/entrypoints/telegram.js +1 -1
- package/dist/entrypoints/testing.js +1 -1
- package/dist/entrypoints/tools/connections.js +6 -4
- package/dist/entrypoints/tools/contract.js +2 -2
- package/dist/entrypoints/tools/invoker.js +6 -6
- package/dist/entrypoints/tools/mcp.js +8 -8
- package/dist/entrypoints/tools.js +11 -11
- package/dist/{index-mha6b4vk.js → index-02h0dfpr.js} +12 -5
- package/dist/{index-0z3kfphz.js → index-38gvr73z.js} +1 -1
- package/dist/{index-8jv0trhg.js → index-5as18gs2.js} +1 -1
- package/dist/{index-t2bsd0hm.js → index-5v5a9k2n.js} +92 -43
- package/dist/{index-c5374vpt.js → index-651xsm48.js} +4 -4
- package/dist/{index-w9mqgnz9.js → index-6b3pcq5z.js} +1 -1
- package/dist/{index-7c046kxr.js → index-c7h371gr.js} +4 -4
- package/dist/{index-mnk5vgdr.js → index-d4cnhfdn.js} +1 -1
- package/dist/{index-t5sjh517.js → index-epmnrnth.js} +18 -1
- package/dist/{index-636mggad.js → index-ff3agzaf.js} +1 -1
- package/dist/{index-7c957abz.js → index-fh2ht88b.js} +1 -1
- package/dist/{index-q6crhe1n.js → index-h7accrrv.js} +19 -6
- package/dist/{index-0d8m0kee.js → index-hvg9hctd.js} +3 -3
- package/dist/{index-nx49x0tw.js → index-hy802jnr.js} +1 -1
- package/dist/{index-dd1z5kxb.js → index-jfk93gja.js} +3 -3
- package/dist/{index-v2eyj2ws.js → index-jprxv2an.js} +6 -6
- package/dist/{index-cykxpxz5.js → index-jy9wq8tp.js} +1 -1
- package/dist/{index-ey15wx6j.js → index-n0adphfg.js} +1 -1
- package/dist/{index-ghwntn9n.js → index-vqdjym30.js} +2 -2
- package/dist/internal/exclusive-lock-owner.d.ts +53 -0
- package/dist/internal/exclusive-lock-owner.d.ts.map +1 -0
- package/dist/internal/exclusive-lock.d.ts +1 -28
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/open-descriptors.d.ts +18 -0
- package/dist/internal/open-descriptors.d.ts.map +1 -0
- package/dist/internal/with-exclusive-lock.d.ts +2 -12
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
- package/dist/process/stream.d.ts +27 -0
- package/dist/process/stream.d.ts.map +1 -0
- package/dist/tools/connections/runtime.d.ts +1 -1
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/execute-args.d.ts.map +1 -1
- package/dist/tools/schema/flatten-join.d.ts.map +1 -1
- package/dist/tools/schema/json-schema-origin.d.ts +17 -0
- package/dist/tools/schema/json-schema-origin.d.ts.map +1 -1
- package/llms/cli.2.txt +10 -0
- package/llms/files.txt +1 -1
- package/llms/process.2.txt +32 -0
- package/llms/process.txt +36 -23
- package/llms/tools-connections.txt +1 -1
- package/llms/tools.txt +8 -3
- package/llms-full.txt +54 -5
- package/llms.txt +5 -5
- package/package.json +1 -1
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
normalizeError2
|
|
11
11
|
} from "../index-fynr93w4.js";
|
|
12
|
-
import"../index-
|
|
12
|
+
import"../index-epmnrnth.js";
|
|
13
13
|
import {
|
|
14
14
|
coerceJsonArgs2
|
|
15
|
-
} from "../index-
|
|
15
|
+
} from "../index-jy9wq8tp.js";
|
|
16
16
|
import"../index-ct75c3at.js";
|
|
17
17
|
import {
|
|
18
18
|
assertToolName,
|
|
@@ -21,19 +21,19 @@ import {
|
|
|
21
21
|
findNonPortableFormats2,
|
|
22
22
|
flattenToolJsonSchema2,
|
|
23
23
|
findUntypedProperties2
|
|
24
|
-
} from "../index-
|
|
24
|
+
} from "../index-h7accrrv.js";
|
|
25
25
|
import {
|
|
26
26
|
ToolExecutionControlError2,
|
|
27
27
|
isToolExecutionControlError2
|
|
28
|
-
} from "../index-
|
|
28
|
+
} from "../index-02h0dfpr.js";
|
|
29
29
|
import {
|
|
30
30
|
collectTools2
|
|
31
|
-
} from "../index-
|
|
31
|
+
} from "../index-vqdjym30.js";
|
|
32
32
|
import {
|
|
33
33
|
mountAgent2,
|
|
34
34
|
describeToolCatalog2,
|
|
35
35
|
buildToolManifest2
|
|
36
|
-
} from "../index-
|
|
36
|
+
} from "../index-c7h371gr.js";
|
|
37
37
|
import"../index-m38ej7e5.js";
|
|
38
38
|
import {
|
|
39
39
|
ALL_TRANSPORTS2,
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
createMcpHttpRoute2,
|
|
61
61
|
createStdioMcpServer2,
|
|
62
62
|
bindStdioProcessSignals2
|
|
63
|
-
} from "../index-
|
|
63
|
+
} from "../index-651xsm48.js";
|
|
64
64
|
import {
|
|
65
65
|
AsyncOperationCancelResultSchema2,
|
|
66
66
|
createAsyncOperationSnapshotSchema2,
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
WaitTimeoutError,
|
|
75
75
|
runWaitOperation,
|
|
76
76
|
createCli2
|
|
77
|
-
} from "../index-
|
|
77
|
+
} from "../index-jprxv2an.js";
|
|
78
78
|
import {
|
|
79
79
|
ManagedFilePathSchema2,
|
|
80
80
|
ManagedFileRefSchema2
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
} from "../index-pzw0fpek.js";
|
|
90
90
|
import {
|
|
91
91
|
createToolInvoker2
|
|
92
|
-
} from "../index-
|
|
92
|
+
} from "../index-jfk93gja.js";
|
|
93
93
|
import {
|
|
94
94
|
ManagedFileError2
|
|
95
95
|
} from "../index-2f9r0jgr.js";
|
|
@@ -111,14 +111,14 @@ import {
|
|
|
111
111
|
} from "../index-yk4g8805.js";
|
|
112
112
|
import {
|
|
113
113
|
collectToolSurface
|
|
114
|
-
} from "../index-
|
|
114
|
+
} from "../index-hvg9hctd.js";
|
|
115
115
|
import {
|
|
116
116
|
getTraceId2
|
|
117
117
|
} from "../index-r6v4mc67.js";
|
|
118
118
|
import {
|
|
119
119
|
defineRuntimeTool2,
|
|
120
120
|
createRuntimeToolFactory2
|
|
121
|
-
} from "../index-
|
|
121
|
+
} from "../index-ff3agzaf.js";
|
|
122
122
|
import {
|
|
123
123
|
formatZodError2
|
|
124
124
|
} from "../index-1eeqpadm.js";
|
|
@@ -2,14 +2,17 @@ import {
|
|
|
2
2
|
normalizeError2,
|
|
3
3
|
validateDeclaredOutput
|
|
4
4
|
} from "./index-fynr93w4.js";
|
|
5
|
+
import {
|
|
6
|
+
localVerdict
|
|
7
|
+
} from "./index-epmnrnth.js";
|
|
5
8
|
import {
|
|
6
9
|
coerceJsonArgs2
|
|
7
|
-
} from "./index-
|
|
10
|
+
} from "./index-jy9wq8tp.js";
|
|
8
11
|
import {
|
|
9
12
|
applyToolViewDefaults,
|
|
10
13
|
projectToolView,
|
|
11
14
|
objectShapeKeys
|
|
12
|
-
} from "./index-
|
|
15
|
+
} from "./index-h7accrrv.js";
|
|
13
16
|
import {
|
|
14
17
|
runWithRequestContext2,
|
|
15
18
|
getRequestContext2
|
|
@@ -91,10 +94,14 @@ function parseToolCallArguments(method, callArgs, {
|
|
|
91
94
|
} catch (err) {
|
|
92
95
|
return { ok: false, message: "Invalid input", thrown: err };
|
|
93
96
|
}
|
|
94
|
-
if (
|
|
95
|
-
|
|
97
|
+
if (result.success)
|
|
98
|
+
input = result.data;
|
|
99
|
+
else {
|
|
100
|
+
const refused = localVerdict(method.inputSchema, result.error);
|
|
101
|
+
if (refused)
|
|
102
|
+
return { ok: false, message: `Invalid input: ${formatZodError2(refused)}` };
|
|
103
|
+
input = inputArgs;
|
|
96
104
|
}
|
|
97
|
-
input = result.data;
|
|
98
105
|
}
|
|
99
106
|
return { ok: true, params, input };
|
|
100
107
|
}
|
|
@@ -18,11 +18,93 @@ import {
|
|
|
18
18
|
|
|
19
19
|
// src/internal/exclusive-lock.ts
|
|
20
20
|
import { randomUUID } from "node:crypto";
|
|
21
|
-
import { lstat, open, readdir, unlink } from "node:fs/promises";
|
|
22
|
-
import { hostname } from "node:os";
|
|
21
|
+
import { lstat, open as open2, readdir as readdir2, unlink } from "node:fs/promises";
|
|
22
|
+
import { hostname as hostname2 } from "node:os";
|
|
23
23
|
import { dirname, join } from "node:path";
|
|
24
|
+
|
|
25
|
+
// src/internal/exclusive-lock-owner.ts
|
|
26
|
+
import { hostname } from "node:os";
|
|
24
27
|
import { z } from "zod";
|
|
25
28
|
|
|
29
|
+
// src/internal/open-descriptors.ts
|
|
30
|
+
import { constants, fstatSync } from "node:fs";
|
|
31
|
+
import { open, readdir } from "node:fs/promises";
|
|
32
|
+
var DESCRIPTOR_DIRECTORY = "/dev/fd";
|
|
33
|
+
async function holdsOpenDescriptor(path, file, descriptorDirectory = DESCRIPTOR_DIRECTORY) {
|
|
34
|
+
const probe = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK).catch(() => null);
|
|
35
|
+
if (!probe)
|
|
36
|
+
return null;
|
|
37
|
+
try {
|
|
38
|
+
const opened = await probe.stat();
|
|
39
|
+
if (!opened.isFile() || opened.ino !== file.ino || opened.dev !== file.dev)
|
|
40
|
+
return null;
|
|
41
|
+
let names;
|
|
42
|
+
try {
|
|
43
|
+
names = await readdir(descriptorDirectory);
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
let listedProbe = false;
|
|
48
|
+
for (const name of names) {
|
|
49
|
+
const descriptor = Number(name);
|
|
50
|
+
if (!Number.isInteger(descriptor) || descriptor < 0)
|
|
51
|
+
continue;
|
|
52
|
+
if (descriptor === probe.fd) {
|
|
53
|
+
listedProbe = true;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const info = fstatSync(descriptor);
|
|
58
|
+
if (info.ino === file.ino && info.dev === file.dev)
|
|
59
|
+
return true;
|
|
60
|
+
} catch {}
|
|
61
|
+
}
|
|
62
|
+
return listedProbe ? false : null;
|
|
63
|
+
} finally {
|
|
64
|
+
await probe.close();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/internal/exclusive-lock-owner.ts
|
|
69
|
+
var ExclusiveLockOwnerSchema = z.object({
|
|
70
|
+
pid: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
71
|
+
host: z.string().min(1),
|
|
72
|
+
acquiredAt: z.string(),
|
|
73
|
+
machine: z.string().min(1).optional().catch(undefined),
|
|
74
|
+
process: ProcessInstanceSchema2.nullable().optional().catch(null)
|
|
75
|
+
});
|
|
76
|
+
function readOwner(text) {
|
|
77
|
+
let parsed;
|
|
78
|
+
try {
|
|
79
|
+
parsed = JSON.parse(text);
|
|
80
|
+
} catch {
|
|
81
|
+
return { owner: undefined, ownerless: true };
|
|
82
|
+
}
|
|
83
|
+
const owner = ExclusiveLockOwnerSchema.safeParse(parsed);
|
|
84
|
+
if (owner.success)
|
|
85
|
+
return { owner: owner.data, ownerless: false };
|
|
86
|
+
const ownerlike = isRecord(parsed) && ["pid", "token", "host", "machine", "process", "acquiredAt"].some((key) => Object.hasOwn(parsed, key));
|
|
87
|
+
return { owner: undefined, ownerless: !ownerlike };
|
|
88
|
+
}
|
|
89
|
+
function attribute(owner, identity) {
|
|
90
|
+
if (identity !== null && owner.machine !== undefined) {
|
|
91
|
+
return owner.machine === identity ? "this-machine" : "another-machine";
|
|
92
|
+
}
|
|
93
|
+
return owner.host === hostname() ? "this-machine" : "unattributable";
|
|
94
|
+
}
|
|
95
|
+
async function diagnose(lock, declaredIdentity) {
|
|
96
|
+
const owner = lock?.owner;
|
|
97
|
+
if (!lock || !owner)
|
|
98
|
+
return { attribution: "unattributable", liveness: "not-probed", owner: null };
|
|
99
|
+
const attribution = attribute(owner, await machineIdentity(declaredIdentity));
|
|
100
|
+
if (attribution !== "this-machine")
|
|
101
|
+
return { attribution, liveness: "not-probed", owner };
|
|
102
|
+
const evidence = await probeProcessOwner2(owner.pid, owner.process);
|
|
103
|
+
if (evidence.identity === "matched" && owner.pid === process.pid && await holdsOpenDescriptor(lock.path, lock) === false)
|
|
104
|
+
return { attribution, liveness: "gone", identity: "descriptor-closed", owner };
|
|
105
|
+
return { attribution, ...evidence, owner };
|
|
106
|
+
}
|
|
107
|
+
|
|
26
108
|
// src/internal/exclusive-lock-read.ts
|
|
27
109
|
var OWNER_RECORD_BYTES = 16 * 1024;
|
|
28
110
|
|
|
@@ -60,49 +142,15 @@ async function readLockRecord(path, {
|
|
|
60
142
|
}
|
|
61
143
|
|
|
62
144
|
// src/internal/exclusive-lock.ts
|
|
63
|
-
var ExclusiveLockOwnerSchema = z.object({
|
|
64
|
-
pid: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
65
|
-
host: z.string().min(1),
|
|
66
|
-
acquiredAt: z.string(),
|
|
67
|
-
machine: z.string().min(1).optional().catch(undefined),
|
|
68
|
-
process: ProcessInstanceSchema2.nullable().optional().catch(null)
|
|
69
|
-
});
|
|
70
145
|
function isCode(error, code) {
|
|
71
146
|
return isRecord(error) && error.code === code;
|
|
72
147
|
}
|
|
73
|
-
function readOwner(text) {
|
|
74
|
-
let parsed;
|
|
75
|
-
try {
|
|
76
|
-
parsed = JSON.parse(text);
|
|
77
|
-
} catch {
|
|
78
|
-
return { owner: undefined, ownerless: true };
|
|
79
|
-
}
|
|
80
|
-
const owner = ExclusiveLockOwnerSchema.safeParse(parsed);
|
|
81
|
-
if (owner.success)
|
|
82
|
-
return { owner: owner.data, ownerless: false };
|
|
83
|
-
const ownerlike = isRecord(parsed) && ["pid", "token", "host", "machine", "process", "acquiredAt"].some((key) => Object.hasOwn(parsed, key));
|
|
84
|
-
return { owner: undefined, ownerless: !ownerlike };
|
|
85
|
-
}
|
|
86
|
-
function attribute(owner, identity) {
|
|
87
|
-
if (identity !== null && owner.machine !== undefined) {
|
|
88
|
-
return owner.machine === identity ? "this-machine" : "another-machine";
|
|
89
|
-
}
|
|
90
|
-
return owner.host === hostname() ? "this-machine" : "unattributable";
|
|
91
|
-
}
|
|
92
|
-
async function diagnose(owner, declaredIdentity) {
|
|
93
|
-
if (!owner)
|
|
94
|
-
return { attribution: "unattributable", liveness: "not-probed", owner: null };
|
|
95
|
-
const attribution = attribute(owner, await machineIdentity(declaredIdentity));
|
|
96
|
-
if (attribution !== "this-machine")
|
|
97
|
-
return { attribution, liveness: "not-probed", owner };
|
|
98
|
-
return { attribution, ...await probeProcessOwner2(owner.pid, owner.process), owner };
|
|
99
|
-
}
|
|
100
148
|
var MAX_RECLAIM_DEPTH = 16;
|
|
101
149
|
var STALE_GUARD_GRACE_MS = 5000;
|
|
102
150
|
var STAGED_NAME = /^\.lock-[0-9a-f-]{36}\.tmp$/;
|
|
103
151
|
async function stagedSibling(path, ino, dev) {
|
|
104
152
|
const directory = dirname(path);
|
|
105
|
-
for (const name of await
|
|
153
|
+
for (const name of await readdir2(directory)) {
|
|
106
154
|
if (!STAGED_NAME.test(name))
|
|
107
155
|
continue;
|
|
108
156
|
const candidate = join(directory, name);
|
|
@@ -130,6 +178,7 @@ async function readLockFile(path, onFailure, signal) {
|
|
|
130
178
|
record = await readLockRecord(path, { signal, singleLink: false });
|
|
131
179
|
}
|
|
132
180
|
return {
|
|
181
|
+
path,
|
|
133
182
|
...readOwner(record.text),
|
|
134
183
|
ino: record.info.ino,
|
|
135
184
|
dev: record.info.dev,
|
|
@@ -143,14 +192,14 @@ async function readLockFile(path, onFailure, signal) {
|
|
|
143
192
|
}
|
|
144
193
|
}
|
|
145
194
|
async function sweepStagedLocks(directory, machine, signal) {
|
|
146
|
-
for (const name of await
|
|
195
|
+
for (const name of await readdir2(directory).catch(() => [])) {
|
|
147
196
|
if (!STAGED_NAME.test(name))
|
|
148
197
|
continue;
|
|
149
198
|
const candidate = join(directory, name);
|
|
150
199
|
const state = await readLockFile(candidate, undefined, signal);
|
|
151
200
|
if (!state?.owner)
|
|
152
201
|
continue;
|
|
153
|
-
if ((await diagnose(state
|
|
202
|
+
if ((await diagnose(state, machine)).liveness !== "gone")
|
|
154
203
|
continue;
|
|
155
204
|
await unlinkIfSame(candidate, state.ino, state.dev, state.stagedName === undefined ? 1 : 2);
|
|
156
205
|
}
|
|
@@ -172,14 +221,14 @@ async function createOwned(path, options, reclaimed) {
|
|
|
172
221
|
const owner = {
|
|
173
222
|
pid: process.pid,
|
|
174
223
|
process: instance,
|
|
175
|
-
host:
|
|
224
|
+
host: hostname2(),
|
|
176
225
|
acquiredAt: new Date().toISOString(),
|
|
177
226
|
...identity !== null && { machine: identity }
|
|
178
227
|
};
|
|
179
228
|
const ownedRecord = `${JSON.stringify(owner)}
|
|
180
229
|
`;
|
|
181
230
|
const staged = join(dirname(path), `.lock-${randomUUID()}.tmp`);
|
|
182
|
-
const handle = await
|
|
231
|
+
const handle = await open2(staged, "wx", options.mode);
|
|
183
232
|
let ino;
|
|
184
233
|
let dev;
|
|
185
234
|
let published = false;
|
|
@@ -271,7 +320,7 @@ async function reclaimUnderGuard(path, options, depth) {
|
|
|
271
320
|
if (readFailure !== undefined)
|
|
272
321
|
return { refused: true, cause: readFailure };
|
|
273
322
|
if (state) {
|
|
274
|
-
const diagnosis = await diagnose(state
|
|
323
|
+
const diagnosis = await diagnose(state, options.machineIdentity);
|
|
275
324
|
if (options.signal?.aborted)
|
|
276
325
|
return { refused: true };
|
|
277
326
|
if (!reclaimable(state, diagnosis, options.ownerlessGraceMs))
|
|
@@ -308,7 +357,7 @@ async function attemptExclusiveLock(path, options, depth = 0) {
|
|
|
308
357
|
readFailure = cause;
|
|
309
358
|
}, options.signal);
|
|
310
359
|
const diagnosis = {
|
|
311
|
-
...await diagnose(state
|
|
360
|
+
...await diagnose(state, options.machineIdentity),
|
|
312
361
|
...readFailure !== undefined && { cause: readFailure }
|
|
313
362
|
};
|
|
314
363
|
if (options.signal?.aborted)
|
|
@@ -8,17 +8,17 @@ import {
|
|
|
8
8
|
validateResolvedInputRounds,
|
|
9
9
|
presentationMetadata,
|
|
10
10
|
prepareProjectedMcpTools
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-h7accrrv.js";
|
|
12
12
|
import {
|
|
13
13
|
parseToolCallArguments,
|
|
14
14
|
toolResultFromError,
|
|
15
15
|
observed
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-02h0dfpr.js";
|
|
17
17
|
import {
|
|
18
18
|
collectTools2,
|
|
19
19
|
createToolRunner,
|
|
20
20
|
formatToolError
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-vqdjym30.js";
|
|
22
22
|
import {
|
|
23
23
|
DEFAULT_CORS_ALLOW_HEADERS2,
|
|
24
24
|
DEFAULT_PROCESS_SIGNALS,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
} from "./index-e6c2spsd.js";
|
|
32
32
|
import {
|
|
33
33
|
collectToolSurface
|
|
34
|
-
} from "./index-
|
|
34
|
+
} from "./index-hvg9hctd.js";
|
|
35
35
|
import {
|
|
36
36
|
runWithRequestContext2,
|
|
37
37
|
getRequestContext2
|
|
@@ -2,21 +2,21 @@ import {
|
|
|
2
2
|
toolResultFromError,
|
|
3
3
|
toolCauseFromResult,
|
|
4
4
|
isToolExecutionControlError2
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-02h0dfpr.js";
|
|
6
6
|
import {
|
|
7
7
|
createToolRunner,
|
|
8
8
|
formatToolError
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-vqdjym30.js";
|
|
10
10
|
import {
|
|
11
11
|
AgentToolError2,
|
|
12
12
|
resolveToolDurability
|
|
13
13
|
} from "./index-56yx8dxp.js";
|
|
14
14
|
import {
|
|
15
15
|
collectToolSurface
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-hvg9hctd.js";
|
|
17
17
|
import {
|
|
18
18
|
agentPresenterOf
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-ff3agzaf.js";
|
|
20
20
|
import {
|
|
21
21
|
isRecord
|
|
22
22
|
} from "./index-9jfdm5tg.js";
|
|
@@ -82,6 +82,23 @@ function markJsonSchemaObjectGuards(schema) {
|
|
|
82
82
|
};
|
|
83
83
|
visit(schema);
|
|
84
84
|
}
|
|
85
|
+
var REMOTE_UNION_VERDICT = Symbol.for("stitchkit.tools.json-schema-remote-union-verdict.v1");
|
|
86
|
+
function markRemoteUnionVerdict(schema) {
|
|
87
|
+
Reflect.defineProperty(schema, REMOTE_UNION_VERDICT, {
|
|
88
|
+
configurable: false,
|
|
89
|
+
enumerable: false,
|
|
90
|
+
value: true,
|
|
91
|
+
writable: false
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function localVerdict(schema, error) {
|
|
95
|
+
if (Reflect.get(schema, REMOTE_UNION_VERDICT) !== true)
|
|
96
|
+
return error;
|
|
97
|
+
const local = error.issues.filter((issue) => issue.code !== "invalid_union");
|
|
98
|
+
if (local.length === 0)
|
|
99
|
+
return null;
|
|
100
|
+
return local.length === error.issues.length ? error : new z.ZodError(local);
|
|
101
|
+
}
|
|
85
102
|
function jsonSchemaObjectCoercionMembers(schema) {
|
|
86
103
|
if (Reflect.get(schema, JSON_SCHEMA_OBJECT_GUARD) !== true)
|
|
87
104
|
return;
|
|
@@ -97,4 +114,4 @@ function jsonSchemaObjectCoercionMembers(schema) {
|
|
|
97
114
|
return;
|
|
98
115
|
}
|
|
99
116
|
|
|
100
|
-
export { markJsonSchemaObjectGuards, jsonSchemaObjectCoercionMembers };
|
|
117
|
+
export { markJsonSchemaObjectGuards, markRemoteUnionVerdict, localVerdict, jsonSchemaObjectCoercionMembers };
|
|
@@ -273,7 +273,8 @@ function typeNames(schema) {
|
|
|
273
273
|
function typeSchema(type, nullable) {
|
|
274
274
|
return { type: nullable ? [type, "null"] : type };
|
|
275
275
|
}
|
|
276
|
-
function commonBaseType(
|
|
276
|
+
function commonBaseType(variants, discriminator) {
|
|
277
|
+
const schemas = variants.map(({ schema }) => schema);
|
|
277
278
|
const names = schemas.map(typeNames);
|
|
278
279
|
if (names.some((value) => value === null))
|
|
279
280
|
return {};
|
|
@@ -293,10 +294,19 @@ function commonBaseType(schemas) {
|
|
|
293
294
|
return nullable ? { type: "null" } : {};
|
|
294
295
|
if (bases.has("array") || bases.has("object")) {
|
|
295
296
|
const alternatives = new Map;
|
|
296
|
-
for (const schema of
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
for (const { schema, labels } of variants) {
|
|
298
|
+
const key = serializeCanonicalJson(schema);
|
|
299
|
+
const known = alternatives.get(key);
|
|
300
|
+
if (known)
|
|
301
|
+
known.labels.push(...labels);
|
|
302
|
+
else
|
|
303
|
+
alternatives.set(key, { schema, labels: [...labels] });
|
|
304
|
+
}
|
|
305
|
+
const ordered = [...alternatives].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([, { schema, labels }]) => ({
|
|
306
|
+
...structuredClone(schema),
|
|
307
|
+
description: `When ${discriminator} = ${[...new Set(labels)].join(" | ")}.`
|
|
308
|
+
}));
|
|
309
|
+
return { anyOf: ordered };
|
|
300
310
|
}
|
|
301
311
|
if (bases.size === 1) {
|
|
302
312
|
const [only] = bases;
|
|
@@ -337,7 +347,10 @@ function mergePropertySchemas(properties, discriminator) {
|
|
|
337
347
|
} else {
|
|
338
348
|
const values = schemas.map(stringValues);
|
|
339
349
|
const allStrings = values.every((value) => value !== null);
|
|
340
|
-
merged = allStrings ? { type: "string", enum: [...new Set(values.flatMap((value) => value ?? []))] } : commonBaseType(structural)
|
|
350
|
+
merged = allStrings ? { type: "string", enum: [...new Set(values.flatMap((value) => value ?? []))] } : commonBaseType(structural.map((schema, index) => ({
|
|
351
|
+
schema,
|
|
352
|
+
labels: properties[index]?.labels ?? []
|
|
353
|
+
})), discriminator);
|
|
341
354
|
}
|
|
342
355
|
const description = describeVariants(properties.map((property, index) => ({
|
|
343
356
|
...property,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
projectToolSurface
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-h7accrrv.js";
|
|
4
4
|
import {
|
|
5
5
|
contractToolMountable
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-vqdjym30.js";
|
|
7
7
|
import {
|
|
8
8
|
runtimeToolMountable
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-ff3agzaf.js";
|
|
10
10
|
|
|
11
11
|
// src/tools/surface.ts
|
|
12
12
|
function collectToolSurface({
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertUniqueToolName
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-h7accrrv.js";
|
|
4
4
|
import {
|
|
5
5
|
toolErrorFromResult
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-02h0dfpr.js";
|
|
7
7
|
import {
|
|
8
8
|
collectTools2,
|
|
9
9
|
createToolRunner
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-vqdjym30.js";
|
|
11
11
|
import {
|
|
12
12
|
AppError2
|
|
13
13
|
} from "./index-j9gxbztg.js";
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./index-fynr93w4.js";
|
|
4
4
|
import {
|
|
5
5
|
jsonSchemaObjectCoercionMembers
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-epmnrnth.js";
|
|
7
7
|
import {
|
|
8
8
|
coerceJsonArgs2
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-jy9wq8tp.js";
|
|
10
10
|
import {
|
|
11
11
|
jsonSchemaFields
|
|
12
12
|
} from "./index-ct75c3at.js";
|
|
@@ -14,15 +14,15 @@ import {
|
|
|
14
14
|
objectShapeKeys,
|
|
15
15
|
assertUniqueToolName,
|
|
16
16
|
buildToolPresentationSchema
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-h7accrrv.js";
|
|
18
18
|
import {
|
|
19
19
|
toolResultFromError,
|
|
20
20
|
toolErrorFromResult
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-02h0dfpr.js";
|
|
22
22
|
import {
|
|
23
23
|
createToolRunner,
|
|
24
24
|
formatToolError
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-vqdjym30.js";
|
|
26
26
|
import {
|
|
27
27
|
fetchGuarded,
|
|
28
28
|
readCapped
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
} from "./index-eemvahkc.js";
|
|
36
36
|
import {
|
|
37
37
|
collectToolSurface
|
|
38
|
-
} from "./index-
|
|
38
|
+
} from "./index-hvg9hctd.js";
|
|
39
39
|
import {
|
|
40
40
|
isUnsafeKey,
|
|
41
41
|
safeJsonParse
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
mergeSchemas,
|
|
4
4
|
assertToolExtensionCompatible,
|
|
5
5
|
projectToolSurface
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-h7accrrv.js";
|
|
7
7
|
import {
|
|
8
8
|
toolErrorFromResult,
|
|
9
9
|
executeToolMethod
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-02h0dfpr.js";
|
|
11
11
|
import {
|
|
12
12
|
isRetryableStatus2
|
|
13
13
|
} from "./index-j9gxbztg.js";
|