@agenthippo-ai/agenthippo 0.2.3-dataplane → 1.110.9

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.
Files changed (130) hide show
  1. package/out/analytics/dashboard/provider.js +13 -2
  2. package/out/analytics/dashboard/webview/panel.js +3 -2
  3. package/out/analytics/identity.js +0 -0
  4. package/out/analytics/service.js +23 -25
  5. package/out/analytics/sessionEvents.js +98 -23
  6. package/out/auth/authBaseUrl.js +59 -0
  7. package/out/auth/bootstrapApply.js +9 -10
  8. package/out/auth/brokerClient.js +48 -14
  9. package/out/auth/provider.js +8 -21
  10. package/out/auth/sessionStore.js +3 -40
  11. package/out/auth/signInFlow.js +2 -1
  12. package/out/auth-broker/config.js +50 -5
  13. package/out/auth-broker/server.js +122 -26
  14. package/out/auth-broker/store.js +25 -24
  15. package/out/authority/warrant.js +206 -0
  16. package/out/branding.js +27 -1
  17. package/out/cli/commands/conformance.js +249 -0
  18. package/out/cli/commands/data-plane.js +67 -0
  19. package/out/cli/commands/deploy.js +1 -0
  20. package/out/cli/commands/gateway.js +4 -0
  21. package/out/cli/commands/pack.js +182 -3
  22. package/out/cli/commands/sandbox.js +332 -0
  23. package/out/cli/commands/serve.js +875 -52
  24. package/out/cli/commands/store.js +12 -4
  25. package/out/cli/data-plane/gateway.js +28 -5
  26. package/out/cli/data-plane/index.js +17 -2
  27. package/out/cli/data-plane/registry.js +9 -0
  28. package/out/cli/data-plane/remote.js +106 -0
  29. package/out/cli/data-plane/sidecar.js +161 -0
  30. package/out/cli/deploy/layers/identity.js +85 -4
  31. package/out/cli/deploy-init.js +89 -24
  32. package/out/cli/deps.js +106 -2
  33. package/out/cli/idp-init.js +35 -0
  34. package/out/cli/index.js +155 -16
  35. package/out/cli/pack-install-ref.js +15 -0
  36. package/out/cli/pack-loader.js +8 -1
  37. package/out/cli/pack-runtime.js +61 -0
  38. package/out/cli/runtime.js +35 -1
  39. package/out/cli/serve-hardening.js +80 -3
  40. package/out/cli/utils.js +12 -1
  41. package/out/engines/base.js +32 -3
  42. package/out/engines/claude.js +33 -15
  43. package/out/engines/codex.js +110 -26
  44. package/out/engines/custom.js +8 -0
  45. package/out/evidence/sessionShip.js +610 -0
  46. package/out/extension.js +11 -2
  47. package/out/gateway/bridge.js +40 -2
  48. package/out/gateway/client.js +34 -1
  49. package/out/gateway/installSource.js +68 -0
  50. package/out/gateway/lifecycle.js +185 -51
  51. package/out/gateway/outboundPaths.js +4 -1
  52. package/out/gateway/secretsPreflight.js +90 -0
  53. package/out/gateway/service.js +7 -2
  54. package/out/headless/index.js +17 -1
  55. package/out/live-e2e/mcp-demo/server.mjs +32 -0
  56. package/out/mcp.js +30 -0
  57. package/out/pack/caps.js +271 -0
  58. package/out/pack/governor.js +309 -0
  59. package/out/pack/lease-schema.js +270 -0
  60. package/out/pack/lease.js +640 -0
  61. package/out/pack/reconcile.js +217 -0
  62. package/out/pack/signature.js +839 -0
  63. package/out/remote/handleRemoteChat.js +44 -3
  64. package/out/remote/remoteTrust.js +277 -0
  65. package/out/remote/serveClient.js +52 -5
  66. package/out/runner/host.js +131 -0
  67. package/out/runner/protocol.js +108 -0
  68. package/out/runner/remoteEngine.js +130 -0
  69. package/out/runtime/interfaces/edit-tracker.js +2 -0
  70. package/out/runtime/vscode/vscode-edit-tracker.js +2 -0
  71. package/out/sandbox/containerDriver.js +570 -0
  72. package/out/sandbox/processDriver.js +315 -0
  73. package/out/sandbox/sandboxRunner.js +191 -0
  74. package/out/sandbox/support.js +301 -0
  75. package/out/sandbox/types.js +55 -0
  76. package/out/scripts/agentide-litellm.sh +67 -5
  77. package/out/scripts/agentide_litellm_hooks_v1.py +182 -21
  78. package/out/scripts/analytics/agentide-litellm-otel.config.yaml +94 -132
  79. package/out/scripts/analytics/setup-analytics.ps1 +37 -13
  80. package/out/scripts/analytics/setup-analytics.sh +93 -13
  81. package/out/scripts/analytics/start-analytics.sh +86 -14
  82. package/out/scripts/gateway/setup-gateway.sh +72 -32
  83. package/out/shared/models.js +11 -110
  84. package/out/spotlight/install.js +7 -1
  85. package/out/store/index.js +41 -10
  86. package/out/sync.js +3 -1
  87. package/out/test/analytics.test.js +162 -23
  88. package/out/test/auth-baseurl.test.js +132 -0
  89. package/out/test/auth-bootstrapApply.test.js +27 -6
  90. package/out/test/auth-broker-hardening.test.js +227 -0
  91. package/out/test/auth-broker.test.js +59 -9
  92. package/out/test/branding.test.js +13 -0
  93. package/out/test/caps-governor.test.js +455 -0
  94. package/out/test/codex-new-file-survival.test.js +119 -0
  95. package/out/test/configuration-scopes.test.js +131 -0
  96. package/out/test/data-plane.test.js +67 -0
  97. package/out/test/deploy-init.test.js +40 -0
  98. package/out/test/gateway-client.test.js +28 -0
  99. package/out/test/gateway-install-source.test.js +111 -0
  100. package/out/test/gateway-lifecycle.test.js +1 -1
  101. package/out/test/gateway-outbound.test.js +7 -0
  102. package/out/test/gateway-secrets-preflight.test.js +127 -0
  103. package/out/test/gateway-session-routing.test.js +18 -0
  104. package/out/test/governor-hardening.test.js +217 -0
  105. package/out/test/headless-sync.test.js +22 -0
  106. package/out/test/lease-signature.test.js +357 -0
  107. package/out/test/lease-trust-root.test.js +273 -0
  108. package/out/test/lease-validation.test.js +169 -0
  109. package/out/test/lease.test.js +114 -0
  110. package/out/test/mcp.test.js +27 -1
  111. package/out/test/pack-admission.test.js +216 -0
  112. package/out/test/pack-digest-parity.test.js +140 -0
  113. package/out/test/pack-reconcile.test.js +183 -0
  114. package/out/test/pack-signature-artifact.test.js +103 -0
  115. package/out/test/pack-signature.test.js +176 -0
  116. package/out/test/pack-trust-root.test.js +202 -0
  117. package/out/test/remote-trust.test.js +242 -0
  118. package/out/test/runner-protocol.test.js +249 -0
  119. package/out/test/sandbox-driver.test.js +553 -0
  120. package/out/test/sandbox-hardening.test.js +395 -0
  121. package/out/test/sandbox-runner.test.js +343 -0
  122. package/out/test/serve-hardening.test.js +45 -6
  123. package/out/test/serveClient.test.js +6 -5
  124. package/out/test/sessionShip.test.js +560 -0
  125. package/out/test/spotlightPublish.test.js +28 -0
  126. package/out/test/store-install-safe.test.js +69 -0
  127. package/out/test/tls-bypass.test.js +90 -0
  128. package/out/test/warrant.test.js +138 -0
  129. package/out/utils.js +46 -9
  130. package/package.json +1 -1
