@spencer-kit/coder-studio 0.3.4 → 0.3.5

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.
package/dist/esm/bin.mjs CHANGED
@@ -8445,8 +8445,12 @@ var init_client = __esm({
8445
8445
  evictedBytesSinceLastWarn = 0;
8446
8446
  lastStreamBufferWarnAt = 0;
8447
8447
  logger;
8448
+ markAlive() {
8449
+ this.isAlive = true;
8450
+ }
8448
8451
  setupSocketHandlers() {
8449
8452
  this.socket.on("message", (data, isBinary) => {
8453
+ this.markAlive();
8450
8454
  if (isBinary) {
8451
8455
  this.messageHandler?.(data);
8452
8456
  return;
@@ -8465,7 +8469,7 @@ var init_client = __esm({
8465
8469
  this.closeHandler?.();
8466
8470
  });
8467
8471
  this.socket.on("pong", () => {
8468
- this.isAlive = true;
8472
+ this.markAlive();
8469
8473
  });
8470
8474
  }
8471
8475
  /**
@@ -8975,6 +8979,10 @@ var init_hub = __esm({
8975
8979
  */
8976
8980
  pingAll() {
8977
8981
  for (const client of this.clients.values()) {
8982
+ if (!client.alive) {
8983
+ client.close(1011, "keepalive_timeout");
8984
+ continue;
8985
+ }
8978
8986
  client.ping();
8979
8987
  }
8980
8988
  }
@@ -9233,6 +9241,18 @@ var init_workspace_activity = __esm({
9233
9241
  }
9234
9242
  });
9235
9243
 
9244
+ // packages/server/src/commands/connection.ts
9245
+ import { z as z8 } from "zod";
9246
+ var init_connection = __esm({
9247
+ "packages/server/src/commands/connection.ts"() {
9248
+ "use strict";
9249
+ init_dispatch();
9250
+ registerCommand("connection.probe", z8.object({}).default({}), async () => {
9251
+ return { ok: true };
9252
+ });
9253
+ }
9254
+ });
9255
+
9236
9256
  // packages/server/src/provider-runtime/runtime-status.ts
9237
9257
  function canAutoInstall(provider, platform, missingCommands, missingPrerequisites, availableCommands) {
9238
9258
  const strategies = provider.install.strategies[platform] ?? [];
@@ -9327,7 +9347,7 @@ var init_runtime_status = __esm({
9327
9347
  });
9328
9348
 
9329
9349
  // packages/server/src/commands/session.ts
9330
- import { z as z8 } from "zod";
9350
+ import { z as z9 } from "zod";
9331
9351
  function getProviderFromRegistry(providerId, registry) {
9332
9352
  return registry.find((provider) => provider.id === providerId);
9333
9353
  }
@@ -9338,8 +9358,8 @@ var init_session = __esm({
9338
9358
  init_dispatch();
9339
9359
  registerCommand(
9340
9360
  "session.list",
9341
- z8.object({
9342
- workspaceId: z8.string()
9361
+ z9.object({
9362
+ workspaceId: z9.string()
9343
9363
  }),
9344
9364
  async (args, ctx) => {
9345
9365
  return ctx.sessionMgr.getForWorkspace(args.workspaceId);
@@ -9347,10 +9367,10 @@ var init_session = __esm({
9347
9367
  );
9348
9368
  registerCommand(
9349
9369
  "session.create",
9350
- z8.object({
9351
- workspaceId: z8.string(),
9352
- providerId: z8.string(),
9353
- draft: z8.string().optional()
9370
+ z9.object({
9371
+ workspaceId: z9.string(),
9372
+ providerId: z9.string(),
9373
+ draft: z9.string().optional()
9354
9374
  }),
9355
9375
  async (args, ctx) => {
9356
9376
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9384,8 +9404,8 @@ var init_session = __esm({
9384
9404
  );
9385
9405
  registerCommand(
9386
9406
  "session.stop",
9387
- z8.object({
9388
- sessionId: z8.string()
9407
+ z9.object({
9408
+ sessionId: z9.string()
9389
9409
  }),
9390
9410
  async (args, ctx) => {
9391
9411
  await ctx.sessionMgr.stop(args.sessionId);
@@ -9393,8 +9413,8 @@ var init_session = __esm({
9393
9413
  );
9394
9414
  registerCommand(
9395
9415
  "session.remove",
9396
- z8.object({
9397
- sessionId: z8.string()
9416
+ z9.object({
9417
+ sessionId: z9.string()
9398
9418
  }),
9399
9419
  async (args, ctx) => {
9400
9420
  const session = ctx.sessionMgr.get(args.sessionId);
@@ -9559,7 +9579,7 @@ var init_tree = __esm({
9559
9579
  });
9560
9580
 
9561
9581
  // packages/server/src/commands/file.ts
9562
- import { z as z9 } from "zod";
9582
+ import { z as z10 } from "zod";
9563
9583
  var init_file = __esm({
9564
9584
  "packages/server/src/commands/file.ts"() {
9565
9585
  "use strict";
@@ -9568,9 +9588,9 @@ var init_file = __esm({
9568
9588
  init_dispatch();
9569
9589
  registerCommand(
9570
9590
  "file.readTree",
9571
- z9.object({
9572
- workspaceId: z9.string(),
9573
- subPath: z9.string().optional()
9591
+ z10.object({
9592
+ workspaceId: z10.string(),
9593
+ subPath: z10.string().optional()
9574
9594
  }),
9575
9595
  async (args, ctx) => {
9576
9596
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9582,10 +9602,10 @@ var init_file = __esm({
9582
9602
  );
9583
9603
  registerCommand(
9584
9604
  "file.search",
9585
- z9.object({
9586
- workspaceId: z9.string(),
9587
- query: z9.string(),
9588
- limit: z9.number().int().positive().max(50).optional()
9605
+ z10.object({
9606
+ workspaceId: z10.string(),
9607
+ query: z10.string(),
9608
+ limit: z10.number().int().positive().max(50).optional()
9589
9609
  }),
9590
9610
  async (args, ctx) => {
9591
9611
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9597,9 +9617,9 @@ var init_file = __esm({
9597
9617
  );
9598
9618
  registerCommand(
9599
9619
  "file.read",
9600
- z9.object({
9601
- workspaceId: z9.string(),
9602
- path: z9.string()
9620
+ z10.object({
9621
+ workspaceId: z10.string(),
9622
+ path: z10.string()
9603
9623
  }),
9604
9624
  async (args, ctx) => {
9605
9625
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9611,9 +9631,9 @@ var init_file = __esm({
9611
9631
  );
9612
9632
  registerCommand(
9613
9633
  "file.create",
9614
- z9.object({
9615
- workspaceId: z9.string(),
9616
- path: z9.string()
9634
+ z10.object({
9635
+ workspaceId: z10.string(),
9636
+ path: z10.string()
9617
9637
  }),
9618
9638
  async (args, ctx) => {
9619
9639
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9631,9 +9651,9 @@ var init_file = __esm({
9631
9651
  );
9632
9652
  registerCommand(
9633
9653
  "file.mkdir",
9634
- z9.object({
9635
- workspaceId: z9.string(),
9636
- path: z9.string()
9654
+ z10.object({
9655
+ workspaceId: z10.string(),
9656
+ path: z10.string()
9637
9657
  }),
9638
9658
  async (args, ctx) => {
9639
9659
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9651,9 +9671,9 @@ var init_file = __esm({
9651
9671
  );
9652
9672
  registerCommand(
9653
9673
  "file.delete",
9654
- z9.object({
9655
- workspaceId: z9.string(),
9656
- path: z9.string()
9674
+ z10.object({
9675
+ workspaceId: z10.string(),
9676
+ path: z10.string()
9657
9677
  }),
9658
9678
  async (args, ctx) => {
9659
9679
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9671,11 +9691,11 @@ var init_file = __esm({
9671
9691
  );
9672
9692
  registerCommand(
9673
9693
  "file.write",
9674
- z9.object({
9675
- workspaceId: z9.string(),
9676
- path: z9.string(),
9677
- content: z9.string(),
9678
- baseHash: z9.string().optional()
9694
+ z10.object({
9695
+ workspaceId: z10.string(),
9696
+ path: z10.string(),
9697
+ content: z10.string(),
9698
+ baseHash: z10.string().optional()
9679
9699
  // For conflict detection
9680
9700
  }),
9681
9701
  async (args, ctx) => {
@@ -9766,7 +9786,7 @@ var init_git_events = __esm({
9766
9786
  });
9767
9787
 
9768
9788
  // packages/server/src/commands/git.ts
9769
- import { z as z10 } from "zod";
9789
+ import { z as z11 } from "zod";
9770
9790
  async function runGitNetworkOperation(ctx, workspaceId, op) {
9771
9791
  if (!ctx.autoFetch?.runExclusive) {
9772
9792
  return op();
@@ -9781,16 +9801,16 @@ var init_git2 = __esm({
9781
9801
  init_diff();
9782
9802
  init_dispatch();
9783
9803
  init_git_events();
9784
- gitHttpAuthSchema = z10.object({
9785
- username: z10.string(),
9786
- password: z10.string()
9804
+ gitHttpAuthSchema = z11.object({
9805
+ username: z11.string(),
9806
+ password: z11.string()
9787
9807
  });
9788
- gitCommitRevisionSchema = z10.string().regex(/^[0-9a-fA-F]{7,64}$/, "Invalid git commit revision");
9808
+ gitCommitRevisionSchema = z11.string().regex(/^[0-9a-fA-F]{7,64}$/, "Invalid git commit revision");
9789
9809
  GIT_BACKGROUND_FETCH_TIMEOUT_MS = 30 * 1e3;
9790
9810
  registerCommand(
9791
9811
  "git.status",
9792
- z10.object({
9793
- workspaceId: z10.string()
9812
+ z11.object({
9813
+ workspaceId: z11.string()
9794
9814
  }),
9795
9815
  async (args, ctx) => {
9796
9816
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9802,9 +9822,9 @@ var init_git2 = __esm({
9802
9822
  );
9803
9823
  registerCommand(
9804
9824
  "git.stage",
9805
- z10.object({
9806
- workspaceId: z10.string(),
9807
- paths: z10.array(z10.string())
9825
+ z11.object({
9826
+ workspaceId: z11.string(),
9827
+ paths: z11.array(z11.string())
9808
9828
  }),
9809
9829
  async (args, ctx) => {
9810
9830
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9818,10 +9838,10 @@ var init_git2 = __esm({
9818
9838
  );
9819
9839
  registerCommand(
9820
9840
  "git.diff",
9821
- z10.object({
9822
- workspaceId: z10.string(),
9823
- path: z10.string(),
9824
- staged: z10.boolean().optional()
9841
+ z11.object({
9842
+ workspaceId: z11.string(),
9843
+ path: z11.string(),
9844
+ staged: z11.boolean().optional()
9825
9845
  }),
9826
9846
  async (args, ctx) => {
9827
9847
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9835,9 +9855,9 @@ var init_git2 = __esm({
9835
9855
  );
9836
9856
  registerCommand(
9837
9857
  "git.log",
9838
- z10.object({
9839
- workspaceId: z10.string(),
9840
- limit: z10.number().int().min(1).max(50).optional()
9858
+ z11.object({
9859
+ workspaceId: z11.string(),
9860
+ limit: z11.number().int().min(1).max(50).optional()
9841
9861
  }),
9842
9862
  async (args, ctx) => {
9843
9863
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9851,8 +9871,8 @@ var init_git2 = __esm({
9851
9871
  );
9852
9872
  registerCommand(
9853
9873
  "git.show",
9854
- z10.object({
9855
- workspaceId: z10.string(),
9874
+ z11.object({
9875
+ workspaceId: z11.string(),
9856
9876
  sha: gitCommitRevisionSchema
9857
9877
  }),
9858
9878
  async (args, ctx) => {
@@ -9867,9 +9887,9 @@ var init_git2 = __esm({
9867
9887
  );
9868
9888
  registerCommand(
9869
9889
  "git.unstage",
9870
- z10.object({
9871
- workspaceId: z10.string(),
9872
- paths: z10.array(z10.string())
9890
+ z11.object({
9891
+ workspaceId: z11.string(),
9892
+ paths: z11.array(z11.string())
9873
9893
  }),
9874
9894
  async (args, ctx) => {
9875
9895
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9883,9 +9903,9 @@ var init_git2 = __esm({
9883
9903
  );
9884
9904
  registerCommand(
9885
9905
  "git.discard",
9886
- z10.object({
9887
- workspaceId: z10.string(),
9888
- paths: z10.array(z10.string())
9906
+ z11.object({
9907
+ workspaceId: z11.string(),
9908
+ paths: z11.array(z11.string())
9889
9909
  }),
9890
9910
  async (args, ctx) => {
9891
9911
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9901,9 +9921,9 @@ var init_git2 = __esm({
9901
9921
  );
9902
9922
  registerCommand(
9903
9923
  "git.commit",
9904
- z10.object({
9905
- workspaceId: z10.string(),
9906
- message: z10.string()
9924
+ z11.object({
9925
+ workspaceId: z11.string(),
9926
+ message: z11.string()
9907
9927
  }),
9908
9928
  async (args, ctx) => {
9909
9929
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -9920,11 +9940,11 @@ var init_git2 = __esm({
9920
9940
  );
9921
9941
  registerCommand(
9922
9942
  "git.push",
9923
- z10.object({
9924
- workspaceId: z10.string(),
9925
- remote: z10.string().optional(),
9926
- branch: z10.string().optional(),
9927
- force: z10.boolean().optional(),
9943
+ z11.object({
9944
+ workspaceId: z11.string(),
9945
+ remote: z11.string().optional(),
9946
+ branch: z11.string().optional(),
9947
+ force: z11.boolean().optional(),
9928
9948
  auth: gitHttpAuthSchema.optional()
9929
9949
  }),
9930
9950
  async (args, ctx) => {
@@ -9951,10 +9971,10 @@ var init_git2 = __esm({
9951
9971
  );
9952
9972
  registerCommand(
9953
9973
  "git.pull",
9954
- z10.object({
9955
- workspaceId: z10.string(),
9956
- remote: z10.string().optional(),
9957
- branch: z10.string().optional(),
9974
+ z11.object({
9975
+ workspaceId: z11.string(),
9976
+ remote: z11.string().optional(),
9977
+ branch: z11.string().optional(),
9958
9978
  auth: gitHttpAuthSchema.optional()
9959
9979
  }),
9960
9980
  async (args, ctx) => {
@@ -9982,12 +10002,12 @@ var init_git2 = __esm({
9982
10002
  );
9983
10003
  registerCommand(
9984
10004
  "git.fetch",
9985
- z10.object({
9986
- workspaceId: z10.string(),
9987
- remote: z10.string().optional(),
9988
- prune: z10.boolean().optional(),
10005
+ z11.object({
10006
+ workspaceId: z11.string(),
10007
+ remote: z11.string().optional(),
10008
+ prune: z11.boolean().optional(),
9989
10009
  auth: gitHttpAuthSchema.optional(),
9990
- background: z10.boolean().optional()
10010
+ background: z11.boolean().optional()
9991
10011
  }),
9992
10012
  async (args, ctx, clientId) => {
9993
10013
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -10016,10 +10036,10 @@ var init_git2 = __esm({
10016
10036
  );
10017
10037
  registerCommand(
10018
10038
  "git.checkout",
10019
- z10.object({
10020
- workspaceId: z10.string(),
10021
- ref: z10.string(),
10022
- createBranch: z10.boolean().optional()
10039
+ z11.object({
10040
+ workspaceId: z11.string(),
10041
+ ref: z11.string(),
10042
+ createBranch: z11.boolean().optional()
10023
10043
  }),
10024
10044
  async (args, ctx) => {
10025
10045
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -10041,10 +10061,10 @@ var init_git2 = __esm({
10041
10061
  );
10042
10062
  registerCommand(
10043
10063
  "git.branch",
10044
- z10.object({
10045
- workspaceId: z10.string(),
10046
- name: z10.string(),
10047
- startPoint: z10.string().optional()
10064
+ z11.object({
10065
+ workspaceId: z11.string(),
10066
+ name: z11.string(),
10067
+ startPoint: z11.string().optional()
10048
10068
  }),
10049
10069
  async (args, ctx) => {
10050
10070
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -10063,8 +10083,8 @@ var init_git2 = __esm({
10063
10083
  );
10064
10084
  registerCommand(
10065
10085
  "git.branches",
10066
- z10.object({
10067
- workspaceId: z10.string()
10086
+ z11.object({
10087
+ workspaceId: z11.string()
10068
10088
  }),
10069
10089
  async (args, ctx) => {
10070
10090
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -10158,7 +10178,7 @@ var init_config_io = __esm({
10158
10178
  });
10159
10179
 
10160
10180
  // packages/server/src/commands/settings.ts
10161
- import { z as z11 } from "zod";
10181
+ import { z as z12 } from "zod";
10162
10182
  function flattenSettings(obj, prefix = "") {
10163
10183
  const result = {};
10164
10184
  for (const [key, value] of Object.entries(obj)) {
@@ -10181,27 +10201,28 @@ var init_settings2 = __esm({
10181
10201
  init_provider_config_repo();
10182
10202
  init_settings();
10183
10203
  init_dispatch();
10184
- SettingsSchema = z11.object({
10185
- defaultProviderId: z11.string().optional(),
10186
- notifications: z11.object({
10187
- enabled: z11.boolean().optional(),
10188
- soundEnabled: z11.boolean().optional(),
10204
+ SettingsSchema = z12.object({
10205
+ defaultProviderId: z12.string().optional(),
10206
+ notifications: z12.object({
10207
+ enabled: z12.boolean().optional(),
10208
+ soundEnabled: z12.boolean().optional(),
10189
10209
  // Legacy field — accepted for backward compat with older clients but
10190
10210
  // no longer surfaced in the UI. The web client now picks the channel
10191
10211
  // automatically based on workspace focus + page visibility.
10192
- onlyWhenBackgrounded: z11.boolean().optional()
10212
+ onlyWhenBackgrounded: z12.boolean().optional()
10193
10213
  }).optional(),
10194
- supervisor: z11.object({
10195
- evaluationTimeoutSec: z11.number().int().min(1).max(MAX_SUPERVISOR_EVALUATION_TIMEOUT_SEC).default(DEFAULT_SUPERVISOR_EVALUATION_TIMEOUT_SEC).optional()
10214
+ supervisor: z12.object({
10215
+ evaluationTimeoutSec: z12.number().int().min(1).max(MAX_SUPERVISOR_EVALUATION_TIMEOUT_SEC).default(DEFAULT_SUPERVISOR_EVALUATION_TIMEOUT_SEC).optional()
10196
10216
  }).optional(),
10197
- appearance: z11.object({
10198
- theme: z11.enum(["dark"]).optional(),
10199
- terminalRenderer: z11.enum(["standard", "compatibility"]).optional(),
10200
- locale: z11.enum(["zh", "en"]).optional()
10217
+ appearance: z12.object({
10218
+ theme: z12.enum(["dark"]).optional(),
10219
+ terminalRenderer: z12.enum(["standard", "compatibility"]).optional(),
10220
+ terminalCopyOnSelect: z12.boolean().optional(),
10221
+ locale: z12.enum(["zh", "en"]).optional()
10201
10222
  }).optional(),
10202
10223
  providers: ProviderSettingsSchema.optional()
10203
10224
  });
10204
- registerCommand("settings.get", z11.object({}), async (_args, ctx) => {
10225
+ registerCommand("settings.get", z12.object({}), async (_args, ctx) => {
10205
10226
  const row = ctx.db.prepare("SELECT key, value FROM user_settings").all();
10206
10227
  const settings = {};
10207
10228
  for (const { key, value } of row) {
@@ -10234,7 +10255,7 @@ var init_settings2 = __esm({
10234
10255
  });
10235
10256
  registerCommand(
10236
10257
  "settings.update",
10237
- z11.object({
10258
+ z12.object({
10238
10259
  settings: SettingsSchema
10239
10260
  }),
10240
10261
  async (args, ctx) => {
@@ -10266,10 +10287,10 @@ var init_settings2 = __esm({
10266
10287
  );
10267
10288
  registerCommand(
10268
10289
  "settings.previewCommand",
10269
- z11.object({
10270
- providerId: z11.string(),
10290
+ z12.object({
10291
+ providerId: z12.string(),
10271
10292
  config: ProviderLaunchConfigInputSchema,
10272
- workspacePath: z11.string().optional()
10293
+ workspacePath: z12.string().optional()
10273
10294
  }),
10274
10295
  async (args, ctx) => {
10275
10296
  const provider = ctx.providerRegistry.find((item) => item.id === args.providerId);
@@ -10290,8 +10311,8 @@ var init_settings2 = __esm({
10290
10311
  );
10291
10312
  registerCommand(
10292
10313
  "settings.readConfigFile",
10293
- z11.object({
10294
- configType: z11.enum(["codex", "claude"])
10314
+ z12.object({
10315
+ configType: z12.enum(["codex", "claude"])
10295
10316
  }),
10296
10317
  async (args) => {
10297
10318
  const result = readConfigFile(args.configType);
@@ -10300,9 +10321,9 @@ var init_settings2 = __esm({
10300
10321
  );
10301
10322
  registerCommand(
10302
10323
  "settings.writeConfigFile",
10303
- z11.object({
10304
- configType: z11.enum(["codex", "claude"]),
10305
- content: z11.string()
10324
+ z12.object({
10325
+ configType: z12.enum(["codex", "claude"]),
10326
+ content: z12.string()
10306
10327
  }),
10307
10328
  async (args) => {
10308
10329
  const result = writeConfigFile(args.configType, args.content);
@@ -10313,19 +10334,19 @@ var init_settings2 = __esm({
10313
10334
  });
10314
10335
 
10315
10336
  // packages/server/src/commands/provider.ts
10316
- import { z as z12 } from "zod";
10337
+ import { z as z13 } from "zod";
10317
10338
  var init_provider = __esm({
10318
10339
  "packages/server/src/commands/provider.ts"() {
10319
10340
  "use strict";
10320
10341
  init_runtime_status();
10321
10342
  init_dispatch();
10322
- registerCommand("provider.runtimeStatus", z12.object({}), async (_args, ctx) => {
10343
+ registerCommand("provider.runtimeStatus", z13.object({}), async (_args, ctx) => {
10323
10344
  return buildProviderRuntimeStatus(ctx.providerRegistry, ctx.providerRuntimeDeps);
10324
10345
  });
10325
10346
  registerCommand(
10326
10347
  "provider.install.start",
10327
- z12.object({
10328
- providerId: z12.string()
10348
+ z13.object({
10349
+ providerId: z13.string()
10329
10350
  }),
10330
10351
  async (args, ctx) => {
10331
10352
  if (!ctx.providerInstallMgr) {
@@ -10339,8 +10360,8 @@ var init_provider = __esm({
10339
10360
  );
10340
10361
  registerCommand(
10341
10362
  "provider.install.get",
10342
- z12.object({
10343
- jobId: z12.string()
10363
+ z13.object({
10364
+ jobId: z13.string()
10344
10365
  }),
10345
10366
  async (args, ctx) => {
10346
10367
  if (!ctx.providerInstallMgr) {
@@ -10363,29 +10384,29 @@ var init_provider = __esm({
10363
10384
  });
10364
10385
 
10365
10386
  // packages/server/src/commands/supervisor.ts
10366
- import { z as z13 } from "zod";
10387
+ import { z as z14 } from "zod";
10367
10388
  var supervisorObjectiveSchema, createSupervisorSchema, updateSupervisorSchema, sessionIdSchema, supervisorIdSchema;
10368
10389
  var init_supervisor2 = __esm({
10369
10390
  "packages/server/src/commands/supervisor.ts"() {
10370
10391
  "use strict";
10371
10392
  init_dispatch();
10372
- supervisorObjectiveSchema = z13.string().trim().min(1).max(4e3);
10373
- createSupervisorSchema = z13.object({
10374
- sessionId: z13.string(),
10375
- workspaceId: z13.string(),
10393
+ supervisorObjectiveSchema = z14.string().trim().min(1).max(4e3);
10394
+ createSupervisorSchema = z14.object({
10395
+ sessionId: z14.string(),
10396
+ workspaceId: z14.string(),
10376
10397
  objective: supervisorObjectiveSchema,
10377
- evaluatorProviderId: z13.string()
10398
+ evaluatorProviderId: z14.string()
10378
10399
  }).strict();
10379
- updateSupervisorSchema = z13.object({
10380
- id: z13.string(),
10400
+ updateSupervisorSchema = z14.object({
10401
+ id: z14.string(),
10381
10402
  objective: supervisorObjectiveSchema.optional(),
10382
- evaluatorProviderId: z13.string().optional()
10403
+ evaluatorProviderId: z14.string().optional()
10383
10404
  }).strict().refine(
10384
10405
  (input2) => input2.objective !== void 0 || input2.evaluatorProviderId !== void 0,
10385
10406
  "objective or evaluatorProviderId is required"
10386
10407
  );
10387
- sessionIdSchema = z13.object({ sessionId: z13.string() });
10388
- supervisorIdSchema = z13.object({ id: z13.string() });
10408
+ sessionIdSchema = z14.object({ sessionId: z14.string() });
10409
+ supervisorIdSchema = z14.object({ id: z14.string() });
10389
10410
  registerCommand("supervisor.create", createSupervisorSchema, async (args, ctx) => {
10390
10411
  return {
10391
10412
  supervisor: await ctx.supervisorMgr.create({
@@ -10563,7 +10584,7 @@ var init_worktree = __esm({
10563
10584
 
10564
10585
  // packages/server/src/commands/worktree.ts
10565
10586
  import path9 from "node:path";
10566
- import { z as z14 } from "zod";
10587
+ import { z as z15 } from "zod";
10567
10588
  async function findRelatedWorkspaceIds(ctx, workspacePath) {
10568
10589
  const targetCommonDir = await getGitCommonDirPath(workspacePath);
10569
10590
  const relatedWorkspaceIds = await Promise.all(
@@ -10596,7 +10617,7 @@ var init_worktree2 = __esm({
10596
10617
  init_worktree();
10597
10618
  init_dispatch();
10598
10619
  init_git_events();
10599
- registerCommand("worktree.list", z14.object({ workspaceId: z14.string() }), async (args, ctx) => {
10620
+ registerCommand("worktree.list", z15.object({ workspaceId: z15.string() }), async (args, ctx) => {
10600
10621
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
10601
10622
  if (!workspace) {
10602
10623
  throw { code: "workspace_not_found", message: `Workspace not found: ${args.workspaceId}` };
@@ -10605,7 +10626,7 @@ var init_worktree2 = __esm({
10605
10626
  });
10606
10627
  registerCommand(
10607
10628
  "worktree.status",
10608
- z14.object({ workspaceId: z14.string(), worktreePath: z14.string() }),
10629
+ z15.object({ workspaceId: z15.string(), worktreePath: z15.string() }),
10609
10630
  async (args, ctx) => {
10610
10631
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
10611
10632
  if (!workspace) {
@@ -10617,10 +10638,10 @@ var init_worktree2 = __esm({
10617
10638
  );
10618
10639
  registerCommand(
10619
10640
  "worktree.diff",
10620
- z14.object({
10621
- workspaceId: z14.string(),
10622
- worktreePath: z14.string(),
10623
- staged: z14.boolean().optional().default(false)
10641
+ z15.object({
10642
+ workspaceId: z15.string(),
10643
+ worktreePath: z15.string(),
10644
+ staged: z15.boolean().optional().default(false)
10624
10645
  }),
10625
10646
  async (args, ctx) => {
10626
10647
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -10633,7 +10654,7 @@ var init_worktree2 = __esm({
10633
10654
  );
10634
10655
  registerCommand(
10635
10656
  "worktree.tree",
10636
- z14.object({ workspaceId: z14.string(), worktreePath: z14.string() }),
10657
+ z15.object({ workspaceId: z15.string(), worktreePath: z15.string() }),
10637
10658
  async (args, ctx) => {
10638
10659
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
10639
10660
  if (!workspace) {
@@ -10645,10 +10666,10 @@ var init_worktree2 = __esm({
10645
10666
  );
10646
10667
  registerCommand(
10647
10668
  "worktree.create",
10648
- z14.object({
10649
- workspaceId: z14.string(),
10650
- branch: z14.string(),
10651
- path: z14.string()
10669
+ z15.object({
10670
+ workspaceId: z15.string(),
10671
+ branch: z15.string(),
10672
+ path: z15.string()
10652
10673
  }),
10653
10674
  async (args, ctx) => {
10654
10675
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -10663,10 +10684,10 @@ var init_worktree2 = __esm({
10663
10684
  );
10664
10685
  registerCommand(
10665
10686
  "worktree.remove",
10666
- z14.object({
10667
- workspaceId: z14.string(),
10668
- worktreePath: z14.string(),
10669
- force: z14.boolean().optional().default(false)
10687
+ z15.object({
10688
+ workspaceId: z15.string(),
10689
+ worktreePath: z15.string(),
10690
+ force: z15.boolean().optional().default(false)
10670
10691
  }),
10671
10692
  async (args, ctx) => {
10672
10693
  const workspace = ctx.workspaceMgr.get(args.workspaceId);
@@ -10690,7 +10711,7 @@ var init_worktree2 = __esm({
10690
10711
  });
10691
10712
 
10692
10713
  // packages/server/src/commands/fencing.ts
10693
- import { z as z15 } from "zod";
10714
+ import { z as z16 } from "zod";
10694
10715
  function createMockFencingRequest() {
10695
10716
  return {
10696
10717
  ip: "127.0.0.1",
@@ -10703,9 +10724,9 @@ var init_fencing2 = __esm({
10703
10724
  init_dispatch();
10704
10725
  registerCommand(
10705
10726
  "fencing.request",
10706
- z15.object({
10707
- workspaceId: z15.string(),
10708
- tabId: z15.string()
10727
+ z16.object({
10728
+ workspaceId: z16.string(),
10729
+ tabId: z16.string()
10709
10730
  }),
10710
10731
  async (args, ctx, clientId) => {
10711
10732
  return ctx.fencingMgr.requestControl(
@@ -10718,7 +10739,7 @@ var init_fencing2 = __esm({
10718
10739
  );
10719
10740
  registerCommand(
10720
10741
  "fencing.heartbeat",
10721
- z15.object({ workspaceId: z15.string() }),
10742
+ z16.object({ workspaceId: z16.string() }),
10722
10743
  async (args, ctx, clientId) => {
10723
10744
  const success = ctx.fencingMgr.heartbeat(args.workspaceId, clientId);
10724
10745
  return { success };
@@ -10726,13 +10747,13 @@ var init_fencing2 = __esm({
10726
10747
  );
10727
10748
  registerCommand(
10728
10749
  "fencing.release",
10729
- z15.object({ workspaceId: z15.string() }),
10750
+ z16.object({ workspaceId: z16.string() }),
10730
10751
  async (args, ctx, clientId) => {
10731
10752
  ctx.fencingMgr.release(args.workspaceId, clientId);
10732
10753
  return {};
10733
10754
  }
10734
10755
  );
10735
- registerCommand("fencing.status", z15.object({ workspaceId: z15.string() }), async (args, ctx) => {
10756
+ registerCommand("fencing.status", z16.object({ workspaceId: z16.string() }), async (args, ctx) => {
10736
10757
  const controller = ctx.fencingMgr.getController(args.workspaceId);
10737
10758
  const isUnresponsive = ctx.fencingMgr.isControllerUnresponsive(args.workspaceId);
10738
10759
  return {
@@ -10743,9 +10764,9 @@ var init_fencing2 = __esm({
10743
10764
  });
10744
10765
  registerCommand(
10745
10766
  "fencing.takeover",
10746
- z15.object({
10747
- workspaceId: z15.string(),
10748
- tabId: z15.string()
10767
+ z16.object({
10768
+ workspaceId: z16.string(),
10769
+ tabId: z16.string()
10749
10770
  }),
10750
10771
  async (args, ctx, clientId) => {
10751
10772
  return ctx.fencingMgr.forceTakeover(
@@ -10765,6 +10786,7 @@ var init_commands = __esm({
10765
10786
  "use strict";
10766
10787
  init_workspace();
10767
10788
  init_workspace_activity();
10789
+ init_connection();
10768
10790
  init_session();
10769
10791
  init_terminal();
10770
10792
  init_file();
@@ -10933,11 +10955,16 @@ async function createServer(configOverrides) {
10933
10955
  );
10934
10956
  }, STARTUP_GC_DELAY_MS);
10935
10957
  gcTimer.unref();
10958
+ const wsKeepaliveTimer = setInterval(() => {
10959
+ wsHub.pingAll();
10960
+ }, WS_KEEPALIVE_INTERVAL_MS);
10961
+ wsKeepaliveTimer.unref();
10936
10962
  let stopped = false;
10937
10963
  const stopServer = async () => {
10938
10964
  if (stopped) return;
10939
10965
  stopped = true;
10940
10966
  clearTimeout(gcTimer);
10967
+ clearInterval(wsKeepaliveTimer);
10941
10968
  await app.close();
10942
10969
  autoFetch.stop();
10943
10970
  supervisorMgr.stop();
@@ -11053,6 +11080,7 @@ function createSessionDatabase(db) {
11053
11080
  }
11054
11081
  };
11055
11082
  }
11083
+ var WS_KEEPALIVE_INTERVAL_MS;
11056
11084
  var init_server = __esm({
11057
11085
  async "packages/server/src/server.ts"() {
11058
11086
  "use strict";
@@ -11085,6 +11113,7 @@ var init_server = __esm({
11085
11113
  init_fencing();
11086
11114
  init_hub();
11087
11115
  init_commands();
11116
+ WS_KEEPALIVE_INTERVAL_MS = 15e3;
11088
11117
  if (isDirectExecution(import.meta.url)) {
11089
11118
  const server = await createServer();
11090
11119
  process.on("SIGINT", async () => {