@adhdev/daemon-standalone 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.js CHANGED
@@ -30033,10 +30033,10 @@ var require_dist3 = __commonJS({
30033
30033
  }
30034
30034
  function getDaemonBuildInfo() {
30035
30035
  if (cached2) return cached2;
30036
- const commit = readInjected(true ? "a0aeebdac30d9abea5b46e3f2618f864bbff19d0" : void 0) ?? "unknown";
30037
- const commitShort = readInjected(true ? "a0aeebda" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30038
- const version2 = readInjected(true ? "0.9.82-rc.325" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30039
- const builtAt = readInjected(true ? "2026-06-19T08:25:17.695Z" : void 0);
30036
+ const commit = readInjected(true ? "9ee42155ad394578ced8959105e9a2c35d0af11b" : void 0) ?? "unknown";
30037
+ const commitShort = readInjected(true ? "9ee42155" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
30038
+ const version2 = readInjected(true ? "0.9.82-rc.326" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
30039
+ const builtAt = readInjected(true ? "2026-06-19T10:17:02.506Z" : void 0);
30040
30040
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
30041
30041
  return cached2;
30042
30042
  }
@@ -39920,6 +39920,652 @@ Next step: ${nextStep}`;
39920
39920
  ]);
39921
39921
  }
39922
39922
  });
39923
+ function normalizeInputEnvelope(input) {
39924
+ const normalized = normalizeInputEnvelopePayload(input);
39925
+ const textFallback = normalized.textFallback ?? flattenInputParts(normalized.parts);
39926
+ return {
39927
+ parts: normalized.parts,
39928
+ textFallback,
39929
+ ...normalized.metadata ? { metadata: normalized.metadata } : {}
39930
+ };
39931
+ }
39932
+ function normalizeMessageParts(content) {
39933
+ if (typeof content === "string") return [{ type: "text", text: content }];
39934
+ if (!Array.isArray(content)) {
39935
+ if (content && typeof content === "object" && typeof content.text === "string") {
39936
+ return [{ type: "text", text: String(content.text) }];
39937
+ }
39938
+ return [];
39939
+ }
39940
+ const parts = [];
39941
+ for (const raw of content) {
39942
+ if (typeof raw === "string") {
39943
+ parts.push({ type: "text", text: raw });
39944
+ continue;
39945
+ }
39946
+ if (!raw || typeof raw !== "object") continue;
39947
+ const part = normalizeMessagePartObject(raw);
39948
+ if (part) parts.push(part);
39949
+ }
39950
+ return parts;
39951
+ }
39952
+ function flattenMessageParts(parts) {
39953
+ return parts.map((part) => {
39954
+ if (part.type === "text") return part.text;
39955
+ if (part.type === "resource") return part.resource.text || "";
39956
+ if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
39957
+ if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
39958
+ if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
39959
+ if (part.type === "resource_link") return [part.name, part.description].filter(Boolean).join("\n");
39960
+ return "";
39961
+ }).filter((value) => value.length > 0).join("\n");
39962
+ }
39963
+ function normalizeInputEnvelopePayload(input) {
39964
+ if (typeof input === "string") {
39965
+ return { parts: [{ type: "text", text: input }], textFallback: input };
39966
+ }
39967
+ if (!input || typeof input !== "object") {
39968
+ return { parts: [], textFallback: "" };
39969
+ }
39970
+ const record2 = input;
39971
+ const nestedInput = record2.input;
39972
+ if (nestedInput && typeof nestedInput === "object") {
39973
+ const nested = nestedInput;
39974
+ return {
39975
+ parts: normalizeInputParts(nested.parts ?? nested.prompt),
39976
+ textFallback: typeof nested.textFallback === "string" ? nested.textFallback : void 0,
39977
+ metadata: normalizeInputMetadata(nested.metadata)
39978
+ };
39979
+ }
39980
+ const directText = typeof record2.text === "string" ? record2.text : typeof record2.message === "string" ? record2.message : void 0;
39981
+ if (directText !== void 0) {
39982
+ return { parts: [{ type: "text", text: directText }], textFallback: directText };
39983
+ }
39984
+ const directParts = normalizeInputParts(record2.parts ?? record2.prompt);
39985
+ return {
39986
+ parts: directParts,
39987
+ textFallback: typeof record2.textFallback === "string" ? record2.textFallback : void 0,
39988
+ metadata: normalizeInputMetadata(record2.metadata)
39989
+ };
39990
+ }
39991
+ function normalizeInputMetadata(value) {
39992
+ if (!value || typeof value !== "object") return void 0;
39993
+ const record2 = value;
39994
+ const metadata = {};
39995
+ if (record2.source === "dashboard" || record2.source === "shortcut_api" || record2.source === "provider_script" || record2.source === "session_replay") {
39996
+ metadata.source = record2.source;
39997
+ }
39998
+ if (typeof record2.clientTimestamp === "number" && Number.isFinite(record2.clientTimestamp)) {
39999
+ metadata.clientTimestamp = record2.clientTimestamp;
40000
+ }
40001
+ return Object.keys(metadata).length > 0 ? metadata : void 0;
40002
+ }
40003
+ function normalizeInputParts(value) {
40004
+ if (!Array.isArray(value)) return [];
40005
+ const parts = [];
40006
+ for (const raw of value) {
40007
+ if (typeof raw === "string") {
40008
+ parts.push({ type: "text", text: raw });
40009
+ continue;
40010
+ }
40011
+ if (!raw || typeof raw !== "object") continue;
40012
+ const part = normalizeInputPartObject(raw);
40013
+ if (part) parts.push(part);
40014
+ }
40015
+ return parts;
40016
+ }
40017
+ function normalizeInputPartObject(raw) {
40018
+ const type = raw.type;
40019
+ if (type === "text" && typeof raw.text === "string") {
40020
+ return { type, text: raw.text };
40021
+ }
40022
+ if (type === "image" && typeof raw.mimeType === "string") {
40023
+ return {
40024
+ type,
40025
+ mimeType: raw.mimeType,
40026
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
40027
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
40028
+ ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
40029
+ };
40030
+ }
40031
+ if (type === "audio" && typeof raw.mimeType === "string") {
40032
+ return {
40033
+ type,
40034
+ mimeType: raw.mimeType,
40035
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
40036
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
40037
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
40038
+ };
40039
+ }
40040
+ if (type === "video" && typeof raw.mimeType === "string") {
40041
+ return {
40042
+ type,
40043
+ mimeType: raw.mimeType,
40044
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
40045
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
40046
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
40047
+ ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
40048
+ };
40049
+ }
40050
+ if (type === "resource" && typeof raw.uri === "string") {
40051
+ return {
40052
+ type,
40053
+ uri: raw.uri,
40054
+ ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
40055
+ ...typeof raw.name === "string" ? { name: raw.name } : {},
40056
+ ...typeof raw.text === "string" ? { text: raw.text } : {},
40057
+ ...typeof raw.data === "string" ? { data: raw.data } : {}
40058
+ };
40059
+ }
40060
+ if (type === "resource_link" && typeof raw.uri === "string") {
40061
+ return {
40062
+ type,
40063
+ uri: raw.uri,
40064
+ name: typeof raw.name === "string" ? raw.name : getUriDisplayName(raw.uri, "resource"),
40065
+ ...typeof raw.title === "string" ? { title: raw.title } : {},
40066
+ ...typeof raw.description === "string" ? { description: raw.description } : {},
40067
+ ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
40068
+ ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
40069
+ ...normalizeAnnotationsProperty(raw.annotations)
40070
+ };
40071
+ }
40072
+ return null;
40073
+ }
40074
+ function normalizeMessagePartObject(raw) {
40075
+ const type = raw.type;
40076
+ if (type === "text" && typeof raw.text === "string") {
40077
+ return { type, text: raw.text };
40078
+ }
40079
+ if (type === "image" && typeof raw.mimeType === "string") {
40080
+ return {
40081
+ type,
40082
+ mimeType: raw.mimeType,
40083
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
40084
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
40085
+ ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
40086
+ };
40087
+ }
40088
+ if (type === "audio" && typeof raw.mimeType === "string") {
40089
+ return {
40090
+ type,
40091
+ mimeType: raw.mimeType,
40092
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
40093
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
40094
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
40095
+ };
40096
+ }
40097
+ if (type === "video" && typeof raw.mimeType === "string") {
40098
+ return {
40099
+ type,
40100
+ mimeType: raw.mimeType,
40101
+ ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
40102
+ ...typeof raw.data === "string" ? { data: raw.data } : {},
40103
+ ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
40104
+ ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
40105
+ };
40106
+ }
40107
+ if (type === "resource_link" && typeof raw.uri === "string" && typeof raw.name === "string") {
40108
+ return {
40109
+ type,
40110
+ uri: raw.uri,
40111
+ name: raw.name,
40112
+ ...typeof raw.title === "string" ? { title: raw.title } : {},
40113
+ ...typeof raw.description === "string" ? { description: raw.description } : {},
40114
+ ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
40115
+ ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
40116
+ ...normalizeAnnotationsProperty(raw.annotations)
40117
+ };
40118
+ }
40119
+ if (type === "resource" && raw.resource && typeof raw.resource === "object") {
40120
+ const resource = raw.resource;
40121
+ if (typeof resource.uri !== "string") return null;
40122
+ return {
40123
+ type,
40124
+ resource: {
40125
+ uri: resource.uri,
40126
+ ...typeof resource.mimeType === "string" || resource.mimeType === null ? { mimeType: resource.mimeType } : {},
40127
+ ...typeof resource.text === "string" ? { text: resource.text } : {},
40128
+ ...typeof resource.blob === "string" ? { blob: resource.blob } : {}
40129
+ }
40130
+ };
40131
+ }
40132
+ return null;
40133
+ }
40134
+ function flattenInputParts(parts) {
40135
+ return parts.map((part) => {
40136
+ if (part.type === "text") return part.text;
40137
+ if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
40138
+ if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
40139
+ if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
40140
+ if (part.type === "resource_link") return [part.title, part.name, part.description, part.uri].filter(Boolean).join("\n");
40141
+ if (part.type === "resource") return part.text || part.name || part.uri;
40142
+ return "";
40143
+ }).filter((value) => value.length > 0).join("\n");
40144
+ }
40145
+ function getUriDisplayName(uri, fallback) {
40146
+ try {
40147
+ const pathname = uri.startsWith("file://") ? new URL(uri).pathname : uri;
40148
+ return pathname.split(/[\\/]/).filter(Boolean).pop() || fallback;
40149
+ } catch {
40150
+ return uri.split(/[\\/]/).filter(Boolean).pop() || fallback;
40151
+ }
40152
+ }
40153
+ function normalizeAnnotationsProperty(value) {
40154
+ if (!value || typeof value !== "object") return {};
40155
+ const record2 = value;
40156
+ const annotations = {};
40157
+ if (Array.isArray(record2.audience)) {
40158
+ const audience = record2.audience.filter((item) => item === "user" || item === "assistant");
40159
+ if (audience.length > 0) annotations.audience = audience;
40160
+ }
40161
+ if (typeof record2.priority === "number" && Number.isFinite(record2.priority)) {
40162
+ annotations.priority = record2.priority;
40163
+ }
40164
+ return Object.keys(annotations).length > 0 ? { annotations } : {};
40165
+ }
40166
+ var init_io_contracts = __esm2({
40167
+ "src/providers/io-contracts.ts"() {
40168
+ "use strict";
40169
+ }
40170
+ });
40171
+ function flattenContent(content) {
40172
+ if (typeof content === "string") return content;
40173
+ return flattenMessageParts(normalizeMessageParts(content));
40174
+ }
40175
+ var init_contracts = __esm2({
40176
+ "src/providers/contracts.ts"() {
40177
+ "use strict";
40178
+ init_io_contracts();
40179
+ init_io_contracts();
40180
+ }
40181
+ });
40182
+ function extractFinalSummaryFromMessages(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
40183
+ if (!Array.isArray(messages) || messages.length === 0) return "";
40184
+ for (let i = messages.length - 1; i >= 0; i--) {
40185
+ const msg = messages[i];
40186
+ if (!msg) continue;
40187
+ const classification = classifyChatMessageVisibility(msg);
40188
+ if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
40189
+ const text = flattenContent(msg.content).trim();
40190
+ if (text) return text.slice(0, maxChars);
40191
+ }
40192
+ }
40193
+ return "";
40194
+ }
40195
+ function readChatMessageTimestampIso(message) {
40196
+ if (!message) return void 0;
40197
+ const record2 = message;
40198
+ for (const value of [record2.timestamp, record2.createdAt, record2.created_at, record2.updatedAt, record2.time]) {
40199
+ if (typeof value === "number" && Number.isFinite(value)) {
40200
+ const ms = value > 1e10 ? value : value * 1e3;
40201
+ return new Date(ms).toISOString();
40202
+ }
40203
+ if (typeof value === "string" && value.trim()) {
40204
+ const ms = new Date(value.trim()).getTime();
40205
+ if (Number.isFinite(ms)) return new Date(ms).toISOString();
40206
+ }
40207
+ }
40208
+ return void 0;
40209
+ }
40210
+ function extractFinalAssistantSummaryEvidence(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
40211
+ if (!Array.isArray(messages) || messages.length === 0) return { finalSummary: "" };
40212
+ for (let i = messages.length - 1; i >= 0; i--) {
40213
+ const msg = messages[i];
40214
+ if (!msg) continue;
40215
+ const classification = classifyChatMessageVisibility(msg);
40216
+ if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
40217
+ const text = flattenContent(msg.content).trim();
40218
+ if (text) {
40219
+ return {
40220
+ finalSummary: text.slice(0, maxChars),
40221
+ transcriptMessageAt: readChatMessageTimestampIso(msg)
40222
+ };
40223
+ }
40224
+ }
40225
+ }
40226
+ return { finalSummary: "" };
40227
+ }
40228
+ function canonicalizeKindHint(value) {
40229
+ return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
40230
+ }
40231
+ function resolveBuiltinOrAliasKind(kind) {
40232
+ if (typeof kind !== "string") return null;
40233
+ const normalizedKind = canonicalizeKindHint(kind);
40234
+ if (!normalizedKind) return null;
40235
+ if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
40236
+ return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
40237
+ }
40238
+ function inferHintKind(value) {
40239
+ const direct = resolveBuiltinOrAliasKind(value);
40240
+ if (direct) return direct;
40241
+ if (typeof value !== "string") return null;
40242
+ const normalized = canonicalizeKindHint(value);
40243
+ if (!normalized) return null;
40244
+ if (/thought|thinking|reasoning/.test(normalized)) return "thought";
40245
+ if (/tool/.test(normalized)) return "tool";
40246
+ if (/terminal|command|shell|console/.test(normalized)) return "terminal";
40247
+ return null;
40248
+ }
40249
+ function inferKindFromToolCalls(message) {
40250
+ const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
40251
+ if (toolCalls.length === 0) return null;
40252
+ if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
40253
+ if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
40254
+ if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
40255
+ return "terminal";
40256
+ }
40257
+ return "tool";
40258
+ }
40259
+ function inferMissingChatMessageKind(message) {
40260
+ const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
40261
+ if (role === "system") return "system";
40262
+ const meta3 = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
40263
+ const hintCandidates = [
40264
+ message?._sub,
40265
+ message?._type,
40266
+ meta3?.label,
40267
+ typeof message?.senderName === "string" ? message.senderName : void 0
40268
+ ];
40269
+ for (const candidate of hintCandidates) {
40270
+ const inferred = inferHintKind(candidate);
40271
+ if (inferred) return inferred;
40272
+ }
40273
+ const inferredFromToolCalls = inferKindFromToolCalls(message);
40274
+ if (inferredFromToolCalls) return inferredFromToolCalls;
40275
+ return null;
40276
+ }
40277
+ function isBuiltinChatMessageKind(kind) {
40278
+ return resolveBuiltinOrAliasKind(kind) !== null;
40279
+ }
40280
+ function normalizeChatMessageKind(kind, role) {
40281
+ const resolvedKind = resolveBuiltinOrAliasKind(kind);
40282
+ if (resolvedKind) return resolvedKind;
40283
+ const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
40284
+ return normalizedRole === "system" ? "system" : "standard";
40285
+ }
40286
+ function resolveChatMessageKind(message) {
40287
+ const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
40288
+ if (explicitKind) return explicitKind;
40289
+ const inferredKind = inferMissingChatMessageKind(message);
40290
+ if (inferredKind) return inferredKind;
40291
+ return normalizeChatMessageKind(message?.kind, message?.role);
40292
+ }
40293
+ function buildChatMessage(message) {
40294
+ return {
40295
+ ...message,
40296
+ kind: resolveChatMessageKind(message)
40297
+ };
40298
+ }
40299
+ function buildSystemChatMessage(message) {
40300
+ return buildChatMessage({
40301
+ ...message,
40302
+ role: "system",
40303
+ kind: message?.kind || "system"
40304
+ });
40305
+ }
40306
+ function buildRuntimeSystemChatMessage(message) {
40307
+ return buildSystemChatMessage({
40308
+ ...message,
40309
+ senderName: typeof message?.senderName === "string" && message.senderName.trim() ? message.senderName : "System"
40310
+ });
40311
+ }
40312
+ function buildAssistantChatMessage(message) {
40313
+ return buildChatMessage({
40314
+ ...message,
40315
+ role: "assistant",
40316
+ kind: message?.kind || "standard"
40317
+ });
40318
+ }
40319
+ function buildThoughtChatMessage(message) {
40320
+ return buildAssistantChatMessage({
40321
+ ...message,
40322
+ kind: message?.kind || "thought"
40323
+ });
40324
+ }
40325
+ function buildToolChatMessage(message) {
40326
+ return buildAssistantChatMessage({
40327
+ ...message,
40328
+ kind: message?.kind || "tool"
40329
+ });
40330
+ }
40331
+ function buildTerminalChatMessage(message) {
40332
+ return buildAssistantChatMessage({
40333
+ ...message,
40334
+ kind: message?.kind || "terminal"
40335
+ });
40336
+ }
40337
+ function buildUserChatMessage(message) {
40338
+ return buildChatMessage({
40339
+ ...message,
40340
+ role: "user",
40341
+ kind: message?.kind || "standard"
40342
+ });
40343
+ }
40344
+ function normalizeChatMessage(message) {
40345
+ return buildChatMessage(message);
40346
+ }
40347
+ function normalizeChatMessages(messages) {
40348
+ return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
40349
+ }
40350
+ function readMessageMeta(message) {
40351
+ const meta3 = message?.meta;
40352
+ return meta3 && typeof meta3 === "object" && !Array.isArray(meta3) ? meta3 : null;
40353
+ }
40354
+ function readStringField(value) {
40355
+ return typeof value === "string" ? value.trim().toLowerCase() : "";
40356
+ }
40357
+ function readRecordField(message, meta3, key) {
40358
+ const record2 = message;
40359
+ return record2[key] ?? meta3?.[key];
40360
+ }
40361
+ function readVisibilityField(message, meta3) {
40362
+ return readStringField(readRecordField(message, meta3, "visibility"));
40363
+ }
40364
+ function readTranscriptVisibilityField(message, meta3) {
40365
+ const record2 = message;
40366
+ return readStringField(record2.transcriptVisibility ?? meta3?.transcriptVisibility ?? record2.visibility ?? meta3?.visibility);
40367
+ }
40368
+ function hasBooleanMarker(message, meta3, keys) {
40369
+ const record2 = message;
40370
+ return keys.some((key) => record2[key] === true || meta3?.[key] === true);
40371
+ }
40372
+ function isActivityKind(kind) {
40373
+ return kind === "thought" || kind === "tool" || kind === "terminal";
40374
+ }
40375
+ function isOrdinaryVisibleTurn(message, role, kind) {
40376
+ if (role === "user" || role === "human") return kind === "standard" || kind === "";
40377
+ if (role === "assistant") return kind === "standard" || kind === "";
40378
+ return false;
40379
+ }
40380
+ function classifyChatMessageVisibility(message) {
40381
+ if (!message) {
40382
+ return {
40383
+ surface: "internal",
40384
+ isUserFacing: false,
40385
+ isActivityFacing: false,
40386
+ isInternal: true,
40387
+ explicitUserFacing: false,
40388
+ explicitHidden: true,
40389
+ role: "",
40390
+ kind: "standard",
40391
+ visibility: "",
40392
+ transcriptVisibility: "",
40393
+ audience: "",
40394
+ source: ""
40395
+ };
40396
+ }
40397
+ const meta3 = readMessageMeta(message);
40398
+ const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
40399
+ const kind = resolveChatMessageKind(message);
40400
+ const visibility = readVisibilityField(message, meta3);
40401
+ const transcriptVisibility = readTranscriptVisibilityField(message, meta3);
40402
+ const audience = readStringField(readRecordField(message, meta3, "audience"));
40403
+ const source = readStringField(readRecordField(message, meta3, "source"));
40404
+ const explicitHidden = EXPLICIT_HIDDEN_VISIBILITIES.has(visibility) || EXPLICIT_HIDDEN_VISIBILITIES.has(transcriptVisibility) || HIDDEN_AUDIENCES.has(audience) || hasBooleanMarker(message, meta3, ["hidden", "internal", "isInternal", "debug", "statusOnly", "controlOnly"]);
40405
+ const explicitUserFacing = EXPLICIT_VISIBLE_VISIBILITIES.has(visibility) || EXPLICIT_VISIBLE_VISIBILITIES.has(transcriptVisibility) || audience === "chat" || hasBooleanMarker(message, meta3, ["userFacing"]);
40406
+ if (explicitHidden) {
40407
+ const activityLike = isActivityKind(kind) || ACTIVITY_SOURCE_SET.has(source);
40408
+ return {
40409
+ surface: activityLike ? "activity" : "internal",
40410
+ isUserFacing: false,
40411
+ isActivityFacing: activityLike,
40412
+ isInternal: !activityLike,
40413
+ explicitUserFacing,
40414
+ explicitHidden,
40415
+ role,
40416
+ kind,
40417
+ visibility,
40418
+ transcriptVisibility,
40419
+ audience,
40420
+ source
40421
+ };
40422
+ }
40423
+ if (explicitUserFacing) {
40424
+ return {
40425
+ surface: "chat",
40426
+ isUserFacing: true,
40427
+ isActivityFacing: false,
40428
+ isInternal: false,
40429
+ explicitUserFacing,
40430
+ explicitHidden,
40431
+ role,
40432
+ kind,
40433
+ visibility,
40434
+ transcriptVisibility,
40435
+ audience,
40436
+ source
40437
+ };
40438
+ }
40439
+ if (INTERNAL_SOURCE_SET.has(source) || role === "system" || kind === "system") {
40440
+ return {
40441
+ surface: "internal",
40442
+ isUserFacing: false,
40443
+ isActivityFacing: false,
40444
+ isInternal: true,
40445
+ explicitUserFacing,
40446
+ explicitHidden,
40447
+ role,
40448
+ kind,
40449
+ visibility,
40450
+ transcriptVisibility,
40451
+ audience,
40452
+ source
40453
+ };
40454
+ }
40455
+ if (ACTIVITY_SOURCE_SET.has(source) || isActivityKind(kind)) {
40456
+ return {
40457
+ surface: "activity",
40458
+ isUserFacing: false,
40459
+ isActivityFacing: true,
40460
+ isInternal: false,
40461
+ explicitUserFacing,
40462
+ explicitHidden,
40463
+ role,
40464
+ kind,
40465
+ visibility,
40466
+ transcriptVisibility,
40467
+ audience,
40468
+ source
40469
+ };
40470
+ }
40471
+ const isUserFacing = isOrdinaryVisibleTurn(message, role, kind);
40472
+ return {
40473
+ surface: isUserFacing ? "chat" : "internal",
40474
+ isUserFacing,
40475
+ isActivityFacing: false,
40476
+ isInternal: !isUserFacing,
40477
+ explicitUserFacing,
40478
+ explicitHidden,
40479
+ role,
40480
+ kind,
40481
+ visibility,
40482
+ transcriptVisibility,
40483
+ audience,
40484
+ source
40485
+ };
40486
+ }
40487
+ function isUserFacingChatMessage(message) {
40488
+ return classifyChatMessageVisibility(message).isUserFacing;
40489
+ }
40490
+ function isActivityChatMessage(message) {
40491
+ return classifyChatMessageVisibility(message).isActivityFacing;
40492
+ }
40493
+ function isInternalChatMessage(message) {
40494
+ return classifyChatMessageVisibility(message).isInternal;
40495
+ }
40496
+ function filterUserFacingChatMessages(messages) {
40497
+ return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
40498
+ }
40499
+ function filterActivityChatMessages(messages) {
40500
+ return (Array.isArray(messages) ? messages : []).filter((message) => isActivityChatMessage(message));
40501
+ }
40502
+ function filterInternalChatMessages(messages) {
40503
+ return (Array.isArray(messages) ? messages : []).filter((message) => isInternalChatMessage(message));
40504
+ }
40505
+ function filterChatMessagesByVisibility(messages, surface) {
40506
+ return (Array.isArray(messages) ? messages : []).filter((message) => classifyChatMessageVisibility(message).surface === surface);
40507
+ }
40508
+ var DEFAULT_FINAL_SUMMARY_MAX_CHARS;
40509
+ var BUILTIN_CHAT_MESSAGE_KINDS;
40510
+ var CHAT_MESSAGE_VISIBILITIES;
40511
+ var CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES;
40512
+ var CHAT_MESSAGE_AUDIENCES;
40513
+ var CHAT_MESSAGE_SOURCES;
40514
+ var CHAT_MESSAGE_ACTIVITY_SOURCES;
40515
+ var CHAT_MESSAGE_INTERNAL_SOURCES;
40516
+ var KNOWN_CHAT_MESSAGE_KINDS;
40517
+ var CHAT_MESSAGE_KIND_ALIASES;
40518
+ var EXPLICIT_HIDDEN_VISIBILITIES;
40519
+ var EXPLICIT_VISIBLE_VISIBILITIES;
40520
+ var HIDDEN_AUDIENCES;
40521
+ var ACTIVITY_SOURCE_SET;
40522
+ var INTERNAL_SOURCE_SET;
40523
+ var init_chat_message_normalization = __esm2({
40524
+ "src/providers/chat-message-normalization.ts"() {
40525
+ "use strict";
40526
+ init_contracts();
40527
+ DEFAULT_FINAL_SUMMARY_MAX_CHARS = 4e3;
40528
+ BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
40529
+ CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
40530
+ CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
40531
+ CHAT_MESSAGE_AUDIENCES = ["chat", "debug", "trace", "internal"];
40532
+ CHAT_MESSAGE_SOURCES = [
40533
+ "assistant_text",
40534
+ "tool_call",
40535
+ "terminal_command",
40536
+ "runtime_activity",
40537
+ "runtime_status",
40538
+ "provider_chrome",
40539
+ "control"
40540
+ ];
40541
+ CHAT_MESSAGE_ACTIVITY_SOURCES = ["tool_call", "terminal_command", "runtime_activity"];
40542
+ CHAT_MESSAGE_INTERNAL_SOURCES = ["runtime_status", "provider_chrome", "control"];
40543
+ KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
40544
+ CHAT_MESSAGE_KIND_ALIASES = {
40545
+ text: "standard",
40546
+ message: "standard",
40547
+ assistant: "standard",
40548
+ thinking: "thought",
40549
+ think: "thought",
40550
+ reasoning: "thought",
40551
+ reason: "thought",
40552
+ toolcall: "tool",
40553
+ tool_call: "tool",
40554
+ tooluse: "tool",
40555
+ tool_use: "tool",
40556
+ action: "tool",
40557
+ command: "terminal",
40558
+ cmd: "terminal",
40559
+ shell: "terminal",
40560
+ console: "terminal"
40561
+ };
40562
+ EXPLICIT_HIDDEN_VISIBILITIES = /* @__PURE__ */ new Set(["hidden", "debug", "internal"]);
40563
+ EXPLICIT_VISIBLE_VISIBILITIES = /* @__PURE__ */ new Set(["visible", "user", "chat"]);
40564
+ HIDDEN_AUDIENCES = /* @__PURE__ */ new Set(["debug", "trace", "internal"]);
40565
+ ACTIVITY_SOURCE_SET = new Set(CHAT_MESSAGE_ACTIVITY_SOURCES);
40566
+ INTERNAL_SOURCE_SET = new Set(CHAT_MESSAGE_INTERNAL_SOURCES);
40567
+ }
40568
+ });
39923
40569
  function resolveReconcileIntervalMs() {
39924
40570
  const raw = readNonEmptyString2(process.env.MESH_RECONCILE_INTERVAL_MS);
39925
40571
  if (raw) {
@@ -40022,6 +40668,15 @@ Next step: ${nextStep}`;
40022
40668
  LOG2.warn("MeshReconcile", `Pending-claim recovery trigger failed for mesh ${mesh.id}: ${e?.message || e}`);
40023
40669
  }
40024
40670
  }
40671
+ for (const mesh of listMeshes()) {
40672
+ const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
40673
+ if (!daemonHostsMesh(mesh, selfIds)) continue;
40674
+ try {
40675
+ await reconcileUnterminatedDirectDispatches(components, mesh, selfIds, localDaemonId);
40676
+ } catch (e) {
40677
+ LOG2.warn("MeshReconcile", `Completion reconcile failed for mesh ${mesh.id}: ${e?.message || e}`);
40678
+ }
40679
+ }
40025
40680
  const coordinators = findLiveCoordinators(components);
40026
40681
  if (coordinators.length === 0) {
40027
40682
  return;
@@ -40115,6 +40770,95 @@ Next step: ${nextStep}`;
40115
40770
  }
40116
40771
  }
40117
40772
  }
40773
+ function unwrapReadChatPayload(raw) {
40774
+ let cursor = raw;
40775
+ for (let depth = 0; depth < 4 && cursor && typeof cursor === "object"; depth++) {
40776
+ const record2 = cursor;
40777
+ if (Array.isArray(record2.messages)) return record2;
40778
+ if (record2.payload && typeof record2.payload === "object") {
40779
+ cursor = record2.payload;
40780
+ continue;
40781
+ }
40782
+ if (record2.result && typeof record2.result === "object") {
40783
+ cursor = record2.result;
40784
+ continue;
40785
+ }
40786
+ if (record2.data && typeof record2.data === "object") {
40787
+ cursor = record2.data;
40788
+ continue;
40789
+ }
40790
+ break;
40791
+ }
40792
+ return cursor && typeof cursor === "object" ? cursor : null;
40793
+ }
40794
+ function readChatPayloadStatus(payload) {
40795
+ return readNonEmptyString2(payload?.status).toLowerCase();
40796
+ }
40797
+ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds, localDaemonId) {
40798
+ const dispatches = getActiveDirectDispatches(mesh.id);
40799
+ if (dispatches.length === 0) return;
40800
+ const dispatchMeshCommand = components.dispatchMeshCommand;
40801
+ const nodeById = new Map(mesh.nodes.map((n) => [n.id, n]));
40802
+ for (const dispatch of dispatches) {
40803
+ const sessionId = readNonEmptyString2(dispatch.sessionId);
40804
+ const nodeId = readNonEmptyString2(dispatch.nodeId);
40805
+ const taskId = readNonEmptyString2(dispatch.taskId);
40806
+ if (!sessionId || !nodeId || !taskId) continue;
40807
+ const node = nodeById.get(nodeId);
40808
+ const nodeDaemonId = readNonEmptyString2(node?.daemonId);
40809
+ const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || localDaemonId !== void 0 && nodeDaemonId === localDaemonId || !!components.instanceManager.getInstance(sessionId);
40810
+ const providerType = readNonEmptyString2(dispatch.providerType);
40811
+ const readArgs = {
40812
+ sessionId,
40813
+ targetSessionId: sessionId,
40814
+ tailLimit: 10,
40815
+ ...node?.workspace ? { workspace: node.workspace } : {},
40816
+ ...providerType ? { agentType: providerType, providerType } : {}
40817
+ };
40818
+ let payload = null;
40819
+ try {
40820
+ if (isLocalNode) {
40821
+ const result = await components.commandHandler.handle("read_chat", readArgs);
40822
+ if (result && result.success === false) continue;
40823
+ payload = unwrapReadChatPayload(result);
40824
+ } else if (dispatchMeshCommand) {
40825
+ const result = await dispatchMeshCommand(nodeDaemonId, "read_chat", readArgs);
40826
+ payload = unwrapReadChatPayload(result);
40827
+ if (payload && payload.success === false) continue;
40828
+ } else {
40829
+ continue;
40830
+ }
40831
+ } catch {
40832
+ continue;
40833
+ }
40834
+ if (!payload) continue;
40835
+ if (readChatPayloadStatus(payload) !== "idle") continue;
40836
+ const messages = Array.isArray(payload.messages) ? payload.messages : [];
40837
+ const evidence = extractFinalAssistantSummaryEvidence(messages);
40838
+ if (!evidence.finalSummary) continue;
40839
+ const providerSessionId = readNonEmptyString2(payload.providerSessionId);
40840
+ const coordinatorDaemonId = selfIds.find((id) => !!id);
40841
+ try {
40842
+ const result = reconcileDirectDispatchCompletionFromTranscript({
40843
+ meshId: mesh.id,
40844
+ nodeId,
40845
+ sessionId,
40846
+ providerType: providerType || void 0,
40847
+ providerSessionId: providerSessionId || void 0,
40848
+ taskId,
40849
+ finalSummary: evidence.finalSummary,
40850
+ ...evidence.transcriptMessageAt ? { transcriptMessageAt: evidence.transcriptMessageAt } : {},
40851
+ ...coordinatorDaemonId ? { targetCoordinatorDaemonId: coordinatorDaemonId } : {},
40852
+ source: "daemon_reconcile_transcript_completion"
40853
+ });
40854
+ if (result.reconciled) {
40855
+ LOG2.info("MeshReconcile", `Synthesized missing completion (${result.kind}) for task ${taskId} on node ${nodeId} (mesh ${mesh.id})`);
40856
+ }
40857
+ } catch (e) {
40858
+ LOG2.warn("MeshReconcile", `Transcript completion reconcile threw for task ${taskId}: ${e?.message || e}`);
40859
+ }
40860
+ }
40861
+ }
40118
40862
  function extractPendingEvents(raw) {
40119
40863
  if (Array.isArray(raw)) return raw;
40120
40864
  if (raw && typeof raw === "object") {
@@ -40164,6 +40908,9 @@ Next step: ${nextStep}`;
40164
40908
  init_mesh_events_coordinator();
40165
40909
  init_mesh_unresolved_forward_outbox();
40166
40910
  init_mesh_events_utils();
40911
+ init_mesh_work_queue();
40912
+ init_mesh_events_stale();
40913
+ init_chat_message_normalization();
40167
40914
  DEFAULT_RECONCILE_INTERVAL_MS = 4e3;
40168
40915
  }
40169
40916
  });
@@ -43931,6 +44678,8 @@ ${lastSnapshot}`;
43931
44678
  errorMessage: this.parseErrorMessage || this.engine.providerErrorMessage || void 0,
43932
44679
  errorReason: this.parseErrorMessage ? "parse_error" : this.engine.providerErrorReason || void 0,
43933
44680
  providerSessionId: this.providerSessionId || void 0,
44681
+ lastOutputAt: this.lastOutputAt,
44682
+ lastScreenChangeAt: this.lastScreenChangeAt,
43934
44683
  ...bufferState ? { bufferState } : {}
43935
44684
  };
43936
44685
  }
@@ -46963,7 +47712,8 @@ ${lastSnapshot}`;
46963
47712
  if (includeSubmodules !== void 0) statusParams.includeSubmodules = includeSubmodules;
46964
47713
  if (submoduleIgnorePaths && submoduleIgnorePaths.length > 0) statusParams.submoduleIgnorePaths = submoduleIgnorePaths;
46965
47714
  const status = await runService(() => services.getStatus(statusParams));
46966
- return "success" in status ? status : { success: true, status };
47715
+ if ("success" in status) return status;
47716
+ return { success: true, status, reporterPlatform: process.platform, reporterArch: process.arch };
46967
47717
  }