@@ -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
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) AgentHippo.ai. All rights reserved.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.dataPlaneSidecarCommand = dataPlaneSidecarCommand;
7
+ /**
8
+ * `agenthippo data-plane` — run the connector as a SIDECAR (secure-obo-design §7.6).
9
+ *
10
+ * This process is the connector's own trust domain: it holds the backend BASE credential
11
+ * (AWS keys, Postgres pool login, …) and runs in a SEPARATE container from the engine. The
12
+ * agent container's `serve` registers turns with this sidecar's authenticated control API and
13
+ * never sees the base credential.
14
+ */
15
+ const pack_loader_1 = require("../pack-loader");
16
+ const data_plane_1 = require("../data-plane");
17
+ const headless_1 = require("../../headless");
18
+ const utils_1 = require("../utils");
19
+ async function dataPlaneSidecarCommand(options) {
20
+ const registerToken = process.env.AGENTHIPPO_DATA_PLANE_TOKEN?.trim();
21
+ if (!registerToken) {
22
+ console.error('Error: AGENTHIPPO_DATA_PLANE_TOKEN is required (shared secret the trusted EDGE — or, legacy, the agent\'s serve — presents to register turns).');
23
+ process.exit(1);
24
+ }
25
+ let pack;
26
+ try {
27
+ pack = await (0, pack_loader_1.loadAgentPack)(options.agent, options.workspace);
28
+ }
29
+ catch (err) {
30
+ console.error(`Error: ${err instanceof Error ? err.message : err}`);
31
+ process.exit(1);
32
+ return;
33
+ }
34
+ const cfg = (0, data_plane_1.resolveDataPlaneConfig)(pack.manifest.spec, pack.packPath);
35
+ if (!cfg) {
36
+ console.error('Error: pack declares no spec.dataPlane — nothing for the sidecar to run.');
37
+ process.exit(1);
38
+ return;
39
+ }
40
+ const logger = options.verbose ? new headless_1.ConsoleLogger('[Sidecar]') : new headless_1.NoOpLogger();
41
+ let sidecar;
42
+ try {
43
+ sidecar = await (0, data_plane_1.startDataPlaneSidecar)({
44
+ config: cfg,
45
+ registerToken,
46
+ gatewayPort: options.gatewayPort,
47
+ controlPort: options.controlPort,
48
+ bindHost: options.host ?? '0.0.0.0',
49
+ logger,
50
+ });
51
+ }
52
+ catch (err) {
53
+ console.error(`${utils_1.COLORS.red}Error: failed to start the data-plane sidecar:${utils_1.COLORS.reset} ${err instanceof Error ? err.message : err}`);
54
+ process.exit(1);
55
+ return;
56
+ }
57
+ console.log(`OK: Data-plane sidecar (provider=${cfg.provider ?? 'passthrough'}) — connector: ${cfg.connectorPath}`);
58
+ console.log(` gateway (engine dials, nonce-auth): ${sidecar.gatewayUrl}`);
59
+ console.log(` control (edge/serve registers, bearer): :${sidecar.controlPort}`);
60
+ console.log(' Base credentials live here only — never in the agent container.');
61
+ console.log(' Edge mode (P1): give the register token to the IdP edge only; serve runs with AGENTHIPPO_DATA_PLANE_EDGE=1 and no token.');
62
+ const shutdown = () => { void sidecar.close().finally(() => process.exit(0)); };
63
+ process.on('SIGINT', shutdown);
64
+ process.on('SIGTERM', shutdown);
65
+ // Keep the process alive.
66
+ await new Promise(() => { });
67
+ }
@@ -215,6 +215,7 @@ async function deployCommand(action, packArg, options) {
215
215
  cookieDomain: options.cookieDomain,
216
216
  colocate: options.colocate,
217
217
  modelRouting,
218
+ edgeTurnConnector: options.edgeTurnConnector?.trim() || undefined,
218
219
  };
219
220
  for (const target of targetsRequested) {
220
221
  const routingSuffix = modelRouting === 'gateway' ? '-gateway' : '';
@@ -115,6 +115,10 @@ async function gatewaySendCommand(options) {
115
115
  await sendViaEgressBroker(egressUrl, nonce, options);
116
116
  return;
117
117
  }
118
+ if (egressUrl) {
119
+ console.error('Error: egress broker is active but AGENTHIPPO_TURN_NONCE is missing — refusing direct gateway send');
120
+ process.exit(1);
121
+ }
118
122
  const storePath = resolveOutboundPath(options.outbound);
119
123
  await ensureStoreFileExists(storePath);
120
124
  const agentId = options.agent.trim();