@codexhost/cli-linux-arm64 0.18.0 → 0.19.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 +59 -2
- package/app/console-web.js +76 -4
- package/app/desktop-controller.mjs +274 -11
- package/app/host-runtime.mjs +12322 -2469
- 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 +392 -269
- 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 +788 -627
- package/app/plugins/opencode/plugin.mjs +59 -2
- package/app/plugins/pi/plugin.mjs +899 -773
- 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 +657 -270
- package/app/web/assets/index-BNQIOOHE.css +1 -0
- package/app/web/assets/index-Feo4BkqN.js +199 -0
- package/app/web/codexhost-settings.js +76 -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 +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 +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 +2339 -1514
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-C0aXz2jD.js +0 -199
- 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, {
|
|
@@ -15647,6 +15501,10 @@ var CLIENT_CHANNEL_VERSION = 1;
|
|
|
15647
15501
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
15648
15502
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
15649
15503
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
15504
|
+
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
15505
|
+
var clientThreadTreeSchema = external_exports.object({
|
|
15506
|
+
parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
|
|
15507
|
+
}).strict();
|
|
15650
15508
|
var clientProjectlessWorkspaceSchema = external_exports.object({
|
|
15651
15509
|
prompt: external_exports.string().max(16384).optional()
|
|
15652
15510
|
}).strict();
|
|
@@ -15663,6 +15521,11 @@ var clientChannelCursorSchema = external_exports.object({
|
|
|
15663
15521
|
sequence: external_exports.number().int().nonnegative()
|
|
15664
15522
|
});
|
|
15665
15523
|
var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
15524
|
+
external_exports.object({
|
|
15525
|
+
type: external_exports.literal("skills-changed"),
|
|
15526
|
+
cursor: clientChannelCursorSchema,
|
|
15527
|
+
cwd: external_exports.string().optional()
|
|
15528
|
+
}),
|
|
15666
15529
|
external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
|
|
15667
15530
|
external_exports.object({
|
|
15668
15531
|
type: external_exports.literal("preferences-changed"),
|
|
@@ -15860,6 +15723,28 @@ var voiceTranscribeResultSchema = external_exports.discriminatedUnion("ok", [
|
|
|
15860
15723
|
external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
|
|
15861
15724
|
]);
|
|
15862
15725
|
|
|
15726
|
+
// ../../shared-contracts/dist/skills.js
|
|
15727
|
+
var skillsListParamsSchema = external_exports.object({
|
|
15728
|
+
threadId: hostThreadIdSchema.optional(),
|
|
15729
|
+
cwd: external_exports.string().min(1).optional()
|
|
15730
|
+
}).strict().refine((params) => !(params.threadId && params.cwd), {
|
|
15731
|
+
message: "Specify threadId or cwd, not both"
|
|
15732
|
+
});
|
|
15733
|
+
var librarySkillSchema = external_exports.object({
|
|
15734
|
+
name: external_exports.string().min(1).regex(/^[^\s[\]]+$/u),
|
|
15735
|
+
description: external_exports.string().optional(),
|
|
15736
|
+
path: external_exports.string().min(1),
|
|
15737
|
+
scope: external_exports.enum(["project", "global"]),
|
|
15738
|
+
source: external_exports.string().min(1)
|
|
15739
|
+
}).strict();
|
|
15740
|
+
var skillsListResultSchema = external_exports.object({
|
|
15741
|
+
revision: external_exports.number().int().nonnegative(),
|
|
15742
|
+
complete: external_exports.boolean(),
|
|
15743
|
+
skills: external_exports.array(librarySkillSchema),
|
|
15744
|
+
warnings: external_exports.array(external_exports.string()).optional()
|
|
15745
|
+
}).strict();
|
|
15746
|
+
var skillsChangedParamsSchema = external_exports.object({ cwd: external_exports.string().min(1).optional() }).strict();
|
|
15747
|
+
|
|
15863
15748
|
// ../../shared-contracts/dist/web-access-tokens.js
|
|
15864
15749
|
var webNetworkAccessUrlSchema = external_exports.object({
|
|
15865
15750
|
/**
|
|
@@ -15965,8 +15850,8 @@ var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
|
|
|
15965
15850
|
var delegationReadParamsSchema = external_exports.strictObject({
|
|
15966
15851
|
threadId: external_exports.string().min(1).max(1024),
|
|
15967
15852
|
view: external_exports.enum(["result", "messages"]),
|
|
15968
|
-
|
|
15969
|
-
|
|
15853
|
+
from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
|
|
15854
|
+
to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
|
|
15970
15855
|
});
|
|
15971
15856
|
|
|
15972
15857
|
// ../../shared-contracts/dist/credential-imports.js
|
|
@@ -16919,6 +16804,17 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
16919
16804
|
status: updateStatusSchema.nullable()
|
|
16920
16805
|
});
|
|
16921
16806
|
|
|
16807
|
+
// ../../shared-contracts/dist/thread-watch-notice.js
|
|
16808
|
+
var THREAD_WATCH_NOTICE_OUTCOMES = [
|
|
16809
|
+
"completed",
|
|
16810
|
+
"failed",
|
|
16811
|
+
"interrupted",
|
|
16812
|
+
"timedOut",
|
|
16813
|
+
"unreadable",
|
|
16814
|
+
"notFound"
|
|
16815
|
+
];
|
|
16816
|
+
var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
|
|
16817
|
+
|
|
16922
16818
|
// ../../shared-contracts/dist/remote-runtime.js
|
|
16923
16819
|
var remoteUpdatePhaseSchema = external_exports.enum([
|
|
16924
16820
|
"idle",
|
|
@@ -16966,6 +16862,14 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
16966
16862
|
archived: external_exports.boolean()
|
|
16967
16863
|
}),
|
|
16968
16864
|
external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
|
|
16865
|
+
external_exports.strictObject({
|
|
16866
|
+
kind: external_exports.literal("configure"),
|
|
16867
|
+
...thread,
|
|
16868
|
+
epoch: identity,
|
|
16869
|
+
modelId: identity.optional(),
|
|
16870
|
+
thinkingOptionId: identity.optional(),
|
|
16871
|
+
permissionModeId: identity.optional()
|
|
16872
|
+
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
|
|
16969
16873
|
external_exports.strictObject({
|
|
16970
16874
|
kind: external_exports.literal("prompt"),
|
|
16971
16875
|
...thread,
|
|
@@ -17038,6 +16942,13 @@ var remoteConnectionsReplySchema = external_exports.union([
|
|
|
17038
16942
|
external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
|
|
17039
16943
|
]);
|
|
17040
16944
|
|
|
16945
|
+
// ../../shared-contracts/dist/thread-title.js
|
|
16946
|
+
var threadTitleInputSchema = external_exports.strictObject({
|
|
16947
|
+
prompt: external_exports.string().trim().min(1).max(2e3),
|
|
16948
|
+
cwd: external_exports.string().max(4096).nullable()
|
|
16949
|
+
});
|
|
16950
|
+
var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
|
|
16951
|
+
|
|
17041
16952
|
// ../../shared-contracts/dist/web-ui-extensions.js
|
|
17042
16953
|
var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
|
|
17043
16954
|
var localizedTextSchema2 = external_exports.union([
|
|
@@ -17081,343 +16992,27 @@ var webUiExtensionRemoveSchema = external_exports.object({ id: webUiExtensionIdS
|
|
|
17081
16992
|
// ../../shared-contracts/dist/index.js
|
|
17082
16993
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
17083
16994
|
|
|
17084
|
-
// ../../harness-adapter/dist/
|
|
17085
|
-
|
|
17086
|
-
|
|
17087
|
-
super(message3);
|
|
17088
|
-
this.name = "SessionImportChangedError";
|
|
17089
|
-
}
|
|
17090
|
-
};
|
|
17091
|
-
function isMissingFileError(error51) {
|
|
17092
|
-
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
17093
|
-
}
|
|
17094
|
-
function sameFileFingerprint(left, right) {
|
|
17095
|
-
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;
|
|
17096
|
-
}
|
|
17097
|
-
var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
|
|
17098
|
-
function isStorageAccessError(error51) {
|
|
17099
|
-
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
|
|
17100
|
-
}
|
|
17101
|
-
async function optionalLstat(file2) {
|
|
17102
|
-
try {
|
|
17103
|
-
return await lstat2(file2);
|
|
17104
|
-
} catch (error51) {
|
|
17105
|
-
if (isMissingFileError(error51))
|
|
17106
|
-
return null;
|
|
17107
|
-
throw error51;
|
|
17108
|
-
}
|
|
17109
|
-
}
|
|
17110
|
-
async function readStableFiles(files, read) {
|
|
17111
|
-
const before = await Promise.all(files.map(optionalLstat));
|
|
17112
|
-
const value = await read(before);
|
|
17113
|
-
const after = await Promise.all(files.map(optionalLstat));
|
|
17114
|
-
if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
|
|
17115
|
-
throw new SessionImportChangedError();
|
|
17116
|
-
return value;
|
|
16995
|
+
// ../../harness-adapter/dist/approval.js
|
|
16996
|
+
function invalidRequest(message3) {
|
|
16997
|
+
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17117
16998
|
}
|
|
17118
|
-
function
|
|
17119
|
-
|
|
17120
|
-
return null;
|
|
17121
|
-
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
17122
|
-
if (!normalized)
|
|
17123
|
-
return null;
|
|
17124
|
-
if (normalized.length <= maxLength)
|
|
17125
|
-
return normalized;
|
|
17126
|
-
const characters = [...normalized];
|
|
17127
|
-
if (characters.length <= maxLength)
|
|
17128
|
-
return normalized;
|
|
17129
|
-
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
16999
|
+
function validateHostApprovalResponse(interaction, response) {
|
|
17000
|
+
return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
17130
17001
|
}
|
|
17131
|
-
|
|
17132
|
-
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
cwd: input.cwd,
|
|
17136
|
-
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
17137
|
-
updatedAt: Math.floor(time3),
|
|
17138
|
-
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
17139
|
-
running: typeof input.running === "boolean" ? input.running : null
|
|
17140
|
-
});
|
|
17141
|
-
return parsed.success ? parsed.data : null;
|
|
17002
|
+
|
|
17003
|
+
// ../../harness-adapter/dist/question.js
|
|
17004
|
+
function invalidRequest2(message3) {
|
|
17005
|
+
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17142
17006
|
}
|
|
17143
|
-
|
|
17144
|
-
|
|
17145
|
-
|
|
17146
|
-
|
|
17147
|
-
constructor(options) {
|
|
17148
|
-
this.#options = options;
|
|
17007
|
+
function validateHostQuestionResponse(interaction, response) {
|
|
17008
|
+
const questionIds = new Set(interaction.questions.map(({ id }) => id));
|
|
17009
|
+
if (response.cancelled) {
|
|
17010
|
+
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
17149
17011
|
}
|
|
17150
|
-
|
|
17151
|
-
|
|
17152
|
-
|
|
17153
|
-
|
|
17154
|
-
};
|
|
17155
|
-
}
|
|
17156
|
-
read(operation) {
|
|
17157
|
-
const signal = this.#abort.signal;
|
|
17158
|
-
if (signal.aborted)
|
|
17159
|
-
return Promise.resolve(this.#closed());
|
|
17160
|
-
let started;
|
|
17161
|
-
try {
|
|
17162
|
-
started = operation(signal);
|
|
17163
|
-
} catch (error51) {
|
|
17164
|
-
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
17165
|
-
}
|
|
17166
|
-
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
17167
|
-
ok: false,
|
|
17168
|
-
error: {
|
|
17169
|
-
code: "unavailable",
|
|
17170
|
-
message: this.#options.unavailableMessage,
|
|
17171
|
-
retryable: true
|
|
17172
|
-
}
|
|
17173
|
-
}).finally(() => this.#pending.delete(request));
|
|
17174
|
-
this.#pending.add(request);
|
|
17175
|
-
return request;
|
|
17176
|
-
}
|
|
17177
|
-
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
17178
|
-
async resolve(operation) {
|
|
17179
|
-
const result = await this.read(operation);
|
|
17180
|
-
if (!result.ok)
|
|
17181
|
-
return result;
|
|
17182
|
-
return result.value ? { ok: true, value: result.value } : {
|
|
17183
|
-
ok: false,
|
|
17184
|
-
error: {
|
|
17185
|
-
code: "sessionNotFound",
|
|
17186
|
-
message: this.#options.notFoundMessage,
|
|
17187
|
-
retryable: false
|
|
17188
|
-
}
|
|
17189
|
-
};
|
|
17190
|
-
}
|
|
17191
|
-
/** Idempotent. Resolves after every started read has settled. */
|
|
17192
|
-
async close() {
|
|
17193
|
-
this.#abort.abort();
|
|
17194
|
-
await Promise.allSettled(this.#pending);
|
|
17195
|
-
}
|
|
17196
|
-
};
|
|
17197
|
-
|
|
17198
|
-
// dist/session-import.js
|
|
17199
|
-
function isRecord(value) {
|
|
17200
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17201
|
-
}
|
|
17202
|
-
function expandDirectory(value, home) {
|
|
17203
|
-
return path5.resolve(value === "~" ? home : value.startsWith(`~${path5.sep}`) || value.startsWith("~/") ? path5.join(home, value.slice(2)) : value);
|
|
17204
|
-
}
|
|
17205
|
-
function ompSessionImportDirectory(environment) {
|
|
17206
|
-
const home = (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os2.homedir();
|
|
17207
|
-
const custom2 = environment.PI_CODING_AGENT_SESSION_DIR;
|
|
17208
|
-
if (custom2)
|
|
17209
|
-
return { directory: expandDirectory(custom2, home), flat: true };
|
|
17210
|
-
const agent = environment.PI_CODING_AGENT_DIR;
|
|
17211
|
-
return {
|
|
17212
|
-
directory: path5.join(agent ? expandDirectory(agent, home) : path5.join(home, ".omp", "agent"), "sessions"),
|
|
17213
|
-
flat: false
|
|
17214
|
-
};
|
|
17215
|
-
}
|
|
17216
|
-
function messageText(content) {
|
|
17217
|
-
if (typeof content === "string")
|
|
17218
|
-
return content;
|
|
17219
|
-
if (!Array.isArray(content))
|
|
17220
|
-
return "";
|
|
17221
|
-
return content.filter((part) => isRecord(part) && part.type === "text" && typeof part.text === "string").map((part) => String(part.text)).join(" ");
|
|
17222
|
-
}
|
|
17223
|
-
async function readFacts(file2, signal) {
|
|
17224
|
-
const stream = createReadStream2(file2, { encoding: "utf8", signal });
|
|
17225
|
-
const lines = createInterface2({ input: stream, crlfDelay: Infinity });
|
|
17226
|
-
let header = null;
|
|
17227
|
-
let nativeTitle = null;
|
|
17228
|
-
let firstPrompt = null;
|
|
17229
|
-
let updatedAt = null;
|
|
17230
|
-
let leafHasUser = false;
|
|
17231
|
-
const hasUserAncestry = /* @__PURE__ */ new Map();
|
|
17232
|
-
try {
|
|
17233
|
-
for await (const line of lines) {
|
|
17234
|
-
signal.throwIfAborted();
|
|
17235
|
-
if (!line.trim())
|
|
17236
|
-
continue;
|
|
17237
|
-
let entry;
|
|
17238
|
-
try {
|
|
17239
|
-
entry = JSON.parse(line);
|
|
17240
|
-
} catch {
|
|
17241
|
-
continue;
|
|
17242
|
-
}
|
|
17243
|
-
if (!isRecord(entry))
|
|
17244
|
-
continue;
|
|
17245
|
-
if (entry.type === "title") {
|
|
17246
|
-
nativeTitle = sessionImportTitle(entry.title);
|
|
17247
|
-
continue;
|
|
17248
|
-
}
|
|
17249
|
-
if (entry.type === "session") {
|
|
17250
|
-
if (header)
|
|
17251
|
-
return null;
|
|
17252
|
-
if (typeof entry.id !== "string" || entry.id.length === 0 || typeof entry.cwd !== "string" || !path5.isAbsolute(entry.cwd))
|
|
17253
|
-
return null;
|
|
17254
|
-
header = { id: entry.id, cwd: entry.cwd };
|
|
17255
|
-
continue;
|
|
17256
|
-
}
|
|
17257
|
-
if (typeof entry.id !== "string" || entry.id.length === 0)
|
|
17258
|
-
continue;
|
|
17259
|
-
const message3 = isRecord(entry.message) ? entry.message : null;
|
|
17260
|
-
const isUser = entry.type === "message" && message3?.role === "user";
|
|
17261
|
-
if (isUser)
|
|
17262
|
-
firstPrompt ??= sessionImportTitle(messageText(message3?.content));
|
|
17263
|
-
leafHasUser = isUser || typeof entry.parentId === "string" && hasUserAncestry.get(entry.parentId) === true;
|
|
17264
|
-
hasUserAncestry.set(entry.id, leafHasUser);
|
|
17265
|
-
if (entry.type === "message" && (message3?.role === "user" || message3?.role === "assistant")) {
|
|
17266
|
-
const time3 = typeof message3.timestamp === "number" ? message3.timestamp : typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : Number.NaN;
|
|
17267
|
-
if (Number.isFinite(time3) && time3 >= 0)
|
|
17268
|
-
updatedAt = time3;
|
|
17269
|
-
}
|
|
17270
|
-
}
|
|
17271
|
-
} finally {
|
|
17272
|
-
lines.close();
|
|
17273
|
-
stream.destroy();
|
|
17274
|
-
}
|
|
17275
|
-
if (!header || !leafHasUser)
|
|
17276
|
-
return null;
|
|
17277
|
-
return {
|
|
17278
|
-
nativeSessionId: header.id,
|
|
17279
|
-
cwd: header.cwd,
|
|
17280
|
-
title: nativeTitle ?? firstPrompt,
|
|
17281
|
-
updatedAt
|
|
17282
|
-
};
|
|
17283
|
-
}
|
|
17284
|
-
var OmpSessionImport = class {
|
|
17285
|
-
#location;
|
|
17286
|
-
#scope = new SessionImportScope({
|
|
17287
|
-
closedMessage: "Omp Session import is closed",
|
|
17288
|
-
unavailableMessage: "Omp sessions could not be read; close native clients, check storage access and retry",
|
|
17289
|
-
notFoundMessage: "Omp Session is no longer importable"
|
|
17290
|
-
});
|
|
17291
|
-
constructor(environment) {
|
|
17292
|
-
this.#location = ompSessionImportDirectory(environment);
|
|
17293
|
-
}
|
|
17294
|
-
listCandidates() {
|
|
17295
|
-
return this.#scope.read(async (signal) => [...(await this.#sources(signal)).values()].flatMap((sources) => (
|
|
17296
|
-
// One identity in two files cannot be resumed unambiguously.
|
|
17297
|
-
sources.length === 1 && sources[0] ? [sources[0].candidate] : []
|
|
17298
|
-
)));
|
|
17299
|
-
}
|
|
17300
|
-
resolveCandidate(nativeSessionId) {
|
|
17301
|
-
return this.#scope.resolve(async (signal) => {
|
|
17302
|
-
const sources = (await this.#sources(signal)).get(nativeSessionId);
|
|
17303
|
-
if (sources?.length !== 1 || !sources[0])
|
|
17304
|
-
return null;
|
|
17305
|
-
const source = await this.#source(sources[0].file, signal);
|
|
17306
|
-
return source?.nativeRef.nativeSessionId === nativeSessionId ? { candidate: source.candidate, nativeRef: source.nativeRef } : null;
|
|
17307
|
-
});
|
|
17308
|
-
}
|
|
17309
|
-
close() {
|
|
17310
|
-
return this.#scope.close();
|
|
17311
|
-
}
|
|
17312
|
-
async #sessionFiles(signal) {
|
|
17313
|
-
const { directory, flat } = this.#location;
|
|
17314
|
-
const info = await optionalLstat(directory);
|
|
17315
|
-
if (!info)
|
|
17316
|
-
return [];
|
|
17317
|
-
if (!info.isDirectory())
|
|
17318
|
-
throw new Error("Omp Session store is not a directory");
|
|
17319
|
-
const files = [];
|
|
17320
|
-
const visit = async (current, projectLevel) => {
|
|
17321
|
-
const entries = await opendir2(current).catch((error51) => {
|
|
17322
|
-
if (isMissingFileError(error51))
|
|
17323
|
-
return null;
|
|
17324
|
-
throw error51;
|
|
17325
|
-
});
|
|
17326
|
-
if (!entries)
|
|
17327
|
-
return;
|
|
17328
|
-
for await (const entry of entries) {
|
|
17329
|
-
signal.throwIfAborted();
|
|
17330
|
-
if (projectLevel && entry.isDirectory())
|
|
17331
|
-
await visit(path5.join(current, entry.name), false);
|
|
17332
|
-
else if (!projectLevel && entry.isFile() && entry.name.endsWith(".jsonl"))
|
|
17333
|
-
files.push(path5.join(current, entry.name));
|
|
17334
|
-
}
|
|
17335
|
-
};
|
|
17336
|
-
await visit(directory, !flat);
|
|
17337
|
-
return files;
|
|
17338
|
-
}
|
|
17339
|
-
/** Session ID to every readable file claiming it. Files changing under the read are skipped. */
|
|
17340
|
-
async #sources(signal) {
|
|
17341
|
-
const found = /* @__PURE__ */ new Map();
|
|
17342
|
-
for (const file2 of await this.#sessionFiles(signal)) {
|
|
17343
|
-
signal.throwIfAborted();
|
|
17344
|
-
try {
|
|
17345
|
-
const source = await this.#source(file2, signal);
|
|
17346
|
-
if (!source)
|
|
17347
|
-
continue;
|
|
17348
|
-
const sources = found.get(source.nativeRef.nativeSessionId) ?? [];
|
|
17349
|
-
sources.push(source);
|
|
17350
|
-
found.set(source.nativeRef.nativeSessionId, sources);
|
|
17351
|
-
} catch (error51) {
|
|
17352
|
-
if (!(error51 instanceof SessionImportChangedError))
|
|
17353
|
-
throw error51;
|
|
17354
|
-
}
|
|
17355
|
-
}
|
|
17356
|
-
return found;
|
|
17357
|
-
}
|
|
17358
|
-
async #source(file2, signal) {
|
|
17359
|
-
signal.throwIfAborted();
|
|
17360
|
-
return readStableFiles([file2], async ([info]) => {
|
|
17361
|
-
if (!info?.isFile() || info.size === 0)
|
|
17362
|
-
return null;
|
|
17363
|
-
try {
|
|
17364
|
-
const facts = await readFacts(file2, signal);
|
|
17365
|
-
if (!facts)
|
|
17366
|
-
return null;
|
|
17367
|
-
const cwd = await realpath(facts.cwd);
|
|
17368
|
-
if (!(await stat(cwd)).isDirectory())
|
|
17369
|
-
return null;
|
|
17370
|
-
const candidate = sessionImportCandidate({
|
|
17371
|
-
nativeSessionId: facts.nativeSessionId,
|
|
17372
|
-
cwd,
|
|
17373
|
-
title: facts.title,
|
|
17374
|
-
updatedAt: facts.updatedAt ?? info.mtimeMs
|
|
17375
|
-
// OMP has no cross-process activity marker: idleness cannot be established.
|
|
17376
|
-
});
|
|
17377
|
-
if (!candidate)
|
|
17378
|
-
return null;
|
|
17379
|
-
return {
|
|
17380
|
-
file: file2,
|
|
17381
|
-
candidate,
|
|
17382
|
-
// Resume needs the file itself: OMP is started with `--session <file>`.
|
|
17383
|
-
nativeRef: nativeSessionRefSchema.parse({
|
|
17384
|
-
harnessId: "omp",
|
|
17385
|
-
nativeSessionId: facts.nativeSessionId,
|
|
17386
|
-
locator: { sessionFile: await realpath(file2) },
|
|
17387
|
-
formatVersion: 1
|
|
17388
|
-
})
|
|
17389
|
-
};
|
|
17390
|
-
} catch (error51) {
|
|
17391
|
-
signal.throwIfAborted();
|
|
17392
|
-
if (isStorageAccessError(error51))
|
|
17393
|
-
throw error51;
|
|
17394
|
-
return null;
|
|
17395
|
-
}
|
|
17396
|
-
});
|
|
17397
|
-
}
|
|
17398
|
-
};
|
|
17399
|
-
|
|
17400
|
-
// ../../harness-adapter/dist/approval.js
|
|
17401
|
-
function invalidRequest(message3) {
|
|
17402
|
-
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17403
|
-
}
|
|
17404
|
-
function validateHostApprovalResponse(interaction, response) {
|
|
17405
|
-
return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
|
|
17406
|
-
}
|
|
17407
|
-
|
|
17408
|
-
// ../../harness-adapter/dist/question.js
|
|
17409
|
-
function invalidRequest2(message3) {
|
|
17410
|
-
return { code: "invalidRequest", message: message3, retryable: false };
|
|
17411
|
-
}
|
|
17412
|
-
function validateHostQuestionResponse(interaction, response) {
|
|
17413
|
-
const questionIds = new Set(interaction.questions.map(({ id }) => id));
|
|
17414
|
-
if (response.cancelled) {
|
|
17415
|
-
return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
|
|
17416
|
-
}
|
|
17417
|
-
for (const answerId of Object.keys(response.answers)) {
|
|
17418
|
-
if (!questionIds.has(answerId)) {
|
|
17419
|
-
return invalidRequest2("Question Response contains an unknown Question ID");
|
|
17420
|
-
}
|
|
17012
|
+
for (const answerId of Object.keys(response.answers)) {
|
|
17013
|
+
if (!questionIds.has(answerId)) {
|
|
17014
|
+
return invalidRequest2("Question Response contains an unknown Question ID");
|
|
17015
|
+
}
|
|
17421
17016
|
}
|
|
17422
17017
|
for (const question of interaction.questions) {
|
|
17423
17018
|
const answers = response.answers[question.id] ?? [];
|
|
@@ -17547,11 +17142,11 @@ var usageFields = /* @__PURE__ */ new Set([
|
|
|
17547
17142
|
"costSource",
|
|
17548
17143
|
"unpricedModels"
|
|
17549
17144
|
]);
|
|
17550
|
-
function
|
|
17145
|
+
function isRecord(value) {
|
|
17551
17146
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17552
17147
|
}
|
|
17553
17148
|
function parseHostUsage(value) {
|
|
17554
|
-
if (!
|
|
17149
|
+
if (!isRecord(value))
|
|
17555
17150
|
throw new Error("Harness Usage must be an object");
|
|
17556
17151
|
const keys = Object.keys(value);
|
|
17557
17152
|
if (keys.length === 0)
|
|
@@ -17598,7 +17193,7 @@ function parseHostUsage(value) {
|
|
|
17598
17193
|
}
|
|
17599
17194
|
if (value.sessionCacheUsage !== void 0) {
|
|
17600
17195
|
const totals2 = value.sessionCacheUsage;
|
|
17601
|
-
if (!
|
|
17196
|
+
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) {
|
|
17602
17197
|
throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
|
|
17603
17198
|
}
|
|
17604
17199
|
}
|
|
@@ -17654,7 +17249,7 @@ var requestFields = /* @__PURE__ */ new Set([
|
|
|
17654
17249
|
"provider"
|
|
17655
17250
|
]);
|
|
17656
17251
|
function parseHostUsageRequest(value) {
|
|
17657
|
-
if (!
|
|
17252
|
+
if (!isRecord(value))
|
|
17658
17253
|
throw new Error("Harness Usage request must be an object");
|
|
17659
17254
|
for (const key of Object.keys(value)) {
|
|
17660
17255
|
if (!requestFields.has(key)) {
|
|
@@ -17682,142 +17277,653 @@ function parseHostUsageRequest(value) {
|
|
|
17682
17277
|
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
17683
17278
|
throw new Error("Harness Usage request must contain 'inputTokens' and 'outputTokens'");
|
|
17684
17279
|
}
|
|
17685
|
-
const request = value;
|
|
17686
|
-
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
17687
|
-
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
17280
|
+
const request = value;
|
|
17281
|
+
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
17282
|
+
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
17283
|
+
}
|
|
17284
|
+
if ((request.reasoningOutputTokens ?? 0) > request.outputTokens) {
|
|
17285
|
+
throw new Error("Harness Usage request 'reasoningOutputTokens' must not exceed 'outputTokens'");
|
|
17286
|
+
}
|
|
17287
|
+
if (request.cacheWrite1hInputTokens !== void 0 && request.cacheWrite1hInputTokens > (request.cacheWriteInputTokens ?? -1)) {
|
|
17288
|
+
throw new Error("Harness Usage request 'cacheWrite1hInputTokens' must not exceed 'cacheWriteInputTokens'");
|
|
17289
|
+
}
|
|
17290
|
+
if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
|
|
17291
|
+
throw new Error("Harness Usage request timing fields must be provided together");
|
|
17292
|
+
}
|
|
17293
|
+
if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
|
|
17294
|
+
throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
|
|
17295
|
+
}
|
|
17296
|
+
return { ...request };
|
|
17297
|
+
}
|
|
17298
|
+
|
|
17299
|
+
// ../../harness-adapter/dist/live-command-catalog.js
|
|
17300
|
+
var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
17301
|
+
// Session lifecycle
|
|
17302
|
+
"branch",
|
|
17303
|
+
"clear",
|
|
17304
|
+
"exit",
|
|
17305
|
+
"fork",
|
|
17306
|
+
"fresh",
|
|
17307
|
+
"new",
|
|
17308
|
+
"quit",
|
|
17309
|
+
"rename",
|
|
17310
|
+
"rename-chat",
|
|
17311
|
+
"reset",
|
|
17312
|
+
"resume",
|
|
17313
|
+
"rewind",
|
|
17314
|
+
"session",
|
|
17315
|
+
"sessions",
|
|
17316
|
+
// Desktop-owned configuration
|
|
17317
|
+
"autocompact",
|
|
17318
|
+
"color",
|
|
17319
|
+
"config",
|
|
17320
|
+
"effort",
|
|
17321
|
+
"fast",
|
|
17322
|
+
"keybindings",
|
|
17323
|
+
"model",
|
|
17324
|
+
"models",
|
|
17325
|
+
"output-style",
|
|
17326
|
+
"permissions",
|
|
17327
|
+
"settings",
|
|
17328
|
+
"statusline",
|
|
17329
|
+
"terminal-setup",
|
|
17330
|
+
"theme",
|
|
17331
|
+
"vim",
|
|
17332
|
+
// Trust and approval policy
|
|
17333
|
+
"always-approve",
|
|
17334
|
+
"auto-mode-setup",
|
|
17335
|
+
// Native login
|
|
17336
|
+
"login",
|
|
17337
|
+
"logout",
|
|
17338
|
+
// Work outliving the Turn
|
|
17339
|
+
"autopilot",
|
|
17340
|
+
"background",
|
|
17341
|
+
"bg",
|
|
17342
|
+
"goal",
|
|
17343
|
+
"jobs",
|
|
17344
|
+
"loop",
|
|
17345
|
+
"multitask",
|
|
17346
|
+
"queue",
|
|
17347
|
+
"remote-control",
|
|
17348
|
+
"schedule",
|
|
17349
|
+
"steer",
|
|
17350
|
+
// Native terminal UI
|
|
17351
|
+
"copy",
|
|
17352
|
+
"debug",
|
|
17353
|
+
"feedback",
|
|
17354
|
+
"heapdump",
|
|
17355
|
+
"share",
|
|
17356
|
+
"shell",
|
|
17357
|
+
// Plugin and MCP management
|
|
17358
|
+
"marketplace",
|
|
17359
|
+
"mcp",
|
|
17360
|
+
"plugins",
|
|
17361
|
+
"reload-plugins"
|
|
17362
|
+
]);
|
|
17363
|
+
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
17364
|
+
function isExcludedLiveCommand(name, extra = {}) {
|
|
17365
|
+
const normalized = name.trim().replace(/^\//u, "");
|
|
17366
|
+
if (new Set(extra.names ?? []).has(normalized))
|
|
17367
|
+
return true;
|
|
17368
|
+
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
17369
|
+
return true;
|
|
17370
|
+
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
17371
|
+
}
|
|
17372
|
+
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
17373
|
+
if (!commandId.startsWith(idPrefix))
|
|
17374
|
+
return null;
|
|
17375
|
+
const descriptor = catalog.commands.find(({ id }) => id === commandId);
|
|
17376
|
+
if (!descriptor)
|
|
17377
|
+
return null;
|
|
17378
|
+
const text = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
17379
|
+
return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
|
|
17380
|
+
}
|
|
17381
|
+
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
17382
|
+
if (!live)
|
|
17383
|
+
return builtIns;
|
|
17384
|
+
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
17385
|
+
const ids = new Set(builtIns.commands.map(({ id }) => id));
|
|
17386
|
+
const dynamic = [];
|
|
17387
|
+
for (const command of live) {
|
|
17388
|
+
const name = command.name.trim().replace(/^\//u, "");
|
|
17389
|
+
if (!name || /\s/u.test(name))
|
|
17390
|
+
continue;
|
|
17391
|
+
if (isExcludedLiveCommand(name, exclusions))
|
|
17392
|
+
continue;
|
|
17393
|
+
const invocation = `/${name}`;
|
|
17394
|
+
const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
17395
|
+
if (invocations.has(invocation) || ids.has(id))
|
|
17396
|
+
continue;
|
|
17397
|
+
const description = command.description?.trim().slice(0, 512);
|
|
17398
|
+
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
17399
|
+
id,
|
|
17400
|
+
invocation,
|
|
17401
|
+
label: name.slice(0, 128),
|
|
17402
|
+
...description ? { description } : {},
|
|
17403
|
+
argumentMode: "text"
|
|
17404
|
+
});
|
|
17405
|
+
if (!parsed.success)
|
|
17406
|
+
continue;
|
|
17407
|
+
invocations.add(invocation);
|
|
17408
|
+
ids.add(id);
|
|
17409
|
+
dynamic.push(parsed.data);
|
|
17410
|
+
}
|
|
17411
|
+
return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
|
|
17412
|
+
}
|
|
17413
|
+
|
|
17414
|
+
// ../../harness-adapter/dist/subagent-configuration.js
|
|
17415
|
+
function subagentConfiguration(value) {
|
|
17416
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
17417
|
+
return {};
|
|
17418
|
+
const row = value;
|
|
17419
|
+
const text = (value2) => typeof value2 === "string" && value2.trim() ? value2 : void 0;
|
|
17420
|
+
const model2 = row.model === "inherit" ? void 0 : text(row.model);
|
|
17421
|
+
const reasoningEffort = text(row.reasoningEffort) ?? text(row.reasoning_effort) ?? text(row.thinking);
|
|
17422
|
+
return { ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
|
|
17423
|
+
}
|
|
17424
|
+
function inheritSubagentConfiguration(child, parent) {
|
|
17425
|
+
const native = subagentConfiguration(child);
|
|
17426
|
+
const model2 = native.model ?? parent.model;
|
|
17427
|
+
const reasoningEffort = native.reasoningEffort ?? parent.reasoningEffort;
|
|
17428
|
+
const next = { ...child };
|
|
17429
|
+
delete next.model;
|
|
17430
|
+
delete next.reasoningEffort;
|
|
17431
|
+
return { ...next, ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
|
|
17432
|
+
}
|
|
17433
|
+
function configureSubagentEvent(event, parent) {
|
|
17434
|
+
const children = (states) => states.map((child) => inheritSubagentConfiguration(child, parent));
|
|
17435
|
+
if (event.type === "item.started" && event.item.type === "subagentDelegation")
|
|
17436
|
+
return { ...event, item: { ...event.item, subagents: children(event.item.subagents) } };
|
|
17437
|
+
if (event.type === "item.updated" && event.update.type === "subagents.replace")
|
|
17438
|
+
return { ...event, update: { ...event.update, subagents: children(event.update.subagents) } };
|
|
17439
|
+
if (event.type === "item.completed" && event.snapshot.item.type === "subagentDelegation")
|
|
17440
|
+
return {
|
|
17441
|
+
...event,
|
|
17442
|
+
snapshot: {
|
|
17443
|
+
...event.snapshot,
|
|
17444
|
+
item: {
|
|
17445
|
+
...event.snapshot.item,
|
|
17446
|
+
subagents: children(event.snapshot.item.subagents)
|
|
17447
|
+
}
|
|
17448
|
+
}
|
|
17449
|
+
};
|
|
17450
|
+
return event;
|
|
17451
|
+
}
|
|
17452
|
+
function configureSubagentSnapshot(snapshot, parent) {
|
|
17453
|
+
return {
|
|
17454
|
+
...snapshot,
|
|
17455
|
+
turns: snapshot.turns.map((turn) => ({
|
|
17456
|
+
...turn,
|
|
17457
|
+
items: turn.items.map((entry) => entry.item.type === "subagentDelegation" ? {
|
|
17458
|
+
...entry,
|
|
17459
|
+
item: {
|
|
17460
|
+
...entry.item,
|
|
17461
|
+
subagents: entry.item.subagents.map((child) => inheritSubagentConfiguration(child, parent))
|
|
17462
|
+
}
|
|
17463
|
+
} : entry)
|
|
17464
|
+
}))
|
|
17465
|
+
};
|
|
17466
|
+
}
|
|
17467
|
+
|
|
17468
|
+
// ../../harness-adapter/dist/usage-statistics.js
|
|
17469
|
+
import { createReadStream } from "node:fs";
|
|
17470
|
+
import { lstat, opendir } from "node:fs/promises";
|
|
17471
|
+
import path4 from "node:path";
|
|
17472
|
+
import { createInterface } from "node:readline";
|
|
17473
|
+
var MAX_SESSION_ID_LENGTH = 512;
|
|
17474
|
+
var MAX_CWD_LENGTH = 4096;
|
|
17475
|
+
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
17476
|
+
function usageSessionTitle(value) {
|
|
17477
|
+
if (typeof value !== "string")
|
|
17478
|
+
return void 0;
|
|
17479
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
17480
|
+
if (!normalized)
|
|
17481
|
+
return void 0;
|
|
17482
|
+
if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
|
|
17483
|
+
return normalized;
|
|
17484
|
+
let title = "";
|
|
17485
|
+
for (const character of normalized) {
|
|
17486
|
+
if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
|
|
17487
|
+
break;
|
|
17488
|
+
title += character;
|
|
17489
|
+
}
|
|
17490
|
+
return `${title.trimEnd()}…`;
|
|
17491
|
+
}
|
|
17492
|
+
function sessionIdOk(value) {
|
|
17493
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
17494
|
+
}
|
|
17495
|
+
function cwdOk(value) {
|
|
17496
|
+
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("\\\\"));
|
|
17497
|
+
}
|
|
17498
|
+
function withUsageSession(entry, session) {
|
|
17499
|
+
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
17500
|
+
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
17501
|
+
const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
|
|
17502
|
+
if (sessionId === void 0 && cwd === void 0)
|
|
17503
|
+
return entry;
|
|
17504
|
+
return {
|
|
17505
|
+
...entry,
|
|
17506
|
+
...sessionId !== void 0 ? { sessionId } : {},
|
|
17507
|
+
...cwd !== void 0 ? { cwd } : {},
|
|
17508
|
+
...sessionTitle !== void 0 ? { sessionTitle } : {}
|
|
17509
|
+
};
|
|
17510
|
+
}
|
|
17511
|
+
function usageEntryFromRequest(request, occurredAtMs) {
|
|
17512
|
+
if (!Number.isSafeInteger(occurredAtMs) || occurredAtMs <= 0)
|
|
17513
|
+
return null;
|
|
17514
|
+
return {
|
|
17515
|
+
id: request.requestId,
|
|
17516
|
+
occurredAtMs,
|
|
17517
|
+
...request.model !== void 0 ? { model: request.model } : {},
|
|
17518
|
+
inputTokens: request.inputTokens,
|
|
17519
|
+
...request.cachedInputTokens !== void 0 ? { cachedInputTokens: request.cachedInputTokens } : {},
|
|
17520
|
+
...request.cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens: request.cacheWriteInputTokens } : {},
|
|
17521
|
+
...request.cacheWrite1hInputTokens !== void 0 ? { cacheWrite1hInputTokens: request.cacheWrite1hInputTokens } : {},
|
|
17522
|
+
outputTokens: request.outputTokens,
|
|
17523
|
+
...request.reasoningOutputTokens !== void 0 ? { reasoningOutputTokens: request.reasoningOutputTokens } : {}
|
|
17524
|
+
};
|
|
17525
|
+
}
|
|
17526
|
+
async function jsonlUsageSources(root, maxDepth, signal) {
|
|
17527
|
+
const sources = [];
|
|
17528
|
+
const visit = async (directory, depth) => {
|
|
17529
|
+
signal.throwIfAborted();
|
|
17530
|
+
const entries = await opendir(directory).catch((error51) => {
|
|
17531
|
+
if (error51.code === "ENOENT")
|
|
17532
|
+
return null;
|
|
17533
|
+
throw error51;
|
|
17534
|
+
});
|
|
17535
|
+
if (!entries)
|
|
17536
|
+
return;
|
|
17537
|
+
for await (const entry of entries) {
|
|
17538
|
+
signal.throwIfAborted();
|
|
17539
|
+
const file2 = path4.join(directory, entry.name);
|
|
17540
|
+
if (entry.isDirectory()) {
|
|
17541
|
+
if (depth < maxDepth)
|
|
17542
|
+
await visit(file2, depth + 1);
|
|
17543
|
+
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
17544
|
+
const info = await lstat(file2).catch(() => null);
|
|
17545
|
+
if (info?.isFile() && info.size > 0) {
|
|
17546
|
+
sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
|
|
17547
|
+
}
|
|
17548
|
+
}
|
|
17549
|
+
}
|
|
17550
|
+
};
|
|
17551
|
+
await visit(root, 0);
|
|
17552
|
+
return sources;
|
|
17553
|
+
}
|
|
17554
|
+
async function* jsonlRecords(file2, marker, signal) {
|
|
17555
|
+
const lines = createInterface({
|
|
17556
|
+
input: createReadStream(file2, { encoding: "utf8", signal }),
|
|
17557
|
+
crlfDelay: Infinity
|
|
17558
|
+
});
|
|
17559
|
+
for await (const line of lines) {
|
|
17560
|
+
if (!line.includes(marker))
|
|
17561
|
+
continue;
|
|
17562
|
+
let value;
|
|
17563
|
+
try {
|
|
17564
|
+
value = JSON.parse(line);
|
|
17565
|
+
} catch {
|
|
17566
|
+
continue;
|
|
17567
|
+
}
|
|
17568
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
17569
|
+
yield value;
|
|
17570
|
+
}
|
|
17571
|
+
}
|
|
17572
|
+
}
|
|
17573
|
+
async function jsonlHeader(file2, match, signal, maxLines = 4) {
|
|
17574
|
+
const stream = createReadStream(file2, { encoding: "utf8", signal });
|
|
17575
|
+
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
17576
|
+
let seen = 0;
|
|
17577
|
+
try {
|
|
17578
|
+
for await (const line of lines) {
|
|
17579
|
+
if (++seen > maxLines)
|
|
17580
|
+
break;
|
|
17581
|
+
let value;
|
|
17582
|
+
try {
|
|
17583
|
+
value = JSON.parse(line);
|
|
17584
|
+
} catch {
|
|
17585
|
+
continue;
|
|
17586
|
+
}
|
|
17587
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
17588
|
+
const record3 = value;
|
|
17589
|
+
if (match(record3))
|
|
17590
|
+
return record3;
|
|
17591
|
+
}
|
|
17592
|
+
}
|
|
17593
|
+
return null;
|
|
17594
|
+
} finally {
|
|
17595
|
+
lines.close();
|
|
17596
|
+
stream.destroy();
|
|
17597
|
+
}
|
|
17598
|
+
}
|
|
17599
|
+
function nativeTimeMs(value) {
|
|
17600
|
+
const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
17601
|
+
return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
|
|
17602
|
+
}
|
|
17603
|
+
|
|
17604
|
+
// dist/session-import.js
|
|
17605
|
+
import { createReadStream as createReadStream2 } from "node:fs";
|
|
17606
|
+
import { opendir as opendir2, realpath, stat } from "node:fs/promises";
|
|
17607
|
+
import os2 from "node:os";
|
|
17608
|
+
import path5 from "node:path";
|
|
17609
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
17610
|
+
|
|
17611
|
+
// ../../harness-adapter/dist/session-import.js
|
|
17612
|
+
import { lstat as lstat2 } from "node:fs/promises";
|
|
17613
|
+
var SessionImportChangedError = class extends Error {
|
|
17614
|
+
constructor(message3 = "Native Session changed during discovery; refresh and retry") {
|
|
17615
|
+
super(message3);
|
|
17616
|
+
this.name = "SessionImportChangedError";
|
|
17617
|
+
}
|
|
17618
|
+
};
|
|
17619
|
+
function isMissingFileError(error51) {
|
|
17620
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
17621
|
+
}
|
|
17622
|
+
function sameFileFingerprint(left, right) {
|
|
17623
|
+
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;
|
|
17624
|
+
}
|
|
17625
|
+
var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
|
|
17626
|
+
function isStorageAccessError(error51) {
|
|
17627
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
|
|
17628
|
+
}
|
|
17629
|
+
async function optionalLstat(file2) {
|
|
17630
|
+
try {
|
|
17631
|
+
return await lstat2(file2);
|
|
17632
|
+
} catch (error51) {
|
|
17633
|
+
if (isMissingFileError(error51))
|
|
17634
|
+
return null;
|
|
17635
|
+
throw error51;
|
|
17636
|
+
}
|
|
17637
|
+
}
|
|
17638
|
+
async function readStableFiles(files, read) {
|
|
17639
|
+
const before = await Promise.all(files.map(optionalLstat));
|
|
17640
|
+
const value = await read(before);
|
|
17641
|
+
const after = await Promise.all(files.map(optionalLstat));
|
|
17642
|
+
if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
|
|
17643
|
+
throw new SessionImportChangedError();
|
|
17644
|
+
return value;
|
|
17645
|
+
}
|
|
17646
|
+
function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
|
|
17647
|
+
if (typeof value !== "string")
|
|
17648
|
+
return null;
|
|
17649
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
17650
|
+
if (!normalized)
|
|
17651
|
+
return null;
|
|
17652
|
+
if (normalized.length <= maxLength)
|
|
17653
|
+
return normalized;
|
|
17654
|
+
const characters = [...normalized];
|
|
17655
|
+
if (characters.length <= maxLength)
|
|
17656
|
+
return normalized;
|
|
17657
|
+
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
17658
|
+
}
|
|
17659
|
+
function sessionImportCandidate(input) {
|
|
17660
|
+
const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
|
|
17661
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
17662
|
+
nativeSessionId: input.nativeSessionId,
|
|
17663
|
+
cwd: input.cwd,
|
|
17664
|
+
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
17665
|
+
updatedAt: Math.floor(time3),
|
|
17666
|
+
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
17667
|
+
running: typeof input.running === "boolean" ? input.running : null
|
|
17668
|
+
});
|
|
17669
|
+
return parsed.success ? parsed.data : null;
|
|
17670
|
+
}
|
|
17671
|
+
var SessionImportScope = class {
|
|
17672
|
+
#abort = new AbortController();
|
|
17673
|
+
#options;
|
|
17674
|
+
#pending = /* @__PURE__ */ new Set();
|
|
17675
|
+
constructor(options) {
|
|
17676
|
+
this.#options = options;
|
|
17677
|
+
}
|
|
17678
|
+
#closed() {
|
|
17679
|
+
return {
|
|
17680
|
+
ok: false,
|
|
17681
|
+
error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
|
|
17682
|
+
};
|
|
17683
|
+
}
|
|
17684
|
+
read(operation) {
|
|
17685
|
+
const signal = this.#abort.signal;
|
|
17686
|
+
if (signal.aborted)
|
|
17687
|
+
return Promise.resolve(this.#closed());
|
|
17688
|
+
let started;
|
|
17689
|
+
try {
|
|
17690
|
+
started = operation(signal);
|
|
17691
|
+
} catch (error51) {
|
|
17692
|
+
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
17693
|
+
}
|
|
17694
|
+
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
17695
|
+
ok: false,
|
|
17696
|
+
error: {
|
|
17697
|
+
code: "unavailable",
|
|
17698
|
+
message: this.#options.unavailableMessage,
|
|
17699
|
+
retryable: true
|
|
17700
|
+
}
|
|
17701
|
+
}).finally(() => this.#pending.delete(request));
|
|
17702
|
+
this.#pending.add(request);
|
|
17703
|
+
return request;
|
|
17704
|
+
}
|
|
17705
|
+
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
17706
|
+
async resolve(operation) {
|
|
17707
|
+
const result = await this.read(operation);
|
|
17708
|
+
if (!result.ok)
|
|
17709
|
+
return result;
|
|
17710
|
+
return result.value ? { ok: true, value: result.value } : {
|
|
17711
|
+
ok: false,
|
|
17712
|
+
error: {
|
|
17713
|
+
code: "sessionNotFound",
|
|
17714
|
+
message: this.#options.notFoundMessage,
|
|
17715
|
+
retryable: false
|
|
17716
|
+
}
|
|
17717
|
+
};
|
|
17718
|
+
}
|
|
17719
|
+
/** Idempotent. Resolves after every started read has settled. */
|
|
17720
|
+
async close() {
|
|
17721
|
+
this.#abort.abort();
|
|
17722
|
+
await Promise.allSettled(this.#pending);
|
|
17723
|
+
}
|
|
17724
|
+
};
|
|
17725
|
+
|
|
17726
|
+
// dist/session-import.js
|
|
17727
|
+
function isRecord2(value) {
|
|
17728
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17729
|
+
}
|
|
17730
|
+
function expandDirectory(value, home) {
|
|
17731
|
+
return path5.resolve(value === "~" ? home : value.startsWith(`~${path5.sep}`) || value.startsWith("~/") ? path5.join(home, value.slice(2)) : value);
|
|
17732
|
+
}
|
|
17733
|
+
function ompSessionImportDirectory(environment) {
|
|
17734
|
+
const home = (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os2.homedir();
|
|
17735
|
+
const custom2 = environment.PI_CODING_AGENT_SESSION_DIR;
|
|
17736
|
+
if (custom2)
|
|
17737
|
+
return { directory: expandDirectory(custom2, home), flat: true };
|
|
17738
|
+
const agent = environment.PI_CODING_AGENT_DIR;
|
|
17739
|
+
return {
|
|
17740
|
+
directory: path5.join(agent ? expandDirectory(agent, home) : path5.join(home, ".omp", "agent"), "sessions"),
|
|
17741
|
+
flat: false
|
|
17742
|
+
};
|
|
17743
|
+
}
|
|
17744
|
+
function messageText(content) {
|
|
17745
|
+
if (typeof content === "string")
|
|
17746
|
+
return content;
|
|
17747
|
+
if (!Array.isArray(content))
|
|
17748
|
+
return "";
|
|
17749
|
+
return content.filter((part) => isRecord2(part) && part.type === "text" && typeof part.text === "string").map((part) => String(part.text)).join(" ");
|
|
17750
|
+
}
|
|
17751
|
+
async function readFacts(file2, signal) {
|
|
17752
|
+
const stream = createReadStream2(file2, { encoding: "utf8", signal });
|
|
17753
|
+
const lines = createInterface2({ input: stream, crlfDelay: Infinity });
|
|
17754
|
+
let header = null;
|
|
17755
|
+
let nativeTitle = null;
|
|
17756
|
+
let firstPrompt = null;
|
|
17757
|
+
let updatedAt = null;
|
|
17758
|
+
let leafHasUser = false;
|
|
17759
|
+
const hasUserAncestry = /* @__PURE__ */ new Map();
|
|
17760
|
+
try {
|
|
17761
|
+
for await (const line of lines) {
|
|
17762
|
+
signal.throwIfAborted();
|
|
17763
|
+
if (!line.trim())
|
|
17764
|
+
continue;
|
|
17765
|
+
let entry;
|
|
17766
|
+
try {
|
|
17767
|
+
entry = JSON.parse(line);
|
|
17768
|
+
} catch {
|
|
17769
|
+
continue;
|
|
17770
|
+
}
|
|
17771
|
+
if (!isRecord2(entry))
|
|
17772
|
+
continue;
|
|
17773
|
+
if (entry.type === "title") {
|
|
17774
|
+
nativeTitle = sessionImportTitle(entry.title);
|
|
17775
|
+
continue;
|
|
17776
|
+
}
|
|
17777
|
+
if (entry.type === "session") {
|
|
17778
|
+
if (header)
|
|
17779
|
+
return null;
|
|
17780
|
+
if (typeof entry.id !== "string" || entry.id.length === 0 || typeof entry.cwd !== "string" || !path5.isAbsolute(entry.cwd))
|
|
17781
|
+
return null;
|
|
17782
|
+
header = { id: entry.id, cwd: entry.cwd };
|
|
17783
|
+
continue;
|
|
17784
|
+
}
|
|
17785
|
+
if (typeof entry.id !== "string" || entry.id.length === 0)
|
|
17786
|
+
continue;
|
|
17787
|
+
const message3 = isRecord2(entry.message) ? entry.message : null;
|
|
17788
|
+
const isUser = entry.type === "message" && message3?.role === "user";
|
|
17789
|
+
if (isUser)
|
|
17790
|
+
firstPrompt ??= sessionImportTitle(messageText(message3?.content));
|
|
17791
|
+
leafHasUser = isUser || typeof entry.parentId === "string" && hasUserAncestry.get(entry.parentId) === true;
|
|
17792
|
+
hasUserAncestry.set(entry.id, leafHasUser);
|
|
17793
|
+
if (entry.type === "message" && (message3?.role === "user" || message3?.role === "assistant")) {
|
|
17794
|
+
const time3 = typeof message3.timestamp === "number" ? message3.timestamp : typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : Number.NaN;
|
|
17795
|
+
if (Number.isFinite(time3) && time3 >= 0)
|
|
17796
|
+
updatedAt = time3;
|
|
17797
|
+
}
|
|
17798
|
+
}
|
|
17799
|
+
} finally {
|
|
17800
|
+
lines.close();
|
|
17801
|
+
stream.destroy();
|
|
17802
|
+
}
|
|
17803
|
+
if (!header || !leafHasUser)
|
|
17804
|
+
return null;
|
|
17805
|
+
return {
|
|
17806
|
+
nativeSessionId: header.id,
|
|
17807
|
+
cwd: header.cwd,
|
|
17808
|
+
title: nativeTitle ?? firstPrompt,
|
|
17809
|
+
updatedAt
|
|
17810
|
+
};
|
|
17811
|
+
}
|
|
17812
|
+
var OmpSessionImport = class {
|
|
17813
|
+
#location;
|
|
17814
|
+
#scope = new SessionImportScope({
|
|
17815
|
+
closedMessage: "Omp Session import is closed",
|
|
17816
|
+
unavailableMessage: "Omp sessions could not be read; close native clients, check storage access and retry",
|
|
17817
|
+
notFoundMessage: "Omp Session is no longer importable"
|
|
17818
|
+
});
|
|
17819
|
+
constructor(environment) {
|
|
17820
|
+
this.#location = ompSessionImportDirectory(environment);
|
|
17821
|
+
}
|
|
17822
|
+
listCandidates() {
|
|
17823
|
+
return this.#scope.read(async (signal) => [...(await this.#sources(signal)).values()].flatMap((sources) => (
|
|
17824
|
+
// One identity in two files cannot be resumed unambiguously.
|
|
17825
|
+
sources.length === 1 && sources[0] ? [sources[0].candidate] : []
|
|
17826
|
+
)));
|
|
17688
17827
|
}
|
|
17689
|
-
|
|
17690
|
-
|
|
17828
|
+
resolveCandidate(nativeSessionId) {
|
|
17829
|
+
return this.#scope.resolve(async (signal) => {
|
|
17830
|
+
const sources = (await this.#sources(signal)).get(nativeSessionId);
|
|
17831
|
+
if (sources?.length !== 1 || !sources[0])
|
|
17832
|
+
return null;
|
|
17833
|
+
const source = await this.#source(sources[0].file, signal);
|
|
17834
|
+
return source?.nativeRef.nativeSessionId === nativeSessionId ? { candidate: source.candidate, nativeRef: source.nativeRef } : null;
|
|
17835
|
+
});
|
|
17691
17836
|
}
|
|
17692
|
-
|
|
17693
|
-
|
|
17837
|
+
close() {
|
|
17838
|
+
return this.#scope.close();
|
|
17694
17839
|
}
|
|
17695
|
-
|
|
17696
|
-
|
|
17840
|
+
async #sessionFiles(signal) {
|
|
17841
|
+
const { directory, flat } = this.#location;
|
|
17842
|
+
const info = await optionalLstat(directory);
|
|
17843
|
+
if (!info)
|
|
17844
|
+
return [];
|
|
17845
|
+
if (!info.isDirectory())
|
|
17846
|
+
throw new Error("Omp Session store is not a directory");
|
|
17847
|
+
const files = [];
|
|
17848
|
+
const visit = async (current, projectLevel) => {
|
|
17849
|
+
const entries = await opendir2(current).catch((error51) => {
|
|
17850
|
+
if (isMissingFileError(error51))
|
|
17851
|
+
return null;
|
|
17852
|
+
throw error51;
|
|
17853
|
+
});
|
|
17854
|
+
if (!entries)
|
|
17855
|
+
return;
|
|
17856
|
+
for await (const entry of entries) {
|
|
17857
|
+
signal.throwIfAborted();
|
|
17858
|
+
if (projectLevel && entry.isDirectory())
|
|
17859
|
+
await visit(path5.join(current, entry.name), false);
|
|
17860
|
+
else if (!projectLevel && entry.isFile() && entry.name.endsWith(".jsonl"))
|
|
17861
|
+
files.push(path5.join(current, entry.name));
|
|
17862
|
+
}
|
|
17863
|
+
};
|
|
17864
|
+
await visit(directory, !flat);
|
|
17865
|
+
return files;
|
|
17697
17866
|
}
|
|
17698
|
-
|
|
17699
|
-
|
|
17867
|
+
/** Session ID to every readable file claiming it. Files changing under the read are skipped. */
|
|
17868
|
+
async #sources(signal) {
|
|
17869
|
+
const found = /* @__PURE__ */ new Map();
|
|
17870
|
+
for (const file2 of await this.#sessionFiles(signal)) {
|
|
17871
|
+
signal.throwIfAborted();
|
|
17872
|
+
try {
|
|
17873
|
+
const source = await this.#source(file2, signal);
|
|
17874
|
+
if (!source)
|
|
17875
|
+
continue;
|
|
17876
|
+
const sources = found.get(source.nativeRef.nativeSessionId) ?? [];
|
|
17877
|
+
sources.push(source);
|
|
17878
|
+
found.set(source.nativeRef.nativeSessionId, sources);
|
|
17879
|
+
} catch (error51) {
|
|
17880
|
+
if (!(error51 instanceof SessionImportChangedError))
|
|
17881
|
+
throw error51;
|
|
17882
|
+
}
|
|
17883
|
+
}
|
|
17884
|
+
return found;
|
|
17700
17885
|
}
|
|
17701
|
-
|
|
17702
|
-
|
|
17703
|
-
|
|
17704
|
-
|
|
17705
|
-
|
|
17706
|
-
|
|
17707
|
-
|
|
17708
|
-
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
|
|
17727
|
-
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
"auto-mode-setup",
|
|
17740
|
-
// Native login
|
|
17741
|
-
"login",
|
|
17742
|
-
"logout",
|
|
17743
|
-
// Work outliving the Turn
|
|
17744
|
-
"autopilot",
|
|
17745
|
-
"background",
|
|
17746
|
-
"bg",
|
|
17747
|
-
"goal",
|
|
17748
|
-
"jobs",
|
|
17749
|
-
"loop",
|
|
17750
|
-
"multitask",
|
|
17751
|
-
"queue",
|
|
17752
|
-
"remote-control",
|
|
17753
|
-
"schedule",
|
|
17754
|
-
"steer",
|
|
17755
|
-
// Native terminal UI
|
|
17756
|
-
"copy",
|
|
17757
|
-
"debug",
|
|
17758
|
-
"feedback",
|
|
17759
|
-
"heapdump",
|
|
17760
|
-
"share",
|
|
17761
|
-
"shell",
|
|
17762
|
-
// Plugin and MCP management
|
|
17763
|
-
"marketplace",
|
|
17764
|
-
"mcp",
|
|
17765
|
-
"plugins",
|
|
17766
|
-
"reload-plugins"
|
|
17767
|
-
]);
|
|
17768
|
-
var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
|
|
17769
|
-
function isExcludedLiveCommand(name, kind, extra = {}) {
|
|
17770
|
-
const normalized = name.trim().replace(/^\//u, "");
|
|
17771
|
-
if (new Set(extra.names ?? []).has(normalized))
|
|
17772
|
-
return true;
|
|
17773
|
-
if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
|
|
17774
|
-
return true;
|
|
17775
|
-
if (kind === "skill")
|
|
17776
|
-
return false;
|
|
17777
|
-
return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
17778
|
-
}
|
|
17779
|
-
function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
|
|
17780
|
-
if (!commandId.startsWith(idPrefix))
|
|
17781
|
-
return null;
|
|
17782
|
-
const descriptor = catalog.commands.find(({ id }) => id === commandId);
|
|
17783
|
-
if (!descriptor)
|
|
17784
|
-
return null;
|
|
17785
|
-
const text = typeof argumentText === "string" ? argumentText.trim() : "";
|
|
17786
|
-
return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
|
|
17787
|
-
}
|
|
17788
|
-
function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
|
|
17789
|
-
if (!live)
|
|
17790
|
-
return builtIns;
|
|
17791
|
-
const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
|
|
17792
|
-
const ids = new Set(builtIns.commands.map(({ id }) => id));
|
|
17793
|
-
const dynamic = [];
|
|
17794
|
-
for (const command of live) {
|
|
17795
|
-
const name = command.name.trim().replace(/^\//u, "");
|
|
17796
|
-
if (!name || /\s/u.test(name))
|
|
17797
|
-
continue;
|
|
17798
|
-
if (isExcludedLiveCommand(name, command.kind, exclusions))
|
|
17799
|
-
continue;
|
|
17800
|
-
const invocation = `/${name}`;
|
|
17801
|
-
const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
|
|
17802
|
-
if (invocations.has(invocation) || ids.has(id))
|
|
17803
|
-
continue;
|
|
17804
|
-
const description = command.description?.trim().slice(0, 512);
|
|
17805
|
-
const parsed = harnessCommandDescriptorSchema.safeParse({
|
|
17806
|
-
id,
|
|
17807
|
-
invocation,
|
|
17808
|
-
label: name.slice(0, 128),
|
|
17809
|
-
...description ? { description } : {},
|
|
17810
|
-
argumentMode: "text",
|
|
17811
|
-
kind: command.kind
|
|
17886
|
+
async #source(file2, signal) {
|
|
17887
|
+
signal.throwIfAborted();
|
|
17888
|
+
return readStableFiles([file2], async ([info]) => {
|
|
17889
|
+
if (!info?.isFile() || info.size === 0)
|
|
17890
|
+
return null;
|
|
17891
|
+
try {
|
|
17892
|
+
const facts = await readFacts(file2, signal);
|
|
17893
|
+
if (!facts)
|
|
17894
|
+
return null;
|
|
17895
|
+
const cwd = await realpath(facts.cwd);
|
|
17896
|
+
if (!(await stat(cwd)).isDirectory())
|
|
17897
|
+
return null;
|
|
17898
|
+
const candidate = sessionImportCandidate({
|
|
17899
|
+
nativeSessionId: facts.nativeSessionId,
|
|
17900
|
+
cwd,
|
|
17901
|
+
title: facts.title,
|
|
17902
|
+
updatedAt: facts.updatedAt ?? info.mtimeMs
|
|
17903
|
+
// OMP has no cross-process activity marker: idleness cannot be established.
|
|
17904
|
+
});
|
|
17905
|
+
if (!candidate)
|
|
17906
|
+
return null;
|
|
17907
|
+
return {
|
|
17908
|
+
file: file2,
|
|
17909
|
+
candidate,
|
|
17910
|
+
// Resume needs the file itself: OMP is started with `--session <file>`.
|
|
17911
|
+
nativeRef: nativeSessionRefSchema.parse({
|
|
17912
|
+
harnessId: "omp",
|
|
17913
|
+
nativeSessionId: facts.nativeSessionId,
|
|
17914
|
+
locator: { sessionFile: await realpath(file2) },
|
|
17915
|
+
formatVersion: 1
|
|
17916
|
+
})
|
|
17917
|
+
};
|
|
17918
|
+
} catch (error51) {
|
|
17919
|
+
signal.throwIfAborted();
|
|
17920
|
+
if (isStorageAccessError(error51))
|
|
17921
|
+
throw error51;
|
|
17922
|
+
return null;
|
|
17923
|
+
}
|
|
17812
17924
|
});
|
|
17813
|
-
if (!parsed.success)
|
|
17814
|
-
continue;
|
|
17815
|
-
invocations.add(invocation);
|
|
17816
|
-
ids.add(id);
|
|
17817
|
-
dynamic.push(parsed.data);
|
|
17818
17925
|
}
|
|
17819
|
-
|
|
17820
|
-
}
|
|
17926
|
+
};
|
|
17821
17927
|
|
|
17822
17928
|
// dist/omp-model-catalog.js
|
|
17823
17929
|
var OMP_MODEL_REF_PREFIX = "omp-model-v1.";
|
|
@@ -18419,10 +18525,9 @@ function parseOmpAvailableCommands(value) {
|
|
|
18419
18525
|
});
|
|
18420
18526
|
}
|
|
18421
18527
|
function ompLiveCommands(native) {
|
|
18422
|
-
return native.filter(({ source, name }) => source !== "builtin" || name === "context").map((command) => ({
|
|
18528
|
+
return native.filter(({ source, name }) => source !== "skill" && (source !== "builtin" || name === "context")).map((command) => ({
|
|
18423
18529
|
name: command.name,
|
|
18424
|
-
description: command.description
|
|
18425
|
-
kind: command.source === "skill" ? "skill" : "command"
|
|
18530
|
+
description: command.description
|
|
18426
18531
|
}));
|
|
18427
18532
|
}
|
|
18428
18533
|
|
|
@@ -18634,6 +18739,9 @@ var OmpRpcUnsupportedCommandError = class extends Error {
|
|
|
18634
18739
|
this.name = "OmpRpcUnsupportedCommandError";
|
|
18635
18740
|
}
|
|
18636
18741
|
};
|
|
18742
|
+
function hasTurnCompletion(active) {
|
|
18743
|
+
return active.terminalEnd || active.localResult !== null && !active.sawAgentStart;
|
|
18744
|
+
}
|
|
18637
18745
|
var textDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
18638
18746
|
function isRecord8(value) {
|
|
18639
18747
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -18690,9 +18798,9 @@ function parseSessionStreaming(response) {
|
|
|
18690
18798
|
}
|
|
18691
18799
|
return isStreaming;
|
|
18692
18800
|
}
|
|
18693
|
-
function
|
|
18801
|
+
function sessionSettled(response, completed) {
|
|
18694
18802
|
const data = sessionStateData(response);
|
|
18695
|
-
return !parseSessionStreaming(response) && (data.isSettled === true || data.isSettled === void 0 &&
|
|
18803
|
+
return !parseSessionStreaming(response) && (data.isSettled === true || data.isSettled === void 0 && completed) && data.isCompacting !== true && data.hasPendingAsyncWork !== true && !(typeof data.queuedMessageCount === "number" && data.queuedMessageCount > 0);
|
|
18696
18804
|
}
|
|
18697
18805
|
function parseAvailableModels(response) {
|
|
18698
18806
|
const data = isRecord8(response.data) ? response.data : null;
|
|
@@ -18924,6 +19032,9 @@ var OmpRpcSession = class {
|
|
|
18924
19032
|
child.stderr.on("data", (chunk) => {
|
|
18925
19033
|
this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
|
|
18926
19034
|
});
|
|
19035
|
+
child.stdin.on("error", (error51) => {
|
|
19036
|
+
this.#fail(new OmpRpcFaultError("processExited", `Omp RPC stdin closed: ${error51.message}`, this.stderrTail));
|
|
19037
|
+
});
|
|
18927
19038
|
child.once("error", (error51) => {
|
|
18928
19039
|
const kind = isRecord8(error51) && error51.code === "ENOENT" ? "notInstalled" : "unavailable";
|
|
18929
19040
|
this.#fail(new OmpRpcFaultError(kind, `Omp RPC failed to start: ${error51.message}`, this.stderrTail));
|
|
@@ -19170,7 +19281,10 @@ var OmpRpcSession = class {
|
|
|
19170
19281
|
tools: /* @__PURE__ */ new Map(),
|
|
19171
19282
|
interactions: /* @__PURE__ */ new Map(),
|
|
19172
19283
|
settlement: "pending",
|
|
19284
|
+
settledNotice: false,
|
|
19285
|
+
settlementRecheck: null,
|
|
19173
19286
|
terminalEnd: false,
|
|
19287
|
+
sawAgentStart: false,
|
|
19174
19288
|
cancellation: "none",
|
|
19175
19289
|
cancellationTimeout: null,
|
|
19176
19290
|
cancellationRecheck: null,
|
|
@@ -19380,12 +19494,21 @@ var OmpRpcSession = class {
|
|
|
19380
19494
|
if (this.#handleSubagentFrame(active, value))
|
|
19381
19495
|
return;
|
|
19382
19496
|
this.#observeUsage(value);
|
|
19383
|
-
if (value.type === "agent_start" && active)
|
|
19497
|
+
if (value.type === "agent_start" && active) {
|
|
19384
19498
|
active.terminalEnd = false;
|
|
19499
|
+
active.sawAgentStart = true;
|
|
19500
|
+
}
|
|
19385
19501
|
if ((value.type === "session_settled" || value.type === "agent_start") && active?.cancellation === "accepted") {
|
|
19386
19502
|
void this.#confirmCancelledTurn(active);
|
|
19387
19503
|
return;
|
|
19388
19504
|
}
|
|
19505
|
+
if (value.type === "session_settled") {
|
|
19506
|
+
if (active && hasTurnCompletion(active)) {
|
|
19507
|
+
active.settledNotice = true;
|
|
19508
|
+
void this.#confirmSettledTurn(active);
|
|
19509
|
+
}
|
|
19510
|
+
return;
|
|
19511
|
+
}
|
|
19389
19512
|
if (!active) {
|
|
19390
19513
|
if (value.type === "extension_ui_request" && this.#isBlockingInteraction(value)) {
|
|
19391
19514
|
this.#fail(new OmpRpcFaultError("protocolError", "Omp RPC requested blocking Extension UI outside an active Turn"));
|
|
@@ -19480,9 +19603,6 @@ var OmpRpcSession = class {
|
|
|
19480
19603
|
void this.#confirmCancelledTurn(active);
|
|
19481
19604
|
return;
|
|
19482
19605
|
}
|
|
19483
|
-
if (active.settlement !== "pending")
|
|
19484
|
-
return;
|
|
19485
|
-
active.settlement = "confirming";
|
|
19486
19606
|
void this.#confirmSettledTurn(active);
|
|
19487
19607
|
}
|
|
19488
19608
|
}
|
|
@@ -19534,6 +19654,7 @@ var OmpRpcSession = class {
|
|
|
19534
19654
|
const description = nonBlankString(payload.description) ? payload.description : nonBlankString(payload.agent) ? `${payload.agent} delegation` : "Subagent delegation";
|
|
19535
19655
|
emit?.({
|
|
19536
19656
|
type: "subagent.started",
|
|
19657
|
+
...subagentConfiguration(payload),
|
|
19537
19658
|
callId,
|
|
19538
19659
|
nativeSubagentId,
|
|
19539
19660
|
description,
|
|
@@ -19566,6 +19687,8 @@ var OmpRpcSession = class {
|
|
|
19566
19687
|
const resultSummary = recentOutput.at(-1);
|
|
19567
19688
|
emit?.({
|
|
19568
19689
|
type: "subagent.updated",
|
|
19690
|
+
...subagentConfiguration(payload),
|
|
19691
|
+
...subagentConfiguration(progress),
|
|
19569
19692
|
callId,
|
|
19570
19693
|
nativeSubagentId,
|
|
19571
19694
|
status,
|
|
@@ -19800,7 +19923,7 @@ var OmpRpcSession = class {
|
|
|
19800
19923
|
throw new OmpRpcFaultError("protocolError", "Omp cancelled Session reload changed its identity or configuration");
|
|
19801
19924
|
}
|
|
19802
19925
|
}
|
|
19803
|
-
if (!
|
|
19926
|
+
if (!sessionSettled(response, active.terminalEnd)) {
|
|
19804
19927
|
active.settlement = "pending";
|
|
19805
19928
|
active.cancellationRecheck = setTimeout(() => {
|
|
19806
19929
|
active.cancellationRecheck = null;
|
|
@@ -19824,10 +19947,15 @@ var OmpRpcSession = class {
|
|
|
19824
19947
|
if (this.#activeTurn !== active || active.settlement !== "pending")
|
|
19825
19948
|
return;
|
|
19826
19949
|
active.localResult = result;
|
|
19827
|
-
active.settlement = "confirming";
|
|
19828
19950
|
void this.#confirmSettledTurn(active);
|
|
19829
19951
|
}
|
|
19830
19952
|
async #confirmSettledTurn(active) {
|
|
19953
|
+
if (this.#activeTurn !== active || active.settlement !== "pending" || active.cancellation !== "none" || !hasTurnCompletion(active))
|
|
19954
|
+
return;
|
|
19955
|
+
if (active.settlementRecheck)
|
|
19956
|
+
clearTimeout(active.settlementRecheck);
|
|
19957
|
+
active.settlementRecheck = null;
|
|
19958
|
+
active.settlement = "confirming";
|
|
19831
19959
|
try {
|
|
19832
19960
|
const response = await this.#send("get_state", {});
|
|
19833
19961
|
const state = parseSessionState(response);
|
|
@@ -19839,8 +19967,21 @@ var OmpRpcSession = class {
|
|
|
19839
19967
|
void this.#confirmCancelledTurn(active);
|
|
19840
19968
|
return;
|
|
19841
19969
|
}
|
|
19842
|
-
if (
|
|
19843
|
-
|
|
19970
|
+
if (!hasTurnCompletion(active)) {
|
|
19971
|
+
active.settlement = "pending";
|
|
19972
|
+
active.settledNotice = false;
|
|
19973
|
+
return;
|
|
19974
|
+
}
|
|
19975
|
+
if (!sessionSettled(response, hasTurnCompletion(active))) {
|
|
19976
|
+
active.settlement = "pending";
|
|
19977
|
+
if (active.settledNotice) {
|
|
19978
|
+
active.settledNotice = false;
|
|
19979
|
+
active.settlementRecheck = setTimeout(() => {
|
|
19980
|
+
active.settlementRecheck = null;
|
|
19981
|
+
void this.#confirmSettledTurn(active);
|
|
19982
|
+
}, 50);
|
|
19983
|
+
}
|
|
19984
|
+
return;
|
|
19844
19985
|
}
|
|
19845
19986
|
this.#state = state;
|
|
19846
19987
|
active.settlement = "confirmed";
|
|
@@ -19856,6 +19997,9 @@ var OmpRpcSession = class {
|
|
|
19856
19997
|
if (this.#activeTurn !== active || active.settlement !== "confirmed" || active.cancellation === "requesting") {
|
|
19857
19998
|
return;
|
|
19858
19999
|
}
|
|
20000
|
+
if (active.settlementRecheck)
|
|
20001
|
+
clearTimeout(active.settlementRecheck);
|
|
20002
|
+
active.settlementRecheck = null;
|
|
19859
20003
|
if (active.cancellationTimeout)
|
|
19860
20004
|
clearTimeout(active.cancellationTimeout);
|
|
19861
20005
|
active.cancellationTimeout = null;
|
|
@@ -20017,6 +20161,8 @@ var OmpRpcSession = class {
|
|
|
20017
20161
|
const active = this.#activeTurn;
|
|
20018
20162
|
if (!active)
|
|
20019
20163
|
return;
|
|
20164
|
+
if (active.settlementRecheck)
|
|
20165
|
+
clearTimeout(active.settlementRecheck);
|
|
20020
20166
|
if (active.cancellationTimeout)
|
|
20021
20167
|
clearTimeout(active.cancellationTimeout);
|
|
20022
20168
|
if (active.cancellationRecheck)
|
|
@@ -20791,6 +20937,7 @@ var OmpSubagentLifecycle = class {
|
|
|
20791
20937
|
subagentId: event.nativeSubagentId,
|
|
20792
20938
|
nativeSubagentId: event.nativeSubagentId,
|
|
20793
20939
|
description: event.description,
|
|
20940
|
+
...subagentConfiguration(event),
|
|
20794
20941
|
...event.role ? { role: event.role } : {},
|
|
20795
20942
|
background: event.background,
|
|
20796
20943
|
status: "running"
|
|
@@ -20815,6 +20962,7 @@ var OmpSubagentLifecycle = class {
|
|
|
20815
20962
|
throw new Error("Omp Subagent delegation has no Agent state");
|
|
20816
20963
|
const subagent = {
|
|
20817
20964
|
...current,
|
|
20965
|
+
...subagentConfiguration(event),
|
|
20818
20966
|
status: event.status === "interrupted" ? "interrupted" : event.status,
|
|
20819
20967
|
...event.description ? { description: event.description } : {},
|
|
20820
20968
|
...event.resultSummary ? { resultSummary: event.resultSummary } : {},
|
|
@@ -21365,7 +21513,19 @@ var OmpHarnessSession = class {
|
|
|
21365
21513
|
...event.resultSummary ? { resultSummary: event.resultSummary } : {}
|
|
21366
21514
|
});
|
|
21367
21515
|
}
|
|
21516
|
+
#subagentConfiguration() {
|
|
21517
|
+
const state = this.#state;
|
|
21518
|
+
const model2 = state.effectiveModel ? decodeOmpModelRef(state.effectiveModel).id : void 0;
|
|
21519
|
+
return {
|
|
21520
|
+
...model2 ? { model: model2 } : {},
|
|
21521
|
+
...state.effectiveThinkingOptionId ? { reasoningEffort: state.effectiveThinkingOptionId } : {}
|
|
21522
|
+
};
|
|
21523
|
+
}
|
|
21368
21524
|
async readSnapshot() {
|
|
21525
|
+
const result = await this.#readSnapshot();
|
|
21526
|
+
return result.ok ? { ok: true, value: configureSubagentSnapshot(result.value, this.#subagentConfiguration()) } : result;
|
|
21527
|
+
}
|
|
21528
|
+
async #readSnapshot() {
|
|
21369
21529
|
if (this.#phase !== "open" && this.#phase !== "faulted") {
|
|
21370
21530
|
return { ok: false, error: invalidState("Omp Session is not open") };
|
|
21371
21531
|
}
|
|
@@ -22552,6 +22712,7 @@ var OmpHarnessSession = class {
|
|
|
22552
22712
|
}
|
|
22553
22713
|
}
|
|
22554
22714
|
#event(event) {
|
|
22715
|
+
event = configureSubagentEvent(event, this.#subagentConfiguration());
|
|
22555
22716
|
this.#channel.emit({ kind: "event", event });
|
|
22556
22717
|
}
|
|
22557
22718
|
#newItemId() {
|