@galaxy-stack/ai-coder-core 0.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 (197) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +131 -0
  3. package/dist/approval/approval-policy.d.ts +31 -0
  4. package/dist/approval/approval-policy.d.ts.map +1 -0
  5. package/dist/approval/approval-policy.js +179 -0
  6. package/dist/approval/approval-policy.js.map +1 -0
  7. package/dist/approval/index.d.ts +2 -0
  8. package/dist/approval/index.d.ts.map +1 -0
  9. package/dist/approval/index.js +2 -0
  10. package/dist/approval/index.js.map +1 -0
  11. package/dist/context/attachment-types.d.ts +35 -0
  12. package/dist/context/attachment-types.d.ts.map +1 -0
  13. package/dist/context/attachment-types.js +9 -0
  14. package/dist/context/attachment-types.js.map +1 -0
  15. package/dist/context/checkpoint.d.ts +194 -0
  16. package/dist/context/checkpoint.d.ts.map +1 -0
  17. package/dist/context/checkpoint.js +921 -0
  18. package/dist/context/checkpoint.js.map +1 -0
  19. package/dist/context/context-manager.d.ts +153 -0
  20. package/dist/context/context-manager.d.ts.map +1 -0
  21. package/dist/context/context-manager.js +541 -0
  22. package/dist/context/context-manager.js.map +1 -0
  23. package/dist/context/context-profile.d.ts +42 -0
  24. package/dist/context/context-profile.d.ts.map +1 -0
  25. package/dist/context/context-profile.js +102 -0
  26. package/dist/context/context-profile.js.map +1 -0
  27. package/dist/context/index.d.ts +7 -0
  28. package/dist/context/index.d.ts.map +1 -0
  29. package/dist/context/index.js +7 -0
  30. package/dist/context/index.js.map +1 -0
  31. package/dist/context/token-ledger.d.ts +102 -0
  32. package/dist/context/token-ledger.d.ts.map +1 -0
  33. package/dist/context/token-ledger.js +205 -0
  34. package/dist/context/token-ledger.js.map +1 -0
  35. package/dist/context/tool-output.d.ts +46 -0
  36. package/dist/context/tool-output.d.ts.map +1 -0
  37. package/dist/context/tool-output.js +82 -0
  38. package/dist/context/tool-output.js.map +1 -0
  39. package/dist/deterministic-order.d.ts +3 -0
  40. package/dist/deterministic-order.d.ts.map +1 -0
  41. package/dist/deterministic-order.js +5 -0
  42. package/dist/deterministic-order.js.map +1 -0
  43. package/dist/index.d.ts +19 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +19 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/ports/approval-port.d.ts +29 -0
  48. package/dist/ports/approval-port.d.ts.map +1 -0
  49. package/dist/ports/approval-port.js +9 -0
  50. package/dist/ports/approval-port.js.map +1 -0
  51. package/dist/ports/artifact-port.d.ts +66 -0
  52. package/dist/ports/artifact-port.d.ts.map +1 -0
  53. package/dist/ports/artifact-port.js +9 -0
  54. package/dist/ports/artifact-port.js.map +1 -0
  55. package/dist/ports/capability-port.d.ts +62 -0
  56. package/dist/ports/capability-port.d.ts.map +1 -0
  57. package/dist/ports/capability-port.js +9 -0
  58. package/dist/ports/capability-port.js.map +1 -0
  59. package/dist/ports/coding-model-port.d.ts +12 -0
  60. package/dist/ports/coding-model-port.d.ts.map +1 -0
  61. package/dist/ports/coding-model-port.js +9 -0
  62. package/dist/ports/coding-model-port.js.map +1 -0
  63. package/dist/ports/command-port.d.ts +94 -0
  64. package/dist/ports/command-port.d.ts.map +1 -0
  65. package/dist/ports/command-port.js +9 -0
  66. package/dist/ports/command-port.js.map +1 -0
  67. package/dist/ports/execution-context.d.ts +30 -0
  68. package/dist/ports/execution-context.d.ts.map +1 -0
  69. package/dist/ports/execution-context.js +11 -0
  70. package/dist/ports/execution-context.js.map +1 -0
  71. package/dist/ports/git-port.d.ts +27 -0
  72. package/dist/ports/git-port.d.ts.map +1 -0
  73. package/dist/ports/git-port.js +9 -0
  74. package/dist/ports/git-port.js.map +1 -0
  75. package/dist/ports/host-adapter.d.ts +36 -0
  76. package/dist/ports/host-adapter.d.ts.map +1 -0
  77. package/dist/ports/host-adapter.js +9 -0
  78. package/dist/ports/host-adapter.js.map +1 -0
  79. package/dist/ports/index.d.ts +16 -0
  80. package/dist/ports/index.d.ts.map +1 -0
  81. package/dist/ports/index.js +16 -0
  82. package/dist/ports/index.js.map +1 -0
  83. package/dist/ports/pagination.d.ts +17 -0
  84. package/dist/ports/pagination.d.ts.map +1 -0
  85. package/dist/ports/pagination.js +9 -0
  86. package/dist/ports/pagination.js.map +1 -0
  87. package/dist/ports/persistence-port.d.ts +59 -0
  88. package/dist/ports/persistence-port.d.ts.map +1 -0
  89. package/dist/ports/persistence-port.js +9 -0
  90. package/dist/ports/persistence-port.js.map +1 -0
  91. package/dist/ports/port-result.d.ts +29 -0
  92. package/dist/ports/port-result.d.ts.map +1 -0
  93. package/dist/ports/port-result.js +20 -0
  94. package/dist/ports/port-result.js.map +1 -0
  95. package/dist/ports/preview-port.d.ts +27 -0
  96. package/dist/ports/preview-port.d.ts.map +1 -0
  97. package/dist/ports/preview-port.js +9 -0
  98. package/dist/ports/preview-port.js.map +1 -0
  99. package/dist/ports/research-port.d.ts +40 -0
  100. package/dist/ports/research-port.d.ts.map +1 -0
  101. package/dist/ports/research-port.js +9 -0
  102. package/dist/ports/research-port.js.map +1 -0
  103. package/dist/ports/trace-port.d.ts +26 -0
  104. package/dist/ports/trace-port.d.ts.map +1 -0
  105. package/dist/ports/trace-port.js +9 -0
  106. package/dist/ports/trace-port.js.map +1 -0
  107. package/dist/ports/workspace-port.d.ts +126 -0
  108. package/dist/ports/workspace-port.d.ts.map +1 -0
  109. package/dist/ports/workspace-port.js +9 -0
  110. package/dist/ports/workspace-port.js.map +1 -0
  111. package/dist/prompt/index.d.ts +2 -0
  112. package/dist/prompt/index.d.ts.map +1 -0
  113. package/dist/prompt/index.js +2 -0
  114. package/dist/prompt/index.js.map +1 -0
  115. package/dist/prompt/prompt-assembler.d.ts +114 -0
  116. package/dist/prompt/prompt-assembler.d.ts.map +1 -0
  117. package/dist/prompt/prompt-assembler.js +363 -0
  118. package/dist/prompt/prompt-assembler.js.map +1 -0
  119. package/dist/retrieval/evidence.d.ts +41 -0
  120. package/dist/retrieval/evidence.d.ts.map +1 -0
  121. package/dist/retrieval/evidence.js +48 -0
  122. package/dist/retrieval/evidence.js.map +1 -0
  123. package/dist/retrieval/index.d.ts +4 -0
  124. package/dist/retrieval/index.d.ts.map +1 -0
  125. package/dist/retrieval/index.js +4 -0
  126. package/dist/retrieval/index.js.map +1 -0
  127. package/dist/retrieval/lexical-retriever.d.ts +56 -0
  128. package/dist/retrieval/lexical-retriever.d.ts.map +1 -0
  129. package/dist/retrieval/lexical-retriever.js +128 -0
  130. package/dist/retrieval/lexical-retriever.js.map +1 -0
  131. package/dist/retrieval/retrieval-policy.d.ts +25 -0
  132. package/dist/retrieval/retrieval-policy.d.ts.map +1 -0
  133. package/dist/retrieval/retrieval-policy.js +71 -0
  134. package/dist/retrieval/retrieval-policy.js.map +1 -0
  135. package/dist/runtime/completion-gate.d.ts +75 -0
  136. package/dist/runtime/completion-gate.d.ts.map +1 -0
  137. package/dist/runtime/completion-gate.js +114 -0
  138. package/dist/runtime/completion-gate.js.map +1 -0
  139. package/dist/runtime/index.d.ts +7 -0
  140. package/dist/runtime/index.d.ts.map +1 -0
  141. package/dist/runtime/index.js +7 -0
  142. package/dist/runtime/index.js.map +1 -0
  143. package/dist/runtime/run-controller.d.ts +55 -0
  144. package/dist/runtime/run-controller.d.ts.map +1 -0
  145. package/dist/runtime/run-controller.js +2673 -0
  146. package/dist/runtime/run-controller.js.map +1 -0
  147. package/dist/runtime/runtime-error.d.ts +7 -0
  148. package/dist/runtime/runtime-error.d.ts.map +1 -0
  149. package/dist/runtime/runtime-error.js +11 -0
  150. package/dist/runtime/runtime-error.js.map +1 -0
  151. package/dist/runtime/runtime-types.d.ts +303 -0
  152. package/dist/runtime/runtime-types.d.ts.map +1 -0
  153. package/dist/runtime/runtime-types.js +2 -0
  154. package/dist/runtime/runtime-types.js.map +1 -0
  155. package/dist/runtime/state-machine.d.ts +27 -0
  156. package/dist/runtime/state-machine.d.ts.map +1 -0
  157. package/dist/runtime/state-machine.js +68 -0
  158. package/dist/runtime/state-machine.js.map +1 -0
  159. package/dist/runtime/trace-emitter.d.ts +17 -0
  160. package/dist/runtime/trace-emitter.d.ts.map +1 -0
  161. package/dist/runtime/trace-emitter.js +91 -0
  162. package/dist/runtime/trace-emitter.js.map +1 -0
  163. package/dist/tools/coding-messages.d.ts +112 -0
  164. package/dist/tools/coding-messages.d.ts.map +1 -0
  165. package/dist/tools/coding-messages.js +20 -0
  166. package/dist/tools/coding-messages.js.map +1 -0
  167. package/dist/tools/index.d.ts +7 -0
  168. package/dist/tools/index.d.ts.map +1 -0
  169. package/dist/tools/index.js +7 -0
  170. package/dist/tools/index.js.map +1 -0
  171. package/dist/tools/json-schema.d.ts +18 -0
  172. package/dist/tools/json-schema.d.ts.map +1 -0
  173. package/dist/tools/json-schema.js +299 -0
  174. package/dist/tools/json-schema.js.map +1 -0
  175. package/dist/tools/settings-types.d.ts +41 -0
  176. package/dist/tools/settings-types.d.ts.map +1 -0
  177. package/dist/tools/settings-types.js +88 -0
  178. package/dist/tools/settings-types.js.map +1 -0
  179. package/dist/tools/tool-effect-profile.d.ts +44 -0
  180. package/dist/tools/tool-effect-profile.d.ts.map +1 -0
  181. package/dist/tools/tool-effect-profile.js +157 -0
  182. package/dist/tools/tool-effect-profile.js.map +1 -0
  183. package/dist/tools/tool-registry-types.d.ts +72 -0
  184. package/dist/tools/tool-registry-types.d.ts.map +1 -0
  185. package/dist/tools/tool-registry-types.js +9 -0
  186. package/dist/tools/tool-registry-types.js.map +1 -0
  187. package/dist/tools/tool-registry.d.ts +155 -0
  188. package/dist/tools/tool-registry.d.ts.map +1 -0
  189. package/dist/tools/tool-registry.js +599 -0
  190. package/dist/tools/tool-registry.js.map +1 -0
  191. package/dist/tools/tool-registry.schema.json +144 -0
  192. package/docs/ARCHITECTURE.md +259 -0
  193. package/docs/HOST_CONFORMANCE.md +210 -0
  194. package/docs/PROMPT_CONTRACT.md +123 -0
  195. package/docs/TOOL_EFFECT_PROFILE.md +77 -0
  196. package/docs/TOOL_REGISTRY_COMPARISON.md +358 -0
  197. package/package.json +76 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Galaxy Agent
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # @galaxy-stack/ai-coder-core
2
+
3
+ Provider-neutral, platform-neutral runtime for the Galaxy AI Coder single agent.
4
+ The same core is intended for:
5
+
6
+ - `galaxy-code` v2 — deterministic Node.js CLI laboratory;
7
+ - `galaxy-vscode-extension` — VS Code host adapters;
8
+ - `galaxy-desktop` — Tauri host adapters.
9
+
10
+ ## Status
11
+
12
+ The single-agent runtime, context manager, prompt assembler, tool registry,
13
+ approval policy, checkpoint format, trace protocol, lexical retrieval, and
14
+ completion gate are implemented and covered by deterministic tests.
15
+
16
+ `galaxy-code` v2 is the reference conformance host. VS Code and Desktop should
17
+ not copy runtime logic; they should implement the same ports and pass the same
18
+ host conformance fixtures first.
19
+
20
+ This package is still pre-integration (`0.1.0`, private). Optional MCP,
21
+ semantic retrieval, background terminal sessions, and subagents are outside
22
+ the current runtime baseline.
23
+
24
+ ## Non-negotiable invariants
25
+
26
+ 1. One AI owns the run state. There is no hidden planner/reviewer agent.
27
+ 2. A model round may emit zero or more correlated tool calls. IDs must be
28
+ non-empty and unique for the run; names may repeat with different arguments.
29
+ The runtime preflights the complete batch, then executes it sequentially in
30
+ emitted order.
31
+ 3. The model sees model-facing names; every result must match the host's
32
+ model-name-to-canonical-ID mapping.
33
+ 4. Hosts provide structured prompt policy only. Runtime assembles and hashes
34
+ the system prompt after capability and registry discovery, then formats the
35
+ sole user task from `AiCoderTaskContract`. If `command.run` is active, the
36
+ host must supply the exact concrete non-interactive interpreter contract;
37
+ the runtime refuses missing/unknown shell metadata before a model request.
38
+ 5. Tool text is never parsed into trusted state. Only declared host effects
39
+ can change inspection, write, validation, diff, plan, approval, or criterion
40
+ evidence.
41
+ 6. Every host effect is checked against a per-canonical-tool capability policy.
42
+ Built-in hosts derive that policy from the exported versioned core profile;
43
+ divergent local copies are rejected at runtime startup.
44
+ 7. Every mutation uses a precondition and records distinct before/after state:
45
+ create has a null `beforeHash`, delete has a null `afterHash`, and at least
46
+ one hash is non-null. Later validation has explicit workspace/path scope.
47
+ 8. Validation and final diff evidence must match the final serialized workspace
48
+ fingerprint before completion.
49
+ 9. A required acceptance criterion must be `satisfied`; `waived` does not close
50
+ a required criterion.
51
+ 10. Checkpoints are cloned before validation, deeply frozen after validation,
52
+ redacted, hashed with SHA-256, and resumed only from trusted host storage (or
53
+ an explicit `trusted_host` provenance assertion).
54
+ 11. Cancellation makes an in-flight side-effect outcome `unknown` unless the
55
+ host returns a structured result. Hosts must honor the supplied signal and
56
+ absolute deadline.
57
+ 12. Identical retries, alternating successful tool cycles, varied failed
58
+ mutations on one path/state, repeated validation failures on one
59
+ fingerprint, and returning content hashes are bounded. Semantically
60
+ identical validation, diff, and criterion evidence does not manufacture a
61
+ new state transition; unresolved no-progress episodes pause with a
62
+ checkpoint.
63
+ 13. Provider-reported context overflow checkpoints, compacts, and recounts
64
+ before another model request. Mandatory state is never silently dropped to
65
+ force a round through.
66
+ 14. Once a mutation has complete current validation and final-diff evidence,
67
+ the next model turn is a bounded finalization turn with no tool definitions.
68
+ Evidence-complete no-progress recovery uses the same boundary; ordinary
69
+ inspect-then-edit or multi-step review work is not finalized early. A
70
+ verified resume re-derives this boundary before its first model request.
71
+
72
+ ## Runtime flow
73
+
74
+ ```text
75
+ request
76
+ -> capability + tool-policy snapshot
77
+ -> core-owned prompt snapshot + canonical user-task contract
78
+ -> bounded context assembly
79
+ -> one streamed model round
80
+ -> zero or more correlated tool calls
81
+ -> atomic batch preflight (IDs, budget, visible registry, canonical JSON)
82
+ -> sequential per-call schema/policy/approval/host adapter
83
+ -> bounded untrusted observation + trusted declared effects
84
+ -> repeat
85
+ -> evidence-ready tool-free finalization turn
86
+ -> final report candidate
87
+ -> model-actionable evidence gate
88
+ -> runtime-owned final-report persistence (when a store is configured)
89
+ -> completion-gate trace + durable trace flush (when trace is configured)
90
+ -> fresh workspace fingerprint
91
+ -> deterministic completion gate
92
+ -> completed
93
+ ```
94
+
95
+ See [ARCHITECTURE.md](docs/ARCHITECTURE.md),
96
+ [PROMPT_CONTRACT.md](docs/PROMPT_CONTRACT.md),
97
+ [TOOL_EFFECT_PROFILE.md](docs/TOOL_EFFECT_PROFILE.md), and
98
+ [HOST_CONFORMANCE.md](docs/HOST_CONFORMANCE.md) for integration contracts.
99
+
100
+ ## Source layout
101
+
102
+ ```text
103
+ src/
104
+ ├── approval/ # fail-closed approval policy
105
+ ├── context/ # context budget, token ledger, checkpoints, output bounds
106
+ ├── ports/ # host capability interfaces and PortResult
107
+ ├── prompt/ # versioned system prompt assembly
108
+ ├── retrieval/ # bounded provider-neutral lexical evidence
109
+ ├── runtime/ # run controller, state machine, completion gate, trace emitter
110
+ └── tools/ # schemas, descriptors, registry and provider protocol
111
+ ```
112
+
113
+ ## Development
114
+
115
+ Requires Node.js 20 or newer.
116
+
117
+ ```bash
118
+ npm install
119
+ npm run verify
120
+ ```
121
+
122
+ `npm run verify` runs strict TypeScript checks, all source tests, a clean build,
123
+ and a public `dist` smoke test. `npm pack --dry-run` should also be checked
124
+ before publishing or consuming the package from another repository.
125
+
126
+ The deterministic end-to-end host gate lives in `galaxy-code`:
127
+
128
+ ```bash
129
+ cd ../../galaxy-code
130
+ npm run check
131
+ ```
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @author Bùi Trọng Hiếu
3
+ * @email kevinbui210191@gmail.com
4
+ * @create date 2026-08-21
5
+ * @modify date 2026-08-28
6
+ * @desc Fail-closed approval, permission, transport, and task-mode policy.
7
+ */
8
+ import type { ApprovalPort, AiCoderApprovalScope } from "../ports/approval-port.js";
9
+ import type { ToolExecutionContext } from "../ports/execution-context.js";
10
+ import type { AiCoderApprovalProfile } from "../tools/settings-types.js";
11
+ import type { AiCoderToolDescriptor, AiCoderToolTransport } from "../tools/tool-registry-types.js";
12
+ export type { AiCoderApprovalRequest } from "../ports/approval-port.js";
13
+ export type { ApprovalPort as AiCoderApprovalCallback } from "../ports/approval-port.js";
14
+ export type AiCoderApprovalPolicyDecision = Readonly<{
15
+ allowed: boolean;
16
+ approvalScope?: AiCoderApprovalScope;
17
+ decision: "approved_by_host" | "auto_approve" | "deny_approval_error" | "deny_approval_timeout" | "deny_approval_unavailable" | "deny_canceled" | "deny_missing_permission" | "deny_run_mode" | "deny_transport" | "denied_by_host";
18
+ reason: string;
19
+ requestId?: string;
20
+ }>;
21
+ export declare function resolveAiCoderManifestPermissions(manifest: unknown): ReadonlySet<string>;
22
+ export declare function requiresAiCoderApproval(approvalProfile: AiCoderApprovalProfile, tool: AiCoderToolDescriptor): boolean;
23
+ export declare function createAiCoderApprovalPolicy(options: Readonly<{
24
+ allowedTransports?: ReadonlySet<AiCoderToolTransport>;
25
+ approvalCallback?: ApprovalPort;
26
+ approvalProfile: AiCoderApprovalProfile;
27
+ approvalTimeoutMs?: number;
28
+ grantedPermissions?: ReadonlySet<string>;
29
+ now?: () => number;
30
+ }>): (tool: AiCoderToolDescriptor, argumentsValue: Readonly<Record<string, unknown>>, context: ToolExecutionContext) => Promise<AiCoderApprovalPolicyDecision>;
31
+ //# sourceMappingURL=approval-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-policy.d.ts","sourceRoot":"","sources":["../../src/approval/approval-policy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,YAAY,EAEZ,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAIzE,OAAO,KAAK,EACV,qBAAqB,EAErB,oBAAoB,EACrB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,YAAY,EAAE,YAAY,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEzF,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAAC;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,QAAQ,EACJ,kBAAkB,GAClB,cAAc,GACd,qBAAqB,GACrB,uBAAuB,GACvB,2BAA2B,GAC3B,eAAe,GACf,yBAAyB,GACzB,eAAe,GACf,gBAAgB,GAChB,gBAAgB,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAkBH,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAUxF;AAED,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,sBAAsB,EACvC,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAGT;AA+CD,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC5D,iBAAiB,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC,CAAC;IACtD,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,eAAe,EAAE,sBAAsB,CAAC;IACxC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB,CAAC,IAOE,MAAM,qBAAqB,EAC3B,gBAAgB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACjD,SAAS,oBAAoB,KAC5B,OAAO,CAAC,6BAA6B,CAAC,CA2G1C"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * @author Bùi Trọng Hiếu
3
+ * @email kevinbui210191@gmail.com
4
+ * @create date 2026-08-21
5
+ * @modify date 2026-08-28
6
+ * @desc Fail-closed approval, permission, transport, and task-mode policy.
7
+ */
8
+ import { isAiCoderToolAllowedInMode, } from "../tools/tool-registry.js";
9
+ const RISK_ORDER = Object.freeze({
10
+ low: 0,
11
+ medium: 1,
12
+ high: 2,
13
+ critical: 3,
14
+ });
15
+ const APPROVAL_THRESHOLDS = Object.freeze({
16
+ "trusted-workspace": "critical",
17
+ balanced: "high",
18
+ strict: "medium",
19
+ });
20
+ const DEFAULT_ALLOWED_TRANSPORTS = new Set(["native", "core"]);
21
+ const DEFAULT_APPROVAL_TIMEOUT_MS = 30_000;
22
+ export function resolveAiCoderManifestPermissions(manifest) {
23
+ if (!manifest || typeof manifest !== "object")
24
+ return new Set();
25
+ const permissions = manifest.permissions;
26
+ if (!Array.isArray(permissions))
27
+ return new Set();
28
+ return new Set(permissions
29
+ .filter((value) => typeof value === "string")
30
+ .map((value) => value.trim())
31
+ .filter(Boolean));
32
+ }
33
+ export function requiresAiCoderApproval(approvalProfile, tool) {
34
+ if (tool.mutability === "external_side_effect")
35
+ return true;
36
+ return RISK_ORDER[tool.risk] >= RISK_ORDER[APPROVAL_THRESHOLDS[approvalProfile]];
37
+ }
38
+ function approvalReason(tool, approvalProfile) {
39
+ const detail = tool.mutability === "external_side_effect" ? "external side effect" : `${tool.risk} risk`;
40
+ return `Approval profile ${approvalProfile} yêu cầu xác nhận ${tool.id} (${detail}).`;
41
+ }
42
+ function waitForApproval(callback, request, context, timeoutMs) {
43
+ return new Promise((resolve) => {
44
+ let settled = false;
45
+ const finish = (outcome) => {
46
+ if (settled)
47
+ return;
48
+ settled = true;
49
+ clearTimeout(timer);
50
+ context.signal.removeEventListener("abort", onAbort);
51
+ resolve(outcome);
52
+ };
53
+ const onAbort = () => finish({ kind: "canceled" });
54
+ const timer = setTimeout(() => finish({ kind: "timeout" }), timeoutMs);
55
+ context.signal.addEventListener("abort", onAbort, { once: true });
56
+ if (context.signal.aborted) {
57
+ onAbort();
58
+ return;
59
+ }
60
+ void Promise.resolve().then(async () => {
61
+ if (settled)
62
+ return;
63
+ try {
64
+ const result = await callback(request, context);
65
+ finish({ kind: "result", result });
66
+ }
67
+ catch {
68
+ finish({ kind: "error", code: "APPROVAL_CALLBACK_THROWN" });
69
+ }
70
+ });
71
+ });
72
+ }
73
+ export function createAiCoderApprovalPolicy(options) {
74
+ const allowedTransports = options.allowedTransports ?? DEFAULT_ALLOWED_TRANSPORTS;
75
+ const grantedPermissions = options.grantedPermissions ?? new Set();
76
+ const now = options.now ?? Date.now;
77
+ const configuredTimeout = Math.max(1, options.approvalTimeoutMs ?? DEFAULT_APPROVAL_TIMEOUT_MS);
78
+ return async (tool, argumentsValue, context) => {
79
+ if (context.signal.aborted || now() >= context.deadline) {
80
+ return Object.freeze({
81
+ allowed: false,
82
+ decision: "deny_canceled",
83
+ reason: `Run ${context.runId} đã bị hủy hoặc hết deadline trước khi thực thi ${tool.id}.`,
84
+ });
85
+ }
86
+ if (!isAiCoderToolAllowedInMode(tool, context.mode)) {
87
+ return Object.freeze({
88
+ allowed: false,
89
+ decision: "deny_run_mode",
90
+ reason: `Task mode ${context.mode} không cho phép ${tool.mutability} tool ${tool.id}.`,
91
+ });
92
+ }
93
+ const missingPermissions = tool.permissions.filter((permission) => !grantedPermissions.has(permission));
94
+ if (missingPermissions.length > 0) {
95
+ return Object.freeze({
96
+ allowed: false,
97
+ decision: "deny_missing_permission",
98
+ reason: `Tool ${tool.id} thiếu permission ${missingPermissions.join(", ")} trong manifest AI Coder.`,
99
+ });
100
+ }
101
+ if (!allowedTransports.has(tool.transport)) {
102
+ return Object.freeze({
103
+ allowed: false,
104
+ decision: "deny_transport",
105
+ reason: `Transport ${tool.transport} của ${tool.id} chưa có policy adapter được host tin cậy.`,
106
+ });
107
+ }
108
+ if (!requiresAiCoderApproval(options.approvalProfile, tool)) {
109
+ return Object.freeze({
110
+ allowed: true,
111
+ decision: "auto_approve",
112
+ reason: `Profile ${options.approvalProfile} cho phép ${tool.id} (${tool.risk}, ${tool.mutability}).`,
113
+ });
114
+ }
115
+ const reason = approvalReason(tool, options.approvalProfile);
116
+ const requestId = `${context.runId}:${context.toolCallId}`;
117
+ if (!options.approvalCallback) {
118
+ return Object.freeze({
119
+ allowed: false,
120
+ decision: "deny_approval_unavailable",
121
+ reason: `${reason} Host không cung cấp approval callback nên yêu cầu bị từ chối.`,
122
+ requestId,
123
+ });
124
+ }
125
+ const remainingMs = context.deadline - now();
126
+ if (remainingMs <= 0) {
127
+ return Object.freeze({
128
+ allowed: false,
129
+ decision: "deny_canceled",
130
+ reason: `${reason} Run đã hết deadline.`,
131
+ requestId,
132
+ });
133
+ }
134
+ const request = Object.freeze({
135
+ approvalProfile: options.approvalProfile,
136
+ argumentsValue,
137
+ reason,
138
+ requestId,
139
+ suggestedScope: "once",
140
+ tool,
141
+ });
142
+ const outcome = await waitForApproval(options.approvalCallback, request, context, Math.min(configuredTimeout, remainingMs));
143
+ if (outcome.kind === "canceled") {
144
+ return Object.freeze({ allowed: false, decision: "deny_canceled", reason: `${reason} Approval bị hủy.`, requestId });
145
+ }
146
+ if (outcome.kind === "timeout") {
147
+ return Object.freeze({ allowed: false, decision: "deny_approval_timeout", reason: `${reason} Approval đã timeout.`, requestId });
148
+ }
149
+ if (outcome.kind === "error") {
150
+ return Object.freeze({ allowed: false, decision: "deny_approval_error", reason: `${reason} Host approval callback lỗi (${outcome.code}).`, requestId });
151
+ }
152
+ if (!outcome.result.ok) {
153
+ return Object.freeze({
154
+ allowed: false,
155
+ decision: "deny_approval_error",
156
+ reason: `${reason} Host trả lỗi ${outcome.result.error.code}: ${outcome.result.error.message}`,
157
+ requestId,
158
+ });
159
+ }
160
+ const decision = outcome.result.data;
161
+ if (!decision.approved) {
162
+ return Object.freeze({
163
+ allowed: false,
164
+ approvalScope: decision.scope,
165
+ decision: "denied_by_host",
166
+ reason: decision.reason || `Host từ chối approval cho ${tool.id}.`,
167
+ requestId,
168
+ });
169
+ }
170
+ return Object.freeze({
171
+ allowed: true,
172
+ approvalScope: decision.scope,
173
+ decision: "approved_by_host",
174
+ reason: decision.reason || reason,
175
+ requestId,
176
+ });
177
+ };
178
+ }
179
+ //# sourceMappingURL=approval-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-policy.js","sourceRoot":"","sources":["../../src/approval/approval-policy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,EACL,0BAA0B,GAC3B,MAAM,2BAA2B,CAAC;AA4BnC,MAAM,UAAU,GAA8C,MAAM,CAAC,MAAM,CAAC;IAC1E,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,CAAC;CACZ,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAA8D,MAAM,CAAC,MAAM,CAAC;IACnG,mBAAmB,EAAE,UAAU;IAC/B,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,QAAQ;CACjB,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAsC,IAA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C1J,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,MAAM,CAAC;gBACnB,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,qBAAqB;gBAC/B,MAAM,EAAE,GAAG,MAAM,iBAAiB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE;gBAC9F,SAAS;aACV,CAAC,CAAC;QACL,CAAC;QACD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;QACrC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,MAAM,CAAC;gBACnB,OAAO,EAAE,KAAK;gBACd,aAAa,EAAE,QAAQ,CAAC,KAAK;gBAC7B,QAAQ,EAAE,gBAAgB;gBAC1B,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,6BAA6B,IAAI,CAAC,EAAE,GAAG;gBAClE,SAAS;aACV,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,OAAO,EAAE,IAAI;YACb,aAAa,EAAE,QAAQ,CAAC,KAAK;YAC7B,QAAQ,EAAE,kBAAkB;YAC5B,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,MAAM;YACjC,SAAS;SACV,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./approval-policy.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/approval/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./approval-policy.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/approval/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @author Bùi Trọng Hiếu
3
+ * @email kevinbui210191@gmail.com
4
+ * @create date 2026-08-21
5
+ * @modify date 2026-08-21
6
+ * @desc Chat attachment shape consumed by ContextManager, TokenLedger, and PromptAssembler.
7
+ */
8
+ export type AiCoderAttachmentSource = "clipboard" | "generated" | "screen_capture" | "tool_output" | "user_upload" | "workspace";
9
+ /**
10
+ * Artifact-first attachment reference. Binary transport is optional because a
11
+ * host may resolve it lazily from `artifactId`; provenance and trust are never
12
+ * optional and dynamic content cannot become an instruction.
13
+ */
14
+ export type AiCoderAttachment = Readonly<{
15
+ artifactId: string;
16
+ byteLength?: number;
17
+ contentSha256: string;
18
+ dataUrl?: string;
19
+ decodedPixels?: number;
20
+ height?: number;
21
+ mimeType: string;
22
+ name: string;
23
+ provenance: Readonly<{
24
+ locator?: string;
25
+ source: AiCoderAttachmentSource;
26
+ }>;
27
+ retention: "default" | "durable" | "temporary";
28
+ trust: "untrusted_data";
29
+ width?: number;
30
+ }>;
31
+ export type PreparedAiCoderAttachments = Readonly<{
32
+ directVision: readonly AiCoderAttachment[];
33
+ promptContext: string;
34
+ }>;
35
+ //# sourceMappingURL=attachment-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment-types.d.ts","sourceRoot":"","sources":["../../src/context/attachment-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,uBAAuB,GAC/B,WAAW,GACX,WAAW,GACX,gBAAgB,GAChB,aAAa,GACb,aAAa,GACb,WAAW,CAAC;AAEhB;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,QAAQ,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,uBAAuB,CAAC;KACjC,CAAC,CAAC;IACH,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;IAC/C,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAAC;IAChD,YAAY,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC3C,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @author Bùi Trọng Hiếu
3
+ * @email kevinbui210191@gmail.com
4
+ * @create date 2026-08-21
5
+ * @modify date 2026-08-21
6
+ * @desc Chat attachment shape consumed by ContextManager, TokenLedger, and PromptAssembler.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=attachment-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment-types.js","sourceRoot":"","sources":["../../src/context/attachment-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Durable, provider-neutral checkpoint used by compaction, pause and crash
3
+ * recovery. Raw model thinking and raw tool output are intentionally absent.
4
+ */
5
+ export declare const AI_CODER_CHECKPOINT_SCHEMA_VERSION: 1;
6
+ export declare const AI_CODER_WORKSPACE_ENTRY_KINDS: readonly ["directory", "file", "missing", "other", "symlink"];
7
+ export type AiCoderWorkspaceEntryKind = typeof AI_CODER_WORKSPACE_ENTRY_KINDS[number];
8
+ export declare function isAiCoderWorkspaceEntryKind(value: unknown): value is AiCoderWorkspaceEntryKind;
9
+ /**
10
+ * Accepts legacy file-only mutations without kinds and the v1-compatible
11
+ * extended form used for directories, symlinks, and special entries.
12
+ */
13
+ export declare function isAiCoderWorkspaceMutationEvidence(value: Readonly<{
14
+ afterHash: string | null;
15
+ afterKind?: AiCoderWorkspaceEntryKind;
16
+ beforeHash: string | null;
17
+ beforeKind?: AiCoderWorkspaceEntryKind;
18
+ }>): boolean;
19
+ export type AiCoderCheckpointReason = "app_shutdown" | "context_threshold" | "failure" | "manual" | "milestone" | "pause" | "provider_overflow" | "tool_result_pressure" | "tool_round_limit";
20
+ export type AiCoderCheckpointPhase = "preparing" | "inspecting" | "planning" | "executing" | "validating" | "reviewing";
21
+ export type AiCoderCheckpointFile = Readonly<{
22
+ contentHash: string | null;
23
+ endLine?: number;
24
+ kind?: AiCoderWorkspaceEntryKind;
25
+ path: string;
26
+ reason?: string;
27
+ startLine?: number;
28
+ }>;
29
+ export type AiCoderCheckpointEdit = Readonly<{
30
+ afterHash: string | null;
31
+ afterKind?: AiCoderWorkspaceEntryKind;
32
+ beforeHash: string | null;
33
+ beforeKind?: AiCoderWorkspaceEntryKind;
34
+ path: string;
35
+ sequence: number;
36
+ toolCallId: string;
37
+ workspaceFingerprint: string;
38
+ }>;
39
+ export type AiCoderCheckpointValidation = Readonly<{
40
+ command?: string;
41
+ detail: string;
42
+ id: string;
43
+ paths?: readonly string[];
44
+ scope: "paths" | "workspace";
45
+ sequence: number;
46
+ status: "failed" | "not_run" | "passed";
47
+ workspaceFingerprint: string;
48
+ }>;
49
+ export type AiCoderCheckpointToolCall = Readonly<{
50
+ argumentsHash: string;
51
+ idempotencyKey?: string;
52
+ name: string;
53
+ outcome: "canceled" | "failed" | "succeeded" | "unknown";
54
+ toolCallId: string;
55
+ }>;
56
+ /**
57
+ * Bounded, host-attested external evidence that survives compaction. The
58
+ * summary remains untrusted source data even though the surrounding
59
+ * checkpoint structure and provenance are verified by the host.
60
+ */
61
+ export type AiCoderCheckpointResearchSource = Readonly<{
62
+ contentHash: string | null;
63
+ kind: "fetch" | "search";
64
+ sequence: number;
65
+ summary: string;
66
+ title?: string;
67
+ toolCallId: string;
68
+ truncated: boolean;
69
+ url: string;
70
+ }>;
71
+ export type AiCoderCheckpointCompatibility = Readonly<{
72
+ activeToolNames: readonly string[];
73
+ capabilitiesHash: string;
74
+ effectCapabilitiesHash: string;
75
+ modelIdentity: string;
76
+ promptHash: string;
77
+ promptVersion: string;
78
+ registrySnapshotHash: string;
79
+ systemPromptHash: string;
80
+ taskContractHash: string;
81
+ }>;
82
+ export type AiCoderCheckpointAcceptanceCriterion = Readonly<{
83
+ evidenceIds: readonly string[];
84
+ id: string;
85
+ required: boolean;
86
+ status: "pending" | "satisfied" | "waived";
87
+ text: string;
88
+ }>;
89
+ export type AiCoderCheckpointNoProgress = Readonly<{
90
+ episodes: number;
91
+ failedToolFamilies: readonly Readonly<{
92
+ count: number;
93
+ key: string;
94
+ }>[];
95
+ hostStateVersions?: readonly Readonly<{
96
+ key: string;
97
+ value: string;
98
+ }>[];
99
+ observationFamilies?: readonly Readonly<{
100
+ count: number;
101
+ key: string;
102
+ }>[];
103
+ previousTool: Readonly<{
104
+ argumentsHash: string;
105
+ name: string;
106
+ repetitions: number;
107
+ }> | null;
108
+ /** Bounded suffix used to continue alternating-cycle detection after resume. */
109
+ toolCycleSuffix?: readonly Readonly<{
110
+ argumentsHash: string;
111
+ name: string;
112
+ }>[];
113
+ }>;
114
+ export type AiCoderRunCheckpointPayload = Readonly<{
115
+ acceptanceCriteria: readonly AiCoderCheckpointAcceptanceCriterion[];
116
+ approvals: readonly string[];
117
+ compatibility: AiCoderCheckpointCompatibility;
118
+ completionEvidence: Readonly<{
119
+ diffReview: Readonly<{
120
+ diffHash: string;
121
+ sequence: number;
122
+ workspaceFingerprint: string;
123
+ }> | null;
124
+ }>;
125
+ constraints: readonly string[];
126
+ decisions: readonly string[];
127
+ delivery: Readonly<{
128
+ attachmentsDelivered: boolean;
129
+ }>;
130
+ edits: readonly AiCoderCheckpointEdit[];
131
+ executionBudget: Readonly<{
132
+ deadlinePolicy: "per_execution_segment";
133
+ persistenceGraceMs: number;
134
+ segmentDeadlineMs: number;
135
+ }>;
136
+ goal: string;
137
+ lastToolCalls: readonly AiCoderCheckpointToolCall[];
138
+ nextAction: string;
139
+ noProgress?: AiCoderCheckpointNoProgress;
140
+ openProblems: readonly string[];
141
+ pendingApprovals: readonly Readonly<{
142
+ requestId: string;
143
+ returnPhase: AiCoderCheckpointPhase;
144
+ toolCallId: string;
145
+ toolName: string;
146
+ }>[];
147
+ phase: AiCoderCheckpointPhase;
148
+ plan: Readonly<{
149
+ completed: readonly string[];
150
+ inProgress: string | null;
151
+ pending: readonly string[];
152
+ }>;
153
+ researchSources?: readonly AiCoderCheckpointResearchSource[];
154
+ runId: string;
155
+ schemaVersion: typeof AI_CODER_CHECKPOINT_SCHEMA_VERSION;
156
+ seenToolCallIds: readonly string[];
157
+ taskId: string;
158
+ tokenLedgerRef: string;
159
+ totals: Readonly<{
160
+ compactionCount: number;
161
+ modelTurns: number;
162
+ toolCalls: number;
163
+ }>;
164
+ validation: readonly AiCoderCheckpointValidation[];
165
+ workspace: Readonly<{
166
+ activeFiles: readonly AiCoderCheckpointFile[];
167
+ dirtyStateSummary: string | null;
168
+ instructions: readonly string[];
169
+ root: string | null;
170
+ stateFingerprint: string | null;
171
+ }>;
172
+ }>;
173
+ export type AiCoderRunCheckpoint = AiCoderRunCheckpointPayload & Readonly<{
174
+ contentHash: string;
175
+ createdAt: string;
176
+ reason: AiCoderCheckpointReason;
177
+ }>;
178
+ export type AiCoderCheckpointValidationIssue = Readonly<{
179
+ code: "HASH_MISMATCH" | "INVALID_FIELD" | "UNSUPPORTED_SCHEMA";
180
+ message: string;
181
+ path: string;
182
+ }>;
183
+ export declare class AiCoderCheckpointIntegrityError extends Error {
184
+ constructor(message: string);
185
+ }
186
+ /** Portable SHA-256 over the deterministic canonical JSON representation. */
187
+ export declare function hashAiCoderCanonicalValue(value: unknown): Promise<string>;
188
+ export declare function redactAiCoderCheckpointText(value: string): string;
189
+ export declare function sanitizeAiCoderCheckpointPayload(payload: AiCoderRunCheckpointPayload): AiCoderRunCheckpointPayload;
190
+ export declare function createAiCoderRunCheckpoint(payload: AiCoderRunCheckpointPayload, reason: AiCoderCheckpointReason, now?: () => string): Promise<AiCoderRunCheckpoint>;
191
+ export declare function validateAiCoderRunCheckpoint(value: unknown): Promise<readonly AiCoderCheckpointValidationIssue[]>;
192
+ export declare function assertAiCoderRunCheckpoint(value: unknown): Promise<AiCoderRunCheckpoint>;
193
+ export declare function formatAiCoderCheckpointMessage(checkpoint: AiCoderRunCheckpoint): string;
194
+ //# sourceMappingURL=checkpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../src/context/checkpoint.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,eAAO,MAAM,kCAAkC,EAAG,CAAU,CAAC;AAE7D,eAAO,MAAM,8BAA8B,+DAMhC,CAAC;AAEZ,MAAM,MAAM,yBAAyB,GAAG,OAAO,8BAA8B,CAAC,MAAM,CAAC,CAAC;AAEtF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,yBAAyB,CAG9F;AAOD;;;GAGG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,QAAQ,CAAC;IACjE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,yBAAyB,CAAC;CACxC,CAAC,GAAG,OAAO,CAeX;AAED,MAAM,MAAM,uBAAuB,GAC/B,cAAc,GACd,mBAAmB,GACnB,SAAS,GACT,QAAQ,GACR,WAAW,GACX,OAAO,GACP,mBAAmB,GACnB,sBAAsB,GACtB,kBAAkB,CAAC;AAcvB,MAAM,MAAM,sBAAsB,GAC9B,WAAW,GACX,YAAY,GACZ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