cuelo 0.10.331 โ 0.10.333
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +56 -56
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/required-server-files.js +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/agent/[id]/account/route.js +1 -1
- package/.next/server/app/api/agent/[id]/account/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/[id]/computer-takeover/route.js +1 -1
- package/.next/server/app/api/agent/[id]/computer-takeover/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/[id]/events/route.js +1 -1
- package/.next/server/app/api/agent/[id]/events/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/[id]/route.js +1 -1
- package/.next/server/app/api/agent/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/new/route.js +1 -1
- package/.next/server/app/api/agent/new/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/running/route.js +1 -1
- package/.next/server/app/api/agent/running/route.js.nft.json +1 -1
- package/.next/server/app/api/gpt6/handles/route.js +1 -1
- package/.next/server/app/api/gpt6/handles/route.js.nft.json +1 -1
- package/.next/server/app/api/gpt6/reply/route.js +1 -1
- package/.next/server/app/api/gpt6/reply/route.js.nft.json +1 -1
- package/.next/server/app/api/gpt6/token/route.js +1 -1
- package/.next/server/app/api/gpt6/token/route.js.nft.json +1 -1
- package/.next/server/app/api/gpt6/web6-session/route.js +1 -1
- package/.next/server/app/api/gpt6/web6-session/route.js.nft.json +1 -1
- package/.next/server/app/api/live/call/[callId]/route.js +1 -1
- package/.next/server/app/api/live/call/[callId]/route.js.nft.json +1 -1
- package/.next/server/app/api/live/draft-secret/route.js +1 -1
- package/.next/server/app/api/live/draft-secret/route.js.nft.json +1 -1
- package/.next/server/app/api/live/events/route.js +1 -1
- package/.next/server/app/api/live/events/route.js.nft.json +1 -1
- package/.next/server/app/api/live/interpret/assist/route.js +1 -1
- package/.next/server/app/api/live/interpret/assist/route.js.nft.json +1 -1
- package/.next/server/app/api/live/interpret/reading/route.js +1 -1
- package/.next/server/app/api/live/interpret/reading/route.js.nft.json +1 -1
- package/.next/server/app/api/live/interpret/route.js +1 -1
- package/.next/server/app/api/live/interpret/route.js.nft.json +1 -1
- package/.next/server/app/api/live/interpret/scan/route.js +1 -1
- package/.next/server/app/api/live/interpret/scan/route.js.nft.json +1 -1
- package/.next/server/app/api/live/interpret/text/route.js +1 -1
- package/.next/server/app/api/live/interpret/text/route.js.nft.json +1 -1
- package/.next/server/app/api/live/offer/route.js +1 -1
- package/.next/server/app/api/live/offer/route.js.nft.json +1 -1
- package/.next/server/app/api/live/voices/route.js +1 -1
- package/.next/server/app/api/live/voices/route.js.nft.json +1 -1
- package/.next/server/app/api/project-trust/route.js +1 -1
- package/.next/server/app/api/project-trust/route.js.nft.json +1 -1
- package/.next/server/app/api/runs/[runId]/prelude/route.js +1 -1
- package/.next/server/app/api/runs/[runId]/prelude/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/auto-name/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/auto-name/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/context/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/context/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/state/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/state/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/route.js +1 -1
- package/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/check/route.js +1 -1
- package/.next/server/app/api/skills/check/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/install/route.js +1 -1
- package/.next/server/app/api/skills/install/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/route.js +1 -1
- package/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/update/route.js +1 -1
- package/.next/server/app/api/skills/update/route.js.nft.json +1 -1
- package/.next/server/app/api/tool-image/route.js +1 -1
- package/.next/server/app/api/tool-image/route.js.nft.json +1 -1
- package/.next/server/app/api/update-maintenance/route.js +1 -1
- package/.next/server/app/api/update-maintenance/route.js.nft.json +1 -1
- package/.next/server/app/api/updates/apply/route.js +2 -2
- package/.next/server/app/api/updates/route.js +1 -1
- package/.next/server/app/api/upkeep/check/route.js +1 -1
- package/.next/server/app/api/upkeep/check/route.js.nft.json +1 -1
- package/.next/server/app/api/upkeep/morning/route.js +2 -3
- package/.next/server/app/api/upkeep/morning/route.js.nft.json +1 -1
- package/.next/server/app/api/upkeep/nightly/export/route.js +1 -1
- package/.next/server/app/api/upkeep/nightly/export/route.js.nft.json +1 -1
- package/.next/server/app/api/upkeep/nightly/result/route.js +1 -2
- package/.next/server/app/api/upkeep/nightly/result/route.js.nft.json +1 -1
- package/.next/server/app/api/upkeep/nightly/route.js +1 -2
- package/.next/server/app/api/upkeep/nightly/route.js.nft.json +1 -1
- package/.next/server/app/api/upkeep/route.js +1 -1
- package/.next/server/app/api/upkeep/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/route.js +1 -1
- package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +4 -4
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/page.js +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/recover/page_client-reference-manifest.js +1 -1
- package/.next/server/app/recover.html +1 -1
- package/.next/server/app/recover.rsc +2 -2
- package/.next/server/app/recover.segments/_full.segment.rsc +2 -2
- package/.next/server/app/recover.segments/_head.segment.rsc +1 -1
- package/.next/server/app/recover.segments/_index.segment.rsc +2 -2
- package/.next/server/app/recover.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/recover.segments/recover/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/recover.segments/recover.segment.rsc +1 -1
- package/.next/server/app-paths-manifest.json +56 -56
- package/.next/server/chunks/2235.js +2 -0
- package/.next/server/chunks/3173.js +3 -0
- package/.next/server/chunks/3392.js +2 -0
- package/.next/server/chunks/4831.js +1 -1
- package/.next/server/chunks/5228.js +1 -1
- package/.next/server/chunks/8041.js +1 -6
- package/.next/server/chunks/{6119.js โ 8094.js} +1 -1
- package/.next/server/chunks/8685.js +2 -2
- package/.next/server/chunks/9467.js +2 -3
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/app/{layout-bc3824f2c0eebb33.js โ layout-b2da0140cc733ca6.js} +1 -1
- package/.next/static/chunks/app/{page-9e999c92e12dc19c.js โ page-2affef230bc901fc.js} +2 -2
- package/.next/trace +113 -113
- package/.next/trace-build +1 -1
- package/README.md +1 -1
- package/Tools/CUELO_Setup/files/native-runtime-patch.js +1 -1
- package/Tools/OMP_Global_Config/agent/extensions/lib/finalize-checks.ts +353 -0
- package/Tools/OMP_Global_Config/agent/extensions/lib/interpreter.ts +12 -6
- package/Tools/OMP_Global_Config/agent/extensions/todo-nudge.ts +48 -14
- package/Tools/OMP_Global_Config/agent/tools/ego-browser/index.ts +19 -4
- package/Tools/OMP_Global_Config/agent/tools/git-finalizer/finalizer.ps1 +11 -1
- package/Tools/OMP_Global_Config/agent/tools/git-finalizer/index.ts +89 -21
- package/Tools/OMP_Global_Config/agent/tools/git-finalizer/integrate.ts +66 -11
- package/Tools/OMP_Global_Config/patches/apply-core-patch.mjs +97 -0
- package/bin/ci-local.mjs +291 -0
- package/install.mjs +124 -10
- package/package.json +3 -2
- package/.next/server/chunks/4259.js +0 -2
- package/.next/server/chunks/8139.js +0 -3
- package/Tools/OMP_Global_Config/agent/extensions/user-input-interpreter.ts +0 -130
- /package/.next/static/{qYIo9_tHAFFQaFxpOUmz_ โ UerdzBExCL9nskNG-lvSd}/_buildManifest.js +0 -0
- /package/.next/static/{qYIo9_tHAFFQaFxpOUmz_ โ UerdzBExCL9nskNG-lvSd}/_ssgManifest.js +0 -0
package/.next/trace-build
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"run-webpack","duration":
|
|
1
|
+
[{"name":"run-webpack","duration":67641037,"timestamp":343719,"id":14,"parentId":1,"tags":{},"startTime":1795191741394,"traceId":"564173344e4e651e"},{"name":"run-typescript","duration":15767195,"timestamp":68363276,"id":11561,"parentId":1,"tags":{},"startTime":1795191809414,"traceId":"564173344e4e651e"},{"name":"static-check","duration":2325910,"timestamp":84206400,"id":11564,"parentId":1,"tags":{},"startTime":1795191825257,"traceId":"564173344e4e651e"},{"name":"static-generation","duration":5726920,"timestamp":86614801,"id":11782,"parentId":1,"tags":{},"startTime":1795191827666,"traceId":"564173344e4e651e"},{"name":"collect-build-traces","duration":14750427,"timestamp":86601016,"id":11779,"parentId":1,"tags":{},"startTime":1795191827652,"traceId":"564173344e4e651e"},{"name":"telemetry-flush","duration":72,"timestamp":101354663,"id":11791,"parentId":1,"tags":{},"startTime":1795191842405,"traceId":"564173344e4e651e"},{"name":"next-build","duration":101068697,"timestamp":286060,"id":1,"tags":{"buildMode":"default","version":"16.2.12","bundler":"webpack","has-custom-webpack-config":"true","use-build-worker":"false"},"startTime":1795191741337,"traceId":"564173344e4e651e"}]
|
package/README.md
CHANGED
|
@@ -376,7 +376,7 @@ bun bin/cuelo.js --reset-password # ๋น๋ฐ๋ฒํธ ์ฌ์ค์
|
|
|
376
376
|
|
|
377
377
|
์ ์กฐ๊ฑด์ ํ๋๋ผ๋ ๋ง์กฑํ์ง ๋ชปํ๊ฑฐ๋ ์ค์น ๋ฐฉ์์ ์์๋ณผ ์ ์์ผ๋ฉด ๋ฒํผ ๋์ ์๋ ๋ช
๋ น์ ํ๋ฉด์ ํ์ํฉ๋๋ค. ์๋ฒ(๋๋ ๊ฐ๋ฐ ์๋ฒ)๋ฅผ ๋จผ์ ๋ฉ์ถ ๋ค `git pull --ff-only && node install.mjs setup`์ ์คํํ์ธ์. `setup`์ด ์คํ ์ค์ธ ์๋ฒ๊ฐ ์ฝ๋ `.next/` ๋น๋ ํด๋๋ฅผ ์๋ก ๋ง๋ค๊ธฐ ๋๋ฌธ์
๋๋ค. `setup`์ `bun install --frozen-lockfile`, SDK ์์ค ์ค๋น, ๋น๋, ํจ์น์ ๊ณ ์ง๋ฌธ ์ ์ฉยท๊ฒ์ฌ๋ฅผ ์ฐจ๋ก๋ก ํฉ๋๋ค. ๋๋๋ฉด `node install.mjs start`๋ก ์๋ฒ๋ฅผ ๋ค์ ์ผญ๋๋ค. `--home <dir>`๋ก ์์ํ๋ค๋ฉด `node install.mjs setup --home <dir>`์ฒ๋ผ ๊ฐ์ ์ต์
์ ๋ถ์ด์ธ์.
|
|
378
378
|
|
|
379
|
-
์ฑ ์
๋ฐ์ดํธ์ ํ๋กํ(ํ๋ค์ค) ์
๋ฐ์ดํธ๋ ๋ฐ๋ก์
๋๋ค. ์ฑ์ ์
๋ฐ์ดํธํด๋ ๊ธฐ์กด ํ๋กํ์ ํ๋ค์คยท์ญํ ์ค์ ์ ๋ฎ์ด์ฐ์ง ์์ต๋๋ค. ์ ๋ฒ์ ์ ํ๋ค์ค๋ `node install.mjs harness-diff`๋ก ์ฐจ์ด๋ฅผ ๋ณด๊ณ `node install.mjs harness-update`๋ก ๋ฐ์ํฉ๋๋ค. ์ฌ์ฉ์๊ฐ ๊ณ ์น์ง ์์ ํ์ผ๋ง ๋ฐฑ์
ํ ๋ฐ๊พธ๊ณ , ๊ณ ์น ํ์ผ๊ณผ `config.yml`์ ๊ทธ๋๋ก ๋ก๋๋ค([๊ธฐ์กด ํ๋กํ์ ํ๋ค์ค ๊ฐฑ์ ](./docs/installation.md#๊ธฐ์กด-ํ๋กํ์-ํ๋ค์ค-๊ฐฑ์ )). ๋ฐ์ ํ CUELO์ `omp`๋ฅผ ๋ค์ ์์ํ์ธ์.
|
|
379
|
+
์ฑ ์
๋ฐ์ดํธ์ ํ๋กํ(ํ๋ค์ค) ์
๋ฐ์ดํธ๋ ๋ฐ๋ก์
๋๋ค. ์ฑ์ ์
๋ฐ์ดํธํด๋ ๊ธฐ์กด ํ๋กํ์ ํ๋ค์คยท์ญํ ์ค์ ์ ๋ฎ์ด์ฐ์ง ์์ต๋๋ค. ์ ๋ฒ์ ์ ํ๋ค์ค๋ `node install.mjs harness-diff`๋ก ์ฐจ์ด๋ฅผ ๋ณด๊ณ `node install.mjs harness-update`๋ก ๋ฐ์ํฉ๋๋ค. ์ฌ์ฉ์๊ฐ ๊ณ ์น์ง ์์ ํ์ผ๋ง ๋ฐฑ์
ํ ๋ฐ๊พธ๊ณ , ์ ๋ฒ์ ์ด ๋๋ ๋ฐฐํฌํ์ง ์๋ ํ์ผ๋ CUELO๊ฐ ์ค์นํ ๊ทธ๋๋ก์ผ ๋๋ง ๋ฐฑ์
ํ ์ง์๋๋ค. ๊ณ ์น ํ์ผ๊ณผ `config.yml`์ ๊ทธ๋๋ก ๋ก๋๋ค([๊ธฐ์กด ํ๋กํ์ ํ๋ค์ค ๊ฐฑ์ ](./docs/installation.md#๊ธฐ์กด-ํ๋กํ์-ํ๋ค์ค-๊ฐฑ์ )). ๋ฐ์ ํ CUELO์ `omp`๋ฅผ ๋ค์ ์์ํ์ธ์.
|
|
380
380
|
|
|
381
381
|
์
๋ฐ์ดํธ ๋๊ธฐ ํ๋ฉด์์ ์คํจ๊ฐ ํ์ธ๋๋๋ผ๋ ์๋ฒ๊ฐ ๋ค์ ์์ฒญ์ ๋ฐ์ ์ ์๊ณ ์๋ ๋ํ๊ฐ ํ์ธ๋๋ฉด ๊ทธ ๋ํ๋ก ์๋ ๋ณต๊ทํฉ๋๋ค. ๋ณต๊ทํ ํ๋ฉด์ ์งํ ์ค์ธ ๋ต๋ณ์ด๋ ์ด๋ฏธ ๋๋ ์คํจ ์๋ด๋ฅผ ๋ฐ๋ผ์ก์ผ๋ฉฐ, ๋ณต๊ท ์์ฒด๊ฐ ๋ช
๋ น์ ๋ค์ ๋ณด๋ด์ง๋ ์์ต๋๋ค.
|
|
382
382
|
|
|
@@ -9,7 +9,7 @@ const MEMORY_RE = /(const phase1Model = await resolveMemoryModel\(\{[^}]*?fallba
|
|
|
9
9
|
const MEMORY_DONE = /const phase1Model = await resolveMemoryModel\(\{[^}]*?fallbackRole: "smol"/;
|
|
10
10
|
const EXPECTED = {
|
|
11
11
|
name: 'cuelo',
|
|
12
|
-
version: '0.10.
|
|
12
|
+
version: '0.10.333',
|
|
13
13
|
distribution: 'cuelo',
|
|
14
14
|
coreVersion: '19.0.1',
|
|
15
15
|
};
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { lstat, mkdir, mkdtemp, open, readFile, readlink, realpath, writeFile } from "node:fs/promises";
|
|
4
|
+
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
5
|
+
import type { CustomToolContext } from "@oh-my-pi/pi-coding-agent";
|
|
6
|
+
import { Process } from "@oh-my-pi/pi-natives";
|
|
7
|
+
import { getAgentDir } from "@oh-my-pi/pi-utils";
|
|
8
|
+
import { spawnExec, type Exec } from "./cross-review";
|
|
9
|
+
|
|
10
|
+
export const FINALIZE_CHECKS_CONFIG = ".finalize-checks.json";
|
|
11
|
+
const DEFAULT_TIMEOUT_SECONDS = 1_200;
|
|
12
|
+
const MAX_TIMER_MS = 2_147_483_647;
|
|
13
|
+
const TERMINATION_GRACE_MS = 10_000;
|
|
14
|
+
const TAIL_BYTES = 12_000;
|
|
15
|
+
|
|
16
|
+
type Check = { name: string; paths: string[]; command: [string, ...string[]]; timeoutSeconds: number };
|
|
17
|
+
type CheckResult = { name: string; seconds: number; reused: boolean };
|
|
18
|
+
export type FinalizeChecksResult = { checks: CheckResult[]; waiver?: string };
|
|
19
|
+
|
|
20
|
+
type Options = {
|
|
21
|
+
root: string;
|
|
22
|
+
files: readonly string[] | (() => Promise<string[]>);
|
|
23
|
+
sessionManager?: CustomToolContext["sessionManager"];
|
|
24
|
+
ledgerDir?: string;
|
|
25
|
+
waiver?: string;
|
|
26
|
+
authorize?: () => Promise<void>;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
git?: string;
|
|
29
|
+
exec?: Exec;
|
|
30
|
+
showDirtyTracked?: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function objectWithKeys(value: unknown, keys: string[]): value is Record<string, unknown> {
|
|
34
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
35
|
+
&& Object.keys(value).every((key) => keys.includes(key));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function validPath(value: unknown): value is string {
|
|
39
|
+
return typeof value === "string" && !/[\\\0\r\n]/.test(value) && !/^[A-Za-z]:/.test(value)
|
|
40
|
+
&& value.replace(/\/$/, "").split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function loadConfig(path: string): Promise<{ source: string; checks: Check[] } | undefined> {
|
|
44
|
+
try {
|
|
45
|
+
const stat = await lstat(path).catch((error: NodeJS.ErrnoException) => {
|
|
46
|
+
if (error.code !== "ENOENT") throw error;
|
|
47
|
+
return undefined;
|
|
48
|
+
});
|
|
49
|
+
if (!stat) return undefined;
|
|
50
|
+
if (!stat.isFile()) throw new Error("expected a regular file");
|
|
51
|
+
const source = await readFile(path, "utf8");
|
|
52
|
+
const config: unknown = JSON.parse(source);
|
|
53
|
+
if (!objectWithKeys(config, ["version", "checks"]) || config.version !== 1 || !Array.isArray(config.checks)) {
|
|
54
|
+
throw new Error("expected version 1 and a checks array");
|
|
55
|
+
}
|
|
56
|
+
const names = new Set<string>();
|
|
57
|
+
const checks = config.checks.map((entry: unknown, index: number): Check => {
|
|
58
|
+
if (!objectWithKeys(entry, ["name", "paths", "command", "timeoutSeconds"])) throw new Error(`checks[${index}] has unknown fields or is not an object`);
|
|
59
|
+
const { name, paths, command, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS } = entry;
|
|
60
|
+
if (typeof name !== "string" || name.trim() !== name || !name || /[\x00-\x1f\x7f]/.test(name) || names.has(name)) {
|
|
61
|
+
throw new Error(`checks[${index}].name must be a unique, non-empty name`);
|
|
62
|
+
}
|
|
63
|
+
if (!Array.isArray(paths) || paths.length === 0 || !paths.every(validPath)) throw new Error(`check ${name}: paths must contain repository-relative file paths or directory prefixes ending in /`);
|
|
64
|
+
if (!Array.isArray(command) || command.length === 0 || !command.every((arg) => typeof arg === "string" && !arg.includes("\0")) || !command[0].trim()) {
|
|
65
|
+
throw new Error(`check ${name}: command must be a non-empty argv array with an executable`);
|
|
66
|
+
}
|
|
67
|
+
if (typeof timeoutSeconds !== "number" || !Number.isSafeInteger(timeoutSeconds) || timeoutSeconds < 1) {
|
|
68
|
+
throw new Error(`check ${name}: timeoutSeconds must be a positive integer`);
|
|
69
|
+
}
|
|
70
|
+
names.add(name);
|
|
71
|
+
return { name, paths, command: command as Check["command"], timeoutSeconds };
|
|
72
|
+
});
|
|
73
|
+
return { source, checks };
|
|
74
|
+
} catch (error) {
|
|
75
|
+
throw new Error(`${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function matches(paths: readonly string[], file: string): boolean {
|
|
80
|
+
if (process.platform === "win32") file = file.toLowerCase();
|
|
81
|
+
return paths.some((path) => {
|
|
82
|
+
if (process.platform === "win32") path = path.toLowerCase();
|
|
83
|
+
return path.endsWith("/") ? file.startsWith(path) : file === path;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function fileFingerprint(root: string, path: string, checkPaths: readonly string[]): Promise<{ value: string; opaque?: true }> {
|
|
88
|
+
const absolute = join(root, path);
|
|
89
|
+
const info = await lstat(absolute).catch((error: NodeJS.ErrnoException) => {
|
|
90
|
+
if (error.code !== "ENOENT") throw error;
|
|
91
|
+
return undefined;
|
|
92
|
+
});
|
|
93
|
+
if (!info) return { value: "missing" };
|
|
94
|
+
const link = info.isSymbolicLink() ? (await readlink(absolute, { encoding: "buffer" })).toString("base64") : "";
|
|
95
|
+
if (!link && !info.isFile()) return { value: `non-file:${info.mode}`, opaque: true };
|
|
96
|
+
const real = await realpath(absolute).catch((error: NodeJS.ErrnoException) => {
|
|
97
|
+
if (link && error.code === "ENOENT") return undefined;
|
|
98
|
+
throw error;
|
|
99
|
+
});
|
|
100
|
+
const within = real && relative(root, real);
|
|
101
|
+
if (within === undefined || isAbsolute(within) || within === ".." || within.startsWith(`..${sep}`)) {
|
|
102
|
+
// The link itself is known even when its target cannot be treated as a repository input.
|
|
103
|
+
return { value: `${real === undefined ? "dangling" : "external"}:${link}`, ...(link && !matches(checkPaths, path) ? {} : { opaque: true }) };
|
|
104
|
+
}
|
|
105
|
+
if (!real) throw new Error("no resolved path");
|
|
106
|
+
const realInfo = await lstat(real, { bigint: true });
|
|
107
|
+
if (!realInfo.isFile()) return { value: `${link}:non-file:${realInfo.mode}`, opaque: true };
|
|
108
|
+
const handle = await open(real, "r");
|
|
109
|
+
try {
|
|
110
|
+
const before = await handle.stat({ bigint: true });
|
|
111
|
+
if (!before.isFile()) throw new Error("file type changed while opening it");
|
|
112
|
+
const hash = createHash("sha256");
|
|
113
|
+
for await (const chunk of handle.createReadStream({ autoClose: false })) hash.update(chunk);
|
|
114
|
+
const after = await lstat(real, { bigint: true });
|
|
115
|
+
if (before.ino !== after.ino || before.dev !== after.dev || before.mode !== after.mode || before.ctimeNs !== after.ctimeNs || before.mtimeNs !== after.mtimeNs || before.size !== after.size) {
|
|
116
|
+
throw new Error("file changed while being read");
|
|
117
|
+
}
|
|
118
|
+
return { value: `${link}:${after.mode}:${hash.digest("hex")}` };
|
|
119
|
+
} finally {
|
|
120
|
+
await handle.close();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type ReadGit = (args: string[]) => ReturnType<Exec>;
|
|
125
|
+
type Snapshot = { hash: string; complete: boolean };
|
|
126
|
+
|
|
127
|
+
/** Hash raw working bytes rather than `git diff`, which can hide changes behind clean filters and index flags. */
|
|
128
|
+
async function fingerprint(root: string, files: readonly string[], paths: readonly string[], git: ReadGit, signal?: AbortSignal): Promise<Snapshot | undefined> {
|
|
129
|
+
try {
|
|
130
|
+
const [head, tracked, committed, untracked] = await Promise.all([
|
|
131
|
+
git(["rev-parse", "--verify", "HEAD"]),
|
|
132
|
+
git(["ls-files", "--stage", "-z"]),
|
|
133
|
+
git(["ls-tree", "--full-tree", "--name-only", "-r", "-z", "HEAD"]),
|
|
134
|
+
git(["-c", "core.untrackedCache=false", "ls-files", "--others", "--exclude-standard", "-z"]),
|
|
135
|
+
]);
|
|
136
|
+
if ([head, tracked, committed, untracked].some((result) => result.code !== 0)) return undefined;
|
|
137
|
+
// Include HEAD paths even when a deletion is already staged and the path is absent from the index.
|
|
138
|
+
const inputs = new Set([FINALIZE_CHECKS_CONFIG, ...files]);
|
|
139
|
+
let complete = true;
|
|
140
|
+
for (const path of committed.stdout.split("\0")) if (path) inputs.add(path);
|
|
141
|
+
for (const entry of tracked.stdout.split("\0")) {
|
|
142
|
+
if (!entry) continue;
|
|
143
|
+
const tab = entry.indexOf("\t");
|
|
144
|
+
if (tab < 0) return undefined;
|
|
145
|
+
if (!entry.slice(0, tab).endsWith(" 0") || entry.startsWith("160000 ")) complete = false;
|
|
146
|
+
inputs.add(entry.slice(tab + 1));
|
|
147
|
+
}
|
|
148
|
+
for (const path of untracked.stdout.split("\0")) if (path && matches(paths, path)) inputs.add(path);
|
|
149
|
+
const hash = createHash("sha256").update(JSON.stringify([head.stdout.trim(), tracked.stdout, files]));
|
|
150
|
+
const ordered: string[] = [];
|
|
151
|
+
for (const path of [...inputs].sort()) {
|
|
152
|
+
// The text Git adapter cannot distinguish invalid UTF-8 from U+FFFD. Keep
|
|
153
|
+
// that part opaque instead of dropping the evidence from all other paths.
|
|
154
|
+
if (path.includes("\uFFFD")) {
|
|
155
|
+
complete = false;
|
|
156
|
+
hash.update(JSON.stringify([path, null]));
|
|
157
|
+
} else ordered.push(path);
|
|
158
|
+
}
|
|
159
|
+
for (let index = 0; index < ordered.length; index += 32) {
|
|
160
|
+
signal?.throwIfAborted();
|
|
161
|
+
const batch = ordered.slice(index, index + 32);
|
|
162
|
+
const entries = await Promise.allSettled(batch.map((path) => fileFingerprint(root, path, paths)));
|
|
163
|
+
for (let offset = 0; offset < batch.length; offset++) {
|
|
164
|
+
const entry = entries[offset];
|
|
165
|
+
if (entry.status === "rejected") {
|
|
166
|
+
complete = false;
|
|
167
|
+
hash.update(JSON.stringify([batch[offset], null]));
|
|
168
|
+
} else {
|
|
169
|
+
if (entry.value.opaque) complete = false;
|
|
170
|
+
hash.update(JSON.stringify([batch[offset], entry.value.value]));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return { hash: hash.digest("hex"), complete };
|
|
175
|
+
} catch {
|
|
176
|
+
// Cache evidence is optional. Unknown, inaccessible or unsupported inputs require a fresh run.
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async function runCommand(check: Check, cwd: string, env: NodeJS.ProcessEnv, fd: number, signal?: AbortSignal): Promise<string | undefined> {
|
|
182
|
+
if (signal?.aborted) return "was cancelled";
|
|
183
|
+
const win = process.platform === "win32";
|
|
184
|
+
const child = spawn(check.command[0], check.command.slice(1), { cwd, env, stdio: ["ignore", fd, fd], detached: !win, windowsHide: true });
|
|
185
|
+
const pid = child.pid;
|
|
186
|
+
let native: Process | null = null;
|
|
187
|
+
if (!win && pid) {
|
|
188
|
+
try { native = Process.fromPid(pid); } catch { /* The live child/group remains available for direct signalling. */ }
|
|
189
|
+
}
|
|
190
|
+
const { promise: closed, resolve: done } = Promise.withResolvers<string | undefined>();
|
|
191
|
+
child.once("error", (error) => done(`could not start: ${error.message}`));
|
|
192
|
+
child.once("close", (code, by) => done(code === 0 ? undefined : code === null ? `was terminated by ${by ?? "an unknown signal"}` : `exited ${code}`));
|
|
193
|
+
let stopped: string | undefined;
|
|
194
|
+
let terminating: Promise<unknown> | undefined;
|
|
195
|
+
let hardKill: ReturnType<typeof setTimeout> | undefined;
|
|
196
|
+
const stop = (reason: string) => {
|
|
197
|
+
if (stopped) return;
|
|
198
|
+
stopped = reason;
|
|
199
|
+
if (!pid || child.exitCode !== null || child.signalCode !== null) return;
|
|
200
|
+
if (win) {
|
|
201
|
+
const { promise, resolve: killed } = Promise.withResolvers<void>();
|
|
202
|
+
terminating = promise;
|
|
203
|
+
execFile("taskkill.exe", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 5_000 }, (error) => {
|
|
204
|
+
if (error) child.kill("SIGKILL");
|
|
205
|
+
killed();
|
|
206
|
+
});
|
|
207
|
+
} else {
|
|
208
|
+
const graceEnd = performance.now() + TERMINATION_GRACE_MS;
|
|
209
|
+
const signalGroup = (name: NodeJS.Signals) => {
|
|
210
|
+
// Only use a numeric PGID while its leader is still our live child.
|
|
211
|
+
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
212
|
+
try { process.kill(-pid, name); } catch (error) {
|
|
213
|
+
if ((error as NodeJS.ErrnoException).code !== "ESRCH") child.kill(name);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const fallback = () => {
|
|
217
|
+
signalGroup("SIGTERM");
|
|
218
|
+
hardKill = setTimeout(() => signalGroup("SIGKILL"), Math.max(0, graceEnd - performance.now()));
|
|
219
|
+
};
|
|
220
|
+
// A stable native reference retains group/tree identity across the grace.
|
|
221
|
+
if (native) terminating = native.terminate({ group: true, gracefulMs: TERMINATION_GRACE_MS }).catch(fallback);
|
|
222
|
+
else fallback();
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const deadline = performance.now() + check.timeoutSeconds * 1_000;
|
|
226
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
227
|
+
const schedule = () => {
|
|
228
|
+
const left = deadline - performance.now();
|
|
229
|
+
if (left <= 0) stop(`timed out after ${check.timeoutSeconds}s`);
|
|
230
|
+
else timer = setTimeout(schedule, Math.min(left, MAX_TIMER_MS));
|
|
231
|
+
};
|
|
232
|
+
const abort = () => stop("was cancelled");
|
|
233
|
+
schedule();
|
|
234
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
235
|
+
if (signal?.aborted) abort();
|
|
236
|
+
try {
|
|
237
|
+
const status = await closed;
|
|
238
|
+
await terminating;
|
|
239
|
+
return stopped ?? status;
|
|
240
|
+
} finally {
|
|
241
|
+
clearTimeout(timer);
|
|
242
|
+
clearTimeout(hardKill);
|
|
243
|
+
signal?.removeEventListener("abort", abort);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function failureContext(root: string, files: readonly string[], git: ReadGit): Promise<string> {
|
|
248
|
+
const result = await git(["--no-optional-locks", "status", "--porcelain=v1", "--no-renames", "--untracked-files=no", "-z"]);
|
|
249
|
+
const label = "Dirty tracked paths outside this publication";
|
|
250
|
+
const paths = result.stdout.split("\0").filter(Boolean).map((line) => line.slice(3))
|
|
251
|
+
.filter((path) => !matches(files, path));
|
|
252
|
+
const names = result.code !== 0 ? "could not be determined" : paths.length === 0 ? "none"
|
|
253
|
+
: paths.slice(0, 8).map((path) => JSON.stringify(path)).join(", ") + (paths.length > 8 ? ` (+${paths.length - 8} more)` : "");
|
|
254
|
+
return `The check ran on the working tree at ${root}. ${label}: ${names}.`;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export async function runFinalizeChecks(options: Options): Promise<FinalizeChecksResult | undefined> {
|
|
258
|
+
const configPath = join(options.root, FINALIZE_CHECKS_CONFIG);
|
|
259
|
+
const config = await loadConfig(configPath);
|
|
260
|
+
if (!config?.checks.length) return undefined;
|
|
261
|
+
const files = typeof options.files === "function" ? await options.files() : options.files;
|
|
262
|
+
const selected = config.checks.filter((check) => files.some((file) => matches(check.paths, file)));
|
|
263
|
+
if (!selected.length) return undefined;
|
|
264
|
+
const waiver = options.waiver?.trim();
|
|
265
|
+
if (waiver) return { checks: [], waiver };
|
|
266
|
+
const trust = options.sessionManager && Reflect.get(options.sessionManager, Symbol.for("cuelo.finalizeChecksProjectTrust"));
|
|
267
|
+
const inCuelo = Reflect.get(globalThis, Symbol.for("cuelo.finalizeChecksBrowser")) === true;
|
|
268
|
+
if ((inCuelo || trust !== undefined) && (typeof trust !== "function" || trust(options.root) !== true)) {
|
|
269
|
+
throw new Error(`The project is untrusted, so ${configPath} was not executed. Trust the project in CUELO, or use finalizeChecksWaiver only if the user explicitly requests a waiver.`);
|
|
270
|
+
}
|
|
271
|
+
await options.authorize?.();
|
|
272
|
+
|
|
273
|
+
const exec = options.exec ?? spawnExec(options.signal);
|
|
274
|
+
const git: ReadGit = (args) => exec(options.git ?? "git", args, { cwd: options.root });
|
|
275
|
+
const root = await realpath(options.root);
|
|
276
|
+
const agentDir = getAgentDir();
|
|
277
|
+
const ledgerDir = resolve(options.ledgerDir ?? (process.env.OMP_FINALIZE_CHECKS_LEDGER || join(agentDir, "finalize-checks-ledger")));
|
|
278
|
+
const env = { ...process.env };
|
|
279
|
+
const envKey = createHash("sha256").update(JSON.stringify(Object.entries(env).sort())).digest("hex");
|
|
280
|
+
const results: CheckResult[] = [];
|
|
281
|
+
const verified: { check: Check; fingerprint: string }[] = [];
|
|
282
|
+
let ranAfterVerification = false;
|
|
283
|
+
let logDir: string | undefined;
|
|
284
|
+
for (const check of selected) {
|
|
285
|
+
options.signal?.throwIfAborted();
|
|
286
|
+
const prior = await fingerprint(root, files, check.paths, git, options.signal);
|
|
287
|
+
options.signal?.throwIfAborted();
|
|
288
|
+
const slot = createHash("sha256").update(JSON.stringify([root, check.name])).digest("hex");
|
|
289
|
+
const ledgerFile = join(ledgerDir, slot);
|
|
290
|
+
const key = prior?.complete ? createHash("sha256").update(JSON.stringify([2, envKey, check, prior.hash])).digest("hex") : undefined;
|
|
291
|
+
if (key && await readFile(ledgerFile, "utf8").catch(() => undefined) === key) {
|
|
292
|
+
results.push({ name: check.name, seconds: 0, reused: true });
|
|
293
|
+
verified.push({ check, fingerprint: prior!.hash });
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (!logDir) {
|
|
298
|
+
const parent = resolve(options.sessionManager?.getArtifactManager().dir ?? join(agentDir, "artifacts"), "finalize-checks");
|
|
299
|
+
await mkdir(parent, { recursive: true, mode: 0o700 });
|
|
300
|
+
logDir = await mkdtemp(join(parent, "run-"));
|
|
301
|
+
}
|
|
302
|
+
const log = join(logDir, `${results.length + 1}.log`);
|
|
303
|
+
const handle = await open(log, "wx+", 0o600);
|
|
304
|
+
const started = performance.now();
|
|
305
|
+
let failure: string | undefined;
|
|
306
|
+
let tail = "";
|
|
307
|
+
try {
|
|
308
|
+
failure = await runCommand(check, root, env, handle.fd, options.signal).catch((error: Error) => `could not start: ${error.message}`);
|
|
309
|
+
if (failure) {
|
|
310
|
+
const size = (await handle.stat()).size;
|
|
311
|
+
const buf = Buffer.allocUnsafe(Math.min(size, TAIL_BYTES));
|
|
312
|
+
const { bytesRead } = await handle.read(buf, 0, buf.length, size - buf.length);
|
|
313
|
+
tail = buf.subarray(0, bytesRead).toString("utf8").trimEnd().split(/\r?\n/).slice(-60).join("\n");
|
|
314
|
+
}
|
|
315
|
+
} finally {
|
|
316
|
+
await handle.close();
|
|
317
|
+
}
|
|
318
|
+
const seconds = Math.round(performance.now() - started) / 1_000;
|
|
319
|
+
if (failure) {
|
|
320
|
+
const context = options.showDirtyTracked ? await failureContext(root, files, git) : undefined;
|
|
321
|
+
throw new Error([`${check.name} ${failure} (${seconds}s).`, context, tail && `Last output:\n${tail}`, `Full log: ${log}`, "Fix the failing check, then call the publication tool again."].filter(Boolean).join("\n"));
|
|
322
|
+
}
|
|
323
|
+
results.push({ name: check.name, seconds, reused: false });
|
|
324
|
+
ranAfterVerification = verified.length > 0;
|
|
325
|
+
const after = await fingerprint(root, files, check.paths, git, options.signal);
|
|
326
|
+
if (after) verified.push({ check, fingerprint: after.hash });
|
|
327
|
+
if (key && after?.complete && after.hash === prior?.hash) {
|
|
328
|
+
try {
|
|
329
|
+
await mkdir(ledgerDir, { recursive: true, mode: 0o700 });
|
|
330
|
+
await writeFile(ledgerFile, key, { mode: 0o600 });
|
|
331
|
+
} catch { /* An unwritable cache must not turn a successful check into a failed one. */ }
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// Subsequent checks can touch inputs of earlier checks. Do not publish based on a stale pass.
|
|
335
|
+
if (ranAfterVerification) {
|
|
336
|
+
for (const entry of verified) {
|
|
337
|
+
if ((await fingerprint(root, files, entry.check.paths, git, options.signal))?.hash !== entry.fingerprint) {
|
|
338
|
+
throw new Error(`${entry.check.name}'s working-tree inputs changed after it passed. Call the publication tool again when the inputs are stable.`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
options.signal?.throwIfAborted();
|
|
343
|
+
if (await readFile(configPath, "utf8").catch(() => undefined) !== config.source) {
|
|
344
|
+
throw new Error(`${configPath} changed during the checks; call the publication tool again.`);
|
|
345
|
+
}
|
|
346
|
+
return { checks: results };
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function finalizeChecksNote(result?: FinalizeChecksResult): string {
|
|
350
|
+
if (!result) return "";
|
|
351
|
+
if (result.waiver) return `Finalize checks waived by explicit user instruction: ${result.waiver}.`;
|
|
352
|
+
return `Finalize checks: ${result.checks.map(({ name, seconds, reused }) => reused ? `${name} reused` : `${name} ran (${seconds}s)`).join("; ")}.`;
|
|
353
|
+
}
|
|
@@ -3,8 +3,8 @@ import { beforeModelAbort, directFallbackModel, isHydrogen, modelRoleSelector, o
|
|
|
3
3
|
// ๋ฐํ์ ํจํค์ง๋ legacy-pi ํ์ฅ loader๊ฐ host SDK ๊ฒฝ๋ก๋ก ์ฌ์์ฑํ๋ฏ๋ก ์๋์์ ์ง์ฐ importํ๋ค.
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* ํต์ญ ์๋ฆฌ(2026-10-30 ์ฌ์ฉ์
|
|
7
|
-
*
|
|
6
|
+
* ํต์ญ ์๋ฆฌ(2026-10-30 ์ฌ์ฉ์ ๊ฒฐ์ , 2026-11-20 ์
๋ ฅ ํต์ญ ์ฒ ๊ฑฐ): Main์ ๋นํ๊ตญ์ด ๋ต ๋ฒ์ญ(korean-reply-guard)์ด ์ฐ๋
|
|
7
|
+
* ๋ชจ๋ธ ํธ์ถ. `modelRoles.interpreter`๋ฅผ ์ฐ๊ณ , ๊ทธ slot์ด ์๋ ์ค์น๋ ์์ ์ฒ๋ผ `tiny`๋ฅผ ์ด๋ค.
|
|
8
8
|
*/
|
|
9
9
|
export const INTERPRETER_ROLE = "interpreter";
|
|
10
10
|
|
|
@@ -13,7 +13,8 @@ export const SECRET_PATTERN = /(?:^|[\s"'`:])(?:password|passwd|api[_ -]?key|bea
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* ํต์ญ ๋ชจ๋ธ๋ก ํ ๋ฒ ํธ์ถํด ํ
์คํธ ๋ต์ ๋๋ ค์ค๋ค. ์ถ๋ ฅ ํ๋์์ ๋๊ธฐ๋ฉด ๋๊ธด ๋ต๊ณผ `truncated`๋ฅผ ํจ๊ป ์ค๋ค.
|
|
16
|
-
* Hydrogen
|
|
16
|
+
* Hydrogen falls back to `interpreterFallback` on operating failures; any other primary falls back to it on a usage
|
|
17
|
+
* limit (2026-11-20 user decision: Terra, then Haiku), within the callers' existing total deadlines.
|
|
17
18
|
*/
|
|
18
19
|
export async function interpret(prompt: string, purpose: string, ctx: ExtensionContext, signal: AbortSignal): Promise<{ text: string; truncated: boolean }> {
|
|
19
20
|
const { completeSimple, isUsageLimitOutcome } = await import("@oh-my-pi/pi-ai");
|
|
@@ -21,7 +22,8 @@ export async function interpret(prompt: string, purpose: string, ctx: ExtensionC
|
|
|
21
22
|
const role = selector ? INTERPRETER_ROLE : "tiny";
|
|
22
23
|
const primary = ctx.models.resolve(`@${role}`);
|
|
23
24
|
const hydrogen = isHydrogen(primary ? `${primary.provider}/${primary.id}` : selector);
|
|
24
|
-
const
|
|
25
|
+
const configured = await directFallbackModel(ctx, "interpreterFallback");
|
|
26
|
+
const fallback = configured && !(primary && configured.provider === primary.provider && configured.id === primary.id) ? configured : undefined;
|
|
25
27
|
if (!primary && !fallback) throw new Error(`modelRoles.${role} ๋ชจ๋ธ์ ํด์ํ์ง ๋ชปํ์ต๋๋ค.`);
|
|
26
28
|
const sessionId = ctx.sessionManager.getSessionId();
|
|
27
29
|
const models = primary ? [primary] : [fallback!];
|
|
@@ -29,8 +31,8 @@ export async function interpret(prompt: string, purpose: string, ctx: ExtensionC
|
|
|
29
31
|
for (let index = 0; index < models.length; index++) {
|
|
30
32
|
const model = models[index]!;
|
|
31
33
|
signal.throwIfAborted();
|
|
32
|
-
//
|
|
33
|
-
const timeout = primary && index === 0 && fallback ? AbortSignal.timeout(
|
|
34
|
+
// Reply translation has 120 s total. Leave half for the alternate when Hydrogen may need it.
|
|
35
|
+
const timeout = hydrogen && primary && index === 0 && fallback ? AbortSignal.timeout(60_000) : undefined;
|
|
34
36
|
const attempt = timeout ? AbortSignal.any([signal, timeout]) : signal;
|
|
35
37
|
let operating: boolean | undefined;
|
|
36
38
|
try {
|
|
@@ -63,6 +65,10 @@ export async function interpret(prompt: string, purpose: string, ctx: ExtensionC
|
|
|
63
65
|
if (index === 0 && hydrogen) {
|
|
64
66
|
if (primary && fallback && (operating ?? await operationalFailure(error))) models.push(fallback);
|
|
65
67
|
} else if (index === 0 && primary && isUsageLimitOutcome(undefined, error instanceof Error ? error.message : String(error))) {
|
|
68
|
+
if (fallback) {
|
|
69
|
+
models.push(fallback);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
66
72
|
for (const route of await sameModelRoutes(ctx.cwd, `${primary.provider}/${primary.id}`)) {
|
|
67
73
|
const next = ctx.models.resolve(route);
|
|
68
74
|
if (next) models.push(next);
|
|
@@ -3,12 +3,25 @@ import { createQuietDelivery } from "./lib/quiet-delivery";
|
|
|
3
3
|
import { onSessionLifecycle } from "./lib/session-identity";
|
|
4
4
|
import { readPersistedTodoProgress, readTodoSnapshot, type TodoSnapshotItem } from "./lib/task-progress";
|
|
5
5
|
|
|
6
|
-
// ์ฌ์ฉ์ ์ง์ ์
๋ ฅ ํ๋์์ todo ์์ด ๋๊ตฌ๋ฅผ ๋ค์ฏ ๋ฒ ๋ถ๋ฅด๋ฉด
|
|
6
|
+
// ์ฌ์ฉ์ ์ง์ ์
๋ ฅ ํ๋์์ todo ์์ด ์ฝ๊ธฐ ์ ์ฉ์ด ์๋ ๋๊ตฌ๋ฅผ ๋ค์ฏ ๋ฒ ๋ถ๋ฅด๋ฉด ์๋ดํ๋ค.
|
|
7
7
|
// 2026-10-08 ์ฌ์ฉ์ ๊ฒฐ์ : ์์ฒญ ๋ถ๋ฅ์ฉ JEV ํธ์ถ์ ๋์ง ์๋๋ค. ๊ฒฐ์ ๋ก ์ ํ์ ๊ท์น๋ง ์ด๋ค.
|
|
8
8
|
// 2026-10-28 ํ๋ณธ(doc/history/2026/10/28-guard-trim/advisory): ์ธ ๋ฒ์งธ ํธ์ถ ์๋ฆผ 281๊ฑด ์ค ๋น-todo ํธ์ถ์ด ๋ท ์ดํ๋ก ๋๋ ์์ฒญ์ด
|
|
9
9
|
// 93๊ฑด(๋ฏธ์ถ์ข
61)์ด์๊ณ , ๋ฏธ์ถ์ข
ํ๋ณธ 25๊ฑด ์ค 17๊ฑด์ด ์งง์ ์ง๋ฌธยท์กฐํ๋ผ ๋ชฉ๋ก์ด ํ์ ์์๋ค. ๊ทธ๋์ ๋ค์ฏ ๋ฒ์งธ ํธ์ถ๋ก ๋ฆ์ถ๋ค.
|
|
10
10
|
const TOOL_CALLS_BEFORE_NUDGE = 5;
|
|
11
11
|
|
|
12
|
+
// Registered read-only tools: file reads/searches, skim, web search and AST queries.
|
|
13
|
+
// LSP is mixed-mode: only the core's read-only actions are exempt. Unknown modes, bash and eval count.
|
|
14
|
+
const READ_ONLY_TOOLS: Record<string, true> = {
|
|
15
|
+
read: true, grep: true, find: true, glob: true, skim: true, web_search: true, ast_grep: true,
|
|
16
|
+
};
|
|
17
|
+
const READ_ONLY_LSP_ACTIONS: Record<string, true> = {
|
|
18
|
+
diagnostics: true, definition: true, type_definition: true, implementation: true, references: true,
|
|
19
|
+
hover: true, symbols: true, status: true, capabilities: true,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type RequestSlot = { claimed: boolean; fifthReminder?: { content: string; atStop: boolean } };
|
|
23
|
+
type Request = { slot: RequestSlot; currentCoreSlot?: () => RequestSlot | undefined };
|
|
24
|
+
|
|
12
25
|
const REMINDER =
|
|
13
26
|
"์ด๋ฒ ์ฌ์ฉ์ ์์ฒญ์์ todo ์์ด ๋๊ตฌ๋ฅผ ์ด์ด ๋ถ๋ฅด๊ณ ์๋ค. ์ฌ๋ฌ ํญ๋ชฉ ๋๋ 3๋จ๊ณ ์ด์ ์์
์ด๋ฉด ์ง๊ธ todo ๋ฅผ init ํด์ ์์ฒญ ํญ๋ชฉ์ ๋น ์ง์์ด ๋๋๊ณ , ์งํ์ ๋ง์ถฐ ์ํ๋ฅผ ๊ฐฑ์ ํ๋ฉฐ ์ด์ด ๊ฐ๋ผ.";
|
|
14
27
|
|
|
@@ -31,19 +44,30 @@ function textOf(content: unknown): string {
|
|
|
31
44
|
|
|
32
45
|
export function createTodoNudge(now: () => number = Date.now) {
|
|
33
46
|
return function todoNudge(pi: ExtensionAPI): void {
|
|
34
|
-
let
|
|
47
|
+
let request: Request | undefined;
|
|
35
48
|
let usedTodo = false;
|
|
36
|
-
|
|
49
|
+
const queuedFifth = new WeakMap<object, Request>();
|
|
37
50
|
let calls = 0;
|
|
38
51
|
let todos: readonly TodoSnapshotItem[] = [];
|
|
39
52
|
let noticeNudged = false;
|
|
40
53
|
let coreNudgedAt = Number.NEGATIVE_INFINITY;
|
|
41
54
|
// wait๋ฅผ ๋๊ฑฐ๋ ๋๋ ํด์ ๋ค์ ์ด์ง ์๋๋ค(2026-11-16, 7์ผ ํ๋ณธ์์ wait ๋๊น 11).
|
|
42
|
-
const quiet = createQuietDelivery(
|
|
55
|
+
const quiet = createQuietDelivery({
|
|
56
|
+
on: pi.on,
|
|
57
|
+
sendMessage(message, options) {
|
|
58
|
+
const owner = typeof message === "object" ? queuedFifth.get(message) : undefined;
|
|
59
|
+
if (!owner) return pi.sendMessage(message, options); // Arrival reminder.
|
|
60
|
+
if (request !== owner) return;
|
|
61
|
+
if (!owner.currentCoreSlot) return pi.sendMessage(message, options); // Standalone OMP without the SDK patch.
|
|
62
|
+
if (owner.currentCoreSlot() !== owner.slot) return;
|
|
63
|
+
// Core polls the current request at injection time, even if newer input arrives after this tool result.
|
|
64
|
+
owner.slot.fifthReminder = { content: REMINDER, atStop: options?.deliverAs === "aside" };
|
|
65
|
+
},
|
|
66
|
+
});
|
|
43
67
|
|
|
44
68
|
onSessionLifecycle(pi, {
|
|
45
69
|
start: (ctx) => {
|
|
46
|
-
|
|
70
|
+
request = undefined;
|
|
47
71
|
noticeNudged = false;
|
|
48
72
|
coreNudgedAt = Number.NEGATIVE_INFINITY;
|
|
49
73
|
todos = readPersistedTodoProgress(ctx.sessionManager.getBranch()).currentTodos;
|
|
@@ -54,13 +78,17 @@ export function createTodoNudge(now: () => number = Date.now) {
|
|
|
54
78
|
},
|
|
55
79
|
});
|
|
56
80
|
pi.on("session_shutdown", () => {
|
|
57
|
-
|
|
81
|
+
request = undefined;
|
|
58
82
|
});
|
|
59
|
-
pi.on("input", (event) => {
|
|
83
|
+
pi.on("input", (event, ctx) => {
|
|
60
84
|
if (event.source !== "interactive" && event.source !== "rpc") return;
|
|
61
|
-
|
|
85
|
+
const manager = ctx.sessionManager as typeof ctx.sessionManager & {
|
|
86
|
+
getCueloTodoNudgeRequest?: () => RequestSlot | undefined;
|
|
87
|
+
};
|
|
88
|
+
const currentCoreSlot = manager.getCueloTodoNudgeRequest?.bind(manager);
|
|
89
|
+
const slot = currentCoreSlot?.();
|
|
90
|
+
request = slot ? { slot, currentCoreSlot } : { slot: { claimed: false } };
|
|
62
91
|
usedTodo = false;
|
|
63
|
-
nudged = false;
|
|
64
92
|
calls = 0;
|
|
65
93
|
});
|
|
66
94
|
pi.on("tool_result", (event) => {
|
|
@@ -72,6 +100,7 @@ export function createTodoNudge(now: () => number = Date.now) {
|
|
|
72
100
|
const message = event.message as { role?: string; customType?: string; content?: unknown };
|
|
73
101
|
if (message.role === "custom" && message.customType === CORE_NUDGE_TYPE) {
|
|
74
102
|
coreNudgedAt = now();
|
|
103
|
+
if (request && !request.currentCoreSlot) request.slot.claimed = true;
|
|
75
104
|
return;
|
|
76
105
|
}
|
|
77
106
|
if (message.role !== "custom" || (message.customType !== "async-result" && message.customType !== "irc:incoming")) return;
|
|
@@ -84,17 +113,22 @@ export function createTodoNudge(now: () => number = Date.now) {
|
|
|
84
113
|
});
|
|
85
114
|
pi.on("tool_call", (event, ctx) => {
|
|
86
115
|
if (event.toolName === "todo") noticeNudged = false;
|
|
87
|
-
if (!
|
|
116
|
+
if (!request || request.slot.claimed || usedTodo || calls >= TOOL_CALLS_BEFORE_NUDGE) return;
|
|
117
|
+
if (request.currentCoreSlot && request.currentCoreSlot() !== request.slot) return;
|
|
88
118
|
if (event.toolName === "todo") {
|
|
89
119
|
usedTodo = true;
|
|
90
120
|
return;
|
|
91
121
|
}
|
|
122
|
+
if (Object.hasOwn(READ_ONLY_TOOLS, event.toolName)) return;
|
|
123
|
+
if (event.toolName === "lsp" && "action" in event.input &&
|
|
124
|
+
typeof event.input.action === "string" && Object.hasOwn(READ_ONLY_LSP_ACTIONS, event.input.action)) return;
|
|
125
|
+
if (++calls < TOOL_CALLS_BEFORE_NUDGE) return;
|
|
92
126
|
// ์ด์ ์์ฒญ์ ์งํ ์ค ๋ชฉ๋ก์ด ์์ผ๋ฉด ์ด๋ฏธ ์ถ์ ์ค์ด๋ค.
|
|
93
127
|
if (todos.some((item) => item.status === "pending" || item.status === "in_progress")) return;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
quiet(
|
|
128
|
+
request.slot.claimed = true;
|
|
129
|
+
const message = { customType: "todo-nudge", content: REMINDER, display: false, attribution: "agent" as const };
|
|
130
|
+
queuedFifth.set(message, request);
|
|
131
|
+
quiet(message, ctx);
|
|
98
132
|
});
|
|
99
133
|
};
|
|
100
134
|
}
|
|
@@ -111,11 +111,26 @@ const page = task.page("p1");
|
|
|
111
111
|
`;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* ๋ณธ๋ฌธ์ ๋จธ๋ฆฌ๋ง๊ณผ ๋ค๋ฅธ ๋ธ๋ก์์ ๋๋ค. 11-14~11-19 Linux 9์ธ์
์ด ego ๊ฐ์ด๋ ์์ ๋๋ก ์ฒซ ํธ์ถ์
|
|
116
|
+
* `const task = await taskSpace(...)`ยท`const page = task.page("p1")`๋ฅผ ์จ์ ๋จธ๋ฆฌ๋ง๊ณผ ๊ฒน์ณ
|
|
117
|
+
* `SyntaxError: Identifier 'task' has already been declared`๋ก ํ ํด์ฉ ๋ฒ๋ ธ๋ค. ๋ธ๋ก์ด๋ฉด ๋ณธ๋ฌธ ์ ์ธ์ ๊ฐ๋ฆฌ๊ธฐ๋ง ํ๋ค.
|
|
118
|
+
* ์ด๋ฆ(๋ฌธ์์ด)๋ง ์ค `taskSpace`๋ ์ด ์ธ์
๊ณต๊ฐ์ ๋๋ ค์ค๋ค. ๊ทธ๋๋ก SDK์ ๋๊ธฐ๋ฉด ์ธ์
์ ๋ฆฌ๊ฐ ๋ชจ๋ฅด๋ ๊ณต๊ฐ์ด ๋จ๋๋ค.
|
|
119
|
+
* ์ซ์ id(์ฌ์ฉ์๊ฐ ๋๊ธด ๊ณต๊ฐ ์ฌ๊ฐ ๋ฑ)๋ ๊ฐ์ด ์๋ ์ต์
(profileId ๋ฑ)์ด ๋ถ์ ํธ์ถ์ ๋ช
์ํ ์์ฒญ์ด๋ผ SDK์ ๊ทธ๋๋ก ๋๊ธด๋ค.
|
|
120
|
+
* ๋ณธ๋ฌธ์ `taskSpace`๋ฅผ ๋งค๊ฐ๋ณ์๋ก ๋ฐ๋ ์์ชฝ ํจ์์ ๋ธ๋ก์์ ๋๋ค. ๋ณธ๋ฌธ์ `const`ยท`let`ยท`var` ์ ์ธ(`task`, `page`, `taskSpace` ํฌํจ)์ด
|
|
121
|
+
* ๋จธ๋ฆฌ๋ง๊ณผ ๊ฒน์น์ง ์๊ณ , ๋์ฒด ํจ์๋ ๋จธ๋ฆฌ๋ง ๋ฒ์์ ๋ฌถ์ฌ ๋ณธ๋ฌธ ์ ์ธ์ ํ๋ค๋ฆฌ์ง ์๋๋ค. ๋ณธ๋ฌธ์ `return` ๊ฐ์ ๊ทธ๋๋ก ๋๋ ค์ค๋ค.
|
|
122
|
+
* finish๊ฐ true๋ฉด ์คํฌ๋ฆฝํธ๊ฐ ๋์ ธ๋ ๊ณต๊ฐ์ ์ ๋ฆฌํ๋ค.
|
|
123
|
+
*/
|
|
115
124
|
export function buildScript(name: string, profile: EgoProfile, body: string, finish: boolean, host: EgoHost = "windows"): string {
|
|
116
|
-
const prelude = buildPrelude(name, profile, host);
|
|
117
|
-
|
|
118
|
-
|
|
125
|
+
const prelude = `${buildPrelude(name, profile, host)}const __egoTask = task;
|
|
126
|
+
const __egoTaskSpace = typeof taskSpace === "function" ? taskSpace : undefined;
|
|
127
|
+
const __egoNamedTaskSpace = (nameOrId, ...rest) => typeof nameOrId === "string" && rest.every((value) => value === undefined || (typeof value === "object" && value !== null && Object.values(value).every((option) => option === undefined)))
|
|
128
|
+
? Promise.resolve(__egoTask)
|
|
129
|
+
: __egoTaskSpace(nameOrId, ...rest);
|
|
130
|
+
`;
|
|
131
|
+
const run = `return await (async (taskSpace) => {\n{\n${body}\n}\n})(__egoNamedTaskSpace);`;
|
|
132
|
+
if (!finish) return `${prelude}${run}\n`;
|
|
133
|
+
return `${prelude}try {\n${run}\n} finally {\n await task.finish({ keep: [] });\n}\n`;
|
|
119
134
|
}
|
|
120
135
|
|
|
121
136
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
[CmdletBinding()]
|
|
2
2
|
param(
|
|
3
3
|
[Parameter(Mandatory = $true)]
|
|
4
|
-
[string]$Request
|
|
4
|
+
[string]$Request,
|
|
5
|
+
[switch]$PreflightOnly
|
|
5
6
|
)
|
|
6
7
|
|
|
7
8
|
$ErrorActionPreference = 'Stop'
|
|
@@ -235,6 +236,11 @@ try {
|
|
|
235
236
|
$repoPaths += $repoPath
|
|
236
237
|
}
|
|
237
238
|
|
|
239
|
+
if ($PreflightOnly) {
|
|
240
|
+
[Console]::Out.WriteLine((@{ ok = $true; stage = 'preflight'; repositoryRoot = $repoRoot; repositoryFiles = @($repoPaths) } | ConvertTo-Json -Compress))
|
|
241
|
+
exit 0
|
|
242
|
+
}
|
|
243
|
+
|
|
238
244
|
$stage = 'remote'
|
|
239
245
|
$branch = (Invoke-Git -WorkingDirectory $repoRoot -GitArgs @('rev-parse', '--abbrev-ref', 'HEAD')).Output
|
|
240
246
|
if (-not $branch -or $branch -eq 'HEAD') { throw 'Detached HEAD is not supported.' }
|
|
@@ -289,6 +295,10 @@ try {
|
|
|
289
295
|
|
|
290
296
|
$stage = 'fetch'
|
|
291
297
|
$headSha = (Invoke-Git -WorkingDirectory $repoRoot -GitArgs @('rev-parse', 'HEAD')).Output
|
|
298
|
+
if ($payload.finalizeChecksHead -and $payload.finalizeChecksHead -cne $headSha) {
|
|
299
|
+
$stage = 'finalize-checks'
|
|
300
|
+
throw 'HEAD changed after running the repository checks. Call git_finalize again.'
|
|
301
|
+
}
|
|
292
302
|
$upstreamSha = $null
|
|
293
303
|
if ($upstreamExists) {
|
|
294
304
|
[void](Invoke-Git -WorkingDirectory $repoRoot -GitArgs @('fetch', '--no-tags', $remote, $upstreamRef))
|