@karlorz/codexhost-cli-win32-x64 0.18.0-1 → 0.19.0-1
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 +59 -2
- package/app/console-web.js +98 -8
- package/app/cpa-live-voice-hook.js +59 -2
- package/app/desktop-controller.mjs +290 -12
- package/app/host-runtime.mjs +12896 -2966
- package/app/plugins/antigravity/plugin.mjs +654 -216
- package/app/plugins/claude-code/plugin.mjs +138 -11
- package/app/plugins/codebuddy/plugin.mjs +152 -20
- package/app/plugins/codex-usage/plugin.mjs +59 -2
- package/app/plugins/copilot/plugin.mjs +59 -2
- package/app/plugins/cursor-cli/plugin.mjs +134 -12
- package/app/plugins/deepseek-harness/manifest.json +2 -2
- package/app/plugins/deepseek-harness/plugin.mjs +86 -7
- package/app/plugins/devin/plugin.mjs +59 -2
- package/app/plugins/grok/plugin.mjs +1093 -970
- package/app/plugins/hermes/plugin.mjs +138 -14
- package/app/plugins/kimi-code/plugin.mjs +59 -2
- package/app/plugins/kiro-cli/plugin.mjs +287 -18
- package/app/plugins/omp/plugin.mjs +789 -628
- package/app/plugins/opencode/plugin.mjs +59 -2
- package/app/plugins/pi/plugin.mjs +786 -660
- package/app/plugins/qoder/plugin.mjs +61 -6
- package/app/plugins/qoder-cn/plugin.mjs +61 -6
- package/app/plugins/qwen-code/plugin.mjs +168 -94
- package/app/plugins/workbuddy/plugin.mjs +152 -20
- package/app/plugins/zcode/plugin.mjs +132 -5
- package/app/renderer-extension.js +434 -39
- package/app/web/assets/{index-py6Ho-Dy.js → index-BCyiiDDL.js} +62 -62
- package/app/web/assets/index-BNQIOOHE.css +1 -0
- package/app/web/codexhost-settings.js +84 -4
- 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 +8 -8
- 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 +8 -6
- 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 +16 -16
- 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 +2345 -1518
- 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-C3lniEH1.css +0 -1
|
@@ -408,152 +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 record3 = value;
|
|
532
|
-
if (match(record3))
|
|
533
|
-
return record3;
|
|
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/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
|
-
// ../../harness-adapter/dist/session-import.js
|
|
555
|
-
import { lstat as lstat2 } from "node:fs/promises";
|
|
556
|
-
|
|
557
411
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
558
412
|
var external_exports = {};
|
|
559
413
|
__export(external_exports, {
|
|
@@ -16065,6 +15919,10 @@ var CLIENT_CHANNEL_VERSION = 1;
|
|
|
16065
15919
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
16066
15920
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
16067
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();
|
|
16068
15926
|
var clientProjectlessWorkspaceSchema = external_exports.object({
|
|
16069
15927
|
prompt: external_exports.string().max(16384).optional()
|
|
16070
15928
|
}).strict();
|
|
@@ -16081,6 +15939,11 @@ var clientChannelCursorSchema = external_exports.object({
|
|
|
16081
15939
|
sequence: external_exports.number().int().nonnegative()
|
|
16082
15940
|
});
|
|
16083
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
|
+
}),
|
|
16084
15947
|
external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
|
|
16085
15948
|
external_exports.object({
|
|
16086
15949
|
type: external_exports.literal("preferences-changed"),
|
|
@@ -16278,6 +16141,28 @@ var voiceTranscribeResultSchema = external_exports.discriminatedUnion("ok", [
|
|
|
16278
16141
|
external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
|
|
16279
16142
|
]);
|
|
16280
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
|
+
|
|
16281
16166
|
// ../../shared-contracts/dist/web-access-tokens.js
|
|
16282
16167
|
var webNetworkAccessUrlSchema = external_exports.object({
|
|
16283
16168
|
/**
|
|
@@ -16383,8 +16268,8 @@ var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
|
|
|
16383
16268
|
var delegationReadParamsSchema = external_exports.strictObject({
|
|
16384
16269
|
threadId: external_exports.string().min(1).max(1024),
|
|
16385
16270
|
view: external_exports.enum(["result", "messages"]),
|
|
16386
|
-
|
|
16387
|
-
|
|
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()
|
|
16388
16273
|
});
|
|
16389
16274
|
|
|
16390
16275
|
// ../../shared-contracts/dist/credential-imports.js
|
|
@@ -17386,6 +17271,17 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
17386
17271
|
status: updateStatusSchema.nullable()
|
|
17387
17272
|
});
|
|
17388
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
|
+
|
|
17389
17285
|
// ../../shared-contracts/dist/remote-runtime.js
|
|
17390
17286
|
var remoteUpdatePhaseSchema = external_exports.enum([
|
|
17391
17287
|
"idle",
|
|
@@ -17433,6 +17329,14 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17433
17329
|
archived: external_exports.boolean()
|
|
17434
17330
|
}),
|
|
17435
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"),
|
|
17436
17340
|
external_exports.strictObject({
|
|
17437
17341
|
kind: external_exports.literal("prompt"),
|
|
17438
17342
|
...thread,
|
|
@@ -17505,6 +17409,13 @@ var remoteConnectionsReplySchema = external_exports.union([
|
|
|
17505
17409
|
external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
|
|
17506
17410
|
]);
|
|
17507
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
|
+
|
|
17508
17419
|
// ../../shared-contracts/dist/web-ui-extensions.js
|
|
17509
17420
|
var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
|
|
17510
17421
|
var localizedTextSchema2 = external_exports.union([
|
|
@@ -17579,343 +17490,27 @@ var threadActivityStopResultSchema = external_exports.strictObject({
|
|
|
17579
17490
|
// ../../shared-contracts/dist/index.js
|
|
17580
17491
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
17581
17492
|
|
|
17582
|
-
// ../../harness-adapter/dist/
|
|
17583
|
-
|
|
17584
|
-
|
|
17585
|
-
super(message3);
|
|
17586
|
-
this.name = "SessionImportChangedError";
|
|
17587
|
-
}
|
|
17588
|
-
};
|
|
17589
|
-
function isMissingFileError(error51) {
|
|
17590
|
-
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
17591
|
-
}
|
|
17592
|
-
function sameFileFingerprint(left, right) {
|
|
17593
|
-
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;
|
|
17594
|
-
}
|
|
17595
|
-
var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
|
|
17596
|
-
function isStorageAccessError(error51) {
|
|
17597
|
-
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
|
|
17598
|
-
}
|
|
17599
|
-
async function optionalLstat(file2) {
|
|
17600
|
-
try {
|
|
17601
|
-
return await lstat2(file2);
|
|
17602
|
-
} catch (error51) {
|
|
17603
|
-
if (isMissingFileError(error51))
|
|
17604
|
-
return null;
|
|
17605
|
-
throw error51;
|
|
17606
|
-
}
|
|
17607
|
-
}
|
|
17608
|
-
async function readStableFiles(files, read) {
|
|
17609
|
-
const before = await Promise.all(files.map(optionalLstat));
|
|
17610
|
-
const value = await read(before);
|
|
17611
|
-
const after = await Promise.all(files.map(optionalLstat));
|
|
17612
|
-
if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
|
|
17613
|
-
throw new SessionImportChangedError();
|
|
17614
|
-
return value;
|
|
17493
|
+
// ../../harness-adapter/dist/approval.js
|
|
17494
|
+
function invalidRequest(message3) {
|
|
17495
|
+
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17615
17496
|
}
|
|
17616
|
-
function
|
|
17617
|
-
|
|
17618
|
-
return null;
|
|
17619
|
-
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
17620
|
-
if (!normalized)
|
|
17621
|
-
return null;
|
|
17622
|
-
if (normalized.length <= maxLength)
|
|
17623
|
-
return normalized;
|
|
17624
|
-
const characters = [...normalized];
|
|
17625
|
-
if (characters.length <= maxLength)
|
|
17626
|
-
return normalized;
|
|
17627
|
-
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
17497
|
+
function validateHostApprovalResponse(interaction, response) {
|
|
17498
|
+
return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
17628
17499
|
}
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
cwd: input.cwd,
|
|
17634
|
-
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
17635
|
-
updatedAt: Math.floor(time3),
|
|
17636
|
-
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
17637
|
-
running: typeof input.running === "boolean" ? input.running : null
|
|
17638
|
-
});
|
|
17639
|
-
return parsed.success ? parsed.data : null;
|
|
17500
|
+
|
|
17501
|
+
// ../../harness-adapter/dist/question.js
|
|
17502
|
+
function invalidRequest2(message3) {
|
|
17503
|
+
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17640
17504
|
}
|
|
17641
|
-
|
|
17642
|
-
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
constructor(options) {
|
|
17646
|
-
this.#options = options;
|
|
17505
|
+
function validateHostQuestionResponse(interaction, response) {
|
|
17506
|
+
const questionIds = new Set(interaction.questions.map(({ id }) => id));
|
|
17507
|
+
if (response.cancelled) {
|
|
17508
|
+
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
17647
17509
|
}
|
|
17648
|
-
|
|
17649
|
-
|
|
17650
|
-
|
|
17651
|
-
|
|
17652
|
-
};
|
|
17653
|
-
}
|
|
17654
|
-
read(operation) {
|
|
17655
|
-
const signal = this.#abort.signal;
|
|
17656
|
-
if (signal.aborted)
|
|
17657
|
-
return Promise.resolve(this.#closed());
|
|
17658
|
-
let started;
|
|
17659
|
-
try {
|
|
17660
|
-
started = operation(signal);
|
|
17661
|
-
} catch (error51) {
|
|
17662
|
-
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
17663
|
-
}
|
|
17664
|
-
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
17665
|
-
ok: false,
|
|
17666
|
-
error: {
|
|
17667
|
-
code: "unavailable",
|
|
17668
|
-
message: this.#options.unavailableMessage,
|
|
17669
|
-
retryable: true
|
|
17670
|
-
}
|
|
17671
|
-
}).finally(() => this.#pending.delete(request));
|
|
17672
|
-
this.#pending.add(request);
|
|
17673
|
-
return request;
|
|
17674
|
-
}
|
|
17675
|
-
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
17676
|
-
async resolve(operation) {
|
|
17677
|
-
const result = await this.read(operation);
|
|
17678
|
-
if (!result.ok)
|
|
17679
|
-
return result;
|
|
17680
|
-
return result.value ? { ok: true, value: result.value } : {
|
|
17681
|
-
ok: false,
|
|
17682
|
-
error: {
|
|
17683
|
-
code: "sessionNotFound",
|
|
17684
|
-
message: this.#options.notFoundMessage,
|
|
17685
|
-
retryable: false
|
|
17686
|
-
}
|
|
17687
|
-
};
|
|
17688
|
-
}
|
|
17689
|
-
/** Idempotent. Resolves after every started read has settled. */
|
|
17690
|
-
async close() {
|
|
17691
|
-
this.#abort.abort();
|
|
17692
|
-
await Promise.allSettled(this.#pending);
|
|
17693
|
-
}
|
|
17694
|
-
};
|
|
17695
|
-
|
|
17696
|
-
// dist/session-import.js
|
|
17697
|
-
function isRecord(value) {
|
|
17698
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17699
|
-
}
|
|
17700
|
-
function expandDirectory(value, home) {
|
|
17701
|
-
return path5.resolve(value === "~" ? home : value.startsWith(`~${path5.sep}`) || value.startsWith("~/") ? path5.join(home, value.slice(2)) : value);
|
|
17702
|
-
}
|
|
17703
|
-
function ompSessionImportDirectory(environment) {
|
|
17704
|
-
const home = (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os2.homedir();
|
|
17705
|
-
const custom2 = environment.PI_CODING_AGENT_SESSION_DIR;
|
|
17706
|
-
if (custom2)
|
|
17707
|
-
return { directory: expandDirectory(custom2, home), flat: true };
|
|
17708
|
-
const agent = environment.PI_CODING_AGENT_DIR;
|
|
17709
|
-
return {
|
|
17710
|
-
directory: path5.join(agent ? expandDirectory(agent, home) : path5.join(home, ".omp", "agent"), "sessions"),
|
|
17711
|
-
flat: false
|
|
17712
|
-
};
|
|
17713
|
-
}
|
|
17714
|
-
function messageText(content) {
|
|
17715
|
-
if (typeof content === "string")
|
|
17716
|
-
return content;
|
|
17717
|
-
if (!Array.isArray(content))
|
|
17718
|
-
return "";
|
|
17719
|
-
return content.filter((part) => isRecord(part) && part.type === "text" && typeof part.text === "string").map((part) => String(part.text)).join(" ");
|
|
17720
|
-
}
|
|
17721
|
-
async function readFacts(file2, signal) {
|
|
17722
|
-
const stream = createReadStream2(file2, { encoding: "utf8", signal });
|
|
17723
|
-
const lines = createInterface2({ input: stream, crlfDelay: Infinity });
|
|
17724
|
-
let header = null;
|
|
17725
|
-
let nativeTitle = null;
|
|
17726
|
-
let firstPrompt = null;
|
|
17727
|
-
let updatedAt = null;
|
|
17728
|
-
let leafHasUser = false;
|
|
17729
|
-
const hasUserAncestry = /* @__PURE__ */ new Map();
|
|
17730
|
-
try {
|
|
17731
|
-
for await (const line of lines) {
|
|
17732
|
-
signal.throwIfAborted();
|
|
17733
|
-
if (!line.trim())
|
|
17734
|
-
continue;
|
|
17735
|
-
let entry;
|
|
17736
|
-
try {
|
|
17737
|
-
entry = JSON.parse(line);
|
|
17738
|
-
} catch {
|
|
17739
|
-
continue;
|
|
17740
|
-
}
|
|
17741
|
-
if (!isRecord(entry))
|
|
17742
|
-
continue;
|
|
17743
|
-
if (entry.type === "title") {
|
|
17744
|
-
nativeTitle = sessionImportTitle(entry.title);
|
|
17745
|
-
continue;
|
|
17746
|
-
}
|
|
17747
|
-
if (entry.type === "session") {
|
|
17748
|
-
if (header)
|
|
17749
|
-
return null;
|
|
17750
|
-
if (typeof entry.id !== "string" || entry.id.length === 0 || typeof entry.cwd !== "string" || !path5.isAbsolute(entry.cwd))
|
|
17751
|
-
return null;
|
|
17752
|
-
header = { id: entry.id, cwd: entry.cwd };
|
|
17753
|
-
continue;
|
|
17754
|
-
}
|
|
17755
|
-
if (typeof entry.id !== "string" || entry.id.length === 0)
|
|
17756
|
-
continue;
|
|
17757
|
-
const message3 = isRecord(entry.message) ? entry.message : null;
|
|
17758
|
-
const isUser = entry.type === "message" && message3?.role === "user";
|
|
17759
|
-
if (isUser)
|
|
17760
|
-
firstPrompt ??= sessionImportTitle(messageText(message3?.content));
|
|
17761
|
-
leafHasUser = isUser || typeof entry.parentId === "string" && hasUserAncestry.get(entry.parentId) === true;
|
|
17762
|
-
hasUserAncestry.set(entry.id, leafHasUser);
|
|
17763
|
-
if (entry.type === "message" && (message3?.role === "user" || message3?.role === "assistant")) {
|
|
17764
|
-
const time3 = typeof message3.timestamp === "number" ? message3.timestamp : typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : Number.NaN;
|
|
17765
|
-
if (Number.isFinite(time3) && time3 >= 0)
|
|
17766
|
-
updatedAt = time3;
|
|
17767
|
-
}
|
|
17768
|
-
}
|
|
17769
|
-
} finally {
|
|
17770
|
-
lines.close();
|
|
17771
|
-
stream.destroy();
|
|
17772
|
-
}
|
|
17773
|
-
if (!header || !leafHasUser)
|
|
17774
|
-
return null;
|
|
17775
|
-
return {
|
|
17776
|
-
nativeSessionId: header.id,
|
|
17777
|
-
cwd: header.cwd,
|
|
17778
|
-
title: nativeTitle ?? firstPrompt,
|
|
17779
|
-
updatedAt
|
|
17780
|
-
};
|
|
17781
|
-
}
|
|
17782
|
-
var OmpSessionImport = class {
|
|
17783
|
-
#location;
|
|
17784
|
-
#scope = new SessionImportScope({
|
|
17785
|
-
closedMessage: "Omp Session import is closed",
|
|
17786
|
-
unavailableMessage: "Omp sessions could not be read; close native clients, check storage access and retry",
|
|
17787
|
-
notFoundMessage: "Omp Session is no longer importable"
|
|
17788
|
-
});
|
|
17789
|
-
constructor(environment) {
|
|
17790
|
-
this.#location = ompSessionImportDirectory(environment);
|
|
17791
|
-
}
|
|
17792
|
-
listCandidates() {
|
|
17793
|
-
return this.#scope.read(async (signal) => [...(await this.#sources(signal)).values()].flatMap((sources) => (
|
|
17794
|
-
// One identity in two files cannot be resumed unambiguously.
|
|
17795
|
-
sources.length === 1 && sources[0] ? [sources[0].candidate] : []
|
|
17796
|
-
)));
|
|
17797
|
-
}
|
|
17798
|
-
resolveCandidate(nativeSessionId) {
|
|
17799
|
-
return this.#scope.resolve(async (signal) => {
|
|
17800
|
-
const sources = (await this.#sources(signal)).get(nativeSessionId);
|
|
17801
|
-
if (sources?.length !== 1 || !sources[0])
|
|
17802
|
-
return null;
|
|
17803
|
-
const source = await this.#source(sources[0].file, signal);
|
|
17804
|
-
return source?.nativeRef.nativeSessionId === nativeSessionId ? { candidate: source.candidate, nativeRef: source.nativeRef } : null;
|
|
17805
|
-
});
|
|
17806
|
-
}
|
|
17807
|
-
close() {
|
|
17808
|
-
return this.#scope.close();
|
|
17809
|
-
}
|
|
17810
|
-
async #sessionFiles(signal) {
|
|
17811
|
-
const { directory, flat } = this.#location;
|
|
17812
|
-
const info = await optionalLstat(directory);
|
|
17813
|
-
if (!info)
|
|
17814
|
-
return [];
|
|
17815
|
-
if (!info.isDirectory())
|
|
17816
|
-
throw new Error("Omp Session store is not a directory");
|
|
17817
|
-
const files = [];
|
|
17818
|
-
const visit = async (current, projectLevel) => {
|
|
17819
|
-
const entries = await opendir2(current).catch((error51) => {
|
|
17820
|
-
if (isMissingFileError(error51))
|
|
17821
|
-
return null;
|
|
17822
|
-
throw error51;
|
|
17823
|
-
});
|
|
17824
|
-
if (!entries)
|
|
17825
|
-
return;
|
|
17826
|
-
for await (const entry of entries) {
|
|
17827
|
-
signal.throwIfAborted();
|
|
17828
|
-
if (projectLevel && entry.isDirectory())
|
|
17829
|
-
await visit(path5.join(current, entry.name), false);
|
|
17830
|
-
else if (!projectLevel && entry.isFile() && entry.name.endsWith(".jsonl"))
|
|
17831
|
-
files.push(path5.join(current, entry.name));
|
|
17832
|
-
}
|
|
17833
|
-
};
|
|
17834
|
-
await visit(directory, !flat);
|
|
17835
|
-
return files;
|
|
17836
|
-
}
|
|
17837
|
-
/** Session ID to every readable file claiming it. Files changing under the read are skipped. */
|
|
17838
|
-
async #sources(signal) {
|
|
17839
|
-
const found = /* @__PURE__ */ new Map();
|
|
17840
|
-
for (const file2 of await this.#sessionFiles(signal)) {
|
|
17841
|
-
signal.throwIfAborted();
|
|
17842
|
-
try {
|
|
17843
|
-
const source = await this.#source(file2, signal);
|
|
17844
|
-
if (!source)
|
|
17845
|
-
continue;
|
|
17846
|
-
const sources = found.get(source.nativeRef.nativeSessionId) ?? [];
|
|
17847
|
-
sources.push(source);
|
|
17848
|
-
found.set(source.nativeRef.nativeSessionId, sources);
|
|
17849
|
-
} catch (error51) {
|
|
17850
|
-
if (!(error51 instanceof SessionImportChangedError))
|
|
17851
|
-
throw error51;
|
|
17852
|
-
}
|
|
17853
|
-
}
|
|
17854
|
-
return found;
|
|
17855
|
-
}
|
|
17856
|
-
async #source(file2, signal) {
|
|
17857
|
-
signal.throwIfAborted();
|
|
17858
|
-
return readStableFiles([file2], async ([info]) => {
|
|
17859
|
-
if (!info?.isFile() || info.size === 0)
|
|
17860
|
-
return null;
|
|
17861
|
-
try {
|
|
17862
|
-
const facts = await readFacts(file2, signal);
|
|
17863
|
-
if (!facts)
|
|
17864
|
-
return null;
|
|
17865
|
-
const cwd = await realpath(facts.cwd);
|
|
17866
|
-
if (!(await stat(cwd)).isDirectory())
|
|
17867
|
-
return null;
|
|
17868
|
-
const candidate = sessionImportCandidate({
|
|
17869
|
-
nativeSessionId: facts.nativeSessionId,
|
|
17870
|
-
cwd,
|
|
17871
|
-
title: facts.title,
|
|
17872
|
-
updatedAt: facts.updatedAt ?? info.mtimeMs
|
|
17873
|
-
// OMP has no cross-process activity marker: idleness cannot be established.
|
|
17874
|
-
});
|
|
17875
|
-
if (!candidate)
|
|
17876
|
-
return null;
|
|
17877
|
-
return {
|
|
17878
|
-
file: file2,
|
|
17879
|
-
candidate,
|
|
17880
|
-
// Resume needs the file itself: OMP is started with `--session <file>`.
|
|
17881
|
-
nativeRef: nativeSessionRefSchema.parse({
|
|
17882
|
-
harnessId: "omp",
|
|
17883
|
-
nativeSessionId: facts.nativeSessionId,
|
|
17884
|
-
locator: { sessionFile: await realpath(file2) },
|
|
17885
|
-
formatVersion: 1
|
|
17886
|
-
})
|
|
17887
|
-
};
|
|
17888
|
-
} catch (error51) {
|
|
17889
|
-
signal.throwIfAborted();
|
|
17890
|
-
if (isStorageAccessError(error51))
|
|
17891
|
-
throw error51;
|
|
17892
|
-
return null;
|
|
17893
|
-
}
|
|
17894
|
-
});
|
|
17895
|
-
}
|
|
17896
|
-
};
|
|
17897
|
-
|
|
17898
|
-
// ../../harness-adapter/dist/approval.js
|
|
17899
|
-
function invalidRequest(message3) {
|
|
17900
|
-
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17901
|
-
}
|
|
17902
|
-
function validateHostApprovalResponse(interaction, response) {
|
|
17903
|
-
return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
17904
|
-
}
|
|
17905
|
-
|
|
17906
|
-
// ../../harness-adapter/dist/question.js
|
|
17907
|
-
function invalidRequest2(message3) {
|
|
17908
|
-
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17909
|
-
}
|
|
17910
|
-
function validateHostQuestionResponse(interaction, response) {
|
|
17911
|
-
const questionIds = new Set(interaction.questions.map(({ id }) => id));
|
|
17912
|
-
if (response.cancelled) {
|
|
17913
|
-
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
17914
|
-
}
|
|
17915
|
-
for (const answerId of Object.keys(response.answers)) {
|
|
17916
|
-
if (!questionIds.has(answerId)) {
|
|
17917
|
-
return invalidRequest2("Question Response contains an unknown Question ID");
|
|
17918
|
-
}
|
|
17510
|
+
for (const answerId of Object.keys(response.answers)) {
|
|
17511
|
+
if (!questionIds.has(answerId)) {
|
|
17512
|
+
return invalidRequest2("Question Response contains an unknown Question ID");
|
|
17513
|
+
}
|
|
17919
17514
|
}
|
|
17920
17515
|
for (const question of interaction.questions) {
|
|
17921
17516
|
const answers = response.answers[question.id] ?? [];
|
|
@@ -18048,11 +17643,11 @@ var usageFields = /* @__PURE__ */ new Set([
|
|
|
18048
17643
|
"costSource",
|
|
18049
17644
|
"unpricedModels"
|
|
18050
17645
|
]);
|
|
18051
|
-
function
|
|
17646
|
+
function isRecord(value) {
|
|
18052
17647
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18053
17648
|
}
|
|
18054
17649
|
function parseHostUsage(value) {
|
|
18055
|
-
if (!
|
|
17650
|
+
if (!isRecord(value))
|
|
18056
17651
|
throw new Error("Harness Usage must be an object");
|
|
18057
17652
|
const keys = Object.keys(value);
|
|
18058
17653
|
if (keys.length === 0)
|
|
@@ -18099,7 +17694,7 @@ function parseHostUsage(value) {
|
|
|
18099
17694
|
}
|
|
18100
17695
|
if (value.sessionCacheUsage !== void 0) {
|
|
18101
17696
|
const totals2 = value.sessionCacheUsage;
|
|
18102
|
-
if (!
|
|
17697
|
+
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) {
|
|
18103
17698
|
throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
|
|
18104
17699
|
}
|
|
18105
17700
|
}
|
|
@@ -18155,7 +17750,7 @@ var requestFields = /* @__PURE__ */ new Set([
|
|
|
18155
17750
|
"provider"
|
|
18156
17751
|
]);
|
|
18157
17752
|
function parseHostUsageRequest(value) {
|
|
18158
|
-
if (!
|
|
17753
|
+
if (!isRecord(value))
|
|
18159
17754
|
throw new Error("Harness Usage request must be an object");
|
|
18160
17755
|
for (const key of Object.keys(value)) {
|
|
18161
17756
|
if (!requestFields.has(key)) {
|
|
@@ -18183,142 +17778,653 @@ function parseHostUsageRequest(value) {
|
|
|
18183
17778
|
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
18184
17779
|
throw new Error("Harness Usage request must contain 'inputTokens' and 'outputTokens'");
|
|
18185
17780
|
}
|
|
18186
|
-
const request = value;
|
|
18187
|
-
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
18188
|
-
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
17781
|
+
const request = value;
|
|
17782
|
+
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
17783
|
+
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
17784
|
+
}
|
|
17785
|
+
if ((request.reasoningOutputTokens ?? 0) > request.outputTokens) {
|
|
17786
|
+
throw new Error("Harness Usage request 'reasoningOutputTokens' must not exceed 'outputTokens'");
|
|
17787
|
+
}
|
|
17788
|
+
if (request.cacheWrite1hInputTokens !== void 0 && request.cacheWrite1hInputTokens > (request.cacheWriteInputTokens ?? -1)) {
|
|
17789
|
+
throw new Error("Harness Usage request 'cacheWrite1hInputTokens' must not exceed 'cacheWriteInputTokens'");
|
|
17790
|
+
}
|
|
17791
|
+
if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
|
|
17792
|
+
throw new Error("Harness Usage request timing fields must be provided together");
|
|
17793
|
+
}
|
|
17794
|
+
if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
|
|
17795
|
+
throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
|
|
17796
|
+
}
|
|
17797
|
+
return { ...request };
|
|
17798
|
+
}
|
|
17799
|
+
|
|
17800
|
+
// ../../harness-adapter/dist/live-command-catalog.js
|
|
17801
|
+
var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
17802
|
+
// Session lifecycle
|
|
17803
|
+
"branch",
|
|
17804
|
+
"clear",
|
|
17805
|
+
"exit",
|
|
17806
|
+
"fork",
|
|
17807
|
+
"fresh",
|
|
17808
|
+
"new",
|
|
17809
|
+
"quit",
|
|
17810
|
+
"rename",
|
|
17811
|
+
"rename-chat",
|
|
17812
|
+
"reset",
|
|
17813
|
+
"resume",
|
|
17814
|
+
"rewind",
|
|
17815
|
+
"session",
|
|
17816
|
+
"sessions",
|
|
17817
|
+
// Desktop-owned configuration
|
|
17818
|
+
"autocompact",
|
|
17819
|
+
"color",
|
|
17820
|
+
"config",
|
|
17821
|
+
"effort",
|
|
17822
|
+
"fast",
|
|
17823
|
+
"keybindings",
|
|
17824
|
+
"model",
|
|
17825
|
+
"models",
|
|
17826
|
+
"output-style",
|
|
17827
|
+
"permissions",
|
|
17828
|
+
"settings",
|
|
17829
|
+
"statusline",
|
|
17830
|
+
"terminal-setup",
|
|
17831
|
+
"theme",
|
|
17832
|
+
"vim",
|
|
17833
|
+
// Trust and approval policy
|
|
17834
|
+
"always-approve",
|
|
17835
|
+
"auto-mode-setup",
|
|
17836
|
+
// Native login
|
|
17837
|
+
"login",
|
|
17838
|
+
"logout",
|
|
17839
|
+
// Work outliving the Turn
|
|
17840
|
+
"autopilot",
|
|
17841
|
+
"background",
|
|
17842
|
+
"bg",
|
|
17843
|
+
"goal",
|
|
17844
|
+
"jobs",
|
|
17845
|
+
"loop",
|
|
17846
|
+
"multitask",
|
|
17847
|
+
"queue",
|
|
17848
|
+
"remote-control",
|
|
17849
|
+
"schedule",
|
|
17850
|
+
"steer",
|
|
17851
|
+
// Native terminal UI
|
|
17852
|
+
"copy",
|
|
17853
|
+
"debug",
|
|
17854
|
+
"feedback",
|
|
17855
|
+
"heapdump",
|
|
17856
|
+
"share",
|
|
17857
|
+
"shell",
|
|
17858
|
+
// Plugin and MCP management
|
|
17859
|
+
"marketplace",
|
|
17860
|
+
"mcp",
|
|
17861
|
+
"plugins",
|
|
17862
|
+
"reload-plugins"
|
|
17863
|
+
]);
|
|
17864
|
+
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
17865
|
+
function isExcludedLiveCommand(name, extra = {}) {
|
|
17866
|
+
const normalized = name.trim().replace(/^\//u, "");
|
|
17867
|
+
if (new Set(extra.names ?? []).has(normalized))
|
|
17868
|
+
return true;
|
|
17869
|
+
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
17870
|
+
return true;
|
|
17871
|
+
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
17872
|
+
}
|
|
17873
|
+
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
17874
|
+
if (!commandId.startsWith(idPrefix))
|
|
17875
|
+
return null;
|
|
17876
|
+
const descriptor = catalog.commands.find(({ id }) => id === commandId);
|
|
17877
|
+
if (!descriptor)
|
|
17878
|
+
return null;
|
|
17879
|
+
const text = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
17880
|
+
return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
|
|
17881
|
+
}
|
|
17882
|
+
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
17883
|
+
if (!live)
|
|
17884
|
+
return builtIns;
|
|
17885
|
+
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
17886
|
+
const ids = new Set(builtIns.commands.map(({ id }) => id));
|
|
17887
|
+
const dynamic = [];
|
|
17888
|
+
for (const command of live) {
|
|
17889
|
+
const name = command.name.trim().replace(/^\//u, "");
|
|
17890
|
+
if (!name || /\s/u.test(name))
|
|
17891
|
+
continue;
|
|
17892
|
+
if (isExcludedLiveCommand(name, exclusions))
|
|
17893
|
+
continue;
|
|
17894
|
+
const invocation = `/${name}`;
|
|
17895
|
+
const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
17896
|
+
if (invocations.has(invocation) || ids.has(id))
|
|
17897
|
+
continue;
|
|
17898
|
+
const description = command.description?.trim().slice(0, 512);
|
|
17899
|
+
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
17900
|
+
id,
|
|
17901
|
+
invocation,
|
|
17902
|
+
label: name.slice(0, 128),
|
|
17903
|
+
...description ? { description } : {},
|
|
17904
|
+
argumentMode: "text"
|
|
17905
|
+
});
|
|
17906
|
+
if (!parsed.success)
|
|
17907
|
+
continue;
|
|
17908
|
+
invocations.add(invocation);
|
|
17909
|
+
ids.add(id);
|
|
17910
|
+
dynamic.push(parsed.data);
|
|
17911
|
+
}
|
|
17912
|
+
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
17913
|
+
}
|
|
17914
|
+
|
|
17915
|
+
// ../../harness-adapter/dist/subagent-configuration.js
|
|
17916
|
+
function subagentConfiguration(value) {
|
|
17917
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
17918
|
+
return {};
|
|
17919
|
+
const row = value;
|
|
17920
|
+
const text = (value2) => typeof value2 === "string" && value2.trim() ? value2 : void 0;
|
|
17921
|
+
const model2 = row.model === "inherit" ? void 0 : text(row.model);
|
|
17922
|
+
const reasoningEffort = text(row.reasoningEffort) ?? text(row.reasoning_effort) ?? text(row.thinking);
|
|
17923
|
+
return { ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
|
|
17924
|
+
}
|
|
17925
|
+
function inheritSubagentConfiguration(child, parent) {
|
|
17926
|
+
const native = subagentConfiguration(child);
|
|
17927
|
+
const model2 = native.model ?? parent.model;
|
|
17928
|
+
const reasoningEffort = native.reasoningEffort ?? parent.reasoningEffort;
|
|
17929
|
+
const next = { ...child };
|
|
17930
|
+
delete next.model;
|
|
17931
|
+
delete next.reasoningEffort;
|
|
17932
|
+
return { ...next, ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
|
|
17933
|
+
}
|
|
17934
|
+
function configureSubagentEvent(event, parent) {
|
|
17935
|
+
const children = (states) => states.map((child) => inheritSubagentConfiguration(child, parent));
|
|
17936
|
+
if (event.type === "item.started" && event.item.type === "subagentDelegation")
|
|
17937
|
+
return { ...event, item: { ...event.item, subagents: children(event.item.subagents) } };
|
|
17938
|
+
if (event.type === "item.updated" && event.update.type === "subagents.replace")
|
|
17939
|
+
return { ...event, update: { ...event.update, subagents: children(event.update.subagents) } };
|
|
17940
|
+
if (event.type === "item.completed" && event.snapshot.item.type === "subagentDelegation")
|
|
17941
|
+
return {
|
|
17942
|
+
...event,
|
|
17943
|
+
snapshot: {
|
|
17944
|
+
...event.snapshot,
|
|
17945
|
+
item: {
|
|
17946
|
+
...event.snapshot.item,
|
|
17947
|
+
subagents: children(event.snapshot.item.subagents)
|
|
17948
|
+
}
|
|
17949
|
+
}
|
|
17950
|
+
};
|
|
17951
|
+
return event;
|
|
17952
|
+
}
|
|
17953
|
+
function configureSubagentSnapshot(snapshot, parent) {
|
|
17954
|
+
return {
|
|
17955
|
+
...snapshot,
|
|
17956
|
+
turns: snapshot.turns.map((turn) => ({
|
|
17957
|
+
...turn,
|
|
17958
|
+
items: turn.items.map((entry) => entry.item.type === "subagentDelegation" ? {
|
|
17959
|
+
...entry,
|
|
17960
|
+
item: {
|
|
17961
|
+
...entry.item,
|
|
17962
|
+
subagents: entry.item.subagents.map((child) => inheritSubagentConfiguration(child, parent))
|
|
17963
|
+
}
|
|
17964
|
+
} : entry)
|
|
17965
|
+
}))
|
|
17966
|
+
};
|
|
17967
|
+
}
|
|
17968
|
+
|
|
17969
|
+
// ../../harness-adapter/dist/usage-statistics.js
|
|
17970
|
+
import { createReadStream } from "node:fs";
|
|
17971
|
+
import { lstat, opendir } from "node:fs/promises";
|
|
17972
|
+
import path4 from "node:path";
|
|
17973
|
+
import { createInterface } from "node:readline";
|
|
17974
|
+
var MAX_SESSION_ID_LENGTH = 512;
|
|
17975
|
+
var MAX_CWD_LENGTH = 4096;
|
|
17976
|
+
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
17977
|
+
function usageSessionTitle(value) {
|
|
17978
|
+
if (typeof value !== "string")
|
|
17979
|
+
return void 0;
|
|
17980
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
17981
|
+
if (!normalized)
|
|
17982
|
+
return void 0;
|
|
17983
|
+
if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
|
|
17984
|
+
return normalized;
|
|
17985
|
+
let title = "";
|
|
17986
|
+
for (const character of normalized) {
|
|
17987
|
+
if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
|
|
17988
|
+
break;
|
|
17989
|
+
title += character;
|
|
17990
|
+
}
|
|
17991
|
+
return `${title.trimEnd()}…`;
|
|
17992
|
+
}
|
|
17993
|
+
function sessionIdOk(value) {
|
|
17994
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
17995
|
+
}
|
|
17996
|
+
function cwdOk(value) {
|
|
17997
|
+
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("\\\\"));
|
|
17998
|
+
}
|
|
17999
|
+
function withUsageSession(entry, session) {
|
|
18000
|
+
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
18001
|
+
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
18002
|
+
const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
|
|
18003
|
+
if (sessionId === void 0 && cwd === void 0)
|
|
18004
|
+
return entry;
|
|
18005
|
+
return {
|
|
18006
|
+
...entry,
|
|
18007
|
+
...sessionId !== void 0 ? { sessionId } : {},
|
|
18008
|
+
...cwd !== void 0 ? { cwd } : {},
|
|
18009
|
+
...sessionTitle !== void 0 ? { sessionTitle } : {}
|
|
18010
|
+
};
|
|
18011
|
+
}
|
|
18012
|
+
function usageEntryFromRequest(request, occurredAtMs) {
|
|
18013
|
+
if (!Number.isSafeInteger(occurredAtMs) || occurredAtMs <= 0)
|
|
18014
|
+
return null;
|
|
18015
|
+
return {
|
|
18016
|
+
id: request.requestId,
|
|
18017
|
+
occurredAtMs,
|
|
18018
|
+
...request.model !== void 0 ? { model: request.model } : {},
|
|
18019
|
+
inputTokens: request.inputTokens,
|
|
18020
|
+
...request.cachedInputTokens !== void 0 ? { cachedInputTokens: request.cachedInputTokens } : {},
|
|
18021
|
+
...request.cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens: request.cacheWriteInputTokens } : {},
|
|
18022
|
+
...request.cacheWrite1hInputTokens !== void 0 ? { cacheWrite1hInputTokens: request.cacheWrite1hInputTokens } : {},
|
|
18023
|
+
outputTokens: request.outputTokens,
|
|
18024
|
+
...request.reasoningOutputTokens !== void 0 ? { reasoningOutputTokens: request.reasoningOutputTokens } : {}
|
|
18025
|
+
};
|
|
18026
|
+
}
|
|
18027
|
+
async function jsonlUsageSources(root, maxDepth, signal) {
|
|
18028
|
+
const sources = [];
|
|
18029
|
+
const visit = async (directory, depth) => {
|
|
18030
|
+
signal.throwIfAborted();
|
|
18031
|
+
const entries = await opendir(directory).catch((error51) => {
|
|
18032
|
+
if (error51.code === "ENOENT")
|
|
18033
|
+
return null;
|
|
18034
|
+
throw error51;
|
|
18035
|
+
});
|
|
18036
|
+
if (!entries)
|
|
18037
|
+
return;
|
|
18038
|
+
for await (const entry of entries) {
|
|
18039
|
+
signal.throwIfAborted();
|
|
18040
|
+
const file2 = path4.join(directory, entry.name);
|
|
18041
|
+
if (entry.isDirectory()) {
|
|
18042
|
+
if (depth < maxDepth)
|
|
18043
|
+
await visit(file2, depth + 1);
|
|
18044
|
+
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
18045
|
+
const info = await lstat(file2).catch(() => null);
|
|
18046
|
+
if (info?.isFile() && info.size > 0) {
|
|
18047
|
+
sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
|
|
18048
|
+
}
|
|
18049
|
+
}
|
|
18050
|
+
}
|
|
18051
|
+
};
|
|
18052
|
+
await visit(root, 0);
|
|
18053
|
+
return sources;
|
|
18054
|
+
}
|
|
18055
|
+
async function* jsonlRecords(file2, marker, signal) {
|
|
18056
|
+
const lines = createInterface({
|
|
18057
|
+
input: createReadStream(file2, { encoding: "utf8", signal }),
|
|
18058
|
+
crlfDelay: Infinity
|
|
18059
|
+
});
|
|
18060
|
+
for await (const line of lines) {
|
|
18061
|
+
if (!line.includes(marker))
|
|
18062
|
+
continue;
|
|
18063
|
+
let value;
|
|
18064
|
+
try {
|
|
18065
|
+
value = JSON.parse(line);
|
|
18066
|
+
} catch {
|
|
18067
|
+
continue;
|
|
18068
|
+
}
|
|
18069
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
18070
|
+
yield value;
|
|
18071
|
+
}
|
|
18072
|
+
}
|
|
18073
|
+
}
|
|
18074
|
+
async function jsonlHeader(file2, match, signal, maxLines = 4) {
|
|
18075
|
+
const stream = createReadStream(file2, { encoding: "utf8", signal });
|
|
18076
|
+
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
18077
|
+
let seen = 0;
|
|
18078
|
+
try {
|
|
18079
|
+
for await (const line of lines) {
|
|
18080
|
+
if (++seen > maxLines)
|
|
18081
|
+
break;
|
|
18082
|
+
let value;
|
|
18083
|
+
try {
|
|
18084
|
+
value = JSON.parse(line);
|
|
18085
|
+
} catch {
|
|
18086
|
+
continue;
|
|
18087
|
+
}
|
|
18088
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
18089
|
+
const record3 = value;
|
|
18090
|
+
if (match(record3))
|
|
18091
|
+
return record3;
|
|
18092
|
+
}
|
|
18093
|
+
}
|
|
18094
|
+
return null;
|
|
18095
|
+
} finally {
|
|
18096
|
+
lines.close();
|
|
18097
|
+
stream.destroy();
|
|
18098
|
+
}
|
|
18099
|
+
}
|
|
18100
|
+
function nativeTimeMs(value) {
|
|
18101
|
+
const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
18102
|
+
return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
|
|
18103
|
+
}
|
|
18104
|
+
|
|
18105
|
+
// dist/session-import.js
|
|
18106
|
+
import { createReadStream as createReadStream2 } from "node:fs";
|
|
18107
|
+
import { opendir as opendir2, realpath, stat } from "node:fs/promises";
|
|
18108
|
+
import os2 from "node:os";
|
|
18109
|
+
import path5 from "node:path";
|
|
18110
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
18111
|
+
|
|
18112
|
+
// ../../harness-adapter/dist/session-import.js
|
|
18113
|
+
import { lstat as lstat2 } from "node:fs/promises";
|
|
18114
|
+
var SessionImportChangedError = class extends Error {
|
|
18115
|
+
constructor(message3 = "Native Session changed during discovery; refresh and retry") {
|
|
18116
|
+
super(message3);
|
|
18117
|
+
this.name = "SessionImportChangedError";
|
|
18118
|
+
}
|
|
18119
|
+
};
|
|
18120
|
+
function isMissingFileError(error51) {
|
|
18121
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
18122
|
+
}
|
|
18123
|
+
function sameFileFingerprint(left, right) {
|
|
18124
|
+
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;
|
|
18125
|
+
}
|
|
18126
|
+
var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
|
|
18127
|
+
function isStorageAccessError(error51) {
|
|
18128
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
|
|
18129
|
+
}
|
|
18130
|
+
async function optionalLstat(file2) {
|
|
18131
|
+
try {
|
|
18132
|
+
return await lstat2(file2);
|
|
18133
|
+
} catch (error51) {
|
|
18134
|
+
if (isMissingFileError(error51))
|
|
18135
|
+
return null;
|
|
18136
|
+
throw error51;
|
|
18137
|
+
}
|
|
18138
|
+
}
|
|
18139
|
+
async function readStableFiles(files, read) {
|
|
18140
|
+
const before = await Promise.all(files.map(optionalLstat));
|
|
18141
|
+
const value = await read(before);
|
|
18142
|
+
const after = await Promise.all(files.map(optionalLstat));
|
|
18143
|
+
if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
|
|
18144
|
+
throw new SessionImportChangedError();
|
|
18145
|
+
return value;
|
|
18146
|
+
}
|
|
18147
|
+
function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
|
|
18148
|
+
if (typeof value !== "string")
|
|
18149
|
+
return null;
|
|
18150
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
18151
|
+
if (!normalized)
|
|
18152
|
+
return null;
|
|
18153
|
+
if (normalized.length <= maxLength)
|
|
18154
|
+
return normalized;
|
|
18155
|
+
const characters = [...normalized];
|
|
18156
|
+
if (characters.length <= maxLength)
|
|
18157
|
+
return normalized;
|
|
18158
|
+
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
18159
|
+
}
|
|
18160
|
+
function sessionImportCandidate(input) {
|
|
18161
|
+
const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
|
|
18162
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
18163
|
+
nativeSessionId: input.nativeSessionId,
|
|
18164
|
+
cwd: input.cwd,
|
|
18165
|
+
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
18166
|
+
updatedAt: Math.floor(time3),
|
|
18167
|
+
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
18168
|
+
running: typeof input.running === "boolean" ? input.running : null
|
|
18169
|
+
});
|
|
18170
|
+
return parsed.success ? parsed.data : null;
|
|
18171
|
+
}
|
|
18172
|
+
var SessionImportScope = class {
|
|
18173
|
+
#abort = new AbortController();
|
|
18174
|
+
#options;
|
|
18175
|
+
#pending = /* @__PURE__ */ new Set();
|
|
18176
|
+
constructor(options) {
|
|
18177
|
+
this.#options = options;
|
|
18178
|
+
}
|
|
18179
|
+
#closed() {
|
|
18180
|
+
return {
|
|
18181
|
+
ok: false,
|
|
18182
|
+
error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
|
|
18183
|
+
};
|
|
18184
|
+
}
|
|
18185
|
+
read(operation) {
|
|
18186
|
+
const signal = this.#abort.signal;
|
|
18187
|
+
if (signal.aborted)
|
|
18188
|
+
return Promise.resolve(this.#closed());
|
|
18189
|
+
let started;
|
|
18190
|
+
try {
|
|
18191
|
+
started = operation(signal);
|
|
18192
|
+
} catch (error51) {
|
|
18193
|
+
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
18194
|
+
}
|
|
18195
|
+
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
18196
|
+
ok: false,
|
|
18197
|
+
error: {
|
|
18198
|
+
code: "unavailable",
|
|
18199
|
+
message: this.#options.unavailableMessage,
|
|
18200
|
+
retryable: true
|
|
18201
|
+
}
|
|
18202
|
+
}).finally(() => this.#pending.delete(request));
|
|
18203
|
+
this.#pending.add(request);
|
|
18204
|
+
return request;
|
|
18205
|
+
}
|
|
18206
|
+
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
18207
|
+
async resolve(operation) {
|
|
18208
|
+
const result = await this.read(operation);
|
|
18209
|
+
if (!result.ok)
|
|
18210
|
+
return result;
|
|
18211
|
+
return result.value ? { ok: true, value: result.value } : {
|
|
18212
|
+
ok: false,
|
|
18213
|
+
error: {
|
|
18214
|
+
code: "sessionNotFound",
|
|
18215
|
+
message: this.#options.notFoundMessage,
|
|
18216
|
+
retryable: false
|
|
18217
|
+
}
|
|
18218
|
+
};
|
|
18219
|
+
}
|
|
18220
|
+
/** Idempotent. Resolves after every started read has settled. */
|
|
18221
|
+
async close() {
|
|
18222
|
+
this.#abort.abort();
|
|
18223
|
+
await Promise.allSettled(this.#pending);
|
|
18224
|
+
}
|
|
18225
|
+
};
|
|
18226
|
+
|
|
18227
|
+
// dist/session-import.js
|
|
18228
|
+
function isRecord2(value) {
|
|
18229
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18230
|
+
}
|
|
18231
|
+
function expandDirectory(value, home) {
|
|
18232
|
+
return path5.resolve(value === "~" ? home : value.startsWith(`~${path5.sep}`) || value.startsWith("~/") ? path5.join(home, value.slice(2)) : value);
|
|
18233
|
+
}
|
|
18234
|
+
function ompSessionImportDirectory(environment) {
|
|
18235
|
+
const home = (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os2.homedir();
|
|
18236
|
+
const custom2 = environment.PI_CODING_AGENT_SESSION_DIR;
|
|
18237
|
+
if (custom2)
|
|
18238
|
+
return { directory: expandDirectory(custom2, home), flat: true };
|
|
18239
|
+
const agent = environment.PI_CODING_AGENT_DIR;
|
|
18240
|
+
return {
|
|
18241
|
+
directory: path5.join(agent ? expandDirectory(agent, home) : path5.join(home, ".omp", "agent"), "sessions"),
|
|
18242
|
+
flat: false
|
|
18243
|
+
};
|
|
18244
|
+
}
|
|
18245
|
+
function messageText(content) {
|
|
18246
|
+
if (typeof content === "string")
|
|
18247
|
+
return content;
|
|
18248
|
+
if (!Array.isArray(content))
|
|
18249
|
+
return "";
|
|
18250
|
+
return content.filter((part) => isRecord2(part) && part.type === "text" && typeof part.text === "string").map((part) => String(part.text)).join(" ");
|
|
18251
|
+
}
|
|
18252
|
+
async function readFacts(file2, signal) {
|
|
18253
|
+
const stream = createReadStream2(file2, { encoding: "utf8", signal });
|
|
18254
|
+
const lines = createInterface2({ input: stream, crlfDelay: Infinity });
|
|
18255
|
+
let header = null;
|
|
18256
|
+
let nativeTitle = null;
|
|
18257
|
+
let firstPrompt = null;
|
|
18258
|
+
let updatedAt = null;
|
|
18259
|
+
let leafHasUser = false;
|
|
18260
|
+
const hasUserAncestry = /* @__PURE__ */ new Map();
|
|
18261
|
+
try {
|
|
18262
|
+
for await (const line of lines) {
|
|
18263
|
+
signal.throwIfAborted();
|
|
18264
|
+
if (!line.trim())
|
|
18265
|
+
continue;
|
|
18266
|
+
let entry;
|
|
18267
|
+
try {
|
|
18268
|
+
entry = JSON.parse(line);
|
|
18269
|
+
} catch {
|
|
18270
|
+
continue;
|
|
18271
|
+
}
|
|
18272
|
+
if (!isRecord2(entry))
|
|
18273
|
+
continue;
|
|
18274
|
+
if (entry.type === "title") {
|
|
18275
|
+
nativeTitle = sessionImportTitle(entry.title);
|
|
18276
|
+
continue;
|
|
18277
|
+
}
|
|
18278
|
+
if (entry.type === "session") {
|
|
18279
|
+
if (header)
|
|
18280
|
+
return null;
|
|
18281
|
+
if (typeof entry.id !== "string" || entry.id.length === 0 || typeof entry.cwd !== "string" || !path5.isAbsolute(entry.cwd))
|
|
18282
|
+
return null;
|
|
18283
|
+
header = { id: entry.id, cwd: entry.cwd };
|
|
18284
|
+
continue;
|
|
18285
|
+
}
|
|
18286
|
+
if (typeof entry.id !== "string" || entry.id.length === 0)
|
|
18287
|
+
continue;
|
|
18288
|
+
const message3 = isRecord2(entry.message) ? entry.message : null;
|
|
18289
|
+
const isUser = entry.type === "message" && message3?.role === "user";
|
|
18290
|
+
if (isUser)
|
|
18291
|
+
firstPrompt ??= sessionImportTitle(messageText(message3?.content));
|
|
18292
|
+
leafHasUser = isUser || typeof entry.parentId === "string" && hasUserAncestry.get(entry.parentId) === true;
|
|
18293
|
+
hasUserAncestry.set(entry.id, leafHasUser);
|
|
18294
|
+
if (entry.type === "message" && (message3?.role === "user" || message3?.role === "assistant")) {
|
|
18295
|
+
const time3 = typeof message3.timestamp === "number" ? message3.timestamp : typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : Number.NaN;
|
|
18296
|
+
if (Number.isFinite(time3) && time3 >= 0)
|
|
18297
|
+
updatedAt = time3;
|
|
18298
|
+
}
|
|
18299
|
+
}
|
|
18300
|
+
} finally {
|
|
18301
|
+
lines.close();
|
|
18302
|
+
stream.destroy();
|
|
18303
|
+
}
|
|
18304
|
+
if (!header || !leafHasUser)
|
|
18305
|
+
return null;
|
|
18306
|
+
return {
|
|
18307
|
+
nativeSessionId: header.id,
|
|
18308
|
+
cwd: header.cwd,
|
|
18309
|
+
title: nativeTitle ?? firstPrompt,
|
|
18310
|
+
updatedAt
|
|
18311
|
+
};
|
|
18312
|
+
}
|
|
18313
|
+
var OmpSessionImport = class {
|
|
18314
|
+
#location;
|
|
18315
|
+
#scope = new SessionImportScope({
|
|
18316
|
+
closedMessage: "Omp Session import is closed",
|
|
18317
|
+
unavailableMessage: "Omp sessions could not be read; close native clients, check storage access and retry",
|
|
18318
|
+
notFoundMessage: "Omp Session is no longer importable"
|
|
18319
|
+
});
|
|
18320
|
+
constructor(environment) {
|
|
18321
|
+
this.#location = ompSessionImportDirectory(environment);
|
|
18322
|
+
}
|
|
18323
|
+
listCandidates() {
|
|
18324
|
+
return this.#scope.read(async (signal) => [...(await this.#sources(signal)).values()].flatMap((sources) => (
|
|
18325
|
+
// One identity in two files cannot be resumed unambiguously.
|
|
18326
|
+
sources.length === 1 && sources[0] ? [sources[0].candidate] : []
|
|
18327
|
+
)));
|
|
18189
18328
|
}
|
|
18190
|
-
|
|
18191
|
-
|
|
18329
|
+
resolveCandidate(nativeSessionId) {
|
|
18330
|
+
return this.#scope.resolve(async (signal) => {
|
|
18331
|
+
const sources = (await this.#sources(signal)).get(nativeSessionId);
|
|
18332
|
+
if (sources?.length !== 1 || !sources[0])
|
|
18333
|
+
return null;
|
|
18334
|
+
const source = await this.#source(sources[0].file, signal);
|
|
18335
|
+
return source?.nativeRef.nativeSessionId === nativeSessionId ? { candidate: source.candidate, nativeRef: source.nativeRef } : null;
|
|
18336
|
+
});
|
|
18192
18337
|
}
|
|
18193
|
-
|
|
18194
|
-
|
|
18338
|
+
close() {
|
|
18339
|
+
return this.#scope.close();
|
|
18195
18340
|
}
|
|
18196
|
-
|
|
18197
|
-
|
|
18341
|
+
async #sessionFiles(signal) {
|
|
18342
|
+
const { directory, flat } = this.#location;
|
|
18343
|
+
const info = await optionalLstat(directory);
|
|
18344
|
+
if (!info)
|
|
18345
|
+
return [];
|
|
18346
|
+
if (!info.isDirectory())
|
|
18347
|
+
throw new Error("Omp Session store is not a directory");
|
|
18348
|
+
const files = [];
|
|
18349
|
+
const visit = async (current, projectLevel) => {
|
|
18350
|
+
const entries = await opendir2(current).catch((error51) => {
|
|
18351
|
+
if (isMissingFileError(error51))
|
|
18352
|
+
return null;
|
|
18353
|
+
throw error51;
|
|
18354
|
+
});
|
|
18355
|
+
if (!entries)
|
|
18356
|
+
return;
|
|
18357
|
+
for await (const entry of entries) {
|
|
18358
|
+
signal.throwIfAborted();
|
|
18359
|
+
if (projectLevel && entry.isDirectory())
|
|
18360
|
+
await visit(path5.join(current, entry.name), false);
|
|
18361
|
+
else if (!projectLevel && entry.isFile() && entry.name.endsWith(".jsonl"))
|
|
18362
|
+
files.push(path5.join(current, entry.name));
|
|
18363
|
+
}
|
|
18364
|
+
};
|
|
18365
|
+
await visit(directory, !flat);
|
|
18366
|
+
return files;
|
|
18198
18367
|
}
|
|
18199
|
-
|
|
18200
|
-
|
|
18368
|
+
/** Session ID to every readable file claiming it. Files changing under the read are skipped. */
|
|
18369
|
+
async #sources(signal) {
|
|
18370
|
+
const found = /* @__PURE__ */ new Map();
|
|
18371
|
+
for (const file2 of await this.#sessionFiles(signal)) {
|
|
18372
|
+
signal.throwIfAborted();
|
|
18373
|
+
try {
|
|
18374
|
+
const source = await this.#source(file2, signal);
|
|
18375
|
+
if (!source)
|
|
18376
|
+
continue;
|
|
18377
|
+
const sources = found.get(source.nativeRef.nativeSessionId) ?? [];
|
|
18378
|
+
sources.push(source);
|
|
18379
|
+
found.set(source.nativeRef.nativeSessionId, sources);
|
|
18380
|
+
} catch (error51) {
|
|
18381
|
+
if (!(error51 instanceof SessionImportChangedError))
|
|
18382
|
+
throw error51;
|
|
18383
|
+
}
|
|
18384
|
+
}
|
|
18385
|
+
return found;
|
|
18201
18386
|
}
|
|
18202
|
-
|
|
18203
|
-
|
|
18204
|
-
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18235
|
-
|
|
18236
|
-
|
|
18237
|
-
|
|
18238
|
-
|
|
18239
|
-
|
|
18240
|
-
"auto-mode-setup",
|
|
18241
|
-
// Native login
|
|
18242
|
-
"login",
|
|
18243
|
-
"logout",
|
|
18244
|
-
// Work outliving the Turn
|
|
18245
|
-
"autopilot",
|
|
18246
|
-
"background",
|
|
18247
|
-
"bg",
|
|
18248
|
-
"goal",
|
|
18249
|
-
"jobs",
|
|
18250
|
-
"loop",
|
|
18251
|
-
"multitask",
|
|
18252
|
-
"queue",
|
|
18253
|
-
"remote-control",
|
|
18254
|
-
"schedule",
|
|
18255
|
-
"steer",
|
|
18256
|
-
// Native terminal UI
|
|
18257
|
-
"copy",
|
|
18258
|
-
"debug",
|
|
18259
|
-
"feedback",
|
|
18260
|
-
"heapdump",
|
|
18261
|
-
"share",
|
|
18262
|
-
"shell",
|
|
18263
|
-
// Plugin and MCP management
|
|
18264
|
-
"marketplace",
|
|
18265
|
-
"mcp",
|
|
18266
|
-
"plugins",
|
|
18267
|
-
"reload-plugins"
|
|
18268
|
-
]);
|
|
18269
|
-
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
18270
|
-
function isExcludedLiveCommand(name, kind, extra = {}) {
|
|
18271
|
-
const normalized = name.trim().replace(/^\//u, "");
|
|
18272
|
-
if (new Set(extra.names ?? []).has(normalized))
|
|
18273
|
-
return true;
|
|
18274
|
-
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
18275
|
-
return true;
|
|
18276
|
-
if (kind === "skill")
|
|
18277
|
-
return false;
|
|
18278
|
-
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
18279
|
-
}
|
|
18280
|
-
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
18281
|
-
if (!commandId.startsWith(idPrefix))
|
|
18282
|
-
return null;
|
|
18283
|
-
const descriptor = catalog.commands.find(({ id }) => id === commandId);
|
|
18284
|
-
if (!descriptor)
|
|
18285
|
-
return null;
|
|
18286
|
-
const text = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
18287
|
-
return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
|
|
18288
|
-
}
|
|
18289
|
-
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
18290
|
-
if (!live)
|
|
18291
|
-
return builtIns;
|
|
18292
|
-
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
18293
|
-
const ids = new Set(builtIns.commands.map(({ id }) => id));
|
|
18294
|
-
const dynamic = [];
|
|
18295
|
-
for (const command of live) {
|
|
18296
|
-
const name = command.name.trim().replace(/^\//u, "");
|
|
18297
|
-
if (!name || /\s/u.test(name))
|
|
18298
|
-
continue;
|
|
18299
|
-
if (isExcludedLiveCommand(name, command.kind, exclusions))
|
|
18300
|
-
continue;
|
|
18301
|
-
const invocation = `/${name}`;
|
|
18302
|
-
const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
18303
|
-
if (invocations.has(invocation) || ids.has(id))
|
|
18304
|
-
continue;
|
|
18305
|
-
const description = command.description?.trim().slice(0, 512);
|
|
18306
|
-
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
18307
|
-
id,
|
|
18308
|
-
invocation,
|
|
18309
|
-
label: name.slice(0, 128),
|
|
18310
|
-
...description ? { description } : {},
|
|
18311
|
-
argumentMode: "text",
|
|
18312
|
-
kind: command.kind
|
|
18387
|
+
async #source(file2, signal) {
|
|
18388
|
+
signal.throwIfAborted();
|
|
18389
|
+
return readStableFiles([file2], async ([info]) => {
|
|
18390
|
+
if (!info?.isFile() || info.size === 0)
|
|
18391
|
+
return null;
|
|
18392
|
+
try {
|
|
18393
|
+
const facts = await readFacts(file2, signal);
|
|
18394
|
+
if (!facts)
|
|
18395
|
+
return null;
|
|
18396
|
+
const cwd = await realpath(facts.cwd);
|
|
18397
|
+
if (!(await stat(cwd)).isDirectory())
|
|
18398
|
+
return null;
|
|
18399
|
+
const candidate = sessionImportCandidate({
|
|
18400
|
+
nativeSessionId: facts.nativeSessionId,
|
|
18401
|
+
cwd,
|
|
18402
|
+
title: facts.title,
|
|
18403
|
+
updatedAt: facts.updatedAt ?? info.mtimeMs
|
|
18404
|
+
// OMP has no cross-process activity marker: idleness cannot be established.
|
|
18405
|
+
});
|
|
18406
|
+
if (!candidate)
|
|
18407
|
+
return null;
|
|
18408
|
+
return {
|
|
18409
|
+
file: file2,
|
|
18410
|
+
candidate,
|
|
18411
|
+
// Resume needs the file itself: OMP is started with `--session <file>`.
|
|
18412
|
+
nativeRef: nativeSessionRefSchema.parse({
|
|
18413
|
+
harnessId: "omp",
|
|
18414
|
+
nativeSessionId: facts.nativeSessionId,
|
|
18415
|
+
locator: { sessionFile: await realpath(file2) },
|
|
18416
|
+
formatVersion: 1
|
|
18417
|
+
})
|
|
18418
|
+
};
|
|
18419
|
+
} catch (error51) {
|
|
18420
|
+
signal.throwIfAborted();
|
|
18421
|
+
if (isStorageAccessError(error51))
|
|
18422
|
+
throw error51;
|
|
18423
|
+
return null;
|
|
18424
|
+
}
|
|
18313
18425
|
});
|
|
18314
|
-
if (!parsed.success)
|
|
18315
|
-
continue;
|
|
18316
|
-
invocations.add(invocation);
|
|
18317
|
-
ids.add(id);
|
|
18318
|
-
dynamic.push(parsed.data);
|
|
18319
18426
|
}
|
|
18320
|
-
|
|
18321
|
-
}
|
|
18427
|
+
};
|
|
18322
18428
|
|
|
18323
18429
|
// dist/omp-model-catalog.js
|
|
18324
18430
|
var OMP_MODEL_REF_PREFIX = "omp-model-v1.";
|
|
@@ -18878,7 +18984,7 @@ var ompDiscoverySpec = {
|
|
|
18878
18984
|
"/opt/homebrew/bin",
|
|
18879
18985
|
"/usr/local/bin"
|
|
18880
18986
|
],
|
|
18881
|
-
windows: ["${APPDATA}/npm", "~/.local/bin", VERSION_MANAGER_ROOTS]
|
|
18987
|
+
windows: ["${APPDATA}/npm", "${LOCALAPPDATA}/omp", "~/.local/bin", VERSION_MANAGER_ROOTS]
|
|
18882
18988
|
}
|
|
18883
18989
|
};
|
|
18884
18990
|
function resolveOmpExecutable(input, dependencies = {}) {
|
|
@@ -18920,10 +19026,9 @@ function parseOmpAvailableCommands(value) {
|
|
|
18920
19026
|
});
|
|
18921
19027
|
}
|
|
18922
19028
|
function ompLiveCommands(native) {
|
|
18923
|
-
return native.filter(({ source, name }) => source !== "builtin" || name === "context").map((command) => ({
|
|
19029
|
+
return native.filter(({ source, name }) => source !== "skill" && (source !== "builtin" || name === "context")).map((command) => ({
|
|
18924
19030
|
name: command.name,
|
|
18925
|
-
description: command.description
|
|
18926
|
-
kind: command.source === "skill" ? "skill" : "command"
|
|
19031
|
+
description: command.description
|
|
18927
19032
|
}));
|
|
18928
19033
|
}
|
|
18929
19034
|
|
|
@@ -19135,6 +19240,9 @@ var OmpRpcUnsupportedCommandError = class extends Error {
|
|
|
19135
19240
|
this.name = "OmpRpcUnsupportedCommandError";
|
|
19136
19241
|
}
|
|
19137
19242
|
};
|
|
19243
|
+
function hasTurnCompletion(active) {
|
|
19244
|
+
return active.terminalEnd || active.localResult !== null && !active.sawAgentStart;
|
|
19245
|
+
}
|
|
19138
19246
|
var textDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
19139
19247
|
function isRecord8(value) {
|
|
19140
19248
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -19191,9 +19299,9 @@ function parseSessionStreaming(response) {
|
|
|
19191
19299
|
}
|
|
19192
19300
|
return isStreaming;
|
|
19193
19301
|
}
|
|
19194
|
-
function
|
|
19302
|
+
function sessionSettled(response, completed) {
|
|
19195
19303
|
const data = sessionStateData(response);
|
|
19196
|
-
return !parseSessionStreaming(response) && (data.isSettled === true || data.isSettled === void 0 &&
|
|
19304
|
+
return !parseSessionStreaming(response) && (data.isSettled === true || data.isSettled === void 0 && completed) && data.isCompacting !== true && data.hasPendingAsyncWork !== true && !(typeof data.queuedMessageCount === "number" && data.queuedMessageCount > 0);
|
|
19197
19305
|
}
|
|
19198
19306
|
function parseAvailableModels(response) {
|
|
19199
19307
|
const data = isRecord8(response.data) ? response.data : null;
|
|
@@ -19425,6 +19533,9 @@ var OmpRpcSession = class {
|
|
|
19425
19533
|
child.stderr.on("data", (chunk) => {
|
|
19426
19534
|
this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
|
|
19427
19535
|
});
|
|
19536
|
+
child.stdin.on("error", (error51) => {
|
|
19537
|
+
this.#fail(new OmpRpcFaultError("processExited", `Omp RPC stdin closed: ${error51.message}`, this.stderrTail));
|
|
19538
|
+
});
|
|
19428
19539
|
child.once("error", (error51) => {
|
|
19429
19540
|
const kind = isRecord8(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
|
|
19430
19541
|
this.#fail(new OmpRpcFaultError(kind, `Omp RPC failed to start: ${error51.message}`, this.stderrTail));
|
|
@@ -19671,7 +19782,10 @@ var OmpRpcSession = class {
|
|
|
19671
19782
|
tools: /* @__PURE__ */ new Map(),
|
|
19672
19783
|
interactions: /* @__PURE__ */ new Map(),
|
|
19673
19784
|
settlement: "pending",
|
|
19785
|
+
settledNotice: false,
|
|
19786
|
+
settlementRecheck: null,
|
|
19674
19787
|
terminalEnd: false,
|
|
19788
|
+
sawAgentStart: false,
|
|
19675
19789
|
cancellation: "none",
|
|
19676
19790
|
cancellationTimeout: null,
|
|
19677
19791
|
cancellationRecheck: null,
|
|
@@ -19881,12 +19995,21 @@ var OmpRpcSession = class {
|
|
|
19881
19995
|
if (this.#handleSubagentFrame(active, value))
|
|
19882
19996
|
return;
|
|
19883
19997
|
this.#observeUsage(value);
|
|
19884
|
-
if (value.type === "agent_start" && active)
|
|
19998
|
+
if (value.type === "agent_start" && active) {
|
|
19885
19999
|
active.terminalEnd = false;
|
|
20000
|
+
active.sawAgentStart = true;
|
|
20001
|
+
}
|
|
19886
20002
|
if ((value.type === "session_settled" || value.type === "agent_start") && active?.cancellation === "accepted") {
|
|
19887
20003
|
void this.#confirmCancelledTurn(active);
|
|
19888
20004
|
return;
|
|
19889
20005
|
}
|
|
20006
|
+
if (value.type === "session_settled") {
|
|
20007
|
+
if (active && hasTurnCompletion(active)) {
|
|
20008
|
+
active.settledNotice = true;
|
|
20009
|
+
void this.#confirmSettledTurn(active);
|
|
20010
|
+
}
|
|
20011
|
+
return;
|
|
20012
|
+
}
|
|
19890
20013
|
if (!active) {
|
|
19891
20014
|
if (value.type === "extension_ui_request" && this.#isBlockingInteraction(value)) {
|
|
19892
20015
|
this.#fail(new OmpRpcFaultError("protocolError", "Omp RPC requested blocking Extension UI outside an active Turn"));
|
|
@@ -19981,9 +20104,6 @@ var OmpRpcSession = class {
|
|
|
19981
20104
|
void this.#confirmCancelledTurn(active);
|
|
19982
20105
|
return;
|
|
19983
20106
|
}
|
|
19984
|
-
if (active.settlement !== "pending")
|
|
19985
|
-
return;
|
|
19986
|
-
active.settlement = "confirming";
|
|
19987
20107
|
void this.#confirmSettledTurn(active);
|
|
19988
20108
|
}
|
|
19989
20109
|
}
|
|
@@ -20035,6 +20155,7 @@ var OmpRpcSession = class {
|
|
|
20035
20155
|
const description = nonBlankString(payload.description) ? payload.description : nonBlankString(payload.agent) ? `${payload.agent} delegation` : "Subagent delegation";
|
|
20036
20156
|
emit?.({
|
|
20037
20157
|
type: "subagent.started",
|
|
20158
|
+
...subagentConfiguration(payload),
|
|
20038
20159
|
callId,
|
|
20039
20160
|
nativeSubagentId,
|
|
20040
20161
|
description,
|
|
@@ -20067,6 +20188,8 @@ var OmpRpcSession = class {
|
|
|
20067
20188
|
const resultSummary = recentOutput.at(-1);
|
|
20068
20189
|
emit?.({
|
|
20069
20190
|
type: "subagent.updated",
|
|
20191
|
+
...subagentConfiguration(payload),
|
|
20192
|
+
...subagentConfiguration(progress),
|
|
20070
20193
|
callId,
|
|
20071
20194
|
nativeSubagentId,
|
|
20072
20195
|
status,
|
|
@@ -20301,7 +20424,7 @@ var OmpRpcSession = class {
|
|
|
20301
20424
|
throw new OmpRpcFaultError("protocolError", "Omp cancelled Session reload changed its identity or configuration");
|
|
20302
20425
|
}
|
|
20303
20426
|
}
|
|
20304
|
-
if (!
|
|
20427
|
+
if (!sessionSettled(response, active.terminalEnd)) {
|
|
20305
20428
|
active.settlement = "pending";
|
|
20306
20429
|
active.cancellationRecheck = setTimeout(() => {
|
|
20307
20430
|
active.cancellationRecheck = null;
|
|
@@ -20325,10 +20448,15 @@ var OmpRpcSession = class {
|
|
|
20325
20448
|
if (this.#activeTurn !== active || active.settlement !== "pending")
|
|
20326
20449
|
return;
|
|
20327
20450
|
active.localResult = result;
|
|
20328
|
-
active.settlement = "confirming";
|
|
20329
20451
|
void this.#confirmSettledTurn(active);
|
|
20330
20452
|
}
|
|
20331
20453
|
async #confirmSettledTurn(active) {
|
|
20454
|
+
if (this.#activeTurn !== active || active.settlement !== "pending" || active.cancellation !== "none" || !hasTurnCompletion(active))
|
|
20455
|
+
return;
|
|
20456
|
+
if (active.settlementRecheck)
|
|
20457
|
+
clearTimeout(active.settlementRecheck);
|
|
20458
|
+
active.settlementRecheck = null;
|
|
20459
|
+
active.settlement = "confirming";
|
|
20332
20460
|
try {
|
|
20333
20461
|
const response = await this.#send("get_state", {});
|
|
20334
20462
|
const state = parseSessionState(response);
|
|
@@ -20340,8 +20468,21 @@ var OmpRpcSession = class {
|
|
|
20340
20468
|
void this.#confirmCancelledTurn(active);
|
|
20341
20469
|
return;
|
|
20342
20470
|
}
|
|
20343
|
-
if (
|
|
20344
|
-
|
|
20471
|
+
if (!hasTurnCompletion(active)) {
|
|
20472
|
+
active.settlement = "pending";
|
|
20473
|
+
active.settledNotice = false;
|
|
20474
|
+
return;
|
|
20475
|
+
}
|
|
20476
|
+
if (!sessionSettled(response, hasTurnCompletion(active))) {
|
|
20477
|
+
active.settlement = "pending";
|
|
20478
|
+
if (active.settledNotice) {
|
|
20479
|
+
active.settledNotice = false;
|
|
20480
|
+
active.settlementRecheck = setTimeout(() => {
|
|
20481
|
+
active.settlementRecheck = null;
|
|
20482
|
+
void this.#confirmSettledTurn(active);
|
|
20483
|
+
}, 50);
|
|
20484
|
+
}
|
|
20485
|
+
return;
|
|
20345
20486
|
}
|
|
20346
20487
|
this.#state = state;
|
|
20347
20488
|
active.settlement = "confirmed";
|
|
@@ -20357,6 +20498,9 @@ var OmpRpcSession = class {
|
|
|
20357
20498
|
if (this.#activeTurn !== active || active.settlement !== "confirmed" || active.cancellation === "requesting") {
|
|
20358
20499
|
return;
|
|
20359
20500
|
}
|
|
20501
|
+
if (active.settlementRecheck)
|
|
20502
|
+
clearTimeout(active.settlementRecheck);
|
|
20503
|
+
active.settlementRecheck = null;
|
|
20360
20504
|
if (active.cancellationTimeout)
|
|
20361
20505
|
clearTimeout(active.cancellationTimeout);
|
|
20362
20506
|
active.cancellationTimeout = null;
|
|
@@ -20518,6 +20662,8 @@ var OmpRpcSession = class {
|
|
|
20518
20662
|
const active = this.#activeTurn;
|
|
20519
20663
|
if (!active)
|
|
20520
20664
|
return;
|
|
20665
|
+
if (active.settlementRecheck)
|
|
20666
|
+
clearTimeout(active.settlementRecheck);
|
|
20521
20667
|
if (active.cancellationTimeout)
|
|
20522
20668
|
clearTimeout(active.cancellationTimeout);
|
|
20523
20669
|
if (active.cancellationRecheck)
|
|
@@ -21292,6 +21438,7 @@ var OmpSubagentLifecycle = class {
|
|
|
21292
21438
|
subagentId: event.nativeSubagentId,
|
|
21293
21439
|
nativeSubagentId: event.nativeSubagentId,
|
|
21294
21440
|
description: event.description,
|
|
21441
|
+
...subagentConfiguration(event),
|
|
21295
21442
|
...event.role ? { role: event.role } : {},
|
|
21296
21443
|
background: event.background,
|
|
21297
21444
|
status: "running"
|
|
@@ -21316,6 +21463,7 @@ var OmpSubagentLifecycle = class {
|
|
|
21316
21463
|
throw new Error("Omp Subagent delegation has no Agent state");
|
|
21317
21464
|
const subagent = {
|
|
21318
21465
|
...current,
|
|
21466
|
+
...subagentConfiguration(event),
|
|
21319
21467
|
status: event.status === "interrupted" ? "interrupted" : event.status,
|
|
21320
21468
|
...event.description ? { description: event.description } : {},
|
|
21321
21469
|
...event.resultSummary ? { resultSummary: event.resultSummary } : {},
|
|
@@ -21866,7 +22014,19 @@ var OmpHarnessSession = class {
|
|
|
21866
22014
|
...event.resultSummary ? { resultSummary: event.resultSummary } : {}
|
|
21867
22015
|
});
|
|
21868
22016
|
}
|
|
22017
|
+
#subagentConfiguration() {
|
|
22018
|
+
const state = this.#state;
|
|
22019
|
+
const model2 = state.effectiveModel ? decodeOmpModelRef(state.effectiveModel).id : void 0;
|
|
22020
|
+
return {
|
|
22021
|
+
...model2 ? { model: model2 } : {},
|
|
22022
|
+
...state.effectiveThinkingOptionId ? { reasoningEffort: state.effectiveThinkingOptionId } : {}
|
|
22023
|
+
};
|
|
22024
|
+
}
|
|
21869
22025
|
async readSnapshot() {
|
|
22026
|
+
const result = await this.#readSnapshot();
|
|
22027
|
+
return result.ok ? { ok: true, value: configureSubagentSnapshot(result.value, this.#subagentConfiguration()) } : result;
|
|
22028
|
+
}
|
|
22029
|
+
async #readSnapshot() {
|
|
21870
22030
|
if (this.#phase !== "open" && this.#phase !== "faulted") {
|
|
21871
22031
|
return { ok: false, error: invalidState("Omp Session is not open") };
|
|
21872
22032
|
}
|
|
@@ -23053,6 +23213,7 @@ var OmpHarnessSession = class {
|
|
|
23053
23213
|
}
|
|
23054
23214
|
}
|
|
23055
23215
|
#event(event) {
|
|
23216
|
+
event = configureSubagentEvent(event, this.#subagentConfiguration());
|
|
23056
23217
|
this.#channel.emit({ kind: "event", event });
|
|
23057
23218
|
}
|
|
23058
23219
|
#newItemId() {
|