codiedev 0.10.0-beta.5 → 0.10.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/captureSignals.js +2 -0
- package/dist/cli.js +38 -50
- package/dist/codexHookTrust.js +67 -4
- package/dist/codie.js +23 -74
- package/dist/codieLauncher.js +18 -22
- package/dist/commands/agentTemplates.generated.js +136 -0
- package/dist/commands/agents.js +1068 -0
- package/dist/commands/agentsSdk.generated.js +7 -0
- package/dist/commands/doctor.js +12 -38
- package/dist/commands/evals.js +187 -0
- package/dist/commands/pack.js +1 -1
- package/dist/commands/traces.js +79 -15
- package/dist/commands/tracesLabel.js +348 -0
- package/dist/connect.js +11 -52
- package/dist/copilotHooks.js +0 -4
- package/dist/cursorHooks.js +0 -15
- package/dist/harnessDirs.js +4 -0
- package/dist/hook.js +33 -197
- package/dist/limitEventReporter.js +1 -1
- package/dist/managedPi.js +240 -0
- package/dist/mcp.js +0 -307
- package/dist/packs/harnesses.js +40 -3
- package/dist/packs/install.js +2 -1
- package/dist/piHooks.js +216 -0
- package/dist/piRuntime.js +120 -0
- package/dist/selfUpdate.js +47 -2
- package/dist/utils.js +232 -115
- package/package.json +5 -7
- package/dist/codieStartup.js +0 -27
- package/dist/commands/promote.js +0 -53
- package/dist/commands/react.js +0 -38
- package/dist/commands/reverseTicket.js +0 -444
- package/dist/commands/security.js +0 -156
- package/dist/prUrl.js +0 -28
- package/dist/security.js +0 -417
- package/dist/securityDeepScan.js +0 -235
- package/dist/securityDoctor.js +0 -61
- package/dist/securityFeature.js +0 -6
- package/dist/securityInstall.js +0 -232
- package/dist/securityInventory.js +0 -566
- package/dist/securityPilot.js +0 -59
- package/dist/securityPolicy.js +0 -181
- package/dist/securitySession.js +0 -72
package/dist/securityPolicy.js
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.BUILT_IN_POLICY_KEYS = void 0;
|
|
37
|
-
exports.trustedPolicyKeysFromEnvironment = trustedPolicyKeysFromEnvironment;
|
|
38
|
-
exports.verifyEndpointSecurityPolicySignature = verifyEndpointSecurityPolicySignature;
|
|
39
|
-
exports.readEndpointSecurityPolicy = readEndpointSecurityPolicy;
|
|
40
|
-
exports.inspectEndpointSecurityPolicy = inspectEndpointSecurityPolicy;
|
|
41
|
-
exports.writeEndpointSecurityPolicy = writeEndpointSecurityPolicy;
|
|
42
|
-
exports.syncEndpointSecurityPolicy = syncEndpointSecurityPolicy;
|
|
43
|
-
const fs = __importStar(require("fs"));
|
|
44
|
-
const crypto = __importStar(require("crypto"));
|
|
45
|
-
const http = __importStar(require("http"));
|
|
46
|
-
const https = __importStar(require("https"));
|
|
47
|
-
const path = __importStar(require("path"));
|
|
48
|
-
const configDir_1 = require("./configDir");
|
|
49
|
-
const security_1 = require("./security");
|
|
50
|
-
const version_1 = require("./version");
|
|
51
|
-
const POLICY_FILE = "security-policy.json";
|
|
52
|
-
function policyFile(companyId) {
|
|
53
|
-
if (!companyId)
|
|
54
|
-
return POLICY_FILE;
|
|
55
|
-
const scope = companyId.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 128);
|
|
56
|
-
return `security-policy.${scope}.json`;
|
|
57
|
-
}
|
|
58
|
-
exports.BUILT_IN_POLICY_KEYS = {
|
|
59
|
-
"codiedev-prod-2026-01": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA0H+UISjTn4zhd6Pk9YmrMBqnJEJmv9fXoavXorlV2cU=\n-----END PUBLIC KEY-----\n",
|
|
60
|
-
};
|
|
61
|
-
function stableJson(value) {
|
|
62
|
-
if (Array.isArray(value))
|
|
63
|
-
return `[${value.map(stableJson).join(",")}]`;
|
|
64
|
-
if (value && typeof value === "object") {
|
|
65
|
-
return `{${Object.entries(value)
|
|
66
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
67
|
-
.map(([key, child]) => `${JSON.stringify(key)}:${stableJson(child)}`)
|
|
68
|
-
.join(",")}}`;
|
|
69
|
-
}
|
|
70
|
-
return JSON.stringify(value) ?? "null";
|
|
71
|
-
}
|
|
72
|
-
function trustedPolicyKeysFromEnvironment(env = process.env) {
|
|
73
|
-
const raw = env.CODIEDEV_SECURITY_POLICY_PUBLIC_KEYS;
|
|
74
|
-
if (!raw)
|
|
75
|
-
return { ...exports.BUILT_IN_POLICY_KEYS };
|
|
76
|
-
try {
|
|
77
|
-
const parsed = JSON.parse(raw);
|
|
78
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
79
|
-
return { ...exports.BUILT_IN_POLICY_KEYS };
|
|
80
|
-
const configured = Object.fromEntries(Object.entries(parsed)
|
|
81
|
-
.filter((entry) => typeof entry[1] === "string"));
|
|
82
|
-
return { ...configured, ...exports.BUILT_IN_POLICY_KEYS };
|
|
83
|
-
}
|
|
84
|
-
catch {
|
|
85
|
-
return { ...exports.BUILT_IN_POLICY_KEYS };
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function verifyEndpointSecurityPolicySignature(policy, trustedKeys = trustedPolicyKeysFromEnvironment()) {
|
|
89
|
-
const configuredKeys = Object.keys(trustedKeys);
|
|
90
|
-
if (configuredKeys.length === 0) {
|
|
91
|
-
return { ok: true, trusted: false, detail: "no endpoint policy public keys are pinned" };
|
|
92
|
-
}
|
|
93
|
-
const envelope = policy.signature;
|
|
94
|
-
if (!envelope || envelope.algorithm !== "Ed25519") {
|
|
95
|
-
return { ok: false, trusted: false, detail: "policy signature is missing" };
|
|
96
|
-
}
|
|
97
|
-
const publicKey = trustedKeys[envelope.keyId];
|
|
98
|
-
if (!publicKey)
|
|
99
|
-
return { ok: false, trusted: false, detail: `policy signing key ${envelope.keyId} is not trusted` };
|
|
100
|
-
const unsigned = { ...policy };
|
|
101
|
-
delete unsigned.signature;
|
|
102
|
-
try {
|
|
103
|
-
const ok = crypto.verify(null, Buffer.from(`${envelope.signedAt}.${stableJson(unsigned)}`), crypto.createPublicKey(publicKey), Buffer.from(envelope.value, "base64"));
|
|
104
|
-
return ok
|
|
105
|
-
? { ok: true, trusted: true, detail: `verified with ${envelope.keyId}` }
|
|
106
|
-
: { ok: false, trusted: false, detail: "policy signature does not match its content" };
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
return { ok: false, trusted: false, detail: `policy signature could not be verified: ${error.message}` };
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function readEndpointSecurityPolicy(stateDir = (0, configDir_1.codiedevStateDir)(), trustedKeys = trustedPolicyKeysFromEnvironment(), companyId) {
|
|
113
|
-
const inspection = inspectEndpointSecurityPolicy(stateDir, trustedKeys, companyId);
|
|
114
|
-
return inspection.verification.ok ? inspection.policy : undefined;
|
|
115
|
-
}
|
|
116
|
-
function inspectEndpointSecurityPolicy(stateDir = (0, configDir_1.codiedevStateDir)(), trustedKeys = trustedPolicyKeysFromEnvironment(), companyId) {
|
|
117
|
-
const target = path.join(stateDir, policyFile(companyId));
|
|
118
|
-
if (!fs.existsSync(target)) {
|
|
119
|
-
return { exists: false, verification: { ok: true, trusted: false, detail: "no cached endpoint policy" } };
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
const value = JSON.parse(fs.readFileSync(target, "utf8"));
|
|
123
|
-
if (value?.schemaVersion !== 1 || !["alert", "block"].includes(value.enforcementMode)) {
|
|
124
|
-
return { exists: true, verification: { ok: false, trusted: false, detail: "cached endpoint policy has an invalid schema" } };
|
|
125
|
-
}
|
|
126
|
-
const policy = value;
|
|
127
|
-
return { exists: true, policy, verification: verifyEndpointSecurityPolicySignature(policy, trustedKeys) };
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
return { exists: true, verification: { ok: false, trusted: false, detail: `cached endpoint policy could not be read: ${error.message}` } };
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function writeEndpointSecurityPolicy(policy, stateDir = (0, configDir_1.codiedevStateDir)(), trustedKeys = trustedPolicyKeysFromEnvironment(), companyId) {
|
|
134
|
-
const verification = verifyEndpointSecurityPolicySignature(policy, trustedKeys);
|
|
135
|
-
if (!verification.ok)
|
|
136
|
-
throw new Error(`Refusing untrusted endpoint policy: ${verification.detail}`);
|
|
137
|
-
fs.mkdirSync(stateDir, { recursive: true, mode: 0o700 });
|
|
138
|
-
const target = path.join(stateDir, policyFile(companyId));
|
|
139
|
-
const temporary = `${target}.${process.pid}.tmp`;
|
|
140
|
-
fs.writeFileSync(temporary, `${JSON.stringify(policy, null, 2)}\n`, { mode: 0o600 });
|
|
141
|
-
fs.chmodSync(temporary, 0o600);
|
|
142
|
-
fs.renameSync(temporary, target);
|
|
143
|
-
}
|
|
144
|
-
async function syncEndpointSecurityPolicy(config, source, timeoutMs = 3_000, stateDir = (0, configDir_1.codiedevStateDir)(), trustedKeys = trustedPolicyKeysFromEnvironment()) {
|
|
145
|
-
const url = new URL("/api/cli/securityPolicy", config.backendUrl);
|
|
146
|
-
if (source)
|
|
147
|
-
url.searchParams.set("source", source);
|
|
148
|
-
const cachedPolicy = readEndpointSecurityPolicy(stateDir, trustedKeys, config.companyId);
|
|
149
|
-
url.searchParams.set("securityRuntimeVersion", String(security_1.SECURITY_RUNTIME_VERSION));
|
|
150
|
-
url.searchParams.set("cliVersion", version_1.CLI_VERSION);
|
|
151
|
-
if (cachedPolicy?.policyVersion)
|
|
152
|
-
url.searchParams.set("securityPolicyVersion", String(cachedPolicy.policyVersion));
|
|
153
|
-
if (config.deviceId)
|
|
154
|
-
url.searchParams.set("endpointId", config.deviceId);
|
|
155
|
-
const transport = url.protocol === "https:" ? https : http;
|
|
156
|
-
const policy = await new Promise((resolve, reject) => {
|
|
157
|
-
const request = transport.request(url, {
|
|
158
|
-
method: "GET",
|
|
159
|
-
headers: { Authorization: `Bearer ${config.token}`, Accept: "application/json" },
|
|
160
|
-
}, (response) => {
|
|
161
|
-
let raw = "";
|
|
162
|
-
response.setEncoding("utf8");
|
|
163
|
-
response.on("data", (chunk) => { raw += chunk; });
|
|
164
|
-
response.on("end", () => {
|
|
165
|
-
if ((response.statusCode ?? 500) >= 300)
|
|
166
|
-
return reject(new Error(`policy_http_${response.statusCode}`));
|
|
167
|
-
try {
|
|
168
|
-
resolve(JSON.parse(raw));
|
|
169
|
-
}
|
|
170
|
-
catch {
|
|
171
|
-
reject(new Error("invalid policy response"));
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
request.setTimeout(timeoutMs, () => request.destroy(new Error(`policy sync timeout after ${timeoutMs}ms`)));
|
|
176
|
-
request.on("error", reject);
|
|
177
|
-
request.end();
|
|
178
|
-
});
|
|
179
|
-
writeEndpointSecurityPolicy(policy, stateDir, trustedKeys, config.companyId);
|
|
180
|
-
return policy;
|
|
181
|
-
}
|
package/dist/securitySession.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.readSessionSecuritySignal = readSessionSecuritySignal;
|
|
37
|
-
exports.recordSensitiveReadSignal = recordSensitiveReadSignal;
|
|
38
|
-
const fs = __importStar(require("fs"));
|
|
39
|
-
const path = __importStar(require("path"));
|
|
40
|
-
const configDir_1 = require("./configDir");
|
|
41
|
-
const SIGNAL_FILE = "security-session-signals.json";
|
|
42
|
-
const MAX_AGE_MS = 2 * 60 * 60 * 1_000;
|
|
43
|
-
function readSignals(stateDir, now) {
|
|
44
|
-
try {
|
|
45
|
-
const parsed = JSON.parse(fs.readFileSync(path.join(stateDir, SIGNAL_FILE), "utf8"));
|
|
46
|
-
if (parsed.schemaVersion !== 1 || !parsed.sessions || typeof parsed.sessions !== "object")
|
|
47
|
-
throw new Error("invalid signals");
|
|
48
|
-
parsed.sessions = Object.fromEntries(Object.entries(parsed.sessions)
|
|
49
|
-
.filter(([, signal]) => signal.sensitiveReadAt && now - signal.sensitiveReadAt <= MAX_AGE_MS)
|
|
50
|
-
.slice(-250));
|
|
51
|
-
return parsed;
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
return { schemaVersion: 1, sessions: {} };
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function readSessionSecuritySignal(sessionId, stateDir = (0, configDir_1.codiedevStateDir)(), now = Date.now()) {
|
|
58
|
-
if (!sessionId)
|
|
59
|
-
return undefined;
|
|
60
|
-
return readSignals(stateDir, now).sessions[sessionId];
|
|
61
|
-
}
|
|
62
|
-
function recordSensitiveReadSignal(sessionId, stateDir = (0, configDir_1.codiedevStateDir)(), now = Date.now()) {
|
|
63
|
-
if (!sessionId)
|
|
64
|
-
return;
|
|
65
|
-
const signals = readSignals(stateDir, now);
|
|
66
|
-
signals.sessions[sessionId] = { sensitiveReadAt: now };
|
|
67
|
-
fs.mkdirSync(stateDir, { recursive: true, mode: 0o700 });
|
|
68
|
-
const target = path.join(stateDir, SIGNAL_FILE);
|
|
69
|
-
const temporary = `${target}.${process.pid}.tmp`;
|
|
70
|
-
fs.writeFileSync(temporary, `${JSON.stringify(signals)}\n`, { mode: 0o600 });
|
|
71
|
-
fs.renameSync(temporary, target);
|
|
72
|
-
}
|