@liberseek/boft-cli-win32-arm64 0.6.0 → 0.6.2

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.
@@ -9,6 +9,58 @@ var __export = (target, all) => {
9
9
  import { randomUUID } from "node:crypto";
10
10
  import path10 from "node:path";
11
11
 
12
+ // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
13
+ var AGENT_METHODS = {
14
+ initialize: "initialize",
15
+ authenticate: "authenticate",
16
+ providers_list: "providers/list",
17
+ providers_set: "providers/set",
18
+ providers_disable: "providers/disable",
19
+ session_new: "session/new",
20
+ session_load: "session/load",
21
+ session_set_mode: "session/set_mode",
22
+ session_set_config_option: "session/set_config_option",
23
+ session_prompt: "session/prompt",
24
+ session_cancel: "session/cancel",
25
+ mcp_message: "mcp/message",
26
+ session_list: "session/list",
27
+ session_delete: "session/delete",
28
+ session_fork: "session/fork",
29
+ session_resume: "session/resume",
30
+ session_close: "session/close",
31
+ logout: "logout",
32
+ nes_start: "nes/start",
33
+ nes_suggest: "nes/suggest",
34
+ nes_accept: "nes/accept",
35
+ nes_reject: "nes/reject",
36
+ nes_close: "nes/close",
37
+ document_did_open: "document/didOpen",
38
+ document_did_change: "document/didChange",
39
+ document_did_close: "document/didClose",
40
+ document_did_save: "document/didSave",
41
+ document_did_focus: "document/didFocus"
42
+ };
43
+ var CLIENT_METHODS = {
44
+ session_request_permission: "session/request_permission",
45
+ session_update: "session/update",
46
+ fs_write_text_file: "fs/write_text_file",
47
+ fs_read_text_file: "fs/read_text_file",
48
+ terminal_create: "terminal/create",
49
+ terminal_output: "terminal/output",
50
+ terminal_release: "terminal/release",
51
+ terminal_wait_for_exit: "terminal/wait_for_exit",
52
+ terminal_kill: "terminal/kill",
53
+ mcp_connect: "mcp/connect",
54
+ mcp_message: "mcp/message",
55
+ mcp_disconnect: "mcp/disconnect",
56
+ elicitation_create: "elicitation/create",
57
+ elicitation_complete: "elicitation/complete"
58
+ };
59
+ var PROTOCOL_METHODS = {
60
+ cancel_request: "$/cancel_request"
61
+ };
62
+ var PROTOCOL_VERSION = 1;
63
+
12
64
  // ../../../node_modules/zod/v4/classic/external.js
13
65
  var external_exports = {};
14
66
  __export(external_exports, {
@@ -14523,1420 +14575,375 @@ function date4(params) {
14523
14575
  // ../../../node_modules/zod/v4/classic/external.js
14524
14576
  config(en_default());
14525
14577
 
14526
- // ../../shared-contracts/dist/version.js
14527
- var WORKSPACE_CONTRACT_VERSION = 1;
14528
-
14529
- // ../../shared-contracts/dist/ids.js
14530
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14531
- message: "Identifier must not be empty or whitespace"
14532
- });
14533
- var harnessIdSchema = opaqueIdSchema.brand();
14534
- var hostThreadIdSchema = opaqueIdSchema.brand();
14535
- var hostTurnIdSchema = opaqueIdSchema.brand();
14536
- var hostItemIdSchema = opaqueIdSchema.brand();
14537
- var hostInteractionIdSchema = opaqueIdSchema.brand();
14538
-
14539
- // ../../shared-contracts/dist/thread-usage.js
14540
- var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14541
- var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
14542
- var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
14543
- var threadUsageSnapshotSchema = external_exports.object({
14544
- inputTokens: nonNegativeSafeIntegerSchema.optional(),
14545
- cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
14546
- cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
14547
- outputTokens: nonNegativeSafeIntegerSchema.optional(),
14548
- outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14549
- reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
14550
- totalTokens: nonNegativeSafeIntegerSchema.optional(),
14551
- totalCostUsd: finiteNonNegativeNumberSchema.optional(),
14552
- cacheHitRatePercent: cacheHitRatePercentSchema.optional(),
14553
- contextWindowTokens: nonNegativeSafeIntegerSchema.optional(),
14554
- contextUsedTokens: nonNegativeSafeIntegerSchema.optional(),
14555
- planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
14556
- planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
14557
- planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
14558
- planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
14559
- }).strict().superRefine((usage, context) => {
14560
- if (Object.keys(usage).length === 0) {
14561
- context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
14562
- }
14563
- const hasContextUsed = usage.contextUsedTokens !== void 0;
14564
- const hasContextWindow = usage.contextWindowTokens !== void 0;
14565
- if (hasContextUsed !== hasContextWindow) {
14566
- context.addIssue({
14567
- code: "custom",
14568
- message: "Thread Usage context fields must be provided together",
14569
- path: [hasContextUsed ? "contextWindowTokens" : "contextUsedTokens"]
14570
- });
14571
- }
14572
- if (usage.contextWindowTokens === 0) {
14573
- context.addIssue({
14574
- code: "custom",
14575
- message: "Thread Usage contextWindowTokens must be greater than zero",
14576
- path: ["contextWindowTokens"]
14577
- });
14578
- }
14579
- if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
14580
- context.addIssue({
14581
- code: "custom",
14582
- message: "Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent",
14583
- path: ["planFiveHourResetsAtUnix"]
14584
- });
14585
- }
14586
- if (usage.planSevenDayResetsAtUnix !== void 0 && usage.planSevenDayUsedPercent === void 0) {
14578
+ // ../../../node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.js
14579
+ var skippedItem = /* @__PURE__ */ Symbol("skippedItem");
14580
+ function defaultOnError(schema, fallback) {
14581
+ return schema.catch(fallback);
14582
+ }
14583
+ function requiredDefaultOnError(schema, fallback) {
14584
+ const schemaWithCatch = schema.catch(fallback);
14585
+ return external_exports.unknown().transform((value, context) => {
14586
+ if (value !== void 0)
14587
+ return schemaWithCatch.parse(value);
14587
14588
  context.addIssue({
14588
14589
  code: "custom",
14589
- message: "Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent",
14590
- path: ["planSevenDayResetsAtUnix"]
14590
+ message: "Required value is missing"
14591
14591
  });
14592
+ return external_exports.NEVER;
14593
+ });
14594
+ }
14595
+ function stringTag(value, key) {
14596
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
14597
+ return void 0;
14592
14598
  }
14593
- });
14594
- var usagePercentSchema = external_exports.number().finite().min(0).max(100);
14595
- var accountCreditsProductUsageSchema = external_exports.object({
14596
- product: external_exports.string().min(1),
14597
- usagePercent: usagePercentSchema,
14598
- resetsAt: external_exports.string().min(1).optional()
14599
- }).strict();
14600
- var accountResetCreditsSchema = external_exports.object({
14601
- availableCount: external_exports.number().int().safe().positive(),
14602
- nextExpiresAt: external_exports.string().min(1).optional(),
14603
- expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
14604
- }).strict();
14605
- var accountCreditsSnapshotSchema = external_exports.object({
14606
- /** Native label when the primary limit is scoped to a model or product group. */
14607
- label: external_exports.string().min(1).optional(),
14608
- usedPercent: usagePercentSchema,
14609
- resetsAt: external_exports.string().min(1).optional(),
14610
- periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
14611
- productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
14612
- resetCredits: accountResetCreditsSchema.optional()
14613
- }).strict();
14614
- var threadUsageInspectionParamsSchema = external_exports.object({
14615
- threadId: hostThreadIdSchema,
14616
- refresh: external_exports.literal("exact").optional()
14617
- }).strict();
14618
- var threadUsageInspectionSchema = external_exports.object({
14619
- threadId: hostThreadIdSchema,
14620
- usage: threadUsageSnapshotSchema.nullable(),
14621
- accountCredits: accountCreditsSnapshotSchema.optional()
14622
- }).strict();
14623
-
14624
- // ../../shared-contracts/dist/harness-accounts.js
14625
- var harnessAccountSnapshotSchema = external_exports.object({
14626
- email: external_exports.string().trim().min(1).max(320).optional(),
14627
- label: external_exports.string().trim().min(1).max(256).optional(),
14628
- plan: external_exports.string().trim().min(1).max(128).optional(),
14629
- credits: accountCreditsSnapshotSchema
14630
- }).strict();
14631
- var harnessAccountListParamsSchema = external_exports.object({}).strict();
14632
- var harnessAccountListResultSchema = external_exports.object({
14633
- accounts: external_exports.array(harnessAccountSnapshotSchema.extend({
14634
- harnessId: harnessIdSchema,
14635
- harnessName: external_exports.string().min(1)
14636
- })).max(128)
14637
- }).strict();
14638
-
14639
- // ../../shared-contracts/dist/json-value.js
14640
- function rejectExplicitUndefined(keys) {
14641
- return (value, context) => {
14642
- for (const key of keys) {
14643
- if (Object.hasOwn(value, key) && value[key] === void 0) {
14644
- context.addIssue({
14645
- code: "custom",
14646
- path: [key],
14647
- message: "Explicit undefined is not valid JSON"
14648
- });
14649
- }
14599
+ const tag = value[key];
14600
+ return typeof tag === "string" ? tag : void 0;
14601
+ }
14602
+ function excludeKnownTags(schema, key, knownTags) {
14603
+ return schema.superRefine((value, context) => {
14604
+ const tag = stringTag(value, key);
14605
+ if (tag !== void 0 && knownTags.includes(tag)) {
14606
+ context.addIssue({
14607
+ code: "custom",
14608
+ path: [key],
14609
+ message: `${key} ${JSON.stringify(tag)} is reserved by a known variant, but the value does not match that variant's schema`
14610
+ });
14650
14611
  }
14651
- };
14612
+ });
14652
14613
  }
14653
- var jsonPrimitiveSchema = external_exports.union([
14654
- external_exports.string(),
14655
- external_exports.number(),
14656
- external_exports.boolean(),
14657
- external_exports.null()
14658
- ]);
14659
- function hasNoCircularReferences(value) {
14660
- const ancestors = /* @__PURE__ */ new WeakSet();
14661
- const stack = [{ value, leaving: false }];
14662
- try {
14663
- while (stack.length > 0) {
14664
- const frame = stack.pop();
14665
- if (!frame)
14666
- break;
14667
- if (frame.leaving) {
14668
- ancestors.delete(frame.value);
14669
- continue;
14614
+ function preserveCustomPayload(schema, key, knownTags) {
14615
+ return external_exports.unknown().transform((value, context) => {
14616
+ const result = schema.safeParse(value);
14617
+ if (!result.success) {
14618
+ for (const issue2 of result.error.issues) {
14619
+ context.addIssue({ ...issue2, input: value });
14670
14620
  }
14671
- if (typeof frame.value !== "object" || frame.value === null)
14672
- continue;
14673
- if (ancestors.has(frame.value))
14674
- return false;
14675
- ancestors.add(frame.value);
14676
- stack.push({ value: frame.value, leaving: true });
14677
- for (const child of Object.values(frame.value)) {
14678
- stack.push({ value: child, leaving: false });
14621
+ return external_exports.NEVER;
14622
+ }
14623
+ const output = result.data;
14624
+ const tag = stringTag(value, key);
14625
+ if (tag !== void 0 && !knownTags.includes(tag)) {
14626
+ const raw = value;
14627
+ for (const [property, rawValue] of Object.entries(raw)) {
14628
+ if (property === "__proto__")
14629
+ continue;
14630
+ if (!Object.hasOwn(output, property))
14631
+ output[property] = rawValue;
14679
14632
  }
14680
14633
  }
14681
- } catch {
14682
- return false;
14683
- }
14684
- return true;
14634
+ return output;
14635
+ });
14636
+ }
14637
+ function vecSkipError(itemSchema) {
14638
+ return external_exports.array(itemSchema.catch(skippedItem)).transform((items) => items.filter((item) => item !== skippedItem));
14685
14639
  }
14686
- var nonCircularSchema = external_exports.custom(hasNoCircularReferences, {
14687
- message: "JSON value must not contain circular references"
14688
- });
14689
- var recursiveJsonValueSchema = external_exports.lazy(() => external_exports.union([
14690
- jsonPrimitiveSchema,
14691
- external_exports.array(recursiveJsonValueSchema),
14692
- external_exports.record(external_exports.string(), recursiveJsonValueSchema)
14693
- ]));
14694
- var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
14695
- var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
14696
- var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
14697
-
14698
- // ../../shared-contracts/dist/errors.js
14699
- var codexhostErrorSchema = external_exports.strictObject({
14700
- code: external_exports.string().min(1),
14701
- message: external_exports.string().min(1),
14702
- retryable: external_exports.boolean(),
14703
- diagnostic: external_exports.string().min(1).optional(),
14704
- stage: external_exports.string().min(1).optional(),
14705
- durationMs: external_exports.number().int().nonnegative().optional(),
14706
- stderrTail: external_exports.string().min(1).optional()
14707
- }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
14708
14640
 
14709
- // ../../shared-contracts/dist/harness-permission-modes.js
14710
- var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
14711
- var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
14712
- var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
14713
- var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
14714
- var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14715
- message: "Value must not be empty or whitespace"
14641
+ // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js
14642
+ var zRequestId = union([number2(), string2()]).nullable();
14643
+ var zSessionId = string2();
14644
+ var zWriteTextFileRequest = object({
14645
+ sessionId: zSessionId,
14646
+ path: string2(),
14647
+ content: string2(),
14648
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14716
14649
  });
14717
- var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
14718
- var harnessPermissionModeSchema = external_exports.object({
14719
- id: harnessPermissionModeIdSchema,
14720
- label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
14721
- description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
14722
- dangerous: external_exports.boolean().optional()
14723
- }).strict();
14724
- var harnessPermissionModeCatalogSchema = external_exports.object({
14725
- modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
14726
- defaultModeId: harnessPermissionModeIdSchema
14727
- }).strict().superRefine((catalog, context) => {
14728
- const ids = /* @__PURE__ */ new Set();
14729
- for (const [index, mode] of catalog.modes.entries()) {
14730
- if (ids.has(mode.id)) {
14731
- context.addIssue({
14732
- code: "custom",
14733
- message: "Permission Mode IDs must be unique",
14734
- path: ["modes", index, "id"]
14735
- });
14736
- }
14737
- ids.add(mode.id);
14738
- }
14739
- if (!ids.has(catalog.defaultModeId)) {
14740
- context.addIssue({
14741
- code: "custom",
14742
- message: "Default Permission Mode must exist in the catalog",
14743
- path: ["defaultModeId"]
14744
- });
14745
- }
14650
+ var zReadTextFileRequest = object({
14651
+ sessionId: zSessionId,
14652
+ path: string2(),
14653
+ line: defaultOnError(int().gte(0).max(4294967295, {
14654
+ error: "Invalid value: Expected uint32 to be <= 4294967295"
14655
+ }).nullish(), () => void 0),
14656
+ limit: defaultOnError(int().gte(0).max(4294967295, {
14657
+ error: "Invalid value: Expected uint32 to be <= 4294967295"
14658
+ }).nullish(), () => void 0),
14659
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14746
14660
  });
14747
- var threadPermissionModeSelectParamsSchema = external_exports.object({
14748
- threadId: hostThreadIdSchema,
14749
- permissionModeId: harnessPermissionModeIdSchema
14750
- }).strict();
14751
-
14752
- // ../../shared-contracts/dist/harness-models.js
14753
- var HARNESS_MODEL_REF_MAX_LENGTH = 512;
14754
- var HARNESS_MODEL_LABEL_MAX_LENGTH = 256;
14755
- var HARNESS_THINKING_OPTION_ID_MAX_LENGTH = 128;
14756
- var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
14757
- var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
14758
- message: "Value must not be empty or whitespace"
14661
+ var zToolCallId = string2();
14662
+ var zToolKind = union([
14663
+ literal("read"),
14664
+ literal("edit"),
14665
+ literal("delete"),
14666
+ literal("move"),
14667
+ literal("search"),
14668
+ literal("execute"),
14669
+ literal("think"),
14670
+ literal("fetch"),
14671
+ literal("switch_mode"),
14672
+ literal("other")
14673
+ ]);
14674
+ var zToolCallStatus = union([
14675
+ literal("pending"),
14676
+ literal("in_progress"),
14677
+ literal("completed"),
14678
+ literal("failed")
14679
+ ]);
14680
+ var zRole = union([literal("assistant"), literal("user")]);
14681
+ var zAnnotations = object({
14682
+ audience: defaultOnError(vecSkipError(zRole).nullish(), () => void 0),
14683
+ lastModified: defaultOnError(string2().nullish(), () => void 0),
14684
+ priority: defaultOnError(number2().nullish(), () => void 0),
14685
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14759
14686
  });
14760
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
14761
- var harnessModelRefSchema = external_exports.object({
14762
- id: harnessModelRefIdSchema
14763
- }).strict();
14764
- var harnessThinkingOptionIdSchema = nonBlankTextSchema2.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
14765
- var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
14766
- var harnessThinkingOptionSchema = external_exports.object({
14767
- id: harnessThinkingOptionIdSchema,
14768
- label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH)
14769
- }).strict();
14770
- var harnessModelSchema = external_exports.object({
14771
- ref: harnessModelRefSchema,
14772
- label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
14773
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
14774
- supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
14775
- }).strict();
14776
- var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
14777
- const ids = /* @__PURE__ */ new Set();
14778
- for (const [index, option] of options.entries()) {
14779
- if (ids.has(option.id)) {
14780
- context.addIssue({
14781
- code: "custom",
14782
- message: "Thinking option IDs must be unique",
14783
- path: [index, "id"]
14784
- });
14785
- }
14786
- ids.add(option.id);
14787
- }
14687
+ var zTextContent = object({
14688
+ annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
14689
+ text: string2(),
14690
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14788
14691
  });
14789
- var harnessModelCatalogSchema = external_exports.object({
14790
- models: external_exports.array(harnessModelSchema),
14791
- defaultModel: harnessModelRefSchema.optional(),
14792
- thinkingOptions: harnessThinkingOptionsSchema,
14793
- defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
14794
- }).strict().superRefine((catalog, context) => {
14795
- const refs = /* @__PURE__ */ new Set();
14796
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
14797
- for (const [index, model] of catalog.models.entries()) {
14798
- if (refs.has(model.ref.id)) {
14799
- context.addIssue({
14800
- code: "custom",
14801
- message: "Model Catalog refs must be unique",
14802
- path: ["models", index, "ref", "id"]
14803
- });
14804
- }
14805
- refs.add(model.ref.id);
14806
- const supportedThinkingIds = /* @__PURE__ */ new Set();
14807
- for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
14808
- if (supportedThinkingIds.has(optionId)) {
14809
- context.addIssue({
14810
- code: "custom",
14811
- message: "Supported Thinking option IDs must be unique per Model",
14812
- path: ["models", index, "supportedThinkingOptionIds", optionIndex]
14813
- });
14814
- }
14815
- supportedThinkingIds.add(optionId);
14816
- if (!thinkingIds.has(optionId)) {
14817
- context.addIssue({
14818
- code: "custom",
14819
- message: "Supported Thinking option must exist in the catalog",
14820
- path: ["models", index, "supportedThinkingOptionIds", optionIndex]
14821
- });
14822
- }
14823
- }
14824
- }
14825
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
14826
- context.addIssue({
14827
- code: "custom",
14828
- message: "Default Model must exist in the Model Catalog",
14829
- path: ["defaultModel", "id"]
14830
- });
14831
- }
14832
- if (catalog.defaultThinkingOptionId && !thinkingIds.has(catalog.defaultThinkingOptionId)) {
14833
- context.addIssue({
14834
- code: "custom",
14835
- message: "Default Thinking option must exist in the catalog",
14836
- path: ["defaultThinkingOptionId"]
14837
- });
14838
- }
14692
+ var zImageContent = object({
14693
+ annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
14694
+ data: string2(),
14695
+ mimeType: string2(),
14696
+ uri: defaultOnError(string2().nullish(), () => void 0),
14697
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14839
14698
  });
14840
- var harnessHistoryCapabilitiesSchema = external_exports.object({
14841
- fork: external_exports.boolean(),
14842
- forkAcrossCwd: external_exports.boolean(),
14843
- rollbackLastTurn: external_exports.boolean()
14844
- }).strict().refine((history) => history.fork || !history.forkAcrossCwd, {
14845
- path: ["forkAcrossCwd"],
14846
- message: "Cross-cwd Fork requires exact history Fork support"
14699
+ var zAudioContent = object({
14700
+ annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
14701
+ data: string2(),
14702
+ mimeType: string2(),
14703
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14847
14704
  });
14848
- var harnessPermissionModeScopeSchema = external_exports.enum(["live", "atCreate"]);
14849
- var harnessSessionCapabilitiesSchema = external_exports.object({
14850
- configuration: external_exports.object({
14851
- selectModel: external_exports.boolean(),
14852
- selectThinkingOption: external_exports.boolean(),
14853
- selectPermissionMode: external_exports.boolean(),
14854
- permissionModeScope: harnessPermissionModeScopeSchema.default("live")
14855
- }).strict(),
14856
- history: harnessHistoryCapabilitiesSchema,
14857
- subagents: external_exports.object({
14858
- observe: external_exports.boolean(),
14859
- readTranscript: external_exports.boolean()
14860
- }).strict().optional(),
14861
- autonomousTurns: external_exports.object({
14862
- observe: external_exports.boolean()
14863
- }).strict().optional(),
14864
- input: external_exports.object({
14865
- image: external_exports.boolean()
14866
- }).strict().optional()
14867
- }).strict();
14868
- var harnessConfigurationStateSchema = external_exports.object({
14869
- effectiveModel: harnessModelRefSchema.optional(),
14870
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
14871
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
14872
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
14873
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
14874
- }).strict().superRefine((state, context) => {
14875
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
14876
- context.addIssue({
14877
- code: "custom",
14878
- message: "Effective Thinking option must be currently available",
14879
- path: ["effectiveThinkingOptionId"]
14880
- });
14881
- }
14705
+ var zResourceLink = object({
14706
+ annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
14707
+ description: defaultOnError(string2().nullish(), () => void 0),
14708
+ mimeType: defaultOnError(string2().nullish(), () => void 0),
14709
+ name: string2(),
14710
+ size: defaultOnError(number2().nullish(), () => void 0),
14711
+ title: defaultOnError(string2().nullish(), () => void 0),
14712
+ uri: string2(),
14713
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14882
14714
  });
14883
- var harnessWebUiCapabilitySchema = external_exports.object({
14884
- open: external_exports.literal(true)
14885
- }).strict();
14886
- var readyHarnessInspectionSchema = external_exports.object({
14887
- status: external_exports.literal("ready"),
14888
- catalog: harnessModelCatalogSchema,
14889
- permissionModes: harnessPermissionModeCatalogSchema.optional(),
14890
- capabilities: harnessSessionCapabilitiesSchema,
14891
- webUi: harnessWebUiCapabilitySchema.optional()
14892
- }).strict().superRefine((inspection, context) => {
14893
- const selectable = inspection.capabilities.configuration.selectPermissionMode;
14894
- if (selectable !== Boolean(inspection.permissionModes)) {
14895
- context.addIssue({
14896
- code: "custom",
14897
- message: "Permission Mode catalog and capability must agree",
14898
- path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
14899
- });
14900
- }
14715
+ var zTextResourceContents = object({
14716
+ mimeType: defaultOnError(string2().nullish(), () => void 0),
14717
+ text: string2(),
14718
+ uri: string2(),
14719
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14901
14720
  });
14902
- var failedHarnessInspectionSchema = external_exports.object({
14903
- status: external_exports.enum(["notInstalled", "unavailable", "error"]),
14904
- error: codexhostErrorSchema
14905
- }).strict();
14906
- var harnessInspectionSchema = external_exports.union([
14907
- readyHarnessInspectionSchema,
14908
- failedHarnessInspectionSchema
14909
- ]);
14910
- var harnessInspectParamsSchema = external_exports.object({
14911
- harnessId: harnessIdSchema,
14912
- cwd: nonBlankTextSchema2.max(16384).optional(),
14913
- refresh: external_exports.boolean().optional()
14914
- }).strict();
14915
- var harnessWebUiOpenParamsSchema = external_exports.object({
14916
- harnessId: harnessIdSchema
14917
- }).strict();
14918
- var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
14919
- var threadModelSelectParamsSchema = external_exports.object({
14920
- threadId: hostThreadIdSchema,
14921
- model: harnessModelRefSchema
14922
- }).strict();
14923
- var threadThinkingSelectParamsSchema = external_exports.object({
14924
- threadId: hostThreadIdSchema,
14925
- thinkingOptionId: harnessThinkingOptionIdSchema
14926
- }).strict();
14927
- var threadInspectionParamsSchema = external_exports.object({
14928
- threadId: hostThreadIdSchema
14929
- }).strict();
14930
- var codexThreadInspectionSchema = external_exports.object({
14931
- owner: external_exports.literal("codex"),
14932
- accountId: nonBlankTextSchema2.optional(),
14933
- locked: external_exports.literal(true)
14934
- }).strict();
14935
- var externalThreadInspectionSchema = external_exports.object({
14936
- owner: external_exports.literal("external"),
14937
- harnessId: nonBlankTextSchema2.max(256),
14938
- transportModelId: nonBlankTextSchema2.max(1024),
14939
- effectiveModel: harnessModelRefSchema.optional(),
14940
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
14941
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
14942
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
14943
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
14944
- history: harnessHistoryCapabilitiesSchema,
14945
- usage: threadUsageSnapshotSchema.optional(),
14946
- /** True when the thread is a read-only child thread materialized for a subagent. */
14947
- subagent: external_exports.boolean().optional(),
14948
- locked: external_exports.literal(true)
14949
- }).strict();
14950
- var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
14951
- codexThreadInspectionSchema,
14952
- externalThreadInspectionSchema
14721
+ var zBlobResourceContents = object({
14722
+ blob: string2(),
14723
+ mimeType: defaultOnError(string2().nullish(), () => void 0),
14724
+ uri: string2(),
14725
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14726
+ });
14727
+ var zEmbeddedResourceResource = union([
14728
+ zTextResourceContents,
14729
+ zBlobResourceContents
14953
14730
  ]);
14954
- var threadOwnershipListParamsSchema = external_exports.object({
14955
- threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
14956
- }).strict().superRefine(({ threadIds }, context) => {
14957
- const seen = /* @__PURE__ */ new Set();
14958
- for (const [index, threadId] of threadIds.entries()) {
14959
- if (seen.has(threadId)) {
14960
- context.addIssue({
14961
- code: "custom",
14962
- message: "Thread ownership-list IDs must be unique",
14963
- path: ["threadIds", index]
14964
- });
14965
- }
14966
- seen.add(threadId);
14967
- }
14731
+ var zEmbeddedResource = object({
14732
+ annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
14733
+ resource: zEmbeddedResourceResource,
14734
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14968
14735
  });
14969
- var codexThreadOwnershipSchema = external_exports.object({
14970
- threadId: hostThreadIdSchema,
14971
- owner: external_exports.literal("codex")
14972
- }).strict();
14973
- var externalThreadOwnershipSchema = external_exports.object({
14974
- threadId: hostThreadIdSchema,
14975
- owner: external_exports.literal("external"),
14976
- harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
14977
- }).strict();
14978
- var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
14979
- codexThreadOwnershipSchema,
14980
- externalThreadOwnershipSchema
14736
+ var zContentBlock = union([
14737
+ zTextContent.and(object({
14738
+ type: literal("text")
14739
+ })),
14740
+ zImageContent.and(object({
14741
+ type: literal("image")
14742
+ })),
14743
+ zAudioContent.and(object({
14744
+ type: literal("audio")
14745
+ })),
14746
+ zResourceLink.and(object({
14747
+ type: literal("resource_link")
14748
+ })),
14749
+ zEmbeddedResource.and(object({
14750
+ type: literal("resource")
14751
+ }))
14981
14752
  ]);
14982
- var threadOwnershipListResultSchema = external_exports.object({
14983
- threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
14984
- }).strict().superRefine(({ threads }, context) => {
14985
- const seen = /* @__PURE__ */ new Set();
14986
- for (const [index, thread] of threads.entries()) {
14987
- if (seen.has(thread.threadId)) {
14988
- context.addIssue({
14989
- code: "custom",
14990
- message: "Thread ownership-list results must be unique",
14991
- path: ["threads", index, "threadId"]
14992
- });
14993
- }
14994
- seen.add(thread.threadId);
14995
- }
14753
+ var zContent = object({
14754
+ content: zContentBlock,
14755
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14996
14756
  });
14997
-
14998
- // ../../shared-contracts/dist/harness-plugins.js
14999
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15000
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15001
- var HARNESS_PLUGIN_LIMIT = 128;
15002
- var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
15003
- var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
15004
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15005
- var pluginPresentationShape = {
15006
- id: harnessPluginIdSchema,
15007
- name: external_exports.string().trim().min(1).max(128),
15008
- version: external_exports.string().min(1).max(128),
15009
- links: external_exports.object({
15010
- documentation: documentationUrlSchema.optional(),
15011
- installation: documentationUrlSchema.optional()
15012
- }).strict().optional()
15013
- };
15014
- var harnessPluginManifestSchema = external_exports.object({
15015
- manifestVersion: external_exports.literal(1),
15016
- ...pluginPresentationShape,
15017
- adapterApiVersion: external_exports.number().int().positive(),
15018
- entry: relativeResourceSchema,
15019
- icon: relativeResourceSchema.optional()
15020
- }).strict();
15021
- var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
15022
- var harnessPluginDescriptorSchema = external_exports.object({
15023
- ...pluginPresentationShape,
15024
- icon: harnessPluginIconSchema.optional()
15025
- }).strict();
15026
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
15027
- var harnessPluginListResultSchema = external_exports.object({
15028
- plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15029
- }).strict();
15030
- var harnessPluginConfigurationSchema = external_exports.object({
15031
- version: external_exports.literal(1),
15032
- enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15033
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15034
- message: "Enabled plugin IDs must be unique",
15035
- path: ["enabled"]
14757
+ var zDiff = object({
14758
+ path: string2(),
14759
+ oldText: defaultOnError(string2().nullish(), () => void 0),
14760
+ newText: string2(),
14761
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15036
14762
  });
15037
-
15038
- // ../../shared-contracts/dist/harness-route.js
15039
- var harnessPluginRouteSchema = external_exports.object({
15040
- harnessId: harnessPluginIdSchema,
15041
- model: harnessModelRefSchema.optional(),
15042
- thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15043
- permissionModeId: harnessPermissionModeIdSchema.optional()
15044
- }).strict();
15045
-
15046
- // ../../shared-contracts/dist/codex-accounts.js
15047
- var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
15048
- var nonBlankTextSchema3 = external_exports.string().trim().min(1);
15049
- var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
15050
- var codexAccountPlanTypeSchema = external_exports.enum([
15051
- "free",
15052
- "go",
15053
- "plus",
15054
- "pro",
15055
- "prolite",
15056
- "team",
15057
- "self_serve_business_prolite",
15058
- "self_serve_business_usage_based",
15059
- "business",
15060
- "ent26",
15061
- "enterprise_cbp_automation",
15062
- "enterprise_cbp_usage_based",
15063
- "enterprise",
15064
- "edu",
15065
- "edu_plus",
15066
- "edu_pro",
15067
- "unknown"
14763
+ var zTerminalId = string2();
14764
+ var zTerminal = object({
14765
+ terminalId: zTerminalId,
14766
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14767
+ });
14768
+ var zToolCallContent = union([
14769
+ zContent.and(object({
14770
+ type: literal("content")
14771
+ })),
14772
+ zDiff.and(object({
14773
+ type: literal("diff")
14774
+ })),
14775
+ zTerminal.and(object({
14776
+ type: literal("terminal")
14777
+ }))
15068
14778
  ]);
15069
- var codexAccountSchema = external_exports.object({
15070
- accountId: accountIdSchema,
15071
- label: nonBlankTextSchema3.max(256),
15072
- email: external_exports.string().email().max(320).optional(),
15073
- planType: codexAccountPlanTypeSchema.optional(),
15074
- codexHome: nonBlankTextSchema3.max(16384),
15075
- active: external_exports.boolean(),
15076
- isDefault: external_exports.boolean(),
15077
- authKind: codexAccountAuthKindSchema.optional(),
15078
- authIdentity: nonBlankTextSchema3.max(256).optional()
15079
- }).strict();
15080
- var codexAccountListResultSchema = external_exports.object({ accounts: external_exports.array(codexAccountSchema).max(128) }).strict();
15081
- var codexAccountCreateParamsSchema = external_exports.object({ label: nonBlankTextSchema3.max(256).optional() }).strict();
15082
- var codexAccountActivateParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
15083
- var codexAccountDeleteParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
15084
- var codexAccountDeleteResultSchema = external_exports.object({ deletedAccountId: accountIdSchema }).strict();
15085
- var codexAccountMutationResultSchema = external_exports.object({ account: codexAccountSchema }).strict();
15086
- var codexAccountLoginStartParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
15087
- var codexAccountLoginStartResultSchema = external_exports.object({
15088
- accountId: accountIdSchema,
15089
- loginId: nonBlankTextSchema3.max(1024),
15090
- verificationUrl: external_exports.string().url().max(16384),
15091
- userCode: nonBlankTextSchema3.max(1024)
15092
- }).strict();
15093
- var codexAccountLoginCancelParamsSchema = external_exports.object({ accountId: accountIdSchema.optional(), loginId: nonBlankTextSchema3.max(1024) }).strict();
15094
- var codexAccountLoginCancelResultSchema = external_exports.object({ cancelled: external_exports.boolean() }).strict();
15095
- var codexAccountLoginCompletedSchema = external_exports.object({
15096
- accountId: accountIdSchema,
15097
- loginId: nonBlankTextSchema3.max(1024),
15098
- success: external_exports.boolean(),
15099
- error: external_exports.string().max(4096).nullable()
15100
- }).strict();
15101
- var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
15102
- var codexAccountUsageResultSchema = external_exports.object({
15103
- accountId: accountIdSchema,
15104
- usage: threadUsageSnapshotSchema.nullable(),
15105
- accountCredits: accountCreditsSnapshotSchema.optional()
15106
- }).strict();
15107
- var codexAccountResetCreditConsumeParamsSchema = external_exports.object({
15108
- accountId: accountIdSchema,
15109
- idempotencyKey: external_exports.string().uuid().optional()
15110
- }).strict();
15111
- var codexAccountResetCreditConsumeOutcomeSchema = external_exports.enum([
15112
- "reset",
15113
- "nothingToReset",
15114
- "noCredit",
15115
- "alreadyRedeemed"
15116
- ]);
15117
- var codexAccountResetCreditConsumeResultSchema = external_exports.object({
15118
- accountId: accountIdSchema,
15119
- outcome: codexAccountResetCreditConsumeOutcomeSchema,
15120
- accountCredits: accountCreditsSnapshotSchema.optional()
15121
- }).strict();
15122
-
15123
- // ../../shared-contracts/dist/harness-session-import.js
15124
- var HARNESS_SESSION_IMPORT_ID_MAX_LENGTH = 1024;
15125
- var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
15126
- var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
15127
- var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
15128
- var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
15129
- var nonBlankTextSchema4 = 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");
15130
- var harnessSessionImportIdSchema = nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
15131
- var harnessSessionImportCandidateSchema = external_exports.object({
15132
- nativeSessionId: harnessSessionImportIdSchema,
15133
- title: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
15134
- updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
15135
- cwd: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
15136
- // Native file discovery cannot reliably observe another process's activity.
15137
- running: external_exports.boolean().nullable()
15138
- }).strict();
15139
- var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict();
15140
- var harnessSessionImportSourcesResultSchema = external_exports.object({
15141
- harnesses: external_exports.array(external_exports.object({
15142
- harnessId: harnessPluginIdSchema,
15143
- name: nonBlankTextSchema4.max(128)
15144
- }).strict()).max(128)
15145
- }).strict();
15146
- var harnessSessionListParamsSchema = external_exports.object({
15147
- harnessId: harnessPluginIdSchema,
15148
- query: external_exports.string().trim().max(4096).refine((value) => !value.includes("\0")).optional(),
15149
- offset: external_exports.number().int().nonnegative().safe().optional(),
15150
- limit: external_exports.number().int().min(1).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH).optional()
15151
- }).strict();
15152
- var harnessSessionListResultSchema = external_exports.object({
15153
- candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH),
15154
- total: external_exports.number().int().nonnegative().safe()
15155
- }).strict();
15156
- var harnessSessionImportParamsSchema = external_exports.object({
15157
- harnessId: harnessPluginIdSchema,
15158
- nativeSessionId: harnessSessionImportIdSchema
15159
- }).strict();
15160
- var harnessSessionImportResultSchema = external_exports.object({
15161
- threadId: nonBlankTextSchema4.max(1024).pipe(hostThreadIdSchema)
15162
- }).strict();
15163
-
15164
- // ../../shared-contracts/dist/deepseek-modern-sessions.js
15165
- var DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH = HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH;
15166
- var DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH = 1024;
15167
- 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");
15168
- var deepSeekModernSessionIdSchema = harnessSessionImportIdSchema;
15169
- var deepSeekModernSessionCandidateSchema = harnessSessionImportCandidateSchema;
15170
- var deepSeekModernSessionListParamsSchema = external_exports.object({}).strict();
15171
- var deepSeekModernSessionListResultSchema = external_exports.object({
15172
- candidates: external_exports.array(deepSeekModernSessionCandidateSchema).max(DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH)
15173
- }).strict();
15174
- var deepSeekModernSessionImportParamsSchema = external_exports.object({
15175
- nativeSessionId: deepSeekModernSessionIdSchema
15176
- }).strict();
15177
- var deepSeekModernSessionImportResultSchema = external_exports.object({
15178
- threadId: nonBlankTextSchema5.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
15179
- }).strict();
15180
-
15181
- // ../../shared-contracts/dist/external-thread-fork.js
15182
- var externalThreadForkParamsSchema = external_exports.object({
15183
- threadId: hostThreadIdSchema,
15184
- lastTurnId: hostTurnIdSchema
15185
- }).strict();
15186
- var externalThreadForkResultSchema = external_exports.object({
15187
- threadId: hostThreadIdSchema
15188
- }).strict();
15189
-
15190
- // ../../shared-contracts/dist/harness-commands.js
15191
- var commandIdSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();
15192
- var commandInvocationSchema = external_exports.string().min(1).max(128);
15193
- var commandLabelSchema = external_exports.string().trim().min(1).max(128);
15194
- var commandDescriptionSchema = external_exports.string().trim().min(1).max(512);
15195
- var harnessCommandDescriptorSchema = external_exports.object({
15196
- id: commandIdSchema,
15197
- invocation: commandInvocationSchema,
15198
- label: commandLabelSchema,
15199
- description: commandDescriptionSchema.optional(),
15200
- argumentMode: external_exports.enum(["none", "text"])
15201
- }).strict();
15202
- var harnessCommandCatalogSchema = external_exports.object({
15203
- commands: external_exports.array(harnessCommandDescriptorSchema)
15204
- }).strict().superRefine((catalog, context) => {
15205
- const ids = /* @__PURE__ */ new Set();
15206
- for (const [index, command] of catalog.commands.entries()) {
15207
- if (ids.has(command.id)) {
15208
- context.addIssue({
15209
- code: "custom",
15210
- message: "Harness command IDs must be unique",
15211
- path: ["commands", index, "id"]
15212
- });
15213
- }
15214
- ids.add(command.id);
15215
- }
14779
+ var zToolCallLocation = object({
14780
+ path: string2(),
14781
+ line: defaultOnError(int().gte(0).max(4294967295, {
14782
+ error: "Invalid value: Expected uint32 to be <= 4294967295"
14783
+ }).nullish(), () => void 0),
14784
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15216
14785
  });
15217
- var harnessCommandsInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema }).strict();
15218
- var threadCommandsInspectParamsSchema = external_exports.object({
15219
- threadId: hostThreadIdSchema
15220
- }).strict();
15221
- var threadCommandExecuteParamsSchema = external_exports.object({
15222
- threadId: hostThreadIdSchema,
15223
- commandId: commandIdSchema,
15224
- turnId: hostTurnIdSchema.optional(),
15225
- arguments: jsonObjectSchema.optional()
15226
- }).strict();
15227
- var threadCommandExecuteResultSchema = external_exports.object({
15228
- accepted: external_exports.literal(true),
15229
- turnId: hostTurnIdSchema
15230
- }).strict();
15231
-
15232
- // ../../shared-contracts/dist/json-rpc.js
15233
- var jsonRpcVersionSchema = external_exports.literal("2.0").optional();
15234
- var absentSchema = external_exports.never().optional();
15235
- var methodSchema = external_exports.string().min(1);
15236
- var jsonRpcIdSchema = external_exports.union([external_exports.string(), external_exports.number().int()]);
15237
- var jsonRpcErrorSchema = external_exports.object({
15238
- code: external_exports.number().int(),
15239
- message: external_exports.string(),
15240
- data: jsonValueSchema.optional()
15241
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["data"]));
15242
- var jsonRpcRequestSchema = external_exports.object({
15243
- jsonrpc: jsonRpcVersionSchema,
15244
- id: jsonRpcIdSchema,
15245
- method: methodSchema,
15246
- params: jsonValueSchema.optional(),
15247
- result: absentSchema,
15248
- error: absentSchema
15249
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "params", "result", "error"]));
15250
- var jsonRpcNotificationSchema = external_exports.object({
15251
- jsonrpc: jsonRpcVersionSchema,
15252
- id: absentSchema,
15253
- method: methodSchema,
15254
- params: jsonValueSchema.optional(),
15255
- result: absentSchema,
15256
- error: absentSchema
15257
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "id", "params", "result", "error"]));
15258
- var jsonRpcSuccessResponseSchema = external_exports.object({
15259
- jsonrpc: jsonRpcVersionSchema,
15260
- id: jsonRpcIdSchema,
15261
- method: absentSchema,
15262
- params: absentSchema,
15263
- result: jsonValueSchema,
15264
- error: absentSchema
15265
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "error"]));
15266
- var jsonRpcErrorResponseSchema = external_exports.object({
15267
- jsonrpc: jsonRpcVersionSchema,
15268
- id: jsonRpcIdSchema,
15269
- method: absentSchema,
15270
- params: absentSchema,
15271
- result: absentSchema,
15272
- error: jsonRpcErrorSchema
15273
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "result"]));
15274
- var jsonRpcEnvelopeSchema = external_exports.union([
15275
- jsonRpcRequestSchema,
15276
- jsonRpcNotificationSchema,
15277
- jsonRpcSuccessResponseSchema,
15278
- jsonRpcErrorResponseSchema
14786
+ var zToolCallUpdate = object({
14787
+ toolCallId: zToolCallId,
14788
+ kind: defaultOnError(zToolKind.nullish(), () => void 0),
14789
+ status: defaultOnError(zToolCallStatus.nullish(), () => void 0),
14790
+ title: defaultOnError(string2().nullish(), () => void 0),
14791
+ name: defaultOnError(string2().nullish(), () => void 0),
14792
+ content: defaultOnError(vecSkipError(zToolCallContent).nullish(), () => void 0),
14793
+ locations: defaultOnError(vecSkipError(zToolCallLocation).nullish(), () => void 0),
14794
+ rawInput: defaultOnError(unknown().optional(), () => void 0),
14795
+ rawOutput: defaultOnError(unknown().optional(), () => void 0),
14796
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14797
+ });
14798
+ var zPermissionOptionId = string2();
14799
+ var zPermissionOptionKind = union([
14800
+ literal("allow_once"),
14801
+ literal("allow_always"),
14802
+ literal("reject_once"),
14803
+ literal("reject_always")
15279
14804
  ]);
15280
-
15281
- // ../../shared-contracts/dist/native-refs.js
15282
- var nativeIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15283
- message: "Native identifier must not be empty or whitespace"
14805
+ var zPermissionOption = object({
14806
+ optionId: zPermissionOptionId,
14807
+ name: string2(),
14808
+ kind: zPermissionOptionKind,
14809
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15284
14810
  });
15285
- var nativeSessionRefV1RuntimeSchema = external_exports.strictObject({
15286
- harnessId: harnessIdSchema,
15287
- nativeSessionId: nativeIdSchema,
15288
- locator: jsonValueSchema.optional(),
15289
- formatVersion: external_exports.literal(1)
15290
- }).superRefine(rejectExplicitUndefined(["locator"]));
15291
- var nativeSessionRefV1Schema = nativeSessionRefV1RuntimeSchema;
15292
- var nativeSessionRefSchema = nativeSessionRefV1Schema;
15293
- var nativeTurnRefV1Schema = external_exports.strictObject({
15294
- harnessId: harnessIdSchema,
15295
- nativeSessionId: nativeIdSchema,
15296
- nativeTurnKey: nativeIdSchema,
15297
- formatVersion: external_exports.literal(1)
14811
+ var zRequestPermissionRequest = object({
14812
+ sessionId: zSessionId,
14813
+ toolCall: zToolCallUpdate,
14814
+ options: array(zPermissionOption),
14815
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15298
14816
  });
15299
- var nativeTurnRefSchema = nativeTurnRefV1Schema;
15300
- var nativeCheckpointRefV1RuntimeSchema = external_exports.strictObject({
15301
- harnessId: harnessIdSchema,
15302
- nativeSessionId: nativeIdSchema,
15303
- checkpointId: nativeIdSchema,
15304
- locator: jsonValueSchema.optional(),
15305
- formatVersion: external_exports.literal(1)
15306
- }).superRefine(rejectExplicitUndefined(["locator"]));
15307
- var nativeCheckpointRefV1Schema = nativeCheckpointRefV1RuntimeSchema;
15308
- var nativeCheckpointRefSchema = nativeCheckpointRefV1Schema;
15309
-
15310
- // ../../shared-contracts/dist/updates.js
15311
- var UPDATE_ERROR_MAX_LENGTH = 500;
15312
- var UPDATE_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
15313
- var updateSemanticVersionSchema = external_exports.string().regex(UPDATE_SEMVER_PATTERN);
15314
- var updateInstallationSchema = external_exports.enum(["npm", "windows-installer", "macos-dmg"]);
15315
- var updatePhaseSchema = external_exports.enum([
15316
- "prepared",
15317
- "downloading",
15318
- "waiting-for-exit",
15319
- "installing",
15320
- "restarting",
15321
- "succeeded",
15322
- "failed"
15323
- ]);
15324
- var updateStatusSchema = external_exports.strictObject({
15325
- version: updateSemanticVersionSchema,
15326
- installation: updateInstallationSchema,
15327
- phase: updatePhaseSchema,
15328
- updatedAt: external_exports.number().int().nonnegative(),
15329
- downloadedBytes: external_exports.number().int().nonnegative().optional(),
15330
- totalBytes: external_exports.number().int().positive().optional(),
15331
- error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
15332
- }).superRefine((status, context) => {
15333
- if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
15334
- context.addIssue({
15335
- code: "custom",
15336
- path: ["downloadedBytes"],
15337
- message: "downloadedBytes must not exceed totalBytes"
15338
- });
15339
- }
14817
+ var zEnvVariable = object({
14818
+ name: string2(),
14819
+ value: string2(),
14820
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15340
14821
  });
15341
- var updateEmptyParamsSchema = external_exports.strictObject({});
15342
- var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/LiberSeek\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
15343
- var updateCheckResultSchema = external_exports.strictObject({
15344
- currentVersion: updateSemanticVersionSchema,
15345
- installation: updateInstallationSchema.nullable(),
15346
- latestVersion: updateSemanticVersionSchema.nullable(),
15347
- updateAvailable: external_exports.boolean(),
15348
- installationAvailable: external_exports.boolean(),
15349
- releaseNotes: external_exports.string().min(1).max(2e4).nullable(),
15350
- releaseNotesUrl: githubReleaseNotesUrlSchema.nullable(),
15351
- status: updateStatusSchema.nullable(),
15352
- error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
14822
+ var zCreateTerminalRequest = object({
14823
+ sessionId: zSessionId,
14824
+ command: string2(),
14825
+ args: defaultOnError(vecSkipError(string2()).optional(), () => []),
14826
+ env: defaultOnError(vecSkipError(zEnvVariable).optional(), () => []),
14827
+ cwd: defaultOnError(string2().nullish(), () => void 0),
14828
+ outputByteLimit: defaultOnError(number2().nullish(), () => void 0),
14829
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15353
14830
  });
15354
- var updateStartResultSchema = external_exports.strictObject({
15355
- status: updateStatusSchema
14831
+ var zTerminalOutputRequest = object({
14832
+ sessionId: zSessionId,
14833
+ terminalId: zTerminalId,
14834
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15356
14835
  });
15357
- var updateStatusResultSchema = external_exports.strictObject({
15358
- status: updateStatusSchema.nullable()
14836
+ var zReleaseTerminalRequest = object({
14837
+ sessionId: zSessionId,
14838
+ terminalId: zTerminalId,
14839
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15359
14840
  });
15360
-
15361
- // ../../shared-contracts/dist/index.js
15362
- var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
15363
-
15364
- // ../../harness-adapter/dist/approval.js
15365
- function invalidRequest(message) {
15366
- return { code: "invalidRequest", message, retryable: false };
15367
- }
15368
- function validateHostApprovalResponse(interaction, response) {
15369
- return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
15370
- }
15371
-
15372
- // ../../harness-adapter/dist/output-channel.js
15373
- var HarnessOutputChannel = class {
15374
- outputs;
15375
- #consumerCreated = false;
15376
- #ended = false;
15377
- #pending = [];
15378
- #values = [];
15379
- constructor() {
15380
- this.outputs = {
15381
- [Symbol.asyncIterator]: () => {
15382
- if (this.#consumerCreated) {
15383
- throw new Error("Harness outputs allow only one consumer");
15384
- }
15385
- this.#consumerCreated = true;
15386
- return {
15387
- next: () => this.#next()
15388
- };
15389
- }
15390
- };
15391
- }
15392
- emit(value) {
15393
- if (this.#ended)
15394
- return false;
15395
- const resolve = this.#pending.shift();
15396
- if (resolve)
15397
- resolve({ done: false, value });
15398
- else
15399
- this.#values.push(value);
15400
- return true;
15401
- }
15402
- end() {
15403
- if (this.#ended)
15404
- return;
15405
- this.#ended = true;
15406
- if (this.#values.length !== 0)
15407
- return;
15408
- for (const resolve of this.#pending.splice(0))
15409
- resolve({ done: true, value: void 0 });
15410
- }
15411
- #next() {
15412
- const value = this.#values.shift();
15413
- if (value !== void 0)
15414
- return Promise.resolve({ done: false, value });
15415
- if (this.#ended)
15416
- return Promise.resolve({ done: true, value: void 0 });
15417
- return new Promise((resolve) => this.#pending.push(resolve));
15418
- }
15419
- };
15420
-
15421
- // ../../harness-adapter/dist/diagnostics.js
15422
- var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
15423
- var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
15424
- var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
15425
- function sanitizeDiagnosticTail(value) {
15426
- const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
15427
- return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
15428
- }
15429
-
15430
- // ../../harness-adapter/dist/usage.js
15431
- var tokenFields = [
15432
- "inputTokens",
15433
- "cachedInputTokens",
15434
- "cacheWriteInputTokens",
15435
- "outputTokens",
15436
- "outputTokensPerSecond",
15437
- "reasoningOutputTokens",
15438
- "totalTokens",
15439
- "contextWindowTokens",
15440
- "contextUsedTokens"
15441
- ];
15442
- var safeIntegerFields = [
15443
- "planFiveHourResetsAtUnix",
15444
- "planSevenDayResetsAtUnix"
15445
- ];
15446
- var percentFields = [
15447
- "cacheHitRatePercent",
15448
- "planFiveHourUsedPercent",
15449
- "planSevenDayUsedPercent"
15450
- ];
15451
- var usageFields = /* @__PURE__ */ new Set([
15452
- ...tokenFields,
15453
- ...safeIntegerFields,
15454
- ...percentFields,
15455
- "totalCostUsd"
14841
+ var zWaitForTerminalExitRequest = object({
14842
+ sessionId: zSessionId,
14843
+ terminalId: zTerminalId,
14844
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14845
+ });
14846
+ var zKillTerminalRequest = object({
14847
+ sessionId: zSessionId,
14848
+ terminalId: zTerminalId,
14849
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
14850
+ });
14851
+ var zElicitationSessionScope = object({
14852
+ sessionId: zSessionId,
14853
+ toolCallId: defaultOnError(zToolCallId.nullish(), () => void 0)
14854
+ });
14855
+ var zElicitationRequestScope = object({
14856
+ requestId: zRequestId
14857
+ });
14858
+ var zElicitationSchemaType = literal("object");
14859
+ var zStringFormat = union([
14860
+ literal("email"),
14861
+ literal("uri"),
14862
+ literal("date"),
14863
+ literal("date-time")
15456
14864
  ]);
15457
- function isRecord(value) {
15458
- return typeof value === "object" && value !== null && !Array.isArray(value);
15459
- }
15460
- function parseHostUsage(value) {
15461
- if (!isRecord(value))
15462
- throw new Error("Harness Usage must be an object");
15463
- const keys = Object.keys(value);
15464
- if (keys.length === 0)
15465
- throw new Error("Harness Usage must contain a reliable field");
15466
- for (const key of keys) {
15467
- if (!usageFields.has(key)) {
15468
- throw new Error(`Harness Usage contains unknown field '${key}'`);
15469
- }
15470
- }
15471
- for (const field of tokenFields) {
15472
- const candidate = value[field];
15473
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
15474
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
15475
- }
15476
- }
15477
- for (const field of safeIntegerFields) {
15478
- const candidate = value[field];
15479
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
15480
- throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
15481
- }
15482
- }
15483
- if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
15484
- throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
15485
- }
15486
- if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
15487
- throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
15488
- }
15489
- for (const field of percentFields) {
15490
- const candidate = value[field];
15491
- if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
15492
- throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
15493
- }
15494
- }
15495
- const hasContextUsed = value.contextUsedTokens !== void 0;
15496
- const hasContextWindow = value.contextWindowTokens !== void 0;
15497
- if (hasContextUsed !== hasContextWindow) {
15498
- throw new Error("Harness Usage context fields must be provided together");
15499
- }
15500
- if (hasContextWindow && value.contextWindowTokens === 0) {
15501
- throw new Error("Harness Usage 'contextWindowTokens' must be greater than zero");
15502
- }
15503
- if (value.planFiveHourResetsAtUnix !== void 0 && value.planFiveHourUsedPercent === void 0) {
15504
- throw new Error("Harness Usage 'planFiveHourResetsAtUnix' must be provided with 'planFiveHourUsedPercent'");
15505
- }
15506
- if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
15507
- throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
15508
- }
15509
- return { ...value };
15510
- }
15511
-
15512
- // dist/acp-transport.js
15513
- import { spawn, spawnSync } from "node:child_process";
15514
- import { readdir, readFile } from "node:fs/promises";
15515
- import os3 from "node:os";
15516
- import path8 from "node:path";
15517
- import { Readable, Writable } from "node:stream";
15518
-
15519
- // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
15520
- var AGENT_METHODS = {
15521
- initialize: "initialize",
15522
- authenticate: "authenticate",
15523
- providers_list: "providers/list",
15524
- providers_set: "providers/set",
15525
- providers_disable: "providers/disable",
15526
- session_new: "session/new",
15527
- session_load: "session/load",
15528
- session_set_mode: "session/set_mode",
15529
- session_set_config_option: "session/set_config_option",
15530
- session_prompt: "session/prompt",
15531
- session_cancel: "session/cancel",
15532
- mcp_message: "mcp/message",
15533
- session_list: "session/list",
15534
- session_delete: "session/delete",
15535
- session_fork: "session/fork",
15536
- session_resume: "session/resume",
15537
- session_close: "session/close",
15538
- logout: "logout",
15539
- nes_start: "nes/start",
15540
- nes_suggest: "nes/suggest",
15541
- nes_accept: "nes/accept",
15542
- nes_reject: "nes/reject",
15543
- nes_close: "nes/close",
15544
- document_did_open: "document/didOpen",
15545
- document_did_change: "document/didChange",
15546
- document_did_close: "document/didClose",
15547
- document_did_save: "document/didSave",
15548
- document_did_focus: "document/didFocus"
15549
- };
15550
- var CLIENT_METHODS = {
15551
- session_request_permission: "session/request_permission",
15552
- session_update: "session/update",
15553
- fs_write_text_file: "fs/write_text_file",
15554
- fs_read_text_file: "fs/read_text_file",
15555
- terminal_create: "terminal/create",
15556
- terminal_output: "terminal/output",
15557
- terminal_release: "terminal/release",
15558
- terminal_wait_for_exit: "terminal/wait_for_exit",
15559
- terminal_kill: "terminal/kill",
15560
- mcp_connect: "mcp/connect",
15561
- mcp_message: "mcp/message",
15562
- mcp_disconnect: "mcp/disconnect",
15563
- elicitation_create: "elicitation/create",
15564
- elicitation_complete: "elicitation/complete"
15565
- };
15566
- var PROTOCOL_METHODS = {
15567
- cancel_request: "$/cancel_request"
15568
- };
15569
- var PROTOCOL_VERSION = 1;
15570
-
15571
- // ../../../node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.js
15572
- var skippedItem = /* @__PURE__ */ Symbol("skippedItem");
15573
- function defaultOnError(schema, fallback) {
15574
- return schema.catch(fallback);
15575
- }
15576
- function requiredDefaultOnError(schema, fallback) {
15577
- const schemaWithCatch = schema.catch(fallback);
15578
- return external_exports.unknown().transform((value, context) => {
15579
- if (value !== void 0)
15580
- return schemaWithCatch.parse(value);
15581
- context.addIssue({
15582
- code: "custom",
15583
- message: "Required value is missing"
15584
- });
15585
- return external_exports.NEVER;
15586
- });
15587
- }
15588
- function stringTag(value, key) {
15589
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
15590
- return void 0;
15591
- }
15592
- const tag = value[key];
15593
- return typeof tag === "string" ? tag : void 0;
15594
- }
15595
- function excludeKnownTags(schema, key, knownTags) {
15596
- return schema.superRefine((value, context) => {
15597
- const tag = stringTag(value, key);
15598
- if (tag !== void 0 && knownTags.includes(tag)) {
15599
- context.addIssue({
15600
- code: "custom",
15601
- path: [key],
15602
- message: `${key} ${JSON.stringify(tag)} is reserved by a known variant, but the value does not match that variant's schema`
15603
- });
15604
- }
15605
- });
15606
- }
15607
- function preserveCustomPayload(schema, key, knownTags) {
15608
- return external_exports.unknown().transform((value, context) => {
15609
- const result = schema.safeParse(value);
15610
- if (!result.success) {
15611
- for (const issue2 of result.error.issues) {
15612
- context.addIssue({ ...issue2, input: value });
15613
- }
15614
- return external_exports.NEVER;
15615
- }
15616
- const output = result.data;
15617
- const tag = stringTag(value, key);
15618
- if (tag !== void 0 && !knownTags.includes(tag)) {
15619
- const raw = value;
15620
- for (const [property, rawValue] of Object.entries(raw)) {
15621
- if (property === "__proto__")
15622
- continue;
15623
- if (!Object.hasOwn(output, property))
15624
- output[property] = rawValue;
15625
- }
15626
- }
15627
- return output;
15628
- });
15629
- }
15630
- function vecSkipError(itemSchema) {
15631
- return external_exports.array(itemSchema.catch(skippedItem)).transform((items) => items.filter((item) => item !== skippedItem));
15632
- }
15633
-
15634
- // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js
15635
- var zRequestId = union([number2(), string2()]).nullable();
15636
- var zSessionId = string2();
15637
- var zWriteTextFileRequest = object({
15638
- sessionId: zSessionId,
15639
- path: string2(),
15640
- content: string2(),
14865
+ var zEnumOption = object({
14866
+ const: string2(),
14867
+ title: string2(),
14868
+ description: defaultOnError(string2().nullish(), () => void 0),
15641
14869
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15642
14870
  });
15643
- var zReadTextFileRequest = object({
15644
- sessionId: zSessionId,
15645
- path: string2(),
15646
- line: defaultOnError(int().gte(0).max(4294967295, {
14871
+ var zStringPropertySchema = object({
14872
+ title: defaultOnError(string2().nullish(), () => void 0),
14873
+ description: defaultOnError(string2().nullish(), () => void 0),
14874
+ minLength: int().gte(0).max(4294967295, {
15647
14875
  error: "Invalid value: Expected uint32 to be <= 4294967295"
15648
- }).nullish(), () => void 0),
15649
- limit: defaultOnError(int().gte(0).max(4294967295, {
14876
+ }).nullish(),
14877
+ maxLength: int().gte(0).max(4294967295, {
15650
14878
  error: "Invalid value: Expected uint32 to be <= 4294967295"
15651
- }).nullish(), () => void 0),
15652
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15653
- });
15654
- var zToolCallId = string2();
15655
- var zToolKind = union([
15656
- literal("read"),
15657
- literal("edit"),
15658
- literal("delete"),
15659
- literal("move"),
15660
- literal("search"),
15661
- literal("execute"),
15662
- literal("think"),
15663
- literal("fetch"),
15664
- literal("switch_mode"),
15665
- literal("other")
15666
- ]);
15667
- var zToolCallStatus = union([
15668
- literal("pending"),
15669
- literal("in_progress"),
15670
- literal("completed"),
15671
- literal("failed")
15672
- ]);
15673
- var zRole = union([literal("assistant"), literal("user")]);
15674
- var zAnnotations = object({
15675
- audience: defaultOnError(vecSkipError(zRole).nullish(), () => void 0),
15676
- lastModified: defaultOnError(string2().nullish(), () => void 0),
15677
- priority: defaultOnError(number2().nullish(), () => void 0),
15678
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15679
- });
15680
- var zTextContent = object({
15681
- annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
15682
- text: string2(),
14879
+ }).nullish(),
14880
+ pattern: string2().nullish(),
14881
+ format: zStringFormat.nullish(),
14882
+ default: defaultOnError(string2().nullish(), () => void 0),
14883
+ enum: array(string2()).nullish(),
14884
+ oneOf: array(zEnumOption).nullish(),
15683
14885
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15684
14886
  });
15685
- var zImageContent = object({
15686
- annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
15687
- data: string2(),
15688
- mimeType: string2(),
15689
- uri: defaultOnError(string2().nullish(), () => void 0),
14887
+ var zNumberPropertySchema = object({
14888
+ title: defaultOnError(string2().nullish(), () => void 0),
14889
+ description: defaultOnError(string2().nullish(), () => void 0),
14890
+ minimum: number2().nullish(),
14891
+ maximum: number2().nullish(),
14892
+ default: defaultOnError(number2().nullish(), () => void 0),
15690
14893
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15691
14894
  });
15692
- var zAudioContent = object({
15693
- annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
15694
- data: string2(),
15695
- mimeType: string2(),
14895
+ var zIntegerPropertySchema = object({
14896
+ title: defaultOnError(string2().nullish(), () => void 0),
14897
+ description: defaultOnError(string2().nullish(), () => void 0),
14898
+ minimum: number2().nullish(),
14899
+ maximum: number2().nullish(),
14900
+ default: defaultOnError(number2().nullish(), () => void 0),
15696
14901
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15697
14902
  });
15698
- var zResourceLink = object({
15699
- annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
15700
- description: defaultOnError(string2().nullish(), () => void 0),
15701
- mimeType: defaultOnError(string2().nullish(), () => void 0),
15702
- name: string2(),
15703
- size: defaultOnError(number2().nullish(), () => void 0),
14903
+ var zBooleanPropertySchema = object({
15704
14904
  title: defaultOnError(string2().nullish(), () => void 0),
15705
- uri: string2(),
14905
+ description: defaultOnError(string2().nullish(), () => void 0),
14906
+ default: defaultOnError(boolean2().nullish(), () => void 0),
15706
14907
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15707
14908
  });
15708
- var zTextResourceContents = object({
15709
- mimeType: defaultOnError(string2().nullish(), () => void 0),
15710
- text: string2(),
15711
- uri: string2(),
14909
+ var zStringMultiSelectItems = object({
14910
+ enum: array(string2()),
15712
14911
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15713
14912
  });
15714
- var zBlobResourceContents = object({
15715
- blob: string2(),
15716
- mimeType: defaultOnError(string2().nullish(), () => void 0),
15717
- uri: string2(),
14913
+ var zTitledMultiSelectItems = object({
14914
+ anyOf: array(zEnumOption),
15718
14915
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15719
14916
  });
15720
- var zEmbeddedResourceResource = union([
15721
- zTextResourceContents,
15722
- zBlobResourceContents
15723
- ]);
15724
- var zEmbeddedResource = object({
15725
- annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
15726
- resource: zEmbeddedResourceResource,
14917
+ var zMultiSelectItems = preserveCustomPayload(union([
14918
+ zStringMultiSelectItems.and(object({
14919
+ type: literal("string")
14920
+ })),
14921
+ excludeKnownTags(object({
14922
+ type: string2()
14923
+ }), "type", ["string"]),
14924
+ zTitledMultiSelectItems
14925
+ ]), "type", ["string"]);
14926
+ var zMultiSelectPropertySchema = object({
14927
+ title: defaultOnError(string2().nullish(), () => void 0),
14928
+ description: defaultOnError(string2().nullish(), () => void 0),
14929
+ minItems: number2().nullish(),
14930
+ maxItems: number2().nullish(),
14931
+ items: zMultiSelectItems,
14932
+ default: defaultOnError(vecSkipError(string2()).nullish(), () => void 0),
15727
14933
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15728
14934
  });
15729
- var zContentBlock = union([
15730
- zTextContent.and(object({
15731
- type: literal("text")
14935
+ var zElicitationPropertySchema = preserveCustomPayload(union([
14936
+ zStringPropertySchema.and(object({
14937
+ type: literal("string")
15732
14938
  })),
15733
- zImageContent.and(object({
15734
- type: literal("image")
14939
+ zNumberPropertySchema.and(object({
14940
+ type: literal("number")
15735
14941
  })),
15736
- zAudioContent.and(object({
15737
- type: literal("audio")
14942
+ zIntegerPropertySchema.and(object({
14943
+ type: literal("integer")
15738
14944
  })),
15739
- zResourceLink.and(object({
15740
- type: literal("resource_link")
15741
- })),
15742
- zEmbeddedResource.and(object({
15743
- type: literal("resource")
15744
- }))
15745
- ]);
15746
- var zContent = object({
15747
- content: zContentBlock,
15748
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15749
- });
15750
- var zDiff = object({
15751
- path: string2(),
15752
- oldText: defaultOnError(string2().nullish(), () => void 0),
15753
- newText: string2(),
15754
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15755
- });
15756
- var zTerminalId = string2();
15757
- var zTerminal = object({
15758
- terminalId: zTerminalId,
15759
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15760
- });
15761
- var zToolCallContent = union([
15762
- zContent.and(object({
15763
- type: literal("content")
15764
- })),
15765
- zDiff.and(object({
15766
- type: literal("diff")
15767
- })),
15768
- zTerminal.and(object({
15769
- type: literal("terminal")
15770
- }))
15771
- ]);
15772
- var zToolCallLocation = object({
15773
- path: string2(),
15774
- line: defaultOnError(int().gte(0).max(4294967295, {
15775
- error: "Invalid value: Expected uint32 to be <= 4294967295"
15776
- }).nullish(), () => void 0),
15777
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15778
- });
15779
- var zToolCallUpdate = object({
15780
- toolCallId: zToolCallId,
15781
- kind: defaultOnError(zToolKind.nullish(), () => void 0),
15782
- status: defaultOnError(zToolCallStatus.nullish(), () => void 0),
15783
- title: defaultOnError(string2().nullish(), () => void 0),
15784
- name: defaultOnError(string2().nullish(), () => void 0),
15785
- content: defaultOnError(vecSkipError(zToolCallContent).nullish(), () => void 0),
15786
- locations: defaultOnError(vecSkipError(zToolCallLocation).nullish(), () => void 0),
15787
- rawInput: defaultOnError(unknown().optional(), () => void 0),
15788
- rawOutput: defaultOnError(unknown().optional(), () => void 0),
15789
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15790
- });
15791
- var zPermissionOptionId = string2();
15792
- var zPermissionOptionKind = union([
15793
- literal("allow_once"),
15794
- literal("allow_always"),
15795
- literal("reject_once"),
15796
- literal("reject_always")
15797
- ]);
15798
- var zPermissionOption = object({
15799
- optionId: zPermissionOptionId,
15800
- name: string2(),
15801
- kind: zPermissionOptionKind,
15802
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15803
- });
15804
- var zRequestPermissionRequest = object({
15805
- sessionId: zSessionId,
15806
- toolCall: zToolCallUpdate,
15807
- options: array(zPermissionOption),
15808
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15809
- });
15810
- var zEnvVariable = object({
15811
- name: string2(),
15812
- value: string2(),
15813
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15814
- });
15815
- var zCreateTerminalRequest = object({
15816
- sessionId: zSessionId,
15817
- command: string2(),
15818
- args: defaultOnError(vecSkipError(string2()).optional(), () => []),
15819
- env: defaultOnError(vecSkipError(zEnvVariable).optional(), () => []),
15820
- cwd: defaultOnError(string2().nullish(), () => void 0),
15821
- outputByteLimit: defaultOnError(number2().nullish(), () => void 0),
15822
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15823
- });
15824
- var zTerminalOutputRequest = object({
15825
- sessionId: zSessionId,
15826
- terminalId: zTerminalId,
15827
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15828
- });
15829
- var zReleaseTerminalRequest = object({
15830
- sessionId: zSessionId,
15831
- terminalId: zTerminalId,
15832
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15833
- });
15834
- var zWaitForTerminalExitRequest = object({
15835
- sessionId: zSessionId,
15836
- terminalId: zTerminalId,
15837
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15838
- });
15839
- var zKillTerminalRequest = object({
15840
- sessionId: zSessionId,
15841
- terminalId: zTerminalId,
15842
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15843
- });
15844
- var zElicitationSessionScope = object({
15845
- sessionId: zSessionId,
15846
- toolCallId: defaultOnError(zToolCallId.nullish(), () => void 0)
15847
- });
15848
- var zElicitationRequestScope = object({
15849
- requestId: zRequestId
15850
- });
15851
- var zElicitationSchemaType = literal("object");
15852
- var zStringFormat = union([
15853
- literal("email"),
15854
- literal("uri"),
15855
- literal("date"),
15856
- literal("date-time")
15857
- ]);
15858
- var zEnumOption = object({
15859
- const: string2(),
15860
- title: string2(),
15861
- description: defaultOnError(string2().nullish(), () => void 0),
15862
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15863
- });
15864
- var zStringPropertySchema = object({
15865
- title: defaultOnError(string2().nullish(), () => void 0),
15866
- description: defaultOnError(string2().nullish(), () => void 0),
15867
- minLength: int().gte(0).max(4294967295, {
15868
- error: "Invalid value: Expected uint32 to be <= 4294967295"
15869
- }).nullish(),
15870
- maxLength: int().gte(0).max(4294967295, {
15871
- error: "Invalid value: Expected uint32 to be <= 4294967295"
15872
- }).nullish(),
15873
- pattern: string2().nullish(),
15874
- format: zStringFormat.nullish(),
15875
- default: defaultOnError(string2().nullish(), () => void 0),
15876
- enum: array(string2()).nullish(),
15877
- oneOf: array(zEnumOption).nullish(),
15878
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15879
- });
15880
- var zNumberPropertySchema = object({
15881
- title: defaultOnError(string2().nullish(), () => void 0),
15882
- description: defaultOnError(string2().nullish(), () => void 0),
15883
- minimum: number2().nullish(),
15884
- maximum: number2().nullish(),
15885
- default: defaultOnError(number2().nullish(), () => void 0),
15886
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15887
- });
15888
- var zIntegerPropertySchema = object({
15889
- title: defaultOnError(string2().nullish(), () => void 0),
15890
- description: defaultOnError(string2().nullish(), () => void 0),
15891
- minimum: number2().nullish(),
15892
- maximum: number2().nullish(),
15893
- default: defaultOnError(number2().nullish(), () => void 0),
15894
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15895
- });
15896
- var zBooleanPropertySchema = object({
15897
- title: defaultOnError(string2().nullish(), () => void 0),
15898
- description: defaultOnError(string2().nullish(), () => void 0),
15899
- default: defaultOnError(boolean2().nullish(), () => void 0),
15900
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15901
- });
15902
- var zStringMultiSelectItems = object({
15903
- enum: array(string2()),
15904
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15905
- });
15906
- var zTitledMultiSelectItems = object({
15907
- anyOf: array(zEnumOption),
15908
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15909
- });
15910
- var zMultiSelectItems = preserveCustomPayload(union([
15911
- zStringMultiSelectItems.and(object({
15912
- type: literal("string")
15913
- })),
15914
- excludeKnownTags(object({
15915
- type: string2()
15916
- }), "type", ["string"]),
15917
- zTitledMultiSelectItems
15918
- ]), "type", ["string"]);
15919
- var zMultiSelectPropertySchema = object({
15920
- title: defaultOnError(string2().nullish(), () => void 0),
15921
- description: defaultOnError(string2().nullish(), () => void 0),
15922
- minItems: number2().nullish(),
15923
- maxItems: number2().nullish(),
15924
- items: zMultiSelectItems,
15925
- default: defaultOnError(vecSkipError(string2()).nullish(), () => void 0),
15926
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => void 0)
15927
- });
15928
- var zElicitationPropertySchema = preserveCustomPayload(union([
15929
- zStringPropertySchema.and(object({
15930
- type: literal("string")
15931
- })),
15932
- zNumberPropertySchema.and(object({
15933
- type: literal("number")
15934
- })),
15935
- zIntegerPropertySchema.and(object({
15936
- type: literal("integer")
15937
- })),
15938
- zBooleanPropertySchema.and(object({
15939
- type: literal("boolean")
14945
+ zBooleanPropertySchema.and(object({
14946
+ type: literal("boolean")
15940
14947
  })),
15941
14948
  zMultiSelectPropertySchema.and(object({
15942
14949
  type: literal("array")
@@ -17251,17 +16258,17 @@ function isResponseMessage(value) {
17251
16258
  function isNotificationMessage(value) {
17252
16259
  return isJsonRpcEnvelope(value) && !("id" in value) && typeof value["method"] === "string";
17253
16260
  }
17254
- function isRecord2(value) {
16261
+ function isRecord(value) {
17255
16262
  return typeof value === "object" && value !== null;
17256
16263
  }
17257
16264
  function isJsonRpcEnvelope(value) {
17258
- return isRecord2(value) && value["jsonrpc"] === "2.0";
16265
+ return isRecord(value) && value["jsonrpc"] === "2.0";
17259
16266
  }
17260
16267
  function isJsonRpcId(value) {
17261
16268
  return value === null || typeof value === "string" || typeof value === "number" && Number.isFinite(value);
17262
16269
  }
17263
16270
  function isResponseShapedMessage(value) {
17264
- return isRecord2(value) && !("method" in value) && ("id" in value || "result" in value || "error" in value);
16271
+ return isRecord(value) && !("method" in value) && ("id" in value || "result" in value || "error" in value);
17265
16272
  }
17266
16273
  function isResponseBatch(batch) {
17267
16274
  let hasValidCall = false;
@@ -17271,7 +16278,7 @@ function isResponseBatch(batch) {
17271
16278
  for (const entry of batch) {
17272
16279
  hasValidCall ||= isRequestMessage(entry) || isNotificationMessage(entry);
17273
16280
  hasValidResponse ||= isResponseMessage(entry);
17274
- if (!isRecord2(entry)) {
16281
+ if (!isRecord(entry)) {
17275
16282
  continue;
17276
16283
  }
17277
16284
  hasCallShape ||= "method" in entry;
@@ -17286,13 +16293,13 @@ function isResponseBatch(batch) {
17286
16293
  return hasResponseShape && !hasCallShape;
17287
16294
  }
17288
16295
  function cancelRequestId(params) {
17289
- if (!isRecord2(params) || !isJsonRpcId(params["requestId"])) {
16296
+ if (!isRecord(params) || !isJsonRpcId(params["requestId"])) {
17290
16297
  return void 0;
17291
16298
  }
17292
16299
  return params["requestId"];
17293
16300
  }
17294
16301
  function isErrorResponse(value) {
17295
- return isRecord2(value) && typeof value["code"] === "number" && Number.isInteger(value["code"]) && typeof value["message"] === "string";
16302
+ return isRecord(value) && typeof value["code"] === "number" && Number.isInteger(value["code"]) && typeof value["message"] === "string";
17296
16303
  }
17297
16304
  var Handled = {
17298
16305
  /**
@@ -17783,7 +16790,7 @@ var Connection = class {
17783
16790
  this.receiveBatch(message);
17784
16791
  return;
17785
16792
  }
17786
- if (!isRecord2(message)) {
16793
+ if (!isRecord(message)) {
17787
16794
  console.error("Invalid message", { message });
17788
16795
  return;
17789
16796
  }
@@ -17846,7 +16853,7 @@ var Connection = class {
17846
16853
  if (this.abortController.signal.aborted) {
17847
16854
  return Promise.resolve();
17848
16855
  }
17849
- if (!isRecord2(message)) {
16856
+ if (!isRecord(message)) {
17850
16857
  console.error("Invalid message", { message });
17851
16858
  return Promise.resolve();
17852
16859
  }
@@ -18216,7 +17223,7 @@ function ndJsonStream(output, input) {
18216
17223
  if (trimmedLine) {
18217
17224
  try {
18218
17225
  const message = JSON.parse(trimmedLine);
18219
- if (isRecord2(message) || Array.isArray(message)) {
17226
+ if (isRecord(message) || Array.isArray(message)) {
18220
17227
  controller.enqueue(message);
18221
17228
  } else {
18222
17229
  console.warn("Skipping JSON line that is not an object:", trimmedLine);
@@ -19487,195 +18494,1240 @@ var ClientSideConnection = class {
19487
18494
  prompt(params) {
19488
18495
  return this.connection.sendRequest(AGENT_METHODS.session_prompt, params);
19489
18496
  }
19490
- /**
19491
- * Cancels ongoing operations for a session.
19492
- *
19493
- * This is a notification sent by the client to cancel an ongoing prompt turn.
19494
- *
19495
- * Upon receiving this notification, the Agent SHOULD:
19496
- * - Stop all language model requests as soon as possible
19497
- * - Abort all tool call invocations in progress
19498
- * - Send any pending `session/update` notifications
19499
- * - Respond to the original `session/prompt` request with `StopReason::Cancelled`
19500
- *
19501
- * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)
19502
- */
19503
- cancel(params) {
19504
- return this.connection.sendNotification(AGENT_METHODS.session_cancel, params);
18497
+ /**
18498
+ * Cancels ongoing operations for a session.
18499
+ *
18500
+ * This is a notification sent by the client to cancel an ongoing prompt turn.
18501
+ *
18502
+ * Upon receiving this notification, the Agent SHOULD:
18503
+ * - Stop all language model requests as soon as possible
18504
+ * - Abort all tool call invocations in progress
18505
+ * - Send any pending `session/update` notifications
18506
+ * - Respond to the original `session/prompt` request with `StopReason::Cancelled`
18507
+ *
18508
+ * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)
18509
+ */
18510
+ cancel(params) {
18511
+ return this.connection.sendNotification(AGENT_METHODS.session_cancel, params);
18512
+ }
18513
+ /**
18514
+ * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
18515
+ *
18516
+ * Starts a NES (Next Edit Suggestions) session.
18517
+ *
18518
+ * @experimental
18519
+ */
18520
+ unstable_startNes(params) {
18521
+ return this.connection.sendRequest(AGENT_METHODS.nes_start, params);
18522
+ }
18523
+ /**
18524
+ * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
18525
+ *
18526
+ * Sends a NES suggestion request.
18527
+ *
18528
+ * @experimental
18529
+ */
18530
+ unstable_suggestNes(params) {
18531
+ return this.connection.sendRequest(AGENT_METHODS.nes_suggest, params);
18532
+ }
18533
+ /**
18534
+ * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
18535
+ *
18536
+ * Closes a NES session.
18537
+ *
18538
+ * @experimental
18539
+ */
18540
+ unstable_closeNes(params) {
18541
+ return this.connection.sendRequest(AGENT_METHODS.nes_close, params, emptyObjectResponse);
18542
+ }
18543
+ /**
18544
+ * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
18545
+ *
18546
+ * Notifies the agent that a document was opened.
18547
+ *
18548
+ * @experimental
18549
+ */
18550
+ unstable_didOpenDocument(params) {
18551
+ return this.connection.sendNotification(AGENT_METHODS.document_did_open, params);
18552
+ }
18553
+ /**
18554
+ * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
18555
+ *
18556
+ * Notifies the agent that a document was changed.
18557
+ *
18558
+ * @experimental
18559
+ */
18560
+ unstable_didChangeDocument(params) {
18561
+ return this.connection.sendNotification(AGENT_METHODS.document_did_change, params);
18562
+ }
18563
+ /**
18564
+ * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
18565
+ *
18566
+ * Notifies the agent that a document was closed.
18567
+ *
18568
+ * @experimental
18569
+ */
18570
+ unstable_didCloseDocument(params) {
18571
+ return this.connection.sendNotification(AGENT_METHODS.document_did_close, params);
18572
+ }
18573
+ /**
18574
+ * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
18575
+ *
18576
+ * Notifies the agent that a document was saved.
18577
+ *
18578
+ * @experimental
18579
+ */
18580
+ unstable_didSaveDocument(params) {
18581
+ return this.connection.sendNotification(AGENT_METHODS.document_did_save, params);
18582
+ }
18583
+ /**
18584
+ * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
18585
+ *
18586
+ * Notifies the agent that a document received focus.
18587
+ *
18588
+ * @experimental
18589
+ */
18590
+ unstable_didFocusDocument(params) {
18591
+ return this.connection.sendNotification(AGENT_METHODS.document_did_focus, params);
18592
+ }
18593
+ /**
18594
+ * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
18595
+ *
18596
+ * Notifies the agent that a NES suggestion was accepted.
18597
+ *
18598
+ * @experimental
18599
+ */
18600
+ unstable_acceptNes(params) {
18601
+ return this.connection.sendNotification(AGENT_METHODS.nes_accept, params);
18602
+ }
18603
+ /**
18604
+ * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
18605
+ *
18606
+ * Notifies the agent that a NES suggestion was rejected.
18607
+ *
18608
+ * @experimental
18609
+ */
18610
+ unstable_rejectNes(params) {
18611
+ return this.connection.sendNotification(AGENT_METHODS.nes_reject, params);
18612
+ }
18613
+ request(method, params, options) {
18614
+ const spec = agentRequestSpecsByMethod[method];
18615
+ return this.connection.sendRequest(method, params, spec?.mapResponse, options);
18616
+ }
18617
+ notify(method, params) {
18618
+ return this.connection.sendNotification(method, params);
18619
+ }
18620
+ /**
18621
+ * Extension method.
18622
+ *
18623
+ * @deprecated Use {@link request}.
18624
+ */
18625
+ extMethod(method, params) {
18626
+ return this.request(method, params);
18627
+ }
18628
+ /**
18629
+ * Extension notification.
18630
+ *
18631
+ * @deprecated Use {@link notify}.
18632
+ */
18633
+ extNotification(method, params) {
18634
+ return this.notify(method, params);
18635
+ }
18636
+ /**
18637
+ * AbortSignal that aborts when the connection closes.
18638
+ *
18639
+ * This signal can be used to:
18640
+ * - Listen for connection closure: `connection.signal.addEventListener('abort', () => {...})`
18641
+ * - Check connection status synchronously: `if (connection.signal.aborted) {...}`
18642
+ * - Pass to other APIs (fetch, setTimeout) for automatic cancellation
18643
+ *
18644
+ * The connection closes when the underlying stream ends, either normally or due to an error.
18645
+ *
18646
+ * @example
18647
+ * ```typescript
18648
+ * const connection = new ClientSideConnection(client, stream);
18649
+ *
18650
+ * // Listen for closure
18651
+ * connection.signal.addEventListener('abort', () => {
18652
+ * console.log('Connection closed - performing cleanup');
18653
+ * });
18654
+ *
18655
+ * // Check status
18656
+ * if (connection.signal.aborted) {
18657
+ * console.log('Connection is already closed');
18658
+ * }
18659
+ *
18660
+ * // Pass to other APIs
18661
+ * fetch(url, { signal: connection.signal });
18662
+ * ```
18663
+ */
18664
+ get signal() {
18665
+ return this.connection.signal;
18666
+ }
18667
+ /**
18668
+ * Promise that resolves when the connection closes.
18669
+ *
18670
+ * The connection closes when the underlying stream ends, either normally or due to an error.
18671
+ * Once closed, the connection cannot send or receive any more messages.
18672
+ *
18673
+ * This is useful for async/await style cleanup:
18674
+ *
18675
+ * @example
18676
+ * ```typescript
18677
+ * const connection = new ClientSideConnection(client, stream);
18678
+ * await connection.closed;
18679
+ * console.log('Connection closed - performing cleanup');
18680
+ * ```
18681
+ */
18682
+ get closed() {
18683
+ return this.connection.closed;
18684
+ }
18685
+ };
18686
+
18687
+ // ../../shared-contracts/dist/version.js
18688
+ var WORKSPACE_CONTRACT_VERSION = 1;
18689
+
18690
+ // ../../shared-contracts/dist/ids.js
18691
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
18692
+ message: "Identifier must not be empty or whitespace"
18693
+ });
18694
+ var harnessIdSchema = opaqueIdSchema.brand();
18695
+ var hostThreadIdSchema = opaqueIdSchema.brand();
18696
+ var hostTurnIdSchema = opaqueIdSchema.brand();
18697
+ var hostItemIdSchema = opaqueIdSchema.brand();
18698
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
18699
+
18700
+ // ../../shared-contracts/dist/thread-usage.js
18701
+ var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
18702
+ var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
18703
+ var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
18704
+ var threadUsageSnapshotSchema = external_exports.object({
18705
+ inputTokens: nonNegativeSafeIntegerSchema.optional(),
18706
+ cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
18707
+ cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
18708
+ outputTokens: nonNegativeSafeIntegerSchema.optional(),
18709
+ outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
18710
+ reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
18711
+ totalTokens: nonNegativeSafeIntegerSchema.optional(),
18712
+ totalCostUsd: finiteNonNegativeNumberSchema.optional(),
18713
+ cacheHitRatePercent: cacheHitRatePercentSchema.optional(),
18714
+ contextWindowTokens: nonNegativeSafeIntegerSchema.optional(),
18715
+ contextUsedTokens: nonNegativeSafeIntegerSchema.optional(),
18716
+ planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
18717
+ planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
18718
+ planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
18719
+ planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
18720
+ }).strict().superRefine((usage, context) => {
18721
+ if (Object.keys(usage).length === 0) {
18722
+ context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
18723
+ }
18724
+ const hasContextUsed = usage.contextUsedTokens !== void 0;
18725
+ const hasContextWindow = usage.contextWindowTokens !== void 0;
18726
+ if (hasContextUsed !== hasContextWindow) {
18727
+ context.addIssue({
18728
+ code: "custom",
18729
+ message: "Thread Usage context fields must be provided together",
18730
+ path: [hasContextUsed ? "contextWindowTokens" : "contextUsedTokens"]
18731
+ });
18732
+ }
18733
+ if (usage.contextWindowTokens === 0) {
18734
+ context.addIssue({
18735
+ code: "custom",
18736
+ message: "Thread Usage contextWindowTokens must be greater than zero",
18737
+ path: ["contextWindowTokens"]
18738
+ });
18739
+ }
18740
+ if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
18741
+ context.addIssue({
18742
+ code: "custom",
18743
+ message: "Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent",
18744
+ path: ["planFiveHourResetsAtUnix"]
18745
+ });
18746
+ }
18747
+ if (usage.planSevenDayResetsAtUnix !== void 0 && usage.planSevenDayUsedPercent === void 0) {
18748
+ context.addIssue({
18749
+ code: "custom",
18750
+ message: "Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent",
18751
+ path: ["planSevenDayResetsAtUnix"]
18752
+ });
18753
+ }
18754
+ });
18755
+ var usagePercentSchema = external_exports.number().finite().min(0).max(100);
18756
+ var accountCreditsProductUsageSchema = external_exports.object({
18757
+ product: external_exports.string().min(1),
18758
+ usagePercent: usagePercentSchema,
18759
+ resetsAt: external_exports.string().min(1).optional()
18760
+ }).strict();
18761
+ var accountResetCreditsSchema = external_exports.object({
18762
+ availableCount: external_exports.number().int().safe().positive(),
18763
+ nextExpiresAt: external_exports.string().min(1).optional(),
18764
+ expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
18765
+ }).strict();
18766
+ var accountCreditsSnapshotSchema = external_exports.object({
18767
+ /** Native label when the primary limit is scoped to a model or product group. */
18768
+ label: external_exports.string().min(1).optional(),
18769
+ usedPercent: usagePercentSchema.optional(),
18770
+ remaining: external_exports.number().finite().optional(),
18771
+ unit: external_exports.string().trim().min(1).max(32).optional(),
18772
+ resetsAt: external_exports.string().min(1).optional(),
18773
+ periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
18774
+ productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
18775
+ resetCredits: accountResetCreditsSchema.optional()
18776
+ }).strict().superRefine((credits, context) => {
18777
+ if (credits.usedPercent === void 0 && credits.remaining === void 0) {
18778
+ context.addIssue({
18779
+ code: "custom",
18780
+ message: "Account credits must include usedPercent or remaining"
18781
+ });
18782
+ }
18783
+ if (credits.remaining !== void 0 && !credits.unit) {
18784
+ context.addIssue({
18785
+ code: "custom",
18786
+ message: "Account remaining credits require a unit",
18787
+ path: ["unit"]
18788
+ });
18789
+ }
18790
+ });
18791
+ var threadUsageInspectionParamsSchema = external_exports.object({
18792
+ threadId: hostThreadIdSchema,
18793
+ refresh: external_exports.literal("exact").optional()
18794
+ }).strict();
18795
+ var threadUsageInspectionSchema = external_exports.object({
18796
+ threadId: hostThreadIdSchema,
18797
+ usage: threadUsageSnapshotSchema.nullable(),
18798
+ accountCredits: accountCreditsSnapshotSchema.optional()
18799
+ }).strict();
18800
+
18801
+ // ../../shared-contracts/dist/harness-accounts.js
18802
+ var harnessAccountSnapshotSchema = external_exports.object({
18803
+ email: external_exports.string().trim().min(1).max(320).optional(),
18804
+ label: external_exports.string().trim().min(1).max(256).optional(),
18805
+ plan: external_exports.string().trim().min(1).max(128).optional(),
18806
+ credits: accountCreditsSnapshotSchema
18807
+ }).strict();
18808
+ var harnessAccountListParamsSchema = external_exports.object({}).strict();
18809
+ var harnessAccountListResultSchema = external_exports.object({
18810
+ accounts: external_exports.array(harnessAccountSnapshotSchema.extend({
18811
+ harnessId: harnessIdSchema,
18812
+ harnessName: external_exports.string().min(1)
18813
+ })).max(128)
18814
+ }).strict();
18815
+
18816
+ // ../../shared-contracts/dist/json-value.js
18817
+ function rejectExplicitUndefined(keys) {
18818
+ return (value, context) => {
18819
+ for (const key of keys) {
18820
+ if (Object.hasOwn(value, key) && value[key] === void 0) {
18821
+ context.addIssue({
18822
+ code: "custom",
18823
+ path: [key],
18824
+ message: "Explicit undefined is not valid JSON"
18825
+ });
18826
+ }
18827
+ }
18828
+ };
18829
+ }
18830
+ var jsonPrimitiveSchema = external_exports.union([
18831
+ external_exports.string(),
18832
+ external_exports.number(),
18833
+ external_exports.boolean(),
18834
+ external_exports.null()
18835
+ ]);
18836
+ function hasNoCircularReferences(value) {
18837
+ const ancestors = /* @__PURE__ */ new WeakSet();
18838
+ const stack = [{ value, leaving: false }];
18839
+ try {
18840
+ while (stack.length > 0) {
18841
+ const frame = stack.pop();
18842
+ if (!frame)
18843
+ break;
18844
+ if (frame.leaving) {
18845
+ ancestors.delete(frame.value);
18846
+ continue;
18847
+ }
18848
+ if (typeof frame.value !== "object" || frame.value === null)
18849
+ continue;
18850
+ if (ancestors.has(frame.value))
18851
+ return false;
18852
+ ancestors.add(frame.value);
18853
+ stack.push({ value: frame.value, leaving: true });
18854
+ for (const child of Object.values(frame.value)) {
18855
+ stack.push({ value: child, leaving: false });
18856
+ }
18857
+ }
18858
+ } catch {
18859
+ return false;
18860
+ }
18861
+ return true;
18862
+ }
18863
+ var nonCircularSchema = external_exports.custom(hasNoCircularReferences, {
18864
+ message: "JSON value must not contain circular references"
18865
+ });
18866
+ var recursiveJsonValueSchema = external_exports.lazy(() => external_exports.union([
18867
+ jsonPrimitiveSchema,
18868
+ external_exports.array(recursiveJsonValueSchema),
18869
+ external_exports.record(external_exports.string(), recursiveJsonValueSchema)
18870
+ ]));
18871
+ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
18872
+ var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
18873
+ var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
18874
+
18875
+ // ../../shared-contracts/dist/errors.js
18876
+ var codexhostErrorSchema = external_exports.strictObject({
18877
+ code: external_exports.string().min(1),
18878
+ message: external_exports.string().min(1),
18879
+ retryable: external_exports.boolean(),
18880
+ diagnostic: external_exports.string().min(1).optional(),
18881
+ stage: external_exports.string().min(1).optional(),
18882
+ durationMs: external_exports.number().int().nonnegative().optional(),
18883
+ stderrTail: external_exports.string().min(1).optional()
18884
+ }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
18885
+
18886
+ // ../../shared-contracts/dist/harness-permission-modes.js
18887
+ var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
18888
+ var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
18889
+ var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
18890
+ var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
18891
+ var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
18892
+ message: "Value must not be empty or whitespace"
18893
+ });
18894
+ var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
18895
+ var harnessPermissionModeSchema = external_exports.object({
18896
+ id: harnessPermissionModeIdSchema,
18897
+ label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
18898
+ description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
18899
+ dangerous: external_exports.boolean().optional()
18900
+ }).strict();
18901
+ var harnessPermissionModeCatalogSchema = external_exports.object({
18902
+ modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
18903
+ defaultModeId: harnessPermissionModeIdSchema
18904
+ }).strict().superRefine((catalog, context) => {
18905
+ const ids = /* @__PURE__ */ new Set();
18906
+ for (const [index, mode] of catalog.modes.entries()) {
18907
+ if (ids.has(mode.id)) {
18908
+ context.addIssue({
18909
+ code: "custom",
18910
+ message: "Permission Mode IDs must be unique",
18911
+ path: ["modes", index, "id"]
18912
+ });
18913
+ }
18914
+ ids.add(mode.id);
18915
+ }
18916
+ if (!ids.has(catalog.defaultModeId)) {
18917
+ context.addIssue({
18918
+ code: "custom",
18919
+ message: "Default Permission Mode must exist in the catalog",
18920
+ path: ["defaultModeId"]
18921
+ });
18922
+ }
18923
+ });
18924
+ var threadPermissionModeSelectParamsSchema = external_exports.object({
18925
+ threadId: hostThreadIdSchema,
18926
+ permissionModeId: harnessPermissionModeIdSchema
18927
+ }).strict();
18928
+
18929
+ // ../../shared-contracts/dist/harness-models.js
18930
+ var HARNESS_MODEL_REF_MAX_LENGTH = 512;
18931
+ var HARNESS_MODEL_LABEL_MAX_LENGTH = 256;
18932
+ var HARNESS_THINKING_OPTION_ID_MAX_LENGTH = 128;
18933
+ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
18934
+ var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
18935
+ message: "Value must not be empty or whitespace"
18936
+ });
18937
+ var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
18938
+ var harnessModelRefSchema = external_exports.object({
18939
+ id: harnessModelRefIdSchema
18940
+ }).strict();
18941
+ var harnessThinkingOptionIdSchema = nonBlankTextSchema2.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
18942
+ var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
18943
+ var harnessThinkingOptionSchema = external_exports.object({
18944
+ id: harnessThinkingOptionIdSchema,
18945
+ label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH)
18946
+ }).strict();
18947
+ var harnessModelSchema = external_exports.object({
18948
+ ref: harnessModelRefSchema,
18949
+ label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
18950
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
18951
+ supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
18952
+ }).strict();
18953
+ var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
18954
+ const ids = /* @__PURE__ */ new Set();
18955
+ for (const [index, option] of options.entries()) {
18956
+ if (ids.has(option.id)) {
18957
+ context.addIssue({
18958
+ code: "custom",
18959
+ message: "Thinking option IDs must be unique",
18960
+ path: [index, "id"]
18961
+ });
18962
+ }
18963
+ ids.add(option.id);
18964
+ }
18965
+ });
18966
+ var harnessModelCatalogSchema = external_exports.object({
18967
+ models: external_exports.array(harnessModelSchema),
18968
+ defaultModel: harnessModelRefSchema.optional(),
18969
+ thinkingOptions: harnessThinkingOptionsSchema,
18970
+ defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
18971
+ }).strict().superRefine((catalog, context) => {
18972
+ const refs = /* @__PURE__ */ new Set();
18973
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
18974
+ for (const [index, model] of catalog.models.entries()) {
18975
+ if (refs.has(model.ref.id)) {
18976
+ context.addIssue({
18977
+ code: "custom",
18978
+ message: "Model Catalog refs must be unique",
18979
+ path: ["models", index, "ref", "id"]
18980
+ });
18981
+ }
18982
+ refs.add(model.ref.id);
18983
+ const supportedThinkingIds = /* @__PURE__ */ new Set();
18984
+ for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
18985
+ if (supportedThinkingIds.has(optionId)) {
18986
+ context.addIssue({
18987
+ code: "custom",
18988
+ message: "Supported Thinking option IDs must be unique per Model",
18989
+ path: ["models", index, "supportedThinkingOptionIds", optionIndex]
18990
+ });
18991
+ }
18992
+ supportedThinkingIds.add(optionId);
18993
+ if (!thinkingIds.has(optionId)) {
18994
+ context.addIssue({
18995
+ code: "custom",
18996
+ message: "Supported Thinking option must exist in the catalog",
18997
+ path: ["models", index, "supportedThinkingOptionIds", optionIndex]
18998
+ });
18999
+ }
19000
+ }
19001
+ }
19002
+ if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
19003
+ context.addIssue({
19004
+ code: "custom",
19005
+ message: "Default Model must exist in the Model Catalog",
19006
+ path: ["defaultModel", "id"]
19007
+ });
19008
+ }
19009
+ if (catalog.defaultThinkingOptionId && !thinkingIds.has(catalog.defaultThinkingOptionId)) {
19010
+ context.addIssue({
19011
+ code: "custom",
19012
+ message: "Default Thinking option must exist in the catalog",
19013
+ path: ["defaultThinkingOptionId"]
19014
+ });
19015
+ }
19016
+ });
19017
+ var harnessHistoryCapabilitiesSchema = external_exports.object({
19018
+ fork: external_exports.boolean(),
19019
+ forkAcrossCwd: external_exports.boolean(),
19020
+ rollbackLastTurn: external_exports.boolean()
19021
+ }).strict().refine((history) => history.fork || !history.forkAcrossCwd, {
19022
+ path: ["forkAcrossCwd"],
19023
+ message: "Cross-cwd Fork requires exact history Fork support"
19024
+ });
19025
+ var harnessPermissionModeScopeSchema = external_exports.enum(["live", "atCreate"]);
19026
+ var harnessSessionCapabilitiesSchema = external_exports.object({
19027
+ configuration: external_exports.object({
19028
+ selectModel: external_exports.boolean(),
19029
+ selectThinkingOption: external_exports.boolean(),
19030
+ selectPermissionMode: external_exports.boolean(),
19031
+ permissionModeScope: harnessPermissionModeScopeSchema.default("live")
19032
+ }).strict(),
19033
+ history: harnessHistoryCapabilitiesSchema,
19034
+ subagents: external_exports.object({
19035
+ observe: external_exports.boolean(),
19036
+ readTranscript: external_exports.boolean()
19037
+ }).strict().optional(),
19038
+ autonomousTurns: external_exports.object({
19039
+ observe: external_exports.boolean()
19040
+ }).strict().optional(),
19041
+ input: external_exports.object({
19042
+ image: external_exports.boolean()
19043
+ }).strict().optional()
19044
+ }).strict();
19045
+ var harnessConfigurationStateSchema = external_exports.object({
19046
+ effectiveModel: harnessModelRefSchema.optional(),
19047
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19048
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19049
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19050
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
19051
+ }).strict().superRefine((state, context) => {
19052
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
19053
+ context.addIssue({
19054
+ code: "custom",
19055
+ message: "Effective Thinking option must be currently available",
19056
+ path: ["effectiveThinkingOptionId"]
19057
+ });
19058
+ }
19059
+ });
19060
+ var harnessWebUiCapabilitySchema = external_exports.object({
19061
+ open: external_exports.literal(true)
19062
+ }).strict();
19063
+ var readyHarnessInspectionSchema = external_exports.object({
19064
+ status: external_exports.literal("ready"),
19065
+ catalog: harnessModelCatalogSchema,
19066
+ permissionModes: harnessPermissionModeCatalogSchema.optional(),
19067
+ capabilities: harnessSessionCapabilitiesSchema,
19068
+ webUi: harnessWebUiCapabilitySchema.optional()
19069
+ }).strict().superRefine((inspection, context) => {
19070
+ const selectable = inspection.capabilities.configuration.selectPermissionMode;
19071
+ if (selectable !== Boolean(inspection.permissionModes)) {
19072
+ context.addIssue({
19073
+ code: "custom",
19074
+ message: "Permission Mode catalog and capability must agree",
19075
+ path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
19076
+ });
19077
+ }
19078
+ });
19079
+ var failedHarnessInspectionSchema = external_exports.object({
19080
+ status: external_exports.enum(["notInstalled", "unavailable", "error"]),
19081
+ error: codexhostErrorSchema
19082
+ }).strict();
19083
+ var harnessInspectionSchema = external_exports.union([
19084
+ readyHarnessInspectionSchema,
19085
+ failedHarnessInspectionSchema
19086
+ ]);
19087
+ var harnessInspectParamsSchema = external_exports.object({
19088
+ harnessId: harnessIdSchema,
19089
+ cwd: nonBlankTextSchema2.max(16384).optional(),
19090
+ refresh: external_exports.boolean().optional()
19091
+ }).strict();
19092
+ var harnessWebUiOpenParamsSchema = external_exports.object({
19093
+ harnessId: harnessIdSchema
19094
+ }).strict();
19095
+ var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
19096
+ var threadModelSelectParamsSchema = external_exports.object({
19097
+ threadId: hostThreadIdSchema,
19098
+ model: harnessModelRefSchema
19099
+ }).strict();
19100
+ var threadThinkingSelectParamsSchema = external_exports.object({
19101
+ threadId: hostThreadIdSchema,
19102
+ thinkingOptionId: harnessThinkingOptionIdSchema
19103
+ }).strict();
19104
+ var threadInspectionParamsSchema = external_exports.object({
19105
+ threadId: hostThreadIdSchema
19106
+ }).strict();
19107
+ var codexThreadInspectionSchema = external_exports.object({
19108
+ owner: external_exports.literal("codex"),
19109
+ accountId: nonBlankTextSchema2.optional(),
19110
+ locked: external_exports.literal(true)
19111
+ }).strict();
19112
+ var externalThreadInspectionSchema = external_exports.object({
19113
+ owner: external_exports.literal("external"),
19114
+ harnessId: nonBlankTextSchema2.max(256),
19115
+ transportModelId: nonBlankTextSchema2.max(1024),
19116
+ effectiveModel: harnessModelRefSchema.optional(),
19117
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19118
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19119
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19120
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
19121
+ history: harnessHistoryCapabilitiesSchema,
19122
+ usage: threadUsageSnapshotSchema.optional(),
19123
+ /** True when the thread is a read-only child thread materialized for a subagent. */
19124
+ subagent: external_exports.boolean().optional(),
19125
+ locked: external_exports.literal(true)
19126
+ }).strict();
19127
+ var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
19128
+ codexThreadInspectionSchema,
19129
+ externalThreadInspectionSchema
19130
+ ]);
19131
+ var threadOwnershipListParamsSchema = external_exports.object({
19132
+ threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19133
+ }).strict().superRefine(({ threadIds }, context) => {
19134
+ const seen = /* @__PURE__ */ new Set();
19135
+ for (const [index, threadId] of threadIds.entries()) {
19136
+ if (seen.has(threadId)) {
19137
+ context.addIssue({
19138
+ code: "custom",
19139
+ message: "Thread ownership-list IDs must be unique",
19140
+ path: ["threadIds", index]
19141
+ });
19142
+ }
19143
+ seen.add(threadId);
19144
+ }
19145
+ });
19146
+ var codexThreadOwnershipSchema = external_exports.object({
19147
+ threadId: hostThreadIdSchema,
19148
+ owner: external_exports.literal("codex")
19149
+ }).strict();
19150
+ var externalThreadOwnershipSchema = external_exports.object({
19151
+ threadId: hostThreadIdSchema,
19152
+ owner: external_exports.literal("external"),
19153
+ harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
19154
+ }).strict();
19155
+ var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
19156
+ codexThreadOwnershipSchema,
19157
+ externalThreadOwnershipSchema
19158
+ ]);
19159
+ var threadOwnershipListResultSchema = external_exports.object({
19160
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19161
+ }).strict().superRefine(({ threads }, context) => {
19162
+ const seen = /* @__PURE__ */ new Set();
19163
+ for (const [index, thread] of threads.entries()) {
19164
+ if (seen.has(thread.threadId)) {
19165
+ context.addIssue({
19166
+ code: "custom",
19167
+ message: "Thread ownership-list results must be unique",
19168
+ path: ["threads", index, "threadId"]
19169
+ });
19170
+ }
19171
+ seen.add(thread.threadId);
19172
+ }
19173
+ });
19174
+
19175
+ // ../../shared-contracts/dist/harness-plugins.js
19176
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
19177
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
19178
+ var HARNESS_PLUGIN_LIMIT = 128;
19179
+ var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
19180
+ var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
19181
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
19182
+ var pluginPresentationShape = {
19183
+ id: harnessPluginIdSchema,
19184
+ name: external_exports.string().trim().min(1).max(128),
19185
+ version: external_exports.string().min(1).max(128),
19186
+ links: external_exports.object({
19187
+ documentation: documentationUrlSchema.optional(),
19188
+ installation: documentationUrlSchema.optional()
19189
+ }).strict().optional()
19190
+ };
19191
+ var harnessPluginManifestSchema = external_exports.object({
19192
+ manifestVersion: external_exports.literal(1),
19193
+ ...pluginPresentationShape,
19194
+ adapterApiVersion: external_exports.number().int().positive(),
19195
+ entry: relativeResourceSchema,
19196
+ icon: relativeResourceSchema.optional()
19197
+ }).strict();
19198
+ var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
19199
+ var harnessPluginDescriptorSchema = external_exports.object({
19200
+ ...pluginPresentationShape,
19201
+ icon: harnessPluginIconSchema.optional()
19202
+ }).strict();
19203
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
19204
+ var harnessPluginListResultSchema = external_exports.object({
19205
+ plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
19206
+ }).strict();
19207
+ var harnessPluginConfigurationSchema = external_exports.object({
19208
+ version: external_exports.literal(1),
19209
+ enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
19210
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
19211
+ message: "Enabled plugin IDs must be unique",
19212
+ path: ["enabled"]
19213
+ });
19214
+
19215
+ // ../../shared-contracts/dist/harness-route.js
19216
+ var harnessPluginRouteSchema = external_exports.object({
19217
+ harnessId: harnessPluginIdSchema,
19218
+ model: harnessModelRefSchema.optional(),
19219
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19220
+ permissionModeId: harnessPermissionModeIdSchema.optional()
19221
+ }).strict();
19222
+
19223
+ // ../../shared-contracts/dist/codex-accounts.js
19224
+ var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
19225
+ var nonBlankTextSchema3 = external_exports.string().trim().min(1);
19226
+ var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
19227
+ var codexAccountPlanTypeSchema = external_exports.enum([
19228
+ "free",
19229
+ "go",
19230
+ "plus",
19231
+ "pro",
19232
+ "prolite",
19233
+ "team",
19234
+ "self_serve_business_prolite",
19235
+ "self_serve_business_usage_based",
19236
+ "business",
19237
+ "ent26",
19238
+ "enterprise_cbp_automation",
19239
+ "enterprise_cbp_usage_based",
19240
+ "enterprise",
19241
+ "edu",
19242
+ "edu_plus",
19243
+ "edu_pro",
19244
+ "unknown"
19245
+ ]);
19246
+ var codexAccountSchema = external_exports.object({
19247
+ accountId: accountIdSchema,
19248
+ label: nonBlankTextSchema3.max(256),
19249
+ email: external_exports.string().email().max(320).optional(),
19250
+ planType: codexAccountPlanTypeSchema.optional(),
19251
+ codexHome: nonBlankTextSchema3.max(16384),
19252
+ active: external_exports.boolean(),
19253
+ isDefault: external_exports.boolean(),
19254
+ authKind: codexAccountAuthKindSchema.optional(),
19255
+ authIdentity: nonBlankTextSchema3.max(256).optional()
19256
+ }).strict();
19257
+ var codexAccountListResultSchema = external_exports.object({ accounts: external_exports.array(codexAccountSchema).max(128) }).strict();
19258
+ var codexAccountCreateParamsSchema = external_exports.object({ label: nonBlankTextSchema3.max(256).optional() }).strict();
19259
+ var codexAccountActivateParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
19260
+ var codexAccountDeleteParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
19261
+ var codexAccountDeleteResultSchema = external_exports.object({ deletedAccountId: accountIdSchema }).strict();
19262
+ var codexAccountMutationResultSchema = external_exports.object({ account: codexAccountSchema }).strict();
19263
+ var codexAccountLoginStartParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
19264
+ var codexAccountLoginStartResultSchema = external_exports.object({
19265
+ accountId: accountIdSchema,
19266
+ loginId: nonBlankTextSchema3.max(1024),
19267
+ verificationUrl: external_exports.string().url().max(16384),
19268
+ userCode: nonBlankTextSchema3.max(1024)
19269
+ }).strict();
19270
+ var codexAccountLoginCancelParamsSchema = external_exports.object({ accountId: accountIdSchema.optional(), loginId: nonBlankTextSchema3.max(1024) }).strict();
19271
+ var codexAccountLoginCancelResultSchema = external_exports.object({ cancelled: external_exports.boolean() }).strict();
19272
+ var codexAccountLoginCompletedSchema = external_exports.object({
19273
+ accountId: accountIdSchema,
19274
+ loginId: nonBlankTextSchema3.max(1024),
19275
+ success: external_exports.boolean(),
19276
+ error: external_exports.string().max(4096).nullable()
19277
+ }).strict();
19278
+ var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
19279
+ var codexAccountUsageResultSchema = external_exports.object({
19280
+ accountId: accountIdSchema,
19281
+ usage: threadUsageSnapshotSchema.nullable(),
19282
+ accountCredits: accountCreditsSnapshotSchema.optional()
19283
+ }).strict();
19284
+ var codexAccountResetCreditConsumeParamsSchema = external_exports.object({
19285
+ accountId: accountIdSchema,
19286
+ idempotencyKey: external_exports.string().uuid().optional()
19287
+ }).strict();
19288
+ var codexAccountResetCreditConsumeOutcomeSchema = external_exports.enum([
19289
+ "reset",
19290
+ "nothingToReset",
19291
+ "noCredit",
19292
+ "alreadyRedeemed"
19293
+ ]);
19294
+ var codexAccountResetCreditConsumeResultSchema = external_exports.object({
19295
+ accountId: accountIdSchema,
19296
+ outcome: codexAccountResetCreditConsumeOutcomeSchema,
19297
+ accountCredits: accountCreditsSnapshotSchema.optional()
19298
+ }).strict();
19299
+
19300
+ // ../../shared-contracts/dist/harness-session-import.js
19301
+ var HARNESS_SESSION_IMPORT_ID_MAX_LENGTH = 1024;
19302
+ var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
19303
+ var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
19304
+ var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
19305
+ var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
19306
+ var nonBlankTextSchema4 = 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");
19307
+ var harnessSessionImportIdSchema = nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
19308
+ var harnessSessionImportCandidateSchema = external_exports.object({
19309
+ nativeSessionId: harnessSessionImportIdSchema,
19310
+ title: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
19311
+ updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
19312
+ cwd: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
19313
+ // Native file discovery cannot reliably observe another process's activity.
19314
+ running: external_exports.boolean().nullable()
19315
+ }).strict();
19316
+ var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict();
19317
+ var harnessSessionImportSourcesResultSchema = external_exports.object({
19318
+ harnesses: external_exports.array(external_exports.object({
19319
+ harnessId: harnessPluginIdSchema,
19320
+ name: nonBlankTextSchema4.max(128)
19321
+ }).strict()).max(128)
19322
+ }).strict();
19323
+ var harnessSessionListParamsSchema = external_exports.object({
19324
+ harnessId: harnessPluginIdSchema,
19325
+ query: external_exports.string().trim().max(4096).refine((value) => !value.includes("\0")).optional(),
19326
+ offset: external_exports.number().int().nonnegative().safe().optional(),
19327
+ limit: external_exports.number().int().min(1).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH).optional()
19328
+ }).strict();
19329
+ var harnessSessionListResultSchema = external_exports.object({
19330
+ candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH),
19331
+ total: external_exports.number().int().nonnegative().safe()
19332
+ }).strict();
19333
+ var harnessSessionImportParamsSchema = external_exports.object({
19334
+ harnessId: harnessPluginIdSchema,
19335
+ nativeSessionId: harnessSessionImportIdSchema
19336
+ }).strict();
19337
+ var harnessSessionImportResultSchema = external_exports.object({
19338
+ threadId: nonBlankTextSchema4.max(1024).pipe(hostThreadIdSchema)
19339
+ }).strict();
19340
+
19341
+ // ../../shared-contracts/dist/deepseek-modern-sessions.js
19342
+ var DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH = HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH;
19343
+ var DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH = 1024;
19344
+ 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");
19345
+ var deepSeekModernSessionIdSchema = harnessSessionImportIdSchema;
19346
+ var deepSeekModernSessionCandidateSchema = harnessSessionImportCandidateSchema;
19347
+ var deepSeekModernSessionListParamsSchema = external_exports.object({}).strict();
19348
+ var deepSeekModernSessionListResultSchema = external_exports.object({
19349
+ candidates: external_exports.array(deepSeekModernSessionCandidateSchema).max(DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH)
19350
+ }).strict();
19351
+ var deepSeekModernSessionImportParamsSchema = external_exports.object({
19352
+ nativeSessionId: deepSeekModernSessionIdSchema
19353
+ }).strict();
19354
+ var deepSeekModernSessionImportResultSchema = external_exports.object({
19355
+ threadId: nonBlankTextSchema5.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
19356
+ }).strict();
19357
+
19358
+ // ../../shared-contracts/dist/external-thread-fork.js
19359
+ var externalThreadForkParamsSchema = external_exports.object({
19360
+ threadId: hostThreadIdSchema,
19361
+ lastTurnId: hostTurnIdSchema
19362
+ }).strict();
19363
+ var externalThreadForkResultSchema = external_exports.object({
19364
+ threadId: hostThreadIdSchema
19365
+ }).strict();
19366
+
19367
+ // ../../shared-contracts/dist/harness-commands.js
19368
+ var commandIdSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();
19369
+ var commandInvocationSchema = external_exports.string().min(1).max(128);
19370
+ var commandLabelSchema = external_exports.string().trim().min(1).max(128);
19371
+ var commandDescriptionSchema = external_exports.string().trim().min(1).max(512);
19372
+ var harnessCommandDescriptorSchema = external_exports.object({
19373
+ id: commandIdSchema,
19374
+ invocation: commandInvocationSchema,
19375
+ label: commandLabelSchema,
19376
+ description: commandDescriptionSchema.optional(),
19377
+ argumentMode: external_exports.enum(["none", "text"])
19378
+ }).strict();
19379
+ var harnessCommandCatalogSchema = external_exports.object({
19380
+ commands: external_exports.array(harnessCommandDescriptorSchema)
19381
+ }).strict().superRefine((catalog, context) => {
19382
+ const ids = /* @__PURE__ */ new Set();
19383
+ for (const [index, command] of catalog.commands.entries()) {
19384
+ if (ids.has(command.id)) {
19385
+ context.addIssue({
19386
+ code: "custom",
19387
+ message: "Harness command IDs must be unique",
19388
+ path: ["commands", index, "id"]
19389
+ });
19390
+ }
19391
+ ids.add(command.id);
19392
+ }
19393
+ });
19394
+ var harnessCommandsInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema }).strict();
19395
+ var threadCommandsInspectParamsSchema = external_exports.object({
19396
+ threadId: hostThreadIdSchema
19397
+ }).strict();
19398
+ var threadCommandExecuteParamsSchema = external_exports.object({
19399
+ threadId: hostThreadIdSchema,
19400
+ commandId: commandIdSchema,
19401
+ turnId: hostTurnIdSchema.optional(),
19402
+ arguments: jsonObjectSchema.optional()
19403
+ }).strict();
19404
+ var threadCommandExecuteResultSchema = external_exports.object({
19405
+ accepted: external_exports.literal(true),
19406
+ turnId: hostTurnIdSchema
19407
+ }).strict();
19408
+
19409
+ // ../../shared-contracts/dist/json-rpc.js
19410
+ var jsonRpcVersionSchema = external_exports.literal("2.0").optional();
19411
+ var absentSchema = external_exports.never().optional();
19412
+ var methodSchema = external_exports.string().min(1);
19413
+ var jsonRpcIdSchema = external_exports.union([external_exports.string(), external_exports.number().int()]);
19414
+ var jsonRpcErrorSchema = external_exports.object({
19415
+ code: external_exports.number().int(),
19416
+ message: external_exports.string(),
19417
+ data: jsonValueSchema.optional()
19418
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["data"]));
19419
+ var jsonRpcRequestSchema = external_exports.object({
19420
+ jsonrpc: jsonRpcVersionSchema,
19421
+ id: jsonRpcIdSchema,
19422
+ method: methodSchema,
19423
+ params: jsonValueSchema.optional(),
19424
+ result: absentSchema,
19425
+ error: absentSchema
19426
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "params", "result", "error"]));
19427
+ var jsonRpcNotificationSchema = external_exports.object({
19428
+ jsonrpc: jsonRpcVersionSchema,
19429
+ id: absentSchema,
19430
+ method: methodSchema,
19431
+ params: jsonValueSchema.optional(),
19432
+ result: absentSchema,
19433
+ error: absentSchema
19434
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "id", "params", "result", "error"]));
19435
+ var jsonRpcSuccessResponseSchema = external_exports.object({
19436
+ jsonrpc: jsonRpcVersionSchema,
19437
+ id: jsonRpcIdSchema,
19438
+ method: absentSchema,
19439
+ params: absentSchema,
19440
+ result: jsonValueSchema,
19441
+ error: absentSchema
19442
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "error"]));
19443
+ var jsonRpcErrorResponseSchema = external_exports.object({
19444
+ jsonrpc: jsonRpcVersionSchema,
19445
+ id: jsonRpcIdSchema,
19446
+ method: absentSchema,
19447
+ params: absentSchema,
19448
+ result: absentSchema,
19449
+ error: jsonRpcErrorSchema
19450
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "result"]));
19451
+ var jsonRpcEnvelopeSchema = external_exports.union([
19452
+ jsonRpcRequestSchema,
19453
+ jsonRpcNotificationSchema,
19454
+ jsonRpcSuccessResponseSchema,
19455
+ jsonRpcErrorResponseSchema
19456
+ ]);
19457
+
19458
+ // ../../shared-contracts/dist/native-refs.js
19459
+ var nativeIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
19460
+ message: "Native identifier must not be empty or whitespace"
19461
+ });
19462
+ var nativeSessionRefV1RuntimeSchema = external_exports.strictObject({
19463
+ harnessId: harnessIdSchema,
19464
+ nativeSessionId: nativeIdSchema,
19465
+ locator: jsonValueSchema.optional(),
19466
+ formatVersion: external_exports.literal(1)
19467
+ }).superRefine(rejectExplicitUndefined(["locator"]));
19468
+ var nativeSessionRefV1Schema = nativeSessionRefV1RuntimeSchema;
19469
+ var nativeSessionRefSchema = nativeSessionRefV1Schema;
19470
+ var nativeTurnRefV1Schema = external_exports.strictObject({
19471
+ harnessId: harnessIdSchema,
19472
+ nativeSessionId: nativeIdSchema,
19473
+ nativeTurnKey: nativeIdSchema,
19474
+ formatVersion: external_exports.literal(1)
19475
+ });
19476
+ var nativeTurnRefSchema = nativeTurnRefV1Schema;
19477
+ var nativeCheckpointRefV1RuntimeSchema = external_exports.strictObject({
19478
+ harnessId: harnessIdSchema,
19479
+ nativeSessionId: nativeIdSchema,
19480
+ checkpointId: nativeIdSchema,
19481
+ locator: jsonValueSchema.optional(),
19482
+ formatVersion: external_exports.literal(1)
19483
+ }).superRefine(rejectExplicitUndefined(["locator"]));
19484
+ var nativeCheckpointRefV1Schema = nativeCheckpointRefV1RuntimeSchema;
19485
+ var nativeCheckpointRefSchema = nativeCheckpointRefV1Schema;
19486
+
19487
+ // ../../shared-contracts/dist/updates.js
19488
+ var UPDATE_ERROR_MAX_LENGTH = 500;
19489
+ var UPDATE_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
19490
+ var updateSemanticVersionSchema = external_exports.string().regex(UPDATE_SEMVER_PATTERN);
19491
+ var updateInstallationSchema = external_exports.enum(["npm", "windows-installer", "macos-dmg"]);
19492
+ var updatePhaseSchema = external_exports.enum([
19493
+ "prepared",
19494
+ "downloading",
19495
+ "waiting-for-exit",
19496
+ "installing",
19497
+ "restarting",
19498
+ "succeeded",
19499
+ "failed"
19500
+ ]);
19501
+ var updateStatusSchema = external_exports.strictObject({
19502
+ version: updateSemanticVersionSchema,
19503
+ installation: updateInstallationSchema,
19504
+ phase: updatePhaseSchema,
19505
+ updatedAt: external_exports.number().int().nonnegative(),
19506
+ downloadedBytes: external_exports.number().int().nonnegative().optional(),
19507
+ totalBytes: external_exports.number().int().positive().optional(),
19508
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
19509
+ }).superRefine((status, context) => {
19510
+ if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
19511
+ context.addIssue({
19512
+ code: "custom",
19513
+ path: ["downloadedBytes"],
19514
+ message: "downloadedBytes must not exceed totalBytes"
19515
+ });
19516
+ }
19517
+ });
19518
+ var updateEmptyParamsSchema = external_exports.strictObject({});
19519
+ var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/LiberSeek\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
19520
+ var updateCheckResultSchema = external_exports.strictObject({
19521
+ currentVersion: updateSemanticVersionSchema,
19522
+ installation: updateInstallationSchema.nullable(),
19523
+ latestVersion: updateSemanticVersionSchema.nullable(),
19524
+ updateAvailable: external_exports.boolean(),
19525
+ installationAvailable: external_exports.boolean(),
19526
+ releaseNotes: external_exports.string().min(1).max(2e4).nullable(),
19527
+ releaseNotesUrl: githubReleaseNotesUrlSchema.nullable(),
19528
+ status: updateStatusSchema.nullable(),
19529
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
19530
+ });
19531
+ var updateStartResultSchema = external_exports.strictObject({
19532
+ status: updateStatusSchema
19533
+ });
19534
+ var updateStatusResultSchema = external_exports.strictObject({
19535
+ status: updateStatusSchema.nullable()
19536
+ });
19537
+
19538
+ // ../../shared-contracts/dist/index.js
19539
+ var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
19540
+
19541
+ // ../../harness-adapter/dist/approval.js
19542
+ function invalidRequest(message) {
19543
+ return { code: "invalidRequest", message, retryable: false };
19544
+ }
19545
+ function validateHostApprovalResponse(interaction, response) {
19546
+ return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
19547
+ }
19548
+
19549
+ // ../../harness-adapter/dist/question.js
19550
+ function invalidRequest2(message) {
19551
+ return { code: "invalidRequest", message, retryable: false };
19552
+ }
19553
+ function validateHostQuestionResponse(interaction, response) {
19554
+ const questionIds = new Set(interaction.questions.map(({ id }) => id));
19555
+ if (response.cancelled) {
19556
+ return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
19505
19557
  }
19506
- /**
19507
- * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
19508
- *
19509
- * Starts a NES (Next Edit Suggestions) session.
19510
- *
19511
- * @experimental
19512
- */
19513
- unstable_startNes(params) {
19514
- return this.connection.sendRequest(AGENT_METHODS.nes_start, params);
19558
+ for (const answerId of Object.keys(response.answers)) {
19559
+ if (!questionIds.has(answerId)) {
19560
+ return invalidRequest2("Question Response contains an unknown Question ID");
19561
+ }
19515
19562
  }
19516
- /**
19517
- * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
19518
- *
19519
- * Sends a NES suggestion request.
19520
- *
19521
- * @experimental
19522
- */
19523
- unstable_suggestNes(params) {
19524
- return this.connection.sendRequest(AGENT_METHODS.nes_suggest, params);
19563
+ for (const question of interaction.questions) {
19564
+ const answers = response.answers[question.id] ?? [];
19565
+ if (!question.optional && answers.length === 0) {
19566
+ return invalidRequest2("Question Response omits a required answer");
19567
+ }
19568
+ if (question.type === "text") {
19569
+ if (answers.length > 1) {
19570
+ return invalidRequest2("Text Question accepts at most one answer");
19571
+ }
19572
+ continue;
19573
+ }
19574
+ if (!question.multiple && answers.length > 1) {
19575
+ return invalidRequest2("Single-choice Question accepts at most one answer");
19576
+ }
19577
+ const declared = new Set(question.options.map(({ value }) => value));
19578
+ if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
19579
+ return invalidRequest2("Question Response contains an undeclared choice");
19580
+ }
19525
19581
  }
19526
- /**
19527
- * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
19528
- *
19529
- * Closes a NES session.
19530
- *
19531
- * @experimental
19532
- */
19533
- unstable_closeNes(params) {
19534
- return this.connection.sendRequest(AGENT_METHODS.nes_close, params, emptyObjectResponse);
19582
+ return null;
19583
+ }
19584
+
19585
+ // ../../harness-adapter/dist/output-channel.js
19586
+ var HarnessOutputChannel = class {
19587
+ outputs;
19588
+ #consumerCreated = false;
19589
+ #ended = false;
19590
+ #pending = [];
19591
+ #values = [];
19592
+ constructor() {
19593
+ this.outputs = {
19594
+ [Symbol.asyncIterator]: () => {
19595
+ if (this.#consumerCreated) {
19596
+ throw new Error("Harness outputs allow only one consumer");
19597
+ }
19598
+ this.#consumerCreated = true;
19599
+ return {
19600
+ next: () => this.#next()
19601
+ };
19602
+ }
19603
+ };
19535
19604
  }
19536
- /**
19537
- * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
19538
- *
19539
- * Notifies the agent that a document was opened.
19540
- *
19541
- * @experimental
19542
- */
19543
- unstable_didOpenDocument(params) {
19544
- return this.connection.sendNotification(AGENT_METHODS.document_did_open, params);
19605
+ emit(value) {
19606
+ if (this.#ended)
19607
+ return false;
19608
+ const resolve = this.#pending.shift();
19609
+ if (resolve)
19610
+ resolve({ done: false, value });
19611
+ else
19612
+ this.#values.push(value);
19613
+ return true;
19545
19614
  }
19546
- /**
19547
- * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
19548
- *
19549
- * Notifies the agent that a document was changed.
19550
- *
19551
- * @experimental
19552
- */
19553
- unstable_didChangeDocument(params) {
19554
- return this.connection.sendNotification(AGENT_METHODS.document_did_change, params);
19615
+ end() {
19616
+ if (this.#ended)
19617
+ return;
19618
+ this.#ended = true;
19619
+ if (this.#values.length !== 0)
19620
+ return;
19621
+ for (const resolve of this.#pending.splice(0))
19622
+ resolve({ done: true, value: void 0 });
19555
19623
  }
19556
- /**
19557
- * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
19558
- *
19559
- * Notifies the agent that a document was closed.
19560
- *
19561
- * @experimental
19562
- */
19563
- unstable_didCloseDocument(params) {
19564
- return this.connection.sendNotification(AGENT_METHODS.document_did_close, params);
19624
+ #next() {
19625
+ const value = this.#values.shift();
19626
+ if (value !== void 0)
19627
+ return Promise.resolve({ done: false, value });
19628
+ if (this.#ended)
19629
+ return Promise.resolve({ done: true, value: void 0 });
19630
+ return new Promise((resolve) => this.#pending.push(resolve));
19565
19631
  }
19566
- /**
19567
- * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
19568
- *
19569
- * Notifies the agent that a document was saved.
19570
- *
19571
- * @experimental
19572
- */
19573
- unstable_didSaveDocument(params) {
19574
- return this.connection.sendNotification(AGENT_METHODS.document_did_save, params);
19632
+ };
19633
+
19634
+ // ../../harness-adapter/dist/diagnostics.js
19635
+ var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
19636
+ var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
19637
+ var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
19638
+ function sanitizeDiagnosticTail(value) {
19639
+ const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
19640
+ return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
19641
+ }
19642
+
19643
+ // ../../harness-adapter/dist/usage.js
19644
+ var tokenFields = [
19645
+ "inputTokens",
19646
+ "cachedInputTokens",
19647
+ "cacheWriteInputTokens",
19648
+ "outputTokens",
19649
+ "outputTokensPerSecond",
19650
+ "reasoningOutputTokens",
19651
+ "totalTokens",
19652
+ "contextWindowTokens",
19653
+ "contextUsedTokens"
19654
+ ];
19655
+ var safeIntegerFields = [
19656
+ "planFiveHourResetsAtUnix",
19657
+ "planSevenDayResetsAtUnix"
19658
+ ];
19659
+ var percentFields = [
19660
+ "cacheHitRatePercent",
19661
+ "planFiveHourUsedPercent",
19662
+ "planSevenDayUsedPercent"
19663
+ ];
19664
+ var usageFields = /* @__PURE__ */ new Set([
19665
+ ...tokenFields,
19666
+ ...safeIntegerFields,
19667
+ ...percentFields,
19668
+ "totalCostUsd"
19669
+ ]);
19670
+ function isRecord2(value) {
19671
+ return typeof value === "object" && value !== null && !Array.isArray(value);
19672
+ }
19673
+ function parseHostUsage(value) {
19674
+ if (!isRecord2(value))
19675
+ throw new Error("Harness Usage must be an object");
19676
+ const keys = Object.keys(value);
19677
+ if (keys.length === 0)
19678
+ throw new Error("Harness Usage must contain a reliable field");
19679
+ for (const key of keys) {
19680
+ if (!usageFields.has(key)) {
19681
+ throw new Error(`Harness Usage contains unknown field '${key}'`);
19682
+ }
19575
19683
  }
19576
- /**
19577
- * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
19578
- *
19579
- * Notifies the agent that a document received focus.
19580
- *
19581
- * @experimental
19582
- */
19583
- unstable_didFocusDocument(params) {
19584
- return this.connection.sendNotification(AGENT_METHODS.document_did_focus, params);
19684
+ for (const field of tokenFields) {
19685
+ const candidate = value[field];
19686
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
19687
+ throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
19688
+ }
19585
19689
  }
19586
- /**
19587
- * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
19588
- *
19589
- * Notifies the agent that a NES suggestion was accepted.
19590
- *
19591
- * @experimental
19592
- */
19593
- unstable_acceptNes(params) {
19594
- return this.connection.sendNotification(AGENT_METHODS.nes_accept, params);
19690
+ for (const field of safeIntegerFields) {
19691
+ const candidate = value[field];
19692
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
19693
+ throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
19694
+ }
19595
19695
  }
19596
- /**
19597
- * **UNSTABLE**: This capability is not part of the spec yet, and may be removed or changed at any point.
19598
- *
19599
- * Notifies the agent that a NES suggestion was rejected.
19600
- *
19601
- * @experimental
19602
- */
19603
- unstable_rejectNes(params) {
19604
- return this.connection.sendNotification(AGENT_METHODS.nes_reject, params);
19696
+ if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
19697
+ throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
19605
19698
  }
19606
- request(method, params, options) {
19607
- const spec = agentRequestSpecsByMethod[method];
19608
- return this.connection.sendRequest(method, params, spec?.mapResponse, options);
19699
+ if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
19700
+ throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
19609
19701
  }
19610
- notify(method, params) {
19611
- return this.connection.sendNotification(method, params);
19702
+ for (const field of percentFields) {
19703
+ const candidate = value[field];
19704
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
19705
+ throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
19706
+ }
19612
19707
  }
19613
- /**
19614
- * Extension method.
19615
- *
19616
- * @deprecated Use {@link request}.
19617
- */
19618
- extMethod(method, params) {
19619
- return this.request(method, params);
19708
+ const hasContextUsed = value.contextUsedTokens !== void 0;
19709
+ const hasContextWindow = value.contextWindowTokens !== void 0;
19710
+ if (hasContextUsed !== hasContextWindow) {
19711
+ throw new Error("Harness Usage context fields must be provided together");
19620
19712
  }
19621
- /**
19622
- * Extension notification.
19623
- *
19624
- * @deprecated Use {@link notify}.
19625
- */
19626
- extNotification(method, params) {
19627
- return this.notify(method, params);
19713
+ if (hasContextWindow && value.contextWindowTokens === 0) {
19714
+ throw new Error("Harness Usage 'contextWindowTokens' must be greater than zero");
19628
19715
  }
19629
- /**
19630
- * AbortSignal that aborts when the connection closes.
19631
- *
19632
- * This signal can be used to:
19633
- * - Listen for connection closure: `connection.signal.addEventListener('abort', () => {...})`
19634
- * - Check connection status synchronously: `if (connection.signal.aborted) {...}`
19635
- * - Pass to other APIs (fetch, setTimeout) for automatic cancellation
19636
- *
19637
- * The connection closes when the underlying stream ends, either normally or due to an error.
19638
- *
19639
- * @example
19640
- * ```typescript
19641
- * const connection = new ClientSideConnection(client, stream);
19642
- *
19643
- * // Listen for closure
19644
- * connection.signal.addEventListener('abort', () => {
19645
- * console.log('Connection closed - performing cleanup');
19646
- * });
19647
- *
19648
- * // Check status
19649
- * if (connection.signal.aborted) {
19650
- * console.log('Connection is already closed');
19651
- * }
19652
- *
19653
- * // Pass to other APIs
19654
- * fetch(url, { signal: connection.signal });
19655
- * ```
19656
- */
19657
- get signal() {
19658
- return this.connection.signal;
19716
+ if (value.planFiveHourResetsAtUnix !== void 0 && value.planFiveHourUsedPercent === void 0) {
19717
+ throw new Error("Harness Usage 'planFiveHourResetsAtUnix' must be provided with 'planFiveHourUsedPercent'");
19659
19718
  }
19660
- /**
19661
- * Promise that resolves when the connection closes.
19662
- *
19663
- * The connection closes when the underlying stream ends, either normally or due to an error.
19664
- * Once closed, the connection cannot send or receive any more messages.
19665
- *
19666
- * This is useful for async/await style cleanup:
19667
- *
19668
- * @example
19669
- * ```typescript
19670
- * const connection = new ClientSideConnection(client, stream);
19671
- * await connection.closed;
19672
- * console.log('Connection closed - performing cleanup');
19673
- * ```
19674
- */
19675
- get closed() {
19676
- return this.connection.closed;
19719
+ if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
19720
+ throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
19677
19721
  }
19678
- };
19722
+ return { ...value };
19723
+ }
19724
+
19725
+ // dist/acp-transport.js
19726
+ import { spawn, spawnSync } from "node:child_process";
19727
+ import { readdir, readFile } from "node:fs/promises";
19728
+ import os3 from "node:os";
19729
+ import path8 from "node:path";
19730
+ import { Readable, Writable } from "node:stream";
19679
19731
 
19680
19732
  // dist/command.js
19681
19733
  import path3 from "node:path";
@@ -21637,6 +21689,232 @@ async function rewindGrokLastTurn(input) {
21637
21689
  return { ok: true, value: { sessionId } };
21638
21690
  }
21639
21691
 
21692
+ // dist/grok-plan-review.js
21693
+ var GROK_PLAN_DECISION_ID = "plan-decision";
21694
+ function isRecord9(value) {
21695
+ return typeof value === "object" && value !== null && !Array.isArray(value);
21696
+ }
21697
+ function stringField2(value, ...keys) {
21698
+ for (const key of keys) {
21699
+ const field = value[key];
21700
+ if (typeof field === "string" && field.length > 0)
21701
+ return field;
21702
+ }
21703
+ return void 0;
21704
+ }
21705
+ function parseGrokExitPlanModeParams(params) {
21706
+ if (!isRecord9(params))
21707
+ return null;
21708
+ const nested = isRecord9(params.input) ? params.input : params;
21709
+ const plan = stringField2(nested, "planContent", "plan_content", "plan") ?? stringField2(params, "planContent", "plan_content", "plan") ?? null;
21710
+ const planFilePath = stringField2(nested, "planFilePath", "plan_file_path") ?? stringField2(params, "planFilePath", "plan_file_path");
21711
+ const sessionId = stringField2(params, "sessionId", "session_id");
21712
+ return {
21713
+ plan,
21714
+ ...sessionId ? { sessionId } : {},
21715
+ ...planFilePath ? { planFilePath } : {}
21716
+ };
21717
+ }
21718
+ function createGrokPlanReview(request, interactionId, turnId) {
21719
+ const warning = "Approving this plan will exit Grok plan mode and let Grok begin implementation. This is not a one-time tool approval.";
21720
+ return {
21721
+ type: "question",
21722
+ interactionId,
21723
+ turnId,
21724
+ title: "Review plan",
21725
+ questions: [
21726
+ {
21727
+ id: GROK_PLAN_DECISION_ID,
21728
+ type: "choice",
21729
+ prompt: request.plan ? `${warning}
21730
+
21731
+ ${request.plan}` : "Grok did not provide plan text. Stay in plan mode and ask Grok to present the plan before approving it.",
21732
+ options: [
21733
+ {
21734
+ value: "stay",
21735
+ label: "Stay in plan mode",
21736
+ description: "Do not approve the plan or begin implementation."
21737
+ },
21738
+ ...request.plan ? [
21739
+ {
21740
+ value: "approve",
21741
+ label: "Approve plan and exit plan mode",
21742
+ description: "Leave plan mode and begin implementation."
21743
+ }
21744
+ ] : []
21745
+ ],
21746
+ multiple: false,
21747
+ allowOther: false,
21748
+ optional: false
21749
+ }
21750
+ ]
21751
+ };
21752
+ }
21753
+ function grokPlanRejectedResponse() {
21754
+ return { approved: false, feedback: "" };
21755
+ }
21756
+ function grokExitPlanModeResponse(request, response) {
21757
+ return {
21758
+ approved: !response.cancelled && request.plan !== null && response.answers[GROK_PLAN_DECISION_ID]?.[0] === "approve",
21759
+ feedback: ""
21760
+ };
21761
+ }
21762
+
21763
+ // dist/grok-question.js
21764
+ var GROK_ASK_USER_QUESTION_METHODS = [
21765
+ "_x.ai/ask_user_question",
21766
+ "x.ai/ask_user_question"
21767
+ ];
21768
+ var GROK_EXIT_PLAN_MODE_METHODS = ["_x.ai/exit_plan_mode", "x.ai/exit_plan_mode"];
21769
+ var GROK_ACP_CLIENT_CAPABILITIES = {
21770
+ _meta: {
21771
+ "x.ai/ask_user_question": true,
21772
+ "x.ai/exit_plan_mode": true
21773
+ }
21774
+ };
21775
+ function isRecord10(value) {
21776
+ return typeof value === "object" && value !== null && !Array.isArray(value);
21777
+ }
21778
+ function stringField3(value, ...keys) {
21779
+ for (const key of keys) {
21780
+ const field = value[key];
21781
+ if (typeof field === "string" && field.length > 0)
21782
+ return field;
21783
+ }
21784
+ return void 0;
21785
+ }
21786
+ function optionalTimeoutMs(value) {
21787
+ for (const key of ["timeoutMs", "timeout_ms", "timeoutSecs", "timeout_secs"]) {
21788
+ const field = value[key];
21789
+ if (typeof field === "number" && Number.isFinite(field) && field > 0) {
21790
+ return key.endsWith("secs") || key.endsWith("Secs") ? field * 1e3 : field;
21791
+ }
21792
+ }
21793
+ return void 0;
21794
+ }
21795
+ function isGrokAskUserQuestionMethod(method) {
21796
+ return GROK_ASK_USER_QUESTION_METHODS.includes(method);
21797
+ }
21798
+ function isGrokExitPlanModeMethod(method) {
21799
+ return GROK_EXIT_PLAN_MODE_METHODS.includes(method);
21800
+ }
21801
+ function questionsPayload(params) {
21802
+ if (Array.isArray(params.questions))
21803
+ return params.questions;
21804
+ if (isRecord10(params.input) && Array.isArray(params.input.questions))
21805
+ return params.input.questions;
21806
+ if (isRecord10(params.askUserQuestion) && Array.isArray(params.askUserQuestion.questions)) {
21807
+ return params.askUserQuestion.questions;
21808
+ }
21809
+ return void 0;
21810
+ }
21811
+ function parseOption(value, labels) {
21812
+ if (!isRecord10(value))
21813
+ return null;
21814
+ const label = stringField3(value, "label");
21815
+ if (!label || labels.has(label))
21816
+ return null;
21817
+ labels.add(label);
21818
+ const description = stringField3(value, "description");
21819
+ const preview = stringField3(value, "preview");
21820
+ const combined = [description, preview].filter((part) => part !== void 0);
21821
+ return {
21822
+ label,
21823
+ ...combined.length > 0 ? { description: combined.join("\n\n") } : {}
21824
+ };
21825
+ }
21826
+ function parseQuestion(value, questions) {
21827
+ if (!isRecord10(value))
21828
+ return null;
21829
+ const question = stringField3(value, "question");
21830
+ if (!question || questions.has(question))
21831
+ return null;
21832
+ if (!Array.isArray(value.options) || value.options.length === 0)
21833
+ return null;
21834
+ const labels = /* @__PURE__ */ new Set();
21835
+ const options = [];
21836
+ for (const option of value.options) {
21837
+ const parsed = parseOption(option, labels);
21838
+ if (!parsed)
21839
+ return null;
21840
+ options.push(parsed);
21841
+ }
21842
+ questions.add(question);
21843
+ const header = stringField3(value, "header");
21844
+ return {
21845
+ question,
21846
+ ...header ? { header } : {},
21847
+ options,
21848
+ multiSelect: value.multiSelect === true || value.multi_select === true
21849
+ };
21850
+ }
21851
+ function parseGrokAskUserQuestionParams(params) {
21852
+ if (!isRecord10(params))
21853
+ return null;
21854
+ const rawQuestions = questionsPayload(params);
21855
+ if (!Array.isArray(rawQuestions) || rawQuestions.length === 0)
21856
+ return null;
21857
+ const seen = /* @__PURE__ */ new Set();
21858
+ const questions = [];
21859
+ for (const value of rawQuestions) {
21860
+ const parsed = parseQuestion(value, seen);
21861
+ if (!parsed)
21862
+ return null;
21863
+ questions.push(parsed);
21864
+ }
21865
+ const sessionId = stringField3(params, "sessionId", "session_id");
21866
+ const timeoutMs = optionalTimeoutMs(params);
21867
+ return {
21868
+ questions,
21869
+ ...sessionId ? { sessionId } : {},
21870
+ ...timeoutMs !== void 0 ? { timeoutMs } : {}
21871
+ };
21872
+ }
21873
+ function grokQuestionId(index) {
21874
+ return `question-${index + 1}`;
21875
+ }
21876
+ function createGrokQuestionInteraction(request, interactionId, turnId, nowMs = Date.now()) {
21877
+ const first = request.questions[0];
21878
+ const title = request.questions.length === 1 ? first?.header ?? first?.question ?? "Grok" : "Grok";
21879
+ return {
21880
+ type: "question",
21881
+ interactionId,
21882
+ turnId,
21883
+ title,
21884
+ questions: request.questions.map((question, index) => ({
21885
+ id: grokQuestionId(index),
21886
+ type: "choice",
21887
+ prompt: question.question,
21888
+ options: question.options.map((option) => ({
21889
+ value: option.label,
21890
+ label: option.label,
21891
+ ...option.description ? { description: option.description } : {}
21892
+ })),
21893
+ multiple: question.multiSelect,
21894
+ allowOther: true,
21895
+ optional: false
21896
+ })),
21897
+ ...request.timeoutMs !== void 0 ? { expiresAt: new Date(nowMs + request.timeoutMs).toISOString() } : {}
21898
+ };
21899
+ }
21900
+ function grokSkipInterviewResponse() {
21901
+ return { outcome: "skip_interview" };
21902
+ }
21903
+ function grokAskUserQuestionResponse(request, response) {
21904
+ if (response.cancelled)
21905
+ return grokSkipInterviewResponse();
21906
+ const answers = {};
21907
+ for (const [index, question] of request.questions.entries()) {
21908
+ const selected = response.answers[grokQuestionId(index)] ?? [];
21909
+ answers[question.question] = question.multiSelect || selected.length !== 1 ? selected : selected[0] ?? "";
21910
+ }
21911
+ return {
21912
+ outcome: "accepted",
21913
+ answers,
21914
+ annotations: {}
21915
+ };
21916
+ }
21917
+
21640
21918
  // dist/permission-modes.js
21641
21919
  var nativePermissionModes = /* @__PURE__ */ new Set(["ask", "auto", "always-approve"]);
21642
21920
  var GROK_DEFAULT_PERMISSION_MODE_ID = harnessPermissionModeIdSchema.parse("ask");
@@ -21686,7 +21964,7 @@ var GrokTransportError = class extends Error {
21686
21964
  this.name = "GrokTransportError";
21687
21965
  }
21688
21966
  };
21689
- function isRecord9(value) {
21967
+ function isRecord11(value) {
21690
21968
  return typeof value === "object" && value !== null && !Array.isArray(value);
21691
21969
  }
21692
21970
  function errorText(error53) {
@@ -21742,7 +22020,7 @@ function signalProcessTree(child, signal) {
21742
22020
  try {
21743
22021
  process.kill(-child.pid, signal);
21744
22022
  } catch (error53) {
21745
- if (!isRecord9(error53) || error53.code !== "ESRCH")
22023
+ if (!isRecord11(error53) || error53.code !== "ESRCH")
21746
22024
  throw error53;
21747
22025
  }
21748
22026
  }
@@ -21830,7 +22108,7 @@ async function readNativeSignals(options, sessionId) {
21830
22108
  }
21831
22109
  }
21832
22110
  function isMissingFile(error53) {
21833
- return isRecord9(error53) && error53.code === "ENOENT";
22111
+ return isRecord11(error53) && error53.code === "ENOENT";
21834
22112
  }
21835
22113
  async function locateGrokNativeSession(options, sessionId) {
21836
22114
  if (sessionId.length === 0)
@@ -21853,7 +22131,7 @@ async function locateGrokNativeSession(options, sessionId) {
21853
22131
  try {
21854
22132
  summaryRaw = await readFile(path8.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
21855
22133
  } catch (error53) {
21856
- if (isMissingFile(error53) || isRecord9(error53) && error53.code === "ENOTDIR")
22134
+ if (isMissingFile(error53) || isRecord11(error53) && error53.code === "ENOTDIR")
21857
22135
  continue;
21858
22136
  throw new GrokTransportError("unavailable", "Grok Native Session metadata could not be read", {
21859
22137
  cause: error53
@@ -21865,10 +22143,10 @@ async function locateGrokNativeSession(options, sessionId) {
21865
22143
  } catch {
21866
22144
  continue;
21867
22145
  }
21868
- if (!isRecord9(parsed))
22146
+ if (!isRecord11(parsed))
21869
22147
  continue;
21870
22148
  const info = parsed.info;
21871
- const cwd = isRecord9(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path8.resolve(info.cwd) : path8.resolve(decodeURIComponent(entry.name));
22149
+ const cwd = isRecord11(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path8.resolve(info.cwd) : path8.resolve(decodeURIComponent(entry.name));
21872
22150
  const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path8.resolve(parsed.source_workspace_dir) : void 0;
21873
22151
  matches.push({
21874
22152
  cwd,
@@ -21901,12 +22179,12 @@ function parseNativeHistory(contents, sessionId) {
21901
22179
  } catch {
21902
22180
  throw new GrokTransportError("protocolError", "Grok Native history contains invalid JSON");
21903
22181
  }
21904
- if (!isRecord9(record2) || !isRecord9(record2.params))
22182
+ if (!isRecord11(record2) || !isRecord11(record2.params))
21905
22183
  continue;
21906
22184
  const params = record2.params;
21907
- if (params.sessionId !== sessionId || !isRecord9(params.update))
22185
+ if (params.sessionId !== sessionId || !isRecord11(params.update))
21908
22186
  continue;
21909
- const metadata = isRecord9(params._meta) ? params._meta : void 0;
22187
+ const metadata = isRecord11(params._meta) ? params._meta : void 0;
21910
22188
  const event = transportEvent(params.update, metadata);
21911
22189
  if (event)
21912
22190
  events.push(metadata ? { ...event, metadata } : event);
@@ -22126,6 +22404,7 @@ var GrokAcpTransport = class {
22126
22404
  const connection = new ClientSideConnection(() => ({
22127
22405
  sessionUpdate: (params) => this.#handleUpdate(params),
22128
22406
  requestPermission: (params) => this.#handlePermission(params),
22407
+ extMethod: (method, params) => this.#handleExtensionRequest(method, params),
22129
22408
  extNotification: (method, params) => this.#handleExtensionNotification(method, params)
22130
22409
  }), stream);
22131
22410
  this.#connection = connection;
@@ -22137,7 +22416,7 @@ var GrokAcpTransport = class {
22137
22416
  });
22138
22417
  const initialize = await withTimeout(connection.initialize({
22139
22418
  protocolVersion: PROTOCOL_VERSION,
22140
- clientCapabilities: {},
22419
+ clientCapabilities: GROK_ACP_CLIENT_CAPABILITIES,
22141
22420
  clientInfo: { name: "codexhost", version: "0.1.6" }
22142
22421
  }), this.#options.commandTimeoutMs, "Grok ACP initialize");
22143
22422
  if (initialize.protocolVersion !== PROTOCOL_VERSION) {
@@ -22146,14 +22425,14 @@ var GrokAcpTransport = class {
22146
22425
  this.#initialize = initialize;
22147
22426
  return initialize;
22148
22427
  }
22149
- async runTurn(text, onEvent, onPermission) {
22428
+ async runTurn(text, onEvent, onPermission, onExtension) {
22150
22429
  const connection = this.#connection;
22151
22430
  if (!connection || !this.#sessionId || this.#closed || this.#closing) {
22152
22431
  throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
22153
22432
  }
22154
22433
  if (this.#activePrompt)
22155
22434
  throw new Error("Grok ACP Session already has an active Prompt");
22156
- const active = { onEvent, onPermission };
22435
+ const active = { onEvent, onPermission, onExtension };
22157
22436
  this.#activePrompt = active;
22158
22437
  try {
22159
22438
  return await connection.prompt({
@@ -22208,7 +22487,7 @@ var GrokAcpTransport = class {
22208
22487
  modelId,
22209
22488
  ...reasoningEffort ? { reasoningEffort } : {}
22210
22489
  });
22211
- if (!isRecord9(response) || !isRecord9(response._meta) || !isRecord9(response._meta.model)) {
22490
+ if (!isRecord11(response) || !isRecord11(response._meta) || !isRecord11(response._meta.model)) {
22212
22491
  throw new GrokTransportError("protocolError", "Grok rejected Model configuration");
22213
22492
  }
22214
22493
  const selected = response._meta.model.Ok;
@@ -22251,7 +22530,7 @@ var GrokAcpTransport = class {
22251
22530
  #handleUpdate(notification) {
22252
22531
  if (this.#sessionId && notification.sessionId !== this.#sessionId)
22253
22532
  return;
22254
- const metadata = isRecord9(notification._meta) ? notification._meta : void 0;
22533
+ const metadata = isRecord11(notification._meta) ? notification._meta : void 0;
22255
22534
  const event = transportEvent(notification.update, metadata);
22256
22535
  if (!event)
22257
22536
  return;
@@ -22266,7 +22545,7 @@ var GrokAcpTransport = class {
22266
22545
  #handleExtensionNotification(method, params) {
22267
22546
  if (!isGrokExtensionSessionUpdateMethod(method))
22268
22547
  return;
22269
- if (typeof params.sessionId !== "string" || !isRecord9(params.update))
22548
+ if (typeof params.sessionId !== "string" || !isRecord11(params.update))
22270
22549
  return;
22271
22550
  this.#handleUpdate(params);
22272
22551
  }
@@ -22276,6 +22555,16 @@ var GrokAcpTransport = class {
22276
22555
  }
22277
22556
  return this.#activePrompt.onPermission({ request: params, options: params.options });
22278
22557
  }
22558
+ #handleExtensionRequest(method, params) {
22559
+ if (this.#activePrompt) {
22560
+ return this.#activePrompt.onExtension({ method, params });
22561
+ }
22562
+ if (isGrokAskUserQuestionMethod(method))
22563
+ return Promise.resolve(grokSkipInterviewResponse());
22564
+ if (isGrokExitPlanModeMethod(method))
22565
+ return Promise.resolve(grokPlanRejectedResponse());
22566
+ throw RequestError.methodNotFound(method);
22567
+ }
22279
22568
  #fault(error53) {
22280
22569
  if (this.#closing || this.#closed)
22281
22570
  return;
@@ -22284,7 +22573,7 @@ var GrokAcpTransport = class {
22284
22573
  };
22285
22574
 
22286
22575
  // dist/grok-models.js
22287
- function isRecord10(value) {
22576
+ function isRecord12(value) {
22288
22577
  return typeof value === "object" && value !== null && !Array.isArray(value);
22289
22578
  }
22290
22579
  function nonBlank(value) {
@@ -22296,7 +22585,7 @@ function thinkingOptions(value) {
22296
22585
  const seen = /* @__PURE__ */ new Set();
22297
22586
  const options = [];
22298
22587
  for (const candidate of value) {
22299
- if (!isRecord10(candidate) || !nonBlank(candidate.label))
22588
+ if (!isRecord12(candidate) || !nonBlank(candidate.label))
22300
22589
  continue;
22301
22590
  const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
22302
22591
  if (!id.success || seen.has(id.data))
@@ -22307,7 +22596,7 @@ function thinkingOptions(value) {
22307
22596
  return options;
22308
22597
  }
22309
22598
  function parseGrokModelState(value) {
22310
- if (!isRecord10(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
22599
+ if (!isRecord12(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
22311
22600
  return null;
22312
22601
  }
22313
22602
  const currentModel = harnessModelRefSchema.safeParse({ id: value.currentModelId });
@@ -22318,12 +22607,12 @@ function parseGrokModelState(value) {
22318
22607
  const models = [];
22319
22608
  let currentThinkingOptionId;
22320
22609
  for (const candidate of value.availableModels) {
22321
- if (!isRecord10(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
22610
+ if (!isRecord12(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
22322
22611
  continue;
22323
22612
  const ref = harnessModelRefSchema.safeParse({ id: candidate.modelId });
22324
22613
  if (!ref.success)
22325
22614
  continue;
22326
- const metadata = isRecord10(candidate._meta) ? candidate._meta : {};
22615
+ const metadata = isRecord12(candidate._meta) ? candidate._meta : {};
22327
22616
  const options2 = thinkingOptions(metadata.reasoningEfforts);
22328
22617
  if (typeof metadata.totalContextTokens === "number" && Number.isSafeInteger(metadata.totalContextTokens) && metadata.totalContextTokens > 0) {
22329
22618
  contextWindowTokensByModel.set(ref.data.id, metadata.totalContextTokens);
@@ -22358,10 +22647,10 @@ function parseGrokModelState(value) {
22358
22647
  };
22359
22648
  }
22360
22649
  function modelStateFromInitialize(response) {
22361
- return parseGrokModelState(isRecord10(response._meta) ? response._meta.modelState : void 0);
22650
+ return parseGrokModelState(isRecord12(response._meta) ? response._meta.modelState : void 0);
22362
22651
  }
22363
22652
  function modelStateFromSessionResponse(response) {
22364
- return parseGrokModelState(isRecord10(response) ? response.models : void 0);
22653
+ return parseGrokModelState(isRecord12(response) ? response.models : void 0);
22365
22654
  }
22366
22655
  function stateForGrokModel(modelState, nativeState, model = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
22367
22656
  const selectedModel = model;
@@ -22385,7 +22674,7 @@ import os4 from "node:os";
22385
22674
  import path9 from "node:path";
22386
22675
  var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
22387
22676
  var REQUEST_TIMEOUT_MS = 15e3;
22388
- function isRecord11(value) {
22677
+ function isRecord13(value) {
22389
22678
  return typeof value === "object" && value !== null && !Array.isArray(value);
22390
22679
  }
22391
22680
  function finitePercent(value) {
@@ -22415,7 +22704,7 @@ function productUsageFrom(value) {
22415
22704
  if (!Array.isArray(value))
22416
22705
  return void 0;
22417
22706
  const products = value.flatMap((entry) => {
22418
- if (!isRecord11(entry) || typeof entry.product !== "string")
22707
+ if (!isRecord13(entry) || typeof entry.product !== "string")
22419
22708
  return [];
22420
22709
  const usagePercent = finitePercent(entry.usagePercent);
22421
22710
  return usagePercent === void 0 ? [] : [{ product: entry.product, usagePercent }];
@@ -22423,13 +22712,13 @@ function productUsageFrom(value) {
22423
22712
  return products.length > 0 ? products : void 0;
22424
22713
  }
22425
22714
  function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()).toISOString()) {
22426
- if (!isRecord11(value) || !isRecord11(value.config))
22715
+ if (!isRecord13(value) || !isRecord13(value.config))
22427
22716
  return null;
22428
22717
  const config2 = value.config;
22429
- const period = isRecord11(config2.currentPeriod) ? config2.currentPeriod : void 0;
22718
+ const period = isRecord13(config2.currentPeriod) ? config2.currentPeriod : void 0;
22430
22719
  const resetsAt = (typeof period?.end === "string" && period.end.length > 0 ? period.end : void 0) ?? (typeof config2.billingPeriodEnd === "string" && config2.billingPeriodEnd.length > 0 ? config2.billingPeriodEnd : void 0);
22431
- const onDemandCap = isRecord11(config2.onDemandCap) ? nonNegativeNumber(config2.onDemandCap.val) : void 0;
22432
- const onDemandUsed = isRecord11(config2.onDemandUsed) ? nonNegativeNumber(config2.onDemandUsed.val) : void 0;
22720
+ const onDemandCap = isRecord13(config2.onDemandCap) ? nonNegativeNumber(config2.onDemandCap.val) : void 0;
22721
+ const onDemandUsed = isRecord13(config2.onDemandUsed) ? nonNegativeNumber(config2.onDemandUsed.val) : void 0;
22433
22722
  const usedPercent = finitePercent(config2.creditUsagePercent) ?? (onDemandCap !== void 0 && onDemandCap > 0 && onDemandUsed !== void 0 ? Math.min(100, Math.max(0, onDemandUsed / onDemandCap * 100)) : void 0);
22434
22723
  if (usedPercent === void 0)
22435
22724
  return null;
@@ -22443,11 +22732,11 @@ function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()
22443
22732
  };
22444
22733
  }
22445
22734
  function selectAccessToken(auth, now) {
22446
- if (!isRecord11(auth))
22735
+ if (!isRecord13(auth))
22447
22736
  return null;
22448
- const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) && isRecord11(value) && typeof value.key === "string" && value.key.length > 0).sort(([left], [right]) => Number(right.startsWith("https://auth.x.ai")) - Number(left.startsWith("https://auth.x.ai")));
22737
+ const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) && isRecord13(value) && typeof value.key === "string" && value.key.length > 0).sort(([left], [right]) => Number(right.startsWith("https://auth.x.ai")) - Number(left.startsWith("https://auth.x.ai")));
22449
22738
  for (const [, value] of entries) {
22450
- if (!isRecord11(value) || typeof value.key !== "string")
22739
+ if (!isRecord13(value) || typeof value.key !== "string")
22451
22740
  continue;
22452
22741
  if (typeof value.expires_at === "string") {
22453
22742
  const expiresAt = Date.parse(value.expires_at);
@@ -22504,11 +22793,12 @@ async function fetchGrokAccount(input = {}) {
22504
22793
  }
22505
22794
  async function fetchGrokCredits(input = {}) {
22506
22795
  const account = await fetchGrokAccount(input);
22507
- if (!account)
22796
+ const usedPercent = account?.credits.usedPercent;
22797
+ if (!account || usedPercent === void 0)
22508
22798
  return null;
22509
22799
  const { credits } = account;
22510
22800
  return {
22511
- usedPercent: credits.usedPercent,
22801
+ usedPercent,
22512
22802
  periodType: credits.periodType === "weekly" || credits.periodType === "monthly" ? credits.periodType : "unknown",
22513
22803
  fetchedAt: (input.now ?? /* @__PURE__ */ new Date()).toISOString(),
22514
22804
  ...credits.resetsAt ? { resetsAt: credits.resetsAt } : {},
@@ -22518,7 +22808,7 @@ async function fetchGrokCredits(input = {}) {
22518
22808
 
22519
22809
  // dist/grok-usage.js
22520
22810
  var USD_TICKS_PER_DOLLAR = 1e10;
22521
- function isRecord12(value) {
22811
+ function isRecord14(value) {
22522
22812
  return typeof value === "object" && value !== null && !Array.isArray(value);
22523
22813
  }
22524
22814
  function optionalToken(value) {
@@ -22535,7 +22825,7 @@ function combineUsage(base, next) {
22535
22825
  return base === null ? next : parseHostUsage({ ...base, ...next });
22536
22826
  }
22537
22827
  function usageFromNative(value) {
22538
- if (!isRecord12(value))
22828
+ if (!isRecord14(value))
22539
22829
  return null;
22540
22830
  const nativeInputTokens = optionalToken(value.inputTokens);
22541
22831
  const cachedRead = optionalToken(value.cachedReadTokens);
@@ -22564,7 +22854,7 @@ function usageFromPrompt(response) {
22564
22854
  return response.usage ? usageFromNative(response.usage) : null;
22565
22855
  }
22566
22856
  function usageFromSignals(value) {
22567
- if (!isRecord12(value))
22857
+ if (!isRecord14(value))
22568
22858
  return null;
22569
22859
  try {
22570
22860
  return parseHostUsage({
@@ -22584,7 +22874,7 @@ var summedUsageFields = [
22584
22874
  "totalTokens"
22585
22875
  ];
22586
22876
  function nativeCostTicks(value) {
22587
- if (!isRecord12(value))
22877
+ if (!isRecord14(value))
22588
22878
  return void 0;
22589
22879
  const ticks = value.costUsdTicks;
22590
22880
  if (typeof ticks !== "number" || !Number.isSafeInteger(ticks) || ticks < 0)
@@ -22661,7 +22951,7 @@ function usageFromCompact(tokensAfter, contextWindowTokens) {
22661
22951
  function usageFromUpdate(update, metadata, contextWindowTokens) {
22662
22952
  try {
22663
22953
  if (update?.sessionUpdate === "usage_update") {
22664
- const cost = isRecord12(update.cost) ? update.cost : null;
22954
+ const cost = isRecord14(update.cost) ? update.cost : null;
22665
22955
  return parseHostUsage({
22666
22956
  contextUsedTokens: update.used,
22667
22957
  contextWindowTokens: update.size,
@@ -22905,6 +23195,7 @@ var GrokHarnessSession = class {
22905
23195
  tools: /* @__PURE__ */ new Map(),
22906
23196
  completedItems: [],
22907
23197
  approvals: /* @__PURE__ */ new Map(),
23198
+ questions: /* @__PURE__ */ new Map(),
22908
23199
  cancellationRequested: false,
22909
23200
  beforeNativeTurnKeys: new Set(this.#snapshot.turns.map((turn) => turn.nativeTurnRef.nativeTurnKey)),
22910
23201
  completion,
@@ -22912,7 +23203,7 @@ var GrokHarnessSession = class {
22912
23203
  };
22913
23204
  this.#active = active;
22914
23205
  this.#event({ type: "turn.started", turnId: command.turnId });
22915
- void this.#transport.runTurn(text, (event) => this.#handleEvent(active, event), (request) => this.#requestPermission(active, request)).then((response) => this.#settleFromHistory(active, terminalOutcome2(response, active.cancellationRequested), response), (error53) => this.#settleFromHistory(active, {
23206
+ void this.#transport.runTurn(text, (event) => this.#handleEvent(active, event), (request) => this.#requestPermission(active, request), (request) => this.#requestExtension(active, request)).then((response) => this.#settleFromHistory(active, terminalOutcome2(response, active.cancellationRequested), response), (error53) => this.#settleFromHistory(active, {
22916
23207
  status: "failed",
22917
23208
  error: normalizeError(error53, "nativeFailure")
22918
23209
  }));
@@ -22979,6 +23270,7 @@ var GrokHarnessSession = class {
22979
23270
  tools: /* @__PURE__ */ new Map(),
22980
23271
  completedItems: [],
22981
23272
  approvals: /* @__PURE__ */ new Map(),
23273
+ questions: /* @__PURE__ */ new Map(),
22982
23274
  cancellationRequested: false,
22983
23275
  beforeNativeTurnKeys: /* @__PURE__ */ new Set(),
22984
23276
  completion,
@@ -23119,16 +23411,7 @@ var GrokHarnessSession = class {
23119
23411
  if (active.cancellationRequested)
23120
23412
  return { ok: true, value: { cancellationRequested: true } };
23121
23413
  active.cancellationRequested = true;
23122
- for (const [interactionId, pending] of active.approvals) {
23123
- active.approvals.delete(interactionId);
23124
- pending.resolve({ outcome: { outcome: "cancelled" } });
23125
- this.#event({
23126
- type: "interaction.closed",
23127
- interactionId,
23128
- turnId: active.command.turnId,
23129
- reason: "cancelled"
23130
- });
23131
- }
23414
+ this.#closePendingInteractions(active, "cancelled");
23132
23415
  try {
23133
23416
  await this.#transport.cancel();
23134
23417
  return { ok: true, value: { cancellationRequested: true } };
@@ -23138,9 +23421,15 @@ var GrokHarnessSession = class {
23138
23421
  }
23139
23422
  async #respond(command) {
23140
23423
  const active = this.#active;
23141
- const pending = active?.approvals.get(command.interactionId);
23142
- if (!active || !pending)
23143
- return { ok: false, error: invalidState("Grok Approval is not pending") };
23424
+ const approval = active?.approvals.get(command.interactionId);
23425
+ if (active && approval)
23426
+ return this.#respondApproval(active, approval, command);
23427
+ const question = active?.questions.get(command.interactionId);
23428
+ if (active && question)
23429
+ return this.#respondQuestion(active, question, command);
23430
+ return { ok: false, error: invalidState("Grok Interaction is not pending") };
23431
+ }
23432
+ #respondApproval(active, pending, command) {
23144
23433
  if (command.response.type !== "approval") {
23145
23434
  return {
23146
23435
  ok: false,
@@ -23174,6 +23463,31 @@ var GrokHarnessSession = class {
23174
23463
  });
23175
23464
  return { ok: true, value: { accepted: true } };
23176
23465
  }
23466
+ #respondQuestion(active, pending, command) {
23467
+ if (command.response.type !== "question") {
23468
+ return {
23469
+ ok: false,
23470
+ error: {
23471
+ code: "invalidRequest",
23472
+ message: "Grok Question requires a Question Response",
23473
+ retryable: false
23474
+ }
23475
+ };
23476
+ }
23477
+ const validation = validateHostQuestionResponse(pending.interaction, command.response);
23478
+ if (validation)
23479
+ return { ok: false, error: validation };
23480
+ const native = pending.type === "planApproval" ? grokExitPlanModeResponse(pending.request, command.response) : grokAskUserQuestionResponse(pending.request, command.response);
23481
+ active.questions.delete(command.interactionId);
23482
+ pending.resolve(native);
23483
+ this.#event({
23484
+ type: "interaction.closed",
23485
+ interactionId: command.interactionId,
23486
+ turnId: active.command.turnId,
23487
+ reason: command.response.cancelled ? "cancelled" : "responded"
23488
+ });
23489
+ return { ok: true, value: { accepted: true } };
23490
+ }
23177
23491
  #requestPermission(active, request) {
23178
23492
  if (this.#active !== active || active.cancellationRequested) {
23179
23493
  return Promise.resolve({ outcome: { outcome: "cancelled" } });
@@ -23198,6 +23512,77 @@ var GrokHarnessSession = class {
23198
23512
  this.#channel.emit({ kind: "interaction", interaction });
23199
23513
  });
23200
23514
  }
23515
+ #requestExtension(active, request) {
23516
+ if (isGrokAskUserQuestionMethod(request.method)) {
23517
+ const parsed = parseGrokAskUserQuestionParams(request.params);
23518
+ if (!parsed) {
23519
+ throw RequestError.invalidParams(request.params, "Grok Question is invalid");
23520
+ }
23521
+ return this.#requestQuestion(active, parsed);
23522
+ }
23523
+ if (isGrokExitPlanModeMethod(request.method)) {
23524
+ const parsed = parseGrokExitPlanModeParams(request.params);
23525
+ if (!parsed) {
23526
+ throw RequestError.invalidParams(request.params, "Grok Plan approval is invalid");
23527
+ }
23528
+ return this.#requestPlanReview(active, parsed);
23529
+ }
23530
+ throw RequestError.methodNotFound(request.method);
23531
+ }
23532
+ #requestQuestion(active, request) {
23533
+ if (this.#active !== active || active.cancellationRequested) {
23534
+ return Promise.resolve(grokSkipInterviewResponse());
23535
+ }
23536
+ const interactionId = hostInteractionIdSchema.parse(this.#randomUUID());
23537
+ const interaction = createGrokQuestionInteraction(request, interactionId, active.command.turnId);
23538
+ return new Promise((resolve) => {
23539
+ active.questions.set(interactionId, {
23540
+ type: "question",
23541
+ interaction,
23542
+ request,
23543
+ resolve
23544
+ });
23545
+ this.#channel.emit({ kind: "interaction", interaction });
23546
+ });
23547
+ }
23548
+ #requestPlanReview(active, request) {
23549
+ if (this.#active !== active || active.cancellationRequested) {
23550
+ return Promise.resolve(grokPlanRejectedResponse());
23551
+ }
23552
+ const interactionId = hostInteractionIdSchema.parse(this.#randomUUID());
23553
+ const interaction = createGrokPlanReview(request, interactionId, active.command.turnId);
23554
+ return new Promise((resolve) => {
23555
+ active.questions.set(interactionId, {
23556
+ type: "planApproval",
23557
+ interaction,
23558
+ request,
23559
+ resolve
23560
+ });
23561
+ this.#channel.emit({ kind: "interaction", interaction });
23562
+ });
23563
+ }
23564
+ #closePendingInteractions(active, reason) {
23565
+ for (const [interactionId, pending] of active.approvals) {
23566
+ active.approvals.delete(interactionId);
23567
+ pending.resolve({ outcome: { outcome: "cancelled" } });
23568
+ this.#event({
23569
+ type: "interaction.closed",
23570
+ interactionId,
23571
+ turnId: active.command.turnId,
23572
+ reason
23573
+ });
23574
+ }
23575
+ for (const [interactionId, pending] of active.questions) {
23576
+ active.questions.delete(interactionId);
23577
+ pending.resolve(pending.type === "planApproval" ? grokPlanRejectedResponse() : grokSkipInterviewResponse());
23578
+ this.#event({
23579
+ type: "interaction.closed",
23580
+ interactionId,
23581
+ turnId: active.command.turnId,
23582
+ reason
23583
+ });
23584
+ }
23585
+ }
23201
23586
  #handleEvent(active, event) {
23202
23587
  if (this.#active !== active || this.#phase !== "open")
23203
23588
  return;
@@ -23475,16 +23860,7 @@ var GrokHarnessSession = class {
23475
23860
  for (const tool of active.tools.values())
23476
23861
  this.#completeItem(active, tool.item, itemOutcome);
23477
23862
  active.tools.clear();
23478
- for (const [interactionId, pending] of active.approvals) {
23479
- active.approvals.delete(interactionId);
23480
- pending.resolve({ outcome: { outcome: "cancelled" } });
23481
- this.#event({
23482
- type: "interaction.closed",
23483
- interactionId,
23484
- turnId: active.command.turnId,
23485
- reason: "cancelled"
23486
- });
23487
- }
23863
+ this.#closePendingInteractions(active, "cancelled");
23488
23864
  this.#active = null;
23489
23865
  if (usage)
23490
23866
  this.#publishUsage(usage, active.command.turnId);
@@ -23514,8 +23890,12 @@ var GrokHarnessSession = class {
23514
23890
  const active = this.#active;
23515
23891
  if (active) {
23516
23892
  active.cancellationRequested = true;
23517
- for (const approval of active.approvals.values())
23893
+ for (const approval of active.approvals.values()) {
23518
23894
  approval.resolve({ outcome: { outcome: "cancelled" } });
23895
+ }
23896
+ for (const question of active.questions.values()) {
23897
+ question.resolve(question.type === "planApproval" ? grokPlanRejectedResponse() : grokSkipInterviewResponse());
23898
+ }
23519
23899
  await this.#transport.cancel().catch(() => void 0);
23520
23900
  await Promise.race([
23521
23901
  active.completion,