@codexhost/cli-win32-arm64 0.26.1 → 0.28.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 +1010 -592
- package/app/console-web.js +1861 -1498
- package/app/desktop-controller.mjs +488 -245
- package/app/host-runtime.mjs +9177 -4006
- package/app/plugins/antigravity/plugin.mjs +9055 -548
- package/app/plugins/claude-code/plugin.mjs +1117 -423
- package/app/plugins/codebuddy/plugin.mjs +599 -261
- package/app/plugins/codex-usage/plugin.mjs +1808 -1357
- package/app/plugins/copilot/plugin.mjs +491 -235
- package/app/plugins/cursor-cli/plugin.mjs +487 -232
- package/app/plugins/deepseek-harness/plugin.mjs +493 -235
- package/app/plugins/devin/plugin.mjs +467 -232
- package/app/plugins/grok/plugin.mjs +547 -253
- package/app/plugins/hermes/plugin.mjs +468 -232
- package/app/plugins/kimi-code/plugin.mjs +762 -439
- package/app/plugins/kiro-cli/plugin.mjs +466 -232
- package/app/plugins/omp/plugin.mjs +1705 -1356
- package/app/plugins/opencode/manifest.json +1 -1
- package/app/plugins/opencode/plugin.mjs +544 -250
- package/app/plugins/pi/plugin.mjs +761 -364
- package/app/plugins/qoder/plugin.mjs +540 -246
- package/app/plugins/qoder-cn/plugin.mjs +540 -246
- package/app/plugins/qwen-code/plugin.mjs +466 -232
- package/app/plugins/workbuddy/plugin.mjs +594 -273
- package/app/plugins/zcode/plugin.mjs +468 -232
- package/app/renderer-extension.js +2653 -657
- package/app/web/assets/index-DBPgg32z.css +1 -0
- package/app/web/assets/index-DWxiVzuS.js +204 -0
- package/app/web/codexhost-settings.js +101 -66
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +65 -65
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- 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 +73 -73
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +19 -19
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- 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 +5 -5
- 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-documentpreview/client.pdf.js +2 -2
- 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 +5065 -1964
- 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(),
|
|
@@ -20094,11 +20126,21 @@ var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionS
|
|
|
20094
20126
|
ids.add(option2.id);
|
|
20095
20127
|
}
|
|
20096
20128
|
});
|
|
20129
|
+
var harnessThinkingOptionsScopeSchema = external_exports.enum(["catalog", "activeModel"]);
|
|
20097
20130
|
var harnessModelCatalogSchema = external_exports.object({
|
|
20098
20131
|
models: external_exports.array(harnessModelSchema),
|
|
20099
20132
|
defaultModel: harnessModelRefSchema.optional(),
|
|
20100
20133
|
thinkingOptions: harnessThinkingOptionsSchema,
|
|
20101
|
-
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
|
|
20134
|
+
defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
20135
|
+
/**
|
|
20136
|
+
* Scope of per-Model `supportedThinkingOptionIds` in this catalog.
|
|
20137
|
+
* Omitted or `"catalog"` means each Model's `supportedThinkingOptionIds`
|
|
20138
|
+
* reflects its own options (omitted or `[]` means none).
|
|
20139
|
+
* `"activeModel"` means only the active Model's Thinking options were
|
|
20140
|
+
* observed; other Models omit `supportedThinkingOptionIds` and must be
|
|
20141
|
+
* validated by the Adapter after selecting the Model.
|
|
20142
|
+
*/
|
|
20143
|
+
thinkingOptionsScope: harnessThinkingOptionsScopeSchema.optional()
|
|
20102
20144
|
}).strict().superRefine((catalog, context) => {
|
|
20103
20145
|
const refs = [];
|
|
20104
20146
|
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id3 }) => id3));
|
|
@@ -20231,7 +20273,7 @@ var harnessInspectionSchema = external_exports.union([
|
|
|
20231
20273
|
]);
|
|
20232
20274
|
var harnessInspectParamsSchema = external_exports.object({
|
|
20233
20275
|
harnessId: harnessIdSchema,
|
|
20234
|
-
cwd:
|
|
20276
|
+
cwd: nonBlankTextSchema3.max(16384).optional(),
|
|
20235
20277
|
refresh: external_exports.boolean().optional(),
|
|
20236
20278
|
/** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
|
|
20237
20279
|
purpose: external_exports.literal("availability").optional(),
|
|
@@ -20261,12 +20303,13 @@ var codexThreadInspectionSchema = external_exports.object({
|
|
|
20261
20303
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
20262
20304
|
effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
20263
20305
|
history: harnessHistoryCapabilitiesSchema.optional(),
|
|
20264
|
-
supportsThreadReferences: external_exports.literal(true).optional()
|
|
20306
|
+
supportsThreadReferences: external_exports.literal(true).optional(),
|
|
20307
|
+
handoff: threadHandoffMetadataSchema.optional()
|
|
20265
20308
|
}).strict();
|
|
20266
20309
|
var externalThreadInspectionSchema = external_exports.object({
|
|
20267
20310
|
owner: external_exports.literal("external"),
|
|
20268
|
-
harnessId:
|
|
20269
|
-
transportModelId:
|
|
20311
|
+
harnessId: nonBlankTextSchema3.max(256),
|
|
20312
|
+
transportModelId: nonBlankTextSchema3.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
|
|
20270
20313
|
effectiveModel: harnessModelRefSchema.optional(),
|
|
20271
20314
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
20272
20315
|
effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
@@ -20276,6 +20319,7 @@ var externalThreadInspectionSchema = external_exports.object({
|
|
|
20276
20319
|
catalog: harnessModelCatalogSchema.optional(),
|
|
20277
20320
|
history: harnessHistoryCapabilitiesSchema,
|
|
20278
20321
|
usage: threadUsageSnapshotSchema.optional(),
|
|
20322
|
+
handoff: threadHandoffMetadataSchema.optional(),
|
|
20279
20323
|
locked: external_exports.literal(true)
|
|
20280
20324
|
}).strict();
|
|
20281
20325
|
var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
|
|
@@ -20913,6 +20957,7 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
20913
20957
|
"codexhost/harness/preferences/get",
|
|
20914
20958
|
"codexhost/harness/preferences/patch",
|
|
20915
20959
|
"thread/list",
|
|
20960
|
+
"thread/metadata/update",
|
|
20916
20961
|
"codexhost/thread/catalog/read",
|
|
20917
20962
|
"thread/read",
|
|
20918
20963
|
"thread/resume",
|
|
@@ -20937,6 +20982,10 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
20937
20982
|
"thread/queue/start",
|
|
20938
20983
|
"codexhost/thread/queue/send-now",
|
|
20939
20984
|
"codexhost/workspace/read",
|
|
20985
|
+
"project/create",
|
|
20986
|
+
"project/update",
|
|
20987
|
+
"project/delete",
|
|
20988
|
+
"project/move",
|
|
20940
20989
|
"codexhost/thread/tree/read",
|
|
20941
20990
|
"codexhost/thread/pins/list",
|
|
20942
20991
|
"codexhost/thread/sections/list",
|
|
@@ -20954,6 +21003,7 @@ var CLIENT_CHANNEL_METHODS = [
|
|
|
20954
21003
|
"codexhost/harness/commands/inspect",
|
|
20955
21004
|
"codexhost/thread/command/execute",
|
|
20956
21005
|
"codexhost/thread/fork",
|
|
21006
|
+
THREAD_HANDOFF_METHOD,
|
|
20957
21007
|
"codexhost/harness/session-import/sources",
|
|
20958
21008
|
"codexhost/harness/session-import/list",
|
|
20959
21009
|
"codexhost/harness/session-import/import",
|
|
@@ -21004,7 +21054,13 @@ var clientProjectlessWorkspaceSchema = external_exports.object({
|
|
|
21004
21054
|
prompt: external_exports.string().max(16384).optional()
|
|
21005
21055
|
}).strict();
|
|
21006
21056
|
var clientWorkspaceSnapshotSchema = external_exports.object({
|
|
21007
|
-
projects: external_exports.array(external_exports.object({
|
|
21057
|
+
projects: external_exports.array(external_exports.object({
|
|
21058
|
+
id: external_exports.string(),
|
|
21059
|
+
name: external_exports.string(),
|
|
21060
|
+
rootPaths: external_exports.array(external_exports.string()),
|
|
21061
|
+
createdAt: external_exports.number().int().optional()
|
|
21062
|
+
})),
|
|
21063
|
+
nativeProjects: external_exports.literal(true).optional(),
|
|
21008
21064
|
assignments: external_exports.record(external_exports.string(), external_exports.string()),
|
|
21009
21065
|
projectless: external_exports.array(external_exports.string()),
|
|
21010
21066
|
/** Canonical external pin membership; pins/list provides the native merged order. */
|
|
@@ -21019,6 +21075,7 @@ var clientChannelCursorSchema = external_exports.object({
|
|
|
21019
21075
|
sequence: external_exports.number().int().nonnegative()
|
|
21020
21076
|
});
|
|
21021
21077
|
var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
21078
|
+
external_exports.object({ type: external_exports.literal("projects-changed"), cursor: clientChannelCursorSchema }),
|
|
21022
21079
|
external_exports.object({
|
|
21023
21080
|
type: external_exports.literal("skills-changed"),
|
|
21024
21081
|
cursor: clientChannelCursorSchema,
|
|
@@ -21182,7 +21239,8 @@ var clientThreadSnapshotSchema = external_exports.object({
|
|
|
21182
21239
|
items: external_exports.array(clientQueuedSubmissionSchema),
|
|
21183
21240
|
pausedReason: external_exports.enum(["interrupted", "outcome-unknown", "failed"]).nullable()
|
|
21184
21241
|
}).optional(),
|
|
21185
|
-
interactions: external_exports.array(clientInteractionSchema)
|
|
21242
|
+
interactions: external_exports.array(clientInteractionSchema),
|
|
21243
|
+
handoff: threadHandoffMetadataSchema.optional()
|
|
21186
21244
|
});
|
|
21187
21245
|
var clientChannelDescriptorSchema = external_exports.object({
|
|
21188
21246
|
version: external_exports.literal(CLIENT_CHANNEL_VERSION),
|
|
@@ -21191,7 +21249,10 @@ var clientChannelDescriptorSchema = external_exports.object({
|
|
|
21191
21249
|
port: external_exports.number().int().min(1).max(65535),
|
|
21192
21250
|
token: external_exports.string().regex(/^[0-9a-f]{64}$/u),
|
|
21193
21251
|
startedAt: external_exports.number(),
|
|
21194
|
-
epoch: external_exports.string().uuid()
|
|
21252
|
+
epoch: external_exports.string().uuid(),
|
|
21253
|
+
capabilities: external_exports.object({
|
|
21254
|
+
peerDelegation: external_exports.literal(1).optional()
|
|
21255
|
+
}).optional()
|
|
21195
21256
|
});
|
|
21196
21257
|
var clientChannelResponseSchema = external_exports.object({
|
|
21197
21258
|
epoch: external_exports.string().uuid(),
|
|
@@ -21210,10 +21271,18 @@ var threadCatalogReadParamsSchema = external_exports.object({
|
|
|
21210
21271
|
* `excludeCwds` folder, the branch ends, or a page bound is reached. Every row read is
|
|
21211
21272
|
* returned, so the native cursors stay contiguous.
|
|
21212
21273
|
*/
|
|
21213
|
-
scope: external_exports.
|
|
21214
|
-
|
|
21215
|
-
|
|
21216
|
-
|
|
21274
|
+
scope: external_exports.union([
|
|
21275
|
+
external_exports.object({
|
|
21276
|
+
cwd: external_exports.string().min(1).max(4096),
|
|
21277
|
+
excludeCwds: external_exports.array(external_exports.string().min(1).max(4096)).max(1024)
|
|
21278
|
+
}).strict(),
|
|
21279
|
+
external_exports.object({
|
|
21280
|
+
projectId: external_exports.string().min(1).max(1024),
|
|
21281
|
+
legacyThreadIds: external_exports.array(external_exports.string().min(1).max(1024)).max(1024),
|
|
21282
|
+
/** Roots whose Threads without a project ID belong to this project, as on Desktop. */
|
|
21283
|
+
rootPaths: external_exports.array(external_exports.string().min(1).max(4096)).max(1024).optional()
|
|
21284
|
+
}).strict()
|
|
21285
|
+
]).optional()
|
|
21217
21286
|
}).strict();
|
|
21218
21287
|
var threadCatalogReadResultSchema = external_exports.object({
|
|
21219
21288
|
threads: external_exports.array(jsonObjectSchema),
|
|
@@ -21400,6 +21469,361 @@ var delegationReadParamsSchema = external_exports.strictObject({
|
|
|
21400
21469
|
to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
|
|
21401
21470
|
});
|
|
21402
21471
|
|
|
21472
|
+
// ../../shared-contracts/dist/remote-peers.js
|
|
21473
|
+
var REMOTE_PEER_ID_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/u;
|
|
21474
|
+
var remotePeerIdSchema = external_exports.string().regex(REMOTE_PEER_ID_PATTERN);
|
|
21475
|
+
var remotePeerNodeIdSchema = external_exports.string().regex(REMOTE_PEER_ID_PATTERN);
|
|
21476
|
+
var remotePeerHostIdSchema = external_exports.string().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u);
|
|
21477
|
+
var remotePeerTransportKindSchema = external_exports.enum(["relay", "tailscale", "lan", "custom"]);
|
|
21478
|
+
var REMOTE_PEER_COLORS = [
|
|
21479
|
+
"blue",
|
|
21480
|
+
"purple",
|
|
21481
|
+
"cyan",
|
|
21482
|
+
"green",
|
|
21483
|
+
"amber",
|
|
21484
|
+
"rose",
|
|
21485
|
+
"slate"
|
|
21486
|
+
];
|
|
21487
|
+
var remotePeerColorSchema = external_exports.enum(REMOTE_PEER_COLORS);
|
|
21488
|
+
var REMOTE_PEER_COLOR_SET = new Set(REMOTE_PEER_COLORS);
|
|
21489
|
+
var remotePeerStateSchema = external_exports.enum([
|
|
21490
|
+
"connected",
|
|
21491
|
+
"connecting",
|
|
21492
|
+
"auth-error",
|
|
21493
|
+
"offline",
|
|
21494
|
+
"disabled"
|
|
21495
|
+
]);
|
|
21496
|
+
var remotePeerSummarySchema = external_exports.object({
|
|
21497
|
+
peerId: remotePeerIdSchema,
|
|
21498
|
+
hostId: remotePeerHostIdSchema,
|
|
21499
|
+
nodeId: remotePeerNodeIdSchema.optional(),
|
|
21500
|
+
name: external_exports.string().min(1).max(120),
|
|
21501
|
+
color: remotePeerColorSchema.optional(),
|
|
21502
|
+
origin: external_exports.string().min(1).max(2048),
|
|
21503
|
+
transportKind: remotePeerTransportKindSchema,
|
|
21504
|
+
encrypted: external_exports.boolean(),
|
|
21505
|
+
enabled: external_exports.boolean(),
|
|
21506
|
+
state: remotePeerStateSchema,
|
|
21507
|
+
supportsPeerPairing: external_exports.boolean().optional(),
|
|
21508
|
+
/** Omitted when either side's node mapping is unknown. */
|
|
21509
|
+
pairedBack: external_exports.boolean().optional(),
|
|
21510
|
+
/** Other configured remote peerIds on this Hub present in this peer's `manifest.peerNodes`. */
|
|
21511
|
+
linkedPeerIds: external_exports.array(remotePeerIdSchema).max(128).optional(),
|
|
21512
|
+
latencyMs: external_exports.number().int().nonnegative().optional(),
|
|
21513
|
+
version: external_exports.string().max(128).optional(),
|
|
21514
|
+
platform: external_exports.string().max(64).optional(),
|
|
21515
|
+
hostname: external_exports.string().max(255).optional(),
|
|
21516
|
+
homeDir: external_exports.string().max(4096).optional(),
|
|
21517
|
+
lastError: external_exports.string().max(1e3).optional(),
|
|
21518
|
+
projectCount: external_exports.number().int().nonnegative(),
|
|
21519
|
+
createdAt: external_exports.string(),
|
|
21520
|
+
updatedAt: external_exports.string()
|
|
21521
|
+
});
|
|
21522
|
+
var remotePeerListResultSchema = external_exports.object({
|
|
21523
|
+
peers: external_exports.array(remotePeerSummarySchema)
|
|
21524
|
+
});
|
|
21525
|
+
var remotePeerAddParamsSchema = external_exports.object({
|
|
21526
|
+
connectionUrl: external_exports.string().min(1).max(4096).optional(),
|
|
21527
|
+
origin: external_exports.string().min(1).max(2048).optional(),
|
|
21528
|
+
token: external_exports.string().min(1).max(2048).optional(),
|
|
21529
|
+
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
21530
|
+
color: remotePeerColorSchema.optional(),
|
|
21531
|
+
pairBack: external_exports.boolean().optional(),
|
|
21532
|
+
meshPeerIds: external_exports.array(remotePeerIdSchema).max(64).optional(),
|
|
21533
|
+
selfOrigin: external_exports.string().min(1).max(2048).optional()
|
|
21534
|
+
}).refine((input3) => Boolean(input3.connectionUrl) || Boolean(input3.origin) && Boolean(input3.token), "Provide either connectionUrl or both origin and token");
|
|
21535
|
+
var remotePeerIntroduceParamsSchema = external_exports.strictObject({
|
|
21536
|
+
origin: external_exports.string().min(1).max(2048),
|
|
21537
|
+
token: external_exports.string().min(1).max(2048),
|
|
21538
|
+
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
21539
|
+
color: remotePeerColorSchema.optional(),
|
|
21540
|
+
expectedNodeId: remotePeerNodeIdSchema.optional()
|
|
21541
|
+
});
|
|
21542
|
+
var remotePeerIntroduceResultSchema = external_exports.object({
|
|
21543
|
+
status: external_exports.enum(["added", "updated", "existing"]),
|
|
21544
|
+
peerId: remotePeerIdSchema,
|
|
21545
|
+
hostId: remotePeerHostIdSchema,
|
|
21546
|
+
nodeId: remotePeerNodeIdSchema.optional()
|
|
21547
|
+
});
|
|
21548
|
+
var remotePeerPairingStatusSchema = external_exports.enum([
|
|
21549
|
+
"added",
|
|
21550
|
+
"updated",
|
|
21551
|
+
"existing",
|
|
21552
|
+
"failed",
|
|
21553
|
+
"skipped"
|
|
21554
|
+
]);
|
|
21555
|
+
var remotePeerPairingStepSchema = external_exports.object({
|
|
21556
|
+
targetPeerId: remotePeerIdSchema,
|
|
21557
|
+
targetName: external_exports.string().min(1).max(120),
|
|
21558
|
+
introducedHost: external_exports.union([external_exports.literal("local"), remotePeerIdSchema]),
|
|
21559
|
+
introducedName: external_exports.string().min(1).max(120),
|
|
21560
|
+
status: remotePeerPairingStatusSchema,
|
|
21561
|
+
error: external_exports.string().max(1e3).optional()
|
|
21562
|
+
});
|
|
21563
|
+
var remotePeerPairingReportSchema = external_exports.object({
|
|
21564
|
+
results: external_exports.array(remotePeerPairingStepSchema)
|
|
21565
|
+
});
|
|
21566
|
+
var remotePeerSyncMeshParamsSchema = external_exports.object({
|
|
21567
|
+
peerIds: external_exports.array(remotePeerIdSchema).max(64).optional(),
|
|
21568
|
+
includeSelf: external_exports.boolean().optional(),
|
|
21569
|
+
includeMesh: external_exports.boolean().optional(),
|
|
21570
|
+
selfOrigin: external_exports.string().min(1).max(2048).optional()
|
|
21571
|
+
});
|
|
21572
|
+
var remotePeerUpdateParamsSchema = external_exports.object({
|
|
21573
|
+
peerId: remotePeerIdSchema,
|
|
21574
|
+
name: external_exports.string().trim().min(1).max(120).optional(),
|
|
21575
|
+
color: remotePeerColorSchema.nullable().optional(),
|
|
21576
|
+
connectionUrl: external_exports.string().min(1).max(4096).optional(),
|
|
21577
|
+
origin: external_exports.string().min(1).max(2048).optional(),
|
|
21578
|
+
token: external_exports.string().min(1).max(2048).optional(),
|
|
21579
|
+
enabled: external_exports.boolean().optional()
|
|
21580
|
+
});
|
|
21581
|
+
var remotePeerIdParamsSchema = external_exports.object({
|
|
21582
|
+
peerId: remotePeerIdSchema
|
|
21583
|
+
});
|
|
21584
|
+
var remotePeerRemoveResultSchema = external_exports.object({
|
|
21585
|
+
removed: external_exports.boolean()
|
|
21586
|
+
});
|
|
21587
|
+
var remotePeerTestParamsSchema = external_exports.object({
|
|
21588
|
+
peerId: remotePeerIdSchema.optional(),
|
|
21589
|
+
connectionUrl: external_exports.string().min(1).max(4096).optional(),
|
|
21590
|
+
origin: external_exports.string().min(1).max(2048).optional(),
|
|
21591
|
+
token: external_exports.string().min(1).max(2048).optional()
|
|
21592
|
+
}).refine((input3) => Boolean(input3.peerId) || Boolean(input3.connectionUrl) || Boolean(input3.origin) && Boolean(input3.token), "Provide peerId, connectionUrl, or both origin and token");
|
|
21593
|
+
var remotePeerTestProjectSchema = external_exports.object({
|
|
21594
|
+
id: external_exports.string().min(1).max(1024),
|
|
21595
|
+
name: external_exports.string().min(1).max(512),
|
|
21596
|
+
path: external_exports.string().min(1).max(8192)
|
|
21597
|
+
});
|
|
21598
|
+
var remotePeerTestResultSchema = external_exports.object({
|
|
21599
|
+
ok: external_exports.boolean(),
|
|
21600
|
+
nodeId: remotePeerNodeIdSchema.optional(),
|
|
21601
|
+
supportsPeerPairing: external_exports.boolean().optional(),
|
|
21602
|
+
pairedBack: external_exports.boolean().optional(),
|
|
21603
|
+
latencyMs: external_exports.number().int().nonnegative().optional(),
|
|
21604
|
+
origin: external_exports.string().max(2048).optional(),
|
|
21605
|
+
transportKind: remotePeerTransportKindSchema.optional(),
|
|
21606
|
+
encrypted: external_exports.boolean().optional(),
|
|
21607
|
+
version: external_exports.string().max(128).optional(),
|
|
21608
|
+
platform: external_exports.string().max(64).optional(),
|
|
21609
|
+
hostname: external_exports.string().max(255).optional(),
|
|
21610
|
+
homeDir: external_exports.string().max(4096).optional(),
|
|
21611
|
+
projectCount: external_exports.number().int().nonnegative().optional(),
|
|
21612
|
+
projects: external_exports.array(remotePeerTestProjectSchema).optional(),
|
|
21613
|
+
error: external_exports.string().max(1e3).optional()
|
|
21614
|
+
});
|
|
21615
|
+
var remotePeerManifestProjectSchema = external_exports.object({
|
|
21616
|
+
id: external_exports.string().min(1).max(1024),
|
|
21617
|
+
name: external_exports.string().min(1).max(512),
|
|
21618
|
+
path: external_exports.string().min(1).max(8192),
|
|
21619
|
+
threadIds: external_exports.array(external_exports.string().min(1).max(1024))
|
|
21620
|
+
});
|
|
21621
|
+
var remotePeerCapabilitiesSchema = external_exports.object({
|
|
21622
|
+
/** /api/peer/v1/uploads, /api/peer/v1/prompt, and /api/peer/v1/file are all available. */
|
|
21623
|
+
attachments: external_exports.literal(1).optional(),
|
|
21624
|
+
/** /api/peer/v1/workspace-files/rpc and /api/peer/v1/workspace-files/download are available. */
|
|
21625
|
+
workspaceFiles: external_exports.literal(1).optional(),
|
|
21626
|
+
/** Peer supports officeToPdf/render over /api/peer/v1/workspace-files/rpc. */
|
|
21627
|
+
officePreview: external_exports.literal(1).optional(),
|
|
21628
|
+
/** /api/peer/v1/delegation is available for fixed-whitelist cross-host delegation. */
|
|
21629
|
+
delegation: external_exports.literal(1).optional(),
|
|
21630
|
+
/** POST /api/peer/v1/peers is available. */
|
|
21631
|
+
peerPairing: external_exports.literal(1).optional()
|
|
21632
|
+
});
|
|
21633
|
+
var remotePeerManifestSchema = external_exports.object({
|
|
21634
|
+
version: external_exports.string().max(128),
|
|
21635
|
+
platform: external_exports.string().max(64),
|
|
21636
|
+
hostname: external_exports.string().max(255),
|
|
21637
|
+
homeDir: external_exports.string().max(4096).optional(),
|
|
21638
|
+
epoch: external_exports.string().min(1).max(256),
|
|
21639
|
+
nodeId: remotePeerNodeIdSchema.optional(),
|
|
21640
|
+
peerNodes: external_exports.record(remotePeerHostIdSchema, remotePeerNodeIdSchema).refine((v) => Object.keys(v).length <= 128).optional(),
|
|
21641
|
+
projects: external_exports.array(remotePeerManifestProjectSchema),
|
|
21642
|
+
capabilities: remotePeerCapabilitiesSchema.optional()
|
|
21643
|
+
});
|
|
21644
|
+
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;
|
|
21645
|
+
var remotePeerPromptParamsSchema = external_exports.strictObject({
|
|
21646
|
+
threadId: external_exports.string().min(1).max(1024),
|
|
21647
|
+
scope: external_exports.string().regex(REMOTE_PEER_UPLOAD_SCOPE_PATTERN).optional(),
|
|
21648
|
+
requestId: external_exports.string().min(1).max(256).optional(),
|
|
21649
|
+
mode: external_exports.enum(["queue", "steer"]).optional(),
|
|
21650
|
+
expectedTurnId: external_exports.string().min(1).max(1024).nullable().optional(),
|
|
21651
|
+
content: external_exports.array(external_exports.discriminatedUnion("type", [
|
|
21652
|
+
external_exports.strictObject({ type: external_exports.literal("text"), text: external_exports.string() }),
|
|
21653
|
+
external_exports.strictObject({ type: external_exports.literal("file"), receiptId: external_exports.string().min(1).max(128) })
|
|
21654
|
+
])).min(1).max(64)
|
|
21655
|
+
});
|
|
21656
|
+
var remotePeerErrorEnvelopeSchema = external_exports.object({
|
|
21657
|
+
ok: external_exports.literal(false),
|
|
21658
|
+
error: external_exports.object({
|
|
21659
|
+
code: external_exports.string(),
|
|
21660
|
+
message: external_exports.string(),
|
|
21661
|
+
details: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
21662
|
+
})
|
|
21663
|
+
});
|
|
21664
|
+
var remotePeerUploadResultSchema = external_exports.union([
|
|
21665
|
+
external_exports.object({
|
|
21666
|
+
ok: external_exports.literal(true),
|
|
21667
|
+
value: external_exports.object({
|
|
21668
|
+
receiptId: external_exports.string().min(1),
|
|
21669
|
+
file: external_exports.object({
|
|
21670
|
+
attachmentId: external_exports.string(),
|
|
21671
|
+
name: external_exports.string(),
|
|
21672
|
+
bytes: external_exports.number().int().nonnegative()
|
|
21673
|
+
})
|
|
21674
|
+
})
|
|
21675
|
+
}),
|
|
21676
|
+
remotePeerErrorEnvelopeSchema
|
|
21677
|
+
]);
|
|
21678
|
+
var remotePeerPromptResultSchema = external_exports.union([
|
|
21679
|
+
external_exports.object({
|
|
21680
|
+
ok: external_exports.literal(true),
|
|
21681
|
+
value: external_exports.object({ accepted: external_exports.literal(true) })
|
|
21682
|
+
}),
|
|
21683
|
+
remotePeerErrorEnvelopeSchema
|
|
21684
|
+
]);
|
|
21685
|
+
var remotePeerDirectoryEntrySchema = external_exports.object({
|
|
21686
|
+
name: external_exports.string().min(1).max(512),
|
|
21687
|
+
path: external_exports.string().min(1).max(8192),
|
|
21688
|
+
kind: external_exports.literal("directory")
|
|
21689
|
+
});
|
|
21690
|
+
var remotePeerListDirsParamsSchema = external_exports.object({
|
|
21691
|
+
peerId: remotePeerIdSchema,
|
|
21692
|
+
path: external_exports.string().min(1).max(8192).optional()
|
|
21693
|
+
});
|
|
21694
|
+
var remotePeerListDirsResultSchema = external_exports.object({
|
|
21695
|
+
path: external_exports.string().min(1).max(8192),
|
|
21696
|
+
parentPath: external_exports.string().min(1).max(8192).nullable(),
|
|
21697
|
+
homeDir: external_exports.string().min(1).max(8192).optional(),
|
|
21698
|
+
entries: external_exports.array(remotePeerDirectoryEntrySchema)
|
|
21699
|
+
});
|
|
21700
|
+
var remotePeerCreateDirParamsSchema = external_exports.object({
|
|
21701
|
+
peerId: remotePeerIdSchema,
|
|
21702
|
+
parentPath: external_exports.string().min(1).max(8192),
|
|
21703
|
+
name: external_exports.string().min(1).max(255).refine((value) => value.trim().length > 0, "Directory name cannot be blank")
|
|
21704
|
+
});
|
|
21705
|
+
var remotePeerCreateDirResultSchema = external_exports.object({
|
|
21706
|
+
path: external_exports.string().min(1).max(8192),
|
|
21707
|
+
name: external_exports.string().min(1).max(255)
|
|
21708
|
+
});
|
|
21709
|
+
var remotePeerCreateWorkspaceParamsSchema = external_exports.object({
|
|
21710
|
+
peerId: remotePeerIdSchema,
|
|
21711
|
+
path: external_exports.string().min(1).max(8192),
|
|
21712
|
+
title: external_exports.string().trim().min(1).max(255).optional()
|
|
21713
|
+
});
|
|
21714
|
+
var remotePeerRenameWorkspaceParamsSchema = external_exports.object({
|
|
21715
|
+
peerId: remotePeerIdSchema,
|
|
21716
|
+
workspaceId: external_exports.string().min(1).max(1024),
|
|
21717
|
+
title: external_exports.string().trim().min(1).max(255)
|
|
21718
|
+
});
|
|
21719
|
+
var remotePeerDeleteWorkspaceParamsSchema = external_exports.object({
|
|
21720
|
+
peerId: remotePeerIdSchema,
|
|
21721
|
+
workspaceId: external_exports.string().min(1).max(1024)
|
|
21722
|
+
});
|
|
21723
|
+
var remotePeerWorkspaceMutationResultSchema = external_exports.object({
|
|
21724
|
+
workspaceId: external_exports.string().min(1).max(1024).optional(),
|
|
21725
|
+
manifest: remotePeerManifestSchema
|
|
21726
|
+
});
|
|
21727
|
+
var delegationRemoteHostsParamsSchema = external_exports.object({
|
|
21728
|
+
sessionHostId: external_exports.string().min(1).max(128).optional()
|
|
21729
|
+
});
|
|
21730
|
+
var delegationRemoteHostOptionSchema = external_exports.object({
|
|
21731
|
+
hostId: external_exports.union([external_exports.literal("local"), remotePeerHostIdSchema]),
|
|
21732
|
+
name: external_exports.string().min(1).max(120),
|
|
21733
|
+
isLocal: external_exports.boolean().optional(),
|
|
21734
|
+
color: remotePeerColorSchema.optional(),
|
|
21735
|
+
hostname: external_exports.string().max(255).optional()
|
|
21736
|
+
});
|
|
21737
|
+
var delegationRemoteHostsResultSchema = external_exports.object({
|
|
21738
|
+
hosts: external_exports.array(delegationRemoteHostOptionSchema)
|
|
21739
|
+
});
|
|
21740
|
+
var delegationHostHarnessesParamsSchema = external_exports.object({
|
|
21741
|
+
hostId: external_exports.union([external_exports.literal("local"), remotePeerHostIdSchema])
|
|
21742
|
+
});
|
|
21743
|
+
var delegationHostHarnessOptionSchema = external_exports.object({
|
|
21744
|
+
id: external_exports.string().regex(/^[a-z0-9][a-z0-9-]*$/u),
|
|
21745
|
+
name: external_exports.string().min(1).max(120)
|
|
21746
|
+
});
|
|
21747
|
+
var delegationHostHarnessesResultSchema = external_exports.object({
|
|
21748
|
+
harnesses: external_exports.array(delegationHostHarnessOptionSchema)
|
|
21749
|
+
});
|
|
21750
|
+
|
|
21751
|
+
// ../../shared-contracts/dist/peer-delegation.js
|
|
21752
|
+
var PEER_DELEGATION_BRIDGE_VERSION = 1;
|
|
21753
|
+
var PEER_DELEGATION_OPERATIONS = [
|
|
21754
|
+
"listHarnesses",
|
|
21755
|
+
"inspect",
|
|
21756
|
+
"start",
|
|
21757
|
+
"send",
|
|
21758
|
+
"cancel",
|
|
21759
|
+
"read",
|
|
21760
|
+
"answer",
|
|
21761
|
+
"list"
|
|
21762
|
+
];
|
|
21763
|
+
var peerDelegationOperationSchema = external_exports.enum(PEER_DELEGATION_OPERATIONS);
|
|
21764
|
+
var peerDelegationRequestSchema = external_exports.strictObject({
|
|
21765
|
+
operation: peerDelegationOperationSchema,
|
|
21766
|
+
hopCount: external_exports.number().int().min(0).max(16),
|
|
21767
|
+
/** Opaque A-side peer pairing identifier used by B to scope implicit deduplication per Peer. */
|
|
21768
|
+
sourceId: remotePeerIdSchema.optional(),
|
|
21769
|
+
input: jsonObjectSchema
|
|
21770
|
+
});
|
|
21771
|
+
var peerDelegationErrorSchema = external_exports.strictObject({
|
|
21772
|
+
code: external_exports.string().min(1).max(128),
|
|
21773
|
+
message: external_exports.string().max(4096),
|
|
21774
|
+
details: jsonObjectSchema.optional()
|
|
21775
|
+
});
|
|
21776
|
+
var peerDelegationResponseSchema = external_exports.union([
|
|
21777
|
+
external_exports.strictObject({
|
|
21778
|
+
ok: external_exports.literal(true),
|
|
21779
|
+
value: jsonValueSchema
|
|
21780
|
+
}),
|
|
21781
|
+
external_exports.strictObject({
|
|
21782
|
+
ok: external_exports.literal(false),
|
|
21783
|
+
error: peerDelegationErrorSchema
|
|
21784
|
+
})
|
|
21785
|
+
]);
|
|
21786
|
+
var peerDelegationHostProjectSchema = external_exports.strictObject({
|
|
21787
|
+
id: external_exports.string().min(1).max(1024),
|
|
21788
|
+
name: external_exports.string().min(1).max(512),
|
|
21789
|
+
path: external_exports.string().min(1).max(8192)
|
|
21790
|
+
});
|
|
21791
|
+
var peerDelegationHostSummarySchema = external_exports.strictObject({
|
|
21792
|
+
hostId: remotePeerHostIdSchema,
|
|
21793
|
+
nodeId: remotePeerNodeIdSchema.optional(),
|
|
21794
|
+
displayName: external_exports.string().min(1).max(120),
|
|
21795
|
+
online: external_exports.boolean(),
|
|
21796
|
+
state: remotePeerStateSchema,
|
|
21797
|
+
delegation: external_exports.boolean(),
|
|
21798
|
+
projects: external_exports.array(peerDelegationHostProjectSchema),
|
|
21799
|
+
platform: external_exports.string().max(64).optional(),
|
|
21800
|
+
hostname: external_exports.string().max(255).optional(),
|
|
21801
|
+
homeDir: external_exports.string().max(4096).optional()
|
|
21802
|
+
});
|
|
21803
|
+
var peerDelegationHostsResultSchema = external_exports.strictObject({
|
|
21804
|
+
hosts: external_exports.array(peerDelegationHostSummarySchema)
|
|
21805
|
+
});
|
|
21806
|
+
var peerDelegationBridgeDescriptorSchema = external_exports.strictObject({
|
|
21807
|
+
version: external_exports.literal(PEER_DELEGATION_BRIDGE_VERSION),
|
|
21808
|
+
instanceId: external_exports.string().min(1).max(128),
|
|
21809
|
+
pid: external_exports.number().int().positive(),
|
|
21810
|
+
endpoint: external_exports.string().min(1).max(256),
|
|
21811
|
+
token: external_exports.string().regex(/^[0-9a-f]{64}$/u),
|
|
21812
|
+
startedAt: external_exports.number().int().nonnegative()
|
|
21813
|
+
});
|
|
21814
|
+
var peerDelegationBridgeRequestSchema = external_exports.union([
|
|
21815
|
+
external_exports.strictObject({
|
|
21816
|
+
operation: external_exports.literal("hosts")
|
|
21817
|
+
}),
|
|
21818
|
+
external_exports.strictObject({
|
|
21819
|
+
operation: peerDelegationOperationSchema,
|
|
21820
|
+
hostId: remotePeerHostIdSchema,
|
|
21821
|
+
hopCount: external_exports.number().int().min(0).max(16),
|
|
21822
|
+
timeoutMs: external_exports.number().int().min(1).max(12e4).optional(),
|
|
21823
|
+
input: jsonObjectSchema
|
|
21824
|
+
})
|
|
21825
|
+
]);
|
|
21826
|
+
|
|
21403
21827
|
// ../../shared-contracts/dist/credential-imports.js
|
|
21404
21828
|
var credentialSourceSchema = external_exports.object({
|
|
21405
21829
|
id: external_exports.string().min(1).max(256),
|
|
@@ -21990,7 +22414,7 @@ var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status"
|
|
|
21990
22414
|
|
|
21991
22415
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
21992
22416
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
21993
|
-
var
|
|
22417
|
+
var nonBlankTextSchema4 = external_exports.string().trim().min(1);
|
|
21994
22418
|
var codexAccountPlanTypeSchema = external_exports.enum([
|
|
21995
22419
|
"free",
|
|
21996
22420
|
"go",
|
|
@@ -22012,7 +22436,7 @@ var codexAccountPlanTypeSchema = external_exports.enum([
|
|
|
22012
22436
|
]);
|
|
22013
22437
|
var codexAccountSchema = external_exports.object({
|
|
22014
22438
|
accountId: accountIdSchema,
|
|
22015
|
-
label:
|
|
22439
|
+
label: nonBlankTextSchema4.max(256),
|
|
22016
22440
|
email: external_exports.string().email().max(320).optional(),
|
|
22017
22441
|
planType: codexAccountPlanTypeSchema.optional()
|
|
22018
22442
|
}).strict();
|
|
@@ -22022,7 +22446,7 @@ var codexAccountListResultSchema = external_exports.object({
|
|
|
22022
22446
|
currentAccountId: accountIdSchema.nullable(),
|
|
22023
22447
|
phase: codexAccountPhaseSchema,
|
|
22024
22448
|
revision: external_exports.number().int().nonnegative(),
|
|
22025
|
-
instanceId:
|
|
22449
|
+
instanceId: nonBlankTextSchema4.max(1024).optional(),
|
|
22026
22450
|
accounts: external_exports.array(codexAccountSchema).max(1)
|
|
22027
22451
|
}).strict();
|
|
22028
22452
|
var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
@@ -22040,13 +22464,13 @@ var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
|
|
|
22040
22464
|
var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
|
|
22041
22465
|
var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
|
|
22042
22466
|
var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
|
|
22043
|
-
var
|
|
22044
|
-
var harnessSessionImportIdSchema =
|
|
22467
|
+
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");
|
|
22468
|
+
var harnessSessionImportIdSchema = nonBlankTextSchema5.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
|
|
22045
22469
|
var harnessSessionImportCandidateSchema = external_exports.object({
|
|
22046
22470
|
nativeSessionId: harnessSessionImportIdSchema,
|
|
22047
|
-
title:
|
|
22471
|
+
title: nonBlankTextSchema5.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
|
|
22048
22472
|
updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
|
|
22049
|
-
cwd:
|
|
22473
|
+
cwd: nonBlankTextSchema5.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
|
|
22050
22474
|
// Native file discovery cannot reliably observe another process's activity.
|
|
22051
22475
|
running: external_exports.boolean().nullable()
|
|
22052
22476
|
}).strict();
|
|
@@ -22054,7 +22478,7 @@ var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict
|
|
|
22054
22478
|
var harnessSessionImportSourcesResultSchema = external_exports.object({
|
|
22055
22479
|
harnesses: external_exports.array(external_exports.object({
|
|
22056
22480
|
harnessId: harnessPluginIdSchema,
|
|
22057
|
-
name:
|
|
22481
|
+
name: nonBlankTextSchema5.max(128)
|
|
22058
22482
|
}).strict()).max(128)
|
|
22059
22483
|
}).strict();
|
|
22060
22484
|
var harnessSessionListParamsSchema = external_exports.object({
|
|
@@ -22072,13 +22496,13 @@ var harnessSessionImportParamsSchema = external_exports.object({
|
|
|
22072
22496
|
nativeSessionId: harnessSessionImportIdSchema
|
|
22073
22497
|
}).strict();
|
|
22074
22498
|
var harnessSessionImportResultSchema = external_exports.object({
|
|
22075
|
-
threadId:
|
|
22499
|
+
threadId: nonBlankTextSchema5.max(1024).pipe(hostThreadIdSchema)
|
|
22076
22500
|
}).strict();
|
|
22077
22501
|
|
|
22078
22502
|
// ../../shared-contracts/dist/deepseek-modern-sessions.js
|
|
22079
22503
|
var DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH = HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH;
|
|
22080
22504
|
var DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH = 1024;
|
|
22081
|
-
var
|
|
22505
|
+
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
22506
|
var deepSeekModernSessionIdSchema = harnessSessionImportIdSchema;
|
|
22083
22507
|
var deepSeekModernSessionCandidateSchema = harnessSessionImportCandidateSchema;
|
|
22084
22508
|
var deepSeekModernSessionListParamsSchema = external_exports.object({}).strict();
|
|
@@ -22089,7 +22513,7 @@ var deepSeekModernSessionImportParamsSchema = external_exports.object({
|
|
|
22089
22513
|
nativeSessionId: deepSeekModernSessionIdSchema
|
|
22090
22514
|
}).strict();
|
|
22091
22515
|
var deepSeekModernSessionImportResultSchema = external_exports.object({
|
|
22092
|
-
threadId:
|
|
22516
|
+
threadId: nonBlankTextSchema6.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
|
|
22093
22517
|
}).strict();
|
|
22094
22518
|
|
|
22095
22519
|
// ../../shared-contracts/dist/external-thread-fork.js
|
|
@@ -22124,9 +22548,10 @@ var harnessCommandCatalogSchema = external_exports.object({
|
|
|
22124
22548
|
/** Partial discovery failures; valid commands remain available. */
|
|
22125
22549
|
warnings: external_exports.array(external_exports.string().min(1)).optional(),
|
|
22126
22550
|
/**
|
|
22127
|
-
* `live` when
|
|
22128
|
-
* workspace (
|
|
22129
|
-
*
|
|
22551
|
+
* `live` when a native Session has reported its live catalog for the
|
|
22552
|
+
* workspace (even when filtering leaves only built-ins); `static` for
|
|
22553
|
+
* Adapter built-ins only before live commands arrive. Adapters may set
|
|
22554
|
+
* `live` once their Session's live catalog has loaded.
|
|
22130
22555
|
*/
|
|
22131
22556
|
source: external_exports.enum(["live", "static"]).optional()
|
|
22132
22557
|
}).strict().superRefine((catalog, context) => {
|
|
@@ -22258,6 +22683,13 @@ var updatePhaseSchema = external_exports.enum([
|
|
|
22258
22683
|
"succeeded",
|
|
22259
22684
|
"failed"
|
|
22260
22685
|
]);
|
|
22686
|
+
var npmDownloadProgressSchema = external_exports.strictObject({
|
|
22687
|
+
completed: external_exports.number().int().nonnegative(),
|
|
22688
|
+
total: external_exports.number().int().positive()
|
|
22689
|
+
}).refine((progress) => progress.completed <= progress.total, {
|
|
22690
|
+
path: ["completed"],
|
|
22691
|
+
message: "completed must not exceed total"
|
|
22692
|
+
});
|
|
22261
22693
|
var updateStatusSchema = external_exports.strictObject({
|
|
22262
22694
|
version: updateSemanticVersionSchema,
|
|
22263
22695
|
installation: updateInstallationSchema,
|
|
@@ -22265,6 +22697,7 @@ var updateStatusSchema = external_exports.strictObject({
|
|
|
22265
22697
|
updatedAt: external_exports.number().int().nonnegative(),
|
|
22266
22698
|
downloadedBytes: external_exports.number().int().nonnegative().optional(),
|
|
22267
22699
|
totalBytes: external_exports.number().int().positive().optional(),
|
|
22700
|
+
npmDownload: npmDownloadProgressSchema.optional(),
|
|
22268
22701
|
error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable(),
|
|
22269
22702
|
serviceStopOutput: external_exports.string().optional()
|
|
22270
22703
|
}).superRefine((status, context) => {
|
|
@@ -22496,7 +22929,8 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
22496
22929
|
kind: external_exports.literal("start"),
|
|
22497
22930
|
itemId: identity,
|
|
22498
22931
|
onlyIfHead: external_exports.literal(true).optional()
|
|
22499
|
-
})
|
|
22932
|
+
}),
|
|
22933
|
+
external_exports.strictObject({ kind: external_exports.literal("sendNow"), itemId: identity })
|
|
22500
22934
|
])
|
|
22501
22935
|
}),
|
|
22502
22936
|
external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...thread, epoch: identity, turnId: identity }),
|
|
@@ -22611,206 +23045,6 @@ var webUiExtensionInstallSchema = external_exports.object({
|
|
|
22611
23045
|
var webUiExtensionEnabledSchema = external_exports.object({ id: webUiExtensionIdSchema, enabled: external_exports.boolean() }).strict();
|
|
22612
23046
|
var webUiExtensionRemoveSchema = external_exports.object({ id: webUiExtensionIdSchema }).strict();
|
|
22613
23047
|
|
|
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
23048
|
// ../../shared-contracts/dist/index.js
|
|
22815
23049
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
22816
23050
|
|
|
@@ -23316,6 +23550,7 @@ var harnessBrokerMethodSchema = external_exports.enum([
|
|
|
23316
23550
|
"adapter.open",
|
|
23317
23551
|
"adapter.sessionImport.list",
|
|
23318
23552
|
"adapter.sessionImport.resolve",
|
|
23553
|
+
"adapter.readSnapshot",
|
|
23319
23554
|
"adapter.subagent.readSnapshot",
|
|
23320
23555
|
"session.readSnapshot",
|
|
23321
23556
|
"session.readCapabilities",
|
|
@@ -23577,6 +23812,11 @@ var sessionExecuteParamsSchema = sessionParamsSchema.extend({
|
|
|
23577
23812
|
var sessionCommandExecuteParamsSchema = sessionParamsSchema.extend({
|
|
23578
23813
|
command: brokerCommandInvocationSchema
|
|
23579
23814
|
});
|
|
23815
|
+
var adapterReadSnapshotSchema = external_exports.object({
|
|
23816
|
+
nativeRef: nativeSessionRefSchema,
|
|
23817
|
+
cwd: cwdSchema,
|
|
23818
|
+
environment: brokerEnvironmentSchema.optional()
|
|
23819
|
+
}).strict();
|
|
23580
23820
|
var subagentReadSnapshotSchema = external_exports.object({
|
|
23581
23821
|
parent: nativeSessionRefSchema,
|
|
23582
23822
|
nativeSubagentId: external_exports.string().min(1).max(4096),
|
|
@@ -23587,6 +23827,8 @@ var harnessErrorSchema = external_exports.object({
|
|
|
23587
23827
|
"notInstalled",
|
|
23588
23828
|
"unavailable",
|
|
23589
23829
|
"authenticationRequired",
|
|
23830
|
+
"rateLimited",
|
|
23831
|
+
"quotaExhausted",
|
|
23590
23832
|
"sessionNotFound",
|
|
23591
23833
|
"sessionBusy",
|
|
23592
23834
|
"checkpointNotFound",
|
|
@@ -23600,6 +23842,7 @@ var harnessErrorSchema = external_exports.object({
|
|
|
23600
23842
|
]),
|
|
23601
23843
|
message: external_exports.string().max(65536),
|
|
23602
23844
|
retryable: external_exports.boolean(),
|
|
23845
|
+
resetsAt: external_exports.string().min(1).max(128).refine((value) => !Number.isNaN(Date.parse(value)), "resetsAt must be a valid timestamp").optional(),
|
|
23603
23846
|
diagnostic: external_exports.string().max(65536).optional(),
|
|
23604
23847
|
stage: external_exports.string().max(1024).optional(),
|
|
23605
23848
|
durationMs: external_exports.number().finite().nonnegative().optional(),
|
|
@@ -23958,6 +24201,7 @@ function parseHarnessResult(value) {
|
|
|
23958
24201
|
code: parsed.code,
|
|
23959
24202
|
message: parsed.message,
|
|
23960
24203
|
retryable: parsed.retryable,
|
|
24204
|
+
...parsed.resetsAt ? { resetsAt: parsed.resetsAt } : {},
|
|
23961
24205
|
...parsed.diagnostic ? { diagnostic: parsed.diagnostic } : {},
|
|
23962
24206
|
...parsed.stage ? { stage: parsed.stage } : {},
|
|
23963
24207
|
...parsed.durationMs !== void 0 ? { durationMs: parsed.durationMs } : {},
|
|
@@ -24467,6 +24711,17 @@ var BrokeredHarnessAdapter = class {
|
|
|
24467
24711
|
#closed = false;
|
|
24468
24712
|
#credits = null;
|
|
24469
24713
|
#creditsRefresh = null;
|
|
24714
|
+
async readSnapshot(input3) {
|
|
24715
|
+
try {
|
|
24716
|
+
return parseHarnessResult(await this.#request("adapter.readSnapshot", {
|
|
24717
|
+
nativeRef: input3.nativeRef,
|
|
24718
|
+
cwd: input3.cwd,
|
|
24719
|
+
environment: input3.environment
|
|
24720
|
+
}, true));
|
|
24721
|
+
} catch (error63) {
|
|
24722
|
+
return { ok: false, error: this.#error(error63) };
|
|
24723
|
+
}
|
|
24724
|
+
}
|
|
24470
24725
|
subagents = {
|
|
24471
24726
|
readSnapshot: async (input3) => {
|
|
24472
24727
|
try {
|
|
@@ -24753,9 +25008,8 @@ import path3 from "node:path";
|
|
|
24753
25008
|
|
|
24754
25009
|
// ../../harness-adapter/dist/usage-statistics.js
|
|
24755
25010
|
import { createReadStream } from "node:fs";
|
|
24756
|
-
import { lstat as lstat2,
|
|
25011
|
+
import { lstat as lstat2, readdir } from "node:fs/promises";
|
|
24757
25012
|
import path2 from "node:path";
|
|
24758
|
-
import { createInterface } from "node:readline";
|
|
24759
25013
|
var MAX_SESSION_ID_LENGTH = 512;
|
|
24760
25014
|
var MAX_CWD_LENGTH = 4096;
|
|
24761
25015
|
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
@@ -24809,40 +25063,101 @@ function usageEntryFromRequest(request, occurredAtMs) {
|
|
|
24809
25063
|
...request.reasoningOutputTokens !== void 0 ? { reasoningOutputTokens: request.reasoningOutputTokens } : {}
|
|
24810
25064
|
};
|
|
24811
25065
|
}
|
|
25066
|
+
var JSONL_CHUNK_BYTES = 128 * 1024;
|
|
25067
|
+
var JSONL_HEADER_CHUNK_BYTES = 16 * 1024;
|
|
24812
25068
|
async function jsonlUsageSources(root, maxDepth, signal) {
|
|
24813
25069
|
const sources = [];
|
|
24814
25070
|
const visit2 = async (directory, depth) => {
|
|
24815
25071
|
signal.throwIfAborted();
|
|
24816
|
-
const entries = await
|
|
25072
|
+
const entries = await readdir(directory, { withFileTypes: true }).catch((error63) => {
|
|
24817
25073
|
if (error63.code === "ENOENT")
|
|
24818
25074
|
return null;
|
|
24819
25075
|
throw error63;
|
|
24820
25076
|
});
|
|
24821
25077
|
if (!entries)
|
|
24822
25078
|
return;
|
|
24823
|
-
|
|
24824
|
-
|
|
25079
|
+
const subdirectories = [];
|
|
25080
|
+
const files = [];
|
|
25081
|
+
for (const entry of entries) {
|
|
24825
25082
|
const file2 = path2.join(directory, entry.name);
|
|
24826
25083
|
if (entry.isDirectory()) {
|
|
24827
25084
|
if (depth < maxDepth)
|
|
24828
|
-
|
|
25085
|
+
subdirectories.push(file2);
|
|
24829
25086
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
24830
|
-
|
|
24831
|
-
|
|
24832
|
-
|
|
25087
|
+
files.push(file2);
|
|
25088
|
+
}
|
|
25089
|
+
}
|
|
25090
|
+
if (files.length > 0) {
|
|
25091
|
+
const stats = await Promise.all(files.map((file2) => lstat2(file2).catch(() => null)));
|
|
25092
|
+
signal.throwIfAborted();
|
|
25093
|
+
for (let i = 0; i < files.length; i++) {
|
|
25094
|
+
const file2 = files[i];
|
|
25095
|
+
const info = stats[i];
|
|
25096
|
+
if (file2 && info?.isFile() && info.size > 0) {
|
|
25097
|
+
sources.push({
|
|
25098
|
+
id: file2,
|
|
25099
|
+
fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}`
|
|
25100
|
+
});
|
|
24833
25101
|
}
|
|
24834
25102
|
}
|
|
24835
25103
|
}
|
|
25104
|
+
for (const subdirectory of subdirectories)
|
|
25105
|
+
await visit2(subdirectory, depth + 1);
|
|
24836
25106
|
};
|
|
24837
25107
|
await visit2(root, 0);
|
|
24838
25108
|
return sources;
|
|
24839
25109
|
}
|
|
25110
|
+
function concatParts(parts, total) {
|
|
25111
|
+
const [single] = parts;
|
|
25112
|
+
return single && parts.length === 1 ? single : Buffer.concat(parts, total);
|
|
25113
|
+
}
|
|
25114
|
+
async function* jsonlLineSlices(file2, signal, highWaterMark) {
|
|
25115
|
+
const stream = createReadStream(file2, { highWaterMark, signal });
|
|
25116
|
+
let parts = [];
|
|
25117
|
+
let buffered = 0;
|
|
25118
|
+
try {
|
|
25119
|
+
for await (const raw of stream) {
|
|
25120
|
+
signal.throwIfAborted();
|
|
25121
|
+
const chunk = raw;
|
|
25122
|
+
let start = 0;
|
|
25123
|
+
let end;
|
|
25124
|
+
while ((end = chunk.indexOf(10, start)) >= 0) {
|
|
25125
|
+
const lineEnd = end > start && chunk[end - 1] === 13 ? end - 1 : end;
|
|
25126
|
+
const slice = chunk.subarray(start, lineEnd);
|
|
25127
|
+
if (buffered === 0) {
|
|
25128
|
+
yield slice;
|
|
25129
|
+
} else {
|
|
25130
|
+
if (slice.length > 0) {
|
|
25131
|
+
parts.push(slice);
|
|
25132
|
+
buffered += slice.length;
|
|
25133
|
+
}
|
|
25134
|
+
const combined = concatParts(parts, buffered);
|
|
25135
|
+
parts = [];
|
|
25136
|
+
buffered = 0;
|
|
25137
|
+
yield combined.length > 0 && combined[combined.length - 1] === 13 ? combined.subarray(0, combined.length - 1) : combined;
|
|
25138
|
+
}
|
|
25139
|
+
start = end + 1;
|
|
25140
|
+
}
|
|
25141
|
+
if (start < chunk.length) {
|
|
25142
|
+
const rest = chunk.subarray(start);
|
|
25143
|
+
parts.push(rest);
|
|
25144
|
+
buffered += rest.length;
|
|
25145
|
+
}
|
|
25146
|
+
}
|
|
25147
|
+
if (buffered > 0) {
|
|
25148
|
+
const combined = concatParts(parts, buffered);
|
|
25149
|
+
yield combined.length > 0 && combined[combined.length - 1] === 13 ? combined.subarray(0, combined.length - 1) : combined;
|
|
25150
|
+
}
|
|
25151
|
+
} finally {
|
|
25152
|
+
stream.destroy();
|
|
25153
|
+
}
|
|
25154
|
+
}
|
|
24840
25155
|
async function* jsonlRecords(file2, marker, signal) {
|
|
24841
|
-
const
|
|
24842
|
-
|
|
24843
|
-
|
|
24844
|
-
|
|
24845
|
-
|
|
25156
|
+
const markerBytes = marker.length > 0 ? Buffer.from(marker, "utf8") : null;
|
|
25157
|
+
for await (const rawLine of jsonlLineSlices(file2, signal, JSONL_CHUNK_BYTES)) {
|
|
25158
|
+
if (markerBytes && !rawLine.includes(markerBytes))
|
|
25159
|
+
continue;
|
|
25160
|
+
const line = rawLine.toString("utf8");
|
|
24846
25161
|
if (!line.includes(marker))
|
|
24847
25162
|
continue;
|
|
24848
25163
|
let value;
|
|
@@ -24927,25 +25242,63 @@ function createClaudeUsageStatistics(environment) {
|
|
|
24927
25242
|
}
|
|
24928
25243
|
|
|
24929
25244
|
// dist/claude-prompt-cache.js
|
|
24930
|
-
|
|
24931
|
-
|
|
25245
|
+
var CLAUDE_PROMPT_CACHE_5M_TTL_SECONDS = 300;
|
|
25246
|
+
var CLAUDE_PROMPT_CACHE_1H_TTL_SECONDS = 3600;
|
|
25247
|
+
function isRecord4(value) {
|
|
25248
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25249
|
+
}
|
|
25250
|
+
function isPositiveSafeInteger(value) {
|
|
25251
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
25252
|
+
}
|
|
25253
|
+
function claudePromptCacheTtlSeconds(usage) {
|
|
25254
|
+
if (!isRecord4(usage) || !isRecord4(usage.cache_creation))
|
|
25255
|
+
return void 0;
|
|
25256
|
+
const split = usage.cache_creation;
|
|
25257
|
+
if (isPositiveSafeInteger(split.ephemeral_5m_input_tokens)) {
|
|
25258
|
+
return CLAUDE_PROMPT_CACHE_5M_TTL_SECONDS;
|
|
25259
|
+
}
|
|
25260
|
+
if (isPositiveSafeInteger(split.ephemeral_1h_input_tokens)) {
|
|
25261
|
+
return CLAUDE_PROMPT_CACHE_1H_TTL_SECONDS;
|
|
25262
|
+
}
|
|
25263
|
+
return void 0;
|
|
25264
|
+
}
|
|
25265
|
+
function claudePromptCacheFromMessages(messages) {
|
|
25266
|
+
let lastResponseAtUnix;
|
|
25267
|
+
let ttlSeconds;
|
|
25268
|
+
let latestTtlTime;
|
|
24932
25269
|
for (const entry of messages) {
|
|
24933
|
-
if (
|
|
25270
|
+
if (!isRecord4(entry) || entry.type !== "assistant" || entry.isSidechain === true || entry.parent_tool_use_id != null) {
|
|
25271
|
+
continue;
|
|
25272
|
+
}
|
|
25273
|
+
const message = isRecord4(entry.message) ? entry.message : null;
|
|
25274
|
+
if (message?.model === "<synthetic>")
|
|
25275
|
+
continue;
|
|
25276
|
+
if (typeof entry.timestamp !== "string")
|
|
24934
25277
|
continue;
|
|
24935
25278
|
const time3 = Math.floor(Date.parse(entry.timestamp) / 1e3);
|
|
24936
|
-
if (Number.isSafeInteger(time3)
|
|
24937
|
-
|
|
25279
|
+
if (!Number.isSafeInteger(time3) || time3 < 0)
|
|
25280
|
+
continue;
|
|
25281
|
+
lastResponseAtUnix = Math.max(lastResponseAtUnix ?? 0, time3);
|
|
25282
|
+
const entryTtl = claudePromptCacheTtlSeconds(message?.usage);
|
|
25283
|
+
if (entryTtl !== void 0 && (latestTtlTime === void 0 || time3 >= latestTtlTime)) {
|
|
25284
|
+
ttlSeconds = entryTtl;
|
|
25285
|
+
latestTtlTime = time3;
|
|
25286
|
+
}
|
|
24938
25287
|
}
|
|
24939
|
-
return
|
|
25288
|
+
return {
|
|
25289
|
+
...lastResponseAtUnix !== void 0 ? { lastResponseAtUnix } : {},
|
|
25290
|
+
...ttlSeconds !== void 0 ? { ttlSeconds } : {}
|
|
25291
|
+
};
|
|
24940
25292
|
}
|
|
24941
|
-
function claudePromptCacheIndicators(accountCreditsSupported, lastResponseAtUnix) {
|
|
24942
|
-
if (!accountCreditsSupported || lastResponseAtUnix === void 0)
|
|
25293
|
+
function claudePromptCacheIndicators(accountCreditsSupported, lastResponseAtUnix, ttlSeconds) {
|
|
25294
|
+
if (!accountCreditsSupported || lastResponseAtUnix === void 0 || ttlSeconds === void 0) {
|
|
24943
25295
|
return [];
|
|
25296
|
+
}
|
|
24944
25297
|
return [
|
|
24945
25298
|
{
|
|
24946
25299
|
kind: "countdown",
|
|
24947
25300
|
id: "prompt-cache",
|
|
24948
|
-
expiresAtUnix: lastResponseAtUnix +
|
|
25301
|
+
expiresAtUnix: lastResponseAtUnix + ttlSeconds,
|
|
24949
25302
|
label: { en: "Prompt cache", "zh-CN": "提示词缓存" }
|
|
24950
25303
|
}
|
|
24951
25304
|
];
|
|
@@ -60601,7 +60954,7 @@ var ClaudeUltracodeUnavailableError = class extends Error {
|
|
|
60601
60954
|
function claudeUltracodeFailure(error63) {
|
|
60602
60955
|
return { ...FAILURES[error63.reason] };
|
|
60603
60956
|
}
|
|
60604
|
-
function
|
|
60957
|
+
function isRecord5(value) {
|
|
60605
60958
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
60606
60959
|
}
|
|
60607
60960
|
function environmentFlag(value) {
|
|
@@ -60615,7 +60968,7 @@ function environmentFlag(value) {
|
|
|
60615
60968
|
return void 0;
|
|
60616
60969
|
}
|
|
60617
60970
|
function workflowsSwitch(settings, environment) {
|
|
60618
|
-
const setting =
|
|
60971
|
+
const setting = isRecord5(settings.effective) ? settings.effective.enableWorkflows : void 0;
|
|
60619
60972
|
const enabledByEnvironment = environmentFlag(environment.CLAUDE_CODE_WORKFLOWS);
|
|
60620
60973
|
if (setting === false || enabledByEnvironment === false || environmentFlag(environment.CLAUDE_CODE_DISABLE_WORKFLOWS) === true) {
|
|
60621
60974
|
return "off";
|
|
@@ -60623,13 +60976,13 @@ function workflowsSwitch(settings, environment) {
|
|
|
60623
60976
|
return setting === true || enabledByEnvironment === true ? "on" : "unknown";
|
|
60624
60977
|
}
|
|
60625
60978
|
function claudeUltracodeActive(settings) {
|
|
60626
|
-
if (!
|
|
60979
|
+
if (!isRecord5(settings) || !isRecord5(settings.applied)) {
|
|
60627
60980
|
throw new ClaudeUltracodeUnavailableError("unverifiable");
|
|
60628
60981
|
}
|
|
60629
60982
|
return settings.applied.ultracode === true;
|
|
60630
60983
|
}
|
|
60631
60984
|
function claudeUltracodeUnavailableReason(settings, environment = {}) {
|
|
60632
|
-
if (!
|
|
60985
|
+
if (!isRecord5(settings) || !isRecord5(settings.applied))
|
|
60633
60986
|
return "unverifiable";
|
|
60634
60987
|
const applied = settings.applied;
|
|
60635
60988
|
if (typeof applied.ultracode !== "boolean")
|
|
@@ -60646,10 +60999,10 @@ function claudeUltracodeUnavailableReason(settings, environment = {}) {
|
|
|
60646
60999
|
|
|
60647
61000
|
// dist/claude-session-import.js
|
|
60648
61001
|
import { createReadStream as createReadStream3 } from "node:fs";
|
|
60649
|
-
import { opendir
|
|
61002
|
+
import { opendir, realpath as realpath3, stat as stat2 } from "node:fs/promises";
|
|
60650
61003
|
import os3 from "node:os";
|
|
60651
61004
|
import path4 from "node:path";
|
|
60652
|
-
import { createInterface as
|
|
61005
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
60653
61006
|
|
|
60654
61007
|
// ../../harness-adapter/dist/session-import.js
|
|
60655
61008
|
var SessionImportChangedError = class extends Error {
|
|
@@ -60748,17 +61101,17 @@ var SessionImportScope = class {
|
|
|
60748
61101
|
var CLAUDE_SESSION_IMPORT_TITLE_MAX_LENGTH = 120;
|
|
60749
61102
|
var CLAUDE_INTERNAL_USER_TEXT = /^<(?:local-command-|command-)/u;
|
|
60750
61103
|
var CLAUDE_SESSION_CHANGED = "Claude Code Session changed during discovery; refresh and retry";
|
|
60751
|
-
function
|
|
61104
|
+
function isRecord6(value) {
|
|
60752
61105
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
60753
61106
|
}
|
|
60754
61107
|
function cleanText(value) {
|
|
60755
61108
|
return sessionImportTitle(value, CLAUDE_SESSION_IMPORT_TITLE_MAX_LENGTH);
|
|
60756
61109
|
}
|
|
60757
61110
|
function userText(message) {
|
|
60758
|
-
if (!
|
|
61111
|
+
if (!isRecord6(message) || message.role !== "user")
|
|
60759
61112
|
return null;
|
|
60760
61113
|
const { content } = message;
|
|
60761
|
-
const text3 = typeof content === "string" ? cleanText(content) : Array.isArray(content) ? cleanText(content.filter((block) =>
|
|
61114
|
+
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
61115
|
return text3 && !CLAUDE_INTERNAL_USER_TEXT.test(text3) ? text3 : null;
|
|
60763
61116
|
}
|
|
60764
61117
|
function claudeProjectsDirectory2(environment) {
|
|
@@ -60767,7 +61120,7 @@ function claudeProjectsDirectory2(environment) {
|
|
|
60767
61120
|
}
|
|
60768
61121
|
async function sessionFiles(directory, signal) {
|
|
60769
61122
|
signal.throwIfAborted();
|
|
60770
|
-
const projects = await
|
|
61123
|
+
const projects = await opendir(directory).catch((error63) => {
|
|
60771
61124
|
if (isMissingFileError(error63))
|
|
60772
61125
|
return null;
|
|
60773
61126
|
throw error63;
|
|
@@ -60779,7 +61132,7 @@ async function sessionFiles(directory, signal) {
|
|
|
60779
61132
|
signal.throwIfAborted();
|
|
60780
61133
|
if (!project2.isDirectory())
|
|
60781
61134
|
continue;
|
|
60782
|
-
const entries = await
|
|
61135
|
+
const entries = await opendir(path4.join(directory, project2.name)).catch((error63) => {
|
|
60783
61136
|
if (isMissingFileError(error63))
|
|
60784
61137
|
return null;
|
|
60785
61138
|
throw error63;
|
|
@@ -60803,7 +61156,7 @@ async function readCandidate(file2, signal) {
|
|
|
60803
61156
|
if (!before.isFile() || before.size === 0)
|
|
60804
61157
|
return null;
|
|
60805
61158
|
const stream = createReadStream3(file2, { encoding: "utf8", signal, end: before.size - 1 });
|
|
60806
|
-
const lines =
|
|
61159
|
+
const lines = createInterface2({ input: stream, crlfDelay: Infinity });
|
|
60807
61160
|
let cwd = null;
|
|
60808
61161
|
let customTitle = null;
|
|
60809
61162
|
let generatedTitle = null;
|
|
@@ -60820,7 +61173,7 @@ async function readCandidate(file2, signal) {
|
|
|
60820
61173
|
} catch {
|
|
60821
61174
|
continue;
|
|
60822
61175
|
}
|
|
60823
|
-
if (!
|
|
61176
|
+
if (!isRecord6(entry))
|
|
60824
61177
|
continue;
|
|
60825
61178
|
if (typeof entry.sessionId === "string" && entry.sessionId !== nativeSessionId)
|
|
60826
61179
|
return null;
|
|
@@ -61296,7 +61649,18 @@ function referencesNpmBin(shim, name, bin) {
|
|
|
61296
61649
|
const text3 = shim.replaceAll("\\", "/").toLowerCase();
|
|
61297
61650
|
return text3.includes(`%dp0%/${target2}"`) || text3.includes(`%~dp0/${target2}"`);
|
|
61298
61651
|
}
|
|
61299
|
-
|
|
61652
|
+
function withAllowedScripts(environment, allowScripts) {
|
|
61653
|
+
if (!allowScripts)
|
|
61654
|
+
return environment;
|
|
61655
|
+
const existing = environment.npm_config_allow_scripts?.trim();
|
|
61656
|
+
if (!existing)
|
|
61657
|
+
return { ...environment, npm_config_allow_scripts: allowScripts };
|
|
61658
|
+
const entries = existing.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
61659
|
+
if (entries.includes(allowScripts))
|
|
61660
|
+
return environment;
|
|
61661
|
+
return { ...environment, npm_config_allow_scripts: [...entries, allowScripts].join(",") };
|
|
61662
|
+
}
|
|
61663
|
+
async function npmInstallation(command, packages, environment, options = {}) {
|
|
61300
61664
|
let selected = await realpath4(command);
|
|
61301
61665
|
if (process.platform === "win32" && /\.(cmd|bat)$/i.test(selected)) {
|
|
61302
61666
|
const shim = (await readFile3(selected, "utf8")).replaceAll("\\", "/");
|
|
@@ -61318,6 +61682,7 @@ async function npmInstallation(command, packages, environment) {
|
|
|
61318
61682
|
if (metadata?.name && packages.includes(metadata.name)) {
|
|
61319
61683
|
const name = metadata.name;
|
|
61320
61684
|
const currentVersion = installationVersion(metadata.version);
|
|
61685
|
+
const tracked = options.successor && options.successor !== name ? options.successor : name;
|
|
61321
61686
|
const segments = name.split("/");
|
|
61322
61687
|
let modules = directory;
|
|
61323
61688
|
for (let index = 0; index < segments.length; index++)
|
|
@@ -61347,13 +61712,23 @@ async function npmInstallation(command, packages, environment) {
|
|
|
61347
61712
|
currentVersion,
|
|
61348
61713
|
canUpdate,
|
|
61349
61714
|
latest: async () => {
|
|
61350
|
-
const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(
|
|
61715
|
+
const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(tracked)}/latest`));
|
|
61351
61716
|
return installationVersion(data.version);
|
|
61352
61717
|
},
|
|
61353
61718
|
update: async (version2) => {
|
|
61354
61719
|
if (!canUpdate || !npm)
|
|
61355
61720
|
throw new Error("Use the original package manager to update this installation");
|
|
61356
|
-
|
|
61721
|
+
const targetVersion = installationVersion(version2);
|
|
61722
|
+
const migrating = tracked !== name;
|
|
61723
|
+
if (migrating)
|
|
61724
|
+
await runInstallationCommand(npm.executable, ["uninstall", "--global", "--prefix", prefix, name], env, 3e5);
|
|
61725
|
+
try {
|
|
61726
|
+
await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${tracked}@${targetVersion}`], withAllowedScripts(env, options.allowScripts), 3e5);
|
|
61727
|
+
} catch (error63) {
|
|
61728
|
+
if (migrating)
|
|
61729
|
+
await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${name}@${currentVersion}`], env, 3e5).catch(() => void 0);
|
|
61730
|
+
throw error63;
|
|
61731
|
+
}
|
|
61357
61732
|
}
|
|
61358
61733
|
};
|
|
61359
61734
|
}
|
|
@@ -61608,7 +61983,7 @@ var hunkSchema = external_exports.object({
|
|
|
61608
61983
|
newLines: external_exports.number().int().nonnegative(),
|
|
61609
61984
|
lines: external_exports.array(external_exports.string())
|
|
61610
61985
|
}).strict();
|
|
61611
|
-
function
|
|
61986
|
+
function isRecord7(value) {
|
|
61612
61987
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61613
61988
|
}
|
|
61614
61989
|
function validNativePath(value) {
|
|
@@ -61632,7 +62007,7 @@ function validHunk(value) {
|
|
|
61632
62007
|
return hunk;
|
|
61633
62008
|
}
|
|
61634
62009
|
function parseClaudeNativeFileChange(toolName, value) {
|
|
61635
|
-
if (toolName !== "Edit" && toolName !== "Write" || !
|
|
62010
|
+
if (toolName !== "Edit" && toolName !== "Write" || !isRecord7(value))
|
|
61636
62011
|
return null;
|
|
61637
62012
|
if (!validNativePath(value.filePath) || !Array.isArray(value.structuredPatch))
|
|
61638
62013
|
return null;
|
|
@@ -61770,11 +62145,11 @@ function isClaudeNarrationSignature(signature) {
|
|
|
61770
62145
|
}
|
|
61771
62146
|
|
|
61772
62147
|
// dist/task-tracker.js
|
|
61773
|
-
function
|
|
62148
|
+
function isRecord8(value) {
|
|
61774
62149
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61775
62150
|
}
|
|
61776
62151
|
function stringField(value, keys) {
|
|
61777
|
-
if (!
|
|
62152
|
+
if (!isRecord8(value))
|
|
61778
62153
|
return void 0;
|
|
61779
62154
|
for (const key of keys) {
|
|
61780
62155
|
const field2 = value[key];
|
|
@@ -61817,7 +62192,7 @@ var ClaudeTaskTracker = class {
|
|
|
61817
62192
|
};
|
|
61818
62193
|
}
|
|
61819
62194
|
#create(args, result) {
|
|
61820
|
-
if (!
|
|
62195
|
+
if (!isRecord8(result) || !isRecord8(result.task))
|
|
61821
62196
|
return;
|
|
61822
62197
|
const id3 = stringField(result.task, ["id"]);
|
|
61823
62198
|
const subject = stringField(args, ["subject"]) ?? stringField(result.task, ["subject"]);
|
|
@@ -61835,7 +62210,7 @@ var ClaudeTaskTracker = class {
|
|
|
61835
62210
|
const id3 = stringField(args, ["taskId", "id", "task_id"]);
|
|
61836
62211
|
if (!id3)
|
|
61837
62212
|
return;
|
|
61838
|
-
const status =
|
|
62213
|
+
const status = isRecord8(args) ? taskStatus(args.status) : void 0;
|
|
61839
62214
|
if (status === "deleted") {
|
|
61840
62215
|
this.#tasks.delete(id3);
|
|
61841
62216
|
return;
|
|
@@ -61854,7 +62229,7 @@ var ClaudeTaskTracker = class {
|
|
|
61854
62229
|
}
|
|
61855
62230
|
/** A read of one task is authoritative for that task, as TaskList is for all of them. */
|
|
61856
62231
|
#refresh(args, result) {
|
|
61857
|
-
if (!
|
|
62232
|
+
if (!isRecord8(result) || !("task" in result))
|
|
61858
62233
|
return;
|
|
61859
62234
|
if (result.task === null) {
|
|
61860
62235
|
const id4 = stringField(args, ["taskId", "id", "task_id"]);
|
|
@@ -61864,20 +62239,20 @@ var ClaudeTaskTracker = class {
|
|
|
61864
62239
|
}
|
|
61865
62240
|
const id3 = stringField(result.task, ["id"]);
|
|
61866
62241
|
const subject = stringField(result.task, ["subject"]);
|
|
61867
|
-
const status =
|
|
62242
|
+
const status = isRecord8(result.task) ? taskStatus(result.task.status) : void 0;
|
|
61868
62243
|
if (!id3 || !subject || !status || status === "deleted")
|
|
61869
62244
|
return;
|
|
61870
62245
|
const activeForm = this.#tasks.get(id3)?.activeForm;
|
|
61871
62246
|
this.#tasks.set(id3, { id: id3, subject, ...activeForm ? { activeForm } : {}, status });
|
|
61872
62247
|
}
|
|
61873
62248
|
#replace(result) {
|
|
61874
|
-
if (!
|
|
62249
|
+
if (!isRecord8(result) || !Array.isArray(result.tasks))
|
|
61875
62250
|
return;
|
|
61876
62251
|
const next = /* @__PURE__ */ new Map();
|
|
61877
62252
|
for (const value of result.tasks) {
|
|
61878
62253
|
const id3 = stringField(value, ["id"]);
|
|
61879
62254
|
const subject = stringField(value, ["subject"]);
|
|
61880
|
-
const status =
|
|
62255
|
+
const status = isRecord8(value) ? taskStatus(value.status) : void 0;
|
|
61881
62256
|
if (!id3 || !subject || !status || status === "deleted")
|
|
61882
62257
|
continue;
|
|
61883
62258
|
const existing = this.#tasks.get(id3);
|
|
@@ -61897,13 +62272,14 @@ var ClaudeTaskTracker = class {
|
|
|
61897
62272
|
// dist/native-message.js
|
|
61898
62273
|
var ABORTED_TERMINALS = /* @__PURE__ */ new Set(["aborted_streaming", "aborted_tools"]);
|
|
61899
62274
|
var AUTHENTICATION_ERRORS = /* @__PURE__ */ new Set(["authentication_failed", "oauth_org_not_allowed"]);
|
|
62275
|
+
var MAX_SAFE_UNIX_SECONDS = 864e10;
|
|
61900
62276
|
var CLAUDE_SUBAGENT_TOOLS = /* @__PURE__ */ new Set(["Agent", "Task", "SendMessage"]);
|
|
61901
62277
|
var CLAUDE_WORKFLOW_TOOL = "Workflow";
|
|
61902
62278
|
var BACKGROUND_OUTPUT_FILE_PATTERN = /Output is being written to: (.+?\.output)\./u;
|
|
61903
62279
|
var SUBAGENT_DESCRIPTION_LIMIT = 500;
|
|
61904
62280
|
var SUBAGENT_SUMMARY_LIMIT = 2e3;
|
|
61905
62281
|
var WORKFLOW_PROGRESS_ENTRY_LIMIT = 500;
|
|
61906
|
-
function
|
|
62282
|
+
function isRecord9(value) {
|
|
61907
62283
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
61908
62284
|
}
|
|
61909
62285
|
function nativeUuid(message) {
|
|
@@ -61913,12 +62289,12 @@ function parentToolUseId(message) {
|
|
|
61913
62289
|
return typeof message.parent_tool_use_id === "string" && message.parent_tool_use_id.length > 0 ? message.parent_tool_use_id : null;
|
|
61914
62290
|
}
|
|
61915
62291
|
function assistantNativeMessageId(message) {
|
|
61916
|
-
if (!
|
|
62292
|
+
if (!isRecord9(message.message))
|
|
61917
62293
|
return null;
|
|
61918
62294
|
return typeof message.message.id === "string" && message.message.id.length > 0 ? message.message.id : null;
|
|
61919
62295
|
}
|
|
61920
62296
|
function assistantContent(message) {
|
|
61921
|
-
if (message.type !== "assistant" || !
|
|
62297
|
+
if (message.type !== "assistant" || !isRecord9(message.message))
|
|
61922
62298
|
return null;
|
|
61923
62299
|
return Array.isArray(message.message.content) ? message.message.content : null;
|
|
61924
62300
|
}
|
|
@@ -61926,10 +62302,10 @@ function assistantText(message) {
|
|
|
61926
62302
|
const content = assistantContent(message);
|
|
61927
62303
|
if (!content)
|
|
61928
62304
|
return null;
|
|
61929
|
-
return content.flatMap((block) =>
|
|
62305
|
+
return content.flatMap((block) => isRecord9(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
|
|
61930
62306
|
}
|
|
61931
62307
|
function assistantError(message) {
|
|
61932
|
-
return
|
|
62308
|
+
return isRecord9(message) && message.type === "assistant" && typeof message.error === "string" ? message.error : null;
|
|
61933
62309
|
}
|
|
61934
62310
|
function boundedString(value, limit) {
|
|
61935
62311
|
if (typeof value !== "string")
|
|
@@ -61940,25 +62316,25 @@ function boundedString(value, limit) {
|
|
|
61940
62316
|
return trimmed.slice(0, limit);
|
|
61941
62317
|
}
|
|
61942
62318
|
function subagentDescription(argumentsValue, toolName) {
|
|
61943
|
-
if (!
|
|
62319
|
+
if (!isRecord9(argumentsValue))
|
|
61944
62320
|
return `${toolName} delegation`;
|
|
61945
62321
|
return boundedString(argumentsValue.description, SUBAGENT_DESCRIPTION_LIMIT) ?? boundedString(argumentsValue.summary, SUBAGENT_DESCRIPTION_LIMIT) ?? boundedString(argumentsValue.name, SUBAGENT_DESCRIPTION_LIMIT) ?? `${toolName} delegation`;
|
|
61946
62322
|
}
|
|
61947
62323
|
function subagentPrompt(argumentsValue) {
|
|
61948
|
-
if (!
|
|
62324
|
+
if (!isRecord9(argumentsValue))
|
|
61949
62325
|
return void 0;
|
|
61950
62326
|
return boundedString(argumentsValue.prompt ?? argumentsValue.message, SUBAGENT_SUMMARY_LIMIT);
|
|
61951
62327
|
}
|
|
61952
62328
|
function subagentRole(argumentsValue) {
|
|
61953
|
-
if (!
|
|
62329
|
+
if (!isRecord9(argumentsValue))
|
|
61954
62330
|
return void 0;
|
|
61955
62331
|
return boundedString(argumentsValue.subagent_type ?? argumentsValue.agent_type, SUBAGENT_DESCRIPTION_LIMIT);
|
|
61956
62332
|
}
|
|
61957
62333
|
function subagentBackground(argumentsValue) {
|
|
61958
|
-
return
|
|
62334
|
+
return isRecord9(argumentsValue) && argumentsValue.run_in_background === true;
|
|
61959
62335
|
}
|
|
61960
62336
|
function targetedSubagentId(argumentsValue) {
|
|
61961
|
-
if (!
|
|
62337
|
+
if (!isRecord9(argumentsValue))
|
|
61962
62338
|
return void 0;
|
|
61963
62339
|
return boundedString(argumentsValue.to ?? argumentsValue.recipient ?? argumentsValue.agentId, SUBAGENT_DESCRIPTION_LIMIT);
|
|
61964
62340
|
}
|
|
@@ -61967,19 +62343,38 @@ function sendResultFromText(outputText) {
|
|
|
61967
62343
|
return void 0;
|
|
61968
62344
|
try {
|
|
61969
62345
|
const parsed = JSON.parse(outputText);
|
|
61970
|
-
return
|
|
62346
|
+
return isRecord9(parsed) ? parsed : void 0;
|
|
61971
62347
|
} catch {
|
|
61972
62348
|
return void 0;
|
|
61973
62349
|
}
|
|
61974
62350
|
}
|
|
61975
62351
|
function claudeSendMessageFailed(nativeResult, outputText) {
|
|
61976
|
-
return
|
|
62352
|
+
return isRecord9(nativeResult) && typeof nativeResult.success === "boolean" ? !nativeResult.success : sendResultFromText(outputText)?.success === false;
|
|
61977
62353
|
}
|
|
61978
62354
|
function includesAuthenticationFailure(errors) {
|
|
61979
62355
|
return errors.some((error63) => AUTHENTICATION_ERRORS.has(error63));
|
|
61980
62356
|
}
|
|
61981
|
-
function failure2(kind) {
|
|
61982
|
-
return {
|
|
62357
|
+
function failure2(kind, resetsAtUnix) {
|
|
62358
|
+
return {
|
|
62359
|
+
status: "failed",
|
|
62360
|
+
kind,
|
|
62361
|
+
...resetsAtUnix !== void 0 ? { resetsAtUnix } : {}
|
|
62362
|
+
};
|
|
62363
|
+
}
|
|
62364
|
+
function validResetsAtUnix(value) {
|
|
62365
|
+
return safeNonNegativeInteger(value) && value > 0 && value <= MAX_SAFE_UNIX_SECONDS ? value : void 0;
|
|
62366
|
+
}
|
|
62367
|
+
function isOverageCoveringRateLimit(info) {
|
|
62368
|
+
return info.isUsingOverage === true || info.overageInUse === true || info.overageStatus === "allowed" || info.overageStatus === "allowed_warning";
|
|
62369
|
+
}
|
|
62370
|
+
function rejectedRateLimitResetUnix(info) {
|
|
62371
|
+
const primary = validResetsAtUnix(info.resetsAt);
|
|
62372
|
+
const overage = info.overageStatus === "rejected" ? validResetsAtUnix(info.overageResetsAt) : void 0;
|
|
62373
|
+
if (info.rateLimitType === "overage")
|
|
62374
|
+
return overage ?? primary;
|
|
62375
|
+
if (primary !== void 0 && overage !== void 0)
|
|
62376
|
+
return Math.min(primary, overage);
|
|
62377
|
+
return primary ?? overage;
|
|
61983
62378
|
}
|
|
61984
62379
|
function safeNonNegativeInteger(value) {
|
|
61985
62380
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
@@ -61988,11 +62383,11 @@ function finiteNonNegativeNumber(value) {
|
|
|
61988
62383
|
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
61989
62384
|
}
|
|
61990
62385
|
function parseResultModelUsage(value) {
|
|
61991
|
-
if (!
|
|
62386
|
+
if (!isRecord9(value))
|
|
61992
62387
|
return void 0;
|
|
61993
62388
|
const usage = [];
|
|
61994
62389
|
for (const [model2, entry] of Object.entries(value)) {
|
|
61995
|
-
if (!
|
|
62390
|
+
if (!isRecord9(entry) || !safeNonNegativeInteger(entry.inputTokens) || !safeNonNegativeInteger(entry.outputTokens)) {
|
|
61996
62391
|
return void 0;
|
|
61997
62392
|
}
|
|
61998
62393
|
const cacheRead = safeNonNegativeInteger(entry.cacheReadInputTokens) ? entry.cacheReadInputTokens : 0;
|
|
@@ -62009,7 +62404,7 @@ function parseResultModelUsage(value) {
|
|
|
62009
62404
|
return usage;
|
|
62010
62405
|
}
|
|
62011
62406
|
function parseLastRequestUsage(value, attribution = {}) {
|
|
62012
|
-
if (!
|
|
62407
|
+
if (!isRecord9(value))
|
|
62013
62408
|
return void 0;
|
|
62014
62409
|
const inputTokens = value.input_tokens;
|
|
62015
62410
|
const outputTokens = value.output_tokens;
|
|
@@ -62021,6 +62416,7 @@ function parseLastRequestUsage(value, attribution = {}) {
|
|
|
62021
62416
|
const requestId = boundedString(attribution.requestId, 500);
|
|
62022
62417
|
const model2 = boundedString(attribution.model, 500);
|
|
62023
62418
|
const provider = boundedString(attribution.provider, 100);
|
|
62419
|
+
const promptCacheTtlSeconds = claudePromptCacheTtlSeconds(value);
|
|
62024
62420
|
return {
|
|
62025
62421
|
...requestId ? { requestId } : {},
|
|
62026
62422
|
...model2 ? { model: model2 } : {},
|
|
@@ -62028,11 +62424,12 @@ function parseLastRequestUsage(value, attribution = {}) {
|
|
|
62028
62424
|
inputTokens,
|
|
62029
62425
|
outputTokens,
|
|
62030
62426
|
cacheCreationInputTokens,
|
|
62031
|
-
cacheReadInputTokens
|
|
62427
|
+
cacheReadInputTokens,
|
|
62428
|
+
...promptCacheTtlSeconds !== void 0 ? { promptCacheTtlSeconds } : {}
|
|
62032
62429
|
};
|
|
62033
62430
|
}
|
|
62034
62431
|
function assistantRequestUsage(message, provider) {
|
|
62035
|
-
if (!
|
|
62432
|
+
if (!isRecord9(message.message))
|
|
62036
62433
|
return void 0;
|
|
62037
62434
|
return parseLastRequestUsage(message.message.usage, {
|
|
62038
62435
|
requestId: message.message.id ?? message.request_id,
|
|
@@ -62055,7 +62452,7 @@ function parseResultUsageEvent(message) {
|
|
|
62055
62452
|
};
|
|
62056
62453
|
}
|
|
62057
62454
|
function parsePlanLimitWindow(value) {
|
|
62058
|
-
if (!
|
|
62455
|
+
if (!isRecord9(value))
|
|
62059
62456
|
return void 0;
|
|
62060
62457
|
const utilization = value.utilization;
|
|
62061
62458
|
if (typeof utilization !== "number" || !Number.isFinite(utilization) || utilization < 0) {
|
|
@@ -62067,12 +62464,12 @@ function parsePlanLimitWindow(value) {
|
|
|
62067
62464
|
return { utilizationPercent, ...resetsAtUnix !== void 0 ? { resetsAtUnix } : {} };
|
|
62068
62465
|
}
|
|
62069
62466
|
function parseClaudePlanLimitEvent(message) {
|
|
62070
|
-
if (!
|
|
62467
|
+
if (!isRecord9(message) || message.type !== "rate_limit_event")
|
|
62071
62468
|
return null;
|
|
62072
62469
|
const info = message.rate_limit_info;
|
|
62073
|
-
if (!
|
|
62470
|
+
if (!isRecord9(info))
|
|
62074
62471
|
return null;
|
|
62075
|
-
const windows =
|
|
62472
|
+
const windows = isRecord9(info.unifiedWindows) ? info.unifiedWindows : void 0;
|
|
62076
62473
|
let fiveHour = parsePlanLimitWindow(windows?.five_hour);
|
|
62077
62474
|
let sevenDay = parsePlanLimitWindow(windows?.seven_day);
|
|
62078
62475
|
if (!fiveHour && !sevenDay) {
|
|
@@ -62090,15 +62487,15 @@ function parseClaudePlanLimitEvent(message) {
|
|
|
62090
62487
|
};
|
|
62091
62488
|
}
|
|
62092
62489
|
function nativeSubagentId(nativeResult, outputText) {
|
|
62093
|
-
if (
|
|
62094
|
-
const structured = boundedString(nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id ?? nativeResult.resumedAgentId ?? nativeResult.revivedAgentId ?? (
|
|
62490
|
+
if (isRecord9(nativeResult)) {
|
|
62491
|
+
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
62492
|
if (structured)
|
|
62096
62493
|
return structured;
|
|
62097
62494
|
}
|
|
62098
62495
|
return boundedString(/agentId:\s*([A-Za-z0-9_-]+)/u.exec(outputText ?? "")?.[1], SUBAGENT_DESCRIPTION_LIMIT);
|
|
62099
62496
|
}
|
|
62100
62497
|
function subagentContinuesInBackground(nativeResult, outputText) {
|
|
62101
|
-
if (
|
|
62498
|
+
if (isRecord9(nativeResult)) {
|
|
62102
62499
|
if (nativeResult.isAsync === true || nativeResult.is_async === true)
|
|
62103
62500
|
return true;
|
|
62104
62501
|
if (nativeResult.status === "async_launched")
|
|
@@ -62111,11 +62508,11 @@ function resultText(content, nativeResult) {
|
|
|
62111
62508
|
if (typeof content === "string") {
|
|
62112
62509
|
text3 = content;
|
|
62113
62510
|
} else if (Array.isArray(content)) {
|
|
62114
|
-
text3 = content.flatMap((block) =>
|
|
62511
|
+
text3 = content.flatMap((block) => isRecord9(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
|
|
62115
62512
|
}
|
|
62116
62513
|
if (text3.length > 0)
|
|
62117
62514
|
return text3;
|
|
62118
|
-
if (!
|
|
62515
|
+
if (!isRecord9(nativeResult))
|
|
62119
62516
|
return void 0;
|
|
62120
62517
|
const stdout = typeof nativeResult.stdout === "string" ? nativeResult.stdout : "";
|
|
62121
62518
|
const stderr = typeof nativeResult.stderr === "string" ? nativeResult.stderr : "";
|
|
@@ -62127,13 +62524,13 @@ function userMessageText(content) {
|
|
|
62127
62524
|
return content;
|
|
62128
62525
|
if (!Array.isArray(content))
|
|
62129
62526
|
return null;
|
|
62130
|
-
const text3 = content.flatMap((block) =>
|
|
62527
|
+
const text3 = content.flatMap((block) => isRecord9(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("");
|
|
62131
62528
|
return text3.length > 0 ? text3 : null;
|
|
62132
62529
|
}
|
|
62133
62530
|
function parseClaudeTaskNotification(message) {
|
|
62134
|
-
if (!
|
|
62531
|
+
if (!isRecord9(message) || message.type !== "user" || !isRecord9(message.message))
|
|
62135
62532
|
return null;
|
|
62136
|
-
if (
|
|
62533
|
+
if (isRecord9(message.origin) && message.origin.kind !== "task-notification")
|
|
62137
62534
|
return null;
|
|
62138
62535
|
const content = userMessageText(message.message.content);
|
|
62139
62536
|
if (!content || !content.includes("<task-notification>"))
|
|
@@ -62193,7 +62590,7 @@ function parseClaudeWorkflowAgents(value) {
|
|
|
62193
62590
|
return null;
|
|
62194
62591
|
const agents = [];
|
|
62195
62592
|
for (const entry of value.slice(0, WORKFLOW_PROGRESS_ENTRY_LIMIT)) {
|
|
62196
|
-
if (!
|
|
62593
|
+
if (!isRecord9(entry) || entry.type !== "workflow_agent")
|
|
62197
62594
|
continue;
|
|
62198
62595
|
const index = entry.index;
|
|
62199
62596
|
const state = workflowAgentState(entry);
|
|
@@ -62226,6 +62623,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62226
62623
|
/** Native record UUIDs already published, across stream and request message IDs. */
|
|
62227
62624
|
#publishedCheckpointIds = /* @__PURE__ */ new Set();
|
|
62228
62625
|
#assistantErrors = [];
|
|
62626
|
+
#rejectedRateLimit = null;
|
|
62229
62627
|
#cancelRequested = false;
|
|
62230
62628
|
#compactionState = "idle";
|
|
62231
62629
|
#completed = false;
|
|
@@ -62235,6 +62633,8 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62235
62633
|
#completedThinkingBlocks = /* @__PURE__ */ new Set();
|
|
62236
62634
|
#protocolConflict = false;
|
|
62237
62635
|
#textConflict = false;
|
|
62636
|
+
/** Fallback notices already published, keyed by request id (or model pair). */
|
|
62637
|
+
#fallbackNoticeKeys = /* @__PURE__ */ new Set();
|
|
62238
62638
|
#tools = /* @__PURE__ */ new Map();
|
|
62239
62639
|
constructor(options = {}) {
|
|
62240
62640
|
this.#provider = options.provider;
|
|
@@ -62245,7 +62645,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62245
62645
|
}
|
|
62246
62646
|
#usageRequest = null;
|
|
62247
62647
|
consume(message) {
|
|
62248
|
-
if (this.#completed || !
|
|
62648
|
+
if (this.#completed || !isRecord9(message))
|
|
62249
62649
|
return { events: [] };
|
|
62250
62650
|
const events = [];
|
|
62251
62651
|
this.#consumeSegmentLevel(message, events);
|
|
@@ -62263,8 +62663,9 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62263
62663
|
if (!nested) {
|
|
62264
62664
|
this.#consumeCompaction(message, events);
|
|
62265
62665
|
this.#consumeLocalCommandOutput(message, events);
|
|
62666
|
+
this.#consumeModelFallback(message, events);
|
|
62266
62667
|
}
|
|
62267
|
-
if (message.type === "stream_event" &&
|
|
62668
|
+
if (message.type === "stream_event" && isRecord9(message.event)) {
|
|
62268
62669
|
if (!nested) {
|
|
62269
62670
|
this.#observeUsage(message.event, events);
|
|
62270
62671
|
this.#consumeStreamEvent(message, events);
|
|
@@ -62272,6 +62673,15 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62272
62673
|
} else if (message.type === "tool_progress") {
|
|
62273
62674
|
this.#consumeToolProgress(message, events);
|
|
62274
62675
|
}
|
|
62676
|
+
if (message.type === "rate_limit_event" && isRecord9(message.rate_limit_info)) {
|
|
62677
|
+
const info = message.rate_limit_info;
|
|
62678
|
+
if (info.status === "rejected" && !isOverageCoveringRateLimit(info)) {
|
|
62679
|
+
const resetsAtUnix = rejectedRateLimitResetUnix(info);
|
|
62680
|
+
this.#rejectedRateLimit = resetsAtUnix !== void 0 ? { resetsAtUnix } : {};
|
|
62681
|
+
} else if (info.status === "allowed" || info.status === "allowed_warning" || info.status === "rejected" && isOverageCoveringRateLimit(info)) {
|
|
62682
|
+
this.#rejectedRateLimit = null;
|
|
62683
|
+
}
|
|
62684
|
+
}
|
|
62275
62685
|
if (!nested) {
|
|
62276
62686
|
const error63 = assistantError(message);
|
|
62277
62687
|
if (error63 !== null)
|
|
@@ -62312,7 +62722,16 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62312
62722
|
} else if (nativeSuccess) {
|
|
62313
62723
|
terminal = { status: "succeeded" };
|
|
62314
62724
|
} else {
|
|
62315
|
-
|
|
62725
|
+
const lastError = this.#assistantErrors.at(-1);
|
|
62726
|
+
if (lastError === "billing_error") {
|
|
62727
|
+
terminal = failure2("billing");
|
|
62728
|
+
} else if (this.#rejectedRateLimit !== null && (lastError === void 0 || lastError === "rate_limit")) {
|
|
62729
|
+
terminal = failure2("quotaExhausted", this.#rejectedRateLimit.resetsAtUnix);
|
|
62730
|
+
} else if (lastError === "rate_limit") {
|
|
62731
|
+
terminal = failure2("rateLimited");
|
|
62732
|
+
} else {
|
|
62733
|
+
terminal = failure2("native");
|
|
62734
|
+
}
|
|
62316
62735
|
}
|
|
62317
62736
|
return { events, terminal };
|
|
62318
62737
|
}
|
|
@@ -62344,6 +62763,34 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62344
62763
|
this.#compactionState = "settled";
|
|
62345
62764
|
events.push({ type: "compaction.completed", outcome: "succeeded" });
|
|
62346
62765
|
}
|
|
62766
|
+
/**
|
|
62767
|
+
* Claude reports a primary-model refusal fallback (the turn retried on a
|
|
62768
|
+
* fallback model) as a `model_refusal_fallback` system push. A `session`
|
|
62769
|
+
* scope (or absent, on older CLIs) means the main thread fell back and the
|
|
62770
|
+
* session model is swapped, so the user sees one non-blocking chat notice;
|
|
62771
|
+
* a `local` scope is a subagent / side-question fallback and stays silent.
|
|
62772
|
+
*/
|
|
62773
|
+
#consumeModelFallback(message, events) {
|
|
62774
|
+
if (message.type !== "system" || message.subtype !== "model_refusal_fallback")
|
|
62775
|
+
return;
|
|
62776
|
+
if (message.scope === "local")
|
|
62777
|
+
return;
|
|
62778
|
+
if (message.direction !== void 0 && message.direction !== "retry" && message.direction !== "sticky")
|
|
62779
|
+
return;
|
|
62780
|
+
const original = typeof message.original_model === "string" ? message.original_model : "";
|
|
62781
|
+
const fallback = typeof message.fallback_model === "string" ? message.fallback_model : "";
|
|
62782
|
+
if (original.length === 0 || fallback.length === 0)
|
|
62783
|
+
return;
|
|
62784
|
+
const key = typeof message.request_id === "string" && message.request_id.length > 0 ? message.request_id : `${original}\0${fallback}`;
|
|
62785
|
+
if (this.#fallbackNoticeKeys.has(key))
|
|
62786
|
+
return;
|
|
62787
|
+
this.#fallbackNoticeKeys.add(key);
|
|
62788
|
+
const checkpointId = nativeUuid(message);
|
|
62789
|
+
const messageId = checkpointId ?? this.#nextMessageId();
|
|
62790
|
+
const delta = `Model fallback: **${original} → ${fallback}**. The session continues on the fallback model; your configured model choice is unchanged.`;
|
|
62791
|
+
events.push({ type: "text.delta", messageId, delta });
|
|
62792
|
+
events.push({ type: "message.completed", messageId, localCommand: true });
|
|
62793
|
+
}
|
|
62347
62794
|
#consumeLocalCommandOutput(message, events) {
|
|
62348
62795
|
if (message.type !== "system" || message.subtype !== "local_command_output")
|
|
62349
62796
|
return;
|
|
@@ -62372,14 +62819,14 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62372
62819
|
if (message.type !== "system")
|
|
62373
62820
|
return;
|
|
62374
62821
|
if (message.subtype === "init") {
|
|
62375
|
-
const mcpServers = Array.isArray(message.mcp_servers) ? message.mcp_servers.flatMap((server) =>
|
|
62822
|
+
const mcpServers = Array.isArray(message.mcp_servers) ? message.mcp_servers.flatMap((server) => isRecord9(server) && typeof server.name === "string" ? [server.name] : []) : void 0;
|
|
62376
62823
|
events.push({ type: "segment.started", ...mcpServers ? { mcpServers } : {} });
|
|
62377
62824
|
return;
|
|
62378
62825
|
}
|
|
62379
62826
|
if (message.subtype !== "background_tasks_changed" || !Array.isArray(message.tasks))
|
|
62380
62827
|
return;
|
|
62381
62828
|
const nativeSubagentIds = message.tasks.flatMap((task) => {
|
|
62382
|
-
if (!
|
|
62829
|
+
if (!isRecord9(task))
|
|
62383
62830
|
return [];
|
|
62384
62831
|
const taskId = boundedString(task.task_id, SUBAGENT_DESCRIPTION_LIMIT);
|
|
62385
62832
|
return taskId ? [taskId] : [];
|
|
@@ -62455,7 +62902,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62455
62902
|
});
|
|
62456
62903
|
return;
|
|
62457
62904
|
}
|
|
62458
|
-
if (message.subtype === "task_updated" &&
|
|
62905
|
+
if (message.subtype === "task_updated" && isRecord9(message.patch)) {
|
|
62459
62906
|
const status = taskStatus2(message.patch.status);
|
|
62460
62907
|
if (!status)
|
|
62461
62908
|
return;
|
|
@@ -62481,7 +62928,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62481
62928
|
*/
|
|
62482
62929
|
#observeUsage(event, events) {
|
|
62483
62930
|
if (event.type === "message_start") {
|
|
62484
|
-
const message =
|
|
62931
|
+
const message = isRecord9(event.message) ? event.message : null;
|
|
62485
62932
|
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
62933
|
return;
|
|
62487
62934
|
}
|
|
@@ -62490,16 +62937,18 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62490
62937
|
return;
|
|
62491
62938
|
if (event.type === "content_block_start") {
|
|
62492
62939
|
request.startedAtMs ??= Date.now();
|
|
62493
|
-
} else if (event.type === "message_delta" &&
|
|
62494
|
-
request.usage = { ...
|
|
62940
|
+
} else if (event.type === "message_delta" && isRecord9(event.usage)) {
|
|
62941
|
+
request.usage = { ...isRecord9(request.usage) ? request.usage : {}, ...event.usage };
|
|
62495
62942
|
} else if (event.type === "message_stop") {
|
|
62496
62943
|
this.#usageRequest = null;
|
|
62944
|
+
const promptCacheTtlSeconds = claudePromptCacheTtlSeconds(request.usage);
|
|
62497
62945
|
events.push({
|
|
62498
62946
|
type: "usage.request",
|
|
62499
62947
|
record: claudeUsageRecord(request.id, request.model, request.usage, {
|
|
62500
62948
|
startedAtMs: request.startedAtMs,
|
|
62501
62949
|
completedAtMs: Date.now()
|
|
62502
|
-
})
|
|
62950
|
+
}),
|
|
62951
|
+
...promptCacheTtlSeconds !== void 0 ? { promptCacheTtlSeconds } : {}
|
|
62503
62952
|
});
|
|
62504
62953
|
}
|
|
62505
62954
|
}
|
|
@@ -62526,9 +62975,9 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62526
62975
|
}
|
|
62527
62976
|
#consumeStreamEvent(message, events) {
|
|
62528
62977
|
const event = message.event;
|
|
62529
|
-
if (!
|
|
62978
|
+
if (!isRecord9(event))
|
|
62530
62979
|
return;
|
|
62531
|
-
if (event.type === "message_start" &&
|
|
62980
|
+
if (event.type === "message_start" && isRecord9(event.message) && typeof event.message.id === "string" && event.message.id.length > 0) {
|
|
62532
62981
|
this.#activeRootStreamMessageId = event.message.id;
|
|
62533
62982
|
this.#messageState(event.message.id);
|
|
62534
62983
|
return;
|
|
@@ -62546,8 +62995,8 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62546
62995
|
}
|
|
62547
62996
|
return;
|
|
62548
62997
|
}
|
|
62549
|
-
const start = event.type === "content_block_start" &&
|
|
62550
|
-
const delta = event.type === "content_block_delta" &&
|
|
62998
|
+
const start = event.type === "content_block_start" && isRecord9(event.content_block) && event.content_block.type === "thinking" ? event.content_block : null;
|
|
62999
|
+
const delta = event.type === "content_block_delta" && isRecord9(event.delta) ? event.delta : null;
|
|
62551
63000
|
if (!start && !delta)
|
|
62552
63001
|
return;
|
|
62553
63002
|
const messageId = this.#activeRootStreamMessageId ?? nativeUuid(message) ?? this.#nextMessageId();
|
|
@@ -62602,7 +63051,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62602
63051
|
const state = this.#messageState(messageId);
|
|
62603
63052
|
const content = assistantContent(message) ?? [];
|
|
62604
63053
|
for (const [index, block] of content.entries()) {
|
|
62605
|
-
if (!
|
|
63054
|
+
if (!isRecord9(block) || block.type !== "thinking")
|
|
62606
63055
|
continue;
|
|
62607
63056
|
const identity2 = `${checkpointId ?? nativeMessageId ?? messageId}:${index}`;
|
|
62608
63057
|
if (this.#completedThinkingBlocks.has(identity2))
|
|
@@ -62619,7 +63068,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62619
63068
|
const complete = typeof block.thinking === "string" ? block.thinking : "";
|
|
62620
63069
|
this.#publishNarration(thinking, blockId, block.signature || thinking?.signature, complete.startsWith(streamed) ? complete : streamed, events);
|
|
62621
63070
|
}
|
|
62622
|
-
const keepsStreaming = nativeMessageId !== null && nativeMessageId === this.#activeRootStreamMessageId && content.length === 1 &&
|
|
63071
|
+
const keepsStreaming = nativeMessageId !== null && nativeMessageId === this.#activeRootStreamMessageId && content.length === 1 && isRecord9(content[0]) && content[0].type === "thinking";
|
|
62623
63072
|
if (keepsStreaming && checkpointId && this.#publishedCheckpointIds.has(checkpointId))
|
|
62624
63073
|
return;
|
|
62625
63074
|
if (!keepsStreaming) {
|
|
@@ -62713,7 +63162,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62713
63162
|
}
|
|
62714
63163
|
#consumeToolUseBlocks(message, events, ignoreKnownIds) {
|
|
62715
63164
|
for (const block of assistantContent(message) ?? []) {
|
|
62716
|
-
if (!
|
|
63165
|
+
if (!isRecord9(block) || block.type !== "tool_use")
|
|
62717
63166
|
continue;
|
|
62718
63167
|
const argumentsResult = jsonValueSchema.safeParse(block.input);
|
|
62719
63168
|
if (typeof block.id !== "string" || block.id.length === 0 || typeof block.name !== "string" || block.name.length === 0 || !argumentsResult.success) {
|
|
@@ -62727,7 +63176,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62727
63176
|
}
|
|
62728
63177
|
const subagent = CLAUDE_SUBAGENT_TOOLS.has(block.name);
|
|
62729
63178
|
const workflow = block.name === CLAUDE_WORKFLOW_TOOL;
|
|
62730
|
-
const spawnName = subagent && block.name !== "SendMessage" &&
|
|
63179
|
+
const spawnName = subagent && block.name !== "SendMessage" && isRecord9(argumentsResult.data) ? boundedString(argumentsResult.data.name, SUBAGENT_DESCRIPTION_LIMIT) : void 0;
|
|
62731
63180
|
this.#tools.set(block.id, {
|
|
62732
63181
|
name: block.name,
|
|
62733
63182
|
subagent,
|
|
@@ -62735,7 +63184,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62735
63184
|
...spawnName ? { spawnName } : {}
|
|
62736
63185
|
});
|
|
62737
63186
|
if (workflow) {
|
|
62738
|
-
const name =
|
|
63187
|
+
const name = isRecord9(argumentsResult.data) ? boundedString(argumentsResult.data.name, SUBAGENT_DESCRIPTION_LIMIT) : void 0;
|
|
62739
63188
|
events.push({ type: "workflow.started", callId: block.id, ...name ? { name } : {} });
|
|
62740
63189
|
} else if (subagent) {
|
|
62741
63190
|
const prompt = subagentPrompt(argumentsResult.data);
|
|
@@ -62777,9 +63226,9 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62777
63226
|
events.push(settled);
|
|
62778
63227
|
}
|
|
62779
63228
|
#consumeToolResults(message, events, ignoreUnknown) {
|
|
62780
|
-
if (!
|
|
63229
|
+
if (!isRecord9(message.message) || !Array.isArray(message.message.content))
|
|
62781
63230
|
return;
|
|
62782
|
-
const resultBlocks = message.message.content.filter((block) =>
|
|
63231
|
+
const resultBlocks = message.message.content.filter((block) => isRecord9(block) && block.type === "tool_result");
|
|
62783
63232
|
if (resultBlocks.length === 0)
|
|
62784
63233
|
return;
|
|
62785
63234
|
if (resultBlocks.length > 1 && message.tool_use_result !== void 0) {
|
|
@@ -62808,8 +63257,8 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62808
63257
|
const outputText = resultText(block.content, nativeResult);
|
|
62809
63258
|
const structuredResult = isClaudeTaskTool(tool.name) ? jsonValueSchema.safeParse(nativeResult) : null;
|
|
62810
63259
|
if (tool.workflow) {
|
|
62811
|
-
const status =
|
|
62812
|
-
const taskId =
|
|
63260
|
+
const status = isRecord9(nativeResult) ? nativeResult.status : void 0;
|
|
63261
|
+
const taskId = isRecord9(nativeResult) ? boundedString(nativeResult.taskId, SUBAGENT_DESCRIPTION_LIMIT) : void 0;
|
|
62813
63262
|
const resultSummary = boundedString(outputText, SUBAGENT_SUMMARY_LIMIT);
|
|
62814
63263
|
events.push({
|
|
62815
63264
|
type: "workflow.launched",
|
|
@@ -62824,13 +63273,13 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62824
63273
|
if (tool.subagent) {
|
|
62825
63274
|
const resultSummary = boundedString(outputText, SUBAGENT_SUMMARY_LIMIT);
|
|
62826
63275
|
const send = tool.name === "SendMessage";
|
|
62827
|
-
const result = send && !
|
|
63276
|
+
const result = send && !isRecord9(nativeResult) ? sendResultFromText(outputText) : nativeResult;
|
|
62828
63277
|
const failed = isError || send && claudeSendMessageFailed(result, outputText);
|
|
62829
63278
|
const agentId = nativeSubagentId(result, outputText);
|
|
62830
63279
|
if (!failed) {
|
|
62831
63280
|
if (tool.spawnName && agentId)
|
|
62832
63281
|
this.#subagentIdsByName.set(tool.spawnName, agentId);
|
|
62833
|
-
if (send &&
|
|
63282
|
+
if (send && isRecord9(result) && isRecord9(result.pin)) {
|
|
62834
63283
|
const name = boundedString(result.pin.name, SUBAGENT_DESCRIPTION_LIMIT);
|
|
62835
63284
|
const id3 = boundedString(result.pin.id, SUBAGENT_DESCRIPTION_LIMIT);
|
|
62836
63285
|
if (name && id3)
|
|
@@ -62848,7 +63297,7 @@ var ClaudeNativeTurnAccumulator = class {
|
|
|
62848
63297
|
continue;
|
|
62849
63298
|
}
|
|
62850
63299
|
const fileChange = isError ? null : parseClaudeNativeFileChange(tool.name, nativeResult);
|
|
62851
|
-
const backgroundTaskId = tool.name === "Bash" && !isError &&
|
|
63300
|
+
const backgroundTaskId = tool.name === "Bash" && !isError && isRecord9(nativeResult) && typeof nativeResult.backgroundTaskId === "string" && nativeResult.backgroundTaskId.length > 0 ? nativeResult.backgroundTaskId : void 0;
|
|
62852
63301
|
const outputFile = backgroundTaskId !== void 0 ? BACKGROUND_OUTPUT_FILE_PATTERN.exec(outputText ?? "")?.[1] : void 0;
|
|
62853
63302
|
const backgroundOutputFile = typeof outputFile === "string" && outputFile.length > 0 ? outputFile : void 0;
|
|
62854
63303
|
events.push({
|
|
@@ -62914,12 +63363,12 @@ function claudeTranscriptItemId(nativeTurnKey, kind, ordinal) {
|
|
|
62914
63363
|
}
|
|
62915
63364
|
|
|
62916
63365
|
// dist/claude-queued-command.js
|
|
62917
|
-
function
|
|
63366
|
+
function isRecord10(value) {
|
|
62918
63367
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
62919
63368
|
}
|
|
62920
63369
|
function readClaudeQueuedCommand(value, sessionId) {
|
|
62921
63370
|
const attachment = value.attachment;
|
|
62922
|
-
if (value.type !== "attachment" || !
|
|
63371
|
+
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
63372
|
return null;
|
|
62924
63373
|
}
|
|
62925
63374
|
const prompt = promptText(attachment.prompt);
|
|
@@ -62933,7 +63382,7 @@ function promptText(prompt) {
|
|
|
62933
63382
|
return prompt;
|
|
62934
63383
|
if (!Array.isArray(prompt))
|
|
62935
63384
|
return "";
|
|
62936
|
-
return prompt.flatMap((block) =>
|
|
63385
|
+
return prompt.flatMap((block) => isRecord10(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
|
|
62937
63386
|
}
|
|
62938
63387
|
|
|
62939
63388
|
// dist/claude-history.js
|
|
@@ -62957,7 +63406,7 @@ function isPersistedClaudeMessageId(expectedId, persistedIds) {
|
|
|
62957
63406
|
}
|
|
62958
63407
|
return false;
|
|
62959
63408
|
}
|
|
62960
|
-
function
|
|
63409
|
+
function isRecord11(value) {
|
|
62961
63410
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
62962
63411
|
}
|
|
62963
63412
|
function textParts(value) {
|
|
@@ -62965,7 +63414,7 @@ function textParts(value) {
|
|
|
62965
63414
|
return value.length > 0 ? [value] : [];
|
|
62966
63415
|
if (!Array.isArray(value))
|
|
62967
63416
|
return [];
|
|
62968
|
-
return value.flatMap((part) =>
|
|
63417
|
+
return value.flatMap((part) => isRecord11(part) && part.type === "text" && typeof part.text === "string" ? [part.text] : []);
|
|
62969
63418
|
}
|
|
62970
63419
|
var localCommandRecordPattern = /^\s*<(local-command-(?:stdout|caveat))>[\s\S]*<\/\1>\s*$/u;
|
|
62971
63420
|
var taskNotificationRecordPattern = /^\s*<task-notification>[\s\S]*<\/task-notification>\s*$/u;
|
|
@@ -63015,7 +63464,7 @@ function localCommandStdoutText(text3) {
|
|
|
63015
63464
|
return match[1] ?? "";
|
|
63016
63465
|
}
|
|
63017
63466
|
function isTaskNotificationOrigin(value) {
|
|
63018
|
-
return
|
|
63467
|
+
return isRecord11(value.origin) && value.origin.kind === "task-notification";
|
|
63019
63468
|
}
|
|
63020
63469
|
function visibleUserTextParts(message) {
|
|
63021
63470
|
if (message.type !== "user" || message.syntheticUser)
|
|
@@ -63029,16 +63478,16 @@ function hasRootToolResult(message) {
|
|
|
63029
63478
|
if (message.type !== "user" || message.nested || !Array.isArray(message.message.content)) {
|
|
63030
63479
|
return false;
|
|
63031
63480
|
}
|
|
63032
|
-
return message.message.content.some((block) =>
|
|
63481
|
+
return message.message.content.some((block) => isRecord11(block) && block.type === "tool_result");
|
|
63033
63482
|
}
|
|
63034
63483
|
function isInterruptionRecord(value, promptId) {
|
|
63035
|
-
if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !
|
|
63484
|
+
if (value.type !== "user" || promptId === null || value.promptId !== promptId || value.promptSource !== void 0 || !isRecord11(value.message))
|
|
63036
63485
|
return false;
|
|
63037
63486
|
const content = value.message.content;
|
|
63038
63487
|
if (!Array.isArray(content) || content.length !== 1)
|
|
63039
63488
|
return false;
|
|
63040
63489
|
const part = content[0];
|
|
63041
|
-
return
|
|
63490
|
+
return isRecord11(part) && part.type === "text" && (part.text === "[Request interrupted by user]" || part.text === "[Request interrupted by user for tool use]");
|
|
63042
63491
|
}
|
|
63043
63492
|
function conversationMessages(values, sessionId) {
|
|
63044
63493
|
const messages = [];
|
|
@@ -63050,7 +63499,7 @@ function conversationMessages(values, sessionId) {
|
|
|
63050
63499
|
const sends = /* @__PURE__ */ new Map();
|
|
63051
63500
|
let pendingNotification = false;
|
|
63052
63501
|
for (const value of values) {
|
|
63053
|
-
if (!
|
|
63502
|
+
if (!isRecord11(value))
|
|
63054
63503
|
throw new Error("Claude history contains a malformed message");
|
|
63055
63504
|
if (value.type === "system")
|
|
63056
63505
|
continue;
|
|
@@ -63074,7 +63523,7 @@ function conversationMessages(values, sessionId) {
|
|
|
63074
63523
|
});
|
|
63075
63524
|
continue;
|
|
63076
63525
|
}
|
|
63077
|
-
if (value.type !== "user" && value.type !== "assistant" || typeof value.uuid !== "string" || value.uuid.length === 0 || value.session_id !== sessionId || !
|
|
63526
|
+
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
63527
|
throw new Error("Claude history contains an invalid message identity");
|
|
63079
63528
|
}
|
|
63080
63529
|
if (ids.has(value.uuid))
|
|
@@ -63090,7 +63539,7 @@ function conversationMessages(values, sessionId) {
|
|
|
63090
63539
|
nested: typeof value.parent_tool_use_id === "string" && value.parent_tool_use_id.length > 0,
|
|
63091
63540
|
interrupted,
|
|
63092
63541
|
startsTurn: false,
|
|
63093
|
-
...
|
|
63542
|
+
...isRecord11(value.forkedFrom) && typeof value.forkedFrom.messageUuid === "string" ? { forkSourceUuid: value.forkedFrom.messageUuid } : {},
|
|
63094
63543
|
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
63544
|
};
|
|
63096
63545
|
const notification = message.type === "user" && !message.nested && (isTaskNotificationOrigin(value) || textParts(message.message.content).some(isTaskNotificationRecord));
|
|
@@ -63298,7 +63747,7 @@ function mapClaudeSnapshotWithCheckpointIds(values, sessionId, mcpServers, tasks
|
|
|
63298
63747
|
const items = [];
|
|
63299
63748
|
let projectedText = false;
|
|
63300
63749
|
for (const [blockIndex, block] of content.entries()) {
|
|
63301
|
-
if (!
|
|
63750
|
+
if (!isRecord11(block))
|
|
63302
63751
|
continue;
|
|
63303
63752
|
if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
63304
63753
|
if (block.thinking.length === 0)
|
|
@@ -63356,7 +63805,7 @@ function mapClaudeSnapshotWithCheckpointIds(values, sessionId, mcpServers, tasks
|
|
|
63356
63805
|
}
|
|
63357
63806
|
} : { status: "succeeded" };
|
|
63358
63807
|
const itemId = toolItem !== null ? claudeTranscriptItemId(user.uuid, "tool", toolItem) : hostItemIdSchema.parse(`claude-item-v1-${message.uuid}-tool-${blockIndex}`);
|
|
63359
|
-
if (block.name === "Bash" &&
|
|
63808
|
+
if (block.name === "Bash" && isRecord11(block.input) && typeof block.input.command === "string") {
|
|
63360
63809
|
items.push({
|
|
63361
63810
|
item: {
|
|
63362
63811
|
type: "commandExecution",
|
|
@@ -63408,7 +63857,7 @@ function toolResultBlocks(messages) {
|
|
|
63408
63857
|
if (message.type !== "user" || !Array.isArray(message.message.content))
|
|
63409
63858
|
continue;
|
|
63410
63859
|
for (const block of message.message.content) {
|
|
63411
|
-
if (
|
|
63860
|
+
if (isRecord11(block) && block.type === "tool_result" && typeof block.tool_use_id === "string") {
|
|
63412
63861
|
results.set(block.tool_use_id, block);
|
|
63413
63862
|
}
|
|
63414
63863
|
}
|
|
@@ -63423,7 +63872,7 @@ function toolResultOutput(block) {
|
|
|
63423
63872
|
}
|
|
63424
63873
|
function resultSubagentId(value, block) {
|
|
63425
63874
|
const nativeResult = value.tool_use_result;
|
|
63426
|
-
if (
|
|
63875
|
+
if (isRecord11(nativeResult)) {
|
|
63427
63876
|
const structured = nativeResult.agentId ?? nativeResult.agent_id ?? nativeResult.task_id;
|
|
63428
63877
|
if (typeof structured === "string" && structured.length > 0)
|
|
63429
63878
|
return structured;
|
|
@@ -63434,13 +63883,13 @@ function resultSubagentId(value, block) {
|
|
|
63434
63883
|
function subagentPrompt2(values, nativeSubagentId2) {
|
|
63435
63884
|
const toolUses = /* @__PURE__ */ new Map();
|
|
63436
63885
|
for (const value of values) {
|
|
63437
|
-
if (!
|
|
63886
|
+
if (!isRecord11(value) || !isRecord11(value.message) || !Array.isArray(value.message.content)) {
|
|
63438
63887
|
continue;
|
|
63439
63888
|
}
|
|
63440
63889
|
for (const block of value.message.content) {
|
|
63441
|
-
if (!
|
|
63890
|
+
if (!isRecord11(block))
|
|
63442
63891
|
continue;
|
|
63443
|
-
if (block.type === "tool_use" && typeof block.id === "string" && (block.name === "Agent" || block.name === "Task") &&
|
|
63892
|
+
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
63893
|
toolUses.set(block.id, block.input.prompt);
|
|
63445
63894
|
continue;
|
|
63446
63895
|
}
|
|
@@ -63454,7 +63903,7 @@ function subagentPrompt2(values, nativeSubagentId2) {
|
|
|
63454
63903
|
return void 0;
|
|
63455
63904
|
}
|
|
63456
63905
|
function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, parentValues = []) {
|
|
63457
|
-
const messages = conversationMessages(values.map((value) =>
|
|
63906
|
+
const messages = conversationMessages(values.map((value) => isRecord11(value) ? { ...value, session_id: parentSessionId } : value), parentSessionId);
|
|
63458
63907
|
const turns = [];
|
|
63459
63908
|
for (let index = 0; index < messages.length; ) {
|
|
63460
63909
|
const first = messages[index];
|
|
@@ -63485,7 +63934,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
|
|
|
63485
63934
|
const content = Array.isArray(message.message.content) ? message.message.content : [{ type: "text", text: message.message.content }];
|
|
63486
63935
|
for (let blockIndex = 0; blockIndex < content.length; blockIndex += 1) {
|
|
63487
63936
|
const block = content[blockIndex];
|
|
63488
|
-
if (!
|
|
63937
|
+
if (!isRecord11(block))
|
|
63489
63938
|
continue;
|
|
63490
63939
|
const itemId = hostItemIdSchema.parse(`claude-subagent-item-v2-${nativeSubagentId2}-${message.uuid}-${blockIndex}`);
|
|
63491
63940
|
if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
@@ -63522,7 +63971,7 @@ function mapClaudeSubagentSnapshot(values, parentSessionId, nativeSubagentId2, p
|
|
|
63522
63971
|
retryable: false
|
|
63523
63972
|
}
|
|
63524
63973
|
} : { status: "succeeded" };
|
|
63525
|
-
if (block.name === "Bash" &&
|
|
63974
|
+
if (block.name === "Bash" && isRecord11(block.input) && typeof block.input.command === "string") {
|
|
63526
63975
|
items.push({
|
|
63527
63976
|
item: {
|
|
63528
63977
|
type: "commandExecution",
|
|
@@ -63759,7 +64208,7 @@ import { readFile as readFile5, rename as rename4, rm as rm5, stat as stat5, wri
|
|
|
63759
64208
|
import { createReadStream as createReadStream4 } from "node:fs";
|
|
63760
64209
|
import os6 from "node:os";
|
|
63761
64210
|
import path12 from "node:path";
|
|
63762
|
-
import { readdir as
|
|
64211
|
+
import { readdir as readdir4, stat as stat4 } from "node:fs/promises";
|
|
63763
64212
|
function projectDirectoryName(cwd) {
|
|
63764
64213
|
return cwd.replace(/[^A-Za-z0-9]/gu, "-");
|
|
63765
64214
|
}
|
|
@@ -63781,7 +64230,7 @@ async function findClaudeTranscript(input3) {
|
|
|
63781
64230
|
return expected;
|
|
63782
64231
|
let projects;
|
|
63783
64232
|
try {
|
|
63784
|
-
projects = await
|
|
64233
|
+
projects = await readdir4(projectsDirectory);
|
|
63785
64234
|
} catch {
|
|
63786
64235
|
return null;
|
|
63787
64236
|
}
|
|
@@ -63814,7 +64263,7 @@ async function* transcriptLines(transcript) {
|
|
|
63814
64263
|
stream.destroy();
|
|
63815
64264
|
}
|
|
63816
64265
|
}
|
|
63817
|
-
function
|
|
64266
|
+
function isRecord12(value) {
|
|
63818
64267
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
63819
64268
|
}
|
|
63820
64269
|
async function readClaudeTranscript(input3) {
|
|
@@ -63831,7 +64280,7 @@ async function readClaudeTranscript(input3) {
|
|
|
63831
64280
|
} catch {
|
|
63832
64281
|
continue;
|
|
63833
64282
|
}
|
|
63834
|
-
if (!
|
|
64283
|
+
if (!isRecord12(entry) || entry.type !== "user" && entry.type !== "assistant" && entry.type !== "attachment" || typeof entry.uuid !== "string" || entry.type !== "attachment" && !isRecord12(entry.message)) {
|
|
63835
64284
|
continue;
|
|
63836
64285
|
}
|
|
63837
64286
|
messages.set(entry.uuid, { ...entry, session_id: input3.sessionId });
|
|
@@ -63840,7 +64289,7 @@ async function readClaudeTranscript(input3) {
|
|
|
63840
64289
|
}
|
|
63841
64290
|
|
|
63842
64291
|
// dist/claude-fork-references.js
|
|
63843
|
-
function
|
|
64292
|
+
function isRecord13(value) {
|
|
63844
64293
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
63845
64294
|
}
|
|
63846
64295
|
function parseEntry(line) {
|
|
@@ -63848,7 +64297,7 @@ function parseEntry(line) {
|
|
|
63848
64297
|
return null;
|
|
63849
64298
|
try {
|
|
63850
64299
|
const entry = JSON.parse(line);
|
|
63851
|
-
return
|
|
64300
|
+
return isRecord13(entry) ? entry : null;
|
|
63852
64301
|
} catch {
|
|
63853
64302
|
return null;
|
|
63854
64303
|
}
|
|
@@ -63857,7 +64306,7 @@ function remapSameAs(value, copies) {
|
|
|
63857
64306
|
if (Array.isArray(value)) {
|
|
63858
64307
|
return value.reduce((count4, item) => count4 + remapSameAs(item, copies), 0);
|
|
63859
64308
|
}
|
|
63860
|
-
if (!
|
|
64309
|
+
if (!isRecord13(value))
|
|
63861
64310
|
return 0;
|
|
63862
64311
|
let count3 = 0;
|
|
63863
64312
|
for (const [key, child] of Object.entries(value)) {
|
|
@@ -63883,7 +64332,7 @@ async function remapForkedSessionReferences(input3) {
|
|
|
63883
64332
|
const copies = /* @__PURE__ */ new Map();
|
|
63884
64333
|
for (const entry of entries) {
|
|
63885
64334
|
const source = entry?.forkedFrom;
|
|
63886
|
-
if (typeof entry?.uuid === "string" &&
|
|
64335
|
+
if (typeof entry?.uuid === "string" && isRecord13(source) && typeof source.messageUuid === "string") {
|
|
63887
64336
|
copies.set(source.messageUuid, entry.uuid);
|
|
63888
64337
|
}
|
|
63889
64338
|
}
|
|
@@ -64552,8 +65001,10 @@ var APPROVAL_TITLE_MAX_LENGTH = 120;
|
|
|
64552
65001
|
var APPROVAL_DESCRIPTION_MAX_LENGTH = 500;
|
|
64553
65002
|
var DEFAULT_ABORT_TIMEOUT_MS = 2e3;
|
|
64554
65003
|
var DEFAULT_STEER_QUEUED_TIMEOUT_MS = 5e3;
|
|
65004
|
+
var DEFAULT_AWAITING_TASK_NOTIFICATION_TIMEOUT_MS = 3e4;
|
|
64555
65005
|
var WORKFLOW_AGENT_LABEL_LIMIT = 1e3;
|
|
64556
65006
|
var INTERRUPT_TIMEOUT_MESSAGE = "Claude SDK interrupt timed out";
|
|
65007
|
+
var SESSION_CRON_TOOLS = /* @__PURE__ */ new Set(["CronCreate", "CronDelete", "ScheduleWakeup"]);
|
|
64557
65008
|
var PushableInput = class {
|
|
64558
65009
|
#closed = false;
|
|
64559
65010
|
#queue = [];
|
|
@@ -64587,6 +65038,7 @@ var PushableInput = class {
|
|
|
64587
65038
|
};
|
|
64588
65039
|
}
|
|
64589
65040
|
};
|
|
65041
|
+
var DEFAULT_MODEL_INSPECT_TIMEOUT_MS = 6e4;
|
|
64590
65042
|
function delay(milliseconds) {
|
|
64591
65043
|
return new Promise((resolve5) => setTimeout(resolve5, milliseconds));
|
|
64592
65044
|
}
|
|
@@ -64606,17 +65058,17 @@ function rejectAfter(milliseconds, message) {
|
|
|
64606
65058
|
function processExited(child) {
|
|
64607
65059
|
return child.exitCode !== null || child.signalCode !== null;
|
|
64608
65060
|
}
|
|
64609
|
-
function
|
|
65061
|
+
function isRecord14(value) {
|
|
64610
65062
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
64611
65063
|
}
|
|
64612
65064
|
function permissionModeFromMessage(value) {
|
|
64613
|
-
if (!
|
|
65065
|
+
if (!isRecord14(value) || value.type !== "system" || value.subtype !== "init" && value.subtype !== "status" || !("permissionMode" in value) || value.permissionMode === void 0) {
|
|
64614
65066
|
return void 0;
|
|
64615
65067
|
}
|
|
64616
65068
|
return isClaudePermissionMode(value.permissionMode) ? value.permissionMode : void 0;
|
|
64617
65069
|
}
|
|
64618
65070
|
function parseContextUsage(value) {
|
|
64619
|
-
if (!
|
|
65071
|
+
if (!isRecord14(value))
|
|
64620
65072
|
throw new Error("Claude SDK context Usage is invalid");
|
|
64621
65073
|
const usedTokens = value.totalTokens;
|
|
64622
65074
|
const maxTokens = value.maxTokens;
|
|
@@ -64633,7 +65085,7 @@ function parseQuestions(input3) {
|
|
|
64633
65085
|
const questions = [];
|
|
64634
65086
|
const questionTexts = /* @__PURE__ */ new Set();
|
|
64635
65087
|
for (const value of input3.questions) {
|
|
64636
|
-
if (!
|
|
65088
|
+
if (!isRecord14(value))
|
|
64637
65089
|
return null;
|
|
64638
65090
|
const question = value.question;
|
|
64639
65091
|
const header = value.header;
|
|
@@ -64644,7 +65096,7 @@ function parseQuestions(input3) {
|
|
|
64644
65096
|
const labels = /* @__PURE__ */ new Set();
|
|
64645
65097
|
const options = [];
|
|
64646
65098
|
for (const option2 of value.options) {
|
|
64647
|
-
if (!
|
|
65099
|
+
if (!isRecord14(option2) || typeof option2.label !== "string" || option2.label.length === 0 || labels.has(option2.label) || typeof option2.description !== "string") {
|
|
64648
65100
|
return null;
|
|
64649
65101
|
}
|
|
64650
65102
|
labels.add(option2.label);
|
|
@@ -64686,7 +65138,7 @@ function permissionUpdateDestination(value) {
|
|
|
64686
65138
|
return void 0;
|
|
64687
65139
|
}
|
|
64688
65140
|
function isPermissionUpdate(value) {
|
|
64689
|
-
if (!
|
|
65141
|
+
if (!isRecord14(value) || !permissionUpdateDestination(value.destination))
|
|
64690
65142
|
return false;
|
|
64691
65143
|
if (value.type === "setMode") {
|
|
64692
65144
|
return typeof value.mode === "string" && PERMISSION_MODES.has(value.mode);
|
|
@@ -64695,7 +65147,7 @@ function isPermissionUpdate(value) {
|
|
|
64695
65147
|
return Array.isArray(value.directories) && value.directories.every((directory) => typeof directory === "string");
|
|
64696
65148
|
}
|
|
64697
65149
|
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) =>
|
|
65150
|
+
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
65151
|
}
|
|
64700
65152
|
return false;
|
|
64701
65153
|
}
|
|
@@ -64809,6 +65261,7 @@ var ClaudeSdkTransport = class {
|
|
|
64809
65261
|
#thinkingOptionId;
|
|
64810
65262
|
#active = null;
|
|
64811
65263
|
#steerQueuedTimeoutMs;
|
|
65264
|
+
#awaitingTaskNotificationTimeoutMs;
|
|
64812
65265
|
#nativeSteer = false;
|
|
64813
65266
|
/** Root tool calls of the requested Turn that have started and not yet returned a result. */
|
|
64814
65267
|
#rootToolCalls = /* @__PURE__ */ new Set();
|
|
@@ -64837,11 +65290,18 @@ var ClaudeSdkTransport = class {
|
|
|
64837
65290
|
#skillNames = /* @__PURE__ */ new Set();
|
|
64838
65291
|
#started = false;
|
|
64839
65292
|
#backgroundTasks = /* @__PURE__ */ new Set();
|
|
65293
|
+
/** Tasks that left the live roster before their terminal `task_notification`, keyed to expiry timestamp. */
|
|
65294
|
+
#awaitingTaskNotifications = /* @__PURE__ */ new Map();
|
|
65295
|
+
/** Authoritative count of process-local session crons/wakeups from the latest Stop hook. */
|
|
65296
|
+
#sessionCronCount = 0;
|
|
65297
|
+
/** True after a session cron tool call until a Stop hook reports `session_crons`. */
|
|
65298
|
+
#sessionCronsUnknown = false;
|
|
64840
65299
|
constructor(options) {
|
|
64841
65300
|
this.sessionId = options.sessionId;
|
|
64842
65301
|
this.#cwd = options.cwd;
|
|
64843
65302
|
this.#abortTimeoutMs = options.abortTimeoutMs ?? DEFAULT_ABORT_TIMEOUT_MS;
|
|
64844
65303
|
this.#steerQueuedTimeoutMs = options.steerQueuedTimeoutMs ?? DEFAULT_STEER_QUEUED_TIMEOUT_MS;
|
|
65304
|
+
this.#awaitingTaskNotificationTimeoutMs = options.awaitingTaskNotificationTimeoutMs ?? DEFAULT_AWAITING_TASK_NOTIFICATION_TIMEOUT_MS;
|
|
64845
65305
|
this.#closeTimeoutMs = options.closeTimeoutMs;
|
|
64846
65306
|
this.#command = options.command;
|
|
64847
65307
|
this.#environment = options.environment ?? process.env;
|
|
@@ -64904,6 +65364,7 @@ var ClaudeSdkTransport = class {
|
|
|
64904
65364
|
permissionMode: this.#permissionMode,
|
|
64905
65365
|
...this.#allowDangerouslySkipPermissions ? { allowDangerouslySkipPermissions: true } : {},
|
|
64906
65366
|
canUseTool: (toolName, input3, options) => this.#canUseTool(toolName, input3, options),
|
|
65367
|
+
hooks: { Stop: [{ hooks: [this.#observeStopHook] }] },
|
|
64907
65368
|
persistSession: true,
|
|
64908
65369
|
includePartialMessages: true,
|
|
64909
65370
|
forwardSubagentText: true,
|
|
@@ -64964,15 +65425,15 @@ var ClaudeSdkTransport = class {
|
|
|
64964
65425
|
return this.#idleLive && this.#idleHandler !== null;
|
|
64965
65426
|
}
|
|
64966
65427
|
#observeRootToolCalls(message) {
|
|
64967
|
-
if (!
|
|
65428
|
+
if (!isRecord14(message) || message.parent_tool_use_id != null)
|
|
64968
65429
|
return;
|
|
64969
65430
|
if (message.type !== "assistant" && message.type !== "user")
|
|
64970
65431
|
return;
|
|
64971
65432
|
const body = message.message;
|
|
64972
|
-
if (!
|
|
65433
|
+
if (!isRecord14(body) || !Array.isArray(body.content))
|
|
64973
65434
|
return;
|
|
64974
65435
|
for (const block of body.content) {
|
|
64975
|
-
if (!
|
|
65436
|
+
if (!isRecord14(block))
|
|
64976
65437
|
continue;
|
|
64977
65438
|
if (message.type === "assistant" && block.type === "tool_use" && typeof block.id === "string") {
|
|
64978
65439
|
this.#rootToolCalls.add(block.id);
|
|
@@ -64982,12 +65443,12 @@ var ClaudeSdkTransport = class {
|
|
|
64982
65443
|
}
|
|
64983
65444
|
}
|
|
64984
65445
|
#observeNativeCapabilities(message) {
|
|
64985
|
-
if (!
|
|
65446
|
+
if (!isRecord14(message) || message.type !== "system" || message.subtype !== "init")
|
|
64986
65447
|
return;
|
|
64987
65448
|
this.#nativeSteer = Array.isArray(message.capabilities) && message.capabilities.includes("msg_lifecycle_v1");
|
|
64988
65449
|
}
|
|
64989
65450
|
#observeSlashCommands(message) {
|
|
64990
|
-
if (!
|
|
65451
|
+
if (!isRecord14(message) || message.type !== "system")
|
|
64991
65452
|
return;
|
|
64992
65453
|
if (message.subtype === "init" && Array.isArray(message.skills)) {
|
|
64993
65454
|
this.#skillNames = new Set(message.skills.filter((name) => typeof name === "string"));
|
|
@@ -65452,9 +65913,19 @@ var ClaudeSdkTransport = class {
|
|
|
65452
65913
|
if (failures.length > 0)
|
|
65453
65914
|
throw new AggregateError(failures, "Claude SDK shutdown could not be confirmed");
|
|
65454
65915
|
this.#backgroundTasks.clear();
|
|
65916
|
+
this.#awaitingTaskNotifications.clear();
|
|
65917
|
+
this.#sessionCronCount = 0;
|
|
65918
|
+
this.#sessionCronsUnknown = false;
|
|
65919
|
+
}
|
|
65920
|
+
#pruneExpiredAwaitingTaskNotifications(now = Date.now()) {
|
|
65921
|
+
for (const [id3, expiresAtMs] of this.#awaitingTaskNotifications) {
|
|
65922
|
+
if (expiresAtMs <= now)
|
|
65923
|
+
this.#awaitingTaskNotifications.delete(id3);
|
|
65924
|
+
}
|
|
65455
65925
|
}
|
|
65456
65926
|
hasBackgroundTasks() {
|
|
65457
|
-
|
|
65927
|
+
this.#pruneExpiredAwaitingTaskNotifications();
|
|
65928
|
+
return this.#backgroundTasks.size > 0 || this.#awaitingTaskNotifications.size > 0 || this.#sessionCronCount > 0 || this.#sessionCronsUnknown;
|
|
65458
65929
|
}
|
|
65459
65930
|
/** The native `task_notification` that follows reports the stopped task. */
|
|
65460
65931
|
async stopBackgroundTask(taskId) {
|
|
@@ -65517,7 +65988,7 @@ var ClaudeSdkTransport = class {
|
|
|
65517
65988
|
* without `started` means no native turn takes it over.
|
|
65518
65989
|
*/
|
|
65519
65990
|
#observeSteer(message) {
|
|
65520
|
-
if (this.#pendingSteers.size === 0 && this.#steerTakeovers.size === 0 || !
|
|
65991
|
+
if (this.#pendingSteers.size === 0 && this.#steerTakeovers.size === 0 || !isRecord14(message) || message.type !== "command_lifecycle") {
|
|
65521
65992
|
return;
|
|
65522
65993
|
}
|
|
65523
65994
|
if (typeof message.command_uuid !== "string" || message.command_uuid.length === 0)
|
|
@@ -65530,15 +66001,60 @@ var ClaudeSdkTransport = class {
|
|
|
65530
66001
|
this.#takeOverSteer(message.command_uuid, message.state === "started");
|
|
65531
66002
|
}
|
|
65532
66003
|
}
|
|
66004
|
+
/** Observation-only Stop hook: reads authoritative background task and session cron state without altering turn control. */
|
|
66005
|
+
#observeStopHook = async (input3) => {
|
|
66006
|
+
if (this.#closing || input3.hook_event_name !== "Stop")
|
|
66007
|
+
return {};
|
|
66008
|
+
if (Array.isArray(input3.session_crons)) {
|
|
66009
|
+
this.#sessionCronCount = input3.session_crons.length;
|
|
66010
|
+
this.#sessionCronsUnknown = false;
|
|
66011
|
+
}
|
|
66012
|
+
if (Array.isArray(input3.background_tasks) && input3.background_tasks.length === 0) {
|
|
66013
|
+
this.#awaitingTaskNotifications.clear();
|
|
66014
|
+
}
|
|
66015
|
+
return {};
|
|
66016
|
+
};
|
|
66017
|
+
#observeSessionCrons(message) {
|
|
66018
|
+
if (!isRecord14(message))
|
|
66019
|
+
return;
|
|
66020
|
+
if (message.type === "assistant" && isRecord14(message.message) && Array.isArray(message.message.content)) {
|
|
66021
|
+
for (const block of message.message.content) {
|
|
66022
|
+
if (isRecord14(block) && block.type === "tool_use" && typeof block.name === "string" && SESSION_CRON_TOOLS.has(block.name)) {
|
|
66023
|
+
this.#sessionCronsUnknown = true;
|
|
66024
|
+
return;
|
|
66025
|
+
}
|
|
66026
|
+
}
|
|
66027
|
+
return;
|
|
66028
|
+
}
|
|
66029
|
+
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)) {
|
|
66030
|
+
this.#sessionCronsUnknown = true;
|
|
66031
|
+
}
|
|
66032
|
+
}
|
|
65533
66033
|
#observeBackgroundTasks(message) {
|
|
65534
|
-
if (!
|
|
66034
|
+
if (!isRecord14(message) || message.type !== "system")
|
|
65535
66035
|
return;
|
|
65536
66036
|
if (message.subtype === "background_tasks_changed" && Array.isArray(message.tasks)) {
|
|
65537
|
-
|
|
65538
|
-
|
|
66037
|
+
const next = new Set(message.tasks.flatMap((task) => isRecord14(task) && typeof task.task_id === "string" ? [task.task_id] : []));
|
|
66038
|
+
const now = Date.now();
|
|
66039
|
+
this.#pruneExpiredAwaitingTaskNotifications(now);
|
|
66040
|
+
const expiresAtMs = now + this.#awaitingTaskNotificationTimeoutMs;
|
|
66041
|
+
for (const id3 of this.#backgroundTasks) {
|
|
66042
|
+
if (!next.has(id3))
|
|
66043
|
+
this.#awaitingTaskNotifications.set(id3, expiresAtMs);
|
|
66044
|
+
}
|
|
66045
|
+
for (const id3 of next) {
|
|
66046
|
+
this.#awaitingTaskNotifications.delete(id3);
|
|
66047
|
+
}
|
|
66048
|
+
this.#backgroundTasks = next;
|
|
66049
|
+
} else if (message.subtype === "task_started" && typeof message.task_id === "string" && message.is_backgrounded !== false) {
|
|
66050
|
+
this.#backgroundTasks.add(message.task_id);
|
|
66051
|
+
this.#awaitingTaskNotifications.delete(message.task_id);
|
|
66052
|
+
} else if (message.subtype === "task_updated" && typeof message.task_id === "string" && isRecord14(message.patch) && message.patch.is_backgrounded === true) {
|
|
65539
66053
|
this.#backgroundTasks.add(message.task_id);
|
|
66054
|
+
this.#awaitingTaskNotifications.delete(message.task_id);
|
|
65540
66055
|
} else if (message.subtype === "task_notification" && typeof message.task_id === "string" && ["completed", "failed", "stopped"].includes(String(message.status))) {
|
|
65541
66056
|
this.#backgroundTasks.delete(message.task_id);
|
|
66057
|
+
this.#awaitingTaskNotifications.delete(message.task_id);
|
|
65542
66058
|
}
|
|
65543
66059
|
}
|
|
65544
66060
|
/** Starts the Segment's autonomous Turn and releases the events it held, in native order. */
|
|
@@ -65550,7 +66066,7 @@ var ClaudeSdkTransport = class {
|
|
|
65550
66066
|
}
|
|
65551
66067
|
/** Remembers Workflow agent labels so their approvals can name the agent asking. */
|
|
65552
66068
|
#observeWorkflowAgents(message) {
|
|
65553
|
-
if (!
|
|
66069
|
+
if (!isRecord14(message) || message.type !== "system" || message.subtype !== "task_progress") {
|
|
65554
66070
|
return;
|
|
65555
66071
|
}
|
|
65556
66072
|
for (const agent of parseClaudeWorkflowAgents(message.workflow_progress) ?? []) {
|
|
@@ -65574,6 +66090,7 @@ var ClaudeSdkTransport = class {
|
|
|
65574
66090
|
try {
|
|
65575
66091
|
for await (const message of activeQuery) {
|
|
65576
66092
|
this.#observeBackgroundTasks(message);
|
|
66093
|
+
this.#observeSessionCrons(message);
|
|
65577
66094
|
this.#observeWorkflowAgents(message);
|
|
65578
66095
|
this.#observeSlashCommands(message);
|
|
65579
66096
|
this.#observeNativeCapabilities(message);
|
|
@@ -65621,7 +66138,7 @@ var ClaudeSdkTransport = class {
|
|
|
65621
66138
|
userMessageId: null,
|
|
65622
66139
|
live: false
|
|
65623
66140
|
});
|
|
65624
|
-
if (autonomous.userMessageId === null &&
|
|
66141
|
+
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
66142
|
autonomous.userMessageId = message.uuid;
|
|
65626
66143
|
}
|
|
65627
66144
|
const interpreted = autonomous.accumulator.consume(message);
|
|
@@ -65685,6 +66202,7 @@ var ClaudeSdkModelInspector = class {
|
|
|
65685
66202
|
#children = [];
|
|
65686
66203
|
#stderrTail = "";
|
|
65687
66204
|
#closeTimeoutMs;
|
|
66205
|
+
#inspectTimeoutMs;
|
|
65688
66206
|
#command;
|
|
65689
66207
|
#cwd;
|
|
65690
66208
|
#environment;
|
|
@@ -65697,6 +66215,7 @@ var ClaudeSdkModelInspector = class {
|
|
|
65697
66215
|
}
|
|
65698
66216
|
constructor(options) {
|
|
65699
66217
|
this.#closeTimeoutMs = options.closeTimeoutMs;
|
|
66218
|
+
this.#inspectTimeoutMs = options.inspectTimeoutMs ?? DEFAULT_MODEL_INSPECT_TIMEOUT_MS;
|
|
65700
66219
|
this.#command = options.command;
|
|
65701
66220
|
this.#cwd = options.cwd;
|
|
65702
66221
|
this.#environment = options.environment ?? process.env;
|
|
@@ -65753,19 +66272,26 @@ var ClaudeSdkModelInspector = class {
|
|
|
65753
66272
|
}
|
|
65754
66273
|
}
|
|
65755
66274
|
async inspect() {
|
|
65756
|
-
const
|
|
66275
|
+
const timeout = rejectAfter(this.#inspectTimeoutMs, "Claude SDK Model inspection timed out");
|
|
65757
66276
|
try {
|
|
65758
|
-
const
|
|
65759
|
-
|
|
65760
|
-
|
|
65761
|
-
|
|
65762
|
-
|
|
65763
|
-
|
|
65764
|
-
|
|
65765
|
-
|
|
65766
|
-
|
|
65767
|
-
|
|
66277
|
+
const activeQuery = this.#createQuery();
|
|
66278
|
+
return await Promise.race([
|
|
66279
|
+
(async () => {
|
|
66280
|
+
const initialized = await activeQuery.initializationResult();
|
|
66281
|
+
const candidate = activeQuery;
|
|
66282
|
+
const canSelectModel = Array.isArray(initialized.models) && typeof candidate.setModel === "function";
|
|
66283
|
+
const canSelectPermissionMode = typeof candidate.setPermissionMode === "function";
|
|
66284
|
+
const modelPicker = await readClaudeUserModelPicker(this.#environment);
|
|
66285
|
+
return {
|
|
66286
|
+
models: mergeClaudeModelPickerOptions(initialized.models, modelPicker),
|
|
66287
|
+
canSelectModel,
|
|
66288
|
+
canSelectPermissionMode
|
|
66289
|
+
};
|
|
66290
|
+
})(),
|
|
66291
|
+
timeout.promise
|
|
66292
|
+
]);
|
|
65768
66293
|
} finally {
|
|
66294
|
+
timeout.cancel();
|
|
65769
66295
|
await this.close();
|
|
65770
66296
|
}
|
|
65771
66297
|
}
|
|
@@ -65776,19 +66302,34 @@ var ClaudeSdkModelInspector = class {
|
|
|
65776
66302
|
}
|
|
65777
66303
|
async #close() {
|
|
65778
66304
|
this.#input.end();
|
|
65779
|
-
|
|
66305
|
+
try {
|
|
66306
|
+
this.#query?.close();
|
|
66307
|
+
} catch {
|
|
66308
|
+
}
|
|
65780
66309
|
for (const child of this.#children) {
|
|
65781
|
-
if (!processExited(child))
|
|
65782
|
-
|
|
66310
|
+
if (!processExited(child)) {
|
|
66311
|
+
try {
|
|
66312
|
+
child.kill("SIGTERM");
|
|
66313
|
+
} catch {
|
|
66314
|
+
}
|
|
66315
|
+
}
|
|
65783
66316
|
}
|
|
65784
66317
|
await Promise.race([
|
|
65785
66318
|
Promise.all(this.#children.map((child) => this.#waitForExit(child))),
|
|
65786
66319
|
delay(this.#closeTimeoutMs)
|
|
65787
66320
|
]);
|
|
65788
66321
|
for (const child of this.#children) {
|
|
65789
|
-
if (!processExited(child))
|
|
65790
|
-
|
|
66322
|
+
if (!processExited(child)) {
|
|
66323
|
+
try {
|
|
66324
|
+
child.kill("SIGKILL");
|
|
66325
|
+
} catch {
|
|
66326
|
+
}
|
|
66327
|
+
}
|
|
65791
66328
|
}
|
|
66329
|
+
await Promise.race([
|
|
66330
|
+
Promise.all(this.#children.map((child) => this.#waitForExit(child))),
|
|
66331
|
+
delay(Math.min(this.#closeTimeoutMs, 1e3))
|
|
66332
|
+
]);
|
|
65792
66333
|
this.#query = null;
|
|
65793
66334
|
}
|
|
65794
66335
|
#spawn(options) {
|
|
@@ -65828,9 +66369,7 @@ function createClaudePlanReview(request, interactionId, turnId) {
|
|
|
65828
66369
|
{
|
|
65829
66370
|
id: DECISION_ID,
|
|
65830
66371
|
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.",
|
|
66372
|
+
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
66373
|
options: [
|
|
65835
66374
|
{
|
|
65836
66375
|
value: "stay",
|
|
@@ -66314,11 +66853,11 @@ var ClaudeBackgroundCommandItems = class {
|
|
|
66314
66853
|
};
|
|
66315
66854
|
|
|
66316
66855
|
// dist/tool-lifecycle.js
|
|
66317
|
-
function
|
|
66856
|
+
function isRecord15(value) {
|
|
66318
66857
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
66319
66858
|
}
|
|
66320
66859
|
function stringField2(value, key) {
|
|
66321
|
-
return
|
|
66860
|
+
return isRecord15(value) && typeof value[key] === "string" ? value[key] : void 0;
|
|
66322
66861
|
}
|
|
66323
66862
|
function toolFailure(toolName) {
|
|
66324
66863
|
return {
|
|
@@ -66713,7 +67252,7 @@ var CONTEXT_USAGE_TTL_MS = 1e4;
|
|
|
66713
67252
|
var CONTEXT_USAGE_FAILURE_COOLDOWN_MS = 5e3;
|
|
66714
67253
|
var REQUEST_USAGE_RETRY_DELAYS_MS = [0, 100, 250, 500, 1e3];
|
|
66715
67254
|
var DEFAULT_CONTINUATION_QUIESCENCE_MS = 2e3;
|
|
66716
|
-
function
|
|
67255
|
+
function isRecord16(value) {
|
|
66717
67256
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
66718
67257
|
}
|
|
66719
67258
|
var SYNTHETIC_AUTONOMOUS_TURN_KEY_PATTERN = /^autonomous-\d+$/u;
|
|
@@ -66723,7 +67262,7 @@ function safeNonNegativeInteger2(value) {
|
|
|
66723
67262
|
function transcriptRequestUsage(messages, messageId) {
|
|
66724
67263
|
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
66725
67264
|
const entry = messages[index];
|
|
66726
|
-
if (!
|
|
67265
|
+
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
67266
|
continue;
|
|
66728
67267
|
}
|
|
66729
67268
|
const inputTokens = entry.message.usage.input_tokens;
|
|
@@ -66731,6 +67270,7 @@ function transcriptRequestUsage(messages, messageId) {
|
|
|
66731
67270
|
const cacheCreationInputTokens = entry.message.usage.cache_creation_input_tokens;
|
|
66732
67271
|
const cacheReadInputTokens = entry.message.usage.cache_read_input_tokens;
|
|
66733
67272
|
if (safeNonNegativeInteger2(inputTokens) && safeNonNegativeInteger2(outputTokens) && safeNonNegativeInteger2(cacheCreationInputTokens) && safeNonNegativeInteger2(cacheReadInputTokens)) {
|
|
67273
|
+
const promptCacheTtlSeconds = claudePromptCacheTtlSeconds(entry.message.usage);
|
|
66734
67274
|
return {
|
|
66735
67275
|
requestId: typeof entry.request_id === "string" && entry.request_id.length > 0 ? entry.request_id : messageId,
|
|
66736
67276
|
...typeof entry.message.model === "string" && entry.message.model.length > 0 ? { model: entry.message.model } : {},
|
|
@@ -66738,7 +67278,8 @@ function transcriptRequestUsage(messages, messageId) {
|
|
|
66738
67278
|
inputTokens,
|
|
66739
67279
|
outputTokens,
|
|
66740
67280
|
cacheCreationInputTokens,
|
|
66741
|
-
cacheReadInputTokens
|
|
67281
|
+
cacheReadInputTokens,
|
|
67282
|
+
...promptCacheTtlSeconds !== void 0 ? { promptCacheTtlSeconds } : {}
|
|
66742
67283
|
};
|
|
66743
67284
|
}
|
|
66744
67285
|
}
|
|
@@ -66747,7 +67288,7 @@ function transcriptRequestUsage(messages, messageId) {
|
|
|
66747
67288
|
function invalidState(message) {
|
|
66748
67289
|
return { code: "invalidState", message, retryable: false };
|
|
66749
67290
|
}
|
|
66750
|
-
function transportFailure(kind) {
|
|
67291
|
+
function transportFailure(kind, resetsAtUnix) {
|
|
66751
67292
|
if (kind === "authentication") {
|
|
66752
67293
|
return {
|
|
66753
67294
|
code: "authenticationRequired",
|
|
@@ -66762,6 +67303,30 @@ function transportFailure(kind) {
|
|
|
66762
67303
|
retryable: false
|
|
66763
67304
|
};
|
|
66764
67305
|
}
|
|
67306
|
+
const resetsAt = resetsAtUnix !== void 0 && Number.isSafeInteger(resetsAtUnix) && resetsAtUnix > 0 && resetsAtUnix <= 864e10 ? isoFromUnix(resetsAtUnix) : void 0;
|
|
67307
|
+
if (kind === "rateLimited") {
|
|
67308
|
+
return {
|
|
67309
|
+
code: "rateLimited",
|
|
67310
|
+
message: resetsAt ? `Claude Code rate limit reached (resets at ${resetsAt})` : "Claude Code rate limit reached",
|
|
67311
|
+
retryable: true,
|
|
67312
|
+
...resetsAt ? { resetsAt } : {}
|
|
67313
|
+
};
|
|
67314
|
+
}
|
|
67315
|
+
if (kind === "quotaExhausted") {
|
|
67316
|
+
return {
|
|
67317
|
+
code: "quotaExhausted",
|
|
67318
|
+
message: resetsAt ? `Claude Code usage limit reached (resets at ${resetsAt})` : "Claude Code usage limit reached",
|
|
67319
|
+
retryable: true,
|
|
67320
|
+
...resetsAt ? { resetsAt } : {}
|
|
67321
|
+
};
|
|
67322
|
+
}
|
|
67323
|
+
if (kind === "billing") {
|
|
67324
|
+
return {
|
|
67325
|
+
code: "quotaExhausted",
|
|
67326
|
+
message: "Claude Code billing or credit limit reached",
|
|
67327
|
+
retryable: false
|
|
67328
|
+
};
|
|
67329
|
+
}
|
|
66765
67330
|
return {
|
|
66766
67331
|
code: "nativeFailure",
|
|
66767
67332
|
message: kind === "textConflict" ? "Claude Code returned inconsistent streamed text" : kind === "cancellationUnproven" ? "Claude Code cancellation could not be proven" : "Claude Code Turn failed",
|
|
@@ -66982,6 +67547,7 @@ var ClaudeHarnessSession = class {
|
|
|
66982
67547
|
#usageGeneration = 0;
|
|
66983
67548
|
#latestUsage = null;
|
|
66984
67549
|
#lastAssistantResponseAtUnix;
|
|
67550
|
+
#promptCacheTtlSeconds;
|
|
66985
67551
|
#accountCreditsSupported;
|
|
66986
67552
|
#minimumContextUsedTokens = null;
|
|
66987
67553
|
#calibratedInputTokens = 0;
|
|
@@ -67002,8 +67568,9 @@ var ClaudeHarnessSession = class {
|
|
|
67002
67568
|
constructor(cwd, dependencies, closeTimeoutMs, onClosed, onPlanLimitObserved, options) {
|
|
67003
67569
|
this.#cwd = cwd;
|
|
67004
67570
|
this.#lastAssistantResponseAtUnix = options.usageHistory.lastResponseAtUnix;
|
|
67571
|
+
this.#promptCacheTtlSeconds = options.usageHistory.promptCacheTtlSeconds;
|
|
67005
67572
|
this.#accountCreditsSupported = options.accountCreditsSupported;
|
|
67006
|
-
const composerIndicators = claudePromptCacheIndicators(this.#accountCreditsSupported, this.#lastAssistantResponseAtUnix);
|
|
67573
|
+
const composerIndicators = claudePromptCacheIndicators(this.#accountCreditsSupported, this.#lastAssistantResponseAtUnix, this.#promptCacheTtlSeconds);
|
|
67007
67574
|
this.initialUsage = composerIndicators.length ? { composerIndicators } : null;
|
|
67008
67575
|
this.#latestUsage = this.initialUsage;
|
|
67009
67576
|
this.#pendingSessions = options.pendingSessions;
|
|
@@ -67108,7 +67675,7 @@ var ClaudeHarnessSession = class {
|
|
|
67108
67675
|
let ids;
|
|
67109
67676
|
try {
|
|
67110
67677
|
ids = new Set(messages.flatMap((message) => {
|
|
67111
|
-
if (!
|
|
67678
|
+
if (!isRecord16(message) || typeof message.uuid !== "string")
|
|
67112
67679
|
return [];
|
|
67113
67680
|
const queued = readClaudeQueuedCommand(message, this.#sessionId);
|
|
67114
67681
|
return queued ? [message.uuid, queued.sourceUuid] : [message.uuid];
|
|
@@ -67297,6 +67864,7 @@ var ClaudeHarnessSession = class {
|
|
|
67297
67864
|
cancellationRequested: false,
|
|
67298
67865
|
steersAwaitingNative: /* @__PURE__ */ new Set(),
|
|
67299
67866
|
usageRequestIds: /* @__PURE__ */ new Set(),
|
|
67867
|
+
promptCacheTtlObserved: false,
|
|
67300
67868
|
estimatedInputTokens: 0,
|
|
67301
67869
|
estimatedOutputTokens: 0,
|
|
67302
67870
|
estimatedCostUsd: 0,
|
|
@@ -67477,6 +68045,7 @@ var ClaudeHarnessSession = class {
|
|
|
67477
68045
|
cancellationRequested: false,
|
|
67478
68046
|
steersAwaitingNative: /* @__PURE__ */ new Set(),
|
|
67479
68047
|
usageRequestIds: /* @__PURE__ */ new Set(),
|
|
68048
|
+
promptCacheTtlObserved: false,
|
|
67480
68049
|
estimatedInputTokens: 0,
|
|
67481
68050
|
estimatedOutputTokens: 0,
|
|
67482
68051
|
estimatedCostUsd: 0,
|
|
@@ -68182,8 +68751,13 @@ var ClaudeHarnessSession = class {
|
|
|
68182
68751
|
}
|
|
68183
68752
|
#handleTurnEvent(active2, event) {
|
|
68184
68753
|
if (event.type === "usage.request") {
|
|
68185
|
-
if (this.#phase !== "closed" && this.#phase !== "faulted")
|
|
68754
|
+
if (this.#phase !== "closed" && this.#phase !== "faulted") {
|
|
68186
68755
|
this.#meterUsage(event.record);
|
|
68756
|
+
if (event.promptCacheTtlSeconds !== void 0) {
|
|
68757
|
+
active2.promptCacheTtlObserved = true;
|
|
68758
|
+
this.#observePromptCacheTtl(event.promptCacheTtlSeconds);
|
|
68759
|
+
}
|
|
68760
|
+
}
|
|
68187
68761
|
return;
|
|
68188
68762
|
}
|
|
68189
68763
|
if (this.#active !== active2 || this.#phase === "closed" || this.#phase === "faulted")
|
|
@@ -68231,6 +68805,10 @@ var ClaudeHarnessSession = class {
|
|
|
68231
68805
|
return;
|
|
68232
68806
|
case "message.completed": {
|
|
68233
68807
|
if (!event.localCommand) {
|
|
68808
|
+
if (event.lastRequestUsage?.promptCacheTtlSeconds !== void 0) {
|
|
68809
|
+
active2.promptCacheTtlObserved = true;
|
|
68810
|
+
this.#promptCacheTtlSeconds = event.lastRequestUsage.promptCacheTtlSeconds;
|
|
68811
|
+
}
|
|
68234
68812
|
this.#lastAssistantResponseAtUnix = Math.floor(Date.now() / 1e3);
|
|
68235
68813
|
this.publishAccountCreditsSupport(this.#accountCreditsSupported);
|
|
68236
68814
|
}
|
|
@@ -68238,7 +68816,7 @@ var ClaudeHarnessSession = class {
|
|
|
68238
68816
|
if (event.lastRequestUsage) {
|
|
68239
68817
|
this.#requestUsageBoundary += 1;
|
|
68240
68818
|
this.#applyLatestRequestUsage(active2, event.lastRequestUsage);
|
|
68241
|
-
} else {
|
|
68819
|
+
} else if (!event.localCommand) {
|
|
68242
68820
|
this.#requestLatestRequestUsage(active2, event.messageId);
|
|
68243
68821
|
}
|
|
68244
68822
|
if (event.checkpointId)
|
|
@@ -68427,6 +69005,19 @@ var ClaudeHarnessSession = class {
|
|
|
68427
69005
|
};
|
|
68428
69006
|
pending = { type: "approval", interaction, request };
|
|
68429
69007
|
} else if (request.type === "planApproval") {
|
|
69008
|
+
if (request.plan) {
|
|
69009
|
+
const item = {
|
|
69010
|
+
type: "agentMessage",
|
|
69011
|
+
itemId: hostItemIdSchema.parse(this.#randomUUID()),
|
|
69012
|
+
text: request.plan
|
|
69013
|
+
};
|
|
69014
|
+
this.#event({ type: "item.started", turnId: active2.command.turnId, item });
|
|
69015
|
+
this.#event({
|
|
69016
|
+
type: "item.completed",
|
|
69017
|
+
turnId: active2.command.turnId,
|
|
69018
|
+
snapshot: { item, outcome: { status: "succeeded" } }
|
|
69019
|
+
});
|
|
69020
|
+
}
|
|
68430
69021
|
pending = {
|
|
68431
69022
|
type: "planApproval",
|
|
68432
69023
|
interaction: createClaudePlanReview(request, interactionId, active2.command.turnId),
|
|
@@ -68647,6 +69238,7 @@ var ClaudeHarnessSession = class {
|
|
|
68647
69238
|
}),
|
|
68648
69239
|
cancellationRequested: false,
|
|
68649
69240
|
usageRequestIds: /* @__PURE__ */ new Set(),
|
|
69241
|
+
promptCacheTtlObserved: false,
|
|
68650
69242
|
estimatedInputTokens: 0,
|
|
68651
69243
|
estimatedOutputTokens: 0,
|
|
68652
69244
|
estimatedCostUsd: 0,
|
|
@@ -68668,7 +69260,14 @@ var ClaudeHarnessSession = class {
|
|
|
68668
69260
|
/** Live native events outside a requested Root Segment; settlements stay Thread-level. */
|
|
68669
69261
|
#deliverLiveEvent(target2, event) {
|
|
68670
69262
|
if (event.type === "usage.request") {
|
|
68671
|
-
this.#
|
|
69263
|
+
if (this.#phase !== "closed" && this.#phase !== "faulted") {
|
|
69264
|
+
this.#meterUsage(event.record);
|
|
69265
|
+
if (event.promptCacheTtlSeconds !== void 0) {
|
|
69266
|
+
if (target2 && this.#active === target2)
|
|
69267
|
+
target2.promptCacheTtlObserved = true;
|
|
69268
|
+
this.#observePromptCacheTtl(event.promptCacheTtlSeconds);
|
|
69269
|
+
}
|
|
69270
|
+
}
|
|
68672
69271
|
return;
|
|
68673
69272
|
}
|
|
68674
69273
|
if (target2 && this.#active === target2) {
|
|
@@ -68719,9 +69318,10 @@ var ClaudeHarnessSession = class {
|
|
|
68719
69318
|
if (this.#active !== active2 || this.#hardCancelTask)
|
|
68720
69319
|
return;
|
|
68721
69320
|
active2.rootSegmentActive = false;
|
|
69321
|
+
active2.promptCacheTtlObserved = false;
|
|
68722
69322
|
if (active2.cancellation) {
|
|
68723
69323
|
if (result.status === "failed") {
|
|
68724
|
-
active2.cancellation.failure ??= transportFailure(result.kind);
|
|
69324
|
+
active2.cancellation.failure ??= transportFailure(result.kind, result.resetsAtUnix);
|
|
68725
69325
|
}
|
|
68726
69326
|
active2.cancellation.interrupting = false;
|
|
68727
69327
|
this.#clearCancelEscalation();
|
|
@@ -68739,7 +69339,7 @@ var ClaudeHarnessSession = class {
|
|
|
68739
69339
|
} else if (result.status === "cancelled") {
|
|
68740
69340
|
this.#finish(active2, { status: "cancelled", reason: result.reason });
|
|
68741
69341
|
} else {
|
|
68742
|
-
this.#finishFailed(active2, transportFailure(result.kind));
|
|
69342
|
+
this.#finishFailed(active2, transportFailure(result.kind, result.resetsAtUnix));
|
|
68743
69343
|
}
|
|
68744
69344
|
}
|
|
68745
69345
|
#requestContextUsage(transport, turnId, retryDelaysMs, detail = "full") {
|
|
@@ -68863,9 +69463,16 @@ var ClaudeHarnessSession = class {
|
|
|
68863
69463
|
if (promptTokens > 0)
|
|
68864
69464
|
this.#minimumContextUsedTokens = promptTokens;
|
|
68865
69465
|
const cacheHitRatePercent = claudeCacheHitRatePercent(usage);
|
|
69466
|
+
if (usage.promptCacheTtlSeconds !== void 0) {
|
|
69467
|
+
active2.promptCacheTtlObserved = true;
|
|
69468
|
+
this.#promptCacheTtlSeconds = usage.promptCacheTtlSeconds;
|
|
69469
|
+
}
|
|
69470
|
+
const composerIndicators = claudePromptCacheIndicators(this.#accountCreditsSupported, this.#lastAssistantResponseAtUnix, this.#promptCacheTtlSeconds);
|
|
69471
|
+
const indicatorChanged = composerIndicators[0]?.expiresAtUnix !== this.#latestUsage?.composerIndicators?.[0]?.expiresAtUnix;
|
|
68866
69472
|
const contextWindowTokens = this.#latestUsage?.contextWindowTokens;
|
|
68867
69473
|
this.#mergeAndPublishUsage({
|
|
68868
69474
|
...cacheHitRatePercent !== void 0 ? { cacheHitRatePercent } : {},
|
|
69475
|
+
...indicatorChanged ? { composerIndicators } : {},
|
|
68869
69476
|
inputTokens: this.#calibratedInputTokens + active2.estimatedInputTokens,
|
|
68870
69477
|
outputTokens: this.#calibratedOutputTokens + active2.estimatedOutputTokens,
|
|
68871
69478
|
...active2.estimatedCostAvailable ? { totalCostUsd: this.#calibratedCostUsd + active2.estimatedCostUsd } : {},
|
|
@@ -68902,6 +69509,13 @@ var ClaudeHarnessSession = class {
|
|
|
68902
69509
|
const cacheHitRatePercent = claudeCacheHitRatePercent(event.lastRequestUsage);
|
|
68903
69510
|
if (cacheHitRatePercent !== void 0)
|
|
68904
69511
|
delta.cacheHitRatePercent = cacheHitRatePercent;
|
|
69512
|
+
if (!active2.promptCacheTtlObserved && event.lastRequestUsage.promptCacheTtlSeconds !== void 0) {
|
|
69513
|
+
this.#promptCacheTtlSeconds = event.lastRequestUsage.promptCacheTtlSeconds;
|
|
69514
|
+
const composerIndicators = claudePromptCacheIndicators(this.#accountCreditsSupported, this.#lastAssistantResponseAtUnix, this.#promptCacheTtlSeconds);
|
|
69515
|
+
if (composerIndicators[0]?.expiresAtUnix !== this.#latestUsage?.composerIndicators?.[0]?.expiresAtUnix) {
|
|
69516
|
+
delta.composerIndicators = composerIndicators;
|
|
69517
|
+
}
|
|
69518
|
+
}
|
|
68905
69519
|
}
|
|
68906
69520
|
if (this.#transport && this.#minimumContextUsedTokens !== null && event.modelUsage?.some(({ contextWindowTokens }) => contextWindowTokens !== void 0)) {
|
|
68907
69521
|
this.#requestContextUsage(this.#transport, active2.command.turnId, [0], "summary");
|
|
@@ -68920,11 +69534,15 @@ var ClaudeHarnessSession = class {
|
|
|
68920
69534
|
if (effective)
|
|
68921
69535
|
this.publishPlanLimit(effective);
|
|
68922
69536
|
}
|
|
69537
|
+
#observePromptCacheTtl(ttlSeconds) {
|
|
69538
|
+
this.#promptCacheTtlSeconds = ttlSeconds;
|
|
69539
|
+
this.publishAccountCreditsSupport(this.#accountCreditsSupported);
|
|
69540
|
+
}
|
|
68923
69541
|
publishAccountCreditsSupport(supported) {
|
|
68924
69542
|
if (this.#phase !== "open")
|
|
68925
69543
|
return;
|
|
68926
69544
|
this.#accountCreditsSupported = supported;
|
|
68927
|
-
const composerIndicators = claudePromptCacheIndicators(supported, this.#lastAssistantResponseAtUnix);
|
|
69545
|
+
const composerIndicators = claudePromptCacheIndicators(supported, this.#lastAssistantResponseAtUnix, this.#promptCacheTtlSeconds);
|
|
68928
69546
|
if (composerIndicators[0]?.expiresAtUnix === this.#latestUsage?.composerIndicators?.[0]?.expiresAtUnix)
|
|
68929
69547
|
return;
|
|
68930
69548
|
this.#mergeAndPublishUsage({ composerIndicators }, this.#active?.command.turnId);
|
|
@@ -69172,6 +69790,81 @@ var ClaudeCodeAdapter = class {
|
|
|
69172
69790
|
resolveCandidate: (nativeSessionId) => this.#importScope.resolve((signal) => this.#importIndex.resolve(nativeSessionId, signal))
|
|
69173
69791
|
});
|
|
69174
69792
|
usageStatistics;
|
|
69793
|
+
async readSnapshot(input3) {
|
|
69794
|
+
if (this.#closePromise) {
|
|
69795
|
+
return { ok: false, error: invalidState("Claude Code Adapter is closed") };
|
|
69796
|
+
}
|
|
69797
|
+
if (input3.nativeRef.harnessId !== this.harnessId || input3.nativeRef.nativeSessionId.trim().length === 0) {
|
|
69798
|
+
return {
|
|
69799
|
+
ok: false,
|
|
69800
|
+
error: {
|
|
69801
|
+
code: "invalidRequest",
|
|
69802
|
+
message: "Claude Code Native Session reference is invalid",
|
|
69803
|
+
retryable: false
|
|
69804
|
+
}
|
|
69805
|
+
};
|
|
69806
|
+
}
|
|
69807
|
+
let messages;
|
|
69808
|
+
try {
|
|
69809
|
+
messages = await this.#dependencies.readSessionMessages({
|
|
69810
|
+
cwd: input3.cwd,
|
|
69811
|
+
sessionId: input3.nativeRef.nativeSessionId
|
|
69812
|
+
}) ?? [];
|
|
69813
|
+
} catch {
|
|
69814
|
+
return {
|
|
69815
|
+
ok: false,
|
|
69816
|
+
error: {
|
|
69817
|
+
code: "nativeFailure",
|
|
69818
|
+
message: "Claude Code history could not be read",
|
|
69819
|
+
retryable: true
|
|
69820
|
+
}
|
|
69821
|
+
};
|
|
69822
|
+
}
|
|
69823
|
+
if (messages.length === 0 && isPendingClaudeSession(input3.nativeRef)) {
|
|
69824
|
+
try {
|
|
69825
|
+
const pending = await this.#pendingSessions.read(input3.nativeRef, input3.cwd);
|
|
69826
|
+
if (!pending.started)
|
|
69827
|
+
return { ok: true, value: { turns: [] } };
|
|
69828
|
+
} catch {
|
|
69829
|
+
return {
|
|
69830
|
+
ok: false,
|
|
69831
|
+
error: {
|
|
69832
|
+
code: "sessionNotFound",
|
|
69833
|
+
message: "Claude Code pending Session is unavailable",
|
|
69834
|
+
retryable: false
|
|
69835
|
+
}
|
|
69836
|
+
};
|
|
69837
|
+
}
|
|
69838
|
+
}
|
|
69839
|
+
if (messages.length === 0) {
|
|
69840
|
+
return {
|
|
69841
|
+
ok: false,
|
|
69842
|
+
error: {
|
|
69843
|
+
code: "sessionNotFound",
|
|
69844
|
+
message: "Claude Code Native Session is unavailable",
|
|
69845
|
+
retryable: false
|
|
69846
|
+
}
|
|
69847
|
+
};
|
|
69848
|
+
}
|
|
69849
|
+
try {
|
|
69850
|
+
return {
|
|
69851
|
+
ok: true,
|
|
69852
|
+
value: {
|
|
69853
|
+
...mapClaudeSnapshot(messages, input3.nativeRef.nativeSessionId),
|
|
69854
|
+
persistentPlan: true
|
|
69855
|
+
}
|
|
69856
|
+
};
|
|
69857
|
+
} catch {
|
|
69858
|
+
return {
|
|
69859
|
+
ok: false,
|
|
69860
|
+
error: {
|
|
69861
|
+
code: "protocolError",
|
|
69862
|
+
message: "Claude Code history is invalid",
|
|
69863
|
+
retryable: false
|
|
69864
|
+
}
|
|
69865
|
+
};
|
|
69866
|
+
}
|
|
69867
|
+
}
|
|
69175
69868
|
subagents = {
|
|
69176
69869
|
readSnapshot: async (input3) => {
|
|
69177
69870
|
if (input3.parent.harnessId !== this.harnessId || input3.nativeSubagentId.trim().length === 0) {
|
|
@@ -69656,10 +70349,11 @@ var ClaudeCodeAdapter = class {
|
|
|
69656
70349
|
const messages = await this.#dependencies.readSessionMessages({ cwd, sessionId });
|
|
69657
70350
|
if (messages === null)
|
|
69658
70351
|
return { requests: [], complete: false };
|
|
69659
|
-
const
|
|
70352
|
+
const promptCache = claudePromptCacheFromMessages(messages);
|
|
69660
70353
|
return {
|
|
69661
70354
|
...claudeUsageHistory(messages),
|
|
69662
|
-
...lastResponseAtUnix !== void 0 ? { lastResponseAtUnix } : {}
|
|
70355
|
+
...promptCache.lastResponseAtUnix !== void 0 ? { lastResponseAtUnix: promptCache.lastResponseAtUnix } : {},
|
|
70356
|
+
...promptCache.ttlSeconds !== void 0 ? { promptCacheTtlSeconds: promptCache.ttlSeconds } : {}
|
|
69663
70357
|
};
|
|
69664
70358
|
} catch {
|
|
69665
70359
|
return { requests: [], complete: false };
|