@dotobokuri/fleet-console 1.58.0 → 1.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cli.mjs +652 -191
  2. package/dist/client/assets/{_baseUniq-DJ4C0UQF.js → _baseUniq-CKkDoWU8.js} +1 -1
  3. package/dist/client/assets/{arc-DkQKttnC.js → arc-CcRdX8oF.js} +1 -1
  4. package/dist/client/assets/{architectureDiagram-Q4EWVU46-BpuET3uK.js → architectureDiagram-Q4EWVU46-gaFzE1W7.js} +1 -1
  5. package/dist/client/assets/{blockDiagram-DXYQGD6D-CatlulZp.js → blockDiagram-DXYQGD6D-Bzybih30.js} +1 -1
  6. package/dist/client/assets/{c4Diagram-AHTNJAMY-BPfWevDh.js → c4Diagram-AHTNJAMY-Dz8bwV9j.js} +1 -1
  7. package/dist/client/assets/channel-CAhLkt5l.js +1 -0
  8. package/dist/client/assets/{chunk-4BX2VUAB-a7lkla2P.js → chunk-4BX2VUAB-DmgZtGyV.js} +1 -1
  9. package/dist/client/assets/{chunk-4TB4RGXK-Bh-20OVN.js → chunk-4TB4RGXK-DX1WxV3U.js} +1 -1
  10. package/dist/client/assets/{chunk-55IACEB6-DiPm-_AS.js → chunk-55IACEB6-Bk4b3T9u.js} +1 -1
  11. package/dist/client/assets/{chunk-EDXVE4YY-BcGep4mz.js → chunk-EDXVE4YY-BzGadfvT.js} +1 -1
  12. package/dist/client/assets/{chunk-FMBD7UC4-Cn0A6Wm1.js → chunk-FMBD7UC4-44f7YyvW.js} +1 -1
  13. package/dist/client/assets/{chunk-OYMX7WX6-DNTIDjw4.js → chunk-OYMX7WX6-CyUAky9W.js} +1 -1
  14. package/dist/client/assets/{chunk-QZHKN3VN-cji_BhbG.js → chunk-QZHKN3VN-C11OUntR.js} +1 -1
  15. package/dist/client/assets/{chunk-YZCP3GAM-B6I5kLlB.js → chunk-YZCP3GAM-DVTmWawU.js} +1 -1
  16. package/dist/client/assets/classDiagram-6PBFFD2Q-BSvLoE2t.js +1 -0
  17. package/dist/client/assets/classDiagram-v2-HSJHXN6E-BSvLoE2t.js +1 -0
  18. package/dist/client/assets/clone-o26VS_sk.js +1 -0
  19. package/dist/client/assets/{cose-bilkent-S5V4N54A-_Xmui3Dj.js → cose-bilkent-S5V4N54A-CEatGsZv.js} +1 -1
  20. package/dist/client/assets/{dagre-KV5264BT-BI_m6tGN.js → dagre-KV5264BT-DlrgN02H.js} +1 -1
  21. package/dist/client/assets/{diagram-5BDNPKRD-JDBqcRRR.js → diagram-5BDNPKRD-BZ3hRO5t.js} +1 -1
  22. package/dist/client/assets/{diagram-G4DWMVQ6-CdIHKaZT.js → diagram-G4DWMVQ6-B-izS46x.js} +1 -1
  23. package/dist/client/assets/{diagram-MMDJMWI5-CULX6wM5.js → diagram-MMDJMWI5-Cw-wnJGs.js} +1 -1
  24. package/dist/client/assets/{diagram-TYMM5635-C1JXiI2W.js → diagram-TYMM5635-BoWnyd4_.js} +1 -1
  25. package/dist/client/assets/{erDiagram-SMLLAGMA-RJI8bZrW.js → erDiagram-SMLLAGMA-BUmyXZbP.js} +1 -1
  26. package/dist/client/assets/{flowDiagram-DWJPFMVM-CSrF7U0E.js → flowDiagram-DWJPFMVM-COS3kjS0.js} +1 -1
  27. package/dist/client/assets/{ganttDiagram-T4ZO3ILL-CHp3LObA.js → ganttDiagram-T4ZO3ILL-BTr1fdio.js} +1 -1
  28. package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-BEeoTjqh.js → gitGraphDiagram-UUTBAWPF-BkGkaosN.js} +1 -1
  29. package/dist/client/assets/{graph-DNvMdh3j.js → graph-DmbgK-mH.js} +1 -1
  30. package/dist/client/assets/index-C-3spb_b.js +465 -0
  31. package/dist/client/assets/index-FU1PGEfG.css +1 -0
  32. package/dist/client/assets/{infoDiagram-42DDH7IO-31kh8JMu.js → infoDiagram-42DDH7IO-B8zI6k1l.js} +1 -1
  33. package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-DZgEgolJ.js → ishikawaDiagram-UXIWVN3A-cIcEzrcK.js} +1 -1
  34. package/dist/client/assets/{journeyDiagram-VCZTEJTY-DfZ3i3Bu.js → journeyDiagram-VCZTEJTY-DhuabHCk.js} +1 -1
  35. package/dist/client/assets/{kanban-definition-6JOO6SKY-giivFfnv.js → kanban-definition-6JOO6SKY-uHTkqxhX.js} +1 -1
  36. package/dist/client/assets/{layout-DdVRNrH8.js → layout-Cfgk_duA.js} +1 -1
  37. package/dist/client/assets/{linear-3cmeYdGh.js → linear-BKvV0sr5.js} +1 -1
  38. package/dist/client/assets/{mermaid.core-Cjqy_Y5Z.js → mermaid.core-DozmrCuG.js} +4 -4
  39. package/dist/client/assets/{min-Cgsd0one.js → min-ke46otlW.js} +1 -1
  40. package/dist/client/assets/{mindmap-definition-QFDTVHPH-PfuGubxC.js → mindmap-definition-QFDTVHPH-d7xzxhzf.js} +1 -1
  41. package/dist/client/assets/{pieDiagram-DEJITSTG-B9O6H439.js → pieDiagram-DEJITSTG-C4S9Jy5A.js} +1 -1
  42. package/dist/client/assets/{quadrantDiagram-34T5L4WZ-DJH7RQzs.js → quadrantDiagram-34T5L4WZ-CoQnj3kv.js} +1 -1
  43. package/dist/client/assets/{requirementDiagram-MS252O5E-BZHTYV2q.js → requirementDiagram-MS252O5E-CdopMDtg.js} +1 -1
  44. package/dist/client/assets/{sankeyDiagram-XADWPNL6-B5aGVyLG.js → sankeyDiagram-XADWPNL6-DdR4zdh4.js} +1 -1
  45. package/dist/client/assets/{sequenceDiagram-FGHM5R23-D2890FYU.js → sequenceDiagram-FGHM5R23-NeYZWVQm.js} +1 -1
  46. package/dist/client/assets/{stateDiagram-FHFEXIEX-DWmhZMWZ.js → stateDiagram-FHFEXIEX-D0CQGKV_.js} +1 -1
  47. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-hM1GV37r.js +1 -0
  48. package/dist/client/assets/{timeline-definition-GMOUNBTQ-B0pTOfcD.js → timeline-definition-GMOUNBTQ-Bz2b3nfQ.js} +1 -1
  49. package/dist/client/assets/{vennDiagram-DHZGUBPP-D-S4XLnE.js → vennDiagram-DHZGUBPP-CVO2Ja80.js} +1 -1
  50. package/dist/client/assets/{wardley-RL74JXVD-ClPA8Fc3.js → wardley-RL74JXVD-Ba_GKs5u.js} +1 -1
  51. package/dist/client/assets/{wardleyDiagram-NUSXRM2D-JJgj7CxJ.js → wardleyDiagram-NUSXRM2D-yP3xvrPy.js} +1 -1
  52. package/dist/client/assets/{xychartDiagram-5P7HB3ND-BBIy9-Kq.js → xychartDiagram-5P7HB3ND-BLSs6w4C.js} +1 -1
  53. package/dist/client/index.html +2 -2
  54. package/dist/fleet-plugins/quota/routes.mjs +173 -268
  55. package/dist/fleet-plugins/scuttlebutt/routes.mjs +552 -125
  56. package/dist/fleet-plugins/terminal/routes.mjs +5639 -4252
  57. package/dist/fleet.mjs +5694 -5374
  58. package/package.json +1 -1
  59. package/dist/client/assets/channel-DDcyY5eB.js +0 -1
  60. package/dist/client/assets/classDiagram-6PBFFD2Q-CqqUqRwS.js +0 -1
  61. package/dist/client/assets/classDiagram-v2-HSJHXN6E-CqqUqRwS.js +0 -1
  62. package/dist/client/assets/clone-CjMEm_X8.js +0 -1
  63. package/dist/client/assets/index-BG857Idy.css +0 -1
  64. package/dist/client/assets/index-CCNdSGui.js +0 -483
  65. package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-DoQKtZ4H.js +0 -1
