@coderifts/agent-guard 14.1.0 → 15.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.
Files changed (106) hide show
  1. package/README.md +3 -1
  2. package/dist/cjs/adapters/crewai.d.ts +88 -0
  3. package/dist/cjs/adapters/crewai.d.ts.map +1 -0
  4. package/dist/cjs/adapters/crewai.js +99 -0
  5. package/dist/cjs/adapters/crewai.js.map +1 -0
  6. package/dist/cjs/adapters/langchain.d.ts +93 -0
  7. package/dist/cjs/adapters/langchain.d.ts.map +1 -0
  8. package/dist/cjs/adapters/langchain.js +99 -0
  9. package/dist/cjs/adapters/langchain.js.map +1 -0
  10. package/dist/cjs/atomic-profile.d.ts +16 -7
  11. package/dist/cjs/atomic-profile.d.ts.map +1 -1
  12. package/dist/cjs/atomic-profile.js +18 -7
  13. package/dist/cjs/atomic-profile.js.map +1 -1
  14. package/dist/cjs/deny-remedy.d.ts +74 -0
  15. package/dist/cjs/deny-remedy.d.ts.map +1 -0
  16. package/dist/cjs/deny-remedy.js +127 -0
  17. package/dist/cjs/deny-remedy.js.map +1 -0
  18. package/dist/cjs/deploy-gate.d.ts +32 -1
  19. package/dist/cjs/deploy-gate.d.ts.map +1 -1
  20. package/dist/cjs/deploy-gate.js +18 -6
  21. package/dist/cjs/deploy-gate.js.map +1 -1
  22. package/dist/cjs/deploy-receipt-token.d.ts +9 -2
  23. package/dist/cjs/deploy-receipt-token.d.ts.map +1 -1
  24. package/dist/cjs/deploy-receipt-token.js +70 -1
  25. package/dist/cjs/deploy-receipt-token.js.map +1 -1
  26. package/dist/cjs/execution-grant.d.ts +100 -0
  27. package/dist/cjs/execution-grant.d.ts.map +1 -1
  28. package/dist/cjs/execution-grant.js +101 -0
  29. package/dist/cjs/execution-grant.js.map +1 -1
  30. package/dist/cjs/guard.d.ts.map +1 -1
  31. package/dist/cjs/guard.js +67 -8
  32. package/dist/cjs/guard.js.map +1 -1
  33. package/dist/cjs/index.d.ts +7 -1
  34. package/dist/cjs/index.d.ts.map +1 -1
  35. package/dist/cjs/index.js +23 -3
  36. package/dist/cjs/index.js.map +1 -1
  37. package/dist/cjs/next-agent-step.d.ts +50 -0
  38. package/dist/cjs/next-agent-step.d.ts.map +1 -0
  39. package/dist/cjs/next-agent-step.js +53 -0
  40. package/dist/cjs/next-agent-step.js.map +1 -0
  41. package/dist/cjs/policy.d.ts.map +1 -1
  42. package/dist/cjs/policy.js +1 -1
  43. package/dist/cjs/policy.js.map +1 -1
  44. package/dist/cjs/posture-receipt.d.ts +39 -0
  45. package/dist/cjs/posture-receipt.d.ts.map +1 -1
  46. package/dist/cjs/posture-receipt.js +39 -0
  47. package/dist/cjs/posture-receipt.js.map +1 -1
  48. package/dist/cjs/types.d.ts +39 -0
  49. package/dist/cjs/types.d.ts.map +1 -1
  50. package/dist/cjs/with-coderifts.d.ts +36 -0
  51. package/dist/cjs/with-coderifts.d.ts.map +1 -1
  52. package/dist/cjs/with-coderifts.js +60 -4
  53. package/dist/cjs/with-coderifts.js.map +1 -1
  54. package/dist/esm/adapters/crewai.d.ts +88 -0
  55. package/dist/esm/adapters/crewai.d.ts.map +1 -0
  56. package/dist/esm/adapters/crewai.js +95 -0
  57. package/dist/esm/adapters/crewai.js.map +1 -0
  58. package/dist/esm/adapters/langchain.d.ts +93 -0
  59. package/dist/esm/adapters/langchain.d.ts.map +1 -0
  60. package/dist/esm/adapters/langchain.js +94 -0
  61. package/dist/esm/adapters/langchain.js.map +1 -0
  62. package/dist/esm/atomic-profile.d.ts +16 -7
  63. package/dist/esm/atomic-profile.d.ts.map +1 -1
  64. package/dist/esm/atomic-profile.js +18 -7
  65. package/dist/esm/atomic-profile.js.map +1 -1
  66. package/dist/esm/deny-remedy.d.ts +74 -0
  67. package/dist/esm/deny-remedy.d.ts.map +1 -0
  68. package/dist/esm/deny-remedy.js +122 -0
  69. package/dist/esm/deny-remedy.js.map +1 -0
  70. package/dist/esm/deploy-gate.d.ts +32 -1
  71. package/dist/esm/deploy-gate.d.ts.map +1 -1
  72. package/dist/esm/deploy-gate.js +18 -6
  73. package/dist/esm/deploy-gate.js.map +1 -1
  74. package/dist/esm/deploy-receipt-token.d.ts +9 -2
  75. package/dist/esm/deploy-receipt-token.d.ts.map +1 -1
  76. package/dist/esm/deploy-receipt-token.js +70 -1
  77. package/dist/esm/deploy-receipt-token.js.map +1 -1
  78. package/dist/esm/execution-grant.d.ts +100 -0
  79. package/dist/esm/execution-grant.d.ts.map +1 -1
  80. package/dist/esm/execution-grant.js +98 -0
  81. package/dist/esm/execution-grant.js.map +1 -1
  82. package/dist/esm/guard.d.ts.map +1 -1
  83. package/dist/esm/guard.js +68 -9
  84. package/dist/esm/guard.js.map +1 -1
  85. package/dist/esm/index.d.ts +7 -1
  86. package/dist/esm/index.d.ts.map +1 -1
  87. package/dist/esm/index.js +12 -1
  88. package/dist/esm/index.js.map +1 -1
  89. package/dist/esm/next-agent-step.d.ts +50 -0
  90. package/dist/esm/next-agent-step.d.ts.map +1 -0
  91. package/dist/esm/next-agent-step.js +49 -0
  92. package/dist/esm/next-agent-step.js.map +1 -0
  93. package/dist/esm/policy.d.ts.map +1 -1
  94. package/dist/esm/policy.js +1 -1
  95. package/dist/esm/policy.js.map +1 -1
  96. package/dist/esm/posture-receipt.d.ts +39 -0
  97. package/dist/esm/posture-receipt.d.ts.map +1 -1
  98. package/dist/esm/posture-receipt.js +39 -0
  99. package/dist/esm/posture-receipt.js.map +1 -1
  100. package/dist/esm/types.d.ts +39 -0
  101. package/dist/esm/types.d.ts.map +1 -1
  102. package/dist/esm/with-coderifts.d.ts +36 -0
  103. package/dist/esm/with-coderifts.d.ts.map +1 -1
  104. package/dist/esm/with-coderifts.js +58 -3
  105. package/dist/esm/with-coderifts.js.map +1 -1
  106. package/package.json +2 -2
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 four):** take the full `GuardOutcome` (ALLOW / BLOCK / APPROVAL / SKIPPED / error
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,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 * 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,IAAI,CAAC,SAAS,IAAI,mCAAmC,CAAC;IAExE,IAAI,IAAY,CAAC;IACjB,IAAI,OAAO,CAAC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C_V1: "ENFORCING_ATOMIC_V1";
17
17
  * to this `deployment_id`.
18
18
  *
19
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.
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.
27
29
  * · NOT an expiry. The receipt carries `measured_at` and no `expires_at`, so
28
30
  * the age check is a FRESHNESS window the CALLER supplies via `maxAgeMs`.
29
31
  * A guard-side default would present our policy as the receipt's statement.
@@ -61,6 +63,13 @@ export type AtomicConstructionInput = {
61
63
  executorId?: string;
62
64
  adapterId?: string;
63
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;
64
73
  executorAttestation?: {
65
74
  registry?: unknown;
66
75
  } | null;
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-profile.d.ts","sourceRoot":"","sources":["../../src/atomic-profile.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB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,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC,GAAG,aAAa,CAahB"}
@@ -34,13 +34,15 @@ exports.PROFILE_ENFORCING_ATOMIC_V1 = 'ENFORCING_ATOMIC_V1';
34
34
  * to this `deployment_id`.
35
35
  *
36
36
  * WHAT IT DOES NOT PROVE, and this list is the point rather than a caveat:
37
- * · NOT executor_id, adapter_id, target_uri or policy_hash binding. The
38
- * producer does not sign those fields measured 2026-08-29 against
39
- * capability-demo demo/src/posture.js:427-435, whose signed body is exactly
40
- * { v, executor_kid, deployment_id, measured_at, verdict, facts, drift }.
41
- * Verifying a field the producer never signed would be the same overclaim
42
- * the audit found, inverted. Deferred to roadmap 1174; until the producer
43
- * signs them, V2 must not imply the receipt binds them.
37
+ * · NOT a tuple the CALLER did not name. executor_id, adapter_id, target_uri
38
+ * and policy_hash ARE now bound (AUDIT P1 / RES-3) — but each only when the
39
+ * construction configures it. The earlier text here said the producer does
40
+ * not sign those fields; re-measured 2026-08-29 against capability-demo
41
+ * demo/src/posture.js, the issuer spreads them into the SIGNED canonical
42
+ * body whenever they carry real content, so binding them is backed by the
43
+ * producer rather than asserted over it. What has NOT changed is the rule
44
+ * underneath: a field nobody configured is reported in the verifier's
45
+ * `not_bound` list, never defaulted into looking checked.
44
46
  * · NOT an expiry. The receipt carries `measured_at` and no `expires_at`, so
45
47
  * the age check is a FRESHNESS window the CALLER supplies via `maxAgeMs`.
46
48
  * A guard-side default would present our policy as the receipt's statement.
@@ -178,10 +180,19 @@ function atomicConstructionProblems(input) {
178
180
  // V2 calls the verifier only with both mandatory args present — a call with neither
179
181
  // is itself a construction problem (the verifier stays permissive when invoked directly).
180
182
  if (deploymentId.length > 0 && maxAgeOk) {
183
+ // The credential-boundary tuple, from the construction input rather than
184
+ // from anywhere this function could invent it. Each is passed ONLY when
185
+ // configured: an absent one reaches the verifier as undefined and comes
186
+ // back named in `not_bound` — the honest record of a boundary this
187
+ // deployment never stated.
181
188
  const r = (0, posture_receipt_js_1.verifyPostureReceipt)(cb.postureReceipt, {
182
189
  registry: cb.registry,
183
190
  pinnedKeyPem: cb.pinnedKeyPem,
184
191
  expectedDeploymentId: deploymentId,
192
+ expectedExecutorId: input.executorId,
193
+ expectedAdapterId: input.adapterId,
194
+ expectedTargetUri: input.targetUri,
195
+ expectedPolicyHash: input.policyHash,
185
196
  maxAgeMs,
186
197
  now: cb.now,
187
198
  });
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-profile.js","sourceRoot":"","sources":["../../src/atomic-profile.ts"],"names":[],"mappings":";;;AA+EA,sDAkBC;AAED,8CAIC;AAGD,kDAEC;AAuCD,gEAuGC;AAED,wDAOC;AAKD,sCA4BC;AApSD;;;;;;;GAOG;AACH,6DAA4D;AAG/C,QAAA,2BAA2B,GAAG,qBAA8B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACU,QAAA,2BAA2B,GAAG,qBAA8B,CAAC;AAE1E;;;;GAIG;AACU,QAAA,uBAAuB,GAAG,kBAA2B,CAAC;AAGtD,QAAA,0BAA0B,GAAG,4BAAqC,CAAC;AAIhF,0EAA0E;AAC7D,QAAA,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,cAAc;IACd,oBAAoB;IACpB,aAAa;IACb,qBAAqB;IACrB,YAAY;IACZ,WA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AC,eAAe,IAAI,KAAK,CAAC,qBAAqB,IAAI,KAAK,CAAC,mBAAmB,EAAE,CAAC;QACtF,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,IAAI,KAAK,CAAC,4BAA4B,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;QAC7D,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,MAAM,EAAE,GAAG,KAAK,CAAC,eAAe,IAAI,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,aAAa;WACxE,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,iBAAiB;WAChE,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,gBAAgB;WAChE,KAAK,CAAC,iBAAiB,CAAC;IAC7B,IAAI,EAAE,IAAI,KAAK,CAAC,gBAAgB;QAAE,OAAO,sBAAsB,CAAC;IAChE,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * deny-remedy.v1 — the machine-readable next step attached to a refusal.
3
+ *
4
+ * CANONICAL SCHEMA: capability-demo/docs/deny-remedy.v1.json
5
+ * sha256 3f51c5afd1708a9185075a4f19f6386ea7d63ad39b0104e31f0e4e887b6e167f
6
+ *
7
+ * This builder is the TypeScript transliteration of the copy carried by the
8
+ * JavaScript deny surfaces — same three classes, same refusal to invent a
9
+ * fourth, same schema. It is a copy rather than a shared package on purpose:
10
+ * these repos are installed independently and a shared
11
+ * dependency would make one of them unable to refuse a request because another
12
+ * failed to resolve.
13
+ *
14
+ * WHERE IT SITS IN THE FLOW. The remedy is attached AFTER a verdict is reached,
15
+ * never inside verification. Nothing here reads a key, checks a signature, or
16
+ * can change allow into deny. A surface that emits a remedy has already refused.
17
+ *
18
+ * WHAT IT REFUSES TO EMIT. Three error classes exist and no more. A refusal
19
+ * whose reason does not map to one of them gets NO remedy — an unmapped reason
20
+ * is a refusal we cannot yet describe as a next step, and inventing a fourth
21
+ * class, or defaulting to the nearest one, would send a caller to a step that
22
+ * does not address why they were refused.
23
+ */
24
+ /** The closed set from the schema. */
25
+ export declare const DENY_ERROR: Readonly<{
26
+ GRANT_REQUIRED: "CODERIFTS_GRANT_REQUIRED";
27
+ GRANT_INVALID: "CODERIFTS_GRANT_INVALID";
28
+ GRANT_MISMATCH: "CODERIFTS_GRANT_MISMATCH";
29
+ }>;
30
+ /** Carried verbatim from the schema so it cannot be softened in rendering. */
31
+ export declare const DOES_NOT_PROMISE = "a grant does not guarantee execution (CAS may still fail)";
32
+ export declare const ARGS_SHAPE: Readonly<{
33
+ artifacts: "Array<{ id, type, before, after }> — the change set being authorized";
34
+ context: "{ operation, environment?, repository?, branch?, pull_request? } — operation is required for authorize";
35
+ }>;
36
+ /** The three classes, as a type. */
37
+ export type DenyError = (typeof DENY_ERROR)[keyof typeof DENY_ERROR];
38
+ /** The emitted object — exactly the shape the schema describes. */
39
+ export interface DenyRemedy {
40
+ error: DenyError;
41
+ target: string | null;
42
+ fingerprint: string | null;
43
+ action_required: {
44
+ tool: 'preflight_change_set';
45
+ mode: 'authorize';
46
+ args_shape: Record<string, string>;
47
+ };
48
+ does_not_promise: string;
49
+ observed?: Record<string, unknown>;
50
+ }
51
+ /**
52
+ * Build the remedy object, or return null when this refusal has no remedy.
53
+ *
54
+ * @param {string} o.error one of DENY_ERROR; anything else returns null
55
+ * @param {string} [o.target] the surface's own addressing for what was refused
56
+ * @param {string} [o.fingerprint] the change-set fingerprint the deny was evaluated
57
+ * against, when the surface has one
58
+ * @param {object} [o.observed] free-form, for an operator reading a log
59
+ * @returns {object|null}
60
+ */
61
+ export declare function buildDenyRemedy({ error, target, fingerprint, observed }: {
62
+ error: DenyError | null;
63
+ target?: string | null;
64
+ fingerprint?: string | null;
65
+ observed?: Record<string, unknown> | null;
66
+ }): DenyRemedy | null;
67
+ /**
68
+ * Map a surface's own refusal reason to an error class.
69
+ *
70
+ * The mapping is explicit and closed. An unlisted reason returns null, which
71
+ * means no remedy — see the note at the top of this file.
72
+ */
73
+ export declare function denyErrorForReason(reason: unknown): DenyError | null;
74
+ //# sourceMappingURL=deny-remedy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deny-remedy.d.ts","sourceRoot":"","sources":["../../src/deny-remedy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,sCAAsC;AACtC,eAAO,MAAM,UAAU;;;;EAIrB,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,8DAA8D,CAAC;AAE5F,eAAO,MAAM,UAAU;;;EAGrB,CAAC;AAIH,oCAAoC;AACpC,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAErE,mEAAmE;AACnE,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE;QAAE,IAAI,EAAE,sBAAsB,CAAC;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IACzG,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,EAAE,KAAK,EAAE,MAAa,EAAE,WAAkB,EAAE,QAAe,EAAE,EAAE;IAC7D,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC3C,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