@adhdev/daemon-core 0.9.82-rc.324 → 0.9.82-rc.326

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
@@ -313,10 +313,10 @@ function readInjected(value) {
313
313
  }
314
314
  function getDaemonBuildInfo() {
315
315
  if (cached) return cached;
316
- const commit = readInjected(true ? "a0aeebdac30d9abea5b46e3f2618f864bbff19d0" : void 0) ?? "unknown";
317
- const commitShort = readInjected(true ? "a0aeebda" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
318
- const version = readInjected(true ? "0.9.82-rc.324" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
319
- const builtAt = readInjected(true ? "2026-06-19T07:37:54.347Z" : void 0);
316
+ const commit = readInjected(true ? "9ee42155ad394578ced8959105e9a2c35d0af11b" : void 0) ?? "unknown";
317
+ const commitShort = readInjected(true ? "9ee42155" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
318
+ const version = readInjected(true ? "0.9.82-rc.326" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
319
+ const builtAt = readInjected(true ? "2026-06-19T10:16:19.073Z" : void 0);
320
320
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
321
321
  return cached;
322
322
  }
@@ -10134,6 +10134,644 @@ var init_mesh_events_coordinator = __esm({
10134
10134
  }
10135
10135
  });
10136
10136
 
10137
+ // src/providers/io-contracts.ts
10138
+ function normalizeInputEnvelope(input) {
10139
+ const normalized = normalizeInputEnvelopePayload(input);
10140
+ const textFallback = normalized.textFallback ?? flattenInputParts(normalized.parts);
10141
+ return {
10142
+ parts: normalized.parts,
10143
+ textFallback,
10144
+ ...normalized.metadata ? { metadata: normalized.metadata } : {}
10145
+ };
10146
+ }
10147
+ function normalizeMessageParts(content) {
10148
+ if (typeof content === "string") return [{ type: "text", text: content }];
10149
+ if (!Array.isArray(content)) {
10150
+ if (content && typeof content === "object" && typeof content.text === "string") {
10151
+ return [{ type: "text", text: String(content.text) }];
10152
+ }
10153
+ return [];
10154
+ }
10155
+ const parts = [];
10156
+ for (const raw of content) {
10157
+ if (typeof raw === "string") {
10158
+ parts.push({ type: "text", text: raw });
10159
+ continue;
10160
+ }
10161
+ if (!raw || typeof raw !== "object") continue;
10162
+ const part = normalizeMessagePartObject(raw);
10163
+ if (part) parts.push(part);
10164
+ }
10165
+ return parts;
10166
+ }
10167
+ function flattenMessageParts(parts) {
10168
+ return parts.map((part) => {
10169
+ if (part.type === "text") return part.text;
10170
+ if (part.type === "resource") return part.resource.text || "";
10171
+ if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
10172
+ if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
10173
+ if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
10174
+ if (part.type === "resource_link") return [part.name, part.description].filter(Boolean).join("\n");
10175
+ return "";
10176
+ }).filter((value) => value.length > 0).join("\n");
10177
+ }
10178
+ function normalizeInputEnvelopePayload(input) {
10179
+ if (typeof input === "string") {
10180
+ return { parts: [{ type: "text", text: input }], textFallback: input };
10181
+ }
10182
+ if (!input || typeof input !== "object") {
10183
+ return { parts: [], textFallback: "" };
10184
+ }
10185
+ const record = input;
10186
+ const nestedInput = record.input;
10187
+ if (nestedInput && typeof nestedInput === "object") {
10188
+ const nested = nestedInput;
10189
+ return {
10190
+ parts: normalizeInputParts(nested.parts ?? nested.prompt),
10191
+ textFallback: typeof nested.textFallback === "string" ? nested.textFallback : void 0,
10192
+ metadata: normalizeInputMetadata(nested.metadata)
10193
+ };
10194
+ }
10195
+ const directText = typeof record.text === "string" ? record.text : typeof record.message === "string" ? record.message : void 0;
10196
+ if (directText !== void 0) {
10197
+ return { parts: [{ type: "text", text: directText }], textFallback: directText };
10198
+ }
10199
+ const directParts = normalizeInputParts(record.parts ?? record.prompt);
10200
+ return {
10201
+ parts: directParts,
10202
+ textFallback: typeof record.textFallback === "string" ? record.textFallback : void 0,
10203
+ metadata: normalizeInputMetadata(record.metadata)
10204
+ };
10205
+ }
10206
+ function normalizeInputMetadata(value) {
10207
+ if (!value || typeof value !== "object") return void 0;
10208
+ const record = value;
10209
+ const metadata = {};
10210
+ if (record.source === "dashboard" || record.source === "shortcut_api" || record.source === "provider_script" || record.source === "session_replay") {
10211
+ metadata.source = record.source;
10212
+ }
10213
+ if (typeof record.clientTimestamp === "number" && Number.isFinite(record.clientTimestamp)) {
10214
+ metadata.clientTimestamp = record.clientTimestamp;
10215
+ }
10216
+ return Object.keys(metadata).length > 0 ? metadata : void 0;
10217
+ }
10218
+ function normalizeInputParts(value) {
10219
+ if (!Array.isArray(value)) return [];
10220
+ const parts = [];
10221
+ for (const raw of value) {
10222
+ if (typeof raw === "string") {
10223
+ parts.push({ type: "text", text: raw });
10224
+ continue;
10225
+ }
10226
+ if (!raw || typeof raw !== "object") continue;
10227
+ const part = normalizeInputPartObject(raw);
10228
+ if (part) parts.push(part);
10229
+ }
10230
+ return parts;
10231
+ }
10232
+ function normalizeInputPartObject(raw) {
10233
+ const type = raw.type;
10234
+ if (type === "text" && typeof raw.text === "string") {
10235
+ return { type, text: raw.text };
10236
+ }
10237
+ if (type === "image" && typeof raw.mimeType === "string") {
10238
+ return {
10239
+ type,
10240
+ mimeType: raw.mimeType,
10241
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10242
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10243
+ ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
10244
+ };
10245
+ }
10246
+ if (type === "audio" && typeof raw.mimeType === "string") {
10247
+ return {
10248
+ type,
10249
+ mimeType: raw.mimeType,
10250
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10251
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10252
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
10253
+ };
10254
+ }
10255
+ if (type === "video" && typeof raw.mimeType === "string") {
10256
+ return {
10257
+ type,
10258
+ mimeType: raw.mimeType,
10259
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10260
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10261
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
10262
+ ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
10263
+ };
10264
+ }
10265
+ if (type === "resource" && typeof raw.uri === "string") {
10266
+ return {
10267
+ type,
10268
+ uri: raw.uri,
10269
+ ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
10270
+ ...typeof raw.name === "string" ? { name: raw.name } : {},
10271
+ ...typeof raw.text === "string" ? { text: raw.text } : {},
10272
+ ...typeof raw.data === "string" ? { data: raw.data } : {}
10273
+ };
10274
+ }
10275
+ if (type === "resource_link" && typeof raw.uri === "string") {
10276
+ return {
10277
+ type,
10278
+ uri: raw.uri,
10279
+ name: typeof raw.name === "string" ? raw.name : getUriDisplayName(raw.uri, "resource"),
10280
+ ...typeof raw.title === "string" ? { title: raw.title } : {},
10281
+ ...typeof raw.description === "string" ? { description: raw.description } : {},
10282
+ ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
10283
+ ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
10284
+ ...normalizeAnnotationsProperty(raw.annotations)
10285
+ };
10286
+ }
10287
+ return null;
10288
+ }
10289
+ function normalizeMessagePartObject(raw) {
10290
+ const type = raw.type;
10291
+ if (type === "text" && typeof raw.text === "string") {
10292
+ return { type, text: raw.text };
10293
+ }
10294
+ if (type === "image" && typeof raw.mimeType === "string") {
10295
+ return {
10296
+ type,
10297
+ mimeType: raw.mimeType,
10298
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10299
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10300
+ ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
10301
+ };
10302
+ }
10303
+ if (type === "audio" && typeof raw.mimeType === "string") {
10304
+ return {
10305
+ type,
10306
+ mimeType: raw.mimeType,
10307
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10308
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10309
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
10310
+ };
10311
+ }
10312
+ if (type === "video" && typeof raw.mimeType === "string") {
10313
+ return {
10314
+ type,
10315
+ mimeType: raw.mimeType,
10316
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10317
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10318
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
10319
+ ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
10320
+ };
10321
+ }
10322
+ if (type === "resource_link" && typeof raw.uri === "string" && typeof raw.name === "string") {
10323
+ return {
10324
+ type,
10325
+ uri: raw.uri,
10326
+ name: raw.name,
10327
+ ...typeof raw.title === "string" ? { title: raw.title } : {},
10328
+ ...typeof raw.description === "string" ? { description: raw.description } : {},
10329
+ ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
10330
+ ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
10331
+ ...normalizeAnnotationsProperty(raw.annotations)
10332
+ };
10333
+ }
10334
+ if (type === "resource" && raw.resource && typeof raw.resource === "object") {
10335
+ const resource = raw.resource;
10336
+ if (typeof resource.uri !== "string") return null;
10337
+ return {
10338
+ type,
10339
+ resource: {
10340
+ uri: resource.uri,
10341
+ ...typeof resource.mimeType === "string" || resource.mimeType === null ? { mimeType: resource.mimeType } : {},
10342
+ ...typeof resource.text === "string" ? { text: resource.text } : {},
10343
+ ...typeof resource.blob === "string" ? { blob: resource.blob } : {}
10344
+ }
10345
+ };
10346
+ }
10347
+ return null;
10348
+ }
10349
+ function flattenInputParts(parts) {
10350
+ return parts.map((part) => {
10351
+ if (part.type === "text") return part.text;
10352
+ if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
10353
+ if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
10354
+ if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
10355
+ if (part.type === "resource_link") return [part.title, part.name, part.description, part.uri].filter(Boolean).join("\n");
10356
+ if (part.type === "resource") return part.text || part.name || part.uri;
10357
+ return "";
10358
+ }).filter((value) => value.length > 0).join("\n");
10359
+ }
10360
+ function getUriDisplayName(uri, fallback) {
10361
+ try {
10362
+ const pathname = uri.startsWith("file://") ? new URL(uri).pathname : uri;
10363
+ return pathname.split(/[\\/]/).filter(Boolean).pop() || fallback;
10364
+ } catch {
10365
+ return uri.split(/[\\/]/).filter(Boolean).pop() || fallback;
10366
+ }
10367
+ }
10368
+ function normalizeAnnotationsProperty(value) {
10369
+ if (!value || typeof value !== "object") return {};
10370
+ const record = value;
10371
+ const annotations = {};
10372
+ if (Array.isArray(record.audience)) {
10373
+ const audience = record.audience.filter((item) => item === "user" || item === "assistant");
10374
+ if (audience.length > 0) annotations.audience = audience;
10375
+ }
10376
+ if (typeof record.priority === "number" && Number.isFinite(record.priority)) {
10377
+ annotations.priority = record.priority;
10378
+ }
10379
+ return Object.keys(annotations).length > 0 ? { annotations } : {};
10380
+ }
10381
+ var init_io_contracts = __esm({
10382
+ "src/providers/io-contracts.ts"() {
10383
+ "use strict";
10384
+ }
10385
+ });
10386
+
10387
+ // src/providers/contracts.ts
10388
+ function flattenContent(content) {
10389
+ if (typeof content === "string") return content;
10390
+ return flattenMessageParts(normalizeMessageParts(content));
10391
+ }
10392
+ var init_contracts = __esm({
10393
+ "src/providers/contracts.ts"() {
10394
+ "use strict";
10395
+ init_io_contracts();
10396
+ init_io_contracts();
10397
+ }
10398
+ });
10399
+
10400
+ // src/providers/chat-message-normalization.ts
10401
+ function extractFinalSummaryFromMessages(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
10402
+ if (!Array.isArray(messages) || messages.length === 0) return "";
10403
+ for (let i = messages.length - 1; i >= 0; i--) {
10404
+ const msg = messages[i];
10405
+ if (!msg) continue;
10406
+ const classification = classifyChatMessageVisibility(msg);
10407
+ if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
10408
+ const text = flattenContent(msg.content).trim();
10409
+ if (text) return text.slice(0, maxChars);
10410
+ }
10411
+ }
10412
+ return "";
10413
+ }
10414
+ function readChatMessageTimestampIso(message) {
10415
+ if (!message) return void 0;
10416
+ const record = message;
10417
+ for (const value of [record.timestamp, record.createdAt, record.created_at, record.updatedAt, record.time]) {
10418
+ if (typeof value === "number" && Number.isFinite(value)) {
10419
+ const ms = value > 1e10 ? value : value * 1e3;
10420
+ return new Date(ms).toISOString();
10421
+ }
10422
+ if (typeof value === "string" && value.trim()) {
10423
+ const ms = new Date(value.trim()).getTime();
10424
+ if (Number.isFinite(ms)) return new Date(ms).toISOString();
10425
+ }
10426
+ }
10427
+ return void 0;
10428
+ }
10429
+ function extractFinalAssistantSummaryEvidence(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
10430
+ if (!Array.isArray(messages) || messages.length === 0) return { finalSummary: "" };
10431
+ for (let i = messages.length - 1; i >= 0; i--) {
10432
+ const msg = messages[i];
10433
+ if (!msg) continue;
10434
+ const classification = classifyChatMessageVisibility(msg);
10435
+ if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
10436
+ const text = flattenContent(msg.content).trim();
10437
+ if (text) {
10438
+ return {
10439
+ finalSummary: text.slice(0, maxChars),
10440
+ transcriptMessageAt: readChatMessageTimestampIso(msg)
10441
+ };
10442
+ }
10443
+ }
10444
+ }
10445
+ return { finalSummary: "" };
10446
+ }
10447
+ function canonicalizeKindHint(value) {
10448
+ return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
10449
+ }
10450
+ function resolveBuiltinOrAliasKind(kind) {
10451
+ if (typeof kind !== "string") return null;
10452
+ const normalizedKind = canonicalizeKindHint(kind);
10453
+ if (!normalizedKind) return null;
10454
+ if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
10455
+ return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
10456
+ }
10457
+ function inferHintKind(value) {
10458
+ const direct = resolveBuiltinOrAliasKind(value);
10459
+ if (direct) return direct;
10460
+ if (typeof value !== "string") return null;
10461
+ const normalized = canonicalizeKindHint(value);
10462
+ if (!normalized) return null;
10463
+ if (/thought|thinking|reasoning/.test(normalized)) return "thought";
10464
+ if (/tool/.test(normalized)) return "tool";
10465
+ if (/terminal|command|shell|console/.test(normalized)) return "terminal";
10466
+ return null;
10467
+ }
10468
+ function inferKindFromToolCalls(message) {
10469
+ const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
10470
+ if (toolCalls.length === 0) return null;
10471
+ if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
10472
+ if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
10473
+ if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
10474
+ return "terminal";
10475
+ }
10476
+ return "tool";
10477
+ }
10478
+ function inferMissingChatMessageKind(message) {
10479
+ const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
10480
+ if (role === "system") return "system";
10481
+ const meta = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
10482
+ const hintCandidates = [
10483
+ message?._sub,
10484
+ message?._type,
10485
+ meta?.label,
10486
+ typeof message?.senderName === "string" ? message.senderName : void 0
10487
+ ];
10488
+ for (const candidate of hintCandidates) {
10489
+ const inferred = inferHintKind(candidate);
10490
+ if (inferred) return inferred;
10491
+ }
10492
+ const inferredFromToolCalls = inferKindFromToolCalls(message);
10493
+ if (inferredFromToolCalls) return inferredFromToolCalls;
10494
+ return null;
10495
+ }
10496
+ function isBuiltinChatMessageKind(kind) {
10497
+ return resolveBuiltinOrAliasKind(kind) !== null;
10498
+ }
10499
+ function normalizeChatMessageKind(kind, role) {
10500
+ const resolvedKind = resolveBuiltinOrAliasKind(kind);
10501
+ if (resolvedKind) return resolvedKind;
10502
+ const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
10503
+ return normalizedRole === "system" ? "system" : "standard";
10504
+ }
10505
+ function resolveChatMessageKind(message) {
10506
+ const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
10507
+ if (explicitKind) return explicitKind;
10508
+ const inferredKind = inferMissingChatMessageKind(message);
10509
+ if (inferredKind) return inferredKind;
10510
+ return normalizeChatMessageKind(message?.kind, message?.role);
10511
+ }
10512
+ function buildChatMessage(message) {
10513
+ return {
10514
+ ...message,
10515
+ kind: resolveChatMessageKind(message)
10516
+ };
10517
+ }
10518
+ function buildSystemChatMessage(message) {
10519
+ return buildChatMessage({
10520
+ ...message,
10521
+ role: "system",
10522
+ kind: message?.kind || "system"
10523
+ });
10524
+ }
10525
+ function buildRuntimeSystemChatMessage(message) {
10526
+ return buildSystemChatMessage({
10527
+ ...message,
10528
+ senderName: typeof message?.senderName === "string" && message.senderName.trim() ? message.senderName : "System"
10529
+ });
10530
+ }
10531
+ function buildAssistantChatMessage(message) {
10532
+ return buildChatMessage({
10533
+ ...message,
10534
+ role: "assistant",
10535
+ kind: message?.kind || "standard"
10536
+ });
10537
+ }
10538
+ function buildThoughtChatMessage(message) {
10539
+ return buildAssistantChatMessage({
10540
+ ...message,
10541
+ kind: message?.kind || "thought"
10542
+ });
10543
+ }
10544
+ function buildToolChatMessage(message) {
10545
+ return buildAssistantChatMessage({
10546
+ ...message,
10547
+ kind: message?.kind || "tool"
10548
+ });
10549
+ }
10550
+ function buildTerminalChatMessage(message) {
10551
+ return buildAssistantChatMessage({
10552
+ ...message,
10553
+ kind: message?.kind || "terminal"
10554
+ });
10555
+ }
10556
+ function buildUserChatMessage(message) {
10557
+ return buildChatMessage({
10558
+ ...message,
10559
+ role: "user",
10560
+ kind: message?.kind || "standard"
10561
+ });
10562
+ }
10563
+ function normalizeChatMessage(message) {
10564
+ return buildChatMessage(message);
10565
+ }
10566
+ function normalizeChatMessages(messages) {
10567
+ return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
10568
+ }
10569
+ function readMessageMeta(message) {
10570
+ const meta = message?.meta;
10571
+ return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : null;
10572
+ }
10573
+ function readStringField(value) {
10574
+ return typeof value === "string" ? value.trim().toLowerCase() : "";
10575
+ }
10576
+ function readRecordField(message, meta, key) {
10577
+ const record = message;
10578
+ return record[key] ?? meta?.[key];
10579
+ }
10580
+ function readVisibilityField(message, meta) {
10581
+ return readStringField(readRecordField(message, meta, "visibility"));
10582
+ }
10583
+ function readTranscriptVisibilityField(message, meta) {
10584
+ const record = message;
10585
+ return readStringField(record.transcriptVisibility ?? meta?.transcriptVisibility ?? record.visibility ?? meta?.visibility);
10586
+ }
10587
+ function hasBooleanMarker(message, meta, keys) {
10588
+ const record = message;
10589
+ return keys.some((key) => record[key] === true || meta?.[key] === true);
10590
+ }
10591
+ function isActivityKind(kind) {
10592
+ return kind === "thought" || kind === "tool" || kind === "terminal";
10593
+ }
10594
+ function isOrdinaryVisibleTurn(message, role, kind) {
10595
+ if (role === "user" || role === "human") return kind === "standard" || kind === "";
10596
+ if (role === "assistant") return kind === "standard" || kind === "";
10597
+ return false;
10598
+ }
10599
+ function classifyChatMessageVisibility(message) {
10600
+ if (!message) {
10601
+ return {
10602
+ surface: "internal",
10603
+ isUserFacing: false,
10604
+ isActivityFacing: false,
10605
+ isInternal: true,
10606
+ explicitUserFacing: false,
10607
+ explicitHidden: true,
10608
+ role: "",
10609
+ kind: "standard",
10610
+ visibility: "",
10611
+ transcriptVisibility: "",
10612
+ audience: "",
10613
+ source: ""
10614
+ };
10615
+ }
10616
+ const meta = readMessageMeta(message);
10617
+ const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
10618
+ const kind = resolveChatMessageKind(message);
10619
+ const visibility = readVisibilityField(message, meta);
10620
+ const transcriptVisibility = readTranscriptVisibilityField(message, meta);
10621
+ const audience = readStringField(readRecordField(message, meta, "audience"));
10622
+ const source = readStringField(readRecordField(message, meta, "source"));
10623
+ const explicitHidden = EXPLICIT_HIDDEN_VISIBILITIES.has(visibility) || EXPLICIT_HIDDEN_VISIBILITIES.has(transcriptVisibility) || HIDDEN_AUDIENCES.has(audience) || hasBooleanMarker(message, meta, ["hidden", "internal", "isInternal", "debug", "statusOnly", "controlOnly"]);
10624
+ const explicitUserFacing = EXPLICIT_VISIBLE_VISIBILITIES.has(visibility) || EXPLICIT_VISIBLE_VISIBILITIES.has(transcriptVisibility) || audience === "chat" || hasBooleanMarker(message, meta, ["userFacing"]);
10625
+ if (explicitHidden) {
10626
+ const activityLike = isActivityKind(kind) || ACTIVITY_SOURCE_SET.has(source);
10627
+ return {
10628
+ surface: activityLike ? "activity" : "internal",
10629
+ isUserFacing: false,
10630
+ isActivityFacing: activityLike,
10631
+ isInternal: !activityLike,
10632
+ explicitUserFacing,
10633
+ explicitHidden,
10634
+ role,
10635
+ kind,
10636
+ visibility,
10637
+ transcriptVisibility,
10638
+ audience,
10639
+ source
10640
+ };
10641
+ }
10642
+ if (explicitUserFacing) {
10643
+ return {
10644
+ surface: "chat",
10645
+ isUserFacing: true,
10646
+ isActivityFacing: false,
10647
+ isInternal: false,
10648
+ explicitUserFacing,
10649
+ explicitHidden,
10650
+ role,
10651
+ kind,
10652
+ visibility,
10653
+ transcriptVisibility,
10654
+ audience,
10655
+ source
10656
+ };
10657
+ }
10658
+ if (INTERNAL_SOURCE_SET.has(source) || role === "system" || kind === "system") {
10659
+ return {
10660
+ surface: "internal",
10661
+ isUserFacing: false,
10662
+ isActivityFacing: false,
10663
+ isInternal: true,
10664
+ explicitUserFacing,
10665
+ explicitHidden,
10666
+ role,
10667
+ kind,
10668
+ visibility,
10669
+ transcriptVisibility,
10670
+ audience,
10671
+ source
10672
+ };
10673
+ }
10674
+ if (ACTIVITY_SOURCE_SET.has(source) || isActivityKind(kind)) {
10675
+ return {
10676
+ surface: "activity",
10677
+ isUserFacing: false,
10678
+ isActivityFacing: true,
10679
+ isInternal: false,
10680
+ explicitUserFacing,
10681
+ explicitHidden,
10682
+ role,
10683
+ kind,
10684
+ visibility,
10685
+ transcriptVisibility,
10686
+ audience,
10687
+ source
10688
+ };
10689
+ }
10690
+ const isUserFacing = isOrdinaryVisibleTurn(message, role, kind);
10691
+ return {
10692
+ surface: isUserFacing ? "chat" : "internal",
10693
+ isUserFacing,
10694
+ isActivityFacing: false,
10695
+ isInternal: !isUserFacing,
10696
+ explicitUserFacing,
10697
+ explicitHidden,
10698
+ role,
10699
+ kind,
10700
+ visibility,
10701
+ transcriptVisibility,
10702
+ audience,
10703
+ source
10704
+ };
10705
+ }
10706
+ function isUserFacingChatMessage(message) {
10707
+ return classifyChatMessageVisibility(message).isUserFacing;
10708
+ }
10709
+ function isActivityChatMessage(message) {
10710
+ return classifyChatMessageVisibility(message).isActivityFacing;
10711
+ }
10712
+ function isInternalChatMessage(message) {
10713
+ return classifyChatMessageVisibility(message).isInternal;
10714
+ }
10715
+ function filterUserFacingChatMessages(messages) {
10716
+ return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
10717
+ }
10718
+ function filterActivityChatMessages(messages) {
10719
+ return (Array.isArray(messages) ? messages : []).filter((message) => isActivityChatMessage(message));
10720
+ }
10721
+ function filterInternalChatMessages(messages) {
10722
+ return (Array.isArray(messages) ? messages : []).filter((message) => isInternalChatMessage(message));
10723
+ }
10724
+ function filterChatMessagesByVisibility(messages, surface) {
10725
+ return (Array.isArray(messages) ? messages : []).filter((message) => classifyChatMessageVisibility(message).surface === surface);
10726
+ }
10727
+ var DEFAULT_FINAL_SUMMARY_MAX_CHARS, BUILTIN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_VISIBILITIES, CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES, CHAT_MESSAGE_AUDIENCES, CHAT_MESSAGE_SOURCES, CHAT_MESSAGE_ACTIVITY_SOURCES, CHAT_MESSAGE_INTERNAL_SOURCES, KNOWN_CHAT_MESSAGE_KINDS, CHAT_MESSAGE_KIND_ALIASES, EXPLICIT_HIDDEN_VISIBILITIES, EXPLICIT_VISIBLE_VISIBILITIES, HIDDEN_AUDIENCES, ACTIVITY_SOURCE_SET, INTERNAL_SOURCE_SET;
10728
+ var init_chat_message_normalization = __esm({
10729
+ "src/providers/chat-message-normalization.ts"() {
10730
+ "use strict";
10731
+ init_contracts();
10732
+ DEFAULT_FINAL_SUMMARY_MAX_CHARS = 4e3;
10733
+ BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
10734
+ CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
10735
+ CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
10736
+ CHAT_MESSAGE_AUDIENCES = ["chat", "debug", "trace", "internal"];
10737
+ CHAT_MESSAGE_SOURCES = [
10738
+ "assistant_text",
10739
+ "tool_call",
10740
+ "terminal_command",
10741
+ "runtime_activity",
10742
+ "runtime_status",
10743
+ "provider_chrome",
10744
+ "control"
10745
+ ];
10746
+ CHAT_MESSAGE_ACTIVITY_SOURCES = ["tool_call", "terminal_command", "runtime_activity"];
10747
+ CHAT_MESSAGE_INTERNAL_SOURCES = ["runtime_status", "provider_chrome", "control"];
10748
+ KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
10749
+ CHAT_MESSAGE_KIND_ALIASES = {
10750
+ text: "standard",
10751
+ message: "standard",
10752
+ assistant: "standard",
10753
+ thinking: "thought",
10754
+ think: "thought",
10755
+ reasoning: "thought",
10756
+ reason: "thought",
10757
+ toolcall: "tool",
10758
+ tool_call: "tool",
10759
+ tooluse: "tool",
10760
+ tool_use: "tool",
10761
+ action: "tool",
10762
+ command: "terminal",
10763
+ cmd: "terminal",
10764
+ shell: "terminal",
10765
+ console: "terminal"
10766
+ };
10767
+ EXPLICIT_HIDDEN_VISIBILITIES = /* @__PURE__ */ new Set(["hidden", "debug", "internal"]);
10768
+ EXPLICIT_VISIBLE_VISIBILITIES = /* @__PURE__ */ new Set(["visible", "user", "chat"]);
10769
+ HIDDEN_AUDIENCES = /* @__PURE__ */ new Set(["debug", "trace", "internal"]);
10770
+ ACTIVITY_SOURCE_SET = new Set(CHAT_MESSAGE_ACTIVITY_SOURCES);
10771
+ INTERNAL_SOURCE_SET = new Set(CHAT_MESSAGE_INTERNAL_SOURCES);
10772
+ }
10773
+ });
10774
+
10137
10775
  // src/mesh/mesh-reconcile-loop.ts
