@cmmd-center/forge 0.12.0 → 0.13.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 (25) hide show
  1. package/dist/bin.cjs +140 -61
  2. package/dist/bin.mjs +137 -60
  3. package/dist/client/assets/{CanvasPanel-CL4T3ptl.js → CanvasPanel-BUdwnabz.js} +2 -2
  4. package/dist/client/assets/{CompositeItem-NATmsDHX.js → CompositeItem-BxaZQRyb.js} +2 -2
  5. package/dist/client/assets/{DiffPanel-29UmSyE3.js → DiffPanel-BOLibNHF.js} +3 -3
  6. package/dist/client/assets/{DiffPanel.logic-D5Bn5tgT.js → DiffPanel.logic-BrRjlJeM.js} +2 -2
  7. package/dist/client/assets/DiffPanelShell-CgycIPfE.js +2531 -0
  8. package/dist/client/assets/{DiffWorkerPoolProvider-BMZL3CsO.js → DiffWorkerPoolProvider-jWJpEXVo.js} +8 -8
  9. package/dist/client/assets/PullRequestCodePanel-BW7XdaG8.js +5 -0
  10. package/dist/client/assets/{Virtualizer-uq0d5TwY.js → Virtualizer-qjNwH1hl.js} +2 -2
  11. package/dist/client/assets/{canvasStateStore-DtidOKbV.js → canvasStateStore-DDwjZ3AG.js} +2 -2
  12. package/dist/client/assets/{cmmdAuthRedirect-CzACd5XJ.js → cmmdAuthRedirect-CPfIOB5Y.js} +2 -2
  13. package/dist/client/assets/index-9clxg-cN.js +151 -0
  14. package/dist/client/assets/index-Dk7T0zVg.css +1 -0
  15. package/dist/client/assets/src-dZ5rHSKC.js +3 -0
  16. package/dist/client/assets/{toggle-pwklbW9N.js → toggle-Bn-2EZmB.js} +2 -2
  17. package/dist/client/assets/{useTriggerFocusGuards-CPLQ8_CW.js → useTriggerFocusGuards-DRINKzwL.js} +2 -2
  18. package/dist/client/index.html +11 -11
  19. package/dist/forge-build.json +1 -1
  20. package/package.json +1 -1
  21. package/dist/client/assets/DiffPanelShell-ClKPX_Pu.js +0 -2531
  22. package/dist/client/assets/PullRequestCodePanel-Cp75delh.js +0 -5
  23. package/dist/client/assets/index-BMcOaHS_.css +0 -1
  24. package/dist/client/assets/index-BOI5P7rG.js +0 -151
  25. package/dist/client/assets/src-BlFkWEsP.js +0 -3
package/dist/bin.cjs CHANGED
@@ -16544,7 +16544,7 @@ function makeNetServiceShape(createServer = node_net.createServer) {
16544
16544
  }
16545
16545
  //#endregion
16546
16546
  //#region ../../packages/shared/src/releaseInfo.generated.ts
16547
- const FORGE_RELEASE_VERSION = "0.12.0";
16547
+ const FORGE_RELEASE_VERSION = "0.13.0";
16548
16548
  //#endregion
16549
16549
  //#region ../../packages/shared/src/hostProcess.ts
