@adhdev/daemon-core 0.9.82-rc.144 → 0.9.82-rc.145

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.mjs CHANGED
@@ -4591,13 +4591,34 @@ var init_provider_schema = __esm({
4591
4591
  }
4592
4592
  }
4593
4593
  },
4594
+ nativeHistory: {
4595
+ type: "object",
4596
+ description: "Native transcript adapter declaration. v1 canonical field name. Daemon reads/lists provider-native history files via the named scripts (or the built-in adapter identified by $schema).",
4597
+ additionalProperties: true,
4598
+ properties: {
4599
+ $schema: { type: "string" },
4600
+ format: { type: "string" },
4601
+ watchPath: { type: "string" },
4602
+ mode: { enum: ["native-source", "materialized-mirror", "disabled", "daemon-mirror"] },
4603
+ contractVersion: { type: "string" },
4604
+ scripts: {
4605
+ type: "object",
4606
+ additionalProperties: false,
4607
+ properties: {
4608
+ readSession: { type: "string" },
4609
+ listSessions: { type: "string" }
4610
+ }
4611
+ }
4612
+ }
4613
+ },
4594
4614
  canonicalHistory: {
4595
4615
  type: "object",
4596
- additionalProperties: false,
4616
+ description: "Deprecated v0 alias for `nativeHistory`. The loader copies this block into `nativeHistory` at load time. New manifests should use `nativeHistory` directly.",
4617
+ additionalProperties: true,
4597
4618
  properties: {
4598
4619
  format: { type: "string" },
4599
4620
  watchPath: { type: "string" },
4600
- mode: { enum: ["native-source", "daemon-mirror"] },
4621
+ mode: { enum: ["native-source", "materialized-mirror", "disabled", "daemon-mirror"] },
4601
4622
  contractVersion: { type: "string" },
4602
4623
  scripts: {
4603
4624
  type: "object",
@@ -4622,11 +4643,6 @@ var init_provider_schema = __esm({
4622
4643
  description: "Declarative TUI parsing primitives. When present, daemon's builder synthesises detectStatus / parseApproval / parseSession from these blocks. Each block is identified by its $schema.",
4623
4644
  additionalProperties: true
4624
4645
  },
4625
- nativeHistory: {
4626
- type: "object",
4627
- description: "Declarative native-history adapter declaration. Daemon's builder routes readChat history through the named adapter ($schema).",
4628
- additionalProperties: true
4629
- },
4630
4646
  overrides: {
4631
4647
  type: "object",
4632
4648
  description: "Optional JS override pointers. Presence promotes the provider tier to `extended`. Each value identifies the handler being overridden and the relative path to the JS file implementing it.",
@@ -5888,6 +5904,11 @@ function buildParseSessionFromTui(spec) {
5888
5904
  dispatchOrder: spec.dispatchOrder
5889
5905
  }) : () => null;
5890
5906
  const parseApproval = spec.modal ? buildParseApprovalFromTui(spec.modal) : () => null;
5907
+ const sessionIdRe = spec.sessionIdExtraction ? new RegExp(
5908
+ spec.sessionIdExtraction.regex,
5909
+ spec.sessionIdExtraction.flags ?? "i"
5910
+ ) : null;
5911
+ const sessionIdScope = spec.sessionIdExtraction?.scope ?? "tail";
5891
5912
  return function parseSession(input) {
5892
5913
  const status = detectStatus(input) ?? "idle";
5893
5914
  const modal = parseApproval(input);
@@ -5938,13 +5959,20 @@ function buildParseSessionFromTui(spec) {
5938
5959
  if (cont) last.content = last.content ? `${last.content}
5939
5960
  ${cont}` : cont;
5940
5961
  }
5941
- return {
5962
+ const result = {
5942
5963
  status,
5943
5964
  messages,
5944
5965
  activeModal: modal,
5945
5966
  modal,
5946
5967
  parsedStatus: status
5947
5968
  };
5969
+ if (sessionIdRe) {
5970
+ const haystack = stripAnsi2(pickInputText(input, sessionIdScope));
5971
+ const match = haystack.match(sessionIdRe);
5972
+ const captured = match?.[1]?.trim();
5973
+ if (captured) result.providerSessionId = captured;
5974
+ }
5975
+ return result;
5948
5976
  };
5949
5977
  }
5950
5978
  var ANSI_RE, OSC_RE;
@@ -19794,7 +19822,7 @@ function isCurrentRuntimePtySafelyAttributed(args) {
19794
19822
  return true;
19795
19823
  }
19796
19824
  function supportsCliNativeTranscript(providerType, provider) {
19797
- if (provider?.category === "cli" && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
19825
+ if (provider?.category === "cli" && isNativeSourceCanonicalHistory(provider?.nativeHistory)) {
19798
19826
  return true;
19799
19827
  }
19800
19828
  if (CLI_NATIVE_TRANSCRIPT_PROVIDERS.has(providerType)) {
@@ -20142,7 +20170,7 @@ function summarizeProviderForDebug(provider) {
20142
20170
  name: provider.name,
20143
20171
  category: provider.category,
20144
20172
  version: provider.version,
20145
- canonicalHistory: provider.canonicalHistory,
20173
+ canonicalHistory: provider.nativeHistory,
20146
20174
  historyBehavior: provider.historyBehavior,
20147
20175
  webviewMatchText: provider.webviewMatchText,
20148
20176
  scriptNames: scripts,
@@ -20493,8 +20521,8 @@ async function handleChatHistory(h, args) {
20493
20521
  const exactNativeHistoryScope = Boolean(
20494
20522
  typeof args?.targetSessionId === "string" && args.targetSessionId.trim() || typeof args?.historySessionId === "string" && args.historySessionId.trim() || typeof args?.providerSessionId === "string" && args.providerSessionId.trim()
20495
20523
  );
20496
- const result = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory) ? readCliProviderNativeHistory(agentStr, {
20497
- canonicalHistory: provider?.canonicalHistory,
20524
+ const result = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.nativeHistory) ? readCliProviderNativeHistory(agentStr, {
20525
+ canonicalHistory: provider?.nativeHistory,
20498
20526
  historySessionId,
20499
20527
  workspace,
20500
20528
  offset: offset || 0,
@@ -20503,7 +20531,7 @@ async function handleChatHistory(h, args) {
20503
20531
  historyBehavior: provider?.historyBehavior,
20504
20532
  scripts: provider?.scripts
20505
20533
  }) : readProviderChatHistory(agentStr, {
20506
- canonicalHistory: provider?.canonicalHistory,
20534
+ canonicalHistory: provider?.nativeHistory,
20507
20535
  historySessionId,
20508
20536
  workspace,
20509
20537
  offset: offset || 0,
@@ -20512,7 +20540,7 @@ async function handleChatHistory(h, args) {
20512
20540
  historyBehavior: provider?.historyBehavior,
20513
20541
  scripts: provider?.scripts
20514
20542
  });
20515
- if (supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
20543
+ if (supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.nativeHistory)) {
20516
20544
  const lookup = result.lookup === "workspace" ? "workspace" : "session";
20517
20545
  const messages = Array.isArray(result.messages) ? normalizeNativeHistoryMessages(agentStr, result.messages, result?.providerSessionId) : [];
20518
20546
  const historyProviderSessionId = typeof result?.providerSessionId === "string" ? result.providerSessionId : readHistorySessionIdFromMessages(messages) || historySessionId;
@@ -20593,7 +20621,7 @@ async function handleReadChat(h, args) {
20593
20621
  let selectedStatus = returnedStatus;
20594
20622
  const sessionWorkspace = typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : typeof adapter.workingDir === "string" ? adapter.workingDir : void 0;
20595
20623
  const intendedWorkspace = typeof args?.workspace === "string" ? args.workspace : void 0;
20596
- const supportsNative = supportsCliNativeTranscript(providerType, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory);
20624
+ const supportsNative = supportsCliNativeTranscript(providerType, provider) && isNativeSourceCanonicalHistory(provider?.nativeHistory);
20597
20625
  const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h, adapter.cliType);
20598
20626
  const workspace = sessionWorkspace;
20599
20627
  const nativeHistoryLimit = Math.max(
@@ -20611,7 +20639,7 @@ async function handleReadChat(h, args) {
20611
20639
  if (supportsNative) {
20612
20640
  try {
20613
20641
  nativeHistory = readCliProviderNativeHistory(agentStr, {
20614
- canonicalHistory: provider?.canonicalHistory,
20642
+ canonicalHistory: provider?.nativeHistory,
20615
20643
  historySessionId: nativeHistorySessionId,
20616
20644
  workspace,
20617
20645
  offset: 0,
@@ -20672,7 +20700,7 @@ async function handleReadChat(h, args) {
20672
20700
  });
20673
20701
  const mayProbeLiveCodexWorkspaceNative = adapter.cliType === "codex-cli" && liveCurrentRuntimePtySafe && !(typeof args?.providerSessionId === "string" && args.providerSessionId.trim()) && !(providerSessionId && providerSessionId.trim()) && (!historyProviderSessionId || historyProviderSessionId === nativeHistorySessionId || historyProviderSessionId === historySessionId);
20674
20702
  const liveWorkspaceNativeHistory = mayProbeLiveCodexWorkspaceNative ? readLiveCodexWorkspaceNativeHistory(agentStr, {
20675
- canonicalHistory: provider?.canonicalHistory,
20703
+ canonicalHistory: provider?.nativeHistory,
20676
20704
  workspace,
20677
20705
  offset: 0,
20678
20706
  limit: nativeHistoryLimit,
@@ -20781,7 +20809,7 @@ async function handleReadChat(h, args) {
20781
20809
  returnedStatus: String(selectedStatus || ""),
20782
20810
  selectedMessageSource: messageSource.selected,
20783
20811
  messageSource,
20784
- shouldPreferAdapterMessages: supportsCliNativeTranscript(providerType, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory) && messageSource.selected !== "native-history" && typeof messageSource.fallbackReason === "string" && messageSource.fallbackReason.startsWith("native_history_") && messageSource.fallbackReason !== "native_history_not_checked" && !isUnsafeNativeTranscriptFallback(messageSource.fallbackReason) && !(selectedTranscriptAuthority === "provider" && selectedCoverage === "full"),
20812
+ shouldPreferAdapterMessages: supportsCliNativeTranscript(providerType, provider) && isNativeSourceCanonicalHistory(provider?.nativeHistory) && messageSource.selected !== "native-history" && typeof messageSource.fallbackReason === "string" && messageSource.fallbackReason.startsWith("native_history_") && messageSource.fallbackReason !== "native_history_not_checked" && !isUnsafeNativeTranscriptFallback(messageSource.fallbackReason) && !(selectedTranscriptAuthority === "provider" && selectedCoverage === "full"),
20785
20813
  parsedMsgCount: parsedRecord.messages.length,
20786
20814
  returnedMsgCount: selectedMessages.length
20787
20815
  },
@@ -20796,9 +20824,9 @@ async function handleReadChat(h, args) {
20796
20824
  const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
20797
20825
  const workspace = typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
20798
20826
  const intendedWorkspace = typeof args?.workspace === "string" ? args.workspace : void 0;
20799
- const supportsNative = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory);
20827
+ const supportsNative = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.nativeHistory);
20800
20828
  const history = supportsNative ? readCliProviderNativeHistory(agentStr, {
20801
- canonicalHistory: provider?.canonicalHistory,
20829
+ canonicalHistory: provider?.nativeHistory,
20802
20830
  historySessionId,
20803
20831
  workspace,
20804
20832
  offset: 0,
@@ -20807,7 +20835,7 @@ async function handleReadChat(h, args) {
20807
20835
  historyBehavior: provider?.historyBehavior,
20808
20836
  scripts: provider?.scripts
20809
20837
  }) : readProviderChatHistory(agentStr, {
20810
- canonicalHistory: provider?.canonicalHistory,
20838
+ canonicalHistory: provider?.nativeHistory,
20811
20839
  historySessionId,
20812
20840
  workspace,
20813
20841
  offset: 0,
@@ -25028,7 +25056,7 @@ ${effect.notification.body || ""}`.trim();
25028
25056
  }
25029
25057
  syncCanonicalSavedHistoryIfNeeded() {
25030
25058
  if (!this.providerSessionId) return false;
25031
- const canonicalHistory = this.provider.canonicalHistory;
25059
+ const canonicalHistory = this.provider.nativeHistory;
25032
25060
  if (!canonicalHistory) return false;
25033
25061
  if (isNativeSourceCanonicalHistory(canonicalHistory)) {
25034
25062
  const cacheKey = [this.type, this.providerSessionId, this.workingDir].join("\0");
@@ -25085,8 +25113,8 @@ ${effect.notification.body || ""}`.trim();
25085
25113
  restorePersistedHistoryFromCurrentSession() {
25086
25114
  if (!this.providerSessionId) return;
25087
25115
  this.syncCanonicalSavedHistoryIfNeeded();
25088
- const restoredHistory = isNativeSourceCanonicalHistory(this.provider.canonicalHistory) ? readProviderChatHistory(this.type, {
25089
- canonicalHistory: this.provider.canonicalHistory,
25116
+ const restoredHistory = isNativeSourceCanonicalHistory(this.provider.nativeHistory) ? readProviderChatHistory(this.type, {
25117
+ canonicalHistory: this.provider.nativeHistory,
25090
25118
  historySessionId: this.providerSessionId,
25091
25119
  workspace: this.workingDir,
25092
25120
  offset: 0,
@@ -27429,10 +27457,13 @@ var KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
27429
27457
  "approvalPositiveHints",
27430
27458
  "sessionIdPattern",
27431
27459
  "historyBehavior",
27432
- "canonicalHistory",
27433
- // v1 contract spelling; the loader aliases nativeHistory →
27434
- // canonicalHistory so downstream code reads the legacy name.
27460
+ // v1 canonical field name. The loader fills this in for legacy v0
27461
+ // manifests that ship the old `canonicalHistory` spelling.
27435
27462
  "nativeHistory",
27463
+ // Deprecated v0 alias for `nativeHistory`. Kept in the allowed-keys
27464
+ // list so legacy provider.json manifests don't trip the unknown-key
27465
+ // warning during the one-release deprecation window.
27466
+ "canonicalHistory",
27436
27467
  "autoFixProfile",
27437
27468
  "ideLevelScripts",
27438
27469
  "allowInputDuringGeneration",
@@ -27508,7 +27539,7 @@ function validateProviderDefinition(raw) {
27508
27539
  warnings.push("Extension providers should have extensionId");
27509
27540
  }
27510
27541
  validateCapabilities(provider, controls, errors);
27511
- validateCanonicalHistory(provider.canonicalHistory, errors);
27542
+ validateNativeHistory(provider.nativeHistory, errors);
27512
27543
  validateMeshCoordinator(provider.meshCoordinator, errors);
27513
27544
  for (const control of controls) {
27514
27545
  validateControl(control, errors);
@@ -27596,40 +27627,40 @@ function validateCapabilities(provider, controls, errors) {
27596
27627
  errors.push("providers declaring controls must set capabilities.controls.typedResults=true");
27597
27628
  }
27598
27629
  }
27599
- function validateCanonicalHistory(raw, errors) {
27630
+ function validateNativeHistory(raw, errors) {
27600
27631
  if (raw === void 0) return;
27601
27632
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
27602
- errors.push("canonicalHistory must be an object");
27633
+ errors.push("nativeHistory must be an object");
27603
27634
  return;
27604
27635
  }
27605
- const canonicalHistory = raw;
27606
- const format = canonicalHistory.format;
27636
+ const nativeHistory = raw;
27637
+ const format = nativeHistory.format;
27607
27638
  if (format !== void 0 && (typeof format !== "string" || !format.trim())) {
27608
- errors.push("canonicalHistory.format must be a non-empty string when provided");
27639
+ errors.push("nativeHistory.format must be a non-empty string when provided");
27609
27640
  }
27610
- const watchPath = canonicalHistory.watchPath;
27641
+ const watchPath = nativeHistory.watchPath;
27611
27642
  if (watchPath !== void 0 && (typeof watchPath !== "string" || !watchPath.trim())) {
27612
- errors.push("canonicalHistory.watchPath must be a non-empty string when provided");
27643
+ errors.push("nativeHistory.watchPath must be a non-empty string when provided");
27613
27644
  }
27614
- const mode = canonicalHistory.mode;
27645
+ const mode = nativeHistory.mode;
27615
27646
  if (mode !== void 0 && !["native-source", "materialized-mirror", "disabled"].includes(String(mode))) {
27616
- errors.push("canonicalHistory.mode must be one of: native-source, materialized-mirror, disabled");
27647
+ errors.push("nativeHistory.mode must be one of: native-source, materialized-mirror, disabled");
27617
27648
  }
27618
- const chatContractVersion = canonicalHistory.contractVersion;
27649
+ const chatContractVersion = nativeHistory.contractVersion;
27619
27650
  if (chatContractVersion !== void 0 && chatContractVersion !== "1.0" && chatContractVersion !== "2.0") {
27620
- errors.push(`canonicalHistory.contractVersion must be '1.0' or '2.0' when provided (got ${JSON.stringify(chatContractVersion)})`);
27651
+ errors.push(`nativeHistory.contractVersion must be '1.0' or '2.0' when provided (got ${JSON.stringify(chatContractVersion)})`);
27621
27652
  }
27622
- const scripts = canonicalHistory.scripts;
27653
+ const scripts = nativeHistory.scripts;
27623
27654
  if (scripts === void 0) return;
27624
27655
  if (!scripts || typeof scripts !== "object" || Array.isArray(scripts)) {
27625
- errors.push("canonicalHistory.scripts must be an object");
27656
+ errors.push("nativeHistory.scripts must be an object");
27626
27657
  return;
27627
27658
  }
27628
27659
  const scriptConfig = scripts;
27629
27660
  for (const key of ["readSession", "listSessions"]) {
27630
27661
  const value = scriptConfig[key];
27631
27662
  if (typeof value !== "string" || !value.trim()) {
27632
- errors.push(`canonicalHistory.scripts.${key} must be a non-empty string`);
27663
+ errors.push(`nativeHistory.scripts.${key} must be a non-empty string`);
27633
27664
  }
27634
27665
  }
27635
27666
  }
@@ -29322,8 +29353,12 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
29322
29353
  ...providerFields,
29323
29354
  ...extensionIdPattern instanceof RegExp ? { extensionIdPattern } : {}
29324
29355
  };
29325
- if (normalizedProvider.nativeHistory && !normalizedProvider.canonicalHistory) {
29326
- normalizedProvider.canonicalHistory = normalizedProvider.nativeHistory;
29356
+ const nh = normalizedProvider.nativeHistory;
29357
+ const ch = normalizedProvider.canonicalHistory;
29358
+ if (nh && !ch) {
29359
+ normalizedProvider.canonicalHistory = nh;
29360
+ } else if (ch && !nh) {
29361
+ normalizedProvider.nativeHistory = ch;
29327
29362
  }
29328
29363
  const validation = validateProviderDefinition(normalizedProvider);
29329
29364
  for (const warning of validation.warnings) {
@@ -34019,7 +34054,7 @@ var DaemonCommandRouter = class {
34019
34054
  const requestedProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : typeof args?.activeProviderSessionId === "string" ? args.activeProviderSessionId.trim() : "";
34020
34055
  const providerMeta = this.deps.providerLoader.resolve?.(providerType) || this.deps.providerLoader.getMeta(providerType);
34021
34056
  const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
34022
- canonicalHistory: providerMeta?.canonicalHistory,
34057
+ canonicalHistory: providerMeta?.nativeHistory,
34023
34058
  offset,
34024
34059
  limit,
34025
34060
  historyBehavior: providerMeta?.historyBehavior,