agent-shim 14.12.2 → 14.12.4

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/cli.cjs CHANGED
@@ -76444,7 +76444,7 @@ var init_package = __esm({
76444
76444
  "package.json"() {
76445
76445
  package_default = {
76446
76446
  name: "agent-shim",
76447
- version: "14.12.2",
76447
+ version: "14.12.4",
76448
76448
  description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
76449
76449
  license: "MIT",
76450
76450
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -77280,6 +77280,11 @@ function isOptionValue(token) {
77280
77280
  return token !== void 0 && !token.startsWith("-");
77281
77281
  }
77282
77282
  function isClaudeSubcommand(passthrough) {
77283
+ const first = passthrough[0];
77284
+ const afterPermissionFlags = passthrough.find((token) => !FLAGS_BEFORE_DAEMON.has(token));
77285
+ if (first !== void 0 && FIRST_ARGUMENT_SUBCOMMANDS.has(first) || afterPermissionFlags === "daemon") {
77286
+ return true;
77287
+ }
77283
77288
  let index = 0;
77284
77289
  while (index < passthrough.length) {
77285
77290
  const token = passthrough[index];
@@ -77305,7 +77310,7 @@ function isClaudeSubcommand(passthrough) {
77305
77310
  }
77306
77311
  return false;
77307
77312
  }
77308
- var CLAUDE_SUBCOMMANDS, VALUE_OPTIONS, VARIADIC_OPTIONS, OPTIONAL_VALUE_OPTIONS;
77313
+ var CLAUDE_SUBCOMMANDS, FIRST_ARGUMENT_SUBCOMMANDS, FLAGS_BEFORE_DAEMON, VALUE_OPTIONS, VARIADIC_OPTIONS, OPTIONAL_VALUE_OPTIONS;
77309
77314
  var init_claudeSubcommand = __esm({
77310
77315
  "src/launcher/claudeSubcommand.ts"() {
77311
77316
  "use strict";
@@ -77315,23 +77320,32 @@ var init_claudeSubcommand = __esm({
77315
77320
  "auth",
77316
77321
  "auto-mode",
77317
77322
  "doctor",
77323
+ "edit-hook",
77318
77324
  "gateway",
77319
77325
  "import",
77326
+ "import-conversations",
77320
77327
  "install",
77321
77328
  "kill",
77322
77329
  "logs",
77323
77330
  "mcp",
77324
77331
  "plugin",
77325
77332
  "plugins",
77333
+ "project",
77326
77334
  "purge",
77335
+ "rc",
77336
+ "remote-control",
77327
77337
  "respawn",
77328
77338
  "rm",
77339
+ "sandbox",
77329
77340
  "setup-token",
77330
77341
  "stop",
77331
77342
  "ultrareview",
77332
77343
  "update",
77333
- "upgrade"
77344
+ "upgrade",
77345
+ "workspace-trust"
77334
77346
  ]);
77347
+ FIRST_ARGUMENT_SUBCOMMANDS = /* @__PURE__ */ new Set(["bridge", "daemon", "remote", "self-hosted-agent-proxy", "self-hosted-runner", "sync"]);
77348
+ FLAGS_BEFORE_DAEMON = /* @__PURE__ */ new Set(["--allow-dangerously-skip-permissions", "--dangerously-skip-permissions"]);
77335
77349
  VALUE_OPTIONS = /* @__PURE__ */ new Set([
77336
77350
  "--agent",
77337
77351
  "--agents",
@@ -155849,6 +155863,16 @@ function parseJsonObject5(body) {
155849
155863
  }
155850
155864
  return isRecord22(parsed) ? parsed : void 0;
155851
155865
  }
155866
+ function internalEventOf(event, newUuid, now) {
155867
+ if (!isRecord22(event) || !isRecord22(event.payload)) {
155868
+ return void 0;
155869
+ }
155870
+ const eventType = nonEmptyString4(event.payload, "type");
155871
+ return eventType === void 0 ? void 0 : { eventId: newUuid(), eventType, payload: event.payload, isCompaction: event.is_compaction === true, agentId: nonEmptyString4(event, "session_agent_id"), createdAt: new Date(now()).toISOString() };
155872
+ }
155873
+ function internalEventRow(event) {
155874
+ return { event_id: event.eventId, event_type: event.eventType, payload: event.payload, is_compaction: event.isCompaction, created_at: event.createdAt, ...event.agentId === void 0 ? {} : { session_agent_id: event.agentId } };
155875
+ }
155852
155876
  function mintWorkerJwt(randomToken, issuedAt) {
155853
155877
  const encode3 = (value3) => Buffer.from(JSON.stringify(value3), "utf8").toString("base64url");
155854
155878
  const header = encode3({ alg: "HS256", typ: "JWT" });
@@ -156165,25 +156189,22 @@ data: ${JSON.stringify(envelope2)}
156165
156189
  return;
156166
156190
  }
156167
156191
  const events = body?.events;
156168
- if (!Array.isArray(events)) {
156169
- await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "an internal event batch is an array" } });
156192
+ const posted = Array.isArray(events) ? events : void 0;
156193
+ const filed = posted?.map((event) => internalEventOf(event, deps.newUuid, deps.now)).filter((event) => event !== void 0);
156194
+ if (filed === void 0 || filed.length !== posted?.length) {
156195
+ await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "an internal event batch is an array of events, each carrying one typed payload object" } });
156170
156196
  return;
156171
156197
  }
156172
- for (const event of events) {
156173
- if (isRecord22(event)) {
156174
- session.internalEvents.push({ eventId: deps.newUuid(), body: event });
156175
- }
156176
- }
156198
+ session.internalEvents.push(...filed);
156177
156199
  await answerJson2(response, HTTP_STATUS.ok, {});
156178
156200
  return;
156179
156201
  }
156180
156202
  if (workerTail === "internal-events" && method === "GET") {
156181
156203
  const query = new URL(request7.url, "http://127.0.0.1").searchParams;
156182
- if (query.get("session_agent_id") !== null || query.get("subagents") !== null) {
156183
- await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "this surface keeps one internal-events channel per session, so an agent-scoped read has no subset to serve" } });
156184
- return;
156185
- }
156186
- const page = pageOfRcChannel(request7.url, session.internalEvents, (event) => event.eventId, (event) => ({ event_id: event.eventId, payload: event.body }));
156204
+ const agentId = query.get("session_agent_id");
156205
+ const everyAgent = query.get("subagents") !== null;
156206
+ const rows = session.internalEvents.filter((event) => agentId !== null ? event.agentId === agentId : event.agentId !== void 0 === everyAgent);
156207
+ const page = pageOfRcChannel(request7.url, rows, (event) => event.eventId, internalEventRow);
156187
156208
  if ("error" in page) {
156188
156209
  const anchorUnknown = query.get("after_event_id") !== null && page.error.startsWith("the anchor names an event id");
156189
156210
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: anchorUnknown ? "after_event_id_not_found" : "invalid_request_error", message: page.error } });
package/dist/index.cjs CHANGED
@@ -15210,7 +15210,7 @@ var init_package = __esm({
15210
15210
  "package.json"() {
15211
15211
  package_default = {
15212
15212
  name: "agent-shim",
15213
- version: "14.12.2",
15213
+ version: "14.12.4",
15214
15214
  description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
15215
15215
  license: "MIT",
15216
15216
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -18315,6 +18315,11 @@ function isOptionValue(token) {
18315
18315
  return token !== void 0 && !token.startsWith("-");
18316
18316
  }
18317
18317
  function isClaudeSubcommand(passthrough) {
18318
+ const first = passthrough[0];
18319
+ const afterPermissionFlags = passthrough.find((token) => !FLAGS_BEFORE_DAEMON.has(token));
18320
+ if (first !== void 0 && FIRST_ARGUMENT_SUBCOMMANDS.has(first) || afterPermissionFlags === "daemon") {
18321
+ return true;
18322
+ }
18318
18323
  let index = 0;
18319
18324
  while (index < passthrough.length) {
18320
18325
  const token = passthrough[index];
@@ -18340,7 +18345,7 @@ function isClaudeSubcommand(passthrough) {
18340
18345
  }
18341
18346
  return false;
18342
18347
  }
18343
- var CLAUDE_SUBCOMMANDS, VALUE_OPTIONS, VARIADIC_OPTIONS, OPTIONAL_VALUE_OPTIONS;
18348
+ var CLAUDE_SUBCOMMANDS, FIRST_ARGUMENT_SUBCOMMANDS, FLAGS_BEFORE_DAEMON, VALUE_OPTIONS, VARIADIC_OPTIONS, OPTIONAL_VALUE_OPTIONS;
18344
18349
  var init_claudeSubcommand = __esm({
18345
18350
  "src/launcher/claudeSubcommand.ts"() {
18346
18351
  "use strict";
@@ -18350,23 +18355,32 @@ var init_claudeSubcommand = __esm({
18350
18355
  "auth",
18351
18356
  "auto-mode",
18352
18357
  "doctor",
18358
+ "edit-hook",
18353
18359
  "gateway",
18354
18360
  "import",
18361
+ "import-conversations",
18355
18362
  "install",
18356
18363
  "kill",
18357
18364
  "logs",
18358
18365
  "mcp",
18359
18366
  "plugin",
18360
18367
  "plugins",
18368
+ "project",
18361
18369
  "purge",
18370
+ "rc",
18371
+ "remote-control",
18362
18372
  "respawn",
18363
18373
  "rm",
18374
+ "sandbox",
18364
18375
  "setup-token",
18365
18376
  "stop",
18366
18377
  "ultrareview",
18367
18378
  "update",
18368
- "upgrade"
18379
+ "upgrade",
18380
+ "workspace-trust"
18369
18381
  ]);
18382
+ FIRST_ARGUMENT_SUBCOMMANDS = /* @__PURE__ */ new Set(["bridge", "daemon", "remote", "self-hosted-agent-proxy", "self-hosted-runner", "sync"]);
18383
+ FLAGS_BEFORE_DAEMON = /* @__PURE__ */ new Set(["--allow-dangerously-skip-permissions", "--dangerously-skip-permissions"]);
18370
18384
  VALUE_OPTIONS = /* @__PURE__ */ new Set([
18371
18385
  "--agent",
18372
18386
  "--agents",
@@ -27939,6 +27953,16 @@ function parseJsonObject5(body) {
27939
27953
  }
27940
27954
  return isRecord16(parsed) ? parsed : void 0;
27941
27955
  }
27956
+ function internalEventOf(event, newUuid, now) {
27957
+ if (!isRecord16(event) || !isRecord16(event.payload)) {
27958
+ return void 0;
27959
+ }
27960
+ const eventType = nonEmptyString4(event.payload, "type");
27961
+ return eventType === void 0 ? void 0 : { eventId: newUuid(), eventType, payload: event.payload, isCompaction: event.is_compaction === true, agentId: nonEmptyString4(event, "session_agent_id"), createdAt: new Date(now()).toISOString() };
27962
+ }
27963
+ function internalEventRow(event) {
27964
+ return { event_id: event.eventId, event_type: event.eventType, payload: event.payload, is_compaction: event.isCompaction, created_at: event.createdAt, ...event.agentId === void 0 ? {} : { session_agent_id: event.agentId } };
27965
+ }
27942
27966
  function mintWorkerJwt(randomToken, issuedAt) {
27943
27967
  const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
27944
27968
  const header = encode({ alg: "HS256", typ: "JWT" });
@@ -28255,25 +28279,22 @@ data: ${JSON.stringify(envelope)}
28255
28279
  return;
28256
28280
  }
28257
28281
  const events = body?.events;
28258
- if (!Array.isArray(events)) {
28259
- await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "an internal event batch is an array" } });
28282
+ const posted = Array.isArray(events) ? events : void 0;
28283
+ const filed = posted?.map((event) => internalEventOf(event, deps.newUuid, deps.now)).filter((event) => event !== void 0);
28284
+ if (filed === void 0 || filed.length !== posted?.length) {
28285
+ await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "an internal event batch is an array of events, each carrying one typed payload object" } });
28260
28286
  return;
28261
28287
  }
28262
- for (const event of events) {
28263
- if (isRecord16(event)) {
28264
- session.internalEvents.push({ eventId: deps.newUuid(), body: event });
28265
- }
28266
- }
28288
+ session.internalEvents.push(...filed);
28267
28289
  await answerJson2(response, HTTP_STATUS.ok, {});
28268
28290
  return;
28269
28291
  }
28270
28292
  if (workerTail === "internal-events" && method === "GET") {
28271
28293
  const query = new URL(request4.url, "http://127.0.0.1").searchParams;
28272
- if (query.get("session_agent_id") !== null || query.get("subagents") !== null) {
28273
- await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "this surface keeps one internal-events channel per session, so an agent-scoped read has no subset to serve" } });
28274
- return;
28275
- }
28276
- const page = pageOfRcChannel(request4.url, session.internalEvents, (event) => event.eventId, (event) => ({ event_id: event.eventId, payload: event.body }));
28294
+ const agentId = query.get("session_agent_id");
28295
+ const everyAgent = query.get("subagents") !== null;
28296
+ const rows = session.internalEvents.filter((event) => agentId !== null ? event.agentId === agentId : event.agentId !== void 0 === everyAgent);
28297
+ const page = pageOfRcChannel(request4.url, rows, (event) => event.eventId, internalEventRow);
28277
28298
  if ("error" in page) {
28278
28299
  const anchorUnknown = query.get("after_event_id") !== null && page.error.startsWith("the anchor names an event id");
28279
28300
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: anchorUnknown ? "after_event_id_not_found" : "invalid_request_error", message: page.error } });
package/dist/index.mjs CHANGED
@@ -15181,7 +15181,7 @@ var init_package = __esm({
15181
15181
  "package.json"() {
15182
15182
  package_default = {
15183
15183
  name: "agent-shim",
15184
- version: "14.12.2",
15184
+ version: "14.12.4",
15185
15185
  description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
15186
15186
  license: "MIT",
15187
15187
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -18282,6 +18282,11 @@ function isOptionValue(token) {
18282
18282
  return token !== void 0 && !token.startsWith("-");
18283
18283
  }
18284
18284
  function isClaudeSubcommand(passthrough) {
18285
+ const first = passthrough[0];
18286
+ const afterPermissionFlags = passthrough.find((token) => !FLAGS_BEFORE_DAEMON.has(token));
18287
+ if (first !== void 0 && FIRST_ARGUMENT_SUBCOMMANDS.has(first) || afterPermissionFlags === "daemon") {
18288
+ return true;
18289
+ }
18285
18290
  let index = 0;
18286
18291
  while (index < passthrough.length) {
18287
18292
  const token = passthrough[index];
@@ -18307,7 +18312,7 @@ function isClaudeSubcommand(passthrough) {
18307
18312
  }
18308
18313
  return false;
18309
18314
  }
18310
- var CLAUDE_SUBCOMMANDS, VALUE_OPTIONS, VARIADIC_OPTIONS, OPTIONAL_VALUE_OPTIONS;
18315
+ var CLAUDE_SUBCOMMANDS, FIRST_ARGUMENT_SUBCOMMANDS, FLAGS_BEFORE_DAEMON, VALUE_OPTIONS, VARIADIC_OPTIONS, OPTIONAL_VALUE_OPTIONS;
18311
18316
  var init_claudeSubcommand = __esm({
18312
18317
  "src/launcher/claudeSubcommand.ts"() {
18313
18318
  "use strict";
@@ -18317,23 +18322,32 @@ var init_claudeSubcommand = __esm({
18317
18322
  "auth",
18318
18323
  "auto-mode",
18319
18324
  "doctor",
18325
+ "edit-hook",
18320
18326
  "gateway",
18321
18327
  "import",
18328
+ "import-conversations",
18322
18329
  "install",
18323
18330
  "kill",
18324
18331
  "logs",
18325
18332
  "mcp",
18326
18333
  "plugin",
18327
18334
  "plugins",
18335
+ "project",
18328
18336
  "purge",
18337
+ "rc",
18338
+ "remote-control",
18329
18339
  "respawn",
18330
18340
  "rm",
18341
+ "sandbox",
18331
18342
  "setup-token",
18332
18343
  "stop",
18333
18344
  "ultrareview",
18334
18345
  "update",
18335
- "upgrade"
18346
+ "upgrade",
18347
+ "workspace-trust"
18336
18348
  ]);
18349
+ FIRST_ARGUMENT_SUBCOMMANDS = /* @__PURE__ */ new Set(["bridge", "daemon", "remote", "self-hosted-agent-proxy", "self-hosted-runner", "sync"]);
18350
+ FLAGS_BEFORE_DAEMON = /* @__PURE__ */ new Set(["--allow-dangerously-skip-permissions", "--dangerously-skip-permissions"]);
18337
18351
  VALUE_OPTIONS = /* @__PURE__ */ new Set([
18338
18352
  "--agent",
18339
18353
  "--agents",
@@ -27486,6 +27500,16 @@ function parseJsonObject5(body) {
27486
27500
  }
27487
27501
  return isRecord16(parsed) ? parsed : void 0;
27488
27502
  }
27503
+ function internalEventOf(event, newUuid, now) {
27504
+ if (!isRecord16(event) || !isRecord16(event.payload)) {
27505
+ return void 0;
27506
+ }
27507
+ const eventType = nonEmptyString4(event.payload, "type");
27508
+ return eventType === void 0 ? void 0 : { eventId: newUuid(), eventType, payload: event.payload, isCompaction: event.is_compaction === true, agentId: nonEmptyString4(event, "session_agent_id"), createdAt: new Date(now()).toISOString() };
27509
+ }
27510
+ function internalEventRow(event) {
27511
+ return { event_id: event.eventId, event_type: event.eventType, payload: event.payload, is_compaction: event.isCompaction, created_at: event.createdAt, ...event.agentId === void 0 ? {} : { session_agent_id: event.agentId } };
27512
+ }
27489
27513
  function mintWorkerJwt(randomToken, issuedAt) {
27490
27514
  const encode = (value) => Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
27491
27515
  const header = encode({ alg: "HS256", typ: "JWT" });
@@ -27802,25 +27826,22 @@ data: ${JSON.stringify(envelope)}
27802
27826
  return;
27803
27827
  }
27804
27828
  const events = body?.events;
27805
- if (!Array.isArray(events)) {
27806
- await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "an internal event batch is an array" } });
27829
+ const posted = Array.isArray(events) ? events : void 0;
27830
+ const filed = posted?.map((event) => internalEventOf(event, deps.newUuid, deps.now)).filter((event) => event !== void 0);
27831
+ if (filed === void 0 || filed.length !== posted?.length) {
27832
+ await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "an internal event batch is an array of events, each carrying one typed payload object" } });
27807
27833
  return;
27808
27834
  }
27809
- for (const event of events) {
27810
- if (isRecord16(event)) {
27811
- session.internalEvents.push({ eventId: deps.newUuid(), body: event });
27812
- }
27813
- }
27835
+ session.internalEvents.push(...filed);
27814
27836
  await answerJson2(response, HTTP_STATUS.ok, {});
27815
27837
  return;
27816
27838
  }
27817
27839
  if (workerTail === "internal-events" && method === "GET") {
27818
27840
  const query = new URL(request4.url, "http://127.0.0.1").searchParams;
27819
- if (query.get("session_agent_id") !== null || query.get("subagents") !== null) {
27820
- await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "this surface keeps one internal-events channel per session, so an agent-scoped read has no subset to serve" } });
27821
- return;
27822
- }
27823
- const page = pageOfRcChannel(request4.url, session.internalEvents, (event) => event.eventId, (event) => ({ event_id: event.eventId, payload: event.body }));
27841
+ const agentId = query.get("session_agent_id");
27842
+ const everyAgent = query.get("subagents") !== null;
27843
+ const rows = session.internalEvents.filter((event) => agentId !== null ? event.agentId === agentId : event.agentId !== void 0 === everyAgent);
27844
+ const page = pageOfRcChannel(request4.url, rows, (event) => event.eventId, internalEventRow);
27824
27845
  if ("error" in page) {
27825
27846
  const anchorUnknown = query.get("after_event_id") !== null && page.error.startsWith("the anchor names an event id");
27826
27847
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: anchorUnknown ? "after_event_id_not_found" : "invalid_request_error", message: page.error } });