package/dist/cli.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import * as fs9 from 'node:fs';
3
- import fs9__default, { constants, realpathSync, accessSync, existsSync, lstatSync } from 'node:fs';
3
+ import fs9__default, { realpathSync, accessSync, constants as constants$1, existsSync, lstatSync } from 'node:fs';
4
4
  import * as path18 from 'node:path';
5
5
  import path18__default, { join, resolve, relative, sep } from 'node:path';
6
6
  import { fileURLToPath, pathToFileURL } from 'node:url';
7
- import { execFile, spawn, execFileSync } from 'node:child_process';
7
+ import { spawn, execFileSync } from 'node:child_process';
8
8
  import process4 from 'node:process';
9
9
  import * as os4 from 'node:os';
10
10
  import os4__default, { tmpdir } from 'node:os';
@@ -15,7 +15,12 @@ import https from 'node:https';
15
15
  import { mkdtemp, rm, mkdir, readdir, readFile, stat, appendFile, writeFile, rename, realpath, lstat } from 'node:fs/promises';
16
16
  import fontList from 'font-list';
17
17
  import net2 from 'node:net';
18
- import { promisify } from 'node:util';
18
+ import { execFile } from 'child_process';
19
+ import { constants } from 'fs';
20
+ import 'fs/promises';
21
+ import os8 from 'os';
22
+ import { promisify } from 'util';
23
+ import { deflateRawSync } from 'zlib';
19
24
  import { EventEmitter } from 'node:events';
20
25
  import { query } from '@anthropic-ai/claude-agent-sdk';
21
26
  import selfsigned from 'selfsigned';
