@adhdev/daemon-core 0.9.82-rc.325 → 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.mjs CHANGED
@@ -308,10 +308,10 @@ function readInjected(value) {
308
308
  }
309
309
  function getDaemonBuildInfo() {
310
310
  if (cached) return cached;
311
- const commit = readInjected(true ? "a0aeebdac30d9abea5b46e3f2618f864bbff19d0" : void 0) ?? "unknown";
312
- const commitShort = readInjected(true ? "a0aeebda" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
313
- const version = readInjected(true ? "0.9.82-rc.325" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
314
- const builtAt = readInjected(true ? "2026-06-19T08:24:25.509Z" : void 0);
311
+ const commit = readInjected(true ? "9ee42155ad394578ced8959105e9a2c35d0af11b" : void 0) ?? "unknown";
312
+ const commitShort = readInjected(true ? "9ee42155" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
313
+ const version = readInjected(true ? "0.9.82-rc.326" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
314
+ const builtAt = readInjected(true ? "2026-06-19T10:16:19.073Z" : void 0);
315
315
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
316
316
  return cached;
317
317
  }
@@ -10130,6 +10130,644 @@ var init_mesh_events_coordinator = __esm({
10130
10130
  }
10131
10131
  });
10132
10132
 
10133
+ // src/providers/io-contracts.ts
10134
+ function normalizeInputEnvelope(input) {
10135
+ const normalized = normalizeInputEnvelopePayload(input);
10136
+ const textFallback = normalized.textFallback ?? flattenInputParts(normalized.parts);
10137
+ return {
10138
+ parts: normalized.parts,
10139
+ textFallback,
10140
+ ...normalized.metadata ? { metadata: normalized.metadata } : {}
10141
+ };
10142
+ }
10143
+ function normalizeMessageParts(content) {
10144
+ if (typeof content === "string") return [{ type: "text", text: content }];
10145
+ if (!Array.isArray(content)) {
10146
+ if (content && typeof content === "object" && typeof content.text === "string") {
10147
+ return [{ type: "text", text: String(content.text) }];
10148
+ }
10149
+ return [];
10150
+ }
10151
+ const parts = [];
10152
+ for (const raw of content) {
10153
+ if (typeof raw === "string") {
10154
+ parts.push({ type: "text", text: raw });
10155
+ continue;
10156
+ }
10157
+ if (!raw || typeof raw !== "object") continue;
10158
+ const part = normalizeMessagePartObject(raw);
10159
+ if (part) parts.push(part);
10160
+ }
10161
+ return parts;
10162
+ }
10163
+ function flattenMessageParts(parts) {
10164
+ return parts.map((part) => {
10165
+ if (part.type === "text") return part.text;
10166
+ if (part.type === "resource") return part.resource.text || "";
10167
+ if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
10168
+ if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
10169
+ if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
10170
+ if (part.type === "resource_link") return [part.name, part.description].filter(Boolean).join("\n");
10171
+ return "";
10172
+ }).filter((value) => value.length > 0).join("\n");
10173
+ }
10174
+ function normalizeInputEnvelopePayload(input) {
10175
+ if (typeof input === "string") {
10176
+ return { parts: [{ type: "text", text: input }], textFallback: input };
10177
+ }
10178
+ if (!input || typeof input !== "object") {
10179
+ return { parts: [], textFallback: "" };
10180
+ }
10181
+ const record = input;
10182
+ const nestedInput = record.input;
10183
+ if (nestedInput && typeof nestedInput === "object") {
10184
+ const nested = nestedInput;
10185
+ return {
10186
+ parts: normalizeInputParts(nested.parts ?? nested.prompt),
10187
+ textFallback: typeof nested.textFallback === "string" ? nested.textFallback : void 0,
10188
+ metadata: normalizeInputMetadata(nested.metadata)
10189
+ };
10190
+ }
10191
+ const directText = typeof record.text === "string" ? record.text : typeof record.message === "string" ? record.message : void 0;
10192
+ if (directText !== void 0) {
10193
+ return { parts: [{ type: "text", text: directText }], textFallback: directText };
10194
+ }
10195
+ const directParts = normalizeInputParts(record.parts ?? record.prompt);
10196
+ return {
10197
+ parts: directParts,
10198
+ textFallback: typeof record.textFallback === "string" ? record.textFallback : void 0,
10199
+ metadata: normalizeInputMetadata(record.metadata)
10200
+ };
10201
+ }
10202
+ function normalizeInputMetadata(value) {
10203
+ if (!value || typeof value !== "object") return void 0;
10204
+ const record = value;
10205
+ const metadata = {};
10206
+ if (record.source === "dashboard" || record.source === "shortcut_api" || record.source === "provider_script" || record.source === "session_replay") {
10207
+ metadata.source = record.source;
10208
+ }
10209
+ if (typeof record.clientTimestamp === "number" && Number.isFinite(record.clientTimestamp)) {
10210
+ metadata.clientTimestamp = record.clientTimestamp;
10211
+ }
10212
+ return Object.keys(metadata).length > 0 ? metadata : void 0;
10213
+ }
10214
+ function normalizeInputParts(value) {
10215
+ if (!Array.isArray(value)) return [];
10216
+ const parts = [];
10217
+ for (const raw of value) {
10218
+ if (typeof raw === "string") {
10219
+ parts.push({ type: "text", text: raw });
10220
+ continue;
10221
+ }
10222
+ if (!raw || typeof raw !== "object") continue;
10223
+ const part = normalizeInputPartObject(raw);
10224
+ if (part) parts.push(part);
10225
+ }
10226
+ return parts;
10227
+ }
10228
+ function normalizeInputPartObject(raw) {
10229
+ const type = raw.type;
10230
+ if (type === "text" && typeof raw.text === "string") {
10231
+ return { type, text: raw.text };
10232
+ }
10233
+ if (type === "image" && typeof raw.mimeType === "string") {
10234
+ return {
10235
+ type,
10236
+ mimeType: raw.mimeType,
10237
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10238
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10239
+ ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
10240
+ };
10241
+ }
10242
+ if (type === "audio" && typeof raw.mimeType === "string") {
10243
+ return {
10244
+ type,
10245
+ mimeType: raw.mimeType,
10246
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10247
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10248
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
10249
+ };
10250
+ }
10251
+ if (type === "video" && typeof raw.mimeType === "string") {
10252
+ return {
10253
+ type,
10254
+ mimeType: raw.mimeType,
10255
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10256
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10257
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
10258
+ ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
10259
+ };
10260
+ }
10261
+ if (type === "resource" && typeof raw.uri === "string") {
10262
+ return {
10263
+ type,
10264
+ uri: raw.uri,
10265
+ ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
10266
+ ...typeof raw.name === "string" ? { name: raw.name } : {},
10267
+ ...typeof raw.text === "string" ? { text: raw.text } : {},
10268
+ ...typeof raw.data === "string" ? { data: raw.data } : {}
10269
+ };
10270
+ }
10271
+ if (type === "resource_link" && typeof raw.uri === "string") {
10272
+ return {
10273
+ type,
10274
+ uri: raw.uri,
10275
+ name: typeof raw.name === "string" ? raw.name : getUriDisplayName(raw.uri, "resource"),
10276
+ ...typeof raw.title === "string" ? { title: raw.title } : {},
10277
+ ...typeof raw.description === "string" ? { description: raw.description } : {},
10278
+ ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
10279
+ ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
10280
+ ...normalizeAnnotationsProperty(raw.annotations)
10281
+ };
10282
+ }
10283
+ return null;
10284
+ }
10285
+ function normalizeMessagePartObject(raw) {
10286
+ const type = raw.type;
10287
+ if (type === "text" && typeof raw.text === "string") {
10288
+ return { type, text: raw.text };
10289
+ }
10290
+ if (type === "image" && typeof raw.mimeType === "string") {
10291
+ return {
10292
+ type,
10293
+ mimeType: raw.mimeType,
10294
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10295
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10296
+ ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
10297
+ };
10298
+ }
10299
+ if (type === "audio" && typeof raw.mimeType === "string") {
10300
+ return {
10301
+ type,
10302
+ mimeType: raw.mimeType,
10303
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10304
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10305
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
10306
+ };
10307
+ }
10308
+ if (type === "video" && typeof raw.mimeType === "string") {
10309
+ return {
10310
+ type,
10311
+ mimeType: raw.mimeType,
10312
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
10313
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
10314
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
10315
+ ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
10316
+ };
10317
+ }
10318
+ if (type === "resource_link" && typeof raw.uri === "string" && typeof raw.name === "string") {
10319
+ return {
10320
+ type,
10321
+ uri: raw.uri,
10322
+ name: raw.name,
10323
+ ...typeof raw.title === "string" ? { title: raw.title } : {},
10324
+ ...typeof raw.description === "string" ? { description: raw.description } : {},
10325
+ ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
10326
+ ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
10327
+ ...normalizeAnnotationsProperty(raw.annotations)
10328
+ };
10329
+ }
10330
+ if (type === "resource" && raw.resource && typeof raw.resource === "object") {
10331
+ const resource = raw.resource;
10332
+ if (typeof resource.uri !== "string") return null;
10333
+ return {
10334
+ type,
10335
+ resource: {
10336
+ uri: resource.uri,
10337
+ ...typeof resource.mimeType === "string" || resource.mimeType === null ? { mimeType: resource.mimeType } : {},
10338
+ ...typeof resource.text === "string" ? { text: resource.text } : {},
10339
+ ...typeof resource.blob === "string" ? { blob: resource.blob } : {}
10340
+ }
10341
+ };
10342
+ }
10343
+ return null;
10344
+ }
10345
+ function flattenInputParts(parts) {
10346
+ return parts.map((part) => {
10347
+ if (part.type === "text") return part.text;
10348
+ if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
10349
+ if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
10350
+ if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
10351
+ if (part.type === "resource_link") return [part.title, part.name, part.description, part.uri].filter(Boolean).join("\n");
10352
+ if (part.type === "resource") return part.text || part.name || part.uri;
10353
+ return "";
10354
+ }).filter((value) => value.length > 0).join("\n");
10355
+ }
10356
+ function getUriDisplayName(uri, fallback) {
10357
+ try {
10358
+ const pathname = uri.startsWith("file://") ? new URL(uri).pathname : uri;
10359
+ return pathname.split(/[\\/]/).filter(Boolean).pop() || fallback;
10360
+ } catch {
10361
+ return uri.split(/[\\/]/).filter(Boolean).pop() || fallback;
10362
+ }
10363
+ }
10364
+ function normalizeAnnotationsProperty(value) {
10365
+ if (!value || typeof value !== "object") return {};
10366
+ const record = value;
10367
+ const annotations = {};
10368
+ if (Array.isArray(record.audience)) {
10369
+ const audience = record.audience.filter((item) => item === "user" || item === "assistant");
10370
+ if (audience.length > 0) annotations.audience = audience;
10371
+ }
10372
+ if (typeof record.priority === "number" && Number.isFinite(record.priority)) {
10373
+ annotations.priority = record.priority;
10374
+ }
10375
+ return Object.keys(annotations).length > 0 ? { annotations } : {};
10376
+ }
10377
+ var init_io_contracts = __esm({
10378
+ "src/providers/io-contracts.ts"() {
10379
+ "use strict";
10380
+ }
10381
+ });
10382
+
10383
+ // src/providers/contracts.ts
10384
+ function flattenContent(content) {
10385
+ if (typeof content === "string") return content;
10386
+ return flattenMessageParts(normalizeMessageParts(content));
10387
+ }
10388
+ var init_contracts = __esm({
10389
+ "src/providers/contracts.ts"() {
10390
+ "use strict";
10391
+ init_io_contracts();
10392
+ init_io_contracts();
10393
+ }
10394
+ });
10395
+
10396
+ // src/providers/chat-message-normalization.ts
10397
+ function extractFinalSummaryFromMessages(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
10398
+ if (!Array.isArray(messages) || messages.length === 0) return "";
10399
+ for (let i = messages.length - 1; i >= 0; i--) {
10400
+ const msg = messages[i];
10401
+ if (!msg) continue;
10402
+ const classification = classifyChatMessageVisibility(msg);
10403
+ if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
10404
+ const text = flattenContent(msg.content).trim();
10405
+ if (text) return text.slice(0, maxChars);
10406
+ }
10407
+ }
10408
+ return "";
10409
+ }
10410
+ function readChatMessageTimestampIso(message) {
10411
+ if (!message) return void 0;
10412
+ const record = message;
10413
+ for (const value of [record.timestamp, record.createdAt, record.created_at, record.updatedAt, record.time]) {
10414
+ if (typeof value === "number" && Number.isFinite(value)) {
10415
+ const ms = value > 1e10 ? value : value * 1e3;
10416
+ return new Date(ms).toISOString();
10417
+ }
10418
+ if (typeof value === "string" && value.trim()) {
10419
+ const ms = new Date(value.trim()).getTime();
10420
+ if (Number.isFinite(ms)) return new Date(ms).toISOString();
10421
+ }
10422
+ }
10423
+ return void 0;
10424
+ }
10425
+ function extractFinalAssistantSummaryEvidence(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
10426
+ if (!Array.isArray(messages) || messages.length === 0) return { finalSummary: "" };
10427
+ for (let i = messages.length - 1; i >= 0; i--) {
10428
+ const msg = messages[i];
10429
+ if (!msg) continue;
10430
+ const classification = classifyChatMessageVisibility(msg);
10431
+ if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
10432
+ const text = flattenContent(msg.content).trim();
10433
+ if (text) {
10434
+ return {
10435
+ finalSummary: text.slice(0, maxChars),
10436
+ transcriptMessageAt: readChatMessageTimestampIso(msg)
10437
+ };
10438
+ }
10439
+ }
10440
+ }
10441
+ return { finalSummary: "" };
10442
+ }
10443
+ function canonicalizeKindHint(value) {
10444
+ return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
10445
+ }
10446
+ function resolveBuiltinOrAliasKind(kind) {
10447
+ if (typeof kind !== "string") return null;
10448
+ const normalizedKind = canonicalizeKindHint(kind);
10449
+ if (!normalizedKind) return null;
10450
+ if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
10451
+ return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
10452
+ }
10453
+ function inferHintKind(value) {
10454
+ const direct = resolveBuiltinOrAliasKind(value);
10455
+ if (direct) return direct;
10456
+ if (typeof value !== "string") return null;
10457
+ const normalized = canonicalizeKindHint(value);
10458
+ if (!normalized) return null;
10459
+ if (/thought|thinking|reasoning/.test(normalized)) return "thought";
10460
+ if (/tool/.test(normalized)) return "tool";
10461
+ if (/terminal|command|shell|console/.test(normalized)) return "terminal";
10462
+ return null;
10463
+ }
10464
+ function inferKindFromToolCalls(message) {
10465
+ const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
10466
+ if (toolCalls.length === 0) return null;
10467
+ if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
10468
+ if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
10469
+ if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
10470
+ return "terminal";
10471
+ }
10472
+ return "tool";
10473
+ }
10474
+ function inferMissingChatMessageKind(message) {
10475
+ const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
10476
+ if (role === "system") return "system";
10477
+ const meta = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
10478
+ const hintCandidates = [
10479
+ message?._sub,
10480
+ message?._type,
10481
+ meta?.label,
10482
+ typeof message?.senderName === "string" ? message.senderName : void 0
10483
+ ];
10484
+ for (const candidate of hintCandidates) {
10485
+ const inferred = inferHintKind(candidate);
10486
+ if (inferred) return inferred;
10487
+ }
10488
+ const inferredFromToolCalls = inferKindFromToolCalls(message);
10489
+ if (inferredFromToolCalls) return inferredFromToolCalls;
10490
+ return null;
10491
+ }
10492
+ function isBuiltinChatMessageKind(kind) {
10493
+ return resolveBuiltinOrAliasKind(kind) !== null;
10494
+ }
10495
+ function normalizeChatMessageKind(kind, role) {
10496
+ const resolvedKind = resolveBuiltinOrAliasKind(kind);
10497
+ if (resolvedKind) return resolvedKind;
10498
+ const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
10499
+ return normalizedRole === "system" ? "system" : "standard";
10500
+ }
10501
+ function resolveChatMessageKind(message) {
10502
+ const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
10503
+ if (explicitKind) return explicitKind;
10504
+ const inferredKind = inferMissingChatMessageKind(message);
10505
+ if (inferredKind) return inferredKind;
10506
+ return normalizeChatMessageKind(message?.kind, message?.role);
10507
+ }
10508
+ function buildChatMessage(message) {
10509
+ return {
10510
+ ...message,
10511
+ kind: resolveChatMessageKind(message)
10512
+ };
10513
+ }
10514
+ function buildSystemChatMessage(message) {
10515
+ return buildChatMessage({
10516
+ ...message,
10517
+ role: "system",
10518
+ kind: message?.kind || "system"
10519
+ });
10520
+ }
10521
+ function buildRuntimeSystemChatMessage(message) {
10522
+ return buildSystemChatMessage({
10523
+ ...message,
10524
+ senderName: typeof message?.senderName === "string" && message.senderName.trim() ? message.senderName : "System"
10525
+ });
10526
+ }
10527
+ function buildAssistantChatMessage(message) {
10528
+ return buildChatMessage({
10529
+ ...message,
10530
+ role: "assistant",
10531
+ kind: message?.kind || "standard"
10532
+ });
10533
+ }
10534
+ function buildThoughtChatMessage(message) {
10535
+ return buildAssistantChatMessage({
10536
+ ...message,
10537
+ kind: message?.kind || "thought"
10538
+ });
10539
+ }
10540
+ function buildToolChatMessage(message) {
10541
+ return buildAssistantChatMessage({
10542
+ ...message,
10543
+ kind: message?.kind || "tool"
10544
+ });
10545
+ }
10546
+ function buildTerminalChatMessage(message) {
10547
+ return buildAssistantChatMessage({
10548
+ ...message,
10549
+ kind: message?.kind || "terminal"
10550
+ });
10551
+ }
10552
+ function buildUserChatMessage(message) {
10553
+ return buildChatMessage({
10554
+ ...message,
10555
+ role: "user",
10556
+ kind: message?.kind || "standard"
10557
+ });
10558
+ }
10559
+ function normalizeChatMessage(message) {
10560
+ return buildChatMessage(message);
10561
+ }
10562
+ function normalizeChatMessages(messages) {
10563
+ return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
10564
+ }
10565
+ function readMessageMeta(message) {
10566
+ const meta = message?.meta;
10567
+ return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : null;
10568
+ }
10569
+ function readStringField(value) {
10570
+ return typeof value === "string" ? value.trim().toLowerCase() : "";
10571
+ }
10572
+ function readRecordField(message, meta, key) {
10573
+ const record = message;
10574
+ return record[key] ?? meta?.[key];
10575
+ }
10576
+ function readVisibilityField(message, meta) {
10577
+ return readStringField(readRecordField(message, meta, "visibility"));
10578
+ }
10579
+ function readTranscriptVisibilityField(message, meta) {
10580
+ const record = message;
10581
+ return readStringField(record.transcriptVisibility ?? meta?.transcriptVisibility ?? record.visibility ?? meta?.visibility);
10582
+ }
10583
+ function hasBooleanMarker(message, meta, keys) {
10584
+ const record = message;
10585
+ return keys.some((key) => record[key] === true || meta?.[key] === true);
10586
+ }
10587
+ function isActivityKind(kind) {
10588
+ return kind === "thought" || kind === "tool" || kind === "terminal";
10589
+ }
10590
+ function isOrdinaryVisibleTurn(message, role, kind) {
10591
+ if (role === "user" || role === "human") return kind === "standard" || kind === "";
10592
+ if (role === "assistant") return kind === "standard" || kind === "";
10593
+ return false;
10594
+ }
10595
+ function classifyChatMessageVisibility(message) {
10596
+ if (!message) {
10597
+ return {
10598
+ surface: "internal",
10599
+ isUserFacing: false,
10600
+ isActivityFacing: false,
10601
+ isInternal: true,
10602
+ explicitUserFacing: false,
10603
+ explicitHidden: true,
10604
+ role: "",
10605
+ kind: "standard",
10606
+ visibility: "",
10607
+ transcriptVisibility: "",
10608
+ audience: "",
10609
+ source: ""
10610
+ };
10611
+ }
10612
+ const meta = readMessageMeta(message);
10613
+ const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
10614
+ const kind = resolveChatMessageKind(message);
10615
+ const visibility = readVisibilityField(message, meta);
10616
+ const transcriptVisibility = readTranscriptVisibilityField(message, meta);
10617
+ const audience = readStringField(readRecordField(message, meta, "audience"));
10618
+ const source = readStringField(readRecordField(message, meta, "source"));
10619
+ 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"]);
10620
+ const explicitUserFacing = EXPLICIT_VISIBLE_VISIBILITIES.has(visibility) || EXPLICIT_VISIBLE_VISIBILITIES.has(transcriptVisibility) || audience === "chat" || hasBooleanMarker(message, meta, ["userFacing"]);
10621
+ if (explicitHidden) {
10622
+ const activityLike = isActivityKind(kind) || ACTIVITY_SOURCE_SET.has(source);
10623
+ return {
10624
+ surface: activityLike ? "activity" : "internal",
10625
+ isUserFacing: false,
10626
+ isActivityFacing: activityLike,
10627
+ isInternal: !activityLike,
10628
+ explicitUserFacing,
10629
+ explicitHidden,
10630
+ role,
10631
+ kind,
10632
+ visibility,
10633
+ transcriptVisibility,
10634
+ audience,
10635
+ source
10636
+ };
10637
+ }
10638
+ if (explicitUserFacing) {
10639
+ return {
10640
+ surface: "chat",
10641
+ isUserFacing: true,
10642
+ isActivityFacing: false,
10643
+ isInternal: false,
10644
+ explicitUserFacing,
10645
+ explicitHidden,
10646
+ role,
10647
+ kind,
10648
+ visibility,
10649
+ transcriptVisibility,
10650
+ audience,
10651
+ source
10652
+ };
10653
+ }
10654
+ if (INTERNAL_SOURCE_SET.has(source) || role === "system" || kind === "system") {
10655
+ return {
10656
+ surface: "internal",
10657
+ isUserFacing: false,
10658
+ isActivityFacing: false,
10659
+ isInternal: true,
10660
+ explicitUserFacing,
10661
+ explicitHidden,
10662
+ role,
10663
+ kind,
10664
+ visibility,
10665
+ transcriptVisibility,
10666
+ audience,
10667
+ source
10668
+ };
10669
+ }
10670
+ if (ACTIVITY_SOURCE_SET.has(source) || isActivityKind(kind)) {
10671
+ return {
10672
+ surface: "activity",
10673
+ isUserFacing: false,
10674
+ isActivityFacing: true,
10675
+ isInternal: false,
10676
+ explicitUserFacing,
10677
+ explicitHidden,
10678
+ role,
10679
+ kind,
10680
+ visibility,
10681
+ transcriptVisibility,
10682
+ audience,
10683
+ source
10684
+ };
10685
+ }
10686
+ const isUserFacing = isOrdinaryVisibleTurn(message, role, kind);
10687
+ return {
10688
+ surface: isUserFacing ? "chat" : "internal",
10689
+ isUserFacing,
10690
+ isActivityFacing: false,
10691
+ isInternal: !isUserFacing,
10692
+ explicitUserFacing,
10693
+ explicitHidden,
10694
+ role,
10695
+ kind,
10696
+ visibility,
10697
+ transcriptVisibility,
10698
+ audience,
10699
+ source
10700
+ };
10701
+ }
10702
+ function isUserFacingChatMessage(message) {
10703
+ return classifyChatMessageVisibility(message).isUserFacing;
10704
+ }
10705
+ function isActivityChatMessage(message) {
10706
+ return classifyChatMessageVisibility(message).isActivityFacing;
10707
+ }
10708
+ function isInternalChatMessage(message) {
10709
+ return classifyChatMessageVisibility(message).isInternal;
10710
+ }
10711
+ function filterUserFacingChatMessages(messages) {
10712
+ return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
10713
+ }
10714
+ function filterActivityChatMessages(messages) {
10715
+ return (Array.isArray(messages) ? messages : []).filter((message) => isActivityChatMessage(message));
10716
+ }
10717
+ function filterInternalChatMessages(messages) {
10718
+ return (Array.isArray(messages) ? messages : []).filter((message) => isInternalChatMessage(message));
10719
+ }
10720
+ function filterChatMessagesByVisibility(messages, surface) {
10721
+ return (Array.isArray(messages) ? messages : []).filter((message) => classifyChatMessageVisibility(message).surface === surface);
10722
+ }
10723
+ 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;
10724
+ var init_chat_message_normalization = __esm({
10725
+ "src/providers/chat-message-normalization.ts"() {
10726
+ "use strict";
10727
+ init_contracts();
10728
+ DEFAULT_FINAL_SUMMARY_MAX_CHARS = 4e3;
10729
+ BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
10730
+ CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
10731
+ CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
10732
+ CHAT_MESSAGE_AUDIENCES = ["chat", "debug", "trace", "internal"];
10733
+ CHAT_MESSAGE_SOURCES = [
10734
+ "assistant_text",
10735
+ "tool_call",
10736
+ "terminal_command",
10737
+ "runtime_activity",
10738
+ "runtime_status",
10739
+ "provider_chrome",
10740
+ "control"
10741
+ ];
10742
+ CHAT_MESSAGE_ACTIVITY_SOURCES = ["tool_call", "terminal_command", "runtime_activity"];
10743
+ CHAT_MESSAGE_INTERNAL_SOURCES = ["runtime_status", "provider_chrome", "control"];
10744
+ KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
10745
+ CHAT_MESSAGE_KIND_ALIASES = {
10746
+ text: "standard",
10747
+ message: "standard",
10748
+ assistant: "standard",
10749
+ thinking: "thought",
10750
+ think: "thought",
10751
+ reasoning: "thought",
10752
+ reason: "thought",
10753
+ toolcall: "tool",
10754
+ tool_call: "tool",
10755
+ tooluse: "tool",
10756
+ tool_use: "tool",
10757
+ action: "tool",
10758
+ command: "terminal",
10759
+ cmd: "terminal",
10760
+ shell: "terminal",
10761
+ console: "terminal"
10762
+ };
10763
+ EXPLICIT_HIDDEN_VISIBILITIES = /* @__PURE__ */ new Set(["hidden", "debug", "internal"]);
10764
+ EXPLICIT_VISIBLE_VISIBILITIES = /* @__PURE__ */ new Set(["visible", "user", "chat"]);
10765
+ HIDDEN_AUDIENCES = /* @__PURE__ */ new Set(["debug", "trace", "internal"]);
10766
+ ACTIVITY_SOURCE_SET = new Set(CHAT_MESSAGE_ACTIVITY_SOURCES);
10767
+ INTERNAL_SOURCE_SET = new Set(CHAT_MESSAGE_INTERNAL_SOURCES);
10768
+ }
10769
+ });
10770
+
10133
10771
  // src/mesh/mesh-reconcile-loop.ts
