@liberseek/boft-cli-win32-arm64 0.6.1 → 0.6.3

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,1250 @@ 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
+ totalCredits: finiteNonNegativeNumberSchema.optional(),
18714
+ contextUsagePercent: finiteNonNegativeNumberSchema.optional(),
18715
+ cacheHitRatePercent: cacheHitRatePercentSchema.optional(),
18716
+ contextWindowTokens: nonNegativeSafeIntegerSchema.optional(),
18717
+ contextUsedTokens: nonNegativeSafeIntegerSchema.optional(),
18718
+ planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
18719
+ planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
18720
+ planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
18721
+ planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
18722
+ }).strict().superRefine((usage, context) => {
18723
+ if (Object.keys(usage).length === 0) {
18724
+ context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
18725
+ }
18726
+ const hasContextUsed = usage.contextUsedTokens !== void 0;
18727
+ const hasContextWindow = usage.contextWindowTokens !== void 0;
18728
+ if (hasContextUsed !== hasContextWindow) {
18729
+ context.addIssue({
18730
+ code: "custom",
18731
+ message: "Thread Usage context fields must be provided together",
18732
+ path: [hasContextUsed ? "contextWindowTokens" : "contextUsedTokens"]
18733
+ });
18734
+ }
18735
+ if (usage.contextWindowTokens === 0) {
18736
+ context.addIssue({
18737
+ code: "custom",
18738
+ message: "Thread Usage contextWindowTokens must be greater than zero",
18739
+ path: ["contextWindowTokens"]
18740
+ });
18741
+ }
18742
+ if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
18743
+ context.addIssue({
18744
+ code: "custom",
18745
+ message: "Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent",
18746
+ path: ["planFiveHourResetsAtUnix"]
18747
+ });
18748
+ }
18749
+ if (usage.planSevenDayResetsAtUnix !== void 0 && usage.planSevenDayUsedPercent === void 0) {
18750
+ context.addIssue({
18751
+ code: "custom",
18752
+ message: "Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent",
18753
+ path: ["planSevenDayResetsAtUnix"]
18754
+ });
18755
+ }
18756
+ });
18757
+ var usagePercentSchema = external_exports.number().finite().min(0).max(100);
18758
+ var accountCreditsProductUsageSchema = external_exports.object({
18759
+ product: external_exports.string().min(1),
18760
+ usagePercent: usagePercentSchema,
18761
+ resetsAt: external_exports.string().min(1).optional()
18762
+ }).strict();
18763
+ var accountResetCreditsSchema = external_exports.object({
18764
+ availableCount: external_exports.number().int().safe().positive(),
18765
+ nextExpiresAt: external_exports.string().min(1).optional(),
18766
+ expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
18767
+ }).strict();
18768
+ var accountCreditsSnapshotSchema = external_exports.object({
18769
+ /** Native label when the primary limit is scoped to a model or product group. */
18770
+ label: external_exports.string().min(1).optional(),
18771
+ usedPercent: usagePercentSchema.optional(),
18772
+ remaining: external_exports.number().finite().optional(),
18773
+ unit: external_exports.string().trim().min(1).max(32).optional(),
18774
+ resetsAt: external_exports.string().min(1).optional(),
18775
+ periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
18776
+ productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
18777
+ resetCredits: accountResetCreditsSchema.optional()
18778
+ }).strict().superRefine((credits, context) => {
18779
+ if (credits.usedPercent === void 0 && credits.remaining === void 0) {
18780
+ context.addIssue({
18781
+ code: "custom",
18782
+ message: "Account credits must include usedPercent or remaining"
18783
+ });
18784
+ }
18785
+ if (credits.remaining !== void 0 && !credits.unit) {
18786
+ context.addIssue({
18787
+ code: "custom",
18788
+ message: "Account remaining credits require a unit",
18789
+ path: ["unit"]
18790
+ });
18791
+ }
18792
+ });
18793
+ var threadUsageInspectionParamsSchema = external_exports.object({
18794
+ threadId: hostThreadIdSchema,
18795
+ refresh: external_exports.literal("exact").optional()
18796
+ }).strict();
18797
+ var threadUsageInspectionSchema = external_exports.object({
18798
+ threadId: hostThreadIdSchema,
18799
+ usage: threadUsageSnapshotSchema.nullable(),
18800
+ accountCredits: accountCreditsSnapshotSchema.optional()
18801
+ }).strict();
18802
+
18803
+ // ../../shared-contracts/dist/harness-accounts.js
18804
+ var harnessAccountSnapshotSchema = external_exports.object({
18805
+ email: external_exports.string().trim().min(1).max(320).optional(),
18806
+ label: external_exports.string().trim().min(1).max(256).optional(),
18807
+ plan: external_exports.string().trim().min(1).max(128).optional(),
18808
+ credits: accountCreditsSnapshotSchema
18809
+ }).strict();
18810
+ var harnessAccountListParamsSchema = external_exports.object({}).strict();
18811
+ var harnessAccountListResultSchema = external_exports.object({
18812
+ accounts: external_exports.array(harnessAccountSnapshotSchema.extend({
18813
+ harnessId: harnessIdSchema,
18814
+ harnessName: external_exports.string().min(1)
18815
+ })).max(128)
18816
+ }).strict();
18817
+
18818
+ // ../../shared-contracts/dist/json-value.js
18819
+ function rejectExplicitUndefined(keys) {
18820
+ return (value, context) => {
18821
+ for (const key of keys) {
18822
+ if (Object.hasOwn(value, key) && value[key] === void 0) {
18823
+ context.addIssue({
18824
+ code: "custom",
18825
+ path: [key],
18826
+ message: "Explicit undefined is not valid JSON"
18827
+ });
18828
+ }
18829
+ }
18830
+ };
18831
+ }
18832
+ var jsonPrimitiveSchema = external_exports.union([
18833
+ external_exports.string(),
18834
+ external_exports.number(),
18835
+ external_exports.boolean(),
18836
+ external_exports.null()
18837
+ ]);
18838
+ function hasNoCircularReferences(value) {
18839
+ const ancestors = /* @__PURE__ */ new WeakSet();
18840
+ const stack = [{ value, leaving: false }];
18841
+ try {
18842
+ while (stack.length > 0) {
18843
+ const frame = stack.pop();
18844
+ if (!frame)
18845
+ break;
18846
+ if (frame.leaving) {
18847
+ ancestors.delete(frame.value);
18848
+ continue;
18849
+ }
18850
+ if (typeof frame.value !== "object" || frame.value === null)
18851
+ continue;
18852
+ if (ancestors.has(frame.value))
18853
+ return false;
18854
+ ancestors.add(frame.value);
18855
+ stack.push({ value: frame.value, leaving: true });
18856
+ for (const child of Object.values(frame.value)) {
18857
+ stack.push({ value: child, leaving: false });
18858
+ }
18859
+ }
18860
+ } catch {
18861
+ return false;
18862
+ }
18863
+ return true;
18864
+ }
18865
+ var nonCircularSchema = external_exports.custom(hasNoCircularReferences, {
18866
+ message: "JSON value must not contain circular references"
18867
+ });
18868
+ var recursiveJsonValueSchema = external_exports.lazy(() => external_exports.union([
18869
+ jsonPrimitiveSchema,
18870
+ external_exports.array(recursiveJsonValueSchema),
18871
+ external_exports.record(external_exports.string(), recursiveJsonValueSchema)
18872
+ ]));
18873
+ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
18874
+ var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
18875
+ var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
18876
+
18877
+ // ../../shared-contracts/dist/errors.js
18878
+ var codexhostErrorSchema = external_exports.strictObject({
18879
+ code: external_exports.string().min(1),
18880
+ message: external_exports.string().min(1),
18881
+ retryable: external_exports.boolean(),
18882
+ diagnostic: external_exports.string().min(1).optional(),
18883
+ stage: external_exports.string().min(1).optional(),
18884
+ durationMs: external_exports.number().int().nonnegative().optional(),
18885
+ stderrTail: external_exports.string().min(1).optional()
18886
+ }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
18887
+
18888
+ // ../../shared-contracts/dist/harness-permission-modes.js
18889
+ var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
18890
+ var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
18891
+ var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
18892
+ var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
18893
+ var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
18894
+ message: "Value must not be empty or whitespace"
18895
+ });
18896
+ 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();
18897
+ var harnessPermissionModeSchema = external_exports.object({
18898
+ id: harnessPermissionModeIdSchema,
18899
+ label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
18900
+ description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
18901
+ dangerous: external_exports.boolean().optional()
18902
+ }).strict();
18903
+ var harnessPermissionModeCatalogSchema = external_exports.object({
18904
+ modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
18905
+ defaultModeId: harnessPermissionModeIdSchema
18906
+ }).strict().superRefine((catalog, context) => {
18907
+ const ids = /* @__PURE__ */ new Set();
18908
+ for (const [index, mode] of catalog.modes.entries()) {
18909
+ if (ids.has(mode.id)) {
18910
+ context.addIssue({
18911
+ code: "custom",
18912
+ message: "Permission Mode IDs must be unique",
18913
+ path: ["modes", index, "id"]
18914
+ });
18915
+ }
18916
+ ids.add(mode.id);
18917
+ }
18918
+ if (!ids.has(catalog.defaultModeId)) {
18919
+ context.addIssue({
18920
+ code: "custom",
18921
+ message: "Default Permission Mode must exist in the catalog",
18922
+ path: ["defaultModeId"]
18923
+ });
18924
+ }
18925
+ });
18926
+ var threadPermissionModeSelectParamsSchema = external_exports.object({
18927
+ threadId: hostThreadIdSchema,
18928
+ permissionModeId: harnessPermissionModeIdSchema
18929
+ }).strict();
18930
+
18931
+ // ../../shared-contracts/dist/harness-models.js
18932
+ var HARNESS_MODEL_REF_MAX_LENGTH = 512;
18933
+ var HARNESS_MODEL_LABEL_MAX_LENGTH = 256;
18934
+ var HARNESS_THINKING_OPTION_ID_MAX_LENGTH = 128;
18935
+ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
18936
+ var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
18937
+ message: "Value must not be empty or whitespace"
18938
+ });
18939
+ var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
18940
+ var harnessModelRefSchema = external_exports.object({
18941
+ id: harnessModelRefIdSchema
18942
+ }).strict();
18943
+ 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();
18944
+ var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
18945
+ var harnessThinkingOptionSchema = external_exports.object({
18946
+ id: harnessThinkingOptionIdSchema,
18947
+ label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH)
18948
+ }).strict();
18949
+ var harnessModelSchema = external_exports.object({
18950
+ ref: harnessModelRefSchema,
18951
+ label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
18952
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
18953
+ supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
18954
+ }).strict();
18955
+ var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
18956
+ const ids = /* @__PURE__ */ new Set();
18957
+ for (const [index, option] of options.entries()) {
18958
+ if (ids.has(option.id)) {
18959
+ context.addIssue({
18960
+ code: "custom",
18961
+ message: "Thinking option IDs must be unique",
18962
+ path: [index, "id"]
18963
+ });
18964
+ }
18965
+ ids.add(option.id);
18966
+ }
18967
+ });
18968
+ var harnessModelCatalogSchema = external_exports.object({
18969
+ models: external_exports.array(harnessModelSchema),
18970
+ defaultModel: harnessModelRefSchema.optional(),
18971
+ thinkingOptions: harnessThinkingOptionsSchema,
18972
+ defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
18973
+ }).strict().superRefine((catalog, context) => {
18974
+ const refs = /* @__PURE__ */ new Set();
18975
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
18976
+ for (const [index, model] of catalog.models.entries()) {
18977
+ if (refs.has(model.ref.id)) {
18978
+ context.addIssue({
18979
+ code: "custom",
18980
+ message: "Model Catalog refs must be unique",
18981
+ path: ["models", index, "ref", "id"]
18982
+ });
18983
+ }
18984
+ refs.add(model.ref.id);
18985
+ const supportedThinkingIds = /* @__PURE__ */ new Set();
18986
+ for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
18987
+ if (supportedThinkingIds.has(optionId)) {
18988
+ context.addIssue({
18989
+ code: "custom",
18990
+ message: "Supported Thinking option IDs must be unique per Model",
18991
+ path: ["models", index, "supportedThinkingOptionIds", optionIndex]
18992
+ });
18993
+ }
18994
+ supportedThinkingIds.add(optionId);
18995
+ if (!thinkingIds.has(optionId)) {
18996
+ context.addIssue({
18997
+ code: "custom",
18998
+ message: "Supported Thinking option must exist in the catalog",
18999
+ path: ["models", index, "supportedThinkingOptionIds", optionIndex]
19000
+ });
19001
+ }
19002
+ }
19003
+ }
19004
+ if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
19005
+ context.addIssue({
19006
+ code: "custom",
19007
+ message: "Default Model must exist in the Model Catalog",
19008
+ path: ["defaultModel", "id"]
19009
+ });
19010
+ }
19011
+ if (catalog.defaultThinkingOptionId && !thinkingIds.has(catalog.defaultThinkingOptionId)) {
19012
+ context.addIssue({
19013
+ code: "custom",
19014
+ message: "Default Thinking option must exist in the catalog",
19015
+ path: ["defaultThinkingOptionId"]
19016
+ });
19017
+ }
19018
+ });
19019
+ var harnessHistoryCapabilitiesSchema = external_exports.object({
19020
+ fork: external_exports.boolean(),
19021
+ forkAcrossCwd: external_exports.boolean(),
19022
+ rollbackLastTurn: external_exports.boolean()
19023
+ }).strict().refine((history) => history.fork || !history.forkAcrossCwd, {
19024
+ path: ["forkAcrossCwd"],
19025
+ message: "Cross-cwd Fork requires exact history Fork support"
19026
+ });
19027
+ var harnessPermissionModeScopeSchema = external_exports.enum(["live", "atCreate"]);
19028
+ var harnessSessionCapabilitiesSchema = external_exports.object({
19029
+ configuration: external_exports.object({
19030
+ selectModel: external_exports.boolean(),
19031
+ selectThinkingOption: external_exports.boolean(),
19032
+ selectPermissionMode: external_exports.boolean(),
19033
+ permissionModeScope: harnessPermissionModeScopeSchema.default("live")
19034
+ }).strict(),
19035
+ history: harnessHistoryCapabilitiesSchema,
19036
+ subagents: external_exports.object({
19037
+ observe: external_exports.boolean(),
19038
+ readTranscript: external_exports.boolean()
19039
+ }).strict().optional(),
19040
+ autonomousTurns: external_exports.object({
19041
+ observe: external_exports.boolean()
19042
+ }).strict().optional(),
19043
+ input: external_exports.object({
19044
+ image: external_exports.boolean()
19045
+ }).strict().optional()
19046
+ }).strict();
19047
+ var harnessConfigurationStateSchema = external_exports.object({
19048
+ effectiveModel: harnessModelRefSchema.optional(),
19049
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19050
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19051
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19052
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
19053
+ }).strict().superRefine((state, context) => {
19054
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
19055
+ context.addIssue({
19056
+ code: "custom",
19057
+ message: "Effective Thinking option must be currently available",
19058
+ path: ["effectiveThinkingOptionId"]
19059
+ });
19060
+ }
19061
+ });
19062
+ var harnessWebUiCapabilitySchema = external_exports.object({
19063
+ open: external_exports.literal(true)
19064
+ }).strict();
19065
+ var readyHarnessInspectionSchema = external_exports.object({
19066
+ status: external_exports.literal("ready"),
19067
+ catalog: harnessModelCatalogSchema,
19068
+ permissionModes: harnessPermissionModeCatalogSchema.optional(),
19069
+ capabilities: harnessSessionCapabilitiesSchema,
19070
+ webUi: harnessWebUiCapabilitySchema.optional()
19071
+ }).strict().superRefine((inspection, context) => {
19072
+ const selectable = inspection.capabilities.configuration.selectPermissionMode;
19073
+ if (selectable !== Boolean(inspection.permissionModes)) {
19074
+ context.addIssue({
19075
+ code: "custom",
19076
+ message: "Permission Mode catalog and capability must agree",
19077
+ path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
19078
+ });
19079
+ }
19080
+ });
19081
+ var failedHarnessInspectionSchema = external_exports.object({
19082
+ status: external_exports.enum(["notInstalled", "unavailable", "error"]),
19083
+ error: codexhostErrorSchema
19084
+ }).strict();
19085
+ var harnessInspectionSchema = external_exports.union([
19086
+ readyHarnessInspectionSchema,
19087
+ failedHarnessInspectionSchema
19088
+ ]);
19089
+ var harnessInspectParamsSchema = external_exports.object({
19090
+ harnessId: harnessIdSchema,
19091
+ cwd: nonBlankTextSchema2.max(16384).optional(),
19092
+ refresh: external_exports.boolean().optional()
19093
+ }).strict();
19094
+ var harnessWebUiOpenParamsSchema = external_exports.object({
19095
+ harnessId: harnessIdSchema
19096
+ }).strict();
19097
+ var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
19098
+ var threadModelSelectParamsSchema = external_exports.object({
19099
+ threadId: hostThreadIdSchema,
19100
+ model: harnessModelRefSchema
19101
+ }).strict();
19102
+ var threadThinkingSelectParamsSchema = external_exports.object({
19103
+ threadId: hostThreadIdSchema,
19104
+ thinkingOptionId: harnessThinkingOptionIdSchema
19105
+ }).strict();
19106
+ var threadInspectionParamsSchema = external_exports.object({
19107
+ threadId: hostThreadIdSchema
19108
+ }).strict();
19109
+ var codexThreadInspectionSchema = external_exports.object({
19110
+ owner: external_exports.literal("codex"),
19111
+ accountId: nonBlankTextSchema2.optional(),
19112
+ locked: external_exports.literal(true)
19113
+ }).strict();
19114
+ var externalThreadInspectionSchema = external_exports.object({
19115
+ owner: external_exports.literal("external"),
19116
+ harnessId: nonBlankTextSchema2.max(256),
19117
+ transportModelId: nonBlankTextSchema2.max(1024),
19118
+ effectiveModel: harnessModelRefSchema.optional(),
19119
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19120
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19121
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19122
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
19123
+ history: harnessHistoryCapabilitiesSchema,
19124
+ usage: threadUsageSnapshotSchema.optional(),
19125
+ /** True when the thread is a read-only child thread materialized for a subagent. */
19126
+ subagent: external_exports.boolean().optional(),
19127
+ locked: external_exports.literal(true)
19128
+ }).strict();
19129
+ var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
19130
+ codexThreadInspectionSchema,
19131
+ externalThreadInspectionSchema
19132
+ ]);
19133
+ var threadOwnershipListParamsSchema = external_exports.object({
19134
+ threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19135
+ }).strict().superRefine(({ threadIds }, context) => {
19136
+ const seen = /* @__PURE__ */ new Set();
19137
+ for (const [index, threadId] of threadIds.entries()) {
19138
+ if (seen.has(threadId)) {
19139
+ context.addIssue({
19140
+ code: "custom",
19141
+ message: "Thread ownership-list IDs must be unique",
19142
+ path: ["threadIds", index]
19143
+ });
19144
+ }
19145
+ seen.add(threadId);
19146
+ }
19147
+ });
19148
+ var codexThreadOwnershipSchema = external_exports.object({
19149
+ threadId: hostThreadIdSchema,
19150
+ owner: external_exports.literal("codex")
19151
+ }).strict();
19152
+ var externalThreadOwnershipSchema = external_exports.object({
19153
+ threadId: hostThreadIdSchema,
19154
+ owner: external_exports.literal("external"),
19155
+ harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
19156
+ }).strict();
19157
+ var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
19158
+ codexThreadOwnershipSchema,
19159
+ externalThreadOwnershipSchema
19160
+ ]);
19161
+ var threadOwnershipListResultSchema = external_exports.object({
19162
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19163
+ }).strict().superRefine(({ threads }, context) => {
19164
+ const seen = /* @__PURE__ */ new Set();
19165
+ for (const [index, thread] of threads.entries()) {
19166
+ if (seen.has(thread.threadId)) {
19167
+ context.addIssue({
19168
+ code: "custom",
19169
+ message: "Thread ownership-list results must be unique",
19170
+ path: ["threads", index, "threadId"]
19171
+ });
19172
+ }
19173
+ seen.add(thread.threadId);
19174
+ }
19175
+ });
19176
+
19177
+ // ../../shared-contracts/dist/harness-plugins.js
19178
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
19179
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
19180
+ var HARNESS_PLUGIN_LIMIT = 128;
19181
+ 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);
19182
+ 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");
19183
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
19184
+ var pluginPresentationShape = {
19185
+ id: harnessPluginIdSchema,
19186
+ name: external_exports.string().trim().min(1).max(128),
19187
+ version: external_exports.string().min(1).max(128),
19188
+ links: external_exports.object({
19189
+ documentation: documentationUrlSchema.optional(),
19190
+ installation: documentationUrlSchema.optional()
19191
+ }).strict().optional()
19192
+ };
19193
+ var harnessPluginManifestSchema = external_exports.object({
19194
+ manifestVersion: external_exports.literal(1),
19195
+ ...pluginPresentationShape,
19196
+ adapterApiVersion: external_exports.number().int().positive(),
19197
+ entry: relativeResourceSchema,
19198
+ icon: relativeResourceSchema.optional()
19199
+ }).strict();
19200
+ 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);
19201
+ var harnessPluginDescriptorSchema = external_exports.object({
19202
+ ...pluginPresentationShape,
19203
+ icon: harnessPluginIconSchema.optional()
19204
+ }).strict();
19205
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
19206
+ var harnessPluginListResultSchema = external_exports.object({
19207
+ plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
19208
+ }).strict();
19209
+ var harnessPluginConfigurationSchema = external_exports.object({
19210
+ version: external_exports.literal(1),
19211
+ enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
19212
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
19213
+ message: "Enabled plugin IDs must be unique",
19214
+ path: ["enabled"]
19215
+ });
19216
+
19217
+ // ../../shared-contracts/dist/harness-route.js
19218
+ var harnessPluginRouteSchema = external_exports.object({
19219
+ harnessId: harnessPluginIdSchema,
19220
+ model: harnessModelRefSchema.optional(),
19221
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19222
+ permissionModeId: harnessPermissionModeIdSchema.optional()
19223
+ }).strict();
19224
+
19225
+ // ../../shared-contracts/dist/codex-accounts.js
19226
+ var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
19227
+ var nonBlankTextSchema3 = external_exports.string().trim().min(1);
19228
+ var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
19229
+ var codexAccountPlanTypeSchema = external_exports.enum([
19230
+ "free",
19231
+ "go",
19232
+ "plus",
19233
+ "pro",
19234
+ "prolite",
19235
+ "team",
19236
+ "self_serve_business_prolite",
19237
+ "self_serve_business_usage_based",
19238
+ "business",
19239
+ "ent26",
19240
+ "enterprise_cbp_automation",
19241
+ "enterprise_cbp_usage_based",
19242
+ "enterprise",
19243
+ "edu",
19244
+ "edu_plus",
19245
+ "edu_pro",
19246
+ "unknown"
19247
+ ]);
19248
+ var codexAccountSchema = external_exports.object({
19249
+ accountId: accountIdSchema,
19250
+ label: nonBlankTextSchema3.max(256),
19251
+ email: external_exports.string().email().max(320).optional(),
19252
+ planType: codexAccountPlanTypeSchema.optional(),
19253
+ codexHome: nonBlankTextSchema3.max(16384),
19254
+ active: external_exports.boolean(),
19255
+ isDefault: external_exports.boolean(),
19256
+ authKind: codexAccountAuthKindSchema.optional(),
19257
+ authIdentity: nonBlankTextSchema3.max(256).optional()
19258
+ }).strict();
19259
+ var codexAccountListResultSchema = external_exports.object({ accounts: external_exports.array(codexAccountSchema).max(128) }).strict();
19260
+ var codexAccountCreateParamsSchema = external_exports.object({ label: nonBlankTextSchema3.max(256).optional() }).strict();
19261
+ var codexAccountActivateParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
19262
+ var codexAccountDeleteParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
19263
+ var codexAccountDeleteResultSchema = external_exports.object({ deletedAccountId: accountIdSchema }).strict();
19264
+ var codexAccountMutationResultSchema = external_exports.object({ account: codexAccountSchema }).strict();
19265
+ var codexAccountLoginStartParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
19266
+ var codexAccountLoginStartResultSchema = external_exports.object({
19267
+ accountId: accountIdSchema,
19268
+ loginId: nonBlankTextSchema3.max(1024),
19269
+ verificationUrl: external_exports.string().url().max(16384),
19270
+ userCode: nonBlankTextSchema3.max(1024)
19271
+ }).strict();
19272
+ var codexAccountLoginCancelParamsSchema = external_exports.object({ accountId: accountIdSchema.optional(), loginId: nonBlankTextSchema3.max(1024) }).strict();
19273
+ var codexAccountLoginCancelResultSchema = external_exports.object({ cancelled: external_exports.boolean() }).strict();
19274
+ var codexAccountLoginCompletedSchema = external_exports.object({
19275
+ accountId: accountIdSchema,
19276
+ loginId: nonBlankTextSchema3.max(1024),
19277
+ success: external_exports.boolean(),
19278
+ error: external_exports.string().max(4096).nullable()
19279
+ }).strict();
19280
+ var codexAccountUsageParamsSchema = external_exports.object({ accountId: accountIdSchema }).strict();
19281
+ var codexAccountUsageResultSchema = external_exports.object({
19282
+ accountId: accountIdSchema,
19283
+ usage: threadUsageSnapshotSchema.nullable(),
19284
+ accountCredits: accountCreditsSnapshotSchema.optional()
19285
+ }).strict();
19286
+ var codexAccountResetCreditConsumeParamsSchema = external_exports.object({
19287
+ accountId: accountIdSchema,
19288
+ idempotencyKey: external_exports.string().uuid().optional()
19289
+ }).strict();
19290
+ var codexAccountResetCreditConsumeOutcomeSchema = external_exports.enum([
19291
+ "reset",
19292
+ "nothingToReset",
19293
+ "noCredit",
19294
+ "alreadyRedeemed"
19295
+ ]);
19296
+ var codexAccountResetCreditConsumeResultSchema = external_exports.object({
19297
+ accountId: accountIdSchema,
19298
+ outcome: codexAccountResetCreditConsumeOutcomeSchema,
19299
+ accountCredits: accountCreditsSnapshotSchema.optional()
19300
+ }).strict();
19301
+
19302
+ // ../../shared-contracts/dist/harness-session-import.js
19303
+ var HARNESS_SESSION_IMPORT_ID_MAX_LENGTH = 1024;
19304
+ var HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH = 16384;
19305
+ var HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH = 4096;
19306
+ var HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH = 1e3;
19307
+ var HARNESS_SESSION_IMPORT_UPDATED_AT_MAX = 864e13;
19308
+ 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");
19309
+ var harnessSessionImportIdSchema = nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_ID_MAX_LENGTH);
19310
+ var harnessSessionImportCandidateSchema = external_exports.object({
19311
+ nativeSessionId: harnessSessionImportIdSchema,
19312
+ title: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH).nullable(),
19313
+ updatedAt: external_exports.number().int().nonnegative().max(HARNESS_SESSION_IMPORT_UPDATED_AT_MAX),
19314
+ cwd: nonBlankTextSchema4.max(HARNESS_SESSION_IMPORT_CWD_MAX_LENGTH),
19315
+ // Native file discovery cannot reliably observe another process's activity.
19316
+ running: external_exports.boolean().nullable()
19317
+ }).strict();
19318
+ var harnessSessionImportSourcesParamsSchema = external_exports.object({}).strict();
19319
+ var harnessSessionImportSourcesResultSchema = external_exports.object({
19320
+ harnesses: external_exports.array(external_exports.object({
19321
+ harnessId: harnessPluginIdSchema,
19322
+ name: nonBlankTextSchema4.max(128)
19323
+ }).strict()).max(128)
19324
+ }).strict();
19325
+ var harnessSessionListParamsSchema = external_exports.object({
19326
+ harnessId: harnessPluginIdSchema,
19327
+ query: external_exports.string().trim().max(4096).refine((value) => !value.includes("\0")).optional(),
19328
+ offset: external_exports.number().int().nonnegative().safe().optional(),
19329
+ limit: external_exports.number().int().min(1).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH).optional()
19330
+ }).strict();
19331
+ var harnessSessionListResultSchema = external_exports.object({
19332
+ candidates: external_exports.array(harnessSessionImportCandidateSchema).max(HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH),
19333
+ total: external_exports.number().int().nonnegative().safe()
19334
+ }).strict();
19335
+ var harnessSessionImportParamsSchema = external_exports.object({
19336
+ harnessId: harnessPluginIdSchema,
19337
+ nativeSessionId: harnessSessionImportIdSchema
19338
+ }).strict();
19339
+ var harnessSessionImportResultSchema = external_exports.object({
19340
+ threadId: nonBlankTextSchema4.max(1024).pipe(hostThreadIdSchema)
19341
+ }).strict();
19342
+
19343
+ // ../../shared-contracts/dist/deepseek-modern-sessions.js
19344
+ var DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH = HARNESS_SESSION_IMPORT_LIST_MAX_LENGTH;
19345
+ var DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH = 1024;
19346
+ 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");
19347
+ var deepSeekModernSessionIdSchema = harnessSessionImportIdSchema;
19348
+ var deepSeekModernSessionCandidateSchema = harnessSessionImportCandidateSchema;
19349
+ var deepSeekModernSessionListParamsSchema = external_exports.object({}).strict();
19350
+ var deepSeekModernSessionListResultSchema = external_exports.object({
19351
+ candidates: external_exports.array(deepSeekModernSessionCandidateSchema).max(DEEPSEEK_MODERN_SESSION_LIST_MAX_LENGTH)
19352
+ }).strict();
19353
+ var deepSeekModernSessionImportParamsSchema = external_exports.object({
19354
+ nativeSessionId: deepSeekModernSessionIdSchema
19355
+ }).strict();
19356
+ var deepSeekModernSessionImportResultSchema = external_exports.object({
19357
+ threadId: nonBlankTextSchema5.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
19358
+ }).strict();
19359
+
19360
+ // ../../shared-contracts/dist/external-thread-fork.js
19361
+ var externalThreadForkParamsSchema = external_exports.object({
19362
+ threadId: hostThreadIdSchema,
19363
+ lastTurnId: hostTurnIdSchema
19364
+ }).strict();
19365
+ var externalThreadForkResultSchema = external_exports.object({
19366
+ threadId: hostThreadIdSchema
19367
+ }).strict();
19368
+
19369
+ // ../../shared-contracts/dist/harness-commands.js
19370
+ var commandIdSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();
19371
+ var commandInvocationSchema = external_exports.string().min(1).max(128);
19372
+ var commandLabelSchema = external_exports.string().trim().min(1).max(128);
19373
+ var commandDescriptionSchema = external_exports.string().trim().min(1).max(512);
19374
+ var harnessCommandDescriptorSchema = external_exports.object({
19375
+ id: commandIdSchema,
19376
+ invocation: commandInvocationSchema,
19377
+ label: commandLabelSchema,
19378
+ description: commandDescriptionSchema.optional(),
19379
+ argumentMode: external_exports.enum(["none", "text"])
19380
+ }).strict();
19381
+ var harnessCommandCatalogSchema = external_exports.object({
19382
+ commands: external_exports.array(harnessCommandDescriptorSchema)
19383
+ }).strict().superRefine((catalog, context) => {
19384
+ const ids = /* @__PURE__ */ new Set();
19385
+ for (const [index, command] of catalog.commands.entries()) {
19386
+ if (ids.has(command.id)) {
19387
+ context.addIssue({
19388
+ code: "custom",
19389
+ message: "Harness command IDs must be unique",
19390
+ path: ["commands", index, "id"]
19391
+ });
19392
+ }
19393
+ ids.add(command.id);
19394
+ }
19395
+ });
19396
+ var harnessCommandsInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema }).strict();
19397
+ var threadCommandsInspectParamsSchema = external_exports.object({
19398
+ threadId: hostThreadIdSchema
19399
+ }).strict();
19400
+ var threadCommandExecuteParamsSchema = external_exports.object({
19401
+ threadId: hostThreadIdSchema,
19402
+ commandId: commandIdSchema,
19403
+ turnId: hostTurnIdSchema.optional(),
19404
+ arguments: jsonObjectSchema.optional()
19405
+ }).strict();
19406
+ var threadCommandExecuteResultSchema = external_exports.object({
19407
+ accepted: external_exports.literal(true),
19408
+ turnId: hostTurnIdSchema
19409
+ }).strict();
19410
+
19411
+ // ../../shared-contracts/dist/json-rpc.js
19412
+ var jsonRpcVersionSchema = external_exports.literal("2.0").optional();
19413
+ var absentSchema = external_exports.never().optional();
19414
+ var methodSchema = external_exports.string().min(1);
19415
+ var jsonRpcIdSchema = external_exports.union([external_exports.string(), external_exports.number().int()]);
19416
+ var jsonRpcErrorSchema = external_exports.object({
19417
+ code: external_exports.number().int(),
19418
+ message: external_exports.string(),
19419
+ data: jsonValueSchema.optional()
19420
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["data"]));
19421
+ var jsonRpcRequestSchema = external_exports.object({
19422
+ jsonrpc: jsonRpcVersionSchema,
19423
+ id: jsonRpcIdSchema,
19424
+ method: methodSchema,
19425
+ params: jsonValueSchema.optional(),
19426
+ result: absentSchema,
19427
+ error: absentSchema
19428
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "params", "result", "error"]));
19429
+ var jsonRpcNotificationSchema = external_exports.object({
19430
+ jsonrpc: jsonRpcVersionSchema,
19431
+ id: absentSchema,
19432
+ method: methodSchema,
19433
+ params: jsonValueSchema.optional(),
19434
+ result: absentSchema,
19435
+ error: absentSchema
19436
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "id", "params", "result", "error"]));
19437
+ var jsonRpcSuccessResponseSchema = external_exports.object({
19438
+ jsonrpc: jsonRpcVersionSchema,
19439
+ id: jsonRpcIdSchema,
19440
+ method: absentSchema,
19441
+ params: absentSchema,
19442
+ result: jsonValueSchema,
19443
+ error: absentSchema
19444
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "error"]));
19445
+ var jsonRpcErrorResponseSchema = external_exports.object({
19446
+ jsonrpc: jsonRpcVersionSchema,
19447
+ id: jsonRpcIdSchema,
19448
+ method: absentSchema,
19449
+ params: absentSchema,
19450
+ result: absentSchema,
19451
+ error: jsonRpcErrorSchema
19452
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "result"]));
19453
+ var jsonRpcEnvelopeSchema = external_exports.union([
19454
+ jsonRpcRequestSchema,
19455
+ jsonRpcNotificationSchema,
19456
+ jsonRpcSuccessResponseSchema,
19457
+ jsonRpcErrorResponseSchema
19458
+ ]);
19459
+
19460
+ // ../../shared-contracts/dist/native-refs.js
19461
+ var nativeIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
19462
+ message: "Native identifier must not be empty or whitespace"
19463
+ });
19464
+ var nativeSessionRefV1RuntimeSchema = external_exports.strictObject({
19465
+ harnessId: harnessIdSchema,
19466
+ nativeSessionId: nativeIdSchema,
19467
+ locator: jsonValueSchema.optional(),
19468
+ formatVersion: external_exports.literal(1)
19469
+ }).superRefine(rejectExplicitUndefined(["locator"]));
19470
+ var nativeSessionRefV1Schema = nativeSessionRefV1RuntimeSchema;
19471
+ var nativeSessionRefSchema = nativeSessionRefV1Schema;
19472
+ var nativeTurnRefV1Schema = external_exports.strictObject({
19473
+ harnessId: harnessIdSchema,
19474
+ nativeSessionId: nativeIdSchema,
19475
+ nativeTurnKey: nativeIdSchema,
19476
+ formatVersion: external_exports.literal(1)
19477
+ });
19478
+ var nativeTurnRefSchema = nativeTurnRefV1Schema;
19479
+ var nativeCheckpointRefV1RuntimeSchema = external_exports.strictObject({
19480
+ harnessId: harnessIdSchema,
19481
+ nativeSessionId: nativeIdSchema,
19482
+ checkpointId: nativeIdSchema,
19483
+ locator: jsonValueSchema.optional(),
19484
+ formatVersion: external_exports.literal(1)
19485
+ }).superRefine(rejectExplicitUndefined(["locator"]));
19486
+ var nativeCheckpointRefV1Schema = nativeCheckpointRefV1RuntimeSchema;
19487
+ var nativeCheckpointRefSchema = nativeCheckpointRefV1Schema;
19488
+
19489
+ // ../../shared-contracts/dist/updates.js
19490
+ var UPDATE_ERROR_MAX_LENGTH = 500;
19491
+ var UPDATE_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
19492
+ var updateSemanticVersionSchema = external_exports.string().regex(UPDATE_SEMVER_PATTERN);
19493
+ var updateInstallationSchema = external_exports.enum(["npm", "windows-installer", "macos-dmg"]);
19494
+ var updatePhaseSchema = external_exports.enum([
19495
+ "prepared",
19496
+ "downloading",
19497
+ "waiting-for-exit",
19498
+ "installing",
19499
+ "restarting",
19500
+ "succeeded",
19501
+ "failed"
19502
+ ]);
19503
+ var updateStatusSchema = external_exports.strictObject({
19504
+ version: updateSemanticVersionSchema,
19505
+ installation: updateInstallationSchema,
19506
+ phase: updatePhaseSchema,
19507
+ updatedAt: external_exports.number().int().nonnegative(),
19508
+ downloadedBytes: external_exports.number().int().nonnegative().optional(),
19509
+ totalBytes: external_exports.number().int().positive().optional(),
19510
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
19511
+ }).superRefine((status, context) => {
19512
+ if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
19513
+ context.addIssue({
19514
+ code: "custom",
19515
+ path: ["downloadedBytes"],
19516
+ message: "downloadedBytes must not exceed totalBytes"
19517
+ });
19518
+ }
19519
+ });
19520
+ var updateEmptyParamsSchema = external_exports.strictObject({});
19521
+ 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");
19522
+ var updateCheckResultSchema = external_exports.strictObject({
19523
+ currentVersion: updateSemanticVersionSchema,
19524
+ installation: updateInstallationSchema.nullable(),
19525
+ latestVersion: updateSemanticVersionSchema.nullable(),
19526
+ updateAvailable: external_exports.boolean(),
19527
+ installationAvailable: external_exports.boolean(),
19528
+ releaseNotes: external_exports.string().min(1).max(2e4).nullable(),
19529
+ releaseNotesUrl: githubReleaseNotesUrlSchema.nullable(),
19530
+ status: updateStatusSchema.nullable(),
19531
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
19532
+ });
19533
+ var updateStartResultSchema = external_exports.strictObject({
19534
+ status: updateStatusSchema
19535
+ });
19536
+ var updateStatusResultSchema = external_exports.strictObject({
19537
+ status: updateStatusSchema.nullable()
19538
+ });
19539
+
19540
+ // ../../shared-contracts/dist/index.js
19541
+ var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
19542
+
19543
+ // ../../harness-adapter/dist/approval.js
19544
+ function invalidRequest(message) {
19545
+ return { code: "invalidRequest", message, retryable: false };
19546
+ }
19547
+ function validateHostApprovalResponse(interaction, response) {
19548
+ return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
19549
+ }
19550
+
19551
+ // ../../harness-adapter/dist/question.js
19552
+ function invalidRequest2(message) {
19553
+ return { code: "invalidRequest", message, retryable: false };
19554
+ }
19555
+ function validateHostQuestionResponse(interaction, response) {
19556
+ const questionIds = new Set(interaction.questions.map(({ id }) => id));
19557
+ if (response.cancelled) {
19558
+ return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
19505
19559
  }
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);
19560
+ for (const answerId of Object.keys(response.answers)) {
19561
+ if (!questionIds.has(answerId)) {
19562
+ return invalidRequest2("Question Response contains an unknown Question ID");
19563
+ }
19515
19564
  }
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);
19565
+ for (const question of interaction.questions) {
19566
+ const answers = response.answers[question.id] ?? [];
19567
+ if (!question.optional && answers.length === 0) {
19568
+ return invalidRequest2("Question Response omits a required answer");
19569
+ }
19570
+ if (question.type === "text") {
19571
+ if (answers.length > 1) {
19572
+ return invalidRequest2("Text Question accepts at most one answer");
19573
+ }
19574
+ continue;
19575
+ }
19576
+ if (!question.multiple && answers.length > 1) {
19577
+ return invalidRequest2("Single-choice Question accepts at most one answer");
19578
+ }
19579
+ const declared = new Set(question.options.map(({ value }) => value));
19580
+ if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
19581
+ return invalidRequest2("Question Response contains an undeclared choice");
19582
+ }
19525
19583
  }
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);
19584
+ return null;
19585
+ }
19586
+
19587
+ // ../../harness-adapter/dist/output-channel.js
19588
+ var HarnessOutputChannel = class {
19589
+ outputs;
19590
+ #consumerCreated = false;
19591
+ #ended = false;
19592
+ #pending = [];
19593
+ #values = [];
19594
+ constructor() {
19595
+ this.outputs = {
19596
+ [Symbol.asyncIterator]: () => {
19597
+ if (this.#consumerCreated) {
19598
+ throw new Error("Harness outputs allow only one consumer");
19599
+ }
19600
+ this.#consumerCreated = true;
19601
+ return {
19602
+ next: () => this.#next()
19603
+ };
19604
+ }
19605
+ };
19535
19606
  }
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);
19607
+ emit(value) {
19608
+ if (this.#ended)
19609
+ return false;
19610
+ const resolve = this.#pending.shift();
19611
+ if (resolve)
19612
+ resolve({ done: false, value });
19613
+ else
19614
+ this.#values.push(value);
19615
+ return true;
19545
19616
  }
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);
19617
+ end() {
19618
+ if (this.#ended)
19619
+ return;
19620
+ this.#ended = true;
19621
+ if (this.#values.length !== 0)
19622
+ return;
19623
+ for (const resolve of this.#pending.splice(0))
19624
+ resolve({ done: true, value: void 0 });
19555
19625
  }
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);
19626
+ #next() {
19627
+ const value = this.#values.shift();
19628
+ if (value !== void 0)
19629
+ return Promise.resolve({ done: false, value });
19630
+ if (this.#ended)
19631
+ return Promise.resolve({ done: true, value: void 0 });
19632
+ return new Promise((resolve) => this.#pending.push(resolve));
19565
19633
  }
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);
19634
+ };
19635
+
19636
+ // ../../harness-adapter/dist/diagnostics.js
19637
+ var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
19638
+ var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
19639
+ var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
19640
+ function sanitizeDiagnosticTail(value) {
19641
+ const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
19642
+ return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
19643
+ }
19644
+
19645
+ // ../../harness-adapter/dist/usage.js
19646
+ var tokenFields = [
19647
+ "inputTokens",
19648
+ "cachedInputTokens",
19649
+ "cacheWriteInputTokens",
19650
+ "outputTokens",
19651
+ "outputTokensPerSecond",
19652
+ "reasoningOutputTokens",
19653
+ "totalTokens",
19654
+ "contextWindowTokens",
19655
+ "contextUsedTokens"
19656
+ ];
19657
+ var safeIntegerFields = [
19658
+ "planFiveHourResetsAtUnix",
19659
+ "planSevenDayResetsAtUnix"
19660
+ ];
19661
+ var percentFields = [
19662
+ "cacheHitRatePercent",
19663
+ "planFiveHourUsedPercent",
19664
+ "planSevenDayUsedPercent"
19665
+ ];
19666
+ var usageFields = /* @__PURE__ */ new Set([
19667
+ ...tokenFields,
19668
+ ...safeIntegerFields,
19669
+ ...percentFields,
19670
+ "totalCostUsd",
19671
+ "totalCredits",
19672
+ "contextUsagePercent"
19673
+ ]);
19674
+ function isRecord2(value) {
19675
+ return typeof value === "object" && value !== null && !Array.isArray(value);
19676
+ }
19677
+ function parseHostUsage(value) {
19678
+ if (!isRecord2(value))
19679
+ throw new Error("Harness Usage must be an object");
19680
+ const keys = Object.keys(value);
19681
+ if (keys.length === 0)
19682
+ throw new Error("Harness Usage must contain a reliable field");
19683
+ for (const key of keys) {
19684
+ if (!usageFields.has(key)) {
19685
+ throw new Error(`Harness Usage contains unknown field '${key}'`);
19686
+ }
19575
19687
  }
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);
19688
+ for (const field of tokenFields) {
19689
+ const candidate = value[field];
19690
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
19691
+ throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
19692
+ }
19585
19693
  }
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);
19694
+ for (const field of safeIntegerFields) {
19695
+ const candidate = value[field];
19696
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
19697
+ throw new Error(`Harness Usage '${field}' must be a non-negative safe integer`);
19698
+ }
19595
19699
  }
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);
19700
+ if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
19701
+ throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
19702
+ }
19703
+ if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
19704
+ throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
19605
19705
  }
