@dailephd/my-centcom 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -5
- package/apps/daemon/dist/artifacts/returnSnapshots.d.ts +12 -0
- package/apps/daemon/dist/artifacts/returnSnapshots.js +41 -0
- package/apps/daemon/dist/bootstrap/app.d.ts +21 -0
- package/apps/daemon/dist/bootstrap/app.js +27 -0
- package/apps/daemon/dist/bootstrap/installLayout.d.ts +81 -0
- package/apps/daemon/dist/bootstrap/installLayout.js +164 -0
- package/apps/daemon/dist/bootstrap/main.d.ts +14 -0
- package/apps/daemon/dist/bootstrap/main.js +141 -0
- package/apps/daemon/dist/bootstrap/operatorConsole.d.ts +75 -0
- package/apps/daemon/dist/bootstrap/operatorConsole.js +293 -0
- package/apps/daemon/dist/bootstrap/privateDataRoot.d.ts +38 -0
- package/apps/daemon/dist/bootstrap/privateDataRoot.js +204 -0
- package/apps/daemon/dist/bootstrap/secureMain.d.ts +118 -0
- package/apps/daemon/dist/bootstrap/secureMain.js +403 -0
- package/apps/daemon/dist/bootstrap/setup.d.ts +93 -0
- package/apps/daemon/dist/bootstrap/setup.js +738 -0
- package/apps/daemon/dist/context/changeProposal.d.ts +97 -0
- package/apps/daemon/dist/context/changeProposal.js +259 -0
- package/apps/daemon/dist/context/gitEvidence.d.ts +88 -0
- package/apps/daemon/dist/context/gitEvidence.js +332 -0
- package/apps/daemon/dist/context/gitObservation.d.ts +30 -0
- package/apps/daemon/dist/context/gitObservation.js +113 -0
- package/apps/daemon/dist/context/projectReadIssuer.d.ts +68 -0
- package/apps/daemon/dist/context/projectReadIssuer.js +158 -0
- package/apps/daemon/dist/context/projectReadService.d.ts +153 -0
- package/apps/daemon/dist/context/projectReadService.js +652 -0
- package/apps/daemon/dist/context/projectViewService.d.ts +85 -0
- package/apps/daemon/dist/context/projectViewService.js +332 -0
- package/apps/daemon/dist/context/proposalRecorder.d.ts +11 -0
- package/apps/daemon/dist/context/proposalRecorder.js +19 -0
- package/apps/daemon/dist/plugins/drivers/codexMcpConfig.d.ts +40 -0
- package/apps/daemon/dist/plugins/drivers/codexMcpConfig.js +73 -0
- package/apps/daemon/dist/plugins/drivers/codexModelCompatibility.d.ts +49 -0
- package/apps/daemon/dist/plugins/drivers/codexModelCompatibility.js +70 -0
- package/apps/daemon/dist/plugins/drivers/fakePluginDriver.d.ts +16 -0
- package/apps/daemon/dist/plugins/drivers/fakePluginDriver.js +115 -0
- package/apps/daemon/dist/plugins/drivers/finiteCliDriver.d.ts +153 -0
- package/apps/daemon/dist/plugins/drivers/finiteCliDriver.js +505 -0
- package/apps/daemon/dist/plugins/registry/operationCatalog.d.ts +23 -0
- package/apps/daemon/dist/plugins/registry/operationCatalog.js +41 -0
- package/apps/daemon/dist/plugins/registry/registryOperationCatalog.d.ts +14 -0
- package/apps/daemon/dist/plugins/registry/registryOperationCatalog.js +29 -0
- package/apps/daemon/dist/plugins/registry/verifiedCapabilityRegistry.d.ts +151 -0
- package/apps/daemon/dist/plugins/registry/verifiedCapabilityRegistry.js +579 -0
- package/apps/daemon/dist/projects/codingAuthority.d.ts +102 -0
- package/apps/daemon/dist/projects/codingAuthority.js +244 -0
- package/apps/daemon/dist/projects/fixtureAuthorization.d.ts +54 -0
- package/apps/daemon/dist/projects/fixtureAuthorization.js +172 -0
- package/apps/daemon/dist/projects/pairedAuthority.d.ts +158 -0
- package/apps/daemon/dist/projects/pairedAuthority.js +273 -0
- package/apps/daemon/dist/projects/trustedCliConsent.d.ts +47 -0
- package/apps/daemon/dist/projects/trustedCliConsent.js +84 -0
- package/apps/daemon/dist/runs/changeApplier.d.ts +59 -0
- package/apps/daemon/dist/runs/changeApplier.js +319 -0
- package/apps/daemon/dist/runs/codingWorkflowService.d.ts +283 -0
- package/apps/daemon/dist/runs/codingWorkflowService.js +785 -0
- package/apps/daemon/dist/runs/durableIntentCoordinator.d.ts +72 -0
- package/apps/daemon/dist/runs/durableIntentCoordinator.js +160 -0
- package/apps/daemon/dist/runs/inMemoryCoordinator.d.ts +55 -0
- package/apps/daemon/dist/runs/inMemoryCoordinator.js +375 -0
- package/apps/daemon/dist/runs/runExecutor.d.ts +154 -0
- package/apps/daemon/dist/runs/runExecutor.js +295 -0
- package/apps/daemon/dist/runs/workflowService.d.ts +185 -0
- package/apps/daemon/dist/runs/workflowService.js +300 -0
- package/apps/daemon/dist/runtime/boundedProcessHost.d.ts +111 -0
- package/apps/daemon/dist/runtime/boundedProcessHost.js +752 -0
- package/apps/daemon/dist/runtime/evidenceRedaction.d.ts +30 -0
- package/apps/daemon/dist/runtime/evidenceRedaction.js +79 -0
- package/apps/daemon/dist/runtime/executionDiagnostics.d.ts +134 -0
- package/apps/daemon/dist/runtime/executionDiagnostics.js +213 -0
- package/apps/daemon/dist/runtime/modelExecutionPolicy.d.ts +22 -0
- package/apps/daemon/dist/runtime/modelExecutionPolicy.js +19 -0
- package/apps/daemon/dist/runtime/mxcExecution.d.ts +12 -0
- package/apps/daemon/dist/runtime/mxcExecution.js +163 -0
- package/apps/daemon/dist/runtime/mxcIntegrity.d.ts +24 -0
- package/apps/daemon/dist/runtime/mxcIntegrity.js +81 -0
- package/apps/daemon/dist/runtime/mxcWorker.d.ts +2 -0
- package/apps/daemon/dist/runtime/mxcWorker.js +45 -0
- package/apps/daemon/dist/runtime/provisionedExecution.d.ts +150 -0
- package/apps/daemon/dist/runtime/provisionedExecution.js +653 -0
- package/apps/daemon/dist/runtime/testExecution.d.ts +76 -0
- package/apps/daemon/dist/runtime/testExecution.js +106 -0
- package/apps/daemon/dist/runtime/testProfiles.d.ts +10 -0
- package/apps/daemon/dist/runtime/testProfiles.js +4 -0
- package/apps/daemon/dist/runtime/trustedAgentStaging.d.ts +89 -0
- package/apps/daemon/dist/runtime/trustedAgentStaging.js +262 -0
- package/apps/daemon/dist/runtime/trustedCaBundle.d.ts +77 -0
- package/apps/daemon/dist/runtime/trustedCaBundle.js +125 -0
- package/apps/daemon/dist/runtime/windows/windowsJobSupervisor.d.ts +166 -0
- package/apps/daemon/dist/runtime/windows/windowsJobSupervisor.js +521 -0
- package/apps/daemon/dist/storage/diagnosticLog.d.ts +63 -0
- package/apps/daemon/dist/storage/diagnosticLog.js +136 -0
- package/apps/daemon/dist/storage/executionTelemetry.d.ts +63 -0
- package/apps/daemon/dist/storage/executionTelemetry.js +247 -0
- package/apps/daemon/dist/storage/protectedSecrets.d.ts +39 -0
- package/apps/daemon/dist/storage/protectedSecrets.js +106 -0
- package/apps/daemon/dist/storage/sqliteLedger.d.ts +786 -0
- package/apps/daemon/dist/storage/sqliteLedger.js +1303 -0
- package/apps/daemon/dist/transports/http/dispatch.d.ts +43 -0
- package/apps/daemon/dist/transports/http/dispatch.js +405 -0
- package/apps/daemon/dist/transports/http/secureRoutes.d.ts +40 -0
- package/apps/daemon/dist/transports/http/secureRoutes.js +332 -0
- package/apps/daemon/dist/transports/http/workflowRoutes.d.ts +41 -0
- package/apps/daemon/dist/transports/http/workflowRoutes.js +473 -0
- package/apps/daemon/dist/transports/mcp/localProjectReadServer.d.ts +182 -0
- package/apps/daemon/dist/transports/mcp/localProjectReadServer.js +221 -0
- package/apps/daemon/dist/transports/native/nativeHost.d.ts +24 -0
- package/apps/daemon/dist/transports/native/nativeHost.js +344 -0
- package/apps/daemon/package.json +24 -0
- package/apps/daemon/src/runtime/benign/referenceEcho.mjs +27 -0
- package/apps/daemon/src/runtime/windows/buildSupervisor.mjs +87 -0
- package/apps/daemon/src/runtime/windows/supervisorMain.cs +676 -0
- package/apps/extension/manifest.secure.json +25 -0
- package/apps/extension/scripts/build.mjs +173 -0
- package/apps/extension/src/background/secureWorker.ts +1595 -0
- package/apps/extension/src/background/serviceWorker.ts +892 -0
- package/apps/extension/src/content/captureSelection.ts +64 -0
- package/apps/extension/src/content/secureInsert.ts +207 -0
- package/apps/extension/src/probe/index.html +41 -0
- package/apps/extension/src/probe/main.ts +201 -0
- package/apps/extension/src/sidepanel/index.html +203 -0
- package/apps/extension/src/sidepanel/main.ts +903 -0
- package/package.json +19 -3
- package/packages/contracts/dist/artifacts.d.ts +66 -0
- package/packages/contracts/dist/artifacts.js +64 -0
- package/packages/contracts/dist/automation.d.ts +540 -0
- package/packages/contracts/dist/automation.js +191 -0
- package/packages/contracts/dist/browser.d.ts +251 -0
- package/packages/contracts/dist/browser.js +131 -0
- package/packages/contracts/dist/context.d.ts +71 -0
- package/packages/contracts/dist/context.js +73 -0
- package/packages/contracts/dist/diagnostics.d.ts +99 -0
- package/packages/contracts/dist/diagnostics.js +284 -0
- package/packages/contracts/dist/effects.d.ts +42 -0
- package/packages/contracts/dist/effects.js +42 -0
- package/packages/contracts/dist/errors.d.ts +75 -0
- package/packages/contracts/dist/errors.js +70 -0
- package/packages/contracts/dist/events.d.ts +50 -0
- package/packages/contracts/dist/events.js +34 -0
- package/packages/contracts/dist/executionDiagnostics.d.ts +212 -0
- package/packages/contracts/dist/executionDiagnostics.js +101 -0
- package/packages/contracts/dist/identity.d.ts +54 -0
- package/packages/contracts/dist/identity.js +40 -0
- package/packages/contracts/dist/index.d.ts +20 -0
- package/packages/contracts/dist/index.js +20 -0
- package/packages/contracts/dist/invocation.d.ts +90 -0
- package/packages/contracts/dist/invocation.js +77 -0
- package/packages/contracts/dist/lifecycle.d.ts +130 -0
- package/packages/contracts/dist/lifecycle.js +135 -0
- package/packages/contracts/dist/plugin.d.ts +214 -0
- package/packages/contracts/dist/plugin.js +117 -0
- package/packages/contracts/dist/projectRead.d.ts +205 -0
- package/packages/contracts/dist/projectRead.js +162 -0
- package/packages/contracts/dist/secure.d.ts +128 -0
- package/packages/contracts/dist/secure.js +99 -0
- package/packages/contracts/package.json +32 -0
- package/packages/contracts/src/artifacts.ts +83 -0
- package/packages/contracts/src/automation.ts +238 -0
- package/packages/contracts/src/browser.ts +164 -0
- package/packages/contracts/src/context.ts +91 -0
- package/packages/contracts/src/diagnostics.ts +318 -0
- package/packages/contracts/src/effects.ts +49 -0
- package/packages/contracts/src/errors.ts +83 -0
- package/packages/contracts/src/events.ts +46 -0
- package/packages/contracts/src/executionDiagnostics.ts +116 -0
- package/packages/contracts/src/identity.ts +68 -0
- package/packages/contracts/src/index.ts +20 -0
- package/packages/contracts/src/invocation.ts +96 -0
- package/packages/contracts/src/lifecycle.ts +169 -0
- package/packages/contracts/src/plugin.ts +174 -0
- package/packages/contracts/src/projectRead.ts +179 -0
- package/packages/contracts/src/secure.ts +136 -0
- package/provenance.json +179 -9
- package/source.zip +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C07 RUN-SCOPED PROJECT VIEW (SW-077). Provider-neutral; Node built-ins and the C07 path policy only.
|
|
3
|
+
*
|
|
4
|
+
* The trusted daemon materialises, for ONE run of ONE project under ONE grant, a private COPY of only the material the project-read policy would ever serve: regular files, no links or
|
|
5
|
+
* junctions, no hard-link aliases, no Git internals, no credentials, no nested repositories, bounded in count and size. The agent process is then pointed at the COPY (working directory and
|
|
6
|
+
* reader root) and is never granted the original project by this mechanism. Consequences, each pinned by tests:
|
|
7
|
+
* - a bypass of the reader (any tool the model might reach) can only reveal bytes the policy already allowed: the withheld material is not on the agent's side of the boundary at all;
|
|
8
|
+
* - the view is a snapshot: a later change to the source never changes an already approved view (copies, not links: NTFS hard links share one security descriptor and one content);
|
|
9
|
+
* - the view is integrity-checkable: a manifest OUTSIDE the view (not readable by the agent) records every file's SHA-256, size and source identity; verifyProjectView() recomputes them and
|
|
10
|
+
* requires the EXACT file set;
|
|
11
|
+
* - the view dies with the run: removeProjectView() on release/revocation and purgeProjectViews() at daemon start.
|
|
12
|
+
* ROOT MARKER: the reviewed process host only accepts an approved root that contains a `.git` entry. The view therefore carries an EMPTY `.git` directory created by the daemon: it holds no Git data (no
|
|
13
|
+
* objects, config or refs), is recorded in the manifest (`rootMarker`) and is re-verified to be empty. The reader refuses `.git` paths anyway, so it is never served.
|
|
14
|
+
* It does NOT touch, loosen or tighten the ACL of the original project. Whether a project the operator registered earlier still carries a RESTRICTED read grant is operator state; the
|
|
15
|
+
* acceptance probes measure it (a project without that grant is unreadable to the agent, a project with it is still readable by the agent directly - the view does not change that fact).
|
|
16
|
+
*/
|
|
17
|
+
export declare const PROJECT_VIEW_LIMITS: Readonly<{
|
|
18
|
+
maxFiles: 512;
|
|
19
|
+
maxFileBytes: 1048576;
|
|
20
|
+
maxTotalBytes: number;
|
|
21
|
+
maxDepth: 16;
|
|
22
|
+
}>;
|
|
23
|
+
export interface ProjectViewFileRecord {
|
|
24
|
+
readonly rel: string;
|
|
25
|
+
readonly bytes: number;
|
|
26
|
+
readonly sha256: string;
|
|
27
|
+
readonly sourceIdentity: string;
|
|
28
|
+
readonly sourceMtimeMs: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ProjectViewManifest {
|
|
31
|
+
readonly schema: 'my-centcom.project-view/1';
|
|
32
|
+
readonly viewId: string;
|
|
33
|
+
readonly projectId: string;
|
|
34
|
+
readonly runId: string;
|
|
35
|
+
readonly grantId: string;
|
|
36
|
+
readonly sourceRootSha256: string;
|
|
37
|
+
readonly createdAt: string;
|
|
38
|
+
readonly expiresAt: string;
|
|
39
|
+
readonly files: readonly ProjectViewFileRecord[];
|
|
40
|
+
readonly omitted: Readonly<Record<string, number>>;
|
|
41
|
+
readonly rootMarker: '.git (empty directory)';
|
|
42
|
+
}
|
|
43
|
+
export type ProjectViewDenied = 'SOURCE_INVALID' | 'VIEW_LIMIT_EXCEEDED' | 'VIEW_IO_FAILED' | 'VIEW_ID_INVALID';
|
|
44
|
+
export type ProjectViewResult = {
|
|
45
|
+
readonly ok: true;
|
|
46
|
+
readonly viewId: string;
|
|
47
|
+
readonly root: string;
|
|
48
|
+
readonly manifestPath: string;
|
|
49
|
+
readonly manifestSha256: string;
|
|
50
|
+
readonly files: number;
|
|
51
|
+
readonly bytes: number;
|
|
52
|
+
readonly omitted: Readonly<Record<string, number>>;
|
|
53
|
+
} | {
|
|
54
|
+
readonly ok: false;
|
|
55
|
+
readonly code: ProjectViewDenied;
|
|
56
|
+
};
|
|
57
|
+
export declare const manifestPathOf: (viewsRoot: string, viewId: string) => string;
|
|
58
|
+
/** Materialises the view. `sourceRoot` must be the canonical project root already established by the trusted authority; nothing else about the source is trusted. */
|
|
59
|
+
export declare function materializeProjectView(o: {
|
|
60
|
+
sourceRoot: string;
|
|
61
|
+
viewsRoot: string;
|
|
62
|
+
projectId: string;
|
|
63
|
+
runId: string;
|
|
64
|
+
grantId: string;
|
|
65
|
+
expiresAt: string;
|
|
66
|
+
now?: () => number;
|
|
67
|
+
viewId?: string;
|
|
68
|
+
}): ProjectViewResult;
|
|
69
|
+
export interface ProjectViewVerification {
|
|
70
|
+
readonly ok: boolean;
|
|
71
|
+
readonly problems: readonly string[];
|
|
72
|
+
readonly files: number;
|
|
73
|
+
}
|
|
74
|
+
/** Recomputes every digest and requires the EXACT file set of the manifest (no extra file, no missing file, no link, no changed byte). */
|
|
75
|
+
export declare function verifyProjectView(o: {
|
|
76
|
+
viewsRoot: string;
|
|
77
|
+
viewId: string;
|
|
78
|
+
expectedManifestSha256?: string;
|
|
79
|
+
}): ProjectViewVerification;
|
|
80
|
+
/** Removes one view and its manifest. Returns whether anything was removed. Refuses ids that are not generated view ids (no path is ever built from other input). */
|
|
81
|
+
export declare function removeProjectView(viewsRoot: string, viewId: string): boolean;
|
|
82
|
+
/** Daemon start: every view and manifest left by a previous incarnation belongs to a run that cannot resume. Returns the number of views removed. */
|
|
83
|
+
export declare function purgeProjectViews(viewsRoot: string): number;
|
|
84
|
+
export declare const isInsideView: (viewRoot: string, p: string) => boolean;
|
|
85
|
+
//# sourceMappingURL=projectViewService.d.ts.map
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
2
|
+
import { chmodSync, closeSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync, existsSync } from 'node:fs';
|
|
3
|
+
import { join, sep } from 'node:path';
|
|
4
|
+
import { PR_LIMITS, validateRelativePath } from './projectReadService.js';
|
|
5
|
+
/**
|
|
6
|
+
* C07 RUN-SCOPED PROJECT VIEW (SW-077). Provider-neutral; Node built-ins and the C07 path policy only.
|
|
7
|
+
*
|
|
8
|
+
* The trusted daemon materialises, for ONE run of ONE project under ONE grant, a private COPY of only the material the project-read policy would ever serve: regular files, no links or
|
|
9
|
+
* junctions, no hard-link aliases, no Git internals, no credentials, no nested repositories, bounded in count and size. The agent process is then pointed at the COPY (working directory and
|
|
10
|
+
* reader root) and is never granted the original project by this mechanism. Consequences, each pinned by tests:
|
|
11
|
+
* - a bypass of the reader (any tool the model might reach) can only reveal bytes the policy already allowed: the withheld material is not on the agent's side of the boundary at all;
|
|
12
|
+
* - the view is a snapshot: a later change to the source never changes an already approved view (copies, not links: NTFS hard links share one security descriptor and one content);
|
|
13
|
+
* - the view is integrity-checkable: a manifest OUTSIDE the view (not readable by the agent) records every file's SHA-256, size and source identity; verifyProjectView() recomputes them and
|
|
14
|
+
* requires the EXACT file set;
|
|
15
|
+
* - the view dies with the run: removeProjectView() on release/revocation and purgeProjectViews() at daemon start.
|
|
16
|
+
* ROOT MARKER: the reviewed process host only accepts an approved root that contains a `.git` entry. The view therefore carries an EMPTY `.git` directory created by the daemon: it holds no Git data (no
|
|
17
|
+
* objects, config or refs), is recorded in the manifest (`rootMarker`) and is re-verified to be empty. The reader refuses `.git` paths anyway, so it is never served.
|
|
18
|
+
* It does NOT touch, loosen or tighten the ACL of the original project. Whether a project the operator registered earlier still carries a RESTRICTED read grant is operator state; the
|
|
19
|
+
* acceptance probes measure it (a project without that grant is unreadable to the agent, a project with it is still readable by the agent directly - the view does not change that fact).
|
|
20
|
+
*/
|
|
21
|
+
export const PROJECT_VIEW_LIMITS = Object.freeze({ maxFiles: 512, maxFileBytes: PR_LIMITS.maxFileBytes, maxTotalBytes: 8 * 1024 * 1024, maxDepth: 16 });
|
|
22
|
+
const sha256 = (b) => createHash('sha256').update(b).digest('hex');
|
|
23
|
+
const VIEW_ID = /^view\.[A-Za-z0-9_-]{16,40}$/;
|
|
24
|
+
const idOf = (st) => `${st.dev.toString(16)}:${st.ino.toString(16)}`;
|
|
25
|
+
const manifestDirOf = (viewsRoot) => `${viewsRoot}.manifests`;
|
|
26
|
+
export const manifestPathOf = (viewsRoot, viewId) => join(manifestDirOf(viewsRoot), `${viewId}.json`);
|
|
27
|
+
function readFully(path, expectedIdentity, size) {
|
|
28
|
+
let fd = -1;
|
|
29
|
+
try {
|
|
30
|
+
fd = openSync(path, 'r');
|
|
31
|
+
const st = fstatSync(fd, { bigint: true });
|
|
32
|
+
if (!st.isFile() || idOf(st) !== expectedIdentity || Number(st.size) !== size || st.nlink !== 1n)
|
|
33
|
+
return undefined;
|
|
34
|
+
const buf = Buffer.alloc(size);
|
|
35
|
+
let n = 0;
|
|
36
|
+
while (n < size) {
|
|
37
|
+
const r = readSync(fd, buf, n, size - n, n);
|
|
38
|
+
if (r <= 0)
|
|
39
|
+
break;
|
|
40
|
+
n += r;
|
|
41
|
+
}
|
|
42
|
+
const extra = Buffer.alloc(1);
|
|
43
|
+
if (n !== size || readSync(fd, extra, 0, 1, size) !== 0)
|
|
44
|
+
return undefined; // shrank or grew while being copied
|
|
45
|
+
const st2 = fstatSync(fd, { bigint: true });
|
|
46
|
+
if (Number(st2.size) !== size || st2.mtimeNs !== st.mtimeNs)
|
|
47
|
+
return undefined;
|
|
48
|
+
return { bytes: buf, sourceMtimeMs: Number(st.mtimeMs) };
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
if (fd >= 0)
|
|
55
|
+
try {
|
|
56
|
+
closeSync(fd);
|
|
57
|
+
}
|
|
58
|
+
catch { /* closed */ }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Materialises the view. `sourceRoot` must be the canonical project root already established by the trusted authority; nothing else about the source is trusted. */
|
|
62
|
+
export function materializeProjectView(o) {
|
|
63
|
+
const now = o.now ?? Date.now;
|
|
64
|
+
const viewId = o.viewId ?? `view.${randomBytes(18).toString('base64url')}`;
|
|
65
|
+
if (!VIEW_ID.test(viewId))
|
|
66
|
+
return { ok: false, code: 'VIEW_ID_INVALID' };
|
|
67
|
+
let source;
|
|
68
|
+
try {
|
|
69
|
+
const st = lstatSync(o.sourceRoot);
|
|
70
|
+
if (!st.isDirectory() || st.isSymbolicLink())
|
|
71
|
+
return { ok: false, code: 'SOURCE_INVALID' };
|
|
72
|
+
source = realpathSync.native(o.sourceRoot);
|
|
73
|
+
if (process.platform === 'win32' ? source.toLowerCase() !== o.sourceRoot.toLowerCase() : source !== o.sourceRoot)
|
|
74
|
+
return { ok: false, code: 'SOURCE_INVALID' };
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return { ok: false, code: 'SOURCE_INVALID' };
|
|
78
|
+
}
|
|
79
|
+
const omitted = {};
|
|
80
|
+
const skip = (why) => { omitted[why] = (omitted[why] ?? 0) + 1; };
|
|
81
|
+
const files = [];
|
|
82
|
+
let total = 0;
|
|
83
|
+
let overLimit = false;
|
|
84
|
+
const walk = (dir, rel) => {
|
|
85
|
+
if (overLimit)
|
|
86
|
+
return;
|
|
87
|
+
if (rel.length >= PROJECT_VIEW_LIMITS.maxDepth) {
|
|
88
|
+
skip('depth');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
let names;
|
|
92
|
+
try {
|
|
93
|
+
names = readdirSync(dir).sort();
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
skip('unreadable_directory');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
for (const name of names) {
|
|
100
|
+
const parts = [...rel, name];
|
|
101
|
+
const full = join(dir, name);
|
|
102
|
+
let st;
|
|
103
|
+
try {
|
|
104
|
+
st = lstatSync(full, { bigint: true });
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
skip('vanished');
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (st.isSymbolicLink()) {
|
|
111
|
+
skip('link_or_junction');
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const policy = validateRelativePath(parts.join('/'), { allowRoot: false });
|
|
115
|
+
if (!policy.ok) {
|
|
116
|
+
skip(parts.length === 1 && name.toLowerCase() === '.git' ? 'git_internals' : 'policy_withheld');
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (st.isDirectory()) {
|
|
120
|
+
if (existsSync(join(full, '.git'))) {
|
|
121
|
+
skip('nested_repository');
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
walk(full, parts);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (!st.isFile()) {
|
|
128
|
+
skip('not_regular_file');
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (st.nlink !== 1n) {
|
|
132
|
+
skip('hard_link_alias');
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const size = Number(st.size);
|
|
136
|
+
if (size > PROJECT_VIEW_LIMITS.maxFileBytes) {
|
|
137
|
+
skip('oversize');
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (files.length >= PROJECT_VIEW_LIMITS.maxFiles || total + size > PROJECT_VIEW_LIMITS.maxTotalBytes) {
|
|
141
|
+
overLimit = true;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const got = readFully(full, idOf(st), size);
|
|
145
|
+
if (!got) {
|
|
146
|
+
skip('changed_during_copy');
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
total += size;
|
|
150
|
+
files.push({ rel: parts.join('/'), bytes: size, sha256: sha256(got.bytes), sourceIdentity: idOf(st), sourceMtimeMs: got.sourceMtimeMs, bytesBuf: got.bytes });
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
walk(source, []);
|
|
154
|
+
if (overLimit)
|
|
155
|
+
return { ok: false, code: 'VIEW_LIMIT_EXCEEDED' };
|
|
156
|
+
const root = join(o.viewsRoot, viewId);
|
|
157
|
+
const manifestFile = manifestPathOf(o.viewsRoot, viewId);
|
|
158
|
+
try {
|
|
159
|
+
mkdirSync(o.viewsRoot, { recursive: true });
|
|
160
|
+
mkdirSync(manifestDirOf(o.viewsRoot), { recursive: true });
|
|
161
|
+
mkdirSync(root);
|
|
162
|
+
for (const f of files) {
|
|
163
|
+
const to = join(root, ...f.rel.split('/'));
|
|
164
|
+
mkdirSync(join(to, '..'), { recursive: true });
|
|
165
|
+
writeFileSync(to, f.bytesBuf, { flag: 'wx' });
|
|
166
|
+
try {
|
|
167
|
+
chmodSync(to, 0o444);
|
|
168
|
+
}
|
|
169
|
+
catch { /* ACLs, not mode bits, protect the file on Windows */ }
|
|
170
|
+
}
|
|
171
|
+
mkdirSync(join(root, '.git')); // empty root marker, see the header
|
|
172
|
+
const manifest = {
|
|
173
|
+
schema: 'my-centcom.project-view/1', viewId, projectId: o.projectId, runId: o.runId, grantId: o.grantId, sourceRootSha256: sha256(source.toLowerCase()),
|
|
174
|
+
createdAt: new Date(now()).toISOString(), expiresAt: o.expiresAt, files: files.map(({ bytesBuf: _b, ...r }) => r), omitted, rootMarker: '.git (empty directory)',
|
|
175
|
+
};
|
|
176
|
+
const text = JSON.stringify(manifest);
|
|
177
|
+
const tmp = `${manifestFile}.tmp`;
|
|
178
|
+
writeFileSync(tmp, text, { encoding: 'utf8', flag: 'wx' });
|
|
179
|
+
renameSync(tmp, manifestFile);
|
|
180
|
+
return { ok: true, viewId, root: realpathSync.native(root), manifestPath: manifestFile, manifestSha256: sha256(text), files: files.length, bytes: total, omitted };
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
try {
|
|
184
|
+
rmSync(root, { recursive: true, force: true });
|
|
185
|
+
rmSync(manifestFile, { force: true });
|
|
186
|
+
}
|
|
187
|
+
catch { /* best effort */ }
|
|
188
|
+
return { ok: false, code: 'VIEW_IO_FAILED' };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/** Recomputes every digest and requires the EXACT file set of the manifest (no extra file, no missing file, no link, no changed byte). */
|
|
192
|
+
export function verifyProjectView(o) {
|
|
193
|
+
const problems = [];
|
|
194
|
+
if (!VIEW_ID.test(o.viewId))
|
|
195
|
+
return { ok: false, problems: ['view id invalid'], files: 0 };
|
|
196
|
+
let text;
|
|
197
|
+
let manifest;
|
|
198
|
+
try {
|
|
199
|
+
text = readFileSync(manifestPathOf(o.viewsRoot, o.viewId), 'utf8');
|
|
200
|
+
manifest = JSON.parse(text);
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
return { ok: false, problems: ['manifest unreadable'], files: 0 };
|
|
204
|
+
}
|
|
205
|
+
if (o.expectedManifestSha256 !== undefined && sha256(text) !== o.expectedManifestSha256)
|
|
206
|
+
problems.push('manifest changed');
|
|
207
|
+
if (manifest.schema !== 'my-centcom.project-view/1' || manifest.viewId !== o.viewId)
|
|
208
|
+
problems.push('manifest identity');
|
|
209
|
+
const root = join(o.viewsRoot, o.viewId);
|
|
210
|
+
const seen = new Set();
|
|
211
|
+
const walk = (dir, rel) => {
|
|
212
|
+
let names;
|
|
213
|
+
try {
|
|
214
|
+
names = readdirSync(dir);
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
problems.push('unreadable directory');
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
for (const n of names) {
|
|
221
|
+
const full = join(dir, n);
|
|
222
|
+
const parts = [...rel, n];
|
|
223
|
+
let st;
|
|
224
|
+
try {
|
|
225
|
+
st = lstatSync(full);
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
problems.push('vanished ' + parts.join('/'));
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (st.isSymbolicLink()) {
|
|
232
|
+
problems.push('link ' + parts.join('/'));
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (st.isDirectory()) {
|
|
236
|
+
if (rel.length === 0 && n === '.git') {
|
|
237
|
+
try {
|
|
238
|
+
if (readdirSync(full).length !== 0)
|
|
239
|
+
problems.push('root marker is not empty');
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
problems.push('root marker unreadable');
|
|
243
|
+
}
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
walk(full, parts);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (!st.isFile()) {
|
|
250
|
+
problems.push('not a regular file ' + parts.join('/'));
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
seen.add(parts.join('/'));
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
if (!existsSync(root))
|
|
257
|
+
problems.push('view directory missing');
|
|
258
|
+
else {
|
|
259
|
+
walk(root, []);
|
|
260
|
+
if (!existsSync(join(root, '.git')))
|
|
261
|
+
problems.push('root marker missing');
|
|
262
|
+
}
|
|
263
|
+
const want = new Map(manifest.files.map((f) => [f.rel, f]));
|
|
264
|
+
for (const rel of seen)
|
|
265
|
+
if (!want.has(rel))
|
|
266
|
+
problems.push('unexpected file ' + rel);
|
|
267
|
+
for (const [rel, f] of want) {
|
|
268
|
+
if (!seen.has(rel)) {
|
|
269
|
+
problems.push('missing file ' + rel);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
try {
|
|
273
|
+
const b = readFileSync(join(root, ...rel.split('/')));
|
|
274
|
+
if (b.length !== f.bytes || sha256(b) !== f.sha256)
|
|
275
|
+
problems.push('content changed ' + rel);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
problems.push('unreadable ' + rel);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return { ok: problems.length === 0, problems, files: want.size };
|
|
282
|
+
}
|
|
283
|
+
/** Removes one view and its manifest. Returns whether anything was removed. Refuses ids that are not generated view ids (no path is ever built from other input). */
|
|
284
|
+
export function removeProjectView(viewsRoot, viewId) {
|
|
285
|
+
if (!VIEW_ID.test(viewId))
|
|
286
|
+
return false;
|
|
287
|
+
let any = false;
|
|
288
|
+
const root = join(viewsRoot, viewId);
|
|
289
|
+
if (existsSync(root)) {
|
|
290
|
+
try {
|
|
291
|
+
rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
292
|
+
any = true;
|
|
293
|
+
}
|
|
294
|
+
catch { /* reported by existence below */ }
|
|
295
|
+
}
|
|
296
|
+
const m = manifestPathOf(viewsRoot, viewId);
|
|
297
|
+
if (existsSync(m)) {
|
|
298
|
+
try {
|
|
299
|
+
rmSync(m, { force: true });
|
|
300
|
+
any = true;
|
|
301
|
+
}
|
|
302
|
+
catch { /* best effort */ }
|
|
303
|
+
}
|
|
304
|
+
return any;
|
|
305
|
+
}
|
|
306
|
+
/** Daemon start: every view and manifest left by a previous incarnation belongs to a run that cannot resume. Returns the number of views removed. */
|
|
307
|
+
export function purgeProjectViews(viewsRoot) {
|
|
308
|
+
let n = 0;
|
|
309
|
+
for (const dir of [viewsRoot, manifestDirOf(viewsRoot)]) {
|
|
310
|
+
let names;
|
|
311
|
+
try {
|
|
312
|
+
names = readdirSync(dir);
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
for (const name of names) {
|
|
318
|
+
const id = name.replace(/\.json(\.tmp)?$/, '');
|
|
319
|
+
if (!VIEW_ID.test(id))
|
|
320
|
+
continue; // never touch anything that is not a generated view artifact
|
|
321
|
+
try {
|
|
322
|
+
rmSync(join(dir, name), { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
323
|
+
if (dir === viewsRoot)
|
|
324
|
+
n += 1;
|
|
325
|
+
}
|
|
326
|
+
catch { /* retried at the next start */ }
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return n;
|
|
330
|
+
}
|
|
331
|
+
export const isInsideView = (viewRoot, p) => (p.toLowerCase() + sep).startsWith(viewRoot.toLowerCase() + sep);
|
|
332
|
+
//# sourceMappingURL=projectViewService.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C07 PROPOSAL RECORDER (SW-080). The ONLY write capability in the MCP adapter's closure, deliberately isolated in its own tiny module so that the read service and the protocol
|
|
3
|
+
* adapter stay write-free (a source-inspection test pins both facts).
|
|
4
|
+
*
|
|
5
|
+
* It does one thing: create ONE new file, with an exclusive-create flag, whose name must match the fixed envelope pattern, inside the single directory it was constructed with.
|
|
6
|
+
* It never overwrites, deletes, renames, follows a caller-supplied path or touches the project. The content is data the daemon will re-validate before it believes any of it.
|
|
7
|
+
*/
|
|
8
|
+
export type RecordOutcome = 'OK' | 'EXISTS' | 'FAILED';
|
|
9
|
+
export declare const PROPOSAL_ENVELOPE_MAX_BYTES = 600000;
|
|
10
|
+
export declare function createProposalRecorder(dir: string): (fileName: string, text: string) => RecordOutcome;
|
|
11
|
+
//# sourceMappingURL=proposalRecorder.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
const NAME = /^cap\.[A-Za-z0-9_-]{16,64}\.[a-f0-9]{16}\.proposal\.json$/;
|
|
4
|
+
export const PROPOSAL_ENVELOPE_MAX_BYTES = 600_000;
|
|
5
|
+
export function createProposalRecorder(dir) {
|
|
6
|
+
return (fileName, text) => {
|
|
7
|
+
if (typeof fileName !== 'string' || !NAME.test(fileName) || typeof text !== 'string' || Buffer.byteLength(text, 'utf8') > PROPOSAL_ENVELOPE_MAX_BYTES)
|
|
8
|
+
return 'FAILED';
|
|
9
|
+
try {
|
|
10
|
+
mkdirSync(dir, { recursive: true });
|
|
11
|
+
writeFileSync(join(dir, fileName), text, { encoding: 'utf8', flag: 'wx' });
|
|
12
|
+
return 'OK';
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
return e.code === 'EEXIST' ? 'EXISTS' : 'FAILED';
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=proposalRecorder.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C06 PROVIDER-SPECIFIC adapter (SW-074): how the pinned Codex CLI (0.167.0) is told about the local read-only project MCP server.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is Codex's own `-c key=value` configuration surface (verified against rust-v0.167.0 config/src/mcp_types.rs and core/src/mcp_tool_call.rs and exercised by the
|
|
5
|
+
* non-model harness). Project identity, grants, path security and audit evidence are NOT here: they live in the provider-neutral C07 read service and capability issuer. Another
|
|
6
|
+
* coding agent gets its own sibling of this file; nothing in C07 or the MCP adapter changes for it.
|
|
7
|
+
*
|
|
8
|
+
* What the configuration does:
|
|
9
|
+
* - registers exactly ONE stdio server (an absolute node.exe running the reviewed adapter script; --preserve-symlinks[-main] because the restricted identity cannot lstat the user profile
|
|
10
|
+
* directories that Node's module loader would otherwise canonicalize, the same reason the reviewed reference profiles use them); no shell, no URL, no network transport;
|
|
11
|
+
* - forwards exactly two environment variables to it by NAME (the run-scoped capability file path and TEMP); their VALUES come from the host's trusted
|
|
12
|
+
* per-run environment, never from this file, the prompt or the model;
|
|
13
|
+
* - enables exactly the three reviewed tools (enabled_tools is an exact allowlist; any other tool the server might advertise is not exposed to the model);
|
|
14
|
+
* - sets approval_mode = "approve" for those three tools. With approval policy Never, Codex asks for approval only when a tool's mode requires it; "approve" never does.
|
|
15
|
+
* That is a convenience for Codex's own gate and NOT an authorization: the adapter independently authorizes every call against the run-scoped capability;
|
|
16
|
+
* - marks the server `required`, so a server that cannot start fails the run instead of silently continuing without it.
|
|
17
|
+
*/
|
|
18
|
+
/** The environment variable NAMES forwarded to the stdio server: the capability path (per-run, pinned file) and TEMP (the daemon-created scratch whose mcp-audit subdirectory takes the audit). */
|
|
19
|
+
export declare const CODEX_MCP_FORWARDED_ENV: readonly ["CENTCOM_PROJECT_READ_CAPABILITY", "TEMP"];
|
|
20
|
+
/**
|
|
21
|
+
* SW-075 MODEL-VISIBLE TOOL SURFACE (Codex 0.167.0, measured against the real pinned binary with the scripted endpoint; see the SW-075 report).
|
|
22
|
+
*
|
|
23
|
+
* This is a MODEL-VISIBLE restriction only: it removes tools from the list the model is offered. It does NOT revoke any operating-system permission of the Codex process.
|
|
24
|
+
*
|
|
25
|
+
* The model slug comes from the reviewed compatibility registry (codexModelCompatibility.ts) because the tool surface is a property of the model catalog entry, not only of the feature flags:
|
|
26
|
+
* classic-tool-mode slugs honour the flags below, while code-mode slugs (gpt-5.6-*, gpt-6*) ship a JavaScript `exec` orchestration tool and collaboration/sub-agent tools that no feature flag removes;
|
|
27
|
+
* those are reduced only by the reviewed, digest-pinned catalogue override. An unreviewed slug must never run this profile. SECURITY DOES NOT DEPEND ON THIS FILTERING ALONE: see the run-scoped project view.
|
|
28
|
+
*/
|
|
29
|
+
export { CODEX_MCP_ONLY_MODEL } from './codexModelCompatibility.js';
|
|
30
|
+
/** Feature flags turned OFF for the MCP-only profile: every built-in capability that reaches local resources, executes code, spawns agents or reaches the network. */
|
|
31
|
+
export declare const CODEX_MCP_ONLY_DISABLED_FEATURES: readonly ["shell_tool", "unified_exec", "view_image", "goals", "multi_agent", "multi_agent_v2", "image_generation", "apps", "plugins", "browser_use", "browser_use_external", "computer_use", "in_app_browser", "tool_suggest", "skill_search", "code_mode", "memories", "sleep_tool", "hooks"];
|
|
32
|
+
export declare function codexMcpOnlyToolSurfaceArgs(): string[];
|
|
33
|
+
export interface CodexProjectReadMcp {
|
|
34
|
+
readonly nodeExecutable: string;
|
|
35
|
+
readonly serverScript: string; /** the staged, digest-pinned MCP-only model catalogue (no apply_patch); see trustedAgentStaging.stageMcpOnlyModelCatalog */
|
|
36
|
+
readonly modelCatalog: string; /** SW-080: also enable the propose_change tool (only for a run holding a PROPOSE grant) */
|
|
37
|
+
readonly proposeTool?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function codexProjectReadMcpArgs(c: CodexProjectReadMcp): string[];
|
|
40
|
+
//# sourceMappingURL=codexMcpConfig.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { isAbsolute } from 'node:path';
|
|
2
|
+
import { CODEX_MCP_ONLY_MODEL as SELECTED_MODEL } from './codexModelCompatibility.js';
|
|
3
|
+
import { PROJECT_READ_CODEX_SERVER_ID, PROJECT_READ_ENV_CAPABILITY, PROJECT_READ_TOOLS, PROJECT_PROPOSE_TOOLS } from '../../../../../packages/contracts/dist/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* C06 PROVIDER-SPECIFIC adapter (SW-074): how the pinned Codex CLI (0.167.0) is told about the local read-only project MCP server.
|
|
6
|
+
*
|
|
7
|
+
* Everything here is Codex's own `-c key=value` configuration surface (verified against rust-v0.167.0 config/src/mcp_types.rs and core/src/mcp_tool_call.rs and exercised by the
|
|
8
|
+
* non-model harness). Project identity, grants, path security and audit evidence are NOT here: they live in the provider-neutral C07 read service and capability issuer. Another
|
|
9
|
+
* coding agent gets its own sibling of this file; nothing in C07 or the MCP adapter changes for it.
|
|
10
|
+
*
|
|
11
|
+
* What the configuration does:
|
|
12
|
+
* - registers exactly ONE stdio server (an absolute node.exe running the reviewed adapter script; --preserve-symlinks[-main] because the restricted identity cannot lstat the user profile
|
|
13
|
+
* directories that Node's module loader would otherwise canonicalize, the same reason the reviewed reference profiles use them); no shell, no URL, no network transport;
|
|
14
|
+
* - forwards exactly two environment variables to it by NAME (the run-scoped capability file path and TEMP); their VALUES come from the host's trusted
|
|
15
|
+
* per-run environment, never from this file, the prompt or the model;
|
|
16
|
+
* - enables exactly the three reviewed tools (enabled_tools is an exact allowlist; any other tool the server might advertise is not exposed to the model);
|
|
17
|
+
* - sets approval_mode = "approve" for those three tools. With approval policy Never, Codex asks for approval only when a tool's mode requires it; "approve" never does.
|
|
18
|
+
* That is a convenience for Codex's own gate and NOT an authorization: the adapter independently authorizes every call against the run-scoped capability;
|
|
19
|
+
* - marks the server `required`, so a server that cannot start fails the run instead of silently continuing without it.
|
|
20
|
+
*/
|
|
21
|
+
/** The environment variable NAMES forwarded to the stdio server: the capability path (per-run, pinned file) and TEMP (the daemon-created scratch whose mcp-audit subdirectory takes the audit). */
|
|
22
|
+
export const CODEX_MCP_FORWARDED_ENV = [PROJECT_READ_ENV_CAPABILITY, 'TEMP'];
|
|
23
|
+
/**
|
|
24
|
+
* SW-075 MODEL-VISIBLE TOOL SURFACE (Codex 0.167.0, measured against the real pinned binary with the scripted endpoint; see the SW-075 report).
|
|
25
|
+
*
|
|
26
|
+
* This is a MODEL-VISIBLE restriction only: it removes tools from the list the model is offered. It does NOT revoke any operating-system permission of the Codex process.
|
|
27
|
+
*
|
|
28
|
+
* The model slug comes from the reviewed compatibility registry (codexModelCompatibility.ts) because the tool surface is a property of the model catalog entry, not only of the feature flags:
|
|
29
|
+
* classic-tool-mode slugs honour the flags below, while code-mode slugs (gpt-5.6-*, gpt-6*) ship a JavaScript `exec` orchestration tool and collaboration/sub-agent tools that no feature flag removes;
|
|
30
|
+
* those are reduced only by the reviewed, digest-pinned catalogue override. An unreviewed slug must never run this profile. SECURITY DOES NOT DEPEND ON THIS FILTERING ALONE: see the run-scoped project view.
|
|
31
|
+
*/
|
|
32
|
+
export { CODEX_MCP_ONLY_MODEL } from './codexModelCompatibility.js'; // SW-077: chosen by the reviewed compatibility registry, never pinned here
|
|
33
|
+
/** Feature flags turned OFF for the MCP-only profile: every built-in capability that reaches local resources, executes code, spawns agents or reaches the network. */
|
|
34
|
+
export const CODEX_MCP_ONLY_DISABLED_FEATURES = [
|
|
35
|
+
'shell_tool', 'unified_exec', 'view_image', 'goals', 'multi_agent', 'multi_agent_v2', 'image_generation', 'apps', 'plugins', 'browser_use', 'browser_use_external',
|
|
36
|
+
'computer_use', 'in_app_browser', 'tool_suggest', 'skill_search', 'code_mode', 'memories', 'sleep_tool', 'hooks',
|
|
37
|
+
];
|
|
38
|
+
export function codexMcpOnlyToolSurfaceArgs() {
|
|
39
|
+
return [
|
|
40
|
+
'-c', `model=${toml(SELECTED_MODEL)}`,
|
|
41
|
+
'-c', 'web_search="disabled"',
|
|
42
|
+
// Built-in project READS that reach the model outside the MCP policy (measured, SW-075): AGENTS.md / AGENTS.override.md project documents and SKILL.md skill descriptions. Both are switched off.
|
|
43
|
+
'-c', 'project_doc_max_bytes=0',
|
|
44
|
+
'-c', 'skills={include_instructions=false}',
|
|
45
|
+
// ONE inline table (2 argv entries): the bounded process host caps argv at 64 entries, and the argv cap is not weakened for this.
|
|
46
|
+
'-c', `features={${CODEX_MCP_ONLY_DISABLED_FEATURES.map((f) => `${f}=false`).join(',')}}`,
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
const CONTROL = /[\u0000-\u001f\u007f]/;
|
|
50
|
+
const toml = (v) => JSON.stringify(v); // a JSON string is a valid TOML basic string for these (printable, escaped) values
|
|
51
|
+
export function codexProjectReadMcpArgs(c) {
|
|
52
|
+
for (const p of [c.nodeExecutable, c.serverScript, c.modelCatalog]) {
|
|
53
|
+
if (typeof p !== 'string' || !isAbsolute(p) || CONTROL.test(p) || p.split(/[\\/]+/).includes('..'))
|
|
54
|
+
throw new Error('CODEX_MCP_CONFIG_INVALID');
|
|
55
|
+
}
|
|
56
|
+
const id = `mcp_servers.${PROJECT_READ_CODEX_SERVER_ID}`;
|
|
57
|
+
// SW-080: the proposal tool is offered ONLY when the trusted composition asks for it (the run holds a PROPOSE grant); the default surface is unchanged.
|
|
58
|
+
const tools = c.proposeTool === true ? [...PROJECT_READ_TOOLS, ...PROJECT_PROPOSE_TOOLS] : PROJECT_READ_TOOLS;
|
|
59
|
+
const kv = (k, v) => ['-c', `${k}=${v}`];
|
|
60
|
+
return [
|
|
61
|
+
...codexMcpOnlyToolSurfaceArgs(),
|
|
62
|
+
...kv('model_catalog_json', toml(c.modelCatalog)),
|
|
63
|
+
...kv(`${id}.command`, toml(c.nodeExecutable)),
|
|
64
|
+
...kv(`${id}.args`, `[${toml("--preserve-symlinks")},${toml("--preserve-symlinks-main")},${toml(c.serverScript)}]`),
|
|
65
|
+
...kv(`${id}.env_vars`, `[${CODEX_MCP_FORWARDED_ENV.map(toml).join(',')}]`),
|
|
66
|
+
...kv(`${id}.enabled_tools`, `[${tools.map(toml).join(',')}]`),
|
|
67
|
+
...kv(`${id}.required`, 'true'),
|
|
68
|
+
...kv(`${id}.startup_timeout_sec`, '20'),
|
|
69
|
+
...kv(`${id}.tool_timeout_sec`, '30'),
|
|
70
|
+
...tools.flatMap((t) => kv(`${id}.tools.${t}.approval_mode`, '"approve"')),
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=codexMcpConfig.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C06 PROVIDER-SPECIFIC (Codex) MODEL COMPATIBILITY REGISTRY (SW-077). The ONLY place a Codex model slug is chosen for the MCP-only profile.
|
|
3
|
+
*
|
|
4
|
+
* Five different facts must never be conflated (a listing is not an entitlement):
|
|
5
|
+
* RECOGNIZED ...... the installed binary's bundled catalogue (`codex debug models`) contains the slug.
|
|
6
|
+
* ADVERTISED ...... a catalogue / backend list shows it (here: the account-scoped list the backend returned to `model/list` for the isolated sign-in).
|
|
7
|
+
* OFFICIAL ........ OpenAI documentation says the authentication method supports it.
|
|
8
|
+
* ENTITLED ........ this account may actually run inference with it. Provable ONLY by a successful inference request; a provider refusal proves the opposite.
|
|
9
|
+
* COMPATIBLE ...... its tool surface can be reduced to the reviewed MCP-only surface (verified offline against the pinned binary with a scripted endpoint).
|
|
10
|
+
* `entitlement` below is therefore REFUSED_BY_PROVIDER or ACCEPTED_BY_PROVIDER ONLY when a real inference request was observed to be refused / accepted (SW-076, SW-078); everything else is UNVERIFIED.
|
|
11
|
+
*
|
|
12
|
+
* No automatic fallback: selection returns exactly the one SELECTED record. A model that the provider refused is marked UNSUPPORTED and can never be selected again;
|
|
13
|
+
* choosing another model is a reviewed code change (a new SELECTED record plus a reviewed catalogue derivation), never a runtime decision.
|
|
14
|
+
*/
|
|
15
|
+
export type CodexModelStatus = 'UNSUPPORTED' | 'SELECTED' | 'CANDIDATE_NOT_REVIEWED';
|
|
16
|
+
export type CodexModelEntitlement = 'REFUSED_BY_PROVIDER' | 'ACCEPTED_BY_PROVIDER' | 'UNVERIFIED';
|
|
17
|
+
export interface CodexModelEvidence {
|
|
18
|
+
readonly source: string;
|
|
19
|
+
readonly observation: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CodexModelRecord {
|
|
22
|
+
readonly slug: string;
|
|
23
|
+
readonly status: CodexModelStatus;
|
|
24
|
+
readonly entitlement: CodexModelEntitlement;
|
|
25
|
+
/** The vendor catalogue's tool mode for the slug (what the model would expose WITHOUT the reviewed override). */
|
|
26
|
+
readonly vendorToolMode: 'classic' | 'code_mode_only';
|
|
27
|
+
readonly recognizedByBinary: boolean;
|
|
28
|
+
readonly advertisedByBackendListForThisSignIn: boolean;
|
|
29
|
+
readonly evidence: readonly CodexModelEvidence[];
|
|
30
|
+
readonly constraints: readonly string[];
|
|
31
|
+
}
|
|
32
|
+
/** Facts recorded about the environment in which the evidence was gathered. */
|
|
33
|
+
export declare const CODEX_COMPATIBILITY_CONTEXT: Readonly<{
|
|
34
|
+
codexVersion: "0.167.0";
|
|
35
|
+
authMethod: "ChatGPT sign-in (isolated CODEX_HOME)";
|
|
36
|
+
recordedAt: "2026-11-09";
|
|
37
|
+
discovery: "codex app-server `model/list` (includeHidden) against the isolated sign-in: a NON-inference request answered by the backend; bundled catalogue via `codex debug models`";
|
|
38
|
+
}>;
|
|
39
|
+
export declare const CODEX_MODEL_COMPATIBILITY: readonly CodexModelRecord[];
|
|
40
|
+
export declare class ModelSelectionError extends Error {
|
|
41
|
+
readonly code: 'NO_SELECTED_MODEL' | 'MULTIPLE_SELECTED_MODELS' | 'SELECTED_MODEL_UNSUPPORTED';
|
|
42
|
+
constructor(code: 'NO_SELECTED_MODEL' | 'MULTIPLE_SELECTED_MODELS' | 'SELECTED_MODEL_UNSUPPORTED', message: string);
|
|
43
|
+
}
|
|
44
|
+
/** Exactly one reviewed SELECTED record, and never one the provider refused. Deterministic: no environment, no account state, no fallback. */
|
|
45
|
+
export declare function selectCodexModelForMcp(records?: readonly CodexModelRecord[]): CodexModelRecord;
|
|
46
|
+
export declare const CODEX_MCP_ONLY_MODEL: string;
|
|
47
|
+
/** True when `slug` is known to be refused for this authentication method (used by classifiers and the gate to avoid re-trying a refused model). */
|
|
48
|
+
export declare const isRefusedModel: (slug: string) => boolean;
|
|
49
|
+
//# sourceMappingURL=codexModelCompatibility.d.ts.map
|