@coderifts/agent-guard 13.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 +29 -3
- 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 +112 -0
- package/dist/cjs/atomic-profile.d.ts.map +1 -0
- package/dist/cjs/atomic-profile.js +228 -0
- package/dist/cjs/atomic-profile.js.map +1 -0
- package/dist/cjs/cas-attestation.d.ts +7 -2
- package/dist/cjs/cas-attestation.d.ts.map +1 -1
- package/dist/cjs/cas-attestation.js +10 -0
- package/dist/cjs/cas-attestation.js.map +1 -1
- package/dist/cjs/deploy-gate.d.ts +15 -3
- package/dist/cjs/deploy-gate.d.ts.map +1 -1
- package/dist/cjs/deploy-gate.js +15 -3
- package/dist/cjs/deploy-gate.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/execution-grant.d.ts +2 -0
- package/dist/cjs/execution-grant.d.ts.map +1 -1
- package/dist/cjs/execution-grant.js.map +1 -1
- package/dist/cjs/execution-proof.d.ts.map +1 -1
- package/dist/cjs/execution-proof.js +3 -1
- package/dist/cjs/execution-proof.js.map +1 -1
- package/dist/cjs/gate-refusal.js +1 -1
- package/dist/cjs/guard.d.ts.map +1 -1
- package/dist/cjs/guard.js +35 -7
- package/dist/cjs/guard.js.map +1 -1
- package/dist/cjs/index.d.ts +10 -4
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +30 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/monitoring-delivery.d.ts +1 -1
- package/dist/cjs/monitoring-delivery.d.ts.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/types.d.ts +1 -1
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/with-coderifts.d.ts +50 -5
- package/dist/cjs/with-coderifts.d.ts.map +1 -1
- package/dist/cjs/with-coderifts.js +51 -6
- 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 +112 -0
- package/dist/esm/atomic-profile.d.ts.map +1 -0
- package/dist/esm/atomic-profile.js +219 -0
- package/dist/esm/atomic-profile.js.map +1 -0
- package/dist/esm/cas-attestation.d.ts +7 -2
- package/dist/esm/cas-attestation.d.ts.map +1 -1
- package/dist/esm/cas-attestation.js +10 -0
- package/dist/esm/cas-attestation.js.map +1 -1
- package/dist/esm/deploy-gate.d.ts +15 -3
- package/dist/esm/deploy-gate.d.ts.map +1 -1
- package/dist/esm/deploy-gate.js +15 -3
- package/dist/esm/deploy-gate.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/execution-grant.d.ts +2 -0
- package/dist/esm/execution-grant.d.ts.map +1 -1
- package/dist/esm/execution-grant.js.map +1 -1
- package/dist/esm/execution-proof.d.ts.map +1 -1
- package/dist/esm/execution-proof.js +3 -1
- package/dist/esm/execution-proof.js.map +1 -1
- package/dist/esm/gate-refusal.js +1 -1
- package/dist/esm/guard.d.ts.map +1 -1
- package/dist/esm/guard.js +36 -8
- package/dist/esm/guard.js.map +1 -1
- package/dist/esm/index.d.ts +10 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +9 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/monitoring-delivery.d.ts +1 -1
- package/dist/esm/monitoring-delivery.d.ts.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/types.d.ts +1 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/with-coderifts.d.ts +50 -5
- package/dist/esm/with-coderifts.d.ts.map +1 -1
- package/dist/esm/with-coderifts.js +48 -6
- package/dist/esm/with-coderifts.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,153 @@
|
|
|
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 type { WithCodeRiftsInput, WithCodeRiftsResult, CompositionAssurance, ReceiptThreadHandle } from '../with-coderifts.js';
|
|
34
|
+
import type { CoverageObservedHandle } from '../coverage-observed.js';
|
|
35
|
+
import type { ProtectedTool, RegistryCoverageReport } from '../tool-registry.js';
|
|
36
|
+
import type { GuardOutcome } from '../types.js';
|
|
37
|
+
/**
|
|
38
|
+
* Second argument of Vercel AI SDK v4 `execute` (ToolExecutionOptions).
|
|
39
|
+
* @see https://ai-sdk.dev/v4/docs/ai-sdk-core/tools-and-tool-calling#tool-execution-options
|
|
40
|
+
*/
|
|
41
|
+
export type VercelToolExecutionOptions = {
|
|
42
|
+
toolCallId: string;
|
|
43
|
+
messages?: unknown[];
|
|
44
|
+
abortSignal?: AbortSignal;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Dependency-free Vercel `tool()` object (no `ai` import).
|
|
48
|
+
* Name is the key in the generateText `tools` record, not a field on the object.
|
|
49
|
+
* @see https://ai-sdk.dev/v4/docs/reference/ai-sdk-core/tool
|
|
50
|
+
*/
|
|
51
|
+
export type VercelTool = {
|
|
52
|
+
description?: string;
|
|
53
|
+
/** JSON Schema — v4 `parameters` accepts Zod Schema | JSON Schema. */
|
|
54
|
+
parameters: Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Guarded execute. Return is the Vercel RESULT (generateText puts it in ToolResultPart.result).
|
|
57
|
+
* Mutators: proof-bound string from bindVercelGuardOutcome (never a nested part, never raw GuardOutcome).
|
|
58
|
+
* Readonly passthrough may return the raw factory value.
|
|
59
|
+
*/
|
|
60
|
+
execute: (args: unknown, options?: VercelToolExecutionOptions) => Promise<unknown>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Result of withCodeRiftsVercel — Vercel tool record + core assurance, unflattened.
|
|
64
|
+
*
|
|
65
|
+
* `tools` is the ONLY bag intended for generateText / streamText. `protected_tools`
|
|
66
|
+
* is the same guarded list (with execute) for host dispatch — never the raw tools.
|
|
67
|
+
*/
|
|
68
|
+
export type WithCodeRiftsVercelResult = {
|
|
69
|
+
/** generateText `tools` record — only protected/guarded tools, keyed by name. */
|
|
70
|
+
tools: Record<string, VercelTool>;
|
|
71
|
+
/**
|
|
72
|
+
* Guarded ProtectedTool list from withCodeRifts (same tools as `tools`).
|
|
73
|
+
* Host may dispatch through these; never raw tools.
|
|
74
|
+
*/
|
|
75
|
+
protected_tools: ProtectedTool[];
|
|
76
|
+
/** Untouched registry report — registry's own truth. */
|
|
77
|
+
registry_report: RegistryCoverageReport;
|
|
78
|
+
/**
|
|
79
|
+
* Product-level assurance — deliberately narrower than the registry.
|
|
80
|
+
* Passed through untouched; may still show inescapable_runtime:false and
|
|
81
|
+
* residual composition_call_policy_incomplete.
|
|
82
|
+
*/
|
|
83
|
+
composition_assurance: CompositionAssurance;
|
|
84
|
+
/** Per-composition receipt cursor — NOT product-truth chain evidence. */
|
|
85
|
+
receipt_thread: ReceiptThreadHandle;
|
|
86
|
+
/** Observed coverage for this withCodeRifts run. Half A always; Half B via reportToolDispatch. */
|
|
87
|
+
coverage_observed: CoverageObservedHandle;
|
|
88
|
+
repository?: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Map one ProtectedTool → Vercel `tool()` object (description, parameters, execute).
|
|
92
|
+
* Binds guarded execute; mutator GuardOutcome is mapped through bindVercelGuardOutcome.
|
|
93
|
+
* Prefer tool.inputSchema when it is a plain object; otherwise empty object schema.
|
|
94
|
+
*/
|
|
95
|
+
export declare function protectedToolToVercel(tool: ProtectedTool): VercelTool;
|
|
96
|
+
/**
|
|
97
|
+
* Convert a list of ProtectedTool into a Vercel generateText `tools` record.
|
|
98
|
+
* Does NOT call the guard — map over an already-protected list.
|
|
99
|
+
*/
|
|
100
|
+
export declare function toVercelTools(protectedTools: readonly ProtectedTool[]): Record<string, VercelTool>;
|
|
101
|
+
/**
|
|
102
|
+
* Build Vercel-ready guarded tools from raw tools + client + operation.
|
|
103
|
+
*
|
|
104
|
+
* Calls withCodeRifts internally (guard logic stays in the core). Returns:
|
|
105
|
+
* - `tools` — generateText record { [name]: { description?, parameters, execute } }
|
|
106
|
+
* - `protected_tools` — same guarded tools
|
|
107
|
+
* - assurance objects from the core, passed through untouched
|
|
108
|
+
*
|
|
109
|
+
* @param input Same shape as withCodeRifts (WithCodeRiftsInput).
|
|
110
|
+
*/
|
|
111
|
+
export declare function withCodeRiftsVercel(input: WithCodeRiftsInput): WithCodeRiftsVercelResult;
|
|
112
|
+
/**
|
|
113
|
+
* Shape adapter over an existing WithCodeRiftsResult (composition style).
|
|
114
|
+
* Prefer withCodeRiftsVercel when starting from raw tools.
|
|
115
|
+
*
|
|
116
|
+
* Does not re-run the guard; does not invent assurance.
|
|
117
|
+
*/
|
|
118
|
+
export declare function vercelToolAdapter(result: WithCodeRiftsResult): WithCodeRiftsVercelResult;
|
|
119
|
+
/**
|
|
120
|
+
* Minimal Vercel AI SDK v4 tool-result part. No `ai` dependency.
|
|
121
|
+
* Id field is `toolCallId` (ToolExecutionOptions / ToolResultPart).
|
|
122
|
+
* @see https://ai-sdk.dev/v4/docs/ai-sdk-core/tools-and-tool-calling
|
|
123
|
+
*/
|
|
124
|
+
export type VercelToolResult = {
|
|
125
|
+
type: 'tool-result';
|
|
126
|
+
toolCallId: string;
|
|
127
|
+
toolName?: string;
|
|
128
|
+
result: string;
|
|
129
|
+
};
|
|
130
|
+
declare const __proofBoundVercelBrand: unique symbol;
|
|
131
|
+
export type ProofBoundVercelToolResult = VercelToolResult & {
|
|
132
|
+
readonly __proofBound: typeof __proofBoundVercelBrand;
|
|
133
|
+
};
|
|
134
|
+
export type BindVercelGuardOutcomeArgs<T> = {
|
|
135
|
+
/** Vercel toolCallId this tool-result answers. */
|
|
136
|
+
toolCallId: string;
|
|
137
|
+
/** Optional tool name (ToolResultPart.toolName). */
|
|
138
|
+
toolName?: string;
|
|
139
|
+
serialize?: (result: T) => string;
|
|
140
|
+
/**
|
|
141
|
+
* Attach the rendered GuardExecutionProof (S4). Default ON.
|
|
142
|
+
* Pass `false` to opt out.
|
|
143
|
+
*/
|
|
144
|
+
attachProof?: boolean;
|
|
145
|
+
};
|
|
146
|
+
export declare function defaultSerializeVercelToolResult<T>(result: T): string;
|
|
147
|
+
/**
|
|
148
|
+
* Map a full GuardOutcome into a Vercel tool-result part with proof embedded.
|
|
149
|
+
* Same arm mapping as bindOpenAIGuardOutcome; id field is toolCallId.
|
|
150
|
+
*/
|
|
151
|
+
export declare function bindVercelGuardOutcome<T>(outcome: GuardOutcome<T>, args: BindVercelGuardOutcomeArgs<T>): ProofBoundVercelToolResult;
|
|
152
|
+
export {};
|
|
153
|
+
//# sourceMappingURL=vercel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/adapters/vercel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,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KAAK,EAAE,kBAAkB,GAAG,yBAAyB,CAGxF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,yBAAyB,CAexF;AAID;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,MAAM,CAAC;AACrD,MAAM,MAAM,0BAA0B,GAAG,gBAAgB,GAAG;IAC1D,QAAQ,CAAC,YAAY,EAAE,OAAO,uBAAuB,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,CAAC,IAAI;IAC1C,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wBAAgB,gCAAgC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAgBrE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EACxB,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAClC,0BAA0B,CA4B5B"}
|
|
@@ -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
|
+
}
|
|
247
|
+
//# sourceMappingURL=vercel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel.js","sourceRoot":"","sources":["../../../src/adapters/vercel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAUrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,GACZ,MAAM,oBAAoB,CAAC;AA6D5B,+EAA+E;AAC/E,MAAM,gBAAgB,GAA4B,MAAM,CAAC,MAAM,CAAC;IAC9D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,EAAE;CACf,CAAC,CAAC;AAEH;;;GAGG;AACH,SAAS,qBAAqB,CAAC,CAAU;IACvC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK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SAAS,CAAC;QAC3D,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI;YACF,uDAAuD,IAAI,MAAM,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;IAC7F,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,KAAK,KAAK;QACvC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,0BAA0B,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAW,CAAC;IAC9D,MAAM,IAAI,GAAqB;QAC7B,IAAI,EAAE,aAAa;QACnB,UAAU;QACV,MAAM;KACP,CAAC;IACF,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,EAAE,EAAE,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;IACD,OAAO,IAAkC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { PostureVerifyInput } from './posture-receipt.js';
|
|
2
|
+
export declare const PROFILE_ENFORCING_ATOMIC_V1: "ENFORCING_ATOMIC_V1";
|
|
3
|
+
/**
|
|
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`.
|
|
18
|
+
*
|
|
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.
|
|
39
|
+
*/
|
|
40
|
+
export declare const GUARD_ATOMIC_WIRE_VALUE: "ENFORCING_ATOMIC";
|
|
41
|
+
export type AtomicProfileSpelling = 'ENFORCING_ATOMIC' | 'ENFORCING_ATOMIC_V1' | 'ENFORCING_ATOMIC_V2';
|
|
42
|
+
export declare const ATOMIC_PROFILE_UNSATISFIED: "ATOMIC_PROFILE_UNSATISFIED";
|
|
43
|
+
export type AtomicOutcome = 'AUTHORIZED_COMMITTED' | 'REFUSED' | 'INDETERMINATE';
|
|
44
|
+
/** Frozen invariant names — adding one is ATOMIC_V2, not an edit here. */
|
|
45
|
+
export declare const ATOMIC_INVARIANTS: readonly ["verified_receipt", "verified_grant_v2", "exact_executor", "exact_target", "after_payload_hash", "fresh_nonce", "nonce_consumed_once", "target_CAS", "read_back", "executor_attestation", "credential_boundary"];
|
|
46
|
+
export type MutatorRegister = {
|
|
47
|
+
registerMutator: (name: string) => MutatorRegister;
|
|
48
|
+
has: (name: string) => boolean;
|
|
49
|
+
list: () => readonly string[];
|
|
50
|
+
};
|
|
51
|
+
export declare function createMutatorRegister(): MutatorRegister;
|
|
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;
|
|
55
|
+
export type AtomicConstructionInput = {
|
|
56
|
+
executionGrant?: {
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
resolveStateNonce?: unknown;
|
|
59
|
+
grantVersion?: string;
|
|
60
|
+
} | null;
|
|
61
|
+
executorId?: string;
|
|
62
|
+
adapterId?: string;
|
|
63
|
+
targetUri?: string;
|
|
64
|
+
executorAttestation?: {
|
|
65
|
+
registry?: unknown;
|
|
66
|
+
} | null;
|
|
67
|
+
mutatorRegister?: MutatorRegister | null;
|
|
68
|
+
casAdapter?: unknown;
|
|
69
|
+
readBack?: unknown;
|
|
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;
|
|
89
|
+
};
|
|
90
|
+
export declare const CREDENTIAL_BOUNDARY_BARE_REJECTED: string;
|
|
91
|
+
export declare function atomicConstructionProblems(input: AtomicConstructionInput): string[];
|
|
92
|
+
export declare function throwAtomicUnsatisfied(problems: string[]): never;
|
|
93
|
+
/**
|
|
94
|
+
* Per-call outcome union. Host-claimed commit never AUTHORIZED_COMMITTED.
|
|
95
|
+
*/
|
|
96
|
+
export declare function atomicOutcome(input: {
|
|
97
|
+
receiptVerified: boolean;
|
|
98
|
+
grantV2Valid: boolean;
|
|
99
|
+
executorMatch: boolean;
|
|
100
|
+
targetMatch: boolean;
|
|
101
|
+
nonceFresh: boolean;
|
|
102
|
+
nonceConsumedOnce: boolean;
|
|
103
|
+
casCommitted: boolean;
|
|
104
|
+
readBackOk: boolean;
|
|
105
|
+
executorAttested: boolean;
|
|
106
|
+
mutatorRegistered: boolean;
|
|
107
|
+
authUnavailable?: boolean;
|
|
108
|
+
nonceStoreUnavailable?: boolean;
|
|
109
|
+
readBackUnavailable?: boolean;
|
|
110
|
+
signerUnavailableAfterCommit?: boolean;
|
|
111
|
+
}): AtomicOutcome;
|
|
112
|
+
//# sourceMappingURL=atomic-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic-profile.d.ts","sourceRoot":"","sources":["../../src/atomic-profile.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,eAAO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