@adhdev/daemon-core 0.9.82-rc.325 → 0.9.82-rc.327
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/cli-adapters/provider-cli-shared.d.ts +15 -0
- package/dist/config/mesh-config.d.ts +5 -0
- package/dist/git/git-commands.d.ts +2 -0
- package/dist/index.js +835 -599
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +835 -599
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-work-queue.d.ts +2 -0
- package/dist/providers/chat-message-normalization.d.ts +12 -0
- package/dist/repo-mesh-types.d.ts +12 -0
- package/package.json +2 -2
- package/src/cli-adapters/provider-cli-adapter.ts +2 -0
- package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
- package/src/cli-adapters/provider-cli-shared.ts +15 -0
- package/src/commands/router.ts +90 -9
- package/src/config/mesh-config.ts +7 -0
- package/src/git/git-commands.ts +13 -2
- package/src/mesh/mesh-reconcile-loop.ts +147 -0
- package/src/mesh/mesh-work-queue.ts +28 -8
- package/src/providers/chat-message-normalization.ts +47 -0
- package/src/providers/cli-provider-instance.ts +9 -1
- package/src/repo-mesh-types.ts +12 -0
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 ? "
|
|
312
|
-
const commitShort = readInjected(true ? "
|
|
313
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
314
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
311
|
+
const commit = readInjected(true ? "993e3922de8abe554822450e2b4c26c2c9f5f64a" : void 0) ?? "unknown";
|
|
312
|
+
const commitShort = readInjected(true ? "993e3922" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
313
|
+
const version = readInjected(true ? "0.9.82-rc.327" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
314
|
+
const builtAt = readInjected(true ? "2026-06-19T12:31:25.870Z" : void 0);
|
|
315
315
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
316
316
|
return cached;
|
|
317
317
|
}
|
|
@@ -1940,6 +1940,8 @@ function updateNode(meshId, nodeId, opts) {
|
|
|
1940
1940
|
const node = mesh.nodes.find((n) => n.id === nodeId);
|
|
1941
1941
|
if (!node) return void 0;
|
|
1942
1942
|
if (opts.userOverrides) node.userOverrides = { ...node.userOverrides, ...opts.userOverrides };
|
|
1943
|
+
if (opts.reportedPlatform && opts.reportedPlatform.trim()) node.reportedPlatform = opts.reportedPlatform.trim();
|
|
1944
|
+
if (opts.reportedArch && opts.reportedArch.trim()) node.reportedArch = opts.reportedArch.trim();
|
|
1943
1945
|
if (opts.policy) node.policy = { ...node.policy, ...opts.policy };
|
|
1944
1946
|
if (opts.worktreeBootstrap) node.worktreeBootstrap = opts.worktreeBootstrap;
|
|
1945
1947
|
if (Object.prototype.hasOwnProperty.call(opts, "systemPrompt")) {
|
|
@@ -3104,11 +3106,15 @@ function readNodeOverride(node, key) {
|
|
|
3104
3106
|
const value = overrides[key];
|
|
3105
3107
|
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
3106
3108
|
}
|
|
3109
|
+
function readNodeReporter(node, key) {
|
|
3110
|
+
const value = key === "platform" ? node?.reportedPlatform : node?.reportedArch;
|
|
3111
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
3112
|
+
}
|
|
3107
3113
|
function buildMeshNodeCapabilityTags(node, providerType) {
|
|
3108
3114
|
const provider = typeof providerType === "string" && providerType.trim() ? providerType.trim() : firstProviderPriority(node?.policy);
|
|
3109
3115
|
const worktreeBranch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : null;
|
|
3110
|
-
const os30 = readNodeOverride(node, "platform") ?? process.platform;
|
|
3111
|
-
const arch2 = readNodeOverride(node, "arch") ?? process.arch;
|
|
3116
|
+
const os30 = readNodeOverride(node, "platform") ?? readNodeReporter(node, "platform") ?? process.platform;
|
|
3117
|
+
const arch2 = readNodeOverride(node, "arch") ?? readNodeReporter(node, "arch") ?? process.arch;
|
|
3112
3118
|
return normalizeMeshCapabilityTags([
|
|
3113
3119
|
...Array.isArray(node?.capabilities) ? node.capabilities : [],
|
|
3114
3120
|
`os=${os30}`,
|
|
@@ -10130,6 +10136,644 @@ var init_mesh_events_coordinator = __esm({
|
|
|
10130
10136
|
}
|
|
10131
10137
|
});
|
|
10132
10138
|
|
|
10139
|
+
// src/providers/io-contracts.ts
|
|
10140
|
+
function normalizeInputEnvelope(input) {
|
|
10141
|
+
const normalized = normalizeInputEnvelopePayload(input);
|
|
10142
|
+
const textFallback = normalized.textFallback ?? flattenInputParts(normalized.parts);
|
|
10143
|
+
return {
|
|
10144
|
+
parts: normalized.parts,
|
|
10145
|
+
textFallback,
|
|
10146
|
+
...normalized.metadata ? { metadata: normalized.metadata } : {}
|
|
10147
|
+
};
|
|
10148
|
+
}
|
|
10149
|
+
function normalizeMessageParts(content) {
|
|
10150
|
+
if (typeof content === "string") return [{ type: "text", text: content }];
|
|
10151
|
+
if (!Array.isArray(content)) {
|
|
10152
|
+
if (content && typeof content === "object" && typeof content.text === "string") {
|
|
10153
|
+
return [{ type: "text", text: String(content.text) }];
|
|
10154
|
+
}
|
|
10155
|
+
return [];
|
|
10156
|
+
}
|
|
10157
|
+
const parts = [];
|
|
10158
|
+
for (const raw of content) {
|
|
10159
|
+
if (typeof raw === "string") {
|
|
10160
|
+
parts.push({ type: "text", text: raw });
|
|
10161
|
+
continue;
|
|
10162
|
+
}
|
|
10163
|
+
if (!raw || typeof raw !== "object") continue;
|
|
10164
|
+
const part = normalizeMessagePartObject(raw);
|
|
10165
|
+
if (part) parts.push(part);
|
|
10166
|
+
}
|
|
10167
|
+
return parts;
|
|
10168
|
+
}
|
|
10169
|
+
function flattenMessageParts(parts) {
|
|
10170
|
+
return parts.map((part) => {
|
|
10171
|
+
if (part.type === "text") return part.text;
|
|
10172
|
+
if (part.type === "resource") return part.resource.text || "";
|
|
10173
|
+
if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
|
|
10174
|
+
if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
|
|
10175
|
+
if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
|
|
10176
|
+
if (part.type === "resource_link") return [part.name, part.description].filter(Boolean).join("\n");
|
|
10177
|
+
return "";
|
|
10178
|
+
}).filter((value) => value.length > 0).join("\n");
|
|
10179
|
+
}
|
|
10180
|
+
function normalizeInputEnvelopePayload(input) {
|
|
10181
|
+
if (typeof input === "string") {
|
|
10182
|
+
return { parts: [{ type: "text", text: input }], textFallback: input };
|
|
10183
|
+
}
|
|
10184
|
+
if (!input || typeof input !== "object") {
|
|
10185
|
+
return { parts: [], textFallback: "" };
|
|
10186
|
+
}
|
|
10187
|
+
const record = input;
|
|
10188
|
+
const nestedInput = record.input;
|
|
10189
|
+
if (nestedInput && typeof nestedInput === "object") {
|
|
10190
|
+
const nested = nestedInput;
|
|
10191
|
+
return {
|
|
10192
|
+
parts: normalizeInputParts(nested.parts ?? nested.prompt),
|
|
10193
|
+
textFallback: typeof nested.textFallback === "string" ? nested.textFallback : void 0,
|
|
10194
|
+
metadata: normalizeInputMetadata(nested.metadata)
|
|
10195
|
+
};
|
|
10196
|
+
}
|
|
10197
|
+
const directText = typeof record.text === "string" ? record.text : typeof record.message === "string" ? record.message : void 0;
|
|
10198
|
+
if (directText !== void 0) {
|
|
10199
|
+
return { parts: [{ type: "text", text: directText }], textFallback: directText };
|
|
10200
|
+
}
|
|
10201
|
+
const directParts = normalizeInputParts(record.parts ?? record.prompt);
|
|
10202
|
+
return {
|
|
10203
|
+
parts: directParts,
|
|
10204
|
+
textFallback: typeof record.textFallback === "string" ? record.textFallback : void 0,
|
|
10205
|
+
metadata: normalizeInputMetadata(record.metadata)
|
|
10206
|
+
};
|
|
10207
|
+
}
|
|
10208
|
+
function normalizeInputMetadata(value) {
|
|
10209
|
+
if (!value || typeof value !== "object") return void 0;
|
|
10210
|
+
const record = value;
|
|
10211
|
+
const metadata = {};
|
|
10212
|
+
if (record.source === "dashboard" || record.source === "shortcut_api" || record.source === "provider_script" || record.source === "session_replay") {
|
|
10213
|
+
metadata.source = record.source;
|
|
10214
|
+
}
|
|
10215
|
+
if (typeof record.clientTimestamp === "number" && Number.isFinite(record.clientTimestamp)) {
|
|
10216
|
+
metadata.clientTimestamp = record.clientTimestamp;
|
|
10217
|
+
}
|
|
10218
|
+
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
10219
|
+
}
|
|
10220
|
+
function normalizeInputParts(value) {
|
|
10221
|
+
if (!Array.isArray(value)) return [];
|
|
10222
|
+
const parts = [];
|
|
10223
|
+
for (const raw of value) {
|
|
10224
|
+
if (typeof raw === "string") {
|
|
10225
|
+
parts.push({ type: "text", text: raw });
|
|
10226
|
+
continue;
|
|
10227
|
+
}
|
|
10228
|
+
if (!raw || typeof raw !== "object") continue;
|
|
10229
|
+
const part = normalizeInputPartObject(raw);
|
|
10230
|
+
if (part) parts.push(part);
|
|
10231
|
+
}
|
|
10232
|
+
return parts;
|
|
10233
|
+
}
|
|
10234
|
+
function normalizeInputPartObject(raw) {
|
|
10235
|
+
const type = raw.type;
|
|
10236
|
+
if (type === "text" && typeof raw.text === "string") {
|
|
10237
|
+
return { type, text: raw.text };
|
|
10238
|
+
}
|
|
10239
|
+
if (type === "image" && typeof raw.mimeType === "string") {
|
|
10240
|
+
return {
|
|
10241
|
+
type,
|
|
10242
|
+
mimeType: raw.mimeType,
|
|
10243
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
10244
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
10245
|
+
...typeof raw.alt === "string" ? { alt: raw.alt } : {}
|
|
10246
|
+
};
|
|
10247
|
+
}
|
|
10248
|
+
if (type === "audio" && typeof raw.mimeType === "string") {
|
|
10249
|
+
return {
|
|
10250
|
+
type,
|
|
10251
|
+
mimeType: raw.mimeType,
|
|
10252
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
10253
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
10254
|
+
...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
|
|
10255
|
+
};
|
|
10256
|
+
}
|
|
10257
|
+
if (type === "video" && typeof raw.mimeType === "string") {
|
|
10258
|
+
return {
|
|
10259
|
+
type,
|
|
10260
|
+
mimeType: raw.mimeType,
|
|
10261
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
10262
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
10263
|
+
...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
|
|
10264
|
+
...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
|
|
10265
|
+
};
|
|
10266
|
+
}
|
|
10267
|
+
if (type === "resource" && typeof raw.uri === "string") {
|
|
10268
|
+
return {
|
|
10269
|
+
type,
|
|
10270
|
+
uri: raw.uri,
|
|
10271
|
+
...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
|
|
10272
|
+
...typeof raw.name === "string" ? { name: raw.name } : {},
|
|
10273
|
+
...typeof raw.text === "string" ? { text: raw.text } : {},
|
|
10274
|
+
...typeof raw.data === "string" ? { data: raw.data } : {}
|
|
10275
|
+
};
|
|
10276
|
+
}
|
|
10277
|
+
if (type === "resource_link" && typeof raw.uri === "string") {
|
|
10278
|
+
return {
|
|
10279
|
+
type,
|
|
10280
|
+
uri: raw.uri,
|
|
10281
|
+
name: typeof raw.name === "string" ? raw.name : getUriDisplayName(raw.uri, "resource"),
|
|
10282
|
+
...typeof raw.title === "string" ? { title: raw.title } : {},
|
|
10283
|
+
...typeof raw.description === "string" ? { description: raw.description } : {},
|
|
10284
|
+
...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
|
|
10285
|
+
...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
|
|
10286
|
+
...normalizeAnnotationsProperty(raw.annotations)
|
|
10287
|
+
};
|
|
10288
|
+
}
|
|
10289
|
+
return null;
|
|
10290
|
+
}
|
|
10291
|
+
function normalizeMessagePartObject(raw) {
|
|
10292
|
+
const type = raw.type;
|
|
10293
|
+
if (type === "text" && typeof raw.text === "string") {
|
|
10294
|
+
return { type, text: raw.text };
|
|
10295
|
+
}
|
|
10296
|
+
if (type === "image" && typeof raw.mimeType === "string") {
|
|
10297
|
+
return {
|
|
10298
|
+
type,
|
|
10299
|
+
mimeType: raw.mimeType,
|
|
10300
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
10301
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
10302
|
+
...typeof raw.alt === "string" ? { alt: raw.alt } : {}
|
|
10303
|
+
};
|
|
10304
|
+
}
|
|
10305
|
+
if (type === "audio" && typeof raw.mimeType === "string") {
|
|
10306
|
+
return {
|
|
10307
|
+
type,
|
|
10308
|
+
mimeType: raw.mimeType,
|
|
10309
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
10310
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
10311
|
+
...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {}
|
|
10312
|
+
};
|
|
10313
|
+
}
|
|
10314
|
+
if (type === "video" && typeof raw.mimeType === "string") {
|
|
10315
|
+
return {
|
|
10316
|
+
type,
|
|
10317
|
+
mimeType: raw.mimeType,
|
|
10318
|
+
...typeof raw.uri === "string" ? { uri: raw.uri } : {},
|
|
10319
|
+
...typeof raw.data === "string" ? { data: raw.data } : {},
|
|
10320
|
+
...typeof raw.transcript === "string" ? { transcript: raw.transcript } : {},
|
|
10321
|
+
...typeof raw.posterUri === "string" ? { posterUri: raw.posterUri } : {}
|
|
10322
|
+
};
|
|
10323
|
+
}
|
|
10324
|
+
if (type === "resource_link" && typeof raw.uri === "string" && typeof raw.name === "string") {
|
|
10325
|
+
return {
|
|
10326
|
+
type,
|
|
10327
|
+
uri: raw.uri,
|
|
10328
|
+
name: raw.name,
|
|
10329
|
+
...typeof raw.title === "string" ? { title: raw.title } : {},
|
|
10330
|
+
...typeof raw.description === "string" ? { description: raw.description } : {},
|
|
10331
|
+
...typeof raw.mimeType === "string" ? { mimeType: raw.mimeType } : {},
|
|
10332
|
+
...typeof raw.size === "number" && Number.isFinite(raw.size) ? { size: raw.size } : {},
|
|
10333
|
+
...normalizeAnnotationsProperty(raw.annotations)
|
|
10334
|
+
};
|
|
10335
|
+
}
|
|
10336
|
+
if (type === "resource" && raw.resource && typeof raw.resource === "object") {
|
|
10337
|
+
const resource = raw.resource;
|
|
10338
|
+
if (typeof resource.uri !== "string") return null;
|
|
10339
|
+
return {
|
|
10340
|
+
type,
|
|
10341
|
+
resource: {
|
|
10342
|
+
uri: resource.uri,
|
|
10343
|
+
...typeof resource.mimeType === "string" || resource.mimeType === null ? { mimeType: resource.mimeType } : {},
|
|
10344
|
+
...typeof resource.text === "string" ? { text: resource.text } : {},
|
|
10345
|
+
...typeof resource.blob === "string" ? { blob: resource.blob } : {}
|
|
10346
|
+
}
|
|
10347
|
+
};
|
|
10348
|
+
}
|
|
10349
|
+
return null;
|
|
10350
|
+
}
|
|
10351
|
+
function flattenInputParts(parts) {
|
|
10352
|
+
return parts.map((part) => {
|
|
10353
|
+
if (part.type === "text") return part.text;
|
|
10354
|
+
if (part.type === "image") return part.alt || (part.data ? `[image: ${part.mimeType}]` : "");
|
|
10355
|
+
if (part.type === "audio") return part.transcript || (part.data ? `[audio: ${part.mimeType}]` : "");
|
|
10356
|
+
if (part.type === "video") return part.transcript || (part.data ? `[video: ${part.mimeType}]` : "");
|
|
10357
|
+
if (part.type === "resource_link") return [part.title, part.name, part.description, part.uri].filter(Boolean).join("\n");
|
|
10358
|
+
if (part.type === "resource") return part.text || part.name || part.uri;
|
|
10359
|
+
return "";
|
|
10360
|
+
}).filter((value) => value.length > 0).join("\n");
|
|
10361
|
+
}
|
|
10362
|
+
function getUriDisplayName(uri, fallback) {
|
|
10363
|
+
try {
|
|
10364
|
+
const pathname = uri.startsWith("file://") ? new URL(uri).pathname : uri;
|
|
10365
|
+
return pathname.split(/[\\/]/).filter(Boolean).pop() || fallback;
|
|
10366
|
+
} catch {
|
|
10367
|
+
return uri.split(/[\\/]/).filter(Boolean).pop() || fallback;
|
|
10368
|
+
}
|
|
10369
|
+
}
|
|
10370
|
+
function normalizeAnnotationsProperty(value) {
|
|
10371
|
+
if (!value || typeof value !== "object") return {};
|
|
10372
|
+
const record = value;
|
|
10373
|
+
const annotations = {};
|
|
10374
|
+
if (Array.isArray(record.audience)) {
|
|
10375
|
+
const audience = record.audience.filter((item) => item === "user" || item === "assistant");
|
|
10376
|
+
if (audience.length > 0) annotations.audience = audience;
|
|
10377
|
+
}
|
|
10378
|
+
if (typeof record.priority === "number" && Number.isFinite(record.priority)) {
|
|
10379
|
+
annotations.priority = record.priority;
|
|
10380
|
+
}
|
|
10381
|
+
return Object.keys(annotations).length > 0 ? { annotations } : {};
|
|
10382
|
+
}
|
|
10383
|
+
var init_io_contracts = __esm({
|
|
10384
|
+
"src/providers/io-contracts.ts"() {
|
|
10385
|
+
"use strict";
|
|
10386
|
+
}
|
|
10387
|
+
});
|
|
10388
|
+
|
|
10389
|
+
// src/providers/contracts.ts
|
|
10390
|
+
function flattenContent(content) {
|
|
10391
|
+
if (typeof content === "string") return content;
|
|
10392
|
+
return flattenMessageParts(normalizeMessageParts(content));
|
|
10393
|
+
}
|
|
10394
|
+
var init_contracts = __esm({
|
|
10395
|
+
"src/providers/contracts.ts"() {
|
|
10396
|
+
"use strict";
|
|
10397
|
+
init_io_contracts();
|
|
10398
|
+
init_io_contracts();
|
|
10399
|
+
}
|
|
10400
|
+
});
|
|
10401
|
+
|
|
10402
|
+
// src/providers/chat-message-normalization.ts
|
|
10403
|
+
function extractFinalSummaryFromMessages(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
|
|
10404
|
+
if (!Array.isArray(messages) || messages.length === 0) return "";
|
|
10405
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
10406
|
+
const msg = messages[i];
|
|
10407
|
+
if (!msg) continue;
|
|
10408
|
+
const classification = classifyChatMessageVisibility(msg);
|
|
10409
|
+
if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
|
|
10410
|
+
const text = flattenContent(msg.content).trim();
|
|
10411
|
+
if (text) return text.slice(0, maxChars);
|
|
10412
|
+
}
|
|
10413
|
+
}
|
|
10414
|
+
return "";
|
|
10415
|
+
}
|
|
10416
|
+
function readChatMessageTimestampIso(message) {
|
|
10417
|
+
if (!message) return void 0;
|
|
10418
|
+
const record = message;
|
|
10419
|
+
for (const value of [record.timestamp, record.createdAt, record.created_at, record.updatedAt, record.time]) {
|
|
10420
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
10421
|
+
const ms = value > 1e10 ? value : value * 1e3;
|
|
10422
|
+
return new Date(ms).toISOString();
|
|
10423
|
+
}
|
|
10424
|
+
if (typeof value === "string" && value.trim()) {
|
|
10425
|
+
const ms = new Date(value.trim()).getTime();
|
|
10426
|
+
if (Number.isFinite(ms)) return new Date(ms).toISOString();
|
|
10427
|
+
}
|
|
10428
|
+
}
|
|
10429
|
+
return void 0;
|
|
10430
|
+
}
|
|
10431
|
+
function extractFinalAssistantSummaryEvidence(messages, maxChars = DEFAULT_FINAL_SUMMARY_MAX_CHARS) {
|
|
10432
|
+
if (!Array.isArray(messages) || messages.length === 0) return { finalSummary: "" };
|
|
10433
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
10434
|
+
const msg = messages[i];
|
|
10435
|
+
if (!msg) continue;
|
|
10436
|
+
const classification = classifyChatMessageVisibility(msg);
|
|
10437
|
+
if (classification.isUserFacing && (msg.role === "assistant" || msg.role === "model")) {
|
|
10438
|
+
const text = flattenContent(msg.content).trim();
|
|
10439
|
+
if (text) {
|
|
10440
|
+
return {
|
|
10441
|
+
finalSummary: text.slice(0, maxChars),
|
|
10442
|
+
transcriptMessageAt: readChatMessageTimestampIso(msg)
|
|
10443
|
+
};
|
|
10444
|
+
}
|
|
10445
|
+
}
|
|
10446
|
+
}
|
|
10447
|
+
return { finalSummary: "" };
|
|
10448
|
+
}
|
|
10449
|
+
function canonicalizeKindHint(value) {
|
|
10450
|
+
return value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
10451
|
+
}
|
|
10452
|
+
function resolveBuiltinOrAliasKind(kind) {
|
|
10453
|
+
if (typeof kind !== "string") return null;
|
|
10454
|
+
const normalizedKind = canonicalizeKindHint(kind);
|
|
10455
|
+
if (!normalizedKind) return null;
|
|
10456
|
+
if (KNOWN_CHAT_MESSAGE_KINDS.has(normalizedKind)) return normalizedKind;
|
|
10457
|
+
return CHAT_MESSAGE_KIND_ALIASES[normalizedKind] || null;
|
|
10458
|
+
}
|
|
10459
|
+
function inferHintKind(value) {
|
|
10460
|
+
const direct = resolveBuiltinOrAliasKind(value);
|
|
10461
|
+
if (direct) return direct;
|
|
10462
|
+
if (typeof value !== "string") return null;
|
|
10463
|
+
const normalized = canonicalizeKindHint(value);
|
|
10464
|
+
if (!normalized) return null;
|
|
10465
|
+
if (/thought|thinking|reasoning/.test(normalized)) return "thought";
|
|
10466
|
+
if (/tool/.test(normalized)) return "tool";
|
|
10467
|
+
if (/terminal|command|shell|console/.test(normalized)) return "terminal";
|
|
10468
|
+
return null;
|
|
10469
|
+
}
|
|
10470
|
+
function inferKindFromToolCalls(message) {
|
|
10471
|
+
const toolCalls = Array.isArray(message?.toolCalls) ? message.toolCalls : [];
|
|
10472
|
+
if (toolCalls.length === 0) return null;
|
|
10473
|
+
if (toolCalls.some((toolCall) => toolCall?.kind === "think")) return "thought";
|
|
10474
|
+
if (toolCalls.some((toolCall) => toolCall?.kind === "execute")) return "terminal";
|
|
10475
|
+
if (toolCalls.some((toolCall) => Array.isArray(toolCall?.content) && toolCall.content.some((entry) => entry?.type === "terminal"))) {
|
|
10476
|
+
return "terminal";
|
|
10477
|
+
}
|
|
10478
|
+
return "tool";
|
|
10479
|
+
}
|
|
10480
|
+
function inferMissingChatMessageKind(message) {
|
|
10481
|
+
const role = typeof message?.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
10482
|
+
if (role === "system") return "system";
|
|
10483
|
+
const meta = message?.meta && typeof message.meta === "object" ? message.meta : void 0;
|
|
10484
|
+
const hintCandidates = [
|
|
10485
|
+
message?._sub,
|
|
10486
|
+
message?._type,
|
|
10487
|
+
meta?.label,
|
|
10488
|
+
typeof message?.senderName === "string" ? message.senderName : void 0
|
|
10489
|
+
];
|
|
10490
|
+
for (const candidate of hintCandidates) {
|
|
10491
|
+
const inferred = inferHintKind(candidate);
|
|
10492
|
+
if (inferred) return inferred;
|
|
10493
|
+
}
|
|
10494
|
+
const inferredFromToolCalls = inferKindFromToolCalls(message);
|
|
10495
|
+
if (inferredFromToolCalls) return inferredFromToolCalls;
|
|
10496
|
+
return null;
|
|
10497
|
+
}
|
|
10498
|
+
function isBuiltinChatMessageKind(kind) {
|
|
10499
|
+
return resolveBuiltinOrAliasKind(kind) !== null;
|
|
10500
|
+
}
|
|
10501
|
+
function normalizeChatMessageKind(kind, role) {
|
|
10502
|
+
const resolvedKind = resolveBuiltinOrAliasKind(kind);
|
|
10503
|
+
if (resolvedKind) return resolvedKind;
|
|
10504
|
+
const normalizedRole = typeof role === "string" ? role.trim().toLowerCase() : "";
|
|
10505
|
+
return normalizedRole === "system" ? "system" : "standard";
|
|
10506
|
+
}
|
|
10507
|
+
function resolveChatMessageKind(message) {
|
|
10508
|
+
const explicitKind = resolveBuiltinOrAliasKind(message?.kind);
|
|
10509
|
+
if (explicitKind) return explicitKind;
|
|
10510
|
+
const inferredKind = inferMissingChatMessageKind(message);
|
|
10511
|
+
if (inferredKind) return inferredKind;
|
|
10512
|
+
return normalizeChatMessageKind(message?.kind, message?.role);
|
|
10513
|
+
}
|
|
10514
|
+
function buildChatMessage(message) {
|
|
10515
|
+
return {
|
|
10516
|
+
...message,
|
|
10517
|
+
kind: resolveChatMessageKind(message)
|
|
10518
|
+
};
|
|
10519
|
+
}
|
|
10520
|
+
function buildSystemChatMessage(message) {
|
|
10521
|
+
return buildChatMessage({
|
|
10522
|
+
...message,
|
|
10523
|
+
role: "system",
|
|
10524
|
+
kind: message?.kind || "system"
|
|
10525
|
+
});
|
|
10526
|
+
}
|
|
10527
|
+
function buildRuntimeSystemChatMessage(message) {
|
|
10528
|
+
return buildSystemChatMessage({
|
|
10529
|
+
...message,
|
|
10530
|
+
senderName: typeof message?.senderName === "string" && message.senderName.trim() ? message.senderName : "System"
|
|
10531
|
+
});
|
|
10532
|
+
}
|
|
10533
|
+
function buildAssistantChatMessage(message) {
|
|
10534
|
+
return buildChatMessage({
|
|
10535
|
+
...message,
|
|
10536
|
+
role: "assistant",
|
|
10537
|
+
kind: message?.kind || "standard"
|
|
10538
|
+
});
|
|
10539
|
+
}
|
|
10540
|
+
function buildThoughtChatMessage(message) {
|
|
10541
|
+
return buildAssistantChatMessage({
|
|
10542
|
+
...message,
|
|
10543
|
+
kind: message?.kind || "thought"
|
|
10544
|
+
});
|
|
10545
|
+
}
|
|
10546
|
+
function buildToolChatMessage(message) {
|
|
10547
|
+
return buildAssistantChatMessage({
|
|
10548
|
+
...message,
|
|
10549
|
+
kind: message?.kind || "tool"
|
|
10550
|
+
});
|
|
10551
|
+
}
|
|
10552
|
+
function buildTerminalChatMessage(message) {
|
|
10553
|
+
return buildAssistantChatMessage({
|
|
10554
|
+
...message,
|
|
10555
|
+
kind: message?.kind || "terminal"
|
|
10556
|
+
});
|
|
10557
|
+
}
|
|
10558
|
+
function buildUserChatMessage(message) {
|
|
10559
|
+
return buildChatMessage({
|
|
10560
|
+
...message,
|
|
10561
|
+
role: "user",
|
|
10562
|
+
kind: message?.kind || "standard"
|
|
10563
|
+
});
|
|
10564
|
+
}
|
|
10565
|
+
function normalizeChatMessage(message) {
|
|
10566
|
+
return buildChatMessage(message);
|
|
10567
|
+
}
|
|
10568
|
+
function normalizeChatMessages(messages) {
|
|
10569
|
+
return (Array.isArray(messages) ? messages : []).map((message) => normalizeChatMessage(message));
|
|
10570
|
+
}
|
|
10571
|
+
function readMessageMeta(message) {
|
|
10572
|
+
const meta = message?.meta;
|
|
10573
|
+
return meta && typeof meta === "object" && !Array.isArray(meta) ? meta : null;
|
|
10574
|
+
}
|
|
10575
|
+
function readStringField(value) {
|
|
10576
|
+
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
10577
|
+
}
|
|
10578
|
+
function readRecordField(message, meta, key) {
|
|
10579
|
+
const record = message;
|
|
10580
|
+
return record[key] ?? meta?.[key];
|
|
10581
|
+
}
|
|
10582
|
+
function readVisibilityField(message, meta) {
|
|
10583
|
+
return readStringField(readRecordField(message, meta, "visibility"));
|
|
10584
|
+
}
|
|
10585
|
+
function readTranscriptVisibilityField(message, meta) {
|
|
10586
|
+
const record = message;
|
|
10587
|
+
return readStringField(record.transcriptVisibility ?? meta?.transcriptVisibility ?? record.visibility ?? meta?.visibility);
|
|
10588
|
+
}
|
|
10589
|
+
function hasBooleanMarker(message, meta, keys) {
|
|
10590
|
+
const record = message;
|
|
10591
|
+
return keys.some((key) => record[key] === true || meta?.[key] === true);
|
|
10592
|
+
}
|
|
10593
|
+
function isActivityKind(kind) {
|
|
10594
|
+
return kind === "thought" || kind === "tool" || kind === "terminal";
|
|
10595
|
+
}
|
|
10596
|
+
function isOrdinaryVisibleTurn(message, role, kind) {
|
|
10597
|
+
if (role === "user" || role === "human") return kind === "standard" || kind === "";
|
|
10598
|
+
if (role === "assistant") return kind === "standard" || kind === "";
|
|
10599
|
+
return false;
|
|
10600
|
+
}
|
|
10601
|
+
function classifyChatMessageVisibility(message) {
|
|
10602
|
+
if (!message) {
|
|
10603
|
+
return {
|
|
10604
|
+
surface: "internal",
|
|
10605
|
+
isUserFacing: false,
|
|
10606
|
+
isActivityFacing: false,
|
|
10607
|
+
isInternal: true,
|
|
10608
|
+
explicitUserFacing: false,
|
|
10609
|
+
explicitHidden: true,
|
|
10610
|
+
role: "",
|
|
10611
|
+
kind: "standard",
|
|
10612
|
+
visibility: "",
|
|
10613
|
+
transcriptVisibility: "",
|
|
10614
|
+
audience: "",
|
|
10615
|
+
source: ""
|
|
10616
|
+
};
|
|
10617
|
+
}
|
|
10618
|
+
const meta = readMessageMeta(message);
|
|
10619
|
+
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
10620
|
+
const kind = resolveChatMessageKind(message);
|
|
10621
|
+
const visibility = readVisibilityField(message, meta);
|
|
10622
|
+
const transcriptVisibility = readTranscriptVisibilityField(message, meta);
|
|
10623
|
+
const audience = readStringField(readRecordField(message, meta, "audience"));
|
|
10624
|
+
const source = readStringField(readRecordField(message, meta, "source"));
|
|
10625
|
+
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"]);
|
|
10626
|
+
const explicitUserFacing = EXPLICIT_VISIBLE_VISIBILITIES.has(visibility) || EXPLICIT_VISIBLE_VISIBILITIES.has(transcriptVisibility) || audience === "chat" || hasBooleanMarker(message, meta, ["userFacing"]);
|
|
10627
|
+
if (explicitHidden) {
|
|
10628
|
+
const activityLike = isActivityKind(kind) || ACTIVITY_SOURCE_SET.has(source);
|
|
10629
|
+
return {
|
|
10630
|
+
surface: activityLike ? "activity" : "internal",
|
|
10631
|
+
isUserFacing: false,
|
|
10632
|
+
isActivityFacing: activityLike,
|
|
10633
|
+
isInternal: !activityLike,
|
|
10634
|
+
explicitUserFacing,
|
|
10635
|
+
explicitHidden,
|
|
10636
|
+
role,
|
|
10637
|
+
kind,
|
|
10638
|
+
visibility,
|
|
10639
|
+
transcriptVisibility,
|
|
10640
|
+
audience,
|
|
10641
|
+
source
|
|
10642
|
+
};
|
|
10643
|
+
}
|
|
10644
|
+
if (explicitUserFacing) {
|
|
10645
|
+
return {
|
|
10646
|
+
surface: "chat",
|
|
10647
|
+
isUserFacing: true,
|
|
10648
|
+
isActivityFacing: false,
|
|
10649
|
+
isInternal: false,
|
|
10650
|
+
explicitUserFacing,
|
|
10651
|
+
explicitHidden,
|
|
10652
|
+
role,
|
|
10653
|
+
kind,
|
|
10654
|
+
visibility,
|
|
10655
|
+
transcriptVisibility,
|
|
10656
|
+
audience,
|
|
10657
|
+
source
|
|
10658
|
+
};
|
|
10659
|
+
}
|
|
10660
|
+
if (INTERNAL_SOURCE_SET.has(source) || role === "system" || kind === "system") {
|
|
10661
|
+
return {
|
|
10662
|
+
surface: "internal",
|
|
10663
|
+
isUserFacing: false,
|
|
10664
|
+
isActivityFacing: false,
|
|
10665
|
+
isInternal: true,
|
|
10666
|
+
explicitUserFacing,
|
|
10667
|
+
explicitHidden,
|
|
10668
|
+
role,
|
|
10669
|
+
kind,
|
|
10670
|
+
visibility,
|
|
10671
|
+
transcriptVisibility,
|
|
10672
|
+
audience,
|
|
10673
|
+
source
|
|
10674
|
+
};
|
|
10675
|
+
}
|
|
10676
|
+
if (ACTIVITY_SOURCE_SET.has(source) || isActivityKind(kind)) {
|
|
10677
|
+
return {
|
|
10678
|
+
surface: "activity",
|
|
10679
|
+
isUserFacing: false,
|
|
10680
|
+
isActivityFacing: true,
|
|
10681
|
+
isInternal: false,
|
|
10682
|
+
explicitUserFacing,
|
|
10683
|
+
explicitHidden,
|
|
10684
|
+
role,
|
|
10685
|
+
kind,
|
|
10686
|
+
visibility,
|
|
10687
|
+
transcriptVisibility,
|
|
10688
|
+
audience,
|
|
10689
|
+
source
|
|
10690
|
+
};
|
|
10691
|
+
}
|
|
10692
|
+
const isUserFacing = isOrdinaryVisibleTurn(message, role, kind);
|
|
10693
|
+
return {
|
|
10694
|
+
surface: isUserFacing ? "chat" : "internal",
|
|
10695
|
+
isUserFacing,
|
|
10696
|
+
isActivityFacing: false,
|
|
10697
|
+
isInternal: !isUserFacing,
|
|
10698
|
+
explicitUserFacing,
|
|
10699
|
+
explicitHidden,
|
|
10700
|
+
role,
|
|
10701
|
+
kind,
|
|
10702
|
+
visibility,
|
|
10703
|
+
transcriptVisibility,
|
|
10704
|
+
audience,
|
|
10705
|
+
source
|
|
10706
|
+
};
|
|
10707
|
+
}
|
|
10708
|
+
function isUserFacingChatMessage(message) {
|
|
10709
|
+
return classifyChatMessageVisibility(message).isUserFacing;
|
|
10710
|
+
}
|
|
10711
|
+
function isActivityChatMessage(message) {
|
|
10712
|
+
return classifyChatMessageVisibility(message).isActivityFacing;
|
|
10713
|
+
}
|
|
10714
|
+
function isInternalChatMessage(message) {
|
|
10715
|
+
return classifyChatMessageVisibility(message).isInternal;
|
|
10716
|
+
}
|
|
10717
|
+
function filterUserFacingChatMessages(messages) {
|
|
10718
|
+
return (Array.isArray(messages) ? messages : []).filter((message) => isUserFacingChatMessage(message));
|
|
10719
|
+
}
|
|
10720
|
+
function filterActivityChatMessages(messages) {
|
|
10721
|
+
return (Array.isArray(messages) ? messages : []).filter((message) => isActivityChatMessage(message));
|
|
10722
|
+
}
|
|
10723
|
+
function filterInternalChatMessages(messages) {
|
|
10724
|
+
return (Array.isArray(messages) ? messages : []).filter((message) => isInternalChatMessage(message));
|
|
10725
|
+
}
|
|
10726
|
+
function filterChatMessagesByVisibility(messages, surface) {
|
|
10727
|
+
return (Array.isArray(messages) ? messages : []).filter((message) => classifyChatMessageVisibility(message).surface === surface);
|
|
10728
|
+
}
|
|
10729
|
+
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;
|
|
10730
|
+
var init_chat_message_normalization = __esm({
|
|
10731
|
+
"src/providers/chat-message-normalization.ts"() {
|
|
10732
|
+
"use strict";
|
|
10733
|
+
init_contracts();
|
|
10734
|
+
DEFAULT_FINAL_SUMMARY_MAX_CHARS = 4e3;
|
|
10735
|
+
BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
|
|
10736
|
+
CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
|
|
10737
|
+
CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
|
|
10738
|
+
CHAT_MESSAGE_AUDIENCES = ["chat", "debug", "trace", "internal"];
|
|
10739
|
+
CHAT_MESSAGE_SOURCES = [
|
|
10740
|
+
"assistant_text",
|
|
10741
|
+
"tool_call",
|
|
10742
|
+
"terminal_command",
|
|
10743
|
+
"runtime_activity",
|
|
10744
|
+
"runtime_status",
|
|
10745
|
+
"provider_chrome",
|
|
10746
|
+
"control"
|
|
10747
|
+
];
|
|
10748
|
+
CHAT_MESSAGE_ACTIVITY_SOURCES = ["tool_call", "terminal_command", "runtime_activity"];
|
|
10749
|
+
CHAT_MESSAGE_INTERNAL_SOURCES = ["runtime_status", "provider_chrome", "control"];
|
|
10750
|
+
KNOWN_CHAT_MESSAGE_KINDS = new Set(BUILTIN_CHAT_MESSAGE_KINDS);
|
|
10751
|
+
CHAT_MESSAGE_KIND_ALIASES = {
|
|
10752
|
+
text: "standard",
|
|
10753
|
+
message: "standard",
|
|
10754
|
+
assistant: "standard",
|
|
10755
|
+
thinking: "thought",
|
|
10756
|
+
think: "thought",
|
|
10757
|
+
reasoning: "thought",
|
|
10758
|
+
reason: "thought",
|
|
10759
|
+
toolcall: "tool",
|
|
10760
|
+
tool_call: "tool",
|
|
10761
|
+
tooluse: "tool",
|
|
10762
|
+
tool_use: "tool",
|
|
10763
|
+
action: "tool",
|
|
10764
|
+
command: "terminal",
|
|
10765
|
+
cmd: "terminal",
|
|
10766
|
+
shell: "terminal",
|
|
10767
|
+
console: "terminal"
|
|
10768
|
+
};
|
|
10769
|
+
EXPLICIT_HIDDEN_VISIBILITIES = /* @__PURE__ */ new Set(["hidden", "debug", "internal"]);
|
|
10770
|
+
EXPLICIT_VISIBLE_VISIBILITIES = /* @__PURE__ */ new Set(["visible", "user", "chat"]);
|
|
10771
|
+
HIDDEN_AUDIENCES = /* @__PURE__ */ new Set(["debug", "trace", "internal"]);
|
|
10772
|
+
ACTIVITY_SOURCE_SET = new Set(CHAT_MESSAGE_ACTIVITY_SOURCES);
|
|
10773
|
+
INTERNAL_SOURCE_SET = new Set(CHAT_MESSAGE_INTERNAL_SOURCES);
|
|
10774
|
+
}
|
|
10775
|
+
});
|
|
10776
|
+
|
|
10133
10777
|
// src/mesh/mesh-reconcile-loop.ts
|
|
10134
10778
|
function resolveReconcileIntervalMs() {
|
|
10135
10779
|
const raw = readNonEmptyString2(process.env.MESH_RECONCILE_INTERVAL_MS);
|
|
@@ -10233,6 +10877,15 @@ async function runMeshReconcileTick(components) {
|
|
|
10233
10877
|
LOG.warn("MeshReconcile", `Pending-claim recovery trigger failed for mesh ${mesh.id}: ${e?.message || e}`);
|
|
10234
10878
|
}
|
|
10235
10879
|
}
|
|
10880
|
+
for (const mesh of listMeshes()) {
|
|
10881
|
+
const selfIds = resolveCoordinatorSelfIds(mesh, drainDaemonIds);
|
|
10882
|
+
if (!daemonHostsMesh(mesh, selfIds)) continue;
|
|
10883
|
+
try {
|
|
10884
|
+
await reconcileUnterminatedDirectDispatches(components, mesh, selfIds, localDaemonId);
|
|
10885
|
+
} catch (e) {
|
|
10886
|
+
LOG.warn("MeshReconcile", `Completion reconcile failed for mesh ${mesh.id}: ${e?.message || e}`);
|
|
10887
|
+
}
|
|
10888
|
+
}
|
|
10236
10889
|
const coordinators = findLiveCoordinators(components);
|
|
10237
10890
|
if (coordinators.length === 0) {
|
|
10238
10891
|
return;
|
|
@@ -10326,6 +10979,95 @@ async function pullRemoteNodeQueues(components, mesh, localDaemonId, candidateDa
|
|
|
10326
10979
|
}
|
|
10327
10980
|
}
|
|
10328
10981
|
}
|
|
10982
|
+
function unwrapReadChatPayload(raw) {
|
|
10983
|
+
let cursor = raw;
|
|
10984
|
+
for (let depth = 0; depth < 4 && cursor && typeof cursor === "object"; depth++) {
|
|
10985
|
+
const record = cursor;
|
|
10986
|
+
if (Array.isArray(record.messages)) return record;
|
|
10987
|
+
if (record.payload && typeof record.payload === "object") {
|
|
10988
|
+
cursor = record.payload;
|
|
10989
|
+
continue;
|
|
10990
|
+
}
|
|
10991
|
+
if (record.result && typeof record.result === "object") {
|
|
10992
|
+
cursor = record.result;
|
|
10993
|
+
continue;
|
|
10994
|
+
}
|
|
10995
|
+
if (record.data && typeof record.data === "object") {
|
|
10996
|
+
cursor = record.data;
|
|
10997
|
+
continue;
|
|
10998
|
+
}
|
|
10999
|
+
break;
|
|
11000
|
+
}
|
|
11001
|
+
return cursor && typeof cursor === "object" ? cursor : null;
|
|
11002
|
+
}
|
|
11003
|
+
function readChatPayloadStatus(payload) {
|
|
11004
|
+
return readNonEmptyString2(payload?.status).toLowerCase();
|
|
11005
|
+
}
|
|
11006
|
+
async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds, localDaemonId) {
|
|
11007
|
+
const dispatches = getActiveDirectDispatches(mesh.id);
|
|
11008
|
+
if (dispatches.length === 0) return;
|
|
11009
|
+
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
11010
|
+
const nodeById = new Map(mesh.nodes.map((n) => [n.id, n]));
|
|
11011
|
+
for (const dispatch of dispatches) {
|
|
11012
|
+
const sessionId = readNonEmptyString2(dispatch.sessionId);
|
|
11013
|
+
const nodeId = readNonEmptyString2(dispatch.nodeId);
|
|
11014
|
+
const taskId = readNonEmptyString2(dispatch.taskId);
|
|
11015
|
+
if (!sessionId || !nodeId || !taskId) continue;
|
|
11016
|
+
const node = nodeById.get(nodeId);
|
|
11017
|
+
const nodeDaemonId = readNonEmptyString2(node?.daemonId);
|
|
11018
|
+
const isLocalNode = !nodeDaemonId || selfIds.includes(nodeDaemonId) || localDaemonId !== void 0 && nodeDaemonId === localDaemonId || !!components.instanceManager.getInstance(sessionId);
|
|
11019
|
+
const providerType = readNonEmptyString2(dispatch.providerType);
|
|
11020
|
+
const readArgs = {
|
|
11021
|
+
sessionId,
|
|
11022
|
+
targetSessionId: sessionId,
|
|
11023
|
+
tailLimit: 10,
|
|
11024
|
+
...node?.workspace ? { workspace: node.workspace } : {},
|
|
11025
|
+
...providerType ? { agentType: providerType, providerType } : {}
|
|
11026
|
+
};
|
|
11027
|
+
let payload = null;
|
|
11028
|
+
try {
|
|
11029
|
+
if (isLocalNode) {
|
|
11030
|
+
const result = await components.commandHandler.handle("read_chat", readArgs);
|
|
11031
|
+
if (result && result.success === false) continue;
|
|
11032
|
+
payload = unwrapReadChatPayload(result);
|
|
11033
|
+
} else if (dispatchMeshCommand) {
|
|
11034
|
+
const result = await dispatchMeshCommand(nodeDaemonId, "read_chat", readArgs);
|
|
11035
|
+
payload = unwrapReadChatPayload(result);
|
|
11036
|
+
if (payload && payload.success === false) continue;
|
|
11037
|
+
} else {
|
|
11038
|
+
continue;
|
|
11039
|
+
}
|
|
11040
|
+
} catch {
|
|
11041
|
+
continue;
|
|
11042
|
+
}
|
|
11043
|
+
if (!payload) continue;
|
|
11044
|
+
if (readChatPayloadStatus(payload) !== "idle") continue;
|
|
11045
|
+
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
11046
|
+
const evidence = extractFinalAssistantSummaryEvidence(messages);
|
|
11047
|
+
if (!evidence.finalSummary) continue;
|
|
11048
|
+
const providerSessionId = readNonEmptyString2(payload.providerSessionId);
|
|
11049
|
+
const coordinatorDaemonId = selfIds.find((id) => !!id);
|
|
11050
|
+
try {
|
|
11051
|
+
const result = reconcileDirectDispatchCompletionFromTranscript({
|
|
11052
|
+
meshId: mesh.id,
|
|
11053
|
+
nodeId,
|
|
11054
|
+
sessionId,
|
|
11055
|
+
providerType: providerType || void 0,
|
|
11056
|
+
providerSessionId: providerSessionId || void 0,
|
|
11057
|
+
taskId,
|
|
11058
|
+
finalSummary: evidence.finalSummary,
|
|
11059
|
+
...evidence.transcriptMessageAt ? { transcriptMessageAt: evidence.transcriptMessageAt } : {},
|
|
11060
|
+
...coordinatorDaemonId ? { targetCoordinatorDaemonId: coordinatorDaemonId } : {},
|
|
11061
|
+
source: "daemon_reconcile_transcript_completion"
|
|
11062
|
+
});
|
|
11063
|
+
if (result.reconciled) {
|
|
11064
|
+
LOG.info("MeshReconcile", `Synthesized missing completion (${result.kind}) for task ${taskId} on node ${nodeId} (mesh ${mesh.id})`);
|
|
11065
|
+
}
|
|
11066
|
+
} catch (e) {
|
|
11067
|
+
LOG.warn("MeshReconcile", `Transcript completion reconcile threw for task ${taskId}: ${e?.message || e}`);
|
|
11068
|
+
}
|
|
11069
|
+
}
|
|
11070
|
+
}
|
|
10329
11071
|
function extractPendingEvents(raw) {
|
|
10330
11072
|
if (Array.isArray(raw)) return raw;
|
|
10331
11073
|
if (raw && typeof raw === "object") {
|
|
@@ -10375,6 +11117,9 @@ var init_mesh_reconcile_loop = __esm({
|
|
|
10375
11117
|
init_mesh_events_coordinator();
|
|
10376
11118
|
init_mesh_unresolved_forward_outbox();
|
|
10377
11119
|
init_mesh_events_utils();
|
|
11120
|
+
init_mesh_work_queue();
|
|
11121
|
+
init_mesh_events_stale();
|
|
11122
|
+
init_chat_message_normalization();
|
|
10378
11123
|
DEFAULT_RECONCILE_INTERVAL_MS = 4e3;
|
|
10379
11124
|
}
|
|
10380
11125
|
});
|
|
@@ -14144,6 +14889,8 @@ ${lastSnapshot}`;
|
|
|
14144
14889
|
errorMessage: this.parseErrorMessage || this.engine.providerErrorMessage || void 0,
|
|
14145
14890
|
errorReason: this.parseErrorMessage ? "parse_error" : this.engine.providerErrorReason || void 0,
|
|
14146
14891
|
providerSessionId: this.providerSessionId || void 0,
|
|
14892
|
+
lastOutputAt: this.lastOutputAt,
|
|
14893
|
+
lastScreenChangeAt: this.lastScreenChangeAt,
|
|
14147
14894
|
...bufferState ? { bufferState } : {}
|
|
14148
14895
|
};
|
|
14149
14896
|
}
|
|
@@ -16837,7 +17584,8 @@ async function handleGitCommand(command, args, services = defaultGitCommandServi
|
|
|
16837
17584
|
if (includeSubmodules !== void 0) statusParams.includeSubmodules = includeSubmodules;
|
|
16838
17585
|
if (submoduleIgnorePaths && submoduleIgnorePaths.length > 0) statusParams.submoduleIgnorePaths = submoduleIgnorePaths;
|
|
16839
17586
|
const status = await runService(() => services.getStatus(statusParams));
|
|
16840
|
-
|
|
17587
|
+
if ("success" in status) return status;
|
|
17588
|
+
return { success: true, status, reporterPlatform: process.platform, reporterArch: process.arch };
|
|
16841
17589
|
}
|
|
16842
17590
|
case "git_diff_summary": {
|
|
16843
17591
|
if (!services.getDiffSummary) return serviceNotImplemented(command);
|
|
@@ -20528,258 +21276,11 @@ var CdpDomHandlers = class {
|
|
|
20528
21276
|
};
|
|
20529
21277
|
|
|
20530
21278
|
// src/providers/ide-provider-instance.ts
|
|
21279
|
+
init_contracts();
|
|
20531
21280
|
import * as crypto2 from "crypto";
|
|
20532
21281
|
|
|
20533
|
-
// src/providers/
|
|
20534
|
-
|
|
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
|
-
}
|
|
21282
|
+
// src/providers/extension-provider-instance.ts
|
|
21283
|
+
init_contracts();
|
|
20783
21284
|
|
|
20784
21285
|
// src/providers/status-monitor.ts
|
|
20785
21286
|
var DEFAULT_MONITOR_CONFIG = {
|
|
@@ -20893,342 +21394,9 @@ var StatusMonitor = class {
|
|
|
20893
21394
|
}
|
|
20894
21395
|
};
|
|
20895
21396
|
|
|
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
21397
|
// src/providers/control-effects.ts
|
|
21398
|
+
init_contracts();
|
|
21399
|
+
init_chat_message_normalization();
|
|
21232
21400
|
function extractProviderControlValues(controls, data) {
|
|
21233
21401
|
if (!data || typeof data !== "object") return void 0;
|
|
21234
21402
|
const values = {};
|
|
@@ -21422,6 +21590,7 @@ ${cleanBody}`;
|
|
|
21422
21590
|
}
|
|
21423
21591
|
|
|
21424
21592
|
// src/config/chat-history.ts
|
|
21593
|
+
init_chat_message_normalization();
|
|
21425
21594
|
import * as fs6 from "fs";
|
|
21426
21595
|
import * as path14 from "path";
|
|
21427
21596
|
import * as os8 from "os";
|
|
@@ -22963,6 +23132,9 @@ function resolveProviderStateSurface(params) {
|
|
|
22963
23132
|
};
|
|
22964
23133
|
}
|
|
22965
23134
|
|
|
23135
|
+
// src/providers/extension-provider-instance.ts
|
|
23136
|
+
init_chat_message_normalization();
|
|
23137
|
+
|
|
22966
23138
|
// src/providers/open-panel-support.ts
|
|
22967
23139
|
var IDE_PROVIDER_SESSION_CAPABILITIES_BASE = [
|
|
22968
23140
|
"read_chat",
|
|
@@ -23398,6 +23570,9 @@ ${effect.notification.body || ""}`.trim();
|
|
|
23398
23570
|
// src/providers/ide-provider-instance.ts
|
|
23399
23571
|
init_logger();
|
|
23400
23572
|
|
|
23573
|
+
// src/providers/read-chat-contract.ts
|
|
23574
|
+
init_contracts();
|
|
23575
|
+
|
|
23401
23576
|
// src/providers/transcript-v2.ts
|
|
23402
23577
|
var CHAT_CONTRACT_VERSION_V1 = "1.0";
|
|
23403
23578
|
|
|
@@ -23617,6 +23792,7 @@ function looksLikeActiveApprovalPromptText(content) {
|
|
|
23617
23792
|
}
|
|
23618
23793
|
|
|
23619
23794
|
// src/providers/ide-provider-instance.ts
|
|
23795
|
+
init_chat_message_normalization();
|
|
23620
23796
|
async function withTimeout(promise, timeoutMs, label) {
|
|
23621
23797
|
let timer = null;
|
|
23622
23798
|
try {
|
|
@@ -25269,6 +25445,7 @@ function resolveLegacyProviderScript(fn, scriptName, params) {
|
|
|
25269
25445
|
}
|
|
25270
25446
|
|
|
25271
25447
|
// src/commands/chat-commands.ts
|
|
25448
|
+
init_contracts();
|
|
25272
25449
|
import * as fs7 from "fs";
|
|
25273
25450
|
import * as os9 from "os";
|
|
25274
25451
|
import * as path15 from "path";
|
|
@@ -25761,6 +25938,7 @@ function synthesiseV1UnitKey(providerType, sessionId, positionalSeq, message) {
|
|
|
25761
25938
|
var CHAT_SOURCE_REGISTRY = new ChatSourceRegistry();
|
|
25762
25939
|
|
|
25763
25940
|
// src/commands/chat-commands.ts
|
|
25941
|
+
init_chat_message_normalization();
|
|
25764
25942
|
var RECENT_SEND_WINDOW_MS = 1200;
|
|
25765
25943
|
var READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
|
|
25766
25944
|
var HOT_TAIL_MIN_LIMIT = 60;
|
|
@@ -30594,6 +30772,7 @@ import { execFileSync as execFileSync2 } from "child_process";
|
|
|
30594
30772
|
import chalk from "chalk";
|
|
30595
30773
|
|
|
30596
30774
|
// src/providers/cli-provider-instance.ts
|
|
30775
|
+
init_contracts();
|
|
30597
30776
|
import * as os18 from "os";
|
|
30598
30777
|
import * as path24 from "path";
|
|
30599
30778
|
import * as crypto4 from "crypto";
|
|
@@ -33135,6 +33314,9 @@ function normalizeProviderSessionId(provider, providerSessionId) {
|
|
|
33135
33314
|
return normalizedId;
|
|
33136
33315
|
}
|
|
33137
33316
|
|
|
33317
|
+
// src/providers/cli-provider-instance.ts
|
|
33318
|
+
init_chat_message_normalization();
|
|
33319
|
+
|
|
33138
33320
|
// src/providers/working-dir.ts
|
|
33139
33321
|
function workingDirBasename(p) {
|
|
33140
33322
|
return (p || "").split(/[\\/]/).filter(Boolean).pop() || "session";
|
|
@@ -34265,7 +34447,7 @@ var CliProviderInstance = class _CliProviderInstance {
|
|
|
34265
34447
|
const dirName = workingDirBasename(this.workingDir);
|
|
34266
34448
|
const chatTitle = `${this.provider.name} \xB7 ${dirName}`;
|
|
34267
34449
|
const partial = this.adapter.getPartialResponse();
|
|
34268
|
-
const progressFingerprint = newStatus === "generating" ? `${partial || ""}`.slice(-2e3) : void 0;
|
|
34450
|
+
const progressFingerprint = newStatus === "generating" ? `${`${partial || ""}`.slice(-2e3)}::scr=${adapterStatus.lastScreenChangeAt ?? 0}::out=${adapterStatus.lastOutputAt ?? 0}` : void 0;
|
|
34269
34451
|
const previousStatus = this.lastStatus;
|
|
34270
34452
|
if (newStatus !== this.lastStatus) {
|
|
34271
34453
|
LOG.info("CLI", `[${this.type}] status: ${this.lastStatus} \u2192 ${newStatus}`);
|
|
@@ -34937,6 +35119,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
34937
35119
|
};
|
|
34938
35120
|
|
|
34939
35121
|
// src/providers/acp-provider-instance.ts
|
|
35122
|
+
init_contracts();
|
|
34940
35123
|
import * as path25 from "path";
|
|
34941
35124
|
import { Readable, Writable } from "stream";
|
|
34942
35125
|
import { spawn } from "child_process";
|
|
@@ -34946,6 +35129,7 @@ import {
|
|
|
34946
35129
|
RequestError,
|
|
34947
35130
|
PROTOCOL_VERSION
|
|
34948
35131
|
} from "@agentclientprotocol/sdk";
|
|
35132
|
+
init_chat_message_normalization();
|
|
34949
35133
|
init_logger();
|
|
34950
35134
|
function getPromptCapabilityFlags(agentCapabilities) {
|
|
34951
35135
|
const prompt = agentCapabilities?.promptCapabilities || {};
|
|
@@ -36175,6 +36359,7 @@ ${rawInput}` : rawInput;
|
|
|
36175
36359
|
};
|
|
36176
36360
|
|
|
36177
36361
|
// src/commands/cli-manager.ts
|
|
36362
|
+
init_contracts();
|
|
36178
36363
|
init_logger();
|
|
36179
36364
|
|
|
36180
36365
|
// src/commands/hosted-runtime-restore.ts
|
|
@@ -42677,7 +42862,9 @@ function buildLivePeerGitConnection(connection, timestamp = (/* @__PURE__ */ new
|
|
|
42677
42862
|
};
|
|
42678
42863
|
}
|
|
42679
42864
|
function recordInlineMeshDirectGitTruth(node, git, source) {
|
|
42680
|
-
if (!node || typeof node !== "object" || Array.isArray(node))
|
|
42865
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
42866
|
+
return { reporterPlatform: null, reporterArch: null };
|
|
42867
|
+
}
|
|
42681
42868
|
const checkedAt = readNumberValue(git.lastCheckedAt) ?? Date.now();
|
|
42682
42869
|
const updatedAt = new Date(checkedAt).toISOString();
|
|
42683
42870
|
const nextGit = {
|
|
@@ -42695,6 +42882,38 @@ function recordInlineMeshDirectGitTruth(node, git, source) {
|
|
|
42695
42882
|
node.lastSeenAt = updatedAt;
|
|
42696
42883
|
const repoRoot = readStringValue(nextGit.repoRoot);
|
|
42697
42884
|
if (repoRoot && !readStringValue(node.repoRoot)) node.repoRoot = repoRoot;
|
|
42885
|
+
const isLocalSource = source === "selected_coordinator_local_git";
|
|
42886
|
+
const reporterPlatform = readStringValue(git.reporterPlatform) ?? (isLocalSource ? process.platform : null);
|
|
42887
|
+
const reporterArch = readStringValue(git.reporterArch) ?? (isLocalSource ? process.arch : null);
|
|
42888
|
+
stampNodeReporterPlatform(node, reporterPlatform, reporterArch);
|
|
42889
|
+
if (reporterPlatform) node.reportedPlatform = reporterPlatform;
|
|
42890
|
+
if (reporterArch) node.reportedArch = reporterArch;
|
|
42891
|
+
return { reporterPlatform, reporterArch };
|
|
42892
|
+
}
|
|
42893
|
+
function stampNodeReporterPlatform(node, platform10, arch2) {
|
|
42894
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) return;
|
|
42895
|
+
if (!platform10 && !arch2) return;
|
|
42896
|
+
const overrides = node.userOverrides && typeof node.userOverrides === "object" && !Array.isArray(node.userOverrides) ? node.userOverrides : {};
|
|
42897
|
+
let changed = false;
|
|
42898
|
+
if (platform10 && !readStringValue(overrides.platform)) {
|
|
42899
|
+
overrides.platform = platform10;
|
|
42900
|
+
changed = true;
|
|
42901
|
+
}
|
|
42902
|
+
if (arch2 && !readStringValue(overrides.arch)) {
|
|
42903
|
+
overrides.arch = arch2;
|
|
42904
|
+
changed = true;
|
|
42905
|
+
}
|
|
42906
|
+
if (changed) node.userOverrides = overrides;
|
|
42907
|
+
}
|
|
42908
|
+
function persistNodeReporterPlatform(meshSource, mesh, nodeId, reporter) {
|
|
42909
|
+
if (meshSource !== "local_config") return;
|
|
42910
|
+
const meshId = readStringValue(mesh?.id);
|
|
42911
|
+
if (!meshId || !nodeId) return;
|
|
42912
|
+
const reportedPlatform = reporter.reporterPlatform ?? void 0;
|
|
42913
|
+
const reportedArch = reporter.reporterArch ?? void 0;
|
|
42914
|
+
if (!reportedPlatform && !reportedArch) return;
|
|
42915
|
+
void Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports)).then(({ updateNode: updateNode2 }) => updateNode2(meshId, nodeId, { reportedPlatform, reportedArch })).catch(() => {
|
|
42916
|
+
});
|
|
42698
42917
|
}
|
|
42699
42918
|
function buildCachedInlineMeshGitStatus(node) {
|
|
42700
42919
|
const liveGit = buildInlineMeshTransitGitStatus(node);
|
|
@@ -43188,7 +43407,13 @@ async function probeRemoteMeshGitStatus(args) {
|
|
|
43188
43407
|
new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), args.timeoutMs))
|
|
43189
43408
|
]);
|
|
43190
43409
|
const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
|
|
43191
|
-
|
|
43410
|
+
if (!remoteGit || typeof remoteGit !== "object" || typeof remoteGit.isGitRepo !== "boolean") return null;
|
|
43411
|
+
const reporterPlatform = readStringValue(remoteResult?.reporterPlatform);
|
|
43412
|
+
const reporterArch = readStringValue(remoteResult?.reporterArch);
|
|
43413
|
+
const git = remoteGit;
|
|
43414
|
+
if (reporterPlatform) git.reporterPlatform = reporterPlatform;
|
|
43415
|
+
if (reporterArch) git.reporterArch = reporterArch;
|
|
43416
|
+
return git;
|
|
43192
43417
|
}
|
|
43193
43418
|
var MESH_DIRECT_PROBE_MAX_RETRIES = 2;
|
|
43194
43419
|
function readMeshConnectionState(connection) {
|
|
@@ -43271,7 +43496,8 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
43271
43496
|
try {
|
|
43272
43497
|
const localGit = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
43273
43498
|
if (localGit?.isGitRepo) {
|
|
43274
|
-
recordInlineMeshDirectGitTruth(node, localGit, "selected_coordinator_local_git");
|
|
43499
|
+
const reporter = recordInlineMeshDirectGitTruth(node, localGit, "selected_coordinator_local_git");
|
|
43500
|
+
persistNodeReporterPlatform(args.meshSource, args.mesh, nodeId, reporter);
|
|
43275
43501
|
localConfirmedCount += 1;
|
|
43276
43502
|
continue;
|
|
43277
43503
|
}
|
|
@@ -43301,7 +43527,8 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
43301
43527
|
});
|
|
43302
43528
|
const remoteGit = args.probeCache ? await args.probeCache.probe(daemonId, workspace, runProbe) : await runProbe();
|
|
43303
43529
|
if (remoteGit) {
|
|
43304
|
-
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
43530
|
+
const reporter = recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
43531
|
+
persistNodeReporterPlatform(args.meshSource, args.mesh, nodeId, reporter);
|
|
43305
43532
|
peerConfirmedCount += 1;
|
|
43306
43533
|
continue;
|
|
43307
43534
|
}
|
|
@@ -49518,7 +49745,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
49518
49745
|
if (!connectionReported || connectionState === "unknown") {
|
|
49519
49746
|
status.connection = buildLivePeerGitConnection(connection, refreshedAt);
|
|
49520
49747
|
}
|
|
49521
|
-
recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
49748
|
+
const reporter = recordInlineMeshDirectGitTruth(node, remoteGit, "selected_coordinator_mesh_p2p_git");
|
|
49749
|
+
persistNodeReporterPlatform(meshRecord.source, mesh, nodeId, reporter);
|
|
49522
49750
|
remoteProbeApplied = true;
|
|
49523
49751
|
}
|
|
49524
49752
|
}
|
|
@@ -49550,7 +49778,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
49550
49778
|
try {
|
|
49551
49779
|
const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
49552
49780
|
status.git = gitStatus;
|
|
49553
|
-
recordInlineMeshDirectGitTruth(node, gitStatus, "selected_coordinator_local_git");
|
|
49781
|
+
const reporter = recordInlineMeshDirectGitTruth(node, gitStatus, "selected_coordinator_local_git");
|
|
49782
|
+
persistNodeReporterPlatform(meshRecord.source, mesh, nodeId, reporter);
|
|
49554
49783
|
if (gitStatus.isGitRepo) {
|
|
49555
49784
|
status.health = deriveMeshNodeHealthFromGit(gitStatus);
|
|
49556
49785
|
} else {
|
|
@@ -50088,6 +50317,7 @@ var DEFAULT_DAEMON_PORT = 19222;
|
|
|
50088
50317
|
var DAEMON_WS_PATH = "/ipc";
|
|
50089
50318
|
|
|
50090
50319
|
// src/chat/subscription-updates.ts
|
|
50320
|
+
init_chat_message_normalization();
|
|
50091
50321
|
function normalizeModalButtons(value) {
|
|
50092
50322
|
return Array.isArray(value) ? value.filter((button) => typeof button === "string") : [];
|
|
50093
50323
|
}
|
|
@@ -50228,6 +50458,7 @@ async function runAsyncBatch(items, worker, options = {}) {
|
|
|
50228
50458
|
}
|
|
50229
50459
|
|
|
50230
50460
|
// src/agent-stream/provider-adapter.ts
|
|
50461
|
+
init_chat_message_normalization();
|
|
50231
50462
|
var ProviderStreamAdapter = class {
|
|
50232
50463
|
agentType;
|
|
50233
50464
|
agentName;
|
|
@@ -50912,6 +51143,7 @@ var DaemonAgentStreamManager = class {
|
|
|
50912
51143
|
|
|
50913
51144
|
// src/agent-stream/poller.ts
|
|
50914
51145
|
init_logger();
|
|
51146
|
+
init_chat_message_normalization();
|
|
50915
51147
|
var AgentStreamPoller = class {
|
|
50916
51148
|
deps;
|
|
50917
51149
|
timer = null;
|
|
@@ -51433,6 +51665,10 @@ var ProviderInstanceManager = class {
|
|
|
51433
51665
|
}
|
|
51434
51666
|
};
|
|
51435
51667
|
|
|
51668
|
+
// src/index.ts
|
|
51669
|
+
init_io_contracts();
|
|
51670
|
+
init_chat_message_normalization();
|
|
51671
|
+
|
|
51436
51672
|
// src/providers/version-archive.ts
|
|
51437
51673
|
import * as fs27 from "fs";
|
|
51438
51674
|
import * as path37 from "path";
|