10134
10772
  function resolveReconcileIntervalMs() {
10135
10773
  const raw = readNonEmptyString2(process.env.MESH_RECONCILE_INTERVAL_MS);
@@ -10233,6 +10871,15 @@ async function runMeshReconcileTick(components) {
10233
10871
  LOG.warn("MeshReconcile", `Pending-claim recovery trigger failed for mesh ${mesh.id}: ${e?.message || e}`);
10234
10872
  }
10235
10873
  }
10874
+ for (const mesh of listMeshes()) {
10875
+ const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
10876
+ if (!daemonHostsMesh(mesh, selfIds)) continue;
10877
+ try {
10878
+ await reconcileUnterminatedDirectDispatches(components, mesh, selfIds, localDaemonId);
10879
+ } catch (e) {
10880
+ LOG.warn("MeshReconcile", `Completion reconcile failed for mesh ${mesh.id}: ${e?.message || e}`);
10881
+ }
10882
+ }
10236
10883
  const coordinators = findLiveCoordinators(components);
10237
10884
  if (coordinators.length === 0) {
10238
10885
  return;
@@ -10326,6 +10973,95 @@ async function pullRemoteNodeQueues(components, mesh, localDaemonId, candidateDa
10326
10973
  }
10327
10974
  }
10328
10975
  }
