@coderifts/agent-guard 4.2.0 → 5.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.
Files changed (56) hide show
  1. package/README.md +180 -35
  2. package/dist/cjs/adapters/anthropic.d.ts +90 -0
  3. package/dist/cjs/adapters/anthropic.d.ts.map +1 -0
  4. package/dist/cjs/adapters/anthropic.js +97 -0
  5. package/dist/cjs/adapters/anthropic.js.map +1 -0
  6. package/dist/cjs/adapters/gemini.d.ts +114 -0
  7. package/dist/cjs/adapters/gemini.d.ts.map +1 -0
  8. package/dist/cjs/adapters/gemini.js +110 -0
  9. package/dist/cjs/adapters/gemini.js.map +1 -0
  10. package/dist/cjs/adapters/langgraph.d.ts +117 -0
  11. package/dist/cjs/adapters/langgraph.d.ts.map +1 -0
  12. package/dist/cjs/adapters/langgraph.js +113 -0
  13. package/dist/cjs/adapters/langgraph.js.map +1 -0
  14. package/dist/cjs/adapters/openai.d.ts +93 -0
  15. package/dist/cjs/adapters/openai.d.ts.map +1 -0
  16. package/dist/cjs/adapters/openai.js +97 -0
  17. package/dist/cjs/adapters/openai.js.map +1 -0
  18. package/dist/cjs/final-answer-proof.d.ts +80 -0
  19. package/dist/cjs/final-answer-proof.d.ts.map +1 -0
  20. package/dist/cjs/final-answer-proof.js +222 -0
  21. package/dist/cjs/final-answer-proof.js.map +1 -0
  22. package/dist/cjs/guard.d.ts.map +1 -1
  23. package/dist/cjs/guard.js +5 -1
  24. package/dist/cjs/guard.js.map +1 -1
  25. package/dist/cjs/index.d.ts +10 -0
  26. package/dist/cjs/index.d.ts.map +1 -1
  27. package/dist/cjs/index.js +33 -2
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/esm/adapters/anthropic.d.ts +90 -0
  30. package/dist/esm/adapters/anthropic.d.ts.map +1 -0
  31. package/dist/esm/adapters/anthropic.js +91 -0
  32. package/dist/esm/adapters/anthropic.js.map +1 -0
  33. package/dist/esm/adapters/gemini.d.ts +114 -0
  34. package/dist/esm/adapters/gemini.d.ts.map +1 -0
  35. package/dist/esm/adapters/gemini.js +104 -0
  36. package/dist/esm/adapters/gemini.js.map +1 -0
  37. package/dist/esm/adapters/langgraph.d.ts +117 -0
  38. package/dist/esm/adapters/langgraph.d.ts.map +1 -0
  39. package/dist/esm/adapters/langgraph.js +107 -0
  40. package/dist/esm/adapters/langgraph.js.map +1 -0
  41. package/dist/esm/adapters/openai.d.ts +93 -0
  42. package/dist/esm/adapters/openai.d.ts.map +1 -0
  43. package/dist/esm/adapters/openai.js +91 -0
  44. package/dist/esm/adapters/openai.js.map +1 -0
  45. package/dist/esm/final-answer-proof.d.ts +80 -0
  46. package/dist/esm/final-answer-proof.d.ts.map +1 -0
  47. package/dist/esm/final-answer-proof.js +217 -0
  48. package/dist/esm/final-answer-proof.js.map +1 -0
  49. package/dist/esm/guard.d.ts.map +1 -1
  50. package/dist/esm/guard.js +5 -1
  51. package/dist/esm/guard.js.map +1 -1
  52. package/dist/esm/index.d.ts +10 -0
  53. package/dist/esm/index.d.ts.map +1 -1
  54. package/dist/esm/index.js +12 -0
  55. package/dist/esm/index.js.map +1 -1
  56. package/package.json +2 -2
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ /**
3
+ * Google Gemini function-calling adapter over withCodeRifts (ID632 slice 4 —
4
+ * same thin pattern as OpenAI / Anthropic / LangGraph).
5
+ *
6
+ * Thin SHAPE converter only. Guard logic stays in withCodeRifts; this module:
7
+ * 1. calls withCodeRifts with the same input shape,
8
+ * 2. maps ProtectedTool[] → Gemini generateContent tools shape,
9
+ * 3. returns Gemini-shaped tools PLUS the untouched assurance objects
10
+ * (registry_report, composition_assurance, receipt_thread).
11
+ *
12
+ * Gemini nesting (differs from OpenAI):
13
+ * tools: [ { functionDeclarations: [ { name, description?, parameters }, … ] } ]
14
+ * One tools entry wraps ALL declarations in a single functionDeclarations array —
15
+ * not one { type: 'function' } object per tool.
16
+ *
17
+ * Honesty (do not "upgrade" assurance):
18
+ * - composition_assurance is passed through EXACTLY as the core reported it
19
+ * (COMPOSITION_CALL_POLICY_COMPLETE may still be false; inescapable_runtime may be false).
20
+ * - The adapter converts tool SHAPE for the model API; it does not claim product-level
21
+ * inescapability the core does not claim.
22
+ *
23
+ * Only-protected-tools (6/D at the adapter surface):
24
+ * - `tools` is derived ONLY from the frozen registry's ProtectedTool list.
25
+ * - Raw tools never appear in the returned Gemini table. The host may still hold a raw
26
+ * reference outside this table; that boundary stays the host's responsibility.
27
+ *
28
+ * Ergonomics (5–10 lines): pass raw tools + client + operation → Gemini-ready tools.
29
+ * Mirrors src/adapters/openai.ts — only the target tool shape differs.
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.protectedToolToFunctionDeclaration = protectedToolToFunctionDeclaration;
33
+ exports.toGeminiTools = toGeminiTools;
34
+ exports.withCodeRiftsGemini = withCodeRiftsGemini;
35
+ exports.geminiToolAdapter = geminiToolAdapter;
36
+ const with_coderifts_js_1 = require("../with-coderifts.js");
37
+ /** Empty OpenAPI-like JSON Schema — used when a ProtectedTool has no inputSchema. */
38
+ const EMPTY_PARAMETERS = Object.freeze({
39
+ type: 'object',
40
+ properties: {},
41
+ });
42
+ /**
43
+ * Map one ProtectedTool → Gemini functionDeclaration (shape only; no execute).
44
+ * Prefer tool.inputSchema when it is a plain object; otherwise empty object schema.
45
+ */
46
+ function protectedToolToFunctionDeclaration(tool) {
47
+ const parameters = tool.inputSchema != null
48
+ && typeof tool.inputSchema === 'object'
49
+ && !Array.isArray(tool.inputSchema)
50
+ ? tool.inputSchema
51
+ : { ...EMPTY_PARAMETERS };
52
+ const out = {
53
+ name: tool.name,
54
+ parameters,
55
+ };
56
+ if (tool.description != null && tool.description !== '') {
57
+ out.description = tool.description;
58
+ }
59
+ return out;
60
+ }
61
+ /**
62
+ * Convert ProtectedTool[] into Gemini `tools` array:
63
+ * [ { functionDeclarations: [ … ] } ]
64
+ *
65
+ * Empty protected list → empty tools array (no empty wrapper).
66
+ * Does NOT call the guard — pure shape map over an already-protected list.
67
+ */
68
+ function toGeminiTools(protectedTools) {
69
+ if (protectedTools.length === 0)
70
+ return [];
71
+ return [{
72
+ functionDeclarations: protectedTools.map(protectedToolToFunctionDeclaration),
73
+ }];
74
+ }
75
+ /**
76
+ * Build Gemini-ready guarded tools from raw tools + client + operation.
77
+ *
78
+ * Calls withCodeRifts internally (guard logic stays in the core). Returns:
79
+ * - `tools` — Gemini shape [ { functionDeclarations: […] } ]
80
+ * - `protected_tools` — same guarded tools for host execute dispatch
81
+ * - assurance objects from the core, passed through untouched
82
+ *
83
+ * @param input Same shape as withCodeRifts (WithCodeRiftsInput).
84
+ */
85
+ function withCodeRiftsGemini(input) {
86
+ const core = (0, with_coderifts_js_1.withCodeRifts)(input);
87
+ return geminiToolAdapter(core);
88
+ }
89
+ /**
90
+ * Shape-only adapter over an existing WithCodeRiftsResult (composition style).
91
+ * Prefer withCodeRiftsGemini when starting from raw tools.
92
+ *
93
+ * Does not re-run the guard; does not invent assurance.
94
+ */
95
+ function geminiToolAdapter(result) {
96
+ const protected_tools = result.tools;
97
+ const tools = toGeminiTools(protected_tools);
98
+ const out = {
99
+ tools,
100
+ protected_tools,
101
+ registry_report: result.registry_report,
102
+ composition_assurance: result.composition_assurance,
103
+ receipt_thread: result.receipt_thread,
104
+ };
105
+ if (result.repository !== undefined) {
106
+ out.repository = result.repository;
107
+ }
108
+ return out;
109
+ }
110
+ //# sourceMappingURL=gemini.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../src/adapters/gemini.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;AA2EH,gFAgBC;AASD,sCAKC;AAYD,kDAGC;AAQD,8CAcC;AA5ID,4DAAqD;AA+DrD,qFAAqF;AACrF,MAAM,gBAAgB,GAA4B,MAAM,CAAC,MAAM,CAAC;IAC9D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,EAAE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AAE,MAAM,CAAC,qBAAqB;QACnD,cAAc,EAAE,MAAM,CAAC,cAAc;KACtC,CAAC;IACF,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACpC,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * LangChain / LangGraph tool adapter over withCodeRifts (ID632 slice 3 — same thin
3
+ * pattern as OpenAI / Anthropic).
4
+ *
5
+ * Thin converter only. Guard logic stays in withCodeRifts; this module:
6
+ * 1. calls withCodeRifts with the same input shape,
7
+ * 2. maps each ProtectedTool → a framework-agnostic tool descriptor that
8
+ * LangChain's tool()/StructuredTool and LangGraph's ToolNode can accept,
9
+ * 3. returns those descriptors PLUS the untouched assurance objects
10
+ * (registry_report, composition_assurance, receipt_thread).
11
+ *
12
+ * NO hard dependency on langchain / @langchain/* / langgraph packages. The host
13
+ * owns the framework import and wires descriptors into tool() / ToolNode /
14
+ * bind_tools / StateGraph themselves.
15
+ *
16
+ * Descriptor shape (dependency-free plain object):
17
+ * { name, description?, schema, func, invoke }
18
+ * - schema = JSON Schema from ProtectedTool.inputSchema (or empty object schema)
19
+ * - func / invoke = the GUARDED execute (same function reference) — never the raw tool
20
+ *
21
+ * Honesty (do not "upgrade" assurance):
22
+ * - composition_assurance is passed through EXACTLY as the core reported it
23
+ * (COMPOSITION_CALL_POLICY_COMPLETE may still be false; inescapable_runtime may be false).
24
+ * - The adapter converts tool shape + binds guarded execute; it does not claim product-level
25
+ * inescapability the core does not claim.
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. The host may still hold a raw
30
+ * reference outside this table; that boundary stays the host's responsibility.
31
+ *
32
+ * Ergonomics (5–10 lines): pass raw tools + client + operation → LangGraph-ready descriptors.
33
+ * Mirrors src/adapters/openai.ts and anthropic.ts — only the target tool shape differs.
34
+ */
35
+ import type { WithCodeRiftsInput, WithCodeRiftsResult, CompositionAssurance, ReceiptThreadHandle } from '../with-coderifts.js';
36
+ import type { ProtectedTool, RegistryCoverageReport } from '../tool-registry.js';
37
+ /**
38
+ * Framework-agnostic LangChain/LangGraph tool descriptor (no package import).
39
+ *
40
+ * Host wiring (illustrative — host supplies the framework packages, e.g.
41
+ * @langchain/core tools + @langchain/langgraph ToolNode):
42
+ * const lcTools = tools.map((d) =>
43
+ * hostTool(d.func, { name: d.name, description: d.description, schema: d.schema }));
44
+ * // then hostToolNode(lcTools) / hostLlm.bindTools(lcTools)
45
+ */
46
+ export type LangGraphToolDescriptor = {
47
+ name: string;
48
+ description?: string;
49
+ /** JSON Schema for tool args (LangChain `schema` / StructuredTool args). */
50
+ schema: Record<string, unknown>;
51
+ /**
52
+ * Guarded execute — same as ProtectedTool.execute.
53
+ * Pass to LangChain `tool(func, …)` or StructuredTool-style runners.
54
+ */
55
+ func: (args: unknown) => Promise<unknown>;
56
+ /**
57
+ * Alias of `func` for invoke-style APIs (StructuredTool.invoke / ToolNode).
58
+ * Same guarded execute reference as `func`.
59
+ */
60
+ invoke: (args: unknown) => Promise<unknown>;
61
+ };
62
+ /**
63
+ * Result of withCodeRiftsLangGraph — descriptors + core assurance, unflattened.
64
+ *
65
+ * `tools` is the ONLY list intended for the model/runtime tool table. `protected_tools` is the
66
+ * same guarded list for host inspection — never the raw tools.
67
+ */
68
+ export type WithCodeRiftsLangGraphResult = {
69
+ /** LangGraph/LangChain-compatible descriptors — only protected/guarded tools. */
70
+ tools: LangGraphToolDescriptor[];
71
+ /**
72
+ * Guarded ProtectedTool list from withCodeRifts (same tools as `tools`).
73
+ * Host may use these for dispatch; 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
+ repository?: string;
87
+ };
88
+ /**
89
+ * Map one ProtectedTool → LangGraph/LangChain tool descriptor.
90
+ * Binds guarded execute to both `func` and `invoke` (same reference).
91
+ * Prefer tool.inputSchema when it is a plain object; otherwise empty object schema.
92
+ */
93
+ export declare function protectedToolToLangGraph(tool: ProtectedTool): LangGraphToolDescriptor;
94
+ /**
95
+ * Convert a list of ProtectedTool into LangGraph/LangChain descriptors.
96
+ * Does NOT call the guard — pure map over an already-protected list.
97
+ */
98
+ export declare function toLangGraphTools(protectedTools: readonly ProtectedTool[]): LangGraphToolDescriptor[];
99
+ /**
100
+ * Build LangGraph/LangChain-ready guarded tool descriptors from raw tools + client + operation.
101
+ *
102
+ * Calls withCodeRifts internally (guard logic stays in the core). Returns:
103
+ * - `tools` — plain descriptors { name, description?, schema, func, invoke }
104
+ * - `protected_tools` — same guarded tools
105
+ * - assurance objects from the core, passed through untouched
106
+ *
107
+ * @param input Same shape as withCodeRifts (WithCodeRiftsInput).
108
+ */
109
+ export declare function withCodeRiftsLangGraph(input: WithCodeRiftsInput): WithCodeRiftsLangGraphResult;
110
+ /**
111
+ * Shape adapter over an existing WithCodeRiftsResult (composition style).
112
+ * Prefer withCodeRiftsLangGraph when starting from raw tools.
113
+ *
114
+ * Does not re-run the guard; does not invent assurance.
115
+ */
116
+ export declare function langGraphToolAdapter(result: WithCodeRiftsResult): WithCodeRiftsLangGraphResult;
117
+ //# sourceMappingURL=langgraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langgraph.d.ts","sourceRoot":"","sources":["../../../src/adapters/langgraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,KAAK,EACV,kBAAkB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F"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ /**
3
+ * LangChain / LangGraph tool adapter over withCodeRifts (ID632 slice 3 — same thin
4
+ * pattern as OpenAI / Anthropic).
5
+ *
6
+ * Thin converter only. Guard logic stays in withCodeRifts; this module:
7
+ * 1. calls withCodeRifts with the same input shape,
8
+ * 2. maps each ProtectedTool → a framework-agnostic tool descriptor that
9
+ * LangChain's tool()/StructuredTool and LangGraph's ToolNode can accept,
10
+ * 3. returns those descriptors PLUS the untouched assurance objects
11
+ * (registry_report, composition_assurance, receipt_thread).
12
+ *
13
+ * NO hard dependency on langchain / @langchain/* / langgraph packages. The host
14
+ * owns the framework import and wires descriptors into tool() / ToolNode /
15
+ * bind_tools / StateGraph themselves.
16
+ *
17
+ * Descriptor shape (dependency-free plain object):
18
+ * { name, description?, schema, func, invoke }
19
+ * - schema = JSON Schema from ProtectedTool.inputSchema (or empty object schema)
20
+ * - func / invoke = the GUARDED execute (same function reference) — never the raw tool
21
+ *
22
+ * Honesty (do not "upgrade" assurance):
23
+ * - composition_assurance is passed through EXACTLY as the core reported it
24
+ * (COMPOSITION_CALL_POLICY_COMPLETE may still be false; inescapable_runtime may be false).
25
+ * - The adapter converts tool shape + binds guarded execute; it does not claim product-level
26
+ * inescapability the core does not claim.
27
+ *
28
+ * Only-protected-tools (6/D at the adapter surface):
29
+ * - `tools` is derived ONLY from the frozen registry's ProtectedTool list.
30
+ * - Raw tools never appear in the returned table. The host may still hold a raw
31
+ * reference outside this table; that boundary stays the host's responsibility.
32
+ *
33
+ * Ergonomics (5–10 lines): pass raw tools + client + operation → LangGraph-ready descriptors.
34
+ * Mirrors src/adapters/openai.ts and anthropic.ts — only the target tool shape differs.
35
+ */
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.protectedToolToLangGraph = protectedToolToLangGraph;
38
+ exports.toLangGraphTools = toLangGraphTools;
39
+ exports.withCodeRiftsLangGraph = withCodeRiftsLangGraph;
40
+ exports.langGraphToolAdapter = langGraphToolAdapter;
41
+ const with_coderifts_js_1 = require("../with-coderifts.js");
42
+ /** Empty JSON Schema object — used when a ProtectedTool has no inputSchema. */
43
+ const EMPTY_SCHEMA = Object.freeze({
44
+ type: 'object',
45
+ properties: {},
46
+ });
47
+ /**
48
+ * Map one ProtectedTool → LangGraph/LangChain tool descriptor.
49
+ * Binds guarded execute to both `func` and `invoke` (same reference).
50
+ * Prefer tool.inputSchema when it is a plain object; otherwise empty object schema.
51
+ */
52
+ function protectedToolToLangGraph(tool) {
53
+ const schema = tool.inputSchema != null
54
+ && typeof tool.inputSchema === 'object'
55
+ && !Array.isArray(tool.inputSchema)
56
+ ? tool.inputSchema
57
+ : { ...EMPTY_SCHEMA };
58
+ // Guarded execute only — never a raw unwrapped executor.
59
+ const guarded = (args) => Promise.resolve(tool.execute(args));
60
+ const out = {
61
+ name: tool.name,
62
+ schema,
63
+ func: guarded,
64
+ invoke: guarded,
65
+ };
66
+ if (tool.description != null && tool.description !== '') {
67
+ out.description = tool.description;
68
+ }
69
+ return out;
70
+ }
71
+ /**
72
+ * Convert a list of ProtectedTool into LangGraph/LangChain descriptors.
73
+ * Does NOT call the guard — pure map over an already-protected list.
74
+ */
75
+ function toLangGraphTools(protectedTools) {
76
+ return protectedTools.map(protectedToolToLangGraph);
77
+ }
78
+ /**
79
+ * Build LangGraph/LangChain-ready guarded tool descriptors from raw tools + client + operation.
80
+ *
81
+ * Calls withCodeRifts internally (guard logic stays in the core). Returns:
82
+ * - `tools` — plain descriptors { name, description?, schema, func, invoke }
83
+ * - `protected_tools` — same guarded tools
84
+ * - assurance objects from the core, passed through untouched
85
+ *
86
+ * @param input Same shape as withCodeRifts (WithCodeRiftsInput).
87
+ */
88
+ function withCodeRiftsLangGraph(input) {
89
+ const core = (0, with_coderifts_js_1.withCodeRifts)(input);
90
+ return langGraphToolAdapter(core);
91
+ }
92
+ /**
93
+ * Shape adapter over an existing WithCodeRiftsResult (composition style).
94
+ * Prefer withCodeRiftsLangGraph when starting from raw tools.
95
+ *
96
+ * Does not re-run the guard; does not invent assurance.
97
+ */
98
+ function langGraphToolAdapter(result) {
99
+ const protected_tools = result.tools;
100
+ const tools = toLangGraphTools(protected_tools);
101
+ const out = {
102
+ tools,
103
+ protected_tools,
104
+ registry_report: result.registry_report,
105
+ composition_assurance: result.composition_assurance,
106
+ receipt_thread: result.receipt_thread,
107
+ };
108
+ if (result.repository !== undefined) {
109
+ out.repository = result.repository;
110
+ }
111
+ return out;
112
+ }
113
+ //# sourceMappingURL=langgraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langgraph.js","sourceRoot":"","sources":["../../../src/adapters/langgraph.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;AA2EH,4DAqBC;AAMD,4CAEC;AAYD,wDAGC;AAQD,oDAcC;AA3ID,4DAAqD;AA8DrD,+EAA+E;AAC/E,MAAM,YAAY,GAA4B,MAAM,CAAC,MAAM,CAAC;IAC1D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,EAAE;CACf,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,IAAmB;IAC1D,MAAM,MAAM,GACV,IAAI,CAAC,WAAW,IAAI,IAAI;WACrB,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ;WACpC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC;QACjC,CAAC,CAAE,IAAI,CAAC,WAAuC;QAC/C,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,CAAC;IAE1B,yDAAyD;IACzD,MAAM,OAAO,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvE,MAAM,GAAG,GAA4B;QACnC,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM;QACN,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,OAAO;KAChB,CAAC;IACF,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW,KAAK,EAAE,EAAE,CAAC;QACxD,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,cAAwC;IACvE,OAAO,cAAc,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,sBAAsB,CAAC,KAAyB;IAC9D,MAAM,IAAI,GAAwB,IAAA,iCAAa,EAAC,KAAK,CAAC,CAAC;IACvD,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,MAA2B;IAC9D,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC;IACrC,MAAM,KAAK,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC;IAChD,MAAM,GAAG,GAAiC;QACxC,KAAK;QACL,eAAe;QACf,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;QACnD,cAAc,EAAE,MAAM,CAAC,cAAc;KACtC,CAAC;IACF,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACpC,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * OpenAI tool-calling adapter over withCodeRifts (ID632 slice 1 — reference adapter).
3
+ *
4
+ * Thin SHAPE converter only. Guard logic stays in withCodeRifts; this module:
5
+ * 1. calls withCodeRifts with the same input shape,
6
+ * 2. maps each ProtectedTool → OpenAI chat.completions tool definition,
7
+ * 3. returns OpenAI-shaped tools PLUS the untouched assurance objects
8
+ * (registry_report, composition_assurance, receipt_thread).
9
+ *
10
+ * Honesty (do not "upgrade" assurance):
11
+ * - composition_assurance is passed through EXACTLY as the core reported it
12
+ * (COMPOSITION_CALL_POLICY_COMPLETE may still be false; inescapable_runtime may be false).
13
+ * - The adapter converts tool SHAPE for the model API; it does not claim product-level
14
+ * inescapability the core does not claim.
15
+ *
16
+ * Only-protected-tools (6/D at the adapter surface):
17
+ * - `tools` is derived ONLY from the frozen registry's ProtectedTool list.
18
+ * - Raw tools never appear in the returned OpenAI table. The host may still hold a raw
19
+ * reference outside this table; that boundary stays the host's responsibility.
20
+ *
21
+ * Ergonomics (5–10 lines): pass raw tools + client + operation → OpenAI-ready guarded tools.
22
+ * LangGraph / Anthropic adapters follow the same thin-converter pattern later.
23
+ */
24
+ import type { WithCodeRiftsInput, WithCodeRiftsResult, CompositionAssurance, ReceiptThreadHandle } from '../with-coderifts.js';
25
+ import type { ProtectedTool, RegistryCoverageReport } from '../tool-registry.js';
26
+ /**
27
+ * OpenAI chat.completions `tools[]` element (function tool).
28
+ * @see https://platform.openai.com/docs/guides/function-calling
29
+ */
30
+ export type OpenAIFunctionTool = {
31
+ type: 'function';
32
+ function: {
33
+ name: string;
34
+ description?: string;
35
+ /** JSON Schema object for the function arguments (OpenAI `parameters`). */
36
+ parameters: Record<string, unknown>;
37
+ };
38
+ };
39
+ /**
40
+ * Result of withCodeRiftsOpenAI — OpenAI tool definitions + core assurance, unflattened.
41
+ *
42
+ * `tools` is the ONLY list intended for the model/runtime tool table. `protected_tools` is the
43
+ * same guarded list (with execute) for host dispatch after tool_calls — never the raw tools.
44
+ */
45
+ export type WithCodeRiftsOpenAIResult = {
46
+ /** OpenAI-shaped tools for chat.completions — only protected/guarded tools. */
47
+ tools: OpenAIFunctionTool[];
48
+ /**
49
+ * Guarded ProtectedTool list from withCodeRifts (same tools as `tools`, with execute).
50
+ * Host dispatches model tool_calls through these only. Never raw tools.
51
+ */
52
+ protected_tools: ProtectedTool[];
53
+ /** Untouched registry report — registry's own truth. */
54
+ registry_report: RegistryCoverageReport;
55
+ /**
56
+ * Product-level assurance — deliberately narrower than the registry.
57
+ * Passed through untouched; may still show inescapable_runtime:false and
58
+ * residual composition_call_policy_incomplete.
59
+ */
60
+ composition_assurance: CompositionAssurance;
61
+ /** Per-composition receipt cursor — NOT product-truth chain evidence. */
62
+ receipt_thread: ReceiptThreadHandle;
63
+ repository?: string;
64
+ };
65
+ /**
66
+ * Map one ProtectedTool → OpenAI function tool definition (shape only; no execute).
67
+ * Prefer tool.inputSchema when it is a plain object; otherwise empty object schema.
68
+ */
69
+ export declare function protectedToolToOpenAI(tool: ProtectedTool): OpenAIFunctionTool;
70
+ /**
71
+ * Convert a list of ProtectedTool into OpenAI tool definitions.
72
+ * Does NOT call the guard — pure shape map over an already-protected list.
73
+ */
74
+ export declare function toOpenAITools(protectedTools: readonly ProtectedTool[]): OpenAIFunctionTool[];
75
+ /**
76
+ * Build OpenAI-ready guarded tools from raw tools + client + operation.
77
+ *
78
+ * Calls withCodeRifts internally (guard logic stays in the core). Returns:
79
+ * - `tools` — OpenAI chat.completions shape (function tools only)
80
+ * - `protected_tools` — same guarded tools for host execute dispatch
81
+ * - assurance objects from the core, passed through untouched
82
+ *
83
+ * @param input Same shape as withCodeRifts (WithCodeRiftsInput).
84
+ */
85
+ export declare function withCodeRiftsOpenAI(input: WithCodeRiftsInput): WithCodeRiftsOpenAIResult;
86
+ /**
87
+ * Shape-only adapter over an existing WithCodeRiftsResult (composition style).
88
+ * Prefer withCodeRiftsOpenAI when starting from raw tools.
89
+ *
90
+ * Does not re-run the guard; does not invent assurance.
91
+ */
92
+ export declare function openAIToolAdapter(result: WithCodeRiftsResult): WithCodeRiftsOpenAIResult;
93
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/adapters/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KA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APE converter only. Guard logic stays in withCodeRifts; this module:
6
+ * 1. calls withCodeRifts with the same input shape,
7
+ * 2. maps each ProtectedTool → OpenAI chat.completions tool definition,
8
+ * 3. returns OpenAI-shaped tools PLUS the untouched assurance objects
9
+ * (registry_report, composition_assurance, receipt_thread).
10
+ *
11
+ * Honesty (do not "upgrade" assurance):
12
+ * - composition_assurance is passed through EXACTLY as the core reported it
13
+ * (COMPOSITION_CALL_POLICY_COMPLETE may still be false; inescapable_runtime may be false).
14
+ * - The adapter converts tool SHAPE for the model API; it does not claim product-level
15
+ * inescapability the core does not claim.
16
+ *
17
+ * Only-protected-tools (6/D at the adapter surface):
18
+ * - `tools` is derived ONLY from the frozen registry's ProtectedTool list.
19
+ * - Raw tools never appear in the returned OpenAI table. The host may still hold a raw
20
+ * reference outside this table; that boundary stays the host's responsibility.
21
+ *
22
+ * Ergonomics (5–10 lines): pass raw tools + client + operation → OpenAI-ready guarded tools.
23
+ * LangGraph / Anthropic adapters follow the same thin-converter pattern later.
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.protectedToolToOpenAI = protectedToolToOpenAI;
27
+ exports.toOpenAITools = toOpenAITools;
28
+ exports.withCodeRiftsOpenAI = withCodeRiftsOpenAI;
29
+ exports.openAIToolAdapter = openAIToolAdapter;
30
+ const with_coderifts_js_1 = require("../with-coderifts.js");
31
+ /** Empty JSON Schema object — used when a ProtectedTool has no inputSchema. */
32
+ const EMPTY_PARAMETERS = Object.freeze({
33
+ type: 'object',
34
+ properties: {},
35
+ });
36
+ /**
37
+ * Map one ProtectedTool → OpenAI function tool definition (shape only; no execute).
38
+ * Prefer tool.inputSchema when it is a plain object; otherwise empty object schema.
39
+ */
40
+ function protectedToolToOpenAI(tool) {
41
+ const parameters = tool.inputSchema != null
42
+ && typeof tool.inputSchema === 'object'
43
+ && !Array.isArray(tool.inputSchema)
44
+ ? tool.inputSchema
45
+ : { ...EMPTY_PARAMETERS };
46
+ const fn = {
47
+ name: tool.name,
48
+ parameters,
49
+ };
50
+ if (tool.description != null && tool.description !== '') {
51
+ fn.description = tool.description;
52
+ }
53
+ return { type: 'function', function: fn };
54
+ }
55
+ /**
56
+ * Convert a list of ProtectedTool into OpenAI tool definitions.
57
+ * Does NOT call the guard — pure shape map over an already-protected list.
58
+ */
59
+ function toOpenAITools(protectedTools) {
60
+ return protectedTools.map(protectedToolToOpenAI);
61
+ }
62
+ /**
63
+ * Build OpenAI-ready guarded tools from raw tools + client + operation.
64
+ *
65
+ * Calls withCodeRifts internally (guard logic stays in the core). Returns:
66
+ * - `tools` — OpenAI chat.completions shape (function tools only)
67
+ * - `protected_tools` — same guarded tools for host execute dispatch
68
+ * - assurance objects from the core, passed through untouched
69
+ *
70
+ * @param input Same shape as withCodeRifts (WithCodeRiftsInput).
71
+ */
72
+ function withCodeRiftsOpenAI(input) {
73
+ const core = (0, with_coderifts_js_1.withCodeRifts)(input);
74
+ return openAIToolAdapter(core);
75
+ }
76
+ /**
77
+ * Shape-only adapter over an existing WithCodeRiftsResult (composition style).
78
+ * Prefer withCodeRiftsOpenAI when starting from raw tools.
79
+ *
80
+ * Does not re-run the guard; does not invent assurance.
81
+ */
82
+ function openAIToolAdapter(result) {
83
+ const protected_tools = result.tools;
84
+ const tools = toOpenAITools(protected_tools);
85
+ const out = {
86
+ tools,
87
+ protected_tools,
88
+ registry_report: result.registry_report,
89
+ composition_assurance: result.composition_assurance,
90
+ receipt_thread: result.receipt_thread,
91
+ };
92
+ if (result.repository !== undefined) {
93
+ out.repository = result.repository;
94
+ }
95
+ return out;
96
+ }
97
+ //# sourceMappingURL=openai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../src/adapters/openai.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AA8DH,sDAgBC;AAMD,sCAEC;AAYD,kDAGC;AAQD,8CAcC;AAzHD,4DAAqD;AAkDrD,+EAA+E;AAC/E,MAAM,gBA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CAAC,eAAe;QACvC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;QACnD,cAAc,EAAE,MAAM,CAAC,cAAc;KACtC,CAAC;IACF,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACpC,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACrC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Human-readable final-answer proof block (ID645) — render layer over GuardExecutionProof.
3
+ *
4
+ * Does NOT assemble or re-decide protection. It FAITHFULLY formats a machine
5
+ * GuardExecutionProof (from buildExecutionProof) so an agent can embed it in a final
6
+ * answer without overclaiming.
7
+ *
8
+ * Honesty rules:
9
+ * - currently_authorized:null → "NOT EVALUATED (SKIPPED)" — never a soft pass
10
+ * - currently_authorized:false → "NOT AUTHORIZED" — never "protected/verified"
11
+ * - currently_authorized:true → "AUTHORIZED" only when receipt.verified; still surfaces limits
12
+ * - limits block always appears (operative non-claims)
13
+ *
14
+ * Does not modify execution-proof.ts or the proof shape.
15
+ */
16
+ import type { GuardExecutionProof } from './execution-proof.js';
17
+ export type FinalAnswerProofFormat = 'markdown' | 'plain';
18
+ export type RenderFinalAnswerProofOptions = {
19
+ /**
20
+ * Output format. Default 'markdown'.
21
+ * plain = no #/* markup (still line-oriented, limits as bullet-like lines with "- ").
22
+ */
23
+ format?: FinalAnswerProofFormat;
24
+ /**
25
+ * When true (default), always include the limits / non-claims section.
26
+ * Setting false is allowed for ultra-compact hosts but is discouraged — the whole
27
+ * point of this block is honest non-overclaim.
28
+ */
29
+ includeLimits?: boolean;
30
+ /**
31
+ * Optional heading override. Default: "CodeRifts execution proof".
32
+ */
33
+ title?: string;
34
+ };
35
+ export type AttachProofToAgentResponseOptions = RenderFinalAnswerProofOptions & {
36
+ /**
37
+ * How to embed the rendered block.
38
+ * - 'append_text' (default): append a string section to a string response, or set
39
+ * `final_answer_proof` + `final_answer_proof_text` on object responses
40
+ * - 'field_only': never mutate text; only attach structured fields on objects
41
+ * (string responses become `{ text, final_answer_proof, final_answer_proof_text }`)
42
+ */
43
+ mode?: 'append_text' | 'field_only';
44
+ /**
45
+ * Separator before the appended block when mode is append_text and response is a string.
46
+ * Default: "\n\n---\n\n"
47
+ */
48
+ separator?: string;
49
+ };
50
+ /** Coarse human status derived only from proof fields (never invents protection). */
51
+ export type FinalAnswerProofBanner = 'ENFORCED' | 'AUTHORIZED' | 'NOT_AUTHORIZED' | 'NOT_EVALUATED_SKIPPED' | 'PREFLIGHTED_NOT_AUTHORIZED' | 'NO_PREFLIGHT';
52
+ /**
53
+ * Map proof fields → a single banner label that is visibly different for
54
+ * authorized / not-authorized / skipped / no-preflight.
55
+ */
56
+ export declare function deriveProofBanner(proof: GuardExecutionProof): FinalAnswerProofBanner;
57
+ /**
58
+ * Render a GuardExecutionProof as a compact human-readable block.
59
+ * Faithful to fields; never upgrades null/false authorization into "protected".
60
+ */
61
+ export declare function renderFinalAnswerProof(proof: GuardExecutionProof, opts?: RenderFinalAnswerProofOptions): string;
62
+ /**
63
+ * Attach a rendered proof to a host response (framework-agnostic).
64
+ *
65
+ * Convention:
66
+ * - String response + append_text → `response + separator + rendered`
67
+ * - Object response → shallow copy with:
68
+ * final_answer_proof: GuardExecutionProof (reference; not deep-cloned)
69
+ * final_answer_proof_text: string (rendered block)
70
+ * and, when mode is append_text and a stringish field exists (`text` | `content` |
71
+ * `message` | `final_answer`), that field is appended with the block.
72
+ * - field_only never mutates string fields; wraps bare strings in an object.
73
+ *
74
+ * Hosts that only want the string can call renderFinalAnswerProof directly.
75
+ */
76
+ export declare function attachProofToAgentResponse<T = unknown>(response: T, proof: GuardExecutionProof, opts?: AttachProofToAgentResponseOptions): T | (Record<string, unknown> & {
77
+ final_answer_proof: GuardExecutionProof;
78
+ final_answer_proof_text: string;
79
+ });
80
+ //# sourceMappingURL=final-answer-proof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"final-answer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