@adhdev/mesh-shared 1.0.82-rc.22 → 1.0.82-rc.24

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/index.js CHANGED
@@ -20,7 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ ASSISTANT_ACCOUNT_SLOT: () => ASSISTANT_ACCOUNT_SLOT,
24
+ ASSISTANT_FOLLOWER_ALLOWED_OPS: () => ASSISTANT_FOLLOWER_ALLOWED_OPS,
23
25
  ASSISTANT_OWNER_VERBS: () => ASSISTANT_OWNER_VERBS,
26
+ ASSISTANT_REMOTE_FOLLOW_COMMAND: () => ASSISTANT_REMOTE_FOLLOW_COMMAND,
27
+ ASSISTANT_REMOTE_PROJECT_ACCESS_COMMAND: () => ASSISTANT_REMOTE_PROJECT_ACCESS_COMMAND,
28
+ ASSISTANT_REMOTE_PROJECT_CATALOG_COMMAND: () => ASSISTANT_REMOTE_PROJECT_CATALOG_COMMAND,
29
+ ASSISTANT_REMOTE_PROJECT_COMMAND: () => ASSISTANT_REMOTE_PROJECT_COMMAND,
24
30
  ASSISTANT_REVIEW_TURN_VERBS: () => ASSISTANT_REVIEW_TURN_VERBS,
25
31
  ASSISTANT_SESSION_ID_ARG: () => ASSISTANT_SESSION_ID_ARG,
26
32
  ASSISTANT_SESSION_ID_ENV: () => ASSISTANT_SESSION_ID_ENV,