46968
47718
  case "git_diff_summary": {
46969
47719
  if (!services.getDiffSummary) return serviceNotImplemented(command);
@@ -50597,253 +51347,8 @@ ${lastSnapshot}`;
50597
51347
  }
50598
51348
  };
50599
51349
  var crypto2 = __toESM2(require("crypto"));
50600
- function normalizeInputEnvelope(input) {
50601
- const normalized = normalizeInputEnvelopePayload(input);
50602
- const textFallback = normalized.textFallback ?? flattenInputParts(normalized.parts);
50603
- return {
50604
- parts: normalized.parts,
50605
- textFallback,
50606
- ...normalized.metadata ? { metadata: normalized.metadata } : {}
50607
- };
50608
- }
50609
- function normalizeMessageParts(content) {
50610
- if (typeof content === "string") return [{ type: "text", text: content }];
50611
- if (!Array.isArray(content)) {
50612
- if (content && typeof content === "object" && typeof content.text === "string") {
50613
- return [{ type: "text", text: String(content.text) }];
50614
- }
50615
- return [];
50616
- }
50617
- const parts = [];
50618
- for (const raw of content) {
50619
- if (typeof raw === "string") {
50620
- parts.push({ type: "text", text: raw });
50621
- continue;
50622
- }
50623
- if (!raw || typeof raw !== "object") continue;
50624
- const part = normalizeMessagePartObject(raw);
50625
- if (part) parts.push(part);
50626
- }
50627
- return parts;
50628
- }
50629
- function flattenMessageParts(parts) {
50630
- return parts.map((part) => {
50631
- if (part.type === "text") return part.text;
50632
- if (part.type === "resource") return part.resource.text || "";
50633
- if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
50634
- if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
50635
- if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
50636
- if (part.type === "resource_link") return [part.name, part.description].filter(Boolean).join("\n");
50637
- return "";
50638
- }).filter((value) => value.length > 0).join("\n");
50639
- }
50640
- function normalizeInputEnvelopePayload(input) {
50641
- if (typeof input === "string") {
50642
- return { parts: [{ type: "text", text: input }], textFallback: input };
50643
- }
50644
- if (!input || typeof input !== "object") {
50645
- return { parts: [], textFallback: "" };
50646
- }
50647
- const record2 = input;
50648
- const nestedInput = record2.input;
50649
- if (nestedInput && typeof nestedInput === "object") {
50650
- const nested = nestedInput;
50651
- return {
50652
- parts: normalizeInputParts(nested.parts ?? nested.prompt),
50653
- textFallback: typeof nested.textFallback === "string" ? nested.textFallback : void 0,
50654
- metadata: normalizeInputMetadata(nested.metadata)
50655
- };
50656
- }
50657
- const directText = typeof record2.text === "string" ? record2.text : typeof record2.message === "string" ? record2.message : void 0;
50658
- if (directText !== void 0) {
50659
- return { parts: [{ type: "text", text: directText }], textFallback: directText };
50660
- }
50661
- const directParts = normalizeInputParts(record2.parts ?? record2.prompt);
50662
- return {
50663
- parts: directParts,
50664
- textFallback: typeof record2.textFallback === "string" ? record2.textFallback : void 0,
50665
- metadata: normalizeInputMetadata(record2.metadata)
50666
- };
50667
- }
50668
- function normalizeInputMetadata(value) {
50669
- if (!value || typeof value !== "object") return void 0;
50670
- const record2 = value;
50671
- const metadata = {};
50672
- if (record2.source === "dashboard" || record2.source === "shortcut_api" || record2.source === "provider_script" || record2.source === "session_replay") {
50673
- metadata.source = record2.source;
50674
- }
50675
- if (typeof record2.clientTimestamp === "number" && Number.isFinite(record2.clientTimestamp)) {
50676
- metadata.clientTimestamp = record2.clientTimestamp;
50677
- }
50678
- return Object.keys(metadata).length > 0 ? metadata : void 0;
50679
- }
50680
- function normalizeInputParts(value) {
50681
- if (!Array.isArray(value)) return [];
50682
- const parts = [];
50683
- for (const raw of value) {
50684
- if (typeof raw === "string") {
50685
- parts.push({ type: "text", text: raw });
50686
- continue;
50687
- }
50688
- if (!raw || typeof raw !== "object") continue;
50689
- const part = normalizeInputPartObject(raw);
50690
- if (part) parts.push(part);
50691
- }
50692
- return parts;
50693
- }
50694
- function normalizeInputPartObject(raw) {
50695
- const type = raw.type;
50696
- if (type === "text" && typeof raw.text === "string") {
50697
- return { type, text: raw.text };
50698
- }
50699
- if (type === "image" && typeof raw.mimeType === "string") {
50700
- return {
50701
- type,
50702
- mimeType: raw.mimeType,
50703
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
50704
- ...typeof raw.data === "string" ? { data: raw.data } : {},
50705
- ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
50706
- };
50707
- }
50708
- if (type === "audio" && typeof raw.mimeType === "string") {
50709
- return {
50710
- type,
50711
- mimeType: raw.mimeType,
50712
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
50713
- ...typeof raw.data === "string" ? { data: raw.data } : {},
50714
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
50715
- };
50716
- }
50717
- if (type === "video" && typeof raw.mimeType === "string") {
50718
- return {
50719
- type,
50720
- mimeType: raw.mimeType,
50721
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
50722
- ...typeof raw.data === "string" ? { data: raw.data } : {},
50723
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
50724
- ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
50725
- };
50726
- }
50727
- if (type === "resource" && typeof raw.uri === "string") {
50728
- return {
50729
- type,
50730
- uri: raw.uri,
50731
- ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
50732
- ...typeof raw.name === "string" ? { name: raw.name } : {},
50733
- ...typeof raw.text === "string" ? { text: raw.text } : {},
50734
- ...typeof raw.data === "string" ? { data: raw.data } : {}
50735
- };
50736
- }
50737
- if (type === "resource_link" && typeof raw.uri === "string") {
50738
- return {
50739
- type,
50740
- uri: raw.uri,
50741
- name: typeof raw.name === "string" ? raw.name : getUriDisplayName(raw.uri, "resource"),
50742
- ...typeof raw.title === "string" ? { title: raw.title } : {},
50743
- ...typeof raw.description === "string" ? { description: raw.description } : {},
50744
- ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
50745
- ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
50746
- ...normalizeAnnotationsProperty(raw.annotations)
50747
- };
50748
- }
50749
- return null;
50750
- }
50751
- function normalizeMessagePartObject(raw) {
50752
- const type = raw.type;
50753
- if (type === "text" && typeof raw.text === "string") {
50754
- return { type, text: raw.text };
50755
- }
50756
- if (type === "image" && typeof raw.mimeType === "string") {
50757
- return {
50758
- type,
50759
- mimeType: raw.mimeType,
50760
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
50761
- ...typeof raw.data === "string" ? { data: raw.data } : {},
50762
- ...typeof raw.alt === "string" ? { alt: raw.alt } : {}
50763
- };
50764
- }
50765
- if (type === "audio" && typeof raw.mimeType === "string") {
50766
- return {
50767
- type,
50768
- mimeType: raw.mimeType,
50769
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
50770
- ...typeof raw.data === "string" ? { data: raw.data } : {},
50771
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
50772
- };
50773
- }
50774
- if (type === "video" && typeof raw.mimeType === "string") {
50775
- return {
50776
- type,
50777
- mimeType: raw.mimeType,
50778
- ...typeof raw.uri === "string" ? { uri: raw.uri } : {},
50779
- ...typeof raw.data === "string" ? { data: raw.data } : {},
50780
- ...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
50781
- ...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
50782
- };
50783
- }
50784
- if (type === "resource_link" && typeof raw.uri === "string" && typeof raw.name === "string") {
50785
- return {
50786
- type,
50787
- uri: raw.uri,
50788
- name: raw.name,
50789
- ...typeof raw.title === "string" ? { title: raw.title } : {},
50790
- ...typeof raw.description === "string" ? { description: raw.description } : {},
50791
- ...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
50792
- ...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
50793
- ...normalizeAnnotationsProperty(raw.annotations)
50794
- };
50795
- }
50796
- if (type === "resource" && raw.resource && typeof raw.resource === "object") {
50797
- const resource = raw.resource;
50798
- if (typeof resource.uri !== "string") return null;
50799
- return {
50800
- type,
50801
- resource: {
50802
- uri: resource.uri,
50803
- ...typeof resource.mimeType === "string" || resource.mimeType === null ? { mimeType: resource.mimeType } : {},
50804
- ...typeof resource.text === "string" ? { text: resource.text } : {},
50805
- ...typeof resource.blob === "string" ? { blob: resource.blob } : {}
50806
- }
50807
- };
50808
- }
50809
- return null;
50810
- }
50811
- function flattenInputParts(parts) {
50812
- return parts.map((part) => {
50813
- if (part.type === "text") return part.text;
50814
- if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
50815
- if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
50816
- if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
50817
- if (part.type === "resource_link") return [part.title, part.name, part.description, part.uri].filter(Boolean).join("\n");
50818
- if (part.type === "resource") return part.text || part.name || part.uri;
50819
- return "";
50820
- }).filter((value) => value.length > 0).join("\n");
50821
- }
50822
- function getUriDisplayName(uri, fallback) {
50823
- try {
50824
- const pathname = uri.startsWith("file://") ? new URL(uri).pathname : uri;
50825
- return pathname.split(/[\\/]/).filter(Boolean).pop() || fallback;
50826
- } catch {
50827
- return uri.split(/[\\/]/).filter(Boolean).pop() || fallback;
50828
- }
50829
- }
50830
- function normalizeAnnotationsProperty(value) {
50831
- if (!value || typeof value !== "object") return {};
50832
- const record2 = value;
50833
- const annotations = {};
50834
- if (Array.isArray(record2.audience)) {
50835
- const audience = record2.audience.filter((item) => item === "user" || item === "assistant");
50836
- if (audience.length > 0) annotations.audience = audience;
50837
- }
50838
- if (typeof record2.priority === "number" && Number.isFinite(record2.priority)) {
50839
- annotations.priority = record2.priority;
50840
- }
50841
- return Object.keys(annotations).length > 0 ? { annotations } : {};
50842
- }
50843
- function flattenContent(content) {
50844
- if (typeof content === "string") return content;
50845
- return flattenMessageParts(normalizeMessageParts(content));
50846
- }
51350
+ init_contracts();
51351
+ init_contracts();
50847
51352
  var DEFAULT_MONITOR_CONFIG = {
50848
51353
  approvalAlert: true,
50849
51354
  longGeneratingAlert: true,
@@ -50954,339 +51459,8 @@ ${lastSnapshot}`;
50954
51459
  }