10138
10776
  function resolveReconcileIntervalMs() {
10139
10777
  const raw = readNonEmptyString2(process.env.MESH_RECONCILE_INTERVAL_MS);
@@ -10237,6 +10875,15 @@ async function runMeshReconcileTick(components) {
10237
10875
  LOG.warn("MeshReconcile", `Pending-claim recovery trigger failed for mesh ${mesh.id}: ${e?.message || e}`);
10238
10876
  }
10239
10877
  }
10878
+ for (const mesh of listMeshes()) {
10879
+ const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
10880
+ if (!daemonHostsMesh(mesh, selfIds)) continue;
10881
+ try {
10882
+ await reconcileUnterminatedDirectDispatches(components, mesh, selfIds, localDaemonId);
10883
+ } catch (e) {
10884
+ LOG.warn("MeshReconcile", `Completion reconcile failed for mesh ${mesh.id}: ${e?.message || e}`);
10885
+ }
10886
+ }
10240
10887
  const coordinators = findLiveCoordinators(components);
10241
10888
  if (coordinators.length === 0) {
10242
10889
  return;
@@ -10330,6 +10977,95 @@ async function pullRemoteNodeQueues(components, mesh, localDaemonId, candidateDa
10330
10977
  }
10331
10978
  }
10332
10979
  }
