@coderifts/agent-guard 15.0.0 → 16.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 +3 -1
- package/dist/cjs/adapters/crewai.d.ts +88 -0
- package/dist/cjs/adapters/crewai.d.ts.map +1 -0
- package/dist/cjs/adapters/crewai.js +99 -0
- package/dist/cjs/adapters/crewai.js.map +1 -0
- package/dist/cjs/adapters/langchain.d.ts +93 -0
- package/dist/cjs/adapters/langchain.d.ts.map +1 -0
- package/dist/cjs/adapters/langchain.js +99 -0
- package/dist/cjs/adapters/langchain.js.map +1 -0
- package/dist/cjs/deploy-gate.d.ts +18 -0
- package/dist/cjs/deploy-gate.d.ts.map +1 -1
- package/dist/cjs/deploy-gate.js +18 -6
- package/dist/cjs/deploy-gate.js.map +1 -1
- package/dist/cjs/deploy-receipt-token.d.ts +7 -0
- package/dist/cjs/deploy-receipt-token.d.ts.map +1 -1
- package/dist/cjs/deploy-receipt-token.js +6 -0
- package/dist/cjs/deploy-receipt-token.js.map +1 -1
- package/dist/cjs/execution-grant.d.ts +4 -2
- package/dist/cjs/execution-grant.d.ts.map +1 -1
- package/dist/cjs/execution-grant.js +6 -0
- package/dist/cjs/execution-grant.js.map +1 -1
- package/dist/cjs/guard.d.ts.map +1 -1
- package/dist/cjs/guard.js +63 -0
- package/dist/cjs/guard.js.map +1 -1
- package/dist/cjs/index.d.ts +10 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +33 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/next-agent-step.d.ts +50 -0
- package/dist/cjs/next-agent-step.d.ts.map +1 -0
- package/dist/cjs/next-agent-step.js +53 -0
- package/dist/cjs/next-agent-step.js.map +1 -0
- package/dist/cjs/offline-verify.d.ts +75 -0
- package/dist/cjs/offline-verify.d.ts.map +1 -0
- package/dist/cjs/offline-verify.js +74 -0
- package/dist/cjs/offline-verify.js.map +1 -0
- 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/types.d.ts +64 -1
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/unguarded-mutation.d.ts +76 -0
- package/dist/cjs/unguarded-mutation.d.ts.map +1 -0
- package/dist/cjs/unguarded-mutation.js +101 -0
- package/dist/cjs/unguarded-mutation.js.map +1 -0
- package/dist/cjs/vendor/VENDOR.sha256 +13 -0
- package/dist/cjs/vendor/arity.js +53 -0
- package/dist/cjs/vendor/verify.js +454 -0
- package/dist/cjs/with-coderifts.d.ts +21 -0
- package/dist/cjs/with-coderifts.d.ts.map +1 -1
- package/dist/cjs/with-coderifts.js +42 -1
- package/dist/cjs/with-coderifts.js.map +1 -1
- package/dist/esm/adapters/crewai.d.ts +88 -0
- package/dist/esm/adapters/crewai.d.ts.map +1 -0
- package/dist/esm/adapters/crewai.js +95 -0
- package/dist/esm/adapters/crewai.js.map +1 -0
- package/dist/esm/adapters/langchain.d.ts +93 -0
- package/dist/esm/adapters/langchain.d.ts.map +1 -0
- package/dist/esm/adapters/langchain.js +94 -0
- package/dist/esm/adapters/langchain.js.map +1 -0
- package/dist/esm/deploy-gate.d.ts +18 -0
- package/dist/esm/deploy-gate.d.ts.map +1 -1
- package/dist/esm/deploy-gate.js +18 -6
- package/dist/esm/deploy-gate.js.map +1 -1
- package/dist/esm/deploy-receipt-token.d.ts +7 -0
- package/dist/esm/deploy-receipt-token.d.ts.map +1 -1
- package/dist/esm/deploy-receipt-token.js +6 -0
- package/dist/esm/deploy-receipt-token.js.map +1 -1
- package/dist/esm/execution-grant.d.ts +4 -2
- package/dist/esm/execution-grant.d.ts.map +1 -1
- package/dist/esm/execution-grant.js +6 -0
- package/dist/esm/execution-grant.js.map +1 -1
- package/dist/esm/guard.d.ts.map +1 -1
- package/dist/esm/guard.js +63 -0
- package/dist/esm/guard.js.map +1 -1
- package/dist/esm/index.d.ts +10 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +18 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/next-agent-step.d.ts +50 -0
- package/dist/esm/next-agent-step.d.ts.map +1 -0
- package/dist/esm/next-agent-step.js +49 -0
- package/dist/esm/next-agent-step.js.map +1 -0
- package/dist/esm/offline-verify.d.ts +75 -0
- package/dist/esm/offline-verify.d.ts.map +1 -0
- package/dist/esm/offline-verify.js +70 -0
- package/dist/esm/offline-verify.js.map +1 -0
- 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/types.d.ts +64 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/unguarded-mutation.d.ts +76 -0
- package/dist/esm/unguarded-mutation.d.ts.map +1 -0
- package/dist/esm/unguarded-mutation.js +97 -0
- package/dist/esm/unguarded-mutation.js.map +1 -0
- package/dist/esm/vendor/VENDOR.sha256 +13 -0
- package/dist/esm/vendor/arity.js +53 -0
- package/dist/esm/vendor/verify.js +454 -0
- package/dist/esm/with-coderifts.d.ts +21 -0
- package/dist/esm/with-coderifts.d.ts.map +1 -1
- package/dist/esm/with-coderifts.js +40 -0
- package/dist/esm/with-coderifts.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -340,8 +340,10 @@ message — not only in a human final answer.
|
|
|
340
340
|
| `bindAnthropicGuardOutcome(outcome, { tool_use_id })` | `tool_use_id` | Anthropic `tool_result` `content` (string) |
|
|
341
341
|
| `bindGeminiGuardOutcome(outcome, { name })` | function `name` | Gemini `functionResponse.response` — a **structured object** `{ result, final_answer_proof, … }` (not a text field) |
|
|
342
342
|
| `bindLangGraphGuardOutcome(outcome, { tool_call_id, name? })` | `tool_call_id` (+ optional `name`) | LangGraph/LangChain ToolMessage `content` (string) |
|
|
343
|
+
| `bindLangChainToolOutcome(outcome, { tool_call_id, name? })` | `tool_call_id` (+ optional `name`) | LangChain **`content_and_artifact`** — `content` (string, to the model) + `artifact` (structured proof, kept OUT of the model's context) |
|
|
344
|
+
| `bindCrewAIToolOutcome(outcome, { tool_name })` | `tool_name` | CrewAI `result` (string) + **`result_as_answer`** — `true` on every arm the guard did not permit |
|
|
343
345
|
|
|
344
|
-
**Behaviour (all
|
|
346
|
+
**Behaviour (all six):** take the full `GuardOutcome` (ALLOW / BLOCK / APPROVAL / SKIPPED / error
|
|
345
347
|
arms); **auto-attach** `outcome.proof` by default (S4; `{ attachProof: false }` opts out); on a
|
|
346
348
|
blocked arm state that the gate did not permit execution with **no fabricated tool result**; on
|
|
347
349
|
factory-error arms report the failure + proof. Pure and non-mutating. No framework SDK dependency
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CrewAI tool-result proof binder (I-1272).
|
|
3
|
+
*
|
|
4
|
+
* MEASURED SHAPE. CrewAI tools are Python (`crewai_tools.BaseTool`), and a tool's
|
|
5
|
+
* `_run` return value is placed into the agent's context as the tool's observation.
|
|
6
|
+
* The one structural control CrewAI gives a tool over that observation is
|
|
7
|
+
* `result_as_answer`:
|
|
8
|
+
*
|
|
9
|
+
* class MyTool(BaseTool):
|
|
10
|
+
* name: str = "..."
|
|
11
|
+
* result_as_answer: bool = True # this tool's output IS the agent's final answer
|
|
12
|
+
*
|
|
13
|
+
* With `result_as_answer=True` the agent does not keep reasoning around the output —
|
|
14
|
+
* it is returned as the answer.
|
|
15
|
+
*
|
|
16
|
+
* SOURCES (docs, no package imported — this repo is TypeScript and CrewAI is Python;
|
|
17
|
+
* the host serialises this object into its tool's return, exactly as with every other
|
|
18
|
+
* adapter here, which never import their framework either):
|
|
19
|
+
* - CrewAI "Create your own tools" / `BaseTool` — `_run` return, `result_as_answer`.
|
|
20
|
+
* https://docs.crewai.com/concepts/tools
|
|
21
|
+
* - CrewAI "Agents" — tool output handling and final-answer forcing.
|
|
22
|
+
* https://docs.crewai.com/concepts/agents
|
|
23
|
+
*
|
|
24
|
+
* WHY THAT FLAG IS THE MAPPING THAT MATTERS. A gate refusal is not an observation to
|
|
25
|
+
* reason around; it is the end of that path. Setting `result_as_answer: true` on the
|
|
26
|
+
* blocked arm is the CrewAI-native way of saying so, and it is the same statement the
|
|
27
|
+
* other binders make by refusing to fabricate a result. An executed result is an
|
|
28
|
+
* ordinary observation, so the flag is false there — the agent goes on working.
|
|
29
|
+
*
|
|
30
|
+
* INVARIANTS, identical to the four shipped binders:
|
|
31
|
+
* - PURE and non-mutating; no CrewAI dependency (a plain JSON-serialisable object).
|
|
32
|
+
* - Type-level ProofBound brand.
|
|
33
|
+
* - The blocked arm carries NO fabricated tool result — only the gate's own message.
|
|
34
|
+
* - `result` is byte-identical to what attachProofToAgentResponse produces for the
|
|
35
|
+
* same outcome, so this binder cannot drift from the others (asserted in tests).
|
|
36
|
+
*/
|
|
37
|
+
import type { GuardOutcome } from '../types.js';
|
|
38
|
+
import type { GuardExecutionProof } from '../execution-proof.js';
|
|
39
|
+
/**
|
|
40
|
+
* Minimal CrewAI tool result (no crewai dependency).
|
|
41
|
+
*
|
|
42
|
+
* Host wiring (Python side receives this as JSON):
|
|
43
|
+
* bound = bindCrewAIToolOutcome(outcome, { tool_name: 'apply_openapi' });
|
|
44
|
+
* # tool._run returns bound["result"]; the tool declares
|
|
45
|
+
* # result_as_answer = bound["result_as_answer"]
|
|
46
|
+
*/
|
|
47
|
+
export type CrewAIToolResult = {
|
|
48
|
+
/** The observation string CrewAI places in the agent's context. */
|
|
49
|
+
result: string;
|
|
50
|
+
/**
|
|
51
|
+
* True when this output IS the agent's final answer and must not be reasoned
|
|
52
|
+
* around — every arm where the guard did not permit execution.
|
|
53
|
+
*/
|
|
54
|
+
result_as_answer: boolean;
|
|
55
|
+
/** The tool this result answers for. */
|
|
56
|
+
tool_name: string;
|
|
57
|
+
/**
|
|
58
|
+
* Structured proof, alongside the string. CrewAI itself only reads `result`;
|
|
59
|
+
* this rides for the host's audit path and is never required by the framework.
|
|
60
|
+
*/
|
|
61
|
+
final_answer_proof: GuardExecutionProof;
|
|
62
|
+
};
|
|
63
|
+
declare const __proofBoundCrewAIBrand: unique symbol;
|
|
64
|
+
export type ProofBoundCrewAIToolResult = CrewAIToolResult & {
|
|
65
|
+
readonly __proofBound: typeof __proofBoundCrewAIBrand;
|
|
66
|
+
};
|
|
67
|
+
export type BindCrewAIToolOutcomeArgs<T> = {
|
|
68
|
+
/** CrewAI tool name this result answers for. */
|
|
69
|
+
tool_name: string;
|
|
70
|
+
serialize?: (result: T) => string;
|
|
71
|
+
/**
|
|
72
|
+
* Append the rendered GuardExecutionProof to `result` (S4). Default ON.
|
|
73
|
+
* The structured `final_answer_proof` field is present either way.
|
|
74
|
+
*/
|
|
75
|
+
attachProof?: boolean;
|
|
76
|
+
};
|
|
77
|
+
export declare function defaultSerializeCrewAIToolResult<T>(result: T): string;
|
|
78
|
+
/**
|
|
79
|
+
* Map a full GuardOutcome into a CrewAI tool result.
|
|
80
|
+
*
|
|
81
|
+
* Arm mapping is the shipped one (same as bindOpenAIGuardOutcome):
|
|
82
|
+
* executed → serialized result, result_as_answer: false
|
|
83
|
+
* gate refusal → formatGateRefusalBody, result_as_answer: TRUE, no fabricated result
|
|
84
|
+
* factory error → the failure named with its verdict, result_as_answer: TRUE
|
|
85
|
+
*/
|
|
86
|
+
export declare function bindCrewAIToolOutcome<T>(outcome: GuardOutcome<T>, args: BindCrewAIToolOutcomeArgs<T>): ProofBoundCrewAIToolResult;
|
|
87
|
+
export {};
|
|
88
|
+
//# sourceMappingURL=crewai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crewai.d.ts","sourceRoot":"","sources":["../../../src/adapters/crewai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAQjE;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,kBAAkB,EAAE,mBAAmB,CAAC;CACzC,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,yBAAyB,CAAC,CAAC,IAAI;IACzC,gDAAgD;IAChD,SAAS,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;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EACxB,IAAI,EAAE,yBAAyB,CAAC,CAAC,CAAC,GACjC,0BAA0B,CA+B5B"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CrewAI tool-result proof binder (I-1272).
|
|
4
|
+
*
|
|
5
|
+
* MEASURED SHAPE. CrewAI tools are Python (`crewai_tools.BaseTool`), and a tool's
|
|
6
|
+
* `_run` return value is placed into the agent's context as the tool's observation.
|
|
7
|
+
* The one structural control CrewAI gives a tool over that observation is
|
|
8
|
+
* `result_as_answer`:
|
|
9
|
+
*
|
|
10
|
+
* class MyTool(BaseTool):
|
|
11
|
+
* name: str = "..."
|
|
12
|
+
* result_as_answer: bool = True # this tool's output IS the agent's final answer
|
|
13
|
+
*
|
|
14
|
+
* With `result_as_answer=True` the agent does not keep reasoning around the output —
|
|
15
|
+
* it is returned as the answer.
|
|
16
|
+
*
|
|
17
|
+
* SOURCES (docs, no package imported — this repo is TypeScript and CrewAI is Python;
|
|
18
|
+
* the host serialises this object into its tool's return, exactly as with every other
|
|
19
|
+
* adapter here, which never import their framework either):
|
|
20
|
+
* - CrewAI "Create your own tools" / `BaseTool` — `_run` return, `result_as_answer`.
|
|
21
|
+
* https://docs.crewai.com/concepts/tools
|
|
22
|
+
* - CrewAI "Agents" — tool output handling and final-answer forcing.
|
|
23
|
+
* https://docs.crewai.com/concepts/agents
|
|
24
|
+
*
|
|
25
|
+
* WHY THAT FLAG IS THE MAPPING THAT MATTERS. A gate refusal is not an observation to
|
|
26
|
+
* reason around; it is the end of that path. Setting `result_as_answer: true` on the
|
|
27
|
+
* blocked arm is the CrewAI-native way of saying so, and it is the same statement the
|
|
28
|
+
* other binders make by refusing to fabricate a result. An executed result is an
|
|
29
|
+
* ordinary observation, so the flag is false there — the agent goes on working.
|
|
30
|
+
*
|
|
31
|
+
* INVARIANTS, identical to the four shipped binders:
|
|
32
|
+
* - PURE and non-mutating; no CrewAI dependency (a plain JSON-serialisable object).
|
|
33
|
+
* - Type-level ProofBound brand.
|
|
34
|
+
* - The blocked arm carries NO fabricated tool result — only the gate's own message.
|
|
35
|
+
* - `result` is byte-identical to what attachProofToAgentResponse produces for the
|
|
36
|
+
* same outcome, so this binder cannot drift from the others (asserted in tests).
|
|
37
|
+
*/
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.defaultSerializeCrewAIToolResult = defaultSerializeCrewAIToolResult;
|
|
40
|
+
exports.bindCrewAIToolOutcome = bindCrewAIToolOutcome;
|
|
41
|
+
const final_answer_proof_js_1 = require("../final-answer-proof.js");
|
|
42
|
+
const gate_refusal_js_1 = require("../gate-refusal.js");
|
|
43
|
+
function defaultSerializeCrewAIToolResult(result) {
|
|
44
|
+
if (typeof result === 'string')
|
|
45
|
+
return result;
|
|
46
|
+
if (typeof result === 'number'
|
|
47
|
+
|| typeof result === 'boolean'
|
|
48
|
+
|| typeof result === 'bigint'
|
|
49
|
+
|| result === null
|
|
50
|
+
|| result === undefined) {
|
|
51
|
+
return String(result);
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
return JSON.stringify(result);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return String(result);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Map a full GuardOutcome into a CrewAI tool result.
|
|
62
|
+
*
|
|
63
|
+
* Arm mapping is the shipped one (same as bindOpenAIGuardOutcome):
|
|
64
|
+
* executed → serialized result, result_as_answer: false
|
|
65
|
+
* gate refusal → formatGateRefusalBody, result_as_answer: TRUE, no fabricated result
|
|
66
|
+
* factory error → the failure named with its verdict, result_as_answer: TRUE
|
|
67
|
+
*/
|
|
68
|
+
function bindCrewAIToolOutcome(outcome, args) {
|
|
69
|
+
const serialize = args.serialize ?? defaultSerializeCrewAIToolResult;
|
|
70
|
+
let body;
|
|
71
|
+
let resultAsAnswer;
|
|
72
|
+
if (outcome.executed === true) {
|
|
73
|
+
body = serialize(outcome.result);
|
|
74
|
+
resultAsAnswer = false;
|
|
75
|
+
}
|
|
76
|
+
else if (outcome.executionAttempted === false) {
|
|
77
|
+
body = (0, gate_refusal_js_1.formatGateRefusalBody)(outcome);
|
|
78
|
+
// The gate said no. There is nothing for the agent to reason around.
|
|
79
|
+
resultAsAnswer = true;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const err = 'error' in outcome ? outcome.error : undefined;
|
|
83
|
+
const kind = (0, gate_refusal_js_1.verdictKind)(outcome);
|
|
84
|
+
body = `Tool execution failed after gate decision (verdict: ${kind}): ${(0, gate_refusal_js_1.formatGuardError)(err)}`;
|
|
85
|
+
// The factory ran and threw: the agent must not invent a success from a failure.
|
|
86
|
+
resultAsAnswer = true;
|
|
87
|
+
}
|
|
88
|
+
const result = args.attachProof === false
|
|
89
|
+
? body
|
|
90
|
+
: (0, final_answer_proof_js_1.attachProofToAgentResponse)(body, outcome.proof);
|
|
91
|
+
const out = {
|
|
92
|
+
result,
|
|
93
|
+
result_as_answer: resultAsAnswer,
|
|
94
|
+
tool_name: args.tool_name,
|
|
95
|
+
final_answer_proof: outcome.proof,
|
|
96
|
+
};
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=crewai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crewai.js","sourceRoot":"","sources":["../../../src/adapters/crewai.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;AAoDH,4EAgBC;AAUD,sDAkCC;AA5GD,oEAAsE;AACtE,wDAI4B;AA2C5B,SAAgB,gCAAgC,CAAI,MAAS;IAC3D,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IAC9C,IACE,OAAO,MAAM,KAAK,QAAQ;WACvB,OAAO,MAAM,KAAK,SAAS;WAC3B,OAAO,MAAM,KAAK,QAAQ;WAC1B,MAAM,KAAK,IAAI;WACf,MAAM,KAAK,SAAS,EACvB,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,OAAwB,EACxB,IAAkC;IAElC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,gCAAgC,CAAC;IAErE,IAAI,IAAY,CAAC;IACjB,IAAI,cAAuB,CAAC;IAC5B,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACjC,cAAc,GAAG,KAAK,CAAC;IACzB,CAAC;SAAM,IAAI,OAAO,CAAC,kBAAkB,KAAK,KAAK,EAAE,CAAC;QAChD,IAAI,GAAG,IAAA,uCAAqB,EAAC,OAAO,CAAC,CAAC;QACtC,qEAAqE;QACrE,cAAc,GAAG,IAAI,CAAC;IACxB,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,GAAG,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3D,MAAM,IAAI,GAAG,IAAA,6BAAW,EAAC,OAAO,CAAC,CAAC;QAClC,IAAI,GAAG,uDAAuD,IAAI,MAAM,IAAA,kCAAgB,EAAC,GAAG,CAAC,EAAE,CAAC;QAChG,iFAAiF;QACjF,cAAc,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,KAAK,KAAK;QACvC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAA,kDAA0B,EAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAW,CAAC;IAE9D,MAAM,GAAG,GAAqB;QAC5B,MAAM;QACN,gBAAgB,EAAE,cAAc;QAChC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,kBAAkB,EAAE,OAAO,CAAC,KAAK;KAClC,CAAC;IACF,OAAO,GAAiC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain `content_and_artifact` proof binder (I-1272).
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS IS NOT bindLangGraphGuardOutcome. That binder answers a ToolMessage:
|
|
5
|
+
* everything it carries — refusal body AND rendered proof — is a string that lands
|
|
6
|
+
* in the model's context. LangChain has a second, documented return contract for
|
|
7
|
+
* exactly the case where part of a tool's output should NOT reach the model:
|
|
8
|
+
*
|
|
9
|
+
* const t = tool(fn, { name, schema, responseFormat: 'content_and_artifact' });
|
|
10
|
+
* // fn returns the tuple [content, artifact]
|
|
11
|
+
* // → ToolMessage { content, artifact }: `content` goes to the model,
|
|
12
|
+
* // `artifact` is preserved on the message and stays out of the prompt.
|
|
13
|
+
*
|
|
14
|
+
* MEASURED SOURCES (docs + types, no package imported):
|
|
15
|
+
* - LangChain JS "How to return artifacts from a tool" — `responseFormat:
|
|
16
|
+
* "content_and_artifact"`, tool returns `[content, artifact]`.
|
|
17
|
+
* https://js.langchain.com/docs/how_to/tool_artifacts/
|
|
18
|
+
* - `ToolMessage` fields `content` / `artifact` / `tool_call_id` / `name`
|
|
19
|
+
* (@langchain/core `messages/tool`).
|
|
20
|
+
* https://js.langchain.com/docs/concepts/messages/
|
|
21
|
+
*
|
|
22
|
+
* A GuardExecutionProof is precisely an artifact: a downstream auditor wants every
|
|
23
|
+
* field of it, and a model wants none of them. Putting the structured proof in
|
|
24
|
+
* `artifact` keeps it verifiable without spending context on it.
|
|
25
|
+
*
|
|
26
|
+
* INVARIANTS, identical to the four shipped binders:
|
|
27
|
+
* - PURE and non-mutating; no @langchain/* dependency (minimal local types only).
|
|
28
|
+
* - Type-level ProofBound brand, so the compiler can tell a bound result from a raw one.
|
|
29
|
+
* - The blocked arm carries NO fabricated tool result — only the gate's own message.
|
|
30
|
+
* - `content` is byte-identical to what attachProofToAgentResponse produces for the
|
|
31
|
+
* same outcome, so this binder cannot drift from the others (asserted in tests).
|
|
32
|
+
*/
|
|
33
|
+
import type { GuardOutcome } from '../types.js';
|
|
34
|
+
import type { GuardExecutionProof } from '../execution-proof.js';
|
|
35
|
+
/**
|
|
36
|
+
* Minimal LangChain content-and-artifact tool output (no @langchain/* dependency).
|
|
37
|
+
*
|
|
38
|
+
* Host wiring:
|
|
39
|
+
* const bound = bindLangChainToolOutcome(outcome, { tool_call_id });
|
|
40
|
+
* return [bound.content, bound.artifact]; // inside a content_and_artifact tool
|
|
41
|
+
* // or: new ToolMessage({ ...bound })
|
|
42
|
+
*/
|
|
43
|
+
export type LangChainToolOutput = {
|
|
44
|
+
/** Goes to the model. */
|
|
45
|
+
content: string;
|
|
46
|
+
/** Preserved on the ToolMessage, kept OUT of the model's context. */
|
|
47
|
+
artifact: LangChainToolArtifact;
|
|
48
|
+
tool_call_id: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
};
|
|
51
|
+
/** What rides in `artifact`. Structured on purpose — an auditor reads this, not a model. */
|
|
52
|
+
export type LangChainToolArtifact = {
|
|
53
|
+
/** Guard-defined provenance marker, same idiom as proof_spec / view_spec. */
|
|
54
|
+
artifact_spec: 'coderifts-guard-artifact.v1';
|
|
55
|
+
/** The full proof object, untouched. */
|
|
56
|
+
final_answer_proof: GuardExecutionProof;
|
|
57
|
+
/** Whether the guarded factory ran. Mirrors outcome.executed; never re-derived. */
|
|
58
|
+
executed: boolean;
|
|
59
|
+
/** Whether this run was enforcing. Mirrors outcome.enforced. */
|
|
60
|
+
enforced: boolean;
|
|
61
|
+
/** Verdict kind (ALLOW / MONITOR / BLOCK / APPROVAL / SKIPPED / UNAVAILABLE). */
|
|
62
|
+
verdict: string;
|
|
63
|
+
};
|
|
64
|
+
declare const __proofBoundLangChainBrand: unique symbol;
|
|
65
|
+
export type ProofBoundLangChainToolOutput = LangChainToolOutput & {
|
|
66
|
+
readonly __proofBound: typeof __proofBoundLangChainBrand;
|
|
67
|
+
};
|
|
68
|
+
export type BindLangChainToolOutcomeArgs<T> = {
|
|
69
|
+
/** The tool_call_id this output answers. */
|
|
70
|
+
tool_call_id: string;
|
|
71
|
+
/** Optional tool name (ToolMessage.name). */
|
|
72
|
+
name?: string;
|
|
73
|
+
serialize?: (result: T) => string;
|
|
74
|
+
/**
|
|
75
|
+
* Append the RENDERED proof text to `content` (S4). Default ON, matching every
|
|
76
|
+
* other binder. `false` leaves `content` as the bare body — the artifact still
|
|
77
|
+
* carries the structured proof, which is the reason to opt out.
|
|
78
|
+
*/
|
|
79
|
+
attachProof?: boolean;
|
|
80
|
+
};
|
|
81
|
+
export declare function defaultSerializeLangChainToolResult<T>(result: T): string;
|
|
82
|
+
export declare const LANGCHAIN_ARTIFACT_SPEC: "coderifts-guard-artifact.v1";
|
|
83
|
+
/**
|
|
84
|
+
* Map a full GuardOutcome into a LangChain content_and_artifact tool output.
|
|
85
|
+
*
|
|
86
|
+
* Arm mapping is the shipped one (same as bindOpenAIGuardOutcome):
|
|
87
|
+
* executed → serialized result
|
|
88
|
+
* gate refusal → formatGateRefusalBody, NO fabricated result
|
|
89
|
+
* factory error → the failure, named, with the verdict that preceded it
|
|
90
|
+
*/
|
|
91
|
+
export declare function bindLangChainToolOutcome<T>(outcome: GuardOutcome<T>, args: BindLangChainToolOutcomeArgs<T>): ProofBoundLangChainToolOutput;
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=langchain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../../src/adapters/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAQjE;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,QAAQ,EAAE,qBAAqB,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,4FAA4F;AAC5F,MAAM,MAAM,qBAAqB,GAAG;IAClC,6EAA6E;IAC7E,aAAa,EAAE,6BAA6B,CAAC;IAC7C,wCAAwC;IACxC,kBAAkB,EAAE,mBAAmB,CAAC;IACxC,mFAAmF;IACnF,QAAQ,EAAE,OAAO,CAAC;IAClB,gEAAgE;IAChE,QAAQ,EAAE,OAAO,CAAC;IAClB,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,OAAO,CAAC,MAAM,0BAA0B,EAAE,OAAO,MAAM,CAAC;AACxD,MAAM,MAAM,6BAA6B,GAAG,mBAAmB,GAAG;IAChE,QAAQ,CAAC,YAAY,EAAE,OAAO,0BAA0B,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,4BAA4B,CAAC,CAAC,IAAI;IAC5C,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC;IAClC;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wBAAgB,mCAAmC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAgBxE;AAED,eAAO,MAAM,uBAAuB,EAAG,6BAAsC,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EACxB,IAAI,EAAE,4BAA4B,CAAC,CAAC,CAAC,GACpC,6BAA6B,CAiC/B"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LangChain `content_and_artifact` proof binder (I-1272).
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS IS NOT bindLangGraphGuardOutcome. That binder answers a ToolMessage:
|
|
6
|
+
* everything it carries — refusal body AND rendered proof — is a string that lands
|
|
7
|
+
* in the model's context. LangChain has a second, documented return contract for
|
|
8
|
+
* exactly the case where part of a tool's output should NOT reach the model:
|
|
9
|
+
*
|
|
10
|
+
* const t = tool(fn, { name, schema, responseFormat: 'content_and_artifact' });
|
|
11
|
+
* // fn returns the tuple [content, artifact]
|
|
12
|
+
* // → ToolMessage { content, artifact }: `content` goes to the model,
|
|
13
|
+
* // `artifact` is preserved on the message and stays out of the prompt.
|
|
14
|
+
*
|
|
15
|
+
* MEASURED SOURCES (docs + types, no package imported):
|
|
16
|
+
* - LangChain JS "How to return artifacts from a tool" — `responseFormat:
|
|
17
|
+
* "content_and_artifact"`, tool returns `[content, artifact]`.
|
|
18
|
+
* https://js.langchain.com/docs/how_to/tool_artifacts/
|
|
19
|
+
* - `ToolMessage` fields `content` / `artifact` / `tool_call_id` / `name`
|
|
20
|
+
* (@langchain/core `messages/tool`).
|
|
21
|
+
* https://js.langchain.com/docs/concepts/messages/
|
|
22
|
+
*
|
|
23
|
+
* A GuardExecutionProof is precisely an artifact: a downstream auditor wants every
|
|
24
|
+
* field of it, and a model wants none of them. Putting the structured proof in
|
|
25
|
+
* `artifact` keeps it verifiable without spending context on it.
|
|
26
|
+
*
|
|
27
|
+
* INVARIANTS, identical to the four shipped binders:
|
|
28
|
+
* - PURE and non-mutating; no @langchain/* dependency (minimal local types only).
|
|
29
|
+
* - Type-level ProofBound brand, so the compiler can tell a bound result from a raw one.
|
|
30
|
+
* - The blocked arm carries NO fabricated tool result — only the gate's own message.
|
|
31
|
+
* - `content` is byte-identical to what attachProofToAgentResponse produces for the
|
|
32
|
+
* same outcome, so this binder cannot drift from the others (asserted in tests).
|
|
33
|
+
*/
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.LANGCHAIN_ARTIFACT_SPEC = void 0;
|
|
36
|
+
exports.defaultSerializeLangChainToolResult = defaultSerializeLangChainToolResult;
|
|
37
|
+
exports.bindLangChainToolOutcome = bindLangChainToolOutcome;
|
|
38
|
+
const final_answer_proof_js_1 = require("../final-answer-proof.js");
|
|
39
|
+
const gate_refusal_js_1 = require("../gate-refusal.js");
|
|
40
|
+
function defaultSerializeLangChainToolResult(result) {
|
|
41
|
+
if (typeof result === 'string')
|
|
42
|
+
return result;
|
|
43
|
+
if (typeof result === 'number'
|
|
44
|
+
|| typeof result === 'boolean'
|
|
45
|
+
|| typeof result === 'bigint'
|
|
46
|
+
|| result === null
|
|
47
|
+
|| result === undefined) {
|
|
48
|
+
return String(result);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
return JSON.stringify(result);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return String(result);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.LANGCHAIN_ARTIFACT_SPEC = 'coderifts-guard-artifact.v1';
|
|
58
|
+
/**
|
|
59
|
+
* Map a full GuardOutcome into a LangChain content_and_artifact tool output.
|
|
60
|
+
*
|
|
61
|
+
* Arm mapping is the shipped one (same as bindOpenAIGuardOutcome):
|
|
62
|
+
* executed → serialized result
|
|
63
|
+
* gate refusal → formatGateRefusalBody, NO fabricated result
|
|
64
|
+
* factory error → the failure, named, with the verdict that preceded it
|
|
65
|
+
*/
|
|
66
|
+
function bindLangChainToolOutcome(outcome, args) {
|
|
67
|
+
const serialize = args.serialize ?? defaultSerializeLangChainToolResult;
|
|
68
|
+
let body;
|
|
69
|
+
if (outcome.executed === true) {
|
|
70
|
+
body = serialize(outcome.result);
|
|
71
|
+
}
|
|
72
|
+
else if (outcome.executionAttempted === false) {
|
|
73
|
+
body = (0, gate_refusal_js_1.formatGateRefusalBody)(outcome);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const err = 'error' in outcome ? outcome.error : undefined;
|
|
77
|
+
const kind = (0, gate_refusal_js_1.verdictKind)(outcome);
|
|
78
|
+
body = `Tool execution failed after gate decision (verdict: ${kind}): ${(0, gate_refusal_js_1.formatGuardError)(err)}`;
|
|
79
|
+
}
|
|
80
|
+
const content = args.attachProof === false
|
|
81
|
+
? body
|
|
82
|
+
: (0, final_answer_proof_js_1.attachProofToAgentResponse)(body, outcome.proof);
|
|
83
|
+
const out = {
|
|
84
|
+
content,
|
|
85
|
+
artifact: {
|
|
86
|
+
artifact_spec: exports.LANGCHAIN_ARTIFACT_SPEC,
|
|
87
|
+
final_answer_proof: outcome.proof,
|
|
88
|
+
executed: outcome.executed === true,
|
|
89
|
+
enforced: outcome.enforced === true,
|
|
90
|
+
verdict: (0, gate_refusal_js_1.verdictKind)(outcome),
|
|
91
|
+
},
|
|
92
|
+
tool_call_id: args.tool_call_id,
|
|
93
|
+
};
|
|
94
|
+
if (args.name != null && args.name !== '') {
|
|
95
|
+
out.name = args.name;
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=langchain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.js","sourceRoot":"","sources":["../../../src/adapters/langchain.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AA6DH,kFAgBC;AAYD,4DAoCC;AAzHD,oEAAsE;AACtE,wDAI4B;AAoD5B,SAAgB,mCAAmC,CAAI,MAAS;IAC9D,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IAC9C,IACE,OAAO,MAAM,KAAK,QAAQ;WACvB,OAAO,MAAM,KAAK,SAAS;WAC3B,OAAO,MAAM,KAAK,QAAQ;WAC1B,MAAM,KAAK,IAAI;WACf,MAAM,KAAK,SAAS,EACvB,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;AACH,CAAC;AAEY,QAAA,uBAAuB,GAAG,6BAAsC,CAAC;AAE9E;;;;;;;GAOG;AACH,SAAgB,wBAAwB,CACtC,OAAwB,EACxB,IAAqC;IAErC,MAAM,SAAS,GAAG,IA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D,OAAO,GAAoC,CAAC;AAC9C,CAAC"}
|
|
@@ -37,6 +37,8 @@ import type { GateStatusState, EnforcementState } from './merge-gate.js';
|
|
|
37
37
|
import { type DeployTokenReceipt } from './deploy-receipt-token.js';
|
|
38
38
|
export type { GateStatusState, EnforcementState } from './merge-gate.js';
|
|
39
39
|
export type { DeployTokenReceipt } from './deploy-receipt-token.js';
|
|
40
|
+
import { type NextAgentStep } from './next-agent-step.js';
|
|
41
|
+
export type { NextAgentStep } from './next-agent-step.js';
|
|
40
42
|
/**
|
|
41
43
|
* Guard-defined VERIFIED-VIEW provenance marker (same idiom as `proof_spec` /
|
|
42
44
|
* `attestation_spec`). A host that already verified (CLI, etc.) MUST set this —
|
|
@@ -185,6 +187,22 @@ export type DeployGateDecision = {
|
|
|
185
187
|
* Observation: which input mode ran and the verify_status. Not a preimage field.
|
|
186
188
|
*/
|
|
187
189
|
verification: DeployVerificationObservation;
|
|
190
|
+
/**
|
|
191
|
+
* I-1288f — the DECISION's own remediation suggestion, lifted verbatim from the
|
|
192
|
+
* `decision_result` envelope this gate verified.
|
|
193
|
+
*
|
|
194
|
+
* PRESENT ONLY IN TOKEN MODE. `verified_view` and `unverified` receipts are
|
|
195
|
+
* host-supplied views: nothing in this process checked a signature over their
|
|
196
|
+
* contents, so a step read from one would be guidance with no issuer behind it.
|
|
197
|
+
* TOKEN mode is the only path where the guard itself bound the body hash.
|
|
198
|
+
*
|
|
199
|
+
* Absent when the envelope carried none, on every allow-class deploy (the issuer
|
|
200
|
+
* sends null), and on every non-token mode. Additive: not a verdict input, not a
|
|
201
|
+
* preimage field, and no branch below reads it — see the deep-equal test.
|
|
202
|
+
*
|
|
203
|
+
* NOT PERMISSION: branch on `reason` / `deploy_allowed`, never on this.
|
|
204
|
+
*/
|
|
205
|
+
next_step?: NextAgentStep;
|
|
188
206
|
};
|
|
189
207
|
/**
|
|
190
208
|
* §1.4 — the normative, first-match-wins deploy decision. Pure; no I/O; deterministic.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-gate.d.ts","sourceRoot":"","sources":["../../src/deploy-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy-gate.d.ts","sourceRoot":"","sources":["../../src/deploy-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7E,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAG,wBAAiC,CAAC;AAE1E;;sFAEsF;AACtF,MAAM,MAAM,gBAAgB,GACxB,sBAAsB,GACtB,YAAY,GACZ,wBAAwB,GACxB,oBAAoB,GACpB,cAAc,GACd,gBAAgB,GAChB,sBAAsB,GACtB,oBAAoB,GACpB,iBAAiB,GACjB,oBAAoB,GACpB,mBAAmB,GACnB,4BAA4B,GAC5B,aAAa;AACf;;;;;GAKG;GACD,wBAAwB;AAC1B;;;;GAIG;GACD,yBAA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AC,EAAE,iBAAiB,GAAG,yBAAyB,GAAG,IAAI,CAAC;IAC/D,0FAA0F;IAC1F,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,eAAe,EAAE,qBAAqB,CAAC;IACvC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,8FAA8F;IAC9F,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,+EAA+E;IAC/E,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,eAAe,CAAC;IACvB,MAAM,EAAE,gBAAgB,CAAC;IACzB,iBAAiB,EAAE,gBAAgB,CAAC;IACpC,kBAAkB,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B;;;OAGG;IACH,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;QACjC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;KAC1B,CAAC;IACF;;OAEG;IACH,YAAY,EAAE,6BAA6B,CAAC;IAC5C;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B,CAAC;AAkCF;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,kBAAkB,CAmKrE"}
|
package/dist/cjs/deploy-gate.js
CHANGED
|
@@ -40,6 +40,7 @@ exports.asVerifiedDeployReceiptView = asVerifiedDeployReceiptView;
|
|
|
40
40
|
exports.isVerifiedDeployReceiptView = isVerifiedDeployReceiptView;
|
|
41
41
|
exports.deployGate = deployGate;
|
|
42
42
|
const deploy_receipt_token_js_1 = require("./deploy-receipt-token.js");
|
|
43
|
+
const next_agent_step_js_1 = require("./next-agent-step.js");
|
|
43
44
|
/**
|
|
44
45
|
* Guard-defined VERIFIED-VIEW provenance marker (same idiom as `proof_spec` /
|
|
45
46
|
* `attestation_spec`). A host that already verified (CLI, etc.) MUST set this —
|
|
@@ -121,12 +122,23 @@ function deployGate(input) {
|
|
|
121
122
|
bound_artifact_id: r && r.bound_artifact_id != null ? norm(r.bound_artifact_id) : null,
|
|
122
123
|
operation: r && r.operation != null ? String(r.operation) : null,
|
|
123
124
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
/**
|
|
126
|
+
* The step is read from `receipt` ONLY when this run verified a token itself. A
|
|
127
|
+
* verified-view or unverified receipt is a host claim about someone else's check,
|
|
128
|
+
* and `fail()` in the token verifier returns `view: null`, so a token that did not
|
|
129
|
+
* authenticate has no view to read from either. Both guards, stated once here.
|
|
130
|
+
*/
|
|
131
|
+
const nextStepOf = (r) => (verification.mode === 'token' ? (0, next_agent_step_js_1.readNextAgentStep)(r) : null);
|
|
132
|
+
const deny = (state, reason) => {
|
|
133
|
+
const step = nextStepOf(receipt);
|
|
134
|
+
return {
|
|
135
|
+
deploy_allowed: false, state, reason, enforcement_state, inescapable_deploy: false,
|
|
136
|
+
residuals: [],
|
|
137
|
+
detail: detailOf(receipt),
|
|
138
|
+
verification,
|
|
139
|
+
...(step ? { next_step: step } : {}),
|
|
140
|
+
};
|
|
141
|
+
};
|
|
130
142
|
// 0) incomplete target → pending/failure (fail-closed on missing evaluation input).
|
|
131
143
|
if (!target.environment || String(target.environment).trim() === ''
|
|
132
144
|
|| !target.artifact_id || String(target.artifact_id).trim() === '') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-gate.js","sourceRoot":"","sources":["../../src/deploy-gate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;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type NextAgentStep } from './next-agent-step.js';
|
|
15
16
|
import type { ExecutorKeyRegistry } from '@coderifts/sdk';
|
|
16
17
|
/** Structural receipt view produced after TOKEN verify (assignable to DeployReceiptView). */
|
|
17
18
|
export type TokenDerivedReceiptView = {
|
|
@@ -24,6 +25,12 @@ export type TokenDerivedReceiptView = {
|
|
|
24
25
|
verdict_fingerprint?: string;
|
|
25
26
|
body_hash?: string;
|
|
26
27
|
target_id?: string;
|
|
28
|
+
/**
|
|
29
|
+
* I-1288f — the decision's own remediation suggestion, lifted from the envelope.
|
|
30
|
+
* Only ever populated by viewFromEnvelope, which runs after the body hash bound.
|
|
31
|
+
* `fail()` returns `view: null`, so no unverified token can produce one.
|
|
32
|
+
*/
|
|
33
|
+
next_agent_step?: NextAgentStep | null;
|
|
27
34
|
};
|
|
28
35
|
export declare const CHAIN_SIGNING_PREFIX = "crchain.v1";
|
|
29
36
|
export type DeployTokenReceipt = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-receipt-token.d.ts","sourceRoot":"","sources":["../../src/deploy-receipt-token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"deploy-receipt-token.d.ts","sourceRoot":"","sources":["../../src/deploy-receipt-token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,6FAA6F;AAC7F,MAAM,MAAM,uBAAuB,GAAG;IACpC,oBAAoB,EAAE,OAAO,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iBAAiB,CAAC,EAAE,MAAM,G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AE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,EAClF,KAAK,CAAC,EAAE,MAAM,GACb,uBAAuB,CA0IzB"}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.CHAIN_SIGNING_PREFIX = void 0;
|
|
18
18
|
exports.verifyDeployReceiptToken = verifyDeployReceiptToken;
|
|
19
|
+
const next_agent_step_js_1 = require("./next-agent-step.js");
|
|
19
20
|
const node_crypto_1 = require("node:crypto");
|
|
20
21
|
const sdk_1 = require("@coderifts/sdk");
|
|
21
22
|
const receipt_binding_js_1 = require("./receipt-binding.js");
|
|
@@ -170,6 +171,11 @@ function viewFromEnvelope(envelope, payload, currently_authorized) {
|
|
|
170
171
|
: (typeof payload.fp === 'string' ? payload.fp : undefined),
|
|
171
172
|
body_hash: typeof payload.bh === 'string' ? payload.bh : undefined,
|
|
172
173
|
target_id: envelope.target_id == null ? undefined : String(envelope.target_id),
|
|
174
|
+
// Read from the envelope the caller supplied. On the currently_authorized path the
|
|
175
|
+
// body hash has already bound it; on the expired / retired-key paths the signature
|
|
176
|
+
// was authentic too. Every path that did NOT authenticate returns through fail(),
|
|
177
|
+
// which sets view: null — so this field cannot carry an unsigned step.
|
|
178
|
+
next_agent_step: (0, next_agent_step_js_1.readNextAgentStep)(envelope),
|
|
173
179
|
};
|
|
174
180
|
}
|
|
175
181
|
/**
|