@coderifts/agent-guard 14.0.0 → 14.1.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 +28 -2
- package/dist/cjs/adapters/vercel.d.ts +153 -0
- package/dist/cjs/adapters/vercel.d.ts.map +1 -0
- package/dist/cjs/adapters/vercel.js +255 -0
- package/dist/cjs/adapters/vercel.js.map +1 -0
- package/dist/cjs/atomic-profile.d.ts +59 -8
- package/dist/cjs/atomic-profile.d.ts.map +1 -1
- package/dist/cjs/atomic-profile.js +111 -2
- package/dist/cjs/atomic-profile.js.map +1 -1
- package/dist/cjs/execute-tool-call.d.ts +16 -1
- package/dist/cjs/execute-tool-call.d.ts.map +1 -1
- package/dist/cjs/execute-tool-call.js +26 -0
- package/dist/cjs/execute-tool-call.js.map +1 -1
- package/dist/cjs/gate-refusal.js +1 -1
- package/dist/cjs/index.d.ts +8 -4
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +22 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/posture-receipt.d.ts +79 -0
- package/dist/cjs/posture-receipt.d.ts.map +1 -0
- package/dist/cjs/posture-receipt.js +181 -0
- package/dist/cjs/posture-receipt.js.map +1 -0
- package/dist/cjs/with-coderifts.d.ts +2 -2
- package/dist/cjs/with-coderifts.d.ts.map +1 -1
- package/dist/cjs/with-coderifts.js +4 -2
- package/dist/cjs/with-coderifts.js.map +1 -1
- package/dist/esm/adapters/vercel.d.ts +153 -0
- package/dist/esm/adapters/vercel.d.ts.map +1 -0
- package/dist/esm/adapters/vercel.js +247 -0
- package/dist/esm/adapters/vercel.js.map +1 -0
- package/dist/esm/atomic-profile.d.ts +59 -8
- package/dist/esm/atomic-profile.d.ts.map +1 -1
- package/dist/esm/atomic-profile.js +109 -1
- package/dist/esm/atomic-profile.js.map +1 -1
- package/dist/esm/execute-tool-call.d.ts +16 -1
- package/dist/esm/execute-tool-call.d.ts.map +1 -1
- package/dist/esm/execute-tool-call.js +25 -0
- package/dist/esm/execute-tool-call.js.map +1 -1
- package/dist/esm/gate-refusal.js +1 -1
- package/dist/esm/index.d.ts +8 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/posture-receipt.d.ts +79 -0
- package/dist/esm/posture-receipt.d.ts.map +1 -0
- package/dist/esm/posture-receipt.js +177 -0
- package/dist/esm/posture-receipt.js.map +1 -0
- package/dist/esm/with-coderifts.d.ts +2 -2
- package/dist/esm/with-coderifts.d.ts.map +1 -1
- package/dist/esm/with-coderifts.js +3 -2
- package/dist/esm/with-coderifts.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel AI SDK tool adapter over withCodeRifts (roadmap 129 / wave-2 —
|
|
3
|
+
* same thin pattern as OpenAI / Anthropic / LangGraph / Gemini).
|
|
4
|
+
*
|
|
5
|
+
* Thin converter. Guard logic stays in withCodeRifts; this module:
|
|
6
|
+
* 1. calls withCodeRifts with the same input shape,
|
|
7
|
+
* 2. maps each ProtectedTool → a dependency-free Vercel `tool()` object,
|
|
8
|
+
* 3. wraps `execute` so the guarded execute runs first, then bindVercelGuardOutcome,
|
|
9
|
+
* 4. returns those tools PLUS the untouched assurance objects.
|
|
10
|
+
*
|
|
11
|
+
* Measured Vercel AI SDK v4 `tool()` (no `ai` package in this repo; types from
|
|
12
|
+
* https://ai-sdk.dev/v4/docs/reference/ai-sdk-core/tool ):
|
|
13
|
+
*
|
|
14
|
+
* import { tool } from 'ai';
|
|
15
|
+
* tool({
|
|
16
|
+
* description?: string,
|
|
17
|
+
* parameters: Zod Schema | JSON Schema,
|
|
18
|
+
* execute?: async (parameters: T, options: ToolExecutionOptions) => RESULT,
|
|
19
|
+
* })
|
|
20
|
+
* ToolExecutionOptions = { toolCallId: string, messages: CoreMessage[], abortSignal?: AbortSignal }
|
|
21
|
+
*
|
|
22
|
+
* generateText / streamText `tools` is a Record keyed by tool name (not an array).
|
|
23
|
+
* This package does NOT depend on `ai` or `zod`. `parameters` is JSON Schema from
|
|
24
|
+
* ProtectedTool.inputSchema (v4 accepts JSON Schema; hosts may wrap with `tool()` + Zod).
|
|
25
|
+
*
|
|
26
|
+
* Only-protected-tools (6/D at the adapter surface):
|
|
27
|
+
* - `tools` is derived ONLY from the frozen registry's ProtectedTool list.
|
|
28
|
+
* - Raw tools never appear in the returned table.
|
|
29
|
+
*
|
|
30
|
+
* Honesty (do not "upgrade" assurance): composition_assurance is passed through
|
|
31
|
+
* EXACTLY as the core reported it.
|
|
32
|
+
*/
|
|
33
|
+
import { withCodeRifts } from '../with-coderifts.js';
|
|
34
|
+
import { buildExecutionProof } from '../execution-proof.js';
|
|
35
|
+
import { attachProofToAgentResponse } from '../final-answer-proof.js';
|
|
36
|
+
import { formatGateRefusalBody, formatGuardError, verdictKind, } from '../gate-refusal.js';
|
|
37
|
+
/** Empty JSON Schema object — used when a ProtectedTool has no inputSchema. */
|
|
38
|
+
const EMPTY_PARAMETERS = Object.freeze({
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {},
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Local GuardOutcome duck-type. Do not import execute-tool-call (that module
|
|
44
|
+
* imports this binder — a cycle). Same fields as isGuardOutcome.
|
|
45
|
+
*/
|
|
46
|
+
function looksLikeGuardOutcome(x) {
|
|
47
|
+
if (!x || typeof x !== 'object')
|
|
48
|
+
return false;
|
|
49
|
+
const o = x;
|
|
50
|
+
return (typeof o.executed === 'boolean'
|
|
51
|
+
&& typeof o.executionAttempted === 'boolean'
|
|
52
|
+
&& o.proof != null
|
|
53
|
+
&& typeof o.proof === 'object'
|
|
54
|
+
&& o.verdict != null
|
|
55
|
+
&& typeof o.verdict === 'object');
|
|
56
|
+
}
|
|
57
|
+
function toolCallIdFromOptions(options) {
|
|
58
|
+
if (options && typeof options.toolCallId === 'string')
|
|
59
|
+
return options.toolCallId;
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
const FRESHNESS_NOT_CONFIGURED = Object.freeze({
|
|
63
|
+
wiring: 'NOT_CONFIGURED',
|
|
64
|
+
write_style: false,
|
|
65
|
+
require_freshness: false,
|
|
66
|
+
});
|
|
67
|
+
const CW_NOT_REPORTED = Object.freeze({
|
|
68
|
+
conditional_write: 'not_reported',
|
|
69
|
+
require_conditional_write: false,
|
|
70
|
+
write_style: false,
|
|
71
|
+
mutating: false,
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* Guarded mutator returned a non-outcome — never forward the raw value to generateText.
|
|
75
|
+
* Same CONFIG_ERROR / UNAVAILABLE arm as execute-tool-call unknownToolOutcome (no cycle).
|
|
76
|
+
*/
|
|
77
|
+
function guardedNonOutcomeRefusal(toolName) {
|
|
78
|
+
const verdict = {
|
|
79
|
+
kind: 'UNAVAILABLE',
|
|
80
|
+
cause: 'CONFIG_ERROR',
|
|
81
|
+
failPolicy: 'closed',
|
|
82
|
+
resolution: 'CLOSED',
|
|
83
|
+
action: 'STOP',
|
|
84
|
+
decisionMissing: true,
|
|
85
|
+
unavailableCount: 1,
|
|
86
|
+
};
|
|
87
|
+
const commit_observation = {
|
|
88
|
+
status: 'not_observed',
|
|
89
|
+
observed_at: new Date().toISOString(),
|
|
90
|
+
host_attestation: 'absent',
|
|
91
|
+
};
|
|
92
|
+
const proof = buildExecutionProof({
|
|
93
|
+
preflighted: false,
|
|
94
|
+
executionAttempted: false,
|
|
95
|
+
executed: false,
|
|
96
|
+
enforced: false,
|
|
97
|
+
verdict,
|
|
98
|
+
commitObservation: commit_observation,
|
|
99
|
+
});
|
|
100
|
+
void toolName;
|
|
101
|
+
return {
|
|
102
|
+
executionAttempted: false,
|
|
103
|
+
executed: false,
|
|
104
|
+
enforced: false,
|
|
105
|
+
verdict,
|
|
106
|
+
preflighted: false,
|
|
107
|
+
proof,
|
|
108
|
+
freshness: FRESHNESS_NOT_CONFIGURED,
|
|
109
|
+
conditional_write: CW_NOT_REPORTED,
|
|
110
|
+
commit_observation,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Map one ProtectedTool → Vercel `tool()` object (description, parameters, execute).
|
|
115
|
+
* Binds guarded execute; mutator GuardOutcome is mapped through bindVercelGuardOutcome.
|
|
116
|
+
* Prefer tool.inputSchema when it is a plain object; otherwise empty object schema.
|
|
117
|
+
*/
|
|
118
|
+
export function protectedToolToVercel(tool) {
|
|
119
|
+
const parameters = tool.inputSchema != null
|
|
120
|
+
&& typeof tool.inputSchema === 'object'
|
|
121
|
+
&& !Array.isArray(tool.inputSchema)
|
|
122
|
+
? tool.inputSchema
|
|
123
|
+
: { ...EMPTY_PARAMETERS };
|
|
124
|
+
const execute = async (args, options) => {
|
|
125
|
+
const raw = await Promise.resolve().then(() => tool.execute(args));
|
|
126
|
+
const bindArgs = {
|
|
127
|
+
toolCallId: toolCallIdFromOptions(options),
|
|
128
|
+
toolName: tool.name,
|
|
129
|
+
};
|
|
130
|
+
// generateText treats execute's return as RESULT (the `result` field of a
|
|
131
|
+
// tool-result part). Return the bound body, not the part — otherwise the
|
|
132
|
+
// SDK nests { type:'tool-result', result: { type:'tool-result', ... } }.
|
|
133
|
+
if (looksLikeGuardOutcome(raw)) {
|
|
134
|
+
return bindVercelGuardOutcome(raw, bindArgs).result;
|
|
135
|
+
}
|
|
136
|
+
if (tool._coderifts && tool._coderifts.guarded) {
|
|
137
|
+
return bindVercelGuardOutcome(guardedNonOutcomeRefusal(tool.name), bindArgs).result;
|
|
138
|
+
}
|
|
139
|
+
return raw;
|
|
140
|
+
};
|
|
141
|
+
const out = {
|
|
142
|
+
parameters,
|
|
143
|
+
execute,
|
|
144
|
+
};
|
|
145
|
+
if (tool.description != null && tool.description !== '') {
|
|
146
|
+
out.description = tool.description;
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Convert a list of ProtectedTool into a Vercel generateText `tools` record.
|
|
152
|
+
* Does NOT call the guard — map over an already-protected list.
|
|
153
|
+
*/
|
|
154
|
+
export function toVercelTools(protectedTools) {
|
|
155
|
+
const out = {};
|
|
156
|
+
for (const t of protectedTools) {
|
|
157
|
+
out[t.name] = protectedToolToVercel(t);
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Build Vercel-ready guarded tools from raw tools + client + operation.
|
|
163
|
+
*
|
|
164
|
+
* Calls withCodeRifts internally (guard logic stays in the core). Returns:
|
|
165
|
+
* - `tools` — generateText record { [name]: { description?, parameters, execute } }
|
|
166
|
+
* - `protected_tools` — same guarded tools
|
|
167
|
+
* - assurance objects from the core, passed through untouched
|
|
168
|
+
*
|
|
169
|
+
* @param input Same shape as withCodeRifts (WithCodeRiftsInput).
|
|
170
|
+
*/
|
|
171
|
+
export function withCodeRiftsVercel(input) {
|
|
172
|
+
const core = withCodeRifts(input);
|
|
173
|
+
return vercelToolAdapter(core);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Shape adapter over an existing WithCodeRiftsResult (composition style).
|
|
177
|
+
* Prefer withCodeRiftsVercel when starting from raw tools.
|
|
178
|
+
*
|
|
179
|
+
* Does not re-run the guard; does not invent assurance.
|
|
180
|
+
*/
|
|
181
|
+
export function vercelToolAdapter(result) {
|
|
182
|
+
const protected_tools = result.tools;
|
|
183
|
+
const tools = toVercelTools(protected_tools);
|
|
184
|
+
const out = {
|
|
185
|
+
tools,
|
|
186
|
+
protected_tools,
|
|
187
|
+
registry_report: result.registry_report,
|
|
188
|
+
composition_assurance: result.composition_assurance,
|
|
189
|
+
receipt_thread: result.receipt_thread,
|
|
190
|
+
coverage_observed: result.coverage_observed,
|
|
191
|
+
};
|
|
192
|
+
if (result.repository !== undefined) {
|
|
193
|
+
out.repository = result.repository;
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
export function defaultSerializeVercelToolResult(result) {
|
|
198
|
+
if (typeof result === 'string')
|
|
199
|
+
return result;
|
|
200
|
+
if (typeof result === 'number'
|
|
201
|
+
|| typeof result === 'boolean'
|
|
202
|
+
|| typeof result === 'bigint'
|
|
203
|
+
|| result === null
|
|
204
|
+
|| result === undefined) {
|
|
205
|
+
return String(result);
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
return JSON.stringify(result);
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return String(result);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Map a full GuardOutcome into a Vercel tool-result part with proof embedded.
|
|
216
|
+
* Same arm mapping as bindOpenAIGuardOutcome; id field is toolCallId.
|
|
217
|
+
*/
|
|
218
|
+
export function bindVercelGuardOutcome(outcome, args) {
|
|
219
|
+
const toolCallId = args.toolCallId;
|
|
220
|
+
const serialize = args.serialize ?? defaultSerializeVercelToolResult;
|
|
221
|
+
let body;
|
|
222
|
+
if (outcome.executed === true) {
|
|
223
|
+
body = serialize(outcome.result);
|
|
224
|
+
}
|
|
225
|
+
else if (outcome.executionAttempted === false) {
|
|
226
|
+
body = formatGateRefusalBody(outcome);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
const err = 'error' in outcome ? outcome.error : undefined;
|
|
230
|
+
const kind = verdictKind(outcome);
|
|
231
|
+
body =
|
|
232
|
+
`Tool execution failed after gate decision (verdict: ${kind}): ${formatGuardError(err)}`;
|
|
233
|
+
}
|
|
234
|
+
const result = args.attachProof === false
|
|
235
|
+
? body
|
|
236
|
+
: attachProofToAgentResponse(body, outcome.proof);
|
|
237
|
+
const part = {
|
|
238
|
+
type: 'tool-result',
|
|
239
|
+
toolCallId,
|
|
240
|
+
result,
|
|
241
|
+
};
|
|
242
|
+
if (args.toolName != null && args.toolName !== '') {
|
|
243
|
+
part.toolName = args.toolName;
|
|
244
|
+
}
|
|
245
|
+
return part;
|
|
246
|
+
}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;IACD,OAAO,IAAkC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,14 +1,44 @@
|
|
|
1
|
+
import type { PostureVerifyInput } from './posture-receipt.js';
|
|
2
|
+
export declare const PROFILE_ENFORCING_ATOMIC_V1: "ENFORCING_ATOMIC_V1";
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* ENFORCING_ATOMIC_V2 (roadmap 1167) — V1 plus a VERIFIED credential boundary.
|
|
5
|
+
*
|
|
6
|
+
* WHY A NEW NAME RATHER THAN A STRICTER _V1. with-coderifts.ts:228 states the
|
|
7
|
+
* rule this package learned from its own 10.0.0 and 12.0.0 releases: "The next
|
|
8
|
+
* tightening MUST be `_V2`; adding a condition to `_V1` reintroduces the defect
|
|
9
|
+
* this type exists to remove." A caller who wrote `_V1` keeps exactly the
|
|
10
|
+
* contract they asked for; the stricter check costs them nothing.
|
|
11
|
+
*
|
|
12
|
+
* WHAT V2's credential_boundary PROVES:
|
|
13
|
+
* A signed `cr.posture.receipt.v1` verified against a caller-supplied key
|
|
14
|
+
* (registry or pinned PEM) asserts `verdict: 'PASS'` — the credential
|
|
15
|
+
* boundary was read back out of the live catalog at `measured_at`, that
|
|
16
|
+
* reading is inside the caller's freshness window, and the receipt is bound
|
|
17
|
+
* to this `deployment_id`.
|
|
3
18
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
19
|
+
* WHAT IT DOES NOT PROVE, and this list is the point rather than a caveat:
|
|
20
|
+
* · NOT executor_id, adapter_id, target_uri or policy_hash binding. The
|
|
21
|
+
* producer does not sign those fields — measured 2026-08-29 against
|
|
22
|
+
* capability-demo demo/src/posture.js:427-435, whose signed body is exactly
|
|
23
|
+
* { v, executor_kid, deployment_id, measured_at, verdict, facts, drift }.
|
|
24
|
+
* Verifying a field the producer never signed would be the same overclaim
|
|
25
|
+
* the audit found, inverted. Deferred to roadmap 1174; until the producer
|
|
26
|
+
* signs them, V2 must not imply the receipt binds them.
|
|
27
|
+
* · NOT an expiry. The receipt carries `measured_at` and no `expires_at`, so
|
|
28
|
+
* the age check is a FRESHNESS window the CALLER supplies via `maxAgeMs`.
|
|
29
|
+
* A guard-side default would present our policy as the receipt's statement.
|
|
30
|
+
* · NOT executor behaviour. Same honest limit as every other invariant here:
|
|
31
|
+
* construction demands wiring, and a read-back at `measured_at` is a fact
|
|
32
|
+
* about that moment, not about the write that happens afterwards.
|
|
33
|
+
*/
|
|
34
|
+
export declare const PROFILE_ENFORCING_ATOMIC_V2: "ENFORCING_ATOMIC_V2";
|
|
35
|
+
/**
|
|
36
|
+
* The unsuffixed wire value stays pinned to V1 FOREVER (with-coderifts.ts:231-233).
|
|
37
|
+
* Re-pointing it at V2 would silently move every existing caller — the migration
|
|
38
|
+
* the versioned names exist to refuse.
|
|
8
39
|
*/
|
|
9
|
-
export declare const PROFILE_ENFORCING_ATOMIC_V1: "ENFORCING_ATOMIC_V1";
|
|
10
40
|
export declare const GUARD_ATOMIC_WIRE_VALUE: "ENFORCING_ATOMIC";
|
|
11
|
-
export type AtomicProfileSpelling = 'ENFORCING_ATOMIC' | 'ENFORCING_ATOMIC_V1';
|
|
41
|
+
export type AtomicProfileSpelling = 'ENFORCING_ATOMIC' | 'ENFORCING_ATOMIC_V1' | 'ENFORCING_ATOMIC_V2';
|
|
12
42
|
export declare const ATOMIC_PROFILE_UNSATISFIED: "ATOMIC_PROFILE_UNSATISFIED";
|
|
13
43
|
export type AtomicOutcome = 'AUTHORIZED_COMMITTED' | 'REFUSED' | 'INDETERMINATE';
|
|
14
44
|
/** Frozen invariant names — adding one is ATOMIC_V2, not an edit here. */
|
|
@@ -19,7 +49,9 @@ export type MutatorRegister = {
|
|
|
19
49
|
list: () => readonly string[];
|
|
20
50
|
};
|
|
21
51
|
export declare function createMutatorRegister(): MutatorRegister;
|
|
22
|
-
export declare function isEnforcingAtomic(profile: unknown):
|
|
52
|
+
export declare function isEnforcingAtomic(profile: unknown): profile is AtomicProfileSpelling;
|
|
53
|
+
/** V2 only. The unsuffixed alias is V1 and must never answer true here. */
|
|
54
|
+
export declare function isEnforcingAtomicV2(profile: unknown): boolean;
|
|
23
55
|
export type AtomicConstructionInput = {
|
|
24
56
|
executionGrant?: {
|
|
25
57
|
enabled?: boolean;
|
|
@@ -36,7 +68,26 @@ export type AtomicConstructionInput = {
|
|
|
36
68
|
casAdapter?: unknown;
|
|
37
69
|
readBack?: unknown;
|
|
38
70
|
credentialBoundary?: unknown;
|
|
71
|
+
/** V2 ONLY. Ignored on V1, whose credential_boundary check is frozen. */
|
|
72
|
+
profile?: AtomicProfileSpelling;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* V2 caller-supplied freshness window must be finite, positive, and ≤ 24h.
|
|
76
|
+
* A larger value is not a freshness check (the receipt has no expires_at).
|
|
77
|
+
*/
|
|
78
|
+
export declare const ATOMIC_V2_MAX_AGE_MS_CAP = 86400000;
|
|
79
|
+
/**
|
|
80
|
+
* V2 credential_boundary input. A bare `true` is deliberately NOT assignable.
|
|
81
|
+
*/
|
|
82
|
+
export type VerifiedCredentialBoundary = {
|
|
83
|
+
postureReceipt: string;
|
|
84
|
+
registry?: PostureVerifyInput['registry'];
|
|
85
|
+
pinnedKeyPem?: string;
|
|
86
|
+
deploymentId?: string;
|
|
87
|
+
maxAgeMs?: number;
|
|
88
|
+
now?: () => number;
|
|
39
89
|
};
|
|
90
|
+
export declare const CREDENTIAL_BOUNDARY_BARE_REJECTED: string;
|
|
40
91
|
export declare function atomicConstructionProblems(input: AtomicConstructionInput): string[];
|
|
41
92
|
export declare function throwAtomicUnsatisfied(problems: string[]): never;
|
|
42
93
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomic-profile.d.ts","sourceRoot":"","sources":["../../src/atomic-profile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"atomic-profile.d.ts","sourceRoot":"","sources":["../../src/atomic-profile.ts"],"names":[],"mappings":"AASA,OAAO,K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CAAC;IAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC,GAAG,aAAa,CAahB"}
|
|
@@ -6,7 +6,45 @@
|
|
|
6
6
|
* wired. Executor behaviour (nonce consume-once, CAS, read-back, attestation)
|
|
7
7
|
* is still observed per call; construction only demands the wiring.
|
|
8
8
|
*/
|
|
9
|
+
import { verifyPostureReceipt } from './posture-receipt.js';
|
|
9
10
|
export const PROFILE_ENFORCING_ATOMIC_V1 = 'ENFORCING_ATOMIC_V1';
|
|
11
|
+
/**
|
|
12
|
+
* ENFORCING_ATOMIC_V2 (roadmap 1167) — V1 plus a VERIFIED credential boundary.
|
|
13
|
+
*
|
|
14
|
+
* WHY A NEW NAME RATHER THAN A STRICTER _V1. with-coderifts.ts:228 states the
|
|
15
|
+
* rule this package learned from its own 10.0.0 and 12.0.0 releases: "The next
|
|
16
|
+
* tightening MUST be `_V2`; adding a condition to `_V1` reintroduces the defect
|
|
17
|
+
* this type exists to remove." A caller who wrote `_V1` keeps exactly the
|
|
18
|
+
* contract they asked for; the stricter check costs them nothing.
|
|
19
|
+
*
|
|
20
|
+
* WHAT V2's credential_boundary PROVES:
|
|
21
|
+
* A signed `cr.posture.receipt.v1` verified against a caller-supplied key
|
|
22
|
+
* (registry or pinned PEM) asserts `verdict: 'PASS'` — the credential
|
|
23
|
+
* boundary was read back out of the live catalog at `measured_at`, that
|
|
24
|
+
* reading is inside the caller's freshness window, and the receipt is bound
|
|
25
|
+
* to this `deployment_id`.
|
|
26
|
+
*
|
|
27
|
+
* WHAT IT DOES NOT PROVE, and this list is the point rather than a caveat:
|
|
28
|
+
* · NOT executor_id, adapter_id, target_uri or policy_hash binding. The
|
|
29
|
+
* producer does not sign those fields — measured 2026-08-29 against
|
|
30
|
+
* capability-demo demo/src/posture.js:427-435, whose signed body is exactly
|
|
31
|
+
* { v, executor_kid, deployment_id, measured_at, verdict, facts, drift }.
|
|
32
|
+
* Verifying a field the producer never signed would be the same overclaim
|
|
33
|
+
* the audit found, inverted. Deferred to roadmap 1174; until the producer
|
|
34
|
+
* signs them, V2 must not imply the receipt binds them.
|
|
35
|
+
* · NOT an expiry. The receipt carries `measured_at` and no `expires_at`, so
|
|
36
|
+
* the age check is a FRESHNESS window the CALLER supplies via `maxAgeMs`.
|
|
37
|
+
* A guard-side default would present our policy as the receipt's statement.
|
|
38
|
+
* · NOT executor behaviour. Same honest limit as every other invariant here:
|
|
39
|
+
* construction demands wiring, and a read-back at `measured_at` is a fact
|
|
40
|
+
* about that moment, not about the write that happens afterwards.
|
|
41
|
+
*/
|
|
42
|
+
export const PROFILE_ENFORCING_ATOMIC_V2 = 'ENFORCING_ATOMIC_V2';
|
|
43
|
+
/**
|
|
44
|
+
* The unsuffixed wire value stays pinned to V1 FOREVER (with-coderifts.ts:231-233).
|
|
45
|
+
* Re-pointing it at V2 would silently move every existing caller — the migration
|
|
46
|
+
* the versioned names exist to refuse.
|
|
47
|
+
*/
|
|
10
48
|
export const GUARD_ATOMIC_WIRE_VALUE = 'ENFORCING_ATOMIC';
|
|
11
49
|
export const ATOMIC_PROFILE_UNSATISFIED = 'ATOMIC_PROFILE_UNSATISFIED';
|
|
12
50
|
/** Frozen invariant names — adding one is ATOMIC_V2, not an edit here. */
|
|
@@ -43,8 +81,22 @@ export function createMutatorRegister() {
|
|
|
43
81
|
return api;
|
|
44
82
|
}
|
|
45
83
|
export function isEnforcingAtomic(profile) {
|
|
46
|
-
return profile === 'ENFORCING_ATOMIC'
|
|
84
|
+
return profile === 'ENFORCING_ATOMIC'
|
|
85
|
+
|| profile === PROFILE_ENFORCING_ATOMIC_V1
|
|
86
|
+
|| profile === PROFILE_ENFORCING_ATOMIC_V2;
|
|
87
|
+
}
|
|
88
|
+
/** V2 only. The unsuffixed alias is V1 and must never answer true here. */
|
|
89
|
+
export function isEnforcingAtomicV2(profile) {
|
|
90
|
+
return profile === PROFILE_ENFORCING_ATOMIC_V2;
|
|
47
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* V2 caller-supplied freshness window must be finite, positive, and ≤ 24h.
|
|
94
|
+
* A larger value is not a freshness check (the receipt has no expires_at).
|
|
95
|
+
*/
|
|
96
|
+
export const ATOMIC_V2_MAX_AGE_MS_CAP = 86_400_000;
|
|
97
|
+
export const CREDENTIAL_BOUNDARY_BARE_REJECTED = 'credential_boundary: a verified cr.posture.receipt.v1 is required; a bare assertion is no '
|
|
98
|
+
+ 'longer accepted. ENFORCING_ATOMIC_V1 still accepts the bare form and is frozen — move to '
|
|
99
|
+
+ '_V2 to get this check.';
|
|
48
100
|
export function atomicConstructionProblems(input) {
|
|
49
101
|
const problems = [];
|
|
50
102
|
const grant = input.executionGrant;
|
|
@@ -82,6 +134,62 @@ export function atomicConstructionProblems(input) {
|
|
|
82
134
|
if (input.credentialBoundary !== true && typeof input.credentialBoundary !== 'object') {
|
|
83
135
|
problems.push('credential_boundary: credentialBoundary assertion required');
|
|
84
136
|
}
|
|
137
|
+
// ── V2 ONLY (1167). The two lines above are the FROZEN V1 check and are not
|
|
138
|
+
// edited: on V1 a bare `true` still satisfies credential_boundary, exactly as
|
|
139
|
+
// it did before this file gained a V2. Everything below runs only when the
|
|
140
|
+
// caller asked for _V2, which is what makes the tightening opt-in.
|
|
141
|
+
if (isEnforcingAtomicV2(input.profile)) {
|
|
142
|
+
const cb = input.credentialBoundary;
|
|
143
|
+
if (cb === true || !cb || typeof cb !== 'object' || typeof cb.postureReceipt !== 'string') {
|
|
144
|
+
problems.push(CREDENTIAL_BOUNDARY_BARE_REJECTED);
|
|
145
|
+
}
|
|
146
|
+
else if (!cb.registry && !cb.pinnedKeyPem) {
|
|
147
|
+
problems.push('credential_boundary: credentialBoundary.registry or .pinnedKeyPem required — the posture '
|
|
148
|
+
+ 'receipt is verified against a caller-supplied key; this package never fetches one.');
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
const deploymentId = typeof cb.deploymentId === 'string' ? cb.deploymentId : '';
|
|
152
|
+
if (deploymentId.length === 0) {
|
|
153
|
+
problems.push('credential_boundary: credentialBoundary.deploymentId required under ENFORCING_ATOMIC_V2 — '
|
|
154
|
+
+ 'the posture receipt must be bound to this deployment.');
|
|
155
|
+
}
|
|
156
|
+
const maxAgeMs = cb.maxAgeMs;
|
|
157
|
+
const maxAgeOk = typeof maxAgeMs === 'number'
|
|
158
|
+
&& Number.isFinite(maxAgeMs)
|
|
159
|
+
&& maxAgeMs > 0
|
|
160
|
+
&& maxAgeMs <= ATOMIC_V2_MAX_AGE_MS_CAP;
|
|
161
|
+
if (typeof maxAgeMs !== 'number' || !Number.isFinite(maxAgeMs) || maxAgeMs <= 0) {
|
|
162
|
+
problems.push('credential_boundary: credentialBoundary.maxAgeMs required under ENFORCING_ATOMIC_V2 — '
|
|
163
|
+
+ 'a finite positive freshness window; the receipt signs measured_at and no expires_at.');
|
|
164
|
+
}
|
|
165
|
+
else if (maxAgeMs > ATOMIC_V2_MAX_AGE_MS_CAP) {
|
|
166
|
+
problems.push(`credential_boundary: credentialBoundary.maxAgeMs exceeds the ${ATOMIC_V2_MAX_AGE_MS_CAP}ms `
|
|
167
|
+
+ 'cap (24h). A larger window is not a freshness check.');
|
|
168
|
+
}
|
|
169
|
+
// V2 calls the verifier only with both mandatory args present — a call with neither
|
|
170
|
+
// is itself a construction problem (the verifier stays permissive when invoked directly).
|
|
171
|
+
if (deploymentId.length > 0 && maxAgeOk) {
|
|
172
|
+
const r = verifyPostureReceipt(cb.postureReceipt, {
|
|
173
|
+
registry: cb.registry,
|
|
174
|
+
pinnedKeyPem: cb.pinnedKeyPem,
|
|
175
|
+
expectedDeploymentId: deploymentId,
|
|
176
|
+
maxAgeMs,
|
|
177
|
+
now: cb.now,
|
|
178
|
+
});
|
|
179
|
+
if (!r.valid) {
|
|
180
|
+
problems.push(`credential_boundary: posture receipt not verified — ${r.status} (${r.reason}). `
|
|
181
|
+
+ (r.status === 'POSTURE_STALE'
|
|
182
|
+
? 'This is the caller-supplied freshness window (maxAgeMs), not a receipt-carried '
|
|
183
|
+
+ 'expiry: cr.posture.receipt.v1 signs measured_at and no expires_at.'
|
|
184
|
+
: r.status === 'POSTURE_FAIL'
|
|
185
|
+
? 'The signature verified; the posture did not. A signed FAIL is a drift artifact — '
|
|
186
|
+
+ 'the boundary regressed, the receipt is intact.'
|
|
187
|
+
: 'Supply a posture receipt signed by a key in the registry, bound to this '
|
|
188
|
+
+ 'deployment_id, with verdict PASS.'));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
85
193
|
return problems;
|
|
86
194
|
}
|
|
87
195
|
export function throwAtomicUnsatisfied(problems) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomic-profile.js","sourceRoot":"","sources":["../../src/atomic-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,qBAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"atomic-profile.js","sourceRoot":"","sources":["../../src/atomic-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG5D,MAAM,CAAC,MAAM,2BAA2B,GAAG,qBAA8B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,qBAA8B,CAAC;AAE1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAA2B,CAAC;AAGnE,MAAM,CAAC,MAAM,0BAA0B,GAAG,4BAAqC,CAAC;AAIhF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,cAAc;IACd,oBAAoB;IACpB,aAAa;IACb,qBAAq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ProofBoundOpenAIToolMessage } fro
|
|
|
25
25
|
import { type BindAnthropicGuardOutcomeArgs, type ProofBoundAnthropicToolResult } from './adapters/anthropic.js';
|
|
26
26
|
import { type BindGeminiGuardOutcomeArgs, type ProofBoundGeminiFunctionResponse } from './adapters/gemini.js';
|
|
27
27
|
import { type BindLangGraphGuardOutcomeArgs, type ProofBoundLangGraphToolMessage } from './adapters/langgraph.js';
|
|
28
|
+
import { type BindVercelGuardOutcomeArgs, type ProofBoundVercelToolResult } from './adapters/vercel.js';
|
|
28
29
|
/**
|
|
29
30
|
* Accepts a bare ProtectedTool[] or a withCodeRifts / withCodeRifts* result that
|
|
30
31
|
* carries `tools` and/or `protected_tools`.
|
|
31
32
|
*/
|
|
32
33
|
export type ProtectedToolTableInput = readonly ProtectedTool[] | {
|
|
33
|
-
|
|
34
|
+
/** Core withCodeRifts tools[], or a provider shape record/array (ignored unless it has execute). */
|
|
35
|
+
tools?: readonly ProtectedTool[] | Record<string, unknown>;
|
|
34
36
|
protected_tools?: readonly ProtectedTool[];
|
|
35
37
|
};
|
|
36
38
|
/** Measured shape: every arm has executed + executionAttempted + proof + verdict. */
|
|
@@ -97,4 +99,17 @@ export type ExecuteLangGraphToolCallArgs = {
|
|
|
97
99
|
serialize?: BindLangGraphGuardOutcomeArgs<unknown>['serialize'];
|
|
98
100
|
};
|
|
99
101
|
export declare function executeLangGraphToolCall(args: ExecuteLangGraphToolCallArgs): Promise<ProofBoundLangGraphToolMessage>;
|
|
102
|
+
export type ExecuteVercelToolCallArgs = {
|
|
103
|
+
tools: ProtectedToolTableInput;
|
|
104
|
+
/** Vercel toolCallId this tool-result answers. */
|
|
105
|
+
toolCallId: string;
|
|
106
|
+
name: string;
|
|
107
|
+
arguments?: unknown;
|
|
108
|
+
serialize?: BindVercelGuardOutcomeArgs<unknown>['serialize'];
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Vercel AI SDK face: protected table + one tool call → ProofBoundVercelToolResult only.
|
|
112
|
+
* Return type is branded — host cannot type-check a forgotten-proof path.
|
|
113
|
+
*/
|
|
114
|
+
export declare function executeVercelToolCall(args: ExecuteVercelToolCallArgs): Promise<ProofBoundVercelToolResult>;
|
|
100
115
|
//# sourceMappingURL=execute-tool-call.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-tool-call.d.ts","sourceRoot":"","sources":["../../src/execute-tool-call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAgB,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EACnC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,gCAAgC,EACtC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACpC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"execute-tool-call.d.ts","sourceRoot":"","sources":["../../src/execute-tool-call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAgB,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EACnC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,gCAAgC,EACtC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AC5C,IAAI,EAAE,4BAA4B,GACjC,OAAO,CAAC,8BAA8B,CAAC,CAkBzC;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,uBAAuB,CAAC;IAC/B,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;CAC9D,CAAC;AAEF;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,0BAA0B,CAAC,CAmBrC"}
|
|
@@ -24,6 +24,7 @@ import { bindOpenAIGuardOutcome, } from './adapters/openai.js';
|
|
|
24
24
|
import { bindAnthropicGuardOutcome, } from './adapters/anthropic.js';
|
|
25
25
|
import { bindGeminiGuardOutcome, } from './adapters/gemini.js';
|
|
26
26
|
import { bindLangGraphGuardOutcome, } from './adapters/langgraph.js';
|
|
27
|
+
import { bindVercelGuardOutcome, } from './adapters/vercel.js';
|
|
27
28
|
function resolveProtectedTools(table) {
|
|
28
29
|
if (Array.isArray(table))
|
|
29
30
|
return table;
|
|
@@ -324,6 +325,30 @@ export async function executeLangGraphToolCall(args) {
|
|
|
324
325
|
}
|
|
325
326
|
return bound;
|
|
326
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Vercel AI SDK face: protected table + one tool call → ProofBoundVercelToolResult only.
|
|
330
|
+
* Return type is branded — host cannot type-check a forgotten-proof path.
|
|
331
|
+
*/
|
|
332
|
+
export async function executeVercelToolCall(args) {
|
|
333
|
+
const callArgs = parseMaybeJsonArgs(args.arguments);
|
|
334
|
+
const outcome = await executeProtectedTool(args.tools, args.name, callArgs);
|
|
335
|
+
const bound = bindVercelGuardOutcome(outcome, {
|
|
336
|
+
toolCallId: args.toolCallId,
|
|
337
|
+
toolName: args.name,
|
|
338
|
+
serialize: args.serialize,
|
|
339
|
+
});
|
|
340
|
+
if (outcome.executionAttempted === false) {
|
|
341
|
+
const result = appendEnvelopeSurface(bound.result, outcome);
|
|
342
|
+
const part = {
|
|
343
|
+
type: 'tool-result',
|
|
344
|
+
toolCallId: args.toolCallId,
|
|
345
|
+
toolName: args.name,
|
|
346
|
+
result,
|
|
347
|
+
};
|
|
348
|
+
return part;
|
|
349
|
+
}
|
|
350
|
+
return bound;
|
|
351
|
+
}
|
|
327
352
|
// ── helpers ──────────────────────────────────────────────────────────────────
|
|
328
353
|
function parseMaybeJsonArgs(args) {
|
|
329
354
|
if (typeof args === 'string') {
|