10980
+ function unwrapReadChatPayload(raw) {
10981
+ let cursor = raw;
10982
+ for (let depth = 0; depth < 4 && cursor && typeof cursor === "object"; depth++) {
10983
+ const record = cursor;
10984
+ if (Array.isArray(record.messages)) return record;
10985
+ if (record.payload && typeof record.payload === "object") {
10986
+ cursor = record.payload;
10987
+ continue;
10988
+ }
10989
+ if (record.result && typeof record.result === "object") {
10990
+ cursor = record.result;
10991
+ continue;
10992
+ }
10993
+ if (record.data && typeof record.data === "object") {
10994
+ cursor = record.data;
10995
+ continue;
10996
+ }
10997
+ break;
10998
+ }
10999
+ return cursor && typeof cursor === "object" ? cursor : null;
11000
+ }
11001
+ function readChatPayloadStatus(payload) {
11002
+ return readNonEmptyString2(payload?.status).toLowerCase();
11003
+ }
11004
+ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds, localDaemonId) {
11005
+ const dispatches = getActiveDirectDispatches(mesh.id);
11006
+ if (dispatches.length === 0) return;
11007
+ const dispatchMeshCommand = components.dispatchMeshCommand;
11008
+ const nodeById = new Map(mesh.nodes.map((n) => [n.id, n]));
11009
+ for (const dispatch of dispatches) {
11010
+ const sessionId = readNonEmptyString2(dispatch.sessionId);
11011
+ const nodeId = readNonEmptyString2(dispatch.nodeId);
11012
+ const taskId = readNonEmptyString2(dispatch.taskId);
11013
+ if (!sessionId || !nodeId || !taskId) continue;
11014
+ const node = nodeById.get(nodeId);
11015
+ const nodeDaemonId = readNonEmptyString2(node?.daemonId);
11016
+ const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || localDaemonId !== void 0 && nodeDaemonId === localDaemonId || !!components.instanceManager.getInstance(sessionId);
11017
+ const providerType = readNonEmptyString2(dispatch.providerType);
11018
+ const readArgs = {
11019
+ sessionId,
11020
+ targetSessionId: sessionId,
11021
+ tailLimit: 10,
11022
+ ...node?.workspace ? { workspace: node.workspace } : {},
11023
+ ...providerType ? { agentType: providerType, providerType } : {}
11024
+ };
11025
+ let payload = null;
11026
+ try {
11027
+ if (isLocalNode) {
11028
+ const result = await components.commandHandler.handle("read_chat", readArgs);
11029
+ if (result && result.success === false) continue;
11030
+ payload = unwrapReadChatPayload(result);
11031
+ } else if (dispatchMeshCommand) {
11032
+ const result = await dispatchMeshCommand(nodeDaemonId, "read_chat", readArgs);
11033
+ payload = unwrapReadChatPayload(result);
11034
+ if (payload && payload.success === false) continue;
11035
+ } else {
11036
+ continue;
11037
+ }
11038
+ } catch {
11039
+ continue;
11040
+ }
11041
+ if (!payload) continue;
11042
+ if (readChatPayloadStatus(payload) !== "idle") continue;
11043
+ const messages = Array.isArray(payload.messages) ? payload.messages : [];
11044
+ const evidence = extractFinalAssistantSummaryEvidence(messages);
11045
+ if (!evidence.finalSummary) continue;
11046
+ const providerSessionId = readNonEmptyString2(payload.providerSessionId);
11047
+ const coordinatorDaemonId = selfIds.find((id) => !!id);
11048
+ try {
11049
+ const result = reconcileDirectDispatchCompletionFromTranscript({
11050
+ meshId: mesh.id,
11051
+ nodeId,
11052
+ sessionId,
11053
+ providerType: providerType || void 0,
11054
+ providerSessionId: providerSessionId || void 0,
11055
+ taskId,
11056
+ finalSummary: evidence.finalSummary,
11057
+ ...evidence.transcriptMessageAt ? { transcriptMessageAt: evidence.transcriptMessageAt } : {},
11058
+ ...coordinatorDaemonId ? { targetCoordinatorDaemonId: coordinatorDaemonId } : {},
11059
+ source: "daemon_reconcile_transcript_completion"
11060
+ });
11061
+ if (result.reconciled) {
11062
+ LOG.info("MeshReconcile", `Synthesized missing completion (${result.kind}) for task ${taskId} on node ${nodeId} (mesh ${mesh.id})`);
11063
+ }
11064
+ } catch (e) {
11065
+ LOG.warn("MeshReconcile", `Transcript completion reconcile threw for task ${taskId}: ${e?.message || e}`);
11066
+ }
11067
+ }
11068
+ }
10333
11069
  function extractPendingEvents(raw) {
10334
11070
  if (Array.isArray(raw)) return raw;
10335
11071
  if (raw && typeof raw === "object") {
@@ -10379,6 +11115,9 @@ var init_mesh_reconcile_loop = __esm({
10379
11115
  init_mesh_events_coordinator();
10380
11116
  init_mesh_unresolved_forward_outbox();
10381
11117
  init_mesh_events_utils();
11118
+ init_mesh_work_queue();
11119
+ init_mesh_events_stale();
11120
+ init_chat_message_normalization();
10382
11121
  DEFAULT_RECONCILE_INTERVAL_MS = 4e3;
10383
11122
  }
10384
11123
  });
@@ -14149,6 +14888,8 @@ ${lastSnapshot}`;
14149
14888
  errorMessage: this.parseErrorMessage || this.engine.providerErrorMessage || void 0,
14150
14889
  errorReason: this.parseErrorMessage ? "parse_error" : this.engine.providerErrorReason || void 0,
14151
14890
  providerSessionId: this.providerSessionId || void 0,
14891
+ lastOutputAt: this.lastOutputAt,
14892
+ lastScreenChangeAt: this.lastScreenChangeAt,
14152
14893
  ...bufferState ? { bufferState } : {}
14153
14894
  };
14154
14895
  }
@@ -17190,7 +17931,8 @@ async function handleGitCommand(command, args, services = defaultGitCommandServi
17190
17931
  if (includeSubmodules !== void 0) statusParams.includeSubmodules = includeSubmodules;
17191
17932
  if (submoduleIgnorePaths && submoduleIgnorePaths.length > 0) statusParams.submoduleIgnorePaths = submoduleIgnorePaths;
17192
17933
  const status = await runService(() => services.getStatus(statusParams));
17193
- return "success" in status ? status : { success: true, status };
17934
+ if ("success" in status) return status;
17935
+ return { success: true, status, reporterPlatform: process.platform, reporterArch: process.arch };
17194
17936
  }
17195
17937
  case "git_diff_summary": {
17196
17938
  if (!services.getDiffSummary) return serviceNotImplemented(command);
@@ -20882,257 +21624,10 @@ var CdpDomHandlers = class {
20882
21624
 
20883
21625
  // src/providers/ide-provider-instance.ts
20884
21626
  var crypto2 = __toESM(require("crypto"));
21627
+ init_contracts();
20885
21628
 
20886
- // src/providers/io-contracts.ts
20887
- function normalizeInputEnvelope(input) {
20888
- const normalized = normalizeInputEnvelopePayload(input);
20889
- const textFallback = normalized.textFallback ?? flattenInputParts(normalized.parts);
20890
- return {
20891
- parts: normalized.parts,
20892
- textFallback,
20893
- ...normalized.metadata ? { metadata: normalized.metadata } : {}
20894
- };
20895
- }
20896
- function normalizeMessageParts(content) {
20897
- if (typeof content === "string") return [{ type: "text", text: content }];
20898
- if (!Array.isArray(content)) {
20899
- if (content && typeof content === "object" && typeof content.text === "string") {
20900
- return [{ type: "text", text: String(content.text) }];
20901
- }
20902
- return [];
20903
- }
20904
- const parts = [];
20905
- for (const raw of content) {
20906
- if (typeof raw === "string") {
20907
- parts.push({ type: "text", text: raw });
20908
- continue;
20909
- }
20910
- if (!raw || typeof raw !== "object") continue;
20911
- const part = normalizeMessagePartObject(raw);
20912
- if (part) parts.push(part);
20913
- }
20914
- return parts;
20915
- }
20916
- function flattenMessageParts(parts) {
20917
- return parts.map((part) => {
20918
- if (part.type === "text") return part.text;
20919
- if (part.type === "resource") return part.resource.text || "";
20920
- if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
20921
- if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
20922
- if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
20923
- if (part.type === "resource_link") return [part.name, part.description].filter(Boolean).join("\n");
20924
- return "";
20925
- }).filter((value) => value.length > 0).join("\n");
20926
- }
20927
- function normalizeInputEnvelopePayload(input) {
20928
- if (typeof input === "string") {
20929
- return { parts: [{ type: "text", text: input }], textFallback: input };
20930
- }
20931
- if (!input || typeof input !== "object") {
20932
- return { parts: [], textFallback: "" };
20933
- }
20934
- const record = input;
20935
- const nestedInput = record.input;
20936
- if (nestedInput && typeof nestedInput === "object") {
20937
- const nested = nestedInput;
20938
- return {
20939
- parts: normalizeInputParts(nested.parts ?? nested.prompt),
20940
- textFallback: typeof nested.textFallback === "string" ? nested.textFallback : void 0,
20941
- metadata: normalizeInputMetadata(nested.metadata)
20942
- };
20943
- }
20944
- const directText = typeof record.text === "string" ? record.text : typeof record.message === "string" ? record.message : void 0;
20945
- if (directText !== void 0) {
20946
- return { parts: [{ type: "text", text: directText }], textFallback: directText };
20947
- }
20948
- const directParts = normalizeInputParts(record.parts ?? record.prompt);
20949
- return {
20950
- parts: directParts,
20951
- textFallback: typeof record.textFallback === "string" ? record.textFallback : void 0,
20952
- metadata: normalizeInputMetadata(record.metadata)
20953
- };
20954
- }
20955
- function normalizeInputMetadata(value) {
20956
- if (!value || typeof value !== "object") return void 0;
20957
- const record = value;
20958
- const metadata = {};
20959
- if (record.source === "dashboard" || record.source === "shortcut_api" || record.source === "provider_script" || record.source === "session_replay") {
20960
- metadata.source = record.source;
20961
- }
20962
- if (typeof record.clientTimestamp === "number" && Number.isFinite(record.clientTimestamp)) {
20963
- metadata.clientTimestamp = record.clientTimestamp;
20964
- }
20965
- return Object.keys(metadata).length > 0 ? metadata : void 0;
20966
- }
20967
- function normalizeInputParts(value) {
20968
- if (!Array.isArray(value)) return [];
20969
- const parts = [];
20970
- for (const raw of value) {
20971
- if (typeof raw === "string") {
20972
- parts.push({ type: "text", text: raw });
20973
- continue;
20974
- }
20975
- if (!raw || typeof raw !== "object") continue;
20976
- const part = normalizeInputPartObject(raw);
20977
- if (part) parts.push(part);
20978
- }
20979
- return parts;
20980
- }
20981
- function normalizeInputPartObject(raw) {
20982
- const type = raw.type;
20983
- if (type === "text" && typeof raw.text === "string") {
20984
- return { type, text: raw.text };
20985
- }
20986
- if (type === "image" && typeof raw.mimeType === "string") {
20987
- return {
20988
- type,
20989
- mimeType: raw.mimeType,
20990
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
20991
- ...typeof raw.data === "string" ? { data: raw.data } : {},
20992
- ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
20993
- };
20994
- }
20995
- if (type === "audio" && typeof raw.mimeType === "string") {
20996
- return {
20997
- type,
20998
- mimeType: raw.mimeType,
20999
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
21000
- ...typeof raw.data === "string" ? { data: raw.data } : {},
21001
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
21002
- };
21003
- }
21004
- if (type === "video" && typeof raw.mimeType === "string") {
21005
- return {
21006
- type,
21007
- mimeType: raw.mimeType,
21008
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
21009
- ...typeof raw.data === "string" ? { data: raw.data } : {},
21010
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
21011
- ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
21012
- };
21013
- }
21014
- if (type === "resource" && typeof raw.uri === "string") {
21015
- return {
21016
- type,
21017
- uri: raw.uri,
21018
- ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
21019
- ...typeof raw.name === "string" ? { name: raw.name } : {},
21020
- ...typeof raw.text === "string" ? { text: raw.text } : {},
21021
- ...typeof raw.data === "string" ? { data: raw.data } : {}
21022
- };
21023
- }
21024
- if (type === "resource_link" && typeof raw.uri === "string") {
21025
- return {
21026
- type,
21027
- uri: raw.uri,
21028
- name: typeof raw.name === "string" ? raw.name : getUriDisplayName(raw.uri, "resource"),
21029
- ...typeof raw.title === "string" ? { title: raw.title } : {},
21030
- ...typeof raw.description === "string" ? { description: raw.description } : {},
21031
- ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
21032
- ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
21033
- ...normalizeAnnotationsProperty(raw.annotations)
21034
- };
21035
- }
21036
- return null;
21037
- }
21038
- function normalizeMessagePartObject(raw) {
21039
- const type = raw.type;
21040
- if (type === "text" && typeof raw.text === "string") {
21041
- return { type, text: raw.text };
21042
- }
21043
- if (type === "image" && typeof raw.mimeType === "string") {
21044
- return {
21045
- type,
21046
- mimeType: raw.mimeType,
21047
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
21048
- ...typeof raw.data === "string" ? { data: raw.data } : {},
21049
- ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
21050
- };
21051
- }
21052
- if (type === "audio" && typeof raw.mimeType === "string") {
21053
- return {
21054
- type,
21055
- mimeType: raw.mimeType,
21056
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
21057
- ...typeof raw.data === "string" ? { data: raw.data } : {},
21058
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
21059
- };
21060
- }
21061
- if (type === "video" && typeof raw.mimeType === "string") {
21062
- return {
21063
- type,
21064
- mimeType: raw.mimeType,
21065
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
21066
- ...typeof raw.data === "string" ? { data: raw.data } : {},
21067
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
21068
- ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
21069
- };
21070
- }
21071
- if (type === "resource_link" && typeof raw.uri === "string" && typeof raw.name === "string") {
21072
- return {
21073
- type,
21074
- uri: raw.uri,
21075
- name: raw.name,
21076
- ...typeof raw.title === "string" ? { title: raw.title } : {},
21077
- ...typeof raw.description === "string" ? { description: raw.description } : {},
21078
- ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
21079
- ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
21080
- ...normalizeAnnotationsProperty(raw.annotations)
21081
- };
21082
- }
21083
- if (type === "resource" && raw.resource && typeof raw.resource === "object") {
21084
- const resource = raw.resource;
21085
- if (typeof resource.uri !== "string") return null;
21086
- return {
21087
- type,
21088
- resource: {
21089
- uri: resource.uri,
21090
- ...typeof resource.mimeType === "string" || resource.mimeType === null ? { mimeType: resource.mimeType } : {},
21091
- ...typeof resource.text === "string" ? { text: resource.text } : {},
21092
- ...typeof resource.blob === "string" ? { blob: resource.blob } : {}
21093
- }
21094
- };
21095
- }
21096
- return null;
21097
- }
21098
- function flattenInputParts(parts) {
21099
- return parts.map((part) => {
21100
- if (part.type === "text") return part.text;
21101
- if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
21102
- if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
21103
- if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
21104
- if (part.type === "resource_link") return [part.title, part.name, part.description, part.uri].filter(Boolean).join("\n");
21105
- if (part.type === "resource") return part.text || part.name || part.uri;
21106
- return "";
21107
- }).filter((value) => value.length > 0).join("\n");
21108
- }
21109
- function getUriDisplayName(uri, fallback) {
21110
- try {
21111
- const pathname = uri.startsWith("file://") ? new URL(uri).pathname : uri;
21112
- return pathname.split(/[\\/]/).filter(Boolean).pop() || fallback;
21113
- } catch {
21114
- return uri.split(/[\\/]/).filter(Boolean).pop() || fallback;
21115
- }
21116
- }
21117
- function normalizeAnnotationsProperty(value) {
21118
- if (!value || typeof value !== "object") return {};
21119
- const record = value;
21120
- const annotations = {};
21121
- if (Array.isArray(record.audience)) {
21122
- const audience = record.audience.filter((item) => item === "user" || item === "assistant");
21123
- if (audience.length > 0) annotations.audience = audience;
21124
- }
21125
- if (typeof record.priority === "number" && Number.isFinite(record.priority)) {
21126
- annotations.priority = record.priority;
21127
- }
21128
- return Object.keys(annotations).length > 0 ? { annotations } : {};
21129
- }
21130
-
21131
- // src/providers/contracts.ts
21132
- function flattenContent(content) {
21133
- if (typeof content === "string") return content;
21134
- return flattenMessageParts(normalizeMessageParts(content));
21135
- }
21629
+ // src/providers/extension-provider-instance.ts
21630
+ init_contracts();
21136
21631
 
21137
21632
  // src/providers/status-monitor.ts
21138
21633
  var DEFAULT_MONITOR_CONFIG = {
@@ -21246,342 +21741,9 @@ var StatusMonitor = class {
21246
21741
  }
21247
21742
  };
21248
21743
 
21249
- // src/providers/chat-message-normalization.ts
21250
- var DEFAULT_FINAL_SUMMARY_MAX_CHARS = 4e3;
21251
- function extractFinalSummaryFromMessages(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
21252
- if (!Array.isArray(messages) || messages.length === 0) return "";
21253
- for (let i = messages.length - 1; i >= 0; i--) {
21254
- const msg = messages[i];
21255
- if (!msg) continue;
21256
- const classification = classifyChatMessageVisibility(msg);
21257
- if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
21258
- const text = flattenContent(msg.content).trim();
21259
- if (text) return text.slice(0, maxChars);
21260
- }
21261
- }
21262
- return "";
21263
- }
21264
- var BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
21265
- var CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
21266
- var CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
21267
- var CHAT_MESSAGE_AUDIENCES = ["chat", "debug", "trace", "internal"];
21268
- var CHAT_MESSAGE_SOURCES = [
21269
- "assistant_text",
21270
- "tool_call",
21271
- "terminal_command",
21272
- "runtime_activity",
21273
- "runtime_status",
21274
- "provider_chrome",
21275
- "control"
21276
- ];
21277
- var CHAT_MESSAGE_ACTIVITY_SOURCES = ["tool_call", "terminal_command", "runtime_activity"];
21278
- var CHAT_MESSAGE_INTERNAL_SOURCES = ["runtime_status", "provider_chrome", "control"];
21279
- var KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
21280
- var CHAT_MESSAGE_KIND_ALIASES = {
21281
- text: "standard",
21282
- message: "standard",
21283
- assistant: "standard",
21284
- thinking: "thought",
21285
- think: "thought",
21286
- reasoning: "thought",
21287
- reason: "thought",
21288
- toolcall: "tool",
21289
- tool_call: "tool",
21290
- tooluse: "tool",
21291
- tool_use: "tool",
21292
- action: "tool",
21293
- command: "terminal",
21294
- cmd: "terminal",
21295
- shell: "terminal",
21296
- console: "terminal"
21297
- };
21298
- function canonicalizeKindHint(value) {
21299
- return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
21300
- }
21301
- function resolveBuiltinOrAliasKind(kind) {
21302
- if (typeof kind !== "string") return null;
21303
- const normalizedKind = canonicalizeKindHint(kind);
21304
- if (!normalizedKind) return null;
21305
- if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
21306
- return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
21307
- }
21308
- function inferHintKind(value) {
21309
- const direct = resolveBuiltinOrAliasKind(value);
21310
- if (direct) return direct;
21311
- if (typeof value !== "string") return null;
21312
- const normalized = canonicalizeKindHint(value);
21313
- if (!normalized) return null;
21314
- if (/thought|thinking|reasoning/.test(normalized)) return "thought";
21315
- if (/tool/.test(normalized)) return "tool";
21316
- if (/terminal|command|shell|console/.test(normalized)) return "terminal";
21317
- return null;
21318
- }
21319
- function inferKindFromToolCalls(message) {
21320
- const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
21321
- if (toolCalls.length === 0) return null;
21322
- if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
21323
- if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
21324
- if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
21325
- return "terminal";
21326
- }
21327
- return "tool";
21328
- }
21329
- function inferMissingChatMessageKind(message) {
21330
- const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
21331
- if (role === "system") return "system";
21332
- const meta = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
21333
- const hintCandidates = [
21334
- message?._sub,
21335
- message?._type,
21336
- meta?.label,
21337
- typeof message?.senderName === "string" ? message.senderName : void 0
21338
- ];
21339
- for (const candidate of hintCandidates) {
21340
- const inferred = inferHintKind(candidate);
21341
- if (inferred) return inferred;
21342
- }
21343
- const inferredFromToolCalls = inferKindFromToolCalls(message);
21344
- if (inferredFromToolCalls) return inferredFromToolCalls;
21345
- return null;
21346
- }
21347
- function isBuiltinChatMessageKind(kind) {
21348
- return resolveBuiltinOrAliasKind(kind) !== null;
21349
- }
21350
- function normalizeChatMessageKind(kind, role) {
21351
- const resolvedKind = resolveBuiltinOrAliasKind(kind);
21352
- if (resolvedKind) return resolvedKind;
21353
- const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
21354
- return normalizedRole === "system" ? "system" : "standard";
21355
- }
21356
- function resolveChatMessageKind(message) {
21357
- const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
21358
- if (explicitKind) return explicitKind;
21359
- const inferredKind = inferMissingChatMessageKind(message);
21360
- if (inferredKind) return inferredKind;
21361
- return normalizeChatMessageKind(message?.kind, message?.role);
21362
- }
21363
- function buildChatMessage(message) {
21364
- return {
21365
- ...message,
21366
- kind: resolveChatMessageKind(message)
21367
- };
21368
- }
21369
- function buildSystemChatMessage(message) {
21370
- return buildChatMessage({
21371
- ...message,
21372
- role: "system",
21373
- kind: message?.kind || "system"
21374
- });
21375
- }
21376
- function buildRuntimeSystemChatMessage(message) {
21377
- return buildSystemChatMessage({
21378
- ...message,
21379
- senderName: typeof message?.senderName === "string" && message.senderName.trim() ? message.senderName : "System"
21380
- });
21381
- }
21382
- function buildAssistantChatMessage(message) {
21383
- return buildChatMessage({
21384
- ...message,
21385
- role: "assistant",
21386
- kind: message?.kind || "standard"
21387
- });
21388
- }
21389
- function buildThoughtChatMessage(message) {
21390
- return buildAssistantChatMessage({
21391
- ...message,
21392
- kind: message?.kind || "thought"
21393
- });
21394
- }
21395
- function buildToolChatMessage(message) {
21396
- return buildAssistantChatMessage({
21397
- ...message,
21398
- kind: message?.kind || "tool"
21399
- });
21400
- }
21401
- function buildTerminalChatMessage(message) {
21402
- return buildAssistantChatMessage({
21403
- ...message,
21404
- kind: message?.kind || "terminal"
21405
- });
21406
- }
21407
- function buildUserChatMessage(message) {
21408
- return buildChatMessage({
21409
- ...message,
21410
- role: "user",
21411
- kind: message?.kind || "standard"
21412
- });
21413
- }
21414
- function normalizeChatMessage(message) {
21415
- return buildChatMessage(message);
21416
- }
21417
- function normalizeChatMessages(messages) {
21418
- return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
21419
- }
21420
- function readMessageMeta(message) {
21421
- const meta = message?.meta;
21422
- return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : null;
21423
- }
21424
- function readStringField(value) {
21425
- return typeof value === "string" ? value.trim().toLowerCase() : "";
21426
- }
21427
- function readRecordField(message, meta, key) {
21428
- const record = message;
21429
- return record[key] ?? meta?.[key];
21430
- }
21431
- function readVisibilityField(message, meta) {
21432
- return readStringField(readRecordField(message, meta, "visibility"));
21433
- }
21434
- function readTranscriptVisibilityField(message, meta) {
21435
- const record = message;
21436
- return readStringField(record.transcriptVisibility ?? meta?.transcriptVisibility ?? record.visibility ?? meta?.visibility);
21437
- }
21438
- var EXPLICIT_HIDDEN_VISIBILITIES = /* @__PURE__ */ new Set(["hidden", "debug", "internal"]);
21439
- var EXPLICIT_VISIBLE_VISIBILITIES = /* @__PURE__ */ new Set(["visible", "user", "chat"]);
21440
- var HIDDEN_AUDIENCES = /* @__PURE__ */ new Set(["debug", "trace", "internal"]);
21441
- var ACTIVITY_SOURCE_SET = new Set(CHAT_MESSAGE_ACTIVITY_SOURCES);
21442
- var INTERNAL_SOURCE_SET = new Set(CHAT_MESSAGE_INTERNAL_SOURCES);
21443
- function hasBooleanMarker(message, meta, keys) {
21444
- const record = message;
21445
- return keys.some((key) => record[key] === true || meta?.[key] === true);
21446
- }
21447
- function isActivityKind(kind) {
21448
- return kind === "thought" || kind === "tool" || kind === "terminal";
21449
- }
21450
- function isOrdinaryVisibleTurn(message, role, kind) {
21451
- if (role === "user" || role === "human") return kind === "standard" || kind === "";
21452
- if (role === "assistant") return kind === "standard" || kind === "";
21453
- return false;
21454
- }
21455
- function classifyChatMessageVisibility(message) {
21456
- if (!message) {
21457
- return {
21458
- surface: "internal",
21459
- isUserFacing: false,
21460
- isActivityFacing: false,
21461
- isInternal: true,
21462
- explicitUserFacing: false,
21463
- explicitHidden: true,
21464
- role: "",
21465
- kind: "standard",
21466
- visibility: "",
21467
- transcriptVisibility: "",
21468
- audience: "",
21469
- source: ""
21470
- };
21471
- }
21472
- const meta = readMessageMeta(message);
21473
- const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
21474
- const kind = resolveChatMessageKind(message);
21475
- const visibility = readVisibilityField(message, meta);
21476
- const transcriptVisibility = readTranscriptVisibilityField(message, meta);
21477
- const audience = readStringField(readRecordField(message, meta, "audience"));
21478
- const source = readStringField(readRecordField(message, meta, "source"));
21479
- const explicitHidden = EXPLICIT_HIDDEN_VISIBILITIES.has(visibility) || EXPLICIT_HIDDEN_VISIBILITIES.has(transcriptVisibility) || HIDDEN_AUDIENCES.has(audience) || hasBooleanMarker(message, meta, ["hidden", "internal", "isInternal", "debug", "statusOnly", "controlOnly"]);
21480
- const explicitUserFacing = EXPLICIT_VISIBLE_VISIBILITIES.has(visibility) || EXPLICIT_VISIBLE_VISIBILITIES.has(transcriptVisibility) || audience === "chat" || hasBooleanMarker(message, meta, ["userFacing"]);
21481
- if (explicitHidden) {
21482
- const activityLike = isActivityKind(kind) || ACTIVITY_SOURCE_SET.has(source);
21483
- return {
21484
- surface: activityLike ? "activity" : "internal",
21485
- isUserFacing: false,
21486
- isActivityFacing: activityLike,
21487
- isInternal: !activityLike,
21488
- explicitUserFacing,
21489
- explicitHidden,
21490
- role,
21491
- kind,
21492
- visibility,
21493
- transcriptVisibility,
21494
- audience,
21495
- source
21496
- };
21497
- }
21498
- if (explicitUserFacing) {
21499
- return {
21500
- surface: "chat",
21501
- isUserFacing: true,
21502
- isActivityFacing: false,
21503
- isInternal: false,
21504
- explicitUserFacing,
21505
- explicitHidden,
21506
- role,
21507
- kind,
21508
- visibility,
21509
- transcriptVisibility,
21510
- audience,
21511
- source
21512
- };
21513
- }
21514
- if (INTERNAL_SOURCE_SET.has(source) || role === "system" || kind === "system") {
21515
- return {
21516
- surface: "internal",
21517
- isUserFacing: false,
21518
- isActivityFacing: false,
21519
- isInternal: true,
21520
- explicitUserFacing,
21521
- explicitHidden,
21522
- role,
21523
- kind,
21524
- visibility,
21525
- transcriptVisibility,
21526
- audience,
21527
- source
21528
- };
21529
- }
21530
- if (ACTIVITY_SOURCE_SET.has(source) || isActivityKind(kind)) {
21531
- return {
21532
- surface: "activity",
21533
- isUserFacing: false,
21534
- isActivityFacing: true,
21535
- isInternal: false,
21536
- explicitUserFacing,
21537
- explicitHidden,
21538
- role,
21539
- kind,
21540
- visibility,
21541
- transcriptVisibility,
21542
- audience,
21543
- source
21544
- };
21545
- }
21546
- const isUserFacing = isOrdinaryVisibleTurn(message, role, kind);
21547
- return {
21548
- surface: isUserFacing ? "chat" : "internal",
21549
- isUserFacing,
21550
- isActivityFacing: false,
21551
- isInternal: !isUserFacing,
21552
- explicitUserFacing,
21553
- explicitHidden,
21554
- role,
21555
- kind,
21556
- visibility,
21557
- transcriptVisibility,
21558
- audience,
21559
- source
21560
- };
21561
- }
21562
- function isUserFacingChatMessage(message) {
21563
- return classifyChatMessageVisibility(message).isUserFacing;
21564
- }
21565
- function isActivityChatMessage(message) {
21566
- return classifyChatMessageVisibility(message).isActivityFacing;
21567
- }
21568
- function isInternalChatMessage(message) {
21569
- return classifyChatMessageVisibility(message).isInternal;
21570
- }
21571
- function filterUserFacingChatMessages(messages) {
21572
- return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
21573
- }
21574
- function filterActivityChatMessages(messages) {
21575
- return (Array.isArray(messages) ? messages : []).filter((message) => isActivityChatMessage(message));
21576
- }
21577
- function filterInternalChatMessages(messages) {
21578
- return (Array.isArray(messages) ? messages : []).filter((message) => isInternalChatMessage(message));
21579
- }
21580
- function filterChatMessagesByVisibility(messages, surface) {
21581
- return (Array.isArray(messages) ? messages : []).filter((message) => classifyChatMessageVisibility(message).surface === surface);
21582
- }
21583
-
21584
21744
  // src/providers/control-effects.ts
21745
+ init_contracts();
21746
+ init_chat_message_normalization();
21585
21747
  function extractProviderControlValues(controls, data) {
21586
21748
  if (!data || typeof data !== "object") return void 0;
21587
21749
  const values = {};
@@ -21778,6 +21940,7 @@ ${cleanBody}`;
21778
21940
  var fs6 = __toESM(require("fs"));
21779
21941
  var path14 = __toESM(require("path"));
21780
21942
  var os8 = __toESM(require("os"));
21943
+ init_chat_message_normalization();
21781
21944
  var HISTORY_DIR = path14.join(os8.homedir(), ".adhdev", "history");
21782
21945
  var RETAIN_DAYS = 30;
21783
21946
  var SAVED_HISTORY_INDEX_VERSION = 1;
@@ -23316,6 +23479,9 @@ function resolveProviderStateSurface(params) {
23316
23479
  };
23317
23480
  }
