@karlorz/codexhost-cli-win32-x64 0.18.0-0 → 0.19.0-0
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/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +317 -59
- package/app/console-web.js +1889 -141
- package/app/cpa-live-voice-hook.js +1938 -428
- package/app/desktop-controller.mjs +2081 -212
- package/app/host-runtime.mjs +14818 -3381
- package/app/overlay-voice-bootstrap.js +1616 -0
- package/app/plugins/antigravity/plugin.mjs +963 -324
- package/app/plugins/claude-code/plugin.mjs +395 -67
- package/app/plugins/codebuddy/plugin.mjs +409 -76
- package/app/plugins/codex-usage/plugin.mjs +316 -58
- package/app/plugins/copilot/plugin.mjs +316 -58
- package/app/plugins/cursor-cli/plugin.mjs +391 -68
- package/app/plugins/deepseek-harness/manifest.json +2 -2
- package/app/plugins/deepseek-harness/plugin.mjs +343 -63
- package/app/plugins/devin/plugin.mjs +316 -58
- package/app/plugins/grok/plugin.mjs +1350 -1026
- package/app/plugins/hermes/plugin.mjs +395 -70
- package/app/plugins/kimi-code/plugin.mjs +316 -58
- package/app/plugins/kiro-cli/plugin.mjs +544 -74
- package/app/plugins/omp/plugin.mjs +1264 -902
- package/app/plugins/opencode/plugin.mjs +316 -58
- package/app/plugins/pi/plugin.mjs +1189 -862
- package/app/plugins/qoder/plugin.mjs +318 -62
- package/app/plugins/qoder-cn/plugin.mjs +318 -62
- package/app/plugins/qwen-code/plugin.mjs +425 -150
- package/app/plugins/workbuddy/plugin.mjs +409 -76
- package/app/plugins/zcode/plugin.mjs +389 -61
- package/app/renderer-extension.js +11830 -8531
- package/app/voice-profile-pins.json +25 -0
- package/app/voice-qualification.json +4 -0
- package/app/web/assets/index-BCyiiDDL.js +199 -0
- package/app/web/assets/index-BNQIOOHE.css +1 -0
- package/app/web/codexhost-settings.js +1895 -190
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
- package/app/web/plugins/deepseek-ai__dsh-client-file-upload/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +129 -8
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +65 -63
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +95 -93
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.excel.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
- package/app/web-modules/server.mjs +3279 -1676
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-Bs17Kuah.js +0 -199
- package/app/web/assets/index-C3lniEH1.css +0 -1
|
@@ -408,149 +408,6 @@ function createHarnessInstaller(environment, source) {
|
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
-
// ../../harness-adapter/dist/usage-statistics.js
|
|
412
|
-
import { createReadStream } from "node:fs";
|
|
413
|
-
import { lstat, opendir } from "node:fs/promises";
|
|
414
|
-
import path4 from "node:path";
|
|
415
|
-
import { createInterface } from "node:readline";
|
|
416
|
-
var MAX_SESSION_ID_LENGTH = 512;
|
|
417
|
-
var MAX_CWD_LENGTH = 4096;
|
|
418
|
-
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
419
|
-
function usageSessionTitle(value) {
|
|
420
|
-
if (typeof value !== "string")
|
|
421
|
-
return void 0;
|
|
422
|
-
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
423
|
-
if (!normalized)
|
|
424
|
-
return void 0;
|
|
425
|
-
if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
|
|
426
|
-
return normalized;
|
|
427
|
-
let title = "";
|
|
428
|
-
for (const character of normalized) {
|
|
429
|
-
if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
|
|
430
|
-
break;
|
|
431
|
-
title += character;
|
|
432
|
-
}
|
|
433
|
-
return `${title.trimEnd()}…`;
|
|
434
|
-
}
|
|
435
|
-
function sessionIdOk(value) {
|
|
436
|
-
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
437
|
-
}
|
|
438
|
-
function cwdOk(value) {
|
|
439
|
-
return typeof value === "string" && value.length > 0 && value.length <= MAX_CWD_LENGTH && !value.includes("\0") && (value.startsWith("/") || /^[A-Za-z]:[\\/]/u.test(value) || value.startsWith("\\\\"));
|
|
440
|
-
}
|
|
441
|
-
function withUsageSession(entry, session) {
|
|
442
|
-
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
443
|
-
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
444
|
-
const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
|
|
445
|
-
if (sessionId === void 0 && cwd === void 0)
|
|
446
|
-
return entry;
|
|
447
|
-
return {
|
|
448
|
-
...entry,
|
|
449
|
-
...sessionId !== void 0 ? { sessionId } : {},
|
|
450
|
-
...cwd !== void 0 ? { cwd } : {},
|
|
451
|
-
...sessionTitle !== void 0 ? { sessionTitle } : {}
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
function usageEntryFromRequest(request, occurredAtMs) {
|
|
455
|
-
if (!Number.isSafeInteger(occurredAtMs) || occurredAtMs <= 0)
|
|
456
|
-
return null;
|
|
457
|
-
return {
|
|
458
|
-
id: request.requestId,
|
|
459
|
-
occurredAtMs,
|
|
460
|
-
...request.model !== void 0 ? { model: request.model } : {},
|
|
461
|
-
inputTokens: request.inputTokens,
|
|
462
|
-
...request.cachedInputTokens !== void 0 ? { cachedInputTokens: request.cachedInputTokens } : {},
|
|
463
|
-
...request.cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens: request.cacheWriteInputTokens } : {},
|
|
464
|
-
...request.cacheWrite1hInputTokens !== void 0 ? { cacheWrite1hInputTokens: request.cacheWrite1hInputTokens } : {},
|
|
465
|
-
outputTokens: request.outputTokens,
|
|
466
|
-
...request.reasoningOutputTokens !== void 0 ? { reasoningOutputTokens: request.reasoningOutputTokens } : {}
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
async function jsonlUsageSources(root, maxDepth, signal) {
|
|
470
|
-
const sources = [];
|
|
471
|
-
const visit = async (directory, depth) => {
|
|
472
|
-
signal.throwIfAborted();
|
|
473
|
-
const entries = await opendir(directory).catch((error51) => {
|
|
474
|
-
if (error51.code === "ENOENT")
|
|
475
|
-
return null;
|
|
476
|
-
throw error51;
|
|
477
|
-
});
|
|
478
|
-
if (!entries)
|
|
479
|
-
return;
|
|
480
|
-
for await (const entry of entries) {
|
|
481
|
-
signal.throwIfAborted();
|
|
482
|
-
const file2 = path4.join(directory, entry.name);
|
|
483
|
-
if (entry.isDirectory()) {
|
|
484
|
-
if (depth < maxDepth)
|
|
485
|
-
await visit(file2, depth + 1);
|
|
486
|
-
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
487
|
-
const info = await lstat(file2).catch(() => null);
|
|
488
|
-
if (info?.isFile() && info.size > 0) {
|
|
489
|
-
sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
await visit(root, 0);
|
|
495
|
-
return sources;
|
|
496
|
-
}
|
|
497
|
-
async function* jsonlRecords(file2, marker, signal) {
|
|
498
|
-
const lines = createInterface({
|
|
499
|
-
input: createReadStream(file2, { encoding: "utf8", signal }),
|
|
500
|
-
crlfDelay: Infinity
|
|
501
|
-
});
|
|
502
|
-
for await (const line of lines) {
|
|
503
|
-
if (!line.includes(marker))
|
|
504
|
-
continue;
|
|
505
|
-
let value;
|
|
506
|
-
try {
|
|
507
|
-
value = JSON.parse(line);
|
|
508
|
-
} catch {
|
|
509
|
-
continue;
|
|
510
|
-
}
|
|
511
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
512
|
-
yield value;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
async function jsonlHeader(file2, match, signal, maxLines = 4) {
|
|
517
|
-
const stream = createReadStream(file2, { encoding: "utf8", signal });
|
|
518
|
-
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
519
|
-
let seen = 0;
|
|
520
|
-
try {
|
|
521
|
-
for await (const line of lines) {
|
|
522
|
-
if (++seen > maxLines)
|
|
523
|
-
break;
|
|
524
|
-
let value;
|
|
525
|
-
try {
|
|
526
|
-
value = JSON.parse(line);
|
|
527
|
-
} catch {
|
|
528
|
-
continue;
|
|
529
|
-
}
|
|
530
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
531
|
-
const record10 = value;
|
|
532
|
-
if (match(record10))
|
|
533
|
-
return record10;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
return null;
|
|
537
|
-
} finally {
|
|
538
|
-
lines.close();
|
|
539
|
-
stream.destroy();
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
function nativeTimeMs(value) {
|
|
543
|
-
const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
544
|
-
return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// dist/pi-session-import.js
|
|
548
|
-
import { createReadStream as createReadStream2 } from "node:fs";
|
|
549
|
-
import { opendir as opendir2, realpath, stat } from "node:fs/promises";
|
|
550
|
-
import os2 from "node:os";
|
|
551
|
-
import path5 from "node:path";
|
|
552
|
-
import { createInterface as createInterface2 } from "node:readline";
|
|
553
|
-
|
|
554
411
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
555
412
|
var external_exports = {};
|
|
556
413
|
__export(external_exports, {
|
|
@@ -15092,7 +14949,7 @@ var harnessGoalSetSchema = external_exports.object({
|
|
|
15092
14949
|
origin: goalOriginSchema
|
|
15093
14950
|
});
|
|
15094
14951
|
|
|
15095
|
-
// ../../shared-contracts/dist/realtime-call.js
|
|
14952
|
+
// ../../shared-contracts/dist/realtime-call-core.js
|
|
15096
14953
|
var REALTIME_CALL_FORWARDED_HEADERS = [
|
|
15097
14954
|
"openai-alpha",
|
|
15098
14955
|
"thread-id",
|
|
@@ -15101,7 +14958,9 @@ var REALTIME_CALL_FORWARDED_HEADERS = [
|
|
|
15101
14958
|
"x-codex-turn-metadata"
|
|
15102
14959
|
];
|
|
15103
14960
|
var FORWARDED_HEADERS = new Set(REALTIME_CALL_FORWARDED_HEADERS);
|
|
15104
|
-
var REALTIME_CALL_ID_PATTERN = /^
|
|
14961
|
+
var REALTIME_CALL_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/u;
|
|
14962
|
+
|
|
14963
|
+
// ../../shared-contracts/dist/realtime-call.js
|
|
15105
14964
|
var requestId = external_exports.string().min(1).max(128);
|
|
15106
14965
|
var realtimeCallParamsSchema = external_exports.discriminatedUnion("operation", [
|
|
15107
14966
|
external_exports.object({
|
|
@@ -15156,12 +15015,6 @@ var RELAY_PUBLIC_ORIGIN = "https://codexhost.karldigi.dev";
|
|
|
15156
15015
|
var RELAY_PUBLIC_RESOURCE = `${RELAY_PUBLIC_ORIGIN}/mcp`;
|
|
15157
15016
|
var RELAY_WAIT_TIMEOUT_MAX_MS = 25e3;
|
|
15158
15017
|
var RELAY_MAX_BODY_BYTES = 2 * 1024 * 1024;
|
|
15159
|
-
var RELAY_ALLOWED_ROUTES = [
|
|
15160
|
-
"/v1/enroll/status",
|
|
15161
|
-
"/v1/thread/read",
|
|
15162
|
-
"/v1/thread/wait",
|
|
15163
|
-
"/v1/thread/send"
|
|
15164
|
-
];
|
|
15165
15018
|
var relayLinkHelloSchema = external_exports.strictObject({
|
|
15166
15019
|
v: external_exports.literal(RELAY_LINK_PROTOCOL_VERSION),
|
|
15167
15020
|
secret: external_exports.string().min(1).max(4096)
|
|
@@ -15173,8 +15026,11 @@ var relayLinkHelloAckSchema = external_exports.strictObject({
|
|
|
15173
15026
|
var relayLinkRequestSchema = external_exports.strictObject({
|
|
15174
15027
|
requestId: external_exports.string().min(1).max(128),
|
|
15175
15028
|
deadlineMs: external_exports.number().int().positive(),
|
|
15176
|
-
route: external_exports.
|
|
15177
|
-
body: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
15029
|
+
route: external_exports.string().min(1).max(128),
|
|
15030
|
+
body: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
15031
|
+
operationalClient: external_exports.string().min(1).max(64).optional(),
|
|
15032
|
+
oauthClientId: external_exports.string().min(1).max(128).optional(),
|
|
15033
|
+
dispatchGrant: external_exports.enum(["legacy-four", "full-dispatch"]).optional()
|
|
15178
15034
|
});
|
|
15179
15035
|
var relayLinkErrorSchema = external_exports.strictObject({
|
|
15180
15036
|
code: external_exports.string().min(1).max(64),
|
|
@@ -15218,6 +15074,204 @@ var relayEnrollStatusResultSchema = external_exports.strictObject({
|
|
|
15218
15074
|
runtime: external_exports.enum(["reachable", "unreachable"])
|
|
15219
15075
|
});
|
|
15220
15076
|
|
|
15077
|
+
// ../../shared-contracts/dist/external-clients.js
|
|
15078
|
+
var EXTERNAL_CLIENT_NAME_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/u;
|
|
15079
|
+
var externalClientNameSchema = external_exports.string().trim().min(1).max(64).regex(EXTERNAL_CLIENT_NAME_PATTERN);
|
|
15080
|
+
var externalClientAccessSchema = external_exports.enum(["all-threads", "selected-workspaces"]);
|
|
15081
|
+
var externalClientConnectionModeSchema = external_exports.enum(["public-relay", "local", "direct"]);
|
|
15082
|
+
var externalClientDispatchGrantSchema = external_exports.enum(["legacy-four", "full-dispatch"]);
|
|
15083
|
+
var workspacePathSchema = external_exports.string().trim().min(1).max(4096);
|
|
15084
|
+
var directUrlSchema = external_exports.string().trim().max(2048);
|
|
15085
|
+
var externalClientPublicViewSchema = external_exports.strictObject({
|
|
15086
|
+
name: externalClientNameSchema,
|
|
15087
|
+
createdAt: external_exports.string().min(1).max(64),
|
|
15088
|
+
access: externalClientAccessSchema,
|
|
15089
|
+
workspaces: external_exports.array(workspacePathSchema).max(64),
|
|
15090
|
+
connectionMode: externalClientConnectionModeSchema,
|
|
15091
|
+
dispatchGrant: externalClientDispatchGrantSchema,
|
|
15092
|
+
oauthClientId: external_exports.string().trim().min(1).max(128).optional(),
|
|
15093
|
+
directUrl: directUrlSchema.optional(),
|
|
15094
|
+
mcpUrl: external_exports.string().min(1).max(2048).optional(),
|
|
15095
|
+
mcpUrlNote: external_exports.string().min(1).max(512).optional()
|
|
15096
|
+
});
|
|
15097
|
+
var externalClientListParamsSchema = external_exports.strictObject({});
|
|
15098
|
+
var externalClientListResultSchema = external_exports.strictObject({
|
|
15099
|
+
clients: external_exports.array(externalClientPublicViewSchema).max(256)
|
|
15100
|
+
});
|
|
15101
|
+
var externalClientWriteFieldsSchema = external_exports.strictObject({
|
|
15102
|
+
access: externalClientAccessSchema.optional(),
|
|
15103
|
+
workspaces: external_exports.array(workspacePathSchema).max(64).optional(),
|
|
15104
|
+
connectionMode: externalClientConnectionModeSchema.optional(),
|
|
15105
|
+
dispatchGrant: externalClientDispatchGrantSchema.optional(),
|
|
15106
|
+
oauthClientId: external_exports.string().trim().min(1).max(128).optional(),
|
|
15107
|
+
directUrl: directUrlSchema.optional()
|
|
15108
|
+
});
|
|
15109
|
+
var externalClientCreateParamsSchema = externalClientWriteFieldsSchema.extend({
|
|
15110
|
+
name: externalClientNameSchema
|
|
15111
|
+
});
|
|
15112
|
+
var externalClientCreateResultSchema = externalClientPublicViewSchema.extend({
|
|
15113
|
+
token: external_exports.string().min(1).max(256).optional()
|
|
15114
|
+
});
|
|
15115
|
+
var externalClientUpdateParamsSchema = externalClientWriteFieldsSchema.extend({
|
|
15116
|
+
name: externalClientNameSchema,
|
|
15117
|
+
clearOauthClientId: external_exports.literal(true).optional()
|
|
15118
|
+
});
|
|
15119
|
+
var externalClientRevokeParamsSchema = external_exports.strictObject({
|
|
15120
|
+
name: externalClientNameSchema
|
|
15121
|
+
});
|
|
15122
|
+
var externalClientRevokeResultSchema = external_exports.strictObject({
|
|
15123
|
+
name: externalClientNameSchema,
|
|
15124
|
+
revoked: external_exports.literal(true)
|
|
15125
|
+
});
|
|
15126
|
+
var stringProp = (description) => ({ type: "string", description });
|
|
15127
|
+
var integerProp = (description) => ({
|
|
15128
|
+
type: "integer",
|
|
15129
|
+
minimum: 0,
|
|
15130
|
+
description
|
|
15131
|
+
});
|
|
15132
|
+
var threadProp = stringProp("Thread id or codex://threads/<id> link");
|
|
15133
|
+
var EXTERNAL_MCP_TOOL_DESCRIPTORS = [
|
|
15134
|
+
{
|
|
15135
|
+
name: "harness_list",
|
|
15136
|
+
description: "List the Harnesses this codexhost can delegate to.",
|
|
15137
|
+
inputSchema: { type: "object", properties: {} }
|
|
15138
|
+
},
|
|
15139
|
+
{
|
|
15140
|
+
name: "harness_inspect",
|
|
15141
|
+
description: "Read a Harness's Models, Thinking options and defaults; use the returned ids when delegating.",
|
|
15142
|
+
inputSchema: {
|
|
15143
|
+
type: "object",
|
|
15144
|
+
properties: {
|
|
15145
|
+
harnessId: stringProp("Harness id from harness_list"),
|
|
15146
|
+
cwd: stringProp("Absolute workspace path"),
|
|
15147
|
+
refresh: { type: "boolean" }
|
|
15148
|
+
},
|
|
15149
|
+
required: ["harnessId"]
|
|
15150
|
+
}
|
|
15151
|
+
},
|
|
15152
|
+
{
|
|
15153
|
+
name: "delegate_start",
|
|
15154
|
+
description: "Start a task in a new Thread and return at once. Without parentThread the work belongs to this client and cwd is required. watch=true records an event for this client when the Thread stops (read it with events_poll or the SSE stream).",
|
|
15155
|
+
inputSchema: {
|
|
15156
|
+
type: "object",
|
|
15157
|
+
properties: {
|
|
15158
|
+
harnessId: stringProp("Harness id from harness_list"),
|
|
15159
|
+
task: stringProp("The full task text"),
|
|
15160
|
+
taskName: stringProp("Short display name"),
|
|
15161
|
+
cwd: stringProp("Absolute workspace path"),
|
|
15162
|
+
model: stringProp("Model id from harness_inspect"),
|
|
15163
|
+
thinking: stringProp("Thinking option id from harness_inspect"),
|
|
15164
|
+
parentThread: stringProp("Optional parent Thread"),
|
|
15165
|
+
requestId: stringProp("Reuse to retry idempotently"),
|
|
15166
|
+
refs: {
|
|
15167
|
+
type: "array",
|
|
15168
|
+
items: { type: "string" },
|
|
15169
|
+
description: "Absolute URIs of where the work came from"
|
|
15170
|
+
},
|
|
15171
|
+
watch: { type: "boolean", description: "Record an event when the Thread stops" },
|
|
15172
|
+
watchTimeoutMs: integerProp("How long to watch; default 29 minutes")
|
|
15173
|
+
},
|
|
15174
|
+
required: ["harnessId", "task"]
|
|
15175
|
+
}
|
|
15176
|
+
},
|
|
15177
|
+
{
|
|
15178
|
+
name: "thread_read",
|
|
15179
|
+
description: "Read a Thread's status and latest result, or page its visible messages (view=messages). Never changes the Thread.",
|
|
15180
|
+
inputSchema: {
|
|
15181
|
+
type: "object",
|
|
15182
|
+
properties: {
|
|
15183
|
+
thread: threadProp,
|
|
15184
|
+
view: { type: "string", enum: ["result", "messages"] },
|
|
15185
|
+
cursor: stringProp("Message cursor"),
|
|
15186
|
+
limit: integerProp("Messages per page, at most 100")
|
|
15187
|
+
},
|
|
15188
|
+
required: ["thread"]
|
|
15189
|
+
}
|
|
15190
|
+
},
|
|
15191
|
+
{
|
|
15192
|
+
name: "thread_wait",
|
|
15193
|
+
description: "Wait up to timeoutMs (at most 60000) for a Thread to stop, then return the same snapshot as thread_read plus timedOut.",
|
|
15194
|
+
inputSchema: {
|
|
15195
|
+
type: "object",
|
|
15196
|
+
properties: {
|
|
15197
|
+
thread: threadProp,
|
|
15198
|
+
timeoutMs: integerProp("At most 60000; default 30000"),
|
|
15199
|
+
view: { type: "string", enum: ["result", "messages"] }
|
|
15200
|
+
},
|
|
15201
|
+
required: ["thread"]
|
|
15202
|
+
}
|
|
15203
|
+
},
|
|
15204
|
+
{
|
|
15205
|
+
name: "thread_list",
|
|
15206
|
+
description: "List Threads: by workspace (cwd), by parent Thread, by the client that started them, or by reference.",
|
|
15207
|
+
inputSchema: {
|
|
15208
|
+
type: "object",
|
|
15209
|
+
properties: {
|
|
15210
|
+
cwd: stringProp("Absolute workspace path"),
|
|
15211
|
+
parent: stringProp("Parent Thread"),
|
|
15212
|
+
client: stringProp("Client name"),
|
|
15213
|
+
ref: stringProp("Reference URI"),
|
|
15214
|
+
limit: integerProp("At most 100; default 25"),
|
|
15215
|
+
cursor: stringProp("Cursor from a previous page"),
|
|
15216
|
+
sort: {
|
|
15217
|
+
type: "string",
|
|
15218
|
+
enum: [
|
|
15219
|
+
"created-asc",
|
|
15220
|
+
"created-desc",
|
|
15221
|
+
"updated-asc",
|
|
15222
|
+
"updated-desc",
|
|
15223
|
+
"recency-asc",
|
|
15224
|
+
"recency-desc"
|
|
15225
|
+
]
|
|
15226
|
+
}
|
|
15227
|
+
}
|
|
15228
|
+
}
|
|
15229
|
+
},
|
|
15230
|
+
{
|
|
15231
|
+
name: "thread_send",
|
|
15232
|
+
description: "Start a new Turn in an idle Thread. THREAD_BUSY means its current Turn is still running; messages are not queued.",
|
|
15233
|
+
inputSchema: {
|
|
15234
|
+
type: "object",
|
|
15235
|
+
properties: { thread: threadProp, message: stringProp("Message text") },
|
|
15236
|
+
required: ["thread", "message"]
|
|
15237
|
+
}
|
|
15238
|
+
},
|
|
15239
|
+
{
|
|
15240
|
+
name: "thread_cancel",
|
|
15241
|
+
description: "Cancel a Thread's active Turn, keeping the Thread and its history.",
|
|
15242
|
+
inputSchema: { type: "object", properties: { thread: threadProp }, required: ["thread"] }
|
|
15243
|
+
},
|
|
15244
|
+
{
|
|
15245
|
+
name: "thread_watch",
|
|
15246
|
+
description: "Record one event for this client when the Thread stops or the watch expires.",
|
|
15247
|
+
inputSchema: {
|
|
15248
|
+
type: "object",
|
|
15249
|
+
properties: { thread: threadProp, timeoutMs: integerProp("Default 29 minutes") },
|
|
15250
|
+
required: ["thread"]
|
|
15251
|
+
}
|
|
15252
|
+
},
|
|
15253
|
+
{
|
|
15254
|
+
name: "thread_watches",
|
|
15255
|
+
description: "List watches that have not been delivered yet.",
|
|
15256
|
+
inputSchema: { type: "object", properties: {} }
|
|
15257
|
+
},
|
|
15258
|
+
{
|
|
15259
|
+
name: "events_poll",
|
|
15260
|
+
description: "Read this client's events after a cursor (0 for all retained). Waits up to timeoutMs (at most 60000) for the first one. Pass the returned cursor back next time. CURSOR_EXPIRED: reconcile with thread_list client=<this client>.",
|
|
15261
|
+
inputSchema: {
|
|
15262
|
+
type: "object",
|
|
15263
|
+
properties: {
|
|
15264
|
+
after: integerProp("Cursor; 0 for all retained"),
|
|
15265
|
+
timeoutMs: integerProp("At most 60000; default 0"),
|
|
15266
|
+
limit: integerProp("At most 100")
|
|
15267
|
+
}
|
|
15268
|
+
}
|
|
15269
|
+
}
|
|
15270
|
+
];
|
|
15271
|
+
|
|
15272
|
+
// ../../shared-contracts/dist/external-mcp-map.js
|
|
15273
|
+
var DEFAULT_WATCH_MS = 29 * 6e4;
|
|
15274
|
+
|
|
15221
15275
|
// ../../shared-contracts/dist/grok-computer-use.js
|
|
15222
15276
|
var grokComputerUseGetSchema = external_exports.object({}).strict();
|
|
15223
15277
|
var grokComputerUseSetSchema = external_exports.object({
|
|
@@ -15814,11 +15868,61 @@ var threadSteeringInspectResultSchema = external_exports.object({
|
|
|
15814
15868
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
15815
15869
|
}).strict();
|
|
15816
15870
|
|
|
15871
|
+
// ../../shared-contracts/dist/voice-settings.js
|
|
15872
|
+
var voiceRoutesSchema = external_exports.strictObject({
|
|
15873
|
+
chatExperience: external_exports.enum(["chatgpt", "codex"]),
|
|
15874
|
+
chatConnection: external_exports.enum(["desktop", "gateway"]),
|
|
15875
|
+
workConnection: external_exports.enum(["desktop", "gateway"])
|
|
15876
|
+
});
|
|
15877
|
+
var DEFAULT_VOICE_ROUTES = Object.freeze({
|
|
15878
|
+
chatExperience: "chatgpt",
|
|
15879
|
+
chatConnection: "desktop",
|
|
15880
|
+
workConnection: "gateway"
|
|
15881
|
+
});
|
|
15882
|
+
var voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() });
|
|
15883
|
+
var voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
|
|
15884
|
+
external_exports.strictObject({
|
|
15885
|
+
operation: external_exports.literal("get"),
|
|
15886
|
+
runtime: external_exports.strictObject({
|
|
15887
|
+
id: external_exports.string().uuid(),
|
|
15888
|
+
revision: external_exports.string().max(64),
|
|
15889
|
+
activeCall: external_exports.boolean()
|
|
15890
|
+
}).optional()
|
|
15891
|
+
}),
|
|
15892
|
+
external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
|
|
15893
|
+
external_exports.strictObject({
|
|
15894
|
+
operation: external_exports.literal("set"),
|
|
15895
|
+
settings: voiceSettingsSchema,
|
|
15896
|
+
revision: external_exports.string().max(64)
|
|
15897
|
+
}),
|
|
15898
|
+
external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(true) })
|
|
15899
|
+
]);
|
|
15900
|
+
var voiceSettingsStateSchema = external_exports.strictObject({
|
|
15901
|
+
settings: voiceSettingsSchema,
|
|
15902
|
+
initialized: external_exports.boolean(),
|
|
15903
|
+
revision: external_exports.string(),
|
|
15904
|
+
activeInject: external_exports.boolean().nullable(),
|
|
15905
|
+
envOverride: external_exports.enum(["0", "1"]).nullable(),
|
|
15906
|
+
activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
|
|
15907
|
+
routesActive: external_exports.boolean().nullable(),
|
|
15908
|
+
activeCall: external_exports.boolean().nullable(),
|
|
15909
|
+
gatewayReady: external_exports.boolean().nullable(),
|
|
15910
|
+
restartAvailable: external_exports.boolean(),
|
|
15911
|
+
restart: external_exports.strictObject({
|
|
15912
|
+
phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
|
|
15913
|
+
error: external_exports.string().nullable()
|
|
15914
|
+
})
|
|
15915
|
+
});
|
|
15916
|
+
|
|
15817
15917
|
// ../../shared-contracts/dist/client-channel.js
|
|
15818
15918
|
var CLIENT_CHANNEL_VERSION = 1;
|
|
15819
15919
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
15820
15920
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
15821
15921
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
15922
|
+
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
15923
|
+
var clientThreadTreeSchema = external_exports.object({
|
|
15924
|
+
parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
|
|
15925
|
+
}).strict();
|
|
15822
15926
|
var clientProjectlessWorkspaceSchema = external_exports.object({
|
|
15823
15927
|
prompt: external_exports.string().max(16384).optional()
|
|
15824
15928
|
}).strict();
|
|
@@ -15835,6 +15939,11 @@ var clientChannelCursorSchema = external_exports.object({
|
|
|
15835
15939
|
sequence: external_exports.number().int().nonnegative()
|
|
15836
15940
|
});
|
|
15837
15941
|
var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
15942
|
+
external_exports.object({
|
|
15943
|
+
type: external_exports.literal("skills-changed"),
|
|
15944
|
+
cursor: clientChannelCursorSchema,
|
|
15945
|
+
cwd: external_exports.string().optional()
|
|
15946
|
+
}),
|
|
15838
15947
|
external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
|
|
15839
15948
|
external_exports.object({
|
|
15840
15949
|
type: external_exports.literal("preferences-changed"),
|
|
@@ -16032,6 +16141,28 @@ var voiceTranscribeResultSchema = external_exports.discriminatedUnion("ok", [
|
|
|
16032
16141
|
external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
|
|
16033
16142
|
]);
|
|
16034
16143
|
|
|
16144
|
+
// ../../shared-contracts/dist/skills.js
|
|
16145
|
+
var skillsListParamsSchema = external_exports.object({
|
|
16146
|
+
threadId: hostThreadIdSchema.optional(),
|
|
16147
|
+
cwd: external_exports.string().min(1).optional()
|
|
16148
|
+
}).strict().refine((params) => !(params.threadId && params.cwd), {
|
|
16149
|
+
message: "Specify threadId or cwd, not both"
|
|
16150
|
+
});
|
|
16151
|
+
var librarySkillSchema = external_exports.object({
|
|
16152
|
+
name: external_exports.string().min(1).regex(/^[^\s[\]]+$/u),
|
|
16153
|
+
description: external_exports.string().optional(),
|
|
16154
|
+
path: external_exports.string().min(1),
|
|
16155
|
+
scope: external_exports.enum(["project", "global"]),
|
|
16156
|
+
source: external_exports.string().min(1)
|
|
16157
|
+
}).strict();
|
|
16158
|
+
var skillsListResultSchema = external_exports.object({
|
|
16159
|
+
revision: external_exports.number().int().nonnegative(),
|
|
16160
|
+
complete: external_exports.boolean(),
|
|
16161
|
+
skills: external_exports.array(librarySkillSchema),
|
|
16162
|
+
warnings: external_exports.array(external_exports.string()).optional()
|
|
16163
|
+
}).strict();
|
|
16164
|
+
var skillsChangedParamsSchema = external_exports.object({ cwd: external_exports.string().min(1).optional() }).strict();
|
|
16165
|
+
|
|
16035
16166
|
// ../../shared-contracts/dist/web-access-tokens.js
|
|
16036
16167
|
var webNetworkAccessUrlSchema = external_exports.object({
|
|
16037
16168
|
/**
|
|
@@ -16137,8 +16268,8 @@ var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
|
|
|
16137
16268
|
var delegationReadParamsSchema = external_exports.strictObject({
|
|
16138
16269
|
threadId: external_exports.string().min(1).max(1024),
|
|
16139
16270
|
view: external_exports.enum(["result", "messages"]),
|
|
16140
|
-
|
|
16141
|
-
|
|
16271
|
+
from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
|
|
16272
|
+
to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
|
|
16142
16273
|
});
|
|
16143
16274
|
|
|
16144
16275
|
// ../../shared-contracts/dist/credential-imports.js
|
|
@@ -16590,6 +16721,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
|
|
|
16590
16721
|
"codexhost/voice/gateway-status",
|
|
16591
16722
|
"codexhost/enrollment/list",
|
|
16592
16723
|
"codexhost/enrollment/revoke",
|
|
16724
|
+
"codexhost/external-clients/list",
|
|
16725
|
+
"codexhost/external-clients/create",
|
|
16726
|
+
"codexhost/external-clients/update",
|
|
16727
|
+
"codexhost/external-clients/revoke",
|
|
16593
16728
|
"codexhost/console/remote-connections",
|
|
16594
16729
|
"codexhost/runtime/status",
|
|
16595
16730
|
"codexhost/remote/ssh-setup",
|
|
@@ -17136,6 +17271,17 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
17136
17271
|
status: updateStatusSchema.nullable()
|
|
17137
17272
|
});
|
|
17138
17273
|
|
|
17274
|
+
// ../../shared-contracts/dist/thread-watch-notice.js
|
|
17275
|
+
var THREAD_WATCH_NOTICE_OUTCOMES = [
|
|
17276
|
+
"completed",
|
|
17277
|
+
"failed",
|
|
17278
|
+
"interrupted",
|
|
17279
|
+
"timedOut",
|
|
17280
|
+
"unreadable",
|
|
17281
|
+
"notFound"
|
|
17282
|
+
];
|
|
17283
|
+
var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
|
|
17284
|
+
|
|
17139
17285
|
// ../../shared-contracts/dist/remote-runtime.js
|
|
17140
17286
|
var remoteUpdatePhaseSchema = external_exports.enum([
|
|
17141
17287
|
"idle",
|
|
@@ -17183,6 +17329,14 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17183
17329
|
archived: external_exports.boolean()
|
|
17184
17330
|
}),
|
|
17185
17331
|
external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
|
|
17332
|
+
external_exports.strictObject({
|
|
17333
|
+
kind: external_exports.literal("configure"),
|
|
17334
|
+
...thread,
|
|
17335
|
+
epoch: identity,
|
|
17336
|
+
modelId: identity.optional(),
|
|
17337
|
+
thinkingOptionId: identity.optional(),
|
|
17338
|
+
permissionModeId: identity.optional()
|
|
17339
|
+
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
|
|
17186
17340
|
external_exports.strictObject({
|
|
17187
17341
|
kind: external_exports.literal("prompt"),
|
|
17188
17342
|
...thread,
|
|
@@ -17255,6 +17409,13 @@ var remoteConnectionsReplySchema = external_exports.union([
|
|
|
17255
17409
|
external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
|
|
17256
17410
|
]);
|
|
17257
17411
|
|
|
17412
|
+
// ../../shared-contracts/dist/thread-title.js
|
|
17413
|
+
var threadTitleInputSchema = external_exports.strictObject({
|
|
17414
|
+
prompt: external_exports.string().trim().min(1).max(2e3),
|
|
17415
|
+
cwd: external_exports.string().max(4096).nullable()
|
|
17416
|
+
});
|
|
17417
|
+
var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
|
|
17418
|
+
|
|
17258
17419
|
// ../../shared-contracts/dist/web-ui-extensions.js
|
|
17259
17420
|
var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
|
|
17260
17421
|
var localizedTextSchema2 = external_exports.union([
|
|
@@ -17295,52 +17456,6 @@ var webUiExtensionInstallSchema = external_exports.object({
|
|
|
17295
17456
|
var webUiExtensionEnabledSchema = external_exports.object({ id: webUiExtensionIdSchema, enabled: external_exports.boolean() }).strict();
|
|
17296
17457
|
var webUiExtensionRemoveSchema = external_exports.object({ id: webUiExtensionIdSchema }).strict();
|
|
17297
17458
|
|
|
17298
|
-
// ../../shared-contracts/dist/voice-settings.js
|
|
17299
|
-
var voiceRoutesSchema = external_exports.strictObject({
|
|
17300
|
-
chatExperience: external_exports.enum(["chatgpt", "codex"]),
|
|
17301
|
-
chatConnection: external_exports.enum(["desktop", "gateway"]),
|
|
17302
|
-
workConnection: external_exports.enum(["desktop", "gateway"])
|
|
17303
|
-
});
|
|
17304
|
-
var DEFAULT_VOICE_ROUTES = Object.freeze({
|
|
17305
|
-
chatExperience: "chatgpt",
|
|
17306
|
-
chatConnection: "desktop",
|
|
17307
|
-
workConnection: "gateway"
|
|
17308
|
-
});
|
|
17309
|
-
var voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() });
|
|
17310
|
-
var voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
|
|
17311
|
-
external_exports.strictObject({
|
|
17312
|
-
operation: external_exports.literal("get"),
|
|
17313
|
-
runtime: external_exports.strictObject({
|
|
17314
|
-
id: external_exports.string().uuid(),
|
|
17315
|
-
revision: external_exports.string().max(64),
|
|
17316
|
-
activeCall: external_exports.boolean()
|
|
17317
|
-
}).optional()
|
|
17318
|
-
}),
|
|
17319
|
-
external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
|
|
17320
|
-
external_exports.strictObject({
|
|
17321
|
-
operation: external_exports.literal("set"),
|
|
17322
|
-
settings: voiceSettingsSchema,
|
|
17323
|
-
revision: external_exports.string().max(64)
|
|
17324
|
-
}),
|
|
17325
|
-
external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(true) })
|
|
17326
|
-
]);
|
|
17327
|
-
var voiceSettingsStateSchema = external_exports.strictObject({
|
|
17328
|
-
settings: voiceSettingsSchema,
|
|
17329
|
-
initialized: external_exports.boolean(),
|
|
17330
|
-
revision: external_exports.string(),
|
|
17331
|
-
activeInject: external_exports.boolean().nullable(),
|
|
17332
|
-
envOverride: external_exports.enum(["0", "1"]).nullable(),
|
|
17333
|
-
activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
|
|
17334
|
-
routesActive: external_exports.boolean().nullable(),
|
|
17335
|
-
activeCall: external_exports.boolean().nullable(),
|
|
17336
|
-
gatewayReady: external_exports.boolean().nullable(),
|
|
17337
|
-
restartAvailable: external_exports.boolean(),
|
|
17338
|
-
restart: external_exports.strictObject({
|
|
17339
|
-
phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
|
|
17340
|
-
error: external_exports.string().nullable()
|
|
17341
|
-
})
|
|
17342
|
-
});
|
|
17343
|
-
|
|
17344
17459
|
// ../../shared-contracts/dist/background-activity.js
|
|
17345
17460
|
var backgroundActivitySchema = external_exports.strictObject({
|
|
17346
17461
|
id: external_exports.string().min(1),
|
|
@@ -17375,512 +17490,204 @@ var threadActivityStopResultSchema = external_exports.strictObject({
|
|
|
17375
17490
|
// ../../shared-contracts/dist/index.js
|
|
17376
17491
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
17377
17492
|
|
|
17378
|
-
// ../../harness-adapter/dist/
|
|
17379
|
-
|
|
17380
|
-
|
|
17381
|
-
super(message3);
|
|
17382
|
-
this.name = "SessionImportChangedError";
|
|
17383
|
-
}
|
|
17384
|
-
};
|
|
17385
|
-
function isMissingFileError(error51) {
|
|
17386
|
-
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
17387
|
-
}
|
|
17388
|
-
function sameFileFingerprint(left, right) {
|
|
17389
|
-
return left === null || right === null ? left === right : left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
|
|
17390
|
-
}
|
|
17391
|
-
function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
|
|
17392
|
-
if (typeof value !== "string")
|
|
17393
|
-
return null;
|
|
17394
|
-
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
17395
|
-
if (!normalized)
|
|
17396
|
-
return null;
|
|
17397
|
-
if (normalized.length <= maxLength)
|
|
17398
|
-
return normalized;
|
|
17399
|
-
const characters = [...normalized];
|
|
17400
|
-
if (characters.length <= maxLength)
|
|
17401
|
-
return normalized;
|
|
17402
|
-
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
17403
|
-
}
|
|
17404
|
-
function sessionImportCandidate(input) {
|
|
17405
|
-
const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
|
|
17406
|
-
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
17407
|
-
nativeSessionId: input.nativeSessionId,
|
|
17408
|
-
cwd: input.cwd,
|
|
17409
|
-
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
17410
|
-
updatedAt: Math.floor(time3),
|
|
17411
|
-
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
17412
|
-
running: typeof input.running === "boolean" ? input.running : null
|
|
17413
|
-
});
|
|
17414
|
-
return parsed.success ? parsed.data : null;
|
|
17493
|
+
// ../../harness-adapter/dist/question.js
|
|
17494
|
+
function invalidRequest(message3) {
|
|
17495
|
+
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17415
17496
|
}
|
|
17416
|
-
|
|
17417
|
-
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
constructor(options) {
|
|
17421
|
-
this.#options = options;
|
|
17497
|
+
function validateHostQuestionResponse(interaction, response) {
|
|
17498
|
+
const questionIds = new Set(interaction.questions.map(({ id }) => id));
|
|
17499
|
+
if (response.cancelled) {
|
|
17500
|
+
return Object.keys(response.answers).length === 0 ? null : invalidRequest("Cancelled Question Response must not contain answers");
|
|
17422
17501
|
}
|
|
17423
|
-
|
|
17424
|
-
|
|
17425
|
-
|
|
17426
|
-
|
|
17427
|
-
};
|
|
17502
|
+
for (const answerId of Object.keys(response.answers)) {
|
|
17503
|
+
if (!questionIds.has(answerId)) {
|
|
17504
|
+
return invalidRequest("Question Response contains an unknown Question ID");
|
|
17505
|
+
}
|
|
17428
17506
|
}
|
|
17429
|
-
|
|
17430
|
-
const
|
|
17431
|
-
if (
|
|
17432
|
-
return
|
|
17433
|
-
let started;
|
|
17434
|
-
try {
|
|
17435
|
-
started = operation(signal);
|
|
17436
|
-
} catch (error51) {
|
|
17437
|
-
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
17507
|
+
for (const question of interaction.questions) {
|
|
17508
|
+
const answers = response.answers[question.id] ?? [];
|
|
17509
|
+
if (new Set(answers).size !== answers.length) {
|
|
17510
|
+
return invalidRequest("Question Response contains duplicate answers");
|
|
17438
17511
|
}
|
|
17439
|
-
|
|
17440
|
-
|
|
17441
|
-
|
|
17442
|
-
|
|
17443
|
-
|
|
17444
|
-
|
|
17512
|
+
if (!question.optional && answers.length === 0) {
|
|
17513
|
+
return invalidRequest("Question Response omits a required answer");
|
|
17514
|
+
}
|
|
17515
|
+
if (question.type === "text") {
|
|
17516
|
+
if (answers.length > 1) {
|
|
17517
|
+
return invalidRequest("Text Question accepts at most one answer");
|
|
17445
17518
|
}
|
|
17446
|
-
|
|
17447
|
-
|
|
17448
|
-
|
|
17519
|
+
continue;
|
|
17520
|
+
}
|
|
17521
|
+
if (!question.multiple && answers.length > 1) {
|
|
17522
|
+
return invalidRequest("Single-choice Question accepts at most one answer");
|
|
17523
|
+
}
|
|
17524
|
+
const declared = new Set(question.options.map(({ value }) => value));
|
|
17525
|
+
if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
|
|
17526
|
+
return invalidRequest("Question Response contains an undeclared choice");
|
|
17527
|
+
}
|
|
17449
17528
|
}
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17453
|
-
|
|
17454
|
-
|
|
17455
|
-
|
|
17456
|
-
|
|
17457
|
-
|
|
17458
|
-
|
|
17459
|
-
|
|
17460
|
-
|
|
17529
|
+
return null;
|
|
17530
|
+
}
|
|
17531
|
+
|
|
17532
|
+
// ../../harness-adapter/dist/output-channel.js
|
|
17533
|
+
var HarnessOutputChannel = class {
|
|
17534
|
+
outputs;
|
|
17535
|
+
#consumerCreated = false;
|
|
17536
|
+
#ended = false;
|
|
17537
|
+
#pending = [];
|
|
17538
|
+
#values = [];
|
|
17539
|
+
constructor() {
|
|
17540
|
+
this.outputs = {
|
|
17541
|
+
[Symbol.asyncIterator]: () => {
|
|
17542
|
+
if (this.#consumerCreated) {
|
|
17543
|
+
throw new Error("Harness outputs allow only one consumer");
|
|
17544
|
+
}
|
|
17545
|
+
this.#consumerCreated = true;
|
|
17546
|
+
return {
|
|
17547
|
+
next: () => this.#next()
|
|
17548
|
+
};
|
|
17461
17549
|
}
|
|
17462
17550
|
};
|
|
17463
17551
|
}
|
|
17464
|
-
|
|
17465
|
-
|
|
17466
|
-
|
|
17467
|
-
|
|
17552
|
+
emit(value) {
|
|
17553
|
+
if (this.#ended)
|
|
17554
|
+
return false;
|
|
17555
|
+
const resolve = this.#pending.shift();
|
|
17556
|
+
if (resolve)
|
|
17557
|
+
resolve({ done: false, value });
|
|
17558
|
+
else
|
|
17559
|
+
this.#values.push(value);
|
|
17560
|
+
return true;
|
|
17561
|
+
}
|
|
17562
|
+
end() {
|
|
17563
|
+
if (this.#ended)
|
|
17564
|
+
return;
|
|
17565
|
+
this.#ended = true;
|
|
17566
|
+
if (this.#values.length !== 0)
|
|
17567
|
+
return;
|
|
17568
|
+
for (const resolve of this.#pending.splice(0))
|
|
17569
|
+
resolve({ done: true, value: void 0 });
|
|
17570
|
+
}
|
|
17571
|
+
#next() {
|
|
17572
|
+
const value = this.#values.shift();
|
|
17573
|
+
if (value !== void 0)
|
|
17574
|
+
return Promise.resolve({ done: false, value });
|
|
17575
|
+
if (this.#ended)
|
|
17576
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
17577
|
+
return new Promise((resolve) => this.#pending.push(resolve));
|
|
17468
17578
|
}
|
|
17469
17579
|
};
|
|
17470
17580
|
|
|
17471
|
-
// dist/
|
|
17472
|
-
var
|
|
17473
|
-
|
|
17474
|
-
|
|
17475
|
-
|
|
17476
|
-
|
|
17477
|
-
return
|
|
17581
|
+
// ../../harness-adapter/dist/diagnostics.js
|
|
17582
|
+
var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
|
|
17583
|
+
var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
|
|
17584
|
+
var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
|
|
17585
|
+
function sanitizeDiagnosticTail(value) {
|
|
17586
|
+
const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
|
|
17587
|
+
return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
|
|
17478
17588
|
}
|
|
17479
|
-
|
|
17480
|
-
|
|
17481
|
-
|
|
17482
|
-
if (custom2)
|
|
17483
|
-
return { directory: expandDirectory(custom2, home), flat: true };
|
|
17484
|
-
const agent = environment.PI_CODING_AGENT_DIR;
|
|
17589
|
+
|
|
17590
|
+
// ../../harness-adapter/dist/steer.js
|
|
17591
|
+
function unsupportedSteer(harnessLabel) {
|
|
17485
17592
|
return {
|
|
17486
|
-
|
|
17487
|
-
|
|
17488
|
-
|
|
17489
|
-
}
|
|
17490
|
-
|
|
17491
|
-
const files = [];
|
|
17492
|
-
const visit = async (dir, projectLevel) => {
|
|
17493
|
-
signal.throwIfAborted();
|
|
17494
|
-
const entries = await opendir2(dir).catch((error51) => {
|
|
17495
|
-
if (isMissingFileError(error51))
|
|
17496
|
-
return null;
|
|
17497
|
-
throw error51;
|
|
17498
|
-
});
|
|
17499
|
-
if (!entries)
|
|
17500
|
-
return;
|
|
17501
|
-
for await (const entry of entries) {
|
|
17502
|
-
signal.throwIfAborted();
|
|
17503
|
-
if (projectLevel && entry.isDirectory())
|
|
17504
|
-
await visit(path5.join(dir, entry.name), false);
|
|
17505
|
-
else if (!projectLevel && entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
17506
|
-
files.push(path5.join(dir, entry.name));
|
|
17507
|
-
}
|
|
17593
|
+
ok: false,
|
|
17594
|
+
error: {
|
|
17595
|
+
code: "unsupported",
|
|
17596
|
+
message: `${harnessLabel} cannot steer an active Turn natively`,
|
|
17597
|
+
retryable: false
|
|
17508
17598
|
}
|
|
17509
17599
|
};
|
|
17510
|
-
await visit(directory, !flat);
|
|
17511
|
-
return files;
|
|
17512
17600
|
}
|
|
17513
|
-
|
|
17514
|
-
|
|
17515
|
-
|
|
17516
|
-
|
|
17517
|
-
|
|
17518
|
-
|
|
17519
|
-
|
|
17520
|
-
|
|
17521
|
-
|
|
17522
|
-
|
|
17523
|
-
|
|
17524
|
-
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17529
|
-
|
|
17530
|
-
|
|
17531
|
-
|
|
17532
|
-
|
|
17533
|
-
|
|
17534
|
-
|
|
17535
|
-
|
|
17536
|
-
|
|
17537
|
-
|
|
17538
|
-
|
|
17539
|
-
|
|
17540
|
-
|
|
17541
|
-
|
|
17542
|
-
|
|
17543
|
-
|
|
17544
|
-
|
|
17545
|
-
|
|
17546
|
-
|
|
17547
|
-
|
|
17548
|
-
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
hasUser = entry.type === "message" && message3?.role === "user" || typeof entry.parentId === "string" && entries.get(entry.parentId) === true;
|
|
17553
|
-
entries.set(entry.id, hasUser);
|
|
17554
|
-
if (entry.type === "session_info")
|
|
17555
|
-
name = sessionImportTitle(entry.name);
|
|
17556
|
-
if (entry.type === "message" && (message3?.role === "user" || message3?.role === "assistant")) {
|
|
17557
|
-
const time3 = typeof message3.timestamp === "number" ? message3.timestamp : typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : NaN;
|
|
17558
|
-
if (Number.isFinite(time3))
|
|
17559
|
-
updatedAt = time3;
|
|
17560
|
-
}
|
|
17561
|
-
}
|
|
17562
|
-
} finally {
|
|
17563
|
-
lines.close();
|
|
17564
|
-
stream.destroy();
|
|
17565
|
-
}
|
|
17566
|
-
if (!header)
|
|
17567
|
-
return null;
|
|
17568
|
-
if (!hasUser)
|
|
17569
|
-
return null;
|
|
17570
|
-
const after = await stat(file2);
|
|
17571
|
-
if (!sameFileFingerprint(before, after))
|
|
17572
|
-
throw new SessionImportChangedError(PI_SESSION_CHANGED);
|
|
17573
|
-
const cwd = await realpath(String(header.cwd));
|
|
17574
|
-
if (!(await stat(cwd)).isDirectory())
|
|
17575
|
-
return null;
|
|
17576
|
-
const nativeRef = nativeSessionRefSchema.safeParse({
|
|
17577
|
-
harnessId: "pi",
|
|
17578
|
-
nativeSessionId: header.id,
|
|
17579
|
-
locator: { sessionFile: await realpath(file2) },
|
|
17580
|
-
formatVersion: 1
|
|
17581
|
-
});
|
|
17582
|
-
const candidate = sessionImportCandidate({
|
|
17583
|
-
nativeSessionId: header.id,
|
|
17584
|
-
cwd,
|
|
17585
|
-
title: name ?? firstMessage,
|
|
17586
|
-
updatedAt
|
|
17587
|
-
});
|
|
17588
|
-
return candidate && nativeRef.success ? { candidate, nativeRef: nativeRef.data } : null;
|
|
17601
|
+
|
|
17602
|
+
// ../../harness-adapter/dist/usage.js
|
|
17603
|
+
var tokenFields = [
|
|
17604
|
+
"inputTokens",
|
|
17605
|
+
"cachedInputTokens",
|
|
17606
|
+
"cacheWriteInputTokens",
|
|
17607
|
+
"outputTokens",
|
|
17608
|
+
"reasoningOutputTokens",
|
|
17609
|
+
"totalTokens",
|
|
17610
|
+
"contextWindowTokens",
|
|
17611
|
+
"contextUsedTokens"
|
|
17612
|
+
];
|
|
17613
|
+
var safeIntegerFields = [
|
|
17614
|
+
"planFiveHourResetsAtUnix",
|
|
17615
|
+
"planSevenDayResetsAtUnix",
|
|
17616
|
+
"timeToFirstOutputMs"
|
|
17617
|
+
];
|
|
17618
|
+
var percentFields = [
|
|
17619
|
+
"cacheHitRatePercent",
|
|
17620
|
+
"sessionCacheHitRatePercent",
|
|
17621
|
+
"planFiveHourUsedPercent",
|
|
17622
|
+
"planSevenDayUsedPercent"
|
|
17623
|
+
];
|
|
17624
|
+
var usageFields = /* @__PURE__ */ new Set([
|
|
17625
|
+
...tokenFields,
|
|
17626
|
+
...safeIntegerFields,
|
|
17627
|
+
...percentFields,
|
|
17628
|
+
"sessionCacheUsage",
|
|
17629
|
+
"composerIndicators",
|
|
17630
|
+
"totalCostUsd",
|
|
17631
|
+
"totalCredits",
|
|
17632
|
+
"contextUsagePercent",
|
|
17633
|
+
"outputTokensPerSecond",
|
|
17634
|
+
"apiOutputTokensPerSecond",
|
|
17635
|
+
"costSource",
|
|
17636
|
+
"unpricedModels"
|
|
17637
|
+
]);
|
|
17638
|
+
function isRecord(value) {
|
|
17639
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17589
17640
|
}
|
|
17590
|
-
|
|
17591
|
-
|
|
17592
|
-
|
|
17593
|
-
|
|
17594
|
-
|
|
17595
|
-
|
|
17596
|
-
|
|
17597
|
-
|
|
17598
|
-
|
|
17599
|
-
try {
|
|
17600
|
-
header = JSON.parse(line);
|
|
17601
|
-
} catch {
|
|
17602
|
-
return null;
|
|
17603
|
-
}
|
|
17604
|
-
return isRecord(header) && header.type === "session" && header.version === 3 && typeof header.id === "string" ? header.id : null;
|
|
17641
|
+
function parseHostUsage(value) {
|
|
17642
|
+
if (!isRecord(value))
|
|
17643
|
+
throw new Error("Harness Usage must be an object");
|
|
17644
|
+
const keys = Object.keys(value);
|
|
17645
|
+
if (keys.length === 0)
|
|
17646
|
+
throw new Error("Harness Usage must contain a reliable field");
|
|
17647
|
+
for (const key of keys) {
|
|
17648
|
+
if (!usageFields.has(key)) {
|
|
17649
|
+
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
17605
17650
|
}
|
|
17606
|
-
return null;
|
|
17607
|
-
} finally {
|
|
17608
|
-
lines.close();
|
|
17609
|
-
stream.destroy();
|
|
17610
|
-
}
|
|
17611
|
-
}
|
|
17612
|
-
var PiSessionImportIndex = class {
|
|
17613
|
-
#location;
|
|
17614
|
-
#cache = /* @__PURE__ */ new Map();
|
|
17615
|
-
#listing;
|
|
17616
|
-
constructor(environment) {
|
|
17617
|
-
this.#location = piSessionImportDirectory(environment);
|
|
17618
|
-
}
|
|
17619
|
-
list(signal) {
|
|
17620
|
-
this.#listing ??= this.#scan(signal).finally(() => {
|
|
17621
|
-
this.#listing = void 0;
|
|
17622
|
-
});
|
|
17623
|
-
return this.#listing;
|
|
17624
17651
|
}
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
const fingerprint = await stat(file2);
|
|
17635
|
-
const cached2 = this.#cache.get(file2);
|
|
17636
|
-
const source = cached2 && sameFileFingerprint(cached2.fingerprint, fingerprint) ? cached2.source : await readCandidate(file2, signal);
|
|
17637
|
-
if (!source)
|
|
17638
|
-
continue;
|
|
17639
|
-
if (!(await stat(source.candidate.cwd)).isDirectory())
|
|
17640
|
-
continue;
|
|
17641
|
-
if (identities.has(source.nativeRef.nativeSessionId))
|
|
17642
|
-
throw new Error("Pi Session identity is ambiguous across files");
|
|
17643
|
-
identities.add(source.nativeRef.nativeSessionId);
|
|
17644
|
-
next.set(file2, { fingerprint, source });
|
|
17645
|
-
sources.push(source);
|
|
17646
|
-
} catch (error51) {
|
|
17647
|
-
if (!isMissingFileError(error51) && !(error51 instanceof SessionImportChangedError))
|
|
17648
|
-
throw error51;
|
|
17649
|
-
}
|
|
17652
|
+
const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
|
|
17653
|
+
for (const field2 of [
|
|
17654
|
+
"totalCredits",
|
|
17655
|
+
"contextUsagePercent",
|
|
17656
|
+
"apiOutputTokensPerSecond"
|
|
17657
|
+
]) {
|
|
17658
|
+
const candidate = value[field2];
|
|
17659
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
17660
|
+
throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
|
|
17650
17661
|
}
|
|
17651
|
-
this.#cache = next;
|
|
17652
|
-
return structuredClone(sources.sort((left, right) => right.candidate.updatedAt - left.candidate.updatedAt));
|
|
17653
17662
|
}
|
|
17654
|
-
|
|
17655
|
-
const
|
|
17656
|
-
|
|
17657
|
-
|
|
17658
|
-
signal.throwIfAborted();
|
|
17659
|
-
try {
|
|
17660
|
-
const fingerprint = await stat(file2);
|
|
17661
|
-
const cached2 = this.#cache.get(file2);
|
|
17662
|
-
const id = cached2 && sameFileFingerprint(cached2.fingerprint, fingerprint) ? cached2.source.nativeRef.nativeSessionId : await readIdentity(file2, signal);
|
|
17663
|
-
if (id !== nativeSessionId)
|
|
17664
|
-
continue;
|
|
17665
|
-
if (selected)
|
|
17666
|
-
throw new Error("Pi Session identity is ambiguous across files");
|
|
17667
|
-
selected = file2;
|
|
17668
|
-
} catch (error51) {
|
|
17669
|
-
if (!isMissingFileError(error51))
|
|
17670
|
-
throw error51;
|
|
17671
|
-
}
|
|
17663
|
+
for (const field2 of tokenFields) {
|
|
17664
|
+
const candidate = value[field2];
|
|
17665
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
17666
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
17672
17667
|
}
|
|
17673
|
-
|
|
17674
|
-
|
|
17675
|
-
|
|
17676
|
-
|
|
17677
|
-
|
|
17678
|
-
} catch (error51) {
|
|
17679
|
-
if (isMissingFileError(error51))
|
|
17680
|
-
return null;
|
|
17681
|
-
throw error51;
|
|
17668
|
+
}
|
|
17669
|
+
for (const field2 of safeIntegerFields) {
|
|
17670
|
+
const candidate = value[field2];
|
|
17671
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
17672
|
+
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
17682
17673
|
}
|
|
17683
17674
|
}
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
// ../../harness-adapter/dist/question.js
|
|
17687
|
-
function invalidRequest(message3) {
|
|
17688
|
-
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17689
|
-
}
|
|
17690
|
-
function validateHostQuestionResponse(interaction, response) {
|
|
17691
|
-
const questionIds = new Set(interaction.questions.map(({ id }) => id));
|
|
17692
|
-
if (response.cancelled) {
|
|
17693
|
-
return Object.keys(response.answers).length === 0 ? null : invalidRequest("Cancelled Question Response must not contain answers");
|
|
17675
|
+
if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
|
|
17676
|
+
throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
|
|
17694
17677
|
}
|
|
17695
|
-
|
|
17696
|
-
|
|
17697
|
-
return invalidRequest("Question Response contains an unknown Question ID");
|
|
17698
|
-
}
|
|
17678
|
+
if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
|
|
17679
|
+
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
17699
17680
|
}
|
|
17700
|
-
for (const
|
|
17701
|
-
const
|
|
17702
|
-
if (
|
|
17703
|
-
|
|
17681
|
+
for (const field2 of percentFields) {
|
|
17682
|
+
const candidate = value[field2];
|
|
17683
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
17684
|
+
throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
|
|
17704
17685
|
}
|
|
17705
|
-
|
|
17706
|
-
|
|
17707
|
-
|
|
17708
|
-
if (
|
|
17709
|
-
|
|
17710
|
-
return invalidRequest("Text Question accepts at most one answer");
|
|
17711
|
-
}
|
|
17712
|
-
continue;
|
|
17713
|
-
}
|
|
17714
|
-
if (!question.multiple && answers.length > 1) {
|
|
17715
|
-
return invalidRequest("Single-choice Question accepts at most one answer");
|
|
17716
|
-
}
|
|
17717
|
-
const declared = new Set(question.options.map(({ value }) => value));
|
|
17718
|
-
if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
|
|
17719
|
-
return invalidRequest("Question Response contains an undeclared choice");
|
|
17720
|
-
}
|
|
17721
|
-
}
|
|
17722
|
-
return null;
|
|
17723
|
-
}
|
|
17724
|
-
|
|
17725
|
-
// ../../harness-adapter/dist/output-channel.js
|
|
17726
|
-
var HarnessOutputChannel = class {
|
|
17727
|
-
outputs;
|
|
17728
|
-
#consumerCreated = false;
|
|
17729
|
-
#ended = false;
|
|
17730
|
-
#pending = [];
|
|
17731
|
-
#values = [];
|
|
17732
|
-
constructor() {
|
|
17733
|
-
this.outputs = {
|
|
17734
|
-
[Symbol.asyncIterator]: () => {
|
|
17735
|
-
if (this.#consumerCreated) {
|
|
17736
|
-
throw new Error("Harness outputs allow only one consumer");
|
|
17737
|
-
}
|
|
17738
|
-
this.#consumerCreated = true;
|
|
17739
|
-
return {
|
|
17740
|
-
next: () => this.#next()
|
|
17741
|
-
};
|
|
17742
|
-
}
|
|
17743
|
-
};
|
|
17744
|
-
}
|
|
17745
|
-
emit(value) {
|
|
17746
|
-
if (this.#ended)
|
|
17747
|
-
return false;
|
|
17748
|
-
const resolve = this.#pending.shift();
|
|
17749
|
-
if (resolve)
|
|
17750
|
-
resolve({ done: false, value });
|
|
17751
|
-
else
|
|
17752
|
-
this.#values.push(value);
|
|
17753
|
-
return true;
|
|
17754
|
-
}
|
|
17755
|
-
end() {
|
|
17756
|
-
if (this.#ended)
|
|
17757
|
-
return;
|
|
17758
|
-
this.#ended = true;
|
|
17759
|
-
if (this.#values.length !== 0)
|
|
17760
|
-
return;
|
|
17761
|
-
for (const resolve of this.#pending.splice(0))
|
|
17762
|
-
resolve({ done: true, value: void 0 });
|
|
17763
|
-
}
|
|
17764
|
-
#next() {
|
|
17765
|
-
const value = this.#values.shift();
|
|
17766
|
-
if (value !== void 0)
|
|
17767
|
-
return Promise.resolve({ done: false, value });
|
|
17768
|
-
if (this.#ended)
|
|
17769
|
-
return Promise.resolve({ done: true, value: void 0 });
|
|
17770
|
-
return new Promise((resolve) => this.#pending.push(resolve));
|
|
17771
|
-
}
|
|
17772
|
-
};
|
|
17773
|
-
|
|
17774
|
-
// ../../harness-adapter/dist/diagnostics.js
|
|
17775
|
-
var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
|
|
17776
|
-
var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
|
|
17777
|
-
var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
|
|
17778
|
-
function sanitizeDiagnosticTail(value) {
|
|
17779
|
-
const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
|
|
17780
|
-
return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
|
|
17781
|
-
}
|
|
17782
|
-
|
|
17783
|
-
// ../../harness-adapter/dist/steer.js
|
|
17784
|
-
function unsupportedSteer(harnessLabel) {
|
|
17785
|
-
return {
|
|
17786
|
-
ok: false,
|
|
17787
|
-
error: {
|
|
17788
|
-
code: "unsupported",
|
|
17789
|
-
message: `${harnessLabel} cannot steer an active Turn natively`,
|
|
17790
|
-
retryable: false
|
|
17791
|
-
}
|
|
17792
|
-
};
|
|
17793
|
-
}
|
|
17794
|
-
|
|
17795
|
-
// ../../harness-adapter/dist/usage.js
|
|
17796
|
-
var tokenFields = [
|
|
17797
|
-
"inputTokens",
|
|
17798
|
-
"cachedInputTokens",
|
|
17799
|
-
"cacheWriteInputTokens",
|
|
17800
|
-
"outputTokens",
|
|
17801
|
-
"reasoningOutputTokens",
|
|
17802
|
-
"totalTokens",
|
|
17803
|
-
"contextWindowTokens",
|
|
17804
|
-
"contextUsedTokens"
|
|
17805
|
-
];
|
|
17806
|
-
var safeIntegerFields = [
|
|
17807
|
-
"planFiveHourResetsAtUnix",
|
|
17808
|
-
"planSevenDayResetsAtUnix",
|
|
17809
|
-
"timeToFirstOutputMs"
|
|
17810
|
-
];
|
|
17811
|
-
var percentFields = [
|
|
17812
|
-
"cacheHitRatePercent",
|
|
17813
|
-
"sessionCacheHitRatePercent",
|
|
17814
|
-
"planFiveHourUsedPercent",
|
|
17815
|
-
"planSevenDayUsedPercent"
|
|
17816
|
-
];
|
|
17817
|
-
var usageFields = /* @__PURE__ */ new Set([
|
|
17818
|
-
...tokenFields,
|
|
17819
|
-
...safeIntegerFields,
|
|
17820
|
-
...percentFields,
|
|
17821
|
-
"sessionCacheUsage",
|
|
17822
|
-
"composerIndicators",
|
|
17823
|
-
"totalCostUsd",
|
|
17824
|
-
"totalCredits",
|
|
17825
|
-
"contextUsagePercent",
|
|
17826
|
-
"outputTokensPerSecond",
|
|
17827
|
-
"apiOutputTokensPerSecond",
|
|
17828
|
-
"costSource",
|
|
17829
|
-
"unpricedModels"
|
|
17830
|
-
]);
|
|
17831
|
-
function isRecord2(value) {
|
|
17832
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17833
|
-
}
|
|
17834
|
-
function parseHostUsage(value) {
|
|
17835
|
-
if (!isRecord2(value))
|
|
17836
|
-
throw new Error("Harness Usage must be an object");
|
|
17837
|
-
const keys = Object.keys(value);
|
|
17838
|
-
if (keys.length === 0)
|
|
17839
|
-
throw new Error("Harness Usage must contain a reliable field");
|
|
17840
|
-
for (const key of keys) {
|
|
17841
|
-
if (!usageFields.has(key)) {
|
|
17842
|
-
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
17843
|
-
}
|
|
17844
|
-
}
|
|
17845
|
-
const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
|
|
17846
|
-
for (const field2 of [
|
|
17847
|
-
"totalCredits",
|
|
17848
|
-
"contextUsagePercent",
|
|
17849
|
-
"apiOutputTokensPerSecond"
|
|
17850
|
-
]) {
|
|
17851
|
-
const candidate = value[field2];
|
|
17852
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
17853
|
-
throw new Error(`Harness Usage '${field2}' must be a finite non-negative number`);
|
|
17854
|
-
}
|
|
17855
|
-
}
|
|
17856
|
-
for (const field2 of tokenFields) {
|
|
17857
|
-
const candidate = value[field2];
|
|
17858
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
17859
|
-
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
17860
|
-
}
|
|
17861
|
-
}
|
|
17862
|
-
for (const field2 of safeIntegerFields) {
|
|
17863
|
-
const candidate = value[field2];
|
|
17864
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
17865
|
-
throw new Error(`Harness Usage '${field2}' must be a non-negative safe integer`);
|
|
17866
|
-
}
|
|
17867
|
-
}
|
|
17868
|
-
if (value.outputTokensPerSecond !== void 0 && (typeof value.outputTokensPerSecond !== "number" || !Number.isFinite(value.outputTokensPerSecond) || value.outputTokensPerSecond < 0)) {
|
|
17869
|
-
throw new Error("Harness Usage 'outputTokensPerSecond' must be a finite non-negative number");
|
|
17870
|
-
}
|
|
17871
|
-
if (value.totalCostUsd !== void 0 && (typeof value.totalCostUsd !== "number" || !Number.isFinite(value.totalCostUsd) || value.totalCostUsd < 0)) {
|
|
17872
|
-
throw new Error("Harness Usage 'totalCostUsd' must be a finite non-negative number");
|
|
17873
|
-
}
|
|
17874
|
-
for (const field2 of percentFields) {
|
|
17875
|
-
const candidate = value[field2];
|
|
17876
|
-
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0 || candidate > 100)) {
|
|
17877
|
-
throw new Error(`Harness Usage '${field2}' must be between 0 and 100`);
|
|
17878
|
-
}
|
|
17879
|
-
}
|
|
17880
|
-
if (value.sessionCacheUsage !== void 0) {
|
|
17881
|
-
const totals2 = value.sessionCacheUsage;
|
|
17882
|
-
if (!isRecord2(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
|
|
17883
|
-
throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
|
|
17686
|
+
}
|
|
17687
|
+
if (value.sessionCacheUsage !== void 0) {
|
|
17688
|
+
const totals2 = value.sessionCacheUsage;
|
|
17689
|
+
if (!isRecord(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
|
|
17690
|
+
throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
|
|
17884
17691
|
}
|
|
17885
17692
|
}
|
|
17886
17693
|
const hasContextUsed = value.contextUsedTokens !== void 0;
|
|
@@ -17913,192 +17720,694 @@ function parseHostUsage(value) {
|
|
|
17913
17720
|
if (value.costSource !== "publicPrice") {
|
|
17914
17721
|
throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
|
|
17915
17722
|
}
|
|
17916
|
-
return { ...value, ...indicators, unpricedModels: [...models] };
|
|
17723
|
+
return { ...value, ...indicators, unpricedModels: [...models] };
|
|
17724
|
+
}
|
|
17725
|
+
return { ...value, ...indicators };
|
|
17726
|
+
}
|
|
17727
|
+
var requestTokenFields = [
|
|
17728
|
+
"inputTokens",
|
|
17729
|
+
"cachedInputTokens",
|
|
17730
|
+
"cacheWriteInputTokens",
|
|
17731
|
+
"cacheWrite1hInputTokens",
|
|
17732
|
+
"outputTokens",
|
|
17733
|
+
"reasoningOutputTokens",
|
|
17734
|
+
"startedAtMs",
|
|
17735
|
+
"completedAtMs"
|
|
17736
|
+
];
|
|
17737
|
+
var requestFields = /* @__PURE__ */ new Set([
|
|
17738
|
+
...requestTokenFields,
|
|
17739
|
+
"requestId",
|
|
17740
|
+
"historical",
|
|
17741
|
+
"model",
|
|
17742
|
+
"provider"
|
|
17743
|
+
]);
|
|
17744
|
+
function parseHostUsageRequest(value) {
|
|
17745
|
+
if (!isRecord(value))
|
|
17746
|
+
throw new Error("Harness Usage request must be an object");
|
|
17747
|
+
for (const key of Object.keys(value)) {
|
|
17748
|
+
if (!requestFields.has(key)) {
|
|
17749
|
+
throw new Error(`Harness Usage request contains unknown field '${key}'`);
|
|
17750
|
+
}
|
|
17751
|
+
}
|
|
17752
|
+
if (typeof value.requestId !== "string" || value.requestId.length === 0) {
|
|
17753
|
+
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
17754
|
+
}
|
|
17755
|
+
for (const field2 of ["model", "provider"]) {
|
|
17756
|
+
const candidate = value[field2];
|
|
17757
|
+
if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
|
|
17758
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-empty string`);
|
|
17759
|
+
}
|
|
17760
|
+
}
|
|
17761
|
+
if (value.historical !== void 0 && typeof value.historical !== "boolean") {
|
|
17762
|
+
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
17763
|
+
}
|
|
17764
|
+
for (const field2 of requestTokenFields) {
|
|
17765
|
+
const candidate = value[field2];
|
|
17766
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
17767
|
+
throw new Error(`Harness Usage request '${field2}' must be a non-negative safe integer`);
|
|
17768
|
+
}
|
|
17769
|
+
}
|
|
17770
|
+
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
17771
|
+
throw new Error("Harness Usage request must contain 'inputTokens' and 'outputTokens'");
|
|
17772
|
+
}
|
|
17773
|
+
const request = value;
|
|
17774
|
+
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
17775
|
+
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
17776
|
+
}
|
|
17777
|
+
if ((request.reasoningOutputTokens ?? 0) > request.outputTokens) {
|
|
17778
|
+
throw new Error("Harness Usage request 'reasoningOutputTokens' must not exceed 'outputTokens'");
|
|
17779
|
+
}
|
|
17780
|
+
if (request.cacheWrite1hInputTokens !== void 0 && request.cacheWrite1hInputTokens > (request.cacheWriteInputTokens ?? -1)) {
|
|
17781
|
+
throw new Error("Harness Usage request 'cacheWrite1hInputTokens' must not exceed 'cacheWriteInputTokens'");
|
|
17782
|
+
}
|
|
17783
|
+
if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
|
|
17784
|
+
throw new Error("Harness Usage request timing fields must be provided together");
|
|
17785
|
+
}
|
|
17786
|
+
if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
|
|
17787
|
+
throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
|
|
17788
|
+
}
|
|
17789
|
+
return { ...request };
|
|
17790
|
+
}
|
|
17791
|
+
|
|
17792
|
+
// ../../harness-adapter/dist/live-command-catalog.js
|
|
17793
|
+
var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
17794
|
+
// Session lifecycle
|
|
17795
|
+
"branch",
|
|
17796
|
+
"clear",
|
|
17797
|
+
"exit",
|
|
17798
|
+
"fork",
|
|
17799
|
+
"fresh",
|
|
17800
|
+
"new",
|
|
17801
|
+
"quit",
|
|
17802
|
+
"rename",
|
|
17803
|
+
"rename-chat",
|
|
17804
|
+
"reset",
|
|
17805
|
+
"resume",
|
|
17806
|
+
"rewind",
|
|
17807
|
+
"session",
|
|
17808
|
+
"sessions",
|
|
17809
|
+
// Desktop-owned configuration
|
|
17810
|
+
"autocompact",
|
|
17811
|
+
"color",
|
|
17812
|
+
"config",
|
|
17813
|
+
"effort",
|
|
17814
|
+
"fast",
|
|
17815
|
+
"keybindings",
|
|
17816
|
+
"model",
|
|
17817
|
+
"models",
|
|
17818
|
+
"output-style",
|
|
17819
|
+
"permissions",
|
|
17820
|
+
"settings",
|
|
17821
|
+
"statusline",
|
|
17822
|
+
"terminal-setup",
|
|
17823
|
+
"theme",
|
|
17824
|
+
"vim",
|
|
17825
|
+
// Trust and approval policy
|
|
17826
|
+
"always-approve",
|
|
17827
|
+
"auto-mode-setup",
|
|
17828
|
+
// Native login
|
|
17829
|
+
"login",
|
|
17830
|
+
"logout",
|
|
17831
|
+
// Work outliving the Turn
|
|
17832
|
+
"autopilot",
|
|
17833
|
+
"background",
|
|
17834
|
+
"bg",
|
|
17835
|
+
"goal",
|
|
17836
|
+
"jobs",
|
|
17837
|
+
"loop",
|
|
17838
|
+
"multitask",
|
|
17839
|
+
"queue",
|
|
17840
|
+
"remote-control",
|
|
17841
|
+
"schedule",
|
|
17842
|
+
"steer",
|
|
17843
|
+
// Native terminal UI
|
|
17844
|
+
"copy",
|
|
17845
|
+
"debug",
|
|
17846
|
+
"feedback",
|
|
17847
|
+
"heapdump",
|
|
17848
|
+
"share",
|
|
17849
|
+
"shell",
|
|
17850
|
+
// Plugin and MCP management
|
|
17851
|
+
"marketplace",
|
|
17852
|
+
"mcp",
|
|
17853
|
+
"plugins",
|
|
17854
|
+
"reload-plugins"
|
|
17855
|
+
]);
|
|
17856
|
+
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
17857
|
+
function isExcludedLiveCommand(name, extra = {}) {
|
|
17858
|
+
const normalized = name.trim().replace(/^\//u, "");
|
|
17859
|
+
if (new Set(extra.names ?? []).has(normalized))
|
|
17860
|
+
return true;
|
|
17861
|
+
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
17862
|
+
return true;
|
|
17863
|
+
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
17864
|
+
}
|
|
17865
|
+
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
17866
|
+
if (!commandId.startsWith(idPrefix))
|
|
17867
|
+
return null;
|
|
17868
|
+
const descriptor = catalog.commands.find(({ id }) => id === commandId);
|
|
17869
|
+
if (!descriptor)
|
|
17870
|
+
return null;
|
|
17871
|
+
const text4 = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
17872
|
+
return text4 ? `${descriptor.invocation} ${text4}` : descriptor.invocation;
|
|
17873
|
+
}
|
|
17874
|
+
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
17875
|
+
if (!live)
|
|
17876
|
+
return builtIns;
|
|
17877
|
+
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
17878
|
+
const ids = new Set(builtIns.commands.map(({ id }) => id));
|
|
17879
|
+
const dynamic = [];
|
|
17880
|
+
for (const command of live) {
|
|
17881
|
+
const name = command.name.trim().replace(/^\//u, "");
|
|
17882
|
+
if (!name || /\s/u.test(name))
|
|
17883
|
+
continue;
|
|
17884
|
+
if (isExcludedLiveCommand(name, exclusions))
|
|
17885
|
+
continue;
|
|
17886
|
+
const invocation = `/${name}`;
|
|
17887
|
+
const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
17888
|
+
if (invocations.has(invocation) || ids.has(id))
|
|
17889
|
+
continue;
|
|
17890
|
+
const description = command.description?.trim().slice(0, 512);
|
|
17891
|
+
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
17892
|
+
id,
|
|
17893
|
+
invocation,
|
|
17894
|
+
label: name.slice(0, 128),
|
|
17895
|
+
...description ? { description } : {},
|
|
17896
|
+
argumentMode: "text"
|
|
17897
|
+
});
|
|
17898
|
+
if (!parsed.success)
|
|
17899
|
+
continue;
|
|
17900
|
+
invocations.add(invocation);
|
|
17901
|
+
ids.add(id);
|
|
17902
|
+
dynamic.push(parsed.data);
|
|
17903
|
+
}
|
|
17904
|
+
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
17905
|
+
}
|
|
17906
|
+
|
|
17907
|
+
// ../../harness-adapter/dist/subagent-configuration.js
|
|
17908
|
+
function subagentConfiguration(value) {
|
|
17909
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
17910
|
+
return {};
|
|
17911
|
+
const row = value;
|
|
17912
|
+
const text4 = (value2) => typeof value2 === "string" && value2.trim() ? value2 : void 0;
|
|
17913
|
+
const model2 = row.model === "inherit" ? void 0 : text4(row.model);
|
|
17914
|
+
const reasoningEffort = text4(row.reasoningEffort) ?? text4(row.reasoning_effort) ?? text4(row.thinking);
|
|
17915
|
+
return { ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
|
|
17916
|
+
}
|
|
17917
|
+
function inheritSubagentConfiguration(child, parent) {
|
|
17918
|
+
const native = subagentConfiguration(child);
|
|
17919
|
+
const model2 = native.model ?? parent.model;
|
|
17920
|
+
const reasoningEffort = native.reasoningEffort ?? parent.reasoningEffort;
|
|
17921
|
+
const next = { ...child };
|
|
17922
|
+
delete next.model;
|
|
17923
|
+
delete next.reasoningEffort;
|
|
17924
|
+
return { ...next, ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
|
|
17925
|
+
}
|
|
17926
|
+
function configureSubagentEvent(event, parent) {
|
|
17927
|
+
const children = (states2) => states2.map((child) => inheritSubagentConfiguration(child, parent));
|
|
17928
|
+
if (event.type === "item.started" && event.item.type === "subagentDelegation")
|
|
17929
|
+
return { ...event, item: { ...event.item, subagents: children(event.item.subagents) } };
|
|
17930
|
+
if (event.type === "item.updated" && event.update.type === "subagents.replace")
|
|
17931
|
+
return { ...event, update: { ...event.update, subagents: children(event.update.subagents) } };
|
|
17932
|
+
if (event.type === "item.completed" && event.snapshot.item.type === "subagentDelegation")
|
|
17933
|
+
return {
|
|
17934
|
+
...event,
|
|
17935
|
+
snapshot: {
|
|
17936
|
+
...event.snapshot,
|
|
17937
|
+
item: {
|
|
17938
|
+
...event.snapshot.item,
|
|
17939
|
+
subagents: children(event.snapshot.item.subagents)
|
|
17940
|
+
}
|
|
17941
|
+
}
|
|
17942
|
+
};
|
|
17943
|
+
return event;
|
|
17944
|
+
}
|
|
17945
|
+
function configureSubagentSnapshot(snapshot, parent) {
|
|
17946
|
+
return {
|
|
17947
|
+
...snapshot,
|
|
17948
|
+
turns: snapshot.turns.map((turn) => ({
|
|
17949
|
+
...turn,
|
|
17950
|
+
items: turn.items.map((entry) => entry.item.type === "subagentDelegation" ? {
|
|
17951
|
+
...entry,
|
|
17952
|
+
item: {
|
|
17953
|
+
...entry.item,
|
|
17954
|
+
subagents: entry.item.subagents.map((child) => inheritSubagentConfiguration(child, parent))
|
|
17955
|
+
}
|
|
17956
|
+
} : entry)
|
|
17957
|
+
}))
|
|
17958
|
+
};
|
|
17959
|
+
}
|
|
17960
|
+
|
|
17961
|
+
// ../../harness-adapter/dist/usage-statistics.js
|
|
17962
|
+
import { createReadStream } from "node:fs";
|
|
17963
|
+
import { lstat, opendir } from "node:fs/promises";
|
|
17964
|
+
import path4 from "node:path";
|
|
17965
|
+
import { createInterface } from "node:readline";
|
|
17966
|
+
var MAX_SESSION_ID_LENGTH = 512;
|
|
17967
|
+
var MAX_CWD_LENGTH = 4096;
|
|
17968
|
+
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
17969
|
+
function usageSessionTitle(value) {
|
|
17970
|
+
if (typeof value !== "string")
|
|
17971
|
+
return void 0;
|
|
17972
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
17973
|
+
if (!normalized)
|
|
17974
|
+
return void 0;
|
|
17975
|
+
if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
|
|
17976
|
+
return normalized;
|
|
17977
|
+
let title = "";
|
|
17978
|
+
for (const character of normalized) {
|
|
17979
|
+
if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
|
|
17980
|
+
break;
|
|
17981
|
+
title += character;
|
|
17982
|
+
}
|
|
17983
|
+
return `${title.trimEnd()}…`;
|
|
17984
|
+
}
|
|
17985
|
+
function sessionIdOk(value) {
|
|
17986
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
17987
|
+
}
|
|
17988
|
+
function cwdOk(value) {
|
|
17989
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_CWD_LENGTH && !value.includes("\0") && (value.startsWith("/") || /^[A-Za-z]:[\\/]/u.test(value) || value.startsWith("\\\\"));
|
|
17990
|
+
}
|
|
17991
|
+
function withUsageSession(entry, session) {
|
|
17992
|
+
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
17993
|
+
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
17994
|
+
const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
|
|
17995
|
+
if (sessionId === void 0 && cwd === void 0)
|
|
17996
|
+
return entry;
|
|
17997
|
+
return {
|
|
17998
|
+
...entry,
|
|
17999
|
+
...sessionId !== void 0 ? { sessionId } : {},
|
|
18000
|
+
...cwd !== void 0 ? { cwd } : {},
|
|
18001
|
+
...sessionTitle !== void 0 ? { sessionTitle } : {}
|
|
18002
|
+
};
|
|
18003
|
+
}
|
|
18004
|
+
function usageEntryFromRequest(request, occurredAtMs) {
|
|
18005
|
+
if (!Number.isSafeInteger(occurredAtMs) || occurredAtMs <= 0)
|
|
18006
|
+
return null;
|
|
18007
|
+
return {
|
|
18008
|
+
id: request.requestId,
|
|
18009
|
+
occurredAtMs,
|
|
18010
|
+
...request.model !== void 0 ? { model: request.model } : {},
|
|
18011
|
+
inputTokens: request.inputTokens,
|
|
18012
|
+
...request.cachedInputTokens !== void 0 ? { cachedInputTokens: request.cachedInputTokens } : {},
|
|
18013
|
+
...request.cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens: request.cacheWriteInputTokens } : {},
|
|
18014
|
+
...request.cacheWrite1hInputTokens !== void 0 ? { cacheWrite1hInputTokens: request.cacheWrite1hInputTokens } : {},
|
|
18015
|
+
outputTokens: request.outputTokens,
|
|
18016
|
+
...request.reasoningOutputTokens !== void 0 ? { reasoningOutputTokens: request.reasoningOutputTokens } : {}
|
|
18017
|
+
};
|
|
18018
|
+
}
|
|
18019
|
+
async function jsonlUsageSources(root, maxDepth, signal) {
|
|
18020
|
+
const sources = [];
|
|
18021
|
+
const visit = async (directory, depth) => {
|
|
18022
|
+
signal.throwIfAborted();
|
|
18023
|
+
const entries = await opendir(directory).catch((error51) => {
|
|
18024
|
+
if (error51.code === "ENOENT")
|
|
18025
|
+
return null;
|
|
18026
|
+
throw error51;
|
|
18027
|
+
});
|
|
18028
|
+
if (!entries)
|
|
18029
|
+
return;
|
|
18030
|
+
for await (const entry of entries) {
|
|
18031
|
+
signal.throwIfAborted();
|
|
18032
|
+
const file2 = path4.join(directory, entry.name);
|
|
18033
|
+
if (entry.isDirectory()) {
|
|
18034
|
+
if (depth < maxDepth)
|
|
18035
|
+
await visit(file2, depth + 1);
|
|
18036
|
+
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
18037
|
+
const info = await lstat(file2).catch(() => null);
|
|
18038
|
+
if (info?.isFile() && info.size > 0) {
|
|
18039
|
+
sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
|
|
18040
|
+
}
|
|
18041
|
+
}
|
|
18042
|
+
}
|
|
18043
|
+
};
|
|
18044
|
+
await visit(root, 0);
|
|
18045
|
+
return sources;
|
|
18046
|
+
}
|
|
18047
|
+
async function* jsonlRecords(file2, marker, signal) {
|
|
18048
|
+
const lines = createInterface({
|
|
18049
|
+
input: createReadStream(file2, { encoding: "utf8", signal }),
|
|
18050
|
+
crlfDelay: Infinity
|
|
18051
|
+
});
|
|
18052
|
+
for await (const line of lines) {
|
|
18053
|
+
if (!line.includes(marker))
|
|
18054
|
+
continue;
|
|
18055
|
+
let value;
|
|
18056
|
+
try {
|
|
18057
|
+
value = JSON.parse(line);
|
|
18058
|
+
} catch {
|
|
18059
|
+
continue;
|
|
18060
|
+
}
|
|
18061
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
18062
|
+
yield value;
|
|
18063
|
+
}
|
|
18064
|
+
}
|
|
18065
|
+
}
|
|
18066
|
+
async function jsonlHeader(file2, match, signal, maxLines = 4) {
|
|
18067
|
+
const stream = createReadStream(file2, { encoding: "utf8", signal });
|
|
18068
|
+
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
18069
|
+
let seen = 0;
|
|
18070
|
+
try {
|
|
18071
|
+
for await (const line of lines) {
|
|
18072
|
+
if (++seen > maxLines)
|
|
18073
|
+
break;
|
|
18074
|
+
let value;
|
|
18075
|
+
try {
|
|
18076
|
+
value = JSON.parse(line);
|
|
18077
|
+
} catch {
|
|
18078
|
+
continue;
|
|
18079
|
+
}
|
|
18080
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
18081
|
+
const record10 = value;
|
|
18082
|
+
if (match(record10))
|
|
18083
|
+
return record10;
|
|
18084
|
+
}
|
|
18085
|
+
}
|
|
18086
|
+
return null;
|
|
18087
|
+
} finally {
|
|
18088
|
+
lines.close();
|
|
18089
|
+
stream.destroy();
|
|
18090
|
+
}
|
|
18091
|
+
}
|
|
18092
|
+
function nativeTimeMs(value) {
|
|
18093
|
+
const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
18094
|
+
return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
|
|
18095
|
+
}
|
|
18096
|
+
|
|
18097
|
+
// dist/pi-session-import.js
|
|
18098
|
+
import { createReadStream as createReadStream2 } from "node:fs";
|
|
18099
|
+
import { opendir as opendir2, realpath, stat } from "node:fs/promises";
|
|
18100
|
+
import os2 from "node:os";
|
|
18101
|
+
import path5 from "node:path";
|
|
18102
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
18103
|
+
|
|
18104
|
+
// ../../harness-adapter/dist/session-import.js
|
|
18105
|
+
var SessionImportChangedError = class extends Error {
|
|
18106
|
+
constructor(message3 = "Native Session changed during discovery; refresh and retry") {
|
|
18107
|
+
super(message3);
|
|
18108
|
+
this.name = "SessionImportChangedError";
|
|
18109
|
+
}
|
|
18110
|
+
};
|
|
18111
|
+
function isMissingFileError(error51) {
|
|
18112
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
18113
|
+
}
|
|
18114
|
+
function sameFileFingerprint(left, right) {
|
|
18115
|
+
return left === null || right === null ? left === right : left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
|
|
18116
|
+
}
|
|
18117
|
+
function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
|
|
18118
|
+
if (typeof value !== "string")
|
|
18119
|
+
return null;
|
|
18120
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
18121
|
+
if (!normalized)
|
|
18122
|
+
return null;
|
|
18123
|
+
if (normalized.length <= maxLength)
|
|
18124
|
+
return normalized;
|
|
18125
|
+
const characters = [...normalized];
|
|
18126
|
+
if (characters.length <= maxLength)
|
|
18127
|
+
return normalized;
|
|
18128
|
+
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
18129
|
+
}
|
|
18130
|
+
function sessionImportCandidate(input) {
|
|
18131
|
+
const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
|
|
18132
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
18133
|
+
nativeSessionId: input.nativeSessionId,
|
|
18134
|
+
cwd: input.cwd,
|
|
18135
|
+
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
18136
|
+
updatedAt: Math.floor(time3),
|
|
18137
|
+
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
18138
|
+
running: typeof input.running === "boolean" ? input.running : null
|
|
18139
|
+
});
|
|
18140
|
+
return parsed.success ? parsed.data : null;
|
|
18141
|
+
}
|
|
18142
|
+
var SessionImportScope = class {
|
|
18143
|
+
#abort = new AbortController();
|
|
18144
|
+
#options;
|
|
18145
|
+
#pending = /* @__PURE__ */ new Set();
|
|
18146
|
+
constructor(options) {
|
|
18147
|
+
this.#options = options;
|
|
18148
|
+
}
|
|
18149
|
+
#closed() {
|
|
18150
|
+
return {
|
|
18151
|
+
ok: false,
|
|
18152
|
+
error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
|
|
18153
|
+
};
|
|
18154
|
+
}
|
|
18155
|
+
read(operation) {
|
|
18156
|
+
const signal = this.#abort.signal;
|
|
18157
|
+
if (signal.aborted)
|
|
18158
|
+
return Promise.resolve(this.#closed());
|
|
18159
|
+
let started;
|
|
18160
|
+
try {
|
|
18161
|
+
started = operation(signal);
|
|
18162
|
+
} catch (error51) {
|
|
18163
|
+
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
18164
|
+
}
|
|
18165
|
+
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
18166
|
+
ok: false,
|
|
18167
|
+
error: {
|
|
18168
|
+
code: "unavailable",
|
|
18169
|
+
message: this.#options.unavailableMessage,
|
|
18170
|
+
retryable: true
|
|
18171
|
+
}
|
|
18172
|
+
}).finally(() => this.#pending.delete(request));
|
|
18173
|
+
this.#pending.add(request);
|
|
18174
|
+
return request;
|
|
18175
|
+
}
|
|
18176
|
+
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
18177
|
+
async resolve(operation) {
|
|
18178
|
+
const result = await this.read(operation);
|
|
18179
|
+
if (!result.ok)
|
|
18180
|
+
return result;
|
|
18181
|
+
return result.value ? { ok: true, value: result.value } : {
|
|
18182
|
+
ok: false,
|
|
18183
|
+
error: {
|
|
18184
|
+
code: "sessionNotFound",
|
|
18185
|
+
message: this.#options.notFoundMessage,
|
|
18186
|
+
retryable: false
|
|
18187
|
+
}
|
|
18188
|
+
};
|
|
18189
|
+
}
|
|
18190
|
+
/** Idempotent. Resolves after every started read has settled. */
|
|
18191
|
+
async close() {
|
|
18192
|
+
this.#abort.abort();
|
|
18193
|
+
await Promise.allSettled(this.#pending);
|
|
18194
|
+
}
|
|
18195
|
+
};
|
|
18196
|
+
|
|
18197
|
+
// dist/pi-session-import.js
|
|
18198
|
+
var PI_SESSION_CHANGED = "Pi Session changed during discovery; refresh and retry";
|
|
18199
|
+
function isRecord2(value) {
|
|
18200
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18201
|
+
}
|
|
18202
|
+
function expandDirectory(value, home) {
|
|
18203
|
+
return path5.resolve(value === "~" ? home : value.startsWith(`~${path5.sep}`) || value.startsWith("~/") ? path5.join(home, value.slice(2)) : value);
|
|
18204
|
+
}
|
|
18205
|
+
function piSessionImportDirectory(environment) {
|
|
18206
|
+
const home = (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os2.homedir();
|
|
18207
|
+
const custom2 = environment.PI_CODING_AGENT_SESSION_DIR;
|
|
18208
|
+
if (custom2)
|
|
18209
|
+
return { directory: expandDirectory(custom2, home), flat: true };
|
|
18210
|
+
const agent = environment.PI_CODING_AGENT_DIR;
|
|
18211
|
+
return {
|
|
18212
|
+
directory: path5.join(agent ? expandDirectory(agent, home) : path5.join(home, ".pi", "agent"), "sessions"),
|
|
18213
|
+
flat: false
|
|
18214
|
+
};
|
|
18215
|
+
}
|
|
18216
|
+
async function sessionFiles(directory, flat, signal) {
|
|
18217
|
+
const files = [];
|
|
18218
|
+
const visit = async (dir, projectLevel) => {
|
|
18219
|
+
signal.throwIfAborted();
|
|
18220
|
+
const entries = await opendir2(dir).catch((error51) => {
|
|
18221
|
+
if (isMissingFileError(error51))
|
|
18222
|
+
return null;
|
|
18223
|
+
throw error51;
|
|
18224
|
+
});
|
|
18225
|
+
if (!entries)
|
|
18226
|
+
return;
|
|
18227
|
+
for await (const entry of entries) {
|
|
18228
|
+
signal.throwIfAborted();
|
|
18229
|
+
if (projectLevel && entry.isDirectory())
|
|
18230
|
+
await visit(path5.join(dir, entry.name), false);
|
|
18231
|
+
else if (!projectLevel && entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
18232
|
+
files.push(path5.join(dir, entry.name));
|
|
18233
|
+
}
|
|
18234
|
+
}
|
|
18235
|
+
};
|
|
18236
|
+
await visit(directory, !flat);
|
|
18237
|
+
return files;
|
|
18238
|
+
}
|
|
18239
|
+
async function readCandidate(file2, signal) {
|
|
18240
|
+
const before = await stat(file2);
|
|
18241
|
+
if (!before.isFile() || before.size === 0)
|
|
18242
|
+
return null;
|
|
18243
|
+
const stream = createReadStream2(file2, { encoding: "utf8", signal, end: before.size - 1 });
|
|
18244
|
+
const lines = createInterface2({ input: stream, crlfDelay: Infinity });
|
|
18245
|
+
let header;
|
|
18246
|
+
let name = null;
|
|
18247
|
+
let firstMessage = null;
|
|
18248
|
+
let hasUser = false;
|
|
18249
|
+
let updatedAt = before.mtimeMs;
|
|
18250
|
+
const entries = /* @__PURE__ */ new Map();
|
|
18251
|
+
try {
|
|
18252
|
+
for await (const line of lines) {
|
|
18253
|
+
signal.throwIfAborted();
|
|
18254
|
+
if (!line.trim())
|
|
18255
|
+
continue;
|
|
18256
|
+
let entry;
|
|
18257
|
+
try {
|
|
18258
|
+
entry = JSON.parse(line);
|
|
18259
|
+
} catch {
|
|
18260
|
+
return null;
|
|
18261
|
+
}
|
|
18262
|
+
if (!isRecord2(entry))
|
|
18263
|
+
return null;
|
|
18264
|
+
if (!header) {
|
|
18265
|
+
if (entry.type !== "session" || entry.version !== 3 || typeof entry.id !== "string" || typeof entry.cwd !== "string" || !path5.isAbsolute(entry.cwd))
|
|
18266
|
+
return null;
|
|
18267
|
+
header = entry;
|
|
18268
|
+
continue;
|
|
18269
|
+
}
|
|
18270
|
+
if (typeof entry.id !== "string" || entry.id.length === 0 || entries.has(entry.id) || entry.parentId !== null && (typeof entry.parentId !== "string" || !entries.has(entry.parentId)))
|
|
18271
|
+
return null;
|
|
18272
|
+
const message3 = isRecord2(entry.message) ? entry.message : null;
|
|
18273
|
+
if (!firstMessage && entry.type === "message" && message3?.role === "user") {
|
|
18274
|
+
const content = message3.content;
|
|
18275
|
+
const text4 = typeof content === "string" ? content : Array.isArray(content) ? content.filter((block) => isRecord2(block) && block.type === "text" && typeof block.text === "string").map((block) => block.text).join(" ") : "";
|
|
18276
|
+
firstMessage = sessionImportTitle(text4);
|
|
18277
|
+
}
|
|
18278
|
+
hasUser = entry.type === "message" && message3?.role === "user" || typeof entry.parentId === "string" && entries.get(entry.parentId) === true;
|
|
18279
|
+
entries.set(entry.id, hasUser);
|
|
18280
|
+
if (entry.type === "session_info")
|
|
18281
|
+
name = sessionImportTitle(entry.name);
|
|
18282
|
+
if (entry.type === "message" && (message3?.role === "user" || message3?.role === "assistant")) {
|
|
18283
|
+
const time3 = typeof message3.timestamp === "number" ? message3.timestamp : typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : NaN;
|
|
18284
|
+
if (Number.isFinite(time3))
|
|
18285
|
+
updatedAt = time3;
|
|
18286
|
+
}
|
|
18287
|
+
}
|
|
18288
|
+
} finally {
|
|
18289
|
+
lines.close();
|
|
18290
|
+
stream.destroy();
|
|
18291
|
+
}
|
|
18292
|
+
if (!header)
|
|
18293
|
+
return null;
|
|
18294
|
+
if (!hasUser)
|
|
18295
|
+
return null;
|
|
18296
|
+
const after = await stat(file2);
|
|
18297
|
+
if (!sameFileFingerprint(before, after))
|
|
18298
|
+
throw new SessionImportChangedError(PI_SESSION_CHANGED);
|
|
18299
|
+
const cwd = await realpath(String(header.cwd));
|
|
18300
|
+
if (!(await stat(cwd)).isDirectory())
|
|
18301
|
+
return null;
|
|
18302
|
+
const nativeRef = nativeSessionRefSchema.safeParse({
|
|
18303
|
+
harnessId: "pi",
|
|
18304
|
+
nativeSessionId: header.id,
|
|
18305
|
+
locator: { sessionFile: await realpath(file2) },
|
|
18306
|
+
formatVersion: 1
|
|
18307
|
+
});
|
|
18308
|
+
const candidate = sessionImportCandidate({
|
|
18309
|
+
nativeSessionId: header.id,
|
|
18310
|
+
cwd,
|
|
18311
|
+
title: name ?? firstMessage,
|
|
18312
|
+
updatedAt
|
|
18313
|
+
});
|
|
18314
|
+
return candidate && nativeRef.success ? { candidate, nativeRef: nativeRef.data } : null;
|
|
18315
|
+
}
|
|
18316
|
+
async function readIdentity(file2, signal) {
|
|
18317
|
+
const stream = createReadStream2(file2, { encoding: "utf8", signal });
|
|
18318
|
+
const lines = createInterface2({ input: stream, crlfDelay: Infinity });
|
|
18319
|
+
try {
|
|
18320
|
+
for await (const line of lines) {
|
|
18321
|
+
signal.throwIfAborted();
|
|
18322
|
+
if (!line.trim())
|
|
18323
|
+
continue;
|
|
18324
|
+
let header;
|
|
18325
|
+
try {
|
|
18326
|
+
header = JSON.parse(line);
|
|
18327
|
+
} catch {
|
|
18328
|
+
return null;
|
|
18329
|
+
}
|
|
18330
|
+
return isRecord2(header) && header.type === "session" && header.version === 3 && typeof header.id === "string" ? header.id : null;
|
|
18331
|
+
}
|
|
18332
|
+
return null;
|
|
18333
|
+
} finally {
|
|
18334
|
+
lines.close();
|
|
18335
|
+
stream.destroy();
|
|
17917
18336
|
}
|
|
17918
|
-
return { ...value, ...indicators };
|
|
17919
18337
|
}
|
|
17920
|
-
var
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17925
|
-
|
|
17926
|
-
"reasoningOutputTokens",
|
|
17927
|
-
"startedAtMs",
|
|
17928
|
-
"completedAtMs"
|
|
17929
|
-
];
|
|
17930
|
-
var requestFields = /* @__PURE__ */ new Set([
|
|
17931
|
-
...requestTokenFields,
|
|
17932
|
-
"requestId",
|
|
17933
|
-
"historical",
|
|
17934
|
-
"model",
|
|
17935
|
-
"provider"
|
|
17936
|
-
]);
|
|
17937
|
-
function parseHostUsageRequest(value) {
|
|
17938
|
-
if (!isRecord2(value))
|
|
17939
|
-
throw new Error("Harness Usage request must be an object");
|
|
17940
|
-
for (const key of Object.keys(value)) {
|
|
17941
|
-
if (!requestFields.has(key)) {
|
|
17942
|
-
throw new Error(`Harness Usage request contains unknown field '${key}'`);
|
|
17943
|
-
}
|
|
18338
|
+
var PiSessionImportIndex = class {
|
|
18339
|
+
#location;
|
|
18340
|
+
#cache = /* @__PURE__ */ new Map();
|
|
18341
|
+
#listing;
|
|
18342
|
+
constructor(environment) {
|
|
18343
|
+
this.#location = piSessionImportDirectory(environment);
|
|
17944
18344
|
}
|
|
17945
|
-
|
|
17946
|
-
|
|
18345
|
+
list(signal) {
|
|
18346
|
+
this.#listing ??= this.#scan(signal).finally(() => {
|
|
18347
|
+
this.#listing = void 0;
|
|
18348
|
+
});
|
|
18349
|
+
return this.#listing;
|
|
17947
18350
|
}
|
|
17948
|
-
|
|
17949
|
-
const
|
|
17950
|
-
|
|
17951
|
-
|
|
18351
|
+
async #scan(signal) {
|
|
18352
|
+
const { directory, flat } = this.#location;
|
|
18353
|
+
const files = await sessionFiles(directory, flat, signal);
|
|
18354
|
+
const next = /* @__PURE__ */ new Map();
|
|
18355
|
+
const identities = /* @__PURE__ */ new Set();
|
|
18356
|
+
const sources = [];
|
|
18357
|
+
for (const file2 of files) {
|
|
18358
|
+
signal.throwIfAborted();
|
|
18359
|
+
try {
|
|
18360
|
+
const fingerprint = await stat(file2);
|
|
18361
|
+
const cached2 = this.#cache.get(file2);
|
|
18362
|
+
const source = cached2 && sameFileFingerprint(cached2.fingerprint, fingerprint) ? cached2.source : await readCandidate(file2, signal);
|
|
18363
|
+
if (!source)
|
|
18364
|
+
continue;
|
|
18365
|
+
if (!(await stat(source.candidate.cwd)).isDirectory())
|
|
18366
|
+
continue;
|
|
18367
|
+
if (identities.has(source.nativeRef.nativeSessionId))
|
|
18368
|
+
throw new Error("Pi Session identity is ambiguous across files");
|
|
18369
|
+
identities.add(source.nativeRef.nativeSessionId);
|
|
18370
|
+
next.set(file2, { fingerprint, source });
|
|
18371
|
+
sources.push(source);
|
|
18372
|
+
} catch (error51) {
|
|
18373
|
+
if (!isMissingFileError(error51) && !(error51 instanceof SessionImportChangedError))
|
|
18374
|
+
throw error51;
|
|
18375
|
+
}
|
|
17952
18376
|
}
|
|
18377
|
+
this.#cache = next;
|
|
18378
|
+
return structuredClone(sources.sort((left, right) => right.candidate.updatedAt - left.candidate.updatedAt));
|
|
17953
18379
|
}
|
|
17954
|
-
|
|
17955
|
-
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
|
|
17959
|
-
|
|
17960
|
-
|
|
18380
|
+
async resolve(nativeSessionId, signal) {
|
|
18381
|
+
const { directory, flat } = this.#location;
|
|
18382
|
+
let selected;
|
|
18383
|
+
for (const file2 of await sessionFiles(directory, flat, signal)) {
|
|
18384
|
+
signal.throwIfAborted();
|
|
18385
|
+
try {
|
|
18386
|
+
const fingerprint = await stat(file2);
|
|
18387
|
+
const cached2 = this.#cache.get(file2);
|
|
18388
|
+
const id = cached2 && sameFileFingerprint(cached2.fingerprint, fingerprint) ? cached2.source.nativeRef.nativeSessionId : await readIdentity(file2, signal);
|
|
18389
|
+
if (id !== nativeSessionId)
|
|
18390
|
+
continue;
|
|
18391
|
+
if (selected)
|
|
18392
|
+
throw new Error("Pi Session identity is ambiguous across files");
|
|
18393
|
+
selected = file2;
|
|
18394
|
+
} catch (error51) {
|
|
18395
|
+
if (!isMissingFileError(error51))
|
|
18396
|
+
throw error51;
|
|
18397
|
+
}
|
|
18398
|
+
}
|
|
18399
|
+
if (!selected)
|
|
18400
|
+
return null;
|
|
18401
|
+
try {
|
|
18402
|
+
const source = await readCandidate(selected, signal);
|
|
18403
|
+
return source?.nativeRef.nativeSessionId === nativeSessionId ? source : null;
|
|
18404
|
+
} catch (error51) {
|
|
18405
|
+
if (isMissingFileError(error51))
|
|
18406
|
+
return null;
|
|
18407
|
+
throw error51;
|
|
17961
18408
|
}
|
|
17962
18409
|
}
|
|
17963
|
-
|
|
17964
|
-
throw new Error("Harness Usage request must contain 'inputTokens' and 'outputTokens'");
|
|
17965
|
-
}
|
|
17966
|
-
const request = value;
|
|
17967
|
-
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
17968
|
-
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
17969
|
-
}
|
|
17970
|
-
if ((request.reasoningOutputTokens ?? 0) > request.outputTokens) {
|
|
17971
|
-
throw new Error("Harness Usage request 'reasoningOutputTokens' must not exceed 'outputTokens'");
|
|
17972
|
-
}
|
|
17973
|
-
if (request.cacheWrite1hInputTokens !== void 0 && request.cacheWrite1hInputTokens > (request.cacheWriteInputTokens ?? -1)) {
|
|
17974
|
-
throw new Error("Harness Usage request 'cacheWrite1hInputTokens' must not exceed 'cacheWriteInputTokens'");
|
|
17975
|
-
}
|
|
17976
|
-
if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
|
|
17977
|
-
throw new Error("Harness Usage request timing fields must be provided together");
|
|
17978
|
-
}
|
|
17979
|
-
if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
|
|
17980
|
-
throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
|
|
17981
|
-
}
|
|
17982
|
-
return { ...request };
|
|
17983
|
-
}
|
|
17984
|
-
|
|
17985
|
-
// ../../harness-adapter/dist/live-command-catalog.js
|
|
17986
|
-
var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
17987
|
-
// Session lifecycle
|
|
17988
|
-
"branch",
|
|
17989
|
-
"clear",
|
|
17990
|
-
"exit",
|
|
17991
|
-
"fork",
|
|
17992
|
-
"fresh",
|
|
17993
|
-
"new",
|
|
17994
|
-
"quit",
|
|
17995
|
-
"rename",
|
|
17996
|
-
"rename-chat",
|
|
17997
|
-
"reset",
|
|
17998
|
-
"resume",
|
|
17999
|
-
"rewind",
|
|
18000
|
-
"session",
|
|
18001
|
-
"sessions",
|
|
18002
|
-
// Desktop-owned configuration
|
|
18003
|
-
"autocompact",
|
|
18004
|
-
"color",
|
|
18005
|
-
"config",
|
|
18006
|
-
"effort",
|
|
18007
|
-
"fast",
|
|
18008
|
-
"keybindings",
|
|
18009
|
-
"model",
|
|
18010
|
-
"models",
|
|
18011
|
-
"output-style",
|
|
18012
|
-
"permissions",
|
|
18013
|
-
"settings",
|
|
18014
|
-
"statusline",
|
|
18015
|
-
"terminal-setup",
|
|
18016
|
-
"theme",
|
|
18017
|
-
"vim",
|
|
18018
|
-
// Trust and approval policy
|
|
18019
|
-
"always-approve",
|
|
18020
|
-
"auto-mode-setup",
|
|
18021
|
-
// Native login
|
|
18022
|
-
"login",
|
|
18023
|
-
"logout",
|
|
18024
|
-
// Work outliving the Turn
|
|
18025
|
-
"autopilot",
|
|
18026
|
-
"background",
|
|
18027
|
-
"bg",
|
|
18028
|
-
"goal",
|
|
18029
|
-
"jobs",
|
|
18030
|
-
"loop",
|
|
18031
|
-
"multitask",
|
|
18032
|
-
"queue",
|
|
18033
|
-
"remote-control",
|
|
18034
|
-
"schedule",
|
|
18035
|
-
"steer",
|
|
18036
|
-
// Native terminal UI
|
|
18037
|
-
"copy",
|
|
18038
|
-
"debug",
|
|
18039
|
-
"feedback",
|
|
18040
|
-
"heapdump",
|
|
18041
|
-
"share",
|
|
18042
|
-
"shell",
|
|
18043
|
-
// Plugin and MCP management
|
|
18044
|
-
"marketplace",
|
|
18045
|
-
"mcp",
|
|
18046
|
-
"plugins",
|
|
18047
|
-
"reload-plugins"
|
|
18048
|
-
]);
|
|
18049
|
-
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
18050
|
-
function isExcludedLiveCommand(name, kind, extra = {}) {
|
|
18051
|
-
const normalized = name.trim().replace(/^\//u, "");
|
|
18052
|
-
if (new Set(extra.names ?? []).has(normalized))
|
|
18053
|
-
return true;
|
|
18054
|
-
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
18055
|
-
return true;
|
|
18056
|
-
if (kind === "skill")
|
|
18057
|
-
return false;
|
|
18058
|
-
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
18059
|
-
}
|
|
18060
|
-
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
18061
|
-
if (!commandId.startsWith(idPrefix))
|
|
18062
|
-
return null;
|
|
18063
|
-
const descriptor = catalog.commands.find(({ id }) => id === commandId);
|
|
18064
|
-
if (!descriptor)
|
|
18065
|
-
return null;
|
|
18066
|
-
const text4 = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
18067
|
-
return text4 ? `${descriptor.invocation} ${text4}` : descriptor.invocation;
|
|
18068
|
-
}
|
|
18069
|
-
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
18070
|
-
if (!live)
|
|
18071
|
-
return builtIns;
|
|
18072
|
-
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
18073
|
-
const ids = new Set(builtIns.commands.map(({ id }) => id));
|
|
18074
|
-
const dynamic = [];
|
|
18075
|
-
for (const command of live) {
|
|
18076
|
-
const name = command.name.trim().replace(/^\//u, "");
|
|
18077
|
-
if (!name || /\s/u.test(name))
|
|
18078
|
-
continue;
|
|
18079
|
-
if (isExcludedLiveCommand(name, command.kind, exclusions))
|
|
18080
|
-
continue;
|
|
18081
|
-
const invocation = `/${name}`;
|
|
18082
|
-
const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
18083
|
-
if (invocations.has(invocation) || ids.has(id))
|
|
18084
|
-
continue;
|
|
18085
|
-
const description = command.description?.trim().slice(0, 512);
|
|
18086
|
-
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
18087
|
-
id,
|
|
18088
|
-
invocation,
|
|
18089
|
-
label: name.slice(0, 128),
|
|
18090
|
-
...description ? { description } : {},
|
|
18091
|
-
argumentMode: "text",
|
|
18092
|
-
kind: command.kind
|
|
18093
|
-
});
|
|
18094
|
-
if (!parsed.success)
|
|
18095
|
-
continue;
|
|
18096
|
-
invocations.add(invocation);
|
|
18097
|
-
ids.add(id);
|
|
18098
|
-
dynamic.push(parsed.data);
|
|
18099
|
-
}
|
|
18100
|
-
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
18101
|
-
}
|
|
18410
|
+
};
|
|
18102
18411
|
|
|
18103
18412
|
// ../../../node_modules/diff/libesm/diff/base.js
|
|
18104
18413
|
var Diff = class {
|
|
@@ -19027,6 +19336,7 @@ function gotgenesRecord(value) {
|
|
|
19027
19336
|
role: value.type,
|
|
19028
19337
|
status,
|
|
19029
19338
|
background: value.isBackground === true,
|
|
19339
|
+
...subagentConfiguration(value),
|
|
19030
19340
|
...text(value.modelName) ? { model: value.modelName } : {},
|
|
19031
19341
|
...result ? { resultSummary: result.slice(0, 2048) } : {}
|
|
19032
19342
|
},
|
|
@@ -19154,7 +19464,7 @@ var GotgenesSubagents = class {
|
|
|
19154
19464
|
this.observe([
|
|
19155
19465
|
{
|
|
19156
19466
|
...prior,
|
|
19157
|
-
child: { ...prior.child, ...parsed.child
|
|
19467
|
+
child: { ...prior.child, ...subagentConfiguration(parsed.child) }
|
|
19158
19468
|
}
|
|
19159
19469
|
]);
|
|
19160
19470
|
}
|
|
@@ -19317,6 +19627,7 @@ function node(value, depth, budget) {
|
|
|
19317
19627
|
kind: value.kind,
|
|
19318
19628
|
label: value.label,
|
|
19319
19629
|
state: value.state,
|
|
19630
|
+
...subagentConfiguration(value),
|
|
19320
19631
|
...children.length ? { children } : {}
|
|
19321
19632
|
};
|
|
19322
19633
|
}
|
|
@@ -19375,6 +19686,7 @@ function states(run) {
|
|
|
19375
19686
|
subagentId: id,
|
|
19376
19687
|
nativeSubagentId: id,
|
|
19377
19688
|
description: entry.label,
|
|
19689
|
+
...subagentConfiguration(entry),
|
|
19378
19690
|
background: true,
|
|
19379
19691
|
status: statuses[entry.state] ?? "running"
|
|
19380
19692
|
});
|
|
@@ -19421,7 +19733,7 @@ var PiSubagents = class {
|
|
|
19421
19733
|
const observed = states(run);
|
|
19422
19734
|
const retained = this.#children.get(run.id) ?? /* @__PURE__ */ new Map();
|
|
19423
19735
|
for (const child of observed)
|
|
19424
|
-
retained.set(child.subagentId, child);
|
|
19736
|
+
retained.set(child.subagentId, { ...retained.get(child.subagentId), ...child });
|
|
19425
19737
|
this.#children.set(run.id, retained);
|
|
19426
19738
|
const children = [...retained.values()];
|
|
19427
19739
|
if (!publish)
|
|
@@ -21507,10 +21819,9 @@ function parsePiNativeCommands(response) {
|
|
|
21507
21819
|
});
|
|
21508
21820
|
}
|
|
21509
21821
|
function piLiveCommandCatalog(builtIns, native) {
|
|
21510
|
-
return mergeLiveHarnessCommands(builtIns, DYNAMIC_ID_PREFIX, native?.map((command) => ({
|
|
21822
|
+
return mergeLiveHarnessCommands(builtIns, DYNAMIC_ID_PREFIX, native?.filter((command) => command.source !== "skill").map((command) => ({
|
|
21511
21823
|
name: command.name,
|
|
21512
|
-
...command.description ? { description: command.description } : {}
|
|
21513
|
-
kind: command.source === "skill" ? "skill" : "command"
|
|
21824
|
+
...command.description ? { description: command.description } : {}
|
|
21514
21825
|
})) ?? null, { names: PI_EXCLUDED_COMMANDS });
|
|
21515
21826
|
}
|
|
21516
21827
|
function piDynamicCommandPrompt(catalog, commandId, argumentText) {
|
|
@@ -22206,6 +22517,9 @@ var PiRpcSession = class {
|
|
|
22206
22517
|
child.stderr.on("data", (chunk) => {
|
|
22207
22518
|
this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
|
|
22208
22519
|
});
|
|
22520
|
+
child.stdin.on("error", (error51) => {
|
|
22521
|
+
this.#fail(new PiRpcFaultError("processExited", `Pi RPC stdin closed: ${error51.message}`, this.stderrTail));
|
|
22522
|
+
});
|
|
22209
22523
|
child.once("error", (error51) => {
|
|
22210
22524
|
const kind = isRecord9(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
|
|
22211
22525
|
this.#fail(new PiRpcFaultError(kind, `Pi RPC failed to start: ${error51.message}`, this.stderrTail));
|
|
@@ -23584,7 +23898,19 @@ var PiHarnessSession = class {
|
|
|
23584
23898
|
handleTransportFault(error51) {
|
|
23585
23899
|
queueMicrotask(() => this.#fault(error51));
|
|
23586
23900
|
}
|
|
23901
|
+
#subagentConfiguration() {
|
|
23902
|
+
const state2 = this.#state;
|
|
23903
|
+
const model2 = state2.effectiveModel ? decodePiModelRef(state2.effectiveModel).id : void 0;
|
|
23904
|
+
return {
|
|
23905
|
+
...model2 ? { model: model2 } : {},
|
|
23906
|
+
...state2.effectiveThinkingOptionId ? { reasoningEffort: state2.effectiveThinkingOptionId } : {}
|
|
23907
|
+
};
|
|
23908
|
+
}
|
|
23587
23909
|
async readSnapshot() {
|
|
23910
|
+
const result = await this.#readSnapshot();
|
|
23911
|
+
return result.ok ? { ok: true, value: configureSubagentSnapshot(result.value, this.#subagentConfiguration()) } : result;
|
|
23912
|
+
}
|
|
23913
|
+
async #readSnapshot() {
|
|
23588
23914
|
if (this.#phase !== "open") {
|
|
23589
23915
|
return { ok: false, error: invalidState("Pi Session is not open") };
|
|
23590
23916
|
}
|
|
@@ -24889,6 +25215,7 @@ var PiHarnessSession = class {
|
|
|
24889
25215
|
}
|
|
24890
25216
|
}
|
|
24891
25217
|
#event(event) {
|
|
25218
|
+
event = configureSubagentEvent(event, this.#subagentConfiguration());
|
|
24892
25219
|
this.#channel.emit({ kind: "event", event });
|
|
24893
25220
|
}
|
|
24894
25221
|
#newItemId() {
|