@@ -229,11 +235,13 @@ __export(index_exports, {
229
235
  expandDaemonIdForms: () => expandDaemonIdForms,
230
236
  findOwnershipConflicts: () => findOwnershipConflicts,
231
237
  foldKeyedDoc: () => foldKeyedDoc,
238
+ followedRemoteProjectKey: () => followedRemoteProjectKey,
232
239
  formatQuotaAccount: () => formatQuotaAccount,
233
240
  hasGitStatusEvidence: () => hasGitStatusEvidence,
234
241
  hasWorkerProtocolFooter: () => hasWorkerProtocolFooter,
235
242
  interpolateString: () => interpolateString,
236
243
  isActionableProviderApproval: () => isActionableProviderApproval,
244
+ isAssistantFollowerAllowedOp: () => isAssistantFollowerAllowedOp,
237
245
  isAssistantTool: () => isAssistantTool,
238
246
  isBlockedStatus: () => isBlockedStatus,
239
247
  isBusyStatus: () => isBusyStatus,
@@ -333,6 +341,7 @@ __export(index_exports, {
333
341
  normalizeThinkingLevel: () => normalizeThinkingLevel,
334
342
  orderProvidersByBuiltinPreference: () => orderProvidersByBuiltinPreference,
335
343
  parseJsonRecord: () => parseJsonRecord,
344
+ parseRoleLaunchSelection: () => parseRoleLaunchSelection,
336
345
  parseSemver: () => parseSemver,
337
346
  parseSessionLaunchRecord: () => parseSessionLaunchRecord,
338
347
  pathsOverlap: () => pathsOverlap,
@@ -356,6 +365,7 @@ __export(index_exports, {
356
365
  retiredMeshToolError: () => retiredMeshToolError,
357
366
  sanitizeModelIdentifier: () => sanitizeModelIdentifier,
358
367
  sanitizeRefusalCode: () => sanitizeRefusalCode,
368
+ sanitizeRemoteRepoIdentity: () => sanitizeRemoteRepoIdentity,
359
369
  scoreGitStatusCandidate: () => scoreGitStatusCandidate,
360
370
  scoreGitUpstreamFreshness: () => scoreGitUpstreamFreshness,
361
371
  sessionIdsEquivalent: () => sessionIdsEquivalent,
@@ -366,6 +376,7 @@ __export(index_exports, {
366
376
  summarizeGitShape: () => summarizeGitShape,
367
377
  supportsQuota: () => supportsQuota,
368
378
  touchedFilesOutsideOwnership: () => touchedFilesOutsideOwnership,
379
+ unwrapPastedContent: () => unwrapPastedContent,
369
380
  withStatusProbeMarker: () => withStatusProbeMarker
370
381
  });
371
382
  module.exports = __toCommonJS(index_exports);
@@ -566,15 +577,15 @@ function pickBestTransitGitStatus(node, options) {
566
577
  }
567
578
 
568
579
  // src/session-normalize.ts
569
- function deriveSyntheticSessionId(record) {
580
+ function deriveSyntheticSessionId(record2) {
570
581
  const parts = [
571
- readString(record.workspace),
572
- readString(record.providerType, record.provider),
573
- readString(record.role),
574
- readString(record.state, record.status),
575
- readString(record.title),
576
- readString(record.createdAt, record.created_at),
577
- readString(record.startedAt, record.started_at)
582
+ readString(record2.workspace),
583
+ readString(record2.providerType, record2.provider),
584
+ readString(record2.role),
585
+ readString(record2.state, record2.status),
586
+ readString(record2.title),
587
+ readString(record2.createdAt, record2.created_at),
588
+ readString(record2.startedAt, record2.started_at)
578
589
  ].filter((part) => Boolean(part));
579
590
  if (parts.length === 0) return void 0;
580
591
  return `synthetic:${parts.join("|")}`;
@@ -586,33 +597,33 @@ function sessionIdsEquivalent(a, b) {
586
597
  return idA === idB;
587
598
  }
588
599
  function normalizeMeshSessionRecord(entry) {
589
- const record = readRecord(entry);
590
- const sessionId = readString(record.sessionId, record.session_id, record.id) ?? deriveSyntheticSessionId(record);
600
+ const record2 = readRecord(entry);
601
+ const sessionId = readString(record2.sessionId, record2.session_id, record2.id) ?? deriveSyntheticSessionId(record2);
591
602
  if (!sessionId) return null;
592
603
  return {
593
604
  sessionId,
594
- ...readString(record.providerType, record.provider) ? { providerType: readString(record.providerType, record.provider) } : {},
595
- ...readString(record.state, record.status) ? { state: readString(record.state, record.status) } : {},
596
- ...readString(record.chatStatus, record.chat_status) ? { chatStatus: readString(record.chatStatus, record.chat_status) } : {},
597
- ...readString(record.lifecycle) ? { lifecycle: readString(record.lifecycle) } : {},
598
- ...readString(record.surfaceKind, record.surface_kind) ? { surfaceKind: readString(record.surfaceKind, record.surface_kind) } : {},
599
- ...readString(record.recoveryState, record.recovery_state) ? { recoveryState: readString(record.recoveryState, record.recovery_state) } : {},
600
- ...readString(record.workspace) ? { workspace: readString(record.workspace) } : {},
601
- ...readString(record.title) ? { title: readString(record.title) } : {},
602
- ...readString(record.role) ? { role: readString(record.role) } : {},
603
- ...readBoolean(record.isSelfCoordinator, record.is_self_coordinator) !== void 0 ? { isSelfCoordinator: readBoolean(record.isSelfCoordinator, record.is_self_coordinator) } : {},
604
- ...readString(record.statusNote, record.status_note) ? { statusNote: readString(record.statusNote, record.status_note) } : {},
605
- ...readString(record.createdAt, record.created_at) ? { createdAt: readString(record.createdAt, record.created_at) } : {},
606
- ...readString(record.startedAt, record.started_at) ? { startedAt: readString(record.startedAt, record.started_at) } : {},
607
- ...readString(record.lastActivityAt, record.last_activity_at) ? { lastActivityAt: readString(record.lastActivityAt, record.last_activity_at) } : {},
608
- ...readBoolean(record.isCached, record.is_cached) !== void 0 ? { isCached: readBoolean(record.isCached, record.is_cached) } : {}
605
+ ...readString(record2.providerType, record2.provider) ? { providerType: readString(record2.providerType, record2.provider) } : {},
606
+ ...readString(record2.state, record2.status) ? { state: readString(record2.state, record2.status) } : {},
607
+ ...readString(record2.chatStatus, record2.chat_status) ? { chatStatus: readString(record2.chatStatus, record2.chat_status) } : {},
608
+ ...readString(record2.lifecycle) ? { lifecycle: readString(record2.lifecycle) } : {},
609
+ ...readString(record2.surfaceKind, record2.surface_kind) ? { surfaceKind: readString(record2.surfaceKind, record2.surface_kind) } : {},
610
+ ...readString(record2.recoveryState, record2.recovery_state) ? { recoveryState: readString(record2.recoveryState, record2.recovery_state) } : {},
611
+ ...readString(record2.workspace) ? { workspace: readString(record2.workspace) } : {},
612
+ ...readString(record2.title) ? { title: readString(record2.title) } : {},
613
+ ...readString(record2.role) ? { role: readString(record2.role) } : {},
614
+ ...readBoolean(record2.isSelfCoordinator, record2.is_self_coordinator) !== void 0 ? { isSelfCoordinator: readBoolean(record2.isSelfCoordinator, record2.is_self_coordinator) } : {},
615
+ ...readString(record2.statusNote, record2.status_note) ? { statusNote: readString(record2.statusNote, record2.status_note) } : {},
616
+ ...readString(record2.createdAt, record2.created_at) ? { createdAt: readString(record2.createdAt, record2.created_at) } : {},
617
+ ...readString(record2.startedAt, record2.started_at) ? { startedAt: readString(record2.startedAt, record2.started_at) } : {},
618
+ ...readString(record2.lastActivityAt, record2.last_activity_at) ? { lastActivityAt: readString(record2.lastActivityAt, record2.last_activity_at) } : {},
619
+ ...readBoolean(record2.isCached, record2.is_cached) !== void 0 ? { isCached: readBoolean(record2.isCached, record2.is_cached) } : {}
609
620
  };
610
621
  }
611
622
 
612
623
  // src/node-normalize.ts
613
624
  function normalizeMeshNodeId(node) {
614
- const record = node && typeof node === "object" ? node : {};
615
- return readString(record.id, record.nodeId, record.node_id);
625
+ const record2 = node && typeof node === "object" ? node : {};
626
+ return readString(record2.id, record2.nodeId, record2.node_id);
616
627
  }
617
628
  function meshNodeIdMatches(node, candidateId) {
618
629
  if (!candidateId) return false;
@@ -624,12 +635,12 @@ function meshNodeIdMatches(node, candidateId) {
624
635
  // src/node-facts.ts
625
636
  function normalizeMeshNodeFacts(raw) {
626
637
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
627
- const record = raw;
628
- const schemaVersion = Number(record.schemaVersion);
629
- const reportedAt = Number(record.reportedAt);
638
+ const record2 = raw;
639
+ const schemaVersion = Number(record2.schemaVersion);
640
+ const reportedAt = Number(record2.reportedAt);
630
641
  if (!Number.isFinite(schemaVersion) || schemaVersion < 1) return void 0;
631
642
  if (!Number.isFinite(reportedAt) || reportedAt <= 0) return void 0;
632
- return { ...record, schemaVersion, reportedAt };
643
+ return { ...record2, schemaVersion, reportedAt };
633
644
  }
634
645
  var QUOTA_SUPPORTED_PROVIDERS = [
635
646
  "antigravity-cli",
@@ -786,9 +797,9 @@ function expandDaemonIdForms(ids) {
786
797
 
787
798
  // src/git-summarize.ts
788
799
  function summarizeGitShape(status) {
789
- const record = readRecord(status);
790
- if (!Object.keys(record).length) return null;
791
- const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
800
+ const record2 = readRecord(status);
801
+ if (!Object.keys(record2).length) return null;
802
+ const submodules = Array.isArray(record2.submodules) ? record2.submodules.map((entry) => {
792
803
  const sub = readRecord(entry);
793
804
  return {
794
805
  path: readString(sub.path) ?? null,
@@ -798,23 +809,23 @@ function summarizeGitShape(status) {
798
809
  };
799
810
  }) : [];
800
811
  return {
801
- isGitRepo: readBoolean(record.isGitRepo),
802
- workspace: readString(record.workspace) ?? null,
803
- repoRoot: readString(record.repoRoot, record.repo_root) ?? null,
804
- branch: readString(record.branch) ?? null,
805
- upstream: readString(record.upstream) ?? null,
806
- upstreamStatus: readString(record.upstreamStatus, record.upstream_status) ?? null,
807
- headCommit: readString(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
808
- ahead: readNumber(record.ahead) ?? null,
809
- behind: readNumber(record.behind) ?? null,
812
+ isGitRepo: readBoolean(record2.isGitRepo),
813
+ workspace: readString(record2.workspace) ?? null,
814
+ repoRoot: readString(record2.repoRoot, record2.repo_root) ?? null,
815
+ branch: readString(record2.branch) ?? null,
816
+ upstream: readString(record2.upstream) ?? null,
817
+ upstreamStatus: readString(record2.upstreamStatus, record2.upstream_status) ?? null,
818
+ headCommit: readString(record2.headCommit, record2.head_commit)?.slice(0, 12) ?? null,
819
+ ahead: readNumber(record2.ahead) ?? null,
820
+ behind: readNumber(record2.behind) ?? null,
810
821
  dirtyCounts: {
811
- staged: readNumber(record.staged) ?? 0,
812
- modified: readNumber(record.modified) ?? 0,
813
- untracked: readNumber(record.untracked) ?? 0,
814
- deleted: readNumber(record.deleted) ?? 0,
815
- renamed: readNumber(record.renamed) ?? 0
822
+ staged: readNumber(record2.staged) ?? 0,
823
+ modified: readNumber(record2.modified) ?? 0,
824
+ untracked: readNumber(record2.untracked) ?? 0,
825
+ deleted: readNumber(record2.deleted) ?? 0,
826
+ renamed: readNumber(record2.renamed) ?? 0
816
827
  },
817
- lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
828
+ lastCheckedAt: readNumber(record2.lastCheckedAt, record2.last_checked_at) ?? null,
818
829
  submoduleCount: submodules.length,
819
830
  submodules
820
831
  };
@@ -980,10 +991,25 @@ var CLI_SLOT_RECIPES = Object.freeze({
980
991
  ],
981
992
  "antigravity-cli": [
982
993
  {
983
- model: "Gemini 3.1 Pro (High)",
994
+ model: "Gemini 3.8 Flash (High)",
995
+ modelCandidates: ["Gemini 3.8 Flash (High)", "Gemini 4 Argon (Low)", "Gemini 3.7 Flash (High)", "Gemini 3.1 Pro (High)"],
984
996
  difficulty: ["easy"],
985
997
  maxParallel: 2,
986
998
  rationale: "Cheap capacity for easy tasks."
999
+ },
1000
+ {
1001
+ model: "Gemini 4 Argon (Medium)",
1002
+ modelCandidates: ["Gemini 4 Argon (Medium)", "Gemini 3.8 Flash (High)", "Gemini 3.7 Flash (High)", "Gemini 3.1 Pro (High)"],
1003
+ difficulty: ["medium"],
1004
+ maxParallel: 2,
1005
+ rationale: "Balanced Argon tier for medium tasks."
1006
+ },
1007
+ {
1008
+ model: "Gemini 4 Argon (High)",
1009
+ modelCandidates: ["Gemini 4 Argon (High)", "Gemini 3.8 Flash (High)", "Gemini 3.1 Pro (High)"],
1010
+ difficulty: ["difficult"],
1011
+ maxParallel: 1,
1012
+ rationale: "Reserved for hard tasks; capped at 1 to bound cost."
987
1013
  }
988
1014
  ],
989
1015
  "cursor-cli": [
@@ -1022,6 +1048,24 @@ function dedupeDetected(detected) {
1022
1048
  }
1023
1049
  return out;
1024
1050
  }
1051
+ function resolveRecipeModel(recipe, modelOptions) {
1052
+ if (!Array.isArray(modelOptions) || modelOptions.length === 0) {
1053
+ return recipe.model;
1054
+ }
1055
+ const available = new Set(
1056
+ modelOptions.filter((m) => typeof m === "string" && m.trim().length > 0).map((m) => m.trim())
1057
+ );
1058
+ if (available.size === 0) return recipe.model;
1059
+ const candidates = [
1060
+ ...recipe.model ? [recipe.model] : [],
1061
+ ...recipe.modelCandidates ?? []
1062
+ ];
1063
+ for (const candidate of candidates) {
1064
+ const trimmed = typeof candidate === "string" ? candidate.trim() : "";
1065
+ if (trimmed && available.has(trimmed)) return trimmed;
1066
+ }
1067
+ return recipe.model;
1068
+ }
1025
1069
  function buildSlotProposal(detected, currentSlots = []) {
1026
1070
  const providers = dedupeDetected(detected ?? []);
1027
1071
  const proposedSlots = [];
@@ -1037,7 +1081,7 @@ function buildSlotProposal(detected, currentSlots = []) {
1037
1081
  for (const recipe of recipes) {
1038
1082
  const slot = normalizeNodeCapabilitySlot({
1039
1083
  provider: provider.type,
1040
- model: recipe.model,
1084
+ model: resolveRecipeModel(recipe, provider.modelOptions),
1041
1085
  thinkingLevel: recipe.thinkingLevel,
1042
1086
  difficulty: recipe.difficulty,
1043
1087
  maxParallel: recipe.maxParallel
@@ -1127,7 +1171,10 @@ var CANONICAL_MESH_TOOL_NAMES = [
1127
1171
  "mesh_mission_upsert",
1128
1172
  "mesh_mission_list",
1129
1173
  "mesh_review_inbox",
1130
- "mesh_node_slots"
1174
+ "mesh_node_slots",
1175
+ "driver_list",
1176
+ "driver_describe",
1177
+ "artifact_list"
1131
1178
  ];
1132
1179
  var CANONICAL_MESH_TOOL_COUNT = CANONICAL_MESH_TOOL_NAMES.length;
1133
1180
  var RETIRED_MESH_TOOLS = {
@@ -1802,10 +1849,10 @@ function isTerminalSessionRecordStatus(raw) {
1802
1849
  return typeof raw === "string" && TERMINAL_SESSION_RECORD_STATUSES.includes(raw.trim().toLowerCase());
1803
1850
  }
1804
1851
  function isIdleSessionState(state) {
1805
- const record = state && typeof state === "object" ? state : {};
1806
- const status = typeof record.status === "string" ? record.status.trim().toLowerCase() : "";
1852
+ const record2 = state && typeof state === "object" ? state : {};
1853
+ const status = typeof record2.status === "string" ? record2.status.trim().toLowerCase() : "";
1807
1854
  if (isTerminalSessionRecordStatus(status) || isDeadStatus(status)) return false;
1808
- return isReadyStatus(status) || record.activeChat?.status === "waiting_input";
1855
+ return isReadyStatus(status) || record2.activeChat?.status === "waiting_input";
1809
1856
  }
1810
1857
 
1811
1858
  // src/mesh-vocabulary.ts
@@ -1915,6 +1962,14 @@ function isOutboundMessage(value) {
1915
1962
  const candidate = value;
1916
1963
  return isMessageId(candidate.messageId) && typeof candidate.sessionId === "string" && candidate.sessionId.length > 0 && isInputEnvelopeWire(candidate.input) && isOutboundMessageOrigin(candidate.origin) && isSendPolicy(candidate.policy) && typeof candidate.createdAt === "number";
1917
1964
  }
1965
+ var PASTED_OPEN_RE = /^\s*<pasted_content(?:\s+id="[^"]*")?\s*>\s*$/;
1966
+ var PASTED_CLOSE_RE = /^\s*<\/pasted_content(?:\s+id="[^"]*")?\s*>\s*$/;
1967
+ function unwrapPastedContent(text) {
1968
+ const lines = text.replace(/\r\n?/g, "\n").split("\n");
1969
+ const first = lines.findIndex((line) => line.trim());
1970
+ if (first < 0 || !PASTED_OPEN_RE.test(lines[first])) return text;
1971
+ return lines.filter((line) => !PASTED_OPEN_RE.test(line) && !PASTED_CLOSE_RE.test(line)).join("\n");
1972
+ }
1918
1973
 
1919
1974
  // src/mission-brief.ts
1920
1975
  var GOAL_MAX = 500;
@@ -2000,7 +2055,11 @@ var WORKER_TOOLS = [
2000
2055
  "peer_context_pull",
2001
2056
  "git_status",
2002
2057
  "git_log",
2003
- "git_diff"
2058
+ "git_diff",
2059
+ "driver_list",
2060
+ "driver_describe",
2061
+ "driver_invoke",
2062
+ "artifact_register"
2004
2063
  ];
2005
2064
  var WORKER_TOOL_SET = new Set(WORKER_TOOLS);
2006
2065
  function isWorkerTool(value) {
@@ -2099,7 +2158,9 @@ var ASSISTANT_TOOLS = [
2099
2158
  "skill_manage",
2100
2159
  "project_note",
2101
2160
  "launch_defaults",
2102
- "launch_defaults_set"
2161
+ "launch_defaults_set",
2162
+ "driver_list",
2163
+ "driver_describe"
2103
2164
  ];
2104
2165
  var ASSISTANT_TOOL_SET = new Set(ASSISTANT_TOOLS);
2105
2166
  function isAssistantTool(value) {
@@ -2107,6 +2168,8 @@ function isAssistantTool(value) {
2107
2168
  }
2108
2169
  var ASSISTANT_VERB = {
2109
2170
  // tool verbs
2171
+ driverList: "driver_list",
2172
+ driverDescribe: "driver_describe",
2110
2173
  projects: "assistant_projects",
2111
2174
  environment: "assistant_environment",
2112
2175
  action: "assistant_action",
@@ -2137,6 +2200,8 @@ var ASSISTANT_VERB = {
2137
2200
  threadClose: "assistant_thread_close"
2138
2201
  };
2139
2202
  var ASSISTANT_TOOL_VERBS = {
2203
+ driver_list: ASSISTANT_VERB.driverList,
2204
+ driver_describe: ASSISTANT_VERB.driverDescribe,
2140
2205
  projects: ASSISTANT_VERB.projects,
2141
2206
  environment: ASSISTANT_VERB.environment,
2142
2207
  assistant_action: ASSISTANT_VERB.action,
@@ -2170,6 +2235,63 @@ var ASSISTANT_REVIEW_TURN_VERBS = [
2170
2235
  ];
2171
2236
  var ASSISTANT_SESSION_ID_ENV = "ADHDEV_ASSISTANT_SESSION_ID";
2172
2237
  var ASSISTANT_SESSION_ID_ARG = "assistantSessionId";
2238
+ var ASSISTANT_ACCOUNT_SLOT = "personal";
2239
+ var ASSISTANT_REMOTE_PROJECT_COMMAND = "assistant_remote_project";
2240
+ var ASSISTANT_REMOTE_PROJECT_CATALOG_COMMAND = "assistant_remote_project_catalog";
2241
+ var ASSISTANT_REMOTE_PROJECT_ACCESS_COMMAND = "assistant_remote_project_access";
2242
+ var ASSISTANT_REMOTE_FOLLOW_COMMAND = "assistant_remote_follow";
2243
+ var ASSISTANT_FOLLOWER_ALLOWED_OPS = ["status", "read", "poll", "report", "send"];
2244
+ var ASSISTANT_FOLLOWER_ALLOWED_OP_SET = new Set(ASSISTANT_FOLLOWER_ALLOWED_OPS);
2245
+ function isAssistantFollowerAllowedOp(value) {
2246
+ return typeof value === "string" && ASSISTANT_FOLLOWER_ALLOWED_OP_SET.has(value);
2247
+ }
2248
+ function followedRemoteProjectKey(hostDaemonId, meshId) {
2249
+ const canonHost = canonicalDaemonId(hostDaemonId) ?? hostDaemonId.trim();
2250
+ return `${canonHost}::${meshId.trim()}`;
2251
+ }
2252
+ function sanitizeRemoteRepoIdentity(raw) {
2253
+ if (typeof raw !== "string") return null;
2254
+ const trimmed = raw.trim();
2255
+ if (!trimmed) return null;
2256
+ if (trimmed.startsWith("/") || trimmed.startsWith("./") || trimmed.startsWith("../") || trimmed.startsWith("~/") || trimmed.startsWith("\\") || /^[a-zA-Z]:[\\/]/.test(trimmed) || /^file:/i.test(trimmed)) {
2257
+ return null;
2258
+ }
2259
+ const withoutQuery = trimmed.replace(/[?#].*$/, "").replace(/\/+$/, "");
2260
+ if (!withoutQuery) return null;
2261
+ let host = "";
2262
+ let repoPath = "";
2263
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(withoutQuery)) {
2264
+ try {
2265
+ const url = new URL(withoutQuery);
2266
+ if (url.protocol === "file:") return null;
2267
+ host = url.hostname.toLowerCase();
2268
+ repoPath = decodeURIComponent(url.pathname).replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
2269
+ } catch {
2270
+ return null;
2271
+ }
2272
+ } else {
2273
+ const scpMatch = withoutQuery.match(/^(?:[^@/:]+@)?(\[[^\]]+\]|[^/:]+):(.+)$/);
2274
+ if (scpMatch) {
2275
+ host = scpMatch[1].replace(/^\[|\]$/g, "").toLowerCase();
2276
+ repoPath = scpMatch[2].replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
2277
+ } else {
2278
+ const slash = withoutQuery.indexOf("/");
2279
+ if (slash > 0) {
2280
+ const rawHost = withoutQuery.slice(0, slash);
2281
+ const atIdx = rawHost.lastIndexOf("@");
2282
+ host = (atIdx >= 0 ? rawHost.slice(atIdx + 1) : rawHost).toLowerCase();
2283
+ repoPath = withoutQuery.slice(slash + 1).replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
2284
+ }
2285
+ }
2286
+ }
2287
+ if (!host || !repoPath) return null;
2288
+ if (!host.includes(".") && host !== "localhost") return null;
2289
+ if (/[\s@:\\]/.test(host)) return null;
2290
+ const segments = repoPath.split("/").filter(Boolean);
2291
+ if (segments.length === 0) return null;
2292
+ if (segments.some((seg) => seg === "." || seg === ".." || /[\s@:\\]/.test(seg))) return null;
2293
+ return `${host}/${segments.join("/")}`.slice(0, 200);
2294
+ }
2173
2295
 
2174
2296
  // src/turn-evidence.ts
2175
2297
  var MESH_TOPIC_PROTOCOL_VERSION = 2;
@@ -2556,17 +2678,89 @@ function projectTurnEvidenceEntry(evidence, attempt) {
2556
2678
  };
2557
2679
  }
2558
2680
 
2681
+ // src/launch-defaults.ts
2682
+ var LAUNCH_DEFAULT_ROLES = ["assistant", "coordinator"];
2683
+ var LAUNCH_DEFAULT_SOURCES = ["user", "stored_default", "project_default", "provider_default"];
2684
+ var LAUNCH_DEFAULTS_NEXT_LAUNCH_NOTE = "Applies to the next launch; running sessions are unchanged.";
2685
+ function isLaunchDefaultRole(value) {
2686
+ return typeof value === "string" && LAUNCH_DEFAULT_ROLES.includes(value);
2687
+ }
2688
+ function isLaunchDefaultSource(value) {
2689
+ return typeof value === "string" && LAUNCH_DEFAULT_SOURCES.includes(value);
2690
+ }
2691
+ var LAUNCH_DEFAULT_ERROR_CODES = [
2692
+ "invalid_args",
2693
+ "launch_default_required",
2694
+ "launch_default_unavailable",
2695
+ "launch_selection_invalid",
2696
+ "launch_default_invalid",
2697
+ "revision_conflict",
2698
+ "store_unavailable",
2699
+ "store_busy",
2700
+ "persistence_failed",
2701
+ "project_not_found",
2702
+ "project_ambiguous",
2703
+ "project_not_hosted",
2704
+ "project_storage_unavailable",
2705
+ "staging_unavailable",
2706
+ "staging_failed",
2707
+ "review_turn_tool_denied"
2708
+ ];
2709
+
2710
+ // src/role-launch.ts
2711
+ function record(value) {
2712
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
2713
+ }
2714
+ function ref(value) {
2715
+ const r = record(value);
2716
+ if (!r || !isLaunchDefaultRole(r.role) || r.scope !== "global" && r.scope !== "project" || !Number.isSafeInteger(r.revision) || r.revision < 1 || r.scope === "project" && (typeof r.projectId !== "string" || !r.projectId)) return void 0;
2717
+ return {
2718
+ role: r.role,
2719
+ scope: r.scope,
2720
+ revision: r.revision,
2721
+ ...r.scope === "project" ? { projectId: r.projectId } : {}
2722
+ };
2723
+ }
2724
+ function axis(value) {
2725
+ const a = record(value);
2726
+ if (!a || !isLaunchDefaultSource(a.source) || a.value !== null && typeof a.value !== "string") return void 0;
2727
+ const defaultRef = ref(a.defaultRef);
2728
+ if (a.source === "stored_default" && defaultRef?.scope !== "global" || a.source === "project_default" && defaultRef?.scope !== "project" || (a.source === "user" || a.source === "provider_default") && a.defaultRef !== void 0) return void 0;
2729
+ return { value: a.value, source: a.source, ...defaultRef ? { defaultRef } : {} };
2730
+ }
2731
+ function parseRoleLaunchSelection(value) {
2732
+ const r = record(value), s = record(r?.selection), a = record(r?.applied);
2733
+ if (!r || !isLaunchDefaultRole(r.role) || !s || typeof s.provider !== "string" || !s.provider || !Number.isSafeInteger(r.documentRevision) || r.documentRevision < 1 || s.model !== void 0 && typeof s.model !== "string" || s.thinkingLevel !== void 0 && typeof s.thinkingLevel !== "string") return void 0;
2734
+ const provider = axis(a?.provider), model = axis(a?.model), thinkingLevel = axis(a?.thinkingLevel);
2735
+ if (!provider || !model || !thinkingLevel || [provider, model, thinkingLevel].some((axis2) => axis2.defaultRef && (axis2.defaultRef.role !== r.role || axis2.defaultRef.scope === "global" && axis2.defaultRef.revision > r.documentRevision)) || provider.value !== s.provider || model.value !== (s.model ?? null) || thinkingLevel.value !== (s.thinkingLevel ?? null)) return void 0;
2736
+ const defaultRef = ref(r.defaultRef);
2737
+ return {
2738
+ role: r.role,
2739
+ selection: {
2740
+ provider: s.provider,
2741
+ ...typeof s.model === "string" ? { model: s.model } : {},
2742
+ ...typeof s.thinkingLevel === "string" ? { thinkingLevel: s.thinkingLevel } : {}
2743
+ },
2744
+ applied: { provider, model, thinkingLevel },
2745
+ ...defaultRef ? { defaultRef } : {},
2746
+ documentRevision: r.documentRevision
2747
+ };
2748
+ }
2749
+
2559
2750
  // src/session-launch.ts
2560
2751
  var MODEL_AXIS_SOURCES = [
2561
2752
  /** Picked explicitly for this launch (dashboard dropdown, coordinator dialog). */
2562
2753
  "user",
2563
2754
  /** The dashboard dialog restored it from the last launch (browser-local memory). */
2564
2755
  "remembered",
2756
+ /** The authoritative daemon role default or host project override. */
2757
+ "stored_default",
2758
+ "project_default",
2565
2759
  /** A mesh capability slot supplied it (or a difficulty preset the slot outranked). */
2566
2760
  "mesh_slot",
2567
2761
  /** An explicit per-task model / thinking level on a mesh queue task. */
2568
2762
  "task_override",
2569
- /** Nothing was requested; the provider's default is known (discovery / manifest). */
2763
+ /** Nothing requested: the provider chooses; resolvedDefault records it when known. */
2570
2764
  "provider_default",
2571
2765
  /** A value was requested without saying where it came from, or nothing is known. */
2572
2766
  "unspecified"
@@ -2610,10 +2804,10 @@ function readFiniteNumber(value) {
2610
2804
  }
2611
2805
  function parseModelSelection(raw) {
2612
2806
  if (!raw || typeof raw !== "object") return void 0;
2613
- const record = raw;
2807
+ const record2 = raw;
2614
2808
  const history = [];
2615
- if (Array.isArray(record.history)) {
2616
- for (const entry of record.history) {
2809
+ if (Array.isArray(record2.history)) {
2810
+ for (const entry of record2.history) {
2617
2811
  if (!entry || typeof entry !== "object") continue;
2618
2812
  const e = entry;
2619
2813
  const value = readString(e.value);
@@ -2622,14 +2816,14 @@ function parseModelSelection(raw) {
2622
2816
  if (value && at !== void 0 && via) history.push({ at, value, via });
2623
2817
  }
2624
2818
  }
2625
- const requested = readString(record.requested);
2626
- const launchValue = readString(record.launchValue);
2627
- const resolvedDefault = readString(record.resolvedDefault);
2628
- const current = readString(record.current);
2629
- const observed = readString(record.observed);
2630
- const observedAt = readFiniteNumber(record.observedAt);
2819
+ const requested = readString(record2.requested);
2820
+ const launchValue = readString(record2.launchValue);
2821
+ const resolvedDefault = readString(record2.resolvedDefault);
2822
+ const current = readString(record2.current);
2823
+ const observed = readString(record2.observed);
2824
+ const observedAt = readFiniteNumber(record2.observedAt);
2631
2825
  return {
2632
- source: isModelAxisSource(record.source) ? record.source : "unspecified",
2826
+ source: isModelAxisSource(record2.source) ? record2.source : "unspecified",
2633
2827
  ...requested ? { requested } : {},
2634
2828
  ...launchValue ? { launchValue } : {},
2635
2829
  ...resolvedDefault ? { resolvedDefault } : {},
@@ -2641,22 +2835,24 @@ function parseModelSelection(raw) {
2641
2835
  }
2642
2836
  function parseSessionLaunchRecord(raw) {
2643
2837
  if (!raw || typeof raw !== "object") return void 0;
2644
- const record = raw;
2645
- const sessionId = readString(record.sessionId);
2646
- const providerType = readString(record.providerType);
2647
- const launchedAt = readFiniteNumber(record.launchedAt);
2648
- const model = parseModelSelection(record.model);
2649
- const thinkingLevel = parseModelSelection(record.thinkingLevel);
2838
+ const record2 = raw;
2839
+ const sessionId = readString(record2.sessionId);
2840
+ const providerType = readString(record2.providerType);
2841
+ const launchedAt = readFiniteNumber(record2.launchedAt);
2842
+ const model = parseModelSelection(record2.model);
2843
+ const thinkingLevel = parseModelSelection(record2.thinkingLevel);
2650
2844
  if (!sessionId || !providerType || launchedAt === void 0 || !model || !thinkingLevel) return void 0;
2651
- const providerVersion = readString(record.providerVersion);
2652
- const workspace = readString(record.workspace);
2653
- const autoApproveModeId = readString(record.autoApproveModeId);
2845
+ const providerVersion = readString(record2.providerVersion);
2846
+ const workspace = readString(record2.workspace);
2847
+ const autoApproveModeId = readString(record2.autoApproveModeId);
2848
+ const roleLaunch = parseRoleLaunchSelection(record2.roleLaunch);
2654
2849
  return {
2850
+ ...roleLaunch ? { roleLaunch } : {},
2655
2851
  sessionId,
2656
2852
  providerType,
2657
2853
  ...providerVersion ? { providerVersion } : {},
2658
- ...record.providerChannel === "stable" || record.providerChannel === "preview" ? { providerChannel: record.providerChannel } : {},
2659
- launchedBy: isSessionLaunchedBy(record.launchedBy) ? record.launchedBy : "api",
2854
+ ...record2.providerChannel === "stable" || record2.providerChannel === "preview" ? { providerChannel: record2.providerChannel } : {},
2855
+ launchedBy: isSessionLaunchedBy(record2.launchedBy) ? record2.launchedBy : "api",
2660
2856
  launchedAt,
2661
2857
  ...workspace ? { workspace } : {},
2662
2858
  model,
@@ -3920,38 +4116,15 @@ function isProviderQuestionBinding(value) {
3920
4116
  if (["sessionId", "generation", "threadId", "turnId", "itemId"].some((key) => typeof b[key] !== "string" || !b[key].trim())) return false;
3921
4117
  return b.transport === "codex_async" ? b.requestId === void 0 : typeof b.requestId === "string" && !!b.requestId.trim() || typeof b.requestId === "number" && Number.isFinite(b.requestId);
3922
4118
  }
3923
-
3924
- // src/launch-defaults.ts
3925
- var LAUNCH_DEFAULT_ROLES = ["assistant", "coordinator"];
3926
- var LAUNCH_DEFAULT_SOURCES = ["user", "stored_default", "project_default", "provider_default"];
3927
- var LAUNCH_DEFAULTS_NEXT_LAUNCH_NOTE = "Applies to the next launch; running sessions are unchanged.";
3928
- function isLaunchDefaultRole(value) {
3929
- return typeof value === "string" && LAUNCH_DEFAULT_ROLES.includes(value);
3930
- }
3931
- function isLaunchDefaultSource(value) {
3932
- return typeof value === "string" && LAUNCH_DEFAULT_SOURCES.includes(value);
3933
- }
3934
- var LAUNCH_DEFAULT_ERROR_CODES = [
3935
- "invalid_args",
3936
- "launch_default_required",
3937
- "launch_default_unavailable",
3938
- "launch_selection_invalid",
3939
- "launch_default_invalid",
3940
- "revision_conflict",
3941
- "store_unavailable",
3942
- "store_busy",
3943
- "persistence_failed",
3944
- "project_not_found",
3945
- "project_ambiguous",
3946
- "project_not_hosted",
3947
- "project_storage_unavailable",
3948
- "staging_unavailable",
3949
- "staging_failed",
3950
- "review_turn_tool_denied"
3951
- ];
3952
4119
  // Annotate the CommonJS export names for ESM import in node:
3953
4120
  0 && (module.exports = {
4121
+ ASSISTANT_ACCOUNT_SLOT,
4122
+ ASSISTANT_FOLLOWER_ALLOWED_OPS,
3954
4123
  ASSISTANT_OWNER_VERBS,
4124
+ ASSISTANT_REMOTE_FOLLOW_COMMAND,
4125
+ ASSISTANT_REMOTE_PROJECT_ACCESS_COMMAND,
4126
+ ASSISTANT_REMOTE_PROJECT_CATALOG_COMMAND,
4127
+ ASSISTANT_REMOTE_PROJECT_COMMAND,
3955
4128
  ASSISTANT_REVIEW_TURN_VERBS,
3956
4129
  ASSISTANT_SESSION_ID_ARG,
3957
4130
  ASSISTANT_SESSION_ID_ENV,
@@ -4160,11 +4333,13 @@ var LAUNCH_DEFAULT_ERROR_CODES = [
4160
4333
  expandDaemonIdForms,
4161
4334
  findOwnershipConflicts,
4162
4335
  foldKeyedDoc,
4336
+ followedRemoteProjectKey,
4163
4337
  formatQuotaAccount,
4164
4338
  hasGitStatusEvidence,
4165
4339
  hasWorkerProtocolFooter,
4166
4340
  interpolateString,
4167
4341
  isActionableProviderApproval,
4342
+ isAssistantFollowerAllowedOp,
4168
4343
  isAssistantTool,
4169
4344
  isBlockedStatus,
4170
4345
  isBusyStatus,
@@ -4264,6 +4439,7 @@ var LAUNCH_DEFAULT_ERROR_CODES = [
4264
4439
  normalizeThinkingLevel,
4265
4440
  orderProvidersByBuiltinPreference,
4266
4441
  parseJsonRecord,
4442
+ parseRoleLaunchSelection,
4267
4443
  parseSemver,
4268
4444
  parseSessionLaunchRecord,
4269
4445
  pathsOverlap,
@@ -4287,6 +4463,7 @@ var LAUNCH_DEFAULT_ERROR_CODES = [
4287
4463
  retiredMeshToolError,
4288
4464
  sanitizeModelIdentifier,
4289
4465
  sanitizeRefusalCode,
4466
+ sanitizeRemoteRepoIdentity,
4290
4467
  scoreGitStatusCandidate,
4291
4468
  scoreGitUpstreamFreshness,
4292
4469
  sessionIdsEquivalent,
@@ -4297,6 +4474,7 @@ var LAUNCH_DEFAULT_ERROR_CODES = [
4297
4474
  summarizeGitShape,
4298
4475
  supportsQuota,
4299
4476
  touchedFilesOutsideOwnership,
4477
+ unwrapPastedContent,
4300
4478
  withStatusProbeMarker
4301
4479
  });
4302
4480
  //# sourceMappingURL=index.js.map