50955
51460
  }
50956
51461
  };
50957
- var DEFAULT_FINAL_SUMMARY_MAX_CHARS = 4e3;
50958
- function extractFinalSummaryFromMessages(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
50959
- if (!Array.isArray(messages) || messages.length === 0) return "";
50960
- for (let i = messages.length - 1; i >= 0; i--) {
50961
- const msg = messages[i];
50962
- if (!msg) continue;
50963
- const classification = classifyChatMessageVisibility(msg);
50964
- if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
50965
- const text = flattenContent(msg.content).trim();
50966
- if (text) return text.slice(0, maxChars);
50967
- }
50968
- }
50969
- return "";
50970
- }
50971
- var BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
50972
- var CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
50973
- var CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
50974
- var CHAT_MESSAGE_AUDIENCES = ["chat", "debug", "trace", "internal"];
50975
- var CHAT_MESSAGE_SOURCES = [
50976
- "assistant_text",
50977
- "tool_call",
50978
- "terminal_command",
50979
- "runtime_activity",
50980
- "runtime_status",
50981
- "provider_chrome",
50982
- "control"
50983
- ];
50984
- var CHAT_MESSAGE_ACTIVITY_SOURCES = ["tool_call", "terminal_command", "runtime_activity"];
50985
- var CHAT_MESSAGE_INTERNAL_SOURCES = ["runtime_status", "provider_chrome", "control"];
50986
- var KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
50987
- var CHAT_MESSAGE_KIND_ALIASES = {
50988
- text: "standard",
50989
- message: "standard",
50990
- assistant: "standard",
50991
- thinking: "thought",
50992
- think: "thought",
50993
- reasoning: "thought",
50994
- reason: "thought",
50995
- toolcall: "tool",
50996
- tool_call: "tool",
50997
- tooluse: "tool",
50998
- tool_use: "tool",
50999
- action: "tool",
51000
- command: "terminal",
51001
- cmd: "terminal",
51002
- shell: "terminal",
51003
- console: "terminal"
51004
- };
51005
- function canonicalizeKindHint(value) {
51006
- return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
51007
- }
51008
- function resolveBuiltinOrAliasKind(kind) {
51009
- if (typeof kind !== "string") return null;
51010
- const normalizedKind = canonicalizeKindHint(kind);
51011
- if (!normalizedKind) return null;
51012
- if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
51013
- return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
51014
- }
51015
- function inferHintKind(value) {
51016
- const direct = resolveBuiltinOrAliasKind(value);
51017
- if (direct) return direct;
51018
- if (typeof value !== "string") return null;
51019
- const normalized = canonicalizeKindHint(value);
51020
- if (!normalized) return null;
51021
- if (/thought|thinking|reasoning/.test(normalized)) return "thought";
51022
- if (/tool/.test(normalized)) return "tool";
51023
- if (/terminal|command|shell|console/.test(normalized)) return "terminal";
51024
- return null;
51025
- }
51026
- function inferKindFromToolCalls(message) {
51027
- const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
51028
- if (toolCalls.length === 0) return null;
51029
- if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
51030
- if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
51031
- if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
51032
- return "terminal";
51033
- }
51034
- return "tool";
51035
- }
51036
- function inferMissingChatMessageKind(message) {
51037
- const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
51038
- if (role === "system") return "system";
51039
- const meta3 = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
51040
- const hintCandidates = [
51041
- message?._sub,
51042
- message?._type,
51043
- meta3?.label,
51044
- typeof message?.senderName === "string" ? message.senderName : void 0
51045
- ];
51046
- for (const candidate of hintCandidates) {
51047
- const inferred = inferHintKind(candidate);
51048
- if (inferred) return inferred;
51049
- }
51050
- const inferredFromToolCalls = inferKindFromToolCalls(message);
51051
- if (inferredFromToolCalls) return inferredFromToolCalls;
51052
- return null;
51053
- }
51054
- function isBuiltinChatMessageKind(kind) {
51055
- return resolveBuiltinOrAliasKind(kind) !== null;
51056
- }
51057
- function normalizeChatMessageKind(kind, role) {
51058
- const resolvedKind = resolveBuiltinOrAliasKind(kind);
51059
- if (resolvedKind) return resolvedKind;
51060
- const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
51061
- return normalizedRole === "system" ? "system" : "standard";
51062
- }
51063
- function resolveChatMessageKind(message) {
51064
- const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
51065
- if (explicitKind) return explicitKind;
51066
- const inferredKind = inferMissingChatMessageKind(message);
51067
- if (inferredKind) return inferredKind;
51068
- return normalizeChatMessageKind(message?.kind, message?.role);
51069
- }
51070
- function buildChatMessage(message) {
51071
- return {
51072
- ...message,
51073
- kind: resolveChatMessageKind(message)
51074
- };
51075
- }
51076
- function buildSystemChatMessage(message) {
51077
- return buildChatMessage({
51078
- ...message,
51079
- role: "system",
51080
- kind: message?.kind || "system"
51081
- });
51082
- }
51083
- function buildRuntimeSystemChatMessage(message) {
51084
- return buildSystemChatMessage({
51085
- ...message,
51086
- senderName: typeof message?.senderName === "string" && message.senderName.trim() ? message.senderName : "System"
51087
- });
51088
- }
51089
- function buildAssistantChatMessage(message) {
51090
- return buildChatMessage({
51091
- ...message,
51092
- role: "assistant",
51093
- kind: message?.kind || "standard"
51094
- });
51095
- }
51096
- function buildThoughtChatMessage(message) {
51097
- return buildAssistantChatMessage({
51098
- ...message,
51099
- kind: message?.kind || "thought"
51100
- });
51101
- }
51102
- function buildToolChatMessage(message) {
51103
- return buildAssistantChatMessage({
51104
- ...message,
51105
- kind: message?.kind || "tool"
51106
- });
51107
- }
51108
- function buildTerminalChatMessage(message) {
51109
- return buildAssistantChatMessage({
51110
- ...message,
51111
- kind: message?.kind || "terminal"
51112
- });
51113
- }
51114
- function buildUserChatMessage(message) {
51115
- return buildChatMessage({
51116
- ...message,
51117
- role: "user",
51118
- kind: message?.kind || "standard"
51119
- });
51120
- }
51121
- function normalizeChatMessage(message) {
51122
- return buildChatMessage(message);
51123
- }
51124
- function normalizeChatMessages(messages) {
51125
- return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
51126
- }
51127
- function readMessageMeta(message) {
51128
- const meta3 = message?.meta;
51129
- return meta3 && typeof meta3 === "object" && !Array.isArray(meta3) ? meta3 : null;
51130
- }
51131
- function readStringField(value) {
51132
- return typeof value === "string" ? value.trim().toLowerCase() : "";
51133
- }
51134
- function readRecordField(message, meta3, key) {
51135
- const record2 = message;
51136
- return record2[key] ?? meta3?.[key];
51137
- }
51138
- function readVisibilityField(message, meta3) {
51139
- return readStringField(readRecordField(message, meta3, "visibility"));
51140
- }
51141
- function readTranscriptVisibilityField(message, meta3) {
51142
- const record2 = message;
51143
- return readStringField(record2.transcriptVisibility ?? meta3?.transcriptVisibility ?? record2.visibility ?? meta3?.visibility);
51144
- }
51145
- var EXPLICIT_HIDDEN_VISIBILITIES = /* @__PURE__ */ new Set(["hidden", "debug", "internal"]);
51146
- var EXPLICIT_VISIBLE_VISIBILITIES = /* @__PURE__ */ new Set(["visible", "user", "chat"]);
51147
- var HIDDEN_AUDIENCES = /* @__PURE__ */ new Set(["debug", "trace", "internal"]);
51148
- var ACTIVITY_SOURCE_SET = new Set(CHAT_MESSAGE_ACTIVITY_SOURCES);
51149
- var INTERNAL_SOURCE_SET = new Set(CHAT_MESSAGE_INTERNAL_SOURCES);
51150
- function hasBooleanMarker(message, meta3, keys) {
51151
- const record2 = message;
51152
- return keys.some((key) => record2[key] === true || meta3?.[key] === true);
51153
- }
51154
- function isActivityKind(kind) {
51155
- return kind === "thought" || kind === "tool" || kind === "terminal";
51156
- }
51157
- function isOrdinaryVisibleTurn(message, role, kind) {
51158
- if (role === "user" || role === "human") return kind === "standard" || kind === "";
51159
- if (role === "assistant") return kind === "standard" || kind === "";
51160
- return false;
51161
- }
51162
- function classifyChatMessageVisibility(message) {
51163
- if (!message) {
51164
- return {
51165
- surface: "internal",
51166
- isUserFacing: false,
51167
- isActivityFacing: false,
51168
- isInternal: true,
51169
- explicitUserFacing: false,
51170
- explicitHidden: true,
51171
- role: "",
51172
- kind: "standard",
51173
- visibility: "",
51174
- transcriptVisibility: "",
51175
- audience: "",
51176
- source: ""
51177
- };
51178
- }
51179
- const meta3 = readMessageMeta(message);
51180
- const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
51181
- const kind = resolveChatMessageKind(message);
51182
- const visibility = readVisibilityField(message, meta3);
51183
- const transcriptVisibility = readTranscriptVisibilityField(message, meta3);
51184
- const audience = readStringField(readRecordField(message, meta3, "audience"));
51185
- const source = readStringField(readRecordField(message, meta3, "source"));
51186
- const explicitHidden = EXPLICIT_HIDDEN_VISIBILITIES.has(visibility) || EXPLICIT_HIDDEN_VISIBILITIES.has(transcriptVisibility) || HIDDEN_AUDIENCES.has(audience) || hasBooleanMarker(message, meta3, ["hidden", "internal", "isInternal", "debug", "statusOnly", "controlOnly"]);
51187
- const explicitUserFacing = EXPLICIT_VISIBLE_VISIBILITIES.has(visibility) || EXPLICIT_VISIBLE_VISIBILITIES.has(transcriptVisibility) || audience === "chat" || hasBooleanMarker(message, meta3, ["userFacing"]);
51188
- if (explicitHidden) {
51189
- const activityLike = isActivityKind(kind) || ACTIVITY_SOURCE_SET.has(source);
51190
- return {
51191
- surface: activityLike ? "activity" : "internal",
51192
- isUserFacing: false,
51193
- isActivityFacing: activityLike,
51194
- isInternal: !activityLike,
51195
- explicitUserFacing,
51196
- explicitHidden,
51197
- role,
51198
- kind,
51199
- visibility,
51200
- transcriptVisibility,
51201
- audience,
51202
- source
51203
- };
51204
- }
51205
- if (explicitUserFacing) {
51206
- return {
51207
- surface: "chat",
51208
- isUserFacing: true,
51209
- isActivityFacing: false,
51210
- isInternal: false,
51211
- explicitUserFacing,
51212
- explicitHidden,
51213
- role,
51214
- kind,
51215
- visibility,
51216
- transcriptVisibility,
51217
- audience,
51218
- source
51219
- };
51220
- }
51221
- if (INTERNAL_SOURCE_SET.has(source) || role === "system" || kind === "system") {
51222
- return {
51223
- surface: "internal",
51224
- isUserFacing: false,
51225
- isActivityFacing: false,
51226
- isInternal: true,
51227
- explicitUserFacing,
51228
- explicitHidden,
51229
- role,
51230
- kind,
51231
- visibility,
51232
- transcriptVisibility,
51233
- audience,
51234
- source
51235
- };
51236
- }
51237
- if (ACTIVITY_SOURCE_SET.has(source) || isActivityKind(kind)) {
51238
- return {
51239
- surface: "activity",
51240
- isUserFacing: false,
51241
- isActivityFacing: true,
51242
- isInternal: false,
51243
- explicitUserFacing,
51244
- explicitHidden,
51245
- role,
51246
- kind,
51247
- visibility,
51248
- transcriptVisibility,
51249
- audience,
51250
- source
51251
- };
51252
- }
51253
- const isUserFacing = isOrdinaryVisibleTurn(message, role, kind);
51254
- return {
51255
- surface: isUserFacing ? "chat" : "internal",
51256
- isUserFacing,
51257
- isActivityFacing: false,
51258
- isInternal: !isUserFacing,
51259
- explicitUserFacing,
51260
- explicitHidden,
51261
- role,
51262
- kind,
51263
- visibility,
51264
- transcriptVisibility,
51265
- audience,
51266
- source
51267
- };
51268
- }
51269
- function isUserFacingChatMessage(message) {
51270
- return classifyChatMessageVisibility(message).isUserFacing;
51271
- }
51272
- function isActivityChatMessage(message) {
51273
- return classifyChatMessageVisibility(message).isActivityFacing;
51274
- }
51275
- function isInternalChatMessage(message) {
51276
- return classifyChatMessageVisibility(message).isInternal;
51277
- }
51278
- function filterUserFacingChatMessages(messages) {
51279
- return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
51280
- }
51281
- function filterActivityChatMessages(messages) {
51282
- return (Array.isArray(messages) ? messages : []).filter((message) => isActivityChatMessage(message));
51283
- }
51284
- function filterInternalChatMessages(messages) {
51285
- return (Array.isArray(messages) ? messages : []).filter((message) => isInternalChatMessage(message));
51286
- }
51287
- function filterChatMessagesByVisibility(messages, surface) {
51288
- return (Array.isArray(messages) ? messages : []).filter((message) => classifyChatMessageVisibility(message).surface === surface);
51289
- }
51462
+ init_contracts();
51463
+ init_chat_message_normalization();
51290
51464
  function extractProviderControlValues(controls, data) {
51291
51465
  if (!data || typeof data !== "object") return void 0;
51292
51466
  const values = {};
@@ -51481,6 +51655,7 @@ ${cleanBody}`;
51481
51655
  var fs6 = __toESM2(require("fs"));
51482
51656
  var path14 = __toESM2(require("path"));
51483
51657
  var os8 = __toESM2(require("os"));
51658
+ init_chat_message_normalization();
51484
51659
  var HISTORY_DIR = path14.join(os8.homedir(), ".adhdev", "history");
51485
51660
  var RETAIN_DAYS = 30;
51486
51661
  var SAVED_HISTORY_INDEX_VERSION = 1;
@@ -53016,6 +53191,7 @@ ${cleanBody}`;
53016
53191
  })