16550
16550
  /**
@@ -18654,6 +18654,43 @@ const TerminalError = require_Schema$1.Union([
18654
18654
  TerminalSignalError
18655
18655
  ]);
18656
18656
  //#endregion
18657
+ //#region ../../packages/contracts/src/projectScriptCommands.ts
18658
+ const ProjectScriptIcon = require_Schema$1.Literals([
18659
+ "play",
18660
+ "test",
18661
+ "lint",
18662
+ "configure",
18663
+ "build",
18664
+ "debug"
18665
+ ]);
18666
+ const ProjectScript = require_Schema$1.Struct({
18667
+ id: TrimmedNonEmptyString,
18668
+ name: TrimmedNonEmptyString,
18669
+ command: TrimmedNonEmptyString,
18670
+ icon: ProjectScriptIcon,
18671
+ runOnWorktreeCreate: require_Schema$1.Boolean
18672
+ });
18673
+ const ProjectScriptUpdateCommand = require_Schema$1.Struct({
18674
+ type: require_Schema$1.Literal("project.script.update"),
18675
+ commandId: CommandId,
18676
+ projectId: ProjectId,
18677
+ mutation: require_Schema$1.Union([
18678
+ require_Schema$1.Struct({
18679
+ kind: require_Schema$1.Literal("add"),
18680
+ script: ProjectScript
18681
+ }),
18682
+ require_Schema$1.Struct({
18683
+ kind: require_Schema$1.Literal("update"),
18684
+ script: ProjectScript,
18685
+ expected: ProjectScript
18686
+ }),
18687
+ require_Schema$1.Struct({
18688
+ kind: require_Schema$1.Literal("remove"),
18689
+ expected: ProjectScript
18690
+ })
18691
+ ])
18692
+ });
18693
+ //#endregion
18657
18694
  //#region ../../packages/contracts/src/model.ts
18658
18695
  const CODEX_REASONING_EFFORT_OPTIONS = [
18659
18696
  "ultra",
@@ -19313,21 +19350,6 @@ const UploadChatImageAttachment = require_Schema$1.Struct({
19313
19350
  });
19314
19351
  const ChatAttachment = require_Schema$1.Union([ChatImageAttachment]);
19315
19352
  const UploadChatAttachment = require_Schema$1.Union([UploadChatImageAttachment]);
19316
- const ProjectScriptIcon = require_Schema$1.Literals([
19317
- "play",
19318
- "test",
19319
- "lint",
19320
- "configure",
19321
- "build",
19322
- "debug"
19323
- ]);
19324
- const ProjectScript = require_Schema$1.Struct({
19325
- id: TrimmedNonEmptyString,
19326
- name: TrimmedNonEmptyString,
19327
- command: TrimmedNonEmptyString,
19328
- icon: ProjectScriptIcon,
19329
- runOnWorktreeCreate: require_Schema$1.Boolean
19330
- });
19331
19353
  /**
19332
19354
  * Availability of the project's `workspaceRoot` on the server's filesystem.
19333
19355
  *
@@ -19958,6 +19980,7 @@ const ThreadSessionStopCommand = require_Schema$1.Struct({
19958
19980
  const DispatchableClientOrchestrationCommand = require_Schema$1.Union([
19959
19981
  ProjectCreateCommand,
19960
19982
  ProjectMetaUpdateCommand,
19983
+ ProjectScriptUpdateCommand,
19961
19984
  ProjectDeleteCommand,
19962
19985
  ThreadCreateCommand,
19963
19986
  ThreadDeleteCommand,
@@ -19979,6 +20002,7 @@ const DispatchableClientOrchestrationCommand = require_Schema$1.Union([
19979
20002
  const ClientOrchestrationCommand = require_Schema$1.Union([
19980
20003
  ProjectCreateCommand,
19981
20004
  ProjectMetaUpdateCommand,
20005
+ ProjectScriptUpdateCommand,
19982
20006
  ProjectDeleteCommand,
19983
20007
  ThreadCreateCommand,
19984
20008
  ThreadDeleteCommand,
@@ -31834,6 +31858,10 @@ const relayCommandPolicyByType = {
31834
31858
  requiredScope: "project.write",
31835
31859
  deliveryClass: "idempotent-command"
31836
31860
  },
31861
+ "project.script.update": {
31862
+ requiredScope: "project.write",
31863
+ deliveryClass: "idempotent-command"
31864
+ },
31837
31865
  "project.delete": {
31838
31866
  requiredScope: "project.write",
31839
31867
  deliveryClass: "idempotent-command"
@@ -65813,7 +65841,7 @@ function normalizeNumberish(value) {
65813
65841
  }
65814
65842
  //#endregion
65815
65843
  //#region package.json
65816
- var version$1 = "0.12.0";
65844
+ var version$1 = "0.13.0";
65817
65845
  //#endregion
65818
65846
  //#region src/sentry.ts
65819
65847
  const SERVER_APP_NAME = "forge-server";
@@ -96019,6 +96047,10 @@ function threadStatus(thread) {
96019
96047
  if (thread.latestTurn) return "running";
96020
96048
  return "active";
96021
96049
  }
96050
+ function threadProviderAccountId(thread) {
96051
+ const selection = thread.modelSelection;
96052
+ return selection && "providerAccountId" in selection ? selection.providerAccountId ?? null : null;
96053
+ }
96022
96054
  function serializeRuntimeInventory(snapshot, providerInventory) {
96023
96055
  const activeProjects = snapshot.projects.filter((project) => project.availability !== "missing");
96024
96056
  const projectIds = new Set(activeProjects.map((project) => project.id));
@@ -96049,6 +96081,7 @@ function serializeRuntimeInventory(snapshot, providerInventory) {
96049
96081
  status: threadStatus(thread),
96050
96082
  model: thread.modelSelection?.model ?? null,
96051
96083
  provider: thread.modelSelection?.provider ?? null,
96084
+ providerAccountId: threadProviderAccountId(thread),
96052
96085
  branch: thread.branch,
96053
96086
  lastActivityAt: thread.latestUserMessageAt ?? thread.updatedAt,
96054
96087
  kind: thread.kind,
@@ -99286,7 +99319,7 @@ var BrowserManager = class extends require_Schema$1.Service()("forge/browser/Ser
99286
99319
  const DEFAULT_PORT_MIN = 5200;
99287
99320
  const DEFAULT_PORT_MAX = 5999;
99288
99321
  var ThreadDevRuntime = class extends require_Schema$1.Service()("forge/threadDevRuntime/ThreadDevRuntime") {};
99289
- function nowIso$4() {
99322
+ function nowIso$5() {
99290
99323
  return (/* @__PURE__ */ new Date()).toISOString();
