@alook/daemon 0.1.52 → 0.1.54

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/index.js CHANGED
@@ -21973,6 +21973,21 @@ var OwnerDiagnosticReportSchema = exports_external.discriminatedUnion("status",
21973
21973
  }).strict()
21974
21974
  ]);
21975
21975
 
21976
+ // ../shared/src/runtime-models-contract.ts
21977
+ var RUNTIME_MODEL_DISCOVERY_CAPABILITY = "runtime-model-discovery-v1";
21978
+ var RuntimeModelDiscoveryRequestSchema = exports_external.strictObject({
21979
+ requestId: exports_external.string().min(1).max(128),
21980
+ runtimeId: exports_external.string().min(1).max(64)
21981
+ });
21982
+ var RuntimeModelDiscoveryCommandSchema = RuntimeModelDiscoveryRequestSchema.extend({
21983
+ type: exports_external.literal("runtime:discover_models")
21984
+ });
21985
+ var RuntimeModelDiscoveryErrorSchema = exports_external.strictObject({
21986
+ status: exports_external.literal("error"),
21987
+ code: exports_external.string().min(1).max(64),
21988
+ message: exports_external.string().min(1).max(256)
21989
+ });
21990
+
21976
21991
  // ../shared/src/community-cli-contract.ts
21977
21992
  var AGENT_EVENT_PROMPT_MAX_LENGTH = 32768;
21978
21993
  var DM_SERVER = ".dm";
@@ -22057,6 +22072,7 @@ function parseSeq(s) {
22057
22072
  return n;
22058
22073
  }