53017
53192
  };
53018
53193
  }
53194
+ init_chat_message_normalization();
53019
53195
  var IDE_PROVIDER_SESSION_CAPABILITIES_BASE = [
53020
53196
  "read_chat",
53021
53197
  "send_message",
@@ -53445,6 +53621,7 @@ ${effect.notification.body || ""}`.trim();
53445
53621
  }
53446
53622
  };
53447
53623
  init_logger();
53624
+ init_contracts();
53448
53625
  var CHAT_CONTRACT_VERSION_V1 = "1.0";
53449
53626
  var VALID_STATUSES = ["idle", "generating", "waiting_approval", "error", "panel_hidden", "starting", "streaming", "long_generating"];
53450
53627
  var VALID_ROLES = ["user", "assistant", "system", "human"];
@@ -53657,6 +53834,7 @@ ${effect.notification.body || ""}`.trim();
53657
53834
  if (/what do you want to do\?/i.test(text) && /^\s*\d+[.)]\s+\S/m.test(text)) return true;
53658
53835
  return false;
53659
53836
  }
53837
+ init_chat_message_normalization();
53660
53838
  async function withTimeout(promise2, timeoutMs, label) {
53661
53839
  let timer = null;
53662
53840
  try {
@@ -55287,6 +55465,7 @@ ${effect.notification.body || ""}`.trim();
55287
55465
  var os9 = __toESM2(require("os"));
55288
55466
  var path15 = __toESM2(require("path"));
55289
55467
  var import_node_crypto3 = require("crypto");
55468
+ init_contracts();
55290
55469
  init_logger();
55291
55470
  init_debug_config();
55292
55471
  function summarizeString(value) {
@@ -55765,6 +55944,7 @@ ${effect.notification.body || ""}`.trim();
55765
55944
  return `v1:${providerType}:${sessionId}:${ts2 ?? ""}:${positionalSeq}:${role}`;
55766
55945
  }
55767
55946
  var CHAT_SOURCE_REGISTRY = new ChatSourceRegistry();
55947
+ init_chat_message_normalization();
55768
55948
  var RECENT_SEND_WINDOW_MS = 1200;
55769
55949
  var READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
55770
55950
  var HOT_TAIL_MIN_LIMIT = 60;
@@ -60585,6 +60765,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
60585
60765
  var crypto4 = __toESM2(require("crypto"));
60586
60766
  var fs16 = __toESM2(require("fs"));
60587
60767
  var import_node_module = require("module");
60768
+ init_contracts();
60588
60769
  var fs15 = __toESM2(require("fs"));
60589
60770
  var path23 = __toESM2(require("path"));
60590
60771
  init_provider_cli_adapter();
@@ -63098,6 +63279,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
63098
63279
  }
