@ornexus/neocortex 4.66.0 → 4.66.2
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/release-source.json +1 -1
- package/dist/sbom.cdx.json +1206 -1193
- package/docs/install/linux-global-install.md +21 -1
- package/install.js +22 -28
- package/install.ps1 +19 -24
- package/install.sh +26 -30
- package/package.json +2 -2
- package/packages/client/dist/commands/doctor.d.ts +26 -1
- package/packages/client/dist/commands/doctor.js +2 -2
- package/packages/client/dist/commands/invoke.d.ts +149 -1
- package/packages/client/dist/commands/invoke.js +88 -83
- package/packages/client/dist/commands/planning-qa.d.ts +57 -0
- package/packages/client/dist/commands/planning-qa.js +1 -1
- package/packages/client/dist/commands/story-checkpoint.d.ts +2 -0
- package/packages/client/dist/commands/story-checkpoint.js +1 -1
- package/packages/client/dist/commands/story-worktree.d.ts +1 -1
- package/packages/client/dist/commands/story-worktree.js +1 -1
- package/packages/client/dist/git/direct-yolo-checkpoint.d.ts +51 -0
- package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -3
- package/packages/client/dist/git/epic-lifecycle-evidence.d.ts +184 -0
- package/packages/client/dist/git/epic-lifecycle-evidence.js +6 -0
- package/packages/client/dist/git/git-lifecycle-store.d.ts +9 -0
- package/packages/client/dist/git/git-lifecycle-store.js +9 -8
- package/packages/client/dist/git/story-worktree-cleanup.js +1 -1
- package/packages/client/dist/git/story-worktree-integration.js +3 -3
- package/packages/client/dist/git/story-worktree-manager.d.ts +39 -0
- package/packages/client/dist/git/story-worktree-manager.js +3 -3
- package/packages/client/dist/git/story-write-set-extension.d.ts +62 -0
- package/packages/client/dist/git/story-write-set-extension.js +1 -1
- package/packages/client/dist/private-execution/codex-executor.d.ts +13 -0
- package/packages/client/dist/private-execution/codex-executor.js +4 -4
- package/packages/client/dist/private-execution/harness-adapters/antigravity.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/antigravity.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/claude-code.d.ts +8 -0
- package/packages/client/dist/private-execution/harness-adapters/claude-code.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/codex.d.ts +7 -0
- package/packages/client/dist/private-execution/harness-adapters/codex.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/copilot-cli.d.ts +8 -0
- package/packages/client/dist/private-execution/harness-adapters/copilot-cli.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/cursor.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/cursor.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/deepseek.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/deepseek.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/gemini.d.ts +8 -0
- package/packages/client/dist/private-execution/harness-adapters/gemini.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/grok.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/grok.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/index.d.ts +73 -0
- package/packages/client/dist/private-execution/harness-adapters/index.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/kimi.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/kimi.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/openclaw.d.ts +9 -0
- package/packages/client/dist/private-execution/harness-adapters/openclaw.js +1 -0
- package/packages/client/dist/private-execution/harness-adapters/opencode.d.ts +7 -0
- package/packages/client/dist/private-execution/harness-adapters/opencode.js +1 -0
- package/packages/client/dist/private-execution/harness-ephemeral-home.d.ts +19 -0
- package/packages/client/dist/private-execution/harness-ephemeral-home.js +1 -0
- package/packages/client/dist/private-execution/harness-executor.d.ts +79 -0
- package/packages/client/dist/private-execution/harness-executor.js +1 -0
- package/packages/client/dist/private-execution/harness-process.d.ts +43 -0
- package/packages/client/dist/private-execution/harness-process.js +1 -0
- package/packages/client/dist/private-execution/isolated-admission.js +12 -12
- package/packages/client/dist/private-execution/isolated-workspace.d.ts +16 -1
- package/packages/client/dist/private-execution/isolated-workspace.js +1 -1
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.d.ts +2 -3
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +7 -4
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.d.ts +1 -22
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +6 -10
- package/packages/client/dist/state/project-state-snapshot.d.ts +10 -0
- package/packages/client/dist/state/project-state-snapshot.js +1 -1
- package/packages/client/dist/state/structural-dag-projection.d.ts +26 -0
- package/packages/client/dist/state/structural-dag-projection.js +1 -1
- package/packages/client/dist/yoloop/yoloop-client-state-store.d.ts +67 -0
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1
- package/packages/shared/dist/compatibility/index.js +28 -0
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/skill/SKILL.md +1 -1
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex-root.md +2 -2
- package/targets-stubs/claude-code/neocortex-sentinel.md +1 -1
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex.md +2 -2
- package/targets-stubs/codex/AGENTS.md +1 -1
- package/targets-stubs/cursor/agent.md +2 -2
- package/targets-stubs/gemini-cli/agent.md +2 -2
- package/targets-stubs/gemini-cli/agents/neocortex.md +2 -2
- package/targets-stubs/grok/SKILL.md +3 -3
- package/targets-stubs/grok/agents/{neocortex.md → neocortex-sentinel.md} +2 -2
- package/targets-stubs/grok/install-grok.sh +45 -8
- package/targets-stubs/lib/managed-config-merge.js +21 -1
- package/targets-stubs/lib/mcp-merge.js +18 -7
- package/targets-stubs/opencode/neocortex-root.md +1 -1
- package/targets-stubs/opencode/neocortex.md +1 -1
- package/targets-stubs/vscode/neocortex.agent.md +2 -2
|
@@ -45,3 +45,65 @@ export interface ExtendStoryWriteSetOptions {
|
|
|
45
45
|
* integration lock serializes it with the single integrator.
|
|
46
46
|
*/
|
|
47
47
|
export declare function extendStoryWriteSet(options: ExtendStoryWriteSetOptions): Promise<StoryWriteSetExtensionResult>;
|
|
48
|
+
export declare const STORY_WRITE_SET_MANUAL_EDIT_REFUSED: "story-write-set-manual-edit-refused";
|
|
49
|
+
export declare const STORY_WRITE_SET_MANUAL_EDIT_UNVERIFIED: "story-write-set-manual-edit-unverified";
|
|
50
|
+
/** Closed, public-safe request a story child returns to the root (DEC-01). */
|
|
51
|
+
export interface StoryWriteSetExtensionRequest {
|
|
52
|
+
readonly schemaVersion: 1;
|
|
53
|
+
readonly kind: 'story-write-set-extension-request';
|
|
54
|
+
readonly storyId: string;
|
|
55
|
+
readonly epicId: string;
|
|
56
|
+
readonly outcome: 'requested' | 'already-authorized';
|
|
57
|
+
/** Authorized extension UNION the requested paths outside `files_to_modify` (the root needs a superset). */
|
|
58
|
+
readonly paths: readonly string[];
|
|
59
|
+
readonly requestedPathCount: number;
|
|
60
|
+
readonly digest: string;
|
|
61
|
+
readonly requestedBy: 'story_child';
|
|
62
|
+
/** Exact command only the root runs to apply the amendment under CAS; empty when nothing is outside `files_to_modify`. */
|
|
63
|
+
readonly applyCommand: string;
|
|
64
|
+
}
|
|
65
|
+
export type StoryWriteSetExtensionRequestResult = {
|
|
66
|
+
readonly ok: true;
|
|
67
|
+
readonly value: StoryWriteSetExtensionRequest;
|
|
68
|
+
} | {
|
|
69
|
+
readonly ok: false;
|
|
70
|
+
readonly reasonCode: string;
|
|
71
|
+
};
|
|
72
|
+
export type StoryWriteSetManualEditResult = {
|
|
73
|
+
readonly ok: true;
|
|
74
|
+
readonly value: {
|
|
75
|
+
readonly storiesCompared: number;
|
|
76
|
+
};
|
|
77
|
+
} | {
|
|
78
|
+
readonly ok: false;
|
|
79
|
+
readonly reasonCode: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* DEC-05: refuse a hand-edited `files_to_modify` (any story) in the candidate
|
|
83
|
+
* `state.json` against the authorized base: the merge-base of the candidate
|
|
84
|
+
* with the epic execution branch, or `HEAD` for a working-tree candidate when
|
|
85
|
+
* that branch is absent. The candidate is the checkout's working file, or the
|
|
86
|
+
* blob at the tip of `candidateRef` (a story temporary branch, root-side
|
|
87
|
+
* integration). Read-only; fail-closed.
|
|
88
|
+
*/
|
|
89
|
+
export declare function detectStoryWriteSetManualEdit(options: {
|
|
90
|
+
readonly projectRoot: string;
|
|
91
|
+
readonly storyId: string;
|
|
92
|
+
readonly candidateRef?: string;
|
|
93
|
+
}): Promise<StoryWriteSetManualEditResult>;
|
|
94
|
+
/**
|
|
95
|
+
* DEC-01: a story child asks for an amendment. Writes nothing (no state, no
|
|
96
|
+
* overlay, no lock) and runs in a secondary worktree; the root applies the
|
|
97
|
+
* returned `applyCommand` through `extendStoryWriteSet` under CAS.
|
|
98
|
+
*/
|
|
99
|
+
export declare function requestStoryWriteSetExtension(options: {
|
|
100
|
+
readonly projectRoot: string;
|
|
101
|
+
readonly storyId: string;
|
|
102
|
+
readonly paths: readonly string[];
|
|
103
|
+
}): Promise<StoryWriteSetExtensionRequestResult>;
|
|
104
|
+
/**
|
|
105
|
+
* DEC-05 for root-side integration: the temporary branch named by the story's
|
|
106
|
+
* live lease receipt; undefined when no lease receipt is recorded (the
|
|
107
|
+
* integrator then refuses on its own lease checks).
|
|
108
|
+
*/
|
|
109
|
+
export declare function storyWorktreeTemporaryBranchForManualEditGate(projectRoot: string, storyId: string): Promise<string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{execFile as
|
|
1
|
+
import{execFile as T}from"node:child_process";import{createHash as Y}from"node:crypto";import{readFile as x,realpath as L}from"node:fs/promises";import{join as R,resolve as _}from"node:path";import{acquireGitLifecyclePhysicalIntegrationLockWithin as U,ensureRuntimeStory as V,isStoryWorktreeIntegrationReceiptRecord as J,isStoryWriteSetExtension as Z,isStoryWriteSetExtensionPath as P,mutateGitLifecycleRuntime as K,readGitLifecycleRuntime as A,readStoryWorktreeEvidence as b,releaseGitLifecyclePhysicalIntegrationLock as X,STORY_WRITE_SET_MAX_ENTRIES as I,storyWriteSetExtensionDigest as O,storyWriteSetExtensionPaths as W,verifyGitLifecyclePhysicalIntegrationLock as Q}from"./git-lifecycle-store.js";const E=/^P[1-9][0-9]*(?:\.[0-9]+)+$/;class v extends Error{reasonCode;constructor(r){super(r),this.reasonCode=r}}function c(e){throw new v(e)}function $(e,r){return new Promise((t,n)=>{T("git",[...r],{cwd:e,encoding:"utf8",timeout:3e4,env:{...process.env,GIT_TERMINAL_PROMPT:"0",LC_ALL:"C"}},(s,o)=>s?n(new v("story-write-set-extension-not-root")):t(String(o).trim()))})}function l(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function B(e){try{return Z(e)}catch{return!1}}function ee(e){return Y("sha256").update([...e].sort().join("\0")).digest("hex")}function z(e,r,t,n,s){const o=l(l(r.stories)?.[t]);o||c("story-write-set-extension-story-missing");const i=typeof o.epic_id=="string"?o.epic_id:t.split(".")[0];t.startsWith(`${i}.`)||c("story-write-set-extension-story-missing");const a=e.stories[t];(b(e,i)?.receipts??[]).filter(J).some(y=>y.storyId===t&&y.outcome==="integrated")&&c("story-write-set-extension-story-integrated"),(a?.checkpoint||o.checkpoint)&&c("story-write-set-extension-checkpoint-accepted");const h=l(e.epics[i]?.branch_lease);h&&Date.parse(String(h.expiresAt))>s&&c("story-write-set-extension-writer-active"),a?.write_set_extension!==void 0&&!B(a.write_set_extension)&&c("story-write-set-extension-invalid");const f=W(a);f.some(y=>!n.includes(y))&&c("story-write-set-extension-not-superset");const d=Array.isArray(o.files_to_modify)?o.files_to_modify.filter(y=>typeof y=="string"):[],w=[...new Set([...d,...n])].sort();return w.length>I&&c("story-write-set-extension-too-large"),{epicId:i,union:w,unchanged:f.length===n.length}}async function de(e){const r=_(e.projectRoot);let t;try{(typeof e.storyId!="string"||!E.test(e.storyId))&&c("story-write-set-extension-story-invalid"),(!Array.isArray(e.paths)||e.paths.length===0||e.paths.length>I||e.paths.some(u=>!P(u)))&&c("story-write-set-extension-path-invalid");const n=[...new Set(e.paths)].sort(),s=await L(await $(r,["rev-parse","--absolute-git-dir"])),o=await L(await $(r,["rev-parse","--path-format=absolute","--git-common-dir"]));s!==o&&c("story-write-set-extension-not-root");const i=await q({projectRoot:r,storyId:e.storyId});i.ok||c(i.reasonCode);const a=new Date(e.nowIso??Date.now()).toISOString(),g=R(r,".neocortex","state.json"),h=async()=>{const u=await x(g,"utf8"),p=l(JSON.parse(u))??c("story-write-set-extension-state-invalid"),D=await A(r,{required:!0});return{trackedBytes:u,tracked:p,runtime:D,plan:z(D,p,e.storyId,n,Date.now())}},f=O(n),d=(u,p)=>({ok:!0,value:Object.freeze({storyId:e.storyId,epicId:u.epicId,outcome:p,extensionPathCount:n.length,extensionDigest:f,authorizedPathCount:u.union.length,claimRevision:ee(u.union)})}),w=await h();if(w.plan.unchanged)return d(w.plan,"unchanged");const y=`write-set-extension-${f.slice(0,40)}`;t=await U(r,{kind:"direct",storyId:e.storyId,sessionId:y,idempotencyKey:y,expiresAt:new Date(Date.now()+300*1e3).toISOString(),persistent:!1},e.lockWait),t.ok||c(t.reasonCode==="git-lifecycle-integration-backpressure"?"story-write-set-extension-backpressure":"story-write-set-extension-lock-failed");const m=t,{trackedBytes:N,tracked:G,runtime:F,plan:k}=await h();if(k.unchanged)return d(k,"unchanged");await e.beforeCas?.();const H={schemaVersion:1,kind:"root-write-set-extension",paths:n,digest:f,approvedAt:a,approvedBy:"root_agent"};try{await K(r,u=>{z(u,G,e.storyId,n,Date.now()).unchanged&&c("story-write-set-extension-raced"),V(u,e.storyId).write_set_extension=H},{expectedRevision:F.revision,preCommit:async()=>{await Q(m.path,m.owner)||c("story-write-set-extension-lock-raced"),await x(g,"utf8")!==N&&c("story-write-set-extension-raced")}})}catch(u){throw u instanceof Error&&u.message==="git-lifecycle-runtime-revision-conflict"&&c("story-write-set-extension-raced"),u}return d(k,"recorded")}catch(n){if(n instanceof v)return{ok:!1,reasonCode:n.reasonCode};const s=n instanceof Error?n.message:"";return/^git-lifecycle-[a-z0-9-]{1,80}$/.test(s)?{ok:!1,reasonCode:s}:{ok:!1,reasonCode:"story-write-set-extension-failed"}}finally{t?.ok&&await X(t.path,t.owner).catch(()=>{})}}const te="story-write-set-manual-edit-refused",re="story-write-set-manual-edit-unverified",ne="neocortex-client story-checkpoint extend-write-set",C=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,199}$/;function S(e,r){return new Promise(t=>{T("git",[...r],{cwd:e,encoding:"utf8",timeout:3e4,maxBuffer:64*1024*1024,env:{...process.env,GIT_TERMINAL_PROMPT:"0",LC_ALL:"C"}},(n,s)=>t(n?void 0:String(s)))})}function j(e){if(e!==void 0)try{return l(JSON.parse(e))}catch{return}}function M(e){const r=l(e.stories)??{},t=new Map;for(const[n,s]of Object.entries(r)){const o=l(s)?.files_to_modify;o!==void 0&&t.set(n,Array.isArray(o)?JSON.stringify([...new Set(o.filter(i=>typeof i=="string"))].sort()):"!invalid")}return t}async function q(e){const r=_(e.projectRoot),t={ok:!1,reasonCode:re};if(typeof e.storyId!="string"||!E.test(e.storyId)||e.candidateRef!==void 0&&(!C.test(e.candidateRef)||e.candidateRef.includes("..")))return t;const n=e.candidateRef===void 0?await x(R(r,".neocortex","state.json"),"utf8").catch(()=>{}):await S(r,["show",`refs/heads/${e.candidateRef}:.neocortex/state.json`]),s=j(n);if(!s)return t;const o=l(l(s.stories)?.[e.storyId]),i=typeof o?.epic_id=="string"?o.epic_id:e.storyId.split(".")[0],a=l(l(s.epics)?.[i])?.execution_branch,g=e.candidateRef===void 0?"HEAD":`refs/heads/${e.candidateRef}`;let h;if(typeof a=="string"&&C.test(a)&&!a.includes("..")&&await S(r,["rev-parse","--verify","--quiet",`refs/heads/${a}^{commit}`])!==void 0){const y=(await S(r,["merge-base",g,`refs/heads/${a}`]))?.trim();if(!y||!/^[a-f0-9]{40,64}$/.test(y))return t;h=y}else if(e.candidateRef===void 0)h="HEAD";else return t;const f=j(await S(r,["show",`${h}:.neocortex/state.json`]));if(!f)return t;const d=M(f),w=M(s);for(const[y,m]of d)if(w.get(y)!==m)return{ok:!1,reasonCode:te};return{ok:!0,value:Object.freeze({storiesCompared:d.size})}}async function fe(e){const r=_(e.projectRoot);if(typeof e.storyId!="string"||!E.test(e.storyId))return{ok:!1,reasonCode:"story-write-set-extension-story-invalid"};if(!Array.isArray(e.paths)||e.paths.length===0||e.paths.length>I||e.paths.some(d=>!P(d)))return{ok:!1,reasonCode:"story-write-set-extension-path-invalid"};const t=await q({projectRoot:r,storyId:e.storyId});if(!t.ok)return t;const n=j(await x(R(r,".neocortex","state.json"),"utf8").catch(()=>{}));if(!n)return{ok:!1,reasonCode:"story-write-set-extension-state-invalid"};const s=l(l(n.stories)?.[e.storyId]);if(!s)return{ok:!1,reasonCode:"story-write-set-extension-story-missing"};const o=typeof s.epic_id=="string"?s.epic_id:e.storyId.split(".")[0];if(!e.storyId.startsWith(`${o}.`))return{ok:!1,reasonCode:"story-write-set-extension-story-missing"};let i;try{const w=(await A(r)).stories[e.storyId];if(w?.write_set_extension!==void 0&&!B(w.write_set_extension))return{ok:!1,reasonCode:"story-write-set-extension-invalid"};i=W(w)}catch{return{ok:!1,reasonCode:"story-write-set-extension-state-invalid"}}const a=new Set(Array.isArray(s.files_to_modify)?s.files_to_modify.filter(d=>typeof d=="string"):[]),g=new Set([...a,...i]),h=[...new Set(e.paths)].filter(d=>!g.has(d)),f=[...new Set([...i,...e.paths.filter(d=>!a.has(d))])].sort();return a.size+f.length>I?{ok:!1,reasonCode:"story-write-set-extension-too-large"}:{ok:!0,value:Object.freeze({schemaVersion:1,kind:"story-write-set-extension-request",storyId:e.storyId,epicId:o,outcome:h.length===0?"already-authorized":"requested",paths:Object.freeze(f),requestedPathCount:h.length,digest:O(f),requestedBy:"story_child",applyCommand:f.length>0?`${ne} --story ${e.storyId} --paths ${f.join(",")}`:""})}}async function ye(e,r){try{const t=await A(_(e)),n=r.split(".")[0],o=(b(t,n)?.receipts??[]).map(i=>l(i)).filter(i=>i?.kind==="story-worktree-lease"&&i.storyId===r&&typeof i.temporaryBranch=="string"&&C.test(i.temporaryBranch)).sort((i,a)=>String(i.acquiredAt??"").localeCompare(String(a.acquiredAt??""))).at(-1);return o?String(o.temporaryBranch):void 0}catch{return}}export{te as STORY_WRITE_SET_MANUAL_EDIT_REFUSED,re as STORY_WRITE_SET_MANUAL_EDIT_UNVERIFIED,q as detectStoryWriteSetManualEdit,de as extendStoryWriteSet,fe as requestStoryWriteSetExtension,ye as storyWorktreeTemporaryBranchForManualEditGate};
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
import { type PrivateHarnessAdapter } from './harness-executor.js';
|
|
1
2
|
import type { PRIVATE_EXECUTION_CODEX_HOST_KIND } from '../../../shared/dist/compatibility/index.js';
|
|
3
|
+
export declare const PRIVATE_CODEX_DATA_CONTROLS: readonly string[];
|
|
4
|
+
/**
|
|
5
|
+
* P229.01 (CON-P229.01-CODEX-PARITY): Codex is the first declarative
|
|
6
|
+
* PrivateHarnessAdapter. The Linux exec argv below is assembled from this
|
|
7
|
+
* declaration so the bytes stay identical to the P222.16 path; the supervised
|
|
8
|
+
* Linux guard and the v6 preflight remain Codex-specific.
|
|
9
|
+
*
|
|
10
|
+
* P229.02 (AC3): the declaration admits darwin and win32 through the
|
|
11
|
+
* host-neutral core port; `preflightPrivateCodexExecutor`/`runPrivateCodexStep`
|
|
12
|
+
* (v6) stay Linux-only and byte-identical.
|
|
13
|
+
*/
|
|
14
|
+
export declare const PRIVATE_CODEX_HARNESS_ADAPTER: PrivateHarnessAdapter;
|
|
2
15
|
/**
|
|
3
16
|
* Codex-host attributes of the private-execution envelope (P228.18, ADR-3).
|
|
4
17
|
* The Linux platform, ChatGPT subscription login and the v6 sandbox proof are
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{codexLifecycleGuardPath as
|
|
2
|
-
`),
|
|
3
|
-
`))>=0;){const
|
|
4
|
-
`)throw new Error("private-codex-workspace-write-unproven")}catch{throw new Error("private-codex-workspace-write-unproven")}finally{try{
|
|
1
|
+
import{codexLifecycleGuardPath as Y}from"./codex-lifecycle-guard.js";import{execFileSync as q,spawn as U}from"node:child_process";import{createHash as k,randomBytes as Z}from"node:crypto";import{connect as Q,createServer as ee}from"node:net";import{accessSync as M,lstatSync as T,mkdtempSync as te,readFileSync as re,realpathSync as oe,rmdirSync as B,unlinkSync as C,constants as L}from"node:fs";import{homedir as ne}from"node:os";import{join as E,resolve as H}from"node:path";import{gitLifecycleRuntimeDirectory as ie}from"../git/git-lifecycle-store.js";import{captureDirectYoloCheckoutEvidence as j}from"../git/direct-yolo-checkpoint.js";import{createPrivateCodexScopedRunner as se}from"./codex-scoped-permissions.js";import{createPrivateCodexHostRuntime as ae}from"./codex-host-runtime.js";import{sha256Hex as N}from"./harness-executor.js";import{assertPrivateHarnessMaterial as ce}from"./harness-process.js";const G=3e4,m=16*1024,de=1024*1024,I=/^codex-cli\s+(\d+\.\d+\.\d+)\s*$/,y="p222-isolated",z=["PATH","HOME","LANG","LC_ALL","TERM","CODEX_HOME"],$=Object.freeze(["-c",'web_search="disabled"',"-c","features.hooks=false","-c","analytics.enabled=false","-c",'history.persistence="none"',"-c",'otel.exporter="none"',"-c",'otel.metrics_exporter="none"',"-c",'otel.trace_exporter="none"',"-c","otel.log_user_prompt=false","-c","notify=[]"]),ue=Object.freeze({hostKind:"codex-cli",binary:"codex",fixedArgs:Object.freeze(["exec","--ephemeral","--json","--strict-config","-c","features.plugins=false"]),stdinFlag:"-",nativeFlags:$,configDirEnv:"CODEX_HOME",credentialFiles:Object.freeze(["auth.json","config.toml"]),environmentKeys:z,versionArgs:Object.freeze(["--version"]),versionPattern:I,minimumVersion:"0.0.0",platforms:Object.freeze(["linux","darwin","win32"]),credentialSource:Object.freeze({env:"CODEX_HOME",homeRelative:".codex"})});function le(r){try{return ce(r),!0}catch{return!1}}const D=new WeakMap,P=new WeakMap;function fe(r){const e={};for(const t of z)typeof r[t]=="string"&&(e[t]=r[t]);return e}async function F(r,e){if(e.configReadProbe&&(e.stdin!==void 0||r.at(-1)!=="app-server"))throw new Error("private-codex-web-search-isolation-unproven");return new Promise((t,o)=>{const i=fe(process.env);e.codexHome!==void 0&&(i.CODEX_HOME=e.codexHome);const n=process.platform==="linux",a=U(n?process.execPath:e.codexHome===void 0?"codex":"/bin/sh",n?[Y,"process"]:e.codexHome===void 0?[...r]:["-c",'umask 077; exec codex "$@"',"neocortex-private-codex",...r],{cwd:e.cwd,stdio:n?["pipe","pipe","pipe","ipc"]:["pipe","pipe","pipe"],env:i,detached:n}),d=()=>{if(process.platform==="linux"&&a.pid!==void 0)try{process.kill(-a.pid,"SIGKILL")}catch(l){if(l.code!=="ESRCH")throw l}else a.kill("SIGKILL")},s=[],u=[];let w=0,f=0,c=!1,p=!1,x="",S=!1;const b=l=>a.stdin.write(`${JSON.stringify(l)}
|
|
2
|
+
`),O=setTimeout(()=>{c=!0,d()},e.timeoutMs);a.stdout.on("data",l=>{if(w+=l.byteLength,w+f>e.maxOutputBytes)p=!0,d();else if(s.push(l),e.configReadProbe){x+=l.toString("utf8");let v;for(;(v=x.indexOf(`
|
|
3
|
+
`))>=0;){const A=x.slice(0,v);x=x.slice(v+1);try{const R=JSON.parse(A);R.id===1&&R.result&&!S?(S=!0,b({method:"initialized",params:{}}),b({id:2,method:"config/read",params:{includeLayers:!1,cwd:e.cwd}})):R.id===2&&a.stdin.end()}catch{}}}}),a.stderr.on("data",l=>{f+=l.byteLength,w+f>e.maxOutputBytes?(p=!0,d()):u.push(l)}),a.on("error",l=>{clearTimeout(O),o(l)}),a.on("close",l=>{clearTimeout(O),t({exitCode:l,stdout:Buffer.concat(s),stderr:Buffer.concat(u),timedOut:c,outputExceeded:p})}),a.stdin.on("error",()=>{}),n&&a.send({kind:"private-codex-launch",args:[...r],codexHome:e.codexHome},l=>{l&&(clearTimeout(O),d(),o(new Error("private-codex-process-guard-unavailable")))}),e.configReadProbe?b({id:1,method:"initialize",params:{clientInfo:{name:"p222-isolation-probe",version:"1"},capabilities:{}}}):a.stdin.end(e.stdin)})}function h(r){return r.exitCode===0&&!r.timedOut&&!r.outputExceeded}async function W(r,e){const t=await e(["-c","features.plugins=false","plugin","list","--json"],{cwd:r,timeoutMs:1e4,maxOutputBytes:m}),o=await e(["mcp","list","--json"],{cwd:r,timeoutMs:1e4,maxOutputBytes:m});if(!h(t)||!h(o))return null;try{const i=JSON.parse(t.stdout.toString("utf8")),n=JSON.parse(o.stdout.toString("utf8"));if(!!!(i&&typeof i=="object"&&!Array.isArray(i)&&Array.isArray(i.installed)&&i.installed.length===0)||!Array.isArray(n)||n.length>64)return null;const d=n.map(c=>{if(!c||typeof c!="object"||Array.isArray(c))throw new Error("invalid catalog");const p=c;if(typeof p.name!="string"||!/^[A-Za-z0-9_-]{1,64}$/.test(p.name)||typeof p.enabled!="boolean")throw new Error("invalid catalog");return p.name});if(new Set(d).size!==d.length)return null;if(d.length===0)return[];const s=[...d].sort().flatMap(c=>["-c",`mcp_servers.${c}.enabled=false`]),u=await e([...s,"mcp","list","--json"],{cwd:r,timeoutMs:1e4,maxOutputBytes:m});if(!h(u))return null;const w=JSON.parse(u.stdout.toString("utf8"));if(!Array.isArray(w)||w.length!==d.length)return null;const f=new Set;for(const c of w){if(!c||typeof c!="object"||Array.isArray(c)||typeof c.name!="string"||!d.includes(c.name)||c.enabled!==!1||f.has(c.name))return null;f.add(c.name)}return Object.freeze(s)}catch{return null}}async function V(r,e){const t=await e(["-c","features.hooks=false","features","list"],{cwd:r,timeoutMs:1e4,maxOutputBytes:m});if(!h(t))return!1;const o=t.stdout.toString("utf8").split(/\r?\n/).filter(i=>/^hooks\s+\S+\s+(?:true|false)\s*$/.test(i));return o.length===1&&/^hooks\s+\S+\s+false\s*$/.test(o[0])}async function K(r,e,t){const o=await e(["-c","features.plugins=false",...t,...$,"--strict-config","app-server"],{cwd:r,configReadProbe:!0,timeoutMs:1e4,maxOutputBytes:262144});try{if(!h(o))return!1;const n=o.stdout.toString("utf8").split(/\r?\n/).filter(Boolean).map(a=>JSON.parse(a)).filter(a=>a&&a.id===2);return n.length===1&&!n[0].error&&n[0].result?.config?.web_search==="disabled"}catch{return!1}finally{o.stdout.fill(0),o.stderr.fill(0)}}function pe(r){const e=T(r);if(!e.isFile()||e.isSymbolicLink())throw new Error("private-codex-auth-unavailable");M(r,L.R_OK)}function X(r){const e={...process.env};for(const t of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_COMMON_DIR","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES"])delete e[t];try{const t=i=>q("git",[...i],{cwd:r,env:e,encoding:"utf8",timeout:5e3,maxBuffer:m,stdio:["ignore","pipe","ignore"]}).trim(),o=[t(["rev-parse","--git-dir"]),t(["rev-parse","--git-common-dir"])].map(i=>oe(H(r,i)));if(o.some(i=>!T(i).isDirectory()))throw new Error("git-control-invalid");return[...new Set(o)]}catch{throw new Error("private-codex-git-control-unavailable")}}async function me(r,e){const t=await e(["sandbox","-P",y,"--","git","rev-parse","--git-dir"],{cwd:r,timeoutMs:1e4,maxOutputBytes:m});if(!h(t))return!1;for(const o of X(r)){const i=E(o,`.neocortex-git-probe-${Z(16).toString("hex")}`),n=await e(["sandbox","-P",y,"--","sh","-c",'mkdir "$1"',"sh",i],{cwd:r,timeoutMs:1e4,maxOutputBytes:m});let a=!1,d=!1;try{const s=T(i);a=!0,d=s.isDirectory()}catch(s){if(s.code!=="ENOENT")return!1}if(a&&(d?B(i):C(i)),n.exitCode!==1||n.timedOut||n.outputExceeded||a)return!1}return!0}async function we(r,e,t){if(!T(e).isDirectory())return!1;M(e,L.R_OK);const o=await t(["sandbox","-P",y,"--","sh","-c",'if test -r "$1"; then exit 42; else exit 43; fi',"sh",e],{cwd:r,timeoutMs:1e4,maxOutputBytes:m});return o.exitCode===43&&!o.timedOut&&!o.outputExceeded}async function he(r,e){const t=ee(o=>o.end());await new Promise((o,i)=>{t.once("error",i),t.listen(0,"127.0.0.1",()=>o())});try{const o=t.address();if(!o||typeof o=="string")return!1;const i='const s=require("node:net").connect(Number(process.argv[1]),"127.0.0.1");s.setTimeout(1500);s.on("connect",()=>{s.end();process.exit(0)});s.on("error",()=>process.exit(1));s.on("timeout",()=>process.exit(1))';if(!await new Promise(s=>{const u=Q(o.port,"127.0.0.1");u.setTimeout(1500),u.once("connect",()=>{u.end(),s(!0)}),u.once("error",()=>s(!1)),u.once("timeout",()=>{u.destroy(),s(!1)})}))return!1;const a=await e(["sandbox","-P",y,"--","node","--version"],{cwd:r,timeoutMs:5e3,maxOutputBytes:m});if(!h(a))return!1;const d=await e(["sandbox","-P",y,"--","node","-e",i,String(o.port)],{cwd:r,timeoutMs:5e3,maxOutputBytes:m});return d.exitCode===1&&!d.timedOut&&!d.outputExceeded}finally{t.close()}}async function Ae(r,e={}){if((e.platform??process.platform)!=="linux")throw new Error("private-codex-platform-unsupported");const t=H(r),o=e.userHome??ne(),i=e.codexHome??process.env.CODEX_HOME??E(o,".codex"),n=e.runner?void 0:ae(t,i);try{const a=n?async(g,J)=>(n.verify(),F(g,{...J,codexHome:n.home})):F,d=n?.home??i,s=e.runner??await se(t,a,{...e,codexHome:d,credentialSourceHome:n?.sourceHome??i,gitControlDirectories:X(t)}),u=E(d,"auth.json");try{pe(u)}catch{throw new Error("private-codex-auth-unavailable")}const w=await s(["--version"],{cwd:t,timeoutMs:5e3,maxOutputBytes:m}),f=h(w)?I.exec(w.stdout.toString("utf8").trim()):null;if(!f)throw new Error("private-codex-version-unavailable");const c=await s(["login","status"],{cwd:t,timeoutMs:5e3,maxOutputBytes:m});if(!h(c)||!/Logged in using ChatGPT/i.test(Buffer.concat([c.stdout,c.stderr]).toString("utf8")))throw new Error("private-codex-subscription-required");const p=await W(t,s).catch(()=>null);if(p===null)throw new Error("private-codex-mcp-isolation-unproven");if(!await V(t,s).catch(()=>!1))throw new Error("private-codex-hook-isolation-unproven");if(!await K(t,s,p).catch(()=>!1))throw new Error("private-codex-web-search-isolation-unproven");const S=await ie(t).catch(()=>{throw new Error("private-codex-git-lifecycle-read-isolation-unproven")}),b=E(o,".ssh"),O=await s(["sandbox","-P",y,"--","sh","-c",...n?['test ! -r "$1" && test ! -r "$2" && test ! -r "$3"',"sh",u,b,E(i,"auth.json")]:['test ! -r "$1" && test ! -r "$2"',"sh",u,b]],{cwd:t,timeoutMs:1e4,maxOutputBytes:m});if(!h(O))throw new Error("private-codex-auth-isolation-unproven");const l=te(E(t,".private-codex-probe-")),v=E(l,"receipt");try{const g=await s(["sandbox","-P",y,"--","sh","-c",'printf "P222_PROBE\\n" > "$1"',"sh",v],{cwd:t,timeoutMs:1e4,maxOutputBytes:m});if(!h(g)||re(v,"utf8")!==`P222_PROBE
|
|
4
|
+
`)throw new Error("private-codex-workspace-write-unproven")}catch{throw new Error("private-codex-workspace-write-unproven")}finally{try{C(v)}catch{}B(l)}if(!await me(t,s).catch(()=>!1))throw new Error("private-codex-git-control-isolation-unproven");if(!await we(t,S,s).catch(()=>!1))throw new Error("private-codex-git-lifecycle-read-isolation-unproven");if(!await(e.networkProbe??he)(t,s))throw new Error("private-codex-network-isolation-unproven");const _=Object.freeze({schemaVersion:6,hostKind:"codex-cli",hostVersion:f[1],projectRoot:t,observedAtMs:(e.now??Date.now)(),authIsolation:"passed",workspaceWrite:"passed",gitControlWriteDenied:"passed",gitLifecycleReadDenied:"passed",mcpIsolation:"passed",environmentIsolation:"passed",networkDenied:"passed",webSearchDisabled:"passed",credentialKind:"chatgpt-subscription"});if(D.set(_,s),n){const g=setTimeout(()=>{P.delete(_),D.delete(_);try{n.close()}catch{}},G);g.unref(),P.set(_,{runtime:n,timer:g})}return _}catch(a){throw n?.close(),a}}async function ke(r,e,t={}){const o=P.get(e);o&&(clearTimeout(o.timer),P.delete(e));try{const i=(t.now??Date.now)();if(t.model!==void 0&&!/^gpt-[a-z0-9][a-z0-9.-]{0,63}$/.test(t.model))throw new Error("private-codex-model-invalid");if(e.schemaVersion!==6||e.hostKind!=="codex-cli"||e.authIsolation!=="passed"||e.workspaceWrite!=="passed"||e.gitControlWriteDenied!=="passed"||e.gitLifecycleReadDenied!=="passed"||e.mcpIsolation!=="passed"||e.environmentIsolation!=="passed"||e.webSearchDisabled!=="passed"||e.networkDenied!=="passed"||e.credentialKind!=="chatgpt-subscription"||i<e.observedAtMs||i-e.observedAtMs>G||!le(r))throw new Error("private-codex-preflight-stale");const n=t.runner??D.get(e);if(!n)throw new Error("private-codex-preflight-stale");const a=await n(["--version"],{cwd:e.projectRoot,timeoutMs:5e3,maxOutputBytes:m});if(!h(a)||I.exec(a.stdout.toString("utf8").trim())?.[1]!==e.hostVersion)throw new Error("private-codex-version-drift");const d=(c,p)=>{const x=Object.freeze({schemaVersion:1,kind:"PrivateCodexWorkspaceEffectFailure/1",phase:c,agentReturnedSuccessfully:p!==void 0,...p===void 0?{}:{stdoutSha256:k("sha256").update(p.stdout).digest("hex"),stderrSha256:k("sha256").update(p.stderr).digest("hex"),stdoutBytes:p.stdout.length,stderrBytes:p.stderr.length},publicSafe:!0});try{Promise.resolve(t.onWorkspaceEffectFailure?.(x)).catch(()=>{})}catch{}return new Error("private-codex-workspace-effect-unverified")},s=t.requireWorkspaceEffect?await j(e.projectRoot).catch(()=>{throw d("before-capture")}):void 0;if(s&&t.expectedExecutionBranch!==void 0&&s.branch!==t.expectedExecutionBranch)throw d("branch-before");if(!await V(e.projectRoot,n).catch(()=>!1))throw new Error("private-codex-hook-isolation-unproven");const u=await W(e.projectRoot,n).catch(()=>null);if(u===null)throw new Error("private-codex-mcp-isolation-unproven");if(!await K(e.projectRoot,n,u).catch(()=>!1))throw new Error("private-codex-web-search-isolation-unproven");const w=ue,f=await n([...w.fixedArgs,...t.model===void 0?[]:["--model",t.model],...u,...w.nativeFlags,"-c","shell_environment_policy.ignore_default_excludes=false","-c",'shell_environment_policy.include_only=["PATH","HOME","LANG","LC_ALL","TERM"]',"-c",`default_permissions="${y}"`,"-C",e.projectRoot,w.stdinFlag],{cwd:e.projectRoot,stdin:r,timeoutMs:10*6e4,maxOutputBytes:de});if(!h(f))throw new Error("private-codex-execution-unverified");if(o?.runtime.verify(),s){const c=await j(e.projectRoot).catch(()=>{throw d("after-capture",f)});if(c.headSha!==s.headSha||c.branch!==s.branch)throw d("identity-after",f);if(c.payloadDigest===s.payloadDigest)throw d("no-payload-change",f)}return Object.freeze({schemaVersion:1,outcome:"executor-returned-unverified",exitCode:0,stdoutSha256:N(f.stdout),stderrSha256:N(f.stderr),stdoutBytes:f.stdout.byteLength,stderrBytes:f.stderr.byteLength,publicSafe:!0})}finally{o&&(D.delete(e),o.runtime.close())}}export{$ as PRIVATE_CODEX_DATA_CONTROLS,ue as PRIVATE_CODEX_HARNESS_ADAPTER,Ae as preflightPrivateCodexExecutor,fe as privateCodexEnvironment,F as runBoundedCodexProcess,ke as runPrivateCodexStep};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.03 (P229-CON-EXECUTOR, DEC-2/DEC-3): Antigravity CLI (`agy`) headless
|
|
3
|
+
* private adapter. Print mode with `--input-format text` reads the material
|
|
4
|
+
* from stdin; `--sandbox` is the native isolation flag. `HOME` is the
|
|
5
|
+
* ephemeral home. No credential file is copied (A-01: keychain/env). Empty
|
|
6
|
+
* stdout with exit 0 in non-TTY mode is not expressible in the core (D-02).
|
|
7
|
+
*/
|
|
8
|
+
import type { PrivateHarnessAdapter } from '../harness-executor.js';
|
|
9
|
+
export declare const PRIVATE_ANTIGRAVITY_HARNESS_ADAPTER: PrivateHarnessAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({hostKind:"antigravity",binary:"agy",fixedArgs:Object.freeze(["--print","--input-format","text","--output-format","text"]),stdinFlag:null,nativeFlags:Object.freeze(["--sandbox"]),configDirEnv:null,configDirEnvs:Object.freeze({HOME:""}),credentialFiles:Object.freeze([]),environmentKeys:Object.freeze(["PATH","HOME","LANG","LC_ALL","TERM"]),versionArgs:Object.freeze(["--version"]),versionPattern:/^(?:(?:agy|antigravity)\s+)?v?(\d+\.\d+\.\d+)$/,minimumVersion:"0.0.1",platforms:Object.freeze(["linux","darwin","win32"])});export{e as PRIVATE_ANTIGRAVITY_HARNESS_ADAPTER};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.02 (P229-CON-EXECUTOR, AC1): Claude Code headless private adapter. The
|
|
3
|
+
* protected material is read from stdin by print mode; argv carries only fixed
|
|
4
|
+
* flags and `--no-session-persistence`. `CLAUDE_CONFIG_DIR` points at the
|
|
5
|
+
* ephemeral home, where the declared credential is mirrored.
|
|
6
|
+
*/
|
|
7
|
+
import type { PrivateHarnessAdapter } from '../harness-executor.js';
|
|
8
|
+
export declare const PRIVATE_CLAUDE_CODE_HARNESS_ADAPTER: PrivateHarnessAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({hostKind:"claude-code",binary:"claude",fixedArgs:Object.freeze(["-p","--strict-mcp-config","--agent","neocortex-sentinel","--output-format","json"]),stdinFlag:null,nativeFlags:Object.freeze(["--no-session-persistence"]),configDirEnv:null,configDirEnvs:Object.freeze({CLAUDE_CONFIG_DIR:".claude"}),credentialFiles:Object.freeze([".claude/.credentials.json"]),credentialSource:Object.freeze({homeRelative:""}),environmentKeys:Object.freeze(["PATH","HOME","LANG","LC_ALL","TERM"]),versionArgs:Object.freeze(["--version"]),versionPattern:/^(\d+\.\d+\.\d+) \(Claude Code\)$/,minimumVersion:"2.1.0",platforms:Object.freeze(["linux","darwin","win32"])});export{e as PRIVATE_CLAUDE_CODE_HARNESS_ADAPTER};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.02 (AC3, D-002): the Codex adapter is the single declaration integrated
|
|
3
|
+
* by P229.01 in `codex-executor.ts`; it is re-exported here, never copied.
|
|
4
|
+
* darwin/win32 run through the host-neutral core port; the Linux v6 path in
|
|
5
|
+
* `codex-executor.ts` is unchanged.
|
|
6
|
+
*/
|
|
7
|
+
export { PRIVATE_CODEX_DATA_CONTROLS, PRIVATE_CODEX_HARNESS_ADAPTER } from '../codex-executor.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PRIVATE_CODEX_DATA_CONTROLS as _,PRIVATE_CODEX_HARNESS_ADAPTER as R}from"../codex-executor.js";export{_ as PRIVATE_CODEX_DATA_CONTROLS,R as PRIVATE_CODEX_HARNESS_ADAPTER};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.03 (P229-CON-EXECUTOR, DEC-2/DEC-3): GitHub Copilot CLI headless private
|
|
3
|
+
* adapter. Silent mode without `-p` reads the material from piped stdin and
|
|
4
|
+
* never asks the user; auto-update is disabled natively. `COPILOT_HOME` points
|
|
5
|
+
* at the ephemeral home. No credential file is copied (A-01: keychain/env).
|
|
6
|
+
*/
|
|
7
|
+
import type { PrivateHarnessAdapter } from '../harness-executor.js';
|
|
8
|
+
export declare const PRIVATE_COPILOT_CLI_HARNESS_ADAPTER: PrivateHarnessAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({hostKind:"github-copilot-cli",binary:"copilot",fixedArgs:Object.freeze(["-s","--no-ask-user"]),stdinFlag:null,nativeFlags:Object.freeze(["--no-auto-update"]),configDirEnv:"COPILOT_HOME",credentialFiles:Object.freeze([]),environmentKeys:Object.freeze(["PATH","HOME","LANG","LC_ALL","TERM"]),versionArgs:Object.freeze(["--version"]),versionPattern:/^(?:copilot\s+)?v?(\d+\.\d+\.\d+)$/,minimumVersion:"0.0.1",platforms:Object.freeze(["linux","darwin","win32"])});export{e as PRIVATE_COPILOT_CLI_HARNESS_ADAPTER};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.03 (P229-CON-REFUSAL, DEC-2, Q-01): Cursor has no adapter. The research
|
|
3
|
+
* (SRC-03..SRC-07) documents its headless prompt only as an argv argument, never
|
|
4
|
+
* through stdin, so private material would reach argv. It is a declared refusal
|
|
5
|
+
* until stdin is documented; `createPrivateHarnessExecutorPort` returns
|
|
6
|
+
* `undefined` and invoke refuses before any HTTP call.
|
|
7
|
+
*/
|
|
8
|
+
import type { PrivateHarnessRefusalDecision } from './index.js';
|
|
9
|
+
export declare const PRIVATE_CURSOR_HARNESS_DECISION: PrivateHarnessRefusalDecision;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({kind:"refusal",reasonCode:"private-executor-headless-unavailable"});export{e as PRIVATE_CURSOR_HARNESS_DECISION};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.03 (P229-CON-REFUSAL, DEC-2, Q-01): DeepSeek has no adapter. The research
|
|
3
|
+
* (SRC-03..SRC-07) documents its headless prompt only as an argv argument, never
|
|
4
|
+
* through stdin, so private material would reach argv. It is a declared refusal
|
|
5
|
+
* until stdin is documented; `createPrivateHarnessExecutorPort` returns
|
|
6
|
+
* `undefined` and invoke refuses before any HTTP call.
|
|
7
|
+
*/
|
|
8
|
+
import type { PrivateHarnessRefusalDecision } from './index.js';
|
|
9
|
+
export declare const PRIVATE_DEEPSEEK_HARNESS_DECISION: PrivateHarnessRefusalDecision;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({kind:"refusal",reasonCode:"private-executor-headless-unavailable"});export{e as PRIVATE_DEEPSEEK_HARNESS_DECISION};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.02 (P229-CON-EXECUTOR, AC1): Gemini CLI headless private adapter. Piped
|
|
3
|
+
* stdin without a TTY forces non-interactive mode, so argv has no prompt.
|
|
4
|
+
* `GEMINI_CLI_HOME` points at the ephemeral home (checkpointing stays off by
|
|
5
|
+
* default there).
|
|
6
|
+
*/
|
|
7
|
+
import type { PrivateHarnessAdapter } from '../harness-executor.js';
|
|
8
|
+
export declare const PRIVATE_GEMINI_HARNESS_ADAPTER: PrivateHarnessAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({hostKind:"gemini",binary:"gemini",fixedArgs:Object.freeze(["--output-format","json","--approval-mode","auto_edit"]),stdinFlag:null,nativeFlags:Object.freeze([]),configDirEnv:"GEMINI_CLI_HOME",credentialFiles:Object.freeze([".gemini/oauth_creds.json"]),credentialSource:Object.freeze({homeRelative:""}),environmentKeys:Object.freeze(["PATH","HOME","LANG","LC_ALL","TERM"]),versionArgs:Object.freeze(["--version"]),versionPattern:/^v?(\d+\.\d+\.\d+)$/,minimumVersion:"0.16.0",platforms:Object.freeze(["linux","darwin","win32"])});export{e as PRIVATE_GEMINI_HARNESS_ADAPTER};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.03 (P229-CON-REFUSAL, DEC-2, Q-01): Grok has no adapter. The research
|
|
3
|
+
* (SRC-03..SRC-07) documents its headless prompt only as an argv argument, never
|
|
4
|
+
* through stdin, so private material would reach argv. It is a declared refusal
|
|
5
|
+
* until stdin is documented; `createPrivateHarnessExecutorPort` returns
|
|
6
|
+
* `undefined` and invoke refuses before any HTTP call.
|
|
7
|
+
*/
|
|
8
|
+
import type { PrivateHarnessRefusalDecision } from './index.js';
|
|
9
|
+
export declare const PRIVATE_GROK_HARNESS_DECISION: PrivateHarnessRefusalDecision;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({kind:"refusal",reasonCode:"private-executor-headless-unavailable"});export{e as PRIVATE_GROK_HARNESS_DECISION};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { PrivateExecutionHostKind } from '../../../../shared/dist/compatibility/index.js';
|
|
2
|
+
import { type PrivateHarnessAdapter, type PrivateHarnessExecutionReceiptV2, type PrivateHarnessPreflight, type PrivateHarnessProcessRunner } from '../harness-executor.js';
|
|
3
|
+
import type { PrivateHarnessPlatform } from '../harness-process.js';
|
|
4
|
+
export declare const PRIVATE_HARNESS_ADAPTERS: Readonly<Partial<Record<PrivateExecutionHostKind, PrivateHarnessAdapter>>>;
|
|
5
|
+
/**
|
|
6
|
+
* P229.03 (DEC-1, DEC-2): the remaining stdin-capable headless hosts. Kept
|
|
7
|
+
* apart from `PRIVATE_HARNESS_ADAPTERS` so the P229.02 group stays unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PRIVATE_HARNESS_EXTENDED_ADAPTERS: Readonly<Partial<Record<PrivateExecutionHostKind, PrivateHarnessAdapter>>>;
|
|
10
|
+
/** Own-property lookup in the P229.02 group, then the P229.03 extended group. */
|
|
11
|
+
export declare function getPrivateHarnessAdapter(hostKind: unknown): PrivateHarnessAdapter | undefined;
|
|
12
|
+
/** P229.03 (DEC-1, P229-CON-REFUSAL): a host without stdin headless support. */
|
|
13
|
+
export interface PrivateHarnessRefusalDecision {
|
|
14
|
+
readonly kind: 'refusal';
|
|
15
|
+
readonly reasonCode: 'private-executor-headless-unavailable';
|
|
16
|
+
}
|
|
17
|
+
export type PrivateHarnessDecision = {
|
|
18
|
+
readonly kind: 'adapter';
|
|
19
|
+
} | PrivateHarnessRefusalDecision;
|
|
20
|
+
/**
|
|
21
|
+
* P229.03 (DEC-1): one decision per closed host enum value. A new enum value
|
|
22
|
+
* without a decision is a compile error; `adapter` iff an adapter is registered
|
|
23
|
+
* (asserted at runtime by the P229.03 contract test).
|
|
24
|
+
*/
|
|
25
|
+
export declare const PRIVATE_HARNESS_DECISIONS: Readonly<{
|
|
26
|
+
readonly 'claude-code': {
|
|
27
|
+
readonly kind: "adapter";
|
|
28
|
+
};
|
|
29
|
+
readonly opencode: {
|
|
30
|
+
readonly kind: "adapter";
|
|
31
|
+
};
|
|
32
|
+
readonly 'codex-cli': {
|
|
33
|
+
readonly kind: "adapter";
|
|
34
|
+
};
|
|
35
|
+
readonly gemini: {
|
|
36
|
+
readonly kind: "adapter";
|
|
37
|
+
};
|
|
38
|
+
readonly kimi: {
|
|
39
|
+
readonly kind: "adapter";
|
|
40
|
+
};
|
|
41
|
+
readonly 'github-copilot-cli': {
|
|
42
|
+
readonly kind: "adapter";
|
|
43
|
+
};
|
|
44
|
+
readonly openclaw: {
|
|
45
|
+
readonly kind: "adapter";
|
|
46
|
+
};
|
|
47
|
+
readonly antigravity: {
|
|
48
|
+
readonly kind: "adapter";
|
|
49
|
+
};
|
|
50
|
+
readonly vscode: PrivateHarnessRefusalDecision;
|
|
51
|
+
readonly cursor: PrivateHarnessRefusalDecision;
|
|
52
|
+
readonly grok: PrivateHarnessRefusalDecision;
|
|
53
|
+
readonly deepseek: PrivateHarnessRefusalDecision;
|
|
54
|
+
}>;
|
|
55
|
+
/** Decision for an enum value; `undefined` outside the enum (own properties only). */
|
|
56
|
+
export declare function resolvePrivateHarnessDecision(hostKind: unknown): PrivateHarnessDecision | undefined;
|
|
57
|
+
export interface PrivateHarnessExecutorPort {
|
|
58
|
+
readonly hostKind: PrivateExecutionHostKind;
|
|
59
|
+
preflight(): Promise<PrivateHarnessPreflight>;
|
|
60
|
+
run(material: string): Promise<PrivateHarnessExecutionReceiptV2>;
|
|
61
|
+
}
|
|
62
|
+
export interface PrivateHarnessExecutorPortOptions {
|
|
63
|
+
readonly cwd?: string;
|
|
64
|
+
readonly platform?: PrivateHarnessPlatform;
|
|
65
|
+
readonly timeoutMs?: number;
|
|
66
|
+
readonly maxOutputBytes?: number;
|
|
67
|
+
readonly userHome?: string;
|
|
68
|
+
readonly sourceEnv?: NodeJS.ProcessEnv;
|
|
69
|
+
readonly ephemeralBase?: string;
|
|
70
|
+
readonly processRunner?: PrivateHarnessProcessRunner;
|
|
71
|
+
readonly now?: () => number;
|
|
72
|
+
}
|
|
73
|
+
export declare function createPrivateHarnessExecutorPort(hostKind: unknown, options?: PrivateHarnessExecutorPortOptions): PrivateHarnessExecutorPort | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{homedir as E}from"node:os";import{isAbsolute as A,join as f}from"node:path";import{preflightPrivateHarness as u,runPrivateHarness as s}from"../harness-executor.js";import{PRIVATE_CLAUDE_CODE_HARNESS_ADAPTER as _}from"./claude-code.js";import{PRIVATE_CODEX_HARNESS_ADAPTER as R}from"./codex.js";import{PRIVATE_GEMINI_HARNESS_ADAPTER as a}from"./gemini.js";import{PRIVATE_OPENCODE_HARNESS_ADAPTER as m}from"./opencode.js";import{PRIVATE_ANTIGRAVITY_HARNESS_ADAPTER as S}from"./antigravity.js";import{PRIVATE_COPILOT_CLI_HARNESS_ADAPTER as p}from"./copilot-cli.js";import{PRIVATE_CURSOR_HARNESS_DECISION as d}from"./cursor.js";import{PRIVATE_DEEPSEEK_HARNESS_DECISION as l}from"./deepseek.js";import{PRIVATE_GROK_HARNESS_DECISION as P}from"./grok.js";import{PRIVATE_KIMI_HARNESS_ADAPTER as T}from"./kimi.js";import{PRIVATE_OPENCLAW_HARNESS_ADAPTER as I}from"./openclaw.js";const D=10*6e4,O=1024*1024,N=Object.freeze({"claude-code":_,opencode:m,gemini:a,"codex-cli":R}),H=Object.freeze({kimi:T,"github-copilot-cli":p,openclaw:I,antigravity:S});function v(r){if(typeof r=="string"){for(const e of[N,H])if(Object.prototype.hasOwnProperty.call(e,r))return e[r]}}const o=Object.freeze({kind:"adapter"}),g=Object.freeze({kind:"refusal",reasonCode:"private-executor-headless-unavailable"}),c=Object.freeze({"claude-code":o,opencode:o,"codex-cli":o,gemini:o,kimi:o,"github-copilot-cli":o,openclaw:o,antigravity:o,vscode:g,cursor:d,grok:P,deepseek:l});function G(r){if(!(typeof r!="string"||!Object.prototype.hasOwnProperty.call(c,r)))return c[r]}function C(r,e){if(r.credentialFiles.length===0)return;const t=r.credentialSource;if(t===void 0)return;const n=t.env===void 0?void 0:(e.sourceEnv??process.env)[t.env];if(typeof n=="string"&&n.length>0&&A(n))return n;const i=e.userHome??E();return t.homeRelative===""?i:f(i,...t.homeRelative.split("/"))}function X(r,e={}){const t=v(r);if(t===void 0)return;const n=e.cwd??process.cwd();return Object.freeze({hostKind:t.hostKind,preflight:()=>u(t,{cwd:n,platform:e.platform,now:e.now,processRunner:e.processRunner}),run:i=>s(t,i,{cwd:n,platform:e.platform,timeoutMs:e.timeoutMs??D,maxOutputBytes:e.maxOutputBytes??O,credentialSourceDirectory:C(t,e),ephemeralBase:e.ephemeralBase,processRunner:e.processRunner})})}export{N as PRIVATE_HARNESS_ADAPTERS,c as PRIVATE_HARNESS_DECISIONS,H as PRIVATE_HARNESS_EXTENDED_ADAPTERS,X as createPrivateHarnessExecutorPort,v as getPrivateHarnessAdapter,G as resolvePrivateHarnessDecision};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.03 (P229-CON-EXECUTOR, DEC-2/DEC-3): Kimi CLI headless private adapter.
|
|
3
|
+
* Print mode with `--input-format text` reads the material from stdin; argv
|
|
4
|
+
* carries only fixed flags. `HOME` is the ephemeral home, where the declared
|
|
5
|
+
* `.kimi/config.toml` credential is mirrored. `--print` implies auto-approval
|
|
6
|
+
* (R-01), mitigated by the core (ephemeral home, stdin, timeout, env allowlist).
|
|
7
|
+
*/
|
|
8
|
+
import type { PrivateHarnessAdapter } from '../harness-executor.js';
|
|
9
|
+
export declare const PRIVATE_KIMI_HARNESS_ADAPTER: PrivateHarnessAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({hostKind:"kimi",binary:"kimi",fixedArgs:Object.freeze(["--print","--input-format","text","--output-format","text","--final-message-only"]),stdinFlag:null,nativeFlags:Object.freeze([]),configDirEnv:null,configDirEnvs:Object.freeze({HOME:""}),credentialFiles:Object.freeze([".kimi/config.toml"]),credentialSource:Object.freeze({homeRelative:""}),environmentKeys:Object.freeze(["PATH","HOME","LANG","LC_ALL","TERM"]),versionArgs:Object.freeze(["--version"]),versionPattern:/^(?:kimi(?:,\s*version)?\s+)?v?(\d+\.\d+\.\d+)$/,minimumVersion:"0.0.1",platforms:Object.freeze(["linux","darwin","win32"])});export{e as PRIVATE_KIMI_HARNESS_ADAPTER};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.03 (P229-CON-EXECUTOR, DEC-2/DEC-3): OpenClaw headless private adapter.
|
|
3
|
+
* `agent --local` runs embedded (no gateway, no delivery); `--message-file -`
|
|
4
|
+
* is the explicit stdin channel appended last by the core, so argv never
|
|
5
|
+
* carries the material. `HOME` is the ephemeral home. No credential file is
|
|
6
|
+
* copied (A-01: keychain/env).
|
|
7
|
+
*/
|
|
8
|
+
import type { PrivateHarnessAdapter } from '../harness-executor.js';
|
|
9
|
+
export declare const PRIVATE_OPENCLAW_HARNESS_ADAPTER: PrivateHarnessAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({hostKind:"openclaw",binary:"openclaw",fixedArgs:Object.freeze(["agent","--local","--json","--message-file"]),stdinFlag:"-",nativeFlags:Object.freeze([]),configDirEnv:null,configDirEnvs:Object.freeze({HOME:""}),credentialFiles:Object.freeze([]),environmentKeys:Object.freeze(["PATH","HOME","LANG","LC_ALL","TERM"]),versionArgs:Object.freeze(["--version"]),versionPattern:/^(?:openclaw\s+)?v?(\d+\.\d+\.\d+)$/,minimumVersion:"0.0.1",platforms:Object.freeze(["linux","darwin","win32"])});export{e as PRIVATE_OPENCLAW_HARNESS_ADAPTER};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P229.02 (P229-CON-EXECUTOR, AC1): OpenCode headless private adapter.
|
|
3
|
+
* `opencode run` without a positional message reads the material from stdin,
|
|
4
|
+
* so no prompt ever reaches argv. All XDG dirs point under the ephemeral home.
|
|
5
|
+
*/
|
|
6
|
+
import type { PrivateHarnessAdapter } from '../harness-executor.js';
|
|
7
|
+
export declare const PRIVATE_OPENCODE_HARNESS_ADAPTER: PrivateHarnessAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({hostKind:"opencode",binary:"opencode",fixedArgs:Object.freeze(["run","--agent","neocortex-sentinel"]),stdinFlag:null,nativeFlags:Object.freeze([]),configDirEnv:null,configDirEnvs:Object.freeze({XDG_CONFIG_HOME:".config",XDG_DATA_HOME:".local/share",XDG_STATE_HOME:".local/state",XDG_CACHE_HOME:".cache"}),credentialFiles:Object.freeze([".local/share/opencode/auth.json"]),credentialSource:Object.freeze({homeRelative:""}),environmentKeys:Object.freeze(["PATH","HOME","LANG","LC_ALL","TERM"]),versionArgs:Object.freeze(["--version"]),versionPattern:/^(?:opencode\s+)?v?(\d+\.\d+\.\d+)$/,minimumVersion:"1.0.0",platforms:Object.freeze(["linux","darwin","win32"])});export{e as PRIVATE_OPENCODE_HARNESS_ADAPTER};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type PrivateHarnessPlatform } from './harness-process.js';
|
|
2
|
+
export declare const PRIVATE_HARNESS_HOME_PREFIX = ".neocortex-harness-";
|
|
3
|
+
/** `a/b/c/d` with safe segments only; never absolute, `.`, `..`, empty or `\\`. */
|
|
4
|
+
export declare function isSafeHarnessRelativePath(value: unknown): value is string;
|
|
5
|
+
export interface EphemeralHarnessHome {
|
|
6
|
+
/** Local use only: never place this path in receipts or public output. */
|
|
7
|
+
readonly path: string;
|
|
8
|
+
close(): void;
|
|
9
|
+
}
|
|
10
|
+
export interface EphemeralHarnessHomeOptions {
|
|
11
|
+
readonly baseDirectory?: string;
|
|
12
|
+
readonly credentialSourceDirectory?: string;
|
|
13
|
+
readonly credentialFiles?: readonly string[];
|
|
14
|
+
/** P229.02: extra owner-private directories created under the home. */
|
|
15
|
+
readonly directories?: readonly string[];
|
|
16
|
+
readonly platform?: PrivateHarnessPlatform;
|
|
17
|
+
}
|
|
18
|
+
export declare function createEphemeralHarnessHome(options?: EphemeralHarnessHomeOptions): EphemeralHarnessHome;
|
|
19
|
+
export declare function withEphemeralHarnessHome<T>(options: EphemeralHarnessHomeOptions, run: (home: EphemeralHarnessHome) => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{chmodSync as y,closeSync as S,constants as d,fstatSync as w,lstatSync as a,mkdirSync as v,mkdtempSync as g,openSync as x,readFileSync as D,rmSync as O,writeFileSync as _}from"node:fs";import{tmpdir as b}from"node:os";import{join as l}from"node:path";import{resolvePrivateHarnessPlatform as A}from"./harness-process.js";const L=".neocortex-harness-",N=1024*1024,H=/^[A-Za-z0-9._-]{1,64}$/,R=4;function E(e){if(typeof e!="string")return!1;const r=e.split("/");return r.length<1||r.length>R?!1:r.every(o=>H.test(o)&&o!=="."&&o!=="..")}function u(e){return e.split("/")}function s(){throw new Error("private-executor-credential-unavailable")}function T(e){let r;try{r=x(e,d.O_RDONLY|(d.O_NOFOLLOW??0));const o=w(r);(!o.isFile()||o.size<1||o.size>N)&&s();const t=D(r);return(t.length!==o.size||a(e).isSymbolicLink())&&(t.fill(0),s()),t}catch{return s()}finally{r!==void 0&&S(r)}}function F(e,r){const o=u(r);let t=e;for(const n of o.slice(0,-1)){t=l(t,n);try{const i=a(t);(i.isSymbolicLink()||!i.isDirectory())&&s()}catch{s()}}}function p(e,r,o){let t=e;for(const n of u(r)){t=l(t,n);let i=!1;try{try{v(t,{mode:448})}catch(c){if(c.code!=="EEXIST")throw c}const f=a(t);!f.isSymbolicLink()&&f.isDirectory()&&(o!=="win32"&&y(t,448),i=o==="win32"||(a(t).mode&511)===448)}catch{i=!1}if(!i)throw new Error("private-executor-ephemeral-home-unverified")}}function I(e){const r=u(e);return r.length>1?r.slice(0,-1).join("/"):null}function P(e){try{O(e,{recursive:!0,force:!0})}catch{}try{a(e)}catch(r){if(r.code==="ENOENT")return}throw new Error("private-executor-ephemeral-home-residue")}function k(e={}){const r=A(e.platform??process.platform),o=e.credentialFiles??[];for(const c of o)E(c)||s();const t=e.directories??[];for(const c of t)if(!E(c))throw new Error("private-executor-ephemeral-home-unverified");o.length>0&&e.credentialSourceDirectory===void 0&&s();const n=g(l(e.baseDirectory??b(),L));let i=!1;const f=()=>{i||(P(n),i=!0)};try{if(r!=="win32"&&(y(n,448),(a(n).mode&511)!==448))throw new Error("private-executor-ephemeral-home-unverified");for(const c of t)p(n,c,r);for(const c of o){F(e.credentialSourceDirectory,c);const m=T(l(e.credentialSourceDirectory,...u(c)));try{const h=I(c);h!==null&&p(n,h,r);try{_(l(n,...u(c)),m,{mode:384,flag:"wx"})}catch{throw new Error("private-executor-ephemeral-home-unverified")}}finally{m.fill(0)}}}catch(c){throw f(),c}return Object.freeze({path:n,close:f})}async function C(e,r){const o=k(e);let t=!1,n;try{return await r(o)}catch(i){throw t=!0,n=i,i}finally{try{o.close()}catch(i){if(t&&n instanceof Error&&n.cause===void 0)n.cause=i.message;else if(!t)throw i}}}export{L as PRIVATE_HARNESS_HOME_PREFIX,k as createEphemeralHarnessHome,E as isSafeHarnessRelativePath,C as withEphemeralHarnessHome};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { runBoundedHarnessProcess, type BoundedHarnessProcessResult, type PrivateHarnessPlatform } from './harness-process.js';
|
|
2
|
+
export interface PrivateHarnessAdapter {
|
|
3
|
+
readonly hostKind: string;
|
|
4
|
+
readonly binary: string;
|
|
5
|
+
readonly fixedArgs: readonly string[];
|
|
6
|
+
/** Appended last; `null` means the harness reads stdin implicitly. */
|
|
7
|
+
readonly stdinFlag: string | null;
|
|
8
|
+
/** Native non-persistence / sandbox flags. */
|
|
9
|
+
readonly nativeFlags: readonly string[];
|
|
10
|
+
/** Environment variable that points the harness at the ephemeral home. */
|
|
11
|
+
readonly configDirEnv: string | null;
|
|
12
|
+
readonly credentialFiles: readonly string[];
|
|
13
|
+
readonly environmentKeys: readonly string[];
|
|
14
|
+
readonly versionArgs: readonly string[];
|
|
15
|
+
/** Group 1 must capture an `x.y.z` version. */
|
|
16
|
+
readonly versionPattern: RegExp;
|
|
17
|
+
readonly minimumVersion: string;
|
|
18
|
+
readonly platforms: readonly PrivateHarnessPlatform[];
|
|
19
|
+
/**
|
|
20
|
+
* P229.02 (AC-ENV): extra variables -> relative subdirectory of the ephemeral
|
|
21
|
+
* home (`''` = the home itself). Each directory is created owner-private.
|
|
22
|
+
*/
|
|
23
|
+
readonly configDirEnvs?: Readonly<Record<string, string>>;
|
|
24
|
+
/**
|
|
25
|
+
* P229.02 (AC-CRED): where `credentialFiles` are read from: an absolute
|
|
26
|
+
* `env` value when present, else `homeRelative` under the user home.
|
|
27
|
+
*/
|
|
28
|
+
readonly credentialSource?: {
|
|
29
|
+
readonly env?: string;
|
|
30
|
+
readonly homeRelative: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Overrides and directories for every config variable, all under the home. */
|
|
34
|
+
export declare function privateHarnessConfigLayout(adapter: PrivateHarnessAdapter): {
|
|
35
|
+
readonly directories: readonly string[];
|
|
36
|
+
readonly overrides: (homePath: string) => Readonly<Record<string, string>>;
|
|
37
|
+
};
|
|
38
|
+
export type PrivateHarnessOutcome = 'executor-returned-unverified' | 'private-executor-timeout' | 'private-executor-output-exceeded' | 'private-executor-exit-nonzero';
|
|
39
|
+
export interface PrivateHarnessExecutionReceiptV2 {
|
|
40
|
+
readonly schemaVersion: 2;
|
|
41
|
+
readonly kind: 'PrivateHarnessExecutionReceipt/2';
|
|
42
|
+
readonly hostKind: string;
|
|
43
|
+
readonly os: PrivateHarnessPlatform;
|
|
44
|
+
readonly outcome: PrivateHarnessOutcome;
|
|
45
|
+
readonly stdoutSha256: string;
|
|
46
|
+
readonly stderrSha256: string;
|
|
47
|
+
readonly stdoutBytes: number;
|
|
48
|
+
readonly stderrBytes: number;
|
|
49
|
+
readonly publicSafe: true;
|
|
50
|
+
}
|
|
51
|
+
export interface PrivateHarnessPreflight {
|
|
52
|
+
readonly hostKind: string;
|
|
53
|
+
readonly hostVersion: string;
|
|
54
|
+
readonly os: PrivateHarnessPlatform;
|
|
55
|
+
readonly observedAtMs: number;
|
|
56
|
+
}
|
|
57
|
+
export type PrivateHarnessProcessRunner = typeof runBoundedHarnessProcess;
|
|
58
|
+
export declare function buildPrivateHarnessArgv(adapter: PrivateHarnessAdapter): readonly string[];
|
|
59
|
+
export declare function sha256Hex(bytes: Buffer): string;
|
|
60
|
+
export declare function createPrivateHarnessReceipt(input: {
|
|
61
|
+
readonly hostKind: string;
|
|
62
|
+
readonly os: PrivateHarnessPlatform;
|
|
63
|
+
readonly result: BoundedHarnessProcessResult;
|
|
64
|
+
}): PrivateHarnessExecutionReceiptV2;
|
|
65
|
+
export declare function preflightPrivateHarness(adapter: PrivateHarnessAdapter, options: {
|
|
66
|
+
readonly cwd: string;
|
|
67
|
+
readonly platform?: PrivateHarnessPlatform;
|
|
68
|
+
readonly now?: () => number;
|
|
69
|
+
readonly processRunner?: PrivateHarnessProcessRunner;
|
|
70
|
+
}): Promise<PrivateHarnessPreflight>;
|
|
71
|
+
export declare function runPrivateHarness(adapter: PrivateHarnessAdapter, material: string, options: {
|
|
72
|
+
readonly cwd: string;
|
|
73
|
+
readonly platform?: PrivateHarnessPlatform;
|
|
74
|
+
readonly timeoutMs: number;
|
|
75
|
+
readonly maxOutputBytes: number;
|
|
76
|
+
readonly credentialSourceDirectory?: string;
|
|
77
|
+
readonly ephemeralBase?: string;
|
|
78
|
+
readonly processRunner?: PrivateHarnessProcessRunner;
|
|
79
|
+
}): Promise<PrivateHarnessExecutionReceiptV2>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as v}from"node:crypto";import{join as x}from"node:path";import{isSafeHarnessRelativePath as y,withEphemeralHarnessHome as h}from"./harness-ephemeral-home.js";import{assertPrivateHarnessMaterial as p,resolvePrivateHarnessPlatform as f,runBoundedHarnessProcess as d}from"./harness-process.js";const b=16*1024,O=5e3,l=/^(\d+)\.(\d+)\.(\d+)$/;function g(e){const t=Object.entries(e.configDirEnvs??{});for(const[r,o]of t)if(r.length===0||r===e.configDirEnv||o!==""&&!y(o))throw new Error("private-executor-ephemeral-home-unverified");return Object.freeze({directories:Object.freeze(t.map(([,r])=>r).filter(r=>r!=="")),overrides:r=>{const o={};e.configDirEnv!==null&&(o[e.configDirEnv]=r);for(const[n,s]of t)o[n]=s===""?r:x(r,...s.split("/"));return Object.freeze(o)}})}function E(e){return Object.freeze([...e.fixedArgs,...e.nativeFlags,...e.stdinFlag===null?[]:[e.stdinFlag]])}function a(e){return v("sha256").update(e).digest("hex")}function w(e){return e.timedOut?"private-executor-timeout":e.outputExceeded?"private-executor-output-exceeded":e.exitCode===0?"executor-returned-unverified":"private-executor-exit-nonzero"}function H(e){const{result:t}=e;return Object.freeze({schemaVersion:2,kind:"PrivateHarnessExecutionReceipt/2",hostKind:e.hostKind,os:f(e.os),outcome:w(t),stdoutSha256:a(t.stdout),stderrSha256:a(t.stderr),stdoutBytes:t.stdout.byteLength,stderrBytes:t.stderr.byteLength,publicSafe:!0})}function P(e,t){const r=l.exec(e),o=l.exec(t);if(!r||!o)return null;for(let n=1;n<=3;n+=1){const s=Number(r[n])-Number(o[n]);if(s!==0)return s}return 0}function m(e,t){const r=f(t??process.platform);if(!e.platforms.includes(r))throw new Error("private-executor-platform-unsupported");return r}async function M(e,t){const r=m(e,t.platform),n=await(t.processRunner??d)(e.binary,e.versionArgs,{cwd:t.cwd,timeoutMs:O,maxOutputBytes:b,environmentKeys:e.environmentKeys,platform:r});try{const i=n.exitCode===0&&!n.timedOut&&!n.outputExceeded?e.versionPattern.exec(n.stdout.toString("utf8").trim())?.[1]:void 0,u=i===void 0?null:P(i,e.minimumVersion);if(i===void 0||u===null||u<0)throw new Error("private-executor-version-unsupported");return Object.freeze({hostKind:e.hostKind,hostVersion:i,os:r,observedAtMs:(t.now??Date.now)()})}finally{n.stdout.fill(0),n.stderr.fill(0)}}async function R(e,t,r){p(t);const o=m(e,r.platform),n=r.processRunner??d,s=g(e);return h({baseDirectory:r.ephemeralBase,credentialSourceDirectory:r.credentialSourceDirectory,credentialFiles:e.credentialFiles,directories:s.directories,platform:o},async i=>{const u=s.overrides(i.path),c=await n(e.binary,E(e),{cwd:r.cwd,stdin:t,timeoutMs:r.timeoutMs,maxOutputBytes:r.maxOutputBytes,environmentKeys:e.environmentKeys,platform:o,environmentOverrides:Object.keys(u).length===0?void 0:u});try{return H({hostKind:e.hostKind,os:o,result:c})}finally{c.stdout.fill(0),c.stderr.fill(0)}})}export{E as buildPrivateHarnessArgv,H as createPrivateHarnessReceipt,M as preflightPrivateHarness,g as privateHarnessConfigLayout,R as runPrivateHarness,a as sha256Hex};
|