19606
- request(method, params, options) {
19607
- const spec = agentRequestSpecsByMethod[method];
19608
- return this.connection.sendRequest(method, params, spec?.mapResponse, options);
19706
+ for (const field of ["totalCredits", "contextUsagePercent"]) {
19707
+ const candidate = value[field];
19708
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
19709
+ throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
19710
+ }
19609
19711
  }
19610
- notify(method, params) {
19611
- return this.connection.sendNotification(method, params);
19712
+ for (const field of percentFields) {
19713
+ const candidate = value[field];
19714
+ if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
19715
+ throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
19716
+ }
19612
19717
  }
19613
- /**
19614
- * Extension method.
19615
- *
19616
- * @deprecated Use {@link request}.
19617
- */
19618
- extMethod(method, params) {
19619
- return this.request(method, params);
19718
+ const hasContextUsed = value.contextUsedTokens !== void 0;
19719
+ const hasContextWindow = value.contextWindowTokens !== void 0;
19720
+ if (hasContextUsed !== hasContextWindow) {
19721
+ throw new Error("Harness Usage context fields must be provided together");
19620
19722
  }
19621
- /**
19622
- * Extension notification.
19623
- *
19624
- * @deprecated Use {@link notify}.
19625
- */
19626
- extNotification(method, params) {
19627
- return this.notify(method, params);
19723
+ if (hasContextWindow && value.contextWindowTokens === 0) {
19724
+ throw new Error("Harness Usage 'contextWindowTokens' must be greater than zero");
19628
19725
  }
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;
19726
+ if (value.planFiveHourResetsAtUnix !== void 0 && value.planFiveHourUsedPercent === void 0) {
19727
+ throw new Error("Harness Usage 'planFiveHourResetsAtUnix' must be provided with 'planFiveHourUsedPercent'");
19659
19728
  }
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;
19729
+ if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
19730
+ throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
19677
19731
  }
19678
- };
19732
+ return { ...value };
19733
+ }
19734
+
19735
+ // dist/acp-transport.js
19736
+ import { spawn, spawnSync } from "node:child_process";
19737
+ import { readdir, readFile } from "node:fs/promises";
19738
+ import os3 from "node:os";
19739
+ import path8 from "node:path";
19740
+ import { Readable, Writable } from "node:stream";
19679
19741
 