10976
+ function unwrapReadChatPayload(raw) {
10977
+ let cursor = raw;
10978
+ for (let depth = 0; depth < 4 && cursor && typeof cursor === "object"; depth++) {
10979
+ const record = cursor;
10980
+ if (Array.isArray(record.messages)) return record;
10981
+ if (record.payload && typeof record.payload === "object") {
10982
+ cursor = record.payload;
10983
+ continue;
10984
+ }
10985
+ if (record.result && typeof record.result === "object") {
10986
+ cursor = record.result;
10987
+ continue;
10988
+ }
10989
+ if (record.data && typeof record.data === "object") {
10990
+ cursor = record.data;
10991
+ continue;
10992
+ }
10993
+ break;
10994
+ }
10995
+ return cursor && typeof cursor === "object" ? cursor : null;
10996
+ }
10997
+ function readChatPayloadStatus(payload) {
10998
+ return readNonEmptyString2(payload?.status).toLowerCase();
10999
+ }
11000
+ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds, localDaemonId) {
11001
+ const dispatches = getActiveDirectDispatches(mesh.id);
11002
+ if (dispatches.length === 0) return;
11003
+ const dispatchMeshCommand = components.dispatchMeshCommand;
11004
+ const nodeById = new Map(mesh.nodes.map((n) => [n.id, n]));
11005
+ for (const dispatch of dispatches) {
11006
+ const sessionId = readNonEmptyString2(dispatch.sessionId);
11007
+ const nodeId = readNonEmptyString2(dispatch.nodeId);
11008
+ const taskId = readNonEmptyString2(dispatch.taskId);
11009
+ if (!sessionId || !nodeId || !taskId) continue;
11010
+ const node = nodeById.get(nodeId);
11011
+ const nodeDaemonId = readNonEmptyString2(node?.daemonId);
11012
+ const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || localDaemonId !== void 0 && nodeDaemonId === localDaemonId || !!components.instanceManager.getInstance(sessionId);
11013
+ const providerType = readNonEmptyString2(dispatch.providerType);
11014
+ const readArgs = {
11015
+ sessionId,
11016
+ targetSessionId: sessionId,
11017
+ tailLimit: 10,
11018
+ ...node?.workspace ? { workspace: node.workspace } : {},
11019
+ ...providerType ? { agentType: providerType, providerType } : {}
11020
+ };
11021
+ let payload = null;
11022
+ try {
11023
+ if (isLocalNode) {
11024
+ const result = await components.commandHandler.handle("read_chat", readArgs);
11025
+ if (result && result.success === false) continue;
11026
+ payload = unwrapReadChatPayload(result);
11027
+ } else if (dispatchMeshCommand) {
11028
+ const result = await dispatchMeshCommand(nodeDaemonId, "read_chat", readArgs);
11029
+ payload = unwrapReadChatPayload(result);
11030
+ if (payload && payload.success === false) continue;
11031
+ } else {
11032
+ continue;
11033
+ }
11034
+ } catch {
11035
+ continue;
11036
+ }
11037
+ if (!payload) continue;
11038
+ if (readChatPayloadStatus(payload) !== "idle") continue;
11039
+ const messages = Array.isArray(payload.messages) ? payload.messages : [];
11040
+ const evidence = extractFinalAssistantSummaryEvidence(messages);
11041
+ if (!evidence.finalSummary) continue;
11042
+ const providerSessionId = readNonEmptyString2(payload.providerSessionId);
11043
+ const coordinatorDaemonId = selfIds.find((id) => !!id);
11044
+ try {
11045
+ const result = reconcileDirectDispatchCompletionFromTranscript({
11046
+ meshId: mesh.id,
11047
+ nodeId,
11048
+ sessionId,
11049
+ providerType: providerType || void 0,
11050
+ providerSessionId: providerSessionId || void 0,
11051
+ taskId,
11052
+ finalSummary: evidence.finalSummary,
11053
+ ...evidence.transcriptMessageAt ? { transcriptMessageAt: evidence.transcriptMessageAt } : {},
11054
+ ...coordinatorDaemonId ? { targetCoordinatorDaemonId: coordinatorDaemonId } : {},
11055
+ source: "daemon_reconcile_transcript_completion"
11056
+ });
11057
+ if (result.reconciled) {
11058
+ LOG.info("MeshReconcile", `Synthesized missing completion (${result.kind}) for task ${taskId} on node ${nodeId} (mesh ${mesh.id})`);
11059
+ }
11060
+ } catch (e) {
11061
+ LOG.warn("MeshReconcile", `Transcript completion reconcile threw for task ${taskId}: ${e?.message || e}`);
11062
+ }
11063
+ }
11064
+ }
10329
11065
  function extractPendingEvents(raw) {
10330
11066
  if (Array.isArray(raw)) return raw;
10331
11067
  if (raw && typeof raw === "object") {
@@ -10375,6 +11111,9 @@ var init_mesh_reconcile_loop = __esm({
10375
11111
  init_mesh_events_coordinator();
10376
11112
  init_mesh_unresolved_forward_outbox();
10377
11113
  init_mesh_events_utils();
11114
+ init_mesh_work_queue();
11115
+ init_mesh_events_stale();
11116
+ init_chat_message_normalization();
10378
11117
  DEFAULT_RECONCILE_INTERVAL_MS = 4e3;
10379
11118
  }
10380
11119
  });
@@ -14144,6 +14883,8 @@ ${lastSnapshot}`;
14144
14883
  errorMessage: this.parseErrorMessage || this.engine.providerErrorMessage || void 0,
14145
14884
  errorReason: this.parseErrorMessage ? "parse_error" : this.engine.providerErrorReason || void 0,
14146
14885
  providerSessionId: this.providerSessionId || void 0,
14886
+ lastOutputAt: this.lastOutputAt,
14887
+ lastScreenChangeAt: this.lastScreenChangeAt,
14147
14888
  ...bufferState ? { bufferState } : {}
14148
14889
  };
14149
14890
  }
@@ -16837,7 +17578,8 @@ async function handleGitCommand(command, args, services = defaultGitCommandServi
16837
17578
  if (includeSubmodules !== void 0) statusParams.includeSubmodules = includeSubmodules;
16838
17579
  if (submoduleIgnorePaths && submoduleIgnorePaths.length > 0) statusParams.submoduleIgnorePaths = submoduleIgnorePaths;
16839
17580
  const status = await runService(() => services.getStatus(statusParams));
16840
- return "success" in status ? status : { success: true, status };
17581
+ if ("success" in status) return status;
17582
+ return { success: true, status, reporterPlatform: process.platform, reporterArch: process.arch };
16841
17583
  }
16842
17584
  case "git_diff_summary": {
16843
17585
  if (!services.getDiffSummary) return serviceNotImplemented(command);
@@ -20528,258 +21270,11 @@ var CdpDomHandlers = class {
20528
21270
  };
20529
21271
 
20530
21272
  // src/providers/ide-provider-instance.ts
21273
+ init_contracts();
20531
21274
  import * as crypto2 from "crypto";
20532
21275
 
20533
- // src/providers/io-contracts.ts
20534
- function normalizeInputEnvelope(input) {
20535
- const normalized = normalizeInputEnvelopePayload(input);
20536
- const textFallback = normalized.textFallback ?? flattenInputParts(normalized.parts);
20537
- return {
20538
- parts: normalized.parts,
20539
- textFallback,
20540
- ...normalized.metadata ? { metadata: normalized.metadata } : {}
20541
- };
20542
- }
20543
- function normalizeMessageParts(content) {
20544
- if (typeof content === "string") return [{ type: "text", text: content }];
20545
- if (!Array.isArray(content)) {
20546
- if (content && typeof content === "object" && typeof content.text === "string") {
20547
- return [{ type: "text", text: String(content.text) }];
20548
- }
20549
- return [];
20550
- }
20551
- const parts = [];
20552
- for (const raw of content) {
20553
- if (typeof raw === "string") {
20554
- parts.push({ type: "text", text: raw });
20555
- continue;
20556
- }
20557
- if (!raw || typeof raw !== "object") continue;
20558
- const part = normalizeMessagePartObject(raw);
20559
- if (part) parts.push(part);
20560
- }
20561
- return parts;
20562
- }
20563
- function flattenMessageParts(parts) {
20564
- return parts.map((part) => {
20565
- if (part.type === "text") return part.text;
20566
- if (part.type === "resource") return part.resource.text || "";
20567
- if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
20568
- if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
20569
- if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
20570
- if (part.type === "resource_link") return [part.name, part.description].filter(Boolean).join("\n");
20571
- return "";
20572
- }).filter((value) => value.length > 0).join("\n");
20573
- }
20574
- function normalizeInputEnvelopePayload(input) {
20575
- if (typeof input === "string") {
20576
- return { parts: [{ type: "text", text: input }], textFallback: input };
20577
- }
20578
- if (!input || typeof input !== "object") {
20579
- return { parts: [], textFallback: "" };
20580
- }
20581
- const record = input;
20582
- const nestedInput = record.input;
20583
- if (nestedInput && typeof nestedInput === "object") {
20584
- const nested = nestedInput;
20585
- return {
20586
- parts: normalizeInputParts(nested.parts ?? nested.prompt),
20587
- textFallback: typeof nested.textFallback === "string" ? nested.textFallback : void 0,
20588
- metadata: normalizeInputMetadata(nested.metadata)
20589
- };
20590
- }
20591
- const directText = typeof record.text === "string" ? record.text : typeof record.message === "string" ? record.message : void 0;
20592
- if (directText !== void 0) {
20593
- return { parts: [{ type: "text", text: directText }], textFallback: directText };
20594
- }
20595
- const directParts = normalizeInputParts(record.parts ?? record.prompt);
20596
- return {
20597
- parts: directParts,
20598
- textFallback: typeof record.textFallback === "string" ? record.textFallback : void 0,
20599
- metadata: normalizeInputMetadata(record.metadata)
20600
- };
20601
- }
20602
- function normalizeInputMetadata(value) {
20603
- if (!value || typeof value !== "object") return void 0;
20604
- const record = value;
20605
- const metadata = {};
20606
- if (record.source === "dashboard" || record.source === "shortcut_api" || record.source === "provider_script" || record.source === "session_replay") {
20607
- metadata.source = record.source;
20608
- }
20609
- if (typeof record.clientTimestamp === "number" && Number.isFinite(record.clientTimestamp)) {
20610
- metadata.clientTimestamp = record.clientTimestamp;
20611
- }
20612
- return Object.keys(metadata).length > 0 ? metadata : void 0;
20613
- }
20614
- function normalizeInputParts(value) {
20615
- if (!Array.isArray(value)) return [];
20616
- const parts = [];
20617
- for (const raw of value) {
20618
- if (typeof raw === "string") {
20619
- parts.push({ type: "text", text: raw });
20620
- continue;
20621
- }
20622
- if (!raw || typeof raw !== "object") continue;
20623
- const part = normalizeInputPartObject(raw);
20624
- if (part) parts.push(part);
20625
- }
20626
- return parts;
20627
- }
20628
- function normalizeInputPartObject(raw) {
20629
- const type = raw.type;
20630
- if (type === "text" && typeof raw.text === "string") {
20631
- return { type, text: raw.text };
20632
- }
20633
- if (type === "image" && typeof raw.mimeType === "string") {
20634
- return {
20635
- type,
20636
- mimeType: raw.mimeType,
20637
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
20638
- ...typeof raw.data === "string" ? { data: raw.data } : {},
20639
- ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
20640
- };
20641
- }
20642
- if (type === "audio" && typeof raw.mimeType === "string") {
20643
- return {
20644
- type,
20645
- mimeType: raw.mimeType,
20646
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
20647
- ...typeof raw.data === "string" ? { data: raw.data } : {},
20648
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
20649
- };
20650
- }
20651
- if (type === "video" && typeof raw.mimeType === "string") {
20652
- return {
20653
- type,
20654
- mimeType: raw.mimeType,
20655
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
20656
- ...typeof raw.data === "string" ? { data: raw.data } : {},
20657
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
20658
- ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
20659
- };
20660
- }
20661
- if (type === "resource" && typeof raw.uri === "string") {
20662
- return {
20663
- type,
20664
- uri: raw.uri,
20665
- ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
20666
- ...typeof raw.name === "string" ? { name: raw.name } : {},
20667
- ...typeof raw.text === "string" ? { text: raw.text } : {},
20668
- ...typeof raw.data === "string" ? { data: raw.data } : {}
20669
- };
20670
- }
20671
- if (type === "resource_link" && typeof raw.uri === "string") {
20672
- return {
20673
- type,
20674
- uri: raw.uri,
20675
- name: typeof raw.name === "string" ? raw.name : getUriDisplayName(raw.uri, "resource"),
20676
- ...typeof raw.title === "string" ? { title: raw.title } : {},
20677
- ...typeof raw.description === "string" ? { description: raw.description } : {},
20678
- ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
20679
- ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
20680
- ...normalizeAnnotationsProperty(raw.annotations)
20681
- };
20682
- }
20683
- return null;
20684
- }
20685
- function normalizeMessagePartObject(raw) {
20686
- const type = raw.type;
20687
- if (type === "text" && typeof raw.text === "string") {
20688
- return { type, text: raw.text };
20689
- }
20690
- if (type === "image" && typeof raw.mimeType === "string") {
20691
- return {
20692
- type,
20693
- mimeType: raw.mimeType,
20694
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
20695
- ...typeof raw.data === "string" ? { data: raw.data } : {},
20696
- ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
20697
- };
20698
- }
20699
- if (type === "audio" && typeof raw.mimeType === "string") {
20700
- return {
20701
- type,
20702
- mimeType: raw.mimeType,
20703
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
20704
- ...typeof raw.data === "string" ? { data: raw.data } : {},
20705
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
20706
- };
20707
- }
20708
- if (type === "video" && typeof raw.mimeType === "string") {
20709
- return {
20710
- type,
20711
- mimeType: raw.mimeType,
20712
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
20713
- ...typeof raw.data === "string" ? { data: raw.data } : {},
20714
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
20715
- ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
20716
- };
20717
- }
20718
- if (type === "resource_link" && typeof raw.uri === "string" && typeof raw.name === "string") {
20719
- return {
20720
- type,
20721
- uri: raw.uri,
20722
- name: raw.name,
20723
- ...typeof raw.title === "string" ? { title: raw.title } : {},
20724
- ...typeof raw.description === "string" ? { description: raw.description } : {},
20725
- ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
20726
- ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
20727
- ...normalizeAnnotationsProperty(raw.annotations)
20728
- };
20729
- }
20730
- if (type === "resource" && raw.resource && typeof raw.resource === "object") {
20731
- const resource = raw.resource;
20732
- if (typeof resource.uri !== "string") return null;
20733
- return {
20734
- type,
20735
- resource: {
20736
- uri: resource.uri,
20737
- ...typeof resource.mimeType === "string" || resource.mimeType === null ? { mimeType: resource.mimeType } : {},
20738
- ...typeof resource.text === "string" ? { text: resource.text } : {},
20739
- ...typeof resource.blob === "string" ? { blob: resource.blob } : {}
20740
- }
20741
- };
20742
- }
20743
- return null;
20744
- }
20745
- function flattenInputParts(parts) {
20746
- return parts.map((part) => {
20747
- if (part.type === "text") return part.text;
20748
- if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
20749
- if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
20750
- if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
20751
- if (part.type === "resource_link") return [part.title, part.name, part.description, part.uri].filter(Boolean).join("\n");
20752
- if (part.type === "resource") return part.text || part.name || part.uri;
20753
- return "";
20754
- }).filter((value) => value.length > 0).join("\n");
20755
- }
20756
- function getUriDisplayName(uri, fallback) {
20757
- try {
20758
- const pathname = uri.startsWith("file://") ? new URL(uri).pathname : uri;
20759
- return pathname.split(/[\\/]/).filter(Boolean).pop() || fallback;
20760
- } catch {
20761
- return uri.split(/[\\/]/).filter(Boolean).pop() || fallback;
20762
- }
20763
- }
20764
- function normalizeAnnotationsProperty(value) {
20765
- if (!value || typeof value !== "object") return {};
20766
- const record = value;
20767
- const annotations = {};
20768
- if (Array.isArray(record.audience)) {
20769
- const audience = record.audience.filter((item) => item === "user" || item === "assistant");
20770
- if (audience.length > 0) annotations.audience = audience;
20771
- }
20772
- if (typeof record.priority === "number" && Number.isFinite(record.priority)) {
20773
- annotations.priority = record.priority;
20774
- }
20775
- return Object.keys(annotations).length > 0 ? { annotations } : {};
20776
- }
20777
-
20778
- // src/providers/contracts.ts
20779
- function flattenContent(content) {
20780
- if (typeof content === "string") return content;
20781
- return flattenMessageParts(normalizeMessageParts(content));
20782
- }
21276
+ // src/providers/extension-provider-instance.ts
21277
+ init_contracts();
20783
21278
 
20784
21279
  // src/providers/status-monitor.ts
20785
21280
  var DEFAULT_MONITOR_CONFIG = {
@@ -20893,342 +21388,9 @@ var StatusMonitor = class {
20893
21388
  }
20894
21389
  };
20895
21390
 
20896
- // src/providers/chat-message-normalization.ts
20897
- var DEFAULT_FINAL_SUMMARY_MAX_CHARS = 4e3;
20898
- function extractFinalSummaryFromMessages(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
20899
- if (!Array.isArray(messages) || messages.length === 0) return "";
20900
- for (let i = messages.length - 1; i >= 0; i--) {
20901
- const msg = messages[i];
20902
- if (!msg) continue;
20903
- const classification = classifyChatMessageVisibility(msg);
20904
- if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
20905
- const text = flattenContent(msg.content).trim();
20906
- if (text) return text.slice(0, maxChars);
20907
- }
20908
- }
20909
- return "";
20910
- }
20911
- var BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
20912
- var CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
20913
- var CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
20914
- var CHAT_MESSAGE_AUDIENCES = ["chat", "debug", "trace", "internal"];
20915
- var CHAT_MESSAGE_SOURCES = [
20916
- "assistant_text",
20917
- "tool_call",
20918
- "terminal_command",
20919
- "runtime_activity",
20920
- "runtime_status",
20921
- "provider_chrome",
20922
- "control"
20923
- ];
20924
- var CHAT_MESSAGE_ACTIVITY_SOURCES = ["tool_call", "terminal_command", "runtime_activity"];
20925
- var CHAT_MESSAGE_INTERNAL_SOURCES = ["runtime_status", "provider_chrome", "control"];
20926
- var KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
20927
- var CHAT_MESSAGE_KIND_ALIASES = {
20928
- text: "standard",
20929
- message: "standard",
20930
- assistant: "standard",
20931
- thinking: "thought",
20932
- think: "thought",
20933
- reasoning: "thought",
20934
- reason: "thought",
20935
- toolcall: "tool",
20936
- tool_call: "tool",
20937
- tooluse: "tool",
20938
- tool_use: "tool",
20939
- action: "tool",
20940
- command: "terminal",
20941
- cmd: "terminal",
20942
- shell: "terminal",
20943
- console: "terminal"
20944
- };
20945
- function canonicalizeKindHint(value) {
20946
- return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
20947
- }
20948
- function resolveBuiltinOrAliasKind(kind) {
20949
- if (typeof kind !== "string") return null;
20950
- const normalizedKind = canonicalizeKindHint(kind);
20951
- if (!normalizedKind) return null;
20952
- if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
20953
- return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
20954
- }
20955
- function inferHintKind(value) {
20956
- const direct = resolveBuiltinOrAliasKind(value);
20957
- if (direct) return direct;
20958
- if (typeof value !== "string") return null;
20959
- const normalized = canonicalizeKindHint(value);
20960
- if (!normalized) return null;
20961
- if (/thought|thinking|reasoning/.test(normalized)) return "thought";
20962
- if (/tool/.test(normalized)) return "tool";
20963
- if (/terminal|command|shell|console/.test(normalized)) return "terminal";
20964
- return null;
20965
- }
20966
- function inferKindFromToolCalls(message) {
20967
- const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
20968
- if (toolCalls.length === 0) return null;
20969
- if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
20970
- if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
20971
- if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
20972
- return "terminal";
20973
- }
20974
- return "tool";
20975
- }
20976
- function inferMissingChatMessageKind(message) {
20977
- const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
20978
- if (role === "system") return "system";
20979
- const meta = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
20980
- const hintCandidates = [
20981
- message?._sub,
20982
- message?._type,
20983
- meta?.label,
20984
- typeof message?.senderName === "string" ? message.senderName : void 0
20985
- ];
20986
- for (const candidate of hintCandidates) {
20987
- const inferred = inferHintKind(candidate);
20988
- if (inferred) return inferred;
20989
- }
20990
- const inferredFromToolCalls = inferKindFromToolCalls(message);
20991
- if (inferredFromToolCalls) return inferredFromToolCalls;
20992
- return null;
20993
- }
20994
- function isBuiltinChatMessageKind(kind) {
20995
- return resolveBuiltinOrAliasKind(kind) !== null;
20996
- }
20997
- function normalizeChatMessageKind(kind, role) {
20998
- const resolvedKind = resolveBuiltinOrAliasKind(kind);
20999
- if (resolvedKind) return resolvedKind;
21000
- const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
21001
- return normalizedRole === "system" ? "system" : "standard";
21002
- }
21003
- function resolveChatMessageKind(message) {
21004
- const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
21005
- if (explicitKind) return explicitKind;
21006
- const inferredKind = inferMissingChatMessageKind(message);
21007
- if (inferredKind) return inferredKind;
21008
- return normalizeChatMessageKind(message?.kind, message?.role);
21009
- }
21010
- function buildChatMessage(message) {
21011
- return {
21012
- ...message,
21013
- kind: resolveChatMessageKind(message)
21014
- };
21015
- }
21016
- function buildSystemChatMessage(message) {
21017
- return buildChatMessage({
21018
- ...message,
21019
- role: "system",
21020
- kind: message?.kind || "system"
21021
- });
21022
- }
21023
- function buildRuntimeSystemChatMessage(message) {
21024
- return buildSystemChatMessage({
21025
- ...message,
21026
- senderName: typeof message?.senderName === "string" && message.senderName.trim() ? message.senderName : "System"
21027
- });
21028
- }
21029
- function buildAssistantChatMessage(message) {
21030
- return buildChatMessage({
21031
- ...message,
21032
- role: "assistant",
21033
- kind: message?.kind || "standard"
21034
- });
21035
- }
21036
- function buildThoughtChatMessage(message) {
21037
- return buildAssistantChatMessage({
21038
- ...message,
21039
- kind: message?.kind || "thought"
21040
- });
21041
- }
21042
- function buildToolChatMessage(message) {
21043
- return buildAssistantChatMessage({
21044
- ...message,
21045
- kind: message?.kind || "tool"
21046
- });
21047
- }
21048
- function buildTerminalChatMessage(message) {
21049
- return buildAssistantChatMessage({
21050
- ...message,
21051
- kind: message?.kind || "terminal"
21052
- });
21053
- }
21054
- function buildUserChatMessage(message) {
21055
- return buildChatMessage({
21056
- ...message,
21057
- role: "user",
21058
- kind: message?.kind || "standard"
21059
- });
21060
- }
21061
- function normalizeChatMessage(message) {
21062
- return buildChatMessage(message);
21063
- }
21064
- function normalizeChatMessages(messages) {
21065
- return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
21066
- }
21067
- function readMessageMeta(message) {
21068
- const meta = message?.meta;
21069
- return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : null;
21070
- }
21071
- function readStringField(value) {
21072
- return typeof value === "string" ? value.trim().toLowerCase() : "";
21073
- }
21074
- function readRecordField(message, meta, key) {
21075
- const record = message;
21076
- return record[key] ?? meta?.[key];
21077
- }
21078
- function readVisibilityField(message, meta) {
21079
- return readStringField(readRecordField(message, meta, "visibility"));
21080
- }
21081
- function readTranscriptVisibilityField(message, meta) {
21082
- const record = message;
21083
- return readStringField(record.transcriptVisibility ?? meta?.transcriptVisibility ?? record.visibility ?? meta?.visibility);
21084
- }
21085
- var EXPLICIT_HIDDEN_VISIBILITIES = /* @__PURE__ */ new Set(["hidden", "debug", "internal"]);
21086
- var EXPLICIT_VISIBLE_VISIBILITIES = /* @__PURE__ */ new Set(["visible", "user", "chat"]);
21087
- var HIDDEN_AUDIENCES = /* @__PURE__ */ new Set(["debug", "trace", "internal"]);
21088
- var ACTIVITY_SOURCE_SET = new Set(CHAT_MESSAGE_ACTIVITY_SOURCES);
21089
- var INTERNAL_SOURCE_SET = new Set(CHAT_MESSAGE_INTERNAL_SOURCES);
21090
- function hasBooleanMarker(message, meta, keys) {
21091
- const record = message;
21092
- return keys.some((key) => record[key] === true || meta?.[key] === true);
21093
- }
21094
- function isActivityKind(kind) {
21095
- return kind === "thought" || kind === "tool" || kind === "terminal";
21096
- }
21097
- function isOrdinaryVisibleTurn(message, role, kind) {
21098
- if (role === "user" || role === "human") return kind === "standard" || kind === "";
21099
- if (role === "assistant") return kind === "standard" || kind === "";
21100
- return false;
21101
- }
21102
- function classifyChatMessageVisibility(message) {
21103
- if (!message) {
21104
- return {
21105
- surface: "internal",
21106
- isUserFacing: false,
21107
- isActivityFacing: false,
21108
- isInternal: true,
21109
- explicitUserFacing: false,
21110
- explicitHidden: true,
21111
- role: "",
21112
- kind: "standard",
21113
- visibility: "",
21114
- transcriptVisibility: "",
21115
- audience: "",
21116
- source: ""
21117
- };
21118
- }
21119
- const meta = readMessageMeta(message);
21120
- const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
21121
- const kind = resolveChatMessageKind(message);
21122
- const visibility = readVisibilityField(message, meta);
21123
- const transcriptVisibility = readTranscriptVisibilityField(message, meta);
21124
- const audience = readStringField(readRecordField(message, meta, "audience"));
21125
- const source = readStringField(readRecordField(message, meta, "source"));
21126
- 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"]);
21127
- const explicitUserFacing = EXPLICIT_VISIBLE_VISIBILITIES.has(visibility) || EXPLICIT_VISIBLE_VISIBILITIES.has(transcriptVisibility) || audience === "chat" || hasBooleanMarker(message, meta, ["userFacing"]);
21128
- if (explicitHidden) {
21129
- const activityLike = isActivityKind(kind) || ACTIVITY_SOURCE_SET.has(source);
21130
- return {
21131
- surface: activityLike ? "activity" : "internal",
21132
- isUserFacing: false,
21133
- isActivityFacing: activityLike,
21134
- isInternal: !activityLike,
21135
- explicitUserFacing,
21136
- explicitHidden,
21137
- role,
21138
- kind,
21139
- visibility,
21140
- transcriptVisibility,
21141
- audience,
21142
- source
21143
- };
21144
- }
21145
- if (explicitUserFacing) {
21146
- return {
21147
- surface: "chat",
21148
- isUserFacing: true,
21149
- isActivityFacing: false,
21150
- isInternal: false,
21151
- explicitUserFacing,
21152
- explicitHidden,
21153
- role,
21154
- kind,
21155
- visibility,
21156
- transcriptVisibility,
21157
- audience,
21158
- source
21159
- };
21160
- }
21161
- if (INTERNAL_SOURCE_SET.has(source) || role === "system" || kind === "system") {
21162
- return {
21163
- surface: "internal",
21164
- isUserFacing: false,
21165
- isActivityFacing: false,
21166
- isInternal: true,
21167
- explicitUserFacing,
21168
- explicitHidden,
21169
- role,
21170
- kind,
21171
- visibility,
21172
- transcriptVisibility,
21173
- audience,
21174
- source
21175
- };
21176
- }
21177
- if (ACTIVITY_SOURCE_SET.has(source) || isActivityKind(kind)) {
21178
- return {
21179
- surface: "activity",
21180
- isUserFacing: false,
21181
- isActivityFacing: true,
21182
- isInternal: false,
21183
- explicitUserFacing,
21184
- explicitHidden,
21185
- role,
21186
- kind,
21187
- visibility,
21188
- transcriptVisibility,
21189
- audience,
21190
- source
21191
- };
21192
- }
21193
- const isUserFacing = isOrdinaryVisibleTurn(message, role, kind);
21194
- return {
21195
- surface: isUserFacing ? "chat" : "internal",
21196
- isUserFacing,
21197
- isActivityFacing: false,
21198
- isInternal: !isUserFacing,
21199
- explicitUserFacing,
21200
- explicitHidden,
21201
- role,
21202
- kind,
21203
- visibility,
21204
- transcriptVisibility,
21205
- audience,
21206
- source
21207
- };
21208
- }
21209
- function isUserFacingChatMessage(message) {
21210
- return classifyChatMessageVisibility(message).isUserFacing;
21211
- }
21212
- function isActivityChatMessage(message) {
21213
- return classifyChatMessageVisibility(message).isActivityFacing;
21214
- }
21215
- function isInternalChatMessage(message) {
21216
- return classifyChatMessageVisibility(message).isInternal;
21217
- }
21218
- function filterUserFacingChatMessages(messages) {
21219
- return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
21220
- }
21221
- function filterActivityChatMessages(messages) {
21222
- return (Array.isArray(messages) ? messages : []).filter((message) => isActivityChatMessage(message));
21223
- }
21224
- function filterInternalChatMessages(messages) {
21225
- return (Array.isArray(messages) ? messages : []).filter((message) => isInternalChatMessage(message));
21226
- }
21227
- function filterChatMessagesByVisibility(messages, surface) {
21228
- return (Array.isArray(messages) ? messages : []).filter((message) => classifyChatMessageVisibility(message).surface === surface);
21229
- }
21230
-
21231
21391
  // src/providers/control-effects.ts
21392
+ init_contracts();
21393
+ init_chat_message_normalization();
21232
21394
  function extractProviderControlValues(controls, data) {
21233
21395
  if (!data || typeof data !== "object") return void 0;
21234
21396
  const values = {};
@@ -21422,6 +21584,7 @@ ${cleanBody}`;
21422
21584
  }
