@nathapp/nax 0.91.7-canary.6 → 0.91.7-canary.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nax.js +1304 -569
- package/package.json +3 -3
package/dist/nax.js
CHANGED
|
@@ -4006,6 +4006,7 @@ var init_adapter_deps = __esm(() => {
|
|
|
4006
4006
|
_adapterDeps = {
|
|
4007
4007
|
listStoredProviders,
|
|
4008
4008
|
anyAmbientCredential,
|
|
4009
|
+
readEnv: (name) => process.env[name],
|
|
4009
4010
|
authSourceIsExec,
|
|
4010
4011
|
servedAuth,
|
|
4011
4012
|
setTimeout: (fn, ms) => setTimeout(fn, ms),
|
|
@@ -4045,6 +4046,7 @@ function toProviderOverrides(overrides) {
|
|
|
4045
4046
|
return overrides.map((override) => ({
|
|
4046
4047
|
provider: override.provider,
|
|
4047
4048
|
...override.baseUrl !== undefined ? { baseUrl: override.baseUrl } : {},
|
|
4049
|
+
...override.authEnv !== undefined ? { authEnv: override.authEnv } : {},
|
|
4048
4050
|
...override.headers !== undefined ? { headers: { ...override.headers } } : {},
|
|
4049
4051
|
models: override.models.map((model) => ({
|
|
4050
4052
|
id: model.id,
|
|
@@ -18957,6 +18959,9 @@ class NativeSessionAdapter {
|
|
|
18957
18959
|
return true;
|
|
18958
18960
|
if ((await _adapterDeps.listStoredProviders()).length > 0)
|
|
18959
18961
|
return true;
|
|
18962
|
+
if (this.catalogOverrides.some((override) => override.authEnv !== undefined && !!_adapterDeps.readEnv(override.authEnv))) {
|
|
18963
|
+
return true;
|
|
18964
|
+
}
|
|
18960
18965
|
return await _adapterDeps.anyAmbientCredential();
|
|
18961
18966
|
} catch {
|
|
18962
18967
|
return true;
|
|
@@ -27196,18 +27201,13 @@ var init_schemas_acp_agents = __esm(() => {
|
|
|
27196
27201
|
});
|
|
27197
27202
|
|
|
27198
27203
|
// src/config/schemas-model.ts
|
|
27199
|
-
function
|
|
27200
|
-
let url;
|
|
27204
|
+
function isRemotePlainHttp(value) {
|
|
27201
27205
|
try {
|
|
27202
|
-
url = new URL(value);
|
|
27206
|
+
const url = new URL(value);
|
|
27207
|
+
return url.protocol === "http:" && !LOOPBACK_HOSTS.has(url.hostname);
|
|
27203
27208
|
} catch {
|
|
27204
27209
|
return false;
|
|
27205
27210
|
}
|
|
27206
|
-
if (url.username !== "" || url.password !== "")
|
|
27207
|
-
return false;
|
|
27208
|
-
if (url.protocol === "https:")
|
|
27209
|
-
return true;
|
|
27210
|
-
return url.protocol === "http:" && LOOPBACK_HOSTS.has(url.hostname);
|
|
27211
27211
|
}
|
|
27212
27212
|
function isLegacyFlatModels(val) {
|
|
27213
27213
|
if (typeof val !== "object" || val === null)
|
|
@@ -27221,7 +27221,7 @@ function isLegacyFlatModels(val) {
|
|
|
27221
27221
|
}
|
|
27222
27222
|
return false;
|
|
27223
27223
|
}
|
|
27224
|
-
var ConfigPricingTierSchema, ConfigPricingSchema, ThinkingLevelSchema, CatalogPricingSchema, PercentileCutoffSchema, PercentileTargetSchema, OpenRouterRoutingSchema, CatalogModelOverrideSchema, LOOPBACK_HOSTS, BASE_URL_MESSAGE = "baseUrl must be an
|
|
27224
|
+
var ConfigPricingTierSchema, ConfigPricingSchema, ThinkingLevelSchema, CatalogPricingSchema, PercentileCutoffSchema, PercentileTargetSchema, OpenRouterRoutingSchema, CatalogModelOverrideSchema, LOOPBACK_HOSTS, BASE_URL_MESSAGE = "baseUrl must be an http or https URL and must not embed credentials", ProviderCatalogOverrideSchema, ModelDefSchema, ModelEntrySchema, PerAgentModelMapSchema, ModelMapSchema, ModelTierSchema, ConfiguredModelObjectSchema, ConfiguredModelSchema, TierConfigSchema;
|
|
27225
27225
|
var init_schemas_model = __esm(() => {
|
|
27226
27226
|
init_zod();
|
|
27227
27227
|
ConfigPricingTierSchema = object({
|
|
@@ -27276,17 +27276,38 @@ var init_schemas_model = __esm(() => {
|
|
|
27276
27276
|
thinkingLevels: array(ThinkingLevelSchema),
|
|
27277
27277
|
pricing: CatalogPricingSchema,
|
|
27278
27278
|
openRouterRouting: OpenRouterRoutingSchema.optional(),
|
|
27279
|
-
thinkingFormat: _enum(["openai", "qwen", "qwen-chat-template", "deepseek", "zai"]).optional()
|
|
27279
|
+
thinkingFormat: _enum(["openai", "qwen", "qwen-chat-template", "deepseek", "zai", "openrouter"]).optional()
|
|
27280
27280
|
}).strict();
|
|
27281
27281
|
LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
|
|
27282
27282
|
ProviderCatalogOverrideSchema = object({
|
|
27283
27283
|
provider: string2().min(1, "provider must be non-empty"),
|
|
27284
|
-
baseUrl: string2().
|
|
27284
|
+
baseUrl: string2().optional(),
|
|
27285
|
+
authEnv: string2().regex(/^[A-Z_][A-Z0-9_]*$/, "authEnv names an environment variable (e.g. STRATA_API_KEY)").optional(),
|
|
27286
|
+
allowInsecureHttp: boolean2().optional(),
|
|
27285
27287
|
headers: record2(string2(), string2()).refine((h) => Object.keys(h).length > 0, {
|
|
27286
27288
|
message: "headers must not be empty \u2014 omit the key to leave the provider's headers unchanged"
|
|
27287
27289
|
}).optional(),
|
|
27288
27290
|
models: array(CatalogModelOverrideSchema).min(1, "models must not be empty")
|
|
27289
|
-
}).strict()
|
|
27291
|
+
}).strict().superRefine((override, ctx) => {
|
|
27292
|
+
if (override.baseUrl === undefined)
|
|
27293
|
+
return;
|
|
27294
|
+
let url;
|
|
27295
|
+
try {
|
|
27296
|
+
url = new URL(override.baseUrl);
|
|
27297
|
+
} catch {
|
|
27298
|
+
ctx.addIssue({ code: "custom", path: ["baseUrl"], message: BASE_URL_MESSAGE });
|
|
27299
|
+
return;
|
|
27300
|
+
}
|
|
27301
|
+
if (url.username !== "" || url.password !== "" || !["http:", "https:"].includes(url.protocol)) {
|
|
27302
|
+
ctx.addIssue({ code: "custom", path: ["baseUrl"], message: BASE_URL_MESSAGE });
|
|
27303
|
+
} else if (isRemotePlainHttp(override.baseUrl) && override.allowInsecureHttp !== true) {
|
|
27304
|
+
ctx.addIssue({
|
|
27305
|
+
code: "custom",
|
|
27306
|
+
path: ["baseUrl"],
|
|
27307
|
+
message: "baseUrl uses remote http; set allowInsecureHttp: true to send this provider's credential over plain http"
|
|
27308
|
+
});
|
|
27309
|
+
}
|
|
27310
|
+
});
|
|
27290
27311
|
ModelDefSchema = object({
|
|
27291
27312
|
provider: string2().min(1, "Provider must be non-empty"),
|
|
27292
27313
|
model: string2().min(1, "Model must be non-empty"),
|
|
@@ -51727,7 +51748,7 @@ function findRetryAfterSeconds(payload) {
|
|
|
51727
51748
|
}
|
|
51728
51749
|
var QUOTA_PATTERN, MAX_EMBEDDED_CANDIDATES = 8;
|
|
51729
51750
|
var init_parse_agent_error = __esm(() => {
|
|
51730
|
-
QUOTA_PATTERN = /usage limit reached|token plan|exceeded your current quota|insufficient (credits|quota|balance)|purchase credits/i;
|
|
51751
|
+
QUOTA_PATTERN = /usage limit reached|token plan|exceeded your current quota|insufficient[ _](credits|quota|balance)|purchase credits/i;
|
|
51731
51752
|
});
|
|
51732
51753
|
|
|
51733
51754
|
// src/agents/errors/index.ts
|
|
@@ -52056,7 +52077,7 @@ var package_default;
|
|
|
52056
52077
|
var init_package = __esm(() => {
|
|
52057
52078
|
package_default = {
|
|
52058
52079
|
name: "@nathapp/nax",
|
|
52059
|
-
version: "0.91.7-canary.
|
|
52080
|
+
version: "0.91.7-canary.7",
|
|
52060
52081
|
description: "AI Coding Agent Orchestrator \u2014 loops until done",
|
|
52061
52082
|
type: "module",
|
|
52062
52083
|
bin: {
|
|
@@ -52142,11 +52163,11 @@ var init_package = __esm(() => {
|
|
|
52142
52163
|
"@agentclientprotocol/sdk": "~1.7.0",
|
|
52143
52164
|
"@anthropic-ai/sandbox-runtime": "0.0.77",
|
|
52144
52165
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
52145
|
-
"@nathapp/nax-ai": "0.91.7-canary.
|
|
52166
|
+
"@nathapp/nax-ai": "0.91.7-canary.7",
|
|
52146
52167
|
chalk: "^5.6.2",
|
|
52147
52168
|
commander: "^13.1.0",
|
|
52148
52169
|
"highlight.js": "^11.12.0",
|
|
52149
|
-
ink: "
|
|
52170
|
+
ink: "6.7.0",
|
|
52150
52171
|
"ink-spinner": "^5.0.0",
|
|
52151
52172
|
marked: "18.1.0",
|
|
52152
52173
|
react: "^19.2.4",
|
|
@@ -77453,8 +77474,8 @@ var init_version = __esm(() => {
|
|
|
77453
77474
|
NAX_AI_VERSION = CATALOG_VERSION;
|
|
77454
77475
|
NAX_COMMIT = (() => {
|
|
77455
77476
|
try {
|
|
77456
|
-
if (/^[0-9a-f]{6,10}$/.test("
|
|
77457
|
-
return "
|
|
77477
|
+
if (/^[0-9a-f]{6,10}$/.test("4bcd23e"))
|
|
77478
|
+
return "4bcd23e";
|
|
77458
77479
|
} catch {}
|
|
77459
77480
|
try {
|
|
77460
77481
|
const result = Bun.spawnSync(["git", "rev-parse", "--short", "HEAD"], {
|
|
@@ -103714,6 +103735,16 @@ async function resolveThread(ref, thread, deps, cwd) {
|
|
|
103714
103735
|
];
|
|
103715
103736
|
await runForgeWrite(ref, argv, deps, cwd);
|
|
103716
103737
|
}
|
|
103738
|
+
async function unresolveThread(ref, thread, deps, cwd) {
|
|
103739
|
+
const argv = ref.forge === "github" ? ["graphql", "-f", `query=${UNRESOLVE_REVIEW_THREAD}`, "-f", `id=${thread.id}`] : [
|
|
103740
|
+
"-X",
|
|
103741
|
+
"PUT",
|
|
103742
|
+
`projects/${encodeProjectPath(ref.repo)}/merge_requests/${ref.number}/discussions/${endpointId(ref, thread.id, GITLAB_DISCUSSION_ID)}`,
|
|
103743
|
+
"-f",
|
|
103744
|
+
"resolved=false"
|
|
103745
|
+
];
|
|
103746
|
+
await runForgeWrite(ref, argv, deps, cwd);
|
|
103747
|
+
}
|
|
103717
103748
|
async function editComment(ref, comment, body, deps, cwd) {
|
|
103718
103749
|
assertCommentBody(body);
|
|
103719
103750
|
if (ref.forge === "github" && comment.kind === "review") {
|
|
@@ -103736,7 +103767,7 @@ async function postPrComment(ref, body, deps, cwd) {
|
|
|
103736
103767
|
const url = "html_url" in reply ? reply.html_url : ("web_url" in reply) ? reply.web_url : undefined;
|
|
103737
103768
|
return { id: String(reply.id), ...typeof url === "string" ? { url } : {} };
|
|
103738
103769
|
}
|
|
103739
|
-
var MAX_FORGE_COMMENT_CHARS = 65536, NUMERIC_COMMENT_ID, GITLAB_DISCUSSION_ID, RESOLVE_REVIEW_THREAD = "mutation($id: ID!) { resolveReviewThread(input: {threadId: $id}) { thread { id isResolved } } }";
|
|
103770
|
+
var MAX_FORGE_COMMENT_CHARS = 65536, NUMERIC_COMMENT_ID, GITLAB_DISCUSSION_ID, UNRESOLVE_REVIEW_THREAD = "mutation($id: ID!) { unresolveReviewThread(input: {threadId: $id}) { thread { id isResolved } } }", RESOLVE_REVIEW_THREAD = "mutation($id: ID!) { resolveReviewThread(input: {threadId: $id}) { thread { id isResolved } } }";
|
|
103740
103771
|
var init_comments = __esm(() => {
|
|
103741
103772
|
init_errors4();
|
|
103742
103773
|
init_pr_read();
|
|
@@ -103875,6 +103906,26 @@ var init_issues = __esm(() => {
|
|
|
103875
103906
|
init_pr_read();
|
|
103876
103907
|
});
|
|
103877
103908
|
|
|
103909
|
+
// src/forge/marker-grammar.ts
|
|
103910
|
+
function isNaxBotMarkerKey(key) {
|
|
103911
|
+
return MARKER_KEY.exec(key)?.[0] === key;
|
|
103912
|
+
}
|
|
103913
|
+
function parseNaxBotMarker(body) {
|
|
103914
|
+
const pattern = markerPattern();
|
|
103915
|
+
let result = null;
|
|
103916
|
+
for (const match of body.matchAll(pattern)) {
|
|
103917
|
+
const key = match[1];
|
|
103918
|
+
if (key !== undefined)
|
|
103919
|
+
result = { key };
|
|
103920
|
+
}
|
|
103921
|
+
return result;
|
|
103922
|
+
}
|
|
103923
|
+
var TOP_LEVEL_MARKER_KEYS, MARKER_KEY_PATTERN = "[A-Za-z0-9._:-]{1,128}", markerPattern = () => new RegExp(`<!-- nax-bot:v1 key=(${MARKER_KEY_PATTERN}) -->`, "g"), MARKER_KEY;
|
|
103924
|
+
var init_marker_grammar = __esm(() => {
|
|
103925
|
+
TOP_LEVEL_MARKER_KEYS = ["summary", "w-index", "w-evidence", "fix-summary"];
|
|
103926
|
+
MARKER_KEY = new RegExp(`^${MARKER_KEY_PATTERN}$`);
|
|
103927
|
+
});
|
|
103928
|
+
|
|
103878
103929
|
// src/forge/threads.ts
|
|
103879
103930
|
function responseError4(ref, cause) {
|
|
103880
103931
|
return new NaxError(`[forge] Invalid response for ${ref.repo}#${ref.number}`, "FORGE_RESPONSE_UNPARSEABLE", {
|
|
@@ -103970,6 +104021,15 @@ function readGithubThreads(context) {
|
|
|
103970
104021
|
return { items: connection.nodes.map(githubThread), hasNextPage, nextCursor: endCursor ?? undefined };
|
|
103971
104022
|
});
|
|
103972
104023
|
}
|
|
104024
|
+
function isRepliedTopLevelNote(discussion) {
|
|
104025
|
+
if (discussion.individual_note !== false)
|
|
104026
|
+
return false;
|
|
104027
|
+
const first = discussion.notes.find((note) => !note.system);
|
|
104028
|
+
if (!first || first.position != null)
|
|
104029
|
+
return false;
|
|
104030
|
+
const marker = parseNaxBotMarker(first.body);
|
|
104031
|
+
return marker !== null && TOP_LEVEL_MARKER_KEYS.some((key) => key === marker.key);
|
|
104032
|
+
}
|
|
103973
104033
|
function gitlabThread(discussion) {
|
|
103974
104034
|
const first = discussion.notes[0];
|
|
103975
104035
|
const position = first?.position;
|
|
@@ -104022,7 +104082,7 @@ async function listPrComments(ref, deps, cwd) {
|
|
|
104022
104082
|
const endpoint = `projects/${encodeProjectPath(ref.repo)}/merge_requests/${ref.number}/discussions`;
|
|
104023
104083
|
const discussions = await readForgeRestPages(context, endpoint);
|
|
104024
104084
|
try {
|
|
104025
|
-
return discussions.filter((discussion) => discussion.individual_note === true).flatMap((discussion) => discussion.notes.filter((note) => !note.system).map((note) => ({
|
|
104085
|
+
return discussions.filter((discussion) => discussion.individual_note === true || isRepliedTopLevelNote(discussion)).flatMap((discussion) => discussion.notes.filter((note) => !note.system).map((note) => ({
|
|
104026
104086
|
id: String(note.id),
|
|
104027
104087
|
kind: "comment",
|
|
104028
104088
|
author: note.author.username,
|
|
@@ -104041,7 +104101,7 @@ async function listReviewThreads(ref, deps, cwd) {
|
|
|
104041
104101
|
const endpoint = `projects/${encodeProjectPath(ref.repo)}/merge_requests/${ref.number}/discussions`;
|
|
104042
104102
|
const discussions = await readForgeRestPages(context, endpoint);
|
|
104043
104103
|
try {
|
|
104044
|
-
return discussions.filter((discussion) => discussion.individual_note === false).map(gitlabThread);
|
|
104104
|
+
return discussions.filter((discussion) => discussion.individual_note === false && !isRepliedTopLevelNote(discussion)).map(gitlabThread);
|
|
104045
104105
|
} catch (cause) {
|
|
104046
104106
|
throw responseError4(ref, cause);
|
|
104047
104107
|
}
|
|
@@ -104060,6 +104120,7 @@ var MAX_FORGE_PAGES = 50, FORGE_PAGE_SIZE = 100, REVIEW_THREADS_QUERY = `query($
|
|
|
104060
104120
|
}`;
|
|
104061
104121
|
var init_threads = __esm(() => {
|
|
104062
104122
|
init_errors4();
|
|
104123
|
+
init_marker_grammar();
|
|
104063
104124
|
init_pr_read();
|
|
104064
104125
|
});
|
|
104065
104126
|
|
|
@@ -104119,9 +104180,6 @@ var init_trust2 = __esm(() => {
|
|
|
104119
104180
|
function hasNaxWorkflowMarker(body) {
|
|
104120
104181
|
return body.split(/\r?\n/).some((line) => line === NAX_WORKFLOW_PR_MARKER);
|
|
104121
104182
|
}
|
|
104122
|
-
function isNaxBotMarkerKey(key) {
|
|
104123
|
-
return MARKER_KEY.exec(key)?.[0] === key;
|
|
104124
|
-
}
|
|
104125
104183
|
function withNaxBotMarker(body, key) {
|
|
104126
104184
|
if (!isNaxBotMarkerKey(key)) {
|
|
104127
104185
|
throw new NaxError("[forge] Invalid nax bot marker key", "FORGE_MARKER_KEY_INVALID", { stage: "forge", key });
|
|
@@ -104132,16 +104190,6 @@ ${body}
|
|
|
104132
104190
|
|
|
104133
104191
|
<!-- nax-bot:v1 key=${key} -->`;
|
|
104134
104192
|
}
|
|
104135
|
-
function parseNaxBotMarker(body) {
|
|
104136
|
-
const pattern = markerPattern();
|
|
104137
|
-
let result = null;
|
|
104138
|
-
for (const match of body.matchAll(pattern)) {
|
|
104139
|
-
const key = match[1];
|
|
104140
|
-
if (key !== undefined)
|
|
104141
|
-
result = { key };
|
|
104142
|
-
}
|
|
104143
|
-
return result;
|
|
104144
|
-
}
|
|
104145
104193
|
function ownComments(comments, login, threadId) {
|
|
104146
104194
|
return comments.flatMap((comment) => {
|
|
104147
104195
|
if (comment.author !== login)
|
|
@@ -104155,12 +104203,13 @@ function ownComments(comments, login, threadId) {
|
|
|
104155
104203
|
function stripNaxBotMarkers(body) {
|
|
104156
104204
|
return body.replace(markerPattern(), "");
|
|
104157
104205
|
}
|
|
104158
|
-
var NAX_BOT_HEADER = "**nax bot**", NAX_WORKFLOW_PR_MARKER = "<!-- nax-workflow:v1 -->"
|
|
104206
|
+
var NAX_BOT_HEADER = "**nax bot**", NAX_WORKFLOW_PR_MARKER = "<!-- nax-workflow:v1 -->";
|
|
104159
104207
|
var init_marker = __esm(() => {
|
|
104160
104208
|
init_errors4();
|
|
104209
|
+
init_marker_grammar();
|
|
104161
104210
|
init_threads();
|
|
104162
104211
|
init_trust2();
|
|
104163
|
-
|
|
104212
|
+
init_marker_grammar();
|
|
104164
104213
|
});
|
|
104165
104214
|
|
|
104166
104215
|
// src/forge/pr.ts
|
|
@@ -104183,12 +104232,25 @@ async function hasOpenPr(forge, branch, deps, cwd) {
|
|
|
104183
104232
|
if (result.exitCode !== 0) {
|
|
104184
104233
|
throw new NaxError(`hasOpenPr: forge CLI exited with code ${result.exitCode}: ${result.stderr.trim()}`, "FORGE_PR_LIST_FAILED", { forge, branch, exitCode: result.exitCode });
|
|
104185
104234
|
}
|
|
104235
|
+
let parsed;
|
|
104186
104236
|
try {
|
|
104187
|
-
|
|
104188
|
-
|
|
104189
|
-
|
|
104190
|
-
|
|
104237
|
+
parsed = JSON.parse(result.stdout);
|
|
104238
|
+
} catch (cause) {
|
|
104239
|
+
throw new NaxError(`[forge] Cannot parse open PR list for ${branch}`, "FORGE_PR_LIST_UNPARSEABLE", {
|
|
104240
|
+
stage: "forge",
|
|
104241
|
+
forge,
|
|
104242
|
+
branch,
|
|
104243
|
+
cause
|
|
104244
|
+
});
|
|
104245
|
+
}
|
|
104246
|
+
if (!Array.isArray(parsed)) {
|
|
104247
|
+
throw new NaxError(`[forge] Open PR list is not an array for ${branch}`, "FORGE_PR_LIST_UNPARSEABLE", {
|
|
104248
|
+
stage: "forge",
|
|
104249
|
+
forge,
|
|
104250
|
+
branch
|
|
104251
|
+
});
|
|
104191
104252
|
}
|
|
104253
|
+
return parsed.length > 0;
|
|
104192
104254
|
}
|
|
104193
104255
|
async function openPr(forge, input, deps, cwd) {
|
|
104194
104256
|
const baseCmd = forge === "github" ? ["gh", "pr", "create", "--title", input.title, "--body", input.body] : ["glab", "mr", "create", "--title", input.title, "--description", input.body];
|
|
@@ -104382,6 +104444,7 @@ var init_forge = __esm(() => {
|
|
|
104382
104444
|
init_issues();
|
|
104383
104445
|
init_job_log();
|
|
104384
104446
|
init_marker();
|
|
104447
|
+
init_marker_grammar();
|
|
104385
104448
|
init_pr();
|
|
104386
104449
|
init_pr_read();
|
|
104387
104450
|
init_template();
|
|
@@ -124862,6 +124925,35 @@ var init_checks_config_secrets = __esm(() => {
|
|
|
124862
124925
|
_configSecretsCheckDeps = { scanConfigSecrets };
|
|
124863
124926
|
});
|
|
124864
124927
|
|
|
124928
|
+
// src/precheck/checks-catalog-endpoints.ts
|
|
124929
|
+
function checkCatalogEndpoints(catalogOverrides, env) {
|
|
124930
|
+
const checks = [];
|
|
124931
|
+
const warn = (message) => {
|
|
124932
|
+
checks.push({
|
|
124933
|
+
name: "catalog-endpoints",
|
|
124934
|
+
tier: "warning",
|
|
124935
|
+
passed: false,
|
|
124936
|
+
message: `[catalog-endpoints] ${message}`
|
|
124937
|
+
});
|
|
124938
|
+
};
|
|
124939
|
+
for (const override of catalogOverrides) {
|
|
124940
|
+
const { provider, baseUrl, authEnv, allowInsecureHttp } = override;
|
|
124941
|
+
if (baseUrl !== undefined && allowInsecureHttp === true && isRemotePlainHttp(baseUrl)) {
|
|
124942
|
+
warn(`Provider "${provider}" has allowInsecureHttp: true \u2014 its credential is sent unencrypted to ${new URL(baseUrl).host}.`);
|
|
124943
|
+
}
|
|
124944
|
+
if (authEnv && !env[authEnv]) {
|
|
124945
|
+
warn(`Provider "${provider}" authEnv variable ${authEnv} is unset or empty.`);
|
|
124946
|
+
}
|
|
124947
|
+
if (authEnv && baseUrl !== undefined) {
|
|
124948
|
+
warn(`Provider "${provider}" sends variable ${authEnv}'s value as the bearer credential to ${new URL(baseUrl).host}.`);
|
|
124949
|
+
}
|
|
124950
|
+
}
|
|
124951
|
+
return checks;
|
|
124952
|
+
}
|
|
124953
|
+
var init_checks_catalog_endpoints = __esm(() => {
|
|
124954
|
+
init_config();
|
|
124955
|
+
});
|
|
124956
|
+
|
|
124865
124957
|
// src/precheck/checks-model-resolution-walk.ts
|
|
124866
124958
|
function findTierEntryForAgent(entries, agent, tier) {
|
|
124867
124959
|
return entries.find((e) => e.agent === agent && e.tier === tier);
|
|
@@ -125135,6 +125227,7 @@ async function checkModelResolution(config) {
|
|
|
125135
125227
|
message: `Native catalog resolver rejected the bundled snapshot \u2014 every configured native id is treated as unverified until the catalog is back. Configure missing ids under agent.native.catalogOverrides. Sample unresolved ids: ${sample}.`
|
|
125136
125228
|
});
|
|
125137
125229
|
}
|
|
125230
|
+
checks.push(...checkCatalogEndpoints(catalogOverrides, _modelResolutionDeps.env));
|
|
125138
125231
|
if (checks.length === 0) {
|
|
125139
125232
|
return [{ name: "model-resolution", tier: "blocker", passed: true, message: "All configured model ids resolve" }];
|
|
125140
125233
|
}
|
|
@@ -125161,8 +125254,10 @@ function describeDroppedOverrides(entry) {
|
|
|
125161
125254
|
var _modelResolutionDeps;
|
|
125162
125255
|
var init_checks_model_resolution = __esm(() => {
|
|
125163
125256
|
init_src();
|
|
125257
|
+
init_checks_catalog_endpoints();
|
|
125164
125258
|
init_checks_model_resolution_walk();
|
|
125165
125259
|
_modelResolutionDeps = {
|
|
125260
|
+
env: process.env,
|
|
125166
125261
|
resolveNative: (provider, model, overrides) => resolveNativeId(provider, model, overrides)
|
|
125167
125262
|
};
|
|
125168
125263
|
});
|
|
@@ -131774,7 +131869,7 @@ function beforeReady(input, chars = FULL_TEXT) {
|
|
|
131774
131869
|
...shown,
|
|
131775
131870
|
...hidden > 0 ? [`- \u2026and ${hidden} more, see result.json verdict.openItems`] : [],
|
|
131776
131871
|
"",
|
|
131777
|
-
|
|
131872
|
+
`Then: rule on each item by replying on its thread, and run \`nax workflow promote -f ${safeCode(input.feature)} --yes\` to mark the PR ready once every item is settled and CI is green.`
|
|
131778
131873
|
].join(`
|
|
131779
131874
|
`);
|
|
131780
131875
|
}
|
|
@@ -132369,37 +132464,55 @@ function closedKey(key) {
|
|
|
132369
132464
|
function renderItemClosed(sha) {
|
|
132370
132465
|
return `No longer open in the run at ${sha.slice(0, SHORT_SHA_CHARS)}.`;
|
|
132371
132466
|
}
|
|
132467
|
+
function reopenKey(key) {
|
|
132468
|
+
return `wo-${key}`;
|
|
132469
|
+
}
|
|
132470
|
+
function renderItemReopened(sha) {
|
|
132471
|
+
return `Raised again by the run at ${sha.slice(0, SHORT_SHA_CHARS)}. Reply on this thread to rule on it.`;
|
|
132472
|
+
}
|
|
132372
132473
|
function validSha(sha) {
|
|
132373
132474
|
return sha !== undefined && SHA_PATTERN.exec(sha)?.[0] === sha ? sha : undefined;
|
|
132374
132475
|
}
|
|
132375
|
-
function renderItemIndex(index) {
|
|
132476
|
+
function renderItemIndex(index, settled = 0) {
|
|
132376
132477
|
const head = validSha(index.reviewedHead);
|
|
132377
132478
|
const base = head ? validSha(index.reviewedBase) : undefined;
|
|
132378
132479
|
return [
|
|
132379
|
-
`nax workflow
|
|
132480
|
+
`nax workflow items: ${index.keys.length} (${settled} settled)`,
|
|
132380
132481
|
`Reviewed head: ${head ?? "none"}`,
|
|
132381
132482
|
...base ? [`Reviewed base: ${base}`] : [],
|
|
132483
|
+
...(index.pendingReopens ?? []).map(({ key, commentId }) => `Pending reopen: ${key} ${commentId}`),
|
|
132382
132484
|
...index.keys.map((key) => `- ${key}`)
|
|
132383
132485
|
].join(`
|
|
132384
132486
|
`);
|
|
132385
132487
|
}
|
|
132386
132488
|
function parseItemIndex(body) {
|
|
132387
132489
|
const [countLine, headLine, ...rest] = bodyLines(body);
|
|
132388
|
-
const
|
|
132389
|
-
|
|
132490
|
+
const modern = /^nax workflow items: (\d+) \((\d+) settled\)$/.exec(countLine ?? "");
|
|
132491
|
+
const count = modern?.[1] ?? /^nax workflow open items: (\d+)$/.exec(countLine ?? "")?.[1];
|
|
132492
|
+
if (count === undefined || Number(modern?.[2] ?? 0) > Number(count))
|
|
132493
|
+
return null;
|
|
132494
|
+
if (!headLine?.startsWith("Reviewed head: "))
|
|
132390
132495
|
return null;
|
|
132391
132496
|
const head = validSha(headLine.slice("Reviewed head: ".length));
|
|
132392
132497
|
const baseLine = rest[0]?.startsWith("Reviewed base: ") ? rest.shift() : undefined;
|
|
132393
132498
|
const base = head && baseLine ? validSha(baseLine.slice("Reviewed base: ".length)) : undefined;
|
|
132499
|
+
const pendingReopens = [];
|
|
132500
|
+
while (rest[0]?.startsWith("Pending reopen: ")) {
|
|
132501
|
+
const match = /^Pending reopen: (\S+) (\d+)$/.exec(rest.shift() ?? "");
|
|
132502
|
+
if (!match?.[1] || !match[2])
|
|
132503
|
+
return null;
|
|
132504
|
+
pendingReopens.push({ key: match[1], commentId: match[2] });
|
|
132505
|
+
}
|
|
132394
132506
|
if (rest.some((line) => !line.startsWith("- ")) || rest.length !== Number(count))
|
|
132395
132507
|
return null;
|
|
132396
132508
|
return {
|
|
132397
132509
|
keys: rest.map((line) => line.slice(2)),
|
|
132510
|
+
...pendingReopens.length ? { pendingReopens } : {},
|
|
132398
132511
|
...head ? { reviewedHead: head } : {},
|
|
132399
132512
|
...base ? { reviewedBase: base } : {}
|
|
132400
132513
|
};
|
|
132401
132514
|
}
|
|
132402
|
-
var HASH_CHARS2 = 8, SHORT_SHA_CHARS = 7, MAX_REPLY_ID_CHARS = 20, ITEM_KEY_PATTERN, SHA_PATTERN, REPLY_INSTRUCTION = "Rule on it by replying: fixed <sha>, waive: <reason>, confirm, override: <reason>, or verified. Any other reply from a collaborator is read as a ruling only when its meaning is clear.", CHANGE_INSTRUCTION = "To change it, reply on this thread.", DISPOSITION_NAMES, KIND_NAMES;
|
|
132515
|
+
var HASH_CHARS2 = 8, SHORT_SHA_CHARS = 7, MAX_REPLY_ID_CHARS = 20, ITEM_KEY_PATTERN, SHA_PATTERN, REPLY_INSTRUCTION = "Rule on it by replying: fixed <sha>, waive: <reason>, confirm, override: <reason>, or verified. Any other reply from a collaborator is read as a ruling only when its meaning is clear.", CHANGE_INSTRUCTION = "To change it, reply on this thread.", DISPOSITION_NAMES, KIND_NAMES, REOPENED_BY_RERAISE;
|
|
132403
132516
|
var init_item_threads = __esm(() => {
|
|
132404
132517
|
init_errors4();
|
|
132405
132518
|
init_forge();
|
|
@@ -132424,10 +132537,14 @@ var init_item_threads = __esm(() => {
|
|
|
132424
132537
|
ci: true,
|
|
132425
132538
|
reason: true
|
|
132426
132539
|
};
|
|
132540
|
+
REOPENED_BY_RERAISE = new Set([
|
|
132541
|
+
"fixed",
|
|
132542
|
+
"verified"
|
|
132543
|
+
]);
|
|
132427
132544
|
});
|
|
132428
132545
|
|
|
132429
132546
|
// src/workflow/item-thread-state.ts
|
|
132430
|
-
function readThread(thread, login) {
|
|
132547
|
+
function readThread(thread, login, index) {
|
|
132431
132548
|
const own = ownComments(thread.comments, login);
|
|
132432
132549
|
const opener = own[0];
|
|
132433
132550
|
if (!opener || opener.comment !== thread.comments[0] || !opener.key.startsWith("w-"))
|
|
@@ -132436,7 +132553,8 @@ function readThread(thread, login) {
|
|
|
132436
132553
|
if (!identity)
|
|
132437
132554
|
return null;
|
|
132438
132555
|
const last = own.at(-1);
|
|
132439
|
-
const
|
|
132556
|
+
const pending = index?.pendingReopens?.some(({ key, commentId }) => key === opener.key && commentId === last?.comment.id);
|
|
132557
|
+
const parsed = !pending && last?.key.startsWith("wr-") ? parseRulingEcho(last.key, last.comment.body) : null;
|
|
132440
132558
|
const ruling = parsed?.itemKey === opener.key && parsed.itemId === identity.id ? parsed : undefined;
|
|
132441
132559
|
const boundary = last ? thread.comments.indexOf(last.comment) : 0;
|
|
132442
132560
|
const owned = new Set(own.map(({ comment }) => comment));
|
|
@@ -132453,7 +132571,7 @@ function readItemThreads(threads, comments, login) {
|
|
|
132453
132571
|
const indexComment = ownComments(comments, login).filter(({ key }) => key === "w-index").at(-1)?.comment;
|
|
132454
132572
|
const index = indexComment ? parseItemIndex(indexComment.body) : null;
|
|
132455
132573
|
const items = threads.flatMap((thread) => {
|
|
132456
|
-
const item = readThread(thread, login);
|
|
132574
|
+
const item = readThread(thread, login, index ?? undefined);
|
|
132457
132575
|
return item ? [item] : [];
|
|
132458
132576
|
});
|
|
132459
132577
|
return { items, ...indexComment ? { indexComment } : {}, ...index ? { index } : {} };
|
|
@@ -132511,10 +132629,23 @@ async function write(itemId, action) {
|
|
|
132511
132629
|
return false;
|
|
132512
132630
|
}
|
|
132513
132631
|
}
|
|
132514
|
-
async function
|
|
132632
|
+
async function writeItemIndex(index, context, settled = 0) {
|
|
132633
|
+
const { ref, read, deps, cwd } = context;
|
|
132634
|
+
const body = withNaxBotMarker(renderItemIndex(index, settled), "w-index");
|
|
132635
|
+
return write("w-index", async () => {
|
|
132636
|
+
const comment = read.indexComment ?? context.postedIndex;
|
|
132637
|
+
if (comment)
|
|
132638
|
+
await editComment(ref, comment, body, deps, cwd);
|
|
132639
|
+
else {
|
|
132640
|
+
const posted = await postPrComment(ref, body, deps, cwd);
|
|
132641
|
+
context.postedIndex = { id: posted.id, kind: "comment" };
|
|
132642
|
+
}
|
|
132643
|
+
});
|
|
132644
|
+
}
|
|
132645
|
+
async function maintainItemIndex(input, keys, context, options = {}) {
|
|
132515
132646
|
const { ref, read, login, deps, cwd } = context;
|
|
132516
|
-
const
|
|
132517
|
-
const indexed = await
|
|
132647
|
+
const reviewed = options.keepReviewed ? { reviewedHead: read.index?.reviewedHead, reviewedBase: read.index?.reviewedBase } : reviewedIndex(input, read.index);
|
|
132648
|
+
const indexed = await writeItemIndex({ keys, ...reviewed, pendingReopens: options.pendingReopens ?? read.index?.pendingReopens }, context, options.settled ?? 0);
|
|
132518
132649
|
const outcome = { closed: 0, failed: indexed ? 0 : 1 };
|
|
132519
132650
|
if (!indexed)
|
|
132520
132651
|
return outcome;
|
|
@@ -132538,6 +132669,68 @@ var init_item_threads_index = __esm(() => {
|
|
|
132538
132669
|
init_item_threads();
|
|
132539
132670
|
});
|
|
132540
132671
|
|
|
132672
|
+
// src/workflow/item-threads-reopen.ts
|
|
132673
|
+
async function reopenAction(item, context) {
|
|
132674
|
+
const last = ownComments(item.thread.comments, context.login).at(-1)?.key;
|
|
132675
|
+
if (last === reopenKey(item.key))
|
|
132676
|
+
return item.thread.resolved ? "unresolve" : undefined;
|
|
132677
|
+
const closed = last === closedKey(item.key);
|
|
132678
|
+
if (!closed && !context.pending && (!context.changed || !item.ruling || !REOPENED_BY_RERAISE.has(item.ruling.disposition)))
|
|
132679
|
+
return;
|
|
132680
|
+
const writers = await Promise.all(item.replies.map((reply) => context.canWrite({ login: reply.author, id: reply.authorId })));
|
|
132681
|
+
return writers.some(Boolean) ? closed && item.thread.resolved ? "unresolve" : undefined : "notice";
|
|
132682
|
+
}
|
|
132683
|
+
async function reopenReraisedItems(input, keys, context) {
|
|
132684
|
+
const reopened = new Set;
|
|
132685
|
+
const pendingReopens = (context.read.index?.pendingReopens ?? []).filter(({ key, commentId }) => keys.includes(key) && context.read.items.some((item) => item.key === key && ownComments(item.thread.comments, context.login).at(-1)?.comment.id === commentId));
|
|
132686
|
+
const head = reviewedIndex(input, context.read.index).reviewedHead;
|
|
132687
|
+
const changed = Boolean(head && head !== context.read.index?.reviewedHead);
|
|
132688
|
+
const { ref, read, deps, cwd } = context;
|
|
132689
|
+
const current = new Set(keys);
|
|
132690
|
+
const canWrite = writerCheck(context, hasWriteAccess, (login, error) => {
|
|
132691
|
+
getLogger2()?.warn("item-threads", "[item-threads] Could not check ruling permission", { login, error });
|
|
132692
|
+
});
|
|
132693
|
+
let failed = 0;
|
|
132694
|
+
for (const item of read.items) {
|
|
132695
|
+
if (!current.has(item.key))
|
|
132696
|
+
continue;
|
|
132697
|
+
const last = ownComments(item.thread.comments, context.login).at(-1)?.comment;
|
|
132698
|
+
const pending = pendingReopens.some(({ key, commentId }) => key === item.key && commentId === last?.id);
|
|
132699
|
+
const action = await reopenAction(item, { login: context.login, changed, pending, canWrite });
|
|
132700
|
+
if (!action)
|
|
132701
|
+
continue;
|
|
132702
|
+
reopened.add(item.key);
|
|
132703
|
+
try {
|
|
132704
|
+
if (action === "notice") {
|
|
132705
|
+
if (last && !pending)
|
|
132706
|
+
pendingReopens.push({ key: item.key, commentId: last.id });
|
|
132707
|
+
const indexed = await writeItemIndex({ ...read.index, keys, pendingReopens }, context);
|
|
132708
|
+
if (!indexed) {
|
|
132709
|
+
failed++;
|
|
132710
|
+
continue;
|
|
132711
|
+
}
|
|
132712
|
+
const body = withNaxBotMarker(renderItemReopened(input.head ?? context.info.headSha), reopenKey(item.key));
|
|
132713
|
+
await replyToThread(ref, item.thread, body, deps, cwd);
|
|
132714
|
+
}
|
|
132715
|
+
await unresolveThread(ref, item.thread, deps, cwd);
|
|
132716
|
+
} catch (error) {
|
|
132717
|
+
failed++;
|
|
132718
|
+
getLogger2()?.warn("item-threads", "[item-threads] Reopen write failed", {
|
|
132719
|
+
itemId: item.itemId,
|
|
132720
|
+
error: errorMessage(error)
|
|
132721
|
+
});
|
|
132722
|
+
}
|
|
132723
|
+
}
|
|
132724
|
+
return { reopened, failed, pendingReopens };
|
|
132725
|
+
}
|
|
132726
|
+
var init_item_threads_reopen = __esm(() => {
|
|
132727
|
+
init_internal();
|
|
132728
|
+
init_forge();
|
|
132729
|
+
init_logger2();
|
|
132730
|
+
init_item_threads();
|
|
132731
|
+
init_item_threads_index();
|
|
132732
|
+
});
|
|
132733
|
+
|
|
132541
132734
|
// src/workflow/item-threads-post.ts
|
|
132542
132735
|
import { posix as posix7 } from "path";
|
|
132543
132736
|
function warn3(identity, message, error) {
|
|
@@ -132616,7 +132809,16 @@ async function postItemThreads(input, deps = _featureDeps.forge) {
|
|
|
132616
132809
|
outcome.failed++;
|
|
132617
132810
|
}
|
|
132618
132811
|
}
|
|
132619
|
-
const
|
|
132812
|
+
const keys = items.map(itemKey);
|
|
132813
|
+
const maintenance = { ...snapshot, deps, cwd: input.projectDir };
|
|
132814
|
+
const reopen = await reopenReraisedItems(input, keys, maintenance);
|
|
132815
|
+
outcome.failed += reopen.failed;
|
|
132816
|
+
const settled = new Set(snapshot.read.items.filter((item) => item.ruling && item.replies.length === 0 && !reopen.reopened.has(item.key)).map((item) => item.key));
|
|
132817
|
+
const index = await maintainItemIndex(input, keys, maintenance, {
|
|
132818
|
+
keepReviewed: reopen.failed > 0,
|
|
132819
|
+
pendingReopens: reopen.pendingReopens,
|
|
132820
|
+
settled: keys.filter((key) => settled.has(key)).length
|
|
132821
|
+
});
|
|
132620
132822
|
return { ...outcome, closed: index.closed, failed: outcome.failed + index.failed };
|
|
132621
132823
|
}
|
|
132622
132824
|
var init_item_threads_post = __esm(async () => {
|
|
@@ -132627,6 +132829,7 @@ var init_item_threads_post = __esm(async () => {
|
|
|
132627
132829
|
init_item_thread_state();
|
|
132628
132830
|
init_item_threads();
|
|
132629
132831
|
init_item_threads_index();
|
|
132832
|
+
init_item_threads_reopen();
|
|
132630
132833
|
init_open_items();
|
|
132631
132834
|
await init_feature_deps();
|
|
132632
132835
|
});
|
|
@@ -140988,6 +141191,20 @@ function boundedSummary(prefix, sections, suffix) {
|
|
|
140988
141191
|
return withNaxBotMarker([...prefix, ...lists, ...notice, ...suffix].join(`
|
|
140989
141192
|
`), "summary");
|
|
140990
141193
|
}
|
|
141194
|
+
function itemStatusLines(status) {
|
|
141195
|
+
if (status === undefined)
|
|
141196
|
+
return [];
|
|
141197
|
+
const lines = [];
|
|
141198
|
+
if (status.recorded.length > 0) {
|
|
141199
|
+
const shown = status.recorded.slice(0, ITEM_RULING_LIMIT).map(({ id, disposition, by }) => `${safeText(id, ITEM_ID_LIMIT)} ${disposition} by ${by === null ? "nax bot" : `@${by}`}`);
|
|
141200
|
+
const hidden = status.recorded.length - shown.length;
|
|
141201
|
+
if (hidden > 0)
|
|
141202
|
+
shown.push(`and ${hidden} more`);
|
|
141203
|
+
lines.push(`Item rulings recorded: ${status.recorded.length} (${shown.join(", ")}).`);
|
|
141204
|
+
}
|
|
141205
|
+
lines.push(`Open items: ${status.open} of ${status.total}.`);
|
|
141206
|
+
return lines;
|
|
141207
|
+
}
|
|
140991
141208
|
function readinessLines(input) {
|
|
140992
141209
|
const lines = [];
|
|
140993
141210
|
if (input.earlier) {
|
|
@@ -141029,6 +141246,7 @@ function renderReviewSummary(input) {
|
|
|
141029
141246
|
const prefix = [
|
|
141030
141247
|
`Review of ${input.headSha.slice(0, SHORT_SHA_LENGTH2)}${scopeSuffix(input.scope, input.incrementalSince)}: intent ${input.intent}, quality ${input.quality}.`,
|
|
141031
141248
|
`${input.inlineFindings} inline findings, ${input.threadsAnswered} threads answered, ${input.commentVerdicts.length} comments answered.`,
|
|
141249
|
+
...itemStatusLines(input.itemStatus),
|
|
141032
141250
|
...readinessLines(input)
|
|
141033
141251
|
];
|
|
141034
141252
|
if (input.staticMode)
|
|
@@ -141036,7 +141254,7 @@ function renderReviewSummary(input) {
|
|
|
141036
141254
|
const suffix = input.failed > 0 ? [`Could not post ${input.failed} comments; re-run nax bot review.`] : [];
|
|
141037
141255
|
return boundedSummary(prefix, summarySections(input), suffix);
|
|
141038
141256
|
}
|
|
141039
|
-
var TEXT_LIMIT = 2000, AUTHOR_LIMIT = 100, SHORT_SHA_LENGTH2 = 7, SUMMARY_RESERVE = 512, DECISION_LABELS;
|
|
141257
|
+
var TEXT_LIMIT = 2000, AUTHOR_LIMIT = 100, ITEM_RULING_LIMIT = 20, ITEM_ID_LIMIT = 100, SHORT_SHA_LENGTH2 = 7, SUMMARY_RESERVE = 512, DECISION_LABELS;
|
|
141040
141258
|
var init_render_comments = __esm(async () => {
|
|
141041
141259
|
init_forge();
|
|
141042
141260
|
init_pr_body_safe();
|
|
@@ -141393,9 +141611,22 @@ async function writeFinding(input, finding) {
|
|
|
141393
141611
|
const body = renderFindingComment(finding);
|
|
141394
141612
|
if (own) {
|
|
141395
141613
|
await editComment(input.ref, own.comment, body, input.deps, input.cwd);
|
|
141614
|
+
if (own.threadId !== undefined && input.resolvedThreadIds?.has(own.threadId)) {
|
|
141615
|
+
try {
|
|
141616
|
+
await unresolveThread(input.ref, { id: own.threadId }, input.deps, input.cwd);
|
|
141617
|
+
} catch (cause) {
|
|
141618
|
+
getLogger2()?.warn("bot-post", "Could not reopen a re-raised finding thread", {
|
|
141619
|
+
key: own.key,
|
|
141620
|
+
threadId: own.threadId,
|
|
141621
|
+
error: errorMessage(cause)
|
|
141622
|
+
});
|
|
141623
|
+
return false;
|
|
141624
|
+
}
|
|
141625
|
+
}
|
|
141396
141626
|
} else if (finding.file !== undefined && finding.line !== undefined) {
|
|
141397
141627
|
await postInlineComment(input.ref, { path: finding.file, line: finding.line, body, headSha: input.info.headSha, diffRefs: input.info.diffRefs }, input.deps, input.cwd);
|
|
141398
141628
|
}
|
|
141629
|
+
return true;
|
|
141399
141630
|
}
|
|
141400
141631
|
async function postFindings(input) {
|
|
141401
141632
|
const seen = new Set;
|
|
@@ -141418,8 +141649,10 @@ async function postFindings(input) {
|
|
|
141418
141649
|
continue;
|
|
141419
141650
|
}
|
|
141420
141651
|
try {
|
|
141421
|
-
await writeFinding(input, finding)
|
|
141422
|
-
|
|
141652
|
+
if (await writeFinding(input, finding))
|
|
141653
|
+
inlineFindings++;
|
|
141654
|
+
else
|
|
141655
|
+
offLine.push(finding);
|
|
141423
141656
|
} catch (cause) {
|
|
141424
141657
|
if (input.own.some((own) => own.key === key))
|
|
141425
141658
|
throw cause;
|
|
@@ -141460,6 +141693,7 @@ async function postThreads(input) {
|
|
|
141460
141693
|
async function postSummary(input, findings, threads) {
|
|
141461
141694
|
const body = renderReviewSummary({
|
|
141462
141695
|
headSha: input.info.headSha,
|
|
141696
|
+
...input.itemStatus === undefined ? {} : { itemStatus: input.itemStatus },
|
|
141463
141697
|
...input.scope === undefined ? {} : { scope: input.scope },
|
|
141464
141698
|
...input.incrementalSince === undefined ? {} : { incrementalSince: input.incrementalSince },
|
|
141465
141699
|
intent: input.verdict.intent,
|
|
@@ -142076,6 +142310,20 @@ async function readModelCandidates(input, open) {
|
|
|
142076
142310
|
}
|
|
142077
142311
|
return result;
|
|
142078
142312
|
}
|
|
142313
|
+
async function refreshIndex(input, read, settled) {
|
|
142314
|
+
if (!read.index || !read.indexComment)
|
|
142315
|
+
return;
|
|
142316
|
+
const keys = new Set(read.index.keys);
|
|
142317
|
+
const count = new Set(settled.filter((item) => keys.has(item.key)).map((item) => item.key)).size;
|
|
142318
|
+
const body = withNaxBotMarker(renderItemIndex(read.index, count), "w-index");
|
|
142319
|
+
if (body === read.indexComment.body)
|
|
142320
|
+
return;
|
|
142321
|
+
try {
|
|
142322
|
+
await _rulingsDeps.editComment(input.ref, read.indexComment, body, input.deps, input.cwd);
|
|
142323
|
+
} catch (error) {
|
|
142324
|
+
warn5("Could not refresh the item index", { error: errorMessage(error) });
|
|
142325
|
+
}
|
|
142326
|
+
}
|
|
142079
142327
|
async function recordPrRulings(input) {
|
|
142080
142328
|
const read = readItemThreads(input.threads, input.comments, input.login);
|
|
142081
142329
|
const initial = await settleItemThreads(read, permissionReader(input));
|
|
@@ -142106,6 +142354,7 @@ async function recordPrRulings(input) {
|
|
|
142106
142354
|
await resolve53(input, item);
|
|
142107
142355
|
}
|
|
142108
142356
|
await tickBody(input, settled);
|
|
142357
|
+
await refreshIndex(input, read, settled);
|
|
142109
142358
|
const unindexed = unindexedItemKeys(read, input.login);
|
|
142110
142359
|
return {
|
|
142111
142360
|
...read.index ? { index: read.index } : {},
|
|
@@ -142130,6 +142379,7 @@ var init_rulings2 = __esm(() => {
|
|
|
142130
142379
|
init_ruling_keyword();
|
|
142131
142380
|
init_writers();
|
|
142132
142381
|
_rulingsDeps = {
|
|
142382
|
+
editComment,
|
|
142133
142383
|
hasWriteAccess,
|
|
142134
142384
|
readPrInfo,
|
|
142135
142385
|
replyToThread,
|
|
@@ -142317,6 +142567,17 @@ async function writeEvidence(env, outcome, own) {
|
|
|
142317
142567
|
return `evidence comment failed: ${errorMessage(error)}`;
|
|
142318
142568
|
}
|
|
142319
142569
|
}
|
|
142570
|
+
async function readyHeadHold(env, state) {
|
|
142571
|
+
try {
|
|
142572
|
+
const fresh = await _fixReportDeps.readPrInfo(env.ref, env.forge, env.repoRoot);
|
|
142573
|
+
if (fresh.headSha !== (state.pushedSha ?? env.info.headSha))
|
|
142574
|
+
return "PR head changed since this execution";
|
|
142575
|
+
} catch (error) {
|
|
142576
|
+
env.ctx.callCtx.runtime.signal.throwIfAborted();
|
|
142577
|
+
getLogger2()?.warn("bot-fix", "Could not re-read PR head", { pr: env.ref.number, error: errorMessage(error) });
|
|
142578
|
+
return "PR head could not be re-read";
|
|
142579
|
+
}
|
|
142580
|
+
}
|
|
142320
142581
|
async function readyStep(env, state) {
|
|
142321
142582
|
if (state.pushedSha && !await _fixReportDeps.waitForPrHead({ ref: env.ref, repoRoot: env.repoRoot, sha: state.pushedSha }))
|
|
142322
142583
|
return {
|
|
@@ -142335,15 +142596,15 @@ async function readyStep(env, state) {
|
|
|
142335
142596
|
if (!ciAllowsReady(ci.outcome)) {
|
|
142336
142597
|
return { patch: { markedReady: false, readyHeld: `CI ${ci.outcome}: ${ci.detail}` }, exit: "report" };
|
|
142337
142598
|
}
|
|
142599
|
+
const readyHeld = await readyHeadHold(env, state);
|
|
142600
|
+
if (readyHeld)
|
|
142601
|
+
return { patch: { markedReady: false, readyHeld }, exit: "report" };
|
|
142338
142602
|
}
|
|
142339
142603
|
env.ctx.callCtx.runtime.signal.throwIfAborted();
|
|
142340
|
-
const result = await env.forge.run(markReadyArgv(env.ref.forge,
|
|
142604
|
+
const result = await env.forge.run(markReadyArgv(env.ref.forge, env.info.url), { cwd: env.repoRoot });
|
|
142341
142605
|
if (result.exitCode !== 0) {
|
|
142342
|
-
|
|
142343
|
-
|
|
142344
|
-
exitCode: result.exitCode,
|
|
142345
|
-
stderr: result.stderr
|
|
142346
|
-
});
|
|
142606
|
+
const detail = result.stderr.trim() || `exit code ${result.exitCode}`;
|
|
142607
|
+
return { patch: { markedReady: false, readyHeld: `could not mark ready: ${detail}` }, exit: "report" };
|
|
142347
142608
|
}
|
|
142348
142609
|
return { patch: { markedReady: true }, exit: "report" };
|
|
142349
142610
|
}
|
|
@@ -142769,7 +143030,13 @@ async function pushStep(env, _state) {
|
|
|
142769
143030
|
const unsafe = await unsafeTree(env, _state);
|
|
142770
143031
|
if (unsafe)
|
|
142771
143032
|
return unsafe;
|
|
142772
|
-
const result = await _fixStepsDeps.runGit([
|
|
143033
|
+
const result = await _fixStepsDeps.runGit([
|
|
143034
|
+
"push",
|
|
143035
|
+
"--no-verify",
|
|
143036
|
+
`--force-with-lease=refs/heads/${env.info.headRef}:${env.info.headSha}`,
|
|
143037
|
+
"origin",
|
|
143038
|
+
`HEAD:refs/heads/${env.info.headRef}`
|
|
143039
|
+
], env.checkout.worktree, PUSH_TIMEOUT_MS2);
|
|
142773
143040
|
if (result.timedOut)
|
|
142774
143041
|
return { patch: { outcome: "push-unknown" }, exit: "rejected" };
|
|
142775
143042
|
if (result.exitCode !== 0)
|
|
@@ -143059,6 +143326,17 @@ var init_repair_step = __esm(async () => {
|
|
|
143059
143326
|
});
|
|
143060
143327
|
|
|
143061
143328
|
// src/bot/review-rulings.ts
|
|
143329
|
+
function itemStatus(outcome) {
|
|
143330
|
+
if (outcome.index === undefined)
|
|
143331
|
+
return;
|
|
143332
|
+
const settled = new Set(outcome.settled.map(({ key }) => key));
|
|
143333
|
+
const total = outcome.index.keys.length;
|
|
143334
|
+
return {
|
|
143335
|
+
recorded: outcome.recorded.map(({ itemId, disposition, by }) => ({ id: itemId, disposition, by })),
|
|
143336
|
+
open: total - outcome.index.keys.filter((key) => settled.has(key)).length,
|
|
143337
|
+
total
|
|
143338
|
+
};
|
|
143339
|
+
}
|
|
143062
143340
|
async function readReviewRulings(input, record) {
|
|
143063
143341
|
const { staticMode, ctx, ...raw } = input;
|
|
143064
143342
|
if (staticMode || !hasNaxWorkflowMarker(raw.info.body))
|
|
@@ -143070,6 +143348,7 @@ async function readReviewRulings(input, record) {
|
|
|
143070
143348
|
});
|
|
143071
143349
|
return {
|
|
143072
143350
|
reviewedIndex: outcome.index,
|
|
143351
|
+
...outcome.index === undefined ? {} : { itemStatus: itemStatus(outcome) },
|
|
143073
143352
|
settled: outcome.settled.map((item) => ({
|
|
143074
143353
|
id: item.itemId,
|
|
143075
143354
|
kind: item.kind,
|
|
@@ -143507,6 +143786,7 @@ async function reviewEnvironment(input, prepared, context) {
|
|
|
143507
143786
|
},
|
|
143508
143787
|
earlier: postEarlier,
|
|
143509
143788
|
settledKeys: new Set(findings.settled.map(({ ruling }) => ruling.id)),
|
|
143789
|
+
resolvedThreadIds: new Set(ownFindingThreads.filter(({ resolved }) => resolved).map(({ id }) => id)),
|
|
143510
143790
|
...rulings !== undefined && { rulings },
|
|
143511
143791
|
scope,
|
|
143512
143792
|
...scope === "incremental" && { incrementalSince: range.rangeBase },
|
|
@@ -145027,6 +145307,32 @@ var init_chat_agents_listing = __esm(() => {
|
|
|
145027
145307
|
init_subagent_tools();
|
|
145028
145308
|
});
|
|
145029
145309
|
|
|
145310
|
+
// src/chat/chat-effort.ts
|
|
145311
|
+
function isEffortLevel(text) {
|
|
145312
|
+
return EFFORT_LEVELS.some((level) => level === text);
|
|
145313
|
+
}
|
|
145314
|
+
function modelEffort(model) {
|
|
145315
|
+
const { effort } = parseModelSpec(model);
|
|
145316
|
+
return effort !== undefined && isEffortLevel(effort) ? effort : "default";
|
|
145317
|
+
}
|
|
145318
|
+
function withEffort2(model, level) {
|
|
145319
|
+
const { model: base } = parseModelSpec(model);
|
|
145320
|
+
return level === "default" ? base : `${base}[${level}]`;
|
|
145321
|
+
}
|
|
145322
|
+
function cycleEffort(level, step) {
|
|
145323
|
+
const index = EFFORT_LEVELS.indexOf(level);
|
|
145324
|
+
return EFFORT_LEVELS[(index + step + EFFORT_LEVELS.length) % EFFORT_LEVELS.length];
|
|
145325
|
+
}
|
|
145326
|
+
var EFFORT_LEVELS;
|
|
145327
|
+
var init_chat_effort = __esm(() => {
|
|
145328
|
+
init_src();
|
|
145329
|
+
init_internal();
|
|
145330
|
+
EFFORT_LEVELS = [
|
|
145331
|
+
"default",
|
|
145332
|
+
...Object.keys(THINKING_LEVELS)
|
|
145333
|
+
];
|
|
145334
|
+
});
|
|
145335
|
+
|
|
145030
145336
|
// src/chat/chat-ledger.ts
|
|
145031
145337
|
import { join as join181 } from "path";
|
|
145032
145338
|
function createChatLedger(options) {
|
|
@@ -146991,7 +147297,12 @@ async function openChatSession(request, deps = _openChatSessionDeps) {
|
|
|
146991
147297
|
};
|
|
146992
147298
|
const doc = await transcripts.load(meta.sessionId);
|
|
146993
147299
|
const session = doc === null ? await deps.createAgentSession(options) : await deps.resumeAgentSession(meta.sessionId, options);
|
|
146994
|
-
return {
|
|
147300
|
+
return {
|
|
147301
|
+
session,
|
|
147302
|
+
meta,
|
|
147303
|
+
release,
|
|
147304
|
+
history: doc === null ? { messages: [] } : { messages: doc.messages, savedAt: doc.savedAt }
|
|
147305
|
+
};
|
|
146995
147306
|
} catch (error) {
|
|
146996
147307
|
await release();
|
|
146997
147308
|
throw error;
|
|
@@ -147020,6 +147331,67 @@ var init_open_chat_session = __esm(() => {
|
|
|
147020
147331
|
};
|
|
147021
147332
|
});
|
|
147022
147333
|
|
|
147334
|
+
// src/chat/session-hygiene.ts
|
|
147335
|
+
function hasHadTurn(meta) {
|
|
147336
|
+
return meta.updatedAt !== null;
|
|
147337
|
+
}
|
|
147338
|
+
async function resumableRows(input) {
|
|
147339
|
+
const rows = await Promise.all(input.sessions.map(async ({ sessionId, title, updatedAt }) => {
|
|
147340
|
+
if (sessionId === input.currentId)
|
|
147341
|
+
return null;
|
|
147342
|
+
let meta;
|
|
147343
|
+
try {
|
|
147344
|
+
meta = await input.storage.readMeta(sessionId);
|
|
147345
|
+
} catch (error) {
|
|
147346
|
+
if (!(error instanceof Error && ("code" in error) && error.code === "SESSION_META_UNREADABLE"))
|
|
147347
|
+
throw error;
|
|
147348
|
+
input.logger.warn("chat", "skipping unreadable session metadata", { sessionId });
|
|
147349
|
+
return null;
|
|
147350
|
+
}
|
|
147351
|
+
if (meta === null || meta.sessionId !== sessionId || !hasHadTurn(meta))
|
|
147352
|
+
return null;
|
|
147353
|
+
const holder = await input.storage.readLockHolder(sessionId);
|
|
147354
|
+
return { sessionId, title, updatedAt, ...holder?.state === "live" ? { heldByPid: holder.pid } : {} };
|
|
147355
|
+
}));
|
|
147356
|
+
return rows.filter((row) => row !== null);
|
|
147357
|
+
}
|
|
147358
|
+
async function removeIfEmpty(input) {
|
|
147359
|
+
const { sessionId, history, sentOn, storage, logger } = input;
|
|
147360
|
+
if (history === undefined || history.messages.length > 0 || sentOn.has(sessionId))
|
|
147361
|
+
return;
|
|
147362
|
+
try {
|
|
147363
|
+
const meta = await storage.readMeta(sessionId);
|
|
147364
|
+
if (meta !== null && meta.sessionId === sessionId && !hasHadTurn(meta))
|
|
147365
|
+
await storage.removeMeta(sessionId);
|
|
147366
|
+
} catch (cause) {
|
|
147367
|
+
logger.warn("chat", "could not remove empty session", { sessionId, cause });
|
|
147368
|
+
}
|
|
147369
|
+
}
|
|
147370
|
+
function createSessionHygiene(deps) {
|
|
147371
|
+
const sentOn = new Set;
|
|
147372
|
+
return {
|
|
147373
|
+
markSent: (sessionId) => {
|
|
147374
|
+
sentOn.add(sessionId);
|
|
147375
|
+
},
|
|
147376
|
+
async close(handle, nextId) {
|
|
147377
|
+
try {
|
|
147378
|
+
try {
|
|
147379
|
+
await handle.session.close();
|
|
147380
|
+
} finally {
|
|
147381
|
+
await handle.release({ retainLock: true });
|
|
147382
|
+
}
|
|
147383
|
+
} finally {
|
|
147384
|
+
try {
|
|
147385
|
+
if (handle.meta.sessionId !== nextId)
|
|
147386
|
+
await removeIfEmpty({ ...deps, sessionId: handle.meta.sessionId, history: handle.history, sentOn });
|
|
147387
|
+
} finally {
|
|
147388
|
+
await handle.release();
|
|
147389
|
+
}
|
|
147390
|
+
}
|
|
147391
|
+
}
|
|
147392
|
+
};
|
|
147393
|
+
}
|
|
147394
|
+
|
|
147023
147395
|
// src/chat/subagent-session.ts
|
|
147024
147396
|
async function subagentSessionOptions(input, posture, deps) {
|
|
147025
147397
|
const settings = chatSessionSettings(input.mode, posture);
|
|
@@ -147302,7 +147674,7 @@ async function writeTurnMeta(options, costUsd) {
|
|
|
147302
147674
|
...handle.meta,
|
|
147303
147675
|
updatedAt: now,
|
|
147304
147676
|
costUsd: (stored.costUsd ?? 0) + costUsd + (options.extraCostUsd?.() ?? 0),
|
|
147305
|
-
title: stored.title ?? [...message.trim().replace(/\s+/gu, " ")].slice(0, TITLE_CODE_POINT_LIMIT).join("")
|
|
147677
|
+
title: stored.title ?? [...(options.title?.trim() || message).trim().replace(/\s+/gu, " ")].slice(0, TITLE_CODE_POINT_LIMIT).join("")
|
|
147306
147678
|
};
|
|
147307
147679
|
await storage.writeMeta(meta);
|
|
147308
147680
|
return meta;
|
|
@@ -147344,14 +147716,6 @@ var init_turn_runner = __esm(() => {
|
|
|
147344
147716
|
});
|
|
147345
147717
|
|
|
147346
147718
|
// src/chat/chat-host.ts
|
|
147347
|
-
async function closeHandle(handle) {
|
|
147348
|
-
try {
|
|
147349
|
-
await handle.session.close();
|
|
147350
|
-
} finally {
|
|
147351
|
-
await handle.release();
|
|
147352
|
-
}
|
|
147353
|
-
}
|
|
147354
|
-
|
|
147355
147719
|
class NativeChatHost {
|
|
147356
147720
|
deps;
|
|
147357
147721
|
repoRoot;
|
|
@@ -147364,6 +147728,7 @@ class NativeChatHost {
|
|
|
147364
147728
|
confirmJobsBeforeClose;
|
|
147365
147729
|
hostJobs;
|
|
147366
147730
|
fallback;
|
|
147731
|
+
hygiene;
|
|
147367
147732
|
loopHandlers;
|
|
147368
147733
|
projectKey;
|
|
147369
147734
|
outputDir;
|
|
@@ -147381,6 +147746,7 @@ class NativeChatHost {
|
|
|
147381
147746
|
sessionOperations = new Set;
|
|
147382
147747
|
constructor(deps) {
|
|
147383
147748
|
this.deps = deps;
|
|
147749
|
+
this.hygiene = createSessionHygiene(deps);
|
|
147384
147750
|
this.repoRoot = deps.repoRoot;
|
|
147385
147751
|
this.catalog = deps.resources?.catalog;
|
|
147386
147752
|
this.naxPlugins = deps.resources?.naxPlugins;
|
|
@@ -147453,6 +147819,9 @@ class NativeChatHost {
|
|
|
147453
147819
|
throw new NaxError("[chat] no session is open", "CHAT_SESSION_NOT_OPEN", { stage: "chat" });
|
|
147454
147820
|
return this.handle;
|
|
147455
147821
|
}
|
|
147822
|
+
history() {
|
|
147823
|
+
return this.handle?.history ?? { messages: [] };
|
|
147824
|
+
}
|
|
147456
147825
|
current() {
|
|
147457
147826
|
const handle = this.handle;
|
|
147458
147827
|
if (!handle)
|
|
@@ -147520,7 +147889,7 @@ class NativeChatHost {
|
|
|
147520
147889
|
}
|
|
147521
147890
|
async replace(next) {
|
|
147522
147891
|
if (this.closed) {
|
|
147523
|
-
await
|
|
147892
|
+
await this.hygiene.close(next);
|
|
147524
147893
|
this.assertOpen();
|
|
147525
147894
|
}
|
|
147526
147895
|
const previous = this.handle;
|
|
@@ -147537,7 +147906,7 @@ class NativeChatHost {
|
|
|
147537
147906
|
this.asks.reset();
|
|
147538
147907
|
this.asks.setMode(next.meta.mode === "full" ? "full" : "guarded");
|
|
147539
147908
|
if (previous)
|
|
147540
|
-
await
|
|
147909
|
+
await this.hygiene.close(previous, next.meta.sessionId);
|
|
147541
147910
|
}
|
|
147542
147911
|
notice() {
|
|
147543
147912
|
return this.resumeNotice;
|
|
@@ -147563,7 +147932,7 @@ class NativeChatHost {
|
|
|
147563
147932
|
for (const { sessionId } of await this.allSessions()) {
|
|
147564
147933
|
try {
|
|
147565
147934
|
const meta = await this.deps.storage.readMeta(sessionId);
|
|
147566
|
-
if (meta === null || meta.sessionId !== sessionId || chatModeOfMeta(meta.mode) === null)
|
|
147935
|
+
if (meta === null || !hasHadTurn(meta) || meta.sessionId !== sessionId || chatModeOfMeta(meta.mode) === null)
|
|
147567
147936
|
continue;
|
|
147568
147937
|
if ((await this.deps.storage.readLockHolder(sessionId))?.state !== "live")
|
|
147569
147938
|
return sessionId;
|
|
@@ -147671,7 +148040,7 @@ class NativeChatHost {
|
|
|
147671
148040
|
const { mode, model } = this.current();
|
|
147672
148041
|
await this.start({ mode, model });
|
|
147673
148042
|
}
|
|
147674
|
-
async send(message, onEvent) {
|
|
148043
|
+
async send(message, onEvent, options) {
|
|
147675
148044
|
const handle = this.requireHandle();
|
|
147676
148045
|
const ledger = this.ledger;
|
|
147677
148046
|
if (!ledger)
|
|
@@ -147679,6 +148048,7 @@ class NativeChatHost {
|
|
|
147679
148048
|
if (this.sending) {
|
|
147680
148049
|
throw new NaxError("[chat] a turn is already running", "CHAT_TURN_BUSY", { stage: "chat" });
|
|
147681
148050
|
}
|
|
148051
|
+
this.hygiene.markSent(handle.meta.sessionId);
|
|
147682
148052
|
this.sending = true;
|
|
147683
148053
|
this.turnListener = onEvent;
|
|
147684
148054
|
const runs = this.runs;
|
|
@@ -147688,6 +148058,7 @@ class NativeChatHost {
|
|
|
147688
148058
|
handle,
|
|
147689
148059
|
storage: this.deps.storage,
|
|
147690
148060
|
message,
|
|
148061
|
+
title: options?.title,
|
|
147691
148062
|
asks: this.asks,
|
|
147692
148063
|
ledger,
|
|
147693
148064
|
onEvent,
|
|
@@ -147722,10 +148093,7 @@ class NativeChatHost {
|
|
|
147722
148093
|
}
|
|
147723
148094
|
async listSessions() {
|
|
147724
148095
|
const sessions = await this.allSessions();
|
|
147725
|
-
return
|
|
147726
|
-
const holder = await this.deps.storage.readLockHolder(sessionId);
|
|
147727
|
-
return { sessionId, title, updatedAt, ...holder?.state === "live" ? { heldByPid: holder.pid } : {} };
|
|
147728
|
-
}));
|
|
148096
|
+
return resumableRows({ ...this.deps, sessions, currentId: this.handle?.meta.sessionId });
|
|
147729
148097
|
}
|
|
147730
148098
|
close() {
|
|
147731
148099
|
if (this.closing !== undefined)
|
|
@@ -147748,7 +148116,7 @@ class NativeChatHost {
|
|
|
147748
148116
|
async closeSessionAndResources() {
|
|
147749
148117
|
try {
|
|
147750
148118
|
if (this.handle)
|
|
147751
|
-
await
|
|
148119
|
+
await this.hygiene.close(this.handle);
|
|
147752
148120
|
} finally {
|
|
147753
148121
|
try {
|
|
147754
148122
|
await this.deps.resources?.teardown();
|
|
@@ -147890,6 +148258,44 @@ function formatMcpListing(state) {
|
|
|
147890
148258
|
}
|
|
147891
148259
|
var NO_SERVERS = "(no MCP servers)";
|
|
147892
148260
|
|
|
148261
|
+
// src/chat/session-title.ts
|
|
148262
|
+
function sessionTitleText(title, sessionId) {
|
|
148263
|
+
if (title === null)
|
|
148264
|
+
return `untitled ${sessionId.slice(0, SESSION_ID_CHARS)}`;
|
|
148265
|
+
const skill = /^<skill name="([^"]*)"\s/u.exec(title);
|
|
148266
|
+
return skill ? `/${skill[1]}` : title;
|
|
148267
|
+
}
|
|
148268
|
+
var SESSION_ID_CHARS = 8;
|
|
148269
|
+
|
|
148270
|
+
// src/chat/skill-invocation.ts
|
|
148271
|
+
function parseSkillInvocation(content) {
|
|
148272
|
+
const name = SKILL_HEADER.exec(content)?.[1];
|
|
148273
|
+
if (name === undefined)
|
|
148274
|
+
return;
|
|
148275
|
+
const withoutArgs = content.endsWith(SKILL_CLOSE);
|
|
148276
|
+
const delimiter = withoutArgs ? SKILL_CLOSE : SKILL_ARGS_DELIMITER;
|
|
148277
|
+
const close = content.lastIndexOf(delimiter);
|
|
148278
|
+
const headerEnd = content.indexOf(`
|
|
148279
|
+
`);
|
|
148280
|
+
const referencesEnd = content.indexOf(`
|
|
148281
|
+
`, headerEnd + 1);
|
|
148282
|
+
if (headerEnd < 0 || referencesEnd < 0 || close < referencesEnd + 1)
|
|
148283
|
+
return;
|
|
148284
|
+
return {
|
|
148285
|
+
name,
|
|
148286
|
+
args: withoutArgs ? "" : content.slice(close + delimiter.length).trim(),
|
|
148287
|
+
body: content.slice(referencesEnd + 1, close)
|
|
148288
|
+
};
|
|
148289
|
+
}
|
|
148290
|
+
var SKILL_HEADER, SKILL_CLOSE = `
|
|
148291
|
+
</skill>`, SKILL_ARGS_DELIMITER;
|
|
148292
|
+
var init_skill_invocation = __esm(() => {
|
|
148293
|
+
SKILL_HEADER = /^<skill name="([^"]+)"\s/;
|
|
148294
|
+
SKILL_ARGS_DELIMITER = `${SKILL_CLOSE}
|
|
148295
|
+
|
|
148296
|
+
`;
|
|
148297
|
+
});
|
|
148298
|
+
|
|
147893
148299
|
// src/workflow/supplementary-items.ts
|
|
147894
148300
|
function listedDecisionIds(openItems) {
|
|
147895
148301
|
return new Set(openItems.flatMap((item) => [item.id, ...item.ruling?.decisionId ? [item.ruling.decisionId] : []]));
|
|
@@ -148243,12 +148649,14 @@ var init_chat = __esm(() => {
|
|
|
148243
148649
|
init_ask_controller();
|
|
148244
148650
|
init_ask_fallback();
|
|
148245
148651
|
init_chat_agents_listing();
|
|
148652
|
+
init_chat_effort();
|
|
148246
148653
|
init_chat_host();
|
|
148247
148654
|
init_chat_ledger();
|
|
148248
148655
|
init_chat_mcp();
|
|
148249
148656
|
init_chat_mode();
|
|
148250
148657
|
init_jobs();
|
|
148251
148658
|
init_open_chat_session();
|
|
148659
|
+
init_skill_invocation();
|
|
148252
148660
|
init_subagent_model();
|
|
148253
148661
|
init_subagent_tools();
|
|
148254
148662
|
init_turn_runner();
|
|
@@ -164697,7 +165105,7 @@ var visibleLineCount = (lines, str) => str.endsWith(`
|
|
|
164697
165105
|
const extraSlot = previousHadTrailingNewline ? 1 : 0;
|
|
164698
165106
|
buffer.push(eraseLines(previousVisible - visibleCount + extraSlot), cursorUp(visibleCount));
|
|
164699
165107
|
} else {
|
|
164700
|
-
buffer.push(cursorUp(
|
|
165108
|
+
buffer.push(cursorUp(previousLines.length - 1));
|
|
164701
165109
|
}
|
|
164702
165110
|
for (let i = 0;i < visibleCount; i++) {
|
|
164703
165111
|
const isLastLine = i === visibleCount - 1;
|
|
@@ -168477,16 +168885,31 @@ var init_relative_time = __esm(() => {
|
|
|
168477
168885
|
MONTH_LABELS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
168478
168886
|
});
|
|
168479
168887
|
|
|
168480
|
-
// src/tui/chat/
|
|
168888
|
+
// src/tui/chat/picker-model.ts
|
|
168481
168889
|
function displayText(text) {
|
|
168482
168890
|
return oneLine4(sanitizeText(text));
|
|
168483
168891
|
}
|
|
168484
168892
|
function modelEntries(input) {
|
|
168485
|
-
|
|
168486
|
-
|
|
168487
|
-
|
|
168488
|
-
|
|
168489
|
-
|
|
168893
|
+
const choices = new Map;
|
|
168894
|
+
const currentBase = parseModelSpec(input.currentModel).model;
|
|
168895
|
+
for (const original of input.models) {
|
|
168896
|
+
const base = parseModelSpec(original).model;
|
|
168897
|
+
if (!choices.has(base))
|
|
168898
|
+
choices.set(base, original);
|
|
168899
|
+
}
|
|
168900
|
+
return Array.from(choices, ([base, first]) => {
|
|
168901
|
+
const current = base === currentBase;
|
|
168902
|
+
const original = current ? input.currentModel : first;
|
|
168903
|
+
const effortLabel = input.pending?.get(base) ?? parseModelSpec(original).effort ?? "default";
|
|
168904
|
+
return {
|
|
168905
|
+
value: base,
|
|
168906
|
+
label: displayText(base),
|
|
168907
|
+
original,
|
|
168908
|
+
effortLabel,
|
|
168909
|
+
detail: displayText(`effort ${effortLabel}`),
|
|
168910
|
+
current
|
|
168911
|
+
};
|
|
168912
|
+
});
|
|
168490
168913
|
}
|
|
168491
168914
|
function matchingEntries(entries, query) {
|
|
168492
168915
|
const needle = query.toLowerCase();
|
|
@@ -168501,7 +168924,7 @@ function modeEntries(input) {
|
|
|
168501
168924
|
}));
|
|
168502
168925
|
}
|
|
168503
168926
|
function sessionEntry(row, nowMs) {
|
|
168504
|
-
const title = row.title
|
|
168927
|
+
const title = sessionTitleText(row.title, row.sessionId);
|
|
168505
168928
|
const updated = relativeTime(row.updatedAt, nowMs);
|
|
168506
168929
|
return {
|
|
168507
168930
|
value: row.sessionId,
|
|
@@ -168520,6 +168943,14 @@ function resumeNote(input) {
|
|
|
168520
168943
|
function pickerModel(input) {
|
|
168521
168944
|
if (input.kind === "mode")
|
|
168522
168945
|
return { kind: "mode", title: TITLES3.mode, entries: modeEntries(input) };
|
|
168946
|
+
if (input.kind === "effort") {
|
|
168947
|
+
const current = modelEffort(input.currentModel);
|
|
168948
|
+
return {
|
|
168949
|
+
kind: "effort",
|
|
168950
|
+
title: TITLES3.effort,
|
|
168951
|
+
entries: EFFORT_LEVELS.map((level) => ({ value: level, label: level, current: level === current }))
|
|
168952
|
+
};
|
|
168953
|
+
}
|
|
168523
168954
|
if (input.kind === "model") {
|
|
168524
168955
|
const allEntries = modelEntries(input);
|
|
168525
168956
|
const entries = matchingEntries(allEntries, input.query ?? "");
|
|
@@ -168542,73 +168973,40 @@ function pickerModel(input) {
|
|
|
168542
168973
|
...note === undefined ? {} : { note }
|
|
168543
168974
|
};
|
|
168544
168975
|
}
|
|
168976
|
+
var LOADING = "loading\u2026", NO_SESSIONS = "no saved sessions", TITLES3, MODE_CHOICES, _pickerDeps;
|
|
168977
|
+
var init_picker_model = __esm(async () => {
|
|
168978
|
+
init_src();
|
|
168979
|
+
init_chat();
|
|
168980
|
+
init_relative_time();
|
|
168981
|
+
await __promiseAll([
|
|
168982
|
+
init_layout_lines(),
|
|
168983
|
+
init_styled_line()
|
|
168984
|
+
]);
|
|
168985
|
+
TITLES3 = {
|
|
168986
|
+
model: "Switch model",
|
|
168987
|
+
resume: "Resume a session",
|
|
168988
|
+
mode: "Permission mode",
|
|
168989
|
+
effort: "Reasoning effort"
|
|
168990
|
+
};
|
|
168991
|
+
MODE_CHOICES = [
|
|
168992
|
+
{ mode: "guarded", detail: "asks before risky actions" },
|
|
168993
|
+
{ mode: "full", detail: "never asks; runs outside the sandbox when it is unavailable" }
|
|
168994
|
+
];
|
|
168995
|
+
_pickerDeps = { now: () => Date.now() };
|
|
168996
|
+
});
|
|
168997
|
+
|
|
168998
|
+
// src/tui/chat/useChatPicker.ts
|
|
168545
168999
|
function pickerMode(value) {
|
|
168546
169000
|
return value === "full" ? "full" : "guarded";
|
|
168547
169001
|
}
|
|
168548
|
-
function fixedRows(model) {
|
|
168549
|
-
return FRAME_ROWS + (model.kind === "model" ? 1 : 0) + (model.note === undefined ? 0 : 1);
|
|
168550
|
-
}
|
|
168551
|
-
function visibleEntries(model, budget) {
|
|
168552
|
-
return Math.min(model.entries.length, PICKER_MAX_ROWS, Math.max(0, budget - fixedRows(model)));
|
|
168553
|
-
}
|
|
168554
|
-
function windowStart2(count, selected, rows) {
|
|
168555
|
-
return Math.max(FIRST_ENTRY, Math.min(selected - rows + 1, count - rows));
|
|
168556
|
-
}
|
|
168557
|
-
function ruleRow2(theme, columns) {
|
|
168558
|
-
return [styled2(theme.glyphs.rule.repeat(columns), { color: "border" })];
|
|
168559
|
-
}
|
|
168560
|
-
function pointerPrefix(theme, chosen) {
|
|
168561
|
-
const pointer = theme.glyphs.pointer;
|
|
168562
|
-
if (!chosen)
|
|
168563
|
-
return styled2(SPACE3.repeat(displayWidth(pointer) + SPACE3.length));
|
|
168564
|
-
return styled2(`${pointer}${SPACE3}`, { color: "accent" });
|
|
168565
|
-
}
|
|
168566
|
-
function heldLabel(pid) {
|
|
168567
|
-
return `in use (pid ${pid})`;
|
|
168568
|
-
}
|
|
168569
|
-
function entryRow(entry, chosen, theme, columns) {
|
|
168570
|
-
const spans = [pointerPrefix(theme, chosen), styled2(entry.label, chosen ? { bold: true } : {})];
|
|
168571
|
-
if (entry.detail !== undefined)
|
|
168572
|
-
spans.push(styled2(`${COLUMN_GAP}${entry.detail}`, { color: "muted" }));
|
|
168573
|
-
if (entry.current === true)
|
|
168574
|
-
spans.push(styled2(`${COLUMN_GAP}${CURRENT_MARK}`, { color: "accent" }));
|
|
168575
|
-
if (entry.heldPid !== undefined) {
|
|
168576
|
-
spans.push(styled2(`${COLUMN_GAP}${heldLabel(entry.heldPid)}`, { color: "warning" }));
|
|
168577
|
-
}
|
|
168578
|
-
return cutSpans(spans, columns);
|
|
168579
|
-
}
|
|
168580
|
-
function noteRow(note, theme, columns) {
|
|
168581
|
-
const text = displayText(note.text);
|
|
168582
|
-
const spans = note.tone === "warning" ? [styled2(`${theme.glyphs.warning}${SPACE3}`, { color: "warning" }), styled2(text, { color: "warning" })] : [styled2(text, { color: "muted" })];
|
|
168583
|
-
return cutSpans(spans, columns);
|
|
168584
|
-
}
|
|
168585
|
-
function pickerRows(model, budget) {
|
|
168586
|
-
return fixedRows(model) + visibleEntries(model, Math.max(1, Math.floor(budget)));
|
|
168587
|
-
}
|
|
168588
|
-
function pickerLayout(model, options) {
|
|
168589
|
-
const columns = resolveWidth2(options.width);
|
|
168590
|
-
const budget = Math.max(1, Math.floor(options.budget));
|
|
168591
|
-
const rows = visibleEntries(model, budget);
|
|
168592
|
-
const last = Math.max(FIRST_ENTRY, model.entries.length - 1);
|
|
168593
|
-
const selected = Math.min(Math.max(options.selected ?? FIRST_ENTRY, FIRST_ENTRY), last);
|
|
168594
|
-
const first = windowStart2(model.entries.length, selected, rows);
|
|
168595
|
-
const lines = [
|
|
168596
|
-
ruleRow2(options.theme, columns),
|
|
168597
|
-
cutSpans([styled2(displayText(model.title), { bold: true })], columns),
|
|
168598
|
-
...model.kind === "model" ? [
|
|
168599
|
-
cutSpans([styled2(model.query ? `Filter: ${displayText(model.query)}` : "type to filter", { color: "muted" })], columns)
|
|
168600
|
-
] : [],
|
|
168601
|
-
...model.entries.slice(first, first + rows).map((entry, at) => entryRow(entry, first + at === selected, options.theme, columns)),
|
|
168602
|
-
...model.note === undefined ? [] : [noteRow(model.note, options.theme, columns)],
|
|
168603
|
-
ruleRow2(options.theme, columns)
|
|
168604
|
-
];
|
|
168605
|
-
return { selected, first, rows: lines.length, lines };
|
|
168606
|
-
}
|
|
168607
169002
|
function actionFor(host, kind, entry) {
|
|
168608
169003
|
if (kind === "model")
|
|
168609
|
-
return host.switchTo({ model: entry.value });
|
|
169004
|
+
return host.switchTo({ model: entry.original ?? entry.value });
|
|
168610
169005
|
if (kind === "mode")
|
|
168611
169006
|
return host.switchTo({ mode: pickerMode(entry.value) });
|
|
169007
|
+
if (kind === "effort") {
|
|
169008
|
+
return isEffortLevel(entry.value) ? host.switchTo({ model: withEffort2(host.current().model, entry.value) }) : Promise.resolve();
|
|
169009
|
+
}
|
|
168612
169010
|
return host.resume({ id: entry.value });
|
|
168613
169011
|
}
|
|
168614
169012
|
function heldWarning(sessionId, pid) {
|
|
@@ -168618,6 +169016,7 @@ function modelOf(state, current, models) {
|
|
|
168618
169016
|
return pickerModel({
|
|
168619
169017
|
kind: state.kind,
|
|
168620
169018
|
query: state.query,
|
|
169019
|
+
pending: state.pending,
|
|
168621
169020
|
models,
|
|
168622
169021
|
currentModel: current.model,
|
|
168623
169022
|
currentMode: current.mode,
|
|
@@ -168628,14 +169027,17 @@ function modelOf(state, current, models) {
|
|
|
168628
169027
|
function useChatPicker({ host, runControl, onError }) {
|
|
168629
169028
|
const [state, setState] = import_react31.useState(undefined);
|
|
168630
169029
|
const openings = import_react31.useRef(0);
|
|
169030
|
+
const pending = import_react31.useRef(new Map);
|
|
168631
169031
|
const cancel = import_react31.useCallback(() => {
|
|
168632
169032
|
openings.current += 1;
|
|
169033
|
+
pending.current = new Map;
|
|
168633
169034
|
setState(undefined);
|
|
168634
169035
|
}, []);
|
|
168635
169036
|
const open = import_react31.useCallback((kind) => {
|
|
168636
169037
|
openings.current += 1;
|
|
168637
169038
|
const opening = openings.current;
|
|
168638
|
-
|
|
169039
|
+
pending.current = new Map;
|
|
169040
|
+
setState({ kind, query: "", pending: pending.current });
|
|
168639
169041
|
if (kind !== "resume")
|
|
168640
169042
|
return;
|
|
168641
169043
|
host.listSessions().then((sessions) => {
|
|
@@ -168661,17 +169063,109 @@ function useChatPicker({ host, runControl, onError }) {
|
|
|
168661
169063
|
}
|
|
168662
169064
|
openings.current += 1;
|
|
168663
169065
|
setState(undefined);
|
|
168664
|
-
|
|
169066
|
+
const level = pending.current.get(entry.value);
|
|
169067
|
+
const chosen = kind === "model" && level !== undefined ? { ...entry, original: withEffort2(entry.value, level) } : entry;
|
|
169068
|
+
pending.current = new Map;
|
|
169069
|
+
runControl(() => actionFor(host, kind, chosen));
|
|
168665
169070
|
}, [state, host, runControl]);
|
|
168666
169071
|
const current = state === undefined ? undefined : host.current();
|
|
168667
169072
|
const model = state === undefined || current === undefined ? undefined : modelOf(state, current, host.models);
|
|
168668
169073
|
const setQuery = import_react31.useCallback((query) => {
|
|
168669
169074
|
setState((current) => current?.kind === "model" ? { ...current, query } : current);
|
|
168670
169075
|
}, []);
|
|
168671
|
-
|
|
169076
|
+
const cycle = import_react31.useCallback((entry, step) => {
|
|
169077
|
+
if (state?.kind !== "model")
|
|
169078
|
+
return;
|
|
169079
|
+
const initial = entry.effortLabel ?? "default";
|
|
169080
|
+
const level = pending.current.get(entry.value) ?? (isEffortLevel(initial) ? initial : "default");
|
|
169081
|
+
const next = new Map(pending.current);
|
|
169082
|
+
next.set(entry.value, cycleEffort(level, step));
|
|
169083
|
+
pending.current = next;
|
|
169084
|
+
setState((current) => current?.kind === "model" ? { ...current, pending: next } : current);
|
|
169085
|
+
}, [state?.kind]);
|
|
169086
|
+
return { model, open, cancel, choose, setQuery, cycle };
|
|
169087
|
+
}
|
|
169088
|
+
var import_react31;
|
|
169089
|
+
var init_useChatPicker = __esm(async () => {
|
|
169090
|
+
init_chat();
|
|
169091
|
+
await init_picker_model();
|
|
169092
|
+
import_react31 = __toESM(require_react(), 1);
|
|
169093
|
+
});
|
|
169094
|
+
|
|
169095
|
+
// src/tui/chat/Picker.tsx
|
|
169096
|
+
function fixedRows(model) {
|
|
169097
|
+
return FRAME_ROWS + (model.kind === "model" ? 1 : 0) + (model.note === undefined ? 0 : 1);
|
|
169098
|
+
}
|
|
169099
|
+
function visibleEntries(model, budget) {
|
|
169100
|
+
return Math.min(model.entries.length, PICKER_MAX_ROWS, Math.max(0, budget - fixedRows(model)));
|
|
169101
|
+
}
|
|
169102
|
+
function windowStart2(count, selected, rows) {
|
|
169103
|
+
return Math.max(FIRST_ENTRY, Math.min(selected - rows + 1, count - rows));
|
|
168672
169104
|
}
|
|
168673
|
-
function
|
|
168674
|
-
return
|
|
169105
|
+
function ruleRow2(theme, columns) {
|
|
169106
|
+
return [styled2(theme.glyphs.rule.repeat(columns), { color: "border" })];
|
|
169107
|
+
}
|
|
169108
|
+
function pointerPrefix(theme, chosen) {
|
|
169109
|
+
const pointer = theme.glyphs.pointer;
|
|
169110
|
+
if (!chosen)
|
|
169111
|
+
return styled2(SPACE3.repeat(displayWidth(pointer) + SPACE3.length));
|
|
169112
|
+
return styled2(`${pointer}${SPACE3}`, { color: "accent" });
|
|
169113
|
+
}
|
|
169114
|
+
function heldLabel(pid) {
|
|
169115
|
+
return `in use (pid ${pid})`;
|
|
169116
|
+
}
|
|
169117
|
+
function entryRow(entry, chosen, theme, columns) {
|
|
169118
|
+
const spans = [pointerPrefix(theme, chosen), styled2(entry.label, chosen ? { bold: true } : {})];
|
|
169119
|
+
if (entry.detail !== undefined)
|
|
169120
|
+
spans.push(styled2(`${COLUMN_GAP}${entry.detail}`, { color: "muted" }));
|
|
169121
|
+
if (entry.current === true)
|
|
169122
|
+
spans.push(styled2(`${COLUMN_GAP}${CURRENT_MARK}`, { color: "accent" }));
|
|
169123
|
+
if (entry.heldPid !== undefined) {
|
|
169124
|
+
spans.push(styled2(`${COLUMN_GAP}${heldLabel(entry.heldPid)}`, { color: "warning" }));
|
|
169125
|
+
}
|
|
169126
|
+
return cutSpans(spans, columns);
|
|
169127
|
+
}
|
|
169128
|
+
function noteRow(note, theme, columns) {
|
|
169129
|
+
const text = displayText(note.text);
|
|
169130
|
+
const spans = note.tone === "warning" ? [styled2(`${theme.glyphs.warning}${SPACE3}`, { color: "warning" }), styled2(text, { color: "warning" })] : [styled2(text, { color: "muted" })];
|
|
169131
|
+
return cutSpans(spans, columns);
|
|
169132
|
+
}
|
|
169133
|
+
function pickerRows(model, budget) {
|
|
169134
|
+
return fixedRows(model) + visibleEntries(model, Math.max(1, Math.floor(budget)));
|
|
169135
|
+
}
|
|
169136
|
+
function pickerLayout(model, options) {
|
|
169137
|
+
const columns = resolveWidth2(options.width);
|
|
169138
|
+
const budget = Math.max(1, Math.floor(options.budget));
|
|
169139
|
+
const rows = visibleEntries(model, budget);
|
|
169140
|
+
const last = Math.max(FIRST_ENTRY, model.entries.length - 1);
|
|
169141
|
+
const selected = Math.min(Math.max(options.selected ?? FIRST_ENTRY, FIRST_ENTRY), last);
|
|
169142
|
+
const first = windowStart2(model.entries.length, selected, rows);
|
|
169143
|
+
const lines = [
|
|
169144
|
+
ruleRow2(options.theme, columns),
|
|
169145
|
+
cutSpans([styled2(displayText(model.title), { bold: true })], columns),
|
|
169146
|
+
...model.kind === "model" ? [
|
|
169147
|
+
cutSpans([styled2(model.query ? `Filter: ${displayText(model.query)}` : "type to filter", { color: "muted" })], columns)
|
|
169148
|
+
] : [],
|
|
169149
|
+
...model.entries.slice(first, first + rows).map((entry, at) => entryRow(entry, first + at === selected, options.theme, columns)),
|
|
169150
|
+
...model.note === undefined ? [] : [noteRow(model.note, options.theme, columns)],
|
|
169151
|
+
ruleRow2(options.theme, columns)
|
|
169152
|
+
];
|
|
169153
|
+
return { selected, first, rows: lines.length, lines };
|
|
169154
|
+
}
|
|
169155
|
+
function ownsPickerKey(key, kind) {
|
|
169156
|
+
return Boolean(key.escape || key.return || key.upArrow || key.downArrow || kind === "model" && (key.leftArrow || key.rightArrow));
|
|
169157
|
+
}
|
|
169158
|
+
function applyEntryKey(key, entry, actions) {
|
|
169159
|
+
if (key.return)
|
|
169160
|
+
actions.onChoose(entry);
|
|
169161
|
+
else if (key.upArrow)
|
|
169162
|
+
actions.move(-1);
|
|
169163
|
+
else if (key.downArrow)
|
|
169164
|
+
actions.move(1);
|
|
169165
|
+
else if (key.leftArrow)
|
|
169166
|
+
actions.onCycle?.(entry, -1);
|
|
169167
|
+
else if (key.rightArrow)
|
|
169168
|
+
actions.onCycle?.(entry, 1);
|
|
168675
169169
|
}
|
|
168676
169170
|
function editedQuery(input, key, query) {
|
|
168677
169171
|
if (key.ctrl || key.meta)
|
|
@@ -168680,7 +169174,7 @@ function editedQuery(input, key, query) {
|
|
|
168680
169174
|
const graphemes = Array.from(QUERY_SEGMENTER.segment(query), (part) => part.segment);
|
|
168681
169175
|
return graphemes.slice(0, -1).join("");
|
|
168682
169176
|
}
|
|
168683
|
-
if (input !== "" && !key.return && !key.upArrow && !key.downArrow && Array.from(input).every((char) => {
|
|
169177
|
+
if (input !== "" && !key.return && !key.upArrow && !key.downArrow && !key.leftArrow && !key.rightArrow && Array.from(input).every((char) => {
|
|
168684
169178
|
const code = char.codePointAt(0) ?? 0;
|
|
168685
169179
|
return code >= 32 && code !== 127;
|
|
168686
169180
|
}))
|
|
@@ -168694,16 +169188,17 @@ function Picker({
|
|
|
168694
169188
|
budget,
|
|
168695
169189
|
active = true,
|
|
168696
169190
|
onChoose,
|
|
169191
|
+
onCycle,
|
|
168697
169192
|
onCancel,
|
|
168698
169193
|
query = model.query ?? "",
|
|
168699
169194
|
onQuery
|
|
168700
169195
|
}) {
|
|
168701
|
-
const [selection, setSelection] =
|
|
168702
|
-
const latest =
|
|
169196
|
+
const [selection, setSelection] = import_react32.useState({ kind: model.kind, index: FIRST_ENTRY });
|
|
169197
|
+
const latest = import_react32.useRef(selection);
|
|
168703
169198
|
if (latest.current.kind !== model.kind || latest.current.query !== query) {
|
|
168704
169199
|
latest.current = { kind: model.kind, query, index: FIRST_ENTRY };
|
|
168705
169200
|
}
|
|
168706
|
-
const queryRef =
|
|
169201
|
+
const queryRef = import_react32.useRef(query);
|
|
168707
169202
|
queryRef.current = query;
|
|
168708
169203
|
const entries = () => model.kind === "model" ? matchingEntries(model.allEntries ?? model.entries, queryRef.current) : model.entries;
|
|
168709
169204
|
const last = () => Math.max(FIRST_ENTRY, entries().length - 1);
|
|
@@ -168735,7 +169230,7 @@ function Picker({
|
|
|
168735
169230
|
use_input_default((input, key) => {
|
|
168736
169231
|
if (editQuery(input, key))
|
|
168737
169232
|
return;
|
|
168738
|
-
if (!ownsPickerKey(key))
|
|
169233
|
+
if (!ownsPickerKey(key, model.kind))
|
|
168739
169234
|
return;
|
|
168740
169235
|
if (key.escape) {
|
|
168741
169236
|
onCancel();
|
|
@@ -168746,12 +169241,7 @@ function Picker({
|
|
|
168746
169241
|
const entry = entries()[pointer()];
|
|
168747
169242
|
if (entry === undefined)
|
|
168748
169243
|
return;
|
|
168749
|
-
|
|
168750
|
-
onChoose(entry);
|
|
168751
|
-
else if (key.upArrow)
|
|
168752
|
-
move(-1);
|
|
168753
|
-
else if (key.downArrow)
|
|
168754
|
-
move(1);
|
|
169244
|
+
applyEntryKey(key, entry, { onChoose, onCycle, move });
|
|
168755
169245
|
}, { isActive: active });
|
|
168756
169246
|
const layout = pickerLayout(model, { width, theme, budget, selected: pointer() });
|
|
168757
169247
|
return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
|
|
@@ -168762,27 +169252,19 @@ function Picker({
|
|
|
168762
169252
|
}, index, false, undefined, this))
|
|
168763
169253
|
}, undefined, false, undefined, this);
|
|
168764
169254
|
}
|
|
168765
|
-
var
|
|
169255
|
+
var import_react32, jsx_dev_runtime4, PICKER_MAX_ROWS = 8, FRAME_ROWS = 3, FIRST_ENTRY = 0, COLUMN_GAP = " ", CURRENT_MARK = "(current)", QUERY_SEGMENTER;
|
|
168766
169256
|
var init_Picker = __esm(async () => {
|
|
168767
|
-
init_relative_time();
|
|
168768
169257
|
await __promiseAll([
|
|
168769
169258
|
init_build3(),
|
|
168770
169259
|
init_layout_lines(),
|
|
169260
|
+
init_picker_model(),
|
|
168771
169261
|
init_styled_line(),
|
|
168772
|
-
init_wrap()
|
|
169262
|
+
init_wrap(),
|
|
169263
|
+
init_picker_model(),
|
|
169264
|
+
init_useChatPicker()
|
|
168773
169265
|
]);
|
|
168774
|
-
|
|
169266
|
+
import_react32 = __toESM(require_react(), 1);
|
|
168775
169267
|
jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
|
|
168776
|
-
TITLES3 = {
|
|
168777
|
-
model: "Switch model",
|
|
168778
|
-
resume: "Resume a session",
|
|
168779
|
-
mode: "Permission mode"
|
|
168780
|
-
};
|
|
168781
|
-
MODE_CHOICES = [
|
|
168782
|
-
{ mode: "guarded", detail: "asks before risky actions" },
|
|
168783
|
-
{ mode: "full", detail: "never asks; runs outside the sandbox when it is unavailable" }
|
|
168784
|
-
];
|
|
168785
|
-
_pickerDeps = { now: () => Date.now() };
|
|
168786
169268
|
QUERY_SEGMENTER = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
168787
169269
|
});
|
|
168788
169270
|
|
|
@@ -168989,7 +169471,8 @@ function applyTurnStart(status, event) {
|
|
|
168989
169471
|
startedAt: event.at,
|
|
168990
169472
|
phase: THINKING,
|
|
168991
169473
|
inputTokens: 0,
|
|
168992
|
-
outputTokens: 0
|
|
169474
|
+
outputTokens: 0,
|
|
169475
|
+
streamedChars: 0
|
|
168993
169476
|
};
|
|
168994
169477
|
return status.contextTokens === undefined ? started : { ...started, contextTokens: status.contextTokens };
|
|
168995
169478
|
}
|
|
@@ -168998,6 +169481,7 @@ function applyUsage(status, event) {
|
|
|
168998
169481
|
...status,
|
|
168999
169482
|
inputTokens: status.inputTokens + event.inputTokens,
|
|
169000
169483
|
outputTokens: status.outputTokens + event.outputTokens,
|
|
169484
|
+
streamedChars: 0,
|
|
169001
169485
|
contextTokens: event.inputTokens + (event.cacheRead ?? 0) + (event.cacheWrite ?? 0)
|
|
169002
169486
|
};
|
|
169003
169487
|
}
|
|
@@ -169008,9 +169492,9 @@ function reduceTurnStatus(status, event) {
|
|
|
169008
169492
|
case "turn_start":
|
|
169009
169493
|
return applyTurnStart(status, event);
|
|
169010
169494
|
case "thinking_delta":
|
|
169011
|
-
return inPhase(status, THINKING);
|
|
169495
|
+
return { ...inPhase(status, THINKING), streamedChars: status.streamedChars + event.text.length };
|
|
169012
169496
|
case "text_delta":
|
|
169013
|
-
return inPhase(status, WRITING);
|
|
169497
|
+
return { ...inPhase(status, WRITING), streamedChars: status.streamedChars + event.text.length };
|
|
169014
169498
|
case "tool_call":
|
|
169015
169499
|
return inPhase(status, TOOL, event.name);
|
|
169016
169500
|
case "tool_result":
|
|
@@ -169022,7 +169506,7 @@ function reduceTurnStatus(status, event) {
|
|
|
169022
169506
|
case "compaction":
|
|
169023
169507
|
return inPhase(status, COMPACTING);
|
|
169024
169508
|
case "stream_reset":
|
|
169025
|
-
return inPhase(status, RETRYING);
|
|
169509
|
+
return { ...inPhase(status, RETRYING), streamedChars: 0 };
|
|
169026
169510
|
case "usage":
|
|
169027
169511
|
return applyUsage(status, event);
|
|
169028
169512
|
case "turn_end":
|
|
@@ -169037,9 +169521,16 @@ function formatTokens(n) {
|
|
|
169037
169521
|
return `${rounded}`;
|
|
169038
169522
|
return `${(rounded / TOKEN_UNIT).toFixed(TOKEN_DECIMALS)}${TOKEN_SUFFIX}`;
|
|
169039
169523
|
}
|
|
169524
|
+
function modelParts(raw) {
|
|
169525
|
+
const { model, effort } = parseModelSpec(raw);
|
|
169526
|
+
return {
|
|
169527
|
+
name: model.slice(model.lastIndexOf(PATH_SEPARATOR) + 1),
|
|
169528
|
+
suffix: effort === undefined ? "" : `[${effort}]`
|
|
169529
|
+
};
|
|
169530
|
+
}
|
|
169040
169531
|
function shortModel(model) {
|
|
169041
|
-
const
|
|
169042
|
-
return
|
|
169532
|
+
const { name, suffix } = modelParts(model);
|
|
169533
|
+
return `${elideEnd(name, SHORT_MODEL_MAX, ELLIPSIS2)}${suffix}`;
|
|
169043
169534
|
}
|
|
169044
169535
|
function singleRow(text) {
|
|
169045
169536
|
return oneLine4(sanitizeText(text));
|
|
@@ -169162,10 +169653,16 @@ function workingVerb(status, glyphs) {
|
|
|
169162
169653
|
return `Retrying${trailing}`;
|
|
169163
169654
|
}
|
|
169164
169655
|
}
|
|
169656
|
+
function workingTokens(status) {
|
|
169657
|
+
const estimate = formatTokens(Math.ceil(status.streamedChars / CHARS_PER_ESTIMATED_TOKEN));
|
|
169658
|
+
if (status.inputTokens + status.outputTokens === 0)
|
|
169659
|
+
return `${DOWN_ARROW} ~${estimate} tokens`;
|
|
169660
|
+
const suffix = status.streamedChars > 0 ? ` (+~${estimate})` : "";
|
|
169661
|
+
return `${UP_ARROW} ${formatTokens(status.inputTokens)} ${DOWN_ARROW} ${formatTokens(status.outputTokens)}${suffix} tokens`;
|
|
169662
|
+
}
|
|
169165
169663
|
function workingDetail(status, elapsed) {
|
|
169166
169664
|
const seconds = Math.floor(elapsed / MILLIS_PER_SECOND);
|
|
169167
|
-
|
|
169168
|
-
return ` (${seconds}s${SEPARATOR}${tokens}${SEPARATOR}${HINT_TEXT.busy})`;
|
|
169665
|
+
return ` (${seconds}s${SEPARATOR}${workingTokens(status)}${SEPARATOR}${HINT_TEXT.busy})`;
|
|
169169
169666
|
}
|
|
169170
169667
|
function workingLine(status, nowMs, glyphs) {
|
|
169171
169668
|
if (!status.running)
|
|
@@ -169225,10 +169722,29 @@ function elideMiddle(text, columns, ellipsis) {
|
|
|
169225
169722
|
const head = headColumns(text, Math.ceil(room / 2));
|
|
169226
169723
|
return `${head}${ellipsis}${tailColumns(text, room - displayWidth(head))}`;
|
|
169227
169724
|
}
|
|
169228
|
-
function
|
|
169725
|
+
function elideEnd(text, columns, ellipsis) {
|
|
169726
|
+
if (displayWidth(text) <= columns)
|
|
169727
|
+
return text;
|
|
169728
|
+
const room = columns - displayWidth(ellipsis);
|
|
169729
|
+
return room < 0 ? headColumns(ellipsis, columns) : `${headColumns(text, room)}${ellipsis}`;
|
|
169730
|
+
}
|
|
169731
|
+
function headerModel(raw, columns, ellipsis) {
|
|
169732
|
+
const { name, suffix } = modelParts(raw);
|
|
169733
|
+
if (displayWidth(`${name}${suffix}`) <= columns)
|
|
169734
|
+
return `${name}${suffix}`;
|
|
169735
|
+
const room = Math.max(0, columns - displayWidth(suffix) - displayWidth(ellipsis));
|
|
169736
|
+
return `${headColumns(name, room)}${ellipsis}${suffix}`;
|
|
169737
|
+
}
|
|
169738
|
+
function headerTitleLine(state, version, width, glyphs) {
|
|
169229
169739
|
const title = { text: `${glyphs.thinking} ${HEADER_TITLE}`, color: "accent", bold: true };
|
|
169230
|
-
const
|
|
169231
|
-
|
|
169740
|
+
const beforeModel = ` v${singleRow(version)}${SEPARATOR}`;
|
|
169741
|
+
const afterModel = `${SEPARATOR}${modeLabel(state.mode)}`;
|
|
169742
|
+
const modelRoom = width - displayWidth(`${title.text}${beforeModel}${afterModel}`);
|
|
169743
|
+
const model = headerModel(singleRow(state.model), modelRoom, glyphs.ellipsis);
|
|
169744
|
+
const facts = `${beforeModel}${model}${afterModel}`;
|
|
169745
|
+
const room = width - displayWidth(`${title.text}${facts}${SEPARATOR}`);
|
|
169746
|
+
const sessionTitle = state.meta.title !== null && room >= MIN_TITLE_COLUMNS ? `${SEPARATOR}${elideEnd(singleRow(sessionTitleText(state.meta.title, state.sessionId)), room, glyphs.ellipsis)}` : "";
|
|
169747
|
+
return [title, { text: `${facts}${sessionTitle}`, color: "muted" }];
|
|
169232
169748
|
}
|
|
169233
169749
|
function headerPathLine(state, cwd, home, width, glyphs) {
|
|
169234
169750
|
const budget = Math.max(1, width - HEADER_CWD_RESERVE);
|
|
@@ -169246,13 +169762,15 @@ function headerLines(input) {
|
|
|
169246
169762
|
const width = resolveWidth2(input.width);
|
|
169247
169763
|
const glyphs = input.glyphs ?? GLYPHS;
|
|
169248
169764
|
return [
|
|
169249
|
-
headerTitleLine(input.state, input.version, glyphs),
|
|
169765
|
+
headerTitleLine(input.state, input.version, width, glyphs),
|
|
169250
169766
|
headerPathLine(input.state, input.cwd, input.home, width, glyphs),
|
|
169251
169767
|
headerRuleLine(width, glyphs)
|
|
169252
169768
|
];
|
|
169253
169769
|
}
|
|
169254
|
-
var IDLE_STATUS, THINKING = "thinking", WRITING = "writing", TOOL = "tool", APPROVAL = "approval", COMPACTING = "compacting", RETRYING = "retrying", TOKEN_UNIT = 1000, TOKEN_DECIMALS = 1, TOKEN_SUFFIX = "k", SHORT_MODEL_MAX = 24,
|
|
169770
|
+
var IDLE_STATUS, THINKING = "thinking", WRITING = "writing", TOOL = "tool", APPROVAL = "approval", COMPACTING = "compacting", RETRYING = "retrying", TOKEN_UNIT = 1000, TOKEN_DECIMALS = 1, CHARS_PER_ESTIMATED_TOKEN = 4, TOKEN_SUFFIX = "k", SHORT_MODEL_MAX = 24, ELLIPSIS2 = "\u2026", PATH_SEPARATOR = "/", HINT_TEXT, SEPARATOR = " \xB7 ", SANDBOX_OFF = "sandbox off", SANDBOX_UNAVAILABLE = "sandbox unavailable", CONTEXT_WARNING_ABOVE = 70, CONTEXT_DANGER_ABOVE = 90, PERCENT = 100, COST_DECIMALS = 2, COST_PREFIX = "$", GLYPHS, JOB_TARGET_LIMIT = 16, JOB_STRIP_LIMIT = 2, WORKING_TICK_MS = 250, SPINNER_FRAME_MS = 120, MILLIS_PER_SECOND = 1000, UP_ARROW = "\u2191", DOWN_ARROW = "\u2193", HEADER_TITLE = "nax chat", HEADER_CWD_RESERVE = 20, HEADER_INDENT = " ", HOME = "~", SANDBOX_ON = "sandbox on", MIN_TITLE_COLUMNS = 8;
|
|
169255
169771
|
var init_chat_status = __esm(async () => {
|
|
169772
|
+
init_src();
|
|
169773
|
+
init_chat();
|
|
169256
169774
|
init_theme();
|
|
169257
169775
|
init_tool_card();
|
|
169258
169776
|
await __promiseAll([
|
|
@@ -169263,7 +169781,8 @@ var init_chat_status = __esm(async () => {
|
|
|
169263
169781
|
running: false,
|
|
169264
169782
|
phase: "thinking",
|
|
169265
169783
|
inputTokens: 0,
|
|
169266
|
-
outputTokens: 0
|
|
169784
|
+
outputTokens: 0,
|
|
169785
|
+
streamedChars: 0
|
|
169267
169786
|
};
|
|
169268
169787
|
HINT_TEXT = {
|
|
169269
169788
|
copied: "copied",
|
|
@@ -169276,6 +169795,20 @@ var init_chat_status = __esm(async () => {
|
|
|
169276
169795
|
GLYPHS = resolveChatTheme({ env: {}, colorLevel: 0 }).glyphs;
|
|
169277
169796
|
});
|
|
169278
169797
|
|
|
169798
|
+
// src/tui/chat/FixedRow.tsx
|
|
169799
|
+
function FixedRow({ children }) {
|
|
169800
|
+
return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Box_default, {
|
|
169801
|
+
height: 1,
|
|
169802
|
+
overflow: "hidden",
|
|
169803
|
+
children
|
|
169804
|
+
}, undefined, false, undefined, this);
|
|
169805
|
+
}
|
|
169806
|
+
var jsx_dev_runtime5;
|
|
169807
|
+
var init_FixedRow = __esm(async () => {
|
|
169808
|
+
await init_build3();
|
|
169809
|
+
jsx_dev_runtime5 = __toESM(require_jsx_dev_runtime(), 1);
|
|
169810
|
+
});
|
|
169811
|
+
|
|
169279
169812
|
// src/tui/chat/layout-listing.ts
|
|
169280
169813
|
function listingTone(text) {
|
|
169281
169814
|
if (WARNING_MARKERS.some((marker) => text.includes(marker)))
|
|
@@ -169319,11 +169852,7 @@ function rowsOf(text, color, context) {
|
|
|
169319
169852
|
return prefixedLine([styled2(text, { color })], [], context);
|
|
169320
169853
|
}
|
|
169321
169854
|
function welcomeLines(entry, context) {
|
|
169322
|
-
const glyph = styled2(`${context.theme.glyphs.thinking}${SPACE3}`, { color: "accent", bold: true });
|
|
169323
|
-
const title = styled2(WELCOME_TITLE, { color: "accent", bold: true });
|
|
169324
169855
|
return [
|
|
169325
|
-
...prefixedLine([title], [glyph], context),
|
|
169326
|
-
EMPTY_LINE,
|
|
169327
169856
|
...rowsOf(countParts(entry).join(COUNT_SEPARATOR), "muted", context),
|
|
169328
169857
|
...rowsOf(WELCOME_TIPS, "muted", context)
|
|
169329
169858
|
];
|
|
@@ -169337,7 +169866,7 @@ function interruptedLines(context) {
|
|
|
169337
169866
|
const prefix = styled2(resultPrefix(context.theme), { color: "muted" });
|
|
169338
169867
|
return prefixedLine([styled2(INTERRUPTED, { color: "muted" })], [prefix], context);
|
|
169339
169868
|
}
|
|
169340
|
-
var
|
|
169869
|
+
var WELCOME_TIPS = "/feature <name> loads a spec \xB7 /resume picks a session \xB7 /help lists commands", COUNT_SEPARATOR = " \xB7 ", INTERRUPTED = "Interrupted by user", STATUS_STYLE;
|
|
169341
169870
|
var init_layout_status = __esm(async () => {
|
|
169342
169871
|
await __promiseAll([
|
|
169343
169872
|
init_layout_lines(),
|
|
@@ -177372,6 +177901,20 @@ function thinkingLines(entry, context) {
|
|
|
177372
177901
|
function cardIndent(theme) {
|
|
177373
177902
|
return SPACE3.repeat(displayWidth(resultPrefix(theme)));
|
|
177374
177903
|
}
|
|
177904
|
+
function skillLines(entry, context) {
|
|
177905
|
+
const sources = entry.body === "" ? [] : entry.body.replace(/(?:\r\n|[\r\n])$/, "").split(SOURCE_LINE_BREAK);
|
|
177906
|
+
const invocation = `/${entry.name}${entry.args === "" ? "" : SPACE3 + entry.args}`;
|
|
177907
|
+
const user = userLines({ kind: "user", text: invocation }, context);
|
|
177908
|
+
const indent = cardIndent(context.theme);
|
|
177909
|
+
const unit = sources.length === 1 ? "line" : "lines";
|
|
177910
|
+
const hint = context.expanded ? HIDE_HINT : SHOW_HINT;
|
|
177911
|
+
const label = `skill ${entry.name} \xB7 ${sources.length} ${unit} ${hint}`;
|
|
177912
|
+
const header = cardRows(label, { head: resultPrefix(context.theme), rest: indent }, { color: "muted" }, context);
|
|
177913
|
+
if (!context.expanded)
|
|
177914
|
+
return [...user, ...header];
|
|
177915
|
+
const body = sources.flatMap((source) => cardRows(source, { head: indent, rest: indent }, { color: "muted" }, context));
|
|
177916
|
+
return [...user, ...header, ...body];
|
|
177917
|
+
}
|
|
177375
177918
|
function cardRows(text, prefixes, style, context) {
|
|
177376
177919
|
return sanitizeText(text).split(SOURCE_LINE_BREAK).flatMap((physical, index) => prefixedLine([styled2(physical, style)], [styled2(index === 0 ? prefixes.head : prefixes.rest, style)], context));
|
|
177377
177920
|
}
|
|
@@ -177425,6 +177968,8 @@ function layoutEntry(entry, context) {
|
|
|
177425
177968
|
switch (entry.kind) {
|
|
177426
177969
|
case "user":
|
|
177427
177970
|
return userLines(entry, context);
|
|
177971
|
+
case "skill":
|
|
177972
|
+
return skillLines(entry, context);
|
|
177428
177973
|
case "reply":
|
|
177429
177974
|
return replyLines(entry, context);
|
|
177430
177975
|
case "thinking":
|
|
@@ -177454,7 +177999,8 @@ function variantsFor(entry, theme) {
|
|
|
177454
177999
|
LINE_CACHE.set(entry, { theme, variants });
|
|
177455
178000
|
return variants;
|
|
177456
178001
|
}
|
|
177457
|
-
function cachedLines(entry,
|
|
178002
|
+
function cachedLines(entry, base) {
|
|
178003
|
+
const context = entry.kind === "thinking" || entry.kind === "tool" || entry.kind === "skill" ? { ...base, expanded: entry.open ?? base.expanded } : base;
|
|
177458
178004
|
const variants = variantsFor(entry, context.theme);
|
|
177459
178005
|
const key = variantKey(context.width, context.expanded);
|
|
177460
178006
|
const cached = variants.get(key);
|
|
@@ -177481,6 +178027,18 @@ function layoutTranscript(entries, options) {
|
|
|
177481
178027
|
}
|
|
177482
178028
|
return lines;
|
|
177483
178029
|
}
|
|
178030
|
+
function transcriptLineOwners(entries, options) {
|
|
178031
|
+
const owners = [];
|
|
178032
|
+
entries.forEach((entry, index) => {
|
|
178033
|
+
const count = layoutTranscript([entry], options).length;
|
|
178034
|
+
if (count === 0)
|
|
178035
|
+
return;
|
|
178036
|
+
if (owners.length > 0)
|
|
178037
|
+
owners.push(undefined);
|
|
178038
|
+
owners.push(...Array.from({ length: count }, () => index));
|
|
178039
|
+
});
|
|
178040
|
+
return owners;
|
|
178041
|
+
}
|
|
177484
178042
|
var MIN_REPLY_WIDTH, USER_MARKER = ">", USER_BAND = "userBand", THOUGHT_FOR = "Thought for", SHOW_HINT = "(ctrl+o to show)", HIDE_HINT = "(ctrl+o to hide)", SECONDS_SUFFIX = "s", BULLET_COLORS, EXPAND_HINT = "lines (ctrl+o to expand)", HIDDEN_LINE_MARK = "+", _layoutDeps, VARIANT_KEY_SEPARATOR = ":", LINE_CACHE;
|
|
177485
178043
|
var init_layout = __esm(async () => {
|
|
177486
178044
|
init_tool_card();
|
|
@@ -177550,6 +178108,21 @@ function catalogCommand(command, { host, show }) {
|
|
|
177550
178108
|
return { kind: "send", message: buildSkillInvocationMessage({ skill, args: command.rest }) };
|
|
177551
178109
|
show(`unknown command /${command.name}`);
|
|
177552
178110
|
}
|
|
178111
|
+
async function effortCommand(command, { host, show }) {
|
|
178112
|
+
if (command.args.length > 1) {
|
|
178113
|
+
show("usage: /effort [level]");
|
|
178114
|
+
return;
|
|
178115
|
+
}
|
|
178116
|
+
const arg = command.args[0];
|
|
178117
|
+
if (arg === undefined)
|
|
178118
|
+
return { kind: "picker", picker: "effort" };
|
|
178119
|
+
const level = arg.toLowerCase();
|
|
178120
|
+
if (!isEffortLevel(level)) {
|
|
178121
|
+
show(`unknown effort "${arg}"; use one of: ${EFFORT_LEVELS.join(", ")}`);
|
|
178122
|
+
return;
|
|
178123
|
+
}
|
|
178124
|
+
await host.switchTo({ model: withEffort2(host.current().model, level) });
|
|
178125
|
+
}
|
|
177553
178126
|
async function runSlashCommand(command, { host, show }) {
|
|
177554
178127
|
const arg = command.args[0];
|
|
177555
178128
|
switch (command.name) {
|
|
@@ -177584,9 +178157,11 @@ async function runSlashCommand(command, { host, show }) {
|
|
|
177584
178157
|
return { kind: "picker", picker: "model" };
|
|
177585
178158
|
await host.switchTo({ model: arg });
|
|
177586
178159
|
break;
|
|
178160
|
+
case "effort":
|
|
178161
|
+
return effortCommand(command, { host, show });
|
|
177587
178162
|
case "sessions":
|
|
177588
178163
|
for (const row of await host.listSessions()) {
|
|
177589
|
-
show(`${row.sessionId} ${row.title
|
|
178164
|
+
show(`${row.sessionId} ${sessionTitleText(row.title, row.sessionId)}${row.heldByPid === undefined ? "" : ` in use by pid ${row.heldByPid}`}`);
|
|
177590
178165
|
}
|
|
177591
178166
|
break;
|
|
177592
178167
|
case "resume":
|
|
@@ -177631,6 +178206,7 @@ var init_slash_commands = __esm(() => {
|
|
|
177631
178206
|
"help",
|
|
177632
178207
|
"mode",
|
|
177633
178208
|
"model",
|
|
178209
|
+
"effort",
|
|
177634
178210
|
"sessions",
|
|
177635
178211
|
"resume",
|
|
177636
178212
|
"clear",
|
|
@@ -177647,6 +178223,7 @@ var init_slash_commands = __esm(() => {
|
|
|
177647
178223
|
help: "Show commands and skills",
|
|
177648
178224
|
mode: "Switch permission mode",
|
|
177649
178225
|
model: "Switch model",
|
|
178226
|
+
effort: "Switch reasoning effort",
|
|
177650
178227
|
sessions: "List saved sessions",
|
|
177651
178228
|
resume: "Resume a saved session",
|
|
177652
178229
|
clear: "Clear the conversation",
|
|
@@ -177738,16 +178315,27 @@ function pointerPrefix2(theme, chosen) {
|
|
|
177738
178315
|
return styled2(SPACE3.repeat(displayWidth(pointer) + SPACE3.length));
|
|
177739
178316
|
return styled2(`${pointer}${SPACE3}`, { color: "accent" });
|
|
177740
178317
|
}
|
|
177741
|
-
function menuRow(item,
|
|
177742
|
-
const
|
|
177743
|
-
const
|
|
178318
|
+
function menuRow(item, options) {
|
|
178319
|
+
const { chosen, width, nameWidth, theme } = options;
|
|
178320
|
+
const text = `/${item.name}`;
|
|
178321
|
+
const name = styled2(text, chosen ? { bold: true } : {});
|
|
178322
|
+
const padding = SPACE3.repeat(nameWidth - displayWidth(text));
|
|
178323
|
+
const description = styled2(`${padding}${NAME_GAP}${item.description}`, { color: "muted" });
|
|
177744
178324
|
return cutSpans([pointerPrefix2(theme, chosen), name, description], width);
|
|
177745
178325
|
}
|
|
177746
178326
|
function slashMenuLayout(matches, options) {
|
|
177747
178327
|
const selected = Math.min(Math.max(options.selected ?? FIRST_MATCH2, FIRST_MATCH2), matches.length - 1);
|
|
177748
|
-
const
|
|
178328
|
+
const maxRows = options.maxRows ?? SLASH_MENU_MAX_ROWS;
|
|
178329
|
+
const more = matches.length > maxRows && maxRows >= 2;
|
|
178330
|
+
const drawn = matches.length === 0 ? NO_WINDOW : slashMenuWindow(matches.length, selected, more ? maxRows - 1 : maxRows);
|
|
177749
178331
|
const width = resolveWidth2(options.width);
|
|
177750
|
-
const
|
|
178332
|
+
const items = matches.slice(drawn.first, drawn.first + drawn.rows);
|
|
178333
|
+
const nameWidth = items.reduce((widest, item) => Math.max(widest, displayWidth(`/${item.name}`)), 0);
|
|
178334
|
+
const lines = items.map((item, at) => menuRow(item, { chosen: drawn.first + at === selected, width, nameWidth, theme: options.theme }));
|
|
178335
|
+
if (more) {
|
|
178336
|
+
const text = ` ${options.theme.glyphs.ellipsis} ${matches.length - items.length} more`;
|
|
178337
|
+
lines.push(cutSpans([styled2(text, { color: "muted" })], width));
|
|
178338
|
+
}
|
|
177751
178339
|
return { selected, first: drawn.first, rows: lines.length, lines };
|
|
177752
178340
|
}
|
|
177753
178341
|
function ownsMenuKey(key) {
|
|
@@ -177765,8 +178353,8 @@ function SlashMenu({
|
|
|
177765
178353
|
onClose
|
|
177766
178354
|
}) {
|
|
177767
178355
|
const matches = menu.matches ?? [];
|
|
177768
|
-
const [selection, setSelection] =
|
|
177769
|
-
const latest =
|
|
178356
|
+
const [selection, setSelection] = import_react33.useState({ query: menu.query, index: FIRST_MATCH2 });
|
|
178357
|
+
const latest = import_react33.useRef(selection);
|
|
177770
178358
|
if (latest.current.query !== menu.query)
|
|
177771
178359
|
latest.current = { query: menu.query, index: FIRST_MATCH2 };
|
|
177772
178360
|
const pointer = () => Math.min(Math.max(latest.current.index, FIRST_MATCH2), matches.length - 1);
|
|
@@ -177802,15 +178390,15 @@ function SlashMenu({
|
|
|
177802
178390
|
move(1);
|
|
177803
178391
|
}, { isActive: active });
|
|
177804
178392
|
const layout = slashMenuLayout(matches, { width, theme, selected: pointer(), maxRows });
|
|
177805
|
-
return /* @__PURE__ */
|
|
178393
|
+
return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
|
|
177806
178394
|
flexDirection: "column",
|
|
177807
|
-
children: layout.lines.map((line, index) => /* @__PURE__ */
|
|
178395
|
+
children: layout.lines.map((line, index) => /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(StyledLineView, {
|
|
177808
178396
|
line,
|
|
177809
178397
|
theme
|
|
177810
178398
|
}, index, false, undefined, this))
|
|
177811
178399
|
}, undefined, false, undefined, this);
|
|
177812
178400
|
}
|
|
177813
|
-
var
|
|
178401
|
+
var import_react33, jsx_dev_runtime6, NAME_GAP = " ", FIRST_MATCH2 = 0, NO_WINDOW;
|
|
177814
178402
|
var init_SlashMenu = __esm(async () => {
|
|
177815
178403
|
await __promiseAll([
|
|
177816
178404
|
init_build3(),
|
|
@@ -177819,11 +178407,98 @@ var init_SlashMenu = __esm(async () => {
|
|
|
177819
178407
|
init_styled_line(),
|
|
177820
178408
|
init_wrap()
|
|
177821
178409
|
]);
|
|
177822
|
-
|
|
177823
|
-
|
|
178410
|
+
import_react33 = __toESM(require_react(), 1);
|
|
178411
|
+
jsx_dev_runtime6 = __toESM(require_jsx_dev_runtime(), 1);
|
|
177824
178412
|
NO_WINDOW = { first: FIRST_MATCH2, rows: 0 };
|
|
177825
178413
|
});
|
|
177826
178414
|
|
|
178415
|
+
// src/tui/chat/history-replay.ts
|
|
178416
|
+
function replayUser(content) {
|
|
178417
|
+
if (content === "")
|
|
178418
|
+
return [];
|
|
178419
|
+
if (content.startsWith(COMPACTION_SUMMARY_PREFIX)) {
|
|
178420
|
+
return [{ kind: "notice", text: "earlier conversation compacted" }];
|
|
178421
|
+
}
|
|
178422
|
+
const skill = parseSkillInvocation(content);
|
|
178423
|
+
return [skill ? { kind: "skill", ...skill } : { kind: "user", text: content }];
|
|
178424
|
+
}
|
|
178425
|
+
function replayCall(call, result, timing) {
|
|
178426
|
+
return {
|
|
178427
|
+
kind: "tool",
|
|
178428
|
+
turnId: timing.turnId,
|
|
178429
|
+
callId: call.id,
|
|
178430
|
+
name: call.name,
|
|
178431
|
+
input: displayToolInput(call.input),
|
|
178432
|
+
status: result === undefined || result.isError ? "error" : "ok",
|
|
178433
|
+
preview: result === undefined ? NO_RESULT_TEXT : toolResultPreview(result.content),
|
|
178434
|
+
startedAt: timing.timestamp,
|
|
178435
|
+
endedAt: timing.timestamp,
|
|
178436
|
+
children: []
|
|
178437
|
+
};
|
|
178438
|
+
}
|
|
178439
|
+
function replayMessage(message, results, timing) {
|
|
178440
|
+
switch (message.role) {
|
|
178441
|
+
case "user":
|
|
178442
|
+
return replayUser(message.content);
|
|
178443
|
+
case "assistant": {
|
|
178444
|
+
const entries = [];
|
|
178445
|
+
if (message.content !== "")
|
|
178446
|
+
entries.push({ kind: "reply", turnId: timing.turnId, text: message.content });
|
|
178447
|
+
for (const call of message.toolCalls ?? [])
|
|
178448
|
+
entries.push(replayCall(call, results.get(call.id), timing));
|
|
178449
|
+
return entries;
|
|
178450
|
+
}
|
|
178451
|
+
default:
|
|
178452
|
+
return [];
|
|
178453
|
+
}
|
|
178454
|
+
}
|
|
178455
|
+
function replayHistory(history) {
|
|
178456
|
+
const results = new Map;
|
|
178457
|
+
for (const message of history.messages) {
|
|
178458
|
+
if (message.role === "tool-result")
|
|
178459
|
+
results.set(message.toolCallId, message);
|
|
178460
|
+
}
|
|
178461
|
+
const timestamp = history.savedAt ?? FALLBACK_TIMESTAMP;
|
|
178462
|
+
return history.messages.flatMap((message, index) => replayMessage(message, results, { turnId: `history-${index}`, timestamp }));
|
|
178463
|
+
}
|
|
178464
|
+
var FALLBACK_TIMESTAMP = "1970-01-01T00:00:00.000Z", NO_RESULT_TEXT = "No result was recorded for this call.";
|
|
178465
|
+
var init_history_replay = __esm(() => {
|
|
178466
|
+
init_src();
|
|
178467
|
+
init_internal();
|
|
178468
|
+
init_chat();
|
|
178469
|
+
});
|
|
178470
|
+
|
|
178471
|
+
// src/tui/chat/session-transcript.ts
|
|
178472
|
+
function lastServerEvent(events, id) {
|
|
178473
|
+
return events.findLast((event) => event.serverId === id);
|
|
178474
|
+
}
|
|
178475
|
+
function welcomeEntry(host) {
|
|
178476
|
+
const catalog = host.catalog;
|
|
178477
|
+
const servers = host.mcp?.servers ?? [];
|
|
178478
|
+
const events = host.mcp?.events() ?? [];
|
|
178479
|
+
return {
|
|
178480
|
+
kind: "welcome",
|
|
178481
|
+
skills: catalog?.skills.length ?? 0,
|
|
178482
|
+
commands: catalog?.commands.length ?? 0,
|
|
178483
|
+
agents: catalog?.agents.length ?? 0,
|
|
178484
|
+
mcpServers: servers.length,
|
|
178485
|
+
mcpConnected: servers.filter((server) => lastServerEvent(events, server.id)?.kind === "connected").length
|
|
178486
|
+
};
|
|
178487
|
+
}
|
|
178488
|
+
function sessionTranscript(host) {
|
|
178489
|
+
const replayed = replayHistory(host.history?.() ?? { messages: [] });
|
|
178490
|
+
const rows = [welcomeEntry(host), ...replayed];
|
|
178491
|
+
if (replayed.length > 0) {
|
|
178492
|
+
const { meta, sessionId } = host.current();
|
|
178493
|
+
rows.push({ kind: "notice", text: `resumed ${sessionTitleText(meta.title, sessionId)}` });
|
|
178494
|
+
}
|
|
178495
|
+
return rows;
|
|
178496
|
+
}
|
|
178497
|
+
var init_session_transcript = __esm(() => {
|
|
178498
|
+
init_chat();
|
|
178499
|
+
init_history_replay();
|
|
178500
|
+
});
|
|
178501
|
+
|
|
177827
178502
|
// src/tui/chat/viewport.ts
|
|
177828
178503
|
function maxOffset(total, height) {
|
|
177829
178504
|
return Math.max(0, total - height);
|
|
@@ -177884,11 +178559,9 @@ function transcriptPointAt(geometry, x, y) {
|
|
|
177884
178559
|
const { start, end } = visibleRange(total, height, offset);
|
|
177885
178560
|
const marker = unseen > 0 ? 1 : 0;
|
|
177886
178561
|
const count = Math.max(0, end - start - marker);
|
|
177887
|
-
|
|
177888
|
-
const index = row - padding;
|
|
177889
|
-
if (index < 0 || index >= count)
|
|
178562
|
+
if (row >= count)
|
|
177890
178563
|
return;
|
|
177891
|
-
return { line: start +
|
|
178564
|
+
return { line: start + row, column: x - 1 };
|
|
177892
178565
|
}
|
|
177893
178566
|
function ordered(selection) {
|
|
177894
178567
|
const { anchor, focus } = selection;
|
|
@@ -177956,27 +178629,51 @@ var init_selection = __esm(async () => {
|
|
|
177956
178629
|
});
|
|
177957
178630
|
|
|
177958
178631
|
// src/tui/chat/use-mouse-selection.ts
|
|
177959
|
-
function finishSelection(gesture, input) {
|
|
178632
|
+
function finishSelection(gesture, input, sameCell) {
|
|
177960
178633
|
gesture.dragging = false;
|
|
177961
178634
|
const range = gesture.selection;
|
|
177962
|
-
if (!range
|
|
178635
|
+
if (!range)
|
|
177963
178636
|
return;
|
|
178637
|
+
if (range.anchor.line === range.focus.line && range.anchor.column === range.focus.column) {
|
|
178638
|
+
if (!gesture.moved && sameCell)
|
|
178639
|
+
input.onClick?.(range.anchor);
|
|
178640
|
+
return;
|
|
178641
|
+
}
|
|
177964
178642
|
const text = selectedText(input.lines, range);
|
|
177965
178643
|
if (text.length > 0)
|
|
177966
178644
|
input.onCopy?.(text);
|
|
177967
178645
|
}
|
|
178646
|
+
function atPressCell(gesture, event) {
|
|
178647
|
+
return event.x === gesture.press?.x && event.y === gesture.press?.y;
|
|
178648
|
+
}
|
|
178649
|
+
function startSelection(gesture, event, point) {
|
|
178650
|
+
gesture.selection = point ? { anchor: point, focus: point } : undefined;
|
|
178651
|
+
gesture.dragging = point !== undefined;
|
|
178652
|
+
gesture.press = { x: event.x, y: event.y };
|
|
178653
|
+
gesture.moved = false;
|
|
178654
|
+
}
|
|
178655
|
+
function moveSelection(gesture, event, point) {
|
|
178656
|
+
if (!gesture.dragging || !gesture.selection)
|
|
178657
|
+
return;
|
|
178658
|
+
if (!atPressCell(gesture, event))
|
|
178659
|
+
gesture.moved = true;
|
|
178660
|
+
if (!point)
|
|
178661
|
+
return;
|
|
178662
|
+
gesture.selection = { ...gesture.selection, focus: point };
|
|
178663
|
+
return gesture.selection;
|
|
178664
|
+
}
|
|
177968
178665
|
function useMouseSelection(input) {
|
|
177969
|
-
const latest =
|
|
178666
|
+
const latest = import_react34.useRef(input);
|
|
177970
178667
|
latest.current = input;
|
|
177971
|
-
const gesture =
|
|
177972
|
-
const [selection, setSelection] =
|
|
177973
|
-
const [total, setTotal] =
|
|
178668
|
+
const gesture = import_react34.useRef({ dragging: false });
|
|
178669
|
+
const [selection, setSelection] = import_react34.useState();
|
|
178670
|
+
const [total, setTotal] = import_react34.useState(input.lines.length);
|
|
177974
178671
|
if (total !== input.lines.length) {
|
|
177975
178672
|
setTotal(input.lines.length);
|
|
177976
178673
|
gesture.current = { dragging: false };
|
|
177977
178674
|
setSelection(undefined);
|
|
177978
178675
|
}
|
|
177979
|
-
|
|
178676
|
+
import_react34.useEffect(() => {
|
|
177980
178677
|
if (!input.active || !input.mouse)
|
|
177981
178678
|
return;
|
|
177982
178679
|
return input.mouse.subscribe((event) => {
|
|
@@ -177986,23 +178683,23 @@ function useMouseSelection(input) {
|
|
|
177986
178683
|
const point = transcriptPointAt(geometry, event.x, event.y);
|
|
177987
178684
|
const current = gesture.current;
|
|
177988
178685
|
if (event.kind === "press") {
|
|
177989
|
-
current
|
|
177990
|
-
current.dragging = point !== undefined;
|
|
178686
|
+
startSelection(current, event, point);
|
|
177991
178687
|
setSelection(undefined);
|
|
177992
|
-
} else if (event.kind === "drag"
|
|
177993
|
-
|
|
177994
|
-
|
|
178688
|
+
} else if (event.kind === "drag") {
|
|
178689
|
+
const moved = moveSelection(current, event, point);
|
|
178690
|
+
if (moved)
|
|
178691
|
+
setSelection(moved);
|
|
177995
178692
|
} else if (event.kind === "release" && current.dragging) {
|
|
177996
|
-
finishSelection(current, latest.current);
|
|
178693
|
+
finishSelection(current, latest.current, atPressCell(current, event));
|
|
177997
178694
|
}
|
|
177998
178695
|
});
|
|
177999
178696
|
}, [input.active, input.mouse]);
|
|
178000
178697
|
return selection;
|
|
178001
178698
|
}
|
|
178002
|
-
var
|
|
178699
|
+
var import_react34;
|
|
178003
178700
|
var init_use_mouse_selection = __esm(async () => {
|
|
178004
178701
|
await init_selection();
|
|
178005
|
-
|
|
178702
|
+
import_react34 = __toESM(require_react(), 1);
|
|
178006
178703
|
});
|
|
178007
178704
|
|
|
178008
178705
|
// src/tui/chat/TranscriptViewport.tsx
|
|
@@ -178038,7 +178735,7 @@ function nextMemory(memory, total, height, token) {
|
|
|
178038
178735
|
return { ...content, state, token };
|
|
178039
178736
|
}
|
|
178040
178737
|
function ViewportRow({ children }) {
|
|
178041
|
-
return /* @__PURE__ */
|
|
178738
|
+
return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Box_default, {
|
|
178042
178739
|
height: ROW_HEIGHT,
|
|
178043
178740
|
overflow: "hidden",
|
|
178044
178741
|
children
|
|
@@ -178048,22 +178745,22 @@ function ViewportRows({ visible, rows, unseen, theme }) {
|
|
|
178048
178745
|
const showingUnseen = unseen > 0;
|
|
178049
178746
|
const body = showingUnseen ? visible.slice(0, -1) : visible;
|
|
178050
178747
|
const padding = Math.max(0, rows - body.length - (showingUnseen ? 1 : 0));
|
|
178051
|
-
return /* @__PURE__ */
|
|
178748
|
+
return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Box_default, {
|
|
178052
178749
|
flexDirection: "column",
|
|
178053
178750
|
children: [
|
|
178054
|
-
|
|
178055
|
-
children: /* @__PURE__ */
|
|
178056
|
-
children: BLANK_ROW
|
|
178057
|
-
}, undefined, false, undefined, this)
|
|
178058
|
-
}, index, false, undefined, this)),
|
|
178059
|
-
body.map((line, index) => /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(ViewportRow, {
|
|
178060
|
-
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(StyledLineView, {
|
|
178751
|
+
body.map((line, index) => /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ViewportRow, {
|
|
178752
|
+
children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(StyledLineView, {
|
|
178061
178753
|
line,
|
|
178062
178754
|
theme
|
|
178063
178755
|
}, undefined, false, undefined, this)
|
|
178064
178756
|
}, index, false, undefined, this)),
|
|
178065
|
-
|
|
178066
|
-
children: /* @__PURE__ */
|
|
178757
|
+
Array.from({ length: padding }, (_unused, index) => /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ViewportRow, {
|
|
178758
|
+
children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
178759
|
+
children: BLANK_ROW
|
|
178760
|
+
}, undefined, false, undefined, this)
|
|
178761
|
+
}, `padding-${index}`, false, undefined, this)),
|
|
178762
|
+
showingUnseen ? /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ViewportRow, {
|
|
178763
|
+
children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
178067
178764
|
wrap: "truncate",
|
|
178068
178765
|
color: theme.colors.muted,
|
|
178069
178766
|
children: `${UNSEEN_MARKER} ${unseen} ${UNSEEN_LABEL}`
|
|
@@ -178080,11 +178777,12 @@ function TranscriptViewport({
|
|
|
178080
178777
|
mouse,
|
|
178081
178778
|
top = 0,
|
|
178082
178779
|
onCopy,
|
|
178780
|
+
onClick,
|
|
178083
178781
|
followToken = 0
|
|
178084
178782
|
}) {
|
|
178085
178783
|
const rows = viewRows(height);
|
|
178086
178784
|
const total = lines.length;
|
|
178087
|
-
const [memory, setMemory] =
|
|
178785
|
+
const [memory, setMemory] = import_react35.useState({
|
|
178088
178786
|
state: INITIAL_VIEWPORT,
|
|
178089
178787
|
total,
|
|
178090
178788
|
height: rows,
|
|
@@ -178093,7 +178791,7 @@ function TranscriptViewport({
|
|
|
178093
178791
|
if (memory.total !== total || memory.height !== rows || memory.token !== followToken) {
|
|
178094
178792
|
setMemory(nextMemory(memory, total, rows, followToken));
|
|
178095
178793
|
}
|
|
178096
|
-
|
|
178794
|
+
import_react35.useEffect(() => {
|
|
178097
178795
|
if (!active || !mouse)
|
|
178098
178796
|
return;
|
|
178099
178797
|
return mouse.subscribe((event) => {
|
|
@@ -178120,18 +178818,19 @@ function TranscriptViewport({
|
|
|
178120
178818
|
active,
|
|
178121
178819
|
lines,
|
|
178122
178820
|
onCopy,
|
|
178821
|
+
onClick: (point) => onClick?.(point.line),
|
|
178123
178822
|
geometry: { top, height: rows, total, offset: memory.state.offset, unseen: memory.state.unseen }
|
|
178124
178823
|
});
|
|
178125
178824
|
const { start, end } = visibleRange(total, rows, memory.state.offset);
|
|
178126
178825
|
const visible = lines.slice(start, end).map((line, index) => selection ? highlightLine(line, start + index, selection) : line);
|
|
178127
|
-
return /* @__PURE__ */
|
|
178826
|
+
return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ViewportRows, {
|
|
178128
178827
|
visible,
|
|
178129
178828
|
rows,
|
|
178130
178829
|
unseen: memory.state.unseen,
|
|
178131
178830
|
theme
|
|
178132
178831
|
}, undefined, false, undefined, this);
|
|
178133
178832
|
}
|
|
178134
|
-
var
|
|
178833
|
+
var import_react35, jsx_dev_runtime7, MIN_VIEWPORT_ROWS = 1, ROW_HEIGHT = 1, BLANK_ROW = " ", UNSEEN_MARKER = "\u2193", UNSEEN_LABEL = "new lines (End)";
|
|
178135
178834
|
var init_TranscriptViewport = __esm(async () => {
|
|
178136
178835
|
init_viewport();
|
|
178137
178836
|
await __promiseAll([
|
|
@@ -178140,8 +178839,27 @@ var init_TranscriptViewport = __esm(async () => {
|
|
|
178140
178839
|
init_styled_line(),
|
|
178141
178840
|
init_use_mouse_selection()
|
|
178142
178841
|
]);
|
|
178143
|
-
|
|
178144
|
-
|
|
178842
|
+
import_react35 = __toESM(require_react(), 1);
|
|
178843
|
+
jsx_dev_runtime7 = __toESM(require_jsx_dev_runtime(), 1);
|
|
178844
|
+
});
|
|
178845
|
+
|
|
178846
|
+
// src/tui/chat/transcript-click.ts
|
|
178847
|
+
function toggleTranscriptLine(entries, line, options) {
|
|
178848
|
+
const owners = transcriptLineOwners(entries, options);
|
|
178849
|
+
const index = owners[line];
|
|
178850
|
+
if (index === undefined)
|
|
178851
|
+
return entries;
|
|
178852
|
+
const entry = entries[index];
|
|
178853
|
+
if (entry.kind !== "thinking" && entry.kind !== "tool" && entry.kind !== "skill")
|
|
178854
|
+
return entries;
|
|
178855
|
+
const first = owners.indexOf(index);
|
|
178856
|
+
const hint = entry.kind === "skill" ? first + layoutTranscript([{ kind: "user", text: `/${entry.name}${entry.args === "" ? "" : ` ${entry.args}`}` }], options).length : first;
|
|
178857
|
+
if (line !== first && line !== hint)
|
|
178858
|
+
return entries;
|
|
178859
|
+
return entries.map((row, position) => position === index ? { ...entry, open: !(entry.open ?? options.expanded) } : row);
|
|
178860
|
+
}
|
|
178861
|
+
var init_transcript_click = __esm(async () => {
|
|
178862
|
+
await init_layout();
|
|
178145
178863
|
});
|
|
178146
178864
|
|
|
178147
178865
|
// src/tui/chat/transcript-model.ts
|
|
@@ -178318,34 +179036,34 @@ function footerHint(input) {
|
|
|
178318
179036
|
return "idle";
|
|
178319
179037
|
}
|
|
178320
179038
|
function useClipboardFeedback(mouse) {
|
|
178321
|
-
const [copiedChars, setCopiedChars] =
|
|
179039
|
+
const [copiedChars, setCopiedChars] = import_react36.useState();
|
|
178322
179040
|
use_input_default(() => setCopiedChars(undefined));
|
|
178323
|
-
|
|
179041
|
+
import_react36.useEffect(() => mouse?.subscribe((event) => {
|
|
178324
179042
|
if (event.kind === "press")
|
|
178325
179043
|
setCopiedChars(undefined);
|
|
178326
179044
|
}), [mouse]);
|
|
178327
|
-
const onCopy =
|
|
179045
|
+
const onCopy = import_react36.useCallback((text) => {
|
|
178328
179046
|
copyToClipboard(text);
|
|
178329
179047
|
setCopiedChars(text.length);
|
|
178330
179048
|
}, []);
|
|
178331
179049
|
return { copiedChars, onCopy };
|
|
178332
179050
|
}
|
|
178333
|
-
var
|
|
179051
|
+
var import_react36;
|
|
178334
179052
|
var init_use_clipboard_feedback = __esm(async () => {
|
|
178335
179053
|
init_clipboard();
|
|
178336
179054
|
await init_build3();
|
|
178337
|
-
|
|
179055
|
+
import_react36 = __toESM(require_react(), 1);
|
|
178338
179056
|
});
|
|
178339
179057
|
|
|
178340
179058
|
// src/tui/chat/use-jobs.ts
|
|
178341
179059
|
function useJobs(host, { idle, deliver }) {
|
|
178342
179060
|
const jobs = host.jobs;
|
|
178343
|
-
const [, refresh] =
|
|
178344
|
-
const latestDeliver =
|
|
179061
|
+
const [, refresh] = import_react37.useState(0);
|
|
179062
|
+
const latestDeliver = import_react37.useRef(deliver);
|
|
178345
179063
|
latestDeliver.current = deliver;
|
|
178346
|
-
const inFlight =
|
|
178347
|
-
const mounted =
|
|
178348
|
-
|
|
179064
|
+
const inFlight = import_react37.useRef(false);
|
|
179065
|
+
const mounted = import_react37.useRef(false);
|
|
179066
|
+
import_react37.useEffect(() => {
|
|
178349
179067
|
mounted.current = true;
|
|
178350
179068
|
const unsubscribe = jobs?.onChange(() => refresh((revision) => revision + 1));
|
|
178351
179069
|
return () => {
|
|
@@ -178353,7 +179071,7 @@ function useJobs(host, { idle, deliver }) {
|
|
|
178353
179071
|
unsubscribe?.();
|
|
178354
179072
|
};
|
|
178355
179073
|
}, [jobs]);
|
|
178356
|
-
|
|
179074
|
+
import_react37.useEffect(() => {
|
|
178357
179075
|
if (!idle || !jobs || inFlight.current)
|
|
178358
179076
|
return;
|
|
178359
179077
|
const notice = jobs.peekNotice();
|
|
@@ -178377,11 +179095,11 @@ function useJobs(host, { idle, deliver }) {
|
|
|
178377
179095
|
});
|
|
178378
179096
|
return jobs?.running() ?? [];
|
|
178379
179097
|
}
|
|
178380
|
-
var
|
|
179098
|
+
var import_react37;
|
|
178381
179099
|
var init_use_jobs = __esm(() => {
|
|
178382
179100
|
init_internal();
|
|
178383
179101
|
init_logger2();
|
|
178384
|
-
|
|
179102
|
+
import_react37 = __toESM(require_react(), 1);
|
|
178385
179103
|
});
|
|
178386
179104
|
|
|
178387
179105
|
// src/tui/chat/use-slash-menu-keys.ts
|
|
@@ -178391,7 +179109,7 @@ function useSlashMenuKeys({
|
|
|
178391
179109
|
initialDismissal,
|
|
178392
179110
|
blocked
|
|
178393
179111
|
}) {
|
|
178394
|
-
const live =
|
|
179112
|
+
const live = import_react38.useRef({ query: initialQuery, dismissed: initialDismissal });
|
|
178395
179113
|
return {
|
|
178396
179114
|
ownsKeys: () => slashMenuQueryState({ items, query: live.current.query, dismissed: live.current.dismissed, blocked }).open,
|
|
178397
179115
|
sawPrompt: (text) => {
|
|
@@ -178402,10 +179120,30 @@ function useSlashMenuKeys({
|
|
|
178402
179120
|
}
|
|
178403
179121
|
};
|
|
178404
179122
|
}
|
|
178405
|
-
var
|
|
179123
|
+
var import_react38;
|
|
178406
179124
|
var init_use_slash_menu_keys = __esm(async () => {
|
|
178407
179125
|
await init_slash_menu();
|
|
178408
|
-
|
|
179126
|
+
import_react38 = __toESM(require_react(), 1);
|
|
179127
|
+
});
|
|
179128
|
+
|
|
179129
|
+
// src/tui/chat/use-switch-notices.ts
|
|
179130
|
+
function useSwitchNotices(state, append) {
|
|
179131
|
+
const { sessionId, model, mode } = state;
|
|
179132
|
+
const previous = import_react39.useRef({ sessionId, model, mode });
|
|
179133
|
+
import_react39.useEffect(() => {
|
|
179134
|
+
const last = previous.current;
|
|
179135
|
+
previous.current = { sessionId, model, mode };
|
|
179136
|
+
if (last.sessionId !== sessionId)
|
|
179137
|
+
return;
|
|
179138
|
+
if (last.model !== model)
|
|
179139
|
+
append({ kind: "notice", text: `model: ${model.slice(model.lastIndexOf("/") + 1)}` });
|
|
179140
|
+
if (last.mode !== mode)
|
|
179141
|
+
append({ kind: "notice", text: `mode: ${mode}` });
|
|
179142
|
+
}, [sessionId, model, mode, append]);
|
|
179143
|
+
}
|
|
179144
|
+
var import_react39;
|
|
179145
|
+
var init_use_switch_notices = __esm(() => {
|
|
179146
|
+
import_react39 = __toESM(require_react(), 1);
|
|
178409
179147
|
});
|
|
178410
179148
|
|
|
178411
179149
|
// src/tui/chat/useChatKeys.ts
|
|
@@ -178417,13 +179155,13 @@ function clearTimer(handle) {
|
|
|
178417
179155
|
}
|
|
178418
179156
|
function useChatKeys({ host, running, refresh, onError }) {
|
|
178419
179157
|
const { exit } = use_app_default();
|
|
178420
|
-
const queued =
|
|
178421
|
-
const interruptedAt =
|
|
178422
|
-
const quitExpiry =
|
|
178423
|
-
const switching =
|
|
178424
|
-
const closing =
|
|
178425
|
-
const confirming =
|
|
178426
|
-
const [locked, setLocked] =
|
|
179158
|
+
const queued = import_react40.useRef(undefined);
|
|
179159
|
+
const interruptedAt = import_react40.useRef(undefined);
|
|
179160
|
+
const quitExpiry = import_react40.useRef(undefined);
|
|
179161
|
+
const switching = import_react40.useRef(undefined);
|
|
179162
|
+
const closing = import_react40.useRef(false);
|
|
179163
|
+
const confirming = import_react40.useRef(false);
|
|
179164
|
+
const [locked, setLocked] = import_react40.useState(false);
|
|
178427
179165
|
function armQuit() {
|
|
178428
179166
|
clearTimer(quitExpiry);
|
|
178429
179167
|
quitExpiry.current = setTimeout(() => {
|
|
@@ -178431,7 +179169,7 @@ function useChatKeys({ host, running, refresh, onError }) {
|
|
|
178431
179169
|
refresh();
|
|
178432
179170
|
}, DOUBLE_INTERRUPT_MS);
|
|
178433
179171
|
}
|
|
178434
|
-
|
|
179172
|
+
import_react40.useEffect(() => () => clearTimer(quitExpiry), []);
|
|
178435
179173
|
function quitArmed() {
|
|
178436
179174
|
const armedAt = interruptedAt.current;
|
|
178437
179175
|
return armedAt !== undefined && _chatKeyDeps.now() - armedAt < DOUBLE_INTERRUPT_MS;
|
|
@@ -178524,11 +179262,11 @@ function useChatKeys({ host, running, refresh, onError }) {
|
|
|
178524
179262
|
}
|
|
178525
179263
|
};
|
|
178526
179264
|
}
|
|
178527
|
-
var
|
|
179265
|
+
var import_react40, DOUBLE_INTERRUPT_MS = 2000, _chatKeyDeps;
|
|
178528
179266
|
var init_useChatKeys = __esm(async () => {
|
|
178529
179267
|
init_chat();
|
|
178530
179268
|
await init_build3();
|
|
178531
|
-
|
|
179269
|
+
import_react40 = __toESM(require_react(), 1);
|
|
178532
179270
|
_chatKeyDeps = { now: () => Date.now() };
|
|
178533
179271
|
});
|
|
178534
179272
|
|
|
@@ -178536,30 +179274,6 @@ var init_useChatKeys = __esm(async () => {
|
|
|
178536
179274
|
function terminalSize2(stdout) {
|
|
178537
179275
|
return { columns: stdout.columns || DEFAULT_COLUMNS, rows: stdout.rows || DEFAULT_ROWS };
|
|
178538
179276
|
}
|
|
178539
|
-
function FixedRow({ children }) {
|
|
178540
|
-
return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Box_default, {
|
|
178541
|
-
height: 1,
|
|
178542
|
-
overflow: "hidden",
|
|
178543
|
-
children
|
|
178544
|
-
}, undefined, false, undefined, this);
|
|
178545
|
-
}
|
|
178546
|
-
function lastServerEvent(events, id) {
|
|
178547
|
-
return events.findLast((event) => event.serverId === id);
|
|
178548
|
-
}
|
|
178549
|
-
function welcomeEntry(host) {
|
|
178550
|
-
const catalog = host.catalog;
|
|
178551
|
-
const mcp = host.mcp;
|
|
178552
|
-
const servers = mcp?.servers ?? [];
|
|
178553
|
-
const events = mcp?.events() ?? [];
|
|
178554
|
-
return {
|
|
178555
|
-
kind: "welcome",
|
|
178556
|
-
skills: catalog?.skills.length ?? 0,
|
|
178557
|
-
commands: catalog?.commands.length ?? 0,
|
|
178558
|
-
agents: catalog?.agents.length ?? 0,
|
|
178559
|
-
mcpServers: servers.length,
|
|
178560
|
-
mcpConnected: servers.filter((server) => lastServerEvent(events, server.id)?.kind === "connected").length
|
|
178561
|
-
};
|
|
178562
|
-
}
|
|
178563
179277
|
function stopTurn(status) {
|
|
178564
179278
|
return status.running ? { ...status, running: false } : status;
|
|
178565
179279
|
}
|
|
@@ -178594,31 +179308,33 @@ function ChatApp({
|
|
|
178594
179308
|
}) {
|
|
178595
179309
|
const { stdout } = use_stdout_default();
|
|
178596
179310
|
const { copiedChars, onCopy } = useClipboardFeedback(mouse);
|
|
178597
|
-
const [size, setSize] =
|
|
178598
|
-
const
|
|
178599
|
-
const
|
|
178600
|
-
const [
|
|
178601
|
-
const [
|
|
178602
|
-
const [
|
|
178603
|
-
const [
|
|
178604
|
-
const [
|
|
178605
|
-
const [
|
|
178606
|
-
const [
|
|
178607
|
-
const [
|
|
178608
|
-
const [
|
|
178609
|
-
const
|
|
178610
|
-
const
|
|
178611
|
-
const
|
|
178612
|
-
const
|
|
178613
|
-
const
|
|
179311
|
+
const [size, setSize] = import_react41.useState(() => terminalSize2(stdout));
|
|
179312
|
+
const state = host.current();
|
|
179313
|
+
const transcriptSession = import_react41.useRef(state.sessionId);
|
|
179314
|
+
const [entries, setEntries] = import_react41.useState(() => sessionTranscript(host));
|
|
179315
|
+
const [status, setStatus] = import_react41.useState(IDLE_STATUS);
|
|
179316
|
+
const [draft, setDraft] = import_react41.useState(EMPTY_DRAFT);
|
|
179317
|
+
const [busy, setBusy] = import_react41.useState(false);
|
|
179318
|
+
const [clearArmed, setClearArmed] = import_react41.useState(false);
|
|
179319
|
+
const [answerDraft, setAnswerDraft] = import_react41.useState(NO_ANSWER2);
|
|
179320
|
+
const [hint, setHint] = import_react41.useState(undefined);
|
|
179321
|
+
const [nowMs, setNowMs] = import_react41.useState(() => Date.now());
|
|
179322
|
+
const [expanded, setExpanded] = import_react41.useState(false);
|
|
179323
|
+
const [dismissedQuery, setDismissedQuery] = import_react41.useState(undefined);
|
|
179324
|
+
const [followToken, setFollowToken] = import_react41.useState(0);
|
|
179325
|
+
const inputHandle = import_react41.useRef(undefined);
|
|
179326
|
+
const sending = import_react41.useRef(false);
|
|
179327
|
+
const [, refresh] = import_react41.useState(0);
|
|
179328
|
+
const update = import_react41.useCallback(() => refresh((revision) => revision + 1), []);
|
|
179329
|
+
const append = import_react41.useCallback((entry) => {
|
|
178614
179330
|
setEntries((rows) => [...rows, entry]);
|
|
178615
179331
|
}, []);
|
|
178616
|
-
const showError =
|
|
179332
|
+
const showError = import_react41.useCallback((error) => append({ kind: "error", text: errorMessage(error) }), [append]);
|
|
178617
179333
|
const keys = useChatKeys({ host, running: sending, refresh: update, onError: showError });
|
|
178618
179334
|
const picker = useChatPicker({ host, runControl: keys.runControl, onError: showError });
|
|
178619
179335
|
const ask = host.asks.pending()[0];
|
|
178620
179336
|
const turnRunning = busy || status.running;
|
|
178621
|
-
const menuItems =
|
|
179337
|
+
const menuItems = import_react41.useMemo(() => slashMenuItems(host), [host]);
|
|
178622
179338
|
const slashKeys = useSlashMenuKeys({
|
|
178623
179339
|
items: menuItems,
|
|
178624
179340
|
initialQuery: draft.editor.text,
|
|
@@ -178656,31 +179372,37 @@ function ChatApp({
|
|
|
178656
179372
|
return;
|
|
178657
179373
|
host.cancel();
|
|
178658
179374
|
});
|
|
178659
|
-
|
|
179375
|
+
import_react41.useEffect(() => {
|
|
178660
179376
|
const onResize = () => setSize(terminalSize2(stdout));
|
|
178661
179377
|
stdout.on("resize", onResize);
|
|
178662
179378
|
return () => {
|
|
178663
179379
|
stdout.off("resize", onResize);
|
|
178664
179380
|
};
|
|
178665
179381
|
}, [stdout]);
|
|
178666
|
-
|
|
178667
|
-
|
|
179382
|
+
import_react41.useLayoutEffect(() => {
|
|
179383
|
+
if (transcriptSession.current === state.sessionId)
|
|
179384
|
+
return;
|
|
179385
|
+
transcriptSession.current = state.sessionId;
|
|
179386
|
+
setEntries(sessionTranscript(host));
|
|
179387
|
+
}, [host, state.sessionId]);
|
|
179388
|
+
useSwitchNotices(state, append);
|
|
179389
|
+
import_react41.useEffect(() => host.asks.onChange(update), [host, update]);
|
|
179390
|
+
import_react41.useEffect(() => {
|
|
178668
179391
|
const resourceNotice = host.resourceNotice?.();
|
|
178669
179392
|
if (resourceNotice)
|
|
178670
179393
|
append({ kind: "notice", text: resourceNotice });
|
|
178671
179394
|
}, [host, append]);
|
|
178672
|
-
const state = host.current();
|
|
178673
179395
|
const notice = host.notice();
|
|
178674
179396
|
const warn = state.mode === "full" && state.sandbox?.kind === "unavailable";
|
|
178675
|
-
|
|
179397
|
+
import_react41.useEffect(() => {
|
|
178676
179398
|
if (notice)
|
|
178677
179399
|
append({ kind: "notice", text: notice });
|
|
178678
|
-
}, [notice, append]);
|
|
178679
|
-
|
|
179400
|
+
}, [notice, state.sessionId, append]);
|
|
179401
|
+
import_react41.useEffect(() => {
|
|
178680
179402
|
if (warn)
|
|
178681
179403
|
append({ kind: "warning", text: SANDBOX_WARNING });
|
|
178682
179404
|
}, [warn, append]);
|
|
178683
|
-
|
|
179405
|
+
import_react41.useEffect(() => {
|
|
178684
179406
|
if (!status.running)
|
|
178685
179407
|
return;
|
|
178686
179408
|
let handle;
|
|
@@ -178697,7 +179419,7 @@ function ChatApp({
|
|
|
178697
179419
|
clearTimeout(handle);
|
|
178698
179420
|
};
|
|
178699
179421
|
}, [status.running]);
|
|
178700
|
-
const handleEvent =
|
|
179422
|
+
const handleEvent = import_react41.useCallback((event) => {
|
|
178701
179423
|
setEntries((rows) => reduceTranscript(rows, event));
|
|
178702
179424
|
setStatus((current) => reduceTurnStatus(current, event));
|
|
178703
179425
|
if (event.type === "turn_start")
|
|
@@ -178713,17 +179435,14 @@ function ChatApp({
|
|
|
178713
179435
|
sink.flush();
|
|
178714
179436
|
if (!ready)
|
|
178715
179437
|
return;
|
|
178716
|
-
if (outcome === undefined)
|
|
178717
|
-
if (command.name === CLEAR)
|
|
178718
|
-
setEntries([welcomeEntry(host)]);
|
|
179438
|
+
if (outcome === undefined)
|
|
178719
179439
|
return;
|
|
178720
|
-
}
|
|
178721
179440
|
if (outcome.kind === "picker") {
|
|
178722
179441
|
picker.open(outcome.picker);
|
|
178723
179442
|
return;
|
|
178724
179443
|
}
|
|
178725
179444
|
if (outcome.kind === "send") {
|
|
178726
|
-
await sendTurn(outcome.message);
|
|
179445
|
+
await sendTurn(outcome.message, undefined, `/${command.name}${command.rest}`);
|
|
178727
179446
|
return;
|
|
178728
179447
|
}
|
|
178729
179448
|
const { name, template, rest } = outcome;
|
|
@@ -178754,7 +179473,7 @@ function ChatApp({
|
|
|
178754
179473
|
}
|
|
178755
179474
|
await runCommand(command);
|
|
178756
179475
|
}
|
|
178757
|
-
async function sendTurn(message, prepare) {
|
|
179476
|
+
async function sendTurn(message, prepare, title = message) {
|
|
178758
179477
|
if (sending.current)
|
|
178759
179478
|
return false;
|
|
178760
179479
|
sending.current = true;
|
|
@@ -178766,13 +179485,18 @@ function ChatApp({
|
|
|
178766
179485
|
append({ kind: "notice", text: prepared.notice });
|
|
178767
179486
|
return false;
|
|
178768
179487
|
}
|
|
178769
|
-
|
|
179488
|
+
const skill = parseSkillInvocation(prepared.message);
|
|
179489
|
+
append(skill ? { kind: "skill", ...skill } : { kind: "user", text: prepared.message });
|
|
178770
179490
|
setFollowToken((token) => token + 1);
|
|
178771
|
-
|
|
179491
|
+
const onEvent = (event) => {
|
|
178772
179492
|
if (event.type === "turn_start")
|
|
178773
179493
|
started = true;
|
|
178774
179494
|
handleEvent(event);
|
|
178775
|
-
}
|
|
179495
|
+
};
|
|
179496
|
+
if (prepared.message === title)
|
|
179497
|
+
await host.send(prepared.message, onEvent);
|
|
179498
|
+
else
|
|
179499
|
+
await host.send(prepared.message, onEvent, { title });
|
|
178776
179500
|
return true;
|
|
178777
179501
|
} catch (error) {
|
|
178778
179502
|
append({ kind: "error", text: errorMessage(error) });
|
|
@@ -178803,7 +179527,8 @@ function ChatApp({
|
|
|
178803
179527
|
setDraft(next);
|
|
178804
179528
|
}
|
|
178805
179529
|
const columns = size.columns;
|
|
178806
|
-
const
|
|
179530
|
+
const layoutOptions = { width: columns, theme, expanded };
|
|
179531
|
+
const lines = layoutTranscript(entries, layoutOptions);
|
|
178807
179532
|
const header = headerLines({ state, version, cwd, home, width: columns, glyphs: theme.glyphs });
|
|
178808
179533
|
const footer = footerModel({
|
|
178809
179534
|
jobs,
|
|
@@ -178834,40 +179559,41 @@ function ChatApp({
|
|
|
178834
179559
|
budget: bottomBudget
|
|
178835
179560
|
});
|
|
178836
179561
|
const viewportHeight = Math.max(MIN_VIEWPORT_ROWS2, usableRows - HEADER_ROWS - (working ? WORKING_ROWS : 0) - bottomRows - FOOTER_ROWS);
|
|
178837
|
-
return /* @__PURE__ */
|
|
179562
|
+
return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
178838
179563
|
flexDirection: "column",
|
|
178839
179564
|
width: columns,
|
|
178840
179565
|
children: [
|
|
178841
|
-
/* @__PURE__ */
|
|
179566
|
+
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
178842
179567
|
flexDirection: "column",
|
|
178843
|
-
children: header.map((row, index) => /* @__PURE__ */
|
|
178844
|
-
children: /* @__PURE__ */
|
|
179568
|
+
children: header.map((row, index) => /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(FixedRow, {
|
|
179569
|
+
children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(StyledLineView, {
|
|
178845
179570
|
line: row,
|
|
178846
179571
|
theme
|
|
178847
179572
|
}, undefined, false, undefined, this)
|
|
178848
179573
|
}, index, false, undefined, this))
|
|
178849
179574
|
}, undefined, false, undefined, this),
|
|
178850
|
-
/* @__PURE__ */
|
|
179575
|
+
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(TranscriptViewport, {
|
|
178851
179576
|
mouse,
|
|
178852
179577
|
top: HEADER_ROWS,
|
|
178853
179578
|
onCopy,
|
|
179579
|
+
onClick: (line) => setEntries((rows) => toggleTranscriptLine(rows, line, layoutOptions)),
|
|
178854
179580
|
lines,
|
|
178855
179581
|
height: viewportHeight,
|
|
178856
179582
|
theme,
|
|
178857
179583
|
active: viewportActive(keys.locked, picker.model),
|
|
178858
179584
|
followToken
|
|
178859
|
-
},
|
|
178860
|
-
working ? /* @__PURE__ */
|
|
178861
|
-
children: /* @__PURE__ */
|
|
179585
|
+
}, state.sessionId, false, undefined, this),
|
|
179586
|
+
working ? /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(FixedRow, {
|
|
179587
|
+
children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(StyledLineView, {
|
|
178862
179588
|
line: working,
|
|
178863
179589
|
theme
|
|
178864
179590
|
}, undefined, false, undefined, this)
|
|
178865
179591
|
}, undefined, false, undefined, this) : null,
|
|
178866
|
-
ask !== undefined && askModel !== undefined ? /* @__PURE__ */
|
|
179592
|
+
ask !== undefined && askModel !== undefined ? /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
178867
179593
|
height: bottomRows,
|
|
178868
179594
|
overflow: "hidden",
|
|
178869
179595
|
flexDirection: "column",
|
|
178870
|
-
children: /* @__PURE__ */
|
|
179596
|
+
children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(AskCard, {
|
|
178871
179597
|
ask,
|
|
178872
179598
|
model: askModel,
|
|
178873
179599
|
controller: host.asks,
|
|
@@ -178879,27 +179605,28 @@ function ChatApp({
|
|
|
178879
179605
|
onDeclined: () => setHint(TELL_NAX_HINT),
|
|
178880
179606
|
active: !keys.locked
|
|
178881
179607
|
}, ask.requestId, false, undefined, this)
|
|
178882
|
-
}, undefined, false, undefined, this) : picker.model !== undefined ? /* @__PURE__ */
|
|
179608
|
+
}, undefined, false, undefined, this) : picker.model !== undefined ? /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
178883
179609
|
height: bottomRows,
|
|
178884
179610
|
overflow: "hidden",
|
|
178885
179611
|
flexDirection: "column",
|
|
178886
|
-
children: /* @__PURE__ */
|
|
179612
|
+
children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Picker, {
|
|
178887
179613
|
model: picker.model,
|
|
178888
179614
|
width: columns,
|
|
178889
179615
|
theme,
|
|
178890
179616
|
budget: bottomBudget,
|
|
178891
179617
|
active: !keys.locked,
|
|
178892
179618
|
onChoose: picker.choose,
|
|
179619
|
+
onCycle: picker.cycle,
|
|
178893
179620
|
onCancel: picker.cancel,
|
|
178894
179621
|
onQuery: picker.setQuery,
|
|
178895
179622
|
query: picker.model.query
|
|
178896
179623
|
}, undefined, false, undefined, this)
|
|
178897
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */
|
|
179624
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
178898
179625
|
height: bottomRows,
|
|
178899
179626
|
overflow: "hidden",
|
|
178900
179627
|
flexDirection: "column",
|
|
178901
179628
|
children: [
|
|
178902
|
-
/* @__PURE__ */
|
|
179629
|
+
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ChatInput, {
|
|
178903
179630
|
draft,
|
|
178904
179631
|
onDraftChange: changeDraft,
|
|
178905
179632
|
onSubmit: (message) => {
|
|
@@ -178916,7 +179643,7 @@ function ChatApp({
|
|
|
178916
179643
|
handle: inputHandle,
|
|
178917
179644
|
onClearArmedChange: setClearArmed
|
|
178918
179645
|
}, undefined, false, undefined, this),
|
|
178919
|
-
menuShown() ? /* @__PURE__ */
|
|
179646
|
+
menuShown() ? /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(SlashMenu, {
|
|
178920
179647
|
menu,
|
|
178921
179648
|
width: columns,
|
|
178922
179649
|
theme,
|
|
@@ -178932,18 +179659,18 @@ function ChatApp({
|
|
|
178932
179659
|
}, undefined, false, undefined, this) : null
|
|
178933
179660
|
]
|
|
178934
179661
|
}, undefined, true, undefined, this),
|
|
178935
|
-
/* @__PURE__ */
|
|
179662
|
+
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
178936
179663
|
flexDirection: "row",
|
|
178937
179664
|
justifyContent: "space-between",
|
|
178938
179665
|
width: columns,
|
|
178939
179666
|
height: 1,
|
|
178940
179667
|
overflow: "hidden",
|
|
178941
179668
|
children: [
|
|
178942
|
-
/* @__PURE__ */
|
|
179669
|
+
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(StyledLineView, {
|
|
178943
179670
|
line: footer.left,
|
|
178944
179671
|
theme
|
|
178945
179672
|
}, undefined, false, undefined, this),
|
|
178946
|
-
/* @__PURE__ */
|
|
179673
|
+
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(StyledLineView, {
|
|
178947
179674
|
line: footer.right,
|
|
178948
179675
|
theme
|
|
178949
179676
|
}, undefined, false, undefined, this)
|
|
@@ -178952,15 +179679,18 @@ function ChatApp({
|
|
|
178952
179679
|
]
|
|
178953
179680
|
}, undefined, true, undefined, this);
|
|
178954
179681
|
}
|
|
178955
|
-
var
|
|
179682
|
+
var import_react41, jsx_dev_runtime8, FRAME_SLACK_ROWS = 1, HEADER_ROWS = 3, FOOTER_ROWS = 1, WORKING_ROWS = 1, MIN_VIEWPORT_ROWS2 = 1, DEFAULT_COLUMNS = 80, DEFAULT_ROWS = 24, SANDBOX_WARNING = "sandbox unavailable: commands run outside the sandbox", TURN_BUSY_NOTICE = "wait for the turn to finish (Ctrl-C to interrupt)", QUIT = "quit", TELL_NAX_HINT = "tell nax what to do instead", CTRL_O = "o", DEFAULT_THEME, LISTING_TITLES, NO_ANSWER2;
|
|
178956
179683
|
var init_ChatApp = __esm(async () => {
|
|
178957
179684
|
init_internal();
|
|
179685
|
+
init_chat();
|
|
178958
179686
|
init_prompts();
|
|
178959
179687
|
init_resources();
|
|
178960
179688
|
init_version();
|
|
179689
|
+
init_session_transcript();
|
|
178961
179690
|
init_slash_commands();
|
|
178962
179691
|
init_theme();
|
|
178963
179692
|
init_use_jobs();
|
|
179693
|
+
init_use_switch_notices();
|
|
178964
179694
|
await __promiseAll([
|
|
178965
179695
|
init_build3(),
|
|
178966
179696
|
init_AskCard(),
|
|
@@ -178968,18 +179698,20 @@ var init_ChatApp = __esm(async () => {
|
|
|
178968
179698
|
init_bottom_region(),
|
|
178969
179699
|
init_ChatInput(),
|
|
178970
179700
|
init_chat_status(),
|
|
179701
|
+
init_FixedRow(),
|
|
178971
179702
|
init_layout(),
|
|
178972
179703
|
init_Picker(),
|
|
178973
179704
|
init_SlashMenu(),
|
|
178974
179705
|
init_slash_menu(),
|
|
178975
179706
|
init_styled_line(),
|
|
178976
179707
|
init_TranscriptViewport(),
|
|
179708
|
+
init_transcript_click(),
|
|
178977
179709
|
init_use_clipboard_feedback(),
|
|
178978
179710
|
init_use_slash_menu_keys(),
|
|
178979
179711
|
init_useChatKeys()
|
|
178980
179712
|
]);
|
|
178981
|
-
|
|
178982
|
-
|
|
179713
|
+
import_react41 = __toESM(require_react(), 1);
|
|
179714
|
+
jsx_dev_runtime8 = __toESM(require_jsx_dev_runtime(), 1);
|
|
178983
179715
|
DEFAULT_THEME = resolveChatTheme({ env: {}, colorLevel: 0 });
|
|
178984
179716
|
LISTING_TITLES = new Map([
|
|
178985
179717
|
["help", "Commands"],
|
|
@@ -179129,8 +179861,9 @@ function renderChat(props) {
|
|
|
179129
179861
|
mouse.dispose();
|
|
179130
179862
|
};
|
|
179131
179863
|
try {
|
|
179132
|
-
const instance = _renderChatDeps.render(
|
|
179864
|
+
const instance = _renderChatDeps.render(import_react42.createElement(ChatApp, { ...props, mouse: mouse.events }), {
|
|
179133
179865
|
exitOnCtrlC: false,
|
|
179866
|
+
incrementalRendering: true,
|
|
179134
179867
|
stdin: mouse.stdin
|
|
179135
179868
|
});
|
|
179136
179869
|
if (isTTY)
|
|
@@ -179151,7 +179884,7 @@ function renderChat(props) {
|
|
|
179151
179884
|
throw error;
|
|
179152
179885
|
}
|
|
179153
179886
|
}
|
|
179154
|
-
var
|
|
179887
|
+
var import_react42, _renderChatDeps;
|
|
179155
179888
|
var init_chat2 = __esm(async () => {
|
|
179156
179889
|
init_mouse_input();
|
|
179157
179890
|
init_theme();
|
|
@@ -179160,7 +179893,7 @@ var init_chat2 = __esm(async () => {
|
|
|
179160
179893
|
init_ChatApp(),
|
|
179161
179894
|
init_ChatApp()
|
|
179162
179895
|
]);
|
|
179163
|
-
|
|
179896
|
+
import_react42 = __toESM(require_react(), 1);
|
|
179164
179897
|
_renderChatDeps = {
|
|
179165
179898
|
render: render_default,
|
|
179166
179899
|
stdin: () => process.stdin,
|
|
@@ -179759,9 +180492,11 @@ var init_config_descriptions = __esm(() => {
|
|
|
179759
180492
|
"agent.acp": "ACP agent transport settings (claude, codex, cursor, opencode, gemini, pi)",
|
|
179760
180493
|
"agent.native.instructionFileName": "Repository instruction filename (default: AGENTS.md). Custom Markdown basenames load without AGENTS/CLAUDE fallbacks.",
|
|
179761
180494
|
"agent.native.catalogOverrides": "Native only. Explicit catalog entries for model ids newer than the bundled pi-ai snapshot, plus optional provider-wide baseUrl/headers.",
|
|
179762
|
-
"agent.native.catalogOverrides.baseUrl": "Provider-wide endpoint redirect. WARNING: applies to EVERY model of that provider, bundled ones included, and the provider's stored credential is sent to this host. https
|
|
180495
|
+
"agent.native.catalogOverrides.baseUrl": "Provider-wide endpoint redirect. WARNING: applies to EVERY model of that provider, bundled ones included, and the provider's stored credential is sent to this host. https or loopback http; remote http requires allowInsecureHttp: true. Credentials in the URL are always rejected.",
|
|
180496
|
+
"agent.native.catalogOverrides.authEnv": "Environment-variable name supplying this provider's bearer credential when no stored credential exists. Precheck warns when unset and names its destination; never store the secret value here.",
|
|
180497
|
+
"agent.native.catalogOverrides.allowInsecureHttp": "Explicitly allow remote plaintext http endpoints. WARNING: sends this provider's credential unencrypted; inert for https and loopback.",
|
|
179763
180498
|
"agent.native.catalogOverrides.headers": "Provider-wide extra request headers. REPLACES the provider's headers rather than merging; omit the key to leave them unchanged. May carry credentials, so values are masked in this output.",
|
|
179764
|
-
"agent.native.catalogOverrides.thinkingFormat": "Per-model thinking wire format (openai-completions only). Omit to inherit the provider format; use 'qwen-chat-template' for self-hosted servers honouring chat_template_kwargs.enable_thinking.",
|
|
180499
|
+
"agent.native.catalogOverrides.thinkingFormat": "Per-model thinking wire format (openai-completions only). Omit to inherit the provider format; 'openrouter' sends reasoning.effort (including 'none' at off); use 'qwen-chat-template' for self-hosted servers honouring chat_template_kwargs.enable_thinking.",
|
|
179765
180500
|
"agent.native.catalogOverrides.openRouterRouting": "OpenRouter-compatible provider routing for one model (nax#2191). Snake_case keys are wire field names sent verbatim. Reach the wire only on protocol: 'openai-completions'. Pair `sort: 'latency'|'throughput'` with `quantizations` \u2014 default routing is overwhelmingly a single quantization from a single endpoint, and a sort change may otherwise pick a lower-precision one. Routing changes break run-to-run comparability, so keep them fixed across arms.",
|
|
179766
180501
|
"agent.native.catalogOverrides.openRouterRouting.sort": "Routing strategy \u2014 'price' | 'throughput' | 'latency'. Omit to use OpenRouter's default ordering.",
|
|
179767
180502
|
"agent.native.catalogOverrides.openRouterRouting.quantizations": "Filter endpoints to these quantizations (e.g. ['fp8']). The reproducibility lever: one model id can otherwise be served fp4 on one call and fp8 on the next.",
|
|
@@ -189864,7 +190599,7 @@ await init_build3();
|
|
|
189864
190599
|
// src/tui/App.tsx
|
|
189865
190600
|
init_internal();
|
|
189866
190601
|
await init_build3();
|
|
189867
|
-
var
|
|
190602
|
+
var import_react48 = __toESM(require_react(), 1);
|
|
189868
190603
|
|
|
189869
190604
|
// src/utils/queue-writer.ts
|
|
189870
190605
|
init_errors4();
|
|
@@ -189921,7 +190656,7 @@ async function writeRetryCommand(queueFilePath, storyId) {
|
|
|
189921
190656
|
|
|
189922
190657
|
// src/tui/components/CostOverlay.tsx
|
|
189923
190658
|
await init_build3();
|
|
189924
|
-
var
|
|
190659
|
+
var jsx_dev_runtime9 = __toESM(require_jsx_dev_runtime(), 1);
|
|
189925
190660
|
function formatCost2(cost) {
|
|
189926
190661
|
return `$${cost.toFixed(4)}`;
|
|
189927
190662
|
}
|
|
@@ -189930,7 +190665,7 @@ function CostOverlay({ visible = false, stories = [], totalCost = 0 }) {
|
|
|
189930
190665
|
return null;
|
|
189931
190666
|
}
|
|
189932
190667
|
const executedStories = stories.filter((s) => s.cost && s.cost > 0 || s.status !== "pending");
|
|
189933
|
-
return /* @__PURE__ */
|
|
190668
|
+
return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189934
190669
|
flexDirection: "column",
|
|
189935
190670
|
borderStyle: "double",
|
|
189936
190671
|
borderColor: "cyan",
|
|
@@ -189938,87 +190673,87 @@ function CostOverlay({ visible = false, stories = [], totalCost = 0 }) {
|
|
|
189938
190673
|
paddingY: 1,
|
|
189939
190674
|
minWidth: 60,
|
|
189940
190675
|
children: [
|
|
189941
|
-
/* @__PURE__ */
|
|
190676
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189942
190677
|
paddingBottom: 1,
|
|
189943
|
-
children: /* @__PURE__ */
|
|
190678
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
189944
190679
|
bold: true,
|
|
189945
190680
|
color: "cyan",
|
|
189946
190681
|
children: "Cost Breakdown"
|
|
189947
190682
|
}, undefined, false, undefined, this)
|
|
189948
190683
|
}, undefined, false, undefined, this),
|
|
189949
|
-
/* @__PURE__ */
|
|
190684
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189950
190685
|
paddingBottom: 1,
|
|
189951
190686
|
borderBottom: true,
|
|
189952
190687
|
borderColor: "gray",
|
|
189953
190688
|
children: [
|
|
189954
|
-
/* @__PURE__ */
|
|
190689
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189955
190690
|
width: 12,
|
|
189956
|
-
children: /* @__PURE__ */
|
|
190691
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
189957
190692
|
bold: true,
|
|
189958
190693
|
children: "Story ID"
|
|
189959
190694
|
}, undefined, false, undefined, this)
|
|
189960
190695
|
}, undefined, false, undefined, this),
|
|
189961
|
-
/* @__PURE__ */
|
|
190696
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189962
190697
|
width: 12,
|
|
189963
|
-
children: /* @__PURE__ */
|
|
190698
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
189964
190699
|
bold: true,
|
|
189965
190700
|
children: "Status"
|
|
189966
190701
|
}, undefined, false, undefined, this)
|
|
189967
190702
|
}, undefined, false, undefined, this),
|
|
189968
|
-
/* @__PURE__ */
|
|
190703
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189969
190704
|
width: 12,
|
|
189970
|
-
children: /* @__PURE__ */
|
|
190705
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
189971
190706
|
bold: true,
|
|
189972
190707
|
children: "Cost"
|
|
189973
190708
|
}, undefined, false, undefined, this)
|
|
189974
190709
|
}, undefined, false, undefined, this)
|
|
189975
190710
|
]
|
|
189976
190711
|
}, undefined, true, undefined, this),
|
|
189977
|
-
/* @__PURE__ */
|
|
190712
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189978
190713
|
flexDirection: "column",
|
|
189979
190714
|
paddingY: 1,
|
|
189980
|
-
children: executedStories.length > 0 ? executedStories.map((story) => /* @__PURE__ */
|
|
190715
|
+
children: executedStories.length > 0 ? executedStories.map((story) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189981
190716
|
children: [
|
|
189982
|
-
/* @__PURE__ */
|
|
190717
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189983
190718
|
width: 12,
|
|
189984
|
-
children: /* @__PURE__ */
|
|
190719
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
189985
190720
|
children: story.story.id
|
|
189986
190721
|
}, undefined, false, undefined, this)
|
|
189987
190722
|
}, undefined, false, undefined, this),
|
|
189988
|
-
/* @__PURE__ */
|
|
190723
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189989
190724
|
width: 12,
|
|
189990
|
-
children: /* @__PURE__ */
|
|
190725
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
189991
190726
|
color: story.status === "passed" ? "green" : story.status === "failed" ? "red" : undefined,
|
|
189992
190727
|
children: story.status
|
|
189993
190728
|
}, undefined, false, undefined, this)
|
|
189994
190729
|
}, undefined, false, undefined, this),
|
|
189995
|
-
/* @__PURE__ */
|
|
190730
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
189996
190731
|
width: 12,
|
|
189997
|
-
children: /* @__PURE__ */
|
|
190732
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
189998
190733
|
children: formatCost2(story.cost || 0)
|
|
189999
190734
|
}, undefined, false, undefined, this)
|
|
190000
190735
|
}, undefined, false, undefined, this)
|
|
190001
190736
|
]
|
|
190002
|
-
}, story.story.id, true, undefined, this)) : /* @__PURE__ */
|
|
190737
|
+
}, story.story.id, true, undefined, this)) : /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
190003
190738
|
dimColor: true,
|
|
190004
190739
|
children: "No stories executed yet"
|
|
190005
190740
|
}, undefined, false, undefined, this)
|
|
190006
190741
|
}, undefined, false, undefined, this),
|
|
190007
|
-
/* @__PURE__ */
|
|
190742
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
190008
190743
|
paddingTop: 1,
|
|
190009
190744
|
borderTop: true,
|
|
190010
190745
|
borderColor: "gray",
|
|
190011
190746
|
children: [
|
|
190012
|
-
/* @__PURE__ */
|
|
190747
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
190013
190748
|
width: 24,
|
|
190014
|
-
children: /* @__PURE__ */
|
|
190749
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
190015
190750
|
bold: true,
|
|
190016
190751
|
children: "Total Cost:"
|
|
190017
190752
|
}, undefined, false, undefined, this)
|
|
190018
190753
|
}, undefined, false, undefined, this),
|
|
190019
|
-
/* @__PURE__ */
|
|
190754
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
190020
190755
|
width: 12,
|
|
190021
|
-
children: /* @__PURE__ */
|
|
190756
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
190022
190757
|
bold: true,
|
|
190023
190758
|
color: "cyan",
|
|
190024
190759
|
children: formatCost2(totalCost)
|
|
@@ -190026,16 +190761,16 @@ function CostOverlay({ visible = false, stories = [], totalCost = 0 }) {
|
|
|
190026
190761
|
}, undefined, false, undefined, this)
|
|
190027
190762
|
]
|
|
190028
190763
|
}, undefined, true, undefined, this),
|
|
190029
|
-
/* @__PURE__ */
|
|
190764
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
190030
190765
|
justifyContent: "center",
|
|
190031
190766
|
paddingTop: 1,
|
|
190032
190767
|
borderTop: true,
|
|
190033
190768
|
borderColor: "gray",
|
|
190034
|
-
children: /* @__PURE__ */
|
|
190769
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
190035
190770
|
dimColor: true,
|
|
190036
190771
|
children: [
|
|
190037
190772
|
"Press ",
|
|
190038
|
-
/* @__PURE__ */
|
|
190773
|
+
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
190039
190774
|
color: "yellow",
|
|
190040
190775
|
children: "Esc"
|
|
190041
190776
|
}, undefined, false, undefined, this),
|
|
@@ -190049,118 +190784,118 @@ function CostOverlay({ visible = false, stories = [], totalCost = 0 }) {
|
|
|
190049
190784
|
|
|
190050
190785
|
// src/tui/components/HelpOverlay.tsx
|
|
190051
190786
|
await init_build3();
|
|
190052
|
-
var
|
|
190787
|
+
var jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
|
|
190053
190788
|
function HelpOverlay({ visible = false }) {
|
|
190054
190789
|
if (!visible) {
|
|
190055
190790
|
return null;
|
|
190056
190791
|
}
|
|
190057
|
-
return /* @__PURE__ */
|
|
190792
|
+
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
|
|
190058
190793
|
flexDirection: "column",
|
|
190059
190794
|
borderStyle: "double",
|
|
190060
190795
|
borderColor: "cyan",
|
|
190061
190796
|
paddingX: 2,
|
|
190062
190797
|
paddingY: 1,
|
|
190063
190798
|
children: [
|
|
190064
|
-
/* @__PURE__ */
|
|
190799
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
|
|
190065
190800
|
paddingBottom: 1,
|
|
190066
|
-
children: /* @__PURE__ */
|
|
190801
|
+
children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190067
190802
|
bold: true,
|
|
190068
190803
|
color: "cyan",
|
|
190069
190804
|
children: "Keyboard Shortcuts"
|
|
190070
190805
|
}, undefined, false, undefined, this)
|
|
190071
190806
|
}, undefined, false, undefined, this),
|
|
190072
|
-
/* @__PURE__ */
|
|
190807
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
|
|
190073
190808
|
flexDirection: "column",
|
|
190074
190809
|
paddingBottom: 1,
|
|
190075
190810
|
children: [
|
|
190076
|
-
/* @__PURE__ */
|
|
190811
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190077
190812
|
dimColor: true,
|
|
190078
190813
|
children: "Stories Panel (default):"
|
|
190079
190814
|
}, undefined, false, undefined, this),
|
|
190080
|
-
/* @__PURE__ */
|
|
190815
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190081
190816
|
children: [
|
|
190082
190817
|
" ",
|
|
190083
|
-
/* @__PURE__ */
|
|
190818
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190084
190819
|
color: "yellow",
|
|
190085
190820
|
children: "p"
|
|
190086
190821
|
}, undefined, false, undefined, this),
|
|
190087
190822
|
" \u2014 Pause after current story"
|
|
190088
190823
|
]
|
|
190089
190824
|
}, undefined, true, undefined, this),
|
|
190090
|
-
/* @__PURE__ */
|
|
190825
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190091
190826
|
children: [
|
|
190092
190827
|
" ",
|
|
190093
|
-
/* @__PURE__ */
|
|
190828
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190094
190829
|
color: "yellow",
|
|
190095
190830
|
children: "a"
|
|
190096
190831
|
}, undefined, false, undefined, this),
|
|
190097
190832
|
" \u2014 Abort run"
|
|
190098
190833
|
]
|
|
190099
190834
|
}, undefined, true, undefined, this),
|
|
190100
|
-
/* @__PURE__ */
|
|
190835
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190101
190836
|
children: [
|
|
190102
190837
|
" ",
|
|
190103
|
-
/* @__PURE__ */
|
|
190838
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190104
190839
|
color: "yellow",
|
|
190105
190840
|
children: "s"
|
|
190106
190841
|
}, undefined, false, undefined, this),
|
|
190107
190842
|
" \u2014 Skip current story"
|
|
190108
190843
|
]
|
|
190109
190844
|
}, undefined, true, undefined, this),
|
|
190110
|
-
/* @__PURE__ */
|
|
190845
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190111
190846
|
children: [
|
|
190112
190847
|
" ",
|
|
190113
|
-
/* @__PURE__ */
|
|
190848
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190114
190849
|
color: "yellow",
|
|
190115
190850
|
children: "Tab"
|
|
190116
190851
|
}, undefined, false, undefined, this),
|
|
190117
190852
|
" \u2014 Toggle focus to Agent panel"
|
|
190118
190853
|
]
|
|
190119
190854
|
}, undefined, true, undefined, this),
|
|
190120
|
-
/* @__PURE__ */
|
|
190855
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190121
190856
|
children: [
|
|
190122
190857
|
" ",
|
|
190123
|
-
/* @__PURE__ */
|
|
190858
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190124
190859
|
color: "yellow",
|
|
190125
190860
|
children: "q"
|
|
190126
190861
|
}, undefined, false, undefined, this),
|
|
190127
190862
|
" \u2014 Quit TUI"
|
|
190128
190863
|
]
|
|
190129
190864
|
}, undefined, true, undefined, this),
|
|
190130
|
-
/* @__PURE__ */
|
|
190865
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190131
190866
|
children: [
|
|
190132
190867
|
" ",
|
|
190133
|
-
/* @__PURE__ */
|
|
190868
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190134
190869
|
color: "yellow",
|
|
190135
190870
|
children: "?"
|
|
190136
190871
|
}, undefined, false, undefined, this),
|
|
190137
190872
|
" \u2014 Show this help"
|
|
190138
190873
|
]
|
|
190139
190874
|
}, undefined, true, undefined, this),
|
|
190140
|
-
/* @__PURE__ */
|
|
190875
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190141
190876
|
children: [
|
|
190142
190877
|
" ",
|
|
190143
|
-
/* @__PURE__ */
|
|
190878
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190144
190879
|
color: "yellow",
|
|
190145
190880
|
children: "c"
|
|
190146
190881
|
}, undefined, false, undefined, this),
|
|
190147
190882
|
" \u2014 Show cost breakdown"
|
|
190148
190883
|
]
|
|
190149
190884
|
}, undefined, true, undefined, this),
|
|
190150
|
-
/* @__PURE__ */
|
|
190885
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190151
190886
|
children: [
|
|
190152
190887
|
" ",
|
|
190153
|
-
/* @__PURE__ */
|
|
190888
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190154
190889
|
color: "yellow",
|
|
190155
190890
|
children: "r"
|
|
190156
190891
|
}, undefined, false, undefined, this),
|
|
190157
190892
|
" \u2014 Retry last failed story"
|
|
190158
190893
|
]
|
|
190159
190894
|
}, undefined, true, undefined, this),
|
|
190160
|
-
/* @__PURE__ */
|
|
190895
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190161
190896
|
children: [
|
|
190162
190897
|
" ",
|
|
190163
|
-
/* @__PURE__ */
|
|
190898
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190164
190899
|
color: "yellow",
|
|
190165
190900
|
children: "Esc"
|
|
190166
190901
|
}, undefined, false, undefined, this),
|
|
@@ -190169,28 +190904,28 @@ function HelpOverlay({ visible = false }) {
|
|
|
190169
190904
|
}, undefined, true, undefined, this)
|
|
190170
190905
|
]
|
|
190171
190906
|
}, undefined, true, undefined, this),
|
|
190172
|
-
/* @__PURE__ */
|
|
190907
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
|
|
190173
190908
|
flexDirection: "column",
|
|
190174
190909
|
paddingBottom: 1,
|
|
190175
190910
|
children: [
|
|
190176
|
-
/* @__PURE__ */
|
|
190911
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190177
190912
|
dimColor: true,
|
|
190178
190913
|
children: "Agent Panel (when focused):"
|
|
190179
190914
|
}, undefined, false, undefined, this),
|
|
190180
|
-
/* @__PURE__ */
|
|
190915
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190181
190916
|
children: [
|
|
190182
190917
|
" ",
|
|
190183
|
-
/* @__PURE__ */
|
|
190918
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190184
190919
|
color: "yellow",
|
|
190185
190920
|
children: "Ctrl+]"
|
|
190186
190921
|
}, undefined, false, undefined, this),
|
|
190187
190922
|
" \u2014 Escape back to Stories panel"
|
|
190188
190923
|
]
|
|
190189
190924
|
}, undefined, true, undefined, this),
|
|
190190
|
-
/* @__PURE__ */
|
|
190925
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190191
190926
|
children: [
|
|
190192
190927
|
" ",
|
|
190193
|
-
/* @__PURE__ */
|
|
190928
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190194
190929
|
dimColor: true,
|
|
190195
190930
|
children: "All other keys"
|
|
190196
190931
|
}, undefined, false, undefined, this),
|
|
@@ -190199,16 +190934,16 @@ function HelpOverlay({ visible = false }) {
|
|
|
190199
190934
|
}, undefined, true, undefined, this)
|
|
190200
190935
|
]
|
|
190201
190936
|
}, undefined, true, undefined, this),
|
|
190202
|
-
/* @__PURE__ */
|
|
190937
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
|
|
190203
190938
|
justifyContent: "center",
|
|
190204
190939
|
paddingTop: 1,
|
|
190205
190940
|
borderTop: true,
|
|
190206
190941
|
borderColor: "gray",
|
|
190207
|
-
children: /* @__PURE__ */
|
|
190942
|
+
children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190208
190943
|
dimColor: true,
|
|
190209
190944
|
children: [
|
|
190210
190945
|
"Press ",
|
|
190211
|
-
/* @__PURE__ */
|
|
190946
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
190212
190947
|
color: "yellow",
|
|
190213
190948
|
children: "Esc"
|
|
190214
190949
|
}, undefined, false, undefined, this),
|
|
@@ -190223,7 +190958,7 @@ function HelpOverlay({ visible = false }) {
|
|
|
190223
190958
|
// src/tui/components/LiveActivityPanel.tsx
|
|
190224
190959
|
init_internal();
|
|
190225
190960
|
await init_build3();
|
|
190226
|
-
var
|
|
190961
|
+
var jsx_dev_runtime11 = __toESM(require_jsx_dev_runtime(), 1);
|
|
190227
190962
|
var MAX_ESCALATION_DISPLAY = 5;
|
|
190228
190963
|
function LiveActivityPanel({
|
|
190229
190964
|
focused = false,
|
|
@@ -190241,33 +190976,33 @@ function LiveActivityPanel({
|
|
|
190241
190976
|
const hasError = runErrored !== undefined;
|
|
190242
190977
|
const recentEscalations = escalationLog.slice(-MAX_ESCALATION_DISPLAY);
|
|
190243
190978
|
const hasEscalations = recentEscalations.length > 0;
|
|
190244
|
-
return /* @__PURE__ */
|
|
190979
|
+
return /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190245
190980
|
flexDirection: "column",
|
|
190246
190981
|
flexGrow: 1,
|
|
190247
190982
|
borderStyle: "single",
|
|
190248
190983
|
borderColor,
|
|
190249
190984
|
children: [
|
|
190250
|
-
/* @__PURE__ */
|
|
190985
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190251
190986
|
paddingX: 1,
|
|
190252
190987
|
borderStyle: "single",
|
|
190253
190988
|
borderBottom: true,
|
|
190254
190989
|
borderColor,
|
|
190255
|
-
children: /* @__PURE__ */
|
|
190990
|
+
children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190256
190991
|
bold: true,
|
|
190257
190992
|
color: focused ? "cyan" : undefined,
|
|
190258
190993
|
children: [
|
|
190259
190994
|
"Live Activity ",
|
|
190260
|
-
focused && /* @__PURE__ */
|
|
190995
|
+
focused && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190261
190996
|
dimColor: true,
|
|
190262
190997
|
children: "(focused)"
|
|
190263
190998
|
}, undefined, false, undefined, this)
|
|
190264
190999
|
]
|
|
190265
191000
|
}, undefined, true, undefined, this)
|
|
190266
191001
|
}, undefined, false, undefined, this),
|
|
190267
|
-
hasError && /* @__PURE__ */
|
|
191002
|
+
hasError && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190268
191003
|
paddingX: 1,
|
|
190269
191004
|
paddingY: 1,
|
|
190270
|
-
children: /* @__PURE__ */
|
|
191005
|
+
children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190271
191006
|
color: "red",
|
|
190272
191007
|
children: [
|
|
190273
191008
|
"[FAIL] ",
|
|
@@ -190275,49 +191010,49 @@ function LiveActivityPanel({
|
|
|
190275
191010
|
]
|
|
190276
191011
|
}, undefined, true, undefined, this)
|
|
190277
191012
|
}, undefined, false, undefined, this),
|
|
190278
|
-
hasSummary && /* @__PURE__ */
|
|
191013
|
+
hasSummary && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190279
191014
|
flexDirection: "column",
|
|
190280
191015
|
paddingX: 1,
|
|
190281
191016
|
paddingY: 1,
|
|
190282
|
-
children: /* @__PURE__ */
|
|
191017
|
+
children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(RunSummaryRow, {
|
|
190283
191018
|
summary: runSummary
|
|
190284
191019
|
}, undefined, false, undefined, this)
|
|
190285
191020
|
}, undefined, false, undefined, this),
|
|
190286
|
-
hasActiveCalls && /* @__PURE__ */
|
|
191021
|
+
hasActiveCalls && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190287
191022
|
flexDirection: "column",
|
|
190288
191023
|
paddingX: 1,
|
|
190289
191024
|
paddingY: 1,
|
|
190290
|
-
children: activeCallList.map((call) => /* @__PURE__ */
|
|
191025
|
+
children: activeCallList.map((call) => /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ActiveCallRow, {
|
|
190291
191026
|
call,
|
|
190292
191027
|
step: call.storyId ? storySteps?.[call.storyId] : undefined,
|
|
190293
191028
|
currentStage
|
|
190294
191029
|
}, call.callId, false, undefined, this))
|
|
190295
191030
|
}, undefined, false, undefined, this),
|
|
190296
|
-
hasEscalations && /* @__PURE__ */
|
|
191031
|
+
hasEscalations && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190297
191032
|
flexDirection: "column",
|
|
190298
191033
|
paddingX: 1,
|
|
190299
191034
|
children: [
|
|
190300
|
-
/* @__PURE__ */
|
|
191035
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190301
191036
|
dimColor: true,
|
|
190302
191037
|
children: "Escalations:"
|
|
190303
191038
|
}, undefined, false, undefined, this),
|
|
190304
|
-
recentEscalations.map((entry) => /* @__PURE__ */
|
|
191039
|
+
recentEscalations.map((entry) => /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(EscalationRow, {
|
|
190305
191040
|
entry
|
|
190306
191041
|
}, `${entry.storyId}-${entry.at}`, false, undefined, this))
|
|
190307
191042
|
]
|
|
190308
191043
|
}, undefined, true, undefined, this),
|
|
190309
|
-
!hasActiveCalls && storySteps && Object.keys(storySteps).length > 0 && /* @__PURE__ */
|
|
191044
|
+
!hasActiveCalls && storySteps && Object.keys(storySteps).length > 0 && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190310
191045
|
flexDirection: "column",
|
|
190311
191046
|
paddingX: 1,
|
|
190312
191047
|
paddingY: 1,
|
|
190313
|
-
children: Object.entries(storySteps).map(([sid, step]) => /* @__PURE__ */
|
|
191048
|
+
children: Object.entries(storySteps).map(([sid, step]) => /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190314
191049
|
flexDirection: "row",
|
|
190315
191050
|
gap: 1,
|
|
190316
191051
|
children: [
|
|
190317
|
-
/* @__PURE__ */
|
|
191052
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190318
191053
|
children: sid
|
|
190319
191054
|
}, undefined, false, undefined, this),
|
|
190320
|
-
/* @__PURE__ */
|
|
191055
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190321
191056
|
color: "yellow",
|
|
190322
191057
|
children: [
|
|
190323
191058
|
"[",
|
|
@@ -190328,14 +191063,14 @@ function LiveActivityPanel({
|
|
|
190328
191063
|
]
|
|
190329
191064
|
}, sid, true, undefined, this))
|
|
190330
191065
|
}, undefined, false, undefined, this),
|
|
190331
|
-
!hasActiveCalls && !hasSummary && !hasError && (!storySteps || Object.keys(storySteps).length === 0) && /* @__PURE__ */
|
|
191066
|
+
!hasActiveCalls && !hasSummary && !hasError && (!storySteps || Object.keys(storySteps).length === 0) && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190332
191067
|
paddingX: 1,
|
|
190333
191068
|
paddingY: 1,
|
|
190334
|
-
children: currentStage ? /* @__PURE__ */
|
|
191069
|
+
children: currentStage ? /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190335
191070
|
flexDirection: "row",
|
|
190336
191071
|
gap: 1,
|
|
190337
191072
|
children: [
|
|
190338
|
-
/* @__PURE__ */
|
|
191073
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190339
191074
|
color: "yellow",
|
|
190340
191075
|
children: [
|
|
190341
191076
|
"[",
|
|
@@ -190343,12 +191078,12 @@ function LiveActivityPanel({
|
|
|
190343
191078
|
"]"
|
|
190344
191079
|
]
|
|
190345
191080
|
}, undefined, true, undefined, this),
|
|
190346
|
-
/* @__PURE__ */
|
|
191081
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190347
191082
|
dimColor: true,
|
|
190348
191083
|
children: "preparing..."
|
|
190349
191084
|
}, undefined, false, undefined, this)
|
|
190350
191085
|
]
|
|
190351
|
-
}, undefined, true, undefined, this) : /* @__PURE__ */
|
|
191086
|
+
}, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190352
191087
|
dimColor: true,
|
|
190353
191088
|
children: "Waiting for agent..."
|
|
190354
191089
|
}, undefined, false, undefined, this)
|
|
@@ -190357,21 +191092,21 @@ function LiveActivityPanel({
|
|
|
190357
191092
|
}, undefined, true, undefined, this);
|
|
190358
191093
|
}
|
|
190359
191094
|
function ActiveCallRow({ call, step, currentStage }) {
|
|
190360
|
-
const stageLabel = step ? /* @__PURE__ */
|
|
191095
|
+
const stageLabel = step ? /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190361
191096
|
color: "yellow",
|
|
190362
191097
|
children: [
|
|
190363
191098
|
"[",
|
|
190364
191099
|
step,
|
|
190365
191100
|
"]"
|
|
190366
191101
|
]
|
|
190367
|
-
}, undefined, true, undefined, this) : call.stage ? /* @__PURE__ */
|
|
191102
|
+
}, undefined, true, undefined, this) : call.stage ? /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190368
191103
|
dimColor: true,
|
|
190369
191104
|
children: [
|
|
190370
191105
|
"[",
|
|
190371
191106
|
call.stage,
|
|
190372
191107
|
"]"
|
|
190373
191108
|
]
|
|
190374
|
-
}, undefined, true, undefined, this) : currentStage ? /* @__PURE__ */
|
|
191109
|
+
}, undefined, true, undefined, this) : currentStage ? /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190375
191110
|
dimColor: true,
|
|
190376
191111
|
children: [
|
|
190377
191112
|
"[",
|
|
@@ -190379,43 +191114,43 @@ function ActiveCallRow({ call, step, currentStage }) {
|
|
|
190379
191114
|
"]"
|
|
190380
191115
|
]
|
|
190381
191116
|
}, undefined, true, undefined, this) : null;
|
|
190382
|
-
return /* @__PURE__ */
|
|
191117
|
+
return /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190383
191118
|
flexDirection: "column",
|
|
190384
191119
|
marginBottom: 1,
|
|
190385
191120
|
children: [
|
|
190386
|
-
/* @__PURE__ */
|
|
191121
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190387
191122
|
flexDirection: "row",
|
|
190388
191123
|
gap: 1,
|
|
190389
191124
|
children: [
|
|
190390
|
-
/* @__PURE__ */
|
|
191125
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190391
191126
|
color: "cyan",
|
|
190392
191127
|
children: call.agentName
|
|
190393
191128
|
}, undefined, false, undefined, this),
|
|
190394
|
-
call.storyId && /* @__PURE__ */
|
|
191129
|
+
call.storyId && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190395
191130
|
children: stripControlChars(call.storyId)
|
|
190396
191131
|
}, undefined, false, undefined, this),
|
|
190397
191132
|
stageLabel
|
|
190398
191133
|
]
|
|
190399
191134
|
}, undefined, true, undefined, this),
|
|
190400
|
-
/* @__PURE__ */
|
|
191135
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190401
191136
|
flexDirection: "row",
|
|
190402
191137
|
gap: 1,
|
|
190403
191138
|
children: [
|
|
190404
|
-
call.model && /* @__PURE__ */
|
|
191139
|
+
call.model && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190405
191140
|
dimColor: true,
|
|
190406
191141
|
children: [
|
|
190407
191142
|
"model:",
|
|
190408
191143
|
call.model
|
|
190409
191144
|
]
|
|
190410
191145
|
}, undefined, true, undefined, this),
|
|
190411
|
-
call.lastToolName && /* @__PURE__ */
|
|
191146
|
+
call.lastToolName && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190412
191147
|
dimColor: true,
|
|
190413
191148
|
children: [
|
|
190414
191149
|
"tool:",
|
|
190415
191150
|
stripControlChars(call.lastToolName)
|
|
190416
191151
|
]
|
|
190417
191152
|
}, undefined, true, undefined, this),
|
|
190418
|
-
/* @__PURE__ */
|
|
191153
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190419
191154
|
dimColor: true,
|
|
190420
191155
|
children: [
|
|
190421
191156
|
"tools:",
|
|
@@ -190431,38 +191166,38 @@ function ActiveCallRow({ call, step, currentStage }) {
|
|
|
190431
191166
|
}
|
|
190432
191167
|
function RunSummaryRow({ summary }) {
|
|
190433
191168
|
const cost = summary.totalCost !== undefined ? `$${summary.totalCost.toFixed(4)}` : null;
|
|
190434
|
-
return /* @__PURE__ */
|
|
191169
|
+
return /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190435
191170
|
flexDirection: "column",
|
|
190436
|
-
children: /* @__PURE__ */
|
|
191171
|
+
children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190437
191172
|
flexDirection: "row",
|
|
190438
191173
|
gap: 1,
|
|
190439
191174
|
children: [
|
|
190440
|
-
/* @__PURE__ */
|
|
191175
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190441
191176
|
bold: true,
|
|
190442
191177
|
children: "Run complete"
|
|
190443
191178
|
}, undefined, false, undefined, this),
|
|
190444
|
-
/* @__PURE__ */
|
|
191179
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190445
191180
|
color: "green",
|
|
190446
191181
|
children: [
|
|
190447
191182
|
summary.passedStories,
|
|
190448
191183
|
" passed"
|
|
190449
191184
|
]
|
|
190450
191185
|
}, undefined, true, undefined, this),
|
|
190451
|
-
summary.failedStories > 0 && /* @__PURE__ */
|
|
191186
|
+
summary.failedStories > 0 && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190452
191187
|
color: "red",
|
|
190453
191188
|
children: [
|
|
190454
191189
|
summary.failedStories,
|
|
190455
191190
|
" failed"
|
|
190456
191191
|
]
|
|
190457
191192
|
}, undefined, true, undefined, this),
|
|
190458
|
-
summary.skippedStories > 0 && /* @__PURE__ */
|
|
191193
|
+
summary.skippedStories > 0 && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190459
191194
|
dimColor: true,
|
|
190460
191195
|
children: [
|
|
190461
191196
|
summary.skippedStories,
|
|
190462
191197
|
" skipped"
|
|
190463
191198
|
]
|
|
190464
191199
|
}, undefined, true, undefined, this),
|
|
190465
|
-
cost && /* @__PURE__ */
|
|
191200
|
+
cost && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190466
191201
|
dimColor: true,
|
|
190467
191202
|
children: cost
|
|
190468
191203
|
}, undefined, false, undefined, this)
|
|
@@ -190471,23 +191206,23 @@ function RunSummaryRow({ summary }) {
|
|
|
190471
191206
|
}, undefined, false, undefined, this);
|
|
190472
191207
|
}
|
|
190473
191208
|
function EscalationRow({ entry }) {
|
|
190474
|
-
return /* @__PURE__ */
|
|
191209
|
+
return /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
190475
191210
|
flexDirection: "row",
|
|
190476
191211
|
gap: 1,
|
|
190477
191212
|
children: [
|
|
190478
|
-
/* @__PURE__ */
|
|
191213
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190479
191214
|
dimColor: true,
|
|
190480
191215
|
children: stripControlChars(entry.storyId)
|
|
190481
191216
|
}, undefined, false, undefined, this),
|
|
190482
|
-
/* @__PURE__ */
|
|
191217
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190483
191218
|
color: "yellow",
|
|
190484
191219
|
children: entry.fromTier
|
|
190485
191220
|
}, undefined, false, undefined, this),
|
|
190486
|
-
/* @__PURE__ */
|
|
191221
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190487
191222
|
dimColor: true,
|
|
190488
191223
|
children: "->"
|
|
190489
191224
|
}, undefined, false, undefined, this),
|
|
190490
|
-
/* @__PURE__ */
|
|
191225
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
190491
191226
|
color: "cyan",
|
|
190492
191227
|
children: entry.toTier
|
|
190493
191228
|
}, undefined, false, undefined, this)
|
|
@@ -190497,7 +191232,7 @@ function EscalationRow({ entry }) {
|
|
|
190497
191232
|
|
|
190498
191233
|
// src/tui/components/StatusBar.tsx
|
|
190499
191234
|
await init_build3();
|
|
190500
|
-
var
|
|
191235
|
+
var jsx_dev_runtime12 = __toESM(require_jsx_dev_runtime(), 1);
|
|
190501
191236
|
function StatusBar({
|
|
190502
191237
|
currentStage,
|
|
190503
191238
|
currentStoryId,
|
|
@@ -190522,20 +191257,20 @@ function StatusBar({
|
|
|
190522
191257
|
} else {
|
|
190523
191258
|
context = "idle";
|
|
190524
191259
|
}
|
|
190525
|
-
return /* @__PURE__ */
|
|
191260
|
+
return /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(Box_default, {
|
|
190526
191261
|
paddingX: 1,
|
|
190527
191262
|
borderStyle: "single",
|
|
190528
191263
|
borderColor: "gray",
|
|
190529
191264
|
justifyContent: "space-between",
|
|
190530
191265
|
children: [
|
|
190531
|
-
/* @__PURE__ */
|
|
191266
|
+
/* @__PURE__ */ jsx_dev_runtime12.jsxDEV(Text, {
|
|
190532
191267
|
dimColor: true,
|
|
190533
191268
|
children: hints
|
|
190534
191269
|
}, undefined, false, undefined, this),
|
|
190535
|
-
errorMessage ? /* @__PURE__ */
|
|
191270
|
+
errorMessage ? /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(Text, {
|
|
190536
191271
|
color: "red",
|
|
190537
191272
|
children: errorMessage
|
|
190538
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */
|
|
191273
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(Text, {
|
|
190539
191274
|
dimColor: true,
|
|
190540
191275
|
children: context
|
|
190541
191276
|
}, undefined, false, undefined, this)
|
|
@@ -190546,13 +191281,13 @@ function StatusBar({
|
|
|
190546
191281
|
// src/tui/components/StoriesPanel.tsx
|
|
190547
191282
|
init_internal();
|
|
190548
191283
|
await init_build3();
|
|
190549
|
-
var
|
|
191284
|
+
var import_react44 = __toESM(require_react(), 1);
|
|
190550
191285
|
|
|
190551
191286
|
// src/tui/hooks/useLayout.ts
|
|
190552
|
-
var
|
|
191287
|
+
var import_react43 = __toESM(require_react(), 1);
|
|
190553
191288
|
function useLayout() {
|
|
190554
|
-
const [layout, setLayout] =
|
|
190555
|
-
|
|
191289
|
+
const [layout, setLayout] = import_react43.useState(() => computeLayout());
|
|
191290
|
+
import_react43.useEffect(() => {
|
|
190556
191291
|
const handleResize = () => {
|
|
190557
191292
|
setLayout(computeLayout());
|
|
190558
191293
|
};
|
|
@@ -190589,7 +191324,7 @@ function computeLayout() {
|
|
|
190589
191324
|
}
|
|
190590
191325
|
|
|
190591
191326
|
// src/tui/components/StoriesPanel.tsx
|
|
190592
|
-
var
|
|
191327
|
+
var jsx_dev_runtime13 = __toESM(require_jsx_dev_runtime(), 1);
|
|
190593
191328
|
function getStatusIcon(status) {
|
|
190594
191329
|
switch (status) {
|
|
190595
191330
|
case "pending":
|
|
@@ -190618,8 +191353,8 @@ function StoriesPanel({
|
|
|
190618
191353
|
}) {
|
|
190619
191354
|
const maxVisible = compact ? COMPACT_MAX_VISIBLE_STORIES : MAX_VISIBLE_STORIES;
|
|
190620
191355
|
const needsScrolling = stories.length > maxVisible;
|
|
190621
|
-
const [scrollOffset, setScrollOffset] =
|
|
190622
|
-
|
|
191356
|
+
const [scrollOffset, setScrollOffset] = import_react44.useState(0);
|
|
191357
|
+
import_react44.useEffect(() => {
|
|
190623
191358
|
const runningIndex = stories.findIndex((s) => s.status === "running");
|
|
190624
191359
|
if (runningIndex !== -1 && needsScrolling) {
|
|
190625
191360
|
if (runningIndex < scrollOffset) {
|
|
@@ -190632,24 +191367,24 @@ function StoriesPanel({
|
|
|
190632
191367
|
const visibleStories = needsScrolling ? stories.slice(scrollOffset, scrollOffset + maxVisible) : stories;
|
|
190633
191368
|
const canScrollUp = scrollOffset > 0;
|
|
190634
191369
|
const canScrollDown = scrollOffset + maxVisible < stories.length;
|
|
190635
|
-
return /* @__PURE__ */
|
|
191370
|
+
return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
190636
191371
|
flexDirection: "column",
|
|
190637
191372
|
width,
|
|
190638
191373
|
height: maxHeight,
|
|
190639
191374
|
borderStyle: "single",
|
|
190640
191375
|
borderColor: "gray",
|
|
190641
191376
|
children: [
|
|
190642
|
-
/* @__PURE__ */
|
|
191377
|
+
/* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
190643
191378
|
paddingX: 1,
|
|
190644
191379
|
borderStyle: "single",
|
|
190645
191380
|
borderBottom: true,
|
|
190646
191381
|
borderColor: "gray",
|
|
190647
191382
|
children: [
|
|
190648
|
-
/* @__PURE__ */
|
|
191383
|
+
/* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190649
191384
|
bold: true,
|
|
190650
191385
|
children: "Progress"
|
|
190651
191386
|
}, undefined, false, undefined, this),
|
|
190652
|
-
needsScrolling && /* @__PURE__ */
|
|
191387
|
+
needsScrolling && /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190653
191388
|
dimColor: true,
|
|
190654
191389
|
children: [
|
|
190655
191390
|
" (",
|
|
@@ -190659,19 +191394,19 @@ function StoriesPanel({
|
|
|
190659
191394
|
}, undefined, true, undefined, this)
|
|
190660
191395
|
]
|
|
190661
191396
|
}, undefined, true, undefined, this),
|
|
190662
|
-
preRunPhases && Object.keys(preRunPhases).length > 0 && /* @__PURE__ */
|
|
191397
|
+
preRunPhases && Object.keys(preRunPhases).length > 0 && /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
190663
191398
|
flexDirection: "column",
|
|
190664
191399
|
paddingX: 1,
|
|
190665
191400
|
paddingTop: 1,
|
|
190666
|
-
children: Object.entries(preRunPhases).map(([name, phase]) => /* @__PURE__ */
|
|
191401
|
+
children: Object.entries(preRunPhases).map(([name, phase]) => /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(PreRunPhaseRow, {
|
|
190667
191402
|
label: name,
|
|
190668
191403
|
phase,
|
|
190669
191404
|
compact
|
|
190670
191405
|
}, name, false, undefined, this))
|
|
190671
191406
|
}, undefined, false, undefined, this),
|
|
190672
|
-
needsScrolling && canScrollUp && /* @__PURE__ */
|
|
191407
|
+
needsScrolling && canScrollUp && /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
190673
191408
|
paddingX: 1,
|
|
190674
|
-
children: /* @__PURE__ */
|
|
191409
|
+
children: /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190675
191410
|
dimColor: true,
|
|
190676
191411
|
children: [
|
|
190677
191412
|
"\u25B2 ",
|
|
@@ -190680,7 +191415,7 @@ function StoriesPanel({
|
|
|
190680
191415
|
]
|
|
190681
191416
|
}, undefined, true, undefined, this)
|
|
190682
191417
|
}, undefined, false, undefined, this),
|
|
190683
|
-
/* @__PURE__ */
|
|
191418
|
+
/* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
190684
191419
|
flexDirection: "column",
|
|
190685
191420
|
paddingX: 1,
|
|
190686
191421
|
paddingY: 1,
|
|
@@ -190688,8 +191423,8 @@ function StoriesPanel({
|
|
|
190688
191423
|
children: visibleStories.map((s) => {
|
|
190689
191424
|
const icon = getStatusIcon(s.status);
|
|
190690
191425
|
if (compact) {
|
|
190691
|
-
return /* @__PURE__ */
|
|
190692
|
-
children: /* @__PURE__ */
|
|
191426
|
+
return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
191427
|
+
children: /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190693
191428
|
children: [
|
|
190694
191429
|
icon,
|
|
190695
191430
|
" ",
|
|
@@ -190704,19 +191439,19 @@ function StoriesPanel({
|
|
|
190704
191439
|
const showFailureLine = (s.status === "failed" || s.status === "paused") && s.failureReason;
|
|
190705
191440
|
const safeId = stripControlChars(s.story.id);
|
|
190706
191441
|
const safeFailureReason = showFailureLine ? stripControlChars(s.failureReason.slice(0, 25)) : "";
|
|
190707
|
-
return /* @__PURE__ */
|
|
191442
|
+
return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
190708
191443
|
flexDirection: "column",
|
|
190709
191444
|
children: [
|
|
190710
|
-
/* @__PURE__ */
|
|
191445
|
+
/* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190711
191446
|
children: [
|
|
190712
191447
|
icon,
|
|
190713
191448
|
" ",
|
|
190714
191449
|
safeId,
|
|
190715
|
-
/* @__PURE__ */
|
|
191450
|
+
/* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190716
191451
|
dimColor: true,
|
|
190717
191452
|
children: routing
|
|
190718
191453
|
}, undefined, false, undefined, this),
|
|
190719
|
-
tierSuffix ? /* @__PURE__ */
|
|
191454
|
+
tierSuffix ? /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190720
191455
|
dimColor: true,
|
|
190721
191456
|
children: [
|
|
190722
191457
|
" ",
|
|
@@ -190725,7 +191460,7 @@ function StoriesPanel({
|
|
|
190725
191460
|
}, undefined, true, undefined, this) : null
|
|
190726
191461
|
]
|
|
190727
191462
|
}, undefined, true, undefined, this),
|
|
190728
|
-
showFailureLine && /* @__PURE__ */
|
|
191463
|
+
showFailureLine && /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190729
191464
|
dimColor: true,
|
|
190730
191465
|
children: ` \u2514 ${safeFailureReason}`
|
|
190731
191466
|
}, undefined, false, undefined, this)
|
|
@@ -190733,9 +191468,9 @@ function StoriesPanel({
|
|
|
190733
191468
|
}, s.story.id, true, undefined, this);
|
|
190734
191469
|
})
|
|
190735
191470
|
}, undefined, false, undefined, this),
|
|
190736
|
-
needsScrolling && canScrollDown && /* @__PURE__ */
|
|
191471
|
+
needsScrolling && canScrollDown && /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
190737
191472
|
paddingX: 1,
|
|
190738
|
-
children: /* @__PURE__ */
|
|
191473
|
+
children: /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190739
191474
|
dimColor: true,
|
|
190740
191475
|
children: [
|
|
190741
191476
|
"\u25BC ",
|
|
@@ -190744,26 +191479,26 @@ function StoriesPanel({
|
|
|
190744
191479
|
]
|
|
190745
191480
|
}, undefined, true, undefined, this)
|
|
190746
191481
|
}, undefined, false, undefined, this),
|
|
190747
|
-
postRunPhases && (postRunPhases.acceptance || postRunPhases.regression || postRunPhases.review) && /* @__PURE__ */
|
|
191482
|
+
postRunPhases && (postRunPhases.acceptance || postRunPhases.regression || postRunPhases.review) && /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
190748
191483
|
flexDirection: "column",
|
|
190749
191484
|
paddingX: 1,
|
|
190750
191485
|
paddingTop: 1,
|
|
190751
191486
|
children: [
|
|
190752
|
-
/* @__PURE__ */
|
|
191487
|
+
/* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190753
191488
|
dimColor: true,
|
|
190754
191489
|
children: "Post-Run"
|
|
190755
191490
|
}, undefined, false, undefined, this),
|
|
190756
|
-
postRunPhases.acceptance && /* @__PURE__ */
|
|
191491
|
+
postRunPhases.acceptance && /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(PostRunPhaseRow, {
|
|
190757
191492
|
label: "acceptance",
|
|
190758
191493
|
phase: postRunPhases.acceptance,
|
|
190759
191494
|
compact
|
|
190760
191495
|
}, undefined, false, undefined, this),
|
|
190761
|
-
postRunPhases.regression && /* @__PURE__ */
|
|
191496
|
+
postRunPhases.regression && /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(PostRunPhaseRow, {
|
|
190762
191497
|
label: "regression",
|
|
190763
191498
|
phase: postRunPhases.regression,
|
|
190764
191499
|
compact
|
|
190765
191500
|
}, undefined, false, undefined, this),
|
|
190766
|
-
postRunPhases.review && /* @__PURE__ */
|
|
191501
|
+
postRunPhases.review && /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(PostRunPhaseRow, {
|
|
190767
191502
|
label: "review",
|
|
190768
191503
|
phase: postRunPhases.review,
|
|
190769
191504
|
compact
|
|
@@ -190777,8 +191512,8 @@ function PreRunPhaseRow({ label, phase, compact }) {
|
|
|
190777
191512
|
const icon = phase.status === "running" ? "\u25CF" : phase.status === "passed" ? "\u2713" : "\u2717";
|
|
190778
191513
|
const color = phase.status === "running" ? "yellow" : phase.status === "passed" ? "green" : "red";
|
|
190779
191514
|
const displayLabel = compact ? label.slice(0, 6) : label;
|
|
190780
|
-
return /* @__PURE__ */
|
|
190781
|
-
children: /* @__PURE__ */
|
|
191515
|
+
return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
191516
|
+
children: /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190782
191517
|
color,
|
|
190783
191518
|
children: [
|
|
190784
191519
|
icon,
|
|
@@ -190791,8 +191526,8 @@ function PreRunPhaseRow({ label, phase, compact }) {
|
|
|
190791
191526
|
function PostRunPhaseRow({ label, phase, compact }) {
|
|
190792
191527
|
const icon = phase.status === "running" ? ">" : phase.status === "passed" ? "[OK]" : "[X]";
|
|
190793
191528
|
const color = phase.status === "running" ? "cyan" : phase.status === "passed" ? "green" : "red";
|
|
190794
|
-
return /* @__PURE__ */
|
|
190795
|
-
children: /* @__PURE__ */
|
|
191529
|
+
return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
191530
|
+
children: /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
190796
191531
|
color,
|
|
190797
191532
|
children: [
|
|
190798
191533
|
icon,
|
|
@@ -190804,18 +191539,18 @@ function PostRunPhaseRow({ label, phase, compact }) {
|
|
|
190804
191539
|
}
|
|
190805
191540
|
|
|
190806
191541
|
// src/tui/hooks/useAgentStreamEvents.ts
|
|
190807
|
-
var
|
|
191542
|
+
var import_react45 = __toESM(require_react(), 1);
|
|
190808
191543
|
var RENDER_INTERVAL_MS = 150;
|
|
190809
191544
|
function useAgentStreamEvents(bus) {
|
|
190810
|
-
const activeCallsRef =
|
|
190811
|
-
const inputTokensRef =
|
|
190812
|
-
const outputTokensRef =
|
|
190813
|
-
const lastTokensRef =
|
|
190814
|
-
const dirtyRef =
|
|
190815
|
-
const [activeCalls, setActiveCalls] =
|
|
190816
|
-
const [inputTokens, setInputTokens] =
|
|
190817
|
-
const [outputTokens, setOutputTokens] =
|
|
190818
|
-
|
|
191545
|
+
const activeCallsRef = import_react45.useRef(new Map);
|
|
191546
|
+
const inputTokensRef = import_react45.useRef(0);
|
|
191547
|
+
const outputTokensRef = import_react45.useRef(0);
|
|
191548
|
+
const lastTokensRef = import_react45.useRef(new Map);
|
|
191549
|
+
const dirtyRef = import_react45.useRef(false);
|
|
191550
|
+
const [activeCalls, setActiveCalls] = import_react45.useState(new Map);
|
|
191551
|
+
const [inputTokens, setInputTokens] = import_react45.useState(0);
|
|
191552
|
+
const [outputTokens, setOutputTokens] = import_react45.useState(0);
|
|
191553
|
+
import_react45.useEffect(() => {
|
|
190819
191554
|
if (!bus)
|
|
190820
191555
|
return;
|
|
190821
191556
|
const unsubscribe = bus.onAgentStream((event) => {
|
|
@@ -190911,7 +191646,7 @@ function useAgentStreamEvents(bus) {
|
|
|
190911
191646
|
lastTokensRef.current.clear();
|
|
190912
191647
|
};
|
|
190913
191648
|
}, [bus]);
|
|
190914
|
-
|
|
191649
|
+
import_react45.useEffect(() => {
|
|
190915
191650
|
const interval = setInterval(() => {
|
|
190916
191651
|
if (!dirtyRef.current)
|
|
190917
191652
|
return;
|
|
@@ -190988,10 +191723,10 @@ function useKeyboard({ focus, currentStory, onAction, disabled = false }) {
|
|
|
190988
191723
|
|
|
190989
191724
|
// src/tui/hooks/usePipelineBusEvents.ts
|
|
190990
191725
|
init_pipeline2();
|
|
190991
|
-
var
|
|
191726
|
+
var import_react46 = __toESM(require_react(), 1);
|
|
190992
191727
|
var MAX_ESCALATION_LOG_ENTRIES = 5;
|
|
190993
191728
|
function usePipelineBusEvents(initialStories) {
|
|
190994
|
-
const [state, setState] =
|
|
191729
|
+
const [state, setState] = import_react46.useState(() => ({
|
|
190995
191730
|
stories: initialStories,
|
|
190996
191731
|
totalCost: 0,
|
|
190997
191732
|
runPaused: false,
|
|
@@ -191000,7 +191735,7 @@ function usePipelineBusEvents(initialStories) {
|
|
|
191000
191735
|
storySteps: {},
|
|
191001
191736
|
postRunPhases: {}
|
|
191002
191737
|
}));
|
|
191003
|
-
|
|
191738
|
+
import_react46.useEffect(() => {
|
|
191004
191739
|
const unsubStarted = pipelineEventBus.on("story:started", (event) => {
|
|
191005
191740
|
setState((prev) => ({
|
|
191006
191741
|
...prev,
|
|
@@ -191134,12 +191869,12 @@ function usePipelineBusEvents(initialStories) {
|
|
|
191134
191869
|
}
|
|
191135
191870
|
|
|
191136
191871
|
// src/tui/hooks/usePipelineEvents.ts
|
|
191137
|
-
var
|
|
191872
|
+
var import_react47 = __toESM(require_react(), 1);
|
|
191138
191873
|
var PRE_RUN_STAGES = new Set(["acceptance-setup"]);
|
|
191139
191874
|
function usePipelineEvents(events) {
|
|
191140
|
-
const [currentStage, setCurrentStage] =
|
|
191141
|
-
const [preRunPhases, setPreRunPhases] =
|
|
191142
|
-
|
|
191875
|
+
const [currentStage, setCurrentStage] = import_react47.useState(undefined);
|
|
191876
|
+
const [preRunPhases, setPreRunPhases] = import_react47.useState({});
|
|
191877
|
+
import_react47.useEffect(() => {
|
|
191143
191878
|
const onStageEnter = (stage) => {
|
|
191144
191879
|
setCurrentStage(stage);
|
|
191145
191880
|
if (PRE_RUN_STAGES.has(stage)) {
|
|
@@ -191165,9 +191900,9 @@ function usePipelineEvents(events) {
|
|
|
191165
191900
|
}
|
|
191166
191901
|
|
|
191167
191902
|
// src/tui/App.tsx
|
|
191168
|
-
var
|
|
191169
|
-
var MemoStoriesPanel =
|
|
191170
|
-
var MemoLiveActivityPanel =
|
|
191903
|
+
var jsx_dev_runtime14 = __toESM(require_jsx_dev_runtime(), 1);
|
|
191904
|
+
var MemoStoriesPanel = import_react48.memo(StoriesPanel);
|
|
191905
|
+
var MemoLiveActivityPanel = import_react48.memo(LiveActivityPanel);
|
|
191171
191906
|
function formatElapsed(ms) {
|
|
191172
191907
|
const mins = Math.floor(ms / 60000);
|
|
191173
191908
|
const secs = Math.floor(ms % 60000 / 1000);
|
|
@@ -191188,20 +191923,20 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191188
191923
|
const busState = usePipelineBusEvents(initialStories);
|
|
191189
191924
|
const { currentStage, preRunPhases } = usePipelineEvents(events);
|
|
191190
191925
|
const { exit } = use_app_default();
|
|
191191
|
-
const startTimeRef =
|
|
191192
|
-
const [elapsedMs, setElapsedMs] =
|
|
191193
|
-
|
|
191926
|
+
const startTimeRef = import_react48.useRef(Date.now());
|
|
191927
|
+
const [elapsedMs, setElapsedMs] = import_react48.useState(0);
|
|
191928
|
+
import_react48.useEffect(() => {
|
|
191194
191929
|
if (busState.runSummary)
|
|
191195
191930
|
return;
|
|
191196
191931
|
const timer = setInterval(() => setElapsedMs(Date.now() - startTimeRef.current), 1000);
|
|
191197
191932
|
return () => clearInterval(timer);
|
|
191198
191933
|
}, [busState.runSummary]);
|
|
191199
|
-
const [focus, setFocus] =
|
|
191200
|
-
const [showHelp, setShowHelp] =
|
|
191201
|
-
const [showCost, setShowCost] =
|
|
191202
|
-
const [showQuitConfirm, setShowQuitConfirm] =
|
|
191203
|
-
const [showAbortConfirm, setShowAbortConfirm] =
|
|
191204
|
-
const [queueActionError, setQueueActionError] =
|
|
191934
|
+
const [focus, setFocus] = import_react48.useState("stories" /* Stories */);
|
|
191935
|
+
const [showHelp, setShowHelp] = import_react48.useState(false);
|
|
191936
|
+
const [showCost, setShowCost] = import_react48.useState(false);
|
|
191937
|
+
const [showQuitConfirm, setShowQuitConfirm] = import_react48.useState(false);
|
|
191938
|
+
const [showAbortConfirm, setShowAbortConfirm] = import_react48.useState(false);
|
|
191939
|
+
const [queueActionError, setQueueActionError] = import_react48.useState(undefined);
|
|
191205
191940
|
const { activeCalls, inputTokens, outputTokens } = useAgentStreamEvents(agentStreamEvents);
|
|
191206
191941
|
const isRunComplete = !!busState.runSummary;
|
|
191207
191942
|
const runningStories = busState.stories.filter((s) => s.status === "running");
|
|
@@ -191309,24 +192044,24 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191309
192044
|
formatElapsed(displayElapsed)
|
|
191310
192045
|
].filter(Boolean).join(" \xB7 ");
|
|
191311
192046
|
const maxHeight = layout.mode === "single" ? COMPACT_MAX_VISIBLE_STORIES : MAX_VISIBLE_STORIES;
|
|
191312
|
-
return /* @__PURE__ */
|
|
192047
|
+
return /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
191313
192048
|
flexDirection: "column",
|
|
191314
192049
|
height: "100%",
|
|
191315
192050
|
children: [
|
|
191316
|
-
/* @__PURE__ */
|
|
192051
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
191317
192052
|
paddingX: 1,
|
|
191318
192053
|
borderStyle: "single",
|
|
191319
192054
|
borderBottom: true,
|
|
191320
192055
|
borderColor: "cyan",
|
|
191321
192056
|
justifyContent: "space-between",
|
|
191322
192057
|
children: [
|
|
191323
|
-
/* @__PURE__ */
|
|
192058
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191324
192059
|
bold: true,
|
|
191325
192060
|
color: "cyan",
|
|
191326
192061
|
children: [
|
|
191327
192062
|
"nax run \u2014 ",
|
|
191328
192063
|
feature,
|
|
191329
|
-
version ? /* @__PURE__ */
|
|
192064
|
+
version ? /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191330
192065
|
dimColor: true,
|
|
191331
192066
|
color: "cyan",
|
|
191332
192067
|
children: [
|
|
@@ -191336,16 +192071,16 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191336
192071
|
}, undefined, true, undefined, this) : null
|
|
191337
192072
|
]
|
|
191338
192073
|
}, undefined, true, undefined, this),
|
|
191339
|
-
/* @__PURE__ */
|
|
192074
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191340
192075
|
dimColor: true,
|
|
191341
192076
|
children: headerRight
|
|
191342
192077
|
}, undefined, false, undefined, this)
|
|
191343
192078
|
]
|
|
191344
192079
|
}, undefined, true, undefined, this),
|
|
191345
|
-
isTooSmall && /* @__PURE__ */
|
|
192080
|
+
isTooSmall && /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
191346
192081
|
paddingX: 1,
|
|
191347
192082
|
backgroundColor: "yellow",
|
|
191348
|
-
children: /* @__PURE__ */
|
|
192083
|
+
children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191349
192084
|
color: "black",
|
|
191350
192085
|
children: [
|
|
191351
192086
|
"Terminal too narrow (",
|
|
@@ -191356,11 +192091,11 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191356
192091
|
]
|
|
191357
192092
|
}, undefined, true, undefined, this)
|
|
191358
192093
|
}, undefined, false, undefined, this),
|
|
191359
|
-
/* @__PURE__ */
|
|
192094
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
191360
192095
|
flexDirection: layout.mode === "single" ? "column" : "row",
|
|
191361
192096
|
flexGrow: 1,
|
|
191362
192097
|
children: [
|
|
191363
|
-
/* @__PURE__ */
|
|
192098
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(MemoStoriesPanel, {
|
|
191364
192099
|
stories: busState.stories,
|
|
191365
192100
|
preRunPhases,
|
|
191366
192101
|
postRunPhases: busState.postRunPhases,
|
|
@@ -191368,7 +192103,7 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191368
192103
|
compact: layout.mode === "single",
|
|
191369
192104
|
maxHeight
|
|
191370
192105
|
}, undefined, false, undefined, this),
|
|
191371
|
-
/* @__PURE__ */
|
|
192106
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(MemoLiveActivityPanel, {
|
|
191372
192107
|
focused: focus === "agent" /* Agent */,
|
|
191373
192108
|
activeCalls,
|
|
191374
192109
|
storySteps: busState.storySteps,
|
|
@@ -191379,7 +192114,7 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191379
192114
|
}, undefined, false, undefined, this)
|
|
191380
192115
|
]
|
|
191381
192116
|
}, undefined, true, undefined, this),
|
|
191382
|
-
/* @__PURE__ */
|
|
192117
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(StatusBar, {
|
|
191383
192118
|
currentStage,
|
|
191384
192119
|
currentStoryId: currentRunningStory?.story.id,
|
|
191385
192120
|
modelTier: currentRunningStory?.modelTier,
|
|
@@ -191389,21 +192124,21 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191389
192124
|
activeCount,
|
|
191390
192125
|
errorMessage: queueActionError
|
|
191391
192126
|
}, undefined, false, undefined, this),
|
|
191392
|
-
/* @__PURE__ */
|
|
192127
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(HelpOverlay, {
|
|
191393
192128
|
visible: showHelp
|
|
191394
192129
|
}, undefined, false, undefined, this),
|
|
191395
|
-
/* @__PURE__ */
|
|
192130
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(CostOverlay, {
|
|
191396
192131
|
visible: showCost,
|
|
191397
192132
|
stories: busState.stories,
|
|
191398
192133
|
totalCost: busState.totalCost
|
|
191399
192134
|
}, undefined, false, undefined, this),
|
|
191400
|
-
showQuitConfirm && /* @__PURE__ */
|
|
192135
|
+
showQuitConfirm && /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
191401
192136
|
position: "absolute",
|
|
191402
192137
|
width: "100%",
|
|
191403
192138
|
height: "100%",
|
|
191404
192139
|
justifyContent: "center",
|
|
191405
192140
|
alignItems: "center",
|
|
191406
|
-
children: /* @__PURE__ */
|
|
192141
|
+
children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
191407
192142
|
flexDirection: "column",
|
|
191408
192143
|
borderStyle: "double",
|
|
191409
192144
|
borderColor: "yellow",
|
|
@@ -191411,22 +192146,22 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191411
192146
|
paddingY: 1,
|
|
191412
192147
|
backgroundColor: "black",
|
|
191413
192148
|
children: [
|
|
191414
|
-
/* @__PURE__ */
|
|
192149
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191415
192150
|
color: "yellow",
|
|
191416
192151
|
children: "Story is running. Quit anyway?"
|
|
191417
192152
|
}, undefined, false, undefined, this),
|
|
191418
|
-
/* @__PURE__ */
|
|
192153
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
191419
192154
|
paddingTop: 1,
|
|
191420
|
-
children: /* @__PURE__ */
|
|
192155
|
+
children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191421
192156
|
dimColor: true,
|
|
191422
192157
|
children: [
|
|
191423
192158
|
"Press ",
|
|
191424
|
-
/* @__PURE__ */
|
|
192159
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191425
192160
|
color: "yellow",
|
|
191426
192161
|
children: "y"
|
|
191427
192162
|
}, undefined, false, undefined, this),
|
|
191428
192163
|
" to confirm, ",
|
|
191429
|
-
/* @__PURE__ */
|
|
192164
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191430
192165
|
color: "yellow",
|
|
191431
192166
|
children: "n"
|
|
191432
192167
|
}, undefined, false, undefined, this),
|
|
@@ -191437,13 +192172,13 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191437
192172
|
]
|
|
191438
192173
|
}, undefined, true, undefined, this)
|
|
191439
192174
|
}, undefined, false, undefined, this),
|
|
191440
|
-
showAbortConfirm && /* @__PURE__ */
|
|
192175
|
+
showAbortConfirm && /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
191441
192176
|
position: "absolute",
|
|
191442
192177
|
width: "100%",
|
|
191443
192178
|
height: "100%",
|
|
191444
192179
|
justifyContent: "center",
|
|
191445
192180
|
alignItems: "center",
|
|
191446
|
-
children: /* @__PURE__ */
|
|
192181
|
+
children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
191447
192182
|
flexDirection: "column",
|
|
191448
192183
|
borderStyle: "double",
|
|
191449
192184
|
borderColor: "red",
|
|
@@ -191451,22 +192186,22 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191451
192186
|
paddingY: 1,
|
|
191452
192187
|
backgroundColor: "black",
|
|
191453
192188
|
children: [
|
|
191454
|
-
/* @__PURE__ */
|
|
192189
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191455
192190
|
color: "red",
|
|
191456
192191
|
children: "Story is running. Abort anyway?"
|
|
191457
192192
|
}, undefined, false, undefined, this),
|
|
191458
|
-
/* @__PURE__ */
|
|
192193
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
191459
192194
|
paddingTop: 1,
|
|
191460
|
-
children: /* @__PURE__ */
|
|
192195
|
+
children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191461
192196
|
dimColor: true,
|
|
191462
192197
|
children: [
|
|
191463
192198
|
"Press ",
|
|
191464
|
-
/* @__PURE__ */
|
|
192199
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191465
192200
|
color: "yellow",
|
|
191466
192201
|
children: "y"
|
|
191467
192202
|
}, undefined, false, undefined, this),
|
|
191468
192203
|
" to confirm, ",
|
|
191469
|
-
/* @__PURE__ */
|
|
192204
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
191470
192205
|
color: "yellow",
|
|
191471
192206
|
children: "n"
|
|
191472
192207
|
}, undefined, false, undefined, this),
|
|
@@ -191483,9 +192218,9 @@ function App2({ feature, version, stories: initialStories, events, queueFilePath
|
|
|
191483
192218
|
|
|
191484
192219
|
// src/tui/index.tsx
|
|
191485
192220
|
init_events2();
|
|
191486
|
-
var
|
|
192221
|
+
var jsx_dev_runtime15 = __toESM(require_jsx_dev_runtime(), 1);
|
|
191487
192222
|
function renderTui(props) {
|
|
191488
|
-
return render_default(/* @__PURE__ */
|
|
192223
|
+
return render_default(/* @__PURE__ */ jsx_dev_runtime15.jsxDEV(App2, {
|
|
191489
192224
|
...props
|
|
191490
192225
|
}, undefined, false, undefined, this));
|
|
191491
192226
|
}
|