63099
63280
  return normalizedId;
63100
63281
  }
63282
+ init_chat_message_normalization();
63101
63283
  function workingDirBasename(p) {
63102
63284
  return (p || "").split(/[\\/]/).filter(Boolean).pop() || "session";
63103
63285
  }
@@ -64225,7 +64407,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
64225
64407
  const dirName = workingDirBasename(this.workingDir);
64226
64408
  const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
64227
64409
  const partial2 = this.adapter.getPartialResponse();
64228
- const progressFingerprint = newStatus === "generating" ? `${partial2 || ""}`.slice(-2e3) : void 0;
64410
+ const progressFingerprint = newStatus === "generating" ? `${`${partial2 || ""}`.slice(-2e3)}::scr=${adapterStatus.lastScreenChangeAt ?? 0}::out=${adapterStatus.lastOutputAt ?? 0}` : void 0;
64229
64411
  const previousStatus = this.lastStatus;
64230
64412
  if (newStatus !== this.lastStatus) {
64231
64413
  LOG2.info("CLI", `[${this.type}] status: ${this.lastStatus} \u2192 ${newStatus}`);
@@ -64899,6 +65081,8 @@ ${effect.notification.body || ""}`.trim();
64899
65081
  var import_stream = require("stream");
64900
65082
  var import_child_process5 = require("child_process");
64901
65083
  var import_sdk = (init_acp(), __toCommonJS(acp_exports));
65084
+ init_contracts();
65085
+ init_chat_message_normalization();
64902
65086
  init_logger();
64903
65087
  function getPromptCapabilityFlags(agentCapabilities) {
64904
65088
  const prompt = agentCapabilities?.promptCapabilities || {};
@@ -66126,6 +66310,7 @@ ${rawInput}` : rawInput;
66126
66310
  return this.agentCapabilities;
66127
66311
  }