21423
21585
 
21424
21586
  // src/config/chat-history.ts
21587
+ init_chat_message_normalization();
21425
21588
  import * as fs6 from "fs";
21426
21589
  import * as path14 from "path";
21427
21590
  import * as os8 from "os";
@@ -22963,6 +23126,9 @@ function resolveProviderStateSurface(params) {
22963
23126
  };
22964
23127
  }
22965
23128
 
23129
+ // src/providers/extension-provider-instance.ts
23130
+ init_chat_message_normalization();
23131
+
22966
23132
  // src/providers/open-panel-support.ts
22967
23133
  var IDE_PROVIDER_SESSION_CAPABILITIES_BASE = [
22968
23134
  "read_chat",
@@ -23398,6 +23564,9 @@ ${effect.notification.body || ""}`.trim();
23398
23564
  // src/providers/ide-provider-instance.ts
23399
23565
  init_logger();
23400
23566
 
23567
+ // src/providers/read-chat-contract.ts
23568
+ init_contracts();
23569
+
23401
23570
  // src/providers/transcript-v2.ts
23402
23571
  var CHAT_CONTRACT_VERSION_V1 = "1.0";
23403
23572
 
@@ -23617,6 +23786,7 @@ function looksLikeActiveApprovalPromptText(content) {
23617
23786
  }
23618
23787
 
23619
23788
  // src/providers/ide-provider-instance.ts
23789
+ init_chat_message_normalization();
23620
23790
  async function withTimeout(promise, timeoutMs, label) {
23621
23791
  let timer = null;
23622
23792
  try {
@@ -25269,6 +25439,7 @@ function resolveLegacyProviderScript(fn, scriptName, params) {
25269
25439
  }
25270
25440
 
25271
25441
  // src/commands/chat-commands.ts
25442
+ init_contracts();
25272
25443
  import * as fs7 from "fs";
25273
25444
  import * as os9 from "os";
25274
25445
  import * as path15 from "path";
@@ -25761,6 +25932,7 @@ function synthesiseV1UnitKey(providerType, sessionId, positionalSeq, message) {
25761
25932
  var CHAT_SOURCE_REGISTRY = new ChatSourceRegistry();
25762
25933
 
25763
25934
  // src/commands/chat-commands.ts
25935
+ init_chat_message_normalization();
25764
25936
  var RECENT_SEND_WINDOW_MS = 1200;
25765
25937
  var READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
25766
25938
  var HOT_TAIL_MIN_LIMIT = 60;
@@ -30594,6 +30766,7 @@ import { execFileSync as execFileSync2 } from "child_process";
30594
30766
  import chalk from "chalk";
30595
30767
 
30596
30768
  // src/providers/cli-provider-instance.ts
30769
+ init_contracts();
30597
30770
  import * as os18 from "os";
30598
30771
  import * as path24 from "path";
30599
30772
  import * as crypto4 from "crypto";
@@ -33135,6 +33308,9 @@ function normalizeProviderSessionId(provider, providerSessionId) {
33135
33308
  return normalizedId;
33136
33309
  }
33137
33310
 
33311
+ // src/providers/cli-provider-instance.ts
33312
+ init_chat_message_normalization();
33313
+
33138
33314
  // src/providers/working-dir.ts
33139
33315
  function workingDirBasename(p) {
33140
33316
  return (p || "").split(/[\\/]/).filter(Boolean).pop() || "session";
@@ -34265,7 +34441,7 @@ var CliProviderInstance = class _CliProviderInstance {
34265
34441
  const dirName = workingDirBasename(this.workingDir);
34266
34442
  const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
34267
34443
  const partial = this.adapter.getPartialResponse();
34268
- const progressFingerprint = newStatus === "generating" ? `${partial || ""}`.slice(-2e3) : void 0;
34444
+ const progressFingerprint = newStatus === "generating" ? `${`${partial || ""}`.slice(-2e3)}::scr=${adapterStatus.lastScreenChangeAt ?? 0}::out=${adapterStatus.lastOutputAt ?? 0}` : void 0;
34269
34445
  const previousStatus = this.lastStatus;
34270
34446
  if (newStatus !== this.lastStatus) {
34271
34447
  LOG.info("CLI", `[${this.type}] status: ${this.lastStatus} \u2192 ${newStatus}`);
@@ -34937,6 +35113,7 @@ ${effect.notification.body || ""}`.trim();
34937
35113
  };