@@ -92,7 +97,7 @@ function isAccessibleExecutable(candidate, platform) {
92
97
  if (!existsSync(candidate)) return false;
93
98
  if (platform === "win32") return true;
94
99
  try {
95
- accessSync(candidate, constants.X_OK);
100
+ accessSync(candidate, constants$1.X_OK);
96
101
  return true;
97
102
  } catch {
98
103
  return false;
@@ -576,10 +581,10 @@ function isProcessAlive(pid) {
576
581
  }
577
582
  function sanitizeLockOwner(value) {
578
583
  if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
579
- const record3 = value;
580
- const pid = record3.pid;
581
- const hostname5 = record3.hostname;
582
- const startedAt = record3.startedAt;
584
+ const record4 = value;
585
+ const pid = record4.pid;
586
+ const hostname5 = record4.hostname;
587
+ const startedAt = record4.startedAt;
583
588
  if (!Number.isInteger(pid) || pid <= 0) return null;
584
589
  if (typeof hostname5 !== "string" || !hostname5) return null;
585
590
  if (!Number.isFinite(startedAt) || startedAt <= 0) return null;
@@ -947,8 +952,8 @@ function readWorkspaceIdentity(identityPath) {
947
952
  }
948
953
  function isWorkspaceDirectoryIdentity(value) {
949
954
  if (typeof value !== "object" || value === null) return false;
950
- const record3 = value;
951
- return typeof record3.cwd === "string" && record3.cwd.length > 0;
955
+ const record4 = value;
956
+ return typeof record4.cwd === "string" && record4.cwd.length > 0;
952
957
  }
953
958
 
954
959
  // ../../packages/core-infra/src/index.ts
@@ -2350,7 +2355,7 @@ async function recordPatchConflict(patch, paths, reason, options) {
2350
2355
  const current = await pathExists(targetPath) ? await readPatchFile(targetPath) : void 0;
2351
2356
  const currentEntry = current ? parseStoredWikiEntry(current) : void 0;
2352
2357
  const proposedEntry = parsePatchBodyEntry(patch.body);
2353
- const record3 = await createConflict({
2358
+ const record4 = await createConflict({
2354
2359
  reason,
2355
2360
  target: patch.frontmatter.target,
2356
2361
  wikiId: proposedEntry?.id ?? path18__default.basename(patch.frontmatter.target, ".md"),
@@ -2369,14 +2374,14 @@ async function recordPatchConflict(patch, paths, reason, options) {
2369
2374
  now
2370
2375
  }, paths);
2371
2376
  await appendLog(paths, "conflict detected", {
2372
- conflict_id: record3.meta.id,
2377
+ conflict_id: record4.meta.id,
2373
2378
  patch_id: options?.patchId ?? null,
2374
2379
  raw_source_ref: options?.rawSourceRef ?? null,
2375
2380
  reason,
2376
2381
  target: patch.frontmatter.target,
2377
- wiki_id: record3.meta.wikiId
2382
+ wiki_id: record4.meta.wikiId
2378
2383
  }, now);
2379
- return record3.meta.id;
2384
+ return record4.meta.id;
2380
2385
  }
2381
2386
  function parsePatchBodyEntry(content) {
2382
2387
  try {
@@ -2578,7 +2583,7 @@ async function readWikiEntry(id, paths) {
2578
2583
  return readMarkdownFile(fallbackPath);
2579
2584
  }
2580
2585
  const records = await listWikiRecords(paths);
2581
- const match = records.find((record3) => record3.entry.id === id);
2586
+ const match = records.find((record4) => record4.entry.id === id);
2582
2587
  return match ? match.entry : null;
2583
2588
  }
2584
2589
  async function resolveWikiEntryPath(id, paths) {
@@ -2601,7 +2606,7 @@ async function resolveWikiEntryPath(id, paths) {
2601
2606
  return path18__default.relative(paths.root, fallbackPath).replaceAll(path18__default.sep, "/");
2602
2607
  }
2603
2608
  const records = await listWikiRecords(paths);
2604
- const match = records.find((record3) => record3.entry.id === id);
2609
+ const match = records.find((record4) => record4.entry.id === id);
2605
2610
  return match ? match.path : null;
2606
2611
  }
2607
2612
  async function writeWikiEntryAtTarget(entry, target, paths) {
@@ -5077,8 +5082,8 @@ function CreateObject(types, value) {
5077
5082
  }
5078
5083
  function FromUnionKey(types, value) {
5079
5084
  const flattened = Flatten(types);
5080
- const record3 = TryBuildRecord(flattened, value);
5081
- return IsSchema(record3) ? record3 : CreateObject(flattened, value);
5085
+ const record4 = TryBuildRecord(flattened, value);
5086
+ return IsSchema(record4) ? record4 : CreateObject(flattened, value);
5082
5087
  }
5083
5088
 
5084
5089
  // ../../node_modules/.pnpm/typebox@1.1.34/node_modules/typebox/build/type/engine/record/from_key.mjs
@@ -9710,7 +9715,7 @@ async function stageIngestPlan(plan, paths) {
9710
9715
  })
9711
9716
  };
9712
9717
  if (plan.kind === "conflict") {
9713
- const record3 = await createConflict({
9718
+ const record4 = await createConflict({
9714
9719
  reason: plan.conflict.reason,
9715
9720
  target: `wiki/${entry.id}.md`,
9716
9721
  wikiId: entry.id,
@@ -9728,17 +9733,17 @@ async function stageIngestPlan(plan, paths) {
9728
9733
  warnings: plan.warnings
9729
9734
  }, paths);
9730
9735
  await appendLog(paths, "conflict detected", {
9731
- conflict_id: record3.meta.id,
9736
+ conflict_id: record4.meta.id,
9732
9737
  patch_id: null,
9733
9738
  raw_source_ref: rawSourceRef,
9734
9739
  reason: plan.conflict.reason,
9735
- target: record3.meta.target,
9736
- wiki_id: record3.meta.wikiId
9740
+ target: record4.meta.target,
9741
+ wiki_id: record4.meta.wikiId
9737
9742
  });
9738
9743
  return {
9739
9744
  ok: false,
9740
9745
  mode: plan.mode,
9741
- conflict_id: record3.meta.id,
9746
+ conflict_id: record4.meta.id,
9742
9747
  raw_source_ref: rawSourceRef,
9743
9748
  warnings: plan.warnings
9744
9749
  };
@@ -10284,11 +10289,11 @@ function applyBodyReplacement(entry, replaceInput) {
10284
10289
  }
10285
10290
  function parseBodyReplace(value) {
10286
10291
  if (value === void 0 || value === null) return void 0;
10287
- const record3 = value;
10292
+ const record4 = value;
10288
10293
  return {
10289
- find: String(record3.find ?? ""),
10290
- replace: String(record3.replace ?? ""),
10291
- expected_occurrences: typeof record3.expected_occurrences === "number" ? record3.expected_occurrences : void 0
10294
+ find: String(record4.find ?? ""),
10295
+ replace: String(record4.replace ?? ""),
10296
+ expected_occurrences: typeof record4.expected_occurrences === "number" ? record4.expected_occurrences : void 0
10292
10297
  };
10293
10298
  }
10294
10299
  function stringParam(value) {
@@ -11732,9 +11737,9 @@ function readMarker(markerPath) {
11732
11737
  throw new Error("Invalid Fleet Wiki migration marker");
11733
11738
  }
11734
11739
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Invalid Fleet Wiki migration marker");
11735
- const record3 = value;
11736
- if (record3.version !== 1 || record3.outcome !== "copied" || typeof record3.transactionId !== "string" || !/^[0-9a-f-]{36}$/i.test(record3.transactionId) || typeof record3.completedAt !== "string") throw new Error("Invalid Fleet Wiki migration marker");
11737
- return record3;
11740
+ const record4 = value;
11741
+ if (record4.version !== 1 || record4.outcome !== "copied" || typeof record4.transactionId !== "string" || !/^[0-9a-f-]{36}$/i.test(record4.transactionId) || typeof record4.completedAt !== "string") throw new Error("Invalid Fleet Wiki migration marker");
11742
+ return record4;
11738
11743
  }
11739
11744
  function copyTree(source, destination, hooks, sourceRoot = source) {
11740
11745
  fs9.mkdirSync(destination, { recursive: true });
@@ -12530,16 +12535,16 @@ function isValidRemoteAccessInput(value) {
12530
12535
  return value.listenAddress !== "" && value.advertisedHost !== "" && acknowledgmentMatches({ listenAddress: value.listenAddress, advertisedHost: value.advertisedHost, listenPort, advertisedPort }, acknowledgment);
12531
12536
  }
12532
12537
  function normalizeRemoteAccessInput(value) {
12533
- const record3 = value;
12534
- const publicEndpointEnabled = record3.publicEndpointEnabled === true;
12538
+ const record4 = value;
12539
+ const publicEndpointEnabled = record4.publicEndpointEnabled === true;
12535
12540
  return {
12536
- enabled: record3.enabled === true,
12541
+ enabled: record4.enabled === true,
12537
12542
  publicEndpointEnabled,
12538
- listenAddress: record3.listenAddress === "" ? "" : canonicalizeRemoteBindHost(record3.listenAddress),
12539
- advertisedHost: record3.advertisedHost === "" ? "" : canonicalizeRemoteBindHost(record3.advertisedHost),
12540
- listenPort: sanitizeRemotePortSetting(record3.listenPort),
12541
- advertisedPort: sanitizeRemotePortSetting(record3.advertisedPort),
12542
- acknowledgment: publicEndpointEnabled ? sanitizeAcknowledgment(record3.acknowledgment) : null
12543
+ listenAddress: record4.listenAddress === "" ? "" : canonicalizeRemoteBindHost(record4.listenAddress),
12544
+ advertisedHost: record4.advertisedHost === "" ? "" : canonicalizeRemoteBindHost(record4.advertisedHost),
12545
+ listenPort: sanitizeRemotePortSetting(record4.listenPort),
12546
+ advertisedPort: sanitizeRemotePortSetting(record4.advertisedPort),
12547
+ acknowledgment: publicEndpointEnabled ? sanitizeAcknowledgment(record4.acknowledgment) : null
12543
12548
  };
12544
12549
  }
12545
12550
  function withRemoteAccessVisibility(state, req, deps) {
@@ -14565,10 +14570,10 @@ var CoworkStore = class {
14565
14570
  }
14566
14571
  const now = (/* @__PURE__ */ new Date()).toISOString();
14567
14572
  const id = crypto5.randomUUID();
14568
- const record3 = { id, workspaceId, entryId, state: "idle", revision: 0, draft: body2, baseDraft: body2, baseHash, baseVersion, selection: null, annotations: [], ...identity2, targetPath, createdAt: now, updatedAt: now };
14569
- this.sessions.set(this.key(workspaceId, id), record3);
14573
+ const record4 = { id, workspaceId, entryId, state: "idle", revision: 0, draft: body2, baseDraft: body2, baseHash, baseVersion, selection: null, annotations: [], ...identity2, targetPath, createdAt: now, updatedAt: now };
14574
+ this.sessions.set(this.key(workspaceId, id), record4);
14570
14575
  this.writers.set(`${workspaceId}:${entryId}`, id);
14571
- return record3;
14576
+ return record4;
14572
14577
  }
14573
14578
  async get(workspaceId, sessionId) {
14574
14579
  return this.sessions.get(this.key(workspaceId, sessionId)) ?? null;
@@ -14634,9 +14639,9 @@ var CoworkStore = class {
14634
14639
  }
14635
14640
  return dir;
14636
14641
  }
14637
- release(record3) {
14638
- this.writers.delete(`${record3.workspaceId}:${record3.entryId}`);
14639
- const key = this.key(record3.workspaceId, record3.id);
14642
+ release(record4) {
14643
+ this.writers.delete(`${record4.workspaceId}:${record4.entryId}`);
14644
+ const key = this.key(record4.workspaceId, record4.id);
14640
14645
  const dir = this.scratchDirs.get(key);
14641
14646
  this.scratchDirs.delete(key);
14642
14647
  if (dir) void rm(dir, { recursive: true, force: true }).catch(() => void 0);
@@ -15763,7 +15768,7 @@ function defaultSpawnInstall(file2, args) {
15763
15768
  }
15764
15769
  function defaultCanWrite(targetPath) {
15765
15770
  try {
15766
- accessSync(targetPath, constants.W_OK);
15771
+ accessSync(targetPath, constants$1.W_OK);
15767
15772
  return true;
15768
15773
  } catch {
15769
15774
  return false;
@@ -15796,7 +15801,7 @@ function createCoworkMcpRuntime(store, workspaceId, sessionId, resolver) {
15796
15801
  const allowedToolIds = ["wiki_draft_read", "wiki_draft_edit", "wiki_draft_write", "wiki_briefing", "wiki_orient", "wiki_read", "wiki_resolve"];
15797
15802
  const specs = [...draftTools, ...getWikiToolSpecs(resolver).filter((spec) => allowedToolIds.includes(spec.id))];
15798
15803
  for (const spec of specs) registry3.registerAgentTool(spec);
15799
- return { registry: registry3, snapshots, server, manager, specs, allowedToolIds, connection: { strictMcp: true, yoloMode: true, autoApprove: true } };
15804
+ return { registry: registry3, snapshots, server, manager, specs, allowedToolIds };
15800
15805
  }
15801
15806
  function clipText(value, max) {
15802
15807
  return value.length > max ? `${value.slice(0, max - 1)}\u2026` : value;
@@ -15854,7 +15859,7 @@ var CoworkService = class {
15854
15859
  const runtime = createCoworkMcpRuntime(this.store, workspaceId, id, this.resolver);
15855
15860
  const mcp = await runtime.manager.createExecutorMcpSession({ serverName: "cowork", specs: runtime.specs, cwd: this.cwd });
15856
15861
  const providerCwd = await this.store.sessionDir(workspaceId, id);
15857
- const client = await this.connector.connect({ cwd: providerCwd, cli: session.cli, model: session.model, effort: session.effort, systemPrompt: COWORK_SYSTEM_PROMPT, mcpServers: [mcp.mcpServer], allowedToolIds: [...runtime.allowedToolIds], ...runtime.connection });
15862
+ const client = await this.connector.connect({ cwd: providerCwd, model: session.model, effort: session.effort, systemPrompt: COWORK_SYSTEM_PROMPT, mcpServers: [mcp.mcpServer], allowedToolIds: [...runtime.allowedToolIds] });
15858
15863
  this.releaseLive(id);
15859
15864
  this.live.set(id, { workspaceId, client, annotations, cleanup: () => {
15860
15865
  try {
@@ -33453,8 +33458,6 @@ function fileDesc(b64, imports) {
33453
33458
  const reg = createFileRegistry(root, (protoFileName) => void 0 );
33454
33459
  return reg.getFile(root.name);
33455
33460
  }
33456
-
33457
- // ../../packages/core-ai-gateway/dist/index.js
33458
33461
  var REASONING_EFFORTS = [
33459
33462
  "minimal",
33460
33463
  "low",
@@ -33626,6 +33629,26 @@ var benchmarks_default = {
33626
33629
  }
33627
33630
  }
33628
33631
  },
33632
+ "claude-opus-5": {
33633
+ source: "cursorbench",
33634
+ rungs: {
33635
+ low: { score: 62.8, tokensPerTask: 18529, stepsPerTask: 37 },
33636
+ medium: { score: 64.3, tokensPerTask: 23612, stepsPerTask: 44 },
33637
+ high: { score: 66.7, tokensPerTask: 27932, stepsPerTask: 48 },
33638
+ xhigh: { score: 69.3, tokensPerTask: 54239, stepsPerTask: 72 },
33639
+ max: { score: 70, tokensPerTask: 61838, stepsPerTask: 78 }
33640
+ }
33641
+ },
33642
+ "claude-fable-5": {
33643
+ source: "cursorbench",
33644
+ rungs: {
33645
+ low: { score: 62.1, tokensPerTask: 18182, stepsPerTask: 31 },
33646
+ medium: { score: 65.2, tokensPerTask: 30366, stepsPerTask: 41 },
33647
+ high: { score: 66.5, tokensPerTask: 43747, stepsPerTask: 48 },
33648
+ xhigh: { score: 68.4, tokensPerTask: 64971, stepsPerTask: 56 },
33649
+ max: { score: 70.5, tokensPerTask: 103525, stepsPerTask: 72 }
33650
+ }
33651
+ },
33629
33652
  "kimi-k3": {
33630
33653
  source: "cursorbench",
33631
33654
  rungs: {
@@ -33674,7 +33697,7 @@ var benchmarks_default = {
33674
33697
  };
33675
33698
  var models_default = {
33676
33699
  version: 1,
33677
- updatedAt: "2026-08-14T00:00:00Z",
33700
+ updatedAt: "2026-08-15T00:00:00Z",
33678
33701
  providers: {
33679
33702
  codex: {
33680
33703
  name: "Codex",
@@ -33816,7 +33839,7 @@ var models_default = {
33816
33839
  cursor: {
33817
33840
  name: "Cursor",
33818
33841
  defaultModel: "auto",
33819
- source: "Cursor GetUsableModels + Run conversationCheckpointUpdate.token_details.max_tokens (cli-2026.07.08-0c04a8a; auto, composer-2.5, and grok-4.5 families observed 2026-08-01); cursor-agent 2026.08.11-e8db854 observed 2026-08-13 for grok-4.6; quotaScope from DashboardService/GetCurrentPeriodUsage autoBucketModels (2026-08-05)",
33842
+ source: "Cursor GetUsableModels + Run conversationCheckpointUpdate.token_details.max_tokens (cli-2026.07.08-0c04a8a; auto, composer-2.5, and grok-4.5 families observed 2026-08-01); cursor-agent 2026.08.11-e8db854 observed 2026-08-13 for grok-4.6; claude-opus-5 and claude-fable-5 standard/Max Mode windows observed 2026-08-10; quotaScope from DashboardService/GetCurrentPeriodUsage autoBucketModels (2026-08-05)",
33820
33843
  models: [
33821
33844
  {
33822
33845
  modelId: "auto",
@@ -33910,6 +33933,94 @@ var models_default = {
33910
33933
  ],
33911
33934
  upstreamModelIdTemplate: "cursor-grok-4.6-{effort}-fast"
33912
33935
  }
33936
+ },
33937
+ {
33938
+ modelId: "claude-opus-5",
33939
+ name: "Opus-5",
33940
+ capabilityClass: "flagship",
33941
+ quotaScope: "api",
33942
+ contextWindow: 3e5,
33943
+ effort: {
33944
+ supported: true,
33945
+ levels: [
33946
+ "low",
33947
+ "medium",
33948
+ "high",
33949
+ "xhigh",
33950
+ "max"
33951
+ ],
33952
+ upstreamModelIdTemplate: "claude-opus-5-{effort}",
33953
+ upstreamModelIds: {
33954
+ xhigh: "claude-opus-5-thinking-xhigh",
33955
+ max: "claude-opus-5-thinking-max"
33956
+ }
33957
+ },
33958
+ benchmarkKey: "claude-opus-5"
33959
+ },
33960
+ {
33961
+ modelId: "claude-opus-5-1m",
33962
+ name: "Opus-5-1M",
33963
+ capabilityClass: "flagship",
33964
+ quotaScope: "api",
33965
+ contextWindow: 1e6,
33966
+ cursorMaxMode: true,
33967
+ effort: {
33968
+ supported: true,
33969
+ levels: [
33970
+ "low",
33971
+ "medium",
33972
+ "high",
33973
+ "xhigh",
33974
+ "max"
33975
+ ],
33976
+ upstreamModelIdTemplate: "claude-opus-5-{effort}",
33977
+ upstreamModelIds: {
33978
+ xhigh: "claude-opus-5-thinking-xhigh",
33979
+ max: "claude-opus-5-thinking-max"
33980
+ }
33981
+ },
33982
+ benchmarkKey: "claude-opus-5"
33983
+ },
33984
+ {
33985
+ modelId: "claude-fable-5",
33986
+ name: "Fable-5",
33987
+ capabilityClass: "flagship",
33988
+ quotaScope: "api",
33989
+ description: "NO ZDR",
33990
+ contextWindow: 3e5,
33991
+ effort: {
33992
+ supported: true,
33993
+ levels: [
33994
+ "low",
33995
+ "medium",
33996
+ "high",
33997
+ "xhigh",
33998
+ "max"
33999
+ ],
34000
+ upstreamModelIdTemplate: "claude-fable-5-{effort}"
34001
+ },
34002
+ benchmarkKey: "claude-fable-5"
34003
+ },
34004
+ {
34005
+ modelId: "claude-fable-5-1m",
34006
+ name: "Fable-5-1M",
34007
+ capabilityClass: "flagship",
34008
+ quotaScope: "api",
34009
+ description: "NO ZDR",
34010
+ contextWindow: 1e6,
34011
+ cursorMaxMode: true,
34012
+ effort: {
34013
+ supported: true,
34014
+ levels: [
34015
+ "low",
34016
+ "medium",
34017
+ "high",
34018
+ "xhigh",
34019
+ "max"
34020
+ ],
34021
+ upstreamModelIdTemplate: "claude-fable-5-{effort}"
34022
+ },
34023
+ benchmarkKey: "claude-fable-5"
33913
34024
  }
33914
34025
  ]
33915
34026
  },
@@ -34523,13 +34634,14 @@ promisify(execFile);
34523
34634
  process.platform === "win32" ? constants.O_RDONLY : constants.O_RDONLY | constants.O_NONBLOCK;
34524
34635
  ({
34525
34636
  platform: process.platform,
34526
- homedir: os4__default.homedir,
34637
+ homedir: os8.homedir,
34527
34638
  env: process.env});
34528
- var CURSOR_GREP_RECEIPT_PREFIX = "FLEET_CURSOR_GREP_V1:";
34529
- String.raw`
34639
+ var CURSOR_GREP_RECEIPT_PREFIX = "FLEET_CURSOR_GREP_V2:";
34640
+ var CURSOR_GREP_RECEIPT_SCRIPT = String.raw`
34530
34641
  const {spawn}=require("node:child_process");
34531
34642
  const {TextDecoder}=require("node:util");
34532
- const emit=(value)=>process.stdout.write("${CURSOR_GREP_RECEIPT_PREFIX}"+Buffer.from(JSON.stringify(value)).toString("base64url"));
34643
+ const {deflateRawSync}=require("node:zlib");
34644
+ const emit=(value)=>process.stdout.write("${CURSOR_GREP_RECEIPT_PREFIX}"+deflateRawSync(Buffer.from(JSON.stringify(value))).toString("base64url"));
34533
34645
  (async()=>{try {
34534
34646
  const input=JSON.parse(Buffer.from(process.argv[1],"base64url").toString("utf8"));
34535
34647
  const matchSeparator=30;
@@ -34615,6 +34727,7 @@ const emit=(value)=>process.stdout.write("${CURSOR_GREP_RECEIPT_PREFIX}"+Buffer.
34615
34727
  emit({ok:true,outputMode:input.outputMode,files,counts,matches,totalFiles,totalLines,totalMatchedLines,clientTruncated});
34616
34728
  }catch(error){emit({ok:false,error:error instanceof Error?error.message:String(error)});}})();
34617
34729
  `.trim();
34730
+ deflateRawSync(CURSOR_GREP_RECEIPT_SCRIPT).toString("base64url");
34618
34731
  var cursorAgentDescriptor = [
34619
34732
  "CgthZ2VudC5wcm90bxIIYWdlbnQudjEicgoOR2xvYlRvb2xSZXN1bHQSLAoHc3VjY2VzcxgBIAEoCzIZLmFnZW50LnYxLkdsb2JUb29sU3VjY2Vzc0gAEigK",
34620
34733
  "BWVycm9yGAIgASgLMhcuYWdlbnQudjEuR2xvYlRvb2xFcnJvckgAQggKBnJlc3VsdCIeCg1HbG9iVG9vbEVycm9yEg0KBWVycm9yGAEgASgJIokBCg9HbG9i",
@@ -35468,7 +35581,11 @@ function runVendorQuery(input) {
35468
35581
  close() {
35469
35582
  if (closed) return;
35470
35583
  closed = true;
35471
- void run.return?.(void 0);
35584
+ try {
35585
+ const closing = run.return?.(void 0);
35586
+ if (closing !== void 0) void closing.catch(() => void 0);
35587
+ } catch {
35588
+ }
35472
35589
  }
35473
35590
  };
35474
35591
  }
@@ -35538,8 +35655,11 @@ async function createClaudeGatewaySdk(options) {
35538
35655
  };
35539
35656
  },
35540
35657
  close() {
35541
- run.close();
35542
- release();
35658
+ try {
35659
+ run.close();
35660
+ } finally {
35661
+ release();
35662
+ }
35543
35663
  }
35544
35664
  };
35545
35665
  active = tracked;
@@ -35636,6 +35756,364 @@ function vendorServedMcpServers(servers) {
35636
35756
  }]));
35637
35757
  }
35638
35758
 
35759
+ // ../../packages/core-agent/src/claude/execution-events.ts
35760
+ function createClaudeExecutionEventDecoder() {
35761
+ const toolNames = /* @__PURE__ */ new Map();
35762
+ return {
35763
+ decode(message) {
35764
+ if (!isRecord5(message)) return [];
35765
+ if (message.type === "stream_event") return decodeStreamEvent(message);
35766
+ if (message.type === "assistant") return decodeAssistant(message, toolNames);
35767
+ if (message.type === "user") return decodeUser(message, toolNames);
35768
+ if (message.type === "result") return decodeResult(message);
35769
+ return [];
35770
+ }
35771
+ };
35772
+ }
35773
+ function decodeStreamEvent(message) {
35774
+ const inner = record2(message.event);
35775
+ if (inner.type !== "content_block_delta") return [];
35776
+ const delta = record2(inner.delta);
35777
+ if (delta.type === "text_delta" && typeof delta.text === "string" && delta.text.length > 0) {
35778
+ return [{ kind: "text", text: delta.text }];
35779
+ }
35780
+ if (delta.type === "thinking_delta" && typeof delta.thinking === "string" && delta.thinking.length > 0) {
35781
+ return [{ kind: "thinking", text: delta.thinking }];
35782
+ }
35783
+ return [];
35784
+ }
35785
+ function decodeAssistant(message, toolNames) {
35786
+ const events = [];
35787
+ for (const block of blocks(message.message)) {
35788
+ if (block.type !== "tool_use") continue;
35789
+ const name = typeof block.name === "string" ? block.name : "tool";
35790
+ const id = typeof block.id === "string" ? block.id : void 0;
35791
+ if (id !== void 0) toolNames.set(id, name);
35792
+ events.push({
35793
+ kind: "tool-start",
35794
+ ...id === void 0 ? {} : { id },
35795
+ name,
35796
+ input: block.input
35797
+ });
35798
+ }
35799
+ return events;
35800
+ }
35801
+ function decodeUser(message, toolNames) {
35802
+ const events = [];
35803
+ for (const block of blocks(message.message)) {
35804
+ if (block.type !== "tool_result") continue;
35805
+ const id = typeof block.tool_use_id === "string" ? block.tool_use_id : void 0;
35806
+ const name = id === void 0 ? void 0 : toolNames.get(id);
35807
+ events.push({
35808
+ kind: "tool-end",
35809
+ ...id === void 0 ? {} : { id },
35810
+ ...name === void 0 ? {} : { name },
35811
+ isError: block.is_error === true
35812
+ });
35813
+ }
35814
+ return events;
35815
+ }
35816
+ function decodeResult(message) {
35817
+ return [{
35818
+ kind: "result",
35819
+ isError: message.is_error === true,
35820
+ ...typeof message.result === "string" ? { detail: message.result } : {},
35821
+ source: "message"
35822
+ }];
35823
+ }
35824
+ function blocks(message) {
35825
+ const content = record2(message).content;
35826
+ return Array.isArray(content) ? content.map(record2) : [];
35827
+ }
35828
+ function record2(value) {
35829
+ return isRecord5(value) ? value : {};
35830
+ }
35831
+ function isRecord5(value) {
35832
+ return value !== null && typeof value === "object" && !Array.isArray(value);
35833
+ }
35834
+
35835
+ // ../../packages/core-agent/src/claude/execution-loop.ts
35836
+ function createClaudeExecutionLoop(options) {
35837
+ let sdk = null;
35838
+ let started = false;
35839
+ let disposed = false;
35840
+ let active = null;
35841
+ let cancelTurn = null;
35842
+ let resumeId = null;
35843
+ let queueTail = Promise.resolve();
35844
+ let startFlight = null;
35845
+ let disposeFlight = null;
35846
+ async function start() {
35847
+ if (disposed) throw new Error("Session disposed");
35848
+ if (started) return;
35849
+ if (startFlight === null) startFlight = startSdk();
35850
+ try {
35851
+ await startFlight;
35852
+ } catch (error51) {
35853
+ if (!disposed) startFlight = null;
35854
+ throw error51;
35855
+ }
35856
+ }
35857
+ async function startSdk() {
35858
+ const created = await options.createSdk();
35859
+ if (disposed) {
35860
+ await created.dispose().catch(() => void 0);
35861
+ throw new Error("Session disposed");
35862
+ }
35863
+ sdk = created;
35864
+ started = true;
35865
+ if (disposed) {
35866
+ sdk = null;
35867
+ started = false;
35868
+ await created.dispose().catch(() => void 0);
35869
+ throw new Error("Session disposed");
35870
+ }
35871
+ }
35872
+ function run(prompt) {
35873
+ if (disposed) return Promise.reject(new Error("Session disposed"));
35874
+ if (!started || sdk === null) return Promise.reject(new Error("Session not started"));
35875
+ if (typeof prompt !== "string" || prompt.trim().length === 0) {
35876
+ return Promise.reject(new Error("Message required"));
35877
+ }
35878
+ const control = createTurnControl();
35879
+ if (cancelTurn === null) cancelTurn = control.cancel;
35880
+ const work = queueTail.then(async () => {
35881
+ if (cancelTurn === null) cancelTurn = control.cancel;
35882
+ try {
35883
+ await runTurn(prompt, control);
35884
+ } finally {
35885
+ if (cancelTurn === control.cancel) cancelTurn = null;
35886
+ }
35887
+ });
35888
+ queueTail = work.catch(() => void 0);
35889
+ return work;
35890
+ }
35891
+ function closeRun(expected) {
35892
+ const current = active;
35893
+ if (current === null || current.run !== expected) return;
35894
+ current.close();
35895
+ }
35896
+ function cancel() {
35897
+ cancelTurn?.();
35898
+ }
35899
+ function dispose() {
35900
+ if (disposeFlight) return disposeFlight;
35901
+ disposed = true;
35902
+ active?.stop();
35903
+ disposeFlight = disposeResources();
35904
+ return disposeFlight;
35905
+ }
35906
+ async function disposeResources() {
35907
+ let observed = queueTail;
35908
+ for (; ; ) {
35909
+ await observed.catch(() => void 0);
35910
+ if (observed === queueTail) break;
35911
+ observed = queueTail;
35912
+ }
35913
+ await startFlight?.catch(() => void 0);
35914
+ const owned = sdk;
35915
+ sdk = null;
35916
+ started = false;
35917
+ await owned?.dispose().catch(() => void 0);
35918
+ }
35919
+ async function runTurn(prompt, control) {
35920
+ if (disposed) return;
35921
+ const owned = sdk;
35922
+ if (!owned) throw new Error("Session not started");
35923
+ let settled = false;
35924
+ let failed = false;
35925
+ let failure;
35926
+ let pendingResult;
35927
+ let timer;
35928
+ let handle = null;
35929
+ const decoder = createClaudeExecutionEventDecoder();
35930
+ const gate = createGate();
35931
+ const clearTimer = () => {
35932
+ if (timer === void 0) return;
35933
+ clearTimeout(timer);
35934
+ timer = void 0;
35935
+ };
35936
+ const complete = () => {
35937
+ if (settled) return;
35938
+ settled = true;
35939
+ try {
35940
+ clearTimer();
35941
+ if (handle !== null) closeRun(handle.run);
35942
+ } finally {
35943
+ gate.open();
35944
+ }
35945
+ };
35946
+ const fail = (error51) => {
35947
+ if (!failed) {
35948
+ failed = true;
35949
+ failure = error51;
35950
+ }
35951
+ complete();
35952
+ };
35953
+ const queueResult = (event) => {
35954
+ if (settled) return;
35955
+ pendingResult = event;
35956
+ complete();
35957
+ };
35958
+ control.onCancel = () => {
35959
+ if (handle !== null) complete();
35960
+ };
35961
+ try {
35962
+ if (control.canceled) return;
35963
+ const built = await options.buildTurn(prompt);
35964
+ if (disposed || control.canceled) return;
35965
+ assertLoopOwnedKeysAbsent(built);
35966
+ const resume = options.continuation.kind === "resume-child" && resumeId !== null ? { resume: resumeId } : {};
35967
+ let run2;
35968
+ try {
35969
+ run2 = await owned.startTurn({ ...built, prompt, ...resume });
35970
+ } catch (error51) {
35971
+ if (disposed || control.canceled) return;
35972
+ throw error51;
35973
+ }
35974
+ const startedRun = run2;
35975
+ let closed = false;
35976
+ handle = {
35977
+ run: startedRun,
35978
+ stop() {
35979
+ complete();
35980
+ },
35981
+ close() {
35982
+ if (closed) return;
35983
+ closed = true;
35984
+ if (active === handle) active = null;
35985
+ try {
35986
+ startedRun.close();
35987
+ } catch {
35988
+ }
35989
+ }
35990
+ };
35991
+ active = handle;
35992
+ if (disposed || control.canceled) {
35993
+ complete();
35994
+ return;
35995
+ }
35996
+ timer = armWatchdog(options.settlement, () => {
35997
+ try {
35998
+ if (settled || disposed) return;
35999
+ queueResult({ kind: "result", isError: true, source: "watchdog" });
36000
+ } catch {
36001
+ }
36002
+ });
36003
+ const consume = async () => {
36004
+ let iterator;
36005
+ try {
36006
+ iterator = startedRun[Symbol.asyncIterator]();
36007
+ while (!settled) {
36008
+ const step = await iterator.next();
36009
+ if (step.done) {
36010
+ if (!settled && !disposed && options.settlement.kind === "result-required") {
36011
+ queueResult({ kind: "result", isError: true, source: "incomplete" });
36012
+ }
36013
+ break;
36014
+ }
36015
+ if (settled || disposed) break;
36016
+ const message = step.value;
36017
+ if (options.continuation.kind === "resume-child" && resumeId === null && typeof message.session_id === "string") {
36018
+ resumeId = message.session_id;
36019
+ }
36020
+ for (const event of decoder.decode(message)) {
36021
+ if (event.kind === "result") {
36022
+ queueResult(event);
36023
+ break;
36024
+ }
36025
+ try {
36026
+ options.onEvent?.(event);
36027
+ } catch (error51) {
36028
+ fail(error51);
36029
+ break;
36030
+ }
36031
+ }
36032
+ }
36033
+ } catch (error51) {
36034
+ if (disposed || settled) return;
36035
+ fail(error51);
36036
+ } finally {
36037
+ complete();
36038
+ const closing = iterator?.return?.();
36039
+ if (closing !== void 0) void closing.catch(() => void 0);
36040
+ }
36041
+ };
36042
+ const consumption = consume();
36043
+ consumption.catch(() => void 0);
36044
+ await gate.promise;
36045
+ if (disposed) return;
36046
+ if (pendingResult !== void 0 && !failed) {
36047
+ try {
36048
+ options.onEvent?.(pendingResult);
36049
+ } catch (error51) {
36050
+ failed = true;
36051
+ failure = error51;
36052
+ }
36053
+ }
36054
+ } catch (error51) {
36055
+ if (!disposed && !control.canceled && !failed) {
36056
+ failed = true;
36057
+ failure = error51;
36058
+ }
36059
+ } finally {
36060
+ control.onCancel = null;
36061
+ complete();
36062
+ }
36063
+ if (disposed) return;
36064
+ if (failed) return Promise.reject(failure);
36065
+ }
36066
+ return { start, run, cancel, dispose };
36067
+ }
36068
+ function createTurnControl() {
36069
+ const control = {
36070
+ canceled: false,
36071
+ onCancel: null,
36072
+ cancel() {
36073
+ control.canceled = true;
36074
+ control.onCancel?.();
36075
+ }
36076
+ };
36077
+ return control;
36078
+ }
36079
+ function assertLoopOwnedKeysAbsent(built) {
36080
+ if (!built || typeof built !== "object") return;
36081
+ const record4 = built;
36082
+ if (Object.hasOwn(record4, "prompt") || Object.hasOwn(record4, "resume")) {
36083
+ throw new TypeError("buildTurn must not set prompt or resume; those keys are loop-owned.");
36084
+ }
36085
+ }
36086
+ function watchdogMsOf(settlement) {
36087
+ if (settlement.kind !== "result-required") return void 0;
36088
+ const watchdogMs = settlement.watchdogMs;
36089
+ if (typeof watchdogMs !== "number" || !Number.isFinite(watchdogMs) || watchdogMs <= 0) {
36090
+ return void 0;
36091
+ }
36092
+ return watchdogMs;
36093
+ }
36094
+ function createGate() {
36095
+ let opened = false;
36096
+ let resolvePromise = () => void 0;
36097
+ const promise2 = new Promise((resolve3) => {
36098
+ resolvePromise = resolve3;
36099
+ });
36100
+ return {
36101
+ promise: promise2,
36102
+ open() {
36103
+ if (opened) return;
36104
+ opened = true;
36105
+ resolvePromise();
36106
+ }
36107
+ };
36108
+ }
36109
+ function armWatchdog(settlement, onTimeout) {
36110
+ const watchdogMs = watchdogMsOf(settlement);
36111
+ if (watchdogMs === void 0) return void 0;
36112
+ const timer = setTimeout(onTimeout, watchdogMs);
36113
+ timer.unref?.();
36114
+ return timer;
36115
+ }
36116
+
35639
36117
  // core/host/codex/cowork/gateway-adapter.ts
35640
36118
  var GATEWAY_EFFORTS = /* @__PURE__ */ new Set(["low", "medium", "high", "xhigh", "max"]);
35641
36119
  var TURN_WATCHDOG_MS = 10 * 60 * 1e3;
@@ -35668,128 +36146,105 @@ function createCoworkGatewayConnector(deps) {
35668
36146
  const baseUrl = deps.baseUrl();
35669
36147
  if (!baseUrl) throw new Error("cowork_gateway_unavailable");
35670
36148
  const model = options.model && options.model.length > 0 ? options.model : "sonnet";
35671
- const sdk = await createClaudeGatewaySdk({ baseUrl, models: [model] });
35672
- return new CoworkGatewayClient(sdk, options, model);
36149
+ const client = new CoworkGatewayClient();
36150
+ const loop = createClaudeExecutionLoop({
36151
+ createSdk: () => {
36152
+ const create2 = { baseUrl, models: [model] };
36153
+ return deps.createSdk?.(create2) ?? createClaudeGatewaySdk(create2);
36154
+ },
36155
+ buildTurn: () => {
36156
+ const effort = options.effort;
36157
+ const served = toServedMcpServers(options.mcpServers);
36158
+ return {
36159
+ model,
36160
+ systemPrompt: { mode: "replace", text: options.systemPrompt },
36161
+ cwd: options.cwd,
36162
+ disallowedTools: COWORK_DISALLOWED_TOOLS,
36163
+ // 위키 도구는 호스트가 이미 띄운 HTTP MCP 엔드포인트로 온다. 이것을 싣지 않으면 자식은
36164
+ // 시스템 프롬프트가 말하는 도구 이름을 부르지만 그런 도구가 없어 그대로 턴이 끝난다.
36165
+ servedMcpServers: served,
36166
+ // dontAsk는 사전승인되지 않은 도구를 묻지 않고 거부한다 — 노출한 도구는 전부 승인해 둔다.
36167
+ allowedTools: served.flatMap((server) => options.allowedToolIds.map((id) => `mcp__${server.name}__${id}`)),
36168
+ permissionMode: "dontAsk",
36169
+ includePartialMessages: true,
36170
+ ...effort && GATEWAY_EFFORTS.has(effort) ? { effort } : {}
36171
+ };
36172
+ },
36173
+ continuation: { kind: "oneshot" },
36174
+ settlement: { kind: "result-required", watchdogMs: TURN_WATCHDOG_MS },
36175
+ onEvent: (event) => client.publish(event)
36176
+ });
36177
+ client.bind(loop);
36178
+ await loop.start();
36179
+ return client;
35673
36180
  }
35674
36181
  };
35675
36182
  }
35676
36183
  var CoworkGatewayClient = class extends EventEmitter {
35677
- constructor(sdk, options, model) {
35678
- super();
35679
- this.sdk = sdk;
35680
- this.options = options;
35681
- this.model = model;
35682
- }
35683
- sdk;
35684
- options;
35685
- model;
35686
- run = null;
35687
- resumeId = null;
35688
- disposed = false;
35689
- async sendMessage(content) {
35690
- if (this.disposed) throw new Error("cowork_session_disposed");
35691
- const effort = this.options.effort;
35692
- const served = toServedMcpServers(this.options.mcpServers);
35693
- const run = await this.sdk.startTurn({
35694
- prompt: content,
35695
- model: this.model,
35696
- systemPrompt: { mode: "replace", text: this.options.systemPrompt },
35697
- cwd: this.options.cwd,
35698
- disallowedTools: COWORK_DISALLOWED_TOOLS,
35699
- // 위키 도구는 호스트가 이미 띄운 HTTP MCP 엔드포인트로 온다. 이것을 싣지 않으면 자식은
35700
- // 시스템 프롬프트가 말하는 도구 이름을 부르지만 그런 도구가 없어 그대로 턴이 끝난다.
35701
- servedMcpServers: served,
35702
- // dontAsk는 사전승인되지 않은 도구를 묻지 않고 거부한다 — 노출한 도구는 전부 승인해 둔다.
35703
- allowedTools: served.flatMap((server) => this.options.allowedToolIds.map((id) => `mcp__${server.name}__${id}`)),
35704
- permissionMode: "dontAsk",
35705
- includePartialMessages: true,
35706
- ...effort && GATEWAY_EFFORTS.has(effort) ? { effort } : {},
35707
- ...this.resumeId === null ? {} : { resume: this.resumeId }
35708
- });
35709
- this.run = run;
35710
- await this.consume(run);
35711
- }
35712
- async cancelPrompt() {
35713
- this.run?.close();
35714
- this.run = null;
35715
- }
35716
- async disconnect() {
35717
- this.disposed = true;
35718
- this.run?.close();
35719
- this.run = null;
35720
- await this.sdk.dispose().catch(() => void 0);
35721
- }
35722
- /**
35723
- * 한 턴을 소비하고 정확히 한 번 결말을 낸다.
35724
- *
35725
- * 이터레이터가 끝났다는 사실만으로 성공을 알리지 않는다. 인식 가능한 종료 결과를 보지 못한 채
35726
- * 끝나면 그것은 조용한 실패이고, 조용한 실패는 사용자에게 멈춘 화면으로만 보인다.
35727
- */
35728
- async consume(run) {
35729
- const toolNames = /* @__PURE__ */ new Map();
35730
- let settled = false;
35731
- const finish = (error51) => {
35732
- if (settled) return;
35733
- settled = true;
35734
- if (error51) this.emit("error", { message: error51 });
35735
- else this.emit("promptComplete");
35736
- };
35737
- const watchdog = setTimeout(() => {
35738
- run.close();
35739
- finish("cowork_turn_timeout");
35740
- }, TURN_WATCHDOG_MS);
35741
- watchdog.unref?.();
35742
- try {
35743
- for await (const event of run) {
35744
- if (typeof event.session_id === "string" && this.resumeId === null) this.resumeId = event.session_id;
35745
- this.publish(event, toolNames, finish);
35746
- }
35747
- finish(settled ? void 0 : "cowork_turn_incomplete");
35748
- } catch (error51) {
35749
- if (!this.disposed) finish(error51 instanceof Error ? error51.message : String(error51));
35750
- } finally {
35751
- clearTimeout(watchdog);
35752
- if (this.run === run) this.run = null;
36184
+ loop = null;
36185
+ /** 이번 턴을 취소한 뒤에 루프가 내는 종점 정산·이터레이터 거절은 조용히 삼킨다. */
36186
+ canceledTurn = false;
36187
+ bind(loop) {
36188
+ this.loop = loop;
36189
+ }
36190
+ publish(event) {
36191
+ if (this.canceledTurn && event.kind === "result") return;
36192
+ if (event.kind === "text") {
36193
+ this.emit("messageChunk", event.text);
36194
+ return;
35753
36195
  }
35754
- }
35755
- publish(event, toolNames, finish) {
35756
- const type = event.type;
35757
- if (type === "stream_event") {
35758
- const inner = record2(event.event);
35759
- if (inner.type !== "content_block_delta") return;
35760
- const delta = record2(inner.delta);
35761
- if (delta.type === "text_delta" && typeof delta.text === "string" && delta.text.length > 0) {
35762
- this.emit("messageChunk", delta.text);
35763
- }
36196
+ if (event.kind === "thinking") return;
36197
+ if (event.kind === "tool-start") {
36198
+ this.emit("toolCall", event.name, "running");
35764
36199
  return;
35765
36200
  }
35766
- if (type === "assistant") {
35767
- for (const block of blocks(event.message)) {
35768
- if (block.type !== "tool_use") continue;
35769
- const name = typeof block.name === "string" ? block.name : "tool";
35770
- if (typeof block.id === "string") toolNames.set(block.id, name);
35771
- this.emit("toolCall", name, "running");
35772
- }
36201
+ if (event.kind === "tool-end") {
36202
+ this.emit("toolCallUpdate", event.name ?? "tool", event.isError ? "error" : "done");
35773
36203
  return;
35774
36204
  }
35775
- if (type === "user") {
35776
- for (const block of blocks(event.message)) {
35777
- if (block.type !== "tool_result") continue;
35778
- const name = typeof block.tool_use_id === "string" ? toolNames.get(block.tool_use_id) ?? "tool" : "tool";
35779
- this.emit("toolCallUpdate", name, block.is_error === true ? "error" : "done");
35780
- }
36205
+ if (event.source === "incomplete") {
36206
+ this.emit("error", { message: "cowork_turn_incomplete" });
35781
36207
  return;
35782
36208
  }
35783
- if (type === "result") {
35784
- finish(event.is_error === true ? typeof event.result === "string" ? event.result : "cowork_turn_failed" : void 0);
36209
+ if (event.source === "watchdog") {
36210
+ this.emit("error", { message: "cowork_turn_timeout" });
36211
+ return;
36212
+ }
36213
+ if (event.isError) {
36214
+ this.emit("error", { message: event.detail ?? "cowork_turn_failed" });
36215
+ return;
36216
+ }
36217
+ this.emit("promptComplete");
36218
+ }
36219
+ async sendMessage(content) {
36220
+ this.canceledTurn = false;
36221
+ try {
36222
+ await this.requireLoop().run(content);
36223
+ } catch (error51) {
36224
+ if (this.canceledTurn) return;
36225
+ throw disposedError(error51);
35785
36226
  }
35786
36227
  }
36228
+ async cancelPrompt() {
36229
+ this.canceledTurn = true;
36230
+ this.loop?.cancel();
36231
+ }
36232
+ async disconnect() {
36233
+ await this.loop?.dispose();
36234
+ }
36235
+ requireLoop() {
36236
+ if (this.loop === null) throw new Error("cowork_session_disposed");
36237
+ return this.loop;
36238
+ }
35787
36239
  };
36240
+ function disposedError(error51) {
36241
+ return error51 instanceof Error && error51.message === "Session disposed" ? new Error("cowork_session_disposed") : error51;
36242
+ }
35788
36243
  function toServedMcpServers(values) {
35789
36244
  return values.flatMap((value) => {
35790
- const server = record2(value);
36245
+ const server = record3(value);
35791
36246
  if (typeof server.name !== "string" || typeof server.url !== "string") return [];
35792
- const headers = Array.isArray(server.headers) ? server.headers.map(record2).flatMap((header) => typeof header.name === "string" && typeof header.value === "string" ? [{ name: header.name, value: header.value }] : []) : [];
36247
+ const headers = Array.isArray(server.headers) ? server.headers.map(record3).flatMap((header) => typeof header.name === "string" && typeof header.value === "string" ? [{ name: header.name, value: header.value }] : []) : [];
35793
36248
  return [{
35794
36249
  name: server.name,
35795
36250
  url: server.url,
@@ -35798,11 +36253,7 @@ function toServedMcpServers(values) {
35798
36253
  }];
35799
36254
  });
35800
36255
  }
35801
- function blocks(message) {
35802
- const content = record2(message).content;
35803
- return Array.isArray(content) ? content.map(record2) : [];
35804
- }
35805
- function record2(value) {
36256
+ function record3(value) {
35806
36257
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
35807
36258
  }
35808
36259
  function workspaceHash(canonicalCwd) {
@@ -36115,7 +36566,7 @@ function toMetadata(item) {
36115
36566
 
36116
36567
  // core/host/security-headers.ts
36117
36568
  var CONSOLE_SECURITY_HEADERS = {
36118
- "Content-Security-Policy": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://img.shields.io; font-src 'self' data:; connect-src 'self' ws: wss: https://api.github.com; object-src 'none'; base-uri 'none'",
36569
+ "Content-Security-Policy": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https://img.shields.io; font-src 'self' data:; connect-src 'self' ws: wss: https://api.github.com; object-src 'none'; base-uri 'none'",
36119
36570
  "X-Content-Type-Options": "nosniff",
36120
36571
  "Referrer-Policy": "no-referrer",
36121
36572
  "Cache-Control": "no-store"
@@ -36709,7 +37160,7 @@ function createConsoleDurableStateStore(deps = {}) {
36709
37160
  });
36710
37161
  }
36711
37162
  function sanitizeDurableConsoleState(value) {
36712
- if (!isRecord5(value)) return emptyDurableConsoleState();
37163
+ if (!isRecord6(value)) return emptyDurableConsoleState();
36713
37164
  const upgraded = migrateToCurrentVersion(value);
36714
37165
  if (upgraded.version !== STATE_VERSION) return emptyDurableConsoleState();
36715
37166
  return {
@@ -36748,7 +37199,7 @@ function migrateV2ToV3(v2) {
36748
37199
  };
36749
37200
  }
36750
37201
  function migrateV1Operation(value) {
36751
- if (!isRecord5(value)) return null;
37202
+ if (!isRecord6(value)) return null;
36752
37203
  const sessionId = readNonEmptyString(value.sessionId);
36753
37204
  const theaterId = readNonEmptyString(value.theaterId);
36754
37205
  const cwd = readNonEmptyString(value.cwd);
@@ -36762,7 +37213,7 @@ function migrateV1Operation(value) {
36762
37213
  if (cliId) payload.cliId = cliId;
36763
37214
  if (cliLabel) payload.cliLabel = cliLabel;
36764
37215
  if (labelSource) payload.labelSource = labelSource;
36765
- if (isRecord5(value.providerSession)) payload.providerSession = value.providerSession;
37216
+ if (isRecord6(value.providerSession)) payload.providerSession = value.providerSession;
36766
37217
  return {
36767
37218
  id: sessionId,
36768
37219
  theaterId,
@@ -36793,7 +37244,7 @@ function readOperations(value) {
36793
37244
  return nodes;
36794
37245
  }
36795
37246
  function sanitizeTheaterRegistration(value) {
36796
- if (!isRecord5(value)) return null;
37247
+ if (!isRecord6(value)) return null;
36797
37248
  const id = readNonEmptyString(value.id);
36798
37249
  const theaterPath = readNonEmptyString(value.path);
36799
37250
  const realpath3 = readNonEmptyString(value.realpath);
@@ -36813,7 +37264,7 @@ function sanitizeTheaterRegistration(value) {
36813
37264
  };
36814
37265
  }
36815
37266
  function sanitizeOperationNode2(value) {
36816
- if (!isRecord5(value)) return null;
37267
+ if (!isRecord6(value)) return null;
36817
37268
  const id = readNonEmptyString(value.id);
36818
37269
  const theaterId = readNonEmptyString(value.theaterId);
36819
37270
  const type = readNonEmptyString(value.type);
@@ -36837,7 +37288,7 @@ function sanitizeOperationNode2(value) {
36837
37288
  };
36838
37289
  }
36839
37290
  function sanitizeOperationTimestamps(value) {
36840
- if (!isRecord5(value)) return null;
37291
+ if (!isRecord6(value)) return null;
36841
37292
  const createdAt = readFiniteNumber2(value.createdAt);
36842
37293
  const updatedAt = readFiniteNumber2(value.updatedAt);
36843
37294
  if (createdAt === null || updatedAt === null) return null;
@@ -36845,7 +37296,7 @@ function sanitizeOperationTimestamps(value) {
36845
37296
  }
36846
37297
  function sanitizeOperationGeometry(value) {
36847
37298
  if (value === null || value === void 0) return null;
36848
- if (!isRecord5(value)) return null;
37299
+ if (!isRecord6(value)) return null;
36849
37300
  const x = readFiniteNumber2(value.x);
36850
37301
  const y = readFiniteNumber2(value.y);
36851
37302
  const width = readFiniteNumber2(value.width);
@@ -36854,7 +37305,7 @@ function sanitizeOperationGeometry(value) {
36854
37305
  if (x === null || y === null || width === null || height === null || zIndex === null) return null;
36855
37306
  return { x, y, width, height, zIndex };
36856
37307
  }
36857
- function isRecord5(value) {
37308
+ function isRecord6(value) {
36858
37309
  return typeof value === "object" && value !== null && !Array.isArray(value);
36859
37310
  }
36860
37311
  function readNonEmptyString(value) {
@@ -36864,7 +37315,7 @@ function readOptionalString(value) {
36864
37315
  return typeof value === "string" && value.length > 0 ? value : void 0;
36865
37316
  }
36866
37317
  function readRecord(value) {
36867
- return isRecord5(value) ? value : {};
37318
+ return isRecord6(value) ? value : {};
36868
37319
  }
36869
37320
  function remapTerminalPluginId(pluginId) {
36870
37321
  return pluginId === "agent" || pluginId === "shell" ? "terminal" : pluginId;
@@ -36898,7 +37349,7 @@ function readOperationGroups(value) {
36898
37349
  return groups;
36899
37350
  }
36900
37351
  function sanitizeOperationGroup(value) {
36901
- if (!isRecord5(value)) return null;
37352
+ if (!isRecord6(value)) return null;
36902
37353
  const id = readNonEmptyString(value.id);
36903
37354
  const theaterId = readNonEmptyString(value.theaterId);
36904
37355
  const rawName = readNonEmptyString(value.name);
@@ -36920,7 +37371,7 @@ function readDeletionTombstones(value) {
36920
37371
  return tombstones;
36921
37372
  }
36922
37373
  function sanitizeDeletionTombstone(value) {
36923
- if (!isRecord5(value)) return null;
37374
+ if (!isRecord6(value)) return null;
36924
37375
  const deletionId = readNonEmptyString(value.deletionId);
36925
37376
  const targetId = readNonEmptyString(value.targetId);
36926
37377
  const deletedAt = readFiniteNumber2(value.deletedAt);
@@ -37397,7 +37848,7 @@ function createRemoteHostStore(consoleDir, deps = {}) {
37397
37848
  try {
37398
37849
  const parsed = JSON.parse(readFile7(storage.path(HOSTS_FILE)));
37399
37850
  if (parsed?.version !== STORE_VERSION3 || !Array.isArray(parsed.hosts)) return [];
37400
- return parsed.hosts.filter(isRecord6).slice(0, MAX_HOSTS);
37851
+ return parsed.hosts.filter(isRecord7).slice(0, MAX_HOSTS);
37401
37852
  } catch {
37402
37853
  return [];
37403
37854
  }
@@ -37413,7 +37864,7 @@ function createRemoteHostStore(consoleDir, deps = {}) {
37413
37864
  findByOrigin: (origin) => hosts.find((entry) => entry.origin === origin) ?? null,
37414
37865
  remember(link) {
37415
37866
  const existing = hosts.find((entry) => entry.origin === link.origin);
37416
- const record3 = {
37867
+ const record4 = {
37417
37868
  id: existing?.id ?? randomId(),
37418
37869
  // 이름은 사용자가 고쳐 부를 수 있으므로, 이미 고쳐 부른 이름을 링크가 덮어쓰지 않는다.
37419
37870
  label: existing?.label ?? link.label,
@@ -37425,10 +37876,10 @@ function createRemoteHostStore(consoleDir, deps = {}) {
37425
37876
  addedAt: existing?.addedAt ?? now(),
37426
37877
  lastOpenedAt: existing?.lastOpenedAt ?? null
37427
37878
  };
37428
- hosts = [record3, ...hosts.filter((entry) => entry.origin !== link.origin)].slice(0, MAX_HOSTS);
37429
- pending.set(record3.origin, { token: link.token, expiresAt: now() + HANDOFF_TTL_MS });
37879
+ hosts = [record4, ...hosts.filter((entry) => entry.origin !== link.origin)].slice(0, MAX_HOSTS);
37880
+ pending.set(record4.origin, { token: link.token, expiresAt: now() + HANDOFF_TTL_MS });
37430
37881
  write();
37431
- return record3;
37882
+ return record4;
37432
37883
  },
37433
37884
  rename(id, label) {
37434
37885
  const cleaned = sanitizeAccessLabel(label);
@@ -37460,7 +37911,7 @@ function createRemoteHostStore(consoleDir, deps = {}) {
37460
37911
  }
37461
37912
  };
37462
37913
  }
37463
- function isRecord6(value) {
37914
+ function isRecord7(value) {
37464
37915
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
37465
37916
  const entry = value;
37466
37917
  return typeof entry.id === "string" && entry.id.length > 0 && typeof entry.label === "string" && typeof entry.origin === "string" && entry.origin.startsWith("https://") && typeof entry.hostname === "string" && entry.hostname.length > 0 && typeof entry.port === "number" && Number.isSafeInteger(entry.port) && typeof entry.fingerprint === "string" && /^[0-9A-F]{64}$/u.test(entry.fingerprint) && typeof entry.addedAt === "number" && (entry.lastOpenedAt === null || typeof entry.lastOpenedAt === "number");
@@ -37727,7 +38178,7 @@ function discoverFleetPlugins(options = {}) {
37727
38178
  return [...sourcePlugins, ...distPlugins];
37728
38179
  }
37729
38180
  function parseFleetPluginManifest(value) {
37730
- if (!isRecord7(value)) return null;
38181
+ if (!isRecord8(value)) return null;
37731
38182
  const id = readPluginId(value.id);
37732
38183
  if (!id) return null;
37733
38184
  return {
@@ -37834,7 +38285,7 @@ function isSubpath(root, candidate) {
37834
38285
  const relative = path18__default.relative(root, candidate);
37835
38286
  return relative === "" || !relative.startsWith("..") && !path18__default.isAbsolute(relative);
37836
38287
  }
37837
- function isRecord7(value) {
38288
+ function isRecord8(value) {
37838
38289
  return typeof value === "object" && value !== null && !Array.isArray(value);
37839
38290
  }
37840
38291
  var SHIM_DEFINITIONS = [
@@ -39630,13 +40081,15 @@ function createConsoleServer(deps = {}) {
39630
40081
  return operation;
39631
40082
  },
39632
40083
  patch: (id, input) => {
39633
- const previousTitle = "title" in input ? operations.get(id)?.title : void 0;
40084
+ const before = operations.get(id);
39634
40085
  const operation = operations.patch(id, input);
39635
- if (operation) {
40086
+ if (operation && before) {
39636
40087
  persistDurableState();
39637
- if (previousTitle !== void 0 && previousTitle !== operation.title) {
40088
+ if (sanitizedOperationJson(before) !== sanitizedOperationJson(operation)) {
39638
40089
  broadcastOperationChanged(operation);
39639
40090
  }
40091
+ } else if (operation) {
40092
+ persistDurableState();
39640
40093
  }
39641
40094
  return operation;
39642
40095
  },
@@ -40874,6 +41327,14 @@ function createConsoleServer(deps = {}) {
40874
41327
  await codex.registerWorkspace(theater.realpath, theater.lastOpenedAt, theater.id);
40875
41328
  }
40876
41329
  }
41330
+ function sanitizedOperationJson(node) {
41331
+ const sensitiveFields = [
41332
+ ...pluginHost.sensitiveFieldsByPluginId.get(node.pluginId) ?? [],
41333
+ ...pluginPayloadSanitizers.get(node.pluginId) ?? []
41334
+ ];
41335
+ const { ts: _ts, ...rest } = createSanitizedOpDto(node, { sensitiveFields });
41336
+ return JSON.stringify(rest);
41337
+ }
40877
41338
  function broadcastOperationChanged(node) {
40878
41339
  if (operationSseSubscribers.size === 0) return;
40879
41340
  const sensitiveFields = [