66128
66312
  };
66313
+ init_contracts();
66129
66314
  init_logger();
66130
66315
  function shouldRestoreHostedRuntime(record2, managerTag) {
66131
66316
  if (!managerTag) return true;
@@ -72588,6 +72773,25 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
72588
72773
  node.lastSeenAt = updatedAt;
72589
72774
  const repoRoot = readStringValue(nextGit.repoRoot);
72590
72775
  if (repoRoot && !readStringValue(node.repoRoot)) node.repoRoot = repoRoot;
72776
+ const isLocalSource = source === "selected_coordinator_local_git";
72777
+ const reporterPlatform = readStringValue(git.reporterPlatform) ?? (isLocalSource ? process.platform : null);
72778
+ const reporterArch = readStringValue(git.reporterArch) ?? (isLocalSource ? process.arch : null);
72779
+ stampNodeReporterPlatform(node, reporterPlatform, reporterArch);
72780
+ }
72781
+ function stampNodeReporterPlatform(node, platform10, arch2) {
72782
+ if (!node || typeof node !== "object" || Array.isArray(node)) return;
72783
+ if (!platform10 && !arch2) return;
72784
+ const overrides = node.userOverrides && typeof node.userOverrides === "object" && !Array.isArray(node.userOverrides) ? node.userOverrides : {};
72785
+ let changed = false;
72786
+ if (platform10 && !readStringValue(overrides.platform)) {
72787
+ overrides.platform = platform10;
72788
+ changed = true;
72789
+ }
72790
+ if (arch2 && !readStringValue(overrides.arch)) {
72791
+ overrides.arch = arch2;
72792
+ changed = true;
72793
+ }
72794
+ if (changed) node.userOverrides = overrides;
72591
72795
  }