34938
35114
 
34939
35115
  // src/providers/acp-provider-instance.ts
35116
+ init_contracts();
34940
35117
  import * as path25 from "path";
34941
35118
  import { Readable, Writable } from "stream";
34942
35119
  import { spawn } from "child_process";
@@ -34946,6 +35123,7 @@ import {
34946
35123
  RequestError,
34947
35124
  PROTOCOL_VERSION
34948
35125
  } from "@agentclientprotocol/sdk";
35126
+ init_chat_message_normalization();
34949
35127
  init_logger();
34950
35128
  function getPromptCapabilityFlags(agentCapabilities) {
34951
35129
  const prompt = agentCapabilities?.promptCapabilities || {};
@@ -36175,6 +36353,7 @@ ${rawInput}` : rawInput;
36175
36353
  };
36176
36354
 
36177
36355
  // src/commands/cli-manager.ts
36356
+ init_contracts();
36178
36357
  init_logger();
36179
36358
 
36180
36359
  // src/commands/hosted-runtime-restore.ts
@@ -42695,6 +42874,25 @@ function recordInlineMeshDirectGitTruth(node, git, source) {
42695
42874
  node.lastSeenAt = updatedAt;
42696
42875
  const repoRoot = readStringValue(nextGit.repoRoot);
42697
42876
  if (repoRoot && !readStringValue(node.repoRoot)) node.repoRoot = repoRoot;
42877
+ const isLocalSource = source === "selected_coordinator_local_git";
42878
+ const reporterPlatform = readStringValue(git.reporterPlatform) ?? (isLocalSource ? process.platform : null);
42879
+ const reporterArch = readStringValue(git.reporterArch) ?? (isLocalSource ? process.arch : null);
42880
+ stampNodeReporterPlatform(node, reporterPlatform, reporterArch);
42881
+ }
42882
+ function stampNodeReporterPlatform(node, platform10, arch2) {
42883
+ if (!node || typeof node !== "object" || Array.isArray(node)) return;
42884
+ if (!platform10 && !arch2) return;
42885
+ const overrides = node.userOverrides && typeof node.userOverrides === "object" && !Array.isArray(node.userOverrides) ? node.userOverrides : {};
42886
+ let changed = false;
42887
+ if (platform10 && !readStringValue(overrides.platform)) {
42888
+ overrides.platform = platform10;
42889
+ changed = true;
42890
+ }
42891
+ if (arch2 && !readStringValue(overrides.arch)) {
42892
+ overrides.arch = arch2;
42893
+ changed = true;
42894
+ }
42895
+ if (changed) node.userOverrides = overrides;
42698
42896
  }
42699
42897
  function buildCachedInlineMeshGitStatus(node) {
42700
42898
  const liveGit = buildInlineMeshTransitGitStatus(node);
@@ -43188,7 +43386,13 @@ async function probeRemoteMeshGitStatus(args) {
43188
43386
  new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), args.timeoutMs))
43189
43387
  ]);
43190
43388
  const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
43191
- return remoteGit && typeof remoteGit === "object" && typeof remoteGit.isGitRepo === "boolean" ? remoteGit : null;
43389
+ if (!remoteGit || typeof remoteGit !== "object" || typeof remoteGit.isGitRepo !== "boolean") return null;
43390
+ const reporterPlatform = readStringValue(remoteResult?.reporterPlatform);
43391
+ const reporterArch = readStringValue(remoteResult?.reporterArch);
43392
+ const git = remoteGit;
43393
+ if (reporterPlatform) git.reporterPlatform = reporterPlatform;
43394
+ if (reporterArch) git.reporterArch = reporterArch;
43395
+ return git;
43192
43396
  }
43193
43397
  var MESH_DIRECT_PROBE_MAX_RETRIES = 2;
43194
43398
  function readMeshConnectionState(connection) {
@@ -50088,6 +50292,7 @@ var DEFAULT_DAEMON_PORT = 19222;
50088
50292
  var DAEMON_WS_PATH = "/ipc";
50089
50293
 
50090
50294
  // src/chat/subscription-updates.ts
50295
+ init_chat_message_normalization();
50091
50296
  function normalizeModalButtons(value) {
50092
50297
  return Array.isArray(value) ? value.filter((button) => typeof button === "string") : [];
50093
50298
  }
@@ -50228,6 +50433,7 @@ async function runAsyncBatch(items, worker, options = {}) {
50228
50433
  }
50229
50434
 
50230
50435
  // src/agent-stream/provider-adapter.ts
50436
+ init_chat_message_normalization();
50231
50437
  var ProviderStreamAdapter = class {
50232
50438
  agentType;
50233
50439
  agentName;
@@ -50912,6 +51118,7 @@ var DaemonAgentStreamManager = class {
50912
51118
 
50913
51119
  // src/agent-stream/poller.ts
50914
51120
  init_logger();
51121
+ init_chat_message_normalization();
50915
51122
  var AgentStreamPoller = class {
50916
51123
  deps;
50917
51124
  timer = null;
@@ -51433,6 +51640,10 @@ var ProviderInstanceManager = class {
51433
51640
  }
51434
51641
  };
51435
51642
 
51643
+ // src/index.ts
51644
+ init_io_contracts();
51645
+ init_chat_message_normalization();
51646
+
51436
51647
  // src/providers/version-archive.ts
51437
51648
  import * as fs27 from "fs";
51438
51649
  import * as path37 from "path";