23318
23481
 
23482
+ // src/providers/extension-provider-instance.ts
23483
+ init_chat_message_normalization();
23484
+
23319
23485
  // src/providers/open-panel-support.ts
23320
23486
  var IDE_PROVIDER_SESSION_CAPABILITIES_BASE = [
23321
23487
  "read_chat",
@@ -23751,6 +23917,9 @@ ${effect.notification.body || ""}`.trim();
23751
23917
  // src/providers/ide-provider-instance.ts
23752
23918
  init_logger();
23753
23919
 
23920
+ // src/providers/read-chat-contract.ts
23921
+ init_contracts();
23922
+
23754
23923
  // src/providers/transcript-v2.ts
23755
23924
  var CHAT_CONTRACT_VERSION_V1 = "1.0";
23756
23925
 
@@ -23970,6 +24139,7 @@ function looksLikeActiveApprovalPromptText(content) {
23970
24139
  }
23971
24140
 
23972
24141
  // src/providers/ide-provider-instance.ts
24142
+ init_chat_message_normalization();
23973
24143
  async function withTimeout(promise, timeoutMs, label) {
23974
24144
  let timer = null;
23975
24145
  try {
@@ -25626,6 +25796,7 @@ var fs7 = __toESM(require("fs"));
25626
25796
  var os9 = __toESM(require("os"));
25627
25797
  var path15 = __toESM(require("path"));
25628
25798
  var import_node_crypto3 = require("crypto");
25799
+ init_contracts();
25629
25800
  init_logger();
25630
25801
 
25631
25802
  // src/logging/debug-trace.ts
@@ -26114,6 +26285,7 @@ function synthesiseV1UnitKey(providerType, sessionId, positionalSeq, message) {
26114
26285
  var CHAT_SOURCE_REGISTRY = new ChatSourceRegistry();
26115
26286
 
26116
26287
  // src/commands/chat-commands.ts
26288
+ init_chat_message_normalization();
26117
26289
  var RECENT_SEND_WINDOW_MS = 1200;
26118
26290
  var READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
26119
26291
  var HOT_TAIL_MIN_LIMIT = 60;
@@ -30952,6 +31124,7 @@ var path24 = __toESM(require("path"));
30952
31124
  var crypto4 = __toESM(require("crypto"));
30953
31125
  var fs16 = __toESM(require("fs"));
30954
31126
  var import_node_module = require("module");
31127
+ init_contracts();
30955
31128
 
30956
31129
  // src/providers/spec/route.ts
30957
31130
  var fs15 = __toESM(require("fs"));
@@ -33488,6 +33661,9 @@ function normalizeProviderSessionId(provider, providerSessionId) {
33488
33661
  return normalizedId;
33489
33662
  }
33490
33663
 
33664
+ // src/providers/cli-provider-instance.ts
33665
+ init_chat_message_normalization();
33666
+
33491
33667
  // src/providers/working-dir.ts
33492
33668
  function workingDirBasename(p) {
33493
33669
  return (p || "").split(/[\\/]/).filter(Boolean).pop() || "session";
@@ -34618,7 +34794,7 @@ var CliProviderInstance = class _CliProviderInstance {
34618
34794
  const dirName = workingDirBasename(this.workingDir);
34619
34795
  const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
34620
34796
  const partial = this.adapter.getPartialResponse();
34621
- const progressFingerprint = newStatus === "generating" ? `${partial || ""}`.slice(-2e3) : void 0;
34797
+ const progressFingerprint = newStatus === "generating" ? `${`${partial || ""}`.slice(-2e3)}::scr=${adapterStatus.lastScreenChangeAt ?? 0}::out=${adapterStatus.lastOutputAt ?? 0}` : void 0;
34622
34798
  const previousStatus = this.lastStatus;
34623
34799
  if (newStatus !== this.lastStatus) {
34624
34800
  LOG.info("CLI", `[${this.type}] status: ${this.lastStatus} \u2192 ${newStatus}`);
@@ -35294,6 +35470,8 @@ var path25 = __toESM(require("path"));
35294
35470
  var import_stream = require("stream");
35295
35471
  var import_child_process5 = require("child_process");
35296
35472
  var import_sdk = require("@agentclientprotocol/sdk");
35473
+ init_contracts();
35474
+ init_chat_message_normalization();
35297
35475
  init_logger();
35298
35476
  function getPromptCapabilityFlags(agentCapabilities) {
35299
35477
  const prompt = agentCapabilities?.promptCapabilities || {};
@@ -36523,6 +36701,7 @@ ${rawInput}` : rawInput;
36523
36701
  };
