@agenthippo-ai/agenthippo 0.2.3-dataplane → 1.110.11
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/out/agentpack/index.js +3 -1
- package/out/agentpack/paths.js +25 -2
- package/out/analytics/dashboard/localFleetAdapter.js +82 -2
- package/out/analytics/dashboard/provider.js +13 -2
- package/out/analytics/dashboard/webview/panel.js +3 -2
- package/out/analytics/identity.js +0 -0
- package/out/analytics/service.js +29 -25
- package/out/analytics/sessionEvents.js +100 -24
- package/out/auth/authBaseUrl.js +59 -0
- package/out/auth/bootstrapApply.js +9 -10
- package/out/auth/brokerClient.js +48 -14
- package/out/auth/provider.js +8 -21
- package/out/auth/sessionStore.js +3 -40
- package/out/auth/signInFlow.js +2 -1
- package/out/auth-broker/config.js +50 -5
- package/out/auth-broker/server.js +126 -26
- package/out/auth-broker/store.js +25 -24
- package/out/authority/warrant.js +206 -0
- package/out/branding.js +27 -1
- package/out/cli/commands/conformance.js +249 -0
- package/out/cli/commands/data-plane.js +151 -0
- package/out/cli/commands/deploy.js +1 -0
- package/out/cli/commands/gateway.js +4 -0
- package/out/cli/commands/pack.js +182 -3
- package/out/cli/commands/sandbox.js +351 -0
- package/out/cli/commands/serve.js +1145 -130
- package/out/cli/commands/store.js +12 -4
- package/out/cli/credential-context.js +17 -0
- package/out/cli/data-plane/gateway.js +28 -5
- package/out/cli/data-plane/index.js +18 -2
- package/out/cli/data-plane/registry.js +9 -0
- package/out/cli/data-plane/remote.js +106 -0
- package/out/cli/data-plane/sidecar.js +225 -0
- package/out/cli/deploy/layers/identity.js +88 -4
- package/out/cli/deploy-init.js +89 -24
- package/out/cli/deps.js +106 -2
- package/out/cli/idp-init.js +35 -0
- package/out/cli/index.js +171 -17
- package/out/cli/pack-install-ref.js +15 -0
- package/out/cli/pack-loader.js +8 -1
- package/out/cli/pack-runtime.js +61 -0
- package/out/cli/runtime.js +35 -1
- package/out/cli/serve-hardening.js +260 -14
- package/out/cli/utils.js +12 -1
- package/out/engines/base.js +32 -3
- package/out/engines/claude.js +33 -15
- package/out/engines/codex.js +111 -27
- package/out/engines/custom.js +15 -1
- package/out/evidence/sessionShip.js +643 -0
- package/out/extension.js +11 -2
- package/out/gateway/bridge.js +40 -2
- package/out/gateway/client.js +34 -1
- package/out/gateway/installSource.js +68 -0
- package/out/gateway/lifecycle.js +185 -51
- package/out/gateway/outboundPaths.js +4 -1
- package/out/gateway/secretsPreflight.js +90 -0
- package/out/gateway/service.js +7 -2
- package/out/headless/index.js +25 -2
- package/out/live-e2e/mcp-demo/server.mjs +32 -0
- package/out/mcp.js +30 -0
- package/out/pack/caps.js +271 -0
- package/out/pack/governor.js +326 -0
- package/out/pack/lease-schema.js +273 -0
- package/out/pack/lease.js +682 -0
- package/out/pack/reconcile.js +217 -0
- package/out/pack/signature.js +839 -0
- package/out/remote/handleRemoteChat.js +44 -3
- package/out/remote/remoteTrust.js +277 -0
- package/out/remote/serveClient.js +52 -5
- package/out/runner/host.js +141 -0
- package/out/runner/protocol.js +128 -0
- package/out/runner/remoteEngine.js +166 -0
- package/out/runtime/interfaces/edit-tracker.js +2 -0
- package/out/runtime/vscode/vscode-edit-tracker.js +2 -0
- package/out/sandbox/containerDriver.js +572 -0
- package/out/sandbox/processDriver.js +318 -0
- package/out/sandbox/sandboxRunner.js +303 -0
- package/out/sandbox/support.js +301 -0
- package/out/sandbox/types.js +55 -0
- package/out/scripts/agentide-litellm.sh +67 -5
- package/out/scripts/agentide_litellm_hooks_v1.py +266 -21
- package/out/scripts/analytics/agentide-litellm-otel.config.yaml +98 -132
- package/out/scripts/analytics/setup-analytics.ps1 +45 -14
- package/out/scripts/analytics/setup-analytics.sh +106 -15
- package/out/scripts/analytics/start-analytics.sh +86 -14
- package/out/scripts/gateway/setup-gateway.sh +72 -32
- package/out/shared/models.js +11 -110
- package/out/spotlight/install.js +7 -1
- package/out/store/index.js +41 -10
- package/out/sync.js +3 -1
- package/out/test/analytics.test.js +162 -23
- package/out/test/auth-baseurl.test.js +132 -0
- package/out/test/auth-bootstrapApply.test.js +27 -6
- package/out/test/auth-broker-hardening.test.js +227 -0
- package/out/test/auth-broker.test.js +59 -9
- package/out/test/branding.test.js +13 -0
- package/out/test/caps-governor.test.js +460 -0
- package/out/test/codex-new-file-survival.test.js +119 -0
- package/out/test/configuration-scopes.test.js +131 -0
- package/out/test/data-plane-engine-wiring.test.js +32 -0
- package/out/test/data-plane.test.js +380 -0
- package/out/test/deploy-init.test.js +47 -1
- package/out/test/gateway-client.test.js +28 -0
- package/out/test/gateway-install-source.test.js +111 -0
- package/out/test/gateway-lifecycle.test.js +1 -1
- package/out/test/gateway-outbound.test.js +7 -0
- package/out/test/gateway-secrets-preflight.test.js +127 -0
- package/out/test/gateway-session-routing.test.js +18 -0
- package/out/test/governor-hardening.test.js +222 -0
- package/out/test/headless-sync.test.js +22 -0
- package/out/test/lease-signature.test.js +357 -0
- package/out/test/lease-trust-root.test.js +273 -0
- package/out/test/lease-validation.test.js +224 -0
- package/out/test/lease.test.js +114 -0
- package/out/test/localFleetAdapter.test.js +91 -0
- package/out/test/mcp.test.js +27 -1
- package/out/test/pack-admission.test.js +216 -0
- package/out/test/pack-digest-parity.test.js +140 -0
- package/out/test/pack-reconcile.test.js +183 -0
- package/out/test/pack-signature-artifact.test.js +103 -0
- package/out/test/pack-signature.test.js +176 -0
- package/out/test/pack-trust-root.test.js +202 -0
- package/out/test/remote-trust.test.js +242 -0
- package/out/test/runner-protocol.test.js +249 -0
- package/out/test/sandbox-driver.test.js +553 -0
- package/out/test/sandbox-hardening.test.js +406 -0
- package/out/test/sandbox-runner.test.js +343 -0
- package/out/test/sandbox-scope.test.js +449 -0
- package/out/test/serve-cron-acceptance.test.js +370 -0
- package/out/test/serve-gateway-turn.test.js +122 -0
- package/out/test/serve-hardening.test.js +227 -15
- package/out/test/serveClient.test.js +6 -5
- package/out/test/sessionShip.test.js +618 -0
- package/out/test/spotlightPublish.test.js +28 -0
- package/out/test/store-install-safe.test.js +69 -0
- package/out/test/tls-bypass.test.js +90 -0
- package/out/test/warrant.test.js +138 -0
- package/out/utils.js +46 -9
- package/package.json +1 -1
package/out/auth-broker/store.js
CHANGED
|
@@ -136,7 +136,7 @@ class AuthBrokerStore {
|
|
|
136
136
|
id: `usr_${crypto.randomBytes(8).toString('hex')}`,
|
|
137
137
|
email: normalized,
|
|
138
138
|
displayName: displayName?.trim() || normalized.split('@')[0] || normalized,
|
|
139
|
-
teamId: this.config.team.id,
|
|
139
|
+
...(this.config.teamConfigured ? { teamId: this.config.team.id } : {}),
|
|
140
140
|
};
|
|
141
141
|
this.users.set(user.id, user);
|
|
142
142
|
this.persist();
|
|
@@ -210,7 +210,7 @@ class AuthBrokerStore {
|
|
|
210
210
|
sub: user.id,
|
|
211
211
|
email: user.email,
|
|
212
212
|
name: user.displayName,
|
|
213
|
-
team_id: user.teamId,
|
|
213
|
+
...(user.teamId ? { team_id: user.teamId } : {}),
|
|
214
214
|
scope,
|
|
215
215
|
}, this.config.jwtSecret, this.config.accessTokenTtlSec);
|
|
216
216
|
const refreshToken = this.createRefreshToken(user.id, clientId);
|
|
@@ -221,6 +221,9 @@ class AuthBrokerStore {
|
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
buildBootstrap(user) {
|
|
224
|
+
// No AGENTHIPPO_TEAM_ID ⇒ solo deployment: no team object, and nothing is team-managed —
|
|
225
|
+
// store/routing still apply as defaults but are not locked against the user changing them.
|
|
226
|
+
const teamConfigured = this.config.teamConfigured;
|
|
224
227
|
return {
|
|
225
228
|
version: 1,
|
|
226
229
|
user: {
|
|
@@ -228,34 +231,28 @@ class AuthBrokerStore {
|
|
|
228
231
|
email: user.email,
|
|
229
232
|
displayName: user.displayName,
|
|
230
233
|
},
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
...(teamConfigured
|
|
235
|
+
? {
|
|
236
|
+
team: {
|
|
237
|
+
id: this.config.team.id,
|
|
238
|
+
name: this.config.team.name,
|
|
239
|
+
role: 'member',
|
|
240
|
+
},
|
|
241
|
+
}
|
|
242
|
+
: {}),
|
|
236
243
|
store: {
|
|
237
244
|
repo: this.config.team.storeRepo,
|
|
238
245
|
indexUrl: this.config.team.storeIndexUrl,
|
|
239
246
|
githubOrg: this.config.team.githubOrg,
|
|
240
247
|
},
|
|
241
248
|
routing: {
|
|
242
|
-
|
|
243
|
-
litellmApiKey: this.config.team.litellmApiKey,
|
|
244
|
-
// No litellmApiKeyExpiresAt: the team key is static — a fabricated expiry
|
|
245
|
-
// would only pretend rotation exists. Per-user virtual keys are the upgrade path.
|
|
249
|
+
inferenceGatewayUrl: this.config.team.gatewayUrl,
|
|
246
250
|
},
|
|
247
251
|
policy: {
|
|
248
|
-
|
|
249
|
-
teamManagedSettings: ['store', 'routing'],
|
|
252
|
+
teamManagedSettings: teamConfigured ? ['store', 'routing'] : [],
|
|
250
253
|
},
|
|
251
254
|
};
|
|
252
255
|
}
|
|
253
|
-
refreshRoutingCredentials() {
|
|
254
|
-
// The team key is static (no rotation backend yet), so no expiry is reported.
|
|
255
|
-
return {
|
|
256
|
-
litellmApiKey: this.config.team.litellmApiKey,
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
256
|
buildMe(user) {
|
|
260
257
|
return {
|
|
261
258
|
user: {
|
|
@@ -263,11 +260,15 @@ class AuthBrokerStore {
|
|
|
263
260
|
email: user.email,
|
|
264
261
|
displayName: user.displayName,
|
|
265
262
|
},
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
263
|
+
...(this.config.teamConfigured
|
|
264
|
+
? {
|
|
265
|
+
team: {
|
|
266
|
+
id: this.config.team.id,
|
|
267
|
+
name: this.config.team.name,
|
|
268
|
+
role: 'member',
|
|
269
|
+
},
|
|
270
|
+
}
|
|
271
|
+
: {}),
|
|
271
272
|
};
|
|
272
273
|
}
|
|
273
274
|
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) AgentHippo.ai. All rights reserved.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.b64urlEncode = b64urlEncode;
|
|
40
|
+
exports.signCompactJws = signCompactJws;
|
|
41
|
+
exports.verifyCompactJws = verifyCompactJws;
|
|
42
|
+
exports.timingSafeEqualString = timingSafeEqualString;
|
|
43
|
+
exports.generateWarrantKeypair = generateWarrantKeypair;
|
|
44
|
+
exports.mintWarrant = mintWarrant;
|
|
45
|
+
exports.verifyWarrant = verifyWarrant;
|
|
46
|
+
exports.jwks = jwks;
|
|
47
|
+
/**
|
|
48
|
+
* Signed warrants (PLAN/serve-v4-clean.md §6).
|
|
49
|
+
*
|
|
50
|
+
* The P1 breach was not a nonce bug — it was **misplaced minting authority**: serve held a
|
|
51
|
+
* bearer secret that let any holder mint a turn for any user. Edge mode relocated that secret;
|
|
52
|
+
* signing removes it. And the deploy samples still share ONE symmetric HMAC
|
|
53
|
+
* `AGENTHIPPO_AUTH_JWT_SECRET` fleet-wide, so compromising any single federated agent yields
|
|
54
|
+
* token-minting authority for the whole fleet including the IdP.
|
|
55
|
+
*
|
|
56
|
+
* warrant = sign_ES256{ user, pack_version, sandbox_id, tier, exp ≈ turn }
|
|
57
|
+
*
|
|
58
|
+
* The authority plane holds the private key. Data/inference/egress gateways hold **verification
|
|
59
|
+
* keys only** (JWKS) — no plane can mint on another's behalf, and an edge node that is fully
|
|
60
|
+
* compromised can verify but never issue. There is no revocation registry: `exp` is turn-length
|
|
61
|
+
* and anything longer-lived is revoked by killing the sandbox's route (`SandboxDriver.revoke`).
|
|
62
|
+
*
|
|
63
|
+
* Channel binding: a warrant names the `sandbox_id` it was minted for, and the gateway verifies the
|
|
64
|
+
* peer identity of the channel it arrived on INDEPENDENTLY. A warrant lifted from one sandbox and
|
|
65
|
+
* replayed from another fails even though its signature is perfectly valid.
|
|
66
|
+
*/
|
|
67
|
+
const crypto = __importStar(require("node:crypto"));
|
|
68
|
+
/** base64url of a UTF-8 string. */
|
|
69
|
+
function b64urlEncode(s) {
|
|
70
|
+
return Buffer.from(s, 'utf8').toString('base64url');
|
|
71
|
+
}
|
|
72
|
+
/** Sign `payload` as a compact JWS. The ONLY place a private key is used for a JWS in this tree. */
|
|
73
|
+
function signCompactJws(header, payload, privateKeyPem) {
|
|
74
|
+
const fullHeader = { alg: 'ES256', typ: header.typ ?? 'JWT', kid: header.kid };
|
|
75
|
+
const signingInput = `${b64urlEncode(JSON.stringify(fullHeader))}.${b64urlEncode(JSON.stringify(payload))}`;
|
|
76
|
+
const sig = crypto.sign('sha256', Buffer.from(signingInput), {
|
|
77
|
+
key: crypto.createPrivateKey(privateKeyPem),
|
|
78
|
+
dsaEncoding: 'ieee-p1363', // JWS ES256 is raw R||S, not DER
|
|
79
|
+
});
|
|
80
|
+
return `${signingInput}.${sig.toString('base64url')}`;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Verify a compact JWS against public keys only. Claim checking (exp, aud, digest, …) is the
|
|
84
|
+
* caller's job — this answers exactly one question: was this byte sequence signed by a key we
|
|
85
|
+
* already trust, under the algorithm we pinned?
|
|
86
|
+
*/
|
|
87
|
+
function verifyCompactJws(token, publicKeysByKid, opts = {}) {
|
|
88
|
+
const parts = token.split('.');
|
|
89
|
+
if (parts.length !== 3) {
|
|
90
|
+
return { ok: false, reason: 'malformed' };
|
|
91
|
+
}
|
|
92
|
+
const [headerB64, payloadB64, sigB64] = parts;
|
|
93
|
+
let header;
|
|
94
|
+
let payload;
|
|
95
|
+
try {
|
|
96
|
+
header = JSON.parse(Buffer.from(headerB64, 'base64url').toString('utf8'));
|
|
97
|
+
payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString('utf8'));
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return { ok: false, reason: 'unparseable' };
|
|
101
|
+
}
|
|
102
|
+
if (header.alg !== 'ES256') {
|
|
103
|
+
return { ok: false, reason: `unsupported alg ${header.alg}` };
|
|
104
|
+
}
|
|
105
|
+
// A signed artifact of one KIND must never verify as another, even under the same key.
|
|
106
|
+
if (opts.typ !== undefined && header.typ !== undefined && header.typ !== opts.typ) {
|
|
107
|
+
return { ok: false, reason: `unexpected token type ${header.typ}` };
|
|
108
|
+
}
|
|
109
|
+
const publicKeyPem = header.kid ? publicKeysByKid[header.kid] : undefined;
|
|
110
|
+
if (!publicKeyPem) {
|
|
111
|
+
return { ok: false, reason: 'unknown kid' };
|
|
112
|
+
}
|
|
113
|
+
let signatureValid = false;
|
|
114
|
+
try {
|
|
115
|
+
signatureValid = crypto.verify('sha256', Buffer.from(`${headerB64}.${payloadB64}`), { key: crypto.createPublicKey(publicKeyPem), dsaEncoding: 'ieee-p1363' }, Buffer.from(sigB64, 'base64url'));
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return { ok: false, reason: 'bad signature' };
|
|
119
|
+
}
|
|
120
|
+
if (!signatureValid) {
|
|
121
|
+
return { ok: false, reason: 'bad signature' };
|
|
122
|
+
}
|
|
123
|
+
return { ok: true, header, payload, signingInput: `${headerB64}.${payloadB64}` };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Constant-time string compare for values that gate a security decision (digests, thumbprints).
|
|
127
|
+
*
|
|
128
|
+
* These are public values, so a timing oracle is not a practical break — but a digest comparison
|
|
129
|
+
* that short-circuits on the first differing byte is the kind of detail a reviewer has to
|
|
130
|
+
* re-derive every time. One helper, used everywhere, removes the question.
|
|
131
|
+
*/
|
|
132
|
+
function timingSafeEqualString(a, b) {
|
|
133
|
+
const bufA = Buffer.from(a, 'utf8');
|
|
134
|
+
const bufB = Buffer.from(b, 'utf8');
|
|
135
|
+
if (bufA.length !== bufB.length) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
return crypto.timingSafeEqual(bufA, bufB);
|
|
139
|
+
}
|
|
140
|
+
/** Generate an ES256 (P-256) keypair for the authority plane. */
|
|
141
|
+
function generateWarrantKeypair(kid) {
|
|
142
|
+
const { privateKey, publicKey } = crypto.generateKeyPairSync('ec', { namedCurve: 'P-256' });
|
|
143
|
+
const publicKeyPem = publicKey.export({ type: 'spki', format: 'pem' }).toString();
|
|
144
|
+
return {
|
|
145
|
+
privateKeyPem: privateKey.export({ type: 'pkcs8', format: 'pem' }).toString(),
|
|
146
|
+
publicKeyPem,
|
|
147
|
+
kid: kid ?? crypto.createHash('sha256').update(publicKeyPem).digest('hex').slice(0, 16),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Longer than a turn is not a warrant, it's a credential. Hard cap rather than a default. */
|
|
151
|
+
const MAX_TTL_SECONDS = 300;
|
|
152
|
+
function mintWarrant(input, key) {
|
|
153
|
+
const now = input.nowSeconds ?? Math.floor(Date.now() / 1000);
|
|
154
|
+
const ttl = Math.min(input.ttlSeconds ?? 120, MAX_TTL_SECONDS);
|
|
155
|
+
const claims = {
|
|
156
|
+
user: input.user,
|
|
157
|
+
pack: input.pack,
|
|
158
|
+
packVersion: input.packVersion,
|
|
159
|
+
sandboxId: input.sandboxId,
|
|
160
|
+
tier: input.tier,
|
|
161
|
+
aud: input.aud,
|
|
162
|
+
iat: now,
|
|
163
|
+
exp: now + ttl,
|
|
164
|
+
jti: crypto.randomUUID(),
|
|
165
|
+
};
|
|
166
|
+
return signCompactJws({ typ: 'JWT', kid: key.kid }, claims, key.privateKeyPem);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Verify with a public key only. A gateway that can run this cannot mint — that asymmetry is
|
|
170
|
+
* the entire point, and it is what deletes the shared fleet-wide HMAC secret.
|
|
171
|
+
*/
|
|
172
|
+
function verifyWarrant(token, publicKeysByKid, input) {
|
|
173
|
+
// Algorithm confusion is the classic JWT break: a token claiming `none`, or claiming HS256
|
|
174
|
+
// so the verifier uses the public key as an HMAC secret, must be refused outright. That, plus
|
|
175
|
+
// the kid-must-be-known rule, lives in verifyCompactJws — one implementation, no drift.
|
|
176
|
+
const jws = verifyCompactJws(token, publicKeysByKid);
|
|
177
|
+
if (!jws.ok) {
|
|
178
|
+
return { ok: false, reason: jws.reason };
|
|
179
|
+
}
|
|
180
|
+
const claims = jws.payload;
|
|
181
|
+
const now = input.nowSeconds ?? Math.floor(Date.now() / 1000);
|
|
182
|
+
if (typeof claims.exp !== 'number' || claims.exp <= now) {
|
|
183
|
+
return { ok: false, reason: 'expired' };
|
|
184
|
+
}
|
|
185
|
+
if (claims.aud !== input.audience) {
|
|
186
|
+
return { ok: false, reason: `wrong audience ${claims.aud}` };
|
|
187
|
+
}
|
|
188
|
+
// Channel binding — the property §12.4b promises. A stolen warrant presented from a
|
|
189
|
+
// different sandbox fails here even though its signature verifies.
|
|
190
|
+
if (input.channelSandboxId !== undefined && claims.sandboxId !== input.channelSandboxId) {
|
|
191
|
+
return { ok: false, reason: 'warrant not bound to this channel' };
|
|
192
|
+
}
|
|
193
|
+
if (!claims.user) {
|
|
194
|
+
return { ok: false, reason: 'no principal' };
|
|
195
|
+
}
|
|
196
|
+
return { ok: true, claims };
|
|
197
|
+
}
|
|
198
|
+
/** JWKS document for gateways to fetch. Publishes verification material ONLY. */
|
|
199
|
+
function jwks(keys) {
|
|
200
|
+
return {
|
|
201
|
+
keys: keys.map((k) => {
|
|
202
|
+
const jwk = crypto.createPublicKey(k.publicKeyPem).export({ format: 'jwk' });
|
|
203
|
+
return { ...jwk, kid: k.kid, alg: 'ES256', use: 'sig' };
|
|
204
|
+
}),
|
|
205
|
+
};
|
|
206
|
+
}
|
package/out/branding.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* Copyright (c) AgentHippo.ai. All rights reserved.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AGENTIDE_DEPS_PACKAGE_NAME = exports.AGENTIDE_DEPS_DIR_NAME = exports.AGENTIDE_CLI_NAME = exports.AGENTIDE_DIR_NAME = exports.AGENTIDE_EXTENSION_NAME = exports.AGENTIDE_BRAND_NAME = void 0;
|
|
6
|
+
exports.SETTINGS_DISPLAY_PREFIX = exports.SETTINGS_KEY_PREFIX = exports.AGENTIDE_DEPS_PACKAGE_NAME = exports.AGENTIDE_DEPS_DIR_NAME = exports.AGENTIDE_CLI_NAME = exports.AGENTIDE_DIR_NAME = exports.AGENTIDE_EXTENSION_NAME = exports.AGENTIDE_BRAND_NAME = void 0;
|
|
7
|
+
exports.toSettingsDisplayKey = toSettingsDisplayKey;
|
|
8
|
+
exports.describeSettingKey = describeSettingKey;
|
|
7
9
|
exports.applyBrandingTokens = applyBrandingTokens;
|
|
8
10
|
exports.brandify = brandify;
|
|
9
11
|
// Centralized branding so we can rename without sweeping string edits.
|
|
@@ -13,6 +15,30 @@ exports.AGENTIDE_DIR_NAME = '.agent-hippo';
|
|
|
13
15
|
exports.AGENTIDE_CLI_NAME = 'agenthippo';
|
|
14
16
|
exports.AGENTIDE_DEPS_DIR_NAME = `.${exports.AGENTIDE_CLI_NAME}-deps`;
|
|
15
17
|
exports.AGENTIDE_DEPS_PACKAGE_NAME = `${exports.AGENTIDE_CLI_NAME}-deps`;
|
|
18
|
+
/** Internal VS Code settings prefix (stored in settings.json). */
|
|
19
|
+
exports.SETTINGS_KEY_PREFIX = 'agentide.';
|
|
20
|
+
/** User-visible settings prefix in the Settings UI (see workbench settingsDisplayKey.ts). */
|
|
21
|
+
exports.SETTINGS_DISPLAY_PREFIX = 'agenthippoai.';
|
|
22
|
+
/** Map an internal setting key to the label users see in Settings. */
|
|
23
|
+
function toSettingsDisplayKey(key) {
|
|
24
|
+
return key.startsWith(exports.SETTINGS_KEY_PREFIX)
|
|
25
|
+
? exports.SETTINGS_DISPLAY_PREFIX + key.slice(exports.SETTINGS_KEY_PREFIX.length)
|
|
26
|
+
: key;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Name a setting in prose that a user can act on.
|
|
30
|
+
*
|
|
31
|
+
* The display alias exists only inside the Settings UI: `agenthippoai.*` is not a real
|
|
32
|
+
* configuration key, so a message that prints it alone sends the user to paste a key into
|
|
33
|
+
* settings.json that configures nothing. Anything outside the Settings tree — notifications,
|
|
34
|
+
* errors, docs — must name the REAL key and mention the alias only to connect the two.
|
|
35
|
+
*/
|
|
36
|
+
function describeSettingKey(key) {
|
|
37
|
+
const displayKey = toSettingsDisplayKey(key);
|
|
38
|
+
return displayKey === key
|
|
39
|
+
? key
|
|
40
|
+
: `${key} (shown in Settings as ${displayKey})`;
|
|
41
|
+
}
|
|
16
42
|
function applyBrandingTokens(text) {
|
|
17
43
|
return text
|
|
18
44
|
.replace(/\{\{AGENT_BRAND\}\}|\{\{AGENTIDE_BRAND\}\}/g, exports.AGENTIDE_BRAND_NAME)
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) AgentHippo.ai. All rights reserved.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.conformanceCommand = conformanceCommand;
|
|
7
|
+
/**
|
|
8
|
+
* `agenthippo conformance` — the deployment's own proof (PLAN/serve-v4-clean.md §11 step 5).
|
|
9
|
+
*
|
|
10
|
+
* This is the artifact a partner runs at a client site without us in the room, and the honest
|
|
11
|
+
* answer to "why should I believe the isolation claim": the buyer runs the test themselves.
|
|
12
|
+
*
|
|
13
|
+
* Deployment checks PROBE rather than assert — "the four keys are undefined in-sandbox" has to be
|
|
14
|
+
* measured inside a running sandbox, not read off a config file. Checks that cannot be measured in
|
|
15
|
+
* the current environment report `skip` with the reason; a skip is never a pass.
|
|
16
|
+
*
|
|
17
|
+
* The contract checks (cost-cap, warrant-integrity, rollback-kill-switch) are a different claim:
|
|
18
|
+
* they verify THIS BINARY implements the bindings it advertises, and pass anywhere, including on a
|
|
19
|
+
* machine with no deployment. They are reported separately and cannot make a run green on their
|
|
20
|
+
* own — a conformance run that probed nothing exits 2, because a buyer must never be able to get a
|
|
21
|
+
* clean report against a system that was never touched.
|
|
22
|
+
*/
|
|
23
|
+
const node_child_process_1 = require("node:child_process");
|
|
24
|
+
const node_util_1 = require("node:util");
|
|
25
|
+
const support_1 = require("../../sandbox/support");
|
|
26
|
+
const lease_1 = require("../../pack/lease");
|
|
27
|
+
const warrant_1 = require("../../authority/warrant");
|
|
28
|
+
const pexec = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
29
|
+
async function run(bin, args) {
|
|
30
|
+
try {
|
|
31
|
+
const { stdout } = await pexec(bin, args, { maxBuffer: 8 << 20 });
|
|
32
|
+
return { out: stdout, code: 0 };
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
const err = e;
|
|
36
|
+
return { out: `${err.stdout ?? ''}${err.stderr ?? ''}`, code: typeof err.code === 'number' ? err.code : 1 };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* credential-confinement — no data, model, or channel credential is reachable from inside a
|
|
41
|
+
* sandbox (env, /proc, filesystem). This is the check that would have caught the P2 leak: with the
|
|
42
|
+
* connector in the agent container, `PGPASSWORD` was readable from a sibling's /proc.
|
|
43
|
+
*/
|
|
44
|
+
async function credentialConfinement(opts) {
|
|
45
|
+
const name = 'credential-confinement';
|
|
46
|
+
if (!opts.sandbox) {
|
|
47
|
+
return { name, status: 'skip', detail: 'no --sandbox given; cannot probe inside a running sandbox' };
|
|
48
|
+
}
|
|
49
|
+
const rt = opts.runtime ?? 'docker';
|
|
50
|
+
// 1. The sandbox's own environment.
|
|
51
|
+
const env = await run(rt, ['exec', opts.sandbox, 'sh', '-c', 'env']);
|
|
52
|
+
if (env.code !== 0) {
|
|
53
|
+
return { name, status: 'skip', detail: `cannot exec in sandbox ${opts.sandbox}: ${env.out.trim().slice(0, 120)}` };
|
|
54
|
+
}
|
|
55
|
+
const SECRET_PATTERNS = [
|
|
56
|
+
['provider-key', /sk-[A-Za-z0-9]{16,}/],
|
|
57
|
+
['api-key-var', /(^|\n)[A-Z_]*API_KEY=\S/],
|
|
58
|
+
['db-password', /(^|\n)PG(PASSWORD|PASSFILE)=\S/],
|
|
59
|
+
['aws-secret', /(^|\n)AWS_SECRET_ACCESS_KEY=\S/],
|
|
60
|
+
['bearer-token-var', /(^|\n)[A-Z_]*_TOKEN=\S/],
|
|
61
|
+
['generic-secret-var', /(^|\n)[A-Z_]*SECRET[A-Z_]*=\S/],
|
|
62
|
+
];
|
|
63
|
+
// The ONE credential permitted in a sandbox is its own model token: sandbox-bound, spend-capped,
|
|
64
|
+
// worthless anywhere else. Normalize those assignments away so the scan reports only
|
|
65
|
+
// material that would actually be worth stealing.
|
|
66
|
+
const stripSandboxTokens = (text) => text.replace(/^[A-Z_]*=ahc_\S*$/gm, '');
|
|
67
|
+
const hits = (text) => SECRET_PATTERNS.filter(([, re]) => re.test(stripSandboxTokens(text))).map(([label]) => label);
|
|
68
|
+
const envHits = hits(env.out);
|
|
69
|
+
// 2. Every readable process environment in the sandbox's PID namespace — the actual attack that
|
|
70
|
+
// recovered PGPASSWORD from a sibling when the connector ran in the agent container (P2).
|
|
71
|
+
const proc = await run(rt, ['exec', opts.sandbox, 'sh', '-c',
|
|
72
|
+
'for p in /proc/[0-9]*; do tr "\\0" "\\n" < $p/environ 2>/dev/null; done']);
|
|
73
|
+
const procHits = hits(proc.out);
|
|
74
|
+
if (envHits.length === 0 && procHits.length === 0) {
|
|
75
|
+
const hasSandboxToken = /=ahc_/.test(env.out);
|
|
76
|
+
return {
|
|
77
|
+
name, status: 'pass',
|
|
78
|
+
detail: hasSandboxToken
|
|
79
|
+
? 'only a sandbox-scoped model token is present; no provider key, DB password, or bearer secret in env or any /proc environ'
|
|
80
|
+
: 'no credential reachable in the sandbox env or any process environ',
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
name, status: 'fail',
|
|
85
|
+
detail: `credential material reachable inside the sandbox — env: [${envHits.join(', ') || 'none'}], /proc: [${procHits.join(', ') || 'none'}]`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** isolation-tier — the declared tier is actually in force, probed, not assumed. */
|
|
89
|
+
async function isolationTier(opts) {
|
|
90
|
+
const name = 'isolation-tier';
|
|
91
|
+
if (opts.tier === undefined) {
|
|
92
|
+
return { name, status: 'skip', detail: 'no --tier declared' };
|
|
93
|
+
}
|
|
94
|
+
if (opts.tier === 0) {
|
|
95
|
+
return { name, status: 'pass', detail: 'tier 0 declares no boundary — nothing to enforce' };
|
|
96
|
+
}
|
|
97
|
+
if (!opts.sandbox) {
|
|
98
|
+
return { name, status: 'skip', detail: 'no --sandbox given; cannot probe the boundary' };
|
|
99
|
+
}
|
|
100
|
+
const rt = opts.runtime ?? 'docker';
|
|
101
|
+
const pids = await run(rt, ['exec', opts.sandbox, 'sh', '-c', 'ls -d /proc/[0-9]* | wc -l']);
|
|
102
|
+
if (pids.code !== 0) {
|
|
103
|
+
return { name, status: 'skip', detail: 'cannot probe the sandbox' };
|
|
104
|
+
}
|
|
105
|
+
const count = parseInt(pids.out.trim(), 10);
|
|
106
|
+
// A sandbox in its own PID namespace sees only its own handful of processes. A sandbox sharing the
|
|
107
|
+
// host namespace sees everything — which is what tier 0 looks like wearing a tier-2 label.
|
|
108
|
+
if (!Number.isFinite(count)) {
|
|
109
|
+
return { name, status: 'skip', detail: 'unreadable process count' };
|
|
110
|
+
}
|
|
111
|
+
if (count > 50) {
|
|
112
|
+
return { name, status: 'fail', detail: `sandbox sees ${count} processes — PID namespace is NOT isolated despite tier ${opts.tier}` };
|
|
113
|
+
}
|
|
114
|
+
const nets = await run(rt, ['inspect', opts.sandbox, '--format', '{{json .NetworkSettings.Networks}}']);
|
|
115
|
+
const networks = Object.keys(JSON.parse(nets.out.trim() || '{}'));
|
|
116
|
+
if (networks.includes('bridge')) {
|
|
117
|
+
return { name, status: 'fail', detail: 'sandbox is on the default bridge — it is not route-confined' };
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
name, status: 'pass',
|
|
121
|
+
detail: `tier ${opts.tier} in force: own PID namespace (${count} procs), routes=${networks.join(',') || 'none'}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* cost-cap — the model credential in a sandbox cannot be replayed elsewhere (blocker C).
|
|
126
|
+
*
|
|
127
|
+
* Exercises the SHIPPED credential (the ES256 inference warrant serve actually mints), not the
|
|
128
|
+
* removed HMAC token: a check that proves a property of dead code proves nothing about the
|
|
129
|
+
* deployment. The proxy verifies with a public key, so it can check a warrant but never mint one.
|
|
130
|
+
*/
|
|
131
|
+
function costCap() {
|
|
132
|
+
const name = 'cost-cap';
|
|
133
|
+
const upstream = 'sk-conformance-upstream-key';
|
|
134
|
+
const key = (0, warrant_1.generateWarrantKeypair)('conformance-cost-cap');
|
|
135
|
+
const pubs = { [key.kid]: key.publicKeyPem };
|
|
136
|
+
const token = (0, support_1.mintSandboxInferenceWarrant)(key, {
|
|
137
|
+
user: 'probe@corp.com', pack: 'probe', packVersion: '0.0.0', sandboxId: 'sandbox-A', tier: 2,
|
|
138
|
+
});
|
|
139
|
+
const boundToOwnSandbox = (0, warrant_1.verifyWarrant)(token, pubs, { audience: 'inference', channelSandboxId: 'sandbox-A' }).ok;
|
|
140
|
+
const usableElsewhere = (0, warrant_1.verifyWarrant)(token, pubs, { audience: 'inference', channelSandboxId: 'sandbox-B' }).ok;
|
|
141
|
+
const leaksProvider = token.includes(upstream);
|
|
142
|
+
if (boundToOwnSandbox && !usableElsewhere && !leaksProvider) {
|
|
143
|
+
return { name, status: 'pass', detail: 'model token is a sandbox-bound signed warrant and carries no provider key — a cap cannot be evaded by replay' };
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
name, status: 'fail',
|
|
147
|
+
detail: `warrant binding broken (own=${boundToOwnSandbox}, elsewhere=${usableElsewhere}, leaks=${leaksProvider})`,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** evidence-integrity — a warrant proves authority and a gateway cannot mint one. */
|
|
151
|
+
function warrantIntegrity() {
|
|
152
|
+
const name = 'warrant-integrity';
|
|
153
|
+
const key = (0, warrant_1.generateWarrantKeypair)('conformance');
|
|
154
|
+
const pubs = { [key.kid]: key.publicKeyPem };
|
|
155
|
+
const token = (0, warrant_1.mintWarrant)({
|
|
156
|
+
user: 'probe@corp.com', pack: 'probe', packVersion: '0.0.0',
|
|
157
|
+
sandboxId: 'sandbox-A', tier: 2, aud: 'data',
|
|
158
|
+
}, key);
|
|
159
|
+
const own = (0, warrant_1.verifyWarrant)(token, pubs, { audience: 'data', channelSandboxId: 'sandbox-A' });
|
|
160
|
+
const lifted = (0, warrant_1.verifyWarrant)(token, pubs, { audience: 'data', channelSandboxId: 'sandbox-B' });
|
|
161
|
+
const wrongAud = (0, warrant_1.verifyWarrant)(token, pubs, { audience: 'inference', channelSandboxId: 'sandbox-A' });
|
|
162
|
+
if (own.ok && !lifted.ok && !wrongAud.ok) {
|
|
163
|
+
return { name, status: 'pass', detail: 'warrants are signed, sandbox-bound, and audience-scoped; gateways verify but cannot mint' };
|
|
164
|
+
}
|
|
165
|
+
return { name, status: 'fail', detail: `warrant binding broken (own=${own.ok}, lifted=${lifted.ok}, wrongAud=${wrongAud.ok})` };
|
|
166
|
+
}
|
|
167
|
+
/** rollback + kill-switch — admission refuses unpinned versions and revoked leases. */
|
|
168
|
+
function rollbackAndKill() {
|
|
169
|
+
const name = 'rollback-kill-switch';
|
|
170
|
+
const now = Math.floor(Date.now() / 1000);
|
|
171
|
+
const pinned = { pack: 'probe', version: '1.0.0', expiresAt: now + 60, enabled: true };
|
|
172
|
+
const results = {
|
|
173
|
+
pinnedAdmits: safe(() => (0, lease_1.assertAdmitted)(pinned, { pack: 'probe', version: '1.0.0', nowSeconds: now })),
|
|
174
|
+
otherVersionRefused: !safe(() => (0, lease_1.assertAdmitted)(pinned, { pack: 'probe', version: '1.0.1', nowSeconds: now })),
|
|
175
|
+
killSwitchRefuses: !safe(() => (0, lease_1.assertAdmitted)({ ...pinned, enabled: false }, { pack: 'probe', version: '1.0.0', nowSeconds: now })),
|
|
176
|
+
expiredRefused: !safe(() => (0, lease_1.assertAdmitted)({ ...pinned, expiresAt: now - 1 }, { pack: 'probe', version: '1.0.0', nowSeconds: now })),
|
|
177
|
+
};
|
|
178
|
+
const ok = Object.values(results).every(Boolean);
|
|
179
|
+
return {
|
|
180
|
+
name, status: ok ? 'pass' : 'fail',
|
|
181
|
+
detail: ok
|
|
182
|
+
? 'pinned version admits, other versions refused, kill switch and expiry both fail closed'
|
|
183
|
+
: `admission contract broken: ${JSON.stringify(results)}`,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function safe(fn) {
|
|
187
|
+
try {
|
|
188
|
+
fn();
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function conformanceCommand(opts) {
|
|
196
|
+
const tag = (kind) => (c) => ({ ...c, kind });
|
|
197
|
+
const results = [
|
|
198
|
+
tag('deployment')(await credentialConfinement(opts)),
|
|
199
|
+
tag('deployment')(await isolationTier(opts)),
|
|
200
|
+
tag('algorithm')(costCap()),
|
|
201
|
+
tag('algorithm')(warrantIntegrity()),
|
|
202
|
+
tag('algorithm')(rollbackAndKill()),
|
|
203
|
+
];
|
|
204
|
+
const deployment = results.filter((r) => r.kind === 'deployment');
|
|
205
|
+
const probed = deployment.filter((r) => r.status !== 'skip');
|
|
206
|
+
const failed = results.filter((r) => r.status === 'fail');
|
|
207
|
+
// A run that probed nothing is the case this command exists to prevent: it must never be
|
|
208
|
+
// mistaken for a deployment that passed, in the text output, the JSON, or the exit code.
|
|
209
|
+
const nothingProbed = probed.length === 0;
|
|
210
|
+
if (opts.json) {
|
|
211
|
+
console.log(JSON.stringify({
|
|
212
|
+
results,
|
|
213
|
+
deployment_probed: !nothingProbed,
|
|
214
|
+
summary: nothingProbed
|
|
215
|
+
? 'no deployment was probed — algorithm checks verify this binary only'
|
|
216
|
+
: `${probed.filter((r) => r.status === 'pass').length}/${probed.length} deployment checks passed`,
|
|
217
|
+
}, null, 2));
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
console.log('\nAgentHippo conformance\n');
|
|
221
|
+
const show = (r) => {
|
|
222
|
+
const mark = r.status === 'pass' ? 'PASS' : r.status === 'fail' ? 'FAIL' : 'SKIP';
|
|
223
|
+
console.log(` ${mark} ${r.name}\n ${r.detail}`);
|
|
224
|
+
};
|
|
225
|
+
console.log('THIS DEPLOYMENT (probes a running sandbox)');
|
|
226
|
+
deployment.forEach(show);
|
|
227
|
+
console.log('\nTHIS BINARY (contract checks — environment-independent, pass with no deployment)');
|
|
228
|
+
results.filter((r) => r.kind === 'algorithm').forEach(show);
|
|
229
|
+
console.log('');
|
|
230
|
+
if (nothingProbed) {
|
|
231
|
+
console.log('NO DEPLOYMENT WAS PROBED. The binary checks above say nothing about a running');
|
|
232
|
+
console.log('system — pass --sandbox <container> --tier <n> to actually test one.');
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const passed = probed.filter((r) => r.status === 'pass').length;
|
|
236
|
+
console.log(`${passed}/${probed.length} deployment checks passed` +
|
|
237
|
+
(deployment.length - probed.length ? `, ${deployment.length - probed.length} not probed` : ''));
|
|
238
|
+
}
|
|
239
|
+
if (failed.length) {
|
|
240
|
+
console.log(`${failed.length} FAILED`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Non-zero on failure so this can gate a deployment in CI — and non-zero when nothing was
|
|
244
|
+
// probed, so "green" always means a real deployment was measured.
|
|
245
|
+
if (failed.length) {
|
|
246
|
+
return 1;
|
|
247
|
+
}
|
|
248
|
+
return nothingProbed ? 2 : 0;
|
|
249
|
+
}
|