@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.js CHANGED
@@ -4598,13 +4598,34 @@ var init_provider_schema = __esm({
4598
4598
  }
4599
4599
  }
4600
4600
  },
4601
+ nativeHistory: {
4602
+ type: "object",
4603
+ 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).",
4604
+ additionalProperties: true,
4605
+ properties: {
4606
+ $schema: { type: "string" },
4607
+ format: { type: "string" },
4608
+ watchPath: { type: "string" },
4609
+ mode: { enum: ["native-source", "materialized-mirror", "disabled", "daemon-mirror"] },
4610
+ contractVersion: { type: "string" },
4611
+ scripts: {
4612
+ type: "object",
4613
+ additionalProperties: false,
4614
+ properties: {
4615
+ readSession: { type: "string" },
4616
+ listSessions: { type: "string" }
4617
+ }
4618
+ }
4619
+ }
4620
+ },
4601
4621
  canonicalHistory: {
4602
4622
  type: "object",
4603
- additionalProperties: false,
4623
+ description: "Deprecated v0 alias for `nativeHistory`. The loader copies this block into `nativeHistory` at load time. New manifests should use `nativeHistory` directly.",
4624
+ additionalProperties: true,
4604
4625
  properties: {
4605
4626
  format: { type: "string" },
4606
4627
  watchPath: { type: "string" },
4607
- mode: { enum: ["native-source", "daemon-mirror"] },
4628
+ mode: { enum: ["native-source", "materialized-mirror", "disabled", "daemon-mirror"] },
4608
4629
  contractVersion: { type: "string" },
4609
4630
  scripts: {
4610
4631
  type: "object",
@@ -4629,11 +4650,6 @@ var init_provider_schema = __esm({
4629
4650
  description: "Declarative TUI parsing primitives. When present, daemon's builder synthesises detectStatus / parseApproval / parseSession from these blocks. Each block is identified by its $schema.",
4630
4651
  additionalProperties: true
4631
4652
  },
4632
- nativeHistory: {
4633
- type: "object",
4634
- description: "Declarative native-history adapter declaration. Daemon's builder routes readChat history through the named adapter ($schema).",
4635
- additionalProperties: true
4636
- },
4637
4653
  overrides: {
4638
4654
  type: "object",
4639
4655
  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.",
@@ -5891,6 +5907,11 @@ function buildParseSessionFromTui(spec) {
5891
5907
  dispatchOrder: spec.dispatchOrder
5892
5908
  }) : () => null;
5893
5909
  const parseApproval = spec.modal ? buildParseApprovalFromTui(spec.modal) : () => null;
5910
+ const sessionIdRe = spec.sessionIdExtraction ? new RegExp(
5911
+ spec.sessionIdExtraction.regex,
5912
+ spec.sessionIdExtraction.flags ?? "i"
5913
+ ) : null;
5914
+ const sessionIdScope = spec.sessionIdExtraction?.scope ?? "tail";
5894
5915
  return function parseSession(input) {
5895
5916
  const status = detectStatus(input) ?? "idle";
5896
5917
  const modal = parseApproval(input);
@@ -5941,13 +5962,20 @@ function buildParseSessionFromTui(spec) {
5941
5962
  if (cont) last.content = last.content ? `${last.content}
5942
5963
  ${cont}` : cont;
5943
5964
  }
5944
- return {
5965
+ const result = {
5945
5966
  status,
5946
5967
  messages,
5947
5968
  activeModal: modal,
5948
5969
  modal,
5949
5970
  parsedStatus: status
5950
5971
  };
5972
+ if (sessionIdRe) {
5973
+ const haystack = stripAnsi2(pickInputText(input, sessionIdScope));
5974
+ const match = haystack.match(sessionIdRe);
5975
+ const captured = match?.[1]?.trim();
5976
+ if (captured) result.providerSessionId = captured;
5977
+ }
5978
+ return result;
5951
5979
  };
5952
5980
  }
5953
5981
  var crypto3, ANSI_RE, OSC_RE;
@@ -20078,7 +20106,7 @@ function isCurrentRuntimePtySafelyAttributed(args) {
20078
20106
  return true;
20079
20107
  }
20080
20108
  function supportsCliNativeTranscript(providerType, provider) {
20081
- if (provider?.category === "cli" && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
20109
+ if (provider?.category === "cli" && isNativeSourceCanonicalHistory(provider?.nativeHistory)) {
20082
20110
  return true;
20083
20111
  }
20084
20112
  if (CLI_NATIVE_TRANSCRIPT_PROVIDERS.has(providerType)) {
@@ -20426,7 +20454,7 @@ function summarizeProviderForDebug(provider) {
20426
20454
  name: provider.name,
20427
20455
  category: provider.category,
20428
20456
  version: provider.version,
20429
- canonicalHistory: provider.canonicalHistory,
20457
+ canonicalHistory: provider.nativeHistory,
20430
20458
  historyBehavior: provider.historyBehavior,
20431
20459
  webviewMatchText: provider.webviewMatchText,
20432
20460
  scriptNames: scripts,
@@ -20777,8 +20805,8 @@ async function handleChatHistory(h, args) {
20777
20805
  const exactNativeHistoryScope = Boolean(
20778
20806
  typeof args?.targetSessionId === "string" && args.targetSessionId.trim() || typeof args?.historySessionId === "string" && args.historySessionId.trim() || typeof args?.providerSessionId === "string" && args.providerSessionId.trim()
20779
20807
  );
20780
- const result = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory) ? readCliProviderNativeHistory(agentStr, {
20781
- canonicalHistory: provider?.canonicalHistory,
20808
+ const result = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.nativeHistory) ? readCliProviderNativeHistory(agentStr, {
20809
+ canonicalHistory: provider?.nativeHistory,
20782
20810
  historySessionId,
20783
20811
  workspace,
20784
20812
  offset: offset || 0,
@@ -20787,7 +20815,7 @@ async function handleChatHistory(h, args) {
20787
20815
  historyBehavior: provider?.historyBehavior,
20788
20816
  scripts: provider?.scripts
20789
20817
  }) : readProviderChatHistory(agentStr, {
20790
- canonicalHistory: provider?.canonicalHistory,
20818
+ canonicalHistory: provider?.nativeHistory,
20791
20819
  historySessionId,
20792
20820
  workspace,
20793
20821
  offset: offset || 0,
@@ -20796,7 +20824,7 @@ async function handleChatHistory(h, args) {
20796
20824
  historyBehavior: provider?.historyBehavior,
20797
20825
  scripts: provider?.scripts
20798
20826
  });
20799
- if (supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
20827
+ if (supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.nativeHistory)) {
20800
20828
  const lookup = result.lookup === "workspace" ? "workspace" : "session";
20801
20829
  const messages = Array.isArray(result.messages) ? normalizeNativeHistoryMessages(agentStr, result.messages, result?.providerSessionId) : [];
20802
20830
  const historyProviderSessionId = typeof result?.providerSessionId === "string" ? result.providerSessionId : readHistorySessionIdFromMessages(messages) || historySessionId;
@@ -20877,7 +20905,7 @@ async function handleReadChat(h, args) {
20877
20905
  let selectedStatus = returnedStatus;
20878
20906
  const sessionWorkspace = typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : typeof adapter.workingDir === "string" ? adapter.workingDir : void 0;
20879
20907
  const intendedWorkspace = typeof args?.workspace === "string" ? args.workspace : void 0;
20880
- const supportsNative = supportsCliNativeTranscript(providerType, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory);
20908
+ const supportsNative = supportsCliNativeTranscript(providerType, provider) && isNativeSourceCanonicalHistory(provider?.nativeHistory);
20881
20909
  const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h, adapter.cliType);
20882
20910
  const workspace = sessionWorkspace;
20883
20911
  const nativeHistoryLimit = Math.max(
@@ -20895,7 +20923,7 @@ async function handleReadChat(h, args) {
20895
20923
  if (supportsNative) {
20896
20924
  try {
20897
20925
  nativeHistory = readCliProviderNativeHistory(agentStr, {
20898
- canonicalHistory: provider?.canonicalHistory,
20926
+ canonicalHistory: provider?.nativeHistory,
20899
20927
  historySessionId: nativeHistorySessionId,
20900
20928
  workspace,
20901
20929
  offset: 0,
@@ -20956,7 +20984,7 @@ async function handleReadChat(h, args) {
20956
20984
  });
20957
20985
  const mayProbeLiveCodexWorkspaceNative = adapter.cliType === "codex-cli" && liveCurrentRuntimePtySafe && !(typeof args?.providerSessionId === "string" && args.providerSessionId.trim()) && !(providerSessionId && providerSessionId.trim()) && (!historyProviderSessionId || historyProviderSessionId === nativeHistorySessionId || historyProviderSessionId === historySessionId);
20958
20986
  const liveWorkspaceNativeHistory = mayProbeLiveCodexWorkspaceNative ? readLiveCodexWorkspaceNativeHistory(agentStr, {
20959
- canonicalHistory: provider?.canonicalHistory,
20987
+ canonicalHistory: provider?.nativeHistory,
20960
20988
  workspace,
20961
20989
  offset: 0,
20962
20990
  limit: nativeHistoryLimit,
@@ -21065,7 +21093,7 @@ async function handleReadChat(h, args) {
21065
21093
  returnedStatus: String(selectedStatus || ""),
21066
21094
  selectedMessageSource: messageSource.selected,
21067
21095
  messageSource,
21068
- 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"),
21096
+ 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"),
21069
21097
  parsedMsgCount: parsedRecord.messages.length,
21070
21098
  returnedMsgCount: selectedMessages.length
21071
21099
  },
@@ -21080,9 +21108,9 @@ async function handleReadChat(h, args) {
21080
21108
  const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
21081
21109
  const workspace = typeof h.currentSession?.workspace === "string" ? h.currentSession.workspace : void 0;
21082
21110
  const intendedWorkspace = typeof args?.workspace === "string" ? args.workspace : void 0;
21083
- const supportsNative = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory);
21111
+ const supportsNative = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.nativeHistory);
21084
21112
  const history = supportsNative ? readCliProviderNativeHistory(agentStr, {
21085
- canonicalHistory: provider?.canonicalHistory,
21113
+ canonicalHistory: provider?.nativeHistory,
21086
21114
  historySessionId,
21087
21115
  workspace,
21088
21116
  offset: 0,
@@ -21091,7 +21119,7 @@ async function handleReadChat(h, args) {
21091
21119
  historyBehavior: provider?.historyBehavior,
21092
21120
  scripts: provider?.scripts
21093
21121
  }) : readProviderChatHistory(agentStr, {
21094
- canonicalHistory: provider?.canonicalHistory,
21122
+ canonicalHistory: provider?.nativeHistory,
21095
21123
  historySessionId,
21096
21124
  workspace,
21097
21125
  offset: 0,
@@ -25312,7 +25340,7 @@ ${effect.notification.body || ""}`.trim();
25312
25340
  }
25313
25341
  syncCanonicalSavedHistoryIfNeeded() {
25314
25342
  if (!this.providerSessionId) return false;
25315
- const canonicalHistory = this.provider.canonicalHistory;
25343
+ const canonicalHistory = this.provider.nativeHistory;
25316
25344
  if (!canonicalHistory) return false;
25317
25345
  if (isNativeSourceCanonicalHistory(canonicalHistory)) {
25318
25346
  const cacheKey = [this.type, this.providerSessionId, this.workingDir].join("\0");
@@ -25369,8 +25397,8 @@ ${effect.notification.body || ""}`.trim();
25369
25397
  restorePersistedHistoryFromCurrentSession() {
25370
25398
  if (!this.providerSessionId) return;
25371
25399
  this.syncCanonicalSavedHistoryIfNeeded();
25372
- const restoredHistory = isNativeSourceCanonicalHistory(this.provider.canonicalHistory) ? readProviderChatHistory(this.type, {
25373
- canonicalHistory: this.provider.canonicalHistory,
25400
+ const restoredHistory = isNativeSourceCanonicalHistory(this.provider.nativeHistory) ? readProviderChatHistory(this.type, {
25401
+ canonicalHistory: this.provider.nativeHistory,
25374
25402
  historySessionId: this.providerSessionId,
25375
25403
  workspace: this.workingDir,
25376
25404
  offset: 0,
@@ -27708,10 +27736,13 @@ var KNOWN_PROVIDER_FIELDS = /* @__PURE__ */ new Set([
27708
27736
  "approvalPositiveHints",
27709
27737
  "sessionIdPattern",
27710
27738
  "historyBehavior",
27711
- "canonicalHistory",
27712
- // v1 contract spelling; the loader aliases nativeHistory →
27713
- // canonicalHistory so downstream code reads the legacy name.
27739
+ // v1 canonical field name. The loader fills this in for legacy v0
27740
+ // manifests that ship the old `canonicalHistory` spelling.
27714
27741
  "nativeHistory",
27742
+ // Deprecated v0 alias for `nativeHistory`. Kept in the allowed-keys
27743
+ // list so legacy provider.json manifests don't trip the unknown-key
27744
+ // warning during the one-release deprecation window.
27745
+ "canonicalHistory",
27715
27746
  "autoFixProfile",
27716
27747
  "ideLevelScripts",
27717
27748
  "allowInputDuringGeneration",
@@ -27787,7 +27818,7 @@ function validateProviderDefinition(raw) {
27787
27818
  warnings.push("Extension providers should have extensionId");
27788
27819
  }
27789
27820
  validateCapabilities(provider, controls, errors);
27790
- validateCanonicalHistory(provider.canonicalHistory, errors);
27821
+ validateNativeHistory(provider.nativeHistory, errors);
27791
27822
  validateMeshCoordinator(provider.meshCoordinator, errors);
27792
27823
  for (const control of controls) {
27793
27824
  validateControl(control, errors);
@@ -27875,40 +27906,40 @@ function validateCapabilities(provider, controls, errors) {
27875
27906
  errors.push("providers declaring controls must set capabilities.controls.typedResults=true");
27876
27907
  }
27877
27908
  }
27878
- function validateCanonicalHistory(raw, errors) {
27909
+ function validateNativeHistory(raw, errors) {
27879
27910
  if (raw === void 0) return;
27880
27911
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
27881
- errors.push("canonicalHistory must be an object");
27912
+ errors.push("nativeHistory must be an object");
27882
27913
  return;
27883
27914
  }
27884
- const canonicalHistory = raw;
27885
- const format = canonicalHistory.format;
27915
+ const nativeHistory = raw;
27916
+ const format = nativeHistory.format;
27886
27917
  if (format !== void 0 && (typeof format !== "string" || !format.trim())) {
27887
- errors.push("canonicalHistory.format must be a non-empty string when provided");
27918
+ errors.push("nativeHistory.format must be a non-empty string when provided");
27888
27919
  }
27889
- const watchPath = canonicalHistory.watchPath;
27920
+ const watchPath = nativeHistory.watchPath;
27890
27921
  if (watchPath !== void 0 && (typeof watchPath !== "string" || !watchPath.trim())) {
27891
- errors.push("canonicalHistory.watchPath must be a non-empty string when provided");
27922
+ errors.push("nativeHistory.watchPath must be a non-empty string when provided");
27892
27923
  }
27893
- const mode = canonicalHistory.mode;
27924
+ const mode = nativeHistory.mode;
27894
27925
  if (mode !== void 0 && !["native-source", "materialized-mirror", "disabled"].includes(String(mode))) {
27895
- errors.push("canonicalHistory.mode must be one of: native-source, materialized-mirror, disabled");
27926
+ errors.push("nativeHistory.mode must be one of: native-source, materialized-mirror, disabled");
27896
27927
  }
27897
- const chatContractVersion = canonicalHistory.contractVersion;
27928
+ const chatContractVersion = nativeHistory.contractVersion;
27898
27929
  if (chatContractVersion !== void 0 && chatContractVersion !== "1.0" && chatContractVersion !== "2.0") {
27899
- errors.push(`canonicalHistory.contractVersion must be '1.0' or '2.0' when provided (got ${JSON.stringify(chatContractVersion)})`);
27930
+ errors.push(`nativeHistory.contractVersion must be '1.0' or '2.0' when provided (got ${JSON.stringify(chatContractVersion)})`);
27900
27931
  }
27901
- const scripts = canonicalHistory.scripts;
27932
+ const scripts = nativeHistory.scripts;
27902
27933
  if (scripts === void 0) return;
27903
27934
  if (!scripts || typeof scripts !== "object" || Array.isArray(scripts)) {
27904
- errors.push("canonicalHistory.scripts must be an object");
27935
+ errors.push("nativeHistory.scripts must be an object");
27905
27936
  return;
27906
27937
  }
27907
27938
  const scriptConfig = scripts;
27908
27939
  for (const key of ["readSession", "listSessions"]) {
27909
27940
  const value = scriptConfig[key];
27910
27941
  if (typeof value !== "string" || !value.trim()) {
27911
- errors.push(`canonicalHistory.scripts.${key} must be a non-empty string`);
27942
+ errors.push(`nativeHistory.scripts.${key} must be a non-empty string`);
27912
27943
  }
27913
27944
  }
27914
27945
  }
@@ -29601,8 +29632,12 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
29601
29632
  ...providerFields,
29602
29633
  ...extensionIdPattern instanceof RegExp ? { extensionIdPattern } : {}
29603
29634
  };
29604
- if (normalizedProvider.nativeHistory && !normalizedProvider.canonicalHistory) {
29605
- normalizedProvider.canonicalHistory = normalizedProvider.nativeHistory;
29635
+ const nh = normalizedProvider.nativeHistory;
29636
+ const ch = normalizedProvider.canonicalHistory;
29637
+ if (nh && !ch) {
29638
+ normalizedProvider.canonicalHistory = nh;
29639
+ } else if (ch && !nh) {
29640
+ normalizedProvider.nativeHistory = ch;
29606
29641
  }
29607
29642
  const validation = validateProviderDefinition(normalizedProvider);
29608
29643
  for (const warning of validation.warnings) {
@@ -34298,7 +34333,7 @@ var DaemonCommandRouter = class {
34298
34333
  const requestedProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : typeof args?.activeProviderSessionId === "string" ? args.activeProviderSessionId.trim() : "";
34299
34334
  const providerMeta = this.deps.providerLoader.resolve?.(providerType) || this.deps.providerLoader.getMeta(providerType);
34300
34335
  const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
34301
- canonicalHistory: providerMeta?.canonicalHistory,
34336
+ canonicalHistory: providerMeta?.nativeHistory,
34302
34337
  offset,
34303
34338
  limit,
34304
34339
  historyBehavior: providerMeta?.historyBehavior,