36524
36702
 
36525
36703
  // src/commands/cli-manager.ts
36704
+ init_contracts();
36526
36705
  init_logger();
36527
36706
 
36528
36707
  // src/commands/hosted-runtime-restore.ts
@@ -43043,6 +43222,25 @@ function recordInlineMeshDirectGitTruth(node, git, source) {
43043
43222
  node.lastSeenAt = updatedAt;
43044
43223
  const repoRoot = readStringValue(nextGit.repoRoot);
43045
43224
  if (repoRoot && !readStringValue(node.repoRoot)) node.repoRoot = repoRoot;
43225
+ const isLocalSource = source === "selected_coordinator_local_git";
43226
+ const reporterPlatform = readStringValue(git.reporterPlatform) ?? (isLocalSource ? process.platform : null);
43227
+ const reporterArch = readStringValue(git.reporterArch) ?? (isLocalSource ? process.arch : null);
43228
+ stampNodeReporterPlatform(node, reporterPlatform, reporterArch);
43229
+ }
43230
+ function stampNodeReporterPlatform(node, platform10, arch2) {
43231
+ if (!node || typeof node !== "object" || Array.isArray(node)) return;
43232
+ if (!platform10 && !arch2) return;
43233
+ const overrides = node.userOverrides && typeof node.userOverrides === "object" && !Array.isArray(node.userOverrides) ? node.userOverrides : {};
43234
+ let changed = false;
43235
+ if (platform10 && !readStringValue(overrides.platform)) {
43236
+ overrides.platform = platform10;
43237
+ changed = true;
43238
+ }
43239
+ if (arch2 && !readStringValue(overrides.arch)) {
43240
+ overrides.arch = arch2;
43241
+ changed = true;
43242
+ }
43243
+ if (changed) node.userOverrides = overrides;
43046
43244
  }
