@ornexus/neocortex 4.59.1 → 4.59.4
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/sbom.cdx.json +19 -19
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +2 -2
- package/packages/client/dist/commands/invoke.d.ts +47 -0
- package/packages/client/dist/commands/invoke.js +30 -28
- package/packages/client/dist/continuity/invoke-hooks.d.ts +1 -0
- package/packages/client/dist/continuity/invoke-hooks.js +1 -1
- package/packages/client/dist/continuity/runner-bootstrap-policy.d.ts +50 -0
- package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -0
- package/packages/client/dist/continuity/sqlite-store.d.ts +5 -2
- package/packages/client/dist/continuity/sqlite-store.js +16 -16
- package/packages/client/dist/runner/binary.d.ts +68 -0
- package/packages/client/dist/runner/binary.js +1 -0
- package/packages/client/dist/runner/cli.d.ts +2 -13
- package/packages/client/dist/runner/cli.js +10 -10
- package/packages/client/dist/runner/scheduler.d.ts +70 -0
- package/packages/client/dist/runner/scheduler.js +7 -6
- package/packages/client/dist/state/state-json-repair.js +3 -3
- 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.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/opencode/neocortex-root.md +1 -1
- package/targets-stubs/vscode/neocortex.agent.md +2 -2
package/dist/sbom.cdx.json
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"bomFormat": "CycloneDX",
|
|
4
4
|
"specVersion": "1.5",
|
|
5
5
|
"version": 1,
|
|
6
|
-
"serialNumber": "urn:uuid:
|
|
6
|
+
"serialNumber": "urn:uuid:6fc05a3f-c761-4fca-bbb4-d8ad50c4f3e7",
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-06-
|
|
8
|
+
"timestamp": "2026-06-24T05:21:07.061Z",
|
|
9
9
|
"tools": {
|
|
10
10
|
"components": [
|
|
11
11
|
{
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"type": "application",
|
|
84
84
|
"name": "neocortex",
|
|
85
85
|
"group": "@ornexus",
|
|
86
|
-
"version": "4.59.
|
|
87
|
-
"bom-ref": "@ornexus/neocortex@4.59.
|
|
86
|
+
"version": "4.59.4",
|
|
87
|
+
"bom-ref": "@ornexus/neocortex@4.59.4",
|
|
88
88
|
"author": "OrNexus Team",
|
|
89
|
-
"description": "Neocortex v4.59.
|
|
89
|
+
"description": "Neocortex v4.59.4 - Orquestrador de Desenvolvimento de Epics & Stories para Claude Code",
|
|
90
90
|
"licenses": [
|
|
91
91
|
{
|
|
92
92
|
"license": {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
],
|
|
97
|
-
"purl": "pkg:npm/%40ornexus/neocortex@4.59.
|
|
97
|
+
"purl": "pkg:npm/%40ornexus/neocortex@4.59.4?vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2FOrNexus-AI%2Fneocortex.git",
|
|
98
98
|
"externalReferences": [
|
|
99
99
|
{
|
|
100
100
|
"url": "git+https://github.com/OrNexus-AI/neocortex.git",
|
|
@@ -3819,9 +3819,9 @@
|
|
|
3819
3819
|
"type": "library",
|
|
3820
3820
|
"name": "client",
|
|
3821
3821
|
"group": "@neocortex",
|
|
3822
|
-
"version": "4.59.
|
|
3823
|
-
"bom-ref": "@neocortex/client@4.59.
|
|
3824
|
-
"purl": "pkg:npm/%40neocortex/client@4.59.
|
|
3822
|
+
"version": "4.59.4",
|
|
3823
|
+
"bom-ref": "@neocortex/client@4.59.4",
|
|
3824
|
+
"purl": "pkg:npm/%40neocortex/client@4.59.4",
|
|
3825
3825
|
"properties": [
|
|
3826
3826
|
{
|
|
3827
3827
|
"name": "cdx:npm:package:path",
|
|
@@ -3837,9 +3837,9 @@
|
|
|
3837
3837
|
"type": "library",
|
|
3838
3838
|
"name": "shared",
|
|
3839
3839
|
"group": "@neocortex",
|
|
3840
|
-
"version": "4.59.
|
|
3841
|
-
"bom-ref": "@neocortex/shared@4.59.
|
|
3842
|
-
"purl": "pkg:npm/%40neocortex/shared@4.59.
|
|
3840
|
+
"version": "4.59.4",
|
|
3841
|
+
"bom-ref": "@neocortex/shared@4.59.4",
|
|
3842
|
+
"purl": "pkg:npm/%40neocortex/shared@4.59.4",
|
|
3843
3843
|
"properties": [
|
|
3844
3844
|
{
|
|
3845
3845
|
"name": "cdx:npm:package:path",
|
|
@@ -6222,13 +6222,13 @@
|
|
|
6222
6222
|
],
|
|
6223
6223
|
"dependencies": [
|
|
6224
6224
|
{
|
|
6225
|
-
"ref": "@ornexus/neocortex@4.59.
|
|
6225
|
+
"ref": "@ornexus/neocortex@4.59.4",
|
|
6226
6226
|
"dependsOn": [
|
|
6227
6227
|
"@clack/prompts@1.0.1",
|
|
6228
6228
|
"@modelcontextprotocol/sdk@1.26.0",
|
|
6229
|
-
"@neocortex/client@4.59.
|
|
6229
|
+
"@neocortex/client@4.59.4",
|
|
6230
6230
|
"@neocortex/core@0.1.0",
|
|
6231
|
-
"@neocortex/shared@4.59.
|
|
6231
|
+
"@neocortex/shared@4.59.4",
|
|
6232
6232
|
"better-sqlite3@12.11.1",
|
|
6233
6233
|
"execa@9.6.1",
|
|
6234
6234
|
"node-cache@5.1.2",
|
|
@@ -6765,16 +6765,16 @@
|
|
|
6765
6765
|
"ref": "zod@4.3.6"
|
|
6766
6766
|
},
|
|
6767
6767
|
{
|
|
6768
|
-
"ref": "@neocortex/client@4.59.
|
|
6768
|
+
"ref": "@neocortex/client@4.59.4",
|
|
6769
6769
|
"dependsOn": [
|
|
6770
|
-
"@neocortex/shared@4.59.
|
|
6770
|
+
"@neocortex/shared@4.59.4",
|
|
6771
6771
|
"better-sqlite3@12.11.1",
|
|
6772
6772
|
"jose@6.2.2",
|
|
6773
6773
|
"keytar@7.9.0"
|
|
6774
6774
|
]
|
|
6775
6775
|
},
|
|
6776
6776
|
{
|
|
6777
|
-
"ref": "@neocortex/shared@4.59.
|
|
6777
|
+
"ref": "@neocortex/shared@4.59.4"
|
|
6778
6778
|
},
|
|
6779
6779
|
{
|
|
6780
6780
|
"ref": "better-sqlite3@12.11.1",
|
|
@@ -6813,7 +6813,7 @@
|
|
|
6813
6813
|
{
|
|
6814
6814
|
"ref": "@neocortex/core@0.1.0",
|
|
6815
6815
|
"dependsOn": [
|
|
6816
|
-
"@neocortex/shared@4.59.
|
|
6816
|
+
"@neocortex/shared@4.59.4"
|
|
6817
6817
|
]
|
|
6818
6818
|
},
|
|
6819
6819
|
{
|
package/install.ps1
CHANGED
package/install.sh
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ornexus/neocortex",
|
|
3
|
-
"version": "4.59.
|
|
4
|
-
"description": "Neocortex v4.59.
|
|
3
|
+
"version": "4.59.4",
|
|
4
|
+
"description": "Neocortex v4.59.4 - Orquestrador de Desenvolvimento de Epics & Stories para Claude Code",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
|
7
7
|
"claude-code",
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* See the LICENSE file in the project root for full license text.
|
|
12
12
|
*/
|
|
13
13
|
import type { YoloopPersistedState } from '../yoloop/shared-yoloop-types.js';
|
|
14
|
+
import { type RunnerBootstrapPolicyDecision } from '../continuity/runner-bootstrap-policy.js';
|
|
15
|
+
import { type RunnerSchedulerBootstrapOptions, type RunnerSchedulerBootstrapResult } from '../runner/scheduler.js';
|
|
14
16
|
export declare const INVOKE_PAYLOAD_WARNING_THRESHOLD_BYTES: number;
|
|
15
17
|
interface InitProjectMemoryBootstrapSnapshot {
|
|
16
18
|
readonly canonical: {
|
|
@@ -45,6 +47,10 @@ export interface InvokeOptions {
|
|
|
45
47
|
readonly platformTarget?: string;
|
|
46
48
|
/** CLI input source, used to decide when stdin/args-file need chunk transport. */
|
|
47
49
|
readonly inputSource?: InvokeCliInputSource;
|
|
50
|
+
/** Test/integration seam for runner auto-bootstrap; CLI callers leave unset. */
|
|
51
|
+
readonly runnerBootstrapper?: InvokeRunnerSchedulerBootstrapper;
|
|
52
|
+
/** Test/integration seam for recursion guard env; CLI callers leave unset. */
|
|
53
|
+
readonly environment?: NodeJS.ProcessEnv;
|
|
48
54
|
}
|
|
49
55
|
/**
|
|
50
56
|
* Normalize the project root received from wrappers/CLI flags.
|
|
@@ -66,6 +72,40 @@ export interface InvokeResult {
|
|
|
66
72
|
readonly errorCode?: string;
|
|
67
73
|
readonly exitCode: number;
|
|
68
74
|
}
|
|
75
|
+
export interface InvokeRunnerBootstrapMetadata {
|
|
76
|
+
readonly schemaVersion: 1;
|
|
77
|
+
readonly action: RunnerBootstrapPolicyDecision['action'];
|
|
78
|
+
readonly failurePolicy: RunnerBootstrapPolicyDecision['failurePolicy'];
|
|
79
|
+
readonly command: RunnerBootstrapPolicyDecision['command'];
|
|
80
|
+
readonly operation: RunnerBootstrapPolicyDecision['operation'];
|
|
81
|
+
readonly attempted: boolean;
|
|
82
|
+
readonly ok: boolean;
|
|
83
|
+
readonly cached: boolean;
|
|
84
|
+
readonly installed: boolean;
|
|
85
|
+
readonly started: boolean;
|
|
86
|
+
readonly projectKey?: string;
|
|
87
|
+
readonly reasonCodes: readonly string[];
|
|
88
|
+
readonly publicSummary: string;
|
|
89
|
+
readonly failOpenWarning?: boolean;
|
|
90
|
+
readonly publicSafe: true;
|
|
91
|
+
}
|
|
92
|
+
export interface InvokeRunnerAutoBootstrapResult {
|
|
93
|
+
readonly shouldContinue: boolean;
|
|
94
|
+
readonly attachToRequest: boolean;
|
|
95
|
+
readonly metadata: InvokeRunnerBootstrapMetadata;
|
|
96
|
+
readonly warning?: string;
|
|
97
|
+
readonly error?: string;
|
|
98
|
+
readonly errorCode?: string;
|
|
99
|
+
readonly exitCode?: number;
|
|
100
|
+
}
|
|
101
|
+
export type InvokeRunnerSchedulerBootstrapper = (options: RunnerSchedulerBootstrapOptions) => Promise<RunnerSchedulerBootstrapResult>;
|
|
102
|
+
export interface InvokeRunnerAutoBootstrapOptions {
|
|
103
|
+
readonly args: string;
|
|
104
|
+
readonly projectRoot: string;
|
|
105
|
+
readonly platformTarget: string;
|
|
106
|
+
readonly environment?: NodeJS.ProcessEnv;
|
|
107
|
+
readonly bootstrapper?: InvokeRunnerSchedulerBootstrapper;
|
|
108
|
+
}
|
|
69
109
|
export declare function sanitizeInvokeCliOutput(instructions: string | undefined, metadata: Record<string, unknown> | undefined): {
|
|
70
110
|
instructions: string;
|
|
71
111
|
metadata: Record<string, unknown> | undefined;
|
|
@@ -146,6 +186,12 @@ export interface StateSnapshot {
|
|
|
146
186
|
* decides workflow locally and is omitted when disabled or unavailable.
|
|
147
187
|
*/
|
|
148
188
|
readonly graphRetrieval?: unknown;
|
|
189
|
+
/**
|
|
190
|
+
* P181.04 -- request-only runner auto-bootstrap summary. Public-safe only;
|
|
191
|
+
* never persisted to `.neocortex/state.json` and omitted for unrelated
|
|
192
|
+
* non-continuity commands.
|
|
193
|
+
*/
|
|
194
|
+
readonly runnerBootstrap?: InvokeRunnerBootstrapMetadata;
|
|
149
195
|
}
|
|
150
196
|
export interface InvokeArgsRef {
|
|
151
197
|
readonly manifestId: string;
|
|
@@ -195,6 +241,7 @@ export declare function collectStateSnapshot(projectRoot: string): StateSnapshot
|
|
|
195
241
|
export declare function createFullStateSnapshotScope(trigger: string, snapshot: Pick<StateSnapshot, 'stories' | 'epics'>): FullStateSnapshotScope;
|
|
196
242
|
export declare function computeInvokeRequestBodySizeBytes(body: InvokeRequestBody): number;
|
|
197
243
|
export declare function maybeEmitInvokePayloadSizeWarning(body: InvokeRequestBody): number;
|
|
244
|
+
export declare function maybeRunInvokeRunnerAutoBootstrap(options: InvokeRunnerAutoBootstrapOptions): Promise<InvokeRunnerAutoBootstrapResult>;
|
|
198
245
|
/**
|
|
199
246
|
* Execute the invoke command.
|
|
200
247
|
*
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import{createHash as
|
|
1
|
+
import{createHash as $}from"node:crypto";import{existsSync as C,readFileSync as N,unlinkSync as se,writeFileSync as ie,mkdirSync as ae,statSync as ce}from"node:fs";import{join as E}from"node:path";import{homedir as k}from"node:os";import{LicenseClient as ue}from"../license/license-client.js";import{EncryptedCache as U}from"../cache/encrypted-cache.js";import{NoOpCache as de}from"../types/index.js";import{resolveClientPreFlightTrigger as le,TierAwareClient as pe}from"../tier/tier-aware-client.js";import{loadSecureConfig as fe}from"../config/secure-config.js";import{DEFAULT_SERVER_URL as me}from"../constants.js";import{detectFirstRunLocale as ge,renderFirstRunMessage as he}from"../i18n/first-run.js";import{humanizeError as F,formatHumanizedError as M,detectErrorLocale as j}from"../errors/error-messages.js";import{projectStateSnapshotForInvoke as _e}from"../state/project-state-snapshot.js";import{maybeRepairStateJsonBeforeInvoke as ye,StateRepairHardStopError as Ee}from"../state/state-json-repair.js";import{bootstrapArchitectureMemory as Se}from"../memory/project-memory-writer.js";import{RUNNER_BOOTSTRAP_POLICY_REASON_CODES as we,classifyRunnerBootstrapPolicyFromArgs as Re}from"../continuity/runner-bootstrap-policy.js";import{RUNNER_SCHEDULER_BOOTSTRAP_REASON_CODES as Ce,ensureRunnerSchedulerBootstrap as Te}from"../runner/scheduler.js";const I=E(k(),".neocortex"),B=E(I,"cache"),Y=E(B,"menu-cache.json"),K=1440*60*1e3,z=3e4,S="3.9.62",V=256*1024,Ae=.8,R="[REDACTED]",Ne=1e5,O=2e3,Ie=200,Oe=200,be=12,ke=/(?:promptBody|workflow|workflowGraph|stepBody|privateUrl|rawLog|secret|credential|licenseKey|apiKey|internalRouting|serverOnly|proprietary|protected)/i,xe=/(?:PRIVATE|PROTECTED|SERVER_ONLY)[-_\s]*(?:PROMPT|PROMPT_BODY|WORKFLOW|WORKFLOW_GRAPH|STEP_BODY|STEP|ROUTING)\s*[:=][^\n\r]*/gi,H=Math.floor(V*Ae),G=E(I,".first-run-shown"),Pe="<!-- NEOCORTEX-MEMORY-START -->";function De(e){return/^\s*\*?init(?:\s|$)/i.test(e)}function ve(e){const t=E(e,"NEOCORTEX.md"),r=C(t)?N(t,"utf8"):void 0,o=r===void 0?["missing_canonical_memory"]:[r.includes(Pe)?void 0:"missing_managed_memory_block",r.length>18e3?"canonical_memory_over_budget":void 0,/api[-_ ]?key|license[-_ ]?key|password\s*[:=]|secret\s*[:=]/i.test(r)?"possible_secret_shape_detected":void 0].filter(u=>!!u),a=["AGENTS.md","CLAUDE.md","GEMINI.md",".opencode/AGENTS.md",".cursor/rules/neocortex.mdc",".github/copilot-instructions.md"].filter(u=>C(E(e,u))),c=o.includes("possible_secret_shape_detected")?"low":o.length===0?"high":a.length>0?"medium":"low",l=Se(e);return{canonical:{path:"NEOCORTEX.md",exists:r!==void 0,incompleteReasons:o,confidence:c},permittedSources:{packageBuildFiles:l.repositoryMap?.find(u=>u.startsWith("Package/build files:"))?.split(",").length??0,architectureReadmeDocs:l.architectureReferences?.length??0,runtimeConfigTemplates:l.environmentPractices?.[0]?.startsWith("Runtime/config templates:")?l.environmentPractices[0].split(",").length:0,platformWrappers:a.length},wrapperFiles:a,recommendedPreviewCommand:'neocortex-client refresh-memory --dry-run --project-root "$PROJECT_ROOT"',recommendedRefreshCommand:'neocortex-client refresh-memory --project-root "$PROJECT_ROOT"',guardrails:["Use only permitted bootstrap sources; never read real .env files or credentials into memory.","Preserve human-authored wrapper content outside Neocortex managed blocks.","Do not reset .neocortex/state.json or depend on legacy planning.current during init bootstrap."]}}function Le(){try{if(C(G))return;const e=ge(),t=he(e);process.stderr.write(t);try{ae(I,{recursive:!0}),ie(G,new Date().toISOString(),"utf-8")}catch{}}catch{}}function $e(e,t=process.cwd()){return e&&e.trim().length>0?e:t}function Ue(e){return e.replace(/[\w.+-]+@[\w-]+\.[\w.-]+/g,R).replace(/(?:sk|pk|whsec|nxk)[-_](?:test|live|ant|proj|pro|free|enterprise)?[-_]?[A-Za-z0-9_-]{16,}/g,R).replace(/NX-[FPE]-[a-f0-9]{24}-[a-f0-9]{4}/g,R).replace(/eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,R).replace(xe,R)}function T(e,t){const r=Ue(e);return r.length<=t?r:`${r.slice(0,t)}\u2026[TRUNCATED:${r.length-t}]`}function x(e,t=0,r=new WeakSet){if(t>be)return"[MAX_DEPTH]";if(e==null)return e;if(typeof e=="string")return T(e,O);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean")return e;if(typeof e=="bigint")return String(e);if(typeof e=="function"||typeof e=="symbol"||typeof e!="object")return;if(r.has(e))return"[CIRCULAR]";if(r.add(e),Array.isArray(e))return e.slice(0,Ie).map(i=>x(i,t+1,r));const o={};for(const[i,a]of Object.entries(e).slice(0,Oe)){if(ke.test(i)){o[i]=R;continue}const c=x(a,t+1,r);c!==void 0&&(o[i]=c)}return o}function P(e,t){return{instructions:T(e??"",Ne),metadata:t?x(t):void 0}}class y extends Error{code;constructor(t,r){super(r),this.name="InvokeCliInputError",this.code=t}}let D=!1;function Fe(e){const t=[];if(!e||typeof e!="object")return t;const r=e,o=r.planning;if(o&&(o.current!==void 0||Array.isArray(o.history))&&t.push({code:"PLANNING_LEGACY",message:"legacy `planning.current`/`planning.history` detected (not read by v1 orchestrator)"}),Array.isArray(r.stories)&&t.push({code:"STORIES_AS_ARRAY",message:"`stories` is an Array (expected Object keyed by story ID)"}),r.epics&&typeof r.epics=="object"&&!Array.isArray(r.epics))for(const[a,c]of Object.entries(r.epics)){const l=c;if(l&&l.stories!==void 0&&!Array.isArray(l.stories)){t.push({code:"EPIC_STORIES_NOT_ARRAY",message:`epic "${a}" has non-array \`stories\` field (expected string[] of story IDs)`});break}}const i=r.epics&&typeof r.epics=="object"&&Object.keys(r.epics).length>0||r.stories&&typeof r.stories=="object"&&!Array.isArray(r.stories)&&Object.keys(r.stories).length>0||Array.isArray(r.stories)||o&&o.current!==void 0;return r.schema_version===void 0?i&&t.push({code:"SCHEMA_VERSION_MISSING",message:"`schema_version` field missing (expected: `schema_version: 1`)"}):r.schema_version!==1&&t.push({code:"SCHEMA_VERSION_OUTDATED",message:`schema_version=${String(r.schema_version)} (expected: 1)`}),t}function Me(e){if(!(D||e.length===0)){D=!0;try{const t=e.map(r=>` - ${r.message}`).join(`
|
|
2
2
|
`);process.stderr.write(`[Neocortex] state.json schema drift detected:
|
|
3
3
|
${t}
|
|
4
4
|
Run \`neocortex *migrate-state --preview\` to inspect or \`neocortex *migrate-state --apply\` to migrate.
|
|
5
5
|
See docs/arquitetura-software/STATE-JSON-SCHEMA.md for the schema contract.
|
|
6
|
-
`)}catch{}}}function
|
|
7
|
-
`),r=new
|
|
8
|
-
`),t}async function
|
|
9
|
-
[Neocortex] ${
|
|
6
|
+
`)}catch{}}}function At(){D=!1}function q(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function je(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Be(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function b(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0}function w(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/[^a-z0-9_.:-]+/gi,"_").slice(0,120)}function v(e,t){if(!Be(e))return;const r={};for(const o of t){const i=e[o];if(typeof i=="boolean")r[o]=i;else if(typeof i=="number"&&Number.isFinite(i))r[o]=i;else if(typeof i=="string"){const a=w(i);a&&(r[o]=a)}}return Object.keys(r).length>0?r:void 0}function Ye(e){const t=v(e.completionEvidence??e.completion_evidence,["prNumber","pr_number","prState","pr_state","pullRequestState","merged","mergedAt","issueNumber","issue_number","issueState","issue_state","closedAt"]),r=v(e.issueCloseAudit??e.issue_close_audit,["schema_version","event","storyId","epicId","issueNumber","closedAt","publicSafe","rawLogStorage"]),o=v(e.scopedCiEvidence??e.scoped_ci_evidence,["schema_version","storyId","epicId","prNumber","finalState","publicSafe","rawLogStorage"]);return{...typeof e.merged=="boolean"?{merged:e.merged}:{},...typeof e.safeToContinueYoloop=="boolean"?{safeToContinueYoloop:e.safeToContinueYoloop}:{},...typeof e.mergeBlockedRemotely=="boolean"?{mergeBlockedRemotely:e.mergeBlockedRemotely}:{},...w(e.physicalMergeStatus)?{physicalMergeStatus:w(e.physicalMergeStatus)}:{},...w(e.pr_state??e.prState??e.pull_request_state??e.pullRequestState)?{pr_state:w(e.pr_state??e.prState??e.pull_request_state??e.pullRequestState)}:{},...w(e.issue_state??e.issueState??e.workflow_issue_state)?{issue_state:w(e.issue_state??e.issueState??e.workflow_issue_state)}:{},...b(e.issue_number??e.issueNumber)?{issue_number:b(e.issue_number??e.issueNumber)}:{},...t?{completionEvidence:t}:{},...r?{issueCloseAudit:r}:{},...o?{scopedCiEvidence:o}:{}}}function Ke(e){const t=E(e,".neocortex","state.json");if(!C(t))return{config:{project_name:"unknown",default_branch:"main",language:"pt-BR"},stories:{},epics:{}};let r;try{const u=N(t,"utf-8");r=JSON.parse(u)}catch{return{config:{project_name:"unknown",default_branch:"main",language:"pt-BR"},stories:{},epics:{}}}try{const u=Fe(r);u.length>0&&Me(u)}catch{}const o=r.config??r.project??{},i=r.stories??{},a={};for(const[u,d]of Object.entries(i))a[u]={id:d.id??u,title:d.title,epic_id:d.epic_id,status:d.status??"backlog",steps_completed:d.steps_completed??[],last_step:d.last_step??null,branch_name:d.branch_name??null,pr_number:d.pr_number,...b(d.workflow_issue)?{workflow_issue:b(d.workflow_issue)}:{},...Ye(d),depends_on:q(d.depends_on),files_to_modify:je(d.files_to_modify),risk:typeof d.risk=="string"?d.risk:void 0,blast_radius:typeof d.blast_radius=="number"?d.blast_radius:void 0};const c=r.epics??{},l={};for(const[u,d]of Object.entries(c))l[u]={id:d.id??u,title:d.title,status:d.status,stories:d.stories,total_stories:d.total_stories,completed_stories:d.completed_stories,depends_on:q(d.depends_on)};return{schema_version:typeof r.schema_version=="number"?r.schema_version:void 0,config:{project_name:o.project_name??o.name??"unknown",default_branch:o.default_branch??"main",language:o.language??"pt-BR",yolo_mode:o.yolo_mode,user_name:o.user_name,worktree_base:o.worktree_base,max_parallel_stories:o.max_parallel_stories},stories:a,epics:l}}function Nt(e,t){return{kind:"full",trigger:e,targetEpicId:null,targetStoryId:null,includedStoryCount:Object.keys(t.stories).length,omittedStoryCount:0,omittedEpicCount:0,reason:"full-state"}}const J="neocortex:menu:cache";async function ze(e){try{const t=await e.get(J);if(!t)return null;const r=JSON.parse(t);return r.version!==S||Date.now()-r.cachedAt>K?null:r}catch{return null}}async function Ve(e,t,r){try{const o={instructions:t,metadata:r,cachedAt:Date.now(),version:S};await e.set(J,JSON.stringify(o),K),He()}catch{}}function He(){try{C(Y)&&se(Y)}catch{}}function Ge(){return fe()}async function qe(e,t){try{let r;if(t){const c=E(I,"cache");r=new U({cacheDir:c,passphrase:t})}else process.stderr.write(`[neocortex] Warning: No license key in config. Run "neocortex activate" to re-authenticate.
|
|
7
|
+
`),r=new de;const o=new ue({serverUrl:e,licenseKey:t??"",cacheProvider:r}),i=await o.getToken();if(!i)return null;const a=new pe({cacheProvider:r,licenseClient:o});return{token:i,client:o,tierClient:a}}catch{return null}}let W=!1;function X(e){return $("sha256").update(e).digest("hex")}function Je(){const e=Number(process.env.NEOCORTEX_INVOKE_CHUNK_BYTES??"49152");return Number.isFinite(e)&&e>=1024&&e<=98304?Math.floor(e):49152}function We(e,t,r){return`args-${$("sha256").update("invoke-materialization:v1").update(e).update(String(t)).update(JSON.stringify(r)).digest("hex")}`}async function Q(e,t,r,o){const i=await fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,"X-Client-Version":S},body:JSON.stringify(r)}),a=await i.text().catch(()=>""),c=(()=>{try{return a?JSON.parse(a):{}}catch{return{}}})();if(!i.ok){const l=typeof c.error_code=="string"?c.error_code:`HTTP_${i.status}`,u=typeof c.message=="string"?c.message:"materialization upload failed";throw new Error(`${l}: ${u}`)}return c}async function Xe(e,t,r){const o=Buffer.from(t,"utf8"),i=Je(),a=[];for(let f=0,h=0;f<o.byteLength;f+=i,h++){const _=o.subarray(f,Math.min(f+i,o.byteLength));a.push({index:h,sha256:X(_),byteLength:_.byteLength})}const c=X(o),l=We(c,o.byteLength,a),u=Number(process.env.NEOCORTEX_INVOKE_CHUNK_TTL_SECONDS??"900");for(const f of a){const h=f.index*i,_=o.subarray(h,h+f.byteLength);await Q(e,"/api/v1/invoke/materialization/chunks",{manifestId:l,index:f.index,sha256:f.sha256,byteLength:f.byteLength,contentBase64:_.toString("base64"),ttlSeconds:u,idempotencyKey:`${l}:${f.index}:${f.sha256}`},r)}const m=(await Q(e,"/api/v1/invoke/materialization/manifests",{manifestId:l,sha256:c,byteLength:o.byteLength,chunkCount:a.length,chunks:a,ttlSeconds:u,retry:{attempt:1,budget:3,idempotencyKey:l}},r)).argsRef;if(!m?.manifestId)throw new Error("MATERIALIZATION_RESPONSE_INVALID: missing argsRef");return{argsRef:m,chunks:a}}function Qe(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Ze(e){return re(e)??e.trim().split(/\s+/,1)[0]?.slice(0,80)??"(empty)"}function et(e){return e.args!==void 0?Ze(e.args):`argsRef:${e.argsRef.manifestId.slice(0,80)}`}function Z(e){const t=Qe(e);if(t<H)return t;const r=e.stateSnapshot.scope,o=Object.keys(e.stateSnapshot.stories).length,i=r?.kind??"full",a=r?.includedStoryCount??o,c=r?.omittedStoryCount??0;return process.stderr.write(`[Neocortex] invoke payload near server limit: trigger=${et(e)} scope=${i} bytes=${t} limit=${V} includedStories=${a} omittedStories=${c}
|
|
8
|
+
`),t}async function tt(e){const t=Re(e.args,{platformTarget:e.platformTarget,environment:e.environment??process.env});if(t.action==="skipped")return{shouldContinue:!0,attachToRequest:rt(t),metadata:ee(t)};const r=e.bootstrapper??Te;let o;try{o=await r({projectRoot:e.projectRoot,env:e.environment??process.env})}catch{o={ok:!1,attempted:!0,installed:!1,started:!1,cached:!1,projectKey:"unknown",reasonCodes:[Ce.UNEXPECTED_ERROR],publicSummary:"runner scheduler bootstrap stopped unexpectedly.",publicSafe:!0}}const i=ee(t,o);if(o.ok)return{shouldContinue:!0,attachToRequest:!0,metadata:i};const a=i.reasonCodes.slice(0,5).join(",");return t.failurePolicy==="fail-open"?{shouldContinue:!0,attachToRequest:!0,metadata:{...i,failOpenWarning:!0},warning:`Runner auto-bootstrap warning (${a}); continuing fail-open for operator command.`}:{shouldContinue:!1,attachToRequest:!1,metadata:i,errorCode:"RUNNER_BOOTSTRAP_REQUIRED_FAILED",error:`Runner auto-bootstrap required but failed (${a}). Run neocortex-runner doctor or retry after resolving scheduler setup.`,exitCode:1}}function rt(e){return!e.reasonCodes.includes(we.SKIPPED_NON_CONTINUITY_COMMAND)}function ee(e,t){return{schemaVersion:1,action:e.action,failurePolicy:e.failurePolicy,command:e.command,operation:e.operation,attempted:t?.attempted??!1,ok:t?.ok??!0,cached:t?.cached??!1,installed:t?.installed??!1,started:t?.started??!1,...t?.projectKey?{projectKey:t.projectKey}:{},reasonCodes:nt([...e.reasonCodes,...t?.reasonCodes??[]]),publicSummary:t?.publicSummary??e.publicSummary,publicSafe:!0}}function nt(e){return Array.from(new Set(e.map(t=>t.slice(0,120))))}async function te(e,t,r){const o=`${e}/api/v1/invoke`,i=new AbortController,a=setTimeout(()=>i.abort(),z);try{const c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`,"X-Client-Version":S},body:JSON.stringify(t),signal:i.signal});if(clearTimeout(a),!c.ok){const d=await c.text().catch(()=>"Unknown error");let m;try{m=JSON.parse(d)}catch{}return{ok:!1,status:c.status,error:m?`${m.error_code??"ERROR"}: ${m.message??d}`:`HTTP ${c.status}: ${d}`,errorBody:m}}const l=await c.json(),u=c.headers.get("X-Client-Version-Warning");return u&&!W&&(W=!0,process.stderr.write(`
|
|
9
|
+
[Neocortex] ${u}
|
|
10
10
|
|
|
11
|
-
`)),{ok:!0,status:
|
|
11
|
+
`)),{ok:!0,status:c.status,data:l}}catch(c){clearTimeout(a);const l=c instanceof Error?c.message:String(c);return{ok:!1,status:0,error:l.includes("abort")?`Request timeout after ${z/1e3}s`:`Network error: ${l}`}}}async function ot(e){const t=$e(e.projectRoot),r=e.platformTarget??"claude-code";Le();const o=Ge(),i=(e.serverUrl??o?.serverUrl??me).replace(/\/+$/,"");try{ye(t)}catch(n){if(n instanceof Ee)return process.stderr.write(`${n.message}
|
|
12
12
|
`),{success:!1,error:n.message,exitCode:1};const s=n instanceof Error?n.message:String(n);return process.stderr.write(`[Neocortex] state.json repair stopped unexpectedly: ${s}. No request was sent; inspect .neocortex/state.json and rerun.
|
|
13
|
-
`),{success:!1,error:s,exitCode:1}}const
|
|
14
|
-
`),warn:
|
|
13
|
+
`),{success:!1,error:s,exitCode:1}}const a=Ke(t);try{const{maybeAutoResolveYoloopArgs:n}=await import("../yoloop/invoke-hooks.js"),s={args:e.args,projectRoot:t,logger:{info:g=>process.stderr.write(`${g}
|
|
14
|
+
`),warn:g=>process.stderr.write(`${g}
|
|
15
15
|
`)}};n(s),s.args!==e.args&&(e={...e,args:s.args})}catch(n){const s=n instanceof Error?n.message:String(n);process.stderr.write(`[Neocortex] Auto-resolve hook (P121.05) failed: ${s}. Proceeding with raw args.
|
|
16
|
-
`)}try{const{readYoloopForRequest:n}=await import("../yoloop/invoke-hooks.js"),s=await n(e.args,t);s&&(
|
|
17
|
-
`)}try{const{maybeRunDiscoveryHook:n}=await import("../yoloop/invoke-hooks.js");await n({args:e.args,projectRoot:t,stateSnapshot:
|
|
18
|
-
`)}try{const{readArchitecturePolicy:n}=await import("../policy/architecture-policy.js"),s=await n(t);s&&(
|
|
19
|
-
`)}});
|
|
20
|
-
`)}try{const{readAndConsumeCheckpoint:n}=await import("../checkpoint/index.js"),s=await n(t);s&&(
|
|
21
|
-
`)}const
|
|
22
|
-
`)}if(!l&&
|
|
23
|
-
`),{success:!1,error:n.message??"Trigger not available on your plan",exitCode:1}}catch{}const
|
|
16
|
+
`)}try{const{readYoloopForRequest:n}=await import("../yoloop/invoke-hooks.js"),s=await n(e.args,t);s&&(a.yoloop=s)}catch{}try{const{readContinuityForRequest:n}=await import("../continuity/invoke-hooks.js"),s=await n(e.args,t);s&&(a.continuity=s)}catch(n){const s=n instanceof Error?n.message:String(n);process.stderr.write(`[Neocortex] continuity snapshot hook failed: ${s}. Proceeding without continuity state.
|
|
17
|
+
`)}try{const{maybeRunDiscoveryHook:n}=await import("../yoloop/invoke-hooks.js");await n({args:e.args,projectRoot:t,stateSnapshot:a,featureFlag:process.env.YOLOOP_AUTO_DISCOVERY!=="off",logger:{warn:s=>{console.warn(s)},info:s=>{console.error(s)}}})}catch(n){const s=n instanceof Error?n.message:String(n);process.stderr.write(`[Neocortex] discovery hook failed: ${s}. Proceeding without enrichment.
|
|
18
|
+
`)}try{const{readArchitecturePolicy:n}=await import("../policy/architecture-policy.js"),s=await n(t);s&&(a.architecture_policy=s)}catch(n){const s=n instanceof Error?n.message:String(n);console.warn(`[Neocortex] architecture-policy hook failed: ${s}. Proceeding without policy.`)}try{const n=/^(1|true|on|yes)$/i.test(process.env.NEOCORTEX_GRAPH_RETRIEVAL??""),{maybeRunGraphRetrievalHook:s}=await import("../yoloop/invoke-hooks.js"),g=await s({args:e.args,projectRoot:t,featureFlag:n,logger:{warn:A=>process.stderr.write(`${A}
|
|
19
|
+
`)}});g.applied&&g.metadata&&(a.graphRetrieval=g.metadata)}catch(n){const s=n instanceof Error?n.message:String(n);process.stderr.write(`[Neocortex] graph retrieval hook failed: ${s}. Proceeding without enrichment.
|
|
20
|
+
`)}try{const{readAndConsumeCheckpoint:n}=await import("../checkpoint/index.js"),s=await n(t);s&&(a.implementCheckpoint=s)}catch(n){const s=n instanceof Error?n.message:String(n);process.stderr.write(`[Neocortex] checkpoint hook failed: ${s}. Proceeding without checkpoint.
|
|
21
|
+
`)}const c=o?.licenseKey?new U({cacheDir:B,passphrase:o.licenseKey}):null,l=e.args.trim();if(De(l))try{a.projectMemoryBootstrap=ve(t)}catch(n){const s=n instanceof Error?n.message:String(n);process.stderr.write(`[Neocortex] project-memory bootstrap diagnosis failed: ${s}. Proceeding without local memory snapshot.
|
|
22
|
+
`)}if(!l&&c){const n=await ze(c);if(n)return{success:!0,instructions:n.instructions,metadata:n.metadata,exitCode:0}}const u=await qe(i,o?.licenseKey);if(!u){const n=o&&!o.licenseKey?" This may be caused by a machine fingerprint change (e.g., hardware or hostname change).":"";try{const s=j(),g=F("NOT_CONFIGURED",s);g&&process.stderr.write(M(g,s))}catch{}return{success:!1,error:`Not authenticated.${n} Visit https://neocortex.sh/portal/login to get your license key, then run: neocortex activate YOUR-LICENSE-KEY`,exitCode:2}}const d=re(l);if(d)try{const n=await u.tierClient.preFlightCheck(d);if(!n.allowed)return process.stderr.write(`[neocortex] ${n.message}
|
|
23
|
+
`),{success:!1,error:n.message??"Trigger not available on your plan",exitCode:1}}catch{}const m=await tt({args:l,projectRoot:t,platformTarget:r,environment:e.environment??process.env,bootstrapper:e.runnerBootstrapper});if(m.attachToRequest&&(a.runnerBootstrap=m.metadata),m.warning&&process.stderr.write(`[Neocortex] ${m.warning}
|
|
24
|
+
`),!m.shouldContinue)return m.error&&process.stderr.write(`[Neocortex] ${m.error}
|
|
25
|
+
`),{success:!1,error:m.error??"Runner auto-bootstrap required but failed.",errorCode:m.errorCode,exitCode:m.exitCode??1};const f=_e(l,a);let h={args:l,projectRoot:t.replace(k(),"~"),stateSnapshot:f,platformTarget:r};const _=Z(h);if(e.inputSource&&e.inputSource!=="args"&&_>=H)try{h={argsRef:(await Xe(i,l,u.token)).argsRef,projectRoot:t.replace(k(),"~"),stateSnapshot:f,platformTarget:r},Z(h)}catch(n){return{success:!1,error:`INVOKE_MATERIALIZATION_FAILED: ${n instanceof Error?n.message:String(n)}`,errorCode:"INVOKE_MATERIALIZATION_FAILED",exitCode:1}}let p=await te(i,h,u.token);if(!p.ok&&p.status===401){const n=p.errorBody?.fallback_action;if(n==="refresh_token"||n==="re_authenticate"){const s=await u.client.forceRefresh();s&&(p=await te(i,h,s))}}if(!p.ok&&p.status===426){const n=p.errorBody,s=n?.upgrade_command??"npm install -g @ornexus/neocortex@latest",g=n?.min_version??"unknown";return process.stderr.write(`
|
|
24
26
|
`),process.stderr.write(`==================================================
|
|
25
27
|
`),process.stderr.write(` UPGRADE REQUIRED
|
|
26
28
|
`),process.stderr.write(`==================================================
|
|
27
29
|
`),process.stderr.write(`
|
|
28
|
-
Your Neocortex version (${
|
|
29
|
-
`),process.stderr.write(` Minimum required: ${
|
|
30
|
+
Your Neocortex version (${S}) is no longer supported.
|
|
31
|
+
`),process.stderr.write(` Minimum required: ${g}
|
|
30
32
|
|
|
31
33
|
`),process.stderr.write(` Run this command to update:
|
|
32
34
|
|
|
@@ -35,12 +37,12 @@ ${t}
|
|
|
35
37
|
`),process.stderr.write(` After updating, re-run your command.
|
|
36
38
|
`),process.stderr.write(`==================================================
|
|
37
39
|
|
|
38
|
-
`),{success:!1,error:`UPGRADE_REQUIRED: Client version ${
|
|
40
|
+
`),{success:!1,error:`UPGRADE_REQUIRED: Client version ${S} is below minimum ${g}. Run: ${s}`,exitCode:3}}if(!p.ok||!p.data){const n=p.status===401?2:(p.status===429||p.status>=500,1);try{const s=p.errorBody?.error_code??(p.status===429?"RATE_LIMITED":p.status>=500?"SERVER_ERROR":void 0);if(s){const g=j(),A=F(s,g);A&&process.stderr.write(M(A,g))}}catch{}return{success:!1,error:T(p.error??"Unknown error from server",O),exitCode:n}}if(!l&&p.data.metadata?.mode==="menu"&&c&&Ve(c,p.data.instructions,p.data.metadata).catch(()=>{}),p.data.metadata&&u.tierClient.updateQuotaFromResponse(p.data.metadata).catch(()=>{}),p.data.metadata?.mode==="error"&&p.data.metadata?.errorCode==="CLIENT_UPGRADE_REQUIRED")return process.stderr.write(`
|
|
39
41
|
`),process.stderr.write(`==================================================
|
|
40
42
|
`),process.stderr.write(` YOLOOP CLIENT UPGRADE REQUIRED
|
|
41
43
|
`),process.stderr.write(`==================================================
|
|
42
44
|
`),process.stderr.write(`
|
|
43
|
-
Your Neocortex client version (${
|
|
45
|
+
Your Neocortex client version (${S}) does not
|
|
44
46
|
`),process.stderr.write(` support client-side yoloop state persistence.
|
|
45
47
|
|
|
46
48
|
`),process.stderr.write(` Run this command to upgrade:
|
|
@@ -50,14 +52,14 @@ ${t}
|
|
|
50
52
|
`),process.stderr.write(` After upgrading, re-run your yoloop command.
|
|
51
53
|
`),process.stderr.write(`==================================================
|
|
52
54
|
|
|
53
|
-
`),{success:!1,error:"CLIENT_UPGRADE_REQUIRED: This client does not support yoloop client-side persistence. Run: npm install -g @ornexus/neocortex@latest",exitCode:3};if(
|
|
54
|
-
`),{success:!1,error:`CONTINUITY_PERSISTENCE_FAILED: ${
|
|
55
|
-
`),{success:!1,error:`CONTINUITY_PERSISTENCE_FAILED: ${
|
|
55
|
+
`),{success:!1,error:"CLIENT_UPGRADE_REQUIRED: This client does not support yoloop client-side persistence. Run: npm install -g @ornexus/neocortex@latest",exitCode:3};if(p.data.metadata?.yoloopStateUpdate)try{const{persistYoloopFromResponse:n}=await import("../yoloop/invoke-hooks.js");await n(p.data.metadata,t)}catch{}if(p.data.metadata?.continuityStateUpdate)try{const{persistContinuityFromResponse:n}=await import("../continuity/invoke-hooks.js"),s=await n(p.data.metadata,t);if(!s.ok){const g=s.reasonCodes.join(",");return process.stderr.write(`[Neocortex] continuity persistence failed: ${g}. No continuity mutation was committed.
|
|
56
|
+
`),{success:!1,error:`CONTINUITY_PERSISTENCE_FAILED: ${g}`,errorCode:"CONTINUITY_PERSISTENCE_FAILED",exitCode:1}}}catch(n){const s=n instanceof Error?n.message:String(n);return process.stderr.write(`[Neocortex] continuity persistence hook failed: ${s}. No continuity mutation was committed.
|
|
57
|
+
`),{success:!1,error:`CONTINUITY_PERSISTENCE_FAILED: ${T(s,O)}`,errorCode:"CONTINUITY_PERSISTENCE_FAILED",exitCode:1}}if(p.data.metadata?.stateMutated===!0)try{const{persistMigratedStateFromResponse:n}=await import("../yoloop/invoke-hooks.js");await n(p.data.metadata,t)}catch{}if(p.data.metadata?.tier_changed){const n=p.data.metadata.current_tier;try{await u.client.forceRefresh()?(await u.tierClient.invalidateTierCache(),process.stderr.write(`[Neocortex] Token atualizado automaticamente para tier ${n}
|
|
56
58
|
`)):process.stderr.write(`[Neocortex] Seu tier foi atualizado para ${n}! Execute "neocortex activate" para obter um token atualizado.
|
|
57
59
|
`)}catch{process.stderr.write(`[Neocortex] Seu tier foi atualizado para ${n}! Execute "neocortex activate" para obter um token atualizado.
|
|
58
|
-
`)}}const L=
|
|
59
|
-
`),1;throw o}const r=await
|
|
60
|
-
`),r.exitCode;if(t.format==="json"){const o=
|
|
61
|
-
`)}else{const o=
|
|
60
|
+
`)}}const L=P(p.data.instructions,p.data.metadata);return{success:!0,instructions:L.instructions,metadata:L.metadata,exitCode:0}}function re(e){const[t]=e.trim().split(/\s+/,1);return t?/^@?epic-[a-z0-9][a-z0-9._-]*$/i.test(t)?"epic":le(t):null}const ne="Provide exactly one invoke input source: --args <string>, --stdin, or --args-file <path>.";function oe(e){return new y("INVOKE_INPUT_VALUE_MISSING",`${e} requires a value. ${ne}`)}function st(e){try{if(!ce(e).isFile())throw new y("INVOKE_ARGS_FILE_NOT_FILE","--args-file must point to a readable UTF-8 text file.");return N(e,"utf8")}catch(t){throw t instanceof y?t:new y("INVOKE_ARGS_FILE_READ_FAILED","--args-file could not be read as UTF-8 text. Check the path and permissions.")}}function it(){try{if(process.stdin.isTTY)throw new y("INVOKE_STDIN_EMPTY","--stdin requires piped UTF-8 text, for example: neocortex-client invoke --stdin < synthetic.story.md");return N(0,"utf8")}catch(e){throw e instanceof y?e:new y("INVOKE_STDIN_READ_FAILED","--stdin could not be read as UTF-8 text. Pipe command text into stdin and retry.")}}function at(e,t={}){let r,o=!1,i,a,c="plain",l;for(let f=0;f<e.length;f++)switch(e[f]){case"--args":{const _=e[++f];if(_===void 0)throw oe("--args");r=_;break}case"--stdin":o=!0;break;case"--args-file":{const _=e[++f];if(_===void 0)throw oe("--args-file");i=_;break}case"--project-root":a=e[++f];break;case"--format":c=e[++f]??"plain";break;case"--server-url":l=e[++f];break}const u=[r!==void 0?"args":void 0,o?"stdin":void 0,i!==void 0?"args-file":void 0].filter(f=>f!==void 0);if(u.length===0)throw new y("INVOKE_INPUT_SOURCE_MISSING",ne);if(u.length>1)throw new y("INVOKE_INPUT_SOURCE_CONFLICT",`Choose only one invoke input source; received ${u.join(", ")}.`);const d=u[0];return{args:d==="args"?r:d==="stdin"?(t.readStdin??it)():(t.readArgsFile??st)(i),inputSource:d,projectRoot:a,format:c,serverUrl:l}}async function It(e){let t;try{t=at(e)}catch(o){if(o instanceof y)return process.stderr.write(JSON.stringify({error_code:o.code,message:o.message})+`
|
|
61
|
+
`),1;throw o}const r=await ot({args:t.args,inputSource:t.inputSource,projectRoot:t.projectRoot,format:t.format,serverUrl:t.serverUrl});if(!r.success)return process.stderr.write(JSON.stringify({error_code:r.errorCode??(r.exitCode===2?"NOT_CONFIGURED":"INVOKE_ERROR"),message:T(r.error??"",O)})+`
|
|
62
|
+
`),r.exitCode;if(t.format==="json"){const o=P(r.instructions,r.metadata);process.stdout.write(JSON.stringify({instructions:o.instructions,metadata:o.metadata})+`
|
|
63
|
+
`)}else{const o=P(r.instructions,r.metadata);process.stdout.write(o.instructions+`
|
|
62
64
|
`),o.metadata&&process.stderr.write(JSON.stringify(o.metadata)+`
|
|
63
|
-
`)}return 0}export{
|
|
65
|
+
`)}return 0}export{H as INVOKE_PAYLOAD_WARNING_THRESHOLD_BYTES,y as InvokeCliInputError,At as __resetSchemaDriftWarnedForTests,ve as collectInitProjectMemoryBootstrapSnapshot,Ke as collectStateSnapshot,Qe as computeInvokeRequestBodySizeBytes,Nt as createFullStateSnapshotScope,Fe as detectStateSchemaDrift,re as extractPreFlightTrigger,ot as invoke,It as invokeCliHandler,De as isInitTrigger,Z as maybeEmitInvokePayloadSizeWarning,tt as maybeRunInvokeRunnerAutoBootstrap,at as parseInvokeCliOptions,$e as resolveInvokeProjectRoot,P as sanitizeInvokeCliOutput};
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* P180.05 -- invoke.ts hooks for client-owned continuity SQLite state.
|
|
6
6
|
*/
|
|
7
7
|
import { type ContinuityClientReasonCode, type ContinuitySnapshotForInvoke } from './continuity-client-state-store.js';
|
|
8
|
+
export { RUNNER_BOOTSTRAP_POLICY_REASON_CODES, classifyRunnerBootstrapPolicy, classifyRunnerBootstrapPolicyFromArgs, parseRunnerBootstrapCommandIntent, type RunnerBootstrapCommandIntent, type RunnerBootstrapPolicyContext, type RunnerBootstrapPolicyDecision, type RunnerBootstrapPolicyReasonCode, } from './runner-bootstrap-policy.js';
|
|
8
9
|
export interface ContinuityPersistResult {
|
|
9
10
|
readonly ok: boolean;
|
|
10
11
|
readonly appliedOperationIds: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONTINUITY_CLIENT_REASON_CODES as i,ContinuityClientStateStoreError as l,continuitySqliteExists as s,createContinuityHardStopSnapshot as
|
|
1
|
+
import{CONTINUITY_CLIENT_REASON_CODES as i,ContinuityClientStateStoreError as l,continuitySqliteExists as s,createContinuityHardStopSnapshot as f,openContinuityClientStateStore as u}from"./continuity-client-state-store.js";import{RUNNER_BOOTSTRAP_POLICY_REASON_CODES as g,classifyRunnerBootstrapPolicy as T,classifyRunnerBootstrapPolicyFromArgs as R,parseRunnerBootstrapCommandIntent as _}from"./runner-bootstrap-policy.js";import{parseRunnerBootstrapCommandIntent as S}from"./runner-bootstrap-policy.js";function d(e){return S(e).kind!=="unknown"}async function y(e,n,r){if(d(e)||s(n))try{const t=await u({projectRoot:n,now:()=>r??new Date().toISOString()});try{return t.collectSnapshot({nowIso:r})}finally{t.close()}}catch(t){const a=p(t);return d(e)||s(n)?f(a,r??new Date().toISOString()):void 0}}async function O(e,n){const r=e?.continuityStateUpdate;if(!r)return{ok:!0,appliedOperationIds:[],ignoredOperationIds:[],reasonCodes:[i.OK],publicSafe:!0};let o;try{o=await u({projectRoot:n});const t=o.applyStateUpdate(r);return{ok:!0,appliedOperationIds:t.appliedOperationIds,ignoredOperationIds:t.ignoredOperationIds,reasonCodes:t.reasonCodes,publicSafe:!0}}catch(t){const a=p(t),c=t instanceof Error?t.message:String(t);return{ok:!1,appliedOperationIds:[],ignoredOperationIds:[],reasonCodes:a,error:c,publicSafe:!0}}finally{o?.close()}}function p(e){if(e instanceof l)return e.reasonCodes;const n=e instanceof Error?e.message:String(e);return/sqlite-adapter-unavailable/i.test(n)?[i.SQLITE_ADAPTER_UNAVAILABLE]:/integrity|corrupt|malformed|not a database/i.test(n)?[i.SQLITE_INTEGRITY_FAILED]:[i.SQLITE_MUTATION_FAILED]}export{g as RUNNER_BOOTSTRAP_POLICY_REASON_CODES,T as classifyRunnerBootstrapPolicy,R as classifyRunnerBootstrapPolicyFromArgs,d as isContinuityTrigger,_ as parseRunnerBootstrapCommandIntent,O as persistContinuityFromResponse,y as readContinuityForRequest};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* P181.03 -- public-safe runner bootstrap classifier for durable goal/loop
|
|
6
|
+
* operations.
|
|
7
|
+
*/
|
|
8
|
+
export declare const RUNNER_BOOTSTRAP_POLICY_REASON_CODES: {
|
|
9
|
+
readonly REQUIRED_DURABLE_COMMAND: "runner-bootstrap-required-durable-command";
|
|
10
|
+
readonly REQUIRED_UNKNOWN_GOAL_LOOP_OPERATION: "runner-bootstrap-required-unknown-goal-loop-operation";
|
|
11
|
+
readonly OPTIONAL_OPERATOR_COMMAND: "runner-bootstrap-optional-operator-command";
|
|
12
|
+
readonly SKIPPED_BOOTSTRAP_IN_PROGRESS: "runner-bootstrap-skipped-bootstrap-in-progress";
|
|
13
|
+
readonly SKIPPED_RUNNER_PLATFORM: "runner-bootstrap-skipped-runner-platform";
|
|
14
|
+
readonly SKIPPED_GOAL_LOOP_TICK: "runner-bootstrap-skipped-goal-loop-tick";
|
|
15
|
+
readonly SKIPPED_JOBS_COMMAND: "runner-bootstrap-skipped-jobs-command";
|
|
16
|
+
readonly SKIPPED_RUNNER_COMMAND: "runner-bootstrap-skipped-runner-command";
|
|
17
|
+
readonly SKIPPED_NON_CONTINUITY_COMMAND: "runner-bootstrap-skipped-non-continuity-command";
|
|
18
|
+
};
|
|
19
|
+
export type RunnerBootstrapPolicyReasonCode = typeof RUNNER_BOOTSTRAP_POLICY_REASON_CODES[keyof typeof RUNNER_BOOTSTRAP_POLICY_REASON_CODES];
|
|
20
|
+
export type RunnerBootstrapCommandKind = 'goal' | 'loop' | 'jobs' | 'runner' | 'unknown';
|
|
21
|
+
export type RunnerBootstrapOperation = 'create' | 'start' | 'resume' | 'activate' | 'run' | 'run-once' | 'restart' | 'continue' | 'unpause' | 'status' | 'cancel' | 'pause' | 'report' | 'reports' | 'log' | 'logs' | 'tick' | 'unknown' | 'none';
|
|
22
|
+
export type RunnerBootstrapPolicyAction = 'required' | 'optional' | 'skipped';
|
|
23
|
+
export type RunnerBootstrapFailurePolicy = 'fail-closed' | 'fail-open' | 'not-applicable';
|
|
24
|
+
export interface RunnerBootstrapCommandIntent {
|
|
25
|
+
readonly kind: RunnerBootstrapCommandKind;
|
|
26
|
+
/** Canonical public operation token, never raw user text. */
|
|
27
|
+
readonly operation: RunnerBootstrapOperation;
|
|
28
|
+
/** Whether the leading public command token was recognized as an alias/number. */
|
|
29
|
+
readonly recognizedAlias: boolean;
|
|
30
|
+
readonly publicSafe: true;
|
|
31
|
+
}
|
|
32
|
+
export interface RunnerBootstrapPolicyContext {
|
|
33
|
+
readonly platformTarget?: string;
|
|
34
|
+
/** Explicit recursion guard set by future invoke integration. */
|
|
35
|
+
readonly bootstrapInProgress?: boolean;
|
|
36
|
+
/** Optional process-like environment, provided explicitly to keep the classifier pure. */
|
|
37
|
+
readonly environment?: Readonly<Record<string, string | undefined>>;
|
|
38
|
+
}
|
|
39
|
+
export interface RunnerBootstrapPolicyDecision {
|
|
40
|
+
readonly action: RunnerBootstrapPolicyAction;
|
|
41
|
+
readonly failurePolicy: RunnerBootstrapFailurePolicy;
|
|
42
|
+
readonly command: RunnerBootstrapCommandKind;
|
|
43
|
+
readonly operation: RunnerBootstrapOperation;
|
|
44
|
+
readonly reasonCodes: readonly RunnerBootstrapPolicyReasonCode[];
|
|
45
|
+
readonly publicSummary: string;
|
|
46
|
+
readonly publicSafe: true;
|
|
47
|
+
}
|
|
48
|
+
export declare function parseRunnerBootstrapCommandIntent(args: string): RunnerBootstrapCommandIntent;
|
|
49
|
+
export declare function classifyRunnerBootstrapPolicy(commandIntent: RunnerBootstrapCommandIntent, context?: RunnerBootstrapPolicyContext): RunnerBootstrapPolicyDecision;
|
|
50
|
+
export declare function classifyRunnerBootstrapPolicyFromArgs(args: string, context?: RunnerBootstrapPolicyContext): RunnerBootstrapPolicyDecision;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={REQUIRED_DURABLE_COMMAND:"runner-bootstrap-required-durable-command",REQUIRED_UNKNOWN_GOAL_LOOP_OPERATION:"runner-bootstrap-required-unknown-goal-loop-operation",OPTIONAL_OPERATOR_COMMAND:"runner-bootstrap-optional-operator-command",SKIPPED_BOOTSTRAP_IN_PROGRESS:"runner-bootstrap-skipped-bootstrap-in-progress",SKIPPED_RUNNER_PLATFORM:"runner-bootstrap-skipped-runner-platform",SKIPPED_GOAL_LOOP_TICK:"runner-bootstrap-skipped-goal-loop-tick",SKIPPED_JOBS_COMMAND:"runner-bootstrap-skipped-jobs-command",SKIPPED_RUNNER_COMMAND:"runner-bootstrap-skipped-runner-command",SKIPPED_NON_CONTINUITY_COMMAND:"runner-bootstrap-skipped-non-continuity-command"},P=new Set(["goal","goals","durable-goal","continuity-goal","59"]),N=new Set(["loop","loops","durable-loop","continuity-loop","60"]),f=new Set(["jobs","job","continuity-jobs","61"]),R=new Set(["runner","neocortex-runner","continuity-runner","62"]),E=new Map([["goal-tick","goal"],["loop-tick","loop"]]),s=new Set(["create","start","resume","activate","run","run-once","restart","continue","unpause"]),p=new Set(["status","cancel","pause","report","reports","log","logs"]),S=new Set([...s,...p,"tick"]),A=/^@?(?:goal|loop|job)-[a-z0-9][a-z0-9._-]*$/i;function b(r){const o=d(r),n=l(o[0]);if(!n)return u("unknown","none",!1);const a=E.get(n);if(a)return u(a,"tick",!0);const i=T(n);return i==="unknown"?u("unknown","none",!1):u(i,O(_(o)),!0)}function k(r,o={}){if(C(o))return t(r,e.SKIPPED_BOOTSTRAP_IN_PROGRESS,"runner bootstrap skipped because a bootstrap guard is active.");if(D(o.platformTarget)==="runner")return t(r,e.SKIPPED_RUNNER_PLATFORM,"runner bootstrap skipped for runner platform invocation.");if((r.kind==="goal"||r.kind==="loop")&&r.operation==="tick")return t(r,e.SKIPPED_GOAL_LOOP_TICK,`runner bootstrap skipped for ${r.kind} tick operation.`);if(r.kind==="jobs")return t(r,e.SKIPPED_JOBS_COMMAND,"runner bootstrap skipped for jobs command.");if(r.kind==="runner")return t(r,e.SKIPPED_RUNNER_COMMAND,"runner bootstrap skipped for runner command.");if(r.kind!=="goal"&&r.kind!=="loop")return t(r,e.SKIPPED_NON_CONTINUITY_COMMAND,"runner bootstrap skipped for non-continuity command.");if(p.has(r.operation))return{action:"optional",failurePolicy:"fail-open",command:r.kind,operation:r.operation,reasonCodes:[e.OPTIONAL_OPERATOR_COMMAND],publicSummary:`runner bootstrap optional for ${r.kind} operator command.`,publicSafe:!0};const n=s.has(r.operation)||r.operation==="none"?e.REQUIRED_DURABLE_COMMAND:e.REQUIRED_UNKNOWN_GOAL_LOOP_OPERATION;return{action:"required",failurePolicy:"fail-closed",command:r.kind,operation:r.operation==="none"?"create":r.operation,reasonCodes:[n],publicSummary:`runner bootstrap required for durable ${r.kind} command.`,publicSafe:!0}}function M(r,o={}){return k(b(r),o)}function t(r,o,n){return{action:"skipped",failurePolicy:"not-applicable",command:r.kind,operation:r.operation,reasonCodes:[o],publicSummary:n,publicSafe:!0}}function u(r,o,n){return{kind:r,operation:o,recognizedAlias:n,publicSafe:!0}}function T(r){return P.has(r)?"goal":N.has(r)?"loop":f.has(r)?"jobs":R.has(r)?"runner":"unknown"}function O(r){const o=l(r);return o?S.has(o)?o:"unknown":"none"}function _(r){const o=r[1];if(o)return A.test(o)?r[2]:o}function d(r){return r.trim().split(/\s+/).filter(Boolean).slice(0,3)}function l(r){return(r??"").trim().toLowerCase().replace(/^\*/,"")}function D(r){return(r??"").trim().toLowerCase()}function C(r){return r.bootstrapInProgress?!0:c(r.environment?.NEOCORTEX_RUNNER_BOOTSTRAP_IN_PROGRESS)||c(r.environment?.NEOCORTEX_BOOTSTRAP_IN_PROGRESS)}function c(r){return/^(1|true|yes|on)$/i.test(r??"")}export{e as RUNNER_BOOTSTRAP_POLICY_REASON_CODES,k as classifyRunnerBootstrapPolicy,M as classifyRunnerBootstrapPolicyFromArgs,b as parseRunnerBootstrapCommandIntent};
|
|
@@ -9,7 +9,7 @@ export declare const CONTINUITY_SQLITE_FILENAME: "continuity.sqlite";
|
|
|
9
9
|
export declare const CONTINUITY_SQLITE_SCHEMA_VERSION: 1;
|
|
10
10
|
export declare const DEFAULT_CONTINUITY_SQLITE_BUSY_TIMEOUT_MS = 5000;
|
|
11
11
|
export declare const SQLITE_ADAPTER_INSTALL_GUIDANCE = "Install the optional Enterprise continuity SQLite adapter with `npm install --workspace packages/client better-sqlite3 --include=optional` or reinstall Neocortex with optional dependencies enabled.";
|
|
12
|
-
export type ContinuitySqliteStoreErrorCode = 'sqlite-adapter-unavailable' | 'sqlite-integrity-failed' | 'sqlite-migration-failed' | 'sqlite-migration-conflict' | 'sqlite-foreign-key-failed' | 'sqlite-public-safety-rejected' | 'sqlite-mutation-blocked';
|
|
12
|
+
export type ContinuitySqliteStoreErrorCode = 'sqlite-adapter-unavailable' | 'sqlite-integrity-failed' | 'sqlite-migration-failed' | 'sqlite-migration-conflict' | 'sqlite-mutation-failed' | 'sqlite-foreign-key-failed' | 'sqlite-public-safety-rejected' | 'sqlite-mutation-blocked';
|
|
13
13
|
export declare class ContinuitySqliteStoreError extends Error {
|
|
14
14
|
readonly code: ContinuitySqliteStoreErrorCode;
|
|
15
15
|
readonly reasonCode: ContinuitySqliteStoreErrorCode;
|
|
@@ -31,13 +31,16 @@ export interface ContinuitySqliteStatement {
|
|
|
31
31
|
get(...params: readonly unknown[]): unknown;
|
|
32
32
|
all(...params: readonly unknown[]): readonly unknown[];
|
|
33
33
|
}
|
|
34
|
+
export type ContinuitySqliteTransaction<T extends (...args: never[]) => unknown> = T & {
|
|
35
|
+
readonly immediate?: T;
|
|
36
|
+
};
|
|
34
37
|
export interface ContinuitySqliteDatabase {
|
|
35
38
|
pragma(source: string, options?: {
|
|
36
39
|
readonly simple?: boolean;
|
|
37
40
|
}): unknown;
|
|
38
41
|
exec(source: string): void;
|
|
39
42
|
prepare(source: string): ContinuitySqliteStatement;
|
|
40
|
-
transaction<T extends (...args: never[]) => unknown>(fn: T): T
|
|
43
|
+
transaction<T extends (...args: never[]) => unknown>(fn: T): ContinuitySqliteTransaction<T>;
|
|
41
44
|
close(): void;
|
|
42
45
|
}
|
|
43
46
|
export interface ContinuitySqliteAdapter {
|