stitchkit 0.120.0 → 0.122.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 +83 -0
- package/dist/agent-runtime/browser-control-contract.d.ts +12 -0
- package/dist/agent-runtime/browser-control-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-discovery.d.ts +25 -0
- package/dist/agent-runtime/coding-discovery.d.ts.map +1 -0
- package/dist/agent-runtime/coding-search-automaton.d.ts +37 -0
- package/dist/agent-runtime/coding-search-automaton.d.ts.map +1 -0
- package/dist/agent-runtime/coding-search-case-fold.d.ts +4 -0
- package/dist/agent-runtime/coding-search-case-fold.d.ts.map +1 -0
- package/dist/agent-runtime/coding-search-class-ranges.d.ts +10 -0
- package/dist/agent-runtime/coding-search-class-ranges.d.ts.map +1 -0
- package/dist/agent-runtime/coding-search-contract.d.ts +86 -0
- package/dist/agent-runtime/coding-search-contract.d.ts.map +1 -0
- package/dist/agent-runtime/coding-search-limits.d.ts +13 -0
- package/dist/agent-runtime/coding-search-limits.d.ts.map +1 -0
- package/dist/agent-runtime/coding-search-matcher.d.ts +33 -0
- package/dist/agent-runtime/coding-search-matcher.d.ts.map +1 -0
- package/dist/agent-runtime/coding-search-output.d.ts +5 -0
- package/dist/agent-runtime/coding-search-output.d.ts.map +1 -0
- package/dist/agent-runtime/coding-search-regex-syntax.d.ts +39 -0
- package/dist/agent-runtime/coding-search-regex-syntax.d.ts.map +1 -0
- package/dist/agent-runtime/coding-search-unit-classes.d.ts +31 -0
- package/dist/agent-runtime/coding-search-unit-classes.d.ts.map +1 -0
- package/dist/agent-runtime/coding-shell-process.d.ts +1 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +8 -3
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts +1 -11
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-paths.d.ts +6 -2
- package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-refusals.d.ts +6 -0
- package/dist/agent-runtime/coding-tool-refusals.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-search.d.ts +113 -0
- package/dist/agent-runtime/coding-tool-search.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
- package/dist/agent-runtime/contained-scan-budget.d.ts +32 -0
- package/dist/agent-runtime/contained-scan-budget.d.ts.map +1 -0
- package/dist/agent-runtime/contained-scan-contract.d.ts +52 -0
- package/dist/agent-runtime/contained-scan-contract.d.ts.map +1 -0
- package/dist/agent-runtime/contained-scan.d.ts +48 -13
- package/dist/agent-runtime/contained-scan.d.ts.map +1 -1
- package/dist/agent-runtime/control-schema.d.ts +27 -4
- package/dist/agent-runtime/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/event-schema.d.ts +33 -0
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution-state.d.ts +6 -0
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
- package/dist/agent-runtime/run-stream-parts.d.ts +11 -0
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox.d.ts +5 -1
- package/dist/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/agent-runtime/tool-progress.d.ts +21 -0
- package/dist/agent-runtime/tool-progress.d.ts.map +1 -0
- package/dist/agent-runtime/workspace-glob.d.ts +6 -0
- package/dist/agent-runtime/workspace-glob.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/browser.js +7 -3
- package/dist/entrypoints/agent-runtime/coding-tools.js +7 -7
- package/dist/entrypoints/agent-runtime/harness.js +8 -8
- package/dist/entrypoints/agent-runtime/realtime.js +5 -5
- package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +9 -9
- package/dist/entrypoints/agent-runtime/sqlite/node.js +9 -9
- package/dist/entrypoints/agent-runtime/testing.js +9 -9
- package/dist/entrypoints/agent-runtime.d.ts +1 -1
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +15 -13
- package/dist/entrypoints/application/diagnostic-journal.js +3 -3
- package/dist/entrypoints/application/directory-inbox.js +5 -5
- package/dist/entrypoints/cli/publish.js +4 -4
- package/dist/entrypoints/cli.js +4 -4
- package/dist/entrypoints/files.js +4 -4
- package/dist/entrypoints/process/owner-loss.js +2 -1
- package/dist/entrypoints/process.js +4 -4
- package/dist/entrypoints/server.d.ts +1 -0
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +112 -47
- package/dist/entrypoints/telegram.js +3 -3
- package/dist/entrypoints/tools/agent.js +1 -1
- package/dist/entrypoints/tools/toolkit.js +5 -5
- package/dist/{index-yb9n4pgj.js → index-10rg78vf.js} +1 -1
- package/dist/{index-7zwtbak8.js → index-1fyea34p.js} +9 -4
- package/dist/{index-3yb5kft5.js → index-4tyt1qya.js} +1 -1
- package/dist/{index-8xyf8h2k.js → index-6j15ktag.js} +1 -1
- package/dist/{index-zrdcmg6j.js → index-72xtvcvr.js} +40 -6
- package/dist/{index-4qnzda76.js → index-7qyv50r4.js} +1 -1
- package/dist/{index-qctbzmg9.js → index-am1h8c9v.js} +69 -27
- package/dist/{index-e452syyh.js → index-aqmadanx.js} +2 -2
- package/dist/{index-yt7gyg5x.js → index-b51tzcgh.js} +1 -1
- package/dist/{index-aw6zahv1.js → index-dqpesdck.js} +2 -2
- package/dist/{index-1jwsfkfz.js → index-eeahxwvg.js} +60 -76
- package/dist/{index-sb9dr3tq.js → index-eh71zr32.js} +4 -4
- package/dist/{index-nyyam9ce.js → index-f6pw75e1.js} +1 -1
- package/dist/{index-qevqn3d3.js → index-gq3fnq3f.js} +1 -1
- package/dist/{index-bz479f0x.js → index-gtx3eknx.js} +1 -1
- package/dist/{index-mnkk1ffz.js → index-hs76yzt7.js} +13 -1
- package/dist/{index-nn9qvkww.js → index-j95jp7ee.js} +45 -9
- package/dist/{index-2kbysk9s.js → index-m5m9rmvt.js} +2 -0
- package/dist/{index-r3db01kh.js → index-nwm3ww60.js} +1 -1
- package/dist/index-qaqxdbxf.js +2857 -0
- package/dist/index-s9a0fjh3.js +305 -0
- package/dist/{index-b0w7rbpt.js → index-t05a2ry4.js} +39 -3
- package/dist/{index-pq2m7t46.js → index-v8yqk4w7.js} +22 -8
- package/dist/internal/contained-directory.d.ts +1 -1
- package/dist/internal/contained-directory.d.ts.map +1 -1
- package/dist/internal/contained-files.d.ts +18 -51
- package/dist/internal/contained-files.d.ts.map +1 -1
- package/dist/internal/contained-read.d.ts +17 -0
- package/dist/internal/contained-read.d.ts.map +1 -0
- package/dist/internal/darwin-binding.d.ts +3 -1
- package/dist/internal/darwin-binding.d.ts.map +1 -1
- package/dist/process/bun-child.d.ts.map +1 -1
- package/dist/process/command-owner.d.ts.map +1 -1
- package/dist/process/group.d.ts +2 -0
- package/dist/process/group.d.ts.map +1 -1
- package/dist/process/launch.d.ts +1 -0
- package/dist/process/launch.d.ts.map +1 -1
- package/dist/process/owned-child.d.ts.map +1 -1
- package/dist/process/owner-loss-guard.d.ts.map +1 -1
- package/dist/process/owner-loss-protocol.d.ts +1 -0
- package/dist/process/owner-loss-protocol.d.ts.map +1 -1
- package/dist/server/openapi-security.d.ts +73 -0
- package/dist/server/openapi-security.d.ts.map +1 -0
- package/dist/server/openapi.d.ts +12 -0
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts +11 -2
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/repeatable-read.d.ts +9 -0
- package/dist/tools/cli/repeatable-read.d.ts.map +1 -0
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/run-native.d.ts.map +1 -1
- package/dist/tools/runtime-call-context.d.ts +15 -0
- package/dist/tools/runtime-call-context.d.ts.map +1 -0
- package/llms/agent-runtime-browser.txt +4 -1
- package/llms/agent-runtime-coding-tools.txt +9 -9
- package/llms/agent-runtime.2.txt +30 -108
- package/llms/agent-runtime.3.txt +111 -1
- package/llms/agent-runtime.txt +59 -24
- package/llms/application.3.txt +5 -2
- package/llms/cli.txt +21 -9
- package/llms/contract.txt +1 -1
- package/llms/process.txt +3 -1
- package/llms/server.2.txt +48 -0
- package/llms/server.5.txt +4 -0
- package/llms/stitchkit.txt +3 -3
- package/llms/tools.txt +4 -1
- package/llms/{upgrading-0.106.0-0.120.0.txt → upgrading-0.106.0-0.122.0.txt} +81 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +255 -35
- package/llms.txt +7 -7
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/native-assets.json +4 -4
- package/package.json +2 -1
- package/dist/index-0qyrcjfs.js +0 -1478
- package/dist/index-aa50qwv4.js +0 -107
- package/dist/tools/durability-context.d.ts +0 -7
- package/dist/tools/durability-context.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import"../index-
|
|
2
|
-
import"../index-
|
|
3
|
-
import"../index-
|
|
1
|
+
import"../index-m5m9rmvt.js";
|
|
2
|
+
import"../index-gq3fnq3f.js";
|
|
3
|
+
import"../index-gtx3eknx.js";
|
|
4
4
|
import {
|
|
5
5
|
errorCode2,
|
|
6
6
|
normalizeError2
|
|
@@ -53,11 +53,11 @@ import {
|
|
|
53
53
|
} from "../index-bgcwxhxh.js";
|
|
54
54
|
import {
|
|
55
55
|
createFileStateStore2
|
|
56
|
-
} from "../index-
|
|
56
|
+
} from "../index-6j15ktag.js";
|
|
57
57
|
import {
|
|
58
58
|
bindRealtimeServer2
|
|
59
59
|
} from "../index-2bqf0a74.js";
|
|
60
|
-
import"../index-
|
|
60
|
+
import"../index-nwm3ww60.js";
|
|
61
61
|
import {
|
|
62
62
|
withDeadline
|
|
63
63
|
} from "../index-9tqbxv5p.js";
|
|
@@ -1449,6 +1449,66 @@ function createTrustFence(config) {
|
|
|
1449
1449
|
check
|
|
1450
1450
|
};
|
|
1451
1451
|
}
|
|
1452
|
+
// src/server/openapi-security.ts
|
|
1453
|
+
import { z as z2 } from "zod";
|
|
1454
|
+
var SchemeNameSchema = z2.string().regex(/^[a-zA-Z0-9._-]+$/, 'a scheme name may hold only letters, digits, ".", "_" and "-"');
|
|
1455
|
+
var described = { description: z2.string().min(1).optional() };
|
|
1456
|
+
var OpenApiSecuritySchemeSchema = z2.union([
|
|
1457
|
+
z2.strictObject({
|
|
1458
|
+
type: z2.literal("http"),
|
|
1459
|
+
scheme: z2.literal("bearer"),
|
|
1460
|
+
bearerFormat: z2.string().min(1).optional(),
|
|
1461
|
+
...described
|
|
1462
|
+
}),
|
|
1463
|
+
z2.strictObject({ type: z2.literal("http"), scheme: z2.literal("basic"), ...described }),
|
|
1464
|
+
z2.strictObject({
|
|
1465
|
+
type: z2.literal("apiKey"),
|
|
1466
|
+
in: z2.enum(["header", "query", "cookie"]),
|
|
1467
|
+
name: z2.string().min(1),
|
|
1468
|
+
...described
|
|
1469
|
+
})
|
|
1470
|
+
]);
|
|
1471
|
+
var OpenApiSecuritySchema = z2.strictObject({
|
|
1472
|
+
schemes: z2.record(SchemeNameSchema, OpenApiSecuritySchemeSchema),
|
|
1473
|
+
scopes: z2.record(z2.string().min(1), z2.array(SchemeNameSchema).readonly()),
|
|
1474
|
+
defaultScope: z2.string().min(1).optional()
|
|
1475
|
+
});
|
|
1476
|
+
var PUBLIC_SCOPE = "public";
|
|
1477
|
+
function refuse(message) {
|
|
1478
|
+
throw new Error(`[stitchkit] openapi: ${message}`);
|
|
1479
|
+
}
|
|
1480
|
+
function planOpenApiSecurity(input) {
|
|
1481
|
+
const parsed = OpenApiSecuritySchema.safeParse(input);
|
|
1482
|
+
if (!parsed.success) {
|
|
1483
|
+
const issue = parsed.error.issues[0];
|
|
1484
|
+
refuse(`security.${issue?.path.join(".") ?? ""}: ${issue?.message ?? "invalid"}`);
|
|
1485
|
+
}
|
|
1486
|
+
const { schemes, scopes, defaultScope } = parsed.data;
|
|
1487
|
+
if (Object.hasOwn(scopes, PUBLIC_SCOPE)) {
|
|
1488
|
+
refuse(`security.scopes lists "${PUBLIC_SCOPE}", which is open by definition — remove it, or give the protected endpoints their own scope`);
|
|
1489
|
+
}
|
|
1490
|
+
for (const [scope, names] of Object.entries(scopes)) {
|
|
1491
|
+
for (const name of names) {
|
|
1492
|
+
if (!Object.hasOwn(schemes, name)) {
|
|
1493
|
+
refuse(`security.scopes.${scope} names the scheme "${name}", which security.schemes does not declare`);
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
return {
|
|
1498
|
+
schemes,
|
|
1499
|
+
requirement(scope, operation) {
|
|
1500
|
+
const effective = scope ?? defaultScope;
|
|
1501
|
+
if (effective === undefined || effective === PUBLIC_SCOPE)
|
|
1502
|
+
return;
|
|
1503
|
+
const names = Object.hasOwn(scopes, effective) ? scopes[effective] : undefined;
|
|
1504
|
+
if (names === undefined) {
|
|
1505
|
+
refuse(`${operation} has scope "${effective}", but security.scopes names no scheme for it — a protected operation cannot be advertised as open`);
|
|
1506
|
+
}
|
|
1507
|
+
return names.length === 0 ? undefined : names.map((name) => ({ [name]: [] }));
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1452
1512
|
// src/server/openapi.ts
|
|
1453
1513
|
var ERROR_ENVELOPE_SCHEMA = {
|
|
1454
1514
|
type: "object",
|
|
@@ -1484,18 +1544,56 @@ function errorResponse(description) {
|
|
|
1484
1544
|
content: { "application/json": { schema: ERROR_ENVELOPE_SCHEMA } }
|
|
1485
1545
|
};
|
|
1486
1546
|
}
|
|
1487
|
-
function errorResponses(
|
|
1547
|
+
function errorResponses(guarded) {
|
|
1488
1548
|
const responses = {
|
|
1489
1549
|
"400": errorResponse("Validation error"),
|
|
1490
1550
|
"500": errorResponse("Server error")
|
|
1491
1551
|
};
|
|
1492
|
-
if (
|
|
1552
|
+
if (guarded) {
|
|
1493
1553
|
responses["401"] = errorResponse("Unauthorized");
|
|
1494
1554
|
responses["403"] = errorResponse("Forbidden");
|
|
1495
1555
|
}
|
|
1496
1556
|
return responses;
|
|
1497
1557
|
}
|
|
1558
|
+
function multipartRequestBody(inputSchema, multipart) {
|
|
1559
|
+
const inputJson = safeJson(inputSchema, "input");
|
|
1560
|
+
const baseProps = isRecord(inputJson.properties) ? inputJson.properties : {};
|
|
1561
|
+
const baseRequired = Array.isArray(inputJson.required) ? inputJson.required : [];
|
|
1562
|
+
const fileProperties = {};
|
|
1563
|
+
const requiredFiles = [];
|
|
1564
|
+
for (const [field, policy] of Object.entries(multipart.files)) {
|
|
1565
|
+
const binary = {
|
|
1566
|
+
type: "string",
|
|
1567
|
+
format: "binary",
|
|
1568
|
+
...policy.maxBytes !== undefined && { maxLength: policy.maxBytes },
|
|
1569
|
+
...policy.contentTypes !== undefined && {
|
|
1570
|
+
"x-accepted-content-types": policy.contentTypes
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
fileProperties[field] = policy.multiple === true ? {
|
|
1574
|
+
type: "array",
|
|
1575
|
+
items: binary,
|
|
1576
|
+
minItems: policy.required === false ? 0 : 1,
|
|
1577
|
+
...policy.maxFiles !== undefined && { maxItems: policy.maxFiles }
|
|
1578
|
+
} : binary;
|
|
1579
|
+
if (policy.required !== false)
|
|
1580
|
+
requiredFiles.push(field);
|
|
1581
|
+
}
|
|
1582
|
+
return {
|
|
1583
|
+
required: baseRequired.length > 0 || requiredFiles.length > 0,
|
|
1584
|
+
content: {
|
|
1585
|
+
"multipart/form-data": {
|
|
1586
|
+
schema: {
|
|
1587
|
+
type: "object",
|
|
1588
|
+
properties: { ...baseProps, ...fileProperties },
|
|
1589
|
+
required: [...baseRequired, ...requiredFiles]
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1498
1595
|
function generateOpenApiDocument(config) {
|
|
1596
|
+
const security = config.security ? planOpenApiSecurity(config.security) : undefined;
|
|
1499
1597
|
const groups = [
|
|
1500
1598
|
...(config.services ?? []).map((service) => ({ pathPrefix: undefined, service })),
|
|
1501
1599
|
...(config.groups ?? []).flatMap((group) => group.services.map((service) => ({ pathPrefix: group.pathPrefix, service })))
|
|
@@ -1537,7 +1635,9 @@ function generateOpenApiDocument(config) {
|
|
|
1537
1635
|
});
|
|
1538
1636
|
}
|
|
1539
1637
|
}
|
|
1540
|
-
const
|
|
1638
|
+
const requirement = security?.requirement(method.scope, `${method.method} ${fullPath}`);
|
|
1639
|
+
const guarded = security ? requirement !== undefined : method.scope !== undefined && method.scope !== PUBLIC_SCOPE;
|
|
1640
|
+
const responses = { ...errorResponses(guarded) };
|
|
1541
1641
|
if (method.rawResponse) {
|
|
1542
1642
|
responses["200"] = method.method === "HEAD" ? { description: "Headers only" } : {
|
|
1543
1643
|
description: "Success",
|
|
@@ -1579,6 +1679,7 @@ function generateOpenApiDocument(config) {
|
|
|
1579
1679
|
"x-stitchkit-has-output": Boolean(method.outputSchema || method.stream),
|
|
1580
1680
|
...method.stream && { "x-stitchkit-stream": true },
|
|
1581
1681
|
...parameters.length > 0 && { parameters },
|
|
1682
|
+
...requirement && { security: requirement },
|
|
1582
1683
|
responses
|
|
1583
1684
|
};
|
|
1584
1685
|
if (trailingWildcard) {
|
|
@@ -1591,44 +1692,7 @@ function generateOpenApiDocument(config) {
|
|
|
1591
1692
|
}
|
|
1592
1693
|
if (!inputInQuery && (method.inputSchema || method.multipart)) {
|
|
1593
1694
|
if (method.multipart) {
|
|
1594
|
-
|
|
1595
|
-
const baseProps = isRecord(inputJson.properties) ? inputJson.properties : {};
|
|
1596
|
-
const baseRequired = Array.isArray(inputJson.required) ? inputJson.required : [];
|
|
1597
|
-
const fileProperties = {};
|
|
1598
|
-
const requiredFiles = [];
|
|
1599
|
-
for (const [field, policy] of Object.entries(method.multipart.files)) {
|
|
1600
|
-
const binary = {
|
|
1601
|
-
type: "string",
|
|
1602
|
-
format: "binary",
|
|
1603
|
-
...policy.maxBytes !== undefined && { maxLength: policy.maxBytes },
|
|
1604
|
-
...policy.contentTypes !== undefined && {
|
|
1605
|
-
"x-accepted-content-types": policy.contentTypes
|
|
1606
|
-
}
|
|
1607
|
-
};
|
|
1608
|
-
fileProperties[field] = policy.multiple === true ? {
|
|
1609
|
-
type: "array",
|
|
1610
|
-
items: binary,
|
|
1611
|
-
minItems: policy.required === false ? 0 : 1,
|
|
1612
|
-
...policy.maxFiles !== undefined && { maxItems: policy.maxFiles }
|
|
1613
|
-
} : binary;
|
|
1614
|
-
if (policy.required !== false)
|
|
1615
|
-
requiredFiles.push(field);
|
|
1616
|
-
}
|
|
1617
|
-
operation.requestBody = {
|
|
1618
|
-
required: baseRequired.length > 0 || requiredFiles.length > 0,
|
|
1619
|
-
content: {
|
|
1620
|
-
"multipart/form-data": {
|
|
1621
|
-
schema: {
|
|
1622
|
-
type: "object",
|
|
1623
|
-
properties: {
|
|
1624
|
-
...baseProps,
|
|
1625
|
-
...fileProperties
|
|
1626
|
-
},
|
|
1627
|
-
required: [...baseRequired, ...requiredFiles]
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
};
|
|
1695
|
+
operation.requestBody = multipartRequestBody(method.inputSchema, method.multipart);
|
|
1632
1696
|
} else if (method.inputSchema) {
|
|
1633
1697
|
const required = jsonSchemaFields(safeJson(method.inputSchema, "input")).some((f) => f.required);
|
|
1634
1698
|
const schema = safeJson(method.inputSchema, "input");
|
|
@@ -1647,7 +1711,8 @@ function generateOpenApiDocument(config) {
|
|
|
1647
1711
|
openapi: "3.1.0",
|
|
1648
1712
|
info: config.info,
|
|
1649
1713
|
...config.servers && { servers: config.servers },
|
|
1650
|
-
paths
|
|
1714
|
+
paths,
|
|
1715
|
+
...security && { components: { securitySchemes: { ...security.schemes } } }
|
|
1651
1716
|
};
|
|
1652
1717
|
}
|
|
1653
1718
|
function openApiRoute(path, document) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
backoffDelay
|
|
3
3
|
} from "../index-g6a3na27.js";
|
|
4
|
-
import"../index-
|
|
5
|
-
import"../index-
|
|
4
|
+
import"../index-m5m9rmvt.js";
|
|
5
|
+
import"../index-gq3fnq3f.js";
|
|
6
6
|
import {
|
|
7
7
|
attemptExclusiveLock
|
|
8
|
-
} from "../index-
|
|
8
|
+
} from "../index-gtx3eknx.js";
|
|
9
9
|
import {
|
|
10
10
|
TELEGRAM_SEND_FAILURE_REASONS2,
|
|
11
11
|
classifyTelegramSendFailure2
|
|
@@ -8,19 +8,19 @@ import"../../index-69t14s4a.js";
|
|
|
8
8
|
import"../../index-ycqhyars.js";
|
|
9
9
|
import {
|
|
10
10
|
mountAgent2
|
|
11
|
-
} from "../../index-
|
|
11
|
+
} from "../../index-1fyea34p.js";
|
|
12
12
|
import {
|
|
13
13
|
createCli2
|
|
14
|
-
} from "../../index-
|
|
15
|
-
import"../../index-
|
|
14
|
+
} from "../../index-v8yqk4w7.js";
|
|
15
|
+
import"../../index-m5m9rmvt.js";
|
|
16
16
|
import {
|
|
17
17
|
mountMcp2,
|
|
18
18
|
buildMcpServer2,
|
|
19
19
|
createMcpHandler2,
|
|
20
20
|
createStdioMcpServer2
|
|
21
21
|
} from "../../index-knmnj11j.js";
|
|
22
|
-
import"../../index-
|
|
23
|
-
import"../../index-
|
|
22
|
+
import"../../index-aqmadanx.js";
|
|
23
|
+
import"../../index-eeahxwvg.js";
|
|
24
24
|
import"../../index-ff39f9dr.js";
|
|
25
25
|
import"../../index-aqwg2dm5.js";
|
|
26
26
|
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
formatToolError
|
|
9
9
|
} from "./index-ycqhyars.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./index-
|
|
11
|
+
resolveRuntimeToolCall
|
|
12
|
+
} from "./index-eh71zr32.js";
|
|
13
13
|
import {
|
|
14
14
|
AgentToolError2
|
|
15
15
|
} from "./index-1psbyyhj.js";
|
|
@@ -54,8 +54,13 @@ function mountAgent2(services, config = {}) {
|
|
|
54
54
|
});
|
|
55
55
|
const execute = async (rawArgs, options) => {
|
|
56
56
|
const args = isRecord(rawArgs) ? rawArgs : {};
|
|
57
|
-
const
|
|
58
|
-
const
|
|
57
|
+
const runtimeCall = resolveRuntimeToolCall(options.context, options.toolCallId, options.abortSignal);
|
|
58
|
+
const durability = runtimeCall?.durability ?? config.durability?.(options.toolCallId, options.abortSignal);
|
|
59
|
+
const callContext = {
|
|
60
|
+
signal: options.abortSignal,
|
|
61
|
+
toolCallId: options.toolCallId,
|
|
62
|
+
...runtimeCall && { reportProgress: runtimeCall.reportProgress }
|
|
63
|
+
};
|
|
59
64
|
const executeTool = durability ? createToolRunner({
|
|
60
65
|
source: "agent",
|
|
61
66
|
toolSurface: true,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadDarwinBinding
|
|
3
|
+
} from "./index-m5m9rmvt.js";
|
|
1
4
|
import {
|
|
2
5
|
errnoOf
|
|
3
6
|
} from "./index-jj9228tt.js";
|
|
@@ -269,6 +272,7 @@ function ownerLossGuardCommand(guard, executable, args) {
|
|
|
269
272
|
guard.entry,
|
|
270
273
|
OWNER_LOSS_GUARD_FLAG,
|
|
271
274
|
guard.signalTarget,
|
|
275
|
+
...guard.cwdDescriptor === undefined ? [] : ["--stitchkit-cwd-fd", "4"],
|
|
272
276
|
executable,
|
|
273
277
|
...args
|
|
274
278
|
];
|
|
@@ -407,10 +411,16 @@ function spawnBunChild(input) {
|
|
|
407
411
|
const guarded = ownerLoss !== undefined;
|
|
408
412
|
const command = guarded ? ownerLossGuardCommand(ownerLoss, input.executable, input.args) : [input.executable, ...input.args];
|
|
409
413
|
const subprocess = guarded ? Bun.spawn(command, {
|
|
410
|
-
cwd: input.cwd,
|
|
414
|
+
cwd: ownerLoss.cwdDescriptor === undefined ? input.cwd : undefined,
|
|
411
415
|
env: input.env,
|
|
412
416
|
detached: input.group,
|
|
413
|
-
stdio: [
|
|
417
|
+
stdio: [
|
|
418
|
+
"pipe",
|
|
419
|
+
"pipe",
|
|
420
|
+
"pipe",
|
|
421
|
+
"socket-fd",
|
|
422
|
+
...ownerLoss.cwdDescriptor === undefined ? [] : [ownerLoss.cwdDescriptor]
|
|
423
|
+
]
|
|
414
424
|
}) : Bun.spawn(command, {
|
|
415
425
|
cwd: input.cwd,
|
|
416
426
|
env: input.env,
|
|
@@ -446,10 +456,16 @@ function spawnBunInheritedChild(input) {
|
|
|
446
456
|
const guarded = ownerLoss !== undefined;
|
|
447
457
|
const command = guarded ? ownerLossGuardCommand(ownerLoss, input.executable, input.args) : [input.executable, ...input.args];
|
|
448
458
|
const subprocess = guarded ? Bun.spawn(command, {
|
|
449
|
-
cwd: input.cwd,
|
|
459
|
+
cwd: ownerLoss.cwdDescriptor === undefined ? input.cwd : undefined,
|
|
450
460
|
env: input.env,
|
|
451
461
|
detached: input.group,
|
|
452
|
-
stdio: [
|
|
462
|
+
stdio: [
|
|
463
|
+
"inherit",
|
|
464
|
+
"inherit",
|
|
465
|
+
"inherit",
|
|
466
|
+
"socket-fd",
|
|
467
|
+
...ownerLoss.cwdDescriptor === undefined ? [] : [ownerLoss.cwdDescriptor]
|
|
468
|
+
]
|
|
453
469
|
}) : Bun.spawn(command, {
|
|
454
470
|
cwd: input.cwd,
|
|
455
471
|
env: input.env,
|
|
@@ -484,6 +500,7 @@ function spawnBunGuardTarget(executable, args) {
|
|
|
484
500
|
|
|
485
501
|
// src/process/owner-loss-guard.ts
|
|
486
502
|
import { spawn } from "node:child_process";
|
|
503
|
+
import { closeSync } from "node:fs";
|
|
487
504
|
import { Socket } from "node:net";
|
|
488
505
|
import { fileURLToPath } from "node:url";
|
|
489
506
|
var FORWARDED_SIGNALS = [
|
|
@@ -547,7 +564,7 @@ function spawnBunTarget(executable, args, onStarted, onExit, onUnavailable) {
|
|
|
547
564
|
onStarted(child.pid);
|
|
548
565
|
child.exited.then(() => onExit(child.exitCode, child.signalCode));
|
|
549
566
|
}
|
|
550
|
-
function runOwnerLossGuard(signalTarget, executable, args) {
|
|
567
|
+
function runOwnerLossGuard(signalTarget, executable, args, cwdDescriptor) {
|
|
551
568
|
const bun = hostIsBun();
|
|
552
569
|
const control = bun ? connectOwnerLossSocket(3) : new Socket({ fd: 3, readable: true, writable: true });
|
|
553
570
|
let armed = true;
|
|
@@ -613,6 +630,20 @@ function runOwnerLossGuard(signalTarget, executable, args) {
|
|
|
613
630
|
removeForwarders();
|
|
614
631
|
refuseTarget(control, cause);
|
|
615
632
|
};
|
|
633
|
+
if (cwdDescriptor !== undefined) {
|
|
634
|
+
try {
|
|
635
|
+
if (process.platform === "darwin")
|
|
636
|
+
loadDarwinBinding().changeDirectory(cwdDescriptor);
|
|
637
|
+
else if (process.platform === "linux")
|
|
638
|
+
process.chdir(`/proc/self/fd/${cwdDescriptor}`);
|
|
639
|
+
else
|
|
640
|
+
throw new Error("Descriptor command directories require Linux or macOS");
|
|
641
|
+
closeSync(cwdDescriptor);
|
|
642
|
+
} catch (cause) {
|
|
643
|
+
targetUnavailable(cause);
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
616
647
|
if (!bun)
|
|
617
648
|
spawnNodeTarget(executable, args, targetStarted, targetExit, targetUnavailable);
|
|
618
649
|
else
|
|
@@ -625,7 +656,10 @@ function startOwnerLossGuardEntry() {
|
|
|
625
656
|
const entry = process.argv[1];
|
|
626
657
|
if (entry === undefined || fileURLToPath(import.meta.url) !== entry)
|
|
627
658
|
return;
|
|
628
|
-
|
|
659
|
+
const pinnedCwd = process.argv[4] === "--stitchkit-cwd-fd";
|
|
660
|
+
if (pinnedCwd && process.argv[5] !== "4")
|
|
661
|
+
throw new Error("Invalid command directory descriptor");
|
|
662
|
+
runOwnerLossGuard(process.argv[3], process.argv[pinnedCwd ? 6 : 4], process.argv.slice(pinnedCwd ? 7 : 5), pinnedCwd ? 4 : undefined);
|
|
629
663
|
guardInvocation = true;
|
|
630
664
|
}
|
|
631
665
|
function bootstrapNativeCommandOwnerLoss2() {
|
|
@@ -16,8 +16,9 @@ import {
|
|
|
16
16
|
isToolExecutionControlError2
|
|
17
17
|
} from "./index-s3yxw6kt.js";
|
|
18
18
|
import {
|
|
19
|
+
AGENT_TOOL_PROGRESS_MESSAGE_MAX2,
|
|
19
20
|
agentDurableEventId2
|
|
20
|
-
} from "./index-
|
|
21
|
+
} from "./index-hs76yzt7.js";
|
|
21
22
|
import {
|
|
22
23
|
createLocalStepDurability2
|
|
23
24
|
} from "./index-zyc64nbh.js";
|
|
@@ -38,8 +39,8 @@ import {
|
|
|
38
39
|
messageOf
|
|
39
40
|
} from "./index-g149e9pk.js";
|
|
40
41
|
import {
|
|
41
|
-
|
|
42
|
-
} from "./index-
|
|
42
|
+
createRuntimeToolContext
|
|
43
|
+
} from "./index-eh71zr32.js";
|
|
43
44
|
import {
|
|
44
45
|
createMutationQueue
|
|
45
46
|
} from "./index-sykb5ag7.js";
|
|
@@ -2597,6 +2598,7 @@ async function acquireRun(dependencies, input) {
|
|
|
2597
2598
|
absorbed: new Map,
|
|
2598
2599
|
eventsSinceCheckpoint: 0,
|
|
2599
2600
|
sequence: 0,
|
|
2601
|
+
settledToolCalls: new Set,
|
|
2600
2602
|
terminalReason: "success",
|
|
2601
2603
|
nonModelUsage: input.acceptedRun.usage,
|
|
2602
2604
|
modelUsage: undefined,
|
|
@@ -2976,6 +2978,7 @@ async function applyToolPart(execution, part) {
|
|
|
2976
2978
|
emittedAt: now().toISOString()
|
|
2977
2979
|
});
|
|
2978
2980
|
} else if (part.type === "tool-result") {
|
|
2981
|
+
state.settledToolCalls.add(part.toolCallId);
|
|
2979
2982
|
state.parts.push(AgentMessagePartSchema2.parse({
|
|
2980
2983
|
type: "tool-result",
|
|
2981
2984
|
callId: part.toolCallId,
|
|
@@ -2993,6 +2996,7 @@ async function applyToolPart(execution, part) {
|
|
|
2993
2996
|
emittedAt: now().toISOString()
|
|
2994
2997
|
});
|
|
2995
2998
|
} else if (part.type === "tool-error") {
|
|
2999
|
+
state.settledToolCalls.add(part.toolCallId);
|
|
2996
3000
|
state.internalCause = part.error;
|
|
2997
3001
|
if (isToolExecutionControlError2(part.error)) {
|
|
2998
3002
|
await publish({
|
|
@@ -3024,6 +3028,7 @@ async function applyToolPart(execution, part) {
|
|
|
3024
3028
|
emittedAt: now().toISOString()
|
|
3025
3029
|
});
|
|
3026
3030
|
} else if (part.type === "tool-output-denied") {
|
|
3031
|
+
state.settledToolCalls.add(part.toolCallId);
|
|
3027
3032
|
state.parts.push(AgentMessagePartSchema2.parse({
|
|
3028
3033
|
type: "tool-result",
|
|
3029
3034
|
callId: part.toolCallId,
|
|
@@ -3194,6 +3199,37 @@ async function applyStreamPart(execution, scope, part) {
|
|
|
3194
3199
|
}
|
|
3195
3200
|
}
|
|
3196
3201
|
|
|
3202
|
+
// src/agent-runtime/tool-progress.ts
|
|
3203
|
+
var TOOL_PROGRESS_MIN_INTERVAL_MS = 250;
|
|
3204
|
+
function finite(value) {
|
|
3205
|
+
return value !== undefined && Number.isFinite(value) ? value : undefined;
|
|
3206
|
+
}
|
|
3207
|
+
function createToolProgressReporter(execution, toolName, callId, signal) {
|
|
3208
|
+
let lastPublishedAt;
|
|
3209
|
+
return async (update) => {
|
|
3210
|
+
if (signal?.aborted || execution.state.settledToolCalls.has(callId))
|
|
3211
|
+
return;
|
|
3212
|
+
const now = execution.dependencies.now();
|
|
3213
|
+
if (lastPublishedAt !== undefined && now.getTime() - lastPublishedAt < TOOL_PROGRESS_MIN_INTERVAL_MS) {
|
|
3214
|
+
return;
|
|
3215
|
+
}
|
|
3216
|
+
lastPublishedAt = now.getTime();
|
|
3217
|
+
const message = update.message?.slice(0, AGENT_TOOL_PROGRESS_MESSAGE_MAX2);
|
|
3218
|
+
const progress = finite(update.progress);
|
|
3219
|
+
const total = finite(update.total);
|
|
3220
|
+
await execution.dependencies.publish({
|
|
3221
|
+
type: "tool-progress",
|
|
3222
|
+
...transientHead(execution),
|
|
3223
|
+
callId,
|
|
3224
|
+
toolName,
|
|
3225
|
+
...message !== undefined && { message },
|
|
3226
|
+
...progress !== undefined && { progress },
|
|
3227
|
+
...total !== undefined && { total },
|
|
3228
|
+
emittedAt: now.toISOString()
|
|
3229
|
+
});
|
|
3230
|
+
};
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3197
3233
|
// src/agent-runtime/run-model-attempts.ts
|
|
3198
3234
|
function createStopConditions(execution, turn) {
|
|
3199
3235
|
const { config, maxSteps } = execution.dependencies;
|
|
@@ -3268,10 +3304,30 @@ async function prepareAttemptStep(context, attempt, options) {
|
|
|
3268
3304
|
});
|
|
3269
3305
|
return { ...preparedStep, model };
|
|
3270
3306
|
}
|
|
3307
|
+
function runToolDurability(context, toolName, toolCallId, signal) {
|
|
3308
|
+
const { config } = context.execution.dependencies;
|
|
3309
|
+
const { state } = context.execution;
|
|
3310
|
+
const port = config.durability;
|
|
3311
|
+
if (typeof port === "function")
|
|
3312
|
+
return port({
|
|
3313
|
+
store: config.store,
|
|
3314
|
+
conversationId: state.run.conversationId,
|
|
3315
|
+
runId: state.run.id,
|
|
3316
|
+
toolName,
|
|
3317
|
+
toolCallId,
|
|
3318
|
+
signal
|
|
3319
|
+
});
|
|
3320
|
+
return createLocalStepDurability2({
|
|
3321
|
+
store: config.store,
|
|
3322
|
+
conversationId: state.run.conversationId,
|
|
3323
|
+
runId: JSON.stringify([state.run.id, toolName, toolCallId]),
|
|
3324
|
+
signal
|
|
3325
|
+
});
|
|
3326
|
+
}
|
|
3271
3327
|
function startAttemptStream(context, attempt, stopConditions) {
|
|
3272
3328
|
const { execution, turn } = context;
|
|
3273
3329
|
const { config } = execution.dependencies;
|
|
3274
|
-
const {
|
|
3330
|
+
const { idleDeadline, operationLifecycle } = execution;
|
|
3275
3331
|
const { tools } = turn;
|
|
3276
3332
|
const attemptSignal = AbortSignal.any([
|
|
3277
3333
|
execution.executionSignal,
|
|
@@ -3280,29 +3336,15 @@ function startAttemptStream(context, attempt, stopConditions) {
|
|
|
3280
3336
|
return streamAgentTextBoundary({
|
|
3281
3337
|
model: turn.selectedModel.model,
|
|
3282
3338
|
tools,
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
runId: state.run.id,
|
|
3293
|
-
toolName,
|
|
3294
|
-
toolCallId,
|
|
3295
|
-
signal
|
|
3296
|
-
});
|
|
3297
|
-
return createLocalStepDurability2({
|
|
3298
|
-
store: config.store,
|
|
3299
|
-
conversationId: state.run.conversationId,
|
|
3300
|
-
runId: JSON.stringify([state.run.id, toolName, toolCallId]),
|
|
3301
|
-
signal
|
|
3302
|
-
});
|
|
3303
|
-
})
|
|
3304
|
-
]))
|
|
3305
|
-
},
|
|
3339
|
+
toolsContext: Object.fromEntries(Object.entries(tools).filter(([, tool]) => tool.contextSchema === undefined).map(([toolName]) => [
|
|
3340
|
+
toolName,
|
|
3341
|
+
createRuntimeToolContext((toolCallId, signal) => ({
|
|
3342
|
+
...config.durability && {
|
|
3343
|
+
durability: runToolDurability(context, toolName, toolCallId, signal)
|
|
3344
|
+
},
|
|
3345
|
+
reportProgress: createToolProgressReporter(execution, toolName, toolCallId, signal)
|
|
3346
|
+
}))
|
|
3347
|
+
])),
|
|
3306
3348
|
instructions: turn.projection.withCarriedSystem(turn.prompt.instructions),
|
|
3307
3349
|
messages: turn.history,
|
|
3308
3350
|
abortSignal: attemptSignal,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadDarwinBinding
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-m5m9rmvt.js";
|
|
4
4
|
import {
|
|
5
5
|
descriptorPath,
|
|
6
6
|
NumericFileHandle
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-eeahxwvg.js";
|
|
8
8
|
import {
|
|
9
9
|
stagingName
|
|
10
10
|
} from "./index-tt30h7mr.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentControlRequestSchema2,
|
|
3
3
|
AgentControlResponseSchema2
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-t05a2ry4.js";
|
|
5
5
|
import {
|
|
6
6
|
createAgentRuntimeEventSink2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-7qyv50r4.js";
|
|
8
8
|
import {
|
|
9
9
|
assertPositiveSafeInteger
|
|
10
10
|
} from "./index-0s4xebbg.js";
|