22059
22074
  var HostCommandSchema = exports_external.discriminatedUnion("type", [
22075
+ RuntimeModelDiscoveryCommandSchema,
22060
22076
  exports_external.strictObject({
22061
22077
  type: exports_external.literal("machine:heartbeat"),
22062
22078
  nonce: exports_external.string().min(1).max(128)
@@ -22333,6 +22349,58 @@ var CommunityMessagesReadSchema = exports_external.strictObject({
22333
22349
  page: CommunityPageSchema,
22334
22350
  surfaceReceipt: exports_external.strictObject({ channelId: id, surfaceKind: exports_external.enum(["channel", "forum", "thread", "dm"]) })
22335
22351
  });
22352
+ var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
22353
+ viewerId: id,
22354
+ peer: CommunityResourceProfileSchema.nullable(),
22355
+ channel: CommunityChannelResourceSchema,
22356
+ access: CommunityAccessDecisionSchema.extend({ canRead: exports_external.literal(true) }),
22357
+ readState: CommunityReadStateResourceSchema,
22358
+ readStateRevision: exports_external.number().int().nonnegative(),
22359
+ forumFeed: exports_external.lazy(() => CommunityThreadsReadSchema).optional(),
22360
+ opener: CommunityMessageResourceSchema.optional(),
22361
+ parent: CommunityChannelResourceSchema.optional(),
22362
+ selection: exports_external.strictObject({
22363
+ reason: exports_external.enum(["explicit_anchor", "read_pointer", "tail", "read_pointer_missing"]),
22364
+ anchorMessageId: nullableId
22365
+ })
22366
+ }).superRefine((entry, ctx) => {
22367
+ for (const [path, channelId] of [
22368
+ [["channel", "id"], entry.channel.id],
22369
+ [["access", "channelId"], entry.access.channelId],
22370
+ [["readState", "channelId"], entry.readState.channelId],
22371
+ [["surfaceReceipt", "channelId"], entry.surfaceReceipt.channelId],
22372
+ ...entry.messages.map((message2, index2) => [["messages", index2, "channelId"], message2.channelId])
22373
+ ]) {
22374
+ if (channelId !== entry.channelId)
22375
+ ctx.addIssue({ code: "custom", path: [...path], message: "Conversation entry scope mismatch" });
22376
+ }
22377
+ if (entry.channel.type === "dm" !== (entry.peer !== null) || entry.peer?.id === entry.viewerId)
22378
+ ctx.addIssue({ code: "custom", path: ["peer"], message: "Conversation entry peer mismatch" });
22379
+ if (entry.opener && (entry.channel.type !== "thread" || entry.opener.id !== entry.channel.parentMessageId || entry.opener.channelId !== entry.channel.parentChannelId))
22380
+ ctx.addIssue({ code: "custom", path: ["opener"], message: "Conversation entry opener scope mismatch" });
22381
+ if (entry.parent && (entry.channel.type !== "thread" || entry.parent.id !== entry.channel.parentChannelId || entry.parent.serverId !== entry.channel.serverId || entry.parent.type !== "text" && entry.parent.type !== "forum"))
22382
+ ctx.addIssue({ code: "custom", path: ["parent"], message: "Conversation entry parent scope mismatch" });
22383
+ if (entry.forumFeed && (entry.channel.type !== "forum" || entry.forumFeed.channelId !== entry.channelId || entry.forumFeed.channel.id !== entry.channelId || entry.forumFeed.channel.serverId !== entry.channel.serverId || entry.forumFeed.threads.some((thread) => thread.parentChannelId !== entry.channelId || thread.serverId !== entry.channel.serverId)))
22384
+ ctx.addIssue({ code: "custom", path: ["forumFeed"], message: "Conversation entry forum scope mismatch" });
22385
+ if (entry.forumFeed) {
22386
+ const feed = entry.forumFeed, children = new Set(feed.threads.map((thread) => thread.id)), profiles = new Set(feed.included.profiles.map((profile2) => profile2.id));
22387
+ const openers = new Set(feed.threads.flatMap((thread) => thread.parentMessageId ? [thread.parentMessageId] : []));
22388
+ if (feed.included.messages.some((message2) => message2.channelId !== entry.channelId && !children.has(message2.channelId)) || feed.included.tags.some((row) => !openers.has(row.messageId)) || feed.included.participantCounts.some((row) => !children.has(row.channelId)) || feed.included.members.some((member2) => !children.has(member2.channelId) || member2.relation !== "notify" || !profiles.has(member2.userId)))
22389
+ ctx.addIssue({ code: "custom", path: ["forumFeed", "included"], message: "Conversation entry forum included scope mismatch" });
22390
+ }
22391
+ const surfaceKind = entry.channel.type === "text" ? "channel" : entry.channel.type;
22392
+ if (entry.surfaceReceipt.surfaceKind !== surfaceKind)
22393
+ ctx.addIssue({ code: "custom", path: ["surfaceReceipt", "surfaceKind"], message: "Conversation entry surface mismatch" });
22394
+ if (entry.channel.archived)
22395
+ ctx.addIssue({ code: "custom", path: ["channel", "archived"], message: "Conversation entry is archived" });
22396
+ const anchored = entry.selection.reason === "explicit_anchor" || entry.selection.reason === "read_pointer";
22397
+ if (anchored !== (entry.selection.anchorMessageId !== null))
22398
+ ctx.addIssue({ code: "custom", path: ["selection"], message: "Conversation entry selection mismatch" });
22399
+ if (entry.selection.reason === "read_pointer" && entry.selection.anchorMessageId !== entry.readState.lastReadMessageId)
22400
+ ctx.addIssue({ code: "custom", path: ["selection", "anchorMessageId"], message: "Conversation entry read pointer mismatch" });
22401
+ if (entry.selection.reason === "read_pointer_missing" && entry.readState.lastReadMessageId === null)
22402
+ ctx.addIssue({ code: "custom", path: ["selection", "reason"], message: "Conversation entry missing read pointer" });
22403
+ });
22336
22404
  var CommunityMessagePostedSchema = CommunityMessagesReadSchema.pick({ contractVersion: true, channelId: true }).extend({
22337
22405
  message: CommunityMessageResourceSchema,
22338
22406
  deduped: exports_external.boolean(),
@@ -23349,6 +23417,17 @@ var CommunityMachineRuntimeListSchema = exports_external.array(CommunityMachineR
23349
23417
  }
23350
23418
  return out;
23351
23419
  });
23420
+ var RuntimeModelDiscoveryResultSchema = exports_external.discriminatedUnion("status", [
23421
+ exports_external.strictObject({ status: exports_external.literal("complete"), catalog: RuntimeReasoningCatalogSchema.nullable() }),
23422
+ RuntimeModelDiscoveryErrorSchema
23423
+ ]);
23424
+ var HostRuntimeModelsFrameSchema = RuntimeModelDiscoveryRequestSchema.extend({
23425
+ type: exports_external.literal("runtime_models"),
23426
+ result: exports_external.discriminatedUnion("status", [
23427
+ exports_external.strictObject({ status: exports_external.literal("complete"), runtimeReport: CommunityMachineRuntimeListSchema }),
23428
+ RuntimeModelDiscoveryErrorSchema
23429
+ ])
23430
+ });
23352
23431
  var CommunityRunningAgentListSchema = exports_external.array(exports_external.string()).transform((list) => {
23353
23432
  const seen = new Set;
23354
23433
  const out = [];
@@ -24698,6 +24777,13 @@ var communityBotAuditEventSchema = exports_external.strictObject({
24698
24777
  launchId: nullableString.optional(),
24699
24778
  createdAt: string4
24700
24779
  }).refine((event) => Object.prototype.hasOwnProperty.call(event, "payload"));
24780
+ var communityRuntimeModelsSchema = exports_external.strictObject({
24781
+ type: exports_external.literal("community:runtime.models"),
24782
+ machineId: exports_external.string().min(1),
24783
+ requestId: exports_external.string().min(1).max(128),
24784
+ runtimeId: exports_external.string().min(1).max(64),
24785
+ result: RuntimeModelDiscoveryResultSchema
24786
+ });
24701
24787
  var commonCommunityEventSchemas = [
24702
24788
  communityMessageUpdatedSchema,
24703
24789
  communityMessageEditedSchema,
@@ -24736,6 +24822,7 @@ var commonCommunityEventSchemas = [
24736
24822
  communityMachineCreatedSchema,
24737
24823
  communityMachineStatusSchema,
24738
24824
  communityMachineUpdatedSchema,
24825
+ communityRuntimeModelsSchema,
24739
24826
  communityMachineRemovedSchema,
24740
24827
  communityBotAuditEventSchema
24741
24828
  ];
@@ -24806,6 +24893,7 @@ var WS_EVENTS = {
24806
24893
  MACHINE_CREATED: "community:machine.created",
24807
24894
  MACHINE_STATUS: "community:machine.status",
24808
24895
  MACHINE_UPDATED: "community:machine.updated",
24896
+ RUNTIME_MODELS: "community:runtime.models",
24809
24897
  MACHINE_REMOVED: "community:machine.removed",
24810
24898
  BOT_AUDIT_EVENT: "community:bot.audit_event"
24811
24899
  };
@@ -25137,6 +25225,9 @@ var nativeOauthExchangeSchema = exports_external.object({
25137
25225
  code: nativeOauthHandoffCodeSchema
25138
25226
  }).strict();
25139
25227
  var nativeOauthProofSchema = nativeOauthExchangeSchema.omit({ code: true }).strict();
25228
+ // ../shared/src/utils/community-mentions.ts
25229
+ var MENTION_IDENTIFIER_CHARACTERS = /[\p{L}\p{N}_-]/u.source;
25230
+ var ID_CHAR_RE = new RegExp(MENTION_IDENTIFIER_CHARACTERS, "u");
25140
25231
  // ../shared/src/semver.ts
25141
25232
  var RELEASE_VERSION_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
25142
25233
  function parseReleaseVersion(value) {
@@ -26790,6 +26881,56 @@ function tryParseJsonRecord(line) {
26790
26881
  import { existsSync as existsSync2 } from "node:fs";
26791
26882
  import { homedir as homedir2 } from "node:os";
26792
26883
  import { join as join4 } from "node:path";
26884
+
26885
+ // agent-driver/dist/internal/modelCatalog.js
26886
+ var RUNTIME_MODEL_CATALOG_MAX = 1024;
26887
+ var RUNTIME_MODEL_ID_MAX = 100;
26888
+ function normalizeRuntimeModelId(value) {
26889
+ if (typeof value !== "string")
26890
+ return;
26891
+ const id3 = value.trim();
26892
+ if (!id3 || id3.length > RUNTIME_MODEL_ID_MAX || /\s/.test(id3))
26893
+ return;
26894
+ return id3;
26895
+ }
26896
+ function catalogFromIds(ids) {
26897
+ const seen = new Set;
26898
+ const models = [];
26899
+ for (const rawId of ids) {
26900
+ const id3 = normalizeRuntimeModelId(rawId);
26901
+ if (!id3 || seen.has(id3))
26902
+ continue;
26903
+ if (models.length >= RUNTIME_MODEL_CATALOG_MAX)
26904
+ break;
26905
+ seen.add(id3);
26906
+ models.push({ id: id3, supportedReasoningEfforts: [] });
26907
+ }
26908
+ if (models.length === 0)
26909
+ return;
26910
+ return { updateMode: "unsupported", models };
26911
+ }
26912
+ function parseOpenCodeModelCatalog(output2) {
26913
+ const ids = output2.split(/\r?\n/).flatMap((line) => {
26914
+ const id3 = normalizeRuntimeModelId(line);
26915
+ return id3 && /^[^/]+\/.+$/.test(id3) ? [id3] : [];
26916
+ });
26917
+ return catalogFromIds(ids);
26918
+ }
26919
+ function parsePiModelCatalog(values) {
26920
+ if (!Array.isArray(values))
26921
+ return;
26922
+ const ids = values.flatMap((value) => {
26923
+ if (!value || typeof value !== "object")
26924
+ return [];
26925
+ const model = value;
26926
+ const provider = normalizeRuntimeModelId(model.provider);
26927
+ const id3 = normalizeRuntimeModelId(model.id);
26928
+ return provider && id3 && !provider.includes("/") ? [`${provider}/${id3}`] : [];
26929
+ });
26930
+ return catalogFromIds(ids);
26931
+ }
26932
+
26933
+ // agent-driver/dist/adapters/agy/probe.js
26793
26934
  function agySpawnSpec(command, deps = {}, platform = process.platform) {
26794
26935
  const explicit = command?.trim();
26795
26936
  if (explicit)
@@ -26799,27 +26940,39 @@ function agySpawnSpec(command, deps = {}, platform = process.platform) {
26799
26940
  const selected = resolveCommandOnPath("agy", deps) ?? (existsSync2(installed) ? installed : "agy");
26800
26941
  return resolveSpawnSpec("agy", [], selected, deps, platform);
26801
26942
  }
26802
- async function probeAgy(command) {
26803
- const spec = agySpawnSpec(command);
26804
- const version3 = probeCommandVersion(spec.command);
26805
- if (!version3.ok)
26806
- return { status: "unhealthy", lastError: version3.error };
26807
- const child = spawnAgentProcess(spec.command, ["--help"], { cwd: process.cwd(), env: { ...process.env, CI: "1" }, shell: spec.shell, stdin: "ignore" });
26943
+ function parseAgyModelCatalog(output2) {
26944
+ const models = [];
26945
+ const seen = new Set;
26946
+ for (const line of output2.split(/\r?\n/)) {
26947
+ const match = line.match(/^(\S+)\t+(.+)$/);
26948
+ const id3 = normalizeRuntimeModelId(match?.[1]);
26949
+ const displayName = match?.[2]?.trim();
26950
+ if (!id3 || !displayName || seen.has(id3))
26951
+ continue;
26952
+ if (models.length === RUNTIME_MODEL_CATALOG_MAX)
26953
+ break;
26954
+ seen.add(id3);
26955
+ models.push({ id: id3, displayName: displayName.slice(0, 256), supportedReasoningEfforts: [] });
26956
+ }
26957
+ return models.length ? { updateMode: "unsupported", models } : undefined;
26958
+ }
26959
+ async function readAgyCommand(spec, args, includeStderr) {
26960
+ const child = spawnAgentProcess(spec.command, args, { cwd: process.cwd(), env: { ...process.env, CI: "1", AGY_CLI_DISABLE_AUTO_UPDATE: "true" }, shell: spec.shell, stdin: "ignore" });
26808
26961
  try {
26809
- const help = await new Promise((resolve, reject) => {
26962
+ return await new Promise((resolve, reject) => {
26810
26963
  let output2 = "";
26811
- const timer = setTimeout(() => reject(new Error("timeout")), 3000);
26964
+ const timer = setTimeout(() => reject(new Error("timeout")), includeStderr ? 5000 : 30000);
26812
26965
  const fail = () => {
26813
26966
  clearTimeout(timer);
26814
- reject(new Error("help failed"));
26967
+ reject(new Error("command failed"));
26815
26968
  };
26816
26969
  const collect = (chunk2) => {
26817
26970
  output2 += chunk2.toString();
26818
- if (Buffer.byteLength(output2) > 64 * 1024)
26971
+ if (Buffer.byteLength(output2) > (includeStderr ? 64 * 1024 : 1024 * 1024))
26819
26972
  fail();
26820
26973
  };
26821
26974
  child.stdout?.on("data", collect);
26822
- child.stderr?.on("data", collect);
26975
+ child.stderr?.on("data", includeStderr ? collect : () => {});
26823
26976
  child.on("error", fail);
26824
26977
  child.on("close", (code) => {
26825
26978
  clearTimeout(timer);
@@ -26829,14 +26982,34 @@ async function probeAgy(command) {
26829
26982
  fail();
26830
26983
  });
26831
26984
  });
26832
- return ["--input-format", "--output-format", "stream-json", "--conversation"].every((flag) => help.includes(flag)) ? { status: "healthy", version: version3.version } : { status: "unhealthy", version: version3.version, lastError: "agy_stream_incompatible" };
26833
- } catch {
26834
- return { status: "unhealthy", version: version3.version, lastError: "agy_stream_probe_failed" };
26835
26985
  } finally {
26836
26986
  if (child.pid)
26837
26987
  await killProcessTree(child.pid, { graceMs: 100 });
26838
26988
  }
26839
26989
  }
26990
+ async function probeAgy(command, includeModels = false) {
26991
+ const spec = agySpawnSpec(command);
26992
+ const version3 = probeCommandVersion(spec.command);
26993
+ if (!version3.ok)
26994
+ return { status: "unhealthy", lastError: version3.error };
26995
+ let help;
26996
+ try {
26997
+ help = await readAgyCommand(spec, ["--help"], true);
26998
+ } catch {
26999
+ return { status: "unhealthy", version: version3.version, lastError: "agy_stream_probe_failed" };
27000
+ }
27001
+ if (!["--input-format", "--output-format", "stream-json", "--conversation"].every((flag) => help.includes(flag))) {
27002
+ return { status: "unhealthy", version: version3.version, lastError: "agy_stream_incompatible" };
27003
+ }
27004
+ if (!includeModels || !/\bmodels\b/.test(help))
27005
+ return { status: "healthy", version: version3.version };
27006
+ try {
27007
+ const reasoning = parseAgyModelCatalog(await readAgyCommand(spec, ["models"], false));
27008
+ return reasoning ? { status: "healthy", version: version3.version, reasoning } : { status: "unhealthy", version: version3.version, lastError: "agy_model_catalog_invalid" };
27009
+ } catch {
27010
+ return { status: "unhealthy", version: version3.version, lastError: "agy_model_probe_failed" };
27011
+ }
27012
+ }
26840
27013
 
26841
27014
  // agent-driver/dist/internal/token-usage.js
26842
27015
  function validIdentityPart(value) {
@@ -26930,8 +27103,8 @@ class AgyDriver {
26930
27103
  constructor(launchSpec) {
26931
27104
  this.launchSpec = launchSpec;
26932
27105
  }
26933
- probe(command) {
26934
- return probeAgy(command);
27106
+ probe(command, includeModels = true) {
27107
+ return probeAgy(command, includeModels);
26935
27108
  }
26936
27109
  async openLane(ctx, options) {
26937
27110
  const spec = agySpawnSpec(resolveLaunchFieldsOrDefault(ctx.config.runtimeConfig).command);
@@ -27265,54 +27438,6 @@ async function queryNativeRows(path5, cursor, loadSqlite = async () => {
27265
27438
  }
27266
27439
  }
27267
27440
 
27268
- // agent-driver/dist/internal/modelCatalog.js
27269
- var RUNTIME_MODEL_CATALOG_MAX = 1024;
27270
- var RUNTIME_MODEL_ID_MAX = 100;
27271
- function normalizeRuntimeModelId(value) {
27272
- if (typeof value !== "string")
27273
- return;
27274
- const id3 = value.trim();
27275
- if (!id3 || id3.length > RUNTIME_MODEL_ID_MAX || /\s/.test(id3))
27276
- return;
27277
- return id3;
27278
- }
27279
- function catalogFromIds(ids) {
27280
- const seen = new Set;
27281
- const models = [];
27282
- for (const rawId of ids) {
27283
- const id3 = normalizeRuntimeModelId(rawId);
27284
- if (!id3 || seen.has(id3))
27285
- continue;
27286
- if (models.length >= RUNTIME_MODEL_CATALOG_MAX)
27287
- break;
27288
- seen.add(id3);
27289
- models.push({ id: id3, supportedReasoningEfforts: [] });
27290
- }
27291
- if (models.length === 0)
27292
- return;
27293
- return { updateMode: "unsupported", models };
27294
- }
27295
- function parseOpenCodeModelCatalog(output2) {
27296
- const ids = output2.split(/\r?\n/).flatMap((line) => {
27297
- const id3 = normalizeRuntimeModelId(line);
27298
- return id3 && /^[^/]+\/.+$/.test(id3) ? [id3] : [];
27299
- });
27300
- return catalogFromIds(ids);
27301
- }
27302
- function parsePiModelCatalog(values) {
27303
- if (!Array.isArray(values))
27304
- return;
27305
- const ids = values.flatMap((value) => {
27306
- if (!value || typeof value !== "object")
27307
- return [];
27308
- const model = value;
27309
- const provider = normalizeRuntimeModelId(model.provider);
27310
- const id3 = normalizeRuntimeModelId(model.id);
27311
- return provider && id3 && !provider.includes("/") ? [`${provider}/${id3}`] : [];
27312
- });
27313
- return catalogFromIds(ids);
27314
- }
27315
-
27316
27441
  // agent-driver/dist/adapters/antigravity/catalog.js
27317
27442
  function choices(value) {
27318
27443
  if (!Array.isArray(value))
@@ -28131,23 +28256,25 @@ function antigravitySpawnSpec(command, platform = process.platform) {
28131
28256
  }
28132
28257
  async function probeAntigravity(command, options = {}) {
28133
28258
  const spec = antigravitySpawnSpec(command);
28259
+ const includeModels = options.includeModels !== false;
28134
28260
  const identity = createHash3("sha256").update(JSON.stringify([spec.command, process.env.GEMINI_HOME ?? ""])).digest("hex").slice(0, 16);
28135
- const directory = options.cacheDirectory ?? join6(homedir5(), ".cache", "alook", "antigravity-probe", identity);
28261
+ const directory = options.cacheDirectory ?? (includeModels ? join6(homedir5(), ".cache", "alook", "antigravity-probe", identity) : homedir5());
28136
28262
  const cacheFile = join6(directory, "session");
28137
28263
  let cachedSessionId;
28138
- try {
28139
- mkdirSync3(directory, { recursive: true, mode: 448 });
28264
+ if (includeModels)
28140
28265
  try {
28141
- const value = readFileSync2(cacheFile, "utf8");
28142
- if (/^[A-Za-z0-9_-]{1,100}$/.test(value))
28143
- cachedSessionId = value;
28144
- } catch (error62) {
28145
- if (error62.code !== "ENOENT")
28146
- throw error62;
28266
+ mkdirSync3(directory, { recursive: true, mode: 448 });
28267
+ try {
28268
+ const value = readFileSync2(cacheFile, "utf8");
28269
+ if (/^[A-Za-z0-9_-]{1,100}$/.test(value))
28270
+ cachedSessionId = value;
28271
+ } catch (error62) {
28272
+ if (error62.code !== "ENOENT")
28273
+ throw error62;
28274
+ }
28275
+ } catch {
28276
+ return { status: "unhealthy", lastError: "antigravity_acp_probe_storage_failed" };
28147
28277
  }
28148
- } catch {
28149
- return { status: "unhealthy", lastError: "antigravity_acp_probe_storage_failed" };
28150
- }
28151
28278
  let proc;
28152
28279
  try {
28153
28280
  proc = (options.spawn ?? spawnAgentProcess)(spec.command, spec.args, {
@@ -28272,6 +28399,10 @@ async function probeAntigravity(command, options = {}) {
28272
28399
  return fail("antigravity_acp_incompatible");
28273
28400
  const reportedVersion = asRecord(result.agentInfo)?.version;
28274
28401
  version3 = typeof reportedVersion === "string" ? reportedVersion : undefined;
28402
+ if (!includeModels) {
28403
+ finish({ status: "healthy", ...version3 ? { version: version3 } : {} });
28404
+ continue;
28405
+ }
28275
28406
  requestSession(cachedSessionId);
28276
28407
  }
28277
28408
  });
@@ -28293,8 +28424,8 @@ class AntigravityDriver {
28293
28424
  wakeStart: "immediate",
28294
28425
  terminalOwnership: "transport_request"
28295
28426
  };
28296
- probe(command) {
28297
- return probeAntigravity(command);
28427
+ probe(command, includeModels = true) {
28428
+ return includeModels ? probeAntigravity(command) : probeAntigravity(command, { includeModels: false });
28298
28429
  }
28299
28430
  async openLane(ctx, options) {
28300
28431
  return new AntigravityAcpLane(this, ctx, { onRawStdoutLine: options?.onRawStdoutLine });
@@ -29020,13 +29151,13 @@ class ClaudeDriver {
29020
29151
  this.eventNormalizer.beginTurn();
29021
29152
  return receipt;
29022
29153
  }
29023
- probe(command) {
29154
+ probe(command, includeModels = true) {
29024
29155
  const explicit = command?.trim();
29025
29156
  const base = explicit ? (() => {
29026
29157
  const result = probeCommandVersion(explicit);
29027
29158
  return result.ok ? { status: "healthy", version: result.version } : { status: "unhealthy", lastError: result.error };
29028
29159
  })() : probeClaude();
29029
- return base.status === "healthy" ? { ...base, reasoning: CLAUDE_MODEL_CATALOG } : base;
29160
+ return base.status === "healthy" && includeModels ? { ...base, reasoning: CLAUDE_MODEL_CATALOG } : base;
29030
29161
  }
29031
29162
  async openLane(ctx, options) {
29032
29163
  return createProcessLane(this, ctx, { onRawStdoutLine: options?.onRawStdoutLine });
@@ -29821,10 +29952,12 @@ class CodexDriver {
29821
29952
  get codexHome() {
29822
29953
  return this.codexHomeRoot;
29823
29954
  }
29824
- async probe(command) {
29955
+ async probe(command, includeModels = true) {
29825
29956
  const result = await probeCliRuntime("codex", {}, command);
29826
29957
  if (result.status !== "healthy")
29827
29958
  return result;
29959
+ if (!includeModels)
29960
+ return result;
29828
29961
  return {
29829
29962
  ...result,
29830
29963
  reasoning: await this.probeReasoningCatalog(command)
@@ -31189,10 +31322,12 @@ class CursorDriver {
31189
31322
  constructor(catalogProbe = probeCursorAcpCatalog) {
31190
31323
  this.catalogProbe = catalogProbe;
31191
31324
  }
31192
- async probe(command) {
31325
+ async probe(command, includeModels = true) {
31193
31326
  const result = probeCliRuntime("cursor-agent", {}, command);
31194
31327
  if (result.status !== "healthy")
31195
31328
  return result;
31329
+ if (!includeModels)
31330
+ return result;
31196
31331
  let reasoning;
31197
31332
  try {
31198
31333
  reasoning = await this.catalogProbe(command);
@@ -31393,6 +31528,8 @@ async function probeGrokAcpCatalog(command, options = {}) {
31393
31528
  }
31394
31529
  return finish({ status: "unhealthy", lastError: "grok_acp_cached_auth_unsupported" });
31395
31530
  }
31531
+ if (options.includeModels === false)
31532
+ return finish({ status: "compatible" });
31396
31533
  catalog = catalogFromInitialize(result) ?? catalog;
31397
31534
  expectedId = 2;
31398
31535
  write("authenticate", { methodId: AUTH_METHOD_ID4 }, expectedId);
@@ -32402,13 +32539,13 @@ class GrokDriver {
32402
32539
  this.catalogProbe = catalogProbe;
32403
32540
  this.spawnProcess = spawnProcess;
32404
32541
  }
32405
- async probe(command) {
32542
+ async probe(command, includeModels = true) {
32406
32543
  const result = probeCliRuntime("grok", {}, command);
32407
32544
  if (result.status !== "healthy")
32408
32545
  return result;
32409
32546
  let acpProbe;
32410
32547
  try {
32411
- acpProbe = await this.catalogProbe(command);
32548
+ acpProbe = includeModels ? await this.catalogProbe(command) : await this.catalogProbe(command, { includeModels: false });
32412
32549
  } catch {
32413
32550
  acpProbe = { status: "unhealthy", lastError: "grok_acp_probe_failed" };
32414
32551
  }
@@ -34206,7 +34343,7 @@ class OpenCodeDriver {
34206
34343
  throw new Error("Installed OpenCode CLI could not report its version");
34207
34344
  return discoverOpenCodeRecentContext(request, { compatibility: resolveOpenCodeCompatibility(result.version) });
34208
34345
  }
34209
- probe(command) {
34346
+ probe(command, includeModels = true) {
34210
34347
  const result = this.versionProbe("opencode", {}, command);
34211
34348
  if (result.status !== "healthy")
34212
34349
  return result;
@@ -34216,6 +34353,8 @@ class OpenCodeDriver {
34216
34353
  } catch {
34217
34354
  return { ...result, status: "unhealthy", lastError: "unsupported_opencode_cli_version" };
34218
34355
  }
34356
+ if (!includeModels)
34357
+ return result;
34219
34358
  const spec = resolveSpawnSpec("opencode", [...compatibility.modelArgs], command);
34220
34359
  const output2 = this.outputProbe(spec.command, spec.args);
34221
34360
  return {
@@ -34696,16 +34835,18 @@ class PiDriver {
34696
34835
  this.loadSdk = loadSdk;
34697
34836
  this.readVersion = readVersion;
34698
34837
  }
34699
- async probe() {
34838
+ async probe(_command, includeModels = true) {
34700
34839
  const version3 = this.readVersion();
34701
34840
  if (!version3) {
34702
34841
  return { status: "unhealthy", lastError: "sdk_not_installed" };
34703
34842
  }
34843
+ if (!includeModels)
34844
+ return { status: "healthy", version: version3 };
34704
34845
  let timer;
34705
34846
  try {
34706
34847
  const reasoning = await Promise.race([
34707
34848
  this.loadSdk().then(async (sdk) => {
34708
- const modelRuntime = await sdk.ModelRuntime.create();
34849
+ const modelRuntime = sdk.ModelRegistry && sdk.AuthStorage ? sdk.ModelRegistry.create(sdk.AuthStorage.create()) : await sdk.ModelRuntime.create();
34709
34850
  return parsePiModelCatalog(await modelRuntime.getAvailable());
34710
34851
  }),
34711
34852
  new Promise((resolve4) => {
@@ -36567,7 +36708,7 @@ function createAgentDriverSdkWithRegistry(options) {
36567
36708
  const adapter = registration.createAdapter();
36568
36709
  assertAdapterCompatibility(String(registration.id), registration.capabilities, adapter);
36569
36710
  const command = capabilities2.commandOverride ? input2.command : undefined;
36570
- const result = await adapter.probe(command);
36711
+ const result = input2.includeModels === false ? await adapter.probe(command, false) : await adapter.probe(command);
36571
36712
  if (result.status === "healthy") {
36572
36713
  return {
36573
36714
  status: "healthy",
@@ -36694,7 +36835,8 @@ function getDriver(runtimeId) {
36694
36835
  return {
36695
36836
  id: id3,
36696
36837
  capabilities: capabilitiesFor(id3),
36697
- probe: () => createAgentDriverSdk2().probe({ backend: id3 })
36838
+ probe: () => createAgentDriverSdk2().probe({ backend: id3, includeModels: false }),
36839
+ discoverModels: () => createAgentDriverSdk2().probe({ backend: id3 })
36698
36840
  };
36699
36841
  }
36700
36842
  function listRuntimeIds() {
@@ -37527,6 +37669,9 @@ class WsControlChannel {
37527
37669
  }
37528
37670
  this.sendFrame(frame);
37529
37671
  }
37672
+ reportRuntimeModels(frame) {
37673
+ this.sendFrame(frame);
37674
+ }
37530
37675
  restorePendingBotAuditEvent(frame) {
37531
37676
  if (!frame.eventId || !frame.occurredAt)
37532
37677
  return;
@@ -41554,6 +41699,7 @@ class AgentRouter {
41554
41699
  pendingAgentEvents = new Map;
41555
41700
  nextWakeAdmissionOrdinal = 1;
41556
41701
  runtimes = new Map;
41702
+ modelDiscoveries = new Map;
41557
41703
  pendingResend = false;
41558
41704
  scheduleResend;
41559
41705
  log;
@@ -41585,7 +41731,7 @@ class AgentRouter {
41585
41731
  const timeZone = typeof this.opts.timeZone === "function" ? this.opts.timeZone() : this.opts.timeZone;
41586
41732
  return {
41587
41733
  runtimeReport: [...this.runtimes.values()],
41588
- capabilities: [CONTROL_HEARTBEAT_CAPABILITY],
41734
+ capabilities: [CONTROL_HEARTBEAT_CAPABILITY, ...this.opts.channel.reportRuntimeModels ? [RUNTIME_MODEL_DISCOVERY_CAPABILITY] : []],
41589
41735
  runningAgents: [...this.running],
41590
41736
  hostname: this.opts.hostname,
41591
41737
  platform: this.opts.platform,
@@ -41728,8 +41874,54 @@ class AgentRouter {
41728
41874
  });
41729
41875
  return pending;
41730
41876
  }
41877
+ discoverRuntimeModels(runtimeId) {
41878
+ const active = this.modelDiscoveries.get(runtimeId);
41879
+ if (active)
41880
+ return active;
41881
+ const pending = this.runModelDiscovery(runtimeId).finally(() => this.modelDiscoveries.delete(runtimeId));
41882
+ this.modelDiscoveries.set(runtimeId, pending);
41883
+ return pending;
41884
+ }
41885
+ async runModelDiscovery(runtimeId) {
41886
+ let deadline;
41887
+ const timeout = new Promise((resolve5) => {
41888
+ deadline = setTimeout(() => resolve5(null), 40000);
41889
+ });
41890
+ const probe = await Promise.race([
41891
+ Promise.resolve().then(() => this.opts.discoverModels?.(runtimeId) ?? getDriver(runtimeId).discoverModels()),
41892
+ timeout
41893
+ ]).finally(() => clearTimeout(deadline));
41894
+ if (probe?.status === "healthy") {
41895
+ this.runtimes.set(runtimeId, { ...this.runtimes.get(runtimeId), reasoning: probe.reasoning });
41896
+ }
41897
+ return probe;
41898
+ }
41731
41899
  async onCommand(cmd) {
41732
41900
  switch (cmd.type) {
41901
+ case "runtime:discover_models": {
41902
+ const reply = this.opts.channel.reportRuntimeModels;
41903
+ if (!reply)
41904
+ return;
41905
+ const identity = { type: "runtime_models", requestId: cmd.requestId, runtimeId: cmd.runtimeId };
41906
+ try {
41907
+ const current = this.runtimes.get(cmd.runtimeId);
41908
+ if (!current)
41909
+ throw new UnknownRuntimeError(cmd.runtimeId, [...this.runtimes.keys()]);
41910
+ const probe = await this.discoverRuntimeModels(cmd.runtimeId);
41911
+ if (!probe) {
41912
+ reply.call(this.opts.channel, { ...identity, result: { status: "error", code: "model_discovery_timeout", message: "Model discovery timed out; retry the request" } });
41913
+ return;
41914
+ }
41915
+ if (probe.status !== "healthy") {
41916
+ reply.call(this.opts.channel, { ...identity, result: { status: "error", code: probe.error.code, message: probe.error.message } });
41917
+ return;
41918
+ }
41919
+ reply.call(this.opts.channel, { ...identity, result: { status: "complete", runtimeReport: [...this.runtimes.values()] } });
41920
+ } catch {
41921
+ reply.call(this.opts.channel, { ...identity, result: { status: "error", code: "model_discovery_failed", message: "Could not discover models for this runtime" } });
41922
+ }
41923
+ return;
41924
+ }
41733
41925
  case "agent:wake":
41734
41926
  this.log.info("agent:wake received", {
41735
41927
  agentId: cmd.agentId,
package/dist/index.js CHANGED
@@ -1291,6 +1291,56 @@ function tryParseJsonRecord(line) {
1291
1291
  import { existsSync as existsSync2 } from "node:fs";
1292
1292
  import { homedir as homedir2 } from "node:os";
1293
1293
  import { join as join4 } from "node:path";
1294
+
1295
+ // agent-driver/dist/internal/modelCatalog.js
1296
+ var RUNTIME_MODEL_CATALOG_MAX = 1024;
1297
+ var RUNTIME_MODEL_ID_MAX = 100;
1298
+ function normalizeRuntimeModelId(value) {
1299
+ if (typeof value !== "string")
1300
+ return;
1301
+ const id = value.trim();
1302
+ if (!id || id.length > RUNTIME_MODEL_ID_MAX || /\s/.test(id))
1303
+ return;
1304
+ return id;
1305
+ }
1306
+ function catalogFromIds(ids) {
1307
+ const seen = new Set;
1308
+ const models = [];
1309
+ for (const rawId of ids) {
1310
+ const id = normalizeRuntimeModelId(rawId);
1311
+ if (!id || seen.has(id))
1312
+ continue;
1313
+ if (models.length >= RUNTIME_MODEL_CATALOG_MAX)
1314
+ break;
1315
+ seen.add(id);
1316
+ models.push({ id, supportedReasoningEfforts: [] });
1317
+ }
1318
+ if (models.length === 0)
1319
+ return;
1320
+ return { updateMode: "unsupported", models };
1321
+ }
1322
+ function parseOpenCodeModelCatalog(output) {
1323
+ const ids = output.split(/\r?\n/).flatMap((line) => {
1324
+ const id = normalizeRuntimeModelId(line);
1325
+ return id && /^[^/]+\/.+$/.test(id) ? [id] : [];
1326
+ });
1327
+ return catalogFromIds(ids);
1328
+ }
1329
+ function parsePiModelCatalog(values) {
1330
+ if (!Array.isArray(values))
1331
+ return;
1332
+ const ids = values.flatMap((value) => {
1333
+ if (!value || typeof value !== "object")
1334
+ return [];
1335
+ const model = value;
1336
+ const provider = normalizeRuntimeModelId(model.provider);
1337
+ const id = normalizeRuntimeModelId(model.id);
1338
+ return provider && id && !provider.includes("/") ? [`${provider}/${id}`] : [];
1339
+ });
1340
+ return catalogFromIds(ids);
1341
+ }
1342
+
1343
+ // agent-driver/dist/adapters/agy/probe.js
1294
1344
  function agySpawnSpec(command, deps = {}, platform = process.platform) {
1295
1345
  const explicit = command?.trim();
1296
1346
  if (explicit)
@@ -1300,27 +1350,39 @@ function agySpawnSpec(command, deps = {}, platform = process.platform) {
1300
1350
  const selected = resolveCommandOnPath("agy", deps) ?? (existsSync2(installed) ? installed : "agy");
1301
1351
  return resolveSpawnSpec("agy", [], selected, deps, platform);
1302
1352
  }
1303
- async function probeAgy(command) {
1304
- const spec = agySpawnSpec(command);
1305
- const version = probeCommandVersion(spec.command);
1306
- if (!version.ok)
1307
- return { status: "unhealthy", lastError: version.error };
1308
- const child = spawnAgentProcess(spec.command, ["--help"], { cwd: process.cwd(), env: { ...process.env, CI: "1" }, shell: spec.shell, stdin: "ignore" });
1353
+ function parseAgyModelCatalog(output) {
1354
+ const models = [];
1355
+ const seen = new Set;
1356
+ for (const line of output.split(/\r?\n/)) {
1357
+ const match = line.match(/^(\S+)\t+(.+)$/);
1358
+ const id = normalizeRuntimeModelId(match?.[1]);
1359
+ const displayName = match?.[2]?.trim();
1360
+ if (!id || !displayName || seen.has(id))
1361
+ continue;
1362
+ if (models.length === RUNTIME_MODEL_CATALOG_MAX)
1363
+ break;
1364
+ seen.add(id);
1365
+ models.push({ id, displayName: displayName.slice(0, 256), supportedReasoningEfforts: [] });
1366
+ }
1367
+ return models.length ? { updateMode: "unsupported", models } : undefined;
1368
+ }
1369
+ async function readAgyCommand(spec, args, includeStderr) {
1370
+ const child = spawnAgentProcess(spec.command, args, { cwd: process.cwd(), env: { ...process.env, CI: "1", AGY_CLI_DISABLE_AUTO_UPDATE: "true" }, shell: spec.shell, stdin: "ignore" });
1309
1371
  try {
1310
- const help = await new Promise((resolve, reject) => {
1372
+ return await new Promise((resolve, reject) => {
1311
1373
  let output = "";
1312
- const timer = setTimeout(() => reject(new Error("timeout")), 3000);
1374
+ const timer = setTimeout(() => reject(new Error("timeout")), includeStderr ? 5000 : 30000);
1313
1375
  const fail = () => {
1314
1376
  clearTimeout(timer);
1315
- reject(new Error("help failed"));
1377
+ reject(new Error("command failed"));
1316
1378
  };
1317
1379
  const collect = (chunk) => {
1318
1380
  output += chunk.toString();
1319
- if (Buffer.byteLength(output) > 64 * 1024)
1381
+ if (Buffer.byteLength(output) > (includeStderr ? 64 * 1024 : 1024 * 1024))
1320
1382
  fail();
1321
1383
  };
1322
1384
  child.stdout?.on("data", collect);
1323
- child.stderr?.on("data", collect);
1385
+ child.stderr?.on("data", includeStderr ? collect : () => {});
1324
1386
  child.on("error", fail);
1325
1387
  child.on("close", (code) => {
1326
1388
  clearTimeout(timer);
@@ -1330,14 +1392,34 @@ async function probeAgy(command) {
1330
1392
  fail();
1331
1393
  });
1332
1394
  });
1333
- return ["--input-format", "--output-format", "stream-json", "--conversation"].every((flag) => help.includes(flag)) ? { status: "healthy", version: version.version } : { status: "unhealthy", version: version.version, lastError: "agy_stream_incompatible" };
1334
- } catch {
1335
- return { status: "unhealthy", version: version.version, lastError: "agy_stream_probe_failed" };
1336
1395
  } finally {
1337
1396
  if (child.pid)
1338
1397
  await killProcessTree(child.pid, { graceMs: 100 });
1339
1398
  }
1340
1399
  }
1400
+ async function probeAgy(command, includeModels = false) {
1401
+ const spec = agySpawnSpec(command);
1402
+ const version = probeCommandVersion(spec.command);
1403
+ if (!version.ok)
1404
+ return { status: "unhealthy", lastError: version.error };
1405
+ let help;
1406
+ try {
1407
+ help = await readAgyCommand(spec, ["--help"], true);
1408
+ } catch {
1409
+ return { status: "unhealthy", version: version.version, lastError: "agy_stream_probe_failed" };
1410
+ }
1411
+ if (!["--input-format", "--output-format", "stream-json", "--conversation"].every((flag) => help.includes(flag))) {
1412
+ return { status: "unhealthy", version: version.version, lastError: "agy_stream_incompatible" };
1413
+ }
1414
+ if (!includeModels || !/\bmodels\b/.test(help))
1415
+ return { status: "healthy", version: version.version };
1416
+ try {
1417
+ const reasoning = parseAgyModelCatalog(await readAgyCommand(spec, ["models"], false));
1418
+ return reasoning ? { status: "healthy", version: version.version, reasoning } : { status: "unhealthy", version: version.version, lastError: "agy_model_catalog_invalid" };
1419
+ } catch {
1420
+ return { status: "unhealthy", version: version.version, lastError: "agy_model_probe_failed" };
1421
+ }
1422
+ }
1341
1423
 
1342
1424
  // agent-driver/dist/internal/token-usage.js
1343
1425
  function validIdentityPart(value) {
@@ -1431,8 +1513,8 @@ class AgyDriver {
1431
1513
  constructor(launchSpec) {
1432
1514
  this.launchSpec = launchSpec;
1433
1515
  }
1434
- probe(command) {
1435
- return probeAgy(command);
1516
+ probe(command, includeModels = true) {
1517
+ return probeAgy(command, includeModels);
1436
1518
  }
1437
1519
  async openLane(ctx, options) {
1438
1520
  const spec = agySpawnSpec(resolveLaunchFieldsOrDefault(ctx.config.runtimeConfig).command);
@@ -1766,54 +1848,6 @@ async function queryNativeRows(path4, cursor, loadSqlite = async () => {
1766
1848
  }
1767
1849
  }
1768
1850
 
1769
- // agent-driver/dist/internal/modelCatalog.js
1770
- var RUNTIME_MODEL_CATALOG_MAX = 1024;
1771
- var RUNTIME_MODEL_ID_MAX = 100;
1772
- function normalizeRuntimeModelId(value) {
1773
- if (typeof value !== "string")
1774
- return;
1775
- const id = value.trim();
1776
- if (!id || id.length > RUNTIME_MODEL_ID_MAX || /\s/.test(id))
1777
- return;
1778
- return id;
1779
- }
1780
- function catalogFromIds(ids) {
1781
- const seen = new Set;
1782
- const models = [];
1783
- for (const rawId of ids) {
1784
- const id = normalizeRuntimeModelId(rawId);
1785
- if (!id || seen.has(id))
1786
- continue;
1787
- if (models.length >= RUNTIME_MODEL_CATALOG_MAX)
1788
- break;
1789
- seen.add(id);
1790
- models.push({ id, supportedReasoningEfforts: [] });
1791
- }
1792
- if (models.length === 0)
1793
- return;
1794
- return { updateMode: "unsupported", models };
1795
- }
1796
- function parseOpenCodeModelCatalog(output) {
1797
- const ids = output.split(/\r?\n/).flatMap((line) => {
1798
- const id = normalizeRuntimeModelId(line);
1799
- return id && /^[^/]+\/.+$/.test(id) ? [id] : [];
1800
- });
1801
- return catalogFromIds(ids);
1802
- }
1803
- function parsePiModelCatalog(values) {
1804
- if (!Array.isArray(values))
1805
- return;
1806
- const ids = values.flatMap((value) => {
1807
- if (!value || typeof value !== "object")
1808
- return [];
1809
- const model = value;
1810
- const provider = normalizeRuntimeModelId(model.provider);
1811
- const id = normalizeRuntimeModelId(model.id);
1812
- return provider && id && !provider.includes("/") ? [`${provider}/${id}`] : [];
1813
- });
1814
- return catalogFromIds(ids);
1815
- }
1816
-
1817
1851
  // agent-driver/dist/adapters/antigravity/catalog.js
1818
1852
  function choices(value) {
1819
1853
  if (!Array.isArray(value))
@@ -2632,23 +2666,25 @@ function antigravitySpawnSpec(command, platform = process.platform) {
2632
2666
  }
2633
2667
  async function probeAntigravity(command, options = {}) {
2634
2668
  const spec = antigravitySpawnSpec(command);
2669
+ const includeModels = options.includeModels !== false;
2635
2670
  const identity = createHash3("sha256").update(JSON.stringify([spec.command, process.env.GEMINI_HOME ?? ""])).digest("hex").slice(0, 16);
2636
- const directory = options.cacheDirectory ?? join6(homedir5(), ".cache", "alook", "antigravity-probe", identity);
2671
+ const directory = options.cacheDirectory ?? (includeModels ? join6(homedir5(), ".cache", "alook", "antigravity-probe", identity) : homedir5());
2637
2672
  const cacheFile = join6(directory, "session");
2638
2673
  let cachedSessionId;
2639
- try {
2640
- mkdirSync2(directory, { recursive: true, mode: 448 });
2674
+ if (includeModels)
2641
2675
  try {
2642
- const value = readFileSync(cacheFile, "utf8");
2643
- if (/^[A-Za-z0-9_-]{1,100}$/.test(value))
2644
- cachedSessionId = value;
2645
- } catch (error) {
2646
- if (error.code !== "ENOENT")
2647
- throw error;
2676
+ mkdirSync2(directory, { recursive: true, mode: 448 });
2677
+ try {
2678
+ const value = readFileSync(cacheFile, "utf8");
2679
+ if (/^[A-Za-z0-9_-]{1,100}$/.test(value))
2680
+ cachedSessionId = value;
2681
+ } catch (error) {
2682
+ if (error.code !== "ENOENT")
2683
+ throw error;
2684
+ }
2685
+ } catch {
2686
+ return { status: "unhealthy", lastError: "antigravity_acp_probe_storage_failed" };
2648
2687
  }
2649
- } catch {
2650
- return { status: "unhealthy", lastError: "antigravity_acp_probe_storage_failed" };
2651
- }
2652
2688
  let proc;
2653
2689
  try {
2654
2690
  proc = (options.spawn ?? spawnAgentProcess)(spec.command, spec.args, {
@@ -2773,6 +2809,10 @@ async function probeAntigravity(command, options = {}) {
2773
2809
  return fail("antigravity_acp_incompatible");
2774
2810
  const reportedVersion = asRecord(result.agentInfo)?.version;
2775
2811
  version = typeof reportedVersion === "string" ? reportedVersion : undefined;
2812
+ if (!includeModels) {
2813
+ finish({ status: "healthy", ...version ? { version } : {} });
2814
+ continue;
2815
+ }
2776
2816
  requestSession(cachedSessionId);
2777
2817
  }
2778
2818
  });
@@ -2794,8 +2834,8 @@ class AntigravityDriver {
2794
2834
  wakeStart: "immediate",
2795
2835
  terminalOwnership: "transport_request"
2796
2836
  };
2797
- probe(command) {
2798
- return probeAntigravity(command);
2837
+ probe(command, includeModels = true) {
2838
+ return includeModels ? probeAntigravity(command) : probeAntigravity(command, { includeModels: false });
2799
2839
  }
2800
2840
  async openLane(ctx, options) {
2801
2841
  return new AntigravityAcpLane(this, ctx, { onRawStdoutLine: options?.onRawStdoutLine });
@@ -3521,13 +3561,13 @@ class ClaudeDriver {
3521
3561
  this.eventNormalizer.beginTurn();
3522
3562
  return receipt;
3523
3563
  }
3524
- probe(command) {
3564
+ probe(command, includeModels = true) {
3525
3565
  const explicit = command?.trim();
3526
3566
  const base = explicit ? (() => {
3527
3567
  const result = probeCommandVersion(explicit);
3528
3568
  return result.ok ? { status: "healthy", version: result.version } : { status: "unhealthy", lastError: result.error };
3529
3569
  })() : probeClaude();
3530
- return base.status === "healthy" ? { ...base, reasoning: CLAUDE_MODEL_CATALOG } : base;
3570
+ return base.status === "healthy" && includeModels ? { ...base, reasoning: CLAUDE_MODEL_CATALOG } : base;
3531
3571
  }
3532
3572
  async openLane(ctx, options) {
3533
3573
  return createProcessLane(this, ctx, { onRawStdoutLine: options?.onRawStdoutLine });
@@ -4322,10 +4362,12 @@ class CodexDriver {
4322
4362
  get codexHome() {
4323
4363
  return this.codexHomeRoot;
4324
4364
  }
4325
- async probe(command) {
4365
+ async probe(command, includeModels = true) {
4326
4366
  const result = await probeCliRuntime("codex", {}, command);
4327
4367
  if (result.status !== "healthy")
4328
4368
  return result;
4369
+ if (!includeModels)
4370
+ return result;
4329
4371
  return {
4330
4372
  ...result,
4331
4373
  reasoning: await this.probeReasoningCatalog(command)
@@ -5690,10 +5732,12 @@ class CursorDriver {
5690
5732
  constructor(catalogProbe = probeCursorAcpCatalog) {
5691
5733
  this.catalogProbe = catalogProbe;
5692
5734
  }
5693
- async probe(command) {
5735
+ async probe(command, includeModels = true) {
5694
5736
  const result = probeCliRuntime("cursor-agent", {}, command);
5695
5737
  if (result.status !== "healthy")
5696
5738
  return result;
5739
+ if (!includeModels)
5740
+ return result;
5697
5741
  let reasoning;
5698
5742
  try {
5699
5743
  reasoning = await this.catalogProbe(command);
@@ -5894,6 +5938,8 @@ async function probeGrokAcpCatalog(command, options = {}) {
5894
5938
  }
5895
5939
  return finish({ status: "unhealthy", lastError: "grok_acp_cached_auth_unsupported" });
5896
5940
  }
5941
+ if (options.includeModels === false)
5942
+ return finish({ status: "compatible" });
5897
5943
  catalog = catalogFromInitialize(result) ?? catalog;
5898
5944
  expectedId = 2;
5899
5945
  write("authenticate", { methodId: AUTH_METHOD_ID4 }, expectedId);
@@ -6903,13 +6949,13 @@ class GrokDriver {
6903
6949
  this.catalogProbe = catalogProbe;
6904
6950
  this.spawnProcess = spawnProcess;
6905
6951
  }
6906
- async probe(command) {
6952
+ async probe(command, includeModels = true) {
6907
6953
  const result = probeCliRuntime("grok", {}, command);
6908
6954
  if (result.status !== "healthy")
6909
6955
  return result;
6910
6956
  let acpProbe;
6911
6957
  try {
6912
- acpProbe = await this.catalogProbe(command);
6958
+ acpProbe = includeModels ? await this.catalogProbe(command) : await this.catalogProbe(command, { includeModels: false });
6913
6959
  } catch {
6914
6960
  acpProbe = { status: "unhealthy", lastError: "grok_acp_probe_failed" };
6915
6961
  }
@@ -8707,7 +8753,7 @@ class OpenCodeDriver {
8707
8753
  throw new Error("Installed OpenCode CLI could not report its version");
8708
8754
  return discoverOpenCodeRecentContext(request, { compatibility: resolveOpenCodeCompatibility(result.version) });
8709
8755
  }
8710
- probe(command) {
8756
+ probe(command, includeModels = true) {
8711
8757
  const result = this.versionProbe("opencode", {}, command);
8712
8758
  if (result.status !== "healthy")
8713
8759
  return result;
@@ -8717,6 +8763,8 @@ class OpenCodeDriver {
8717
8763
  } catch {
8718
8764
  return { ...result, status: "unhealthy", lastError: "unsupported_opencode_cli_version" };
8719
8765
  }
8766
+ if (!includeModels)
8767
+ return result;
8720
8768
  const spec = resolveSpawnSpec("opencode", [...compatibility.modelArgs], command);
8721
8769
  const output = this.outputProbe(spec.command, spec.args);
8722
8770
  return {
@@ -9197,16 +9245,18 @@ class PiDriver {
9197
9245
  this.loadSdk = loadSdk;
9198
9246
  this.readVersion = readVersion;
9199
9247
  }
9200
- async probe() {
9248
+ async probe(_command, includeModels = true) {
9201
9249
  const version = this.readVersion();
9202
9250
  if (!version) {
9203
9251
  return { status: "unhealthy", lastError: "sdk_not_installed" };
9204
9252
  }
9253
+ if (!includeModels)
9254
+ return { status: "healthy", version };
9205
9255
  let timer;
9206
9256
  try {
9207
9257
  const reasoning = await Promise.race([
9208
9258
  this.loadSdk().then(async (sdk) => {
9209
- const modelRuntime = await sdk.ModelRuntime.create();
9259
+ const modelRuntime = sdk.ModelRegistry && sdk.AuthStorage ? sdk.ModelRegistry.create(sdk.AuthStorage.create()) : await sdk.ModelRuntime.create();
9210
9260
  return parsePiModelCatalog(await modelRuntime.getAvailable());
9211
9261
  }),
9212
9262
  new Promise((resolve4) => {
@@ -11068,7 +11118,7 @@ function createAgentDriverSdkWithRegistry(options) {
11068
11118
  const adapter = registration.createAdapter();
11069
11119
  assertAdapterCompatibility(String(registration.id), registration.capabilities, adapter);
11070
11120
  const command = capabilities2.commandOverride ? input.command : undefined;
11071
- const result = await adapter.probe(command);
11121
+ const result = input.includeModels === false ? await adapter.probe(command, false) : await adapter.probe(command);
11072
11122
  if (result.status === "healthy") {
11073
11123
  return {
11074
11124
  status: "healthy",
@@ -11195,7 +11245,8 @@ function getDriver(runtimeId) {
11195
11245
  return {
11196
11246
  id,
11197
11247
  capabilities: capabilitiesFor(id),
11198
- probe: () => createAgentDriverSdk2().probe({ backend: id })
11248
+ probe: () => createAgentDriverSdk2().probe({ backend: id, includeModels: false }),
11249
+ discoverModels: () => createAgentDriverSdk2().probe({ backend: id })
11199
11250
  };
11200
11251
  }
11201
11252
  function listRuntimeIds() {
@@ -35034,6 +35085,58 @@ var CommunityMessagesReadSchema = exports_external.strictObject({
35034
35085
  page: CommunityPageSchema,
35035
35086
  surfaceReceipt: exports_external.strictObject({ channelId: id, surfaceKind: exports_external.enum(["channel", "forum", "thread", "dm"]) })
35036
35087
  });
35088
+ var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
35089
+ viewerId: id,
35090
+ peer: CommunityResourceProfileSchema.nullable(),
35091
+ channel: CommunityChannelResourceSchema,
35092
+ access: CommunityAccessDecisionSchema.extend({ canRead: exports_external.literal(true) }),
35093
+ readState: CommunityReadStateResourceSchema,
35094
+ readStateRevision: exports_external.number().int().nonnegative(),
35095
+ forumFeed: exports_external.lazy(() => CommunityThreadsReadSchema).optional(),
35096
+ opener: CommunityMessageResourceSchema.optional(),
35097
+ parent: CommunityChannelResourceSchema.optional(),
35098
+ selection: exports_external.strictObject({
35099
+ reason: exports_external.enum(["explicit_anchor", "read_pointer", "tail", "read_pointer_missing"]),
35100
+ anchorMessageId: nullableId
35101
+ })
35102
+ }).superRefine((entry, ctx) => {
35103
+ for (const [path13, channelId] of [
35104
+ [["channel", "id"], entry.channel.id],
35105
+ [["access", "channelId"], entry.access.channelId],
35106
+ [["readState", "channelId"], entry.readState.channelId],
35107
+ [["surfaceReceipt", "channelId"], entry.surfaceReceipt.channelId],
35108
+ ...entry.messages.map((message2, index2) => [["messages", index2, "channelId"], message2.channelId])
35109
+ ]) {
35110
+ if (channelId !== entry.channelId)
35111
+ ctx.addIssue({ code: "custom", path: [...path13], message: "Conversation entry scope mismatch" });
35112
+ }
35113
+ if (entry.channel.type === "dm" !== (entry.peer !== null) || entry.peer?.id === entry.viewerId)
35114
+ ctx.addIssue({ code: "custom", path: ["peer"], message: "Conversation entry peer mismatch" });
35115
+ if (entry.opener && (entry.channel.type !== "thread" || entry.opener.id !== entry.channel.parentMessageId || entry.opener.channelId !== entry.channel.parentChannelId))
35116
+ ctx.addIssue({ code: "custom", path: ["opener"], message: "Conversation entry opener scope mismatch" });
35117
+ if (entry.parent && (entry.channel.type !== "thread" || entry.parent.id !== entry.channel.parentChannelId || entry.parent.serverId !== entry.channel.serverId || entry.parent.type !== "text" && entry.parent.type !== "forum"))
35118
+ ctx.addIssue({ code: "custom", path: ["parent"], message: "Conversation entry parent scope mismatch" });
35119
+ if (entry.forumFeed && (entry.channel.type !== "forum" || entry.forumFeed.channelId !== entry.channelId || entry.forumFeed.channel.id !== entry.channelId || entry.forumFeed.channel.serverId !== entry.channel.serverId || entry.forumFeed.threads.some((thread) => thread.parentChannelId !== entry.channelId || thread.serverId !== entry.channel.serverId)))
35120
+ ctx.addIssue({ code: "custom", path: ["forumFeed"], message: "Conversation entry forum scope mismatch" });
35121
+ if (entry.forumFeed) {
35122
+ const feed = entry.forumFeed, children = new Set(feed.threads.map((thread) => thread.id)), profiles = new Set(feed.included.profiles.map((profile2) => profile2.id));
35123
+ const openers = new Set(feed.threads.flatMap((thread) => thread.parentMessageId ? [thread.parentMessageId] : []));
35124
+ if (feed.included.messages.some((message2) => message2.channelId !== entry.channelId && !children.has(message2.channelId)) || feed.included.tags.some((row) => !openers.has(row.messageId)) || feed.included.participantCounts.some((row) => !children.has(row.channelId)) || feed.included.members.some((member2) => !children.has(member2.channelId) || member2.relation !== "notify" || !profiles.has(member2.userId)))
35125
+ ctx.addIssue({ code: "custom", path: ["forumFeed", "included"], message: "Conversation entry forum included scope mismatch" });
35126
+ }
35127
+ const surfaceKind = entry.channel.type === "text" ? "channel" : entry.channel.type;
35128
+ if (entry.surfaceReceipt.surfaceKind !== surfaceKind)
35129
+ ctx.addIssue({ code: "custom", path: ["surfaceReceipt", "surfaceKind"], message: "Conversation entry surface mismatch" });
35130
+ if (entry.channel.archived)
35131
+ ctx.addIssue({ code: "custom", path: ["channel", "archived"], message: "Conversation entry is archived" });
35132
+ const anchored = entry.selection.reason === "explicit_anchor" || entry.selection.reason === "read_pointer";
35133
+ if (anchored !== (entry.selection.anchorMessageId !== null))
35134
+ ctx.addIssue({ code: "custom", path: ["selection"], message: "Conversation entry selection mismatch" });
35135
+ if (entry.selection.reason === "read_pointer" && entry.selection.anchorMessageId !== entry.readState.lastReadMessageId)
35136
+ ctx.addIssue({ code: "custom", path: ["selection", "anchorMessageId"], message: "Conversation entry read pointer mismatch" });
35137
+ if (entry.selection.reason === "read_pointer_missing" && entry.readState.lastReadMessageId === null)
35138
+ ctx.addIssue({ code: "custom", path: ["selection", "reason"], message: "Conversation entry missing read pointer" });
35139
+ });
35037
35140
  var CommunityMessagePostedSchema = CommunityMessagesReadSchema.pick({ contractVersion: true, channelId: true }).extend({
35038
35141
  message: CommunityMessageResourceSchema,
35039
35142
  deduped: exports_external.boolean(),
@@ -35464,6 +35567,21 @@ var BillingPortalRequestSchema = exports_external.strictObject({
35464
35567
  var BillingRedirectResponseSchema = exports_external.object({
35465
35568
  url: exports_external.string().url()
35466
35569
  });
35570
+ // ../shared/src/runtime-models-contract.ts
35571
+ var RUNTIME_MODEL_DISCOVERY_CAPABILITY = "runtime-model-discovery-v1";
35572
+ var RuntimeModelDiscoveryRequestSchema = exports_external.strictObject({
35573
+ requestId: exports_external.string().min(1).max(128),
35574
+ runtimeId: exports_external.string().min(1).max(64)
35575
+ });
35576
+ var RuntimeModelDiscoveryCommandSchema = RuntimeModelDiscoveryRequestSchema.extend({
35577
+ type: exports_external.literal("runtime:discover_models")
35578
+ });
35579
+ var RuntimeModelDiscoveryErrorSchema = exports_external.strictObject({
35580
+ status: exports_external.literal("error"),
35581
+ code: exports_external.string().min(1).max(64),
35582
+ message: exports_external.string().min(1).max(256)
35583
+ });
35584
+
35467
35585
  // ../shared/src/utils/slug.ts
35468
35586
  init_nanoid();
35469
35587
  var slugId = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz");
@@ -35570,6 +35688,7 @@ function parseSeq(s) {
35570
35688
  return n;
35571
35689
  }
35572
35690
  var HostCommandSchema = exports_external.discriminatedUnion("type", [
35691
+ RuntimeModelDiscoveryCommandSchema,
35573
35692
  exports_external.strictObject({
35574
35693
  type: exports_external.literal("machine:heartbeat"),
35575
35694
  nonce: exports_external.string().min(1).max(128)
@@ -36233,6 +36352,17 @@ var CommunityMachineRuntimeListSchema = exports_external.array(CommunityMachineR
36233
36352
  }
36234
36353
  return out;
36235
36354
  });
36355
+ var RuntimeModelDiscoveryResultSchema = exports_external.discriminatedUnion("status", [
36356
+ exports_external.strictObject({ status: exports_external.literal("complete"), catalog: RuntimeReasoningCatalogSchema.nullable() }),
36357
+ RuntimeModelDiscoveryErrorSchema
36358
+ ]);
36359
+ var HostRuntimeModelsFrameSchema = RuntimeModelDiscoveryRequestSchema.extend({
36360
+ type: exports_external.literal("runtime_models"),
36361
+ result: exports_external.discriminatedUnion("status", [
36362
+ exports_external.strictObject({ status: exports_external.literal("complete"), runtimeReport: CommunityMachineRuntimeListSchema }),
36363
+ RuntimeModelDiscoveryErrorSchema
36364
+ ])
36365
+ });
36236
36366
  var CommunityRunningAgentListSchema = exports_external.array(exports_external.string()).transform((list) => {
36237
36367
  const seen = new Set;
36238
36368
  const out = [];
@@ -37582,6 +37712,13 @@ var communityBotAuditEventSchema = exports_external.strictObject({
37582
37712
  launchId: nullableString.optional(),
37583
37713
  createdAt: string4
37584
37714
  }).refine((event) => Object.prototype.hasOwnProperty.call(event, "payload"));
37715
+ var communityRuntimeModelsSchema = exports_external.strictObject({
37716
+ type: exports_external.literal("community:runtime.models"),
37717
+ machineId: exports_external.string().min(1),
37718
+ requestId: exports_external.string().min(1).max(128),
37719
+ runtimeId: exports_external.string().min(1).max(64),
37720
+ result: RuntimeModelDiscoveryResultSchema
37721
+ });
37585
37722
  var commonCommunityEventSchemas = [
37586
37723
  communityMessageUpdatedSchema,
37587
37724
  communityMessageEditedSchema,
@@ -37620,6 +37757,7 @@ var commonCommunityEventSchemas = [
37620
37757
  communityMachineCreatedSchema,
37621
37758
  communityMachineStatusSchema,
37622
37759
  communityMachineUpdatedSchema,
37760
+ communityRuntimeModelsSchema,
37623
37761
  communityMachineRemovedSchema,
37624
37762
  communityBotAuditEventSchema
37625
37763
  ];
@@ -37690,6 +37828,7 @@ var WS_EVENTS = {
37690
37828
  MACHINE_CREATED: "community:machine.created",
37691
37829
  MACHINE_STATUS: "community:machine.status",
37692
37830
  MACHINE_UPDATED: "community:machine.updated",
37831
+ RUNTIME_MODELS: "community:runtime.models",
37693
37832
  MACHINE_REMOVED: "community:machine.removed",
37694
37833
  BOT_AUDIT_EVENT: "community:bot.audit_event"
37695
37834
  };
@@ -38009,6 +38148,9 @@ var nativeOauthExchangeSchema = exports_external.object({
38009
38148
  code: nativeOauthHandoffCodeSchema
38010
38149
  }).strict();
38011
38150
  var nativeOauthProofSchema = nativeOauthExchangeSchema.omit({ code: true }).strict();
38151
+ // ../shared/src/utils/community-mentions.ts
38152
+ var MENTION_IDENTIFIER_CHARACTERS = /[\p{L}\p{N}_-]/u.source;
38153
+ var ID_CHAR_RE = new RegExp(MENTION_IDENTIFIER_CHARACTERS, "u");
38012
38154
  // src/manager/memoryMaintenancePrompt.ts
38013
38155
  var MEMORY_MAINTENANCE_PROMPT = `The daemon is preparing to reset this idle session. First, clean up your memory so the next session does not inherit incorrect or outdated notes.
38014
38156
 
@@ -40325,6 +40467,7 @@ class AgentRouter {
40325
40467
  pendingAgentEvents = new Map;
40326
40468
  nextWakeAdmissionOrdinal = 1;
40327
40469
  runtimes = new Map;
40470
+ modelDiscoveries = new Map;
40328
40471
  pendingResend = false;
40329
40472
  scheduleResend;
40330
40473
  log;
@@ -40356,7 +40499,7 @@ class AgentRouter {
40356
40499
  const timeZone = typeof this.opts.timeZone === "function" ? this.opts.timeZone() : this.opts.timeZone;
40357
40500
  return {
40358
40501
  runtimeReport: [...this.runtimes.values()],
40359
- capabilities: [CONTROL_HEARTBEAT_CAPABILITY],
40502
+ capabilities: [CONTROL_HEARTBEAT_CAPABILITY, ...this.opts.channel.reportRuntimeModels ? [RUNTIME_MODEL_DISCOVERY_CAPABILITY] : []],
40360
40503
  runningAgents: [...this.running],
40361
40504
  hostname: this.opts.hostname,
40362
40505
  platform: this.opts.platform,
@@ -40499,8 +40642,54 @@ class AgentRouter {
40499
40642
  });
40500
40643
  return pending;
40501
40644
  }
40645
+ discoverRuntimeModels(runtimeId) {
40646
+ const active = this.modelDiscoveries.get(runtimeId);
40647
+ if (active)
40648
+ return active;
40649
+ const pending = this.runModelDiscovery(runtimeId).finally(() => this.modelDiscoveries.delete(runtimeId));
40650
+ this.modelDiscoveries.set(runtimeId, pending);
40651
+ return pending;
40652
+ }
40653
+ async runModelDiscovery(runtimeId) {
40654
+ let deadline;
40655
+ const timeout = new Promise((resolve4) => {
40656
+ deadline = setTimeout(() => resolve4(null), 40000);
40657
+ });
40658
+ const probe = await Promise.race([
40659
+ Promise.resolve().then(() => this.opts.discoverModels?.(runtimeId) ?? getDriver(runtimeId).discoverModels()),
40660
+ timeout
40661
+ ]).finally(() => clearTimeout(deadline));
40662
+ if (probe?.status === "healthy") {
40663
+ this.runtimes.set(runtimeId, { ...this.runtimes.get(runtimeId), reasoning: probe.reasoning });
40664
+ }
40665
+ return probe;
40666
+ }
40502
40667
  async onCommand(cmd) {
40503
40668
  switch (cmd.type) {
40669
+ case "runtime:discover_models": {
40670
+ const reply = this.opts.channel.reportRuntimeModels;
40671
+ if (!reply)
40672
+ return;
40673
+ const identity = { type: "runtime_models", requestId: cmd.requestId, runtimeId: cmd.runtimeId };
40674
+ try {
40675
+ const current = this.runtimes.get(cmd.runtimeId);
40676
+ if (!current)
40677
+ throw new UnknownRuntimeError(cmd.runtimeId, [...this.runtimes.keys()]);
40678
+ const probe = await this.discoverRuntimeModels(cmd.runtimeId);
40679
+ if (!probe) {
40680
+ reply.call(this.opts.channel, { ...identity, result: { status: "error", code: "model_discovery_timeout", message: "Model discovery timed out; retry the request" } });
40681
+ return;
40682
+ }
40683
+ if (probe.status !== "healthy") {
40684
+ reply.call(this.opts.channel, { ...identity, result: { status: "error", code: probe.error.code, message: probe.error.message } });
40685
+ return;
40686
+ }
40687
+ reply.call(this.opts.channel, { ...identity, result: { status: "complete", runtimeReport: [...this.runtimes.values()] } });
40688
+ } catch {
40689
+ reply.call(this.opts.channel, { ...identity, result: { status: "error", code: "model_discovery_failed", message: "Could not discover models for this runtime" } });
40690
+ }
40691
+ return;
40692
+ }
40504
40693
  case "agent:wake":
40505
40694
  this.log.info("agent:wake received", {
40506
40695
  agentId: cmd.agentId,
@@ -41863,6 +42052,9 @@ class WsControlChannel {
41863
42052
  }
41864
42053
  this.sendFrame(frame);
41865
42054
  }
42055
+ reportRuntimeModels(frame) {
42056
+ this.sendFrame(frame);
42057
+ }
41866
42058
  restorePendingBotAuditEvent(frame) {
41867
42059
  if (!frame.eventId || !frame.occurredAt)
41868
42060
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alook/daemon",
3
- "version": "0.1.52",
3
+ "version": "0.1.54",
4
4
  "description": "Alook agent daemon — host-side runtime backend, process manager, credential proxy, and control plane.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/alookai/alook#readme",