@super-one/cli 0.53.1-alpha → 0.53.3-alpha

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.
Files changed (3) hide show
  1. package/MANIFEST.json +2 -2
  2. package/lib/cli.mjs +925 -263
  3. package/package.json +1 -1
package/lib/cli.mjs CHANGED
@@ -659,7 +659,7 @@ var init_host_action_superone_descriptors = __esm({
659
659
  },
660
660
  {
661
661
  "name": "session_rename",
662
- "description": 'Rename the current chat session to a concise topic label shown in the sidebar.\n\nOnly the top-level agent talking directly to the user may call this. If you were launched as a Task/subagent worker, do NOT call it \u2014 you do not own the user-facing session title.\n\nIf the tool returns an error containing "user_locked", the user has manually named this session \u2014 do not call session_rename again for this session.',
662
+ "description": 'Rename the current chat session to a concise topic label shown in the sidebar. Optional tags (set) label it for session_list/session_search \u2014 discover names with session_tag_list.\n\nOnly the top-level agent talking directly to the user may call this. If you were launched as a Task/subagent worker, do NOT call it \u2014 you do not own the user-facing session title.\n\nIf the tool returns an error containing "user_locked", the user has manually named this session \u2014 do not call session_rename again. Tags in the same call were still applied; use session_tag for later tag edits.',
663
663
  "inputSchema": {
664
664
  "type": "object",
665
665
  "properties": {
@@ -668,6 +668,12 @@ var init_host_action_superone_descriptors = __esm({
668
668
  "description": "A concise 4-8 word title describing the current conversation topic.",
669
669
  "minLength": 1,
670
670
  "maxLength": 80
671
+ },
672
+ "tags": {
673
+ "type": "array",
674
+ "items": { "type": "string" },
675
+ "maxItems": 8,
676
+ "description": "Replace this session's tags (set). Discover names with session_tag_list. Empty array clears. Applied even when the title is user_locked."
671
677
  }
672
678
  },
673
679
  "required": [
@@ -676,6 +682,81 @@ var init_host_action_superone_descriptors = __esm({
676
682
  "additionalProperties": false
677
683
  }
678
684
  },
685
+ {
686
+ "name": "session_tag",
687
+ "description": "Tag SuperOne sessions so session_list/session_search can filter by tag. Default: current session. Pass sessionId for one other session, or sessionIds with add to tag many. Use add, remove, or set (exactly one). set: [] clears. Discover existing labels with session_tag_list first \u2014 do not invent names. Only the top-level agent may call this; subagents must not. Not session_rename (titles) and not live collab.",
688
+ "inputSchema": {
689
+ "type": "object",
690
+ "properties": {
691
+ "sessionId": {
692
+ "type": "string",
693
+ "description": "One session to tag. Default: current. Mutually exclusive with sessionIds."
694
+ },
695
+ "sessionIds": {
696
+ "type": "array",
697
+ "items": { "type": "string" },
698
+ "maxItems": 50,
699
+ "description": "Bulk target ids (max 50). add required; set/remove not allowed. Mutually exclusive with sessionId."
700
+ },
701
+ "add": {
702
+ "type": "array",
703
+ "items": { "type": "string" },
704
+ "maxItems": 8,
705
+ "description": "Tags to add (normalized, de-duped). Mutually exclusive with remove/set."
706
+ },
707
+ "remove": {
708
+ "type": "array",
709
+ "items": { "type": "string" },
710
+ "maxItems": 8,
711
+ "description": "Tags to remove. Mutually exclusive with add/set."
712
+ },
713
+ "set": {
714
+ "type": "array",
715
+ "items": { "type": "string" },
716
+ "maxItems": 8,
717
+ "description": "Replace all tags. Empty array clears. Mutually exclusive with add/remove."
718
+ }
719
+ },
720
+ "additionalProperties": false
721
+ }
722
+ },
723
+ {
724
+ "name": "session_tag_list",
725
+ "description": "List tags used on SuperOne sessions (tag + session count). Default: current project; projectId or allProjects for other scope. Filter with query (tag substring). Hidden sessions omitted unless includeHidden. Call this before session_list/session_search with tags. Then filter with tags + tagMatch any (at least one) or all (every tag). Not live collab.",
726
+ "inputSchema": {
727
+ "type": "object",
728
+ "properties": {
729
+ "query": {
730
+ "type": "string",
731
+ "description": "Case-insensitive substring filter on tag name."
732
+ },
733
+ "includeHidden": {
734
+ "type": "boolean",
735
+ "description": "Count hidden sessions. Default false."
736
+ },
737
+ "projectId": {
738
+ "type": "string",
739
+ "description": "List tags in this SuperOne project id only (from project_list). Mutually exclusive with allProjects. Default: current project."
740
+ },
741
+ "allProjects": {
742
+ "type": "boolean",
743
+ "description": "List tags across every SuperOne project. Mutually exclusive with projectId. Default false."
744
+ },
745
+ "limit": {
746
+ "type": "integer",
747
+ "minimum": 1,
748
+ "maximum": 100,
749
+ "description": "Max rows. Default 50, max 100."
750
+ },
751
+ "offset": {
752
+ "type": "integer",
753
+ "minimum": 0,
754
+ "description": "Pagination offset. Default 0."
755
+ }
756
+ },
757
+ "additionalProperties": false
758
+ }
759
+ },
679
760
  {
680
761
  "name": "project_list",
681
762
  "description": "List SuperOne projects (id, name, path, lastActiveAt). Call this to discover projectId before session_list/session_search with projectId. Default order is last-active desc. Filter with query (name/path substring). isCurrent marks the project of the calling session.",
@@ -703,7 +784,7 @@ var init_host_action_superone_descriptors = __esm({
703
784
  },
704
785
  {
705
786
  "name": "session_list",
706
- "description": "List SuperOne sessions (metadata only). Default: current project. Pass projectId (from project_list) for another project, or allProjects=true for every project. Rows include projectId only \u2014 use project_list for path/name. Use before session_read/session_search to find ids. Filter by title query, harness, pin/hidden, dates. Sort with order (default last_active_desc; last_active_asc oldest-first; also created_*, message_count_*, size_*). When order is size_*, rows include sizeBytes (approx character length of stored message JSON for ranking \u2014 not disk page-file bytes). Paginate with limit/offset. Not live collab or harness resume.",
787
+ "description": "List SuperOne sessions (metadata only). Default: current project. Pass projectId (from project_list) or allProjects=true. Rows include projectId only \u2014 use project_list for path/name. Use before session_read/session_search. Filter by title query, harness, pin/hidden, dates, or tags + tagMatch (any=at least one, all=every tag; default any). Discover tags with session_tag_list. Sort with order (default last_active_desc; also created_*, message_count_*, size_*). When order is size_*, rows include sizeBytes (character length of message JSON, not disk bytes). Paginate with limit/offset. Not live collab or harness resume.",
707
788
  "inputSchema": {
708
789
  "type": "object",
709
790
  "properties": {
@@ -741,6 +822,17 @@ var init_host_action_superone_descriptors = __esm({
741
822
  "type": "string",
742
823
  "description": "ISO timestamp \u2014 only sessions last active after this."
743
824
  },
825
+ "tags": {
826
+ "type": "array",
827
+ "items": { "type": "string" },
828
+ "maxItems": 8,
829
+ "description": "Tags from session_tag_list. Filter sessions that have these labels."
830
+ },
831
+ "tagMatch": {
832
+ "type": "string",
833
+ "enum": ["any", "all"],
834
+ "description": "any = at least one listed tag (default). all = every listed tag. Ignored when tags is omitted."
835
+ },
744
836
  "projectId": {
745
837
  "type": "string",
746
838
  "description": "List sessions in this SuperOne project id only (from project_list). Mutually exclusive with allProjects. Default: current project."
@@ -780,7 +872,7 @@ var init_host_action_superone_descriptors = __esm({
780
872
  },
781
873
  {
782
874
  "name": "session_search",
783
- "description": "Search SuperOne chat transcripts by text. Default: current project; projectId (from project_list) or allProjects for cross-project. Returns matching message hits with short snippets and projectId. Then call session_read with sessionId/messageId for full content. Snippets are pointers only \u2014 not full message bodies.",
875
+ "description": "Search SuperOne chat transcripts by text (title + message body). Default: current project; projectId or allProjects for cross-project. Optional tags + tagMatch (any/all, default any) narrows sessions in SQL before scanning messages. Discover tags with session_tag_list. Returns matching message hits with short snippets and projectId. Then call session_read with sessionId/messageId. Snippets are pointers only \u2014 not full bodies.",
784
876
  "inputSchema": {
785
877
  "type": "object",
786
878
  "properties": {
@@ -815,6 +907,17 @@ var init_host_action_superone_descriptors = __esm({
815
907
  ],
816
908
  "description": "Message role filter. Default any."
817
909
  },
910
+ "tags": {
911
+ "type": "array",
912
+ "items": { "type": "string" },
913
+ "maxItems": 8,
914
+ "description": "Tags from session_tag_list. Filter sessions that have these labels."
915
+ },
916
+ "tagMatch": {
917
+ "type": "string",
918
+ "enum": ["any", "all"],
919
+ "description": "any = at least one listed tag (default). all = every listed tag. Ignored when tags is omitted."
920
+ },
818
921
  "projectId": {
819
922
  "type": "string",
820
923
  "description": "Search this SuperOne project id only (from project_list). Mutually exclusive with allProjects. Default: current project."
@@ -838,14 +941,14 @@ var init_host_action_superone_descriptors = __esm({
838
941
  },
839
942
  {
840
943
  "name": "session_read",
841
- "description": "Read any SuperOne session's saved transcript by id (any project; harness-agnostic content; does not resume provider threads). Views: meta | user | assistant | text | tools | tool_detail. user/assistant/text are pure conversation (no tool lines; assistant/text include toolCount). tools = index; tool_detail needs toolUseId. Paginate with limit/cursor; anchor with messageId/around. Prefer user then on-demand assistant/tools. meta includes projectId (use project_list for path/name).",
944
+ "description": "Read another SuperOne session's saved transcript by id (any project; harness-agnostic; does not resume provider threads). Do not read the current session \u2014 it is already in your context. Views: meta | user | assistant | text | tools | tool_detail. user/assistant/text are pure conversation (no tool lines; assistant/text include toolCount). tools = index; tool_detail needs toolUseId. Paginate with limit/cursor; anchor with messageId/around. Prefer user then on-demand assistant/tools. meta includes projectId and tags.",
842
945
  "inputSchema": {
843
946
  "type": "object",
844
947
  "properties": {
845
948
  "sessionId": {
846
949
  "type": "string",
847
950
  "minLength": 1,
848
- "description": "Target SuperOne session id from session_list or session_search (any project)."
951
+ "description": "Target SuperOne session id from session_list or session_search (any project). Do not pass the current session."
849
952
  },
850
953
  "view": {
851
954
  "type": "string",
@@ -9691,6 +9794,8 @@ var init_superone_host_owned_tools = __esm({
9691
9794
  "miniapp_dev_pack",
9692
9795
  "miniapp_dev_update_types",
9693
9796
  "session_rename",
9797
+ "session_tag",
9798
+ "session_tag_list",
9694
9799
  "project_list",
9695
9800
  "session_list",
9696
9801
  "session_search",
@@ -13190,6 +13295,10 @@ var init_session_runtime = __esm({
13190
13295
  session.isUserRenamed = false;
13191
13296
  changed = true;
13192
13297
  }
13298
+ if (!Array.isArray(session.tags)) {
13299
+ session.tags = [];
13300
+ changed = true;
13301
+ }
13193
13302
  if (session.isAutomation !== true && session.isAutomation !== false) {
13194
13303
  session.isAutomation = false;
13195
13304
  changed = true;
@@ -13264,6 +13373,7 @@ var init_session_runtime = __esm({
13264
13373
  isPinned: false,
13265
13374
  isHidden: false,
13266
13375
  isUserRenamed: false,
13376
+ tags: [],
13267
13377
  controllerClientSessionId: controller,
13268
13378
  hostActionCapabilityVersion: controller ? input.hostActionCapabilityVersion ?? HOST_ACTION_CAPABILITY_VERSION : 0,
13269
13379
  hostActionToolGroups: controller ? input.hostActionToolGroups ?? [...DEFAULT_HOST_ACTION_TOOL_GROUPS] : [],
@@ -13455,6 +13565,7 @@ var init_session_runtime = __esm({
13455
13565
  isHidden: false,
13456
13566
  // Fork title is derived; start unlocked so agent can rename the fork.
13457
13567
  isUserRenamed: false,
13568
+ tags: [],
13458
13569
  // Fork inherits controller binding (same paired desktop).
13459
13570
  controllerClientSessionId: source.controllerClientSessionId,
13460
13571
  hostActionCapabilityVersion: source.hostActionCapabilityVersion,
@@ -13927,6 +14038,17 @@ var init_session_runtime = __esm({
13927
14038
  });
13928
14039
  return this.clone(session);
13929
14040
  }
14041
+ setTags(sessionId, tags) {
14042
+ const session = this.live.get(sessionId);
14043
+ if (!session) throw Object.assign(new Error("session not found"), { code: "not_found" });
14044
+ if (session.closed) {
14045
+ throw Object.assign(new Error("session is closed"), { code: "failed_precondition" });
14046
+ }
14047
+ session.tags = [...tags];
14048
+ session.updatedAt = Date.now();
14049
+ this.persist(session);
14050
+ return this.clone(session);
14051
+ }
13930
14052
  setUiFlags(sessionId, flags) {
13931
14053
  const session = this.live.get(sessionId);
13932
14054
  if (!session) throw Object.assign(new Error("session not found"), { code: "not_found" });
@@ -14789,6 +14911,7 @@ var init_session_runtime = __esm({
14789
14911
  transcript: s2.transcript.map((t) => ({ ...t })),
14790
14912
  pendingInteraction: s2.pendingInteraction ? { ...s2.pendingInteraction } : null,
14791
14913
  isUserRenamed: s2.isUserRenamed === true,
14914
+ tags: [...s2.tags ?? []],
14792
14915
  controllerClientSessionId: s2.controllerClientSessionId ?? null,
14793
14916
  hostActionCapabilityVersion: s2.hostActionCapabilityVersion ?? 0,
14794
14917
  hostActionToolGroups: [...s2.hostActionToolGroups ?? []],
@@ -14989,7 +15112,8 @@ function createSqliteSessionStore(db) {
14989
15112
  COALESCE(always_allowed_tools_json, '[]') AS always_allowed_tools_json,
14990
15113
  settings_json,
14991
15114
  COALESCE(is_automation, 0) AS is_automation,
14992
- automation_id
15115
+ automation_id,
15116
+ COALESCE(tags_json, '[]') AS tags_json
14993
15117
  FROM sessions`
14994
15118
  ).all();
14995
15119
  const parseStringArray = (raw) => {
@@ -15028,7 +15152,8 @@ function createSqliteSessionStore(db) {
15028
15152
  hostActionToolGroups: parseStringArray(r.host_action_tool_groups_json),
15029
15153
  alwaysAllowedTools: parseStringArray(r.always_allowed_tools_json),
15030
15154
  isAutomation: r.is_automation === 1,
15031
- automationId: r.automation_id ?? null
15155
+ automationId: r.automation_id ?? null,
15156
+ tags: parseStringArray(r.tags_json)
15032
15157
  };
15033
15158
  });
15034
15159
  },
@@ -15039,8 +15164,8 @@ function createSqliteSessionStore(db) {
15039
15164
  pending_interaction_json, provider_resume, cwd, created_at, updated_at, is_pinned, is_hidden,
15040
15165
  is_user_renamed,
15041
15166
  controller_client_session_id, host_action_capability_version, host_action_tool_groups_json,
15042
- always_allowed_tools_json, settings_json, is_automation, automation_id)
15043
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
15167
+ always_allowed_tools_json, settings_json, is_automation, automation_id, tags_json)
15168
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
15044
15169
  ON CONFLICT(session_id) DO UPDATE SET
15045
15170
  title = excluded.title,
15046
15171
  status = excluded.status,
@@ -15058,7 +15183,8 @@ function createSqliteSessionStore(db) {
15058
15183
  always_allowed_tools_json = excluded.always_allowed_tools_json,
15059
15184
  settings_json = excluded.settings_json,
15060
15185
  is_automation = excluded.is_automation,
15061
- automation_id = excluded.automation_id`
15186
+ automation_id = excluded.automation_id,
15187
+ tags_json = excluded.tags_json`
15062
15188
  ).run(
15063
15189
  session.sessionId,
15064
15190
  session.projectId,
@@ -15081,7 +15207,8 @@ function createSqliteSessionStore(db) {
15081
15207
  JSON.stringify(session.alwaysAllowedTools ?? []),
15082
15208
  serializeSettingsJson(session),
15083
15209
  session.isAutomation ? 1 : 0,
15084
- session.automationId ?? null
15210
+ session.automationId ?? null,
15211
+ JSON.stringify(session.tags ?? [])
15085
15212
  );
15086
15213
  },
15087
15214
  delete(sessionId) {
@@ -42431,13 +42558,13 @@ var init_tool_normalization = __esm({
42431
42558
  // ../../packages/shared/src/session-archive-result-shape.ts
42432
42559
  function isSessionArchiveToolName(toolName) {
42433
42560
  if (!toolName) return false;
42434
- return /(?:^|__)(?:project_list|session_(?:list|search|read|cleanup))$/.test(toolName);
42561
+ return /(?:^|__)(?:project_list|session_(?:list|search|read|cleanup|tag_list))$/.test(toolName);
42435
42562
  }
42436
42563
  function looksLikeSessionArchiveToon(summary) {
42437
- return /(?:^|\n)(?:projects|sessions|hits)\[\d+\]/.test(summary.trim());
42564
+ return /(?:^|\n)(?:projects|sessions|hits|tags)\[\d+\]/.test(summary.trim());
42438
42565
  }
42439
42566
  function looksLikeSessionArchiveJson(obj) {
42440
- return Array.isArray(obj.sessions) || Array.isArray(obj.hits) || Array.isArray(obj.projects) || typeof obj.action === "string" && (Array.isArray(obj.deleted) || Array.isArray(obj.affected) || Array.isArray(obj.candidates) || Array.isArray(obj.failed));
42567
+ return Array.isArray(obj.sessions) || Array.isArray(obj.hits) || Array.isArray(obj.projects) || Array.isArray(obj.tags) || typeof obj.action === "string" && (Array.isArray(obj.deleted) || Array.isArray(obj.affected) || Array.isArray(obj.candidates) || Array.isArray(obj.failed));
42441
42568
  }
42442
42569
  var init_session_archive_result_shape = __esm({
42443
42570
  "../../packages/shared/src/session-archive-result-shape.ts"() {
@@ -51316,6 +51443,139 @@ var init_cursor_sdk_available = __esm({
51316
51443
  }
51317
51444
  });
51318
51445
 
51446
+ // ../../packages/cursor/src/cursor-platform-binaries.ts
51447
+ import { existsSync as existsSync21, statSync as statSync5 } from "node:fs";
51448
+ import { createRequire as createRequire3 } from "node:module";
51449
+ import { dirname as dirname11, join as join18 } from "node:path";
51450
+ function cursorPlatformPackageName(platform2 = process.platform, arch2 = process.arch) {
51451
+ return `@cursor/sdk-${platform2}-${arch2}`;
51452
+ }
51453
+ function toUnpackedAsarPath(filePath) {
51454
+ return filePath.replace(/app\.asar([\\/])/, "app.asar.unpacked$1");
51455
+ }
51456
+ function isExecutableFile(candidate) {
51457
+ try {
51458
+ const st = statSync5(candidate);
51459
+ if (!st.isFile()) return false;
51460
+ if (process.platform === "win32") return true;
51461
+ return (st.mode & 73) !== 0;
51462
+ } catch {
51463
+ return false;
51464
+ }
51465
+ }
51466
+ function cursorSdkRequire() {
51467
+ try {
51468
+ return createRequire3(requireFromHere.resolve("@cursor/sdk/package.json"));
51469
+ } catch {
51470
+ return requireFromHere;
51471
+ }
51472
+ }
51473
+ function resolveCursorPlatformRoot() {
51474
+ const name = cursorPlatformPackageName();
51475
+ const req = cursorSdkRequire();
51476
+ try {
51477
+ const pkgJson = toUnpackedAsarPath(req.resolve(`${name}/package.json`));
51478
+ return existsSync21(pkgJson) ? dirname11(pkgJson) : null;
51479
+ } catch {
51480
+ return null;
51481
+ }
51482
+ }
51483
+ function platformBinName(base) {
51484
+ return process.platform === "win32" ? `${base}.exe` : base;
51485
+ }
51486
+ function resolveCursorSandboxBinary() {
51487
+ const root = resolveCursorPlatformRoot();
51488
+ if (!root) return null;
51489
+ const bin = join18(root, "bin", platformBinName("cursorsandbox"));
51490
+ return isExecutableFile(bin) ? bin : null;
51491
+ }
51492
+ function resolveCursorRipgrepBinary() {
51493
+ const root = resolveCursorPlatformRoot();
51494
+ if (!root) return null;
51495
+ const bin = join18(root, "bin", platformBinName("rg"));
51496
+ return isExecutableFile(bin) ? bin : null;
51497
+ }
51498
+ function resolveCursorTreeSitterVendorDir() {
51499
+ const root = resolveCursorPlatformRoot();
51500
+ if (!root) return null;
51501
+ const vendor = join18(root, "vendor");
51502
+ return existsSync21(join18(vendor, "tree-sitter", "index.js")) ? vendor : null;
51503
+ }
51504
+ function sandboxExecAvailable() {
51505
+ try {
51506
+ statSync5("/usr/bin/sandbox-exec");
51507
+ return true;
51508
+ } catch {
51509
+ return false;
51510
+ }
51511
+ }
51512
+ function isCursorLocalSandboxSupported(probe = {}) {
51513
+ const platform2 = probe.platform ?? process.platform;
51514
+ if (platform2 === "win32") return false;
51515
+ const binary = probe.sandboxBinary !== void 0 ? probe.sandboxBinary : resolveCursorSandboxBinary();
51516
+ if (!binary) return false;
51517
+ if (platform2 === "darwin") {
51518
+ const execOk = probe.sandboxExecExists ?? sandboxExecAvailable();
51519
+ return execOk;
51520
+ }
51521
+ return true;
51522
+ }
51523
+ function resolveCursorSandboxEnabled(requested, probe) {
51524
+ return requested && isCursorLocalSandboxSupported(probe);
51525
+ }
51526
+ function isCursorSandboxUnsupportedError(error51) {
51527
+ const message = error51 instanceof Error ? error51.message : String(error51);
51528
+ return /sandboxing is not supported/i.test(message);
51529
+ }
51530
+ function primeHelperEnv() {
51531
+ if (!process.env.CURSOR_RIPGREP_PATH) {
51532
+ const rg = resolveCursorRipgrepBinary();
51533
+ if (rg) process.env.CURSOR_RIPGREP_PATH = rg;
51534
+ }
51535
+ if (!process.env.CURSOR_TREE_SITTER_VENDOR_DIR) {
51536
+ const vendor = resolveCursorTreeSitterVendorDir();
51537
+ if (vendor) process.env.CURSOR_TREE_SITTER_VENDOR_DIR = vendor;
51538
+ }
51539
+ }
51540
+ function beginPlatformLookup() {
51541
+ if (lookupDepth === 0) {
51542
+ savedArgv1 = process.argv[1];
51543
+ const root = resolveCursorPlatformRoot();
51544
+ if (root) process.argv[1] = join18(root, "package.json");
51545
+ primeHelperEnv();
51546
+ }
51547
+ lookupDepth += 1;
51548
+ return () => {
51549
+ lookupDepth = Math.max(0, lookupDepth - 1);
51550
+ if (lookupDepth === 0 && savedArgv1 !== void 0) {
51551
+ process.argv[1] = savedArgv1;
51552
+ savedArgv1 = void 0;
51553
+ }
51554
+ };
51555
+ }
51556
+ function withCursorPlatformLookup(fn) {
51557
+ const restore = beginPlatformLookup();
51558
+ try {
51559
+ const result = fn();
51560
+ if (result && typeof result.then === "function") {
51561
+ return result.finally(restore);
51562
+ }
51563
+ restore();
51564
+ return result;
51565
+ } catch (error51) {
51566
+ restore();
51567
+ throw error51;
51568
+ }
51569
+ }
51570
+ var requireFromHere, lookupDepth, savedArgv1;
51571
+ var init_cursor_platform_binaries = __esm({
51572
+ "../../packages/cursor/src/cursor-platform-binaries.ts"() {
51573
+ "use strict";
51574
+ requireFromHere = createRequire3(import.meta.url);
51575
+ lookupDepth = 0;
51576
+ }
51577
+ });
51578
+
51319
51579
  // ../../packages/cursor/src/cursor-mcp-map.ts
51320
51580
  function mcpServersToStatus(servers) {
51321
51581
  return Object.keys(servers).map((name) => ({ name, status: "connected" }));
@@ -51841,7 +52101,7 @@ var init_cursor_event_map = __esm({
51841
52101
  import Database2 from "better-sqlite3";
51842
52102
  import { mkdirSync as mkdirSync11 } from "node:fs";
51843
52103
  import { createHash as createHash4 } from "node:crypto";
51844
- import { join as join18 } from "node:path";
52104
+ import { join as join19 } from "node:path";
51845
52105
  function workspaceHash(workspaceRef) {
51846
52106
  return createHash4("md5").update(workspaceRef).digest("hex");
51847
52107
  }
@@ -51884,7 +52144,7 @@ var init_cursor_store = __esm({
51884
52144
  runEvents;
51885
52145
  db;
51886
52146
  constructor(dbPath) {
51887
- mkdirSync11(join18(dbPath, ".."), { recursive: true });
52147
+ mkdirSync11(join19(dbPath, ".."), { recursive: true });
51888
52148
  this.db = new Database2(dbPath);
51889
52149
  this.db.pragma("journal_mode = WAL");
51890
52150
  this.migrate();
@@ -51894,9 +52154,9 @@ var init_cursor_store = __esm({
51894
52154
  this.runEvents = this.createRunEvents();
51895
52155
  }
51896
52156
  static openForWorkspace(userDataRoot, workspaceRef) {
51897
- const dir = join18(userDataRoot, "cursor-sdk", workspaceHash(workspaceRef));
52157
+ const dir = join19(userDataRoot, "cursor-sdk", workspaceHash(workspaceRef));
51898
52158
  mkdirSync11(dir, { recursive: true });
51899
- return new _BetterSqliteLocalAgentStore(join18(dir, "agent-store.db"));
52159
+ return new _BetterSqliteLocalAgentStore(join19(dir, "agent-store.db"));
51900
52160
  }
51901
52161
  dispose() {
51902
52162
  this.db.close();
@@ -52374,6 +52634,126 @@ var init_cursor_sdk_auth = __esm({
52374
52634
  }
52375
52635
  });
52376
52636
 
52637
+ // ../../packages/cursor/src/cursor-local-options.ts
52638
+ function resolveCursorLocalSessionPlan(input) {
52639
+ const config2 = readCursorConfig(input.config);
52640
+ const resolveApiKey = input.resolveApiKey ?? resolveCursorApiKeyPlain;
52641
+ const buildMcpServers = input.buildMcpServers ?? (() => ({}));
52642
+ const isCloud = config2.runtime === "cloud" || (input.providerSessionId?.startsWith("bc-") ?? false);
52643
+ const perm = mapPermissionToCursorLocal(input.permissionMode);
52644
+ const settingSources = config2.settingSources ?? DEFAULT_CURSOR_SETTING_SOURCES;
52645
+ const sandboxRequested = input.sandboxEnabled ?? config2.sandboxEnabled ?? false;
52646
+ const sandboxEnabled = isCloud ? false : resolveCursorSandboxEnabled(sandboxRequested);
52647
+ const mcpServers = isCloud ? stripStdioCwd(buildMcpServers(input.cwd, input.sessionId)) : buildMcpServers(input.cwd, input.sessionId);
52648
+ return {
52649
+ apiKey: resolveApiKey(input.config),
52650
+ config: config2,
52651
+ isCloud,
52652
+ settingSources,
52653
+ sandboxEnabled,
52654
+ sandboxRequested,
52655
+ perm,
52656
+ enableAgentRetries: config2.enableAgentRetries ?? true,
52657
+ mcpServers
52658
+ };
52659
+ }
52660
+ var DEFAULT_CURSOR_SETTING_SOURCES;
52661
+ var init_cursor_local_options = __esm({
52662
+ "../../packages/cursor/src/cursor-local-options.ts"() {
52663
+ "use strict";
52664
+ init_cursor_config();
52665
+ init_cursor_platform_binaries();
52666
+ init_cursor_mcp_map();
52667
+ DEFAULT_CURSOR_SETTING_SOURCES = ["project", "user"];
52668
+ }
52669
+ });
52670
+
52671
+ // ../../packages/cursor/src/cursor-network-retry.ts
52672
+ import { NetworkError } from "@cursor/sdk";
52673
+ function isCursorRetryableNetworkError(error51) {
52674
+ if (error51 instanceof NetworkError) return error51.isRetryable;
52675
+ if (!error51 || typeof error51 !== "object") return false;
52676
+ const name = "name" in error51 ? String(error51.name) : "";
52677
+ if (name !== "NetworkError") return false;
52678
+ if (!("isRetryable" in error51)) return true;
52679
+ return Boolean(error51.isRetryable);
52680
+ }
52681
+ function defaultSleep(ms) {
52682
+ return new Promise((resolve13) => {
52683
+ setTimeout(resolve13, ms);
52684
+ });
52685
+ }
52686
+ async function withCursorNetworkRetries(fn, opts) {
52687
+ const retries = opts?.retries ?? CURSOR_NETWORK_RETRY_ATTEMPTS;
52688
+ const baseDelayMs = opts?.baseDelayMs ?? CURSOR_NETWORK_RETRY_BASE_DELAY_MS;
52689
+ const maxDelayMs = opts?.maxDelayMs ?? CURSOR_NETWORK_RETRY_MAX_DELAY_MS;
52690
+ const sleep = opts?.sleep ?? defaultSleep;
52691
+ let lastError;
52692
+ for (let attempt = 0; attempt <= retries; attempt++) {
52693
+ try {
52694
+ return await fn();
52695
+ } catch (error51) {
52696
+ lastError = error51;
52697
+ if (!isCursorRetryableNetworkError(error51) || attempt === retries) throw error51;
52698
+ const delayMs = Math.min(baseDelayMs * 2 ** attempt, maxDelayMs);
52699
+ opts?.onRetry?.({ attempt: attempt + 1, retries, delayMs, error: error51 });
52700
+ await sleep(delayMs);
52701
+ }
52702
+ }
52703
+ throw lastError;
52704
+ }
52705
+ var CURSOR_NETWORK_RETRY_ATTEMPTS, CURSOR_NETWORK_RETRY_BASE_DELAY_MS, CURSOR_NETWORK_RETRY_MAX_DELAY_MS;
52706
+ var init_cursor_network_retry = __esm({
52707
+ "../../packages/cursor/src/cursor-network-retry.ts"() {
52708
+ "use strict";
52709
+ CURSOR_NETWORK_RETRY_ATTEMPTS = 5;
52710
+ CURSOR_NETWORK_RETRY_BASE_DELAY_MS = 2e3;
52711
+ CURSOR_NETWORK_RETRY_MAX_DELAY_MS = 8e3;
52712
+ }
52713
+ });
52714
+
52715
+ // ../../packages/cursor/src/cursor-sdk-trace.ts
52716
+ function createCursorSdkTracer(onSdkTrace) {
52717
+ const emit = (source, type, data, tag) => {
52718
+ if (!onSdkTrace) return;
52719
+ try {
52720
+ onSdkTrace(source, type, data, tag);
52721
+ } catch {
52722
+ }
52723
+ };
52724
+ return {
52725
+ sdk(type, data, tag) {
52726
+ emit("agent.sdk", type || "unknown", data, tag);
52727
+ },
52728
+ runtime(type, data, tag) {
52729
+ emit("cursor.runtime", type || "unknown", data, tag);
52730
+ }
52731
+ };
52732
+ }
52733
+ function cursorSdkType(value, fallback) {
52734
+ if (!value || typeof value !== "object") return fallback;
52735
+ const type = value.type;
52736
+ return typeof type === "string" && type ? type : fallback;
52737
+ }
52738
+ function cursorUserSendTracePayload(message) {
52739
+ if (typeof message === "string") return { text: message };
52740
+ if (!message || typeof message !== "object") return message;
52741
+ const rec = message;
52742
+ if (!Array.isArray(rec.images)) return message;
52743
+ return {
52744
+ text: rec.text,
52745
+ images: rec.images.map((img) => ({
52746
+ mimeType: typeof img?.mimeType === "string" ? img.mimeType : "",
52747
+ bytes: typeof img?.data === "string" ? img.data.length : 0
52748
+ }))
52749
+ };
52750
+ }
52751
+ var init_cursor_sdk_trace = __esm({
52752
+ "../../packages/cursor/src/cursor-sdk-trace.ts"() {
52753
+ "use strict";
52754
+ }
52755
+ });
52756
+
52377
52757
  // ../../packages/cursor/src/cursor-runtime.ts
52378
52758
  import {
52379
52759
  Agent as Agent4,
@@ -52402,41 +52782,63 @@ async function createCursorRuntime(opts) {
52402
52782
  error: opts.log?.error ?? noopLog.error,
52403
52783
  debug: opts.log?.debug ?? noopLog.debug
52404
52784
  };
52405
- const resolveApiKey = opts.resolveApiKey ?? resolveCursorApiKeyPlain;
52406
- const buildMcpServers = opts.buildMcpServers ?? (() => ({}));
52407
- const config2 = readCursorConfig(opts.config);
52408
- const apiKey = resolveApiKey(opts.config);
52785
+ const tracer = createCursorSdkTracer(opts.onSdkTrace);
52786
+ const plan = resolveCursorLocalSessionPlan(opts);
52787
+ const apiKey = plan.apiKey;
52409
52788
  if (!apiKey) {
52410
52789
  throw new Error(
52411
52790
  "Cursor User API Key missing. Create one at https://cursor.com/dashboard/api, set it on the Cursor provider, or export CURSOR_API_KEY."
52412
52791
  );
52413
52792
  }
52414
- if (config2.useHttp1ForAgent != null) {
52793
+ if (plan.config.useHttp1ForAgent != null) {
52415
52794
  try {
52416
- Cursor4.configure({ local: { useHttp1ForAgent: config2.useHttp1ForAgent } });
52795
+ Cursor4.configure({ local: { useHttp1ForAgent: plan.config.useHttp1ForAgent } });
52417
52796
  } catch (error51) {
52418
52797
  log2.debug("[CursorRuntime] Cursor.configure useHttp1ForAgent failed:", error51);
52419
52798
  }
52420
52799
  }
52421
- const isCloud = config2.runtime === "cloud" || (opts.providerSessionId?.startsWith("bc-") ?? false);
52422
- const modelId = opts.modelSelection?.id || opts.model || config2.model;
52800
+ const isCloud = plan.isCloud;
52801
+ const modelId = opts.modelSelection?.id || opts.model || plan.config.model;
52423
52802
  if (!isCloud && !modelId) {
52424
52803
  throw new Error("Cursor model is required for local agents. Connect Cursor to load models, then select one.");
52425
52804
  }
52426
- const perm = mapPermissionToCursorLocal(opts.permissionMode);
52805
+ const perm = plan.perm;
52427
52806
  const model = opts.modelSelection ?? (modelId ? { id: modelId } : void 0);
52428
- const settingSources = config2.settingSources ?? ["project", "user"];
52429
- const sandboxEnabled = opts.sandboxEnabled ?? config2.sandboxEnabled ?? false;
52430
- const mcpServers = isCloud ? stripStdioCwd(buildMcpServers(opts.cwd, opts.sessionId)) : buildMcpServers(opts.cwd, opts.sessionId);
52807
+ const settingSources = plan.settingSources;
52808
+ let sandboxEnabled = plan.sandboxEnabled;
52809
+ if (plan.sandboxRequested && !sandboxEnabled) {
52810
+ log2.warn(
52811
+ "[CursorRuntime] sandbox requested but Cursor local sandbox is unavailable; running unsandboxed"
52812
+ );
52813
+ }
52814
+ const mcpServers = plan.mcpServers;
52815
+ const config2 = plan.config;
52816
+ const buildMcpServers = opts.buildMcpServers ?? (() => ({}));
52431
52817
  const customTools = isCloud ? void 0 : buildCursorCustomTools({ sessionId: opts.sessionId, cwd: opts.cwd });
52432
52818
  const agentName = opts.agentName?.trim() || void 0;
52433
52819
  const toolRestrictions = isCloud ? {} : resolveCursorToolRestrictions(config2);
52434
52820
  const toolsOpt = toolRestrictions.tools ? { tools: toolRestrictions.tools } : {};
52435
52821
  const disallowedOpt = toolRestrictions.disallowedTools ? { disallowedTools: toolRestrictions.disallowedTools } : {};
52436
- let agent;
52437
- try {
52822
+ const createStarted = Date.now();
52823
+ log2.info("[CursorRuntime] opening agent", {
52824
+ sessionId: opts.sessionId,
52825
+ sandboxEnabled,
52826
+ mcpCount: Object.keys(mcpServers).length,
52827
+ settingSources
52828
+ });
52829
+ tracer.runtime("create_session", {
52830
+ sessionId: opts.sessionId,
52831
+ cwd: opts.cwd,
52832
+ sandboxEnabled,
52833
+ mcpCount: Object.keys(mcpServers).length,
52834
+ settingSources,
52835
+ resume: opts.providerSessionId ?? null,
52836
+ model: modelId ?? null,
52837
+ isCloud
52838
+ }, opts.sessionId);
52839
+ const openAgent = (sandbox) => withCursorPlatformLookup(async () => {
52438
52840
  if (opts.providerSessionId) {
52439
- agent = await Agent4.resume(opts.providerSessionId, {
52841
+ return Agent4.resume(opts.providerSessionId, {
52440
52842
  apiKey,
52441
52843
  ...model ? { model } : {},
52442
52844
  ...agentName ? { name: agentName } : {},
@@ -52449,16 +52851,17 @@ async function createCursorRuntime(opts) {
52449
52851
  cwd: opts.cwd,
52450
52852
  store: getCursorAgentStore(opts.userDataRoot, opts.cwd),
52451
52853
  settingSources,
52452
- sandboxOptions: { enabled: sandboxEnabled },
52854
+ sandboxOptions: { enabled: sandbox },
52453
52855
  // Session permission UI owns autoReview; static config must not override.
52454
52856
  autoReview: perm.autoReview,
52455
- enableAgentRetries: config2.enableAgentRetries ?? true,
52857
+ enableAgentRetries: plan.enableAgentRetries,
52456
52858
  ...customTools ? { customTools } : {}
52457
52859
  }
52458
52860
  }
52459
52861
  });
52460
- } else if (isCloud) {
52461
- agent = await Agent4.create({
52862
+ }
52863
+ if (isCloud) {
52864
+ return Agent4.create({
52462
52865
  apiKey,
52463
52866
  ...model ? { model } : {},
52464
52867
  ...agentName ? { name: agentName } : {},
@@ -52466,30 +52869,77 @@ async function createCursorRuntime(opts) {
52466
52869
  mcpServers,
52467
52870
  cloud: buildCloudOptions(config2)
52468
52871
  });
52469
- } else {
52470
- agent = await Agent4.create({
52471
- apiKey,
52472
- model,
52473
- ...agentName ? { name: agentName } : {},
52474
- mode: perm.mode,
52475
- mcpServers,
52476
- ...toolsOpt,
52477
- ...disallowedOpt,
52478
- local: {
52479
- cwd: opts.cwd,
52480
- store: getCursorAgentStore(opts.userDataRoot, opts.cwd),
52481
- settingSources,
52482
- sandboxOptions: { enabled: sandboxEnabled },
52483
- // Session permission UI owns autoReview; static config must not override.
52484
- autoReview: perm.autoReview,
52485
- enableAgentRetries: config2.enableAgentRetries ?? true,
52486
- ...customTools ? { customTools } : {}
52487
- }
52872
+ }
52873
+ return Agent4.create({
52874
+ apiKey,
52875
+ model,
52876
+ ...agentName ? { name: agentName } : {},
52877
+ mode: perm.mode,
52878
+ mcpServers,
52879
+ ...toolsOpt,
52880
+ ...disallowedOpt,
52881
+ local: {
52882
+ cwd: opts.cwd,
52883
+ store: getCursorAgentStore(opts.userDataRoot, opts.cwd),
52884
+ settingSources,
52885
+ sandboxOptions: { enabled: sandbox },
52886
+ // Session permission UI owns autoReview; static config must not override.
52887
+ autoReview: perm.autoReview,
52888
+ enableAgentRetries: plan.enableAgentRetries,
52889
+ ...customTools ? { customTools } : {}
52890
+ }
52891
+ });
52892
+ });
52893
+ const openAgentRetrying = (sandbox) => withCursorNetworkRetries(() => openAgent(sandbox), {
52894
+ onRetry: ({ attempt, retries, delayMs, error: error51 }) => {
52895
+ const message = error51 instanceof Error ? error51.message : String(error51);
52896
+ log2.warn("[CursorRuntime] retryable network error on Agent.create", {
52897
+ attempt,
52898
+ retries,
52899
+ delayMs,
52900
+ message
52488
52901
  });
52902
+ tracer.runtime("create_retry", {
52903
+ attempt,
52904
+ retries,
52905
+ delayMs,
52906
+ message,
52907
+ name: error51 instanceof Error ? error51.name : "Error"
52908
+ }, opts.sessionId);
52489
52909
  }
52910
+ });
52911
+ let agent;
52912
+ try {
52913
+ agent = await openAgentRetrying(sandboxEnabled);
52490
52914
  } catch (error51) {
52491
- throw formatCursorError(error51);
52915
+ if (!isCloud && sandboxEnabled && isCursorSandboxUnsupportedError(error51)) {
52916
+ log2.warn(
52917
+ "[CursorRuntime] Cursor SDK rejected local sandbox; retrying with sandbox disabled"
52918
+ );
52919
+ tracer.runtime("sandbox_fallback", {
52920
+ sessionId: opts.sessionId,
52921
+ message: error51 instanceof Error ? error51.message : String(error51)
52922
+ }, opts.sessionId);
52923
+ sandboxEnabled = false;
52924
+ try {
52925
+ agent = await openAgentRetrying(false);
52926
+ } catch (retryError) {
52927
+ throw formatCursorError(retryError);
52928
+ }
52929
+ } else {
52930
+ throw formatCursorError(error51);
52931
+ }
52492
52932
  }
52933
+ log2.info("[CursorRuntime] agent ready", {
52934
+ agentId: agent.agentId,
52935
+ ms: Date.now() - createStarted,
52936
+ sandboxEnabled
52937
+ });
52938
+ tracer.runtime("agent_ready", {
52939
+ agentId: agent.agentId,
52940
+ ms: Date.now() - createStarted,
52941
+ sandboxEnabled
52942
+ }, opts.sessionId);
52493
52943
  opts.onProviderSessionId?.(agent.agentId);
52494
52944
  opts.onEvent({ type: "provider_session_id", providerSessionId: agent.agentId });
52495
52945
  let currentRun = null;
@@ -52547,18 +52997,28 @@ async function createCursorRuntime(opts) {
52547
52997
  lastMcpServers = servers;
52548
52998
  const contextWindow = resolveContextWindow(modelSelection);
52549
52999
  const callIdBridge = new CursorTurnCallIdBridge();
53000
+ const sendStarted = Date.now();
53001
+ log2.info("[CursorRuntime] send start", { messageId });
53002
+ tracer.sdk("user_send", cursorUserSendTracePayload(userMessage2), messageId);
53003
+ tracer.runtime("send_start", {
53004
+ messageId,
53005
+ model: modelSelection?.id ?? null,
53006
+ force: Boolean(sendOpts?.force)
53007
+ }, messageId);
52550
53008
  const sendOptions = {
52551
53009
  ...modelSelection ? { model: modelSelection } : {},
52552
53010
  mode: permLocal.mode,
52553
53011
  mcpServers: Object.keys(servers).length ? servers : void 0,
52554
53012
  ...sendOpts?.idempotencyKey ? { idempotencyKey: sendOpts.idempotencyKey } : {},
52555
53013
  onDelta: ({ update }) => {
53014
+ tracer.sdk(cursorSdkType(update, "delta"), update, messageId);
52556
53015
  callIdBridge.observeDelta(update);
52557
53016
  for (const event of mapInteractionUpdate(messageId, update, { contextWindow })) {
52558
53017
  opts.onEvent(event);
52559
53018
  }
52560
53019
  },
52561
53020
  onStep: ({ step }) => {
53021
+ tracer.sdk(cursorSdkType(step, "step"), step, messageId);
52562
53022
  for (const event of mapConversationStep(messageId, step, {
52563
53023
  resolveCallId: () => callIdBridge.claimNextCallId()
52564
53024
  })) {
@@ -52579,28 +53039,54 @@ async function createCursorRuntime(opts) {
52579
53039
  } catch (error51) {
52580
53040
  if (error51 instanceof AgentBusyError && !sendOpts?.force && !isCloud) {
52581
53041
  log2.warn("[CursorRuntime] AgentBusyError \u2014 retrying with local.force");
53042
+ tracer.runtime("agent_busy_retry", {
53043
+ message: error51 instanceof Error ? error51.message : String(error51)
53044
+ }, messageId);
52582
53045
  try {
52583
53046
  run = await agent.send(userMessage2, {
52584
53047
  ...sendOptions,
52585
53048
  local: { force: true }
52586
53049
  });
52587
53050
  } catch (retryError) {
53051
+ tracer.runtime("send_error", {
53052
+ message: retryError instanceof Error ? retryError.message : String(retryError),
53053
+ name: retryError instanceof Error ? retryError.name : "Error",
53054
+ afterForce: true
53055
+ }, messageId);
52588
53056
  throw formatCursorError(retryError);
52589
53057
  }
52590
53058
  } else {
53059
+ tracer.runtime("send_error", {
53060
+ message: error51 instanceof Error ? error51.message : String(error51),
53061
+ name: error51 instanceof Error ? error51.name : "Error",
53062
+ ms: Date.now() - sendStarted
53063
+ }, messageId);
52591
53064
  throw formatCursorError(error51);
52592
53065
  }
52593
53066
  }
52594
53067
  currentRun = run;
52595
53068
  lastRunId = run.id;
52596
- log2.debug("[CursorRuntime] run started", { runId: run.id, agentId: run.agentId });
53069
+ log2.info("[CursorRuntime] run started", {
53070
+ runId: run.id,
53071
+ agentId: run.agentId,
53072
+ ms: Date.now() - sendStarted
53073
+ });
53074
+ tracer.runtime("run_started", {
53075
+ runId: run.id,
53076
+ agentId: run.agentId,
53077
+ ms: Date.now() - sendStarted
53078
+ }, messageId);
52597
53079
  void (async () => {
52598
53080
  try {
52599
53081
  if (!run.supports("stream")) {
52600
53082
  log2.debug("[CursorRuntime] stream unsupported:", run.unsupportedReason("stream"));
53083
+ tracer.runtime("stream_unsupported", {
53084
+ reason: run.unsupportedReason("stream") ?? null
53085
+ }, messageId);
52601
53086
  return;
52602
53087
  }
52603
53088
  for await (const message of run.stream()) {
53089
+ tracer.sdk(cursorSdkType(message, "stream"), message, messageId);
52604
53090
  for (const event of mapSdkMessageLifecycle(messageId, message, {
52605
53091
  includeContent: false,
52606
53092
  contextWindow
@@ -52610,9 +53096,23 @@ async function createCursorRuntime(opts) {
52610
53096
  }
52611
53097
  } catch (error51) {
52612
53098
  log2.debug("[CursorRuntime] stream consumer ended:", error51);
53099
+ tracer.runtime("stream_error", {
53100
+ message: error51 instanceof Error ? error51.message : String(error51),
53101
+ name: error51 instanceof Error ? error51.name : "Error"
53102
+ }, messageId);
52613
53103
  }
52614
53104
  })();
52615
- const result = await run.wait();
53105
+ let result;
53106
+ try {
53107
+ result = await run.wait();
53108
+ } catch (error51) {
53109
+ tracer.runtime("wait_error", {
53110
+ message: error51 instanceof Error ? error51.message : String(error51),
53111
+ name: error51 instanceof Error ? error51.name : "Error"
53112
+ }, messageId);
53113
+ throw formatCursorError(error51);
53114
+ }
53115
+ tracer.sdk("result", result, messageId);
52616
53116
  currentRun = null;
52617
53117
  lastRunId = result.id || lastRunId;
52618
53118
  if (result.usage) {
@@ -52689,10 +53189,14 @@ var init_cursor_runtime = __esm({
52689
53189
  "../../packages/cursor/src/cursor-runtime.ts"() {
52690
53190
  "use strict";
52691
53191
  init_cursor_config();
53192
+ init_cursor_local_options();
53193
+ init_cursor_network_retry();
52692
53194
  init_cursor_custom_tools();
52693
53195
  init_cursor_event_map();
52694
53196
  init_cursor_mcp_map();
52695
53197
  init_cursor_model_selection();
53198
+ init_cursor_platform_binaries();
53199
+ init_cursor_sdk_trace();
52696
53200
  init_cursor_store();
52697
53201
  noopLog = {
52698
53202
  info: () => void 0,
@@ -52713,6 +53217,25 @@ var init_cursor_runtime = __esm({
52713
53217
  }
52714
53218
  });
52715
53219
 
53220
+ // ../../packages/cursor/src/cursor-workspace-prewarm.ts
53221
+ import { createAgentPlatform } from "@cursor/sdk";
53222
+ var init_cursor_workspace_prewarm = __esm({
53223
+ "../../packages/cursor/src/cursor-workspace-prewarm.ts"() {
53224
+ "use strict";
53225
+ init_cursor_sdk_trace();
53226
+ init_cursor_local_options();
53227
+ init_cursor_platform_binaries();
53228
+ }
53229
+ });
53230
+
53231
+ // ../../packages/cursor/src/cursor-skills-discover.ts
53232
+ var init_cursor_skills_discover = __esm({
53233
+ "../../packages/cursor/src/cursor-skills-discover.ts"() {
53234
+ "use strict";
53235
+ init_fs();
53236
+ }
53237
+ });
53238
+
52716
53239
  // ../../packages/cursor/src/run-sdk-turn.ts
52717
53240
  async function runCursorSdkTurn(opts) {
52718
53241
  if (opts.signal?.aborted) {
@@ -52839,6 +53362,7 @@ var init_src5 = __esm({
52839
53362
  "use strict";
52840
53363
  init_cursor_config();
52841
53364
  init_cursor_sdk_available();
53365
+ init_cursor_platform_binaries();
52842
53366
  init_cursor_mcp_map();
52843
53367
  init_cursor_custom_tools();
52844
53368
  init_cursor_event_map();
@@ -52848,6 +53372,10 @@ var init_src5 = __esm({
52848
53372
  init_cursor_cloud();
52849
53373
  init_cursor_sdk_auth();
52850
53374
  init_cursor_runtime();
53375
+ init_cursor_sdk_trace();
53376
+ init_cursor_workspace_prewarm();
53377
+ init_cursor_skills_discover();
53378
+ init_cursor_network_retry();
52851
53379
  init_run_sdk_turn2();
52852
53380
  init_simulated_runner3();
52853
53381
  }
@@ -53061,7 +53589,7 @@ var init_codex_live_turn = __esm({
53061
53589
  });
53062
53590
 
53063
53591
  // src/session/codex-turn-runner.ts
53064
- import { existsSync as existsSync21 } from "node:fs";
53592
+ import { existsSync as existsSync22 } from "node:fs";
53065
53593
  function mapCodexReasoningEffort(effort) {
53066
53594
  if (!effort) return void 0;
53067
53595
  const e = effort.trim().toLowerCase();
@@ -53072,18 +53600,18 @@ function mapCodexReasoningEffort(effort) {
53072
53600
  return void 0;
53073
53601
  }
53074
53602
  function resolveCodexBinaryPath(opts) {
53075
- if (opts.binaryPath && existsSync21(opts.binaryPath)) return opts.binaryPath;
53603
+ if (opts.binaryPath && existsSync22(opts.binaryPath)) return opts.binaryPath;
53076
53604
  const fromEnv = process.env.SUPERONE_CODEX_BINARY?.trim();
53077
- if (fromEnv && existsSync21(fromEnv)) return fromEnv;
53605
+ if (fromEnv && existsSync22(fromEnv)) return fromEnv;
53078
53606
  const status = opts.harnesses?.get("codex");
53079
- if (status?.enabled && (status.state === "ready" || status.state === "needs_auth") && status.command && existsSync21(status.command)) {
53607
+ if (status?.enabled && (status.state === "ready" || status.state === "needs_auth") && status.command && existsSync22(status.command)) {
53080
53608
  return status.command;
53081
53609
  }
53082
53610
  return null;
53083
53611
  }
53084
53612
  function isCodexBinaryOverrideRunnable() {
53085
53613
  const fromEnv = process.env.SUPERONE_CODEX_BINARY?.trim();
53086
- return Boolean(fromEnv && existsSync21(fromEnv));
53614
+ return Boolean(fromEnv && existsSync22(fromEnv));
53087
53615
  }
53088
53616
  function providerEnvKeyOf(env) {
53089
53617
  return [
@@ -60528,8 +61056,8 @@ import { fileURLToPath } from "node:url";
60528
61056
  function resolveCliReleaseVersion() {
60529
61057
  const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
60530
61058
  if (fromEnv) return fromEnv;
60531
- if ("0.53.1-alpha".trim()) {
60532
- return "0.53.1-alpha".trim();
61059
+ if ("0.53.3-alpha".trim()) {
61060
+ return "0.53.3-alpha".trim();
60533
61061
  }
60534
61062
  const fromDist = readDistManifestVersion();
60535
61063
  if (fromDist) return fromDist;
@@ -60779,7 +61307,7 @@ function regenerateIdentity(nodeHome, label) {
60779
61307
  }
60780
61308
 
60781
61309
  // src/runtime.ts
60782
- import { existsSync as existsSync39, readFileSync as readFileSync19, writeFileSync as writeFileSync17 } from "node:fs";
61310
+ import { existsSync as existsSync40, readFileSync as readFileSync19, writeFileSync as writeFileSync17 } from "node:fs";
60783
61311
 
60784
61312
  // src/auth/auth-service.ts
60785
61313
  init_environment();
@@ -61249,7 +61777,8 @@ CREATE TABLE IF NOT EXISTS sessions (
61249
61777
  settings_json TEXT,
61250
61778
  -- Automation ownership markers (filterable in session.list metadata)
61251
61779
  is_automation INTEGER NOT NULL DEFAULT 0,
61252
- automation_id TEXT
61780
+ automation_id TEXT,
61781
+ tags_json TEXT NOT NULL DEFAULT '[]'
61253
61782
  );
61254
61783
 
61255
61784
  -- Host Action channel (durable poll/claim/respond). Also ensured at open time.
@@ -61412,6 +61941,7 @@ function openNodeDatabase(dbPath) {
61412
61941
  ensureSessionSettingsColumn(db);
61413
61942
  ensureCollaborationTables(db);
61414
61943
  ensureAutomationsSupport(db);
61944
+ ensureSessionTagsColumn(db);
61415
61945
  ensureSessionProvidersSupport(db);
61416
61946
  const row = db.prepare("SELECT value FROM meta WHERE key = ?").get("schema_generation");
61417
61947
  if (!row) {
@@ -61608,6 +62138,12 @@ CREATE TABLE IF NOT EXISTS session_collaboration_cursors (
61608
62138
  db.exec(`ALTER TABLE session_collaboration_grants ADD COLUMN kind TEXT NOT NULL DEFAULT 'spawn'`);
61609
62139
  }
61610
62140
  }
62141
+ function ensureSessionTagsColumn(db) {
62142
+ const cols = db.prepare(`PRAGMA table_info(sessions)`).all();
62143
+ if (!cols.some((c) => c.name === "tags_json")) {
62144
+ db.exec(`ALTER TABLE sessions ADD COLUMN tags_json TEXT NOT NULL DEFAULT '[]'`);
62145
+ }
62146
+ }
61611
62147
  function ensureAutomationsSupport(db) {
61612
62148
  const cols = db.prepare(`PRAGMA table_info(sessions)`).all();
61613
62149
  const names = new Set(cols.map((c) => c.name));
@@ -61682,6 +62218,86 @@ init_environment();
61682
62218
  // src/rpc/handlers.ts
61683
62219
  init_environment();
61684
62220
 
62221
+ // ../../packages/shared/src/session-tags.ts
62222
+ var SESSION_TAG_MAX_LENGTH = 32;
62223
+ var SESSION_TAG_MAX_PER_SESSION = 8;
62224
+ var TAG_CHAR = /^[\p{L}\p{N}]+(?:-[\p{L}\p{N}]+)*$/u;
62225
+ function normalizeSessionTag(raw) {
62226
+ const collapsed = raw.trim().toLowerCase().replace(/\s+/g, "-");
62227
+ if (!collapsed || collapsed.length > SESSION_TAG_MAX_LENGTH) return null;
62228
+ if (!TAG_CHAR.test(collapsed)) return null;
62229
+ return collapsed;
62230
+ }
62231
+ function normalizeSessionTagList(raw) {
62232
+ if (!Array.isArray(raw)) {
62233
+ return { error: "tags must be an array of strings" };
62234
+ }
62235
+ const out = [];
62236
+ const seen = /* @__PURE__ */ new Set();
62237
+ for (const item of raw) {
62238
+ if (typeof item !== "string") {
62239
+ return { error: "each tag must be a string" };
62240
+ }
62241
+ const tag = normalizeSessionTag(item);
62242
+ if (!tag) {
62243
+ return {
62244
+ error: `Invalid tag "${item}". Use 1\u2013${SESSION_TAG_MAX_LENGTH} letters, numbers, or hyphens (CJK allowed).`
62245
+ };
62246
+ }
62247
+ if (seen.has(tag)) continue;
62248
+ seen.add(tag);
62249
+ out.push(tag);
62250
+ if (out.length > SESSION_TAG_MAX_PER_SESSION) {
62251
+ return { error: `A session can have at most ${SESSION_TAG_MAX_PER_SESSION} tags.` };
62252
+ }
62253
+ }
62254
+ return { tags: out };
62255
+ }
62256
+ function parseSessionTagOp(args) {
62257
+ const present = [args.add !== void 0, args.remove !== void 0, args.set !== void 0].filter(Boolean).length;
62258
+ if (present === 0) {
62259
+ return { error: "Pass exactly one of add, remove, or set." };
62260
+ }
62261
+ if (present > 1) {
62262
+ return { error: "Pass exactly one of add, remove, or set \u2014 not more than one." };
62263
+ }
62264
+ if (args.set !== void 0) {
62265
+ const parsed2 = normalizeSessionTagList(args.set);
62266
+ if ("error" in parsed2) return parsed2;
62267
+ return { kind: "set", tags: parsed2.tags };
62268
+ }
62269
+ if (args.add !== void 0) {
62270
+ const parsed2 = normalizeSessionTagList(args.add);
62271
+ if ("error" in parsed2) return parsed2;
62272
+ if (parsed2.tags.length === 0) return { error: "add requires at least one tag." };
62273
+ return { kind: "add", tags: parsed2.tags };
62274
+ }
62275
+ const parsed = normalizeSessionTagList(args.remove);
62276
+ if ("error" in parsed) return parsed;
62277
+ if (parsed.tags.length === 0) return { error: "remove requires at least one tag." };
62278
+ return { kind: "remove", tags: parsed.tags };
62279
+ }
62280
+ function applySessionTagOp(current, op) {
62281
+ if (op.kind === "set") return op.tags;
62282
+ if (op.kind === "add") {
62283
+ const seen = new Set(current);
62284
+ const next = [...current];
62285
+ for (const tag of op.tags) {
62286
+ if (seen.has(tag)) continue;
62287
+ if (next.length >= SESSION_TAG_MAX_PER_SESSION) {
62288
+ return {
62289
+ error: `A session can have at most ${SESSION_TAG_MAX_PER_SESSION} tags. Remove some first.`
62290
+ };
62291
+ }
62292
+ seen.add(tag);
62293
+ next.push(tag);
62294
+ }
62295
+ return next;
62296
+ }
62297
+ const drop = new Set(op.tags);
62298
+ return current.filter((tag) => !drop.has(tag));
62299
+ }
62300
+
61685
62301
  // ../../packages/runtime/src/settings/node-agent-settings.ts
61686
62302
  import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
61687
62303
  import { dirname as dirname4 } from "node:path";
@@ -62185,11 +62801,11 @@ function parseState(raw) {
62185
62801
 
62186
62802
  // ../../packages/runtime/src/harness/home-path.ts
62187
62803
  import { homedir as homedir6 } from "node:os";
62188
- import { join as join19 } from "node:path";
62804
+ import { join as join20 } from "node:path";
62189
62805
  var HARNESS_HOME_DIRNAME = "harness";
62190
62806
  var SUPERONE_DIRNAME = ".superone";
62191
62807
  function defaultHarnessHomeRoot(userHome = homedir6()) {
62192
- return join19(userHome, SUPERONE_DIRNAME, HARNESS_HOME_DIRNAME);
62808
+ return join20(userHome, SUPERONE_DIRNAME, HARNESS_HOME_DIRNAME);
62193
62809
  }
62194
62810
  function resolveHarnessHomeRoot(opts = {}) {
62195
62811
  const explicit = opts.override?.trim();
@@ -62203,16 +62819,16 @@ function resolveHarnessHomeRoot(opts = {}) {
62203
62819
 
62204
62820
  // ../../packages/runtime/src/harness/managed-layout.ts
62205
62821
  import {
62206
- existsSync as existsSync22,
62822
+ existsSync as existsSync23,
62207
62823
  mkdirSync as mkdirSync12,
62208
62824
  readdirSync as readdirSync8,
62209
62825
  readFileSync as readFileSync13,
62210
62826
  renameSync as renameSync2,
62211
62827
  rmSync as rmSync2,
62212
- statSync as statSync5,
62828
+ statSync as statSync6,
62213
62829
  writeFileSync as writeFileSync9
62214
62830
  } from "node:fs";
62215
- import { join as join20 } from "node:path";
62831
+ import { join as join21 } from "node:path";
62216
62832
  import { randomBytes as randomBytes3 } from "node:crypto";
62217
62833
  var MANAGED_VERSIONS_DIRNAME = "versions";
62218
62834
  var MANAGED_CURRENT_BASENAME = "current";
@@ -62229,17 +62845,17 @@ function sanitizeRuntimeVersionForPath(runtimeVersion) {
62229
62845
  return v2;
62230
62846
  }
62231
62847
  function managedVersionsDir(prefix) {
62232
- return join20(prefix, MANAGED_VERSIONS_DIRNAME);
62848
+ return join21(prefix, MANAGED_VERSIONS_DIRNAME);
62233
62849
  }
62234
62850
  function managedVersionDir(prefix, runtimeVersion) {
62235
- return join20(managedVersionsDir(prefix), sanitizeRuntimeVersionForPath(runtimeVersion));
62851
+ return join21(managedVersionsDir(prefix), sanitizeRuntimeVersionForPath(runtimeVersion));
62236
62852
  }
62237
62853
  function managedCurrentPath(prefix) {
62238
- return join20(prefix, MANAGED_CURRENT_BASENAME);
62854
+ return join21(prefix, MANAGED_CURRENT_BASENAME);
62239
62855
  }
62240
62856
  function readCurrentPointer(prefix) {
62241
62857
  const path = managedCurrentPath(prefix);
62242
- if (!existsSync22(path)) return null;
62858
+ if (!existsSync23(path)) return null;
62243
62859
  try {
62244
62860
  const raw = JSON.parse(readFileSync13(path, "utf8"));
62245
62861
  if (typeof raw.runtimeVersion !== "string" || !raw.runtimeVersion.trim()) return null;
@@ -62265,7 +62881,7 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
62265
62881
  null,
62266
62882
  2
62267
62883
  );
62268
- const tmp = join20(
62884
+ const tmp = join21(
62269
62885
  prefix,
62270
62886
  `.${MANAGED_CURRENT_BASENAME}.${process.pid}.${randomBytes3(6).toString("hex")}.tmp`
62271
62887
  );
@@ -62274,7 +62890,7 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
62274
62890
  renameSync2(tmp, path);
62275
62891
  } catch {
62276
62892
  try {
62277
- if (existsSync22(path)) rmSync2(path, { force: true });
62893
+ if (existsSync23(path)) rmSync2(path, { force: true });
62278
62894
  renameSync2(tmp, path);
62279
62895
  } catch {
62280
62896
  writeFileSync9(path, body);
@@ -62286,26 +62902,26 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
62286
62902
  }
62287
62903
  }
62288
62904
  function resolveActiveInstallRoot(prefix) {
62289
- if (!prefix || !existsSync22(prefix)) return null;
62905
+ if (!prefix || !existsSync23(prefix)) return null;
62290
62906
  const pointer = readCurrentPointer(prefix);
62291
62907
  if (pointer) {
62292
- if (pointer.installRoot && existsSync22(pointer.installRoot) && statSync5(pointer.installRoot).isDirectory()) {
62908
+ if (pointer.installRoot && existsSync23(pointer.installRoot) && statSync6(pointer.installRoot).isDirectory()) {
62293
62909
  return pointer.installRoot;
62294
62910
  }
62295
62911
  const dir = managedVersionDir(prefix, pointer.runtimeVersion);
62296
- if (existsSync22(dir) && statSync5(dir).isDirectory()) return dir;
62912
+ if (existsSync23(dir) && statSync6(dir).isDirectory()) return dir;
62297
62913
  }
62298
62914
  const versionsRoot = managedVersionsDir(prefix);
62299
- if (existsSync22(versionsRoot)) {
62915
+ if (existsSync23(versionsRoot)) {
62300
62916
  try {
62301
62917
  const kids = readdirSync8(versionsRoot).filter((n) => {
62302
62918
  try {
62303
- return statSync5(join20(versionsRoot, n)).isDirectory();
62919
+ return statSync6(join21(versionsRoot, n)).isDirectory();
62304
62920
  } catch {
62305
62921
  return false;
62306
62922
  }
62307
62923
  });
62308
- if (kids.length === 1) return join20(versionsRoot, kids[0]);
62924
+ if (kids.length === 1) return join21(versionsRoot, kids[0]);
62309
62925
  } catch {
62310
62926
  }
62311
62927
  }
@@ -62313,7 +62929,7 @@ function resolveActiveInstallRoot(prefix) {
62313
62929
  }
62314
62930
  function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
62315
62931
  const versionsRoot = managedVersionsDir(prefix);
62316
- if (!existsSync22(versionsRoot)) return;
62932
+ if (!existsSync23(versionsRoot)) return;
62317
62933
  const keepSet = new Set(
62318
62934
  keep.filter(Boolean).map((v2) => {
62319
62935
  try {
@@ -62327,7 +62943,7 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
62327
62943
  try {
62328
62944
  entries = readdirSync8(versionsRoot).map((name) => {
62329
62945
  try {
62330
- const st = statSync5(join20(versionsRoot, name));
62946
+ const st = statSync6(join21(versionsRoot, name));
62331
62947
  if (!st.isDirectory()) return null;
62332
62948
  return { name, mtime: st.mtimeMs };
62333
62949
  } catch {
@@ -62346,7 +62962,7 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
62346
62962
  }
62347
62963
  for (const e of entries) {
62348
62964
  if (retain.has(e.name)) continue;
62349
- const dir = join20(versionsRoot, e.name);
62965
+ const dir = join21(versionsRoot, e.name);
62350
62966
  try {
62351
62967
  rmSync2(dir, { recursive: true, force: true });
62352
62968
  } catch {
@@ -62358,17 +62974,17 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
62358
62974
  import {
62359
62975
  copyFileSync,
62360
62976
  createReadStream,
62361
- existsSync as existsSync23,
62977
+ existsSync as existsSync24,
62362
62978
  mkdirSync as mkdirSync13,
62363
62979
  mkdtempSync,
62364
62980
  readFileSync as readFileSync14,
62365
62981
  renameSync as renameSync3,
62366
62982
  rmSync as rmSync3,
62367
- statSync as statSync6,
62983
+ statSync as statSync7,
62368
62984
  writeFileSync as writeFileSync10
62369
62985
  } from "node:fs";
62370
62986
  import { createHash as createHash5, randomBytes as randomBytes4 } from "node:crypto";
62371
- import { dirname as dirname11, join as join21, relative, resolve as resolve4, sep as sep3 } from "node:path";
62987
+ import { dirname as dirname12, join as join22, relative, resolve as resolve4, sep as sep3 } from "node:path";
62372
62988
  import { arch as osArch, platform as osPlatform } from "node:os";
62373
62989
  var releaseVersionProvider = null;
62374
62990
  function setHarnessReleaseVersionProvider(fn) {
@@ -62512,13 +63128,13 @@ function parseManagedHarnessPin(id, raw) {
62512
63128
  function loadHarnessReleaseManifest(nodeHome) {
62513
63129
  const fromEnv = process.env.SUPERONE_HARNESS_MANIFEST;
62514
63130
  if (fromEnv) {
62515
- if (!existsSync23(fromEnv)) {
63131
+ if (!existsSync24(fromEnv)) {
62516
63132
  throw new Error(`SUPERONE_HARNESS_MANIFEST not found: ${fromEnv}`);
62517
63133
  }
62518
63134
  return parseHarnessReleaseManifest(JSON.parse(readFileSync14(fromEnv, "utf8")));
62519
63135
  }
62520
- const local = join21(nodeHome, "release-manifest.json");
62521
- if (existsSync23(local)) {
63136
+ const local = join22(nodeHome, "release-manifest.json");
63137
+ if (existsSync24(local)) {
62522
63138
  return parseHarnessReleaseManifest(JSON.parse(readFileSync14(local, "utf8")));
62523
63139
  }
62524
63140
  return null;
@@ -62587,10 +63203,10 @@ async function installManagedArtifactFromFile(opts) {
62587
63203
  throw new Error(`release manifest does not pin managed harness ${opts.harnessId}`);
62588
63204
  }
62589
63205
  const art = selectArtifactPin(pin);
62590
- if (!existsSync23(opts.artifactPath)) {
63206
+ if (!existsSync24(opts.artifactPath)) {
62591
63207
  throw new Error(`artifact not found: ${opts.artifactPath}`);
62592
63208
  }
62593
- if (!statSync6(opts.artifactPath).isFile()) {
63209
+ if (!statSync7(opts.artifactPath).isFile()) {
62594
63210
  throw new Error(`artifact is not a regular file: ${opts.artifactPath}`);
62595
63211
  }
62596
63212
  const digest = await sha256File(opts.artifactPath);
@@ -62605,8 +63221,8 @@ async function installManagedArtifactFromFile(opts) {
62605
63221
  opts.harnessId,
62606
63222
  pin.artifactVersion
62607
63223
  );
62608
- const finalFile = join21(destDir, MANAGED_PAYLOAD_BASENAME);
62609
- const metaPath = join21(destDir, MANAGED_META_BASENAME);
63224
+ const finalFile = join22(destDir, MANAGED_PAYLOAD_BASENAME);
63225
+ const metaPath = join22(destDir, MANAGED_META_BASENAME);
62610
63226
  assertStrictChild(finalFile, destDir, "payload path");
62611
63227
  assertStrictChild(metaPath, destDir, "meta path");
62612
63228
  const metaBody = JSON.stringify(
@@ -62625,8 +63241,8 @@ async function installManagedArtifactFromFile(opts) {
62625
63241
  2
62626
63242
  );
62627
63243
  let reusedExisting = false;
62628
- if (existsSync23(destDir)) {
62629
- const payloadOk = existsSync23(finalFile) && statSync6(finalFile).isFile() && await sha256File(finalFile) === art.digestSha256;
63244
+ if (existsSync24(destDir)) {
63245
+ const payloadOk = existsSync24(finalFile) && statSync7(finalFile).isFile() && await sha256File(finalFile) === art.digestSha256;
62630
63246
  if (payloadOk) {
62631
63247
  reusedExisting = true;
62632
63248
  } else if (mode === "repair") {
@@ -62645,15 +63261,15 @@ async function installManagedArtifactFromFile(opts) {
62645
63261
  );
62646
63262
  }
62647
63263
  } else {
62648
- const harnessRoot2 = dirname11(destDir);
63264
+ const harnessRoot2 = dirname12(destDir);
62649
63265
  mkdirSync13(harnessRoot2, { recursive: true });
62650
63266
  assertPathInside(destDir, harnessRoot2, "version dir");
62651
63267
  const stagingDir = mkdtempSync(
62652
- join21(harnessRoot2, `.staging-${opts.harnessId}-${randomBytes4(8).toString("hex")}-`)
63268
+ join22(harnessRoot2, `.staging-${opts.harnessId}-${randomBytes4(8).toString("hex")}-`)
62653
63269
  );
62654
63270
  assertPathInside(stagingDir, harnessRoot2, "staging dir");
62655
- const stagingFile = join21(stagingDir, MANAGED_PAYLOAD_BASENAME);
62656
- const stagingMeta = join21(stagingDir, MANAGED_META_BASENAME);
63271
+ const stagingFile = join22(stagingDir, MANAGED_PAYLOAD_BASENAME);
63272
+ const stagingMeta = join22(stagingDir, MANAGED_META_BASENAME);
62657
63273
  try {
62658
63274
  copyFileSync(opts.artifactPath, stagingFile);
62659
63275
  const stagedDigest = await sha256File(stagingFile);
@@ -62664,7 +63280,7 @@ async function installManagedArtifactFromFile(opts) {
62664
63280
  renameSync3(stagingDir, destDir);
62665
63281
  } catch (err) {
62666
63282
  rmSync3(stagingDir, { recursive: true, force: true });
62667
- if (existsSync23(destDir) && existsSync23(finalFile)) {
63283
+ if (existsSync24(destDir) && existsSync24(finalFile)) {
62668
63284
  const existingDigest = await sha256File(finalFile);
62669
63285
  if (existingDigest === art.digestSha256) {
62670
63286
  reusedExisting = true;
@@ -62689,7 +63305,7 @@ async function installManagedArtifactFromFile(opts) {
62689
63305
  if (finalDigest !== art.digestSha256) {
62690
63306
  throw new Error(`final payload digest mismatch for ${opts.harnessId}`);
62691
63307
  }
62692
- const harnessRoot = join21(
63308
+ const harnessRoot = join22(
62693
63309
  releasesRoot(opts.nodeHome),
62694
63310
  opts.manifest.cliVersion,
62695
63311
  "harnesses",
@@ -62697,8 +63313,8 @@ async function installManagedArtifactFromFile(opts) {
62697
63313
  );
62698
63314
  assertPathInside(harnessRoot, releasesRoot(opts.nodeHome), "harness root");
62699
63315
  mkdirSync13(harnessRoot, { recursive: true });
62700
- const currentPath = join21(harnessRoot, MANAGED_CURRENT_BASENAME2);
62701
- const currentTmp = join21(
63316
+ const currentPath = join22(harnessRoot, MANAGED_CURRENT_BASENAME2);
63317
+ const currentTmp = join22(
62702
63318
  harnessRoot,
62703
63319
  `.${MANAGED_CURRENT_BASENAME2}.${process.pid}.${randomBytes4(6).toString("hex")}.tmp`
62704
63320
  );
@@ -62737,8 +63353,8 @@ async function installManagedArtifactFromFile(opts) {
62737
63353
  async function replacePayloadAtomically(opts) {
62738
63354
  mkdirSync13(opts.destDir, { recursive: true });
62739
63355
  const nonce = randomBytes4(8).toString("hex");
62740
- const payloadTmp = join21(opts.destDir, `.${MANAGED_PAYLOAD_BASENAME}.${nonce}.tmp`);
62741
- const metaTmp = join21(opts.destDir, `.${MANAGED_META_BASENAME}.${nonce}.tmp`);
63356
+ const payloadTmp = join22(opts.destDir, `.${MANAGED_PAYLOAD_BASENAME}.${nonce}.tmp`);
63357
+ const metaTmp = join22(opts.destDir, `.${MANAGED_META_BASENAME}.${nonce}.tmp`);
62742
63358
  assertStrictChild(payloadTmp, opts.destDir, "payload temp");
62743
63359
  assertStrictChild(metaTmp, opts.destDir, "meta temp");
62744
63360
  try {
@@ -62772,12 +63388,33 @@ function requiredRuntimeVersion(harnessId, manifest) {
62772
63388
  }
62773
63389
 
62774
63390
  // ../../packages/runtime/src/harness/managed-official.ts
62775
- import { existsSync as existsSync24, mkdirSync as mkdirSync14, readFileSync as readFileSync15, readdirSync as readdirSync9, statSync as statSync7, writeFileSync as writeFileSync11 } from "node:fs";
63391
+ import { existsSync as existsSync25, mkdirSync as mkdirSync14, readFileSync as readFileSync15, readdirSync as readdirSync9, statSync as statSync8, writeFileSync as writeFileSync11 } from "node:fs";
62776
63392
  import { arch as osArch2, platform as osPlatform2 } from "node:os";
62777
- import { join as join22, resolve as resolve5 } from "node:path";
63393
+ import { join as join23, resolve as resolve5 } from "node:path";
62778
63394
  var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.226";
62779
- var OFFICIAL_CODEX_NPM_VERSION = "0.146.1";
63395
+ var OFFICIAL_CODEX_NPM_VERSION = "0.147.0";
62780
63396
  var OFFICIAL_CODEX_PACKAGE = "@openai/codex";
63397
+ function codexPlatformPackageVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
63398
+ const platform2 = process.platform;
63399
+ const arch2 = process.arch;
63400
+ if (arch2 !== "arm64" && arch2 !== "x64") {
63401
+ throw new Error(`unsupported arch for Codex: ${arch2}`);
63402
+ }
63403
+ const suffix = platform2 === "darwin" ? `darwin-${arch2}` : platform2 === "linux" ? `linux-${arch2}` : platform2 === "win32" ? `win32-${arch2}` : null;
63404
+ if (!suffix) throw new Error(`unsupported platform for Codex: ${platform2}`);
63405
+ return `${baseVersion}-${suffix}`;
63406
+ }
63407
+ function codexTargetTriple() {
63408
+ const triples = {
63409
+ "darwin-arm64": "aarch64-apple-darwin",
63410
+ "darwin-x64": "x86_64-apple-darwin",
63411
+ "linux-arm64": "aarch64-unknown-linux-musl",
63412
+ "linux-x64": "x86_64-unknown-linux-musl",
63413
+ "win32-arm64": "aarch64-pc-windows-msvc",
63414
+ "win32-x64": "x86_64-pc-windows-msvc"
63415
+ };
63416
+ return triples[`${process.platform}-${process.arch}`] ?? null;
63417
+ }
62781
63418
  function managedHarnessPrefix(nodeHome, harnessId) {
62782
63419
  return resolve5(nodeHome, harnessId);
62783
63420
  }
@@ -62797,7 +63434,7 @@ function claudePlatformPackageName() {
62797
63434
  }
62798
63435
  function isMuslLinux() {
62799
63436
  try {
62800
- if (existsSync24("/etc/alpine-release")) return true;
63437
+ if (existsSync25("/etc/alpine-release")) return true;
62801
63438
  const lib = readdirSync9("/lib").some((n) => n.startsWith("ld-musl"));
62802
63439
  if (lib) return true;
62803
63440
  } catch {
@@ -62805,42 +63442,49 @@ function isMuslLinux() {
62805
63442
  return false;
62806
63443
  }
62807
63444
  function resolveOfficialInstallBinaryInRoot(harnessId, installRoot) {
62808
- if (!installRoot || !existsSync24(installRoot)) return null;
63445
+ if (!installRoot || !existsSync25(installRoot)) return null;
62809
63446
  if (harnessId === "codex") {
63447
+ const triple = codexTargetTriple();
63448
+ const nativeName = process.platform === "win32" ? "codex.exe" : "codex";
62810
63449
  const candidates = [
62811
- join22(installRoot, "bin", "codex"),
62812
- join22(installRoot, "bin", "codex.cmd"),
62813
- join22(installRoot, "lib", "node_modules", "@openai", "codex", "bin", "codex.js")
63450
+ join23(installRoot, "bin", "codex"),
63451
+ join23(installRoot, "bin", "codex.cmd"),
63452
+ join23(installRoot, "lib", "node_modules", "@openai", "codex", "bin", "codex.js"),
63453
+ join23(installRoot, "node_modules", "@openai", "codex", "bin", "codex.js"),
63454
+ ...triple ? [
63455
+ join23(installRoot, "lib", "node_modules", "@openai", "codex", "vendor", triple, "bin", nativeName),
63456
+ join23(installRoot, "node_modules", "@openai", "codex", "vendor", triple, "bin", nativeName)
63457
+ ] : []
62814
63458
  ];
62815
63459
  for (const c of candidates) {
62816
- if (existsSync24(c) && (c.endsWith(".js") || isExecutableFile(c))) return c;
63460
+ if (existsSync25(c) && (c.endsWith(".js") || isExecutableFile2(c))) return c;
62817
63461
  }
62818
63462
  return null;
62819
63463
  }
62820
- const nm = join22(installRoot, "lib", "node_modules");
62821
- const scoped = join22(nm, "@anthropic-ai");
63464
+ const nm = join23(installRoot, "lib", "node_modules");
63465
+ const scoped = join23(nm, "@anthropic-ai");
62822
63466
  try {
62823
- if (existsSync24(scoped)) {
63467
+ if (existsSync25(scoped)) {
62824
63468
  const names = readdirSync9(scoped).filter((n) => n.startsWith("claude-agent-sdk-"));
62825
63469
  for (const n of names) {
62826
63470
  const ext = process.platform === "win32" ? ".exe" : "";
62827
- const bin = join22(scoped, n, `claude${ext}`);
62828
- if (existsSync24(bin)) return bin;
63471
+ const bin = join23(scoped, n, `claude${ext}`);
63472
+ if (existsSync25(bin)) return bin;
62829
63473
  }
62830
63474
  }
62831
63475
  } catch {
62832
63476
  }
62833
- const direct = join22(
63477
+ const direct = join23(
62834
63478
  nm,
62835
63479
  ...claudePlatformPackageName().split("/"),
62836
63480
  process.platform === "win32" ? "claude.exe" : "claude"
62837
63481
  );
62838
- if (existsSync24(direct)) return direct;
63482
+ if (existsSync25(direct)) return direct;
62839
63483
  return null;
62840
63484
  }
62841
- function isExecutableFile(path) {
63485
+ function isExecutableFile2(path) {
62842
63486
  try {
62843
- const st = statSync7(path);
63487
+ const st = statSync8(path);
62844
63488
  if (!st.isFile()) return false;
62845
63489
  if (process.platform === "win32") return true;
62846
63490
  return (st.mode & 73) !== 0;
@@ -62850,7 +63494,7 @@ function isExecutableFile(path) {
62850
63494
  }
62851
63495
 
62852
63496
  // ../../packages/runtime/src/harness/tarball-fetch.ts
62853
- import { existsSync as existsSync25, rmSync as rmSync4 } from "node:fs";
63497
+ import { existsSync as existsSync26, rmSync as rmSync4 } from "node:fs";
62854
63498
  var NPM_REGISTRY = "https://registry.npmjs.org";
62855
63499
  function assertSha256(actualHex, expectedHex) {
62856
63500
  if (actualHex !== expectedHex.toLowerCase()) {
@@ -62868,7 +63512,7 @@ function assertSha512Integrity(actualBase64, integrity) {
62868
63512
  }
62869
63513
  function discardPartial(destPath) {
62870
63514
  try {
62871
- if (existsSync25(destPath)) rmSync4(destPath, { force: true });
63515
+ if (existsSync26(destPath)) rmSync4(destPath, { force: true });
62872
63516
  } catch {
62873
63517
  }
62874
63518
  }
@@ -62949,13 +63593,13 @@ import {
62949
63593
  appendFileSync,
62950
63594
  createReadStream as createReadStream2,
62951
63595
  createWriteStream,
62952
- existsSync as existsSync26,
63596
+ existsSync as existsSync27,
62953
63597
  mkdirSync as mkdirSync15,
62954
63598
  rmSync as rmSync5,
62955
- statSync as statSync8,
63599
+ statSync as statSync9,
62956
63600
  writeFileSync as writeFileSync12
62957
63601
  } from "node:fs";
62958
- import { dirname as dirname12 } from "node:path";
63602
+ import { dirname as dirname13 } from "node:path";
62959
63603
  import { pipeline } from "node:stream/promises";
62960
63604
  import { Readable as Readable2, Transform } from "node:stream";
62961
63605
  var HARNESS_PROGRESS_THROTTLE_MS = 200;
@@ -62984,7 +63628,7 @@ function parseContentRange(header) {
62984
63628
  async function seedHashesFromFile(path) {
62985
63629
  const sha256 = createHash6("sha256");
62986
63630
  const sha512 = createHash6("sha512");
62987
- const size = statSync8(path).size;
63631
+ const size = statSync9(path).size;
62988
63632
  if (size === 0) return { sha256, sha512, size };
62989
63633
  await new Promise((resolve13, reject) => {
62990
63634
  const stream = createReadStream2(path);
@@ -63016,7 +63660,7 @@ async function streamResponseToFile(res, destPath, onProgress, opts = {}) {
63016
63660
  const keepPartial = opts.keepPartialOnError !== false;
63017
63661
  const contentLen = Number(res.headers.get("content-length") ?? 0);
63018
63662
  const total = opts.totalBytes && opts.totalBytes > 0 ? opts.totalBytes : append ? resumeFrom + contentLen : contentLen;
63019
- mkdirSync15(dirname12(destPath), { recursive: true });
63663
+ mkdirSync15(dirname13(destPath), { recursive: true });
63020
63664
  const emit = createThrottledProgress(onProgress, opts.progressThrottleMs);
63021
63665
  let sha256;
63022
63666
  let sha512;
@@ -63074,7 +63718,7 @@ async function streamResponseToFile(res, destPath, onProgress, opts = {}) {
63074
63718
  } catch (err) {
63075
63719
  if (!keepPartial) {
63076
63720
  try {
63077
- if (existsSync26(destPath)) rmSync5(destPath, { force: true });
63721
+ if (existsSync27(destPath)) rmSync5(destPath, { force: true });
63078
63722
  } catch {
63079
63723
  }
63080
63724
  }
@@ -63118,14 +63762,14 @@ async function downloadResumableToFile(httpFetch, url2, destPath, onProgress, lo
63118
63762
  );
63119
63763
  }
63120
63764
  async function downloadResumableToFileUnlocked(httpFetch, url2, destPath, onProgress, log2) {
63121
- mkdirSync15(dirname12(destPath), { recursive: true });
63122
- let existing = existsSync26(destPath) ? statSync8(destPath).size : 0;
63765
+ mkdirSync15(dirname13(destPath), { recursive: true });
63766
+ let existing = existsSync27(destPath) ? statSync9(destPath).size : 0;
63123
63767
  if (existing > 0 && existing < 64) {
63124
63768
  rmSync5(destPath, { force: true });
63125
63769
  existing = 0;
63126
63770
  }
63127
63771
  const tryOnce = async (from) => {
63128
- const diskNow = existsSync26(destPath) ? statSync8(destPath).size : 0;
63772
+ const diskNow = existsSync27(destPath) ? statSync9(destPath).size : 0;
63129
63773
  const start = from > 0 ? diskNow : 0;
63130
63774
  if (from > 0 && diskNow !== from) {
63131
63775
  log2?.warn?.(
@@ -63207,17 +63851,17 @@ function createResumableDownloadToFile(httpFetch, log2) {
63207
63851
 
63208
63852
  // ../../packages/runtime/src/harness/managed-tarball-installer.ts
63209
63853
  import {
63210
- existsSync as existsSync27,
63854
+ existsSync as existsSync28,
63211
63855
  mkdirSync as mkdirSync16,
63212
63856
  mkdtempSync as mkdtempSync2,
63213
63857
  readFileSync as readFileSync16,
63214
63858
  renameSync as renameSync4,
63215
63859
  rmSync as rmSync6,
63216
- statSync as statSync9,
63860
+ statSync as statSync10,
63217
63861
  writeFileSync as writeFileSync13
63218
63862
  } from "node:fs";
63219
63863
  import { tmpdir as tmpdir2 } from "node:os";
63220
- import { dirname as dirname13, join as join23 } from "node:path";
63864
+ import { dirname as dirname14, join as join24 } from "node:path";
63221
63865
  import { spawn as spawn4 } from "node:child_process";
63222
63866
 
63223
63867
  // ../../packages/shared/src/update-channels.ts
@@ -63264,17 +63908,6 @@ function selectHarnessArtifact(manifest, harnessId, platform2, arch2) {
63264
63908
  }
63265
63909
 
63266
63910
  // ../../packages/runtime/src/harness/managed-tarball-installer.ts
63267
- function codexPlatformVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
63268
- const p2 = process.platform;
63269
- const a = process.arch;
63270
- if (a !== "arm64" && a !== "x64") {
63271
- throw new Error(`unsupported arch for Codex: ${a}`);
63272
- }
63273
- if (p2 === "darwin") return `${baseVersion}-darwin-${a}`;
63274
- if (p2 === "linux") return `${baseVersion}-linux-${a}`;
63275
- if (p2 === "win32") return `${baseVersion}-win32-${a}`;
63276
- throw new Error(`unsupported platform for Codex: ${p2}`);
63277
- }
63278
63911
  function managedPackagePins(id) {
63279
63912
  if (id === "claude") {
63280
63913
  const ver = process.env.SUPERONE_CLAUDE_SDK_VERSION?.trim() || OFFICIAL_CLAUDE_SDK_VERSION;
@@ -63290,7 +63923,7 @@ function managedPackagePins(id) {
63290
63923
  packages: [
63291
63924
  {
63292
63925
  name: OFFICIAL_CODEX_PACKAGE,
63293
- version: codexPlatformVersion(base),
63926
+ version: codexPlatformPackageVersion(base),
63294
63927
  nodeModulesDir: OFFICIAL_CODEX_PACKAGE
63295
63928
  }
63296
63929
  ]
@@ -63308,7 +63941,7 @@ function resolveHarnessManifestChannel(explicit, releaseVersion) {
63308
63941
  return "alpha";
63309
63942
  }
63310
63943
  function harnessDownloadDir(homeRoot) {
63311
- return join23(homeRoot, ".download");
63944
+ return join24(homeRoot, ".download");
63312
63945
  }
63313
63946
  function harnessArtifactDownloadKey(opts) {
63314
63947
  const digest = opts.digestSha256?.trim().toLowerCase();
@@ -63322,7 +63955,7 @@ function harnessPartialPath(homeRoot, key) {
63322
63955
  if (!key || key.includes("..") || key.includes("/") || key.includes("\\")) {
63323
63956
  throw new Error(`unsafe download key: ${key}`);
63324
63957
  }
63325
- return join23(harnessDownloadDir(homeRoot), `${key}.partial`);
63958
+ return join24(harnessDownloadDir(homeRoot), `${key}.partial`);
63326
63959
  }
63327
63960
  function extractTgzWithSystemTar(tgzPath, destDir) {
63328
63961
  return new Promise((resolve13, reject) => {
@@ -63342,13 +63975,13 @@ function extractTgzWithSystemTar(tgzPath, destDir) {
63342
63975
  });
63343
63976
  }
63344
63977
  function installPackageDir(packageDir, prefix, nodeModulesRel) {
63345
- const dest = join23(prefix, "lib", "node_modules", ...nodeModulesRel.split("/"));
63346
- const parent = dirname13(dest);
63978
+ const dest = join24(prefix, "lib", "node_modules", ...nodeModulesRel.split("/"));
63979
+ const parent = dirname14(dest);
63347
63980
  mkdirSync16(parent, { recursive: true });
63348
- if (existsSync27(dest)) {
63981
+ if (existsSync28(dest)) {
63349
63982
  rmSync6(dest, { recursive: true, force: true });
63350
63983
  }
63351
- const staging = join23(
63984
+ const staging = join24(
63352
63985
  parent,
63353
63986
  `.staging-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
63354
63987
  );
@@ -63356,12 +63989,12 @@ function installPackageDir(packageDir, prefix, nodeModulesRel) {
63356
63989
  renameSync4(packageDir, staging);
63357
63990
  renameSync4(staging, dest);
63358
63991
  } catch (err) {
63359
- if (existsSync27(staging)) rmSync6(staging, { recursive: true, force: true });
63992
+ if (existsSync28(staging)) rmSync6(staging, { recursive: true, force: true });
63360
63993
  throw err instanceof Error ? err : new Error(`failed to place package into ${dest}: ${String(err)}`);
63361
63994
  }
63362
63995
  return dest;
63363
63996
  }
63364
- function codexTargetTriple() {
63997
+ function codexTargetTriple2() {
63365
63998
  const key = `${process.platform}-${process.arch}`;
63366
63999
  const map2 = {
63367
64000
  "darwin-arm64": "aarch64-apple-darwin",
@@ -63374,12 +64007,12 @@ function codexTargetTriple() {
63374
64007
  return map2[key] ?? null;
63375
64008
  }
63376
64009
  function resolveCodexNativeUnderPrefix(prefix) {
63377
- const triple = codexTargetTriple();
64010
+ const triple = codexTargetTriple2();
63378
64011
  if (!triple) return null;
63379
64012
  const binaryName = process.platform === "win32" ? "codex.exe" : "codex";
63380
64013
  const candidates = [
63381
- join23(prefix, "lib", "node_modules", "@openai", "codex", "vendor", triple, "bin", binaryName),
63382
- join23(
64014
+ join24(prefix, "lib", "node_modules", "@openai", "codex", "vendor", triple, "bin", binaryName),
64015
+ join24(
63383
64016
  prefix,
63384
64017
  "lib",
63385
64018
  "node_modules",
@@ -63392,7 +64025,7 @@ function resolveCodexNativeUnderPrefix(prefix) {
63392
64025
  )
63393
64026
  ];
63394
64027
  for (const c of candidates) {
63395
- if (existsSync27(c) && statSync9(c).isFile()) return c;
64028
+ if (existsSync28(c) && statSync10(c).isFile()) return c;
63396
64029
  }
63397
64030
  return null;
63398
64031
  }
@@ -63402,16 +64035,16 @@ function resolveManagedTarballBinary(id, installRoot) {
63402
64035
  }
63403
64036
  function readRuntimeVersionFromRoot(id, installRoot) {
63404
64037
  try {
63405
- const metaPath = join23(installRoot, "install-meta.json");
63406
- if (existsSync27(metaPath)) {
64038
+ const metaPath = join24(installRoot, "install-meta.json");
64039
+ if (existsSync28(metaPath)) {
63407
64040
  const raw = JSON.parse(readFileSync16(metaPath, "utf8"));
63408
64041
  if (raw.runtimeVersion) return raw.runtimeVersion;
63409
64042
  }
63410
64043
  } catch {
63411
64044
  }
63412
64045
  try {
63413
- const pkgPath = id === "claude" ? null : join23(installRoot, "lib", "node_modules", "@openai", "codex", "package.json");
63414
- if (pkgPath && existsSync27(pkgPath)) {
64046
+ const pkgPath = id === "claude" ? null : join24(installRoot, "lib", "node_modules", "@openai", "codex", "package.json");
64047
+ if (pkgPath && existsSync28(pkgPath)) {
63415
64048
  const raw = JSON.parse(readFileSync16(pkgPath, "utf8"));
63416
64049
  const v2 = raw.version?.trim();
63417
64050
  if (!v2) return null;
@@ -63501,7 +64134,7 @@ function createManagedTarballInstaller(opts = {}) {
63501
64134
  npmVersion
63502
64135
  });
63503
64136
  const partialPath = harnessPartialPath(home.root, downloadKey);
63504
- const work = mkdtempSync2(join23(tmpdir2(), `superone-harness-${id}-`));
64137
+ const work = mkdtempSync2(join24(tmpdir2(), `superone-harness-${id}-`));
63505
64138
  try {
63506
64139
  const { from } = await fetchTarballWithFallback({
63507
64140
  destPath: partialPath,
@@ -63515,15 +64148,15 @@ function createManagedTarballInstaller(opts = {}) {
63515
64148
  log: log2
63516
64149
  });
63517
64150
  source = from;
63518
- const extractRoot = join23(work, "out");
64151
+ const extractRoot = join24(work, "out");
63519
64152
  await extractTgz(partialPath, extractRoot);
63520
- const packageDir = join23(extractRoot, "package");
63521
- if (!existsSync27(packageDir) || !statSync9(packageDir).isDirectory()) {
64153
+ const packageDir = join24(extractRoot, "package");
64154
+ if (!existsSync28(packageDir) || !statSync10(packageDir).isDirectory()) {
63522
64155
  throw new Error(`tarball for ${packageSpec} has no package/ directory`);
63523
64156
  }
63524
64157
  installPackageDir(packageDir, versionDir, npmName);
63525
64158
  try {
63526
- if (existsSync27(partialPath)) rmSync6(partialPath, { force: true });
64159
+ if (existsSync28(partialPath)) rmSync6(partialPath, { force: true });
63527
64160
  } catch {
63528
64161
  }
63529
64162
  } finally {
@@ -63531,7 +64164,7 @@ function createManagedTarballInstaller(opts = {}) {
63531
64164
  }
63532
64165
  }
63533
64166
  writeFileSync13(
63534
- join23(versionDir, "install-meta.json"),
64167
+ join24(versionDir, "install-meta.json"),
63535
64168
  JSON.stringify(
63536
64169
  {
63537
64170
  harnessId: id,
@@ -63575,8 +64208,8 @@ function createManagedTarballInstaller(opts = {}) {
63575
64208
  }
63576
64209
 
63577
64210
  // ../../packages/runtime/src/harness/cursor-availability.ts
63578
- import { createRequire as createRequire3 } from "node:module";
63579
- var require3 = createRequire3(import.meta.url);
64211
+ import { createRequire as createRequire4 } from "node:module";
64212
+ var require3 = createRequire4(import.meta.url);
63580
64213
  function isCursorSdkAvailable2() {
63581
64214
  try {
63582
64215
  require3.resolve("@cursor/sdk");
@@ -63752,7 +64385,7 @@ function isAuthSatisfied(id, deps) {
63752
64385
 
63753
64386
  // ../../packages/runtime/src/harness/enable.ts
63754
64387
  init_environment();
63755
- import { accessSync, constants, existsSync as existsSync28, realpathSync as realpathSync3, statSync as statSync10 } from "node:fs";
64388
+ import { accessSync, constants, existsSync as existsSync29, realpathSync as realpathSync3, statSync as statSync11 } from "node:fs";
63756
64389
  import { isAbsolute as isAbsolute2, resolve as resolve6 } from "node:path";
63757
64390
  async function enableHarness(manager, input, deps) {
63758
64391
  const id = input.harnessId;
@@ -63959,7 +64592,7 @@ function requireRegularReadableFile(path) {
63959
64592
  throw new Error(`path must be absolute: ${path}`);
63960
64593
  }
63961
64594
  const abs = resolve6(path);
63962
- if (!existsSync28(abs) || !statSync10(abs).isFile()) {
64595
+ if (!existsSync29(abs) || !statSync11(abs).isFile()) {
63963
64596
  throw new Error(`not a regular file: ${abs}`);
63964
64597
  }
63965
64598
  accessSync(abs, constants.R_OK);
@@ -63968,9 +64601,9 @@ function requireRegularReadableFile(path) {
63968
64601
  function resolveExternalCommand(explicit, searchNames) {
63969
64602
  if (explicit) {
63970
64603
  const abs = isAbsolute2(explicit) ? explicit : resolve6(explicit);
63971
- if (!existsSync28(abs)) return null;
64604
+ if (!existsSync29(abs)) return null;
63972
64605
  try {
63973
- if (!statSync10(abs).isFile()) return null;
64606
+ if (!statSync11(abs).isFile()) return null;
63974
64607
  accessSync(abs, constants.X_OK);
63975
64608
  } catch {
63976
64609
  return null;
@@ -63983,9 +64616,9 @@ function resolveExternalCommand(explicit, searchNames) {
63983
64616
  for (const dir of dirs) {
63984
64617
  if (!dir) continue;
63985
64618
  const candidate = resolve6(dir, name);
63986
- if (!existsSync28(candidate)) continue;
64619
+ if (!existsSync29(candidate)) continue;
63987
64620
  try {
63988
- if (!statSync10(candidate).isFile()) continue;
64621
+ if (!statSync11(candidate).isFile()) continue;
63989
64622
  accessSync(candidate, constants.X_OK);
63990
64623
  return realpathSync3(candidate);
63991
64624
  } catch {
@@ -64038,7 +64671,7 @@ function looksLikeSecretArg(value) {
64038
64671
  }
64039
64672
 
64040
64673
  // src/session/harness-host.ts
64041
- import { existsSync as existsSync29 } from "node:fs";
64674
+ import { existsSync as existsSync30 } from "node:fs";
64042
64675
  init_src2();
64043
64676
  init_claude_turn_runner();
64044
64677
  init_codex_turn_runner();
@@ -64046,7 +64679,7 @@ init_resolve_service();
64046
64679
  setHarnessReleaseVersionProvider(resolveCliReleaseVersion);
64047
64680
  function envBinaryExists(envName) {
64048
64681
  const v2 = process.env[envName]?.trim();
64049
- return Boolean(v2 && existsSync29(v2));
64682
+ return Boolean(v2 && existsSync30(v2));
64050
64683
  }
64051
64684
  var cliHarnessResolver = {
64052
64685
  resolveBinary(id, harnesses) {
@@ -64056,7 +64689,7 @@ var cliHarnessResolver = {
64056
64689
  return null;
64057
64690
  }
64058
64691
  const command = harnesses.get(id).command;
64059
- return command && existsSync29(command) ? command : null;
64692
+ return command && existsSync30(command) ? command : null;
64060
64693
  },
64061
64694
  isRunnableWithoutCatalog(id) {
64062
64695
  if (id === "claude") return isClaudeRuntimeRunnable();
@@ -64068,7 +64701,7 @@ var cliHarnessResolver = {
64068
64701
  autoRuntime(id) {
64069
64702
  if (id === "claude") {
64070
64703
  const sdk = resolveSdkClaudeBinary();
64071
- if (sdk && existsSync29(sdk)) return { command: sdk, source: "agent-sdk-optional" };
64704
+ if (sdk && existsSync30(sdk)) return { command: sdk, source: "agent-sdk-optional" };
64072
64705
  return null;
64073
64706
  }
64074
64707
  const fromEnv = resolveCodexBinaryPath({});
@@ -64151,8 +64784,8 @@ function enableManaged2(manager, id, artifact, mode = "enable") {
64151
64784
 
64152
64785
  // ../../packages/shared/src/git-clone.ts
64153
64786
  import { execFile as execFile2 } from "node:child_process";
64154
- import { existsSync as existsSync30, mkdirSync as mkdirSync17 } from "node:fs";
64155
- import { isAbsolute as isAbsolute3, join as join24, resolve as resolve7 } from "node:path";
64787
+ import { existsSync as existsSync31, mkdirSync as mkdirSync17 } from "node:fs";
64788
+ import { isAbsolute as isAbsolute3, join as join25, resolve as resolve7 } from "node:path";
64156
64789
 
64157
64790
  // ../../packages/shared/src/git-remote.ts
64158
64791
  function repoNameFromGitUrl(url2) {
@@ -64217,11 +64850,11 @@ function resolveCloneDestination(input) {
64217
64850
  if (name.includes("/") || name.includes("\\") || name === "." || name === "..") {
64218
64851
  throw invalid(`invalid folder name: ${name}`);
64219
64852
  }
64220
- return { path: join24(resolve7(parent), name), name };
64853
+ return { path: join25(resolve7(parent), name), name };
64221
64854
  }
64222
64855
  async function cloneRepository(input) {
64223
64856
  const destination = resolveCloneDestination(input);
64224
- if (existsSync30(destination.path)) {
64857
+ if (existsSync31(destination.path)) {
64225
64858
  throw Object.assign(new Error(`destination already exists: ${destination.path}`), {
64226
64859
  code: "conflict"
64227
64860
  });
@@ -64265,7 +64898,7 @@ async function cloneRepository(input) {
64265
64898
 
64266
64899
  // src/rpc/handlers.ts
64267
64900
  init_resolve_service();
64268
- import { existsSync as existsSync31, mkdirSync as mkdirSync18, readdirSync as readdirSync10, statSync as statSync11 } from "node:fs";
64901
+ import { existsSync as existsSync32, mkdirSync as mkdirSync18, readdirSync as readdirSync10, statSync as statSync12 } from "node:fs";
64269
64902
  import { join as pathJoin, resolve as pathResolve } from "node:path";
64270
64903
  import { arch, cpus, freemem, homedir as homedir7, hostname as hostname4, platform, totalmem, uptime } from "node:os";
64271
64904
 
@@ -66189,6 +66822,7 @@ var MUTATING_METHODS = /* @__PURE__ */ new Set([
66189
66822
  "session.close",
66190
66823
  "session.remove",
66191
66824
  "session.rename",
66825
+ "session.setTags",
66192
66826
  "session.setUiFlags",
66193
66827
  // pin/hide
66194
66828
  "terminal.acquireControl",
@@ -66460,6 +67094,8 @@ async function dispatchRpcInner(method, payload, ctx) {
66460
67094
  return handleSessionRemove(payload, ctx);
66461
67095
  case "session.rename":
66462
67096
  return handleSessionRename(payload, ctx);
67097
+ case "session.setTags":
67098
+ return handleSessionSetTags(payload, ctx);
66463
67099
  case "session.setUiFlags":
66464
67100
  return handleSessionSetUiFlags(payload, ctx);
66465
67101
  case "collaboration.listProfiles":
@@ -67030,7 +67666,7 @@ function handleProjectOpen(payload, ctx) {
67030
67666
  }
67031
67667
  const name = typeof p2.name === "string" ? p2.name : void 0;
67032
67668
  try {
67033
- if (p2.createIfMissing === true && !existsSync31(path)) {
67669
+ if (p2.createIfMissing === true && !existsSync32(path)) {
67034
67670
  mkdirSync18(path, { recursive: true });
67035
67671
  }
67036
67672
  return { result: ctx.projects.open(path, name) };
@@ -67067,10 +67703,10 @@ function handleFsListDir(payload, ctx) {
67067
67703
  }
67068
67704
  try {
67069
67705
  const resolved = expandHostPath(raw);
67070
- if (!existsSync31(resolved)) {
67706
+ if (!existsSync32(resolved)) {
67071
67707
  return { error: { code: "not_found", message: "path not found" } };
67072
67708
  }
67073
- if (!statSync11(resolved).isDirectory()) {
67709
+ if (!statSync12(resolved).isDirectory()) {
67074
67710
  return { error: { code: "invalid_argument", message: "not a directory" } };
67075
67711
  }
67076
67712
  const entries = readdirSync10(resolved, { withFileTypes: true }).filter((ent) => ent.isDirectory() && !ent.name.startsWith(".")).map((ent) => ({
@@ -67953,6 +68589,32 @@ function handleSessionRename(payload, ctx) {
67953
68589
  return mapThrown7(err);
67954
68590
  }
67955
68591
  }
68592
+ function handleSessionSetTags(payload, ctx) {
68593
+ const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
68594
+ if (denied) return denied;
68595
+ const p2 = asRecord17(payload);
68596
+ const sessionId = String(p2.sessionId ?? "");
68597
+ if (!sessionId) {
68598
+ return { error: { code: "invalid_argument", message: "sessionId required" } };
68599
+ }
68600
+ const op = parseSessionTagOp({ add: p2.add, remove: p2.remove, set: p2.set });
68601
+ if ("error" in op) {
68602
+ return { error: { code: "invalid_argument", message: op.error } };
68603
+ }
68604
+ try {
68605
+ const session = ctx.sessions.get(sessionId);
68606
+ if (!session) {
68607
+ return { error: { code: "not_found", message: "session not found" } };
68608
+ }
68609
+ const next = applySessionTagOp(session.tags ?? [], op);
68610
+ if ("error" in next) {
68611
+ return { error: { code: "failed_precondition", message: next.error } };
68612
+ }
68613
+ return { result: ctx.sessions.setTags(sessionId, next) };
68614
+ } catch (err) {
68615
+ return mapThrown7(err);
68616
+ }
68617
+ }
67956
68618
  function handleSessionSetUiFlags(payload, ctx) {
67957
68619
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
67958
68620
  if (denied) return denied;
@@ -68795,9 +69457,9 @@ async function handleHttp(req, res, opts) {
68795
69457
  }
68796
69458
 
68797
69459
  // src/terminal/manager.ts
68798
- import { createRequire as createRequire4 } from "node:module";
68799
- import { existsSync as existsSync32 } from "node:fs";
68800
- var nodeRequire = createRequire4(import.meta.url);
69460
+ import { createRequire as createRequire5 } from "node:module";
69461
+ import { existsSync as existsSync33 } from "node:fs";
69462
+ var nodeRequire = createRequire5(import.meta.url);
68801
69463
  var { spawn: spawn5 } = nodeRequire("node-pty");
68802
69464
  var SNAPSHOT_SOFT_LIMIT = 64 * 1024;
68803
69465
  var OUTPUT_BUFFER_SOFT_LIMIT = 256 * 1024;
@@ -68811,7 +69473,7 @@ var NodeTerminalManager = class {
68811
69473
  }
68812
69474
  byId = /* @__PURE__ */ new Map();
68813
69475
  create(opts) {
68814
- if (!existsSync32(opts.cwd)) {
69476
+ if (!existsSync33(opts.cwd)) {
68815
69477
  throw Object.assign(new Error(`cwd does not exist: ${opts.cwd}`), { code: "invalid_argument" });
68816
69478
  }
68817
69479
  const terminalId = crypto.randomUUID();
@@ -68952,7 +69614,7 @@ var NodeTerminalManager = class {
68952
69614
 
68953
69615
  // src/workspace/project-registry.ts
68954
69616
  import { basename as basename2, resolve as resolve8 } from "node:path";
68955
- import { existsSync as existsSync33, realpathSync as realpathSync4, statSync as statSync12 } from "node:fs";
69617
+ import { existsSync as existsSync34, realpathSync as realpathSync4, statSync as statSync13 } from "node:fs";
68956
69618
  import { createHash as createHash7 } from "node:crypto";
68957
69619
  import { execFileSync as execFileSync2 } from "node:child_process";
68958
69620
  var ProjectRegistry = class {
@@ -68982,7 +69644,7 @@ var ProjectRegistry = class {
68982
69644
  }
68983
69645
  open(path, name) {
68984
69646
  let abs = resolve8(path);
68985
- if (!existsSync33(abs) || !statSync12(abs).isDirectory()) {
69647
+ if (!existsSync34(abs) || !statSync13(abs).isDirectory()) {
68986
69648
  throw Object.assign(new Error(`project path is not a directory: ${abs}`), {
68987
69649
  code: "invalid_argument"
68988
69650
  });
@@ -69026,7 +69688,7 @@ var ProjectRegistry = class {
69026
69688
  toSnapshot(r) {
69027
69689
  let missing = false;
69028
69690
  try {
69029
- missing = !statSync12(r.path).isDirectory();
69691
+ missing = !statSync13(r.path).isDirectory();
69030
69692
  } catch {
69031
69693
  missing = true;
69032
69694
  }
@@ -69066,7 +69728,7 @@ function detectRepoIdentity(abs) {
69066
69728
  init_fs();
69067
69729
  import {
69068
69730
  closeSync,
69069
- existsSync as existsSync34,
69731
+ existsSync as existsSync35,
69070
69732
  fstatSync,
69071
69733
  mkdirSync as mkdirSync19,
69072
69734
  openSync,
@@ -69075,11 +69737,11 @@ import {
69075
69737
  readFileSync as readFileSync17,
69076
69738
  renameSync as renameSync5,
69077
69739
  rmSync as rmSync7,
69078
- statSync as statSync13,
69740
+ statSync as statSync14,
69079
69741
  unlinkSync,
69080
69742
  writeFileSync as writeFileSync14
69081
69743
  } from "node:fs";
69082
- import { dirname as dirname14, join as join25, relative as relative2 } from "node:path";
69744
+ import { dirname as dirname15, join as join26, relative as relative2 } from "node:path";
69083
69745
  import { createHash as createHash8 } from "node:crypto";
69084
69746
  function normalizeRel(path) {
69085
69747
  return path.replace(/\\/g, "/").replace(/\/+$/, "") || ".";
@@ -69125,21 +69787,21 @@ var WorkspaceFsService = class {
69125
69787
  if (!resolved.ok) {
69126
69788
  throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
69127
69789
  }
69128
- if (!existsSync34(resolved.absolutePath)) {
69790
+ if (!existsSync35(resolved.absolutePath)) {
69129
69791
  throw Object.assign(new Error("path not found"), { code: "not_found" });
69130
69792
  }
69131
- const st = statSync13(resolved.absolutePath);
69793
+ const st = statSync14(resolved.absolutePath);
69132
69794
  if (!st.isDirectory()) {
69133
69795
  throw Object.assign(new Error("not a directory"), { code: "invalid_argument" });
69134
69796
  }
69135
69797
  this.projects.touch(projectId);
69136
69798
  const ents = readdirSync11(resolved.absolutePath, { withFileTypes: true });
69137
69799
  return ents.map((ent) => {
69138
- const abs = join25(resolved.absolutePath, ent.name);
69800
+ const abs = join26(resolved.absolutePath, ent.name);
69139
69801
  let size;
69140
69802
  let mtimeMs;
69141
69803
  try {
69142
- const s2 = statSync13(abs);
69804
+ const s2 = statSync14(abs);
69143
69805
  size = s2.size;
69144
69806
  mtimeMs = s2.mtimeMs;
69145
69807
  } catch {
@@ -69160,10 +69822,10 @@ var WorkspaceFsService = class {
69160
69822
  if (!resolved.ok) {
69161
69823
  throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
69162
69824
  }
69163
- if (!existsSync34(resolved.absolutePath)) {
69825
+ if (!existsSync35(resolved.absolutePath)) {
69164
69826
  throw Object.assign(new Error("file not found"), { code: "not_found" });
69165
69827
  }
69166
- const st = statSync13(resolved.absolutePath);
69828
+ const st = statSync14(resolved.absolutePath);
69167
69829
  if (!st.isFile()) {
69168
69830
  throw Object.assign(new Error("not a file"), { code: "invalid_argument" });
69169
69831
  }
@@ -69199,8 +69861,8 @@ var WorkspaceFsService = class {
69199
69861
  if (!resolved.ok) {
69200
69862
  throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
69201
69863
  }
69202
- if (existsSync34(resolved.absolutePath) && expectedHash) {
69203
- const st = statSync13(resolved.absolutePath);
69864
+ if (existsSync35(resolved.absolutePath) && expectedHash) {
69865
+ const st = statSync14(resolved.absolutePath);
69204
69866
  if (st.size > MAX_READ_BYTES) {
69205
69867
  throw Object.assign(
69206
69868
  new Error(`optimistic-write target too large (${st.size} bytes; max ${MAX_READ_BYTES})`),
@@ -69212,15 +69874,15 @@ var WorkspaceFsService = class {
69212
69874
  throw Object.assign(new Error("content hash mismatch"), { code: "conflict" });
69213
69875
  }
69214
69876
  }
69215
- mkdirSync19(dirname14(resolved.absolutePath), { recursive: true });
69877
+ mkdirSync19(dirname15(resolved.absolutePath), { recursive: true });
69216
69878
  const data = typeof content === "string" ? Buffer.from(content, "utf8") : Buffer.from(content);
69217
69879
  if (data.length > MAX_READ_BYTES) {
69218
69880
  throw Object.assign(new Error("write payload too large"), { code: "invalid_argument" });
69219
69881
  }
69220
69882
  let mode = 384;
69221
- if (existsSync34(resolved.absolutePath)) {
69883
+ if (existsSync35(resolved.absolutePath)) {
69222
69884
  try {
69223
- mode = statSync13(resolved.absolutePath).mode & 511;
69885
+ mode = statSync14(resolved.absolutePath).mode & 511;
69224
69886
  } catch {
69225
69887
  }
69226
69888
  }
@@ -69288,7 +69950,7 @@ var WorkspaceFsService = class {
69288
69950
  for (const ent of ents) {
69289
69951
  if (hits.length >= MAX_SEARCH_HITS) return;
69290
69952
  if (ent.name === ".git" || ent.name === "node_modules") continue;
69291
- const abs = join25(dir, ent.name);
69953
+ const abs = join26(dir, ent.name);
69292
69954
  const rel = relative2(root, abs).split("\\").join("/");
69293
69955
  const check2 = resolveProjectPath(root, rel);
69294
69956
  if (!check2.ok) continue;
@@ -69298,7 +69960,7 @@ var WorkspaceFsService = class {
69298
69960
  }
69299
69961
  if (!ent.isFile()) continue;
69300
69962
  try {
69301
- const st = statSync13(abs);
69963
+ const st = statSync14(abs);
69302
69964
  if (st.size > MAX_SEARCH_FILE_BYTES) continue;
69303
69965
  const text = readFileSync17(abs, "utf8");
69304
69966
  const lines = text.split(/\r?\n/);
@@ -69362,8 +70024,8 @@ var WorkspaceFsService = class {
69362
70024
  if (!resolved.ok) {
69363
70025
  throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
69364
70026
  }
69365
- if (existsSync34(resolved.absolutePath)) {
69366
- const st = statSync13(resolved.absolutePath);
70027
+ if (existsSync35(resolved.absolutePath)) {
70028
+ const st = statSync14(resolved.absolutePath);
69367
70029
  if (!st.isDirectory()) {
69368
70030
  throw Object.assign(new Error("path exists and is not a directory"), { code: "conflict" });
69369
70031
  }
@@ -69385,7 +70047,7 @@ var WorkspaceFsService = class {
69385
70047
  if (!resolved.ok) {
69386
70048
  throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
69387
70049
  }
69388
- if (!existsSync34(resolved.absolutePath)) {
70050
+ if (!existsSync35(resolved.absolutePath)) {
69389
70051
  throw Object.assign(new Error("path not found"), { code: "not_found" });
69390
70052
  }
69391
70053
  if (resolved.absolutePath === root) {
@@ -69409,19 +70071,19 @@ var WorkspaceFsService = class {
69409
70071
  if (!from.ok) {
69410
70072
  throw Object.assign(new Error(from.reason), { code: "invalid_argument" });
69411
70073
  }
69412
- if (!existsSync34(from.absolutePath)) {
70074
+ if (!existsSync35(from.absolutePath)) {
69413
70075
  throw Object.assign(new Error("source not found"), { code: "not_found" });
69414
70076
  }
69415
70077
  const to = resolveProjectPath(root, toN);
69416
70078
  if (!to.ok) {
69417
70079
  throw Object.assign(new Error(to.reason), { code: "invalid_argument" });
69418
70080
  }
69419
- if (existsSync34(to.absolutePath)) {
70081
+ if (existsSync35(to.absolutePath)) {
69420
70082
  throw Object.assign(new Error(`target already exists: ${baseNameRel(toN)}`), {
69421
70083
  code: "conflict"
69422
70084
  });
69423
70085
  }
69424
- mkdirSync19(dirname14(to.absolutePath), { recursive: true });
70086
+ mkdirSync19(dirname15(to.absolutePath), { recursive: true });
69425
70087
  renameSync5(from.absolutePath, to.absolutePath);
69426
70088
  this.projects.touch(projectId);
69427
70089
  return { from: fromN, to: toN };
@@ -69446,8 +70108,8 @@ function hashFileBounded(absolutePath, size) {
69446
70108
  }
69447
70109
 
69448
70110
  // src/workspace/git-service.ts
69449
- import { existsSync as existsSync35, mkdirSync as mkdirSync20, realpathSync as realpathSync5, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "node:fs";
69450
- import { join as join27, resolve as resolve10 } from "node:path";
70111
+ import { existsSync as existsSync36, mkdirSync as mkdirSync20, realpathSync as realpathSync5, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "node:fs";
70112
+ import { join as join28, resolve as resolve10 } from "node:path";
69451
70113
  import { tmpdir as tmpdir3 } from "node:os";
69452
70114
  import { randomUUID as randomUUID8 } from "node:crypto";
69453
70115
 
@@ -69524,19 +70186,19 @@ function gitRunSync(folderPath, args, env) {
69524
70186
  }
69525
70187
 
69526
70188
  // ../../packages/runtime/src/git/worktree-plan.ts
69527
- import { basename as basename3, dirname as dirname15, join as join26, resolve as resolve9, sep as sep4 } from "node:path";
70189
+ import { basename as basename3, dirname as dirname16, join as join27, resolve as resolve9, sep as sep4 } from "node:path";
69528
70190
  import { homedir as homedir8 } from "node:os";
69529
70191
  function resolveMainDirFromCommonDir(folderPath, gitCommonDir) {
69530
70192
  const repoRoot = resolve9(folderPath, gitCommonDir.trim());
69531
- return repoRoot.endsWith(`${sep4}.git`) || repoRoot.endsWith("/.git") ? dirname15(repoRoot) : repoRoot;
70193
+ return repoRoot.endsWith(`${sep4}.git`) || repoRoot.endsWith("/.git") ? dirname16(repoRoot) : repoRoot;
69532
70194
  }
69533
70195
  function planNewWorktreePaths(input) {
69534
70196
  const home = input.homeDir ?? homedir8();
69535
70197
  const repoName = basename3(input.mainDir);
69536
70198
  const epoch = Math.floor((input.nowMs ?? Date.now()) / 1e3).toString(36);
69537
70199
  const short = input.shortHash.slice(0, 7);
69538
- const wtDir = join26(home, ".worktrees", repoName);
69539
- const wtPath = join26(wtDir, `${epoch}-${short}`);
70200
+ const wtDir = join27(home, ".worktrees", repoName);
70201
+ const wtPath = join27(wtDir, `${epoch}-${short}`);
69540
70202
  return { wtDir, wtPath };
69541
70203
  }
69542
70204
  function worktreeAddArgs(mode, wtPath, baseRef, branchName) {
@@ -69595,8 +70257,8 @@ function resolveMainWorktreeDir(folderPath) {
69595
70257
  }
69596
70258
  function samePath(a, b2) {
69597
70259
  try {
69598
- const ra = existsSync35(a) ? realpathSync5(a) : resolve10(a);
69599
- const rb = existsSync35(b2) ? realpathSync5(b2) : resolve10(b2);
70260
+ const ra = existsSync36(a) ? realpathSync5(a) : resolve10(a);
70261
+ const rb = existsSync36(b2) ? realpathSync5(b2) : resolve10(b2);
69600
70262
  return ra === rb;
69601
70263
  } catch {
69602
70264
  return resolve10(a) === resolve10(b2);
@@ -69628,7 +70290,7 @@ var WorkspaceGitService = class {
69628
70290
  * --ignored walks the whole tree of ignored paths and dominates remote latency.
69629
70291
  */
69630
70292
  statusForCwd(cwd) {
69631
- if (!existsSync35(join27(cwd, ".git")) && !isGitWorktree(cwd)) {
70293
+ if (!existsSync36(join28(cwd, ".git")) && !isGitWorktree(cwd)) {
69632
70294
  return { isRepo: false, branch: null, dirty: false, ahead: 0, behind: 0, porcelain: "" };
69633
70295
  }
69634
70296
  try {
@@ -69737,15 +70399,15 @@ var WorkspaceGitService = class {
69737
70399
  }
69738
70400
  const abs = resolve10(worktreePath);
69739
70401
  const main2 = resolve10(this.root(projectId));
69740
- if (samePath(abs, main2)) return existsSync35(abs) ? realpathSync5(abs) : abs;
70402
+ if (samePath(abs, main2)) return existsSync36(abs) ? realpathSync5(abs) : abs;
69741
70403
  const listed = this.worktrees(projectId);
69742
70404
  for (const wt of listed) {
69743
70405
  if (samePath(abs, wt.path)) {
69744
- return existsSync35(abs) ? realpathSync5(abs) : resolve10(wt.path);
70406
+ return existsSync36(abs) ? realpathSync5(abs) : resolve10(wt.path);
69745
70407
  }
69746
70408
  }
69747
70409
  try {
69748
- if (existsSync35(abs) && isGitWorktree(abs)) {
70410
+ if (existsSync36(abs) && isGitWorktree(abs)) {
69749
70411
  const commonA = resolve10(abs, git(abs, ["rev-parse", "--git-common-dir"]).trim());
69750
70412
  const commonB = resolve10(main2, git(main2, ["rev-parse", "--git-common-dir"]).trim());
69751
70413
  if (samePath(commonA, commonB)) {
@@ -69787,7 +70449,7 @@ var WorkspaceGitService = class {
69787
70449
  mainDir,
69788
70450
  shortHash: commitHash.slice(0, 7)
69789
70451
  });
69790
- if (!existsSync35(wtDir)) mkdirSync20(wtDir, { recursive: true });
70452
+ if (!existsSync36(wtDir)) mkdirSync20(wtDir, { recursive: true });
69791
70453
  try {
69792
70454
  const addArgs = worktreeAddArgs(mode, wtPath, baseBranch, safeBranchName);
69793
70455
  git(folderPath, ["worktree", ...addArgs]);
@@ -69883,7 +70545,7 @@ var WorkspaceGitService = class {
69883
70545
  const mainStatus = git(diff.mainDir, ["status", "--porcelain"]).trim();
69884
70546
  if (mainStatus) return { ok: false, reason: "main-dirty" };
69885
70547
  const patch = git(diff.worktreePath, ["diff", "--binary", diff.base, diff.tree]);
69886
- const patchFile = join27(tmpdir3(), `s1-handoff-${randomUUID8()}.patch`);
70548
+ const patchFile = join28(tmpdir3(), `s1-handoff-${randomUUID8()}.patch`);
69887
70549
  writeFileSync15(patchFile, `${patch}
69888
70550
  `);
69889
70551
  if (git(diff.mainDir, ["status", "--porcelain"]).trim()) {
@@ -69945,7 +70607,7 @@ var WorkspaceGitService = class {
69945
70607
  };
69946
70608
  }
69947
70609
  writeWorkingTree(worktreePath) {
69948
- const tmpIndex = join27(tmpdir3(), `s1-handoff-${randomUUID8()}.index`);
70610
+ const tmpIndex = join28(tmpdir3(), `s1-handoff-${randomUUID8()}.index`);
69949
70611
  const env = { GIT_INDEX_FILE: tmpIndex };
69950
70612
  try {
69951
70613
  git(worktreePath, ["read-tree", "HEAD"], env);
@@ -70142,7 +70804,7 @@ init_agent_types();
70142
70804
  init_environment();
70143
70805
  init_resolve_service();
70144
70806
  import { createHash as createHash9, randomBytes as randomBytes5, randomUUID as randomUUID10 } from "node:crypto";
70145
- import { existsSync as existsSync36, statSync as statSync14 } from "node:fs";
70807
+ import { existsSync as existsSync37, statSync as statSync15 } from "node:fs";
70146
70808
  import { resolve as pathResolve2 } from "node:path";
70147
70809
  var MAX_MESSAGES_PER_RETRIEVE = 100;
70148
70810
  var EMPTY_MAILBOX_HINT = "No peer has replied yet. Do not retrieve again, do not sleep, do not wait in place \u2014 end your turn or do unrelated work. A task notification will start a new turn for you as soon as a message arrives.";
@@ -71063,7 +71725,7 @@ var CollaborationService = class {
71063
71725
  const project = this.deps.projects.get(projectId);
71064
71726
  const fallback = parentCwd || project?.path || process.cwd();
71065
71727
  const cwd = pathResolve2(config2.cwd || fallback);
71066
- if (!existsSync36(cwd) || !statSync14(cwd).isDirectory()) {
71728
+ if (!existsSync37(cwd) || !statSync15(cwd).isDirectory()) {
71067
71729
  throw Object.assign(new Error(`Working directory does not exist: ${cwd}`), {
71068
71730
  code: "invalid_argument"
71069
71731
  });
@@ -71202,8 +71864,8 @@ var CollaborationService = class {
71202
71864
  };
71203
71865
 
71204
71866
  // src/provider/secret-crypto.ts
71205
- import { existsSync as existsSync37, mkdirSync as mkdirSync21, readFileSync as readFileSync18, writeFileSync as writeFileSync16, chmodSync as chmodSync2 } from "node:fs";
71206
- import { dirname as dirname16 } from "node:path";
71867
+ import { existsSync as existsSync38, mkdirSync as mkdirSync21, readFileSync as readFileSync18, writeFileSync as writeFileSync16, chmodSync as chmodSync2 } from "node:fs";
71868
+ import { dirname as dirname17 } from "node:path";
71207
71869
  import { createCipheriv, createDecipheriv, randomBytes as randomBytes6 } from "node:crypto";
71208
71870
  var ENC_PREFIX2 = "enc:v1:";
71209
71871
  var KEY_BYTES = 32;
@@ -71211,11 +71873,11 @@ function isEncryptedSecret(value) {
71211
71873
  return typeof value === "string" && value.startsWith(ENC_PREFIX2);
71212
71874
  }
71213
71875
  function ensureKeyFile(keyPath) {
71214
- if (existsSync37(keyPath)) {
71876
+ if (existsSync38(keyPath)) {
71215
71877
  const raw = readFileSync18(keyPath);
71216
71878
  if (raw.length === KEY_BYTES) return raw;
71217
71879
  }
71218
- mkdirSync21(dirname16(keyPath), { recursive: true, mode: 448 });
71880
+ mkdirSync21(dirname17(keyPath), { recursive: true, mode: 448 });
71219
71881
  const key = randomBytes6(KEY_BYTES);
71220
71882
  writeFileSync16(keyPath, key, { mode: 384 });
71221
71883
  try {
@@ -71359,7 +72021,7 @@ var WorkspaceWatchService = class {
71359
72021
 
71360
72022
  // src/workspace/tail-watch-service.ts
71361
72023
  init_fs();
71362
- import { existsSync as existsSync38, fstatSync as fstatSync2, openSync as openSync2, closeSync as closeSync2, statSync as statSync15, readSync as readSync2, realpathSync as realpathSync6 } from "node:fs";
72024
+ import { existsSync as existsSync39, fstatSync as fstatSync2, openSync as openSync2, closeSync as closeSync2, statSync as statSync16, readSync as readSync2, realpathSync as realpathSync6 } from "node:fs";
71363
72025
  var MAX_POLL_BYTES = 10 * 1024 * 1024;
71364
72026
  var WorkspaceTailWatchService = class {
71365
72027
  constructor(projects, fs) {
@@ -71381,7 +72043,7 @@ var WorkspaceTailWatchService = class {
71381
72043
  );
71382
72044
  }
71383
72045
  try {
71384
- resolvedAbs = existsSync38(absolutePath) ? realpathSync6(absolutePath) : absolutePath;
72046
+ resolvedAbs = existsSync39(absolutePath) ? realpathSync6(absolutePath) : absolutePath;
71385
72047
  } catch {
71386
72048
  resolvedAbs = absolutePath;
71387
72049
  }
@@ -71412,9 +72074,9 @@ var WorkspaceTailWatchService = class {
71412
72074
  code: "invalid_argument"
71413
72075
  });
71414
72076
  }
71415
- if (existsSync38(resolvedAbs)) {
72077
+ if (existsSync39(resolvedAbs)) {
71416
72078
  try {
71417
- const st = statSync15(resolvedAbs);
72079
+ const st = statSync16(resolvedAbs);
71418
72080
  if (!st.isFile()) {
71419
72081
  throw Object.assign(new Error("not a file"), { code: "invalid_argument" });
71420
72082
  }
@@ -71463,7 +72125,7 @@ var WorkspaceTailWatchService = class {
71463
72125
  { code: "invalid_argument" }
71464
72126
  );
71465
72127
  }
71466
- if (!existsSync38(absolutePath)) {
72128
+ if (!existsSync39(absolutePath)) {
71467
72129
  return {
71468
72130
  content: "",
71469
72131
  encoding: "base64",
@@ -84603,7 +85265,7 @@ function createLocalPairingToken(nodeHome) {
84603
85265
  }
84604
85266
  function readRuntimeStatus(nodeHome) {
84605
85267
  const paths = nodePaths(resolveRuntimeConfig({ nodeHome }).nodeHome);
84606
- if (!existsSync39(paths.runtimeJson)) return null;
85268
+ if (!existsSync40(paths.runtimeJson)) return null;
84607
85269
  try {
84608
85270
  return JSON.parse(readFileSync19(paths.runtimeJson, "utf8"));
84609
85271
  } catch {
@@ -84613,8 +85275,8 @@ function readRuntimeStatus(nodeHome) {
84613
85275
 
84614
85276
  // src/systemd/install.ts
84615
85277
  import { spawnSync as spawnSync2 } from "node:child_process";
84616
- import { chmodSync as chmodSync3, existsSync as existsSync40, mkdirSync as mkdirSync22, unlinkSync as unlinkSync2, writeFileSync as writeFileSync18 } from "node:fs";
84617
- import { dirname as dirname17 } from "node:path";
85278
+ import { chmodSync as chmodSync3, existsSync as existsSync41, mkdirSync as mkdirSync22, unlinkSync as unlinkSync2, writeFileSync as writeFileSync18 } from "node:fs";
85279
+ import { dirname as dirname18 } from "node:path";
84618
85280
 
84619
85281
  // src/systemd/unit.ts
84620
85282
  function renderSystemdUserUnit(opts) {
@@ -84671,7 +85333,7 @@ function checkLinger(user) {
84671
85333
  return { enabled: null, raw };
84672
85334
  }
84673
85335
  function writeSystemdUserUnit(opts, unitPath = systemdUserUnitPath()) {
84674
- mkdirSync22(dirname17(unitPath), { recursive: true });
85336
+ mkdirSync22(dirname18(unitPath), { recursive: true });
84675
85337
  writeFileSync18(unitPath, renderSystemdUserUnit(opts), { encoding: "utf8", mode: 420 });
84676
85338
  try {
84677
85339
  chmodSync3(unitPath, 420);
@@ -84725,7 +85387,7 @@ function uninstallSystemdUserService(removeUnitFile = true) {
84725
85387
  }
84726
85388
  if (removeUnitFile) {
84727
85389
  const path = systemdUserUnitPath();
84728
- if (existsSync40(path)) {
85390
+ if (existsSync41(path)) {
84729
85391
  try {
84730
85392
  unlinkSync2(path);
84731
85393
  } catch (err) {
@@ -84748,7 +85410,7 @@ function systemdUserStatus() {
84748
85410
 
84749
85411
  // src/session/harness-cli.ts
84750
85412
  init_environment();
84751
- import { accessSync as accessSync2, constants as constants2, existsSync as existsSync41, realpathSync as realpathSync7, statSync as statSync16 } from "node:fs";
85413
+ import { accessSync as accessSync2, constants as constants2, existsSync as existsSync42, realpathSync as realpathSync7, statSync as statSync17 } from "node:fs";
84752
85414
  import { isAbsolute as isAbsolute4, resolve as resolve11 } from "node:path";
84753
85415
  import { homedir as homedir9 } from "node:os";
84754
85416
  var DEFERRED_FLAGS = /* @__PURE__ */ new Set([
@@ -85297,10 +85959,10 @@ function resolveExternalCommand2(explicit, pathCandidates) {
85297
85959
  return null;
85298
85960
  }
85299
85961
  function isUsableExecutable(path) {
85300
- if (!existsSync41(path)) return null;
85962
+ if (!existsSync42(path)) return null;
85301
85963
  let st;
85302
85964
  try {
85303
- st = statSync16(path);
85965
+ st = statSync17(path);
85304
85966
  } catch {
85305
85967
  return null;
85306
85968
  }
@@ -85317,10 +85979,10 @@ function isUsableExecutable(path) {
85317
85979
  }
85318
85980
  }
85319
85981
  function probeExecutableIssues(path) {
85320
- if (!existsSync41(path)) return ["command_missing"];
85982
+ if (!existsSync42(path)) return ["command_missing"];
85321
85983
  let st;
85322
85984
  try {
85323
- st = statSync16(path);
85985
+ st = statSync17(path);
85324
85986
  } catch {
85325
85987
  return ["command_missing"];
85326
85988
  }
@@ -85333,9 +85995,9 @@ function probeExecutableIssues(path) {
85333
85995
  return [];
85334
85996
  }
85335
85997
  function probeReadableFileIssues(path) {
85336
- if (!existsSync41(path)) return ["artifact_missing"];
85998
+ if (!existsSync42(path)) return ["artifact_missing"];
85337
85999
  try {
85338
- if (!statSync16(path).isFile()) return ["artifact_not_file"];
86000
+ if (!statSync17(path).isFile()) return ["artifact_not_file"];
85339
86001
  } catch {
85340
86002
  return ["artifact_missing"];
85341
86003
  }