adhdev 0.9.34 → 0.9.35

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
@@ -9954,7 +9954,14 @@ var init_handler = __esm({
9954
9954
  await this._ctx.providerLoader.fetchLatest().catch(() => {
9955
9955
  });
9956
9956
  this._ctx.providerLoader.reload();
9957
- return { success: true };
9957
+ this._ctx.providerLoader.registerToDetector();
9958
+ const refreshedInstances = this._ctx.instanceManager ? this._ctx.instanceManager.refreshProviderDefinitions((providerType) => this._ctx.providerLoader.resolve(providerType)) : 0;
9959
+ const providers = this._ctx.providerLoader.getAll().map((provider) => ({
9960
+ type: provider.type,
9961
+ name: provider.name,
9962
+ category: provider.category
9963
+ }));
9964
+ return { success: true, refreshedInstances, providers };
9958
9965
  }
9959
9966
  return { success: false, error: "ProviderLoader not initialized" };
9960
9967
  }
@@ -11810,6 +11817,8 @@ var init_provider_cli_adapter = __esm({
11810
11817
  messages = [];
11811
11818
  committedMessages = [];
11812
11819
  structuredMessages = [];
11820
+ committedMessagesActivitySignature = "";
11821
+ committedMessagesChangedAt = 0;
11813
11822
  currentStatus = "starting";
11814
11823
  onStatusChange = null;
11815
11824
  responseBuffer = "";
@@ -11891,10 +11900,35 @@ var init_provider_cli_adapter = __esm({
11891
11900
  providerResolutionMeta;
11892
11901
  static FINISH_RETRY_DELAY_MS = 300;
11893
11902
  static MAX_FINISH_RETRIES = 2;
11903
+ buildCommittedMessagesActivitySignature() {
11904
+ const last = this.committedMessages[this.committedMessages.length - 1];
11905
+ return [
11906
+ String(this.committedMessages.length),
11907
+ String(last?.role || ""),
11908
+ String(last?.kind || ""),
11909
+ String(last?.senderName || ""),
11910
+ String(last?.timestamp || ""),
11911
+ String(last?.receivedAt || ""),
11912
+ normalizeComparableMessageContent(last?.content || "").slice(-240)
11913
+ ].join("|");
11914
+ }
11894
11915
  syncMessageViews() {
11916
+ const signature = this.buildCommittedMessagesActivitySignature();
11917
+ if (signature !== this.committedMessagesActivitySignature) {
11918
+ this.committedMessagesActivitySignature = signature;
11919
+ this.committedMessagesChangedAt = Date.now();
11920
+ }
11895
11921
  this.messages = [...this.committedMessages];
11896
11922
  this.structuredMessages = [...this.committedMessages];
11897
11923
  }
11924
+ getLastCommittedMessageActivityAt() {
11925
+ const last = this.committedMessages[this.committedMessages.length - 1];
11926
+ const messageTime = Math.max(
11927
+ typeof last?.receivedAt === "number" && Number.isFinite(last.receivedAt) ? last.receivedAt : 0,
11928
+ typeof last?.timestamp === "number" && Number.isFinite(last.timestamp) ? last.timestamp : 0
11929
+ );
11930
+ return Math.max(messageTime, this.committedMessagesChangedAt || 0);
11931
+ }
11898
11932
  readTerminalScreenText(now = Date.now()) {
11899
11933
  const screenText = this.terminalScreen.getText() || "";
11900
11934
  this.lastScreenText = screenText;
@@ -12034,9 +12068,16 @@ var init_provider_cli_adapter = __esm({
12034
12068
  /** Inject CLI scripts after construction (e.g. when resolved by ProviderLoader) */
12035
12069
  setCliScripts(scripts) {
12036
12070
  this.cliScripts = scripts;
12071
+ this.parsedStatusCache = null;
12072
+ this.parseErrorMessage = null;
12037
12073
  const scriptNames = listCliScriptNames(scripts);
12038
12074
  LOG.info("CLI", `[${this.cliType}] CLI scripts injected: [${scriptNames.join(", ")}]`);
12039
12075
  }
12076
+ /** Refresh provider scripts/config used by this adapter without restarting the PTY runtime. */
12077
+ refreshProviderDefinition(provider) {
12078
+ this.provider = provider;
12079
+ this.setCliScripts(provider.scripts || {});
12080
+ }
12040
12081
  updateRuntimeSettings(settings) {
12041
12082
  this.runtimeSettings = { ...settings };
12042
12083
  }
@@ -14058,6 +14099,11 @@ var init_cli_provider_instance = __esm({
14058
14099
  launchMode;
14059
14100
  startedAt = Date.now();
14060
14101
  onProviderSessionResolved;
14102
+ refreshProviderDefinition(provider) {
14103
+ if (provider.type !== this.type || provider.category !== "cli") return;
14104
+ this.provider = provider;
14105
+ this.adapter.refreshProviderDefinition(provider);
14106
+ }
14061
14107
  // ─── Lifecycle ─────────────────────────────────
14062
14108
  async init(context) {
14063
14109
  this.context = context;
@@ -14268,9 +14314,11 @@ var init_cli_provider_instance = __esm({
14268
14314
  const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
14269
14315
  const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
14270
14316
  const runtime = this.adapter.getRuntimeMetadata();
14317
+ const lastCommittedMessageActivityAt = typeof this.adapter.getLastCommittedMessageActivityAt === "function" ? this.adapter.getLastCommittedMessageActivityAt() : 0;
14271
14318
  return {
14272
14319
  id: this.instanceId,
14273
14320
  status: visibleStatus,
14321
+ lastMessageAt: lastCommittedMessageActivityAt || void 0,
14274
14322
  runtimeLifecycle: runtime?.lifecycle ?? null,
14275
14323
  runtimeSurfaceKind: runtime?.surfaceKind,
14276
14324
  runtimeRestoredFromStorage: runtime?.restoredFromStorage === true,
@@ -39977,6 +40025,9 @@ function projectHotChatSessionStatesFromProviderState(state) {
39977
40025
  const project = (item) => ({
39978
40026
  id: item.instanceId,
39979
40027
  status: item.activeChat?.status || item.status,
40028
+ unread: item.unread,
40029
+ inboxBucket: item.inboxBucket,
40030
+ lastMessageAt: item.lastMessageAt ?? item.activeChat?.lastMessageAt,
39980
40031
  runtimeLifecycle: item.runtime?.lifecycle ?? null,
39981
40032
  runtimeSurfaceKind: item.runtime?.surfaceKind,
39982
40033
  runtimeRestoredFromStorage: item.runtime?.restoredFromStorage === true,
@@ -40189,6 +40240,17 @@ var init_provider_instance_manager = __esm({
40189
40240
  }
40190
40241
  return updated;
40191
40242
  }
40243
+ refreshProviderDefinitions(resolveProvider) {
40244
+ let refreshed = 0;
40245
+ for (const instance of this.instances.values()) {
40246
+ if (typeof instance.refreshProviderDefinition !== "function") continue;
40247
+ const provider = resolveProvider(instance.type);
40248
+ if (!provider || typeof provider !== "object") continue;
40249
+ instance.refreshProviderDefinition(provider);
40250
+ refreshed += 1;
40251
+ }
40252
+ return refreshed;
40253
+ }
40192
40254
  // ─── cleanup ──────────────────────────────────────
40193
40255
  /**
40194
40256
  * All terminate
@@ -44471,20 +44533,7 @@ var init_dev_server = __esm({
44471
44533
  async handleReload(_req, res) {
44472
44534
  try {
44473
44535
  this.providerLoader.reload();
44474
- let refreshedInstances = 0;
44475
- if (this.instanceManager) {
44476
- for (const id of this.instanceManager.listInstanceIds()) {
44477
- const instance = this.instanceManager.getInstance(id);
44478
- const providerType = typeof instance?.type === "string" ? instance.type : "";
44479
- if (!providerType) continue;
44480
- const resolved = this.providerLoader.resolve(providerType);
44481
- if (!resolved) continue;
44482
- if (instance && typeof instance === "object" && "provider" in instance) {
44483
- instance.provider = resolved;
44484
- refreshedInstances += 1;
44485
- }
44486
- }
44487
- }
44536
+ const refreshedInstances = this.instanceManager ? this.instanceManager.refreshProviderDefinitions((providerType) => this.providerLoader.resolve(providerType)) : 0;
44488
44537
  const providers = this.providerLoader.getAll().map((p) => ({
44489
44538
  type: p.type,
44490
44539
  name: p.name,
@@ -56400,7 +56449,7 @@ var init_adhdev_daemon = __esm({
56400
56449
  init_version();
56401
56450
  init_src();
56402
56451
  init_runtime_defaults();
56403
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.34" });
56452
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.35" });
56404
56453
  AdhdevDaemon = class _AdhdevDaemon {
56405
56454
  localHttpServer = null;
56406
56455
  localWss = null;