72592
72796
  function buildCachedInlineMeshGitStatus(node) {
72593
72797
  const liveGit = buildInlineMeshTransitGitStatus(node);
@@ -73081,7 +73285,13 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
73081
73285
  new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), args.timeoutMs))
73082
73286
  ]);
73083
73287
  const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
73084
- return remoteGit && typeof remoteGit === "object" && typeof remoteGit.isGitRepo === "boolean" ? remoteGit : null;
73288
+ if (!remoteGit || typeof remoteGit !== "object" || typeof remoteGit.isGitRepo !== "boolean") return null;
73289
+ const reporterPlatform = readStringValue(remoteResult?.reporterPlatform);
73290
+ const reporterArch = readStringValue(remoteResult?.reporterArch);
73291
+ const git = remoteGit;
73292
+ if (reporterPlatform) git.reporterPlatform = reporterPlatform;
73293
+ if (reporterArch) git.reporterArch = reporterArch;
73294
+ return git;
73085
73295
  }
73086
73296
  var MESH_DIRECT_PROBE_MAX_RETRIES = 2;
73087
73297
  function readMeshConnectionState(connection) {
@@ -79973,6 +80183,7 @@ ${ptyResult.output.slice(-2e3)}`);
79973
80183
  init_debug_config();
79974
80184
  var DEFAULT_DAEMON_PORT2 = 19222;
79975
80185
  var DAEMON_WS_PATH2 = "/ipc";
80186
+ init_chat_message_normalization();
79976
80187
  function normalizeModalButtons(value) {
79977
80188
  return Array.isArray(value) ? value.filter((button) => typeof button === "string") : [];
79978
80189
  }
@@ -80109,6 +80320,7 @@ ${ptyResult.output.slice(-2e3)}`);
80109
80320
  });
80110
80321
  await Promise.all(runners);
80111
80322
  }
80323
+ init_chat_message_normalization();
80112
80324
  var ProviderStreamAdapter = class {
80113
80325
  agentType;
80114
80326
  agentName;
@@ -80789,6 +81001,7 @@ ${ptyResult.output.slice(-2e3)}`);
80789
81001
  }
80790
81002
  };
80791
81003
  init_logger();
81004
+ init_chat_message_normalization();
80792
81005
  var AgentStreamPoller = class {
80793
81006
  deps;
80794
81007
  timer = null;
@@ -81305,6 +81518,8 @@ ${ptyResult.output.slice(-2e3)}`);
81305
81518
  this.eventListeners = [];
81306
81519
  }
81307
81520
  };
81521
+ init_io_contracts();
81522
+ init_chat_message_normalization();
81308
81523
  var fs27 = __toESM2(require("fs"));
81309
81524
  var path37 = __toESM2(require("path"));
81310
81525
  var os28 = __toESM2(require("os"));