99291
99324
  }
99292
99325
  function previewUrlForPort(port) {
@@ -99313,7 +99346,7 @@ const ThreadDevRuntimeLive = require_Schema$1.effect(ThreadDevRuntime, require_S
99313
99346
  allocatedPort: port,
99314
99347
  status: "allocated",
99315
99348
  previewUrl: previewUrlForPort(port),
99316
- updatedAt: nowIso$4()
99349
+ updatedAt: nowIso$5()
99317
99350
  };
99318
99351
  yield* require_HttpServer.update(byThreadId, (current) => {
99319
99352
  const next = new Map(current);
@@ -99335,7 +99368,7 @@ const ThreadDevRuntimeLive = require_Schema$1.effect(ThreadDevRuntime, require_S
99335
99368
  next.set(input.threadId, {
99336
99369
  ...existing,
99337
99370
  status: "released",
99338
- updatedAt: nowIso$4()
99371
+ updatedAt: nowIso$5()
99339
99372
  });
99340
99373
  return next;
99341
99374
  });
@@ -99361,7 +99394,7 @@ const ThreadDevRuntimeLive = require_Schema$1.effect(ThreadDevRuntime, require_S
99361
99394
  ...patch.terminalId !== void 0 ? { terminalId: patch.terminalId } : {},
99362
99395
  ...patch.previewUrl !== void 0 ? { previewUrl: patch.previewUrl } : {},
99363
99396
  ...patch.tunnelId !== void 0 ? { tunnelId: patch.tunnelId } : {},
99364
- updatedAt: nowIso$4()
99397
+ updatedAt: nowIso$5()
99365
99398
  };
99366
99399
  yield* require_HttpServer.update(byThreadId, (current) => {
99367
99400
  const next = new Map(current);
@@ -210973,6 +211006,11 @@ const PUBLIC_PROVIDER_LEAK_PATTERNS = [
210973
211006
  /https?:\/\/[^\s'"<>)]*(?:apex|deepseek|moonshot|kimi)[^\s'"<>)]*/i
210974
211007
  ];
210975
211008
  const DEFAULT_PUBLIC_PROVIDER_ERROR = "CMMD is temporarily unavailable. Check the workspace AI connection and retry.";
211009
+ function isProviderRateOrQuotaError(message) {
211010
+ if (!message) return false;
211011
+ const normalized = message.toLowerCase();
211012
+ return /\b(rate[\s-]?limit|too\s+many\s+requests|usage[ _-]limit|usage_limit_reached|quota|insufficient_quota)\b/.test(normalized) || /\b429\b/.test(normalized);
211013
+ }
210976
211014
  /**
210977
211015
  * Infer a SAFE, clearer failure category from a (possibly leaky) provider error.
210978
211016
  *
@@ -210988,7 +211026,7 @@ function categorizePublicProviderError(message) {
210988
211026
  if (/\bforge_runtime_stopped\b/.test(m) || /\bthis turn was interrupted because the environment was stopped\b/.test(m)) return "This turn was interrupted because the environment was stopped. Start the environment and retry.";
210989
211027
  if (/\bforge_provider_model_not_allowed\b/.test(m) || /\bnot\s+scoped\s+to\s+the\s+requested\s+model\b/.test(m)) return "The workspace AI credential does not cover the model this turn asked for. Retry, or pick that model for the thread.";
210990
211028
  if (/\bmodel\b[\s\S]*\b(not\s+(found|available|supported)|does\s+not\s+exist|unsupported|invalid|unknown)\b/.test(m) || /\b(unsupported|unknown|invalid)\b[\s\S]*\bmodel\b/.test(m) || /\b(model_not_found|invalid_model|model_not_supported)\b/.test(m)) return "The selected model isn't available right now. Pick a different model and retry.";
210991
- if (/\b(rate[\s-]?limit|too\s+many\s+requests|quota|insufficient_quota)\b/.test(m) || /\b429\b/.test(m)) return "The AI service is rate-limited or out of quota. Wait a moment and retry.";
211029
+ if (isProviderRateOrQuotaError(m)) return "The AI service is rate-limited or out of quota. Wait a moment and retry.";
210992
211030
  if (/\b(unauthorized|forbidden|authentication\s+(failed|error|required)|invalid\s+api\s+key|expired\s+(token|credential))\b/.test(m) || /\b40[13]\b/.test(m)) return "Workspace AI authentication failed. Reconnect the workspace and retry.";
210993
211031
  if (/\b(timed?\s*out|timeout|overloaded|service\s+unavailable)\b/.test(m) || /\b50[234]\b/.test(m)) return "The AI service is temporarily overloaded. Retry in a moment.";
210994
211032
  return null;
@@ -228638,7 +228676,7 @@ const OpenCodeRuntimeLive = require_Schema$1.effect(OpenCodeRuntime, makeOpenCod
228638
228676
  //#endregion
228639
228677
  //#region src/provider/Layers/OpenCodeAdapter.ts
228640
228678
  const PROVIDER$5 = "opencode";
228641
- const nowIso$3 = require_Schema$1.map(require_Schema$1.now, require_Schema$1.formatIso);
228679
+ const nowIso$4 = require_Schema$1.map(require_Schema$1.now, require_Schema$1.formatIso);
228642
228680
  /**
228643
228681
  * Map a tagged OpenCodeRuntimeError produced by {@link runOpenCodeSdk} into
228644
228682
  * the adapter-boundary `ProviderAdapterRequestError`. SDK-method-level call
@@ -228665,7 +228703,7 @@ const toProcessError = (threadId, cause) => new ProviderAdapterProcessError({
228665
228703
  });
228666
228704
  const buildEventBase = (input) => require_Schema$1.gen(function* () {
228667
228705
  const uuid = yield* nextUUIDv4;
228668
- const createdAt = input.createdAt ?? (yield* nowIso$3);
228706
+ const createdAt = input.createdAt ?? (yield* nowIso$4);
228669
228707
  return {
228670
228708
  eventId: EventId.make(uuid),
228671
228709
  provider: PROVIDER$5,
@@ -228824,7 +228862,7 @@ function sessionErrorMessage(error) {
228824
228862
  }
228825
228863
  function updateProviderSession(context, patch, options) {
228826
228864
  return require_Schema$1.gen(function* () {
228827
- const updatedAt = yield* nowIso$3;
228865
+ const updatedAt = yield* nowIso$4;
228828
228866
  const nextSession = {
228829
228867
  ...context.session,
228830
228868
  ...patch,
@@ -228946,7 +228984,7 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
228946
228984
  if (("properties" in event ? event.properties.sessionID : void 0) !== context.openCodeSessionId) return;
228947
228985
  const turnId = context.activeTurnId;
228948
228986
  yield* writeNativeEventBestEffort(context.session.threadId, {
228949
- observedAt: yield* nowIso$3,
228987
+ observedAt: yield* nowIso$4,
228950
228988
  event: {
228951
228989
  provider: PROVIDER$5,
228952
228990
  threadId: context.session.threadId,
@@ -229262,7 +229300,7 @@ function makeOpenCodeAdapter(openCodeSettings, options) {
229262
229300
  yield* require_Schema$1.close(started.sessionScope, require_Schema$1.void_$1).pipe(require_Schema$1.ignore);
229263
229301
  return raceWinner.session;
229264
229302
  }
229265
- const createdAt = yield* nowIso$3;
229303
+ const createdAt = yield* nowIso$4;
229266
229304
  const session = {
229267
229305
  provider: PROVIDER$5,
229268
229306
  status: "ready",
@@ -236061,7 +236099,7 @@ function filterEvents(events, options) {
236061
236099
  });
236062
236100
  return options.limit === void 0 ? filtered : filtered.slice(-options.limit);
236063
236101
  }
236064
- function nowIso$2() {
236102
+ function nowIso$3() {
236065
236103
  return (/* @__PURE__ */ new Date()).toISOString();
236066
236104
  }
236067
236105
  //#endregion
@@ -236076,7 +236114,7 @@ var BrowserActionEventRecorder = class {
236076
236114
  type: "browser.action",
236077
236115
  action,
236078
236116
  ...this.sessionFields(),
236079
- timestamp: nowIso$2()
236117
+ timestamp: nowIso$3()
236080
236118
  });
236081
236119
  }
236082
236120
  async result(action) {
@@ -236085,7 +236123,7 @@ var BrowserActionEventRecorder = class {
236085
236123
  action,
236086
236124
  ok: true,
236087
236125
  ...this.sessionFields(),
236088
- timestamp: nowIso$2()
236126
+ timestamp: nowIso$3()
236089
236127
  });
236090
236128
  }