43047
43245
  function buildCachedInlineMeshGitStatus(node) {
43048
43246
  const liveGit = buildInlineMeshTransitGitStatus(node);
@@ -43536,7 +43734,13 @@ async function probeRemoteMeshGitStatus(args) {
43536
43734
  new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), args.timeoutMs))
43537
43735
  ]);
43538
43736
  const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
43539
- return remoteGit && typeof remoteGit === "object" && typeof remoteGit.isGitRepo === "boolean" ? remoteGit : null;
43737
+ if (!remoteGit || typeof remoteGit !== "object" || typeof remoteGit.isGitRepo !== "boolean") return null;
43738
+ const reporterPlatform = readStringValue(remoteResult?.reporterPlatform);
43739
+ const reporterArch = readStringValue(remoteResult?.reporterArch);
43740
+ const git = remoteGit;
43741
+ if (reporterPlatform) git.reporterPlatform = reporterPlatform;
43742
+ if (reporterArch) git.reporterArch = reporterArch;
43743
+ return git;
43540
43744
  }
43541
43745
  var MESH_DIRECT_PROBE_MAX_RETRIES = 2;
43542
43746
  function readMeshConnectionState(connection) {
@@ -50436,6 +50640,7 @@ var DEFAULT_DAEMON_PORT = 19222;
50436
50640
  var DAEMON_WS_PATH = "/ipc";
50437
50641
 
50438
50642
  // src/chat/subscription-updates.ts
50643
+ init_chat_message_normalization();
50439
50644
  function normalizeModalButtons(value) {
50440
50645
  return Array.isArray(value) ? value.filter((button) => typeof button === "string") : [];
50441
50646
  }
@@ -50576,6 +50781,7 @@ async function runAsyncBatch(items, worker, options = {}) {
50576
50781
  }
50577
50782
 
50578
50783
  // src/agent-stream/provider-adapter.ts
50784
+ init_chat_message_normalization();
50579
50785
  var ProviderStreamAdapter = class {
50580
50786
  agentType;
50581
50787
  agentName;
@@ -51260,6 +51466,7 @@ var DaemonAgentStreamManager = class {
51260
51466
 
51261
51467
  // src/agent-stream/poller.ts
51262
51468
  init_logger();
51469
+ init_chat_message_normalization();
51263
51470
  var AgentStreamPoller = class {
51264
51471
  deps;
51265
51472
  timer = null;
@@ -51781,6 +51988,10 @@ var ProviderInstanceManager = class {
51781
51988
  }
51782
51989
  };
51783
51990
 
51991
+ // src/index.ts
51992
+ init_io_contracts();
51993
+ init_chat_message_normalization();
51994
+
51784
51995
  // src/providers/version-archive.ts
51785
51996
  var fs27 = __toESM(require("fs"));
51786
51997
  var path37 = __toESM(require("path"));