stitchkit 0.130.1 → 0.132.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 +68 -0
- package/dist/agent-executor/acp/v1-connect.d.ts +40 -26
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-driver.d.ts +10 -4
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-handlers.d.ts +6 -2
- package/dist/agent-executor/acp/v1-handlers.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-probe.d.ts +38 -0
- package/dist/agent-executor/acp/v1-probe.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts +15 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts +9 -7
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/claude/cli-driver.d.ts +7 -7
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
- package/dist/agent-executor/claude/limits.d.ts +6 -4
- package/dist/agent-executor/claude/limits.d.ts.map +1 -1
- package/dist/agent-executor/claude/session.d.ts +3 -3
- package/dist/agent-executor/claude/session.d.ts.map +1 -1
- package/dist/agent-executor/claude/transcript.d.ts +1 -1
- package/dist/agent-executor/claude/transcript.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/controls.d.ts +1 -0
- package/dist/agent-executor/claude-sdk/controls.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/driver.d.ts +51 -50
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/probe.d.ts +3 -3
- package/dist/agent-executor/claude-sdk/probe.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/query-loop.d.ts +2 -1
- package/dist/agent-executor/claude-sdk/query-loop.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/classify.d.ts.map +1 -1
- package/dist/agent-executor/codex/connect.d.ts +7 -7
- package/dist/agent-executor/codex/connect.d.ts.map +1 -1
- package/dist/agent-executor/codex/control-client.d.ts +86 -99
- package/dist/agent-executor/codex/control-client.d.ts.map +1 -1
- package/dist/agent-executor/codex/control-read-methods.d.ts +7 -0
- package/dist/agent-executor/codex/control-read-methods.d.ts.map +1 -0
- package/dist/agent-executor/codex/driver.d.ts +29 -28
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/codex/event-routing.d.ts +14 -0
- package/dist/agent-executor/codex/event-routing.d.ts.map +1 -0
- package/dist/agent-executor/codex/handlers.d.ts +2 -2
- package/dist/agent-executor/codex/handlers.d.ts.map +1 -1
- package/dist/agent-executor/codex/limits.d.ts +9 -3
- package/dist/agent-executor/codex/limits.d.ts.map +1 -1
- package/dist/agent-executor/codex/notifications.d.ts +183 -0
- package/dist/agent-executor/codex/notifications.d.ts.map +1 -0
- package/dist/agent-executor/codex/pagination.d.ts +54 -0
- package/dist/agent-executor/codex/pagination.d.ts.map +1 -0
- package/dist/agent-executor/codex/protocol.d.ts +586 -148
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/request-answers.d.ts +4 -2
- package/dist/agent-executor/codex/request-answers.d.ts.map +1 -1
- package/dist/agent-executor/codex/responses.d.ts +855 -0
- package/dist/agent-executor/codex/responses.d.ts.map +1 -0
- package/dist/agent-executor/codex/session-bind.d.ts +410 -0
- package/dist/agent-executor/codex/session-bind.d.ts.map +1 -0
- package/dist/agent-executor/codex/session-controls.d.ts +19 -190
- package/dist/agent-executor/codex/session-controls.d.ts.map +1 -1
- package/dist/agent-executor/codex/session-types.d.ts +190 -0
- package/dist/agent-executor/codex/session-types.d.ts.map +1 -0
- package/dist/agent-executor/codex/session.d.ts +1 -1
- package/dist/agent-executor/codex/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/shared-server.d.ts +4 -4
- package/dist/agent-executor/codex/shared-server.d.ts.map +1 -1
- package/dist/agent-executor/codex/shared-thread.d.ts +5 -5
- package/dist/agent-executor/codex/shared-thread.d.ts.map +1 -1
- package/dist/agent-executor/codex/thread-controls.d.ts +45 -36
- package/dist/agent-executor/codex/thread-controls.d.ts.map +1 -1
- package/dist/agent-executor/codex/thread-list-query.d.ts +5 -0
- package/dist/agent-executor/codex/thread-list-query.d.ts.map +1 -0
- package/dist/agent-executor/codex/thread-open.d.ts +20 -20
- package/dist/agent-executor/codex/thread-open.d.ts.map +1 -1
- package/dist/agent-executor/codex/turn-input.d.ts +4 -3
- package/dist/agent-executor/codex/turn-input.d.ts.map +1 -1
- package/dist/agent-executor/codex/unix-socket-target.d.ts +12 -3
- package/dist/agent-executor/codex/unix-socket-target.d.ts.map +1 -1
- package/dist/agent-executor/codex/ws-frame.d.ts +4 -1
- package/dist/agent-executor/codex/ws-frame.d.ts.map +1 -1
- package/dist/agent-executor/contract.d.ts +3 -1
- package/dist/agent-executor/contract.d.ts.map +1 -1
- package/dist/agent-executor/engine-process.d.ts +4 -4
- package/dist/agent-executor/engine-process.d.ts.map +1 -1
- package/dist/agent-executor/engine.d.ts +3 -3
- package/dist/agent-executor/engine.d.ts.map +1 -1
- package/dist/agent-executor/handoff.d.ts.map +1 -1
- package/dist/agent-executor/hello.d.ts +7 -0
- package/dist/agent-executor/hello.d.ts.map +1 -1
- package/dist/agent-executor/json-rpc-peer.d.ts +9 -4
- package/dist/agent-executor/json-rpc-peer.d.ts.map +1 -1
- package/dist/agent-executor/leases.d.ts +1 -1
- package/dist/agent-executor/leases.d.ts.map +1 -1
- package/dist/agent-executor/plan-limits.d.ts +12 -1
- package/dist/agent-executor/plan-limits.d.ts.map +1 -1
- package/dist/agent-executor/profile.d.ts +9 -1
- package/dist/agent-executor/profile.d.ts.map +1 -1
- package/dist/agent-executor/session-primitives.d.ts +8 -0
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-executor/testing/consumer-stubs.d.ts +45 -0
- package/dist/agent-executor/testing/consumer-stubs.d.ts.map +1 -0
- package/dist/agent-executor/testing/fake-claude-sdk-query.d.ts +88 -0
- package/dist/agent-executor/testing/fake-claude-sdk-query.d.ts.map +1 -0
- package/dist/agent-executor/testing/fake-codex-app-server.d.ts +56 -0
- package/dist/agent-executor/testing/fake-codex-app-server.d.ts.map +1 -0
- package/dist/agent-executor/testing/fixtures.d.ts +26 -0
- package/dist/agent-executor/testing/fixtures.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-driver.d.ts +8 -8
- package/dist/agent-executor/testing/replay-driver.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-runner.d.ts +3 -2
- package/dist/agent-executor/testing/replay-runner.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-transcript.d.ts +5 -3
- package/dist/agent-executor/testing/replay-transcript.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +19 -19
- package/dist/agent-runtime/sql-rows.d.ts +10 -10
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/entrypoints/agent-executor/acp.d.ts +2 -1
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +284 -82
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts +4 -0
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/claude-sdk.js +64 -37
- package/dist/entrypoints/agent-executor/claude.d.ts +2 -2
- package/dist/entrypoints/agent-executor/claude.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/claude.js +29 -23
- package/dist/entrypoints/agent-executor/codex.d.ts +9 -5
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/codex.js +1860 -1695
- package/dist/entrypoints/agent-executor/testing.d.ts +4 -0
- package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/testing.js +880 -18
- package/dist/entrypoints/agent-executor.d.ts +3 -3
- package/dist/entrypoints/agent-executor.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor.js +42 -8
- package/dist/entrypoints/process.js +3 -3
- package/dist/entrypoints/sync.js +8 -4
- package/dist/{index-jrn3prgm.js → index-athc412x.js} +29 -4
- package/dist/{index-dbp6xemn.js → index-f9p62ean.js} +219 -7
- package/dist/index-j15dhkda.js +749 -0
- package/dist/index-jcrj0b8z.js +56 -0
- package/dist/{index-1q0n6zek.js → index-kwsr7j5k.js} +84 -44
- package/dist/{index-p1qmpq0p.js → index-z114ax5e.js} +93 -57
- package/dist/sync/session-machine.d.ts.map +1 -1
- package/dist/sync/session.d.ts +3 -3
- package/llms/agent-executor-acp.txt +5 -5
- package/llms/agent-executor-claude-sdk.txt +3 -1
- package/llms/agent-executor-claude.txt +2 -2
- package/llms/agent-executor-codex.txt +11 -8
- package/llms/agent-executor-testing.txt +5 -1
- package/llms/agent-executor.txt +10 -4
- package/llms/stitchkit.txt +75 -74
- package/llms/sync.txt +1 -1
- package/llms/{upgrading-0.128.0-0.130.0.txt → upgrading-0.128.0-0.132.0.txt} +76 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +185 -96
- package/llms.txt +8 -8
- package/package.json +3 -3
- package/dist/index-2s8sy57y.js +0 -229
|
@@ -7,10 +7,10 @@ export { advanceExecutorConnection, canAcceptTurn, type ExecutorConnectionEvent,
|
|
|
7
7
|
export { buildContextHandoff, withInlineHandoffContext, } from '../agent-executor/handoff.js';
|
|
8
8
|
export { ContextHandoffBudgetSchema, ContextHandoffClearEntrySchema, type ContextHandoffEntry, ContextHandoffEntrySchema, type ContextHandoffInput, ContextHandoffInputSchema, ContextHandoffMessageEntrySchema, type ContextHandoffResult, ContextHandoffResultSchema, type ContextHandoffSelectedItem, ContextHandoffSelectedItemSchema, ContextHandoffStrategySchema, type ContextHandoffStructuredItem, ContextHandoffStructuredItemSchema, type InlineHandoffComposition, } from '../agent-executor/handoff-schemas.js';
|
|
9
9
|
export { type ExecutorDriverCapabilities, ExecutorDriverCapabilitiesSchema, type ExecutorEngine, type ExecutorEngineInfo, ExecutorEngineInfoSchema, ExecutorEngineSchema, type ExecutorHello, type ExecutorHelloAck, ExecutorHelloAckSchema, ExecutorHelloSchema, type ExecutorProfile, ExecutorProfileSchema, ExecutorReconcileSchema, ExecutorResumableTurnSchema, type PlanLimits, PlanLimitsSchema, type PlanWindow, PlanWindowSchema, } from '../agent-executor/hello.js';
|
|
10
|
-
export { createJsonRpcPeer, JSON_RPC_LOCAL_TIMEOUT, JSON_RPC_METHOD_NOT_FOUND, JsonRpcError, type JsonRpcHeader, type JsonRpcPeer, type JsonRpcPeerConfig, type JsonRpcValue, } from '../agent-executor/json-rpc-peer.js';
|
|
10
|
+
export { createJsonRpcPeer, JSON_RPC_LOCAL_TIMEOUT, JSON_RPC_METHOD_NOT_FOUND, JsonRpcError, type JsonRpcHeader, type JsonRpcPeer, type JsonRpcPeerConfig, JsonRpcRecordSchema, type JsonRpcValue, JsonRpcValueSchema, } from '../agent-executor/json-rpc-peer.js';
|
|
11
11
|
export { createExecutorLeases, ExecutorLeaseRefusal, type ExecutorLeaseState, ExecutorLeaseStateSchema, type ExecutorLeaseStateStore, memoryExecutorLeaseStore, } from '../agent-executor/leases.js';
|
|
12
|
-
export { mergeRateLimitEvent, planLimitsDue, planLimitsReadFailed, planWindowExpired, } from '../agent-executor/plan-limits.js';
|
|
13
|
-
export { CREDENTIAL_VARIABLES, type ExecutorProfileConfig, ExecutorProfileConfigSchema, engineEnvironment, helloProfile, ownCredentials, } from '../agent-executor/profile.js';
|
|
12
|
+
export { mergeRateLimitEvent, planLimitsDue, planLimitsReadFailed, planWindowDurationMins, planWindowExpired, } from '../agent-executor/plan-limits.js';
|
|
13
|
+
export { CREDENTIAL_VARIABLES, EXECUTOR_ENV_KEY_PATTERN, type ExecutorProfileConfig, ExecutorProfileConfigSchema, engineEnvironment, helloProfile, ownCredentials, sanitizeProfileEnv, } from '../agent-executor/profile.js';
|
|
14
14
|
export { projectExecutorDeltas } from '../agent-executor/projection.js';
|
|
15
15
|
export { canAdvanceTurnPhase, isTerminalTurnPhase } from '../agent-executor/turn-phases.js';
|
|
16
16
|
export { type ExecutorDelta, ExecutorDeltaSchema, type ExecutorErrorKind, ExecutorErrorKindSchema, type ExecutorModelUsage, ExecutorModelUsageSchema, ExecutorRawSchema, type ExecutorStartupPhase, ExecutorStartupPhaseSchema, ExecutorStatusDeltaSchema, type ExecutorThreadDisposition, ExecutorThreadDispositionSchema, type ExecutorTokenUsage, ExecutorTokenUsageSchema, } from '../agent-executor/vocabulary.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-executor.d.ts","sourceRoot":"","sources":["../../src/entrypoints/agent-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,KAAK,eAAe,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAChF,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,aAAa,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EACL,eAAe,EACf,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,WAAW,EAChB,iBAAiB,EACjB,KAAK,WAAW,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,SAAS,EACd,eAAe,EACf,KAAK,SAAS,EACd,eAAe,EACf,KAAK,UAAU,EACf,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,2BAA2B,GAC5B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,KAAK,oBAAoB,EACzB,0BAA0B,EAC1B,KAAK,0BAA0B,EAC/B,gCAAgC,EAChC,4BAA4B,EAC5B,KAAK,4BAA4B,EACjC,kCAAkC,EAClC,KAAK,wBAAwB,GAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,KAAK,0BAA0B,EAC/B,gCAAgC,EAChC,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,eAAe,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,KAAK,UAAU,EACf,gBAAgB,EAChB,KAAK,UAAU,EACf,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,EACzB,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"agent-executor.d.ts","sourceRoot":"","sources":["../../src/entrypoints/agent-executor.ts"],"names":[],"mappings":"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"}
|
|
@@ -41,21 +41,26 @@ import {
|
|
|
41
41
|
ExecutorResumableTurnSchema2,
|
|
42
42
|
ExecutorHelloSchema2,
|
|
43
43
|
ExecutorHelloAckSchema2,
|
|
44
|
+
EXECUTOR_ENV_KEY_PATTERN2,
|
|
45
|
+
sanitizeProfileEnv2,
|
|
44
46
|
ExecutorProfileConfigSchema2,
|
|
45
47
|
CREDENTIAL_VARIABLES2,
|
|
46
48
|
engineEnvironment2,
|
|
47
49
|
ownCredentials2,
|
|
48
50
|
helloProfile2
|
|
49
|
-
} from "../index-
|
|
51
|
+
} from "../index-f9p62ean.js";
|
|
50
52
|
import"../index-v59pxmf1.js";
|
|
51
53
|
import"../index-qa2jjb65.js";
|
|
52
54
|
import"../index-6kec3b14.js";
|
|
53
55
|
import {
|
|
56
|
+
JsonRpcValueSchema2,
|
|
57
|
+
JsonRpcRecordSchema2,
|
|
54
58
|
JsonRpcError2,
|
|
55
59
|
JSON_RPC_METHOD_NOT_FOUND2,
|
|
56
60
|
JSON_RPC_LOCAL_TIMEOUT2,
|
|
57
61
|
createJsonRpcPeer2
|
|
58
|
-
} from "../index-
|
|
62
|
+
} from "../index-kwsr7j5k.js";
|
|
63
|
+
import"../index-09f7w2qq.js";
|
|
59
64
|
import {
|
|
60
65
|
spawnEngineProcess2
|
|
61
66
|
} from "../index-rxh3qy4x.js";
|
|
@@ -66,10 +71,12 @@ import {
|
|
|
66
71
|
} from "../index-x5ayy5bn.js";
|
|
67
72
|
import {
|
|
68
73
|
planWindowExpired2,
|
|
74
|
+
planWindowDurationMins2,
|
|
69
75
|
planLimitsDue2,
|
|
70
76
|
planLimitsReadFailed2,
|
|
71
77
|
mergeRateLimitEvent2
|
|
72
|
-
} from "../index-
|
|
78
|
+
} from "../index-athc412x.js";
|
|
79
|
+
import"../index-pzhqydxb.js";
|
|
73
80
|
import {
|
|
74
81
|
AppError2
|
|
75
82
|
} from "../index-9pv126eh.js";
|
|
@@ -382,6 +389,23 @@ function computeEffectiveTokenCap(budget) {
|
|
|
382
389
|
const available = Math.max(0, window - used - reserve);
|
|
383
390
|
return Math.min(budget.maxTokens, available);
|
|
384
391
|
}
|
|
392
|
+
function widestOmittedIds(prepared, limit) {
|
|
393
|
+
if (limit === 0)
|
|
394
|
+
return [];
|
|
395
|
+
const widest = [];
|
|
396
|
+
const trim = () => {
|
|
397
|
+
widest.sort((a, b) => b.width - a.width);
|
|
398
|
+
if (widest.length > limit)
|
|
399
|
+
widest.length = limit;
|
|
400
|
+
};
|
|
401
|
+
for (const { item } of prepared) {
|
|
402
|
+
widest.push({ id: item.id, width: worstCaseSerializedBytes(item.id) });
|
|
403
|
+
if (widest.length === 2 * limit)
|
|
404
|
+
trim();
|
|
405
|
+
}
|
|
406
|
+
trim();
|
|
407
|
+
return widest.map((candidate) => candidate.id);
|
|
408
|
+
}
|
|
385
409
|
function buildContextHandoff(rawInput) {
|
|
386
410
|
const input = ContextHandoffInputSchema.parse(rawInput);
|
|
387
411
|
const resolved = resolveCandidateEntries(input.entries, input.strategy);
|
|
@@ -427,7 +451,7 @@ function buildContextHandoff(rawInput) {
|
|
|
427
451
|
const tokenCap = computeEffectiveTokenCap(input.budget);
|
|
428
452
|
const byteCap = Math.min(input.budget.maxBytes, tokenCap * 4);
|
|
429
453
|
const maxOmittedCap = input.budget.maxOmittedIds ?? HANDOFF_LIMITS.defaultMaxOmittedIds;
|
|
430
|
-
const widestOmitted = prepared
|
|
454
|
+
const widestOmitted = widestOmittedIds(prepared, maxOmittedCap);
|
|
431
455
|
const omittedClauseCap = Math.floor(byteCap / 8);
|
|
432
456
|
while (widestOmitted.length > 0 && worstCaseSerializedBytes(formatOmittedClause(widestOmitted, prepared.length)) > omittedClauseCap) {
|
|
433
457
|
widestOmitted.pop();
|
|
@@ -444,7 +468,7 @@ function buildContextHandoff(rawInput) {
|
|
|
444
468
|
const baseStructuredBytes = utf8ByteLength(JSON.stringify([headerStructuredItem(reservedHeader)]));
|
|
445
469
|
const baseBytes = Math.max(baseInlineBytes, baseStructuredBytes);
|
|
446
470
|
if (tokenCap === 0 || baseBytes > input.budget.maxBytes || estimateTokensFromBytes(baseBytes) > tokenCap) {
|
|
447
|
-
const omittedIds = omittedListLimit === 0 ? [] : prepared.map((entry) => entry.item.id)
|
|
471
|
+
const omittedIds = omittedListLimit === 0 ? [] : prepared.slice(-omittedListLimit).map((entry) => entry.item.id);
|
|
448
472
|
return {
|
|
449
473
|
strategy: resolved.strategy,
|
|
450
474
|
selectedItems: [],
|
|
@@ -480,9 +504,14 @@ function buildContextHandoff(rawInput) {
|
|
|
480
504
|
}
|
|
481
505
|
const selectedPrepared = prepared.filter((_, index) => selectedIndices.has(index));
|
|
482
506
|
const selectedItems = selectedPrepared.map((entry) => entry.item);
|
|
483
|
-
const
|
|
484
|
-
const omittedItemIds =
|
|
485
|
-
|
|
507
|
+
const omittedTotal = prepared.length - selectedItems.length;
|
|
508
|
+
const omittedItemIds = [];
|
|
509
|
+
for (let index = prepared.length - 1;index >= 0 && omittedItemIds.length < omittedListLimit; index--) {
|
|
510
|
+
const entry = prepared[index];
|
|
511
|
+
if (entry !== undefined && !selectedIndices.has(index))
|
|
512
|
+
omittedItemIds.push(entry.item.id);
|
|
513
|
+
}
|
|
514
|
+
omittedItemIds.reverse();
|
|
486
515
|
const assemble = (ids) => {
|
|
487
516
|
const header = formatHeader({
|
|
488
517
|
strategy: resolved.strategy,
|
|
@@ -782,6 +811,7 @@ export {
|
|
|
782
811
|
ContextHandoffSelectedItemSchema,
|
|
783
812
|
ContextHandoffStrategySchema,
|
|
784
813
|
ContextHandoffStructuredItemSchema,
|
|
814
|
+
EXECUTOR_ENV_KEY_PATTERN2 as EXECUTOR_ENV_KEY_PATTERN,
|
|
785
815
|
EXECUTOR_ERRORS2 as EXECUTOR_ERRORS,
|
|
786
816
|
ExecutorDeltaSchema2 as ExecutorDeltaSchema,
|
|
787
817
|
ExecutorDriverCapabilitiesSchema2 as ExecutorDriverCapabilitiesSchema,
|
|
@@ -807,6 +837,8 @@ export {
|
|
|
807
837
|
JSON_RPC_LOCAL_TIMEOUT2 as JSON_RPC_LOCAL_TIMEOUT,
|
|
808
838
|
JSON_RPC_METHOD_NOT_FOUND2 as JSON_RPC_METHOD_NOT_FOUND,
|
|
809
839
|
JsonRpcError2 as JsonRpcError,
|
|
840
|
+
JsonRpcRecordSchema2 as JsonRpcRecordSchema,
|
|
841
|
+
JsonRpcValueSchema2 as JsonRpcValueSchema,
|
|
810
842
|
PlanLimitsSchema2 as PlanLimitsSchema,
|
|
811
843
|
PlanWindowSchema2 as PlanWindowSchema,
|
|
812
844
|
ThreadClaimSchema2 as ThreadClaimSchema,
|
|
@@ -836,8 +868,10 @@ export {
|
|
|
836
868
|
ownCredentials2 as ownCredentials,
|
|
837
869
|
planLimitsDue2 as planLimitsDue,
|
|
838
870
|
planLimitsReadFailed2 as planLimitsReadFailed,
|
|
871
|
+
planWindowDurationMins2 as planWindowDurationMins,
|
|
839
872
|
planWindowExpired2 as planWindowExpired,
|
|
840
873
|
projectExecutorDeltas2 as projectExecutorDeltas,
|
|
874
|
+
sanitizeProfileEnv2 as sanitizeProfileEnv,
|
|
841
875
|
spawnEngineProcess2 as spawnEngineProcess,
|
|
842
876
|
withInlineHandoffContext
|
|
843
877
|
};
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
normalizeError2
|
|
16
16
|
} from "../index-akf0xkrm.js";
|
|
17
|
-
import {
|
|
18
|
-
runNativeCommand2
|
|
19
|
-
} from "../index-pzhqydxb.js";
|
|
20
17
|
import {
|
|
21
18
|
streamNativeCommand2
|
|
22
19
|
} from "../index-3fym4j8n.js";
|
|
20
|
+
import {
|
|
21
|
+
runNativeCommand2
|
|
22
|
+
} from "../index-pzhqydxb.js";
|
|
23
23
|
import {
|
|
24
24
|
StreamLineLimitError2,
|
|
25
25
|
readBoundedUtf8Lines
|
package/dist/entrypoints/sync.js
CHANGED
|
@@ -526,10 +526,14 @@ class SyncSessionMachine {
|
|
|
526
526
|
this.continueSnapshot(checkedResume(cursor));
|
|
527
527
|
return;
|
|
528
528
|
}
|
|
529
|
-
|
|
530
|
-
|
|
529
|
+
if (cursor !== null)
|
|
530
|
+
assertNonNegativeSafeInteger("saved sync cursor", cursor, TypeError, {
|
|
531
|
+
absent: "refused"
|
|
532
|
+
});
|
|
533
|
+
this.openSession(cursor === null ? "full" : "incremental");
|
|
534
|
+
return chain(cursor === null ? this.ports.beginFullSync() : undefined, () => {
|
|
531
535
|
if (this.alive(stamp))
|
|
532
|
-
this.sendPage({ after: cursor
|
|
536
|
+
this.sendPage({ after: cursor, token: null });
|
|
533
537
|
});
|
|
534
538
|
}), (error) => {
|
|
535
539
|
if (!this.alive(stamp))
|
|
@@ -621,7 +625,7 @@ class SyncSessionMachine {
|
|
|
621
625
|
const full = this.mode === "full";
|
|
622
626
|
const from = full ? this.snapshotFrom : null;
|
|
623
627
|
const catchUp = from !== null && (page.latestVersion ?? from) > from;
|
|
624
|
-
return chain(full ? this.rebasePending() : undefined, () => this.saveLastPage(stamp, expected, catchUp ? from : page.latestVersion, catchUp));
|
|
628
|
+
return chain(full ? this.rebasePending() : undefined, () => this.saveLastPage(stamp, expected, catchUp ? from : page.latestVersion ?? from ?? undefined, catchUp));
|
|
625
629
|
}
|
|
626
630
|
saveLastPage(stamp, expected, cursor, catchUp) {
|
|
627
631
|
if (!this.alive(stamp))
|
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PlanWindowSchema2,
|
|
3
|
-
PlanLimitsSchema2
|
|
4
|
-
|
|
3
|
+
PlanLimitsSchema2,
|
|
4
|
+
clampPlanName
|
|
5
|
+
} from "./index-f9p62ean.js";
|
|
6
|
+
import {
|
|
7
|
+
isPositiveSafeInteger
|
|
8
|
+
} from "./index-gr0kxymw.js";
|
|
5
9
|
|
|
6
10
|
// src/agent-executor/plan-limits.ts
|
|
11
|
+
var MINUTES_SUFFIX = /:([1-9]\d*)m(?::|$)/;
|
|
7
12
|
function planWindowExpired2(window, now) {
|
|
8
13
|
return window.resetsAt !== undefined && Date.parse(window.resetsAt) <= now.getTime();
|
|
9
14
|
}
|
|
15
|
+
function planWindowDurationMins2(window) {
|
|
16
|
+
if (window.windowDurationMins !== undefined)
|
|
17
|
+
return window.windowDurationMins;
|
|
18
|
+
if (window.name === "five_hour" || window.name.startsWith("five_hour_"))
|
|
19
|
+
return 300;
|
|
20
|
+
if (window.name === "seven_day" || window.name.startsWith("seven_day_") || window.name === "weekly") {
|
|
21
|
+
return 10080;
|
|
22
|
+
}
|
|
23
|
+
const match = MINUTES_SUFFIX.exec(window.name);
|
|
24
|
+
if (match?.[1] !== undefined) {
|
|
25
|
+
const parsed = Number(match[1]);
|
|
26
|
+
if (isPositiveSafeInteger(parsed))
|
|
27
|
+
return parsed;
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
10
31
|
function planLimitsDue2(input) {
|
|
11
32
|
if (!Number.isFinite(input.maxAgeMs) || input.maxAgeMs < 0) {
|
|
12
33
|
throw new RangeError(`planLimitsDue maxAgeMs must be a finite non-negative number, received ${input.maxAgeMs}`);
|
|
13
34
|
}
|
|
14
35
|
if (input.limits === undefined)
|
|
15
36
|
return true;
|
|
37
|
+
if (input.limits.answer !== "known" && input.limits.error === undefined)
|
|
38
|
+
return false;
|
|
16
39
|
if (input.limits.windows.some((window) => planWindowExpired2(window, input.now)))
|
|
17
40
|
return true;
|
|
18
41
|
return input.now.getTime() - Date.parse(input.limits.observedAt) >= input.maxAgeMs;
|
|
@@ -30,11 +53,13 @@ function mergeRateLimitEvent2(input) {
|
|
|
30
53
|
for (const window of input.windows)
|
|
31
54
|
merged.set(window.name, PlanWindowSchema2.parse(window));
|
|
32
55
|
const all = [...merged.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
56
|
+
const plan = clampPlanName(input.plan) ?? input.previous?.plan;
|
|
33
57
|
return PlanLimitsSchema2.parse({
|
|
34
58
|
answer: all.length > 0 ? "known" : input.previous?.answer ?? "unpublished",
|
|
35
59
|
windows: all,
|
|
36
|
-
observedAt: input.now.toISOString()
|
|
60
|
+
observedAt: input.now.toISOString(),
|
|
61
|
+
...plan !== undefined && { plan }
|
|
37
62
|
});
|
|
38
63
|
}
|
|
39
64
|
|
|
40
|
-
export { planWindowExpired2, planLimitsDue2, planLimitsReadFailed2, mergeRateLimitEvent2 };
|
|
65
|
+
export { planWindowExpired2, planWindowDurationMins2, planLimitsDue2, planLimitsReadFailed2, mergeRateLimitEvent2 };
|
|
@@ -5,9 +5,22 @@ import {
|
|
|
5
5
|
AgentToolResultPartSchema2,
|
|
6
6
|
AgentMessagePartSchema2
|
|
7
7
|
} from "./index-2rf33y2h.js";
|
|
8
|
+
import {
|
|
9
|
+
createBoundedChannel2
|
|
10
|
+
} from "./index-09f7w2qq.js";
|
|
11
|
+
import {
|
|
12
|
+
runNativeCommand2
|
|
13
|
+
} from "./index-pzhqydxb.js";
|
|
14
|
+
import {
|
|
15
|
+
jsonDataRefusal
|
|
16
|
+
} from "./index-m6w6jtda.js";
|
|
8
17
|
import {
|
|
9
18
|
MAX_TIMER_MS
|
|
10
19
|
} from "./index-mxt0wfjy.js";
|
|
20
|
+
import {
|
|
21
|
+
abortReason,
|
|
22
|
+
linkAbortSignals
|
|
23
|
+
} from "./index-rptj3qnc.js";
|
|
11
24
|
|
|
12
25
|
// src/agent-executor/executor-contract.ts
|
|
13
26
|
import { z as z2 } from "zod";
|
|
@@ -265,12 +278,14 @@ var PlanWindowSchema2 = z3.strictObject({
|
|
|
265
278
|
usedPercent: z3.number().min(0).max(100),
|
|
266
279
|
resetsAt: z3.iso.datetime({ offset: true }).optional(),
|
|
267
280
|
windowDurationMins: z3.int().positive().optional(),
|
|
268
|
-
label: Name.optional()
|
|
281
|
+
label: Name.optional(),
|
|
282
|
+
scope: Name.optional()
|
|
269
283
|
});
|
|
270
284
|
var PlanLimitsSchema2 = z3.strictObject({
|
|
271
285
|
answer: z3.enum(["known", "no-plan-limit", "unpublished"]),
|
|
272
286
|
windows: z3.array(PlanWindowSchema2).max(HELLO_LIMITS.windows),
|
|
273
287
|
observedAt: z3.iso.datetime({ offset: true }),
|
|
288
|
+
plan: Name.optional(),
|
|
274
289
|
error: Text.optional()
|
|
275
290
|
});
|
|
276
291
|
var ExecutorProfileSchema2 = z3.strictObject({
|
|
@@ -324,20 +339,48 @@ var ExecutorHelloAckSchema2 = z3.strictObject({
|
|
|
324
339
|
resumable: z3.array(ExecutorResumeAckSchema).max(HELLO_LIMITS.resumableTurns)
|
|
325
340
|
});
|
|
326
341
|
|
|
342
|
+
// src/agent-executor/session-primitives.ts
|
|
343
|
+
import { createHash } from "node:crypto";
|
|
344
|
+
import { z as z5 } from "zod";
|
|
345
|
+
|
|
327
346
|
// src/agent-executor/profile.ts
|
|
347
|
+
import { homedir } from "node:os";
|
|
348
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
328
349
|
import { z as z4 } from "zod";
|
|
350
|
+
var EXECUTOR_ENV_KEY_PATTERN2 = /^[A-Z_][A-Z0-9_]*$/;
|
|
351
|
+
function sanitizeProfileEnv2(env) {
|
|
352
|
+
const sanitized = {};
|
|
353
|
+
if (env === undefined)
|
|
354
|
+
return sanitized;
|
|
355
|
+
for (const [key, value] of Object.entries(env)) {
|
|
356
|
+
if (typeof value === "string" && EXECUTOR_ENV_KEY_PATTERN2.test(key)) {
|
|
357
|
+
sanitized[key] = value;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return sanitized;
|
|
361
|
+
}
|
|
329
362
|
var ExecutorProfileConfigSchema2 = z4.strictObject({
|
|
330
363
|
profileId: z4.string().min(1).max(128),
|
|
331
364
|
engine: ExecutorEngineSchema2,
|
|
332
365
|
home: z4.string().min(1),
|
|
366
|
+
claudeConfigDir: z4.literal("default").optional(),
|
|
333
367
|
accountLabel: z4.string().min(1).max(200).optional(),
|
|
334
|
-
env: z4.record(z4.string().regex(
|
|
368
|
+
env: z4.record(z4.string().regex(EXECUTOR_ENV_KEY_PATTERN2), z4.string()).default({})
|
|
369
|
+
}).refine((profile) => profile.claudeConfigDir === undefined || (profile.engine === "claude-sdk" || profile.engine === "claude-cli") && profile.env.CLAUDE_CONFIG_DIR === undefined, {
|
|
370
|
+
path: ["claudeConfigDir"],
|
|
371
|
+
message: "Default Claude configuration requires a Claude engine and no declared CLAUDE_CONFIG_DIR"
|
|
335
372
|
});
|
|
336
|
-
function engineProfile(engine, raw) {
|
|
373
|
+
function engineProfile(engine, raw, ambient = process.env) {
|
|
337
374
|
const profile = ExecutorProfileConfigSchema2.parse(raw);
|
|
338
375
|
if (profile.engine !== engine) {
|
|
339
376
|
throw new TypeError(`Profile ${profile.profileId} is for the ${profile.engine} engine; this driver runs ${engine}`);
|
|
340
377
|
}
|
|
378
|
+
if (profile.claudeConfigDir === "default") {
|
|
379
|
+
const userHome = profile.env.HOME ?? ambient.HOME ?? homedir();
|
|
380
|
+
if (!isAbsolute(userHome) || !isAbsolute(profile.home) || resolve(profile.home) !== resolve(userHome, ".claude")) {
|
|
381
|
+
throw new TypeError("The default Claude profile home must match .claude under the engine user home");
|
|
382
|
+
}
|
|
383
|
+
}
|
|
341
384
|
return profile;
|
|
342
385
|
}
|
|
343
386
|
var INHERITED = ["PATH", "HOME", "USER", "LOGNAME", "SHELL", "LANG", "TMPDIR", "TERM", "TZ"];
|
|
@@ -357,7 +400,7 @@ var HOME_VARIABLE = {
|
|
|
357
400
|
acp: "HOME"
|
|
358
401
|
};
|
|
359
402
|
function engineEnvironment2(rawProfile, ambient) {
|
|
360
|
-
const profile =
|
|
403
|
+
const profile = engineProfile(rawProfile.engine, rawProfile, ambient);
|
|
361
404
|
const env = {};
|
|
362
405
|
for (const [name, value] of Object.entries(ambient)) {
|
|
363
406
|
if (value === undefined)
|
|
@@ -365,14 +408,18 @@ function engineEnvironment2(rawProfile, ambient) {
|
|
|
365
408
|
if (INHERITED.includes(name) || name.startsWith("LC_"))
|
|
366
409
|
env[name] = value;
|
|
367
410
|
}
|
|
368
|
-
|
|
411
|
+
if (profile.claudeConfigDir === "default") {
|
|
412
|
+
env.HOME = profile.env.HOME ?? env.HOME ?? dirname(resolve(profile.home));
|
|
413
|
+
} else {
|
|
414
|
+
env[HOME_VARIABLE[profile.engine]] = profile.home;
|
|
415
|
+
}
|
|
369
416
|
return { ...env, ...profile.env };
|
|
370
417
|
}
|
|
371
418
|
function ownCredentials2(ambient) {
|
|
372
419
|
return CREDENTIAL_VARIABLES2.filter((name) => (ambient[name] ?? "") !== "");
|
|
373
420
|
}
|
|
374
421
|
function helloProfile2(input) {
|
|
375
|
-
const profile =
|
|
422
|
+
const profile = engineProfile(input.profile.engine, input.profile, input.ambient);
|
|
376
423
|
return {
|
|
377
424
|
profileId: profile.profileId,
|
|
378
425
|
engine: profile.engine,
|
|
@@ -384,4 +431,169 @@ function helloProfile2(input) {
|
|
|
384
431
|
};
|
|
385
432
|
}
|
|
386
433
|
|
|
387
|
-
|
|
434
|
+
// src/agent-executor/session-primitives.ts
|
|
435
|
+
var TURN_QUEUE = { maxItems: 65536, maxBytes: 64 * 1024 * 1024 };
|
|
436
|
+
var MAX_DATE_MS = 8640000000000000;
|
|
437
|
+
var SAFE_JSON_LIMITS = {
|
|
438
|
+
maxDepth: 100,
|
|
439
|
+
maxNodes: 1e5,
|
|
440
|
+
omitObjectUndefined: true,
|
|
441
|
+
zodJson: true
|
|
442
|
+
};
|
|
443
|
+
function nonEmptyString(value) {
|
|
444
|
+
return typeof value === "string" && value.trim().length > 0 ? value : undefined;
|
|
445
|
+
}
|
|
446
|
+
function clampPlanName(value, maxChars = 256) {
|
|
447
|
+
const trimmed = nonEmptyString(value)?.trim();
|
|
448
|
+
return trimmed !== undefined ? trimmed.slice(0, maxChars) : undefined;
|
|
449
|
+
}
|
|
450
|
+
function epochMsToIso(ms) {
|
|
451
|
+
if (ms === null || ms === undefined)
|
|
452
|
+
return;
|
|
453
|
+
if (!Number.isFinite(ms) || Math.abs(ms) > MAX_DATE_MS)
|
|
454
|
+
return;
|
|
455
|
+
return new Date(ms).toISOString();
|
|
456
|
+
}
|
|
457
|
+
function epochSecondsToIso(seconds) {
|
|
458
|
+
if (seconds === null || seconds === undefined)
|
|
459
|
+
return;
|
|
460
|
+
return epochMsToIso(seconds * 1000);
|
|
461
|
+
}
|
|
462
|
+
function createTurnDeltaChannel() {
|
|
463
|
+
return createBoundedChannel2({
|
|
464
|
+
policy: "ordered",
|
|
465
|
+
...TURN_QUEUE,
|
|
466
|
+
sizeOf: (delta) => JSON.stringify(delta).length
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
function normalizeDeltaIdentifiers(delta) {
|
|
470
|
+
if (delta.type === "tool-call" || delta.type === "tool-result") {
|
|
471
|
+
const callId = nonEmptyString(delta.callId) ?? delta.itemId;
|
|
472
|
+
const toolName = nonEmptyString(delta.toolName) ?? "unknown";
|
|
473
|
+
if (callId === delta.callId && toolName === delta.toolName)
|
|
474
|
+
return delta;
|
|
475
|
+
return { ...delta, callId, toolName };
|
|
476
|
+
}
|
|
477
|
+
if (delta.type === "request") {
|
|
478
|
+
const callId = nonEmptyString(delta.callId);
|
|
479
|
+
const toolName = delta.toolName === undefined ? undefined : nonEmptyString(delta.toolName) ?? "tool";
|
|
480
|
+
if (callId === delta.callId && toolName === delta.toolName)
|
|
481
|
+
return delta;
|
|
482
|
+
const { callId: _callId, toolName: _toolName, ...rest } = delta;
|
|
483
|
+
return {
|
|
484
|
+
...rest,
|
|
485
|
+
...callId !== undefined && { callId },
|
|
486
|
+
...toolName !== undefined && { toolName }
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
return delta;
|
|
490
|
+
}
|
|
491
|
+
function offerTurnDelta(channel, delta) {
|
|
492
|
+
if (channel === undefined)
|
|
493
|
+
return;
|
|
494
|
+
const result = channel.offer(normalizeDeltaIdentifiers(delta));
|
|
495
|
+
if (result.outcome === "refused" && result.reason !== "not-open") {
|
|
496
|
+
channel.fail(new Error(`The turn's delta queue refused a delta (${result.reason})`));
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
function sessionAbort(caller) {
|
|
500
|
+
if (caller?.aborted)
|
|
501
|
+
throw abortReason(caller);
|
|
502
|
+
const own = new AbortController;
|
|
503
|
+
const link = caller ? linkAbortSignals(caller, own.signal) : { signal: own.signal, release: () => {
|
|
504
|
+
return;
|
|
505
|
+
} };
|
|
506
|
+
return { signal: link.signal, abort: () => own.abort(), release: link.release };
|
|
507
|
+
}
|
|
508
|
+
function runEngineCli(input) {
|
|
509
|
+
return runNativeCommand2({
|
|
510
|
+
executable: input.executable,
|
|
511
|
+
args: [...input.prefix, ...input.args],
|
|
512
|
+
env: engineEnvironment2(input.profile, input.ambient),
|
|
513
|
+
envPolicy: "declared-only",
|
|
514
|
+
capture: true,
|
|
515
|
+
maxOutputBytes: 1024 * 1024,
|
|
516
|
+
timeoutMs: 30000
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
function errorText(error) {
|
|
520
|
+
return error instanceof Error ? error.message : String(error);
|
|
521
|
+
}
|
|
522
|
+
async function stopConnection(connection, primary) {
|
|
523
|
+
let stopFailure;
|
|
524
|
+
try {
|
|
525
|
+
await connection.engine.stop();
|
|
526
|
+
} catch (error) {
|
|
527
|
+
stopFailure = { error };
|
|
528
|
+
}
|
|
529
|
+
await connection.reading;
|
|
530
|
+
if (stopFailure === undefined)
|
|
531
|
+
return;
|
|
532
|
+
if (primary === undefined)
|
|
533
|
+
throw stopFailure.error;
|
|
534
|
+
throw new AggregateError([primary.error, stopFailure.error], `${errorText(primary.error)}; stopping the engine also failed: ${errorText(stopFailure.error)}`, { cause: primary.error });
|
|
535
|
+
}
|
|
536
|
+
async function withEphemeralConnection(connect, use) {
|
|
537
|
+
const stop = new AbortController;
|
|
538
|
+
const connection = await connect(stop.signal);
|
|
539
|
+
let answer;
|
|
540
|
+
try {
|
|
541
|
+
answer = await use(connection);
|
|
542
|
+
} catch (error) {
|
|
543
|
+
stop.abort();
|
|
544
|
+
await stopConnection(connection, { error });
|
|
545
|
+
throw error;
|
|
546
|
+
}
|
|
547
|
+
stop.abort();
|
|
548
|
+
try {
|
|
549
|
+
await stopConnection(connection);
|
|
550
|
+
} catch {}
|
|
551
|
+
return answer;
|
|
552
|
+
}
|
|
553
|
+
function safeJsonValue(value) {
|
|
554
|
+
const snapshot = {};
|
|
555
|
+
const refusal = jsonDataRefusal(value, SAFE_JSON_LIMITS, snapshot);
|
|
556
|
+
if (refusal !== undefined) {
|
|
557
|
+
throw new TypeError(`Expected bounded JSON data (refused: ${refusal})`);
|
|
558
|
+
}
|
|
559
|
+
return z5.json().parse(snapshot.value);
|
|
560
|
+
}
|
|
561
|
+
function invokeSafely(invoke) {
|
|
562
|
+
try {
|
|
563
|
+
const result = invoke();
|
|
564
|
+
if (typeof result === "object" && result !== null && "then" in result && typeof result.then === "function") {
|
|
565
|
+
Promise.resolve(result).catch(() => {
|
|
566
|
+
return;
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
} catch {}
|
|
570
|
+
}
|
|
571
|
+
function emitStartupPhase(callback, phase) {
|
|
572
|
+
if (callback === undefined)
|
|
573
|
+
return;
|
|
574
|
+
const parsed = ExecutorStartupPhaseSchema2.parse(phase);
|
|
575
|
+
invokeSafely(() => callback(parsed));
|
|
576
|
+
}
|
|
577
|
+
function clampUniqueWindowName(prefix, suffix, seenNames, disambiguatorSeed, maxChars = 256) {
|
|
578
|
+
const maxPrefix = Math.max(1, maxChars - suffix.length);
|
|
579
|
+
let candidate = prefix.length > maxPrefix ? `${prefix.slice(0, maxPrefix)}${suffix}`.slice(0, maxChars) : `${prefix}${suffix}`;
|
|
580
|
+
if (!seenNames.has(candidate)) {
|
|
581
|
+
seenNames.add(candidate);
|
|
582
|
+
return candidate;
|
|
583
|
+
}
|
|
584
|
+
const digest = createHash("sha256").update(disambiguatorSeed).digest("hex").slice(0, 8);
|
|
585
|
+
const tag = `#${digest}${suffix}`;
|
|
586
|
+
const room = Math.max(1, maxChars - tag.length);
|
|
587
|
+
candidate = `${prefix.slice(0, room)}${tag}`.slice(0, maxChars);
|
|
588
|
+
let index = 2;
|
|
589
|
+
while (seenNames.has(candidate)) {
|
|
590
|
+
const indexedTag = `#${digest}_${index}${suffix}`;
|
|
591
|
+
const indexedRoom = Math.max(1, maxChars - indexedTag.length);
|
|
592
|
+
candidate = `${prefix.slice(0, indexedRoom)}${indexedTag}`.slice(0, maxChars);
|
|
593
|
+
index += 1;
|
|
594
|
+
}
|
|
595
|
+
seenNames.add(candidate);
|
|
596
|
+
return candidate;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export { ExecutorRawSchema2, ExecutorTokenUsageSchema2, ExecutorModelUsageSchema2, ExecutorThreadDispositionSchema2, ExecutorStartupPhaseSchema2, ExecutorStatusDeltaSchema2, ExecutorErrorKindSchema2, ExecutorDeltaSchema2, ThreadClaimSchema2, ThreadLeaseSchema2, ThreadRenewSchema2, ThreadReleaseSchema2, TurnOfferSchema2, TurnPhaseSchema2, TurnFailureKindSchema2, TurnReportSchema2, TurnReportAckSchema2, TurnInterruptSchema2, InteractionReplySchema2, EXECUTOR_ERRORS2, ExecutorEngineSchema2, ExecutorReconcileSchema2, ExecutorDriverCapabilitiesSchema2, PlanWindowSchema2, PlanLimitsSchema2, ExecutorProfileSchema2, ExecutorEngineInfoSchema2, ExecutorResumableTurnSchema2, ExecutorHelloSchema2, ExecutorHelloAckSchema2, EXECUTOR_ENV_KEY_PATTERN2, sanitizeProfileEnv2, ExecutorProfileConfigSchema2, engineProfile, CREDENTIAL_VARIABLES2, engineEnvironment2, ownCredentials2, helloProfile2, TURN_QUEUE, nonEmptyString, clampPlanName, epochMsToIso, epochSecondsToIso, createTurnDeltaChannel, offerTurnDelta, sessionAbort, runEngineCli, stopConnection, withEphemeralConnection, safeJsonValue, invokeSafely, emitStartupPhase, clampUniqueWindowName };
|