236091
236129
  async error(action, error) {
@@ -236094,7 +236132,7 @@ var BrowserActionEventRecorder = class {
236094
236132
  action,
236095
236133
  error: error instanceof Error ? error.message : String(error),
236096
236134
  ...this.sessionFields(),
236097
- timestamp: nowIso$2()
236135
+ timestamp: nowIso$3()
236098
236136
  });
236099
236137
  }
236100
236138
  sessionFields() {
@@ -236615,7 +236653,7 @@ var AgentBrowser = class {
236615
236653
  await this.options.events?.record({
236616
236654
  type: "browser.safety.confirmation.requested",
236617
236655
  ...request,
236618
- createdAt: nowIso$2()
236656
+ createdAt: nowIso$3()
236619
236657
  });
236620
236658
  const result = await this.resolveConfirmation(request);
236621
236659
  const approved = typeof result === "boolean" ? result : result.approved;
@@ -236623,7 +236661,7 @@ var AgentBrowser = class {
236623
236661
  type: "browser.safety.confirmation.resolved",
236624
236662
  approved,
236625
236663
  requestId: request.requestId,
236626
- resolvedAt: nowIso$2(),
236664
+ resolvedAt: nowIso$3(),
236627
236665
  ...this.events.sessionFields()
236628
236666
  });
236629
236667
  if (!approved) throw new BrowserSafetyError(decision.reason ?? "Browser action was not confirmed.", action, {
@@ -281978,7 +282016,7 @@ const DEFAULT_AGENT_BROWSER_BRIDGE_CLOSE_TIMEOUT_MS = 3e4;
281978
282016
  const DEFAULT_AGENT_BROWSER_PLAYWRIGHT_BACKEND_CLOSE_TIMEOUT_MS = 1e4;
281979
282017
  const REMOTE_WEBRTC_UNAVAILABLE_DETAIL = "Remote WebRTC browser display is not available: the current Agent Browser runtime exposes tab control but does not provide a media transport.";
281980
282018
  const REMOTE_WEBRTC_RELAY_REQUIRED_DETAIL = "Remote WebRTC browser display requires a TURN relay in cloud mode. Configure FORGE_BROWSER_WEBRTC_ICE_SERVERS with authenticated turn: or turns: URLs.";
281981
- function nowIso$1() {
282019
+ function nowIso$2() {
281982
282020
  return (/* @__PURE__ */ new Date()).toISOString();
281983
282021
  }
281984
282022
  function positiveTimeoutMs(value) {
@@ -282078,12 +282116,12 @@ function snapshotAfterTimedOutControl(snapshot, command) {
282078
282116
  case "setViewport": return {
282079
282117
  ...snapshot,
282080
282118
  viewport: command.viewport,
282081
- updatedAt: nowIso$1()
282119
+ updatedAt: nowIso$2()
282082
282120
  };
282083
282121
  case "resetViewport": return {
282084
282122
  ...snapshot,
282085
282123
  viewport: DEFAULT_AGENT_BROWSER_VIEWPORT,
282086
- updatedAt: nowIso$1()
282124
+ updatedAt: nowIso$2()
282087
282125
  };
282088
282126
  default: return snapshot;
282089
282127
  }
@@ -282529,7 +282567,7 @@ function toStreamEvent(input) {
282529
282567
  userId: BrowserUserId.make(input.userId),
282530
282568
  agentId: input.agentId,
282531
282569
  ...input.controlState ? { sessionEpoch: input.controlState.sessionEpoch } : {},
282532
- createdAt: nowIso$1()
282570
+ createdAt: nowIso$2()
282533
282571
  };
282534
282572
  switch (input.event.type) {
282535
282573
  case "session.started": return {
@@ -282830,7 +282868,7 @@ function createAgentBrowserHostBridgeManager(bridge, options) {
282830
282868
  environmentId: event.input.environmentId ?? DEFAULT_BROWSER_ENVIRONMENT_ID,
282831
282869
  userId: event.input.userId ?? "local-user",
282832
282870
  agentId: null,
282833
- createdAt: nowIso$1(),
282871
+ createdAt: nowIso$2(),
282834
282872
  type: "display.iceCandidate",
282835
282873
  payload: {
282836
282874
  sessionId: event.input.sessionId,
@@ -294961,7 +294999,7 @@ function resolveBuildCommitFromEnv(env) {
294961
294999
  * environment descriptor down instead of reporting an honest "unknown".
294962
295000
  */
294963
295001
  function readBakedBuildCommit() {
294964
- return "7695a8221bc664caedd33aa411ac7bcdbb0a3594";
295002
+ return "ebc6c5d85de3dc3324a5054f8f29deb2dd89baa7";
294965
295003
  }
294966
295004
  async function resolveServerBuildCommit(input) {
294967
295005
  if (isFullCommitSha(input.baked)) return input.baked;
@@ -298042,6 +298080,52 @@ function toProjectorDecodeError(eventType) {
298042
298080
  });
298043
298081
  }
298044
298082
  //#endregion
298083
+ //#region src/orchestration/deciderEventBase.ts
298084
+ const nowIso$1 = () => (/* @__PURE__ */ new Date()).toISOString();
298085
+ const defaultMetadata = {
298086
+ eventId: crypto.randomUUID(),
298087
+ aggregateKind: "thread",
298088
+ aggregateId: "",
298089
+ occurredAt: nowIso$1(),
298090
+ commandId: null,
298091
+ causationEventId: null,
298092
+ correlationId: null,
298093
+ metadata: {}
298094
+ };
298095
+ function withEventBase(input) {
298096
+ return {
298097
+ ...defaultMetadata,
298098
+ eventId: crypto.randomUUID(),
298099
+ aggregateKind: input.aggregateKind,
298100
+ aggregateId: input.aggregateId,
298101
+ occurredAt: input.occurredAt,
298102
+ commandId: input.commandId,
298103
+ correlationId: input.commandId,
298104
+ metadata: input.metadata ?? {}
298105
+ };
298106
+ }
298107
+ //#endregion
298108
+ //#region src/orchestration/projectScriptMutation.ts
298109
+ function unchanged(a, b) {
298110
+ return a !== void 0 && a.id === b.id && a.name === b.name && a.command === b.command && a.icon === b.icon && a.runOnWorktreeCreate === b.runOnWorktreeCreate;
298111
+ }
298112
+ const applyProjectScriptMutation = require_Schema$1.fn("applyProjectScriptMutation")(function* (scripts, command) {
298113
+ const mutation = command.mutation;
298114
+ const id = mutation.kind === "add" ? mutation.script.id : mutation.expected.id;
298115
+ const existing = scripts.find((script) => script.id === id);
298116
+ if (mutation.kind === "add" ? existing !== void 0 : !unchanged(existing, mutation.expected)) return yield* new OrchestrationCommandInvariantError({
298117
+ commandType: command.type,
298118
+ detail: "This action changed in another window. Reopen it and try again."
298119
+ });
298120
+ if (mutation.kind === "add") return [...scripts, mutation.script];
298121
+ if (mutation.kind === "remove") return scripts.filter((script) => script.id !== id);
298122
+ if (mutation.script.id !== id) return yield* new OrchestrationCommandInvariantError({
298123
+ commandType: command.type,
298124
+ detail: "An action's ID cannot change during an update."
298125
+ });
298126
+ return scripts.map((script) => script.id === id ? mutation.script : script);
298127
+ });
298128
+ //#endregion
298045
298129
  //#region src/orchestration/turnAccountSelection.ts
298046
298130
  /** A per-turn account choice remains local to the thread and cannot change its provider. */
298047
298131
  function turnAccountSelection(current, requested) {
@@ -298098,28 +298182,6 @@ function requireThreadAbsent(input) {
298098
298182
  //#endregion
298099
298183
  //#region src/orchestration/decider.ts
298100
298184
  const nowIso = () => (/* @__PURE__ */ new Date()).toISOString();
298101
- const defaultMetadata = {
298102
- eventId: crypto.randomUUID(),
298103
- aggregateKind: "thread",
298104
- aggregateId: "",
298105
- occurredAt: nowIso(),
298106
- commandId: null,
298107
- causationEventId: null,
298108
- correlationId: null,
298109
- metadata: {}
298110
- };
298111
- function withEventBase(input) {
298112
- return {
298113
- ...defaultMetadata,
298114
- eventId: crypto.randomUUID(),
298115
- aggregateKind: input.aggregateKind,
298116
- aggregateId: input.aggregateId,
298117
- occurredAt: input.occurredAt,
298118
- commandId: input.commandId,
298119
- correlationId: input.commandId,
298120
- metadata: input.metadata ?? {}
298121
- };
298122
- }
298123
298185
  function requireOrdinaryMessageId(commandType, messageId) {
298124
298186
  return isReservedReplicaSourceMessageId(messageId) ? require_Schema$1.fail(new OrchestrationCommandInvariantError({
298125
298187
  commandType,
@@ -298172,6 +298234,22 @@ const decideOrchestrationCommand = require_Schema$1.fn("decideOrchestrationComma
298172
298234
  updatedAt: command.createdAt
298173
298235
  }
298174
298236
  };
298237
+ case "project.script.update": {
298238
+ const scripts = yield* applyProjectScriptMutation((yield* requireProject({
298239
+ readModel,
298240
+ command,
298241
+ projectId: command.projectId
298242
+ })).scripts, command);
298243
+ return yield* decideOrchestrationCommand({
298244
+ readModel,
298245
+ command: {
298246
+ type: "project.meta.update",
298247
+ commandId: command.commandId,
298248
+ projectId: command.projectId,
298249
+ scripts
298250
+ }
298251
+ });
298252
+ }
298175
298253
  case "project.meta.update": {
298176
298254
  yield* requireProject({
298177
298255
  readModel,
@@ -299458,6 +299536,7 @@ function commandToAggregateRef(command) {
299458
299536
  switch (command.type) {
299459
299537
  case "project.create":
299460
299538
  case "project.meta.update":
299539
+ case "project.script.update":
299461
299540
  case "project.delete": return {
299462
299541
  aggregateKind: "project",
299463
299542
  aggregateId: command.projectId