19680
19742
  // dist/command.js
19681
19743
  import path3 from "node:path";
@@ -21637,6 +21699,232 @@ async function rewindGrokLastTurn(input) {
21637
21699
  return { ok: true, value: { sessionId } };
21638
21700
  }
21639
21701
 
21702
+ // dist/grok-plan-review.js
21703
+ var GROK_PLAN_DECISION_ID = "plan-decision";
21704
+ function isRecord9(value) {
21705
+ return typeof value === "object" && value !== null && !Array.isArray(value);
21706
+ }
21707
+ function stringField2(value, ...keys) {
21708
+ for (const key of keys) {
21709
+ const field = value[key];
21710
+ if (typeof field === "string" && field.length > 0)
21711
+ return field;
21712
+ }
21713
+ return void 0;
21714
+ }
21715
+ function parseGrokExitPlanModeParams(params) {
21716
+ if (!isRecord9(params))
21717
+ return null;
21718
+ const nested = isRecord9(params.input) ? params.input : params;
21719
+ const plan = stringField2(nested, "planContent", "plan_content", "plan") ?? stringField2(params, "planContent", "plan_content", "plan") ?? null;
21720
+ const planFilePath = stringField2(nested, "planFilePath", "plan_file_path") ?? stringField2(params, "planFilePath", "plan_file_path");
21721
+ const sessionId = stringField2(params, "sessionId", "session_id");
21722
+ return {
21723
+ plan,
21724
+ ...sessionId ? { sessionId } : {},
21725
+ ...planFilePath ? { planFilePath } : {}
21726
+ };
21727
+ }
21728
+ function createGrokPlanReview(request, interactionId, turnId) {
21729
+ const warning = "Approving this plan will exit Grok plan mode and let Grok begin implementation. This is not a one-time tool approval.";
21730
+ return {
21731
+ type: "question",
21732
+ interactionId,
21733
+ turnId,
21734
+ title: "Review plan",
21735
+ questions: [
21736
+ {
21737
+ id: GROK_PLAN_DECISION_ID,
21738
+ type: "choice",
21739
+ prompt: request.plan ? `${warning}
21740
+
21741
+ ${request.plan}` : "Grok did not provide plan text. Stay in plan mode and ask Grok to present the plan before approving it.",
21742
+ options: [
21743
+ {
21744
+ value: "stay",
21745
+ label: "Stay in plan mode",
21746
+ description: "Do not approve the plan or begin implementation."
21747
+ },
21748
+ ...request.plan ? [
21749
+ {
21750
+ value: "approve",
21751
+ label: "Approve plan and exit plan mode",
21752
+ description: "Leave plan mode and begin implementation."
21753
+ }
21754
+ ] : []
21755
+ ],
21756
+ multiple: false,
21757
+ allowOther: false,
21758
+ optional: false
21759
+ }
21760
+ ]
21761
+ };
21762
+ }
21763
+ function grokPlanRejectedResponse() {
21764
+ return { approved: false, feedback: "" };
21765
+ }
21766
+ function grokExitPlanModeResponse(request, response) {
21767
+ return {
21768
+ approved: !response.cancelled && request.plan !== null && response.answers[GROK_PLAN_DECISION_ID]?.[0] === "approve",
21769
+ feedback: ""
21770
+ };
21771
+ }
21772
+
21773
+ // dist/grok-question.js
21774
+ var GROK_ASK_USER_QUESTION_METHODS = [
21775
+ "_x.ai/ask_user_question",
21776
+ "x.ai/ask_user_question"
21777
+ ];
21778
+ var GROK_EXIT_PLAN_MODE_METHODS = ["_x.ai/exit_plan_mode", "x.ai/exit_plan_mode"];
21779
+ var GROK_ACP_CLIENT_CAPABILITIES = {
21780
+ _meta: {
21781
+ "x.ai/ask_user_question": true,
21782
+ "x.ai/exit_plan_mode": true
21783
+ }
21784
+ };
21785
+ function isRecord10(value) {
21786
+ return typeof value === "object" && value !== null && !Array.isArray(value);
21787
+ }
21788
+ function stringField3(value, ...keys) {
21789
+ for (const key of keys) {
21790
+ const field = value[key];
21791
+ if (typeof field === "string" && field.length > 0)
21792
+ return field;
21793
+ }
21794
+ return void 0;
21795
+ }
21796
+ function optionalTimeoutMs(value) {
21797
+ for (const key of ["timeoutMs", "timeout_ms", "timeoutSecs", "timeout_secs"]) {
21798
+ const field = value[key];
21799
+ if (typeof field === "number" && Number.isFinite(field) && field > 0) {
21800
+ return key.endsWith("secs") || key.endsWith("Secs") ? field * 1e3 : field;
21801
+ }
21802
+ }
21803
+ return void 0;
21804
+ }
21805
+ function isGrokAskUserQuestionMethod(method) {
21806
+ return GROK_ASK_USER_QUESTION_METHODS.includes(method);
21807
+ }
21808
+ function isGrokExitPlanModeMethod(method) {
21809
+ return GROK_EXIT_PLAN_MODE_METHODS.includes(method);
21810
+ }
21811
+ function questionsPayload(params) {
21812
+ if (Array.isArray(params.questions))
21813
+ return params.questions;
21814
+ if (isRecord10(params.input) && Array.isArray(params.input.questions))
21815
+ return params.input.questions;
21816
+ if (isRecord10(params.askUserQuestion) && Array.isArray(params.askUserQuestion.questions)) {
21817
+ return params.askUserQuestion.questions;
21818
+ }
21819
+ return void 0;
21820
+ }
21821
+ function parseOption(value, labels) {
21822
+ if (!isRecord10(value))
21823
+ return null;
21824
+ const label = stringField3(value, "label");
21825
+ if (!label || labels.has(label))
21826
+ return null;
21827
+ labels.add(label);
21828
+ const description = stringField3(value, "description");
21829
+ const preview = stringField3(value, "preview");
21830
+ const combined = [description, preview].filter((part) => part !== void 0);
21831
+ return {
21832
+ label,
21833
+ ...combined.length > 0 ? { description: combined.join("\n\n") } : {}
21834
+ };
21835
+ }
21836
+ function parseQuestion(value, questions) {
21837
+ if (!isRecord10(value))
21838
+ return null;
21839
+ const question = stringField3(value, "question");
21840
+ if (!question || questions.has(question))
21841
+ return null;
21842
+ if (!Array.isArray(value.options) || value.options.length === 0)
21843
+ return null;
21844
+ const labels = /* @__PURE__ */ new Set();
21845
+ const options = [];
21846
+ for (const option of value.options) {
21847
+ const parsed = parseOption(option, labels);
21848
+ if (!parsed)
21849
+ return null;
21850
+ options.push(parsed);
21851
+ }
21852
+ questions.add(question);
21853
+ const header = stringField3(value, "header");
21854
+ return {
21855
+ question,
21856
+ ...header ? { header } : {},
21857
+ options,
21858
+ multiSelect: value.multiSelect === true || value.multi_select === true
21859
+ };
21860
+ }
21861
+ function parseGrokAskUserQuestionParams(params) {
21862
+ if (!isRecord10(params))
21863
+ return null;
21864
+ const rawQuestions = questionsPayload(params);
21865
+ if (!Array.isArray(rawQuestions) || rawQuestions.length === 0)
21866
+ return null;
21867
+ const seen = /* @__PURE__ */ new Set();
21868
+ const questions = [];
21869
+ for (const value of rawQuestions) {
21870
+ const parsed = parseQuestion(value, seen);
21871
+ if (!parsed)
21872
+ return null;
21873
+ questions.push(parsed);
21874
+ }
21875
+ const sessionId = stringField3(params, "sessionId", "session_id");
21876
+ const timeoutMs = optionalTimeoutMs(params);
21877
+ return {
21878
+ questions,
21879
+ ...sessionId ? { sessionId } : {},
21880
+ ...timeoutMs !== void 0 ? { timeoutMs } : {}
21881
+ };
21882
+ }
21883
+ function grokQuestionId(index) {
21884
+ return `question-${index + 1}`;
21885
+ }
21886
+ function createGrokQuestionInteraction(request, interactionId, turnId, nowMs = Date.now()) {
21887
+ const first = request.questions[0];
21888
+ const title = request.questions.length === 1 ? first?.header ?? first?.question ?? "Grok" : "Grok";
21889
+ return {
21890
+ type: "question",
21891
+ interactionId,
21892
+ turnId,
21893
+ title,
21894
+ questions: request.questions.map((question, index) => ({
21895
+ id: grokQuestionId(index),
21896
+ type: "choice",
21897
+ prompt: question.question,
21898
+ options: question.options.map((option) => ({
21899
+ value: option.label,
21900
+ label: option.label,
21901
+ ...option.description ? { description: option.description } : {}
21902
+ })),
21903
+ multiple: question.multiSelect,
21904
+ allowOther: true,
21905
+ optional: false
21906
+ })),
21907
+ ...request.timeoutMs !== void 0 ? { expiresAt: new Date(nowMs + request.timeoutMs).toISOString() } : {}
21908
+ };
21909
+ }
21910
+ function grokSkipInterviewResponse() {
21911
+ return { outcome: "skip_interview" };
21912
+ }
21913
+ function grokAskUserQuestionResponse(request, response) {
21914
+ if (response.cancelled)
21915
+ return grokSkipInterviewResponse();
21916
+ const answers = {};
21917
+ for (const [index, question] of request.questions.entries()) {
21918
+ const selected = response.answers[grokQuestionId(index)] ?? [];
21919
+ answers[question.question] = question.multiSelect || selected.length !== 1 ? selected : selected[0] ?? "";
21920
+ }
21921
+ return {
21922
+ outcome: "accepted",
21923
+ answers,
21924
+ annotations: {}
21925
+ };
21926
+ }
21927
+
21640
21928
  // dist/permission-modes.js
21641
21929
  var nativePermissionModes = /* @__PURE__ */ new Set(["ask", "auto", "always-approve"]);
21642
21930
  var GROK_DEFAULT_PERMISSION_MODE_ID = harnessPermissionModeIdSchema.parse("ask");
@@ -21686,7 +21974,7 @@ var GrokTransportError = class extends Error {
21686
21974
  this.name = "GrokTransportError";
21687
21975
  }
21688
21976
  };
21689
- function isRecord9(value) {
21977
+ function isRecord11(value) {
21690
21978
  return typeof value === "object" && value !== null && !Array.isArray(value);
21691
21979
  }
21692
21980
  function errorText(error53) {
@@ -21742,7 +22030,7 @@ function signalProcessTree(child, signal) {
21742
22030
  try {
21743
22031
  process.kill(-child.pid, signal);
21744
22032
  } catch (error53) {
21745
- if (!isRecord9(error53) || error53.code !== "ESRCH")
22033
+ if (!isRecord11(error53) || error53.code !== "ESRCH")
21746
22034
  throw error53;
21747
22035
  }
21748
22036
  }
@@ -21830,7 +22118,7 @@ async function readNativeSignals(options, sessionId) {
21830
22118
  }
21831
22119
  }
21832
22120
  function isMissingFile(error53) {
21833
- return isRecord9(error53) && error53.code === "ENOENT";
22121
+ return isRecord11(error53) && error53.code === "ENOENT";
21834
22122
  }
21835
22123
  async function locateGrokNativeSession(options, sessionId) {
21836
22124
  if (sessionId.length === 0)
@@ -21853,7 +22141,7 @@ async function locateGrokNativeSession(options, sessionId) {
21853
22141
  try {
21854
22142
  summaryRaw = await readFile(path8.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
21855
22143
  } catch (error53) {
21856
- if (isMissingFile(error53) || isRecord9(error53) && error53.code === "ENOTDIR")
22144
+ if (isMissingFile(error53) || isRecord11(error53) && error53.code === "ENOTDIR")
21857
22145
  continue;
21858
22146
  throw new GrokTransportError("unavailable", "Grok Native Session metadata could not be read", {
21859
22147
  cause: error53
@@ -21865,10 +22153,10 @@ async function locateGrokNativeSession(options, sessionId) {
21865
22153
  } catch {
21866
22154
  continue;
21867
22155
  }
21868
- if (!isRecord9(parsed))
22156
+ if (!isRecord11(parsed))
21869
22157
  continue;
21870
22158
  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));
22159
+ const cwd = isRecord11(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path8.resolve(info.cwd) : path8.resolve(decodeURIComponent(entry.name));
21872
22160
  const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path8.resolve(parsed.source_workspace_dir) : void 0;
21873
22161
  matches.push({
21874
22162
  cwd,
@@ -21901,12 +22189,12 @@ function parseNativeHistory(contents, sessionId) {
21901
22189
  } catch {
21902
22190
  throw new GrokTransportError("protocolError", "Grok Native history contains invalid JSON");
21903
22191
  }
21904
- if (!isRecord9(record2) || !isRecord9(record2.params))
22192
+ if (!isRecord11(record2) || !isRecord11(record2.params))
21905
22193
  continue;
21906
22194
  const params = record2.params;
21907
- if (params.sessionId !== sessionId || !isRecord9(params.update))
22195
+ if (params.sessionId !== sessionId || !isRecord11(params.update))
21908
22196
  continue;
21909
- const metadata = isRecord9(params._meta) ? params._meta : void 0;
22197
+ const metadata = isRecord11(params._meta) ? params._meta : void 0;
21910
22198
  const event = transportEvent(params.update, metadata);
21911
22199
  if (event)
21912
22200
  events.push(metadata ? { ...event, metadata } : event);
@@ -22126,6 +22414,7 @@ var GrokAcpTransport = class {
22126
22414
  const connection = new ClientSideConnection(() => ({
22127
22415
  sessionUpdate: (params) => this.#handleUpdate(params),
22128
22416
  requestPermission: (params) => this.#handlePermission(params),
22417
+ extMethod: (method, params) => this.#handleExtensionRequest(method, params),
22129
22418
  extNotification: (method, params) => this.#handleExtensionNotification(method, params)
22130
22419
  }), stream);
22131
22420
  this.#connection = connection;
@@ -22137,7 +22426,7 @@ var GrokAcpTransport = class {
22137
22426
  });
22138
22427
  const initialize = await withTimeout(connection.initialize({
22139
22428
  protocolVersion: PROTOCOL_VERSION,
22140
- clientCapabilities: {},
22429
+ clientCapabilities: GROK_ACP_CLIENT_CAPABILITIES,
22141
22430
  clientInfo: { name: "codexhost", version: "0.1.6" }
22142
22431
  }), this.#options.commandTimeoutMs, "Grok ACP initialize");
22143
22432
  if (initialize.protocolVersion !== PROTOCOL_VERSION) {
@@ -22146,14 +22435,14 @@ var GrokAcpTransport = class {
22146
22435
  this.#initialize = initialize;
22147
22436
  return initialize;
22148
22437
  }
22149
- async runTurn(text, onEvent, onPermission) {
22438
+ async runTurn(text, onEvent, onPermission, onExtension) {
22150
22439
  const connection = this.#connection;
22151
22440
  if (!connection || !this.#sessionId || this.#closed || this.#closing) {
22152
22441
  throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
22153
22442
  }
22154
22443
  if (this.#activePrompt)
22155
22444
  throw new Error("Grok ACP Session already has an active Prompt");
22156
- const active = { onEvent, onPermission };
22445
+ const active = { onEvent, onPermission, onExtension };
22157
22446
  this.#activePrompt = active;
22158
22447
  try {
22159
22448
  return await connection.prompt({
@@ -22208,7 +22497,7 @@ var GrokAcpTransport = class {
22208
22497
  modelId,
22209
22498
  ...reasoningEffort ? { reasoningEffort } : {}
22210
22499
  });
22211
- if (!isRecord9(response) || !isRecord9(response._meta) || !isRecord9(response._meta.model)) {
22500
+ if (!isRecord11(response) || !isRecord11(response._meta) || !isRecord11(response._meta.model)) {
22212
22501
  throw new GrokTransportError("protocolError", "Grok rejected Model configuration");
22213
22502
  }
22214
22503
  const selected = response._meta.model.Ok;
@@ -22251,7 +22540,7 @@ var GrokAcpTransport = class {
22251
22540
  #handleUpdate(notification) {
22252
22541
  if (this.#sessionId && notification.sessionId !== this.#sessionId)
22253
22542
  return;
22254
- const metadata = isRecord9(notification._meta) ? notification._meta : void 0;
22543
+ const metadata = isRecord11(notification._meta) ? notification._meta : void 0;
22255
22544
  const event = transportEvent(notification.update, metadata);
22256
22545
  if (!event)
22257
22546
  return;
@@ -22266,7 +22555,7 @@ var GrokAcpTransport = class {
22266
22555
  #handleExtensionNotification(method, params) {
22267
22556
  if (!isGrokExtensionSessionUpdateMethod(method))
22268
22557
  return;
22269
- if (typeof params.sessionId !== "string" || !isRecord9(params.update))
22558
+ if (typeof params.sessionId !== "string" || !isRecord11(params.update))
22270
22559
  return;
22271
22560
  this.#handleUpdate(params);
22272
22561
  }
@@ -22276,6 +22565,16 @@ var GrokAcpTransport = class {
22276
22565
  }
22277
22566
  return this.#activePrompt.onPermission({ request: params, options: params.options });
22278
22567
  }
22568
+ #handleExtensionRequest(method, params) {
22569
+ if (this.#activePrompt) {
22570
+ return this.#activePrompt.onExtension({ method, params });
22571
+ }
22572
+ if (isGrokAskUserQuestionMethod(method))
22573
+ return Promise.resolve(grokSkipInterviewResponse());
22574
+ if (isGrokExitPlanModeMethod(method))
22575
+ return Promise.resolve(grokPlanRejectedResponse());
22576
+ throw RequestError.methodNotFound(method);
22577
+ }
22279
22578
  #fault(error53) {
22280
22579
  if (this.#closing || this.#closed)
22281
22580
  return;
@@ -22284,7 +22583,7 @@ var GrokAcpTransport = class {
22284
22583
  };
22285
22584
 
22286
22585
  // dist/grok-models.js
22287
- function isRecord10(value) {
22586
+ function isRecord12(value) {
22288
22587
  return typeof value === "object" && value !== null && !Array.isArray(value);
22289
22588
  }
22290
22589
  function nonBlank(value) {
@@ -22296,7 +22595,7 @@ function thinkingOptions(value) {
22296
22595
  const seen = /* @__PURE__ */ new Set();
22297
22596
  const options = [];
22298
22597
  for (const candidate of value) {
22299
- if (!isRecord10(candidate) || !nonBlank(candidate.label))
22598
+ if (!isRecord12(candidate) || !nonBlank(candidate.label))
22300
22599
  continue;
22301
22600
  const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
22302
22601
  if (!id.success || seen.has(id.data))
@@ -22307,7 +22606,7 @@ function thinkingOptions(value) {
22307
22606
  return options;
22308
22607
  }
22309
22608
  function parseGrokModelState(value) {
22310
- if (!isRecord10(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
22609
+ if (!isRecord12(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
22311
22610
  return null;
22312
22611
  }
22313
22612
  const currentModel = harnessModelRefSchema.safeParse({ id: value.currentModelId });
@@ -22318,12 +22617,12 @@ function parseGrokModelState(value) {
22318
22617
  const models = [];
22319
22618
  let currentThinkingOptionId;
22320
22619
  for (const candidate of value.availableModels) {
22321
- if (!isRecord10(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
22620
+ if (!isRecord12(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
22322
22621
  continue;
22323
22622
  const ref = harnessModelRefSchema.safeParse({ id: candidate.modelId });
22324
22623
  if (!ref.success)
22325
22624
  continue;
22326
- const metadata = isRecord10(candidate._meta) ? candidate._meta : {};
22625
+ const metadata = isRecord12(candidate._meta) ? candidate._meta : {};
22327
22626
  const options2 = thinkingOptions(metadata.reasoningEfforts);
22328
22627
  if (typeof metadata.totalContextTokens === "number" && Number.isSafeInteger(metadata.totalContextTokens) && metadata.totalContextTokens > 0) {
22329
22628
  contextWindowTokensByModel.set(ref.data.id, metadata.totalContextTokens);
@@ -22358,10 +22657,10 @@ function parseGrokModelState(value) {
22358
22657
  };
22359
22658
  }
22360
22659
  function modelStateFromInitialize(response) {
22361
- return parseGrokModelState(isRecord10(response._meta) ? response._meta.modelState : void 0);
22660
+ return parseGrokModelState(isRecord12(response._meta) ? response._meta.modelState : void 0);
22362
22661
  }
22363
22662
  function modelStateFromSessionResponse(response) {
22364
- return parseGrokModelState(isRecord10(response) ? response.models : void 0);
22663
+ return parseGrokModelState(isRecord12(response) ? response.models : void 0);
22365
22664
  }
22366
22665
  function stateForGrokModel(modelState, nativeState, model = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
22367
22666
  const selectedModel = model;
@@ -22385,7 +22684,7 @@ import os4 from "node:os";
22385
22684
  import path9 from "node:path";
22386
22685
  var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
22387
22686
  var REQUEST_TIMEOUT_MS = 15e3;
22388
- function isRecord11(value) {
22687
+ function isRecord13(value) {
22389
22688
  return typeof value === "object" && value !== null && !Array.isArray(value);
22390
22689
  }
22391
22690
  function finitePercent(value) {
@@ -22415,7 +22714,7 @@ function productUsageFrom(value) {
22415
22714
  if (!Array.isArray(value))
22416
22715
  return void 0;
22417
22716
  const products = value.flatMap((entry) => {
22418
- if (!isRecord11(entry) || typeof entry.product !== "string")
22717
+ if (!isRecord13(entry) || typeof entry.product !== "string")
22419
22718
  return [];
22420
22719
  const usagePercent = finitePercent(entry.usagePercent);
22421
22720
  return usagePercent === void 0 ? [] : [{ product: entry.product, usagePercent }];
@@ -22423,13 +22722,13 @@ function productUsageFrom(value) {
22423
22722
  return products.length > 0 ? products : void 0;
22424
22723
  }
22425
22724
  function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()).toISOString()) {
22426
- if (!isRecord11(value) || !isRecord11(value.config))
22725
+ if (!isRecord13(value) || !isRecord13(value.config))
22427
22726
  return null;
22428
22727
  const config2 = value.config;
22429
- const period = isRecord11(config2.currentPeriod) ? config2.currentPeriod : void 0;
22728
+ const period = isRecord13(config2.currentPeriod) ? config2.currentPeriod : void 0;
22430
22729
  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;
22730
+ const onDemandCap = isRecord13(config2.onDemandCap) ? nonNegativeNumber(config2.onDemandCap.val) : void 0;
22731
+ const onDemandUsed = isRecord13(config2.onDemandUsed) ? nonNegativeNumber(config2.onDemandUsed.val) : void 0;
22433
22732
  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
22733
  if (usedPercent === void 0)
22435
22734
  return null;
@@ -22443,11 +22742,11 @@ function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()
22443
22742
  };
22444
22743
  }
22445
22744
  function selectAccessToken(auth, now) {
22446
- if (!isRecord11(auth))
22745
+ if (!isRecord13(auth))
22447
22746
  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")));
22747
+ 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
22748
  for (const [, value] of entries) {
22450
- if (!isRecord11(value) || typeof value.key !== "string")
22749
+ if (!isRecord13(value) || typeof value.key !== "string")
22451
22750
  continue;
22452
22751
  if (typeof value.expires_at === "string") {
22453
22752
  const expiresAt = Date.parse(value.expires_at);
@@ -22504,11 +22803,12 @@ async function fetchGrokAccount(input = {}) {
22504
22803
  }
22505
22804
  async function fetchGrokCredits(input = {}) {
22506
22805
  const account = await fetchGrokAccount(input);
22507
- if (!account)
22806
+ const usedPercent = account?.credits.usedPercent;
22807
+ if (!account || usedPercent === void 0)
22508
22808
  return null;
22509
22809
  const { credits } = account;
22510
22810
  return {
22511
- usedPercent: credits.usedPercent,
22811
+ usedPercent,
22512
22812
  periodType: credits.periodType === "weekly" || credits.periodType === "monthly" ? credits.periodType : "unknown",
22513
22813
  fetchedAt: (input.now ?? /* @__PURE__ */ new Date()).toISOString(),
22514
22814
  ...credits.resetsAt ? { resetsAt: credits.resetsAt } : {},
@@ -22518,7 +22818,7 @@ async function fetchGrokCredits(input = {}) {
22518
22818
 
22519
22819
  // dist/grok-usage.js
22520
22820
  var USD_TICKS_PER_DOLLAR = 1e10;
22521
- function isRecord12(value) {
22821
+ function isRecord14(value) {
22522
22822
  return typeof value === "object" && value !== null && !Array.isArray(value);
22523
22823
  }
22524
22824
  function optionalToken(value) {
@@ -22535,7 +22835,7 @@ function combineUsage(base, next) {
22535
22835
  return base === null ? next : parseHostUsage({ ...base, ...next });
22536
22836
  }
22537
22837
  function usageFromNative(value) {
22538
- if (!isRecord12(value))
22838
+ if (!isRecord14(value))
22539
22839
  return null;
22540
22840
  const nativeInputTokens = optionalToken(value.inputTokens);
22541
22841
  const cachedRead = optionalToken(value.cachedReadTokens);
@@ -22564,7 +22864,7 @@ function usageFromPrompt(response) {
22564
22864
  return response.usage ? usageFromNative(response.usage) : null;
22565
22865
  }
22566
22866
  function usageFromSignals(value) {
22567
- if (!isRecord12(value))
22867
+ if (!isRecord14(value))
22568
22868
  return null;
22569
22869
  try {
22570
22870
  return parseHostUsage({
@@ -22584,7 +22884,7 @@ var summedUsageFields = [
22584
22884
  "totalTokens"
22585
22885
  ];
22586
22886
  function nativeCostTicks(value) {
22587
- if (!isRecord12(value))
22887
+ if (!isRecord14(value))
22588
22888
  return void 0;
22589
22889
  const ticks = value.costUsdTicks;
22590
22890
  if (typeof ticks !== "number" || !Number.isSafeInteger(ticks) || ticks < 0)
@@ -22661,7 +22961,7 @@ function usageFromCompact(tokensAfter, contextWindowTokens) {
22661
22961
  function usageFromUpdate(update, metadata, contextWindowTokens) {
22662
22962
  try {
22663
22963
  if (update?.sessionUpdate === "usage_update") {
22664
- const cost = isRecord12(update.cost) ? update.cost : null;
22964
+ const cost = isRecord14(update.cost) ? update.cost : null;
22665
22965
  return parseHostUsage({
22666
22966
  contextUsedTokens: update.used,
22667
22967
  contextWindowTokens: update.size,
@@ -22905,6 +23205,7 @@ var GrokHarnessSession = class {
22905
23205
  tools: /* @__PURE__ */ new Map(),
22906
23206
  completedItems: [],
22907
23207
  approvals: /* @__PURE__ */ new Map(),
23208
+ questions: /* @__PURE__ */ new Map(),
22908
23209
  cancellationRequested: false,
22909
23210
  beforeNativeTurnKeys: new Set(this.#snapshot.turns.map((turn) => turn.nativeTurnRef.nativeTurnKey)),
22910
23211
  completion,
@@ -22912,7 +23213,7 @@ var GrokHarnessSession = class {
22912
23213
  };
22913
23214
  this.#active = active;
22914
23215
  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, {
23216
+ 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
23217
  status: "failed",
22917
23218
  error: normalizeError(error53, "nativeFailure")
22918
23219
  }));
@@ -22979,6 +23280,7 @@ var GrokHarnessSession = class {
22979
23280
  tools: /* @__PURE__ */ new Map(),
22980
23281
  completedItems: [],
22981
23282
  approvals: /* @__PURE__ */ new Map(),
23283
+ questions: /* @__PURE__ */ new Map(),
22982
23284
  cancellationRequested: false,
22983
23285
  beforeNativeTurnKeys: /* @__PURE__ */ new Set(),
22984
23286
  completion,
@@ -23119,16 +23421,7 @@ var GrokHarnessSession = class {
23119
23421
  if (active.cancellationRequested)
23120
23422
  return { ok: true, value: { cancellationRequested: true } };
23121
23423
  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
- }
23424
+ this.#closePendingInteractions(active, "cancelled");
23132
23425
  try {
23133
23426
  await this.#transport.cancel();
23134
23427
  return { ok: true, value: { cancellationRequested: true } };
@@ -23138,9 +23431,15 @@ var GrokHarnessSession = class {
23138
23431
  }
23139
23432
  async #respond(command) {
23140
23433
  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") };
23434
+ const approval = active?.approvals.get(command.interactionId);
23435
+ if (active && approval)
23436
+ return this.#respondApproval(active, approval, command);
23437
+ const question = active?.questions.get(command.interactionId);
23438
+ if (active && question)
23439
+ return this.#respondQuestion(active, question, command);
23440
+ return { ok: false, error: invalidState("Grok Interaction is not pending") };
23441
+ }
23442
+ #respondApproval(active, pending, command) {
23144
23443
  if (command.response.type !== "approval") {
23145
23444
  return {
23146
23445
  ok: false,
@@ -23174,6 +23473,31 @@ var GrokHarnessSession = class {
23174
23473
  });
23175
23474
  return { ok: true, value: { accepted: true } };
23176
23475
  }
23476
+ #respondQuestion(active, pending, command) {
23477
+ if (command.response.type !== "question") {
23478
+ return {
23479
+ ok: false,
23480
+ error: {
23481
+ code: "invalidRequest",
23482
+ message: "Grok Question requires a Question Response",
23483
+ retryable: false
23484
+ }
23485
+ };
23486
+ }
23487
+ const validation = validateHostQuestionResponse(pending.interaction, command.response);
23488
+ if (validation)
23489
+ return { ok: false, error: validation };
23490
+ const native = pending.type === "planApproval" ? grokExitPlanModeResponse(pending.request, command.response) : grokAskUserQuestionResponse(pending.request, command.response);
23491
+ active.questions.delete(command.interactionId);
23492
+ pending.resolve(native);
23493
+ this.#event({
23494
+ type: "interaction.closed",
23495
+ interactionId: command.interactionId,
23496
+ turnId: active.command.turnId,
23497
+ reason: command.response.cancelled ? "cancelled" : "responded"
23498
+ });
23499
+ return { ok: true, value: { accepted: true } };
23500
+ }
23177
23501
  #requestPermission(active, request) {
23178
23502
  if (this.#active !== active || active.cancellationRequested) {
23179
23503
  return Promise.resolve({ outcome: { outcome: "cancelled" } });
@@ -23198,6 +23522,77 @@ var GrokHarnessSession = class {
23198
23522
  this.#channel.emit({ kind: "interaction", interaction });
23199
23523
  });
23200
23524
  }
23525
+ #requestExtension(active, request) {
23526
+ if (isGrokAskUserQuestionMethod(request.method)) {
23527
+ const parsed = parseGrokAskUserQuestionParams(request.params);
23528
+ if (!parsed) {
23529
+ throw RequestError.invalidParams(request.params, "Grok Question is invalid");
23530
+ }
23531
+ return this.#requestQuestion(active, parsed);
23532
+ }
23533
+ if (isGrokExitPlanModeMethod(request.method)) {
23534
+ const parsed = parseGrokExitPlanModeParams(request.params);
23535
+ if (!parsed) {
23536
+ throw RequestError.invalidParams(request.params, "Grok Plan approval is invalid");
23537
+ }
23538
+ return this.#requestPlanReview(active, parsed);
23539
+ }
23540
+ throw RequestError.methodNotFound(request.method);
23541
+ }
23542
+ #requestQuestion(active, request) {
23543
+ if (this.#active !== active || active.cancellationRequested) {
23544
+ return Promise.resolve(grokSkipInterviewResponse());
23545
+ }
23546
+ const interactionId = hostInteractionIdSchema.parse(this.#randomUUID());
23547
+ const interaction = createGrokQuestionInteraction(request, interactionId, active.command.turnId);
23548
+ return new Promise((resolve) => {
23549
+ active.questions.set(interactionId, {
23550
+ type: "question",
23551
+ interaction,
23552
+ request,
23553
+ resolve
23554
+ });
23555
+ this.#channel.emit({ kind: "interaction", interaction });
23556
+ });
23557
+ }
23558
+ #requestPlanReview(active, request) {
23559
+ if (this.#active !== active || active.cancellationRequested) {
23560
+ return Promise.resolve(grokPlanRejectedResponse());
23561
+ }
23562
+ const interactionId = hostInteractionIdSchema.parse(this.#randomUUID());
23563
+ const interaction = createGrokPlanReview(request, interactionId, active.command.turnId);
23564
+ return new Promise((resolve) => {
23565
+ active.questions.set(interactionId, {
23566
+ type: "planApproval",
23567
+ interaction,
23568
+ request,
23569
+ resolve
23570
+ });
23571
+ this.#channel.emit({ kind: "interaction", interaction });
23572
+ });
23573
+ }
23574
+ #closePendingInteractions(active, reason) {
23575
+ for (const [interactionId, pending] of active.approvals) {
23576
+ active.approvals.delete(interactionId);
23577
+ pending.resolve({ outcome: { outcome: "cancelled" } });
23578
+ this.#event({
23579
+ type: "interaction.closed",
23580
+ interactionId,
23581
+ turnId: active.command.turnId,
23582
+ reason
23583
+ });
23584
+ }
23585
+ for (const [interactionId, pending] of active.questions) {
23586
+ active.questions.delete(interactionId);
23587
+ pending.resolve(pending.type === "planApproval" ? grokPlanRejectedResponse() : grokSkipInterviewResponse());
23588
+ this.#event({
23589
+ type: "interaction.closed",
23590
+ interactionId,
23591
+ turnId: active.command.turnId,
23592
+ reason
23593
+ });
23594
+ }
23595
+ }
23201
23596
  #handleEvent(active, event) {
23202
23597
  if (this.#active !== active || this.#phase !== "open")
23203
23598
  return;
@@ -23475,16 +23870,7 @@ var GrokHarnessSession = class {
23475
23870
  for (const tool of active.tools.values())
23476
23871
  this.#completeItem(active, tool.item, itemOutcome);
23477
23872
  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
- }
23873
+ this.#closePendingInteractions(active, "cancelled");
23488
23874
  this.#active = null;
23489
23875
  if (usage)
23490
23876
  this.#publishUsage(usage, active.command.turnId);
@@ -23514,8 +23900,12 @@ var GrokHarnessSession = class {
23514
23900
  const active = this.#active;
23515
23901
  if (active) {
23516
23902
  active.cancellationRequested = true;
23517
- for (const approval of active.approvals.values())
23903
+ for (const approval of active.approvals.values()) {
23518
23904
  approval.resolve({ outcome: { outcome: "cancelled" } });
23905
+ }
23906
+ for (const question of active.questions.values()) {
23907
+ question.resolve(question.type === "planApproval" ? grokPlanRejectedResponse() : grokSkipInterviewResponse());
23908
+ }
23519
23909
  await this.#transport.cancel().catch(() => void 0);
23520
23910
  await Promise.race([
23521
23911
  active.completion,