@coderifts/agent-guard 14.0.0 → 15.0.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 +68 -8
- package/dist/cjs/atomic-profile.d.ts.map +1 -1
- package/dist/cjs/atomic-profile.js +122 -2
- package/dist/cjs/atomic-profile.js.map +1 -1
- package/dist/cjs/deny-remedy.d.ts +74 -0
- package/dist/cjs/deny-remedy.d.ts.map +1 -0
- package/dist/cjs/deny-remedy.js +127 -0
- package/dist/cjs/deny-remedy.js.map +1 -0
- package/dist/cjs/deploy-gate.d.ts +14 -1
- package/dist/cjs/deploy-gate.d.ts.map +1 -1
- package/dist/cjs/deploy-gate.js.map +1 -1
- package/dist/cjs/deploy-receipt-token.d.ts +2 -2
- package/dist/cjs/deploy-receipt-token.d.ts.map +1 -1
- package/dist/cjs/deploy-receipt-token.js +64 -1
- package/dist/cjs/deploy-receipt-token.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 +100 -0
- package/dist/cjs/execution-grant.d.ts.map +1 -1
- package/dist/cjs/execution-grant.js +101 -0
- package/dist/cjs/execution-grant.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 +56 -8
- package/dist/cjs/guard.js.map +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/policy.d.ts.map +1 -1
- package/dist/cjs/policy.js +1 -1
- package/dist/cjs/policy.js.map +1 -1
- package/dist/cjs/posture-receipt.d.ts +118 -0
- package/dist/cjs/posture-receipt.d.ts.map +1 -0
- package/dist/cjs/posture-receipt.js +220 -0
- package/dist/cjs/posture-receipt.js.map +1 -0
- package/dist/cjs/types.d.ts +23 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/with-coderifts.d.ts +17 -2
- package/dist/cjs/with-coderifts.d.ts.map +1 -1
- package/dist/cjs/with-coderifts.js +22 -5
- 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 +68 -8
- package/dist/esm/atomic-profile.d.ts.map +1 -1
- package/dist/esm/atomic-profile.js +120 -1
- package/dist/esm/atomic-profile.js.map +1 -1
- package/dist/esm/deny-remedy.d.ts +74 -0
- package/dist/esm/deny-remedy.d.ts.map +1 -0
- package/dist/esm/deny-remedy.js +122 -0
- package/dist/esm/deny-remedy.js.map +1 -0
- package/dist/esm/deploy-gate.d.ts +14 -1
- package/dist/esm/deploy-gate.d.ts.map +1 -1
- package/dist/esm/deploy-gate.js.map +1 -1
- package/dist/esm/deploy-receipt-token.d.ts +2 -2
- package/dist/esm/deploy-receipt-token.d.ts.map +1 -1
- package/dist/esm/deploy-receipt-token.js +64 -1
- package/dist/esm/deploy-receipt-token.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 +100 -0
- package/dist/esm/execution-grant.d.ts.map +1 -1
- package/dist/esm/execution-grant.js +98 -0
- package/dist/esm/execution-grant.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 +57 -9
- package/dist/esm/guard.js.map +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/policy.d.ts.map +1 -1
- package/dist/esm/policy.js +1 -1
- package/dist/esm/policy.js.map +1 -1
- package/dist/esm/posture-receipt.d.ts +118 -0
- package/dist/esm/posture-receipt.d.ts.map +1 -0
- package/dist/esm/posture-receipt.js +216 -0
- package/dist/esm/posture-receipt.js.map +1 -0
- package/dist/esm/types.d.ts +23 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/with-coderifts.d.ts +17 -2
- package/dist/esm/with-coderifts.d.ts.map +1 -1
- package/dist/esm/with-coderifts.js +21 -5
- package/dist/esm/with-coderifts.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -230,7 +230,7 @@ opt-down. Not TOCTOU closure (see **`requireExecutionStateMatch`** above).
|
|
|
230
230
|
A conflicting opt-down **aborts construction** (`ENFORCING_STRICT cannot be weakened: <flag> conflicts`).
|
|
231
231
|
Requires `resolvePriorContent` at construction. Does **not** claim host cannot register raw tools
|
|
232
232
|
outside the returned table — residual `calls_outside_guarded_path_invisible`. Adapters
|
|
233
|
-
(`withCodeRiftsOpenAI` / Anthropic / Gemini / LangGraph) still emit only the guarded list.
|
|
233
|
+
(`withCodeRiftsOpenAI` / Anthropic / Gemini / LangGraph / Vercel) still emit only the guarded list.
|
|
234
234
|
|
|
235
235
|
### Production enforcement (`ENFORCING_STRICT` + freshness / CAS)
|
|
236
236
|
|
|
@@ -474,9 +474,35 @@ const {
|
|
|
474
474
|
|
|
475
475
|
See also `examples/gemini-adapter.mjs` (not published in the npm tarball).
|
|
476
476
|
|
|
477
|
+
**Vercel AI SDK (roadmap 129).** Same thin pattern; emits a **dependency-free**
|
|
478
|
+
`generateText` / `streamText` `tools` record (`{ [name]: { description?, parameters, execute } }`)
|
|
479
|
+
matching v4 `tool({ description, parameters, execute })`. This package does **not**
|
|
480
|
+
depend on `ai` or `zod` — `parameters` is JSON Schema from `ProtectedTool.inputSchema`
|
|
481
|
+
(v4 accepts Zod Schema | JSON Schema). `execute` is the guarded factory; mutator
|
|
482
|
+
outcomes are bound with **`bindVercelGuardOutcome`** (`toolCallId`). Assurance still
|
|
483
|
+
unflattened:
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
import { withCodeRiftsVercel } from '@coderifts/agent-guard';
|
|
487
|
+
// host-owned (not a dependency of this package):
|
|
488
|
+
// import { generateText, tool } from 'ai';
|
|
489
|
+
|
|
490
|
+
const {
|
|
491
|
+
tools, // generateText tools record; guarded execute bound
|
|
492
|
+
protected_tools,
|
|
493
|
+
registry_report,
|
|
494
|
+
composition_assurance, // still may be incomplete (inescapable_runtime:false) — do not drop
|
|
495
|
+
receipt_thread,
|
|
496
|
+
} = withCodeRiftsVercel({ tools: rawTools, client, operation: 'merge' });
|
|
497
|
+
|
|
498
|
+
// generateText({ model, tools, prompt }) — only `tools` / `protected_tools` enter the loop
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
See also `examples/vercel-adapter.mjs` (not published in the npm tarball).
|
|
502
|
+
|
|
477
503
|
### Policy delivery
|
|
478
504
|
|
|
479
|
-
The
|
|
505
|
+
The adapters (`withCodeRiftsOpenAI` / Anthropic / Gemini / LangGraph / Vercel, and
|
|
480
506
|
the `bind*GuardOutcome` helpers) are **result-shapers**. They convert guarded
|
|
481
507
|
tools and bind proof onto the **tool result**. They never see the outbound
|
|
482
508
|
`messages` / `system` field, so they cannot auto-inject into the request. File-based
|
|
@@ -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,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,aAAa,CAAC;AAS9D;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC;;;;OAIG;IACH,OAAO,EAAE,CACP,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,0BAA0B,KACjC,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,iFAAiF;IACjF,KAAK,E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AE,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,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vercel AI SDK tool adapter over withCodeRifts (roadmap 129 / wave-2 —
|
|
4
|
+
* same thin pattern as OpenAI / Anthropic / LangGraph / Gemini).
|
|
5
|
+
*
|
|
6
|
+
* Thin converter. Guard logic stays in withCodeRifts; this module:
|
|
7
|
+
* 1. calls withCodeRifts with the same input shape,
|
|
8
|
+
* 2. maps each ProtectedTool → a dependency-free Vercel `tool()` object,
|
|
9
|
+
* 3. wraps `execute` so the guarded execute runs first, then bindVercelGuardOutcome,
|
|
10
|
+
* 4. returns those tools PLUS the untouched assurance objects.
|
|
11
|
+
*
|
|
12
|
+
* Measured Vercel AI SDK v4 `tool()` (no `ai` package in this repo; types from
|
|
13
|
+
* https://ai-sdk.dev/v4/docs/reference/ai-sdk-core/tool ):
|
|
14
|
+
*
|
|
15
|
+
* import { tool } from 'ai';
|
|
16
|
+
* tool({
|
|
17
|
+
* description?: string,
|
|
18
|
+
* parameters: Zod Schema | JSON Schema,
|
|
19
|
+
* execute?: async (parameters: T, options: ToolExecutionOptions) => RESULT,
|
|
20
|
+
* })
|
|
21
|
+
* ToolExecutionOptions = { toolCallId: string, messages: CoreMessage[], abortSignal?: AbortSignal }
|
|
22
|
+
*
|
|
23
|
+
* generateText / streamText `tools` is a Record keyed by tool name (not an array).
|
|
24
|
+
* This package does NOT depend on `ai` or `zod`. `parameters` is JSON Schema from
|
|
25
|
+
* ProtectedTool.inputSchema (v4 accepts JSON Schema; hosts may wrap with `tool()` + Zod).
|
|
26
|
+
*
|
|
27
|
+
* Only-protected-tools (6/D at the adapter surface):
|
|
28
|
+
* - `tools` is derived ONLY from the frozen registry's ProtectedTool list.
|
|
29
|
+
* - Raw tools never appear in the returned table.
|
|
30
|
+
*
|
|
31
|
+
* Honesty (do not "upgrade" assurance): composition_assurance is passed through
|
|
32
|
+
* EXACTLY as the core reported it.
|
|
33
|
+
*/
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.protectedToolToVercel = protectedToolToVercel;
|
|
36
|
+
exports.toVercelTools = toVercelTools;
|
|
37
|
+
exports.withCodeRiftsVercel = withCodeRiftsVercel;
|
|
38
|
+
exports.vercelToolAdapter = vercelToolAdapter;
|
|
39
|
+
exports.defaultSerializeVercelToolResult = defaultSerializeVercelToolResult;
|
|
40
|
+
exports.bindVercelGuardOutcome = bindVercelGuardOutcome;
|
|
41
|
+
const with_coderifts_js_1 = require("../with-coderifts.js");
|
|
42
|
+
const execution_proof_js_1 = require("../execution-proof.js");
|
|
43
|
+
const final_answer_proof_js_1 = require("../final-answer-proof.js");
|
|
44
|
+
const gate_refusal_js_1 = require("../gate-refusal.js");
|
|
45
|
+
/** Empty JSON Schema object — used when a ProtectedTool has no inputSchema. */
|
|
46
|
+
const EMPTY_PARAMETERS = Object.freeze({
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {},
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Local GuardOutcome duck-type. Do not import execute-tool-call (that module
|
|
52
|
+
* imports this binder — a cycle). Same fields as isGuardOutcome.
|
|
53
|
+
*/
|
|
54
|
+
function looksLikeGuardOutcome(x) {
|
|
55
|
+
if (!x || typeof x !== 'object')
|
|
56
|
+
return false;
|
|
57
|
+
const o = x;
|
|
58
|
+
return (typeof o.executed === 'boolean'
|
|
59
|
+
&& typeof o.executionAttempted === 'boolean'
|
|
60
|
+
&& o.proof != null
|
|
61
|
+
&& typeof o.proof === 'object'
|
|
62
|
+
&& o.verdict != null
|
|
63
|
+
&& typeof o.verdict === 'object');
|
|
64
|
+
}
|
|
65
|
+
function toolCallIdFromOptions(options) {
|
|
66
|
+
if (options && typeof options.toolCallId === 'string')
|
|
67
|
+
return options.toolCallId;
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
const FRESHNESS_NOT_CONFIGURED = Object.freeze({
|
|
71
|
+
wiring: 'NOT_CONFIGURED',
|
|
72
|
+
write_style: false,
|
|
73
|
+
require_freshness: false,
|
|
74
|
+
});
|
|
75
|
+
const CW_NOT_REPORTED = Object.freeze({
|
|
76
|
+
conditional_write: 'not_reported',
|
|
77
|
+
require_conditional_write: false,
|
|
78
|
+
write_style: false,
|
|
79
|
+
mutating: false,
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Guarded mutator returned a non-outcome — never forward the raw value to generateText.
|
|
83
|
+
* Same CONFIG_ERROR / UNAVAILABLE arm as execute-tool-call unknownToolOutcome (no cycle).
|
|
84
|
+
*/
|
|
85
|
+
function guardedNonOutcomeRefusal(toolName) {
|
|
86
|
+
const verdict = {
|
|
87
|
+
kind: 'UNAVAILABLE',
|
|
88
|
+
cause: 'CONFIG_ERROR',
|
|
89
|
+
failPolicy: 'closed',
|
|
90
|
+
resolution: 'CLOSED',
|
|
91
|
+
action: 'STOP',
|
|
92
|
+
decisionMissing: true,
|
|
93
|
+
unavailableCount: 1,
|
|
94
|
+
};
|
|
95
|
+
const commit_observation = {
|
|
96
|
+
status: 'not_observed',
|
|
97
|
+
observed_at: new Date().toISOString(),
|
|
98
|
+
host_attestation: 'absent',
|
|
99
|
+
};
|
|
100
|
+
const proof = (0, execution_proof_js_1.buildExecutionProof)({
|
|
101
|
+
preflighted: false,
|
|
102
|
+
executionAttempted: false,
|
|
103
|
+
executed: false,
|
|
104
|
+
enforced: false,
|
|
105
|
+
verdict,
|
|
106
|
+
commitObservation: commit_observation,
|
|
107
|
+
});
|
|
108
|
+
void toolName;
|
|
109
|
+
return {
|
|
110
|
+
executionAttempted: false,
|
|
111
|
+
executed: false,
|
|
112
|
+
enforced: false,
|
|
113
|
+
verdict,
|
|
114
|
+
preflighted: false,
|
|
115
|
+
proof,
|
|
116
|
+
freshness: FRESHNESS_NOT_CONFIGURED,
|
|
117
|
+
conditional_write: CW_NOT_REPORTED,
|
|
118
|
+
commit_observation,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Map one ProtectedTool → Vercel `tool()` object (description, parameters, execute).
|
|
123
|
+
* Binds guarded execute; mutator GuardOutcome is mapped through bindVercelGuardOutcome.
|
|
124
|
+
* Prefer tool.inputSchema when it is a plain object; otherwise empty object schema.
|
|
125
|
+
*/
|
|
126
|
+
function protectedToolToVercel(tool) {
|
|
127
|
+
const parameters = tool.inputSchema != null
|
|
128
|
+
&& typeof tool.inputSchema === 'object'
|
|
129
|
+
&& !Array.isArray(tool.inputSchema)
|
|
130
|
+
? tool.inputSchema
|
|
131
|
+
: { ...EMPTY_PARAMETERS };
|
|
132
|
+
const execute = async (args, options) => {
|
|
133
|
+
const raw = await Promise.resolve().then(() => tool.execute(args));
|
|
134
|
+
const bindArgs = {
|
|
135
|
+
toolCallId: toolCallIdFromOptions(options),
|
|
136
|
+
toolName: tool.name,
|
|
137
|
+
};
|
|
138
|
+
// generateText treats execute's return as RESULT (the `result` field of a
|
|
139
|
+
// tool-result part). Return the bound body, not the part — otherwise the
|
|
140
|
+
// SDK nests { type:'tool-result', result: { type:'tool-result', ... } }.
|
|
141
|
+
if (looksLikeGuardOutcome(raw)) {
|
|
142
|
+
return bindVercelGuardOutcome(raw, bindArgs).result;
|
|
143
|
+
}
|
|
144
|
+
if (tool._coderifts && tool._coderifts.guarded) {
|
|
145
|
+
return bindVercelGuardOutcome(guardedNonOutcomeRefusal(tool.name), bindArgs).result;
|
|
146
|
+
}
|
|
147
|
+
return raw;
|
|
148
|
+
};
|
|
149
|
+
const out = {
|
|
150
|
+
parameters,
|
|
151
|
+
execute,
|
|
152
|
+
};
|
|
153
|
+
if (tool.description != null && tool.description !== '') {
|
|
154
|
+
out.description = tool.description;
|
|
155
|
+
}
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Convert a list of ProtectedTool into a Vercel generateText `tools` record.
|
|
160
|
+
* Does NOT call the guard — map over an already-protected list.
|
|
161
|
+
*/
|
|
162
|
+
function toVercelTools(protectedTools) {
|
|
163
|
+
const out = {};
|
|
164
|
+
for (const t of protectedTools) {
|
|
165
|
+
out[t.name] = protectedToolToVercel(t);
|
|
166
|
+
}
|
|
167
|
+
return out;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Build Vercel-ready guarded tools from raw tools + client + operation.
|
|
171
|
+
*
|
|
172
|
+
* Calls withCodeRifts internally (guard logic stays in the core). Returns:
|
|
173
|
+
* - `tools` — generateText record { [name]: { description?, parameters, execute } }
|
|
174
|
+
* - `protected_tools` — same guarded tools
|
|
175
|
+
* - assurance objects from the core, passed through untouched
|
|
176
|
+
*
|
|
177
|
+
* @param input Same shape as withCodeRifts (WithCodeRiftsInput).
|
|
178
|
+
*/
|
|
179
|
+
function withCodeRiftsVercel(input) {
|
|
180
|
+
const core = (0, with_coderifts_js_1.withCodeRifts)(input);
|
|
181
|
+
return vercelToolAdapter(core);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Shape adapter over an existing WithCodeRiftsResult (composition style).
|
|
185
|
+
* Prefer withCodeRiftsVercel when starting from raw tools.
|
|
186
|
+
*
|
|
187
|
+
* Does not re-run the guard; does not invent assurance.
|
|
188
|
+
*/
|
|
189
|
+
function vercelToolAdapter(result) {
|
|
190
|
+
const protected_tools = result.tools;
|
|
191
|
+
const tools = toVercelTools(protected_tools);
|
|
192
|
+
const out = {
|
|
193
|
+
tools,
|
|
194
|
+
protected_tools,
|
|
195
|
+
registry_report: result.registry_report,
|
|
196
|
+
composition_assurance: result.composition_assurance,
|
|
197
|
+
receipt_thread: result.receipt_thread,
|
|
198
|
+
coverage_observed: result.coverage_observed,
|
|
199
|
+
};
|
|
200
|
+
if (result.repository !== undefined) {
|
|
201
|
+
out.repository = result.repository;
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
function defaultSerializeVercelToolResult(result) {
|
|
206
|
+
if (typeof result === 'string')
|
|
207
|
+
return result;
|
|
208
|
+
if (typeof result === 'number'
|
|
209
|
+
|| typeof result === 'boolean'
|
|
210
|
+
|| typeof result === 'bigint'
|
|
211
|
+
|| result === null
|
|
212
|
+
|| result === undefined) {
|
|
213
|
+
return String(result);
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
return JSON.stringify(result);
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
return String(result);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Map a full GuardOutcome into a Vercel tool-result part with proof embedded.
|
|
224
|
+
* Same arm mapping as bindOpenAIGuardOutcome; id field is toolCallId.
|
|
225
|
+
*/
|
|
226
|
+
function bindVercelGuardOutcome(outcome, args) {
|
|
227
|
+
const toolCallId = args.toolCallId;
|
|
228
|
+
const serialize = args.serialize ?? defaultSerializeVercelToolResult;
|
|
229
|
+
let body;
|
|
230
|
+
if (outcome.executed === true) {
|
|
231
|
+
body = serialize(outcome.result);
|
|
232
|
+
}
|
|
233
|
+
else if (outcome.executionAttempted === false) {
|
|
234
|
+
body = (0, gate_refusal_js_1.formatGateRefusalBody)(outcome);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
const err = 'error' in outcome ? outcome.error : undefined;
|
|
238
|
+
const kind = (0, gate_refusal_js_1.verdictKind)(outcome);
|
|
239
|
+
body =
|
|
240
|
+
`Tool execution failed after gate decision (verdict: ${kind}): ${(0, gate_refusal_js_1.formatGuardError)(err)}`;
|
|
241
|
+
}
|
|
242
|
+
const result = args.attachProof === false
|
|
243
|
+
? body
|
|
244
|
+
: (0, final_answer_proof_js_1.attachProofToAgentResponse)(body, outcome.proof);
|
|
245
|
+
const part = {
|
|
246
|
+
type: 'tool-result',
|
|
247
|
+
toolCallId,
|
|
248
|
+
result,
|
|
249
|
+
};
|
|
250
|
+
if (args.toolName != null && args.toolName !== '') {
|
|
251
|
+
part.toolName = args.toolName;
|
|
252
|
+
}
|
|
253
|
+
return part;
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=vercel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel.js","sourceRoot":"","sources":["../../../src/adapters/vercel.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;AAsKH,sDAqCC;AAMD,sCAQC;AAYD,kDAGC;AAQD,8CAeC;AAkCD,4EAgBC;AAMD,wDA+BC;AApVD,4DAAqD;AAUrD,8DAA4D;AAC5D,oEAAsE;AACtE,wDAI4B;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,CAAC;IAC9C,MAAM,CAAC,GAAG,CAA4B,CAAC;IACvC,OAAO,CACL,OAAO,CAAC,CAAC,QAAQ,KAAK,SAAS;WAC5B,OAAO,CAAC,CAAC,kBAAkB,KAAK,SAAS;WACzC,CAAC,CAAC,KAAK,IAAI,IAAI;WACf,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ;WAC3B,CAAC,CAAC,OAAO,IAAI,IAAI;WACjB,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,CACjC,CAAC;AACJ,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,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"}
|
|
@@ -1,14 +1,46 @@
|
|
|
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 a tuple the CALLER did not name. executor_id, adapter_id, target_uri
|
|
21
|
+
* and policy_hash ARE now bound (AUDIT P1 / RES-3) — but each only when the
|
|
22
|
+
* construction configures it. The earlier text here said the producer does
|
|
23
|
+
* not sign those fields; re-measured 2026-08-29 against capability-demo
|
|
24
|
+
* demo/src/posture.js, the issuer spreads them into the SIGNED canonical
|
|
25
|
+
* body whenever they carry real content, so binding them is backed by the
|
|
26
|
+
* producer rather than asserted over it. What has NOT changed is the rule
|
|
27
|
+
* underneath: a field nobody configured is reported in the verifier's
|
|
28
|
+
* `not_bound` list, never defaulted into looking checked.
|
|
29
|
+
* · NOT an expiry. The receipt carries `measured_at` and no `expires_at`, so
|
|
30
|
+
* the age check is a FRESHNESS window the CALLER supplies via `maxAgeMs`.
|
|
31
|
+
* A guard-side default would present our policy as the receipt's statement.
|
|
32
|
+
* · NOT executor behaviour. Same honest limit as every other invariant here:
|
|
33
|
+
* construction demands wiring, and a read-back at `measured_at` is a fact
|
|
34
|
+
* about that moment, not about the write that happens afterwards.
|
|
35
|
+
*/
|
|
36
|
+
export declare const PROFILE_ENFORCING_ATOMIC_V2: "ENFORCING_ATOMIC_V2";
|
|
37
|
+
/**
|
|
38
|
+
* The unsuffixed wire value stays pinned to V1 FOREVER (with-coderifts.ts:231-233).
|
|
39
|
+
* Re-pointing it at V2 would silently move every existing caller — the migration
|
|
40
|
+
* the versioned names exist to refuse.
|
|
8
41
|
*/
|
|
9
|
-
export declare const PROFILE_ENFORCING_ATOMIC_V1: "ENFORCING_ATOMIC_V1";
|
|
10
42
|
export declare const GUARD_ATOMIC_WIRE_VALUE: "ENFORCING_ATOMIC";
|
|
11
|
-
export type AtomicProfileSpelling = 'ENFORCING_ATOMIC' | 'ENFORCING_ATOMIC_V1';
|
|
43
|
+
export type AtomicProfileSpelling = 'ENFORCING_ATOMIC' | 'ENFORCING_ATOMIC_V1' | 'ENFORCING_ATOMIC_V2';
|
|
12
44
|
export declare const ATOMIC_PROFILE_UNSATISFIED: "ATOMIC_PROFILE_UNSATISFIED";
|
|
13
45
|
export type AtomicOutcome = 'AUTHORIZED_COMMITTED' | 'REFUSED' | 'INDETERMINATE';
|
|
14
46
|
/** Frozen invariant names — adding one is ATOMIC_V2, not an edit here. */
|
|
@@ -19,7 +51,9 @@ export type MutatorRegister = {
|
|
|
19
51
|
list: () => readonly string[];
|
|
20
52
|
};
|
|
21
53
|
export declare function createMutatorRegister(): MutatorRegister;
|
|
22
|
-
export declare function isEnforcingAtomic(profile: unknown):
|
|
54
|
+
export declare function isEnforcingAtomic(profile: unknown): profile is AtomicProfileSpelling;
|
|
55
|
+
/** V2 only. The unsuffixed alias is V1 and must never answer true here. */
|
|
56
|
+
export declare function isEnforcingAtomicV2(profile: unknown): boolean;
|
|
23
57
|
export type AtomicConstructionInput = {
|
|
24
58
|
executionGrant?: {
|
|
25
59
|
enabled?: boolean;
|
|
@@ -29,6 +63,13 @@ export type AtomicConstructionInput = {
|
|
|
29
63
|
executorId?: string;
|
|
30
64
|
adapterId?: string;
|
|
31
65
|
targetUri?: string;
|
|
66
|
+
/**
|
|
67
|
+
* MEASURED: executorId/adapterId/targetUri already existed here; policyHash
|
|
68
|
+
* did not exist anywhere in this package — its only mention was the comment
|
|
69
|
+
* above saying it was not bound. Added so the tuple can be STATED, not so it
|
|
70
|
+
* can be assumed: leaving it unset binds nothing, and says so.
|
|
71
|
+
*/
|
|
72
|
+
policyHash?: string;
|
|
32
73
|
executorAttestation?: {
|
|
33
74
|
registry?: unknown;
|
|
34
75
|
} | null;
|
|
@@ -36,7 +77,26 @@ export type AtomicConstructionInput = {
|
|
|
36
77
|
casAdapter?: unknown;
|
|
37
78
|
readBack?: unknown;
|
|
38
79
|
credentialBoundary?: unknown;
|
|
80
|
+
/** V2 ONLY. Ignored on V1, whose credential_boundary check is frozen. */
|
|
81
|
+
profile?: AtomicProfileSpelling;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* V2 caller-supplied freshness window must be finite, positive, and ≤ 24h.
|
|
85
|
+
* A larger value is not a freshness check (the receipt has no expires_at).
|
|
86
|
+
*/
|
|
87
|
+
export declare const ATOMIC_V2_MAX_AGE_MS_CAP = 86400000;
|
|
88
|
+
/**
|
|
89
|
+
* V2 credential_boundary input. A bare `true` is deliberately NOT assignable.
|
|
90
|
+
*/
|
|
91
|
+
export type VerifiedCredentialBoundary = {
|
|
92
|
+
postureReceipt: string;
|
|
93
|
+
registry?: PostureVerifyInput['registry'];
|
|
94
|
+
pinnedKeyPem?: string;
|
|
95
|
+
deploymentId?: string;
|
|
96
|
+
maxAgeMs?: number;
|
|
97
|
+
now?: () => number;
|
|
39
98
|
};
|
|
99
|
+
export declare const CREDENTIAL_BOUNDARY_BARE_REJECTED: string;
|
|
40
100
|
export declare function atomicConstructionProblems(input: AtomicConstructionInput): string[];
|
|
41
101
|
export declare function throwAtomicUnsatisfied(problems: string[]): never;
|
|
42
102
|
/**
|
|
@@ -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,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,eAAO,MAAM,2BAA2B,EAAG,qBAA8B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,2BAA2B,EAAG,qBAA8B,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAG,kBAA2B,CAAC;AACnE,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;AAEvG,eAAO,MAAM,0BAA0B,EAAG,4BAAqC,CAAC;AAEhF,MAAM,MAAM,aAAa,GAAG,sBAAsB,GAAG,SAAS,GAAG,eAAe,CAAC;AAEjF,0EAA0E;AAC1E,eAAO,MAAM,iBAAiB,4NAYnB,CAAC;AAEZ,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