@codexhost/cli-win32-arm64 0.26.1 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +561 -322
- package/app/console-web.js +543 -369
- package/app/desktop-controller.mjs +385 -243
- package/app/host-runtime.mjs +7774 -3488
- package/app/plugins/antigravity/plugin.mjs +8669 -417
- package/app/plugins/claude-code/plugin.mjs +736 -393
- package/app/plugins/codebuddy/plugin.mjs +388 -233
- package/app/plugins/codex-usage/plugin.mjs +363 -230
- package/app/plugins/copilot/plugin.mjs +388 -233
- package/app/plugins/cursor-cli/plugin.mjs +363 -230
- package/app/plugins/deepseek-harness/plugin.mjs +388 -233
- package/app/plugins/devin/plugin.mjs +363 -230
- package/app/plugins/grok/plugin.mjs +363 -230
- package/app/plugins/hermes/plugin.mjs +363 -230
- package/app/plugins/kimi-code/plugin.mjs +492 -270
- package/app/plugins/kiro-cli/plugin.mjs +363 -230
- package/app/plugins/omp/plugin.mjs +363 -230
- package/app/plugins/opencode/manifest.json +1 -1
- package/app/plugins/opencode/plugin.mjs +439 -248
- package/app/plugins/pi/plugin.mjs +363 -230
- package/app/plugins/qoder/plugin.mjs +363 -230
- package/app/plugins/qoder-cn/plugin.mjs +363 -230
- package/app/plugins/qwen-code/plugin.mjs +363 -230
- package/app/plugins/workbuddy/plugin.mjs +383 -245
- package/app/plugins/zcode/plugin.mjs +363 -230
- package/app/renderer-extension.js +2071 -555
- package/app/web/assets/index-D9l7_ThH.js +199 -0
- package/app/web/assets/index-nw2RXcDu.css +1 -0
- package/app/web/codexhost-settings.js +67 -67
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
- package/app/web/plugins/deepseek-ai__dsh-client-shortcuts/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +4 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +16 -16
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +19 -19
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-shortcuts/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +4 -4
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +71 -71
- package/app/web/plugins.json +2 -1
- package/app/web-modules/server.mjs +2884 -1128
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shell.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-CR4Y8Ndj.css +0 -1
- package/app/web/assets/index-Dw-yHAxN.js +0 -196
|
@@ -19864,6 +19864,38 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
|
|
|
19864
19864
|
// ../../shared-contracts/dist/harness-route-limit.js
|
|
19865
19865
|
var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
|
|
19866
19866
|
|
|
19867
|
+
// ../../shared-contracts/dist/thread-handoff.js
|
|
19868
|
+
var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
19869
|
+
message: "Value must not be empty or whitespace"
|
|
19870
|
+
});
|
|
19871
|
+
var THREAD_HANDOFF_METHOD = "codexhost/thread/handoff";
|
|
19872
|
+
var threadHandoffParamsSchema = external_exports.object({
|
|
19873
|
+
sourceThreadId: hostThreadIdSchema,
|
|
19874
|
+
lastTurnId: hostTurnIdSchema.optional(),
|
|
19875
|
+
targetHarnessId: harnessIdSchema,
|
|
19876
|
+
targetModel: nonBlankTextSchema2.max(1024).optional(),
|
|
19877
|
+
targetThinkingOptionId: nonBlankTextSchema2.max(128).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").optional()
|
|
19878
|
+
}).strict();
|
|
19879
|
+
var threadHandoffMetadataSchema = external_exports.object({
|
|
19880
|
+
sourceThreadId: hostThreadIdSchema,
|
|
19881
|
+
sourceHarnessId: harnessIdSchema,
|
|
19882
|
+
sourceHarnessLabel: nonBlankTextSchema2.max(256).optional(),
|
|
19883
|
+
sourceModel: nonBlankTextSchema2.max(1024).optional(),
|
|
19884
|
+
targetHarnessId: harnessIdSchema,
|
|
19885
|
+
targetHarnessLabel: nonBlankTextSchema2.max(256).optional(),
|
|
19886
|
+
targetModel: nonBlankTextSchema2.max(1024).optional(),
|
|
19887
|
+
totalTurns: external_exports.number().int().min(1),
|
|
19888
|
+
boundaryTurnNumber: external_exports.number().int().min(1),
|
|
19889
|
+
includedTurnNumbers: external_exports.array(external_exports.number().int().min(1)),
|
|
19890
|
+
omittedTurns: external_exports.number().int().min(0),
|
|
19891
|
+
preview: external_exports.string().max(32e3),
|
|
19892
|
+
createdAtMs: external_exports.number().int().nonnegative()
|
|
19893
|
+
}).strict();
|
|
19894
|
+
var threadHandoffResultSchema = external_exports.object({
|
|
19895
|
+
threadId: hostThreadIdSchema,
|
|
19896
|
+
handoff: threadHandoffMetadataSchema
|
|
19897
|
+
}).strict();
|
|
19898
|
+
|
|
19867
19899
|
// ../../shared-contracts/dist/thread-usage.js
|
|
19868
19900
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
19869
19901
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -20047,7 +20079,7 @@ var HARNESS_MODEL_REF_MAX_LENGTH = 512;
|
|
|
20047
20079
|
var HARNESS_MODEL_LABEL_MAX_LENGTH = 256;
|
|
20048
20080
|
var HARNESS_THINKING_OPTION_ID_MAX_LENGTH = 128;
|
|
20049
20081
|
var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
|
|
20050
|
-
var
|
|
20082
|
+
var nonBlankTextSchema3 = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
20051
20083
|
message: "Value must not be empty or whitespace"
|
|
20052
20084
|
});
|
|
20053
20085
|
var harnessModelRefIdSchema = external_exports.string().min(1).max(HARNESS_MODEL_REF_MAX_LENGTH).refine((id3) => !new RegExp("\\p{Cc}", "u").test(id3), "Model Ref must not contain control characters").brand();
|
|
@@ -20059,15 +20091,15 @@ var harnessModelRefSchema = external_exports.object({
|
|
|
20059
20091
|
function sameHarnessModelRef(left, right) {
|
|
20060
20092
|
return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
|
|
20061
20093
|
}
|
|
20062
|
-
var harnessThinkingOptionIdSchema =
|
|
20063
|
-
var harnessResolvedModelLabelSchema =
|
|
20094
|
+
var harnessThinkingOptionIdSchema = nonBlankTextSchema3.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
|
|
20095
|
+
var harnessResolvedModelLabelSchema = nonBlankTextSchema3.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
|
|
20064
20096
|
var harnessThinkingOptionSchema = external_exports.object({
|
|
20065
20097
|
id: harnessThinkingOptionIdSchema,
|
|
20066
|
-
label:
|
|
20098
|
+
label: nonBlankTextSchema3.max(HARNESS_MODEL_LABEL_MAX_LENGTH)
|
|
20067
20099
|
}).strict();
|
|
20068
20100
|
var harnessModelSchema = external_exports.object({
|
|
20069
20101
|
ref: harnessModelRefSchema,
|
|
20070
|
-
label:
|
|
20102
|
+
label: nonBlankTextSchema3.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
20071
20103
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
20072
20104
|
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
20073
20105
|
fastModel: harnessModelRefSchema.optional(),
|
|
@@ -20231,7 +20263,7 @@ var harnessInspectionSchema = external_exports.union([
|
|
|
20231
20263
|
]);
|
|
20232
20264
|
var harnessInspectParamsSchema = external_exports.object({
|
|
20233
20265
|
harnessId: harnessIdSchema,
|
|
20234
|
-
cwd:
|
|
20266
|
+
cwd: nonBlankTextSchema3.max(16384).optional(),
|
|
20235
20267
|
refresh: external_exports.boolean().optional(),
|
|
20236
20268
|
/** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
|
|
20237
20269
|
purpose: external_exports.literal("availability").optional(),
|
|
@@ -20261,12 +20293,13 @@ var codexThreadInspectionSchema = external_exports.object({
|
|
|
20261
20293
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
20262
20294
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
20263
20295
|
history: harnessHistoryCapabilitiesSchema.optional(),
|
|
20264
|
-
supportsThreadReferences: external_exports.literal(true).optional()
|
|
20296
|
+
supportsThreadReferences: external_exports.literal(true).optional(),
|
|
20297
|
+
handoff: threadHandoffMetadataSchema.optional()
|
|
20265
20298
|
}).strict();
|
|
20266
20299
|
var externalThreadInspectionSchema = external_exports.object({
|
|
20267
20300
|
owner: external_exports.literal("external"),
|
|
20268
|
-
harnessId:
|
|
20269
|
-
transportModelId:
|
|
20301
|
+
harnessId: nonBlankTextSchema3.max(256),
|
|
20302
|
+
transportModelId: nonBlankTextSchema3.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
|
|
20270
20303
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
20271
20304
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
20272
20305
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -20276,6 +20309,7 @@ var externalThreadInspectionSchema = external_exports.object({
|
|
|
20276
20309
|
catalog: harnessModelCatalogSchema.optional(),
|
|
20277
20310
|
history: harnessHistoryCapabilitiesSchema,
|
|
20278
20311
|
usage: threadUsageSnapshotSchema.optional(),
|
|
20312
|
+
handoff: threadHandoffMetadataSchema.optional(),
|
|
20279
20313
|
locked: external_exports.literal(true)
|
|
20280
20314
|
}).strict();
|
|
20281
20315
|
var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
|
|
@@ -20913,6 +20947,7 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
20913
20947
|
"codexhost/harness/preferences/get",
|
|
20914
20948
|
"codexhost/harness/preferences/patch",
|
|
20915
20949
|
"thread/list",
|
|
20950
|
+
"thread/metadata/update",
|
|
20916
20951
|
"codexhost/thread/catalog/read",
|
|
20917
20952
|
"thread/read",
|
|
20918
20953
|
"thread/resume",
|
|
@@ -20937,6 +20972,10 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
20937
20972
|
"thread/queue/start",
|
|
20938
20973
|
"codexhost/thread/queue/send-now",
|
|
20939
20974
|
"codexhost/workspace/read",
|
|
20975
|
+
"project/create",
|
|
20976
|
+
"project/update",
|
|
20977
|
+
"project/delete",
|
|
20978
|
+
"project/move",
|
|
20940
20979
|
"codexhost/thread/tree/read",
|
|
20941
20980
|
"codexhost/thread/pins/list",
|
|
20942
20981
|
"codexhost/thread/sections/list",
|
|
@@ -20954,6 +20993,7 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
20954
20993
|
"codexhost/harness/commands/inspect",
|
|
20955
20994
|
"codexhost/thread/command/execute",
|
|
20956
20995
|
"codexhost/thread/fork",
|
|
20996
|
+
THREAD_HANDOFF_METHOD,
|
|
20957
20997
|
"codexhost/harness/session-import/sources",
|
|
20958
20998
|
"codexhost/harness/session-import/list",
|
|
20959
20999
|
"codexhost/harness/session-import/import",
|
|
@@ -21005,6 +21045,7 @@ var clientProjectlessWorkspaceSchema = external_exports.object({
|
|
|
21005
21045
|
}).strict();
|
|
21006
21046
|
var clientWorkspaceSnapshotSchema = external_exports.object({
|
|
21007
21047
|
projects: external_exports.array(external_exports.object({ id: external_exports.string(), name: external_exports.string(), rootPaths: external_exports.array(external_exports.string()) })),
|
|
21048
|
+
nativeProjects: external_exports.literal(true).optional(),
|
|
21008
21049
|
assignments: external_exports.record(external_exports.string(), external_exports.string()),
|
|
21009
21050
|
projectless: external_exports.array(external_exports.string()),
|
|
21010
21051
|
/** Canonical external pin membership; pins/list provides the native merged order. */
|
|
@@ -21019,6 +21060,7 @@ var clientChannelCursorSchema = external_exports.object({
|
|
|
21019
21060
|
sequence: external_exports.number().int().nonnegative()
|
|
21020
21061
|
});
|
|
21021
21062
|
var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
21063
|
+
external_exports.object({ type: external_exports.literal("projects-changed"), cursor: clientChannelCursorSchema }),
|
|
21022
21064
|
external_exports.object({
|
|
21023
21065
|
type: external_exports.literal("skills-changed"),
|
|
21024
21066
|
cursor: clientChannelCursorSchema,
|
|
@@ -21182,7 +21224,8 @@ var clientThreadSnapshotSchema = external_exports.object({
|
|
|
21182
21224
|
items: external_exports.array(clientQueuedSubmissionSchema),
|
|
21183
21225
|
pausedReason: external_exports.enum(["interrupted", "outcome-unknown", "failed"]).nullable()
|
|
21184
21226
|
}).optional(),
|
|
21185
|
-
interactions: external_exports.array(clientInteractionSchema)
|
|
21227
|
+
interactions: external_exports.array(clientInteractionSchema),
|
|
21228
|
+
handoff: threadHandoffMetadataSchema.optional()
|
|
21186
21229
|
});
|
|
21187
21230
|
var clientChannelDescriptorSchema = external_exports.object({
|
|
21188
21231
|
version: external_exports.literal(CLIENT_CHANNEL_VERSION),
|
|
@@ -21191,7 +21234,10 @@ var clientChannelDescriptorSchema = external_exports.object({
|
|
|
21191
21234
|
port: external_exports.number().int().min(1).max(65535),
|
|
21192
21235
|
token: external_exports.string().regex(/^[0-9a-f]{64}$/u),
|
|
21193
21236
|
startedAt: external_exports.number(),
|
|
21194
|
-
epoch: external_exports.string().uuid()
|
|
21237
|
+
epoch: external_exports.string().uuid(),
|
|
21238
|
+
capabilities: external_exports.object({
|
|
21239
|
+
peerDelegation: external_exports.literal(1).optional()
|
|
21240
|
+
}).optional()
|
|
21195
21241
|
});
|
|
21196
21242
|
var clientChannelResponseSchema = external_exports.object({
|
|
21197
21243
|
epoch: external_exports.string().uuid(),
|
|
@@ -21210,10 +21256,18 @@ var threadCatalogReadParamsSchema = external_exports.object({
|
|
|
21210
21256
|
* `excludeCwds` folder, the branch ends, or a page bound is reached. Every row read is
|
|
21211
21257
|
* returned, so the native cursors stay contiguous.
|
|
21212
21258
|
*/
|
|
21213
|
-
scope: external_exports.
|
|
21214
|
-
|
|
21215
|
-
|
|
21216
|
-
|
|
21259
|
+
scope: external_exports.union([
|
|
21260
|
+
external_exports.object({
|
|
21261
|
+
cwd: external_exports.string().min(1).max(4096),
|
|
21262
|
+
excludeCwds: external_exports.array(external_exports.string().min(1).max(4096)).max(1024)
|
|
21263
|
+
}).strict(),
|
|
21264
|
+
external_exports.object({
|
|
21265
|
+
projectId: external_exports.string().min(1).max(1024),
|
|
21266
|
+
legacyThreadIds: external_exports.array(external_exports.string().min(1).max(1024)).max(1024),
|
|
21267
|
+
/** Roots whose Threads without a project ID belong to this project, as on Desktop. */
|
|
21268
|
+
rootPaths: external_exports.array(external_exports.string().min(1).max(4096)).max(1024).optional()
|
|
21269
|
+
}).strict()
|
|
21270
|
+
]).optional()
|
|
21217
21271
|
}).strict();
|
|
21218
21272
|
var threadCatalogReadResultSchema = external_exports.object({
|
|
21219
21273
|
threads: external_exports.array(jsonObjectSchema),
|
|
@@ -21400,6 +21454,283 @@ var delegationReadParamsSchema = external_exports.strictObject({
|
|
|
21400
21454
|
to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
|
|
21401
21455
|
});
|
|
21402
21456
|
|
|
21457
|
+
// ../../shared-contracts/dist/remote-peers.js
|
|
21458
|
+
var REMOTE_PEER_ID_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/u;
|
|
21459
|
+
var remotePeerIdSchema = external_exports.string().regex(REMOTE_PEER_ID_PATTERN);
|
|
21460
|
+
var remotePeerHostIdSchema = external_exports.string().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u);
|
|
21461
|
+
var remotePeerTransportKindSchema = external_exports.enum(["relay", "tailscale", "lan", "custom"]);
|
|
21462
|
+
var REMOTE_PEER_COLORS = [
|
|
21463
|
+
"blue",
|
|
21464
|
+
"purple",
|
|
21465
|
+
"cyan",
|
|
21466
|
+
"green",
|
|
21467
|
+
"amber",
|
|
21468
|
+
"rose",
|
|
21469
|
+
"slate"
|
|
21470
|
+
];
|
|
21471
|
+
var remotePeerColorSchema = external_exports.enum(REMOTE_PEER_COLORS);
|
|
21472
|
+
var REMOTE_PEER_COLOR_SET = new Set(REMOTE_PEER_COLORS);
|
|
21473
|
+
var remotePeerStateSchema = external_exports.enum([
|
|
21474
|
+
"connected",
|
|
21475
|
+
"connecting",
|
|
21476
|
+
"auth-error",
|
|
21477
|
+
"offline",
|
|
21478
|
+
"disabled"
|
|
21479
|
+
]);
|
|
21480
|
+
var remotePeerSummarySchema = external_exports.object({
|
|
21481
|
+
peerId: remotePeerIdSchema,
|
|
21482
|
+
hostId: remotePeerHostIdSchema,
|
|
21483
|
+
name: external_exports.string().min(1).max(120),
|
|
21484
|
+
color: remotePeerColorSchema.optional(),
|
|
21485
|
+
origin: external_exports.string().min(1).max(2048),
|
|
21486
|
+
transportKind: remotePeerTransportKindSchema,
|
|
21487
|
+
encrypted: external_exports.boolean(),
|
|
21488
|
+
enabled: external_exports.boolean(),
|
|
21489
|
+
state: remotePeerStateSchema,
|
|
21490
|
+
latencyMs: external_exports.number().int().nonnegative().optional(),
|
|
21491
|
+
version: external_exports.string().max(128).optional(),
|
|
21492
|
+
platform: external_exports.string().max(64).optional(),
|
|
21493
|
+
hostname: external_exports.string().max(255).optional(),
|
|
21494
|
+
homeDir: external_exports.string().max(4096).optional(),
|
|
21495
|
+
lastError: external_exports.string().max(1e3).optional(),
|
|
21496
|
+
projectCount: external_exports.number().int().nonnegative(),
|
|
21497
|
+
createdAt: external_exports.string(),
|
|
21498
|
+
updatedAt: external_exports.string()
|
|
21499
|
+
});
|
|
21500
|
+
var remotePeerListResultSchema = external_exports.object({
|
|
21501
|
+
peers: external_exports.array(remotePeerSummarySchema)
|
|
21502
|
+
});
|
|
21503
|
+
var remotePeerAddParamsSchema = external_exports.object({
|
|
21504
|
+
connectionUrl: external_exports.string().min(1).max(4096).optional(),
|
|
21505
|
+
origin: external_exports.string().min(1).max(2048).optional(),
|
|
21506
|
+
token: external_exports.string().min(1).max(2048).optional(),
|
|
21507
|
+
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
21508
|
+
color: remotePeerColorSchema.optional()
|
|
21509
|
+
}).refine((input3) => Boolean(input3.connectionUrl) || Boolean(input3.origin) && Boolean(input3.token), "Provide either connectionUrl or both origin and token");
|
|
21510
|
+
var remotePeerUpdateParamsSchema = external_exports.object({
|
|
21511
|
+
peerId: remotePeerIdSchema,
|
|
21512
|
+
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
21513
|
+
color: remotePeerColorSchema.nullable().optional(),
|
|
21514
|
+
connectionUrl: external_exports.string().min(1).max(4096).optional(),
|
|
21515
|
+
origin: external_exports.string().min(1).max(2048).optional(),
|
|
21516
|
+
token: external_exports.string().min(1).max(2048).optional(),
|
|
21517
|
+
enabled: external_exports.boolean().optional()
|
|
21518
|
+
});
|
|
21519
|
+
var remotePeerIdParamsSchema = external_exports.object({
|
|
21520
|
+
peerId: remotePeerIdSchema
|
|
21521
|
+
});
|
|
21522
|
+
var remotePeerRemoveResultSchema = external_exports.object({
|
|
21523
|
+
removed: external_exports.boolean()
|
|
21524
|
+
});
|
|
21525
|
+
var remotePeerTestParamsSchema = external_exports.object({
|
|
21526
|
+
peerId: remotePeerIdSchema.optional(),
|
|
21527
|
+
connectionUrl: external_exports.string().min(1).max(4096).optional(),
|
|
21528
|
+
origin: external_exports.string().min(1).max(2048).optional(),
|
|
21529
|
+
token: external_exports.string().min(1).max(2048).optional()
|
|
21530
|
+
}).refine((input3) => Boolean(input3.peerId) || Boolean(input3.connectionUrl) || Boolean(input3.origin) && Boolean(input3.token), "Provide peerId, connectionUrl, or both origin and token");
|
|
21531
|
+
var remotePeerTestProjectSchema = external_exports.object({
|
|
21532
|
+
id: external_exports.string().min(1).max(1024),
|
|
21533
|
+
name: external_exports.string().min(1).max(512),
|
|
21534
|
+
path: external_exports.string().min(1).max(8192)
|
|
21535
|
+
});
|
|
21536
|
+
var remotePeerTestResultSchema = external_exports.object({
|
|
21537
|
+
ok: external_exports.boolean(),
|
|
21538
|
+
latencyMs: external_exports.number().int().nonnegative().optional(),
|
|
21539
|
+
origin: external_exports.string().max(2048).optional(),
|
|
21540
|
+
transportKind: remotePeerTransportKindSchema.optional(),
|
|
21541
|
+
encrypted: external_exports.boolean().optional(),
|
|
21542
|
+
version: external_exports.string().max(128).optional(),
|
|
21543
|
+
platform: external_exports.string().max(64).optional(),
|
|
21544
|
+
hostname: external_exports.string().max(255).optional(),
|
|
21545
|
+
homeDir: external_exports.string().max(4096).optional(),
|
|
21546
|
+
projectCount: external_exports.number().int().nonnegative().optional(),
|
|
21547
|
+
projects: external_exports.array(remotePeerTestProjectSchema).optional(),
|
|
21548
|
+
error: external_exports.string().max(1e3).optional()
|
|
21549
|
+
});
|
|
21550
|
+
var remotePeerManifestProjectSchema = external_exports.object({
|
|
21551
|
+
id: external_exports.string().min(1).max(1024),
|
|
21552
|
+
name: external_exports.string().min(1).max(512),
|
|
21553
|
+
path: external_exports.string().min(1).max(8192),
|
|
21554
|
+
threadIds: external_exports.array(external_exports.string().min(1).max(1024))
|
|
21555
|
+
});
|
|
21556
|
+
var remotePeerCapabilitiesSchema = external_exports.object({
|
|
21557
|
+
/** /api/peer/v1/uploads, /api/peer/v1/prompt, and /api/peer/v1/file are all available. */
|
|
21558
|
+
attachments: external_exports.literal(1).optional(),
|
|
21559
|
+
/** /api/peer/v1/workspace-files/rpc and /api/peer/v1/workspace-files/download are available. */
|
|
21560
|
+
workspaceFiles: external_exports.literal(1).optional(),
|
|
21561
|
+
/** Peer supports officeToPdf/render over /api/peer/v1/workspace-files/rpc. */
|
|
21562
|
+
officePreview: external_exports.literal(1).optional(),
|
|
21563
|
+
/** /api/peer/v1/delegation is available for fixed-whitelist cross-host delegation. */
|
|
21564
|
+
delegation: external_exports.literal(1).optional()
|
|
21565
|
+
});
|
|
21566
|
+
var remotePeerManifestSchema = external_exports.object({
|
|
21567
|
+
version: external_exports.string().max(128),
|
|
21568
|
+
platform: external_exports.string().max(64),
|
|
21569
|
+
hostname: external_exports.string().max(255),
|
|
21570
|
+
homeDir: external_exports.string().max(4096).optional(),
|
|
21571
|
+
epoch: external_exports.string().min(1).max(256),
|
|
21572
|
+
projects: external_exports.array(remotePeerManifestProjectSchema),
|
|
21573
|
+
capabilities: remotePeerCapabilitiesSchema.optional()
|
|
21574
|
+
});
|
|
21575
|
+
var REMOTE_PEER_UPLOAD_SCOPE_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
21576
|
+
var remotePeerPromptParamsSchema = external_exports.strictObject({
|
|
21577
|
+
threadId: external_exports.string().min(1).max(1024),
|
|
21578
|
+
scope: external_exports.string().regex(REMOTE_PEER_UPLOAD_SCOPE_PATTERN).optional(),
|
|
21579
|
+
requestId: external_exports.string().min(1).max(256).optional(),
|
|
21580
|
+
mode: external_exports.enum(["queue", "steer"]).optional(),
|
|
21581
|
+
expectedTurnId: external_exports.string().min(1).max(1024).nullable().optional(),
|
|
21582
|
+
content: external_exports.array(external_exports.discriminatedUnion("type", [
|
|
21583
|
+
external_exports.strictObject({ type: external_exports.literal("text"), text: external_exports.string() }),
|
|
21584
|
+
external_exports.strictObject({ type: external_exports.literal("file"), receiptId: external_exports.string().min(1).max(128) })
|
|
21585
|
+
])).min(1).max(64)
|
|
21586
|
+
});
|
|
21587
|
+
var remotePeerErrorEnvelopeSchema = external_exports.object({
|
|
21588
|
+
ok: external_exports.literal(false),
|
|
21589
|
+
error: external_exports.object({
|
|
21590
|
+
code: external_exports.string(),
|
|
21591
|
+
message: external_exports.string(),
|
|
21592
|
+
details: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
21593
|
+
})
|
|
21594
|
+
});
|
|
21595
|
+
var remotePeerUploadResultSchema = external_exports.union([
|
|
21596
|
+
external_exports.object({
|
|
21597
|
+
ok: external_exports.literal(true),
|
|
21598
|
+
value: external_exports.object({
|
|
21599
|
+
receiptId: external_exports.string().min(1),
|
|
21600
|
+
file: external_exports.object({
|
|
21601
|
+
attachmentId: external_exports.string(),
|
|
21602
|
+
name: external_exports.string(),
|
|
21603
|
+
bytes: external_exports.number().int().nonnegative()
|
|
21604
|
+
})
|
|
21605
|
+
})
|
|
21606
|
+
}),
|
|
21607
|
+
remotePeerErrorEnvelopeSchema
|
|
21608
|
+
]);
|
|
21609
|
+
var remotePeerPromptResultSchema = external_exports.union([
|
|
21610
|
+
external_exports.object({
|
|
21611
|
+
ok: external_exports.literal(true),
|
|
21612
|
+
value: external_exports.object({ accepted: external_exports.literal(true) })
|
|
21613
|
+
}),
|
|
21614
|
+
remotePeerErrorEnvelopeSchema
|
|
21615
|
+
]);
|
|
21616
|
+
var remotePeerDirectoryEntrySchema = external_exports.object({
|
|
21617
|
+
name: external_exports.string().min(1).max(512),
|
|
21618
|
+
path: external_exports.string().min(1).max(8192),
|
|
21619
|
+
kind: external_exports.literal("directory")
|
|
21620
|
+
});
|
|
21621
|
+
var remotePeerListDirsParamsSchema = external_exports.object({
|
|
21622
|
+
peerId: remotePeerIdSchema,
|
|
21623
|
+
path: external_exports.string().min(1).max(8192).optional()
|
|
21624
|
+
});
|
|
21625
|
+
var remotePeerListDirsResultSchema = external_exports.object({
|
|
21626
|
+
path: external_exports.string().min(1).max(8192),
|
|
21627
|
+
parentPath: external_exports.string().min(1).max(8192).nullable(),
|
|
21628
|
+
homeDir: external_exports.string().min(1).max(8192).optional(),
|
|
21629
|
+
entries: external_exports.array(remotePeerDirectoryEntrySchema)
|
|
21630
|
+
});
|
|
21631
|
+
var remotePeerCreateDirParamsSchema = external_exports.object({
|
|
21632
|
+
peerId: remotePeerIdSchema,
|
|
21633
|
+
parentPath: external_exports.string().min(1).max(8192),
|
|
21634
|
+
name: external_exports.string().min(1).max(255).refine((value) => value.trim().length > 0, "Directory name cannot be blank")
|
|
21635
|
+
});
|
|
21636
|
+
var remotePeerCreateDirResultSchema = external_exports.object({
|
|
21637
|
+
path: external_exports.string().min(1).max(8192),
|
|
21638
|
+
name: external_exports.string().min(1).max(255)
|
|
21639
|
+
});
|
|
21640
|
+
var remotePeerCreateWorkspaceParamsSchema = external_exports.object({
|
|
21641
|
+
peerId: remotePeerIdSchema,
|
|
21642
|
+
path: external_exports.string().min(1).max(8192),
|
|
21643
|
+
title: external_exports.string().trim().min(1).max(255).optional()
|
|
21644
|
+
});
|
|
21645
|
+
var remotePeerRenameWorkspaceParamsSchema = external_exports.object({
|
|
21646
|
+
peerId: remotePeerIdSchema,
|
|
21647
|
+
workspaceId: external_exports.string().min(1).max(1024),
|
|
21648
|
+
title: external_exports.string().trim().min(1).max(255)
|
|
21649
|
+
});
|
|
21650
|
+
var remotePeerDeleteWorkspaceParamsSchema = external_exports.object({
|
|
21651
|
+
peerId: remotePeerIdSchema,
|
|
21652
|
+
workspaceId: external_exports.string().min(1).max(1024)
|
|
21653
|
+
});
|
|
21654
|
+
var remotePeerWorkspaceMutationResultSchema = external_exports.object({
|
|
21655
|
+
workspaceId: external_exports.string().min(1).max(1024).optional(),
|
|
21656
|
+
manifest: remotePeerManifestSchema
|
|
21657
|
+
});
|
|
21658
|
+
|
|
21659
|
+
// ../../shared-contracts/dist/peer-delegation.js
|
|
21660
|
+
var PEER_DELEGATION_BRIDGE_VERSION = 1;
|
|
21661
|
+
var PEER_DELEGATION_OPERATIONS = [
|
|
21662
|
+
"listHarnesses",
|
|
21663
|
+
"inspect",
|
|
21664
|
+
"start",
|
|
21665
|
+
"send",
|
|
21666
|
+
"cancel",
|
|
21667
|
+
"read",
|
|
21668
|
+
"answer",
|
|
21669
|
+
"list"
|
|
21670
|
+
];
|
|
21671
|
+
var peerDelegationOperationSchema = external_exports.enum(PEER_DELEGATION_OPERATIONS);
|
|
21672
|
+
var peerDelegationRequestSchema = external_exports.strictObject({
|
|
21673
|
+
operation: peerDelegationOperationSchema,
|
|
21674
|
+
hopCount: external_exports.number().int().min(0).max(16),
|
|
21675
|
+
/** Opaque A-side peer pairing identifier used by B to scope implicit deduplication per Peer. */
|
|
21676
|
+
sourceId: remotePeerIdSchema.optional(),
|
|
21677
|
+
input: jsonObjectSchema
|
|
21678
|
+
});
|
|
21679
|
+
var peerDelegationErrorSchema = external_exports.strictObject({
|
|
21680
|
+
code: external_exports.string().min(1).max(128),
|
|
21681
|
+
message: external_exports.string().max(4096),
|
|
21682
|
+
details: jsonObjectSchema.optional()
|
|
21683
|
+
});
|
|
21684
|
+
var peerDelegationResponseSchema = external_exports.union([
|
|
21685
|
+
external_exports.strictObject({
|
|
21686
|
+
ok: external_exports.literal(true),
|
|
21687
|
+
value: jsonValueSchema
|
|
21688
|
+
}),
|
|
21689
|
+
external_exports.strictObject({
|
|
21690
|
+
ok: external_exports.literal(false),
|
|
21691
|
+
error: peerDelegationErrorSchema
|
|
21692
|
+
})
|
|
21693
|
+
]);
|
|
21694
|
+
var peerDelegationHostProjectSchema = external_exports.strictObject({
|
|
21695
|
+
id: external_exports.string().min(1).max(1024),
|
|
21696
|
+
name: external_exports.string().min(1).max(512),
|
|
21697
|
+
path: external_exports.string().min(1).max(8192)
|
|
21698
|
+
});
|
|
21699
|
+
var peerDelegationHostSummarySchema = external_exports.strictObject({
|
|
21700
|
+
hostId: remotePeerHostIdSchema,
|
|
21701
|
+
displayName: external_exports.string().min(1).max(120),
|
|
21702
|
+
online: external_exports.boolean(),
|
|
21703
|
+
state: remotePeerStateSchema,
|
|
21704
|
+
delegation: external_exports.boolean(),
|
|
21705
|
+
projects: external_exports.array(peerDelegationHostProjectSchema),
|
|
21706
|
+
platform: external_exports.string().max(64).optional(),
|
|
21707
|
+
hostname: external_exports.string().max(255).optional(),
|
|
21708
|
+
homeDir: external_exports.string().max(4096).optional()
|
|
21709
|
+
});
|
|
21710
|
+
var peerDelegationHostsResultSchema = external_exports.strictObject({
|
|
21711
|
+
hosts: external_exports.array(peerDelegationHostSummarySchema)
|
|
21712
|
+
});
|
|
21713
|
+
var peerDelegationBridgeDescriptorSchema = external_exports.strictObject({
|
|
21714
|
+
version: external_exports.literal(PEER_DELEGATION_BRIDGE_VERSION),
|
|
21715
|
+
instanceId: external_exports.string().min(1).max(128),
|
|
21716
|
+
pid: external_exports.number().int().positive(),
|
|
21717
|
+
endpoint: external_exports.string().min(1).max(256),
|
|
21718
|
+
token: external_exports.string().regex(/^[0-9a-f]{64}$/u),
|
|
21719
|
+
startedAt: external_exports.number().int().nonnegative()
|
|
21720
|
+
});
|
|
21721
|
+
var peerDelegationBridgeRequestSchema = external_exports.union([
|
|
21722
|
+
external_exports.strictObject({
|
|
21723
|
+
operation: external_exports.literal("hosts")
|
|
21724
|
+
}),
|
|
21725
|
+
external_exports.strictObject({
|
|
21726
|
+
operation: peerDelegationOperationSchema,
|
|
21727
|
+
hostId: remotePeerHostIdSchema,
|
|
21728
|
+
hopCount: external_exports.number().int().min(0).max(16),
|
|
21729
|
+
timeoutMs: external_exports.number().int().min(1).max(12e4).optional(),
|
|
21730
|
+
input: jsonObjectSchema
|
|
21731
|
+
})
|
|
21732
|
+
]);
|
|
21733
|
+
|
|
21403
21734
|
// ../../shared-contracts/dist/credential-imports.js
|
|
21404
21735
|
var credentialSourceSchema = external_exports.object({
|
|
21405
21736
|
id: external_exports.string().min(1).max(256),
|
|
@@ -21990,7 +22321,7 @@ var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status"
|
|
|
21990
22321
|
|
|
21991
22322
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
21992
22323
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
21993
|
-
var
|
|
22324
|
+
var nonBlankTextSchema4 = external_exports.string().trim().min(1);
|
|
21994
22325
|
var codexAccountPlanTypeSchema = external_exports.enum([
|
|
21995
22326
|
"free",
|
|
21996
22327
|
"go",
|
|
@@ -22012,7 +22343,7 @@ var codexAccountPlanTypeSchema = external_exports.enum([
|
|
|
22012
22343
|
]);
|
|
22013
22344
|
var codexAccountSchema = external_exports.object({
|
|
22014
22345
|
accountId: accountIdSchema,
|
|
22015
|
-
label:
|
|
22346
|
+
label: nonBlankTextSchema4.max(256),
|
|
22016
22347
|
email: external_exports.string().email().max(320).optional(),
|
|
22017
22348
|
planType: codexAccountPlanTypeSchema.optional()
|
|
22018
22349
|
}).strict();
|
|
@@ -22022,7 +22353,7 @@ var codexAccountListResultSchema = external_exports.object({
|
|
|
22022
22353
|
currentAccountId: accountIdSchema.nullable(),
|
|
22023
22354
|
phase: codexAccountPhaseSchema,
|
|
22024
22355
|
revision: external_exports.number().int().nonnegative(),
|
|
22025
|
-
instanceId:
|
|
22356
|
+
instanceId: nonBlankTextSchema4.max(1024).optional(),
|
|
22026
22357
|
accounts: external_exports.array(codexAccountSchema).max(1)
|
|
22027
22358
|
}).strict();
|
|
22028
22359
|
var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
@@ -22040,13 +22371,13 @@ var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
|
|
|
22040
22371
|
var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
|
|
22041
22372
|
var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
|
|
22042
22373
|
var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
|
|
22043
|
-
var
|
|
22044
|
-
var harnessSessionImportIdSchema =
|
|
22374
|
+
var nonBlankTextSchema5 = external_exports.string().refine((value) => value.trim().length > 0, "Value must not be empty or whitespace").refine((value) => !value.includes("\0"), "Value must not contain NUL");
|
|
22375
|
+
var harnessSessionImportIdSchema = nonBlankTextSchema5.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
|
|
22045
22376
|
var harnessSessionImportCandidateSchema = external_exports.object({
|
|
22046
22377
|
nativeSessionId: harnessSessionImportIdSchema,
|
|
22047
|
-
title:
|
|
22378
|
+
title: nonBlankTextSchema5.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
|
|
22048
22379
|
updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
|
|
22049
|
-
cwd:
|
|
22380
|
+
cwd: nonBlankTextSchema5.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
|
|
22050
22381
|
// Native file discovery cannot reliably observe another process's activity.
|
|
22051
22382
|
running: external_exports.boolean().nullable()
|
|
22052
22383
|
}).strict();
|
|
@@ -22054,7 +22385,7 @@ var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict
|
|
|
22054
22385
|
var harnessSessionImportSourcesResultSchema = external_exports.object({
|
|
22055
22386
|
harnesses: external_exports.array(external_exports.object({
|
|
22056
22387
|
harnessId: harnessPluginIdSchema,
|
|
22057
|
-
name:
|
|
22388
|
+
name: nonBlankTextSchema5.max(128)
|
|
22058
22389
|
}).strict()).max(128)
|
|
22059
22390
|
}).strict();
|
|
22060
22391
|
var harnessSessionListParamsSchema = external_exports.object({
|
|
@@ -22072,13 +22403,13 @@ var harnessSessionImportParamsSchema = external_exports.object({
|
|
|
22072
22403
|
nativeSessionId: harnessSessionImportIdSchema
|
|
22073
22404
|
}).strict();
|
|
22074
22405
|
var harnessSessionImportResultSchema = external_exports.object({
|
|
22075
|
-
threadId:
|
|
22406
|
+
threadId: nonBlankTextSchema5.max(1024).pipe(hostThreadIdSchema)
|
|
22076
22407
|
}).strict();
|
|
22077
22408
|
|
|
22078
22409
|
// ../../shared-contracts/dist/deepseek-modern-sessions.js
|
|
22079
22410
|
var DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH = HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH;
|
|
22080
22411
|
var DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH = 1024;
|
|
22081
|
-
var
|
|
22412
|
+
var nonBlankTextSchema6 = external_exports.string().refine((value) => value.trim().length > 0, "Value must not be empty or whitespace").refine((value) => !value.includes("\0"), "Value must not contain NUL");
|
|
22082
22413
|
var deepSeekModernSessionIdSchema = harnessSessionImportIdSchema;
|
|
22083
22414
|
var deepSeekModernSessionCandidateSchema = harnessSessionImportCandidateSchema;
|
|
22084
22415
|
var deepSeekModernSessionListParamsSchema = external_exports.object({}).strict();
|
|
@@ -22089,7 +22420,7 @@ var deepSeekModernSessionImportParamsSchema = external_exports.object({
|
|
|
22089
22420
|
nativeSessionId: deepSeekModernSessionIdSchema
|
|
22090
22421
|
}).strict();
|
|
22091
22422
|
var deepSeekModernSessionImportResultSchema = external_exports.object({
|
|
22092
|
-
threadId:
|
|
22423
|
+
threadId: nonBlankTextSchema6.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
|
|
22093
22424
|
}).strict();
|
|
22094
22425
|
|
|
22095
22426
|
// ../../shared-contracts/dist/external-thread-fork.js
|
|
@@ -22124,9 +22455,10 @@ var harnessCommandCatalogSchema = external_exports.object({
|
|
|
22124
22455
|
/** Partial discovery failures; valid commands remain available. */
|
|
22125
22456
|
warnings: external_exports.array(external_exports.string().min(1)).optional(),
|
|
22126
22457
|
/**
|
|
22127
|
-
* `live` when
|
|
22128
|
-
* workspace (
|
|
22129
|
-
*
|
|
22458
|
+
* `live` when a native Session has reported its live catalog for the
|
|
22459
|
+
* workspace (even when filtering leaves only built-ins); `static` for
|
|
22460
|
+
* Adapter built-ins only before live commands arrive. Adapters may set
|
|
22461
|
+
* `live` once their Session's live catalog has loaded.
|
|
22130
22462
|
*/
|
|
22131
22463
|
source: external_exports.enum(["live", "static"]).optional()
|
|
22132
22464
|
}).strict().superRefine((catalog, context) => {
|
|
@@ -22496,7 +22828,8 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
22496
22828
|
kind: external_exports.literal("start"),
|
|
22497
22829
|
itemId: identity,
|
|
22498
22830
|
onlyIfHead: external_exports.literal(true).optional()
|
|
22499
|
-
})
|
|
22831
|
+
}),
|
|
22832
|
+
external_exports.strictObject({ kind: external_exports.literal("sendNow"), itemId: identity })
|
|
22500
22833
|
])
|
|
22501
22834
|
}),
|
|
22502
22835
|
external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...thread, epoch: identity, turnId: identity }),
|
|
@@ -22611,206 +22944,6 @@ var webUiExtensionInstallSchema = external_exports.object({
|
|
|
22611
22944
|
var webUiExtensionEnabledSchema = external_exports.object({ id: webUiExtensionIdSchema, enabled: external_exports.boolean() }).strict();
|
|
22612
22945
|
var webUiExtensionRemoveSchema = external_exports.object({ id: webUiExtensionIdSchema }).strict();
|
|
22613
22946
|
|
|
22614
|
-
// ../../shared-contracts/dist/remote-peers.js
|
|
22615
|
-
var REMOTE_PEER_ID_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/u;
|
|
22616
|
-
var remotePeerIdSchema = external_exports.string().regex(REMOTE_PEER_ID_PATTERN);
|
|
22617
|
-
var remotePeerHostIdSchema = external_exports.string().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u);
|
|
22618
|
-
var remotePeerTransportKindSchema = external_exports.enum(["relay", "tailscale", "lan", "custom"]);
|
|
22619
|
-
var REMOTE_PEER_COLORS = [
|
|
22620
|
-
"blue",
|
|
22621
|
-
"purple",
|
|
22622
|
-
"cyan",
|
|
22623
|
-
"green",
|
|
22624
|
-
"amber",
|
|
22625
|
-
"rose",
|
|
22626
|
-
"slate"
|
|
22627
|
-
];
|
|
22628
|
-
var remotePeerColorSchema = external_exports.enum(REMOTE_PEER_COLORS);
|
|
22629
|
-
var REMOTE_PEER_COLOR_SET = new Set(REMOTE_PEER_COLORS);
|
|
22630
|
-
var remotePeerStateSchema = external_exports.enum([
|
|
22631
|
-
"connected",
|
|
22632
|
-
"connecting",
|
|
22633
|
-
"auth-error",
|
|
22634
|
-
"offline",
|
|
22635
|
-
"disabled"
|
|
22636
|
-
]);
|
|
22637
|
-
var remotePeerSummarySchema = external_exports.object({
|
|
22638
|
-
peerId: remotePeerIdSchema,
|
|
22639
|
-
hostId: remotePeerHostIdSchema,
|
|
22640
|
-
name: external_exports.string().min(1).max(120),
|
|
22641
|
-
color: remotePeerColorSchema.optional(),
|
|
22642
|
-
origin: external_exports.string().min(1).max(2048),
|
|
22643
|
-
transportKind: remotePeerTransportKindSchema,
|
|
22644
|
-
encrypted: external_exports.boolean(),
|
|
22645
|
-
enabled: external_exports.boolean(),
|
|
22646
|
-
state: remotePeerStateSchema,
|
|
22647
|
-
latencyMs: external_exports.number().int().nonnegative().optional(),
|
|
22648
|
-
version: external_exports.string().max(128).optional(),
|
|
22649
|
-
platform: external_exports.string().max(64).optional(),
|
|
22650
|
-
hostname: external_exports.string().max(255).optional(),
|
|
22651
|
-
homeDir: external_exports.string().max(4096).optional(),
|
|
22652
|
-
lastError: external_exports.string().max(1e3).optional(),
|
|
22653
|
-
projectCount: external_exports.number().int().nonnegative(),
|
|
22654
|
-
createdAt: external_exports.string(),
|
|
22655
|
-
updatedAt: external_exports.string()
|
|
22656
|
-
});
|
|
22657
|
-
var remotePeerListResultSchema = external_exports.object({
|
|
22658
|
-
peers: external_exports.array(remotePeerSummarySchema)
|
|
22659
|
-
});
|
|
22660
|
-
var remotePeerAddParamsSchema = external_exports.object({
|
|
22661
|
-
connectionUrl: external_exports.string().min(1).max(4096).optional(),
|
|
22662
|
-
origin: external_exports.string().min(1).max(2048).optional(),
|
|
22663
|
-
token: external_exports.string().min(1).max(2048).optional(),
|
|
22664
|
-
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
22665
|
-
color: remotePeerColorSchema.optional()
|
|
22666
|
-
}).refine((input3) => Boolean(input3.connectionUrl) || Boolean(input3.origin) && Boolean(input3.token), "Provide either connectionUrl or both origin and token");
|
|
22667
|
-
var remotePeerUpdateParamsSchema = external_exports.object({
|
|
22668
|
-
peerId: remotePeerIdSchema,
|
|
22669
|
-
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
22670
|
-
color: remotePeerColorSchema.nullable().optional(),
|
|
22671
|
-
connectionUrl: external_exports.string().min(1).max(4096).optional(),
|
|
22672
|
-
origin: external_exports.string().min(1).max(2048).optional(),
|
|
22673
|
-
token: external_exports.string().min(1).max(2048).optional(),
|
|
22674
|
-
enabled: external_exports.boolean().optional()
|
|
22675
|
-
});
|
|
22676
|
-
var remotePeerIdParamsSchema = external_exports.object({
|
|
22677
|
-
peerId: remotePeerIdSchema
|
|
22678
|
-
});
|
|
22679
|
-
var remotePeerRemoveResultSchema = external_exports.object({
|
|
22680
|
-
removed: external_exports.boolean()
|
|
22681
|
-
});
|
|
22682
|
-
var remotePeerTestParamsSchema = external_exports.object({
|
|
22683
|
-
peerId: remotePeerIdSchema.optional(),
|
|
22684
|
-
connectionUrl: external_exports.string().min(1).max(4096).optional(),
|
|
22685
|
-
origin: external_exports.string().min(1).max(2048).optional(),
|
|
22686
|
-
token: external_exports.string().min(1).max(2048).optional()
|
|
22687
|
-
}).refine((input3) => Boolean(input3.peerId) || Boolean(input3.connectionUrl) || Boolean(input3.origin) && Boolean(input3.token), "Provide peerId, connectionUrl, or both origin and token");
|
|
22688
|
-
var remotePeerTestProjectSchema = external_exports.object({
|
|
22689
|
-
id: external_exports.string().min(1).max(1024),
|
|
22690
|
-
name: external_exports.string().min(1).max(512),
|
|
22691
|
-
path: external_exports.string().min(1).max(8192)
|
|
22692
|
-
});
|
|
22693
|
-
var remotePeerTestResultSchema = external_exports.object({
|
|
22694
|
-
ok: external_exports.boolean(),
|
|
22695
|
-
latencyMs: external_exports.number().int().nonnegative().optional(),
|
|
22696
|
-
origin: external_exports.string().max(2048).optional(),
|
|
22697
|
-
transportKind: remotePeerTransportKindSchema.optional(),
|
|
22698
|
-
encrypted: external_exports.boolean().optional(),
|
|
22699
|
-
version: external_exports.string().max(128).optional(),
|
|
22700
|
-
platform: external_exports.string().max(64).optional(),
|
|
22701
|
-
hostname: external_exports.string().max(255).optional(),
|
|
22702
|
-
homeDir: external_exports.string().max(4096).optional(),
|
|
22703
|
-
projectCount: external_exports.number().int().nonnegative().optional(),
|
|
22704
|
-
projects: external_exports.array(remotePeerTestProjectSchema).optional(),
|
|
22705
|
-
error: external_exports.string().max(1e3).optional()
|
|
22706
|
-
});
|
|
22707
|
-
var remotePeerManifestProjectSchema = external_exports.object({
|
|
22708
|
-
id: external_exports.string().min(1).max(1024),
|
|
22709
|
-
name: external_exports.string().min(1).max(512),
|
|
22710
|
-
path: external_exports.string().min(1).max(8192),
|
|
22711
|
-
threadIds: external_exports.array(external_exports.string().min(1).max(1024))
|
|
22712
|
-
});
|
|
22713
|
-
var remotePeerCapabilitiesSchema = external_exports.object({
|
|
22714
|
-
/** /api/peer/v1/uploads, /api/peer/v1/prompt, and /api/peer/v1/file are all available. */
|
|
22715
|
-
attachments: external_exports.literal(1).optional(),
|
|
22716
|
-
/** /api/peer/v1/workspace-files/rpc and /api/peer/v1/workspace-files/download are available. */
|
|
22717
|
-
workspaceFiles: external_exports.literal(1).optional(),
|
|
22718
|
-
/** Peer supports officeToPdf/render over /api/peer/v1/workspace-files/rpc. */
|
|
22719
|
-
officePreview: external_exports.literal(1).optional()
|
|
22720
|
-
});
|
|
22721
|
-
var remotePeerManifestSchema = external_exports.object({
|
|
22722
|
-
version: external_exports.string().max(128),
|
|
22723
|
-
platform: external_exports.string().max(64),
|
|
22724
|
-
hostname: external_exports.string().max(255),
|
|
22725
|
-
homeDir: external_exports.string().max(4096).optional(),
|
|
22726
|
-
epoch: external_exports.string().min(1).max(256),
|
|
22727
|
-
projects: external_exports.array(remotePeerManifestProjectSchema),
|
|
22728
|
-
capabilities: remotePeerCapabilitiesSchema.optional()
|
|
22729
|
-
});
|
|
22730
|
-
var REMOTE_PEER_UPLOAD_SCOPE_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
22731
|
-
var remotePeerPromptParamsSchema = external_exports.strictObject({
|
|
22732
|
-
threadId: external_exports.string().min(1).max(1024),
|
|
22733
|
-
scope: external_exports.string().regex(REMOTE_PEER_UPLOAD_SCOPE_PATTERN).optional(),
|
|
22734
|
-
requestId: external_exports.string().min(1).max(256).optional(),
|
|
22735
|
-
mode: external_exports.enum(["queue", "steer"]).optional(),
|
|
22736
|
-
expectedTurnId: external_exports.string().min(1).max(1024).nullable().optional(),
|
|
22737
|
-
content: external_exports.array(external_exports.discriminatedUnion("type", [
|
|
22738
|
-
external_exports.strictObject({ type: external_exports.literal("text"), text: external_exports.string() }),
|
|
22739
|
-
external_exports.strictObject({ type: external_exports.literal("file"), receiptId: external_exports.string().min(1).max(128) })
|
|
22740
|
-
])).min(1).max(64)
|
|
22741
|
-
});
|
|
22742
|
-
var remotePeerErrorEnvelopeSchema = external_exports.object({
|
|
22743
|
-
ok: external_exports.literal(false),
|
|
22744
|
-
error: external_exports.object({
|
|
22745
|
-
code: external_exports.string(),
|
|
22746
|
-
message: external_exports.string(),
|
|
22747
|
-
details: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
22748
|
-
})
|
|
22749
|
-
});
|
|
22750
|
-
var remotePeerUploadResultSchema = external_exports.union([
|
|
22751
|
-
external_exports.object({
|
|
22752
|
-
ok: external_exports.literal(true),
|
|
22753
|
-
value: external_exports.object({
|
|
22754
|
-
receiptId: external_exports.string().min(1),
|
|
22755
|
-
file: external_exports.object({
|
|
22756
|
-
attachmentId: external_exports.string(),
|
|
22757
|
-
name: external_exports.string(),
|
|
22758
|
-
bytes: external_exports.number().int().nonnegative()
|
|
22759
|
-
})
|
|
22760
|
-
})
|
|
22761
|
-
}),
|
|
22762
|
-
remotePeerErrorEnvelopeSchema
|
|
22763
|
-
]);
|
|
22764
|
-
var remotePeerPromptResultSchema = external_exports.union([
|
|
22765
|
-
external_exports.object({
|
|
22766
|
-
ok: external_exports.literal(true),
|
|
22767
|
-
value: external_exports.object({ accepted: external_exports.literal(true) })
|
|
22768
|
-
}),
|
|
22769
|
-
remotePeerErrorEnvelopeSchema
|
|
22770
|
-
]);
|
|
22771
|
-
var remotePeerDirectoryEntrySchema = external_exports.object({
|
|
22772
|
-
name: external_exports.string().min(1).max(512),
|
|
22773
|
-
path: external_exports.string().min(1).max(8192),
|
|
22774
|
-
kind: external_exports.literal("directory")
|
|
22775
|
-
});
|
|
22776
|
-
var remotePeerListDirsParamsSchema = external_exports.object({
|
|
22777
|
-
peerId: remotePeerIdSchema,
|
|
22778
|
-
path: external_exports.string().min(1).max(8192).optional()
|
|
22779
|
-
});
|
|
22780
|
-
var remotePeerListDirsResultSchema = external_exports.object({
|
|
22781
|
-
path: external_exports.string().min(1).max(8192),
|
|
22782
|
-
parentPath: external_exports.string().min(1).max(8192).nullable(),
|
|
22783
|
-
homeDir: external_exports.string().min(1).max(8192).optional(),
|
|
22784
|
-
entries: external_exports.array(remotePeerDirectoryEntrySchema)
|
|
22785
|
-
});
|
|
22786
|
-
var remotePeerCreateDirParamsSchema = external_exports.object({
|
|
22787
|
-
peerId: remotePeerIdSchema,
|
|
22788
|
-
parentPath: external_exports.string().min(1).max(8192),
|
|
22789
|
-
name: external_exports.string().min(1).max(255).refine((value) => value.trim().length > 0, "Directory name cannot be blank")
|
|
22790
|
-
});
|
|
22791
|
-
var remotePeerCreateDirResultSchema = external_exports.object({
|
|
22792
|
-
path: external_exports.string().min(1).max(8192),
|
|
22793
|
-
name: external_exports.string().min(1).max(255)
|
|
22794
|
-
});
|
|
22795
|
-
var remotePeerCreateWorkspaceParamsSchema = external_exports.object({
|
|
22796
|
-
peerId: remotePeerIdSchema,
|
|
22797
|
-
path: external_exports.string().min(1).max(8192),
|
|
22798
|
-
title: external_exports.string().trim().min(1).max(255).optional()
|
|
22799
|
-
});
|
|
22800
|
-
var remotePeerRenameWorkspaceParamsSchema = external_exports.object({
|
|
22801
|
-
peerId: remotePeerIdSchema,
|
|
22802
|
-
workspaceId: external_exports.string().min(1).max(1024),
|
|
22803
|
-
title: external_exports.string().trim().min(1).max(255)
|
|
22804
|
-
});
|
|
22805
|
-
var remotePeerDeleteWorkspaceParamsSchema = external_exports.object({
|
|
22806
|
-
peerId: remotePeerIdSchema,
|
|
22807
|
-
workspaceId: external_exports.string().min(1).max(1024)
|
|
22808
|
-
});
|
|
22809
|
-
var remotePeerWorkspaceMutationResultSchema = external_exports.object({
|
|
22810
|
-
workspaceId: external_exports.string().min(1).max(1024).optional(),
|
|
22811
|
-
manifest: remotePeerManifestSchema
|
|
22812
|
-
});
|
|
22813
|
-
|
|
22814
22947
|
// ../../shared-contracts/dist/index.js
|
|
22815
22948
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
22816
22949
|
|
|
@@ -24927,25 +25060,63 @@ function createClaudeUsageStatistics(environment) {
|
|
|
24927
25060
|
}
|
|
24928
25061
|
|
|
24929
25062
|
// dist/claude-prompt-cache.js
|
|
24930
|
-
|
|
24931
|
-
|
|
25063
|
+
var CLAUDE_PROMPT_CACHE_5M_TTL_SECONDS = 300;
|
|
25064
|
+
var CLAUDE_PROMPT_CACHE_1H_TTL_SECONDS = 3600;
|
|
25065
|
+
function isRecord4(value) {
|
|
25066
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25067
|
+
}
|
|
25068
|
+
function isPositiveSafeInteger(value) {
|
|
25069
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
25070
|
+
}
|
|
25071
|
+
function claudePromptCacheTtlSeconds(usage) {
|
|
25072
|
+
if (!isRecord4(usage) || !isRecord4(usage.cache_creation))
|
|
25073
|
+
return void 0;
|
|
25074
|
+
const split = usage.cache_creation;
|
|
25075
|
+
if (isPositiveSafeInteger(split.ephemeral_5m_input_tokens)) {
|
|
25076
|
+
return CLAUDE_PROMPT_CACHE_5M_TTL_SECONDS;
|
|
25077
|
+
}
|
|
25078
|
+
if (isPositiveSafeInteger(split.ephemeral_1h_input_tokens)) {
|
|
25079
|
+
return CLAUDE_PROMPT_CACHE_1H_TTL_SECONDS;
|
|
25080
|
+
}
|
|
25081
|
+
return void 0;
|
|
25082
|
+
}
|
|
25083
|
+
function claudePromptCacheFromMessages(messages) {
|
|
25084
|
+
let lastResponseAtUnix;
|
|
25085
|
+
let ttlSeconds;
|
|
25086
|
+
let latestTtlTime;
|
|
24932
25087
|
for (const entry of messages) {
|
|
24933
|
-
if (
|
|
25088
|
+
if (!isRecord4(entry) || entry.type !== "assistant" || entry.isSidechain === true || entry.parent_tool_use_id != null) {
|
|
25089
|
+
continue;
|
|
25090
|
+
}
|
|
25091
|
+
const message = isRecord4(entry.message) ? entry.message : null;
|
|
25092
|
+
if (message?.model === "<synthetic>")
|
|
25093
|
+
continue;
|
|
25094
|
+
if (typeof entry.timestamp !== "string")
|
|
24934
25095
|
continue;
|
|
24935
25096
|
const time3 = Math.floor(Date.parse(entry.timestamp) / 1e3);
|
|
24936
|
-
if (Number.isSafeInteger(time3)
|
|
24937
|
-
|
|
25097
|
+
if (!Number.isSafeInteger(time3) || time3 < 0)
|
|
25098
|
+
continue;
|
|
25099
|
+
lastResponseAtUnix = Math.max(lastResponseAtUnix ?? 0, time3);
|
|
25100
|
+
const entryTtl = claudePromptCacheTtlSeconds(message?.usage);
|
|
25101
|
+
if (entryTtl !== void 0 && (latestTtlTime === void 0 || time3 >= latestTtlTime)) {
|
|
25102
|
+
ttlSeconds = entryTtl;
|
|
25103
|
+
latestTtlTime = time3;
|
|
25104
|
+
}
|
|
24938
25105
|
}
|
|
24939
|
-
return
|
|
25106
|
+
return {
|
|
25107
|
+
...lastResponseAtUnix !== void 0 ? { lastResponseAtUnix } : {},
|
|
25108
|
+
...ttlSeconds !== void 0 ? { ttlSeconds } : {}
|
|
25109
|
+
};
|
|
24940
25110
|
}
|
|
24941
|
-
function claudePromptCacheIndicators(accountCreditsSupported, lastResponseAtUnix) {
|
|
24942
|
-
if (!accountCreditsSupported || lastResponseAtUnix === void 0)
|
|
25111
|
+
function claudePromptCacheIndicators(accountCreditsSupported, lastResponseAtUnix, ttlSeconds) {
|
|
25112
|
+
if (!accountCreditsSupported || lastResponseAtUnix === void 0 || ttlSeconds === void 0) {
|
|
24943
25113
|
return [];
|
|
25114
|
+
}
|
|
24944
25115
|
return [
|
|
24945
25116
|
{
|
|
24946
25117
|
kind: "countdown",
|
|
24947
25118
|
id: "prompt-cache",
|
|
24948
|
-
expiresAtUnix: lastResponseAtUnix +
|
|
25119
|
+
expiresAtUnix: lastResponseAtUnix + ttlSeconds,
|
|
24949
25120
|
label: { en: "Prompt cache", "zh-CN": "提示词缓存" }
|
|
24950
25121
|
}
|
|
24951
25122
|
];
|
|
@@ -60601,7 +60772,7 @@ var ClaudeUltracodeUnavailableError = class extends Error {
|
|
|
60601
60772
|
function claudeUltracodeFailure(error63) {
|
|
60602
60773
|
return { ...FAILURES[error63.reason] };
|
|
60603
60774
|
}
|
|
60604
|
-
function
|
|
60775
|
+
function isRecord5(value) {
|
|
60605
60776
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
60606
60777
|
}
|
|
60607
60778
|
function environmentFlag(value) {
|
|
@@ -60615,7 +60786,7 @@ function environmentFlag(value) {
|
|
|
60615
60786
|
return void 0;
|
|
60616
60787
|
}
|
|
60617
60788
|
function workflowsSwitch(settings, environment) {
|
|
60618
|
-
const setting =
|
|
60789
|
+
const setting = isRecord5(settings.effective) ? settings.effective.enableWorkflows : void 0;
|
|
60619
60790
|
const enabledByEnvironment = environmentFlag(environment.CLAUDE_CODE_WORKFLOWS);
|
|
60620
60791
|
if (setting === false || enabledByEnvironment === false || environmentFlag(environment.CLAUDE_CODE_DISABLE_WORKFLOWS) === true) {
|
|
60621
60792
|
return "off";
|
|
@@ -60623,13 +60794,13 @@ function workflowsSwitch(settings, environment) {
|
|
|
60623
60794
|
return setting === true || enabledByEnvironment === true ? "on" : "unknown";
|
|
60624
60795
|
}
|
|
60625
60796
|
function claudeUltracodeActive(settings) {
|
|
60626
|
-
if (!
|
|
60797
|
+
if (!isRecord5(settings) || !isRecord5(settings.applied)) {
|
|
60627
60798
|
throw new ClaudeUltracodeUnavailableError("unverifiable");
|
|
60628
60799
|
}
|
|
60629
60800
|
return settings.applied.ultracode === true;
|
|
60630
60801
|
}
|
|
60631
60802
|
function claudeUltracodeUnavailableReason(settings, environment = {}) {
|
|
60632
|
-
if (!
|
|
60803
|
+
if (!isRecord5(settings) || !isRecord5(settings.applied))
|
|
60633
60804
|
return "unverifiable";
|
|
60634
60805
|
const applied = settings.applied;
|
|
60635
60806
|
if (typeof applied.ultracode !== "boolean")
|
|
@@ -60748,17 +60919,17 @@ var SessionImportScope = class {
|
|
|
60748
60919
|
var CLAUDE_SESSION_IMPORT_TITLE_MAX_LENGTH = 120;
|
|
60749
60920
|
var CLAUDE_INTERNAL_USER_TEXT = /^<(?:local-command-|command-)/u;
|
|
60750
60921
|
var CLAUDE_SESSION_CHANGED = "Claude Code Session changed during discovery; refresh and retry";
|
|
60751
|
-
function
|
|
60922
|
+
function isRecord6(value) {
|
|
60752
60923
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
60753
60924
|
}
|
|
60754
60925
|
function cleanText(value) {
|
|
60755
60926
|
return sessionImportTitle(value, CLAUDE_SESSION_IMPORT_TITLE_MAX_LENGTH);
|
|
60756
60927
|
}
|
|
60757
60928
|
function userText(message) {
|
|
60758
|
-
if (!
|
|
60929
|
+
if (!isRecord6(message) || message.role !== "user")
|
|
60759
60930
|
return null;
|
|
60760
60931
|
const { content } = message;
|
|
60761
|
-
const text3 = typeof content === "string" ? cleanText(content) : Array.isArray(content) ? cleanText(content.filter((block) =>
|
|
60932
|
+
const text3 = typeof content === "string" ? cleanText(content) : Array.isArray(content) ? cleanText(content.filter((block) => isRecord6(block) && block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join(" ")) : null;
|
|
60762
60933
|
return text3 && !CLAUDE_INTERNAL_USER_TEXT.test(text3) ? text3 : null;
|
|
60763
60934
|
}
|
|
60764
60935
|
function claudeProjectsDirectory2(environment) {
|
|
@@ -60820,7 +60991,7 @@ async function readCandidate(file2, signal) {
|
|
|
60820
60991
|
} catch {
|
|
60821
60992
|
continue;
|
|
60822
60993
|
}
|
|
60823
|
-
if (!
|
|
60994
|
+
if (!isRecord6(entry))
|
|
60824
60995
|
continue;
|
|
60825
60996
|
if (typeof entry.sessionId === "string" && entry.sessionId !== nativeSessionId)
|
|
60826
60997
|
return null;
|
|
@@ -61296,7 +61467,18 @@ function referencesNpmBin(shim, name, bin) {
|
|
|
61296
61467
|
const text3 = shim.replaceAll("\\", "/").toLowerCase();
|
|
61297
61468
|
return text3.includes(`%dp0%/${target2}"`) || text3.includes(`%~dp0/${target2}"`);
|
|
61298
61469
|
}
|
|
61299
|
-
|
|
61470
|
+
function withAllowedScripts(environment, allowScripts) {
|
|
61471
|
+
if (!allowScripts)
|
|
61472
|
+
return environment;
|
|
61473
|
+
const existing = environment.npm_config_allow_scripts?.trim();
|
|
61474
|
+
if (!existing)
|
|
61475
|
+
return { ...environment, npm_config_allow_scripts: allowScripts };
|
|
61476
|
+
const entries = existing.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
61477
|
+
if (entries.includes(allowScripts))
|
|
61478
|
+
return environment;
|
|
61479
|
+
return { ...environment, npm_config_allow_scripts: [...entries, allowScripts].join(",") };
|
|
61480
|
+
}
|
|
61481
|
+
async function npmInstallation(command, packages, environment, options = {}) {
|
|
61300
61482
|
let selected = await realpath4(command);
|
|
61301
61483
|
if (process.platform === "win32" && /\.(cmd|bat)$/i.test(selected)) {
|
|
61302
61484
|
const shim = (await readFile3(selected, "utf8")).replaceAll("\\", "/");
|
|
@@ -61318,6 +61500,7 @@ async function npmInstallation(command, packages, environment) {
|
|
|
61318
61500
|
if (metadata?.name && packages.includes(metadata.name)) {
|
|
61319
61501
|
const name = metadata.name;
|
|
61320
61502
|
const currentVersion = installationVersion(metadata.version);
|
|
61503
|
+
const tracked = options.successor && options.successor !== name ? options.successor : name;
|
|
61321
61504
|
const segments = name.split("/");
|
|
61322
61505
|
let modules = directory;
|
|
61323
61506
|
for (let index = 0; index < segments.length; index++)
|
|
@@ -61347,13 +61530,23 @@ async function npmInstallation(command, packages, environment) {
|
|
|
61347
61530
|
currentVersion,
|
|
61348
61531
|
canUpdate,
|
|
61349
61532
|
latest: async () => {
|
|
61350
|
-
const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(
|
|
61533
|
+
const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(tracked)}/latest`));
|
|
61351
61534
|
return installationVersion(data.version);
|
|
61352
61535
|
},
|
|
61353
61536
|
update: async (version2) => {
|
|
61354
61537
|
if (!canUpdate || !npm)
|
|
61355
61538
|
throw new Error("Use the original package manager to update this installation");
|
|
61356
|
-
|
|
61539
|
+
const targetVersion = installationVersion(version2);
|
|
61540
|
+
const migrating = tracked !== name;
|
|
61541
|
+
if (migrating)
|
|
61542
|
+
await runInstallationCommand(npm.executable, ["uninstall", "--global", "--prefix", prefix, name], env, 3e5);
|
|
61543
|
+
try {
|
|
61544
|
+
await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${tracked}@${targetVersion}`], withAllowedScripts(env, options.allowScripts), 3e5);
|
|
61545
|
+
} catch (error63) {
|
|
61546
|
+
if (migrating)
|
|
61547
|
+
await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${name}@${currentVersion}`], env, 3e5).catch(() => void 0);
|
|
61548
|
+
throw error63;
|
|
61549
|
+
}
|
|
61357
61550
|
}
|
|
61358
61551
|
};
|
|
61359
61552
|
}
|
|
@@ -61608,7 +61801,7 @@ var hunkSchema = external_exports.object({
|
|
|
61608
61801
|
newLines: external_exports.number().int().nonnegative(),
|
|
61609
61802
|
lines: external_exports.array(external_exports.string())
|
|
61610
61803
|
}).strict();
|
|
61611
|
-
function
|
|
61804
|
+
function isRecord7(value) {
|
|
61612
61805
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61613
61806
|
}
|
|
61614
61807
|
function validNativePath(value) {
|
|
@@ -61632,7 +61825,7 @@ function validHunk(value) {
|
|
|
61632
61825
|
return hunk;
|
|
61633
61826
|
}
|
|
61634
61827
|
function parseClaudeNativeFileChange(toolName, value) {
|
|
61635
|
-
if (toolName !== "Edit" && toolName !== "Write" || !
|
|
61828
|
+
if (toolName !== "Edit" && toolName !== "Write" || !isRecord7(value))
|
|
61636
61829
|
return null;
|
|
61637
61830
|
if (!validNativePath(value.filePath) || !Array.isArray(value.structuredPatch))
|
|
61638
61831
|
return null;
|
|
@@ -61770,11 +61963,11 @@ function isClaudeNarrationSignature(signature) {
|
|
|
61770
61963
|
}
|
|
61771
61964
|
|
|
61772
61965
|
// dist/task-tracker.js
|
|
61773
|
-
function
|
|
61966
|
+
function isRecord8(value) {
|
|
61774
61967
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61775
61968
|
}
|
|
61776
61969
|
function stringField(value, keys) {
|
|
61777
|
-
if (!
|
|
61970
|
+
if (!isRecord8(value))
|
|
61778
61971
|
return void 0;
|
|
61779
61972
|
for (const key of keys) {
|
|
61780
61973
|
const field2 = value[key];
|
|
@@ -61817,7 +62010,7 @@ var ClaudeTaskTracker = class {
|
|
|
61817
62010
|
};
|
|
61818
62011
|
}
|
|
61819
62012
|
#create(args, result) {
|
|
61820
|
-
if (!
|
|
62013
|
+
if (!isRecord8(result) || !isRecord8(result.task))
|
|
61821
62014
|
return;
|
|
61822
62015
|
const id3 = stringField(result.task, ["id"]);
|
|
61823
62016
|
const subject = stringField(args, ["subject"]) ?? stringField(result.task, ["subject"]);
|
|
@@ -61835,7 +62028,7 @@ var ClaudeTaskTracker = class {
|
|
|
61835
62028
|
const id3 = stringField(args, ["taskId", "id", "task_id"]);
|
|
61836
62029
|
if (!id3)
|
|
61837
62030
|
return;
|
|
61838
|
-
const status =
|
|
62031
|
+
const status = isRecord8(args) ? taskStatus(args.status) : void 0;
|
|
61839
62032
|
if (status === "deleted") {
|
|
61840
62033
|
this.#tasks.delete(id3);
|
|
61841
62034
|
return;
|
|
@@ -61854,7 +62047,7 @@ var ClaudeTaskTracker = class {
|
|
|
61854
62047
|
}
|
|
61855
62048
|
/** A read of one task is authoritative for that task, as TaskList is for all of them. */
|
|
61856
62049
|
#refresh(args, result) {
|
|
61857
|
-
if (!
|
|
62050
|
+
if (!isRecord8(result) || !("task" in result))
|
|
61858
62051
|
return;
|
|
61859
62052
|
if (result.task === null) {
|
|
61860
62053
|
const id4 = stringField(args, ["taskId", "id", "task_id"]);
|
|
@@ -61864,20 +62057,20 @@ var ClaudeTaskTracker = class {
|
|
|
61864
62057
|
}
|
|
61865
62058
|
const id3 = stringField(result.task, ["id"]);
|
|
61866
62059
|
const subject = stringField(result.task, ["subject"]);
|
|
61867
|
-
const status =
|
|
62060
|
+
const status = isRecord8(result.task) ? taskStatus(result.task.status) : void 0;
|
|
61868
62061
|
if (!id3 || !subject || !status || status === "deleted")
|
|
61869
62062
|
return;
|
|
61870
62063
|
const activeForm = this.#tasks.get(id3)?.activeForm;
|
|
61871
62064
|
this.#tasks.set(id3, { id: id3, subject, ...activeForm ? { activeForm } : {}, status });
|
|
61872
62065
|
}
|
|
61873
62066
|
#replace(result) {
|
|
61874
|
-
if (!
|
|
62067
|
+
if (!isRecord8(result) || !Array.isArray(result.tasks))
|
|
61875
62068
|
return;
|
|
61876
62069
|
const next = /* @__PURE__ */ new Map();
|
|
61877
62070
|
for (const value of result.tasks) {
|
|
61878
62071
|
const id3 = stringField(value, ["id"]);
|
|
61879
62072
|
const subject = stringField(value, ["subject"]);
|
|
61880
|
-
const status =
|
|
62073
|
+
const status = isRecord8(value) ? taskStatus(value.status) : void 0;
|
|
61881
62074
|
if (!id3 || !subject || !status || status === "deleted")
|
|
61882
62075
|
continue;
|
|
61883
62076
|
const existing = this.#tasks.get(id3);
|
|
@@ -61903,7 +62096,7 @@ var BACKGROUND_OUTPUT_FILE_PATTERN = /Output is being written to: (.+?\.output)\
|
|
|
61903
62096
|
var SUBAGENT_DESCRIPTION_LIMIT = 500;
|
|
61904
62097
|
var SUBAGENT_SUMMARY_LIMIT = 2e3;
|
|
61905
62098
|
var WORKFLOW_PROGRESS_ENTRY_LIMIT = 500;
|
|
61906
|
-
function
|
|
62099
|
+
function isRecord9(value) {
|
|
61907
62100
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61908
62101
|
}
|
|
61909
62102
|
function nativeUuid(message) {
|
|
@@ -61913,12 +62106,12 @@ function parentToolUseId(message) {
|
|
|
61913
62106
|
return typeof message.parent_tool_use_id === "string" && message.parent_tool_use_id.length > 0 ? message.parent_tool_use_id : null;
|
|
61914
62107
|
}
|
|
61915
62108
|
function assistantNativeMessageId(message) {
|
|
61916
|
-
if (!
|
|
62109
|
+
if (!isRecord9(message.message))
|
|
61917
62110
|
return null;
|
|
61918
62111
|
return typeof message.message.id === "string" && message.message.id.length > 0 ? message.message.id : null;
|
|
61919
62112
|
}
|
|
61920
62113
|
function assistantContent(message) {
|
|
61921
|
-
if (message.type !== "assistant" || !
|
|
62114
|
+
if (message.type !== "assistant" || !isRecord9(message.message))
|
|
61922
62115
|
return null;
|
|
61923
62116
|
return Array.isArray(message.message.content) ? message.message.content : null;
|
|
61924
62117
|
}
|
|
@@ -61926,10 +62119,10 @@ function assistantText(message) {
|
|
|
61926
62119
|
const content = assistantContent(message);
|
|
61927
62120
|
if (!content)
|
|
61928
62121
|
return null;
|
|
61929
|
-
return content.flatMap((block) =>
|
|
62122
|
+
return content.flatMap((block) => isRecord9(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
|
|
61930
62123
|
}
|
|
61931
62124
|
function assistantError(message) {
|
|
61932
|
-
return
|
|
62125
|
+
return isRecord9(message) && message.type === "assistant" && typeof message.error === "string" ? message.error : null;
|
|
61933
62126
|
}
|
|
61934
62127
|
function boundedString(value, limit) {
|
|
61935
62128
|
if (typeof value !== "string")
|
|
@@ -61940,25 +62133,25 @@ function boundedString(value, limit) {
|
|
|
61940
62133
|
return trimmed.slice(0, limit);
|
|
61941
62134
|
}
|
|
61942
62135
|
function subagentDescription(argumentsValue, toolName) {
|
|
61943
|
-
if (!
|
|
62136
|
+
if (!isRecord9(argumentsValue))
|
|
61944
62137
|
return `${toolName} delegation`;
|
|
61945
62138
|
return boundedString(argumentsValue.description, SUBAGENT_DESCRIPTION_LIMIT) ?? boundedString(argumentsValue.summary, SUBAGENT_DESCRIPTION_LIMIT) ?? boundedString(argumentsValue.name, SUBAGENT_DESCRIPTION_LIMIT) ?? `${toolName} delegation`;
|
|
61946
62139
|
}
|
|
61947
62140
|
function subagentPrompt(argumentsValue) {
|
|
61948
|
-
if (!
|
|
62141
|
+
if (!isRecord9(argumentsValue))
|
|
61949
62142
|
return void 0;
|
|
61950
62143
|
return boundedString(argumentsValue.prompt ?? argumentsValue.message, SUBAGENT_SUMMARY_LIMIT);
|
|
61951
62144
|
}
|
|
61952
62145
|
function subagentRole(argumentsValue) {
|
|
61953
|
-
if (!
|
|
62146
|
+
if (!isRecord9(argumentsValue))
|
|
61954
62147
|
return void 0;
|
|
61955
62148
|
return boundedString(argumentsValue.subagent_type ?? argumentsValue.agent_type, SUBAGENT_DESCRIPTION_LIMIT);
|
|
61956
62149
|
}
|
|
61957
62150
|
function subagentBackground(argumentsValue) {
|
|
61958
|
-
return
|
|
62151
|
+
return isRecord9(argumentsValue) && argumentsValue.run_in_background === true;
|
|
61959
62152
|
}
|
|
61960
62153
|
function targetedSubagentId(argumentsValue) {
|
|
61961
|
-
if (!
|
|
62154
|
+
if (!isRecord9(argumentsValue))
|
|
61962
62155
|
return void 0;
|
|
61963
62156
|
return boundedString(argumentsValue.to ?? argumentsValue.recipient ?? argumentsValue.agentId, SUBAGENT_DESCRIPTION_LIMIT);
|
|
61964
62157
|
}
|
|
@@ -61967,13 +62160,13 @@ function sendResultFromText(outputText) {
|
|
|
61967
62160
|
return void 0;
|
|
61968
62161
|
try {
|
|
61969
62162
|
const parsed = JSON.parse(outputText);
|
|
61970
|
-
return
|
|
62163
|
+
return isRecord9(parsed) ? parsed : void 0;
|
|
61971
62164
|
} catch {
|
|
61972
62165
|
return void 0;
|
|
61973
62166
|
}
|
|
61974
62167
|
}
|
|
61975
62168
|
function claudeSendMessageFailed(nativeResult, outputText) {
|
|
61976
|
-
return
|
|
62169
|
+
return isRecord9(nativeResult) && typeof nativeResult.success === "boolean" ? !nativeResult.success : sendResultFromText(outputText)?.success === false;
|
|
61977
62170
|
}
|
|
61978
62171
|
function includesAuthenticationFailure(errors) {
|
|
61979
62172
|
return errors.some((error63) => AUTHENTICATION_ERRORS.has(error63));
|
|
@@ -61988,11 +62181,11 @@ function finiteNonNegativeNumber(value) {
|
|
|
61988
62181
|
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
61989
62182
|
}
|
|
61990
62183
|
function parseResultModelUsage(value) {
|
|
61991
|
-
if (!
|
|
62184
|
+
if (!isRecord9(value))
|
|
61992
62185
|
return void 0;
|
|
61993
62186
|
const usage = [];
|
|
61994
62187
|
for (const [model2, entry] of Object.entries(value)) {
|
|
61995
|
-
if (!
|
|
62188
|
+
if (!isRecord9(entry) || !safeNonNegativeInteger(entry.inputTokens) || !safeNonNegativeInteger(entry.outputTokens)) {
|
|
61996
62189
|
return void 0;
|
|
61997
62190
|
}
|
|
61998
62191
|
const cacheRead = safeNonNegativeInteger(entry.cacheReadInputTokens) ? entry.cacheReadInputTokens : 0;
|
|
@@ -62009,7 +62202,7 @@ function parseResultModelUsage(value) {
|
|
|
62009
62202
|
return usage;
|
|
62010
62203
|
}
|
|
62011
62204
|
function parseLastRequestUsage(value, attribution = {}) {
|
|
62012
|
-
if (!
|
|
62205
|
+
if (!isRecord9(value))
|
|
62013
62206
|
return void 0;
|
|
62014
62207
|
const inputTokens = value.input_tokens;
|
|
62015
62208
|
const outputTokens = value.output_tokens;
|
|
@@ -62021,6 +62214,7 @@ function parseLastRequestUsage(value, attribution = {}) {
|
|
|
62021
62214
|
const requestId = boundedString(attribution.requestId, 500);
|
|
62022
62215
|
const model2 = boundedString(attribution.model, 500);
|
|
62023
62216
|
const provider = boundedString(attribution.provider, 100);
|
|
62217
|
+
const promptCacheTtlSeconds = claudePromptCacheTtlSeconds(value);
|
|
62024
62218
|
return {
|
|
62025
62219
|
...requestId ? { requestId } : {},
|
|
62026
62220
|
...model2 ? { model: model2 } : {},
|
|
@@ -62028,11 +62222,12 @@ function parseLastRequestUsage(value, attribution = {}) {
|
|
|
62028
62222
|
inputTokens,
|
|
62029
62223
|
outputTokens,
|
|
62030
62224
|
cacheCreationInputTokens,
|
|
62031
|
-
cacheReadInputTokens
|
|
62225
|
+
cacheReadInputTokens,
|
|
62226
|
+
...promptCacheTtlSeconds !== void 0 ? { promptCacheTtlSeconds } : {}
|
|
62032
62227
|
};
|
|
62033
62228
|
}
|
|
62034
62229
|
function assistantRequestUsage(message, provider) {
|
|
62035
|
-
if (!
|
|
62230
|
+
if (!isRecord9(message.message))
|
|
62036
62231
|
return void 0;
|
|
62037
62232
|
return parseLastRequestUsage(message.message.usage, {
|
|
62038
62233
|
requestId: message.message.id ?? message.request_id,
|
|
@@ -62055,7 +62250,7 @@ function parseResultUsageEvent(message) {
|
|
|
62055
62250
|
};
|
|
62056
62251
|
}
|
|
62057
62252
|
function parsePlanLimitWindow(value) {
|
|
62058
|
-
if (!
|
|
62253
|
+
if (!isRecord9(value))
|
|
62059
62254
|
return void 0;
|
|
62060
62255
|
const utilization = value.utilization;
|
|
62061
62256
|
if (typeof utilization !== "number" || !Number.isFinite(utilization) || utilization < 0) {
|
|
@@ -62067,12 +62262,12 @@ function parsePlanLimitWindow(value) {
|
|
|
62067
62262
|
return { utilizationPercent, ...resetsAtUnix !== void 0 ? { resetsAtUnix } : {} };
|
|
62068
62263
|
}
|
|
62069
62264
|
function parseClaudePlanLimitEvent(message) {
|
|
62070
|
-
if (!
|
|
62265
|
+
if (!isRecord9(message) || message.type !== "rate_limit_event")
|
|
62071
62266
|
return null;
|
|
62072
62267
|
const info = message.rate_limit_info;
|
|
62073
|
-
if (!
|
|
62268
|
+
if (!isRecord9(info))
|
|
62074
62269
|
return null;
|
|
62075
|
-
const windows =
|
|
62270
|
+
const windows = isRecord9(info.unifiedWindows) ? info.unifiedWindows : void 0;
|
|
62076
62271
|
let fiveHour = parsePlanLimitWindow(windows?.five_hour);
|
|
62077
62272
|
let sevenDay = parsePlanLimitWindow(windows?.seven_day);
|
|
62078
62273
|
if (!fiveHour && !sevenDay) {
|
|
@@ -62090,15 +62285,15 @@ function parseClaudePlanLimitEvent(message) {
|
|
|
62090
62285
|
};
|
|
62091
62286
|
}
|
|
62092
62287
|
function nativeSubagentId(nativeResult, outputText) {
|
|
62093
|
-
if (
|
|
62094
|
-
const structured = boundedString(nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id ?? nativeResult.resumedAgentId ?? nativeResult.revivedAgentId ?? (
|
|
62288
|
+
if (isRecord9(nativeResult)) {
|
|
62289
|
+
const structured = boundedString(nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id ?? nativeResult.resumedAgentId ?? nativeResult.revivedAgentId ?? (isRecord9(nativeResult.pin) ? nativeResult.pin.id : void 0), SUBAGENT_DESCRIPTION_LIMIT);
|
|
62095
62290
|
if (structured)
|
|
62096
62291
|
return structured;
|
|
62097
62292
|
}
|
|
62098
62293
|
return boundedString(/agentId:\s*([A-Za-z0-9_-]+)/u.exec(outputText ?? "")?.[1], SUBAGENT_DESCRIPTION_LIMIT);
|
|
62099
62294
|
}
|
|
62100
62295
|
function subagentContinuesInBackground(nativeResult, outputText) {
|
|
62101
|
-
if (
|
|
62296
|
+
if (isRecord9(nativeResult)) {
|
|
62102
62297
|
if (nativeResult.isAsync === true || nativeResult.is_async === true)
|
|
62103
62298
|
return true;
|
|
62104
62299
|
if (nativeResult.status === "async_launched")
|
|
@@ -62111,11 +62306,11 @@ function resultText(content, nativeResult) {
|
|
|
62111
62306
|
if (typeof content === "string") {
|
|
62112
62307
|
text3 = content;
|
|
62113
62308
|
} else if (Array.isArray(content)) {
|
|
62114
|
-
text3 = content.flatMap((block) =>
|
|
62309
|
+
text3 = content.flatMap((block) => isRecord9(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
|
|
62115
62310
|
}
|
|
62116
62311
|
if (text3.length > 0)
|
|
62117
62312
|
return text3;
|
|
62118
|
-
if (!
|
|
62313
|
+
if (!isRecord9(nativeResult))
|
|
62119
62314
|
return void 0;
|
|
62120
62315
|
const stdout = typeof nativeResult.stdout === "string" ? nativeResult.stdout : "";
|
|
62121
62316
|
const stderr = typeof nativeResult.stderr === "string" ? nativeResult.stderr : "";
|
|
@@ -62127,13 +62322,13 @@ function userMessageText(content) {
|
|
|
62127
62322
|
return content;
|
|
62128
62323
|
if (!Array.isArray(content))
|
|
62129
62324
|
return null;
|
|
62130
|
-
const text3 = content.flatMap((block) =>
|
|
62325
|
+
const text3 = content.flatMap((block) => isRecord9(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
|
|
62131
62326
|
return text3.length > 0 ? text3 : null;
|
|
62132
62327
|
}
|
|
62133
62328
|
function parseClaudeTaskNotification(message) {
|
|
62134
|
-
if (!
|
|
62329
|
+
if (!isRecord9(message) || message.type !== "user" || !isRecord9(message.message))
|
|
62135
62330
|
return null;
|
|
62136
|
-
if (
|
|
62331
|
+
if (isRecord9(message.origin) && message.origin.kind !== "task-notification")
|
|
62137
62332
|
return null;
|
|
62138
62333
|
const content = userMessageText(message.message.content);
|
|
62139
62334
|
if (!content || !content.includes("<task-notification>"))
|
|
@@ -62193,7 +62388,7 @@ function parseClaudeWorkflowAgents(value) {
|
|
|
62193
62388
|
return null;
|
|
62194
62389
|
const agents = [];
|
|
62195
62390
|
for (const entry of value.slice(0, WORKFLOW_PROGRESS_ENTRY_LIMIT)) {
|
|
62196
|
-
if (!
|
|
62391
|
+
if (!isRecord9(entry) || entry.type !== "workflow_agent")
|
|
62197
62392
|
continue;
|
|
62198
62393
|
const index = entry.index;
|
|
62199
62394
|
const state = workflowAgentState(entry);
|
|
@@ -62245,7 +62440,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62245
62440
|
}
|
|
62246
62441
|
#usageRequest = null;
|
|
62247
62442
|
consume(message) {
|
|
62248
|
-
if (this.#completed || !
|
|
62443
|
+
if (this.#completed || !isRecord9(message))
|
|
62249
62444
|
return { events: [] };
|
|
62250
62445
|
const events = [];
|
|
62251
62446
|
this.#consumeSegmentLevel(message, events);
|
|
@@ -62264,7 +62459,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62264
62459
|
this.#consumeCompaction(message, events);
|
|
62265
62460
|
this.#consumeLocalCommandOutput(message, events);
|
|
62266
62461
|
}
|
|
62267
|
-
if (message.type === "stream_event" &&
|
|
62462
|
+
if (message.type === "stream_event" && isRecord9(message.event)) {
|
|
62268
62463
|
if (!nested) {
|
|
62269
62464
|
this.#observeUsage(message.event, events);
|
|
62270
62465
|
this.#consumeStreamEvent(message, events);
|
|
@@ -62372,14 +62567,14 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62372
62567
|
if (message.type !== "system")
|
|
62373
62568
|
return;
|
|
62374
62569
|
if (message.subtype === "init") {
|
|
62375
|
-
const mcpServers = Array.isArray(message.mcp_servers) ? message.mcp_servers.flatMap((server) =>
|
|
62570
|
+
const mcpServers = Array.isArray(message.mcp_servers) ? message.mcp_servers.flatMap((server) => isRecord9(server) && typeof server.name === "string" ? [server.name] : []) : void 0;
|
|
62376
62571
|
events.push({ type: "segment.started", ...mcpServers ? { mcpServers } : {} });
|
|
62377
62572
|
return;
|
|
62378
62573
|
}
|
|
62379
62574
|
if (message.subtype !== "background_tasks_changed" || !Array.isArray(message.tasks))
|
|
62380
62575
|
return;
|
|
62381
62576
|
const nativeSubagentIds = message.tasks.flatMap((task) => {
|
|
62382
|
-
if (!
|
|
62577
|
+
if (!isRecord9(task))
|
|
62383
62578
|
return [];
|
|
62384
62579
|
const taskId = boundedString(task.task_id, SUBAGENT_DESCRIPTION_LIMIT);
|
|
62385
62580
|
return taskId ? [taskId] : [];
|
|
@@ -62455,7 +62650,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62455
62650
|
});
|
|
62456
62651
|
return;
|
|
62457
62652
|
}
|
|
62458
|
-
if (message.subtype === "task_updated" &&
|
|
62653
|
+
if (message.subtype === "task_updated" && isRecord9(message.patch)) {
|
|
62459
62654
|
const status = taskStatus2(message.patch.status);
|
|
62460
62655
|
if (!status)
|
|
62461
62656
|
return;
|
|
@@ -62481,7 +62676,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62481
62676
|
*/
|
|
62482
62677
|
#observeUsage(event, events) {
|
|
62483
62678
|
if (event.type === "message_start") {
|
|
62484
|
-
const message =
|
|
62679
|
+
const message = isRecord9(event.message) ? event.message : null;
|
|
62485
62680
|
this.#usageRequest = message && typeof message.id === "string" && message.id.length > 0 && isClaudeModelRequest(message.model) ? { id: message.id, model: message.model, usage: message.usage, startedAtMs: null } : null;
|
|
62486
62681
|
return;
|
|
62487
62682
|
}
|
|
@@ -62490,16 +62685,18 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62490
62685
|
return;
|
|
62491
62686
|
if (event.type === "content_block_start") {
|
|
62492
62687
|
request.startedAtMs ??= Date.now();
|
|
62493
|
-
} else if (event.type === "message_delta" &&
|
|
62494
|
-
request.usage = { ...
|
|
62688
|
+
} else if (event.type === "message_delta" && isRecord9(event.usage)) {
|
|
62689
|
+
request.usage = { ...isRecord9(request.usage) ? request.usage : {}, ...event.usage };
|
|
62495
62690
|
} else if (event.type === "message_stop") {
|
|
62496
62691
|
this.#usageRequest = null;
|
|
62692
|
+
const promptCacheTtlSeconds = claudePromptCacheTtlSeconds(request.usage);
|
|
62497
62693
|
events.push({
|
|
62498
62694
|
type: "usage.request",
|
|
62499
62695
|
record: claudeUsageRecord(request.id, request.model, request.usage, {
|
|
62500
62696
|
startedAtMs: request.startedAtMs,
|
|
62501
62697
|
completedAtMs: Date.now()
|
|
62502
|
-
})
|
|
62698
|
+
}),
|
|
62699
|
+
...promptCacheTtlSeconds !== void 0 ? { promptCacheTtlSeconds } : {}
|
|
62503
62700
|
});
|
|
62504
62701
|
}
|
|
62505
62702
|
}
|
|
@@ -62526,9 +62723,9 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62526
62723
|
}
|
|
62527
62724
|
#consumeStreamEvent(message, events) {
|
|
62528
62725
|
const event = message.event;
|
|
62529
|
-
if (!
|
|
62726
|
+
if (!isRecord9(event))
|
|
62530
62727
|
return;
|
|
62531
|
-
if (event.type === "message_start" &&
|
|
62728
|
+
if (event.type === "message_start" && isRecord9(event.message) && typeof event.message.id === "string" && event.message.id.length > 0) {
|
|
62532
62729
|
this.#activeRootStreamMessageId = event.message.id;
|
|
62533
62730
|
this.#messageState(event.message.id);
|
|
62534
62731
|
return;
|
|
@@ -62546,8 +62743,8 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62546
62743
|
}
|
|
62547
62744
|
return;
|
|
62548
62745
|
}
|
|
62549
|
-
const start = event.type === "content_block_start" &&
|
|
62550
|
-
const delta = event.type === "content_block_delta" &&
|
|
62746
|
+
const start = event.type === "content_block_start" && isRecord9(event.content_block) && event.content_block.type === "thinking" ? event.content_block : null;
|
|
62747
|
+
const delta = event.type === "content_block_delta" && isRecord9(event.delta) ? event.delta : null;
|
|
62551
62748
|
if (!start && !delta)
|
|
62552
62749
|
return;
|
|
62553
62750
|
const messageId = this.#activeRootStreamMessageId ?? nativeUuid(message) ?? this.#nextMessageId();
|
|
@@ -62602,7 +62799,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62602
62799
|
const state = this.#messageState(messageId);
|
|
62603
62800
|
const content = assistantContent(message) ?? [];
|
|
62604
62801
|
for (const [index, block] of content.entries()) {
|
|
62605
|
-
if (!
|
|
62802
|
+
if (!isRecord9(block) || block.type !== "thinking")
|
|
62606
62803
|
continue;
|
|
62607
62804
|
const identity2 = `${checkpointId ?? nativeMessageId ?? messageId}:${index}`;
|
|
62608
62805
|
if (this.#completedThinkingBlocks.has(identity2))
|
|
@@ -62619,7 +62816,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62619
62816
|
const complete = typeof block.thinking === "string" ? block.thinking : "";
|
|
62620
62817
|
this.#publishNarration(thinking, blockId, block.signature || thinking?.signature, complete.startsWith(streamed) ? complete : streamed, events);
|
|
62621
62818
|
}
|
|
62622
|
-
const keepsStreaming = nativeMessageId !== null && nativeMessageId === this.#activeRootStreamMessageId && content.length === 1 &&
|
|
62819
|
+
const keepsStreaming = nativeMessageId !== null && nativeMessageId === this.#activeRootStreamMessageId && content.length === 1 && isRecord9(content[0]) && content[0].type === "thinking";
|
|
62623
62820
|
if (keepsStreaming && checkpointId && this.#publishedCheckpointIds.has(checkpointId))
|
|
62624
62821
|
return;
|
|
62625
62822
|
if (!keepsStreaming) {
|
|
@@ -62713,7 +62910,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62713
62910
|
}
|
|
62714
62911
|
#consumeToolUseBlocks(message, events, ignoreKnownIds) {
|
|
62715
62912
|
for (const block of assistantContent(message) ?? []) {
|
|
62716
|
-
if (!
|
|
62913
|
+
if (!isRecord9(block) || block.type !== "tool_use")
|
|
62717
62914
|
continue;
|
|
62718
62915
|
const argumentsResult = jsonValueSchema.safeParse(block.input);
|
|
62719
62916
|
if (typeof block.id !== "string" || block.id.length === 0 || typeof block.name !== "string" || block.name.length === 0 || !argumentsResult.success) {
|
|
@@ -62727,7 +62924,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62727
62924
|
}
|
|
62728
62925
|
const subagent = CLAUDE_SUBAGENT_TOOLS.has(block.name);
|
|
62729
62926
|
const workflow = block.name === CLAUDE_WORKFLOW_TOOL;
|
|
62730
|
-
const spawnName = subagent && block.name !== "SendMessage" &&
|
|
62927
|
+
const spawnName = subagent && block.name !== "SendMessage" && isRecord9(argumentsResult.data) ? boundedString(argumentsResult.data.name, SUBAGENT_DESCRIPTION_LIMIT) : void 0;
|
|
62731
62928
|
this.#tools.set(block.id, {
|
|
62732
62929
|
name: block.name,
|
|
62733
62930
|
subagent,
|
|
@@ -62735,7 +62932,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62735
62932
|
...spawnName ? { spawnName } : {}
|
|
62736
62933
|
});
|
|
62737
62934
|
if (workflow) {
|
|
62738
|
-
const name =
|
|
62935
|
+
const name = isRecord9(argumentsResult.data) ? boundedString(argumentsResult.data.name, SUBAGENT_DESCRIPTION_LIMIT) : void 0;
|
|
62739
62936
|
events.push({ type: "workflow.started", callId: block.id, ...name ? { name } : {} });
|
|
62740
62937
|
} else if (subagent) {
|
|
62741
62938
|
const prompt = subagentPrompt(argumentsResult.data);
|
|
@@ -62777,9 +62974,9 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62777
62974
|
events.push(settled);
|
|
62778
62975
|
}
|
|
62779
62976
|
#consumeToolResults(message, events, ignoreUnknown) {
|
|
62780
|
-
if (!
|
|
62977
|
+
if (!isRecord9(message.message) || !Array.isArray(message.message.content))
|
|
62781
62978
|
return;
|
|
62782
|
-
const resultBlocks = message.message.content.filter((block) =>
|
|
62979
|
+
const resultBlocks = message.message.content.filter((block) => isRecord9(block) && block.type === "tool_result");
|
|
62783
62980
|
if (resultBlocks.length === 0)
|
|
62784
62981
|
return;
|
|
62785
62982
|
if (resultBlocks.length > 1 && message.tool_use_result !== void 0) {
|
|
@@ -62808,8 +63005,8 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62808
63005
|
const outputText = resultText(block.content, nativeResult);
|
|
62809
63006
|
const structuredResult = isClaudeTaskTool(tool.name) ? jsonValueSchema.safeParse(nativeResult) : null;
|
|
62810
63007
|
if (tool.workflow) {
|
|
62811
|
-
const status =
|
|
62812
|
-
const taskId =
|
|
63008
|
+
const status = isRecord9(nativeResult) ? nativeResult.status : void 0;
|
|
63009
|
+
const taskId = isRecord9(nativeResult) ? boundedString(nativeResult.taskId, SUBAGENT_DESCRIPTION_LIMIT) : void 0;
|
|
62813
63010
|
const resultSummary = boundedString(outputText, SUBAGENT_SUMMARY_LIMIT);
|
|
62814
63011
|
events.push({
|
|
62815
63012
|
type: "workflow.launched",
|
|
@@ -62824,13 +63021,13 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62824
63021
|
if (tool.subagent) {
|
|
62825
63022
|
const resultSummary = boundedString(outputText, SUBAGENT_SUMMARY_LIMIT);
|
|
62826
63023
|
const send = tool.name === "SendMessage";
|
|
62827
|
-
const result = send && !
|
|
63024
|
+
const result = send && !isRecord9(nativeResult) ? sendResultFromText(outputText) : nativeResult;
|
|
62828
63025
|
const failed = isError || send && claudeSendMessageFailed(result, outputText);
|
|
62829
63026
|
const agentId = nativeSubagentId(result, outputText);
|
|
62830
63027
|
if (!failed) {
|
|
62831
63028
|
if (tool.spawnName && agentId)
|
|
62832
63029
|
this.#subagentIdsByName.set(tool.spawnName, agentId);
|
|
62833
|
-
if (send &&
|
|
63030
|
+
if (send && isRecord9(result) && isRecord9(result.pin)) {
|
|
62834
63031
|
const name = boundedString(result.pin.name, SUBAGENT_DESCRIPTION_LIMIT);
|
|
62835
63032
|
const id3 = boundedString(result.pin.id, SUBAGENT_DESCRIPTION_LIMIT);
|
|
62836
63033
|
if (name && id3)
|
|
@@ -62848,7 +63045,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62848
63045
|
continue;
|
|
62849
63046
|
}
|
|
62850
63047
|
const fileChange = isError ? null : parseClaudeNativeFileChange(tool.name, nativeResult);
|
|
62851
|
-
const backgroundTaskId = tool.name === "Bash" && !isError &&
|
|
63048
|
+
const backgroundTaskId = tool.name === "Bash" && !isError && isRecord9(nativeResult) && typeof nativeResult.backgroundTaskId === "string" && nativeResult.backgroundTaskId.length > 0 ? nativeResult.backgroundTaskId : void 0;
|
|
62852
63049
|
const outputFile = backgroundTaskId !== void 0 ? BACKGROUND_OUTPUT_FILE_PATTERN.exec(outputText ?? "")?.[1] : void 0;
|
|
62853
63050
|
const backgroundOutputFile = typeof outputFile === "string" && outputFile.length > 0 ? outputFile : void 0;
|
|
62854
63051
|
events.push({
|
|
@@ -62914,12 +63111,12 @@ function claudeTranscriptItemId(nativeTurnKey, kind, ordinal) {
|
|
|
62914
63111
|
}
|
|
62915
63112
|
|
|
62916
63113
|
// dist/claude-queued-command.js
|
|
62917
|
-
function
|
|
63114
|
+
function isRecord10(value) {
|
|
62918
63115
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
62919
63116
|
}
|
|
62920
63117
|
function readClaudeQueuedCommand(value, sessionId) {
|
|
62921
63118
|
const attachment = value.attachment;
|
|
62922
|
-
if (value.type !== "attachment" || !
|
|
63119
|
+
if (value.type !== "attachment" || !isRecord10(attachment) || attachment.type !== "queued_command" || attachment.commandMode !== "prompt" || !isRecord10(attachment.origin) || attachment.origin.kind !== "human" || attachment.humanTurn === false || attachment.isMeta === true || attachment.isSynthetic === true || value.isMeta === true || value.isSynthetic === true || value.isSidechain === true || isRecord10(value.origin) && value.origin.kind !== "human" || typeof value.parent_tool_use_id === "string" && value.parent_tool_use_id.length > 0 || value.sessionId !== void 0 && value.sessionId !== sessionId || value.session_id !== sessionId) {
|
|
62923
63120
|
return null;
|
|
62924
63121
|
}
|
|
62925
63122
|
const prompt = promptText(attachment.prompt);
|
|
@@ -62933,7 +63130,7 @@ function promptText(prompt) {
|
|
|
62933
63130
|
return prompt;
|
|
62934
63131
|
if (!Array.isArray(prompt))
|
|
62935
63132
|
return "";
|
|
62936
|
-
return prompt.flatMap((block) =>
|
|
63133
|
+
return prompt.flatMap((block) => isRecord10(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
62937
63134
|
}
|
|
62938
63135
|
|
|
62939
63136
|
// dist/claude-history.js
|
|
@@ -62957,7 +63154,7 @@ function isPersistedClaudeMessageId(expectedId, persistedIds) {
|
|
|
62957
63154
|
}
|
|
62958
63155
|
return false;
|
|
62959
63156
|
}
|
|
62960
|
-
function
|
|
63157
|
+
function isRecord11(value) {
|
|
62961
63158
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
62962
63159
|
}
|
|
62963
63160
|
function textParts(value) {
|
|
@@ -62965,7 +63162,7 @@ function textParts(value) {
|
|
|
62965
63162
|
return value.length > 0 ? [value] : [];
|
|
62966
63163
|
if (!Array.isArray(value))
|
|
62967
63164
|
return [];
|
|
62968
|
-
return value.flatMap((part) =>
|
|
63165
|
+
return value.flatMap((part) => isRecord11(part) && part.type === "text" && typeof part.text === "string" ? [part.text] : []);
|
|
62969
63166
|
}
|
|
62970
63167
|
var localCommandRecordPattern = /^\s*<(local-command-(?:stdout|caveat))>[\s\S]*<\/\1>\s*$/u;
|
|
62971
63168
|
var taskNotificationRecordPattern = /^\s*<task-notification>[\s\S]*<\/task-notification>\s*$/u;
|
|
@@ -63015,7 +63212,7 @@ function localCommandStdoutText(text3) {
|
|
|
63015
63212
|
return match[1] ?? "";
|
|
63016
63213
|
}
|
|
63017
63214
|
function isTaskNotificationOrigin(value) {
|
|
63018
|
-
return
|
|
63215
|
+
return isRecord11(value.origin) && value.origin.kind === "task-notification";
|
|
63019
63216
|
}
|
|
63020
63217
|
function visibleUserTextParts(message) {
|
|
63021
63218
|
if (message.type !== "user" || message.syntheticUser)
|
|
@@ -63029,16 +63226,16 @@ function hasRootToolResult(message) {
|
|
|
63029
63226
|
if (message.type !== "user" || message.nested || !Array.isArray(message.message.content)) {
|
|
63030
63227
|
return false;
|
|
63031
63228
|
}
|
|
63032
|
-
return message.message.content.some((block) =>
|
|
63229
|
+
return message.message.content.some((block) => isRecord11(block) && block.type === "tool_result");
|
|
63033
63230
|
}
|
|
63034
63231
|
function isInterruptionRecord(value, promptId) {
|
|
63035
|
-
if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !
|
|
63232
|
+
if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !isRecord11(value.message))
|
|
63036
63233
|
return false;
|
|
63037
63234
|
const content = value.message.content;
|
|
63038
63235
|
if (!Array.isArray(content) || content.length !== 1)
|
|
63039
63236
|
return false;
|
|
63040
63237
|
const part = content[0];
|
|
63041
|
-
return
|
|
63238
|
+
return isRecord11(part) && part.type === "text" && (part.text === "[Request interrupted by user]" || part.text === "[Request interrupted by user for tool use]");
|
|
63042
63239
|
}
|
|
63043
63240
|
function conversationMessages(values, sessionId) {
|
|
63044
63241
|
const messages = [];
|
|
@@ -63050,7 +63247,7 @@ function conversationMessages(values, sessionId) {
|
|
|
63050
63247
|
const sends = /* @__PURE__ */ new Map();
|
|
63051
63248
|
let pendingNotification = false;
|
|
63052
63249
|
for (const value of values) {
|
|
63053
|
-
if (!
|
|
63250
|
+
if (!isRecord11(value))
|
|
63054
63251
|
throw new Error("Claude history contains a malformed message");
|
|
63055
63252
|
if (value.type === "system")
|
|
63056
63253
|
continue;
|
|
@@ -63074,7 +63271,7 @@ function conversationMessages(values, sessionId) {
|
|
|
63074
63271
|
});
|
|
63075
63272
|
continue;
|
|
63076
63273
|
}
|
|
63077
|
-
if (value.type !== "user" && value.type !== "assistant" || typeof value.uuid !== "string" || value.uuid.length === 0 || value.session_id !== sessionId || !
|
|
63274
|
+
if (value.type !== "user" && value.type !== "assistant" || typeof value.uuid !== "string" || value.uuid.length === 0 || value.session_id !== sessionId || !isRecord11(value.message) || value.message.role !== value.type) {
|
|
63078
63275
|
throw new Error("Claude history contains an invalid message identity");
|
|
63079
63276
|
}
|
|
63080
63277
|
if (ids.has(value.uuid))
|
|
@@ -63090,7 +63287,7 @@ function conversationMessages(values, sessionId) {
|
|
|
63090
63287
|
nested: typeof value.parent_tool_use_id === "string" && value.parent_tool_use_id.length > 0,
|
|
63091
63288
|
interrupted,
|
|
63092
63289
|
startsTurn: false,
|
|
63093
|
-
...
|
|
63290
|
+
...isRecord11(value.forkedFrom) && typeof value.forkedFrom.messageUuid === "string" ? { forkSourceUuid: value.forkedFrom.messageUuid } : {},
|
|
63094
63291
|
syntheticUser: value.type === "user" && (interrupted || value.isSynthetic === true || value.isMeta === true || value.isCompactSummary === true || value.isVisibleInTranscriptOnly === true || isTaskNotificationOrigin(value) || value.toolUseResult !== void 0 && value.toolUseResult !== null)
|
|
63095
63292
|
};
|
|
63096
63293
|
const notification = message.type === "user" && !message.nested && (isTaskNotificationOrigin(value) || textParts(message.message.content).some(isTaskNotificationRecord));
|
|
@@ -63298,7 +63495,7 @@ function mapClaudeSnapshotWithCheckpointIds(values, sessionId, mcpServers, tasks
|
|
|
63298
63495
|
const items = [];
|
|
63299
63496
|
let projectedText = false;
|
|
63300
63497
|
for (const [blockIndex, block] of content.entries()) {
|
|
63301
|
-
if (!
|
|
63498
|
+
if (!isRecord11(block))
|
|
63302
63499
|
continue;
|
|
63303
63500
|
if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
63304
63501
|
if (block.thinking.length === 0)
|
|
@@ -63356,7 +63553,7 @@ function mapClaudeSnapshotWithCheckpointIds(values, sessionId, mcpServers, tasks
|
|
|
63356
63553
|
}
|
|
63357
63554
|
} : { status: "succeeded" };
|
|
63358
63555
|
const itemId = toolItem !== null ? claudeTranscriptItemId(user.uuid, "tool", toolItem) : hostItemIdSchema.parse(`claude-item-v1-${message.uuid}-tool-${blockIndex}`);
|
|
63359
|
-
if (block.name === "Bash" &&
|
|
63556
|
+
if (block.name === "Bash" && isRecord11(block.input) && typeof block.input.command === "string") {
|
|
63360
63557
|
items.push({
|
|
63361
63558
|
item: {
|
|
63362
63559
|
type: "commandExecution",
|
|
@@ -63408,7 +63605,7 @@ function toolResultBlocks(messages) {
|
|
|
63408
63605
|
if (message.type !== "user" || !Array.isArray(message.message.content))
|
|
63409
63606
|
continue;
|
|
63410
63607
|
for (const block of message.message.content) {
|
|
63411
|
-
if (
|
|
63608
|
+
if (isRecord11(block) && block.type === "tool_result" && typeof block.tool_use_id === "string") {
|
|
63412
63609
|
results.set(block.tool_use_id, block);
|
|
63413
63610
|
}
|
|
63414
63611
|
}
|
|
@@ -63423,7 +63620,7 @@ function toolResultOutput(block) {
|
|
|
63423
63620
|
}
|
|
63424
63621
|
function resultSubagentId(value, block) {
|
|
63425
63622
|
const nativeResult = value.tool_use_result;
|
|
63426
|
-
if (
|
|
63623
|
+
if (isRecord11(nativeResult)) {
|
|
63427
63624
|
const structured = nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id;
|
|
63428
63625
|
if (typeof structured === "string" && structured.length > 0)
|
|
63429
63626
|
return structured;
|
|
@@ -63434,13 +63631,13 @@ function resultSubagentId(value, block) {
|
|
|
63434
63631
|
function subagentPrompt2(values, nativeSubagentId2) {
|
|
63435
63632
|
const toolUses = /* @__PURE__ */ new Map();
|
|
63436
63633
|
for (const value of values) {
|
|
63437
|
-
if (!
|
|
63634
|
+
if (!isRecord11(value) || !isRecord11(value.message) || !Array.isArray(value.message.content)) {
|
|
63438
63635
|
continue;
|
|
63439
63636
|
}
|
|
63440
63637
|
for (const block of value.message.content) {
|
|
63441
|
-
if (!
|
|
63638
|
+
if (!isRecord11(block))
|
|
63442
63639
|
continue;
|
|
63443
|
-
if (block.type === "tool_use" && typeof block.id === "string" && (block.name === "Agent" || block.name === "Task") &&
|
|
63640
|
+
if (block.type === "tool_use" && typeof block.id === "string" && (block.name === "Agent" || block.name === "Task") && isRecord11(block.input) && typeof block.input.prompt === "string" && block.input.prompt.length > 0) {
|
|
63444
63641
|
toolUses.set(block.id, block.input.prompt);
|
|
63445
63642
|
continue;
|
|
63446
63643
|
}
|
|
@@ -63454,7 +63651,7 @@ function subagentPrompt2(values, nativeSubagentId2) {
|
|
|
63454
63651
|
return void 0;
|
|
63455
63652
|
}
|
|
63456
63653
|
function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, parentValues = []) {
|
|
63457
|
-
const messages = conversationMessages(values.map((value) =>
|
|
63654
|
+
const messages = conversationMessages(values.map((value) => isRecord11(value) ? { ...value, session_id: parentSessionId } : value), parentSessionId);
|
|
63458
63655
|
const turns = [];
|
|
63459
63656
|
for (let index = 0; index < messages.length; ) {
|
|
63460
63657
|
const first = messages[index];
|
|
@@ -63485,7 +63682,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
|
|
|
63485
63682
|
const content = Array.isArray(message.message.content) ? message.message.content : [{ type: "text", text: message.message.content }];
|
|
63486
63683
|
for (let blockIndex = 0; blockIndex < content.length; blockIndex += 1) {
|
|
63487
63684
|
const block = content[blockIndex];
|
|
63488
|
-
if (!
|
|
63685
|
+
if (!isRecord11(block))
|
|
63489
63686
|
continue;
|
|
63490
63687
|
const itemId = hostItemIdSchema.parse(`claude-subagent-item-v2-${nativeSubagentId2}-${message.uuid}-${blockIndex}`);
|
|
63491
63688
|
if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
@@ -63522,7 +63719,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
|
|
|
63522
63719
|
retryable: false
|
|
63523
63720
|
}
|
|
63524
63721
|
} : { status: "succeeded" };
|
|
63525
|
-
if (block.name === "Bash" &&
|
|
63722
|
+
if (block.name === "Bash" && isRecord11(block.input) && typeof block.input.command === "string") {
|
|
63526
63723
|
items.push({
|
|
63527
63724
|
item: {
|
|
63528
63725
|
type: "commandExecution",
|
|
@@ -63814,7 +64011,7 @@ async function* transcriptLines(transcript) {
|
|
|
63814
64011
|
stream.destroy();
|
|
63815
64012
|
}
|
|
63816
64013
|
}
|
|
63817
|
-
function
|
|
64014
|
+
function isRecord12(value) {
|
|
63818
64015
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
63819
64016
|
}
|
|
63820
64017
|
async function readClaudeTranscript(input3) {
|
|
@@ -63831,7 +64028,7 @@ async function readClaudeTranscript(input3) {
|
|
|
63831
64028
|
} catch {
|
|
63832
64029
|
continue;
|
|
63833
64030
|
}
|
|
63834
|
-
if (!
|
|
64031
|
+
if (!isRecord12(entry) || entry.type !== "user" && entry.type !== "assistant" && entry.type !== "attachment" || typeof entry.uuid !== "string" || entry.type !== "attachment" && !isRecord12(entry.message)) {
|
|
63835
64032
|
continue;
|
|
63836
64033
|
}
|
|
63837
64034
|
messages.set(entry.uuid, { ...entry, session_id: input3.sessionId });
|
|
@@ -63840,7 +64037,7 @@ async function readClaudeTranscript(input3) {
|
|
|
63840
64037
|
}
|
|
63841
64038
|
|
|
63842
64039
|
// dist/claude-fork-references.js
|
|
63843
|
-
function
|
|
64040
|
+
function isRecord13(value) {
|
|
63844
64041
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
63845
64042
|
}
|
|
63846
64043
|
function parseEntry(line) {
|
|
@@ -63848,7 +64045,7 @@ function parseEntry(line) {
|
|
|
63848
64045
|
return null;
|
|
63849
64046
|
try {
|
|
63850
64047
|
const entry = JSON.parse(line);
|
|
63851
|
-
return
|
|
64048
|
+
return isRecord13(entry) ? entry : null;
|
|
63852
64049
|
} catch {
|
|
63853
64050
|
return null;
|
|
63854
64051
|
}
|
|
@@ -63857,7 +64054,7 @@ function remapSameAs(value, copies) {
|
|
|
63857
64054
|
if (Array.isArray(value)) {
|
|
63858
64055
|
return value.reduce((count4, item) => count4 + remapSameAs(item, copies), 0);
|
|
63859
64056
|
}
|
|
63860
|
-
if (!
|
|
64057
|
+
if (!isRecord13(value))
|
|
63861
64058
|
return 0;
|
|
63862
64059
|
let count3 = 0;
|
|
63863
64060
|
for (const [key, child] of Object.entries(value)) {
|
|
@@ -63883,7 +64080,7 @@ async function remapForkedSessionReferences(input3) {
|
|
|
63883
64080
|
const copies = /* @__PURE__ */ new Map();
|
|
63884
64081
|
for (const entry of entries) {
|
|
63885
64082
|
const source = entry?.forkedFrom;
|
|
63886
|
-
if (typeof entry?.uuid === "string" &&
|
|
64083
|
+
if (typeof entry?.uuid === "string" && isRecord13(source) && typeof source.messageUuid === "string") {
|
|
63887
64084
|
copies.set(source.messageUuid, entry.uuid);
|
|
63888
64085
|
}
|
|
63889
64086
|
}
|
|
@@ -64552,8 +64749,10 @@ var APPROVAL_TITLE_MAX_LENGTH = 120;
|
|
|
64552
64749
|
var APPROVAL_DESCRIPTION_MAX_LENGTH = 500;
|
|
64553
64750
|
var DEFAULT_ABORT_TIMEOUT_MS = 2e3;
|
|
64554
64751
|
var DEFAULT_STEER_QUEUED_TIMEOUT_MS = 5e3;
|
|
64752
|
+
var DEFAULT_AWAITING_TASK_NOTIFICATION_TIMEOUT_MS = 3e4;
|
|
64555
64753
|
var WORKFLOW_AGENT_LABEL_LIMIT = 1e3;
|
|
64556
64754
|
var INTERRUPT_TIMEOUT_MESSAGE = "Claude SDK interrupt timed out";
|
|
64755
|
+
var SESSION_CRON_TOOLS = /* @__PURE__ */ new Set(["CronCreate", "CronDelete", "ScheduleWakeup"]);
|
|
64557
64756
|
var PushableInput = class {
|
|
64558
64757
|
#closed = false;
|
|
64559
64758
|
#queue = [];
|
|
@@ -64587,6 +64786,7 @@ var PushableInput = class {
|
|
|
64587
64786
|
};
|
|
64588
64787
|
}
|
|
64589
64788
|
};
|
|
64789
|
+
var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 6e4;
|
|
64590
64790
|
function delay(milliseconds) {
|
|
64591
64791
|
return new Promise((resolve5) => setTimeout(resolve5, milliseconds));
|
|
64592
64792
|
}
|
|
@@ -64606,17 +64806,17 @@ function rejectAfter(milliseconds, message) {
|
|
|
64606
64806
|
function processExited(child) {
|
|
64607
64807
|
return child.exitCode !== null || child.signalCode !== null;
|
|
64608
64808
|
}
|
|
64609
|
-
function
|
|
64809
|
+
function isRecord14(value) {
|
|
64610
64810
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
64611
64811
|
}
|
|
64612
64812
|
function permissionModeFromMessage(value) {
|
|
64613
|
-
if (!
|
|
64813
|
+
if (!isRecord14(value) || value.type !== "system" || value.subtype !== "init" && value.subtype !== "status" || !("permissionMode" in value) || value.permissionMode === void 0) {
|
|
64614
64814
|
return void 0;
|
|
64615
64815
|
}
|
|
64616
64816
|
return isClaudePermissionMode(value.permissionMode) ? value.permissionMode : void 0;
|
|
64617
64817
|
}
|
|
64618
64818
|
function parseContextUsage(value) {
|
|
64619
|
-
if (!
|
|
64819
|
+
if (!isRecord14(value))
|
|
64620
64820
|
throw new Error("Claude SDK context Usage is invalid");
|
|
64621
64821
|
const usedTokens = value.totalTokens;
|
|
64622
64822
|
const maxTokens = value.maxTokens;
|
|
@@ -64633,7 +64833,7 @@ function parseQuestions(input3) {
|
|
|
64633
64833
|
const questions = [];
|
|
64634
64834
|
const questionTexts = /* @__PURE__ */ new Set();
|
|
64635
64835
|
for (const value of input3.questions) {
|
|
64636
|
-
if (!
|
|
64836
|
+
if (!isRecord14(value))
|
|
64637
64837
|
return null;
|
|
64638
64838
|
const question = value.question;
|
|
64639
64839
|
const header = value.header;
|
|
@@ -64644,7 +64844,7 @@ function parseQuestions(input3) {
|
|
|
64644
64844
|
const labels = /* @__PURE__ */ new Set();
|
|
64645
64845
|
const options = [];
|
|
64646
64846
|
for (const option2 of value.options) {
|
|
64647
|
-
if (!
|
|
64847
|
+
if (!isRecord14(option2) || typeof option2.label !== "string" || option2.label.length === 0 || labels.has(option2.label) || typeof option2.description !== "string") {
|
|
64648
64848
|
return null;
|
|
64649
64849
|
}
|
|
64650
64850
|
labels.add(option2.label);
|
|
@@ -64686,7 +64886,7 @@ function permissionUpdateDestination(value) {
|
|
|
64686
64886
|
return void 0;
|
|
64687
64887
|
}
|
|
64688
64888
|
function isPermissionUpdate(value) {
|
|
64689
|
-
if (!
|
|
64889
|
+
if (!isRecord14(value) || !permissionUpdateDestination(value.destination))
|
|
64690
64890
|
return false;
|
|
64691
64891
|
if (value.type === "setMode") {
|
|
64692
64892
|
return typeof value.mode === "string" && PERMISSION_MODES.has(value.mode);
|
|
@@ -64695,7 +64895,7 @@ function isPermissionUpdate(value) {
|
|
|
64695
64895
|
return Array.isArray(value.directories) && value.directories.every((directory) => typeof directory === "string");
|
|
64696
64896
|
}
|
|
64697
64897
|
if (value.type === "addRules" || value.type === "replaceRules" || value.type === "removeRules") {
|
|
64698
|
-
return typeof value.behavior === "string" && PERMISSION_BEHAVIORS.has(value.behavior) && Array.isArray(value.rules) && value.rules.every((rule) =>
|
|
64898
|
+
return typeof value.behavior === "string" && PERMISSION_BEHAVIORS.has(value.behavior) && Array.isArray(value.rules) && value.rules.every((rule) => isRecord14(rule) && typeof rule.toolName === "string" && (rule.ruleContent === void 0 || typeof rule.ruleContent === "string"));
|
|
64699
64899
|
}
|
|
64700
64900
|
return false;
|
|
64701
64901
|
}
|
|
@@ -64809,6 +65009,7 @@ var ClaudeSdkTransport = class {
|
|
|
64809
65009
|
#thinkingOptionId;
|
|
64810
65010
|
#active = null;
|
|
64811
65011
|
#steerQueuedTimeoutMs;
|
|
65012
|
+
#awaitingTaskNotificationTimeoutMs;
|
|
64812
65013
|
#nativeSteer = false;
|
|
64813
65014
|
/** Root tool calls of the requested Turn that have started and not yet returned a result. */
|
|
64814
65015
|
#rootToolCalls = /* @__PURE__ */ new Set();
|
|
@@ -64837,11 +65038,18 @@ var ClaudeSdkTransport = class {
|
|
|
64837
65038
|
#skillNames = /* @__PURE__ */ new Set();
|
|
64838
65039
|
#started = false;
|
|
64839
65040
|
#backgroundTasks = /* @__PURE__ */ new Set();
|
|
65041
|
+
/** Tasks that left the live roster before their terminal `task_notification`, keyed to expiry timestamp. */
|
|
65042
|
+
#awaitingTaskNotifications = /* @__PURE__ */ new Map();
|
|
65043
|
+
/** Authoritative count of process-local session crons/wakeups from the latest Stop hook. */
|
|
65044
|
+
#sessionCronCount = 0;
|
|
65045
|
+
/** True after a session cron tool call until a Stop hook reports `session_crons`. */
|
|
65046
|
+
#sessionCronsUnknown = false;
|
|
64840
65047
|
constructor(options) {
|
|
64841
65048
|
this.sessionId = options.sessionId;
|
|
64842
65049
|
this.#cwd = options.cwd;
|
|
64843
65050
|
this.#abortTimeoutMs = options.abortTimeoutMs ?? DEFAULT_ABORT_TIMEOUT_MS;
|
|
64844
65051
|
this.#steerQueuedTimeoutMs = options.steerQueuedTimeoutMs ?? DEFAULT_STEER_QUEUED_TIMEOUT_MS;
|
|
65052
|
+
this.#awaitingTaskNotificationTimeoutMs = options.awaitingTaskNotificationTimeoutMs ?? DEFAULT_AWAITING_TASK_NOTIFICATION_TIMEOUT_MS;
|
|
64845
65053
|
this.#closeTimeoutMs = options.closeTimeoutMs;
|
|
64846
65054
|
this.#command = options.command;
|
|
64847
65055
|
this.#environment = options.environment ?? process.env;
|
|
@@ -64904,6 +65112,7 @@ var ClaudeSdkTransport = class {
|
|
|
64904
65112
|
permissionMode: this.#permissionMode,
|
|
64905
65113
|
...this.#allowDangerouslySkipPermissions ? { allowDangerouslySkipPermissions: true } : {},
|
|
64906
65114
|
canUseTool: (toolName, input3, options) => this.#canUseTool(toolName, input3, options),
|
|
65115
|
+
hooks: { Stop: [{ hooks: [this.#observeStopHook] }] },
|
|
64907
65116
|
persistSession: true,
|
|
64908
65117
|
includePartialMessages: true,
|
|
64909
65118
|
forwardSubagentText: true,
|
|
@@ -64964,15 +65173,15 @@ var ClaudeSdkTransport = class {
|
|
|
64964
65173
|
return this.#idleLive && this.#idleHandler !== null;
|
|
64965
65174
|
}
|
|
64966
65175
|
#observeRootToolCalls(message) {
|
|
64967
|
-
if (!
|
|
65176
|
+
if (!isRecord14(message) || message.parent_tool_use_id != null)
|
|
64968
65177
|
return;
|
|
64969
65178
|
if (message.type !== "assistant" && message.type !== "user")
|
|
64970
65179
|
return;
|
|
64971
65180
|
const body = message.message;
|
|
64972
|
-
if (!
|
|
65181
|
+
if (!isRecord14(body) || !Array.isArray(body.content))
|
|
64973
65182
|
return;
|
|
64974
65183
|
for (const block of body.content) {
|
|
64975
|
-
if (!
|
|
65184
|
+
if (!isRecord14(block))
|
|
64976
65185
|
continue;
|
|
64977
65186
|
if (message.type === "assistant" && block.type === "tool_use" && typeof block.id === "string") {
|
|
64978
65187
|
this.#rootToolCalls.add(block.id);
|
|
@@ -64982,12 +65191,12 @@ var ClaudeSdkTransport = class {
|
|
|
64982
65191
|
}
|
|
64983
65192
|
}
|
|
64984
65193
|
#observeNativeCapabilities(message) {
|
|
64985
|
-
if (!
|
|
65194
|
+
if (!isRecord14(message) || message.type !== "system" || message.subtype !== "init")
|
|
64986
65195
|
return;
|
|
64987
65196
|
this.#nativeSteer = Array.isArray(message.capabilities) && message.capabilities.includes("msg_lifecycle_v1");
|
|
64988
65197
|
}
|
|
64989
65198
|
#observeSlashCommands(message) {
|
|
64990
|
-
if (!
|
|
65199
|
+
if (!isRecord14(message) || message.type !== "system")
|
|
64991
65200
|
return;
|
|
64992
65201
|
if (message.subtype === "init" && Array.isArray(message.skills)) {
|
|
64993
65202
|
this.#skillNames = new Set(message.skills.filter((name) => typeof name === "string"));
|
|
@@ -65452,9 +65661,19 @@ var ClaudeSdkTransport = class {
|
|
|
65452
65661
|
if (failures.length > 0)
|
|
65453
65662
|
throw new AggregateError(failures, "Claude SDK shutdown could not be confirmed");
|
|
65454
65663
|
this.#backgroundTasks.clear();
|
|
65664
|
+
this.#awaitingTaskNotifications.clear();
|
|
65665
|
+
this.#sessionCronCount = 0;
|
|
65666
|
+
this.#sessionCronsUnknown = false;
|
|
65667
|
+
}
|
|
65668
|
+
#pruneExpiredAwaitingTaskNotifications(now = Date.now()) {
|
|
65669
|
+
for (const [id3, expiresAtMs] of this.#awaitingTaskNotifications) {
|
|
65670
|
+
if (expiresAtMs <= now)
|
|
65671
|
+
this.#awaitingTaskNotifications.delete(id3);
|
|
65672
|
+
}
|
|
65455
65673
|
}
|
|
65456
65674
|
hasBackgroundTasks() {
|
|
65457
|
-
|
|
65675
|
+
this.#pruneExpiredAwaitingTaskNotifications();
|
|
65676
|
+
return this.#backgroundTasks.size > 0 || this.#awaitingTaskNotifications.size > 0 || this.#sessionCronCount > 0 || this.#sessionCronsUnknown;
|
|
65458
65677
|
}
|
|
65459
65678
|
/** The native `task_notification` that follows reports the stopped task. */
|
|
65460
65679
|
async stopBackgroundTask(taskId) {
|
|
@@ -65517,7 +65736,7 @@ var ClaudeSdkTransport = class {
|
|
|
65517
65736
|
* without `started` means no native turn takes it over.
|
|
65518
65737
|
*/
|
|
65519
65738
|
#observeSteer(message) {
|
|
65520
|
-
if (this.#pendingSteers.size === 0 && this.#steerTakeovers.size === 0 || !
|
|
65739
|
+
if (this.#pendingSteers.size === 0 && this.#steerTakeovers.size === 0 || !isRecord14(message) || message.type !== "command_lifecycle") {
|
|
65521
65740
|
return;
|
|
65522
65741
|
}
|
|
65523
65742
|
if (typeof message.command_uuid !== "string" || message.command_uuid.length === 0)
|
|
@@ -65530,15 +65749,60 @@ var ClaudeSdkTransport = class {
|
|
|
65530
65749
|
this.#takeOverSteer(message.command_uuid, message.state === "started");
|
|
65531
65750
|
}
|
|
65532
65751
|
}
|
|
65752
|
+
/** Observation-only Stop hook: reads authoritative background task and session cron state without altering turn control. */
|
|
65753
|
+
#observeStopHook = async (input3) => {
|
|
65754
|
+
if (this.#closing || input3.hook_event_name !== "Stop")
|
|
65755
|
+
return {};
|
|
65756
|
+
if (Array.isArray(input3.session_crons)) {
|
|
65757
|
+
this.#sessionCronCount = input3.session_crons.length;
|
|
65758
|
+
this.#sessionCronsUnknown = false;
|
|
65759
|
+
}
|
|
65760
|
+
if (Array.isArray(input3.background_tasks) && input3.background_tasks.length === 0) {
|
|
65761
|
+
this.#awaitingTaskNotifications.clear();
|
|
65762
|
+
}
|
|
65763
|
+
return {};
|
|
65764
|
+
};
|
|
65765
|
+
#observeSessionCrons(message) {
|
|
65766
|
+
if (!isRecord14(message))
|
|
65767
|
+
return;
|
|
65768
|
+
if (message.type === "assistant" && isRecord14(message.message) && Array.isArray(message.message.content)) {
|
|
65769
|
+
for (const block of message.message.content) {
|
|
65770
|
+
if (isRecord14(block) && block.type === "tool_use" && typeof block.name === "string" && SESSION_CRON_TOOLS.has(block.name)) {
|
|
65771
|
+
this.#sessionCronsUnknown = true;
|
|
65772
|
+
return;
|
|
65773
|
+
}
|
|
65774
|
+
}
|
|
65775
|
+
return;
|
|
65776
|
+
}
|
|
65777
|
+
if (message.type === "stream_event" && isRecord14(message.event) && message.event.type === "content_block_start" && isRecord14(message.event.content_block) && message.event.content_block.type === "tool_use" && typeof message.event.content_block.name === "string" && SESSION_CRON_TOOLS.has(message.event.content_block.name)) {
|
|
65778
|
+
this.#sessionCronsUnknown = true;
|
|
65779
|
+
}
|
|
65780
|
+
}
|
|
65533
65781
|
#observeBackgroundTasks(message) {
|
|
65534
|
-
if (!
|
|
65782
|
+
if (!isRecord14(message) || message.type !== "system")
|
|
65535
65783
|
return;
|
|
65536
65784
|
if (message.subtype === "background_tasks_changed" && Array.isArray(message.tasks)) {
|
|
65537
|
-
|
|
65538
|
-
|
|
65785
|
+
const next = new Set(message.tasks.flatMap((task) => isRecord14(task) && typeof task.task_id === "string" ? [task.task_id] : []));
|
|
65786
|
+
const now = Date.now();
|
|
65787
|
+
this.#pruneExpiredAwaitingTaskNotifications(now);
|
|
65788
|
+
const expiresAtMs = now + this.#awaitingTaskNotificationTimeoutMs;
|
|
65789
|
+
for (const id3 of this.#backgroundTasks) {
|
|
65790
|
+
if (!next.has(id3))
|
|
65791
|
+
this.#awaitingTaskNotifications.set(id3, expiresAtMs);
|
|
65792
|
+
}
|
|
65793
|
+
for (const id3 of next) {
|
|
65794
|
+
this.#awaitingTaskNotifications.delete(id3);
|
|
65795
|
+
}
|
|
65796
|
+
this.#backgroundTasks = next;
|
|
65797
|
+
} else if (message.subtype === "task_started" && typeof message.task_id === "string" && message.is_backgrounded !== false) {
|
|
65539
65798
|
this.#backgroundTasks.add(message.task_id);
|
|
65799
|
+
this.#awaitingTaskNotifications.delete(message.task_id);
|
|
65800
|
+
} else if (message.subtype === "task_updated" && typeof message.task_id === "string" && isRecord14(message.patch) && message.patch.is_backgrounded === true) {
|
|
65801
|
+
this.#backgroundTasks.add(message.task_id);
|
|
65802
|
+
this.#awaitingTaskNotifications.delete(message.task_id);
|
|
65540
65803
|
} else if (message.subtype === "task_notification" && typeof message.task_id === "string" && ["completed", "failed", "stopped"].includes(String(message.status))) {
|
|
65541
65804
|
this.#backgroundTasks.delete(message.task_id);
|
|
65805
|
+
this.#awaitingTaskNotifications.delete(message.task_id);
|
|
65542
65806
|
}
|
|
65543
65807
|
}
|
|
65544
65808
|
/** Starts the Segment's autonomous Turn and releases the events it held, in native order. */
|
|
@@ -65550,7 +65814,7 @@ var ClaudeSdkTransport = class {
|
|
|
65550
65814
|
}
|
|
65551
65815
|
/** Remembers Workflow agent labels so their approvals can name the agent asking. */
|
|
65552
65816
|
#observeWorkflowAgents(message) {
|
|
65553
|
-
if (!
|
|
65817
|
+
if (!isRecord14(message) || message.type !== "system" || message.subtype !== "task_progress") {
|
|
65554
65818
|
return;
|
|
65555
65819
|
}
|
|
65556
65820
|
for (const agent of parseClaudeWorkflowAgents(message.workflow_progress) ?? []) {
|
|
@@ -65574,6 +65838,7 @@ var ClaudeSdkTransport = class {
|
|
|
65574
65838
|
try {
|
|
65575
65839
|
for await (const message of activeQuery) {
|
|
65576
65840
|
this.#observeBackgroundTasks(message);
|
|
65841
|
+
this.#observeSessionCrons(message);
|
|
65577
65842
|
this.#observeWorkflowAgents(message);
|
|
65578
65843
|
this.#observeSlashCommands(message);
|
|
65579
65844
|
this.#observeNativeCapabilities(message);
|
|
@@ -65621,7 +65886,7 @@ var ClaudeSdkTransport = class {
|
|
|
65621
65886
|
userMessageId: null,
|
|
65622
65887
|
live: false
|
|
65623
65888
|
});
|
|
65624
|
-
if (autonomous.userMessageId === null &&
|
|
65889
|
+
if (autonomous.userMessageId === null && isRecord14(message) && message.type === "user" && (message.parent_tool_use_id === null || message.parent_tool_use_id === void 0) && typeof message.uuid === "string" && message.uuid.length > 0) {
|
|
65625
65890
|
autonomous.userMessageId = message.uuid;
|
|
65626
65891
|
}
|
|
65627
65892
|
const interpreted = autonomous.accumulator.consume(message);
|
|
@@ -65685,6 +65950,7 @@ var ClaudeSdkModelInspector = class {
|
|
|
65685
65950
|
#children = [];
|
|
65686
65951
|
#stderrTail = "";
|
|
65687
65952
|
#closeTimeoutMs;
|
|
65953
|
+
#inspectTimeoutMs;
|
|
65688
65954
|
#command;
|
|
65689
65955
|
#cwd;
|
|
65690
65956
|
#environment;
|
|
@@ -65697,6 +65963,7 @@ var ClaudeSdkModelInspector = class {
|
|
|
65697
65963
|
}
|
|
65698
65964
|
constructor(options) {
|
|
65699
65965
|
this.#closeTimeoutMs = options.closeTimeoutMs;
|
|
65966
|
+
this.#inspectTimeoutMs = options.inspectTimeoutMs ?? DEFAULT_MODEL_INSPECT_TIMEOUT_MS;
|
|
65700
65967
|
this.#command = options.command;
|
|
65701
65968
|
this.#cwd = options.cwd;
|
|
65702
65969
|
this.#environment = options.environment ?? process.env;
|
|
@@ -65753,19 +66020,26 @@ var ClaudeSdkModelInspector = class {
|
|
|
65753
66020
|
}
|
|
65754
66021
|
}
|
|
65755
66022
|
async inspect() {
|
|
65756
|
-
const
|
|
66023
|
+
const timeout = rejectAfter(this.#inspectTimeoutMs, "Claude SDK Model inspection timed out");
|
|
65757
66024
|
try {
|
|
65758
|
-
const
|
|
65759
|
-
|
|
65760
|
-
|
|
65761
|
-
|
|
65762
|
-
|
|
65763
|
-
|
|
65764
|
-
|
|
65765
|
-
|
|
65766
|
-
|
|
65767
|
-
|
|
66025
|
+
const activeQuery = this.#createQuery();
|
|
66026
|
+
return await Promise.race([
|
|
66027
|
+
(async () => {
|
|
66028
|
+
const initialized = await activeQuery.initializationResult();
|
|
66029
|
+
const candidate = activeQuery;
|
|
66030
|
+
const canSelectModel = Array.isArray(initialized.models) && typeof candidate.setModel === "function";
|
|
66031
|
+
const canSelectPermissionMode = typeof candidate.setPermissionMode === "function";
|
|
66032
|
+
const modelPicker = await readClaudeUserModelPicker(this.#environment);
|
|
66033
|
+
return {
|
|
66034
|
+
models: mergeClaudeModelPickerOptions(initialized.models, modelPicker),
|
|
66035
|
+
canSelectModel,
|
|
66036
|
+
canSelectPermissionMode
|
|
66037
|
+
};
|
|
66038
|
+
})(),
|
|
66039
|
+
timeout.promise
|
|
66040
|
+
]);
|
|
65768
66041
|
} finally {
|
|
66042
|
+
timeout.cancel();
|
|
65769
66043
|
await this.close();
|
|
65770
66044
|
}
|
|
65771
66045
|
}
|
|
@@ -65776,19 +66050,34 @@ var ClaudeSdkModelInspector = class {
|
|
|
65776
66050
|
}
|
|
65777
66051
|
async #close() {
|
|
65778
66052
|
this.#input.end();
|
|
65779
|
-
|
|
66053
|
+
try {
|
|
66054
|
+
this.#query?.close();
|
|
66055
|
+
} catch {
|
|
66056
|
+
}
|
|
65780
66057
|
for (const child of this.#children) {
|
|
65781
|
-
if (!processExited(child))
|
|
65782
|
-
|
|
66058
|
+
if (!processExited(child)) {
|
|
66059
|
+
try {
|
|
66060
|
+
child.kill("SIGTERM");
|
|
66061
|
+
} catch {
|
|
66062
|
+
}
|
|
66063
|
+
}
|
|
65783
66064
|
}
|
|
65784
66065
|
await Promise.race([
|
|
65785
66066
|
Promise.all(this.#children.map((child) => this.#waitForExit(child))),
|
|
65786
66067
|
delay(this.#closeTimeoutMs)
|
|
65787
66068
|
]);
|
|
65788
66069
|
for (const child of this.#children) {
|
|
65789
|
-
if (!processExited(child))
|
|
65790
|
-
|
|
66070
|
+
if (!processExited(child)) {
|
|
66071
|
+
try {
|
|
66072
|
+
child.kill("SIGKILL");
|
|
66073
|
+
} catch {
|
|
66074
|
+
}
|
|
66075
|
+
}
|
|
65791
66076
|
}
|
|
66077
|
+
await Promise.race([
|
|
66078
|
+
Promise.all(this.#children.map((child) => this.#waitForExit(child))),
|
|
66079
|
+
delay(Math.min(this.#closeTimeoutMs, 1e3))
|
|
66080
|
+
]);
|
|
65792
66081
|
this.#query = null;
|
|
65793
66082
|
}
|
|
65794
66083
|
#spawn(options) {
|
|
@@ -65828,9 +66117,7 @@ function createClaudePlanReview(request, interactionId, turnId) {
|
|
|
65828
66117
|
{
|
|
65829
66118
|
id: DECISION_ID,
|
|
65830
66119
|
type: "choice",
|
|
65831
|
-
prompt: request.plan ?
|
|
65832
|
-
|
|
65833
|
-
${request.plan}` : "Claude Code did not provide plan text. Stay in plan mode and ask Claude to present the plan before approving it.",
|
|
66120
|
+
prompt: request.plan ? `Review the full plan in the conversation above. ${warning}` : "Claude Code did not provide plan text. Stay in plan mode and ask Claude to present the plan before approving it.",
|
|
65834
66121
|
options: [
|
|
65835
66122
|
{
|
|
65836
66123
|
value: "stay",
|
|
@@ -66314,11 +66601,11 @@ var ClaudeBackgroundCommandItems = class {
|
|
|
66314
66601
|
};
|
|
66315
66602
|
|
|
66316
66603
|
// dist/tool-lifecycle.js
|
|
66317
|
-
function
|
|
66604
|
+
function isRecord15(value) {
|
|
66318
66605
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
66319
66606
|
}
|
|
66320
66607
|
function stringField2(value, key) {
|
|
66321
|
-
return
|
|
66608
|
+
return isRecord15(value) && typeof value[key] === "string" ? value[key] : void 0;
|
|
66322
66609
|
}
|
|
66323
66610
|
function toolFailure(toolName) {
|
|
66324
66611
|
return {
|
|
@@ -66713,7 +67000,7 @@ var CONTEXT_USAGE_TTL_MS = 1e4;
|
|
|
66713
67000
|
var CONTEXT_USAGE_FAILURE_COOLDOWN_MS = 5e3;
|
|
66714
67001
|
var REQUEST_USAGE_RETRY_DELAYS_MS = [0, 100, 250, 500, 1e3];
|
|
66715
67002
|
var DEFAULT_CONTINUATION_QUIESCENCE_MS = 2e3;
|
|
66716
|
-
function
|
|
67003
|
+
function isRecord16(value) {
|
|
66717
67004
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
66718
67005
|
}
|
|
66719
67006
|
var SYNTHETIC_AUTONOMOUS_TURN_KEY_PATTERN = /^autonomous-\d+$/u;
|
|
@@ -66723,7 +67010,7 @@ function safeNonNegativeInteger2(value) {
|
|
|
66723
67010
|
function transcriptRequestUsage(messages, messageId) {
|
|
66724
67011
|
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
66725
67012
|
const entry = messages[index];
|
|
66726
|
-
if (!
|
|
67013
|
+
if (!isRecord16(entry) || entry.type !== "assistant" || entry.parent_tool_use_id !== null && entry.parent_tool_use_id !== void 0 || !isRecord16(entry.message) || entry.message.id !== messageId || !isRecord16(entry.message.usage)) {
|
|
66727
67014
|
continue;
|
|
66728
67015
|
}
|
|
66729
67016
|
const inputTokens = entry.message.usage.input_tokens;
|
|
@@ -66731,6 +67018,7 @@ function transcriptRequestUsage(messages, messageId) {
|
|
|
66731
67018
|
const cacheCreationInputTokens = entry.message.usage.cache_creation_input_tokens;
|
|
66732
67019
|
const cacheReadInputTokens = entry.message.usage.cache_read_input_tokens;
|
|
66733
67020
|
if (safeNonNegativeInteger2(inputTokens) && safeNonNegativeInteger2(outputTokens) && safeNonNegativeInteger2(cacheCreationInputTokens) && safeNonNegativeInteger2(cacheReadInputTokens)) {
|
|
67021
|
+
const promptCacheTtlSeconds = claudePromptCacheTtlSeconds(entry.message.usage);
|
|
66734
67022
|
return {
|
|
66735
67023
|
requestId: typeof entry.request_id === "string" && entry.request_id.length > 0 ? entry.request_id : messageId,
|
|
66736
67024
|
...typeof entry.message.model === "string" && entry.message.model.length > 0 ? { model: entry.message.model } : {},
|
|
@@ -66738,7 +67026,8 @@ function transcriptRequestUsage(messages, messageId) {
|
|
|
66738
67026
|
inputTokens,
|
|
66739
67027
|
outputTokens,
|
|
66740
67028
|
cacheCreationInputTokens,
|
|
66741
|
-
cacheReadInputTokens
|
|
67029
|
+
cacheReadInputTokens,
|
|
67030
|
+
...promptCacheTtlSeconds !== void 0 ? { promptCacheTtlSeconds } : {}
|
|
66742
67031
|
};
|
|
66743
67032
|
}
|
|
66744
67033
|
}
|
|
@@ -66982,6 +67271,7 @@ var ClaudeHarnessSession = class {
|
|
|
66982
67271
|
#usageGeneration = 0;
|
|
66983
67272
|
#latestUsage = null;
|
|
66984
67273
|
#lastAssistantResponseAtUnix;
|
|
67274
|
+
#promptCacheTtlSeconds;
|
|
66985
67275
|
#accountCreditsSupported;
|
|
66986
67276
|
#minimumContextUsedTokens = null;
|
|
66987
67277
|
#calibratedInputTokens = 0;
|
|
@@ -67002,8 +67292,9 @@ var ClaudeHarnessSession = class {
|
|
|
67002
67292
|
constructor(cwd, dependencies, closeTimeoutMs, onClosed, onPlanLimitObserved, options) {
|
|
67003
67293
|
this.#cwd = cwd;
|
|
67004
67294
|
this.#lastAssistantResponseAtUnix = options.usageHistory.lastResponseAtUnix;
|
|
67295
|
+
this.#promptCacheTtlSeconds = options.usageHistory.promptCacheTtlSeconds;
|
|
67005
67296
|
this.#accountCreditsSupported = options.accountCreditsSupported;
|
|
67006
|
-
const composerIndicators = claudePromptCacheIndicators(this.#accountCreditsSupported, this.#lastAssistantResponseAtUnix);
|
|
67297
|
+
const composerIndicators = claudePromptCacheIndicators(this.#accountCreditsSupported, this.#lastAssistantResponseAtUnix, this.#promptCacheTtlSeconds);
|
|
67007
67298
|
this.initialUsage = composerIndicators.length ? { composerIndicators } : null;
|
|
67008
67299
|
this.#latestUsage = this.initialUsage;
|
|
67009
67300
|
this.#pendingSessions = options.pendingSessions;
|
|
@@ -67108,7 +67399,7 @@ var ClaudeHarnessSession = class {
|
|
|
67108
67399
|
let ids;
|
|
67109
67400
|
try {
|
|
67110
67401
|
ids = new Set(messages.flatMap((message) => {
|
|
67111
|
-
if (!
|
|
67402
|
+
if (!isRecord16(message) || typeof message.uuid !== "string")
|
|
67112
67403
|
return [];
|
|
67113
67404
|
const queued = readClaudeQueuedCommand(message, this.#sessionId);
|
|
67114
67405
|
return queued ? [message.uuid, queued.sourceUuid] : [message.uuid];
|
|
@@ -67297,6 +67588,7 @@ var ClaudeHarnessSession = class {
|
|
|
67297
67588
|
cancellationRequested: false,
|
|
67298
67589
|
steersAwaitingNative: /* @__PURE__ */ new Set(),
|
|
67299
67590
|
usageRequestIds: /* @__PURE__ */ new Set(),
|
|
67591
|
+
promptCacheTtlObserved: false,
|
|
67300
67592
|
estimatedInputTokens: 0,
|
|
67301
67593
|
estimatedOutputTokens: 0,
|
|
67302
67594
|
estimatedCostUsd: 0,
|
|
@@ -67477,6 +67769,7 @@ var ClaudeHarnessSession = class {
|
|
|
67477
67769
|
cancellationRequested: false,
|
|
67478
67770
|
steersAwaitingNative: /* @__PURE__ */ new Set(),
|
|
67479
67771
|
usageRequestIds: /* @__PURE__ */ new Set(),
|
|
67772
|
+
promptCacheTtlObserved: false,
|
|
67480
67773
|
estimatedInputTokens: 0,
|
|
67481
67774
|
estimatedOutputTokens: 0,
|
|
67482
67775
|
estimatedCostUsd: 0,
|
|
@@ -68182,8 +68475,13 @@ var ClaudeHarnessSession = class {
|
|
|
68182
68475
|
}
|
|
68183
68476
|
#handleTurnEvent(active2, event) {
|
|
68184
68477
|
if (event.type === "usage.request") {
|
|
68185
|
-
if (this.#phase !== "closed" && this.#phase !== "faulted")
|
|
68478
|
+
if (this.#phase !== "closed" && this.#phase !== "faulted") {
|
|
68186
68479
|
this.#meterUsage(event.record);
|
|
68480
|
+
if (event.promptCacheTtlSeconds !== void 0) {
|
|
68481
|
+
active2.promptCacheTtlObserved = true;
|
|
68482
|
+
this.#observePromptCacheTtl(event.promptCacheTtlSeconds);
|
|
68483
|
+
}
|
|
68484
|
+
}
|
|
68187
68485
|
return;
|
|
68188
68486
|
}
|
|
68189
68487
|
if (this.#active !== active2 || this.#phase === "closed" || this.#phase === "faulted")
|
|
@@ -68231,6 +68529,10 @@ var ClaudeHarnessSession = class {
|
|
|
68231
68529
|
return;
|
|
68232
68530
|
case "message.completed": {
|
|
68233
68531
|
if (!event.localCommand) {
|
|
68532
|
+
if (event.lastRequestUsage?.promptCacheTtlSeconds !== void 0) {
|
|
68533
|
+
active2.promptCacheTtlObserved = true;
|
|
68534
|
+
this.#promptCacheTtlSeconds = event.lastRequestUsage.promptCacheTtlSeconds;
|
|
68535
|
+
}
|
|
68234
68536
|
this.#lastAssistantResponseAtUnix = Math.floor(Date.now() / 1e3);
|
|
68235
68537
|
this.publishAccountCreditsSupport(this.#accountCreditsSupported);
|
|
68236
68538
|
}
|
|
@@ -68427,6 +68729,19 @@ var ClaudeHarnessSession = class {
|
|
|
68427
68729
|
};
|
|
68428
68730
|
pending = { type: "approval", interaction, request };
|
|
68429
68731
|
} else if (request.type === "planApproval") {
|
|
68732
|
+
if (request.plan) {
|
|
68733
|
+
const item = {
|
|
68734
|
+
type: "agentMessage",
|
|
68735
|
+
itemId: hostItemIdSchema.parse(this.#randomUUID()),
|
|
68736
|
+
text: request.plan
|
|
68737
|
+
};
|
|
68738
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item });
|
|
68739
|
+
this.#event({
|
|
68740
|
+
type: "item.completed",
|
|
68741
|
+
turnId: active2.command.turnId,
|
|
68742
|
+
snapshot: { item, outcome: { status: "succeeded" } }
|
|
68743
|
+
});
|
|
68744
|
+
}
|
|
68430
68745
|
pending = {
|
|
68431
68746
|
type: "planApproval",
|
|
68432
68747
|
interaction: createClaudePlanReview(request, interactionId, active2.command.turnId),
|
|
@@ -68647,6 +68962,7 @@ var ClaudeHarnessSession = class {
|
|
|
68647
68962
|
}),
|
|
68648
68963
|
cancellationRequested: false,
|
|
68649
68964
|
usageRequestIds: /* @__PURE__ */ new Set(),
|
|
68965
|
+
promptCacheTtlObserved: false,
|
|
68650
68966
|
estimatedInputTokens: 0,
|
|
68651
68967
|
estimatedOutputTokens: 0,
|
|
68652
68968
|
estimatedCostUsd: 0,
|
|
@@ -68668,7 +68984,14 @@ var ClaudeHarnessSession = class {
|
|
|
68668
68984
|
/** Live native events outside a requested Root Segment; settlements stay Thread-level. */
|
|
68669
68985
|
#deliverLiveEvent(target2, event) {
|
|
68670
68986
|
if (event.type === "usage.request") {
|
|
68671
|
-
this.#
|
|
68987
|
+
if (this.#phase !== "closed" && this.#phase !== "faulted") {
|
|
68988
|
+
this.#meterUsage(event.record);
|
|
68989
|
+
if (event.promptCacheTtlSeconds !== void 0) {
|
|
68990
|
+
if (target2 && this.#active === target2)
|
|
68991
|
+
target2.promptCacheTtlObserved = true;
|
|
68992
|
+
this.#observePromptCacheTtl(event.promptCacheTtlSeconds);
|
|
68993
|
+
}
|
|
68994
|
+
}
|
|
68672
68995
|
return;
|
|
68673
68996
|
}
|
|
68674
68997
|
if (target2 && this.#active === target2) {
|
|
@@ -68719,6 +69042,7 @@ var ClaudeHarnessSession = class {
|
|
|
68719
69042
|
if (this.#active !== active2 || this.#hardCancelTask)
|
|
68720
69043
|
return;
|
|
68721
69044
|
active2.rootSegmentActive = false;
|
|
69045
|
+
active2.promptCacheTtlObserved = false;
|
|
68722
69046
|
if (active2.cancellation) {
|
|
68723
69047
|
if (result.status === "failed") {
|
|
68724
69048
|
active2.cancellation.failure ??= transportFailure(result.kind);
|
|
@@ -68863,9 +69187,16 @@ var ClaudeHarnessSession = class {
|
|
|
68863
69187
|
if (promptTokens > 0)
|
|
68864
69188
|
this.#minimumContextUsedTokens = promptTokens;
|
|
68865
69189
|
const cacheHitRatePercent = claudeCacheHitRatePercent(usage);
|
|
69190
|
+
if (usage.promptCacheTtlSeconds !== void 0) {
|
|
69191
|
+
active2.promptCacheTtlObserved = true;
|
|
69192
|
+
this.#promptCacheTtlSeconds = usage.promptCacheTtlSeconds;
|
|
69193
|
+
}
|
|
69194
|
+
const composerIndicators = claudePromptCacheIndicators(this.#accountCreditsSupported, this.#lastAssistantResponseAtUnix, this.#promptCacheTtlSeconds);
|
|
69195
|
+
const indicatorChanged = composerIndicators[0]?.expiresAtUnix !== this.#latestUsage?.composerIndicators?.[0]?.expiresAtUnix;
|
|
68866
69196
|
const contextWindowTokens = this.#latestUsage?.contextWindowTokens;
|
|
68867
69197
|
this.#mergeAndPublishUsage({
|
|
68868
69198
|
...cacheHitRatePercent !== void 0 ? { cacheHitRatePercent } : {},
|
|
69199
|
+
...indicatorChanged ? { composerIndicators } : {},
|
|
68869
69200
|
inputTokens: this.#calibratedInputTokens + active2.estimatedInputTokens,
|
|
68870
69201
|
outputTokens: this.#calibratedOutputTokens + active2.estimatedOutputTokens,
|
|
68871
69202
|
...active2.estimatedCostAvailable ? { totalCostUsd: this.#calibratedCostUsd + active2.estimatedCostUsd } : {},
|
|
@@ -68902,6 +69233,13 @@ var ClaudeHarnessSession = class {
|
|
|
68902
69233
|
const cacheHitRatePercent = claudeCacheHitRatePercent(event.lastRequestUsage);
|
|
68903
69234
|
if (cacheHitRatePercent !== void 0)
|
|
68904
69235
|
delta.cacheHitRatePercent = cacheHitRatePercent;
|
|
69236
|
+
if (!active2.promptCacheTtlObserved && event.lastRequestUsage.promptCacheTtlSeconds !== void 0) {
|
|
69237
|
+
this.#promptCacheTtlSeconds = event.lastRequestUsage.promptCacheTtlSeconds;
|
|
69238
|
+
const composerIndicators = claudePromptCacheIndicators(this.#accountCreditsSupported, this.#lastAssistantResponseAtUnix, this.#promptCacheTtlSeconds);
|
|
69239
|
+
if (composerIndicators[0]?.expiresAtUnix !== this.#latestUsage?.composerIndicators?.[0]?.expiresAtUnix) {
|
|
69240
|
+
delta.composerIndicators = composerIndicators;
|
|
69241
|
+
}
|
|
69242
|
+
}
|
|
68905
69243
|
}
|
|
68906
69244
|
if (this.#transport && this.#minimumContextUsedTokens !== null && event.modelUsage?.some(({ contextWindowTokens }) => contextWindowTokens !== void 0)) {
|
|
68907
69245
|
this.#requestContextUsage(this.#transport, active2.command.turnId, [0], "summary");
|
|
@@ -68920,11 +69258,15 @@ var ClaudeHarnessSession = class {
|
|
|
68920
69258
|
if (effective)
|
|
68921
69259
|
this.publishPlanLimit(effective);
|
|
68922
69260
|
}
|
|
69261
|
+
#observePromptCacheTtl(ttlSeconds) {
|
|
69262
|
+
this.#promptCacheTtlSeconds = ttlSeconds;
|
|
69263
|
+
this.publishAccountCreditsSupport(this.#accountCreditsSupported);
|
|
69264
|
+
}
|
|
68923
69265
|
publishAccountCreditsSupport(supported) {
|
|
68924
69266
|
if (this.#phase !== "open")
|
|
68925
69267
|
return;
|
|
68926
69268
|
this.#accountCreditsSupported = supported;
|
|
68927
|
-
const composerIndicators = claudePromptCacheIndicators(supported, this.#lastAssistantResponseAtUnix);
|
|
69269
|
+
const composerIndicators = claudePromptCacheIndicators(supported, this.#lastAssistantResponseAtUnix, this.#promptCacheTtlSeconds);
|
|
68928
69270
|
if (composerIndicators[0]?.expiresAtUnix === this.#latestUsage?.composerIndicators?.[0]?.expiresAtUnix)
|
|
68929
69271
|
return;
|
|
68930
69272
|
this.#mergeAndPublishUsage({ composerIndicators }, this.#active?.command.turnId);
|
|
@@ -69656,10 +69998,11 @@ var ClaudeCodeAdapter = class {
|
|
|
69656
69998
|
const messages = await this.#dependencies.readSessionMessages({ cwd, sessionId });
|
|
69657
69999
|
if (messages === null)
|
|
69658
70000
|
return { requests: [], complete: false };
|
|
69659
|
-
const
|
|
70001
|
+
const promptCache = claudePromptCacheFromMessages(messages);
|
|
69660
70002
|
return {
|
|
69661
70003
|
...claudeUsageHistory(messages),
|
|
69662
|
-
...lastResponseAtUnix !== void 0 ? { lastResponseAtUnix } : {}
|
|
70004
|
+
...promptCache.lastResponseAtUnix !== void 0 ? { lastResponseAtUnix: promptCache.lastResponseAtUnix } : {},
|
|
70005
|
+
...promptCache.ttlSeconds !== void 0 ? { promptCacheTtlSeconds: promptCache.ttlSeconds } : {}
|
|
69663
70006
|
};
|
|
69664
70007
|
} catch {
|
|
69665
70008
|
return { requests: [], complete: false };
|