@full-self-browsing/lattice 1.4.0 → 1.5.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 (108) hide show
  1. package/dist/agent-run-C6miAzwI.d.ts +45 -0
  2. package/dist/agent-run-C6miAzwI.d.ts.map +1 -0
  3. package/dist/agent-run-CgPVFl0Z.js +47 -0
  4. package/dist/agent-run-CgPVFl0Z.js.map +1 -0
  5. package/dist/agents.d.ts +5 -0
  6. package/dist/agents.js +6 -0
  7. package/dist/artifact-Bg6mJGnm.d.ts +125 -0
  8. package/dist/artifact-Bg6mJGnm.d.ts.map +1 -0
  9. package/dist/artifact-DOfpeXLb.js +140 -0
  10. package/dist/artifact-DOfpeXLb.js.map +1 -0
  11. package/dist/artifacts.d.ts +2 -0
  12. package/dist/artifacts.js +2 -0
  13. package/dist/audit.d.ts +3 -0
  14. package/dist/audit.js +4 -0
  15. package/dist/catalog-CAfYwB_-.js +91 -0
  16. package/dist/catalog-CAfYwB_-.js.map +1 -0
  17. package/dist/context-pack-Bz3GXmjv.js +99 -0
  18. package/dist/context-pack-Bz3GXmjv.js.map +1 -0
  19. package/dist/context.d.ts +2 -0
  20. package/dist/context.js +2 -0
  21. package/dist/contract-S3oJGlc9.d.ts +74 -0
  22. package/dist/contract-S3oJGlc9.d.ts.map +1 -0
  23. package/dist/core.d.ts +48 -0
  24. package/dist/core.d.ts.map +1 -0
  25. package/dist/core.js +95 -0
  26. package/dist/core.js.map +1 -0
  27. package/dist/errors-eEuEIx6X.js +407 -0
  28. package/dist/errors-eEuEIx6X.js.map +1 -0
  29. package/dist/eval.d.ts +2 -0
  30. package/dist/eval.js +2 -0
  31. package/dist/fingerprint-DodDbQKN.js +34 -0
  32. package/dist/fingerprint-DodDbQKN.js.map +1 -0
  33. package/dist/index-DpnHGHVL.d.ts +53 -0
  34. package/dist/index-DpnHGHVL.d.ts.map +1 -0
  35. package/dist/index.d.ts +90 -3533
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +26 -15968
  38. package/dist/index.js.map +1 -1
  39. package/dist/infer-DLqp5QIM.d.ts +96 -0
  40. package/dist/infer-DLqp5QIM.d.ts.map +1 -0
  41. package/dist/lineage-DBgoPWAZ.js +137 -0
  42. package/dist/lineage-DBgoPWAZ.js.map +1 -0
  43. package/dist/local-CXOGPJ1f.js +139 -0
  44. package/dist/local-CXOGPJ1f.js.map +1 -0
  45. package/dist/local-Dy--7peL.d.ts +10 -0
  46. package/dist/local-Dy--7peL.d.ts.map +1 -0
  47. package/dist/memory-CkQEW6m5.js +62 -0
  48. package/dist/memory-CkQEW6m5.js.map +1 -0
  49. package/dist/memory-DRig5EHV.d.ts +10 -0
  50. package/dist/memory-DRig5EHV.d.ts.map +1 -0
  51. package/dist/negotiate-ClD88hkc.js +10967 -0
  52. package/dist/negotiate-ClD88hkc.js.map +1 -0
  53. package/dist/otel-BgM4e55_.d.ts +421 -0
  54. package/dist/otel-BgM4e55_.d.ts.map +1 -0
  55. package/dist/permission-context-CUKMo79F.js +134 -0
  56. package/dist/permission-context-CUKMo79F.js.map +1 -0
  57. package/dist/plan-DFm8Llep.js +125 -0
  58. package/dist/plan-DFm8Llep.js.map +1 -0
  59. package/dist/preflight-DNHWuJ46.d.ts +64 -0
  60. package/dist/preflight-DNHWuJ46.d.ts.map +1 -0
  61. package/dist/provider-C2IfKsvz.d.ts +1178 -0
  62. package/dist/provider-C2IfKsvz.d.ts.map +1 -0
  63. package/dist/providers.d.ts +4 -0
  64. package/dist/providers.js +4 -0
  65. package/dist/rate-limit-group-nDsBJqSu.d.ts +235 -0
  66. package/dist/rate-limit-group-nDsBJqSu.d.ts.map +1 -0
  67. package/dist/receipt-FYouoPHv.js +205 -0
  68. package/dist/receipt-FYouoPHv.js.map +1 -0
  69. package/dist/replay-CtIhpLek.js +964 -0
  70. package/dist/replay-CtIhpLek.js.map +1 -0
  71. package/dist/result-DLEx2WvU.d.ts +38 -0
  72. package/dist/result-DLEx2WvU.d.ts.map +1 -0
  73. package/dist/router-DU4Z3pTd.js +314 -0
  74. package/dist/router-DU4Z3pTd.js.map +1 -0
  75. package/dist/router-Yo1-aDOv.d.ts +42 -0
  76. package/dist/router-Yo1-aDOv.d.ts.map +1 -0
  77. package/dist/routing.d.ts +6 -0
  78. package/dist/routing.js +4 -0
  79. package/dist/{run-crew-CKdBjh5P.js → run-crew-B2fQLmgB.js} +7 -136
  80. package/dist/run-crew-B2fQLmgB.js.map +1 -0
  81. package/dist/run-crew-Bnve5dyI.d.ts +721 -0
  82. package/dist/run-crew-Bnve5dyI.d.ts.map +1 -0
  83. package/dist/{runtime-D25ehzCj.js → runtime-Dxiet5YS.js} +98 -641
  84. package/dist/runtime-Dxiet5YS.js.map +1 -0
  85. package/dist/scaffolds-DKQrCRqh.d.ts +535 -0
  86. package/dist/scaffolds-DKQrCRqh.d.ts.map +1 -0
  87. package/dist/scaffolds-ekPIlBeU.js +3139 -0
  88. package/dist/scaffolds-ekPIlBeU.js.map +1 -0
  89. package/dist/schema-CNfa_VEy.d.ts +15 -0
  90. package/dist/schema-CNfa_VEy.d.ts.map +1 -0
  91. package/dist/storage-DJKmsaEI.d.ts +26 -0
  92. package/dist/storage-DJKmsaEI.d.ts.map +1 -0
  93. package/dist/storage.d.ts +10 -0
  94. package/dist/storage.d.ts.map +1 -0
  95. package/dist/storage.js +4 -0
  96. package/dist/tool-call-validation-BFoXkwbf.js +107 -0
  97. package/dist/tool-call-validation-BFoXkwbf.js.map +1 -0
  98. package/dist/tools-C4wHgGKQ.js +49 -0
  99. package/dist/tools-C4wHgGKQ.js.map +1 -0
  100. package/dist/tools.d.ts +46 -0
  101. package/dist/tools.d.ts.map +1 -0
  102. package/dist/tools.js +106 -0
  103. package/dist/tools.js.map +1 -0
  104. package/dist/validate-c7EL5uuH.js +224 -0
  105. package/dist/validate-c7EL5uuH.js.map +1 -0
  106. package/package.json +99 -2
  107. package/dist/run-crew-CKdBjh5P.js.map +0 -1
  108. package/dist/runtime-D25ehzCj.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-C2IfKsvz.d.ts","names":[],"sources":["../src/tracing/tracing.ts","../src/outputs/contracts.ts","../src/plan/plan.ts","../src/sessions/session.ts","../src/context/context-pack.ts","../src/contract/invariants.ts","../src/contract/pii-detectors.ts","../src/contract/tripwire.ts","../src/results/errors.ts","../src/tools/tool-use.ts","../src/tools/tools.ts","../src/tools/tool-call-validation.ts","../src/providers/quirks.ts","../src/capabilities/profile.ts","../src/capabilities/sanitizer-recommendations.ts","../src/capabilities/negotiate.ts","../src/providers/provider.ts"],"mappings":";;;;UAAiB,UAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAA,OACP,IAAA,UACA,EAAA,QAAU,CAAA,GAAI,OAAA,CAAQ,CAAA,GACtB,UAAA,GAAa,MAAA,sBACV,CAAA,GAAI,OAAA,CAAQ,CAAA;EAAA,SACR,KAAA,IAAS,IAAA,UAAc,UAAA,GAAa,MAAA;AAAA;AAAA,KAGnC,YAAA;AAAA,UAiCK,QAAA;EAAA,SACN,IAAA,EAAM,YAAA;EAAA,SACN,SAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA,GAAW,MAAA;AAAA;AAAA,KAGV,YAAA,IAAgB,KAAA,EAAO,QAAA,YAAoB,OAAA;;;KCnD3C,kBAAA;AAAA,UAEK,WAAA;EAAA,SACN,UAAA;EAAA,SACA,KAAA;EAAA,SACA,IAAA;IAAA,SACE,KAAA;IAAA,SACA,GAAA;EAAA;EAAA,SAEF,QAAA,GAAW,MAAA;AAAA;AAAA,UAGL,uBAAA;EAAA,SACN,IAAA;AAAA;AAAA,UAGM,0BAAA;EAAA,SACN,IAAA;EAAA,SACA,YAAA,GAAe,YAAA;AAAA;AAAA,KAGd,oBAAA,GAAuB,gBAAA;AAAA,KAEvB,cAAA,GACR,kBAAA,GACA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Key, C as ProviderToolDefinition, D as NegotiationAuthError, E as NegotiatedCapabilities, F as CapabilityAdapter, G as AdapterQuirks, H as RecommendedPromptStrategy, I as KnownFailureMode, J as LiteLLMQuirks, K as AnthropicQuirks, L as ModelCapabilityProfile, M as getRecommendedSanitizers, N as ALL_KNOWN_FAILURE_MODES, O as negotiateCapabilities, P as ALL_TRAINING_CLASSES, Q as OpenRouterQuirks, R as ModelCapabilityProfileModality, S as ProviderToolChoice, T as Usage, U as ToolCallSurface, V as ReasoningSurface, W as TrainingClass, X as OpenAICompatQuirks, Y as LmStudioQuirks, Z as OpenAIQuirks, _ as ProviderStreamOutputChunk, a as ProviderFinishMetadata, b as ProviderStreamUsageChunk, c as ProviderPricingHint, d as ProviderRunRequest, f as ProviderRunResponse, g as ProviderStreamGatewayChunk, h as ProviderStreamCompleteChunk, ht as parseToolUseEnvelope, i as ProviderDataPolicyHints, j as SanitizerKey, k as synthesizeNegotiatedCapabilitiesFromRegistry, l as ProviderRef, m as ProviderStreamChunk, mt as ToolUseRequest, n as ModelCapability, o as ProviderGatewayMetadata, p as ProviderStream, q as GeminiQuirks, r as ProviderAdapter, s as ProviderLatencyClass, t as CapabilityModality, u as ProviderRegistryInput, v as ProviderStreamTextDeltaChunk, w as ProviderTransportMode, x as ProviderStructuredOutputRequest, y as ProviderStreamToolCallChunk, z as ModelCapabilityProfilePricing } from "./provider-C2IfKsvz.js";
2
+ import { C as createAISdkProvider, S as SdkLikeProviderOptions, T as createOpenAIProvider, _ as FakeProviderOptions, a as CollectStreamOptions, b as createAnthropicProvider, c as createXaiProvider, d as LmStudioProviderOptions, f as createLmStudioProvider, g as createGeminiProvider, h as GeminiProviderOptions, i as getToolUseContract, l as OpenRouterProviderOptions, m as createLiteLLMProvider, n as PROMPT_STRATEGIES, o as collectStream, p as LiteLLMProviderOptions, r as getStructuredOutputContract, s as XaiProviderOptions, t as PROMPT_SCAFFOLD_VERSION, u as createOpenRouterProvider, v as createFakeProvider, w as createOpenAICompatibleProvider, x as OpenAICompatibleProviderOptions, y as AnthropicProviderOptions } from "./scaffolds-DKQrCRqh.js";
3
+ import { n as getCapabilityProfile, r as stripOpenRouterVariant, t as findCapabilityProfile } from "./index-DpnHGHVL.js";
4
+ export { ALL_KNOWN_FAILURE_MODES, ALL_TRAINING_CLASSES, type AdapterQuirks, type AnthropicProviderOptions, type AnthropicQuirks, type CapabilityAdapter, type CapabilityModality, type CollectStreamOptions, type FakeProviderOptions, type GeminiProviderOptions, type GeminiQuirks, type KnownFailureMode, type LiteLLMProviderOptions, type LiteLLMQuirks, type LmStudioProviderOptions, type LmStudioQuirks, type ModelCapability, type ModelCapabilityProfile, type ModelCapabilityProfileModality, type ModelCapabilityProfilePricing, type ModelCapabilityProfilePricingKey, type NegotiatedCapabilities, NegotiationAuthError, type OpenAICompatQuirks, type OpenAICompatibleProviderOptions, type OpenAIQuirks, type OpenRouterProviderOptions, type OpenRouterQuirks, PROMPT_SCAFFOLD_VERSION, PROMPT_STRATEGIES, type ProviderAdapter, type ProviderDataPolicyHints, type ProviderFinishMetadata, type ProviderGatewayMetadata, type ProviderLatencyClass, type ProviderPricingHint, type ProviderRef, type ProviderRegistryInput, type ProviderRunRequest, type ProviderRunResponse, type ProviderStream, type ProviderStreamChunk, type ProviderStreamCompleteChunk, type ProviderStreamGatewayChunk, type ProviderStreamOutputChunk, type ProviderStreamTextDeltaChunk, type ProviderStreamToolCallChunk, type ProviderStreamUsageChunk, type ProviderStructuredOutputRequest, type ProviderToolChoice, type ProviderToolDefinition, type ProviderTransportMode, type ReasoningSurface, type RecommendedPromptStrategy, type SanitizerKey, type SdkLikeProviderOptions, type ToolCallSurface, type ToolUseRequest, type TrainingClass, type Usage, type XaiProviderOptions, type XaiQuirks, collectStream, createAISdkProvider, createAnthropicProvider, createFakeProvider, createGeminiProvider, createLiteLLMProvider, createLmStudioProvider, createOpenAICompatibleProvider, createOpenAIProvider, createOpenRouterProvider, createXaiProvider, findCapabilityProfile, getCapabilityProfile, getRecommendedSanitizers, getStructuredOutputContract, getToolUseContract, negotiateCapabilities, parseToolUseEnvelope, stripOpenRouterVariant, synthesizeNegotiatedCapabilitiesFromRegistry };
@@ -0,0 +1,4 @@
1
+ import { a as collectStream, c as createLmStudioProvider, d as createFakeProvider, f as createAnthropicProvider, h as createOpenAIProvider, i as getToolUseContract, l as createLiteLLMProvider, m as createOpenAICompatibleProvider, n as PROMPT_STRATEGIES, o as createXaiProvider, p as createAISdkProvider, r as getStructuredOutputContract, s as createOpenRouterProvider, t as PROMPT_SCAFFOLD_VERSION, u as createGeminiProvider } from "./scaffolds-ekPIlBeU.js";
2
+ import { c as getCapabilityProfile, d as ALL_TRAINING_CLASSES, i as synthesizeNegotiatedCapabilitiesFromRegistry, l as stripOpenRouterVariant, o as getRecommendedSanitizers, r as negotiateCapabilities, s as findCapabilityProfile, t as NegotiationAuthError, u as ALL_KNOWN_FAILURE_MODES } from "./negotiate-ClD88hkc.js";
3
+ import { o as parseToolUseEnvelope } from "./validate-c7EL5uuH.js";
4
+ export { ALL_KNOWN_FAILURE_MODES, ALL_TRAINING_CLASSES, NegotiationAuthError, PROMPT_SCAFFOLD_VERSION, PROMPT_STRATEGIES, collectStream, createAISdkProvider, createAnthropicProvider, createFakeProvider, createGeminiProvider, createLiteLLMProvider, createLmStudioProvider, createOpenAICompatibleProvider, createOpenAIProvider, createOpenRouterProvider, createXaiProvider, findCapabilityProfile, getCapabilityProfile, getRecommendedSanitizers, getStructuredOutputContract, getToolUseContract, negotiateCapabilities, parseToolUseEnvelope, stripOpenRouterVariant, synthesizeNegotiatedCapabilitiesFromRegistry };
@@ -0,0 +1,235 @@
1
+ import { T as Usage, mn as OutputContractMap } from "./provider-C2IfKsvz.js";
2
+ import { F as LatticeConfig, V as HookHandler, W as RegisterOptions, f as AgentIntent, h as DefaultAgentOutputs, k as ConversationTurn, p as AgentResult, x as AgentTransport } from "./run-crew-Bnve5dyI.js";
3
+ import { t as BudgetInvariant } from "./contract-S3oJGlc9.js";
4
+
5
+ //#region src/agent/runtime.d.ts
6
+ /**
7
+ * Resolves the runtime's behaviour for a single `ai.runAgent(intent)` call.
8
+ *
9
+ * Phase 19 ships an in-process default scheduler (the loop runs in the
10
+ * calling Promise), direct transport (provider.execute()), and in-memory
11
+ * transcript (the `conversation` array). Phase 20 promotes scheduler /
12
+ * transport / storage to the pluggable `AgentHost` adapter.
13
+ *
14
+ * Phase 39: `runAgent` is a thin public wrapper over `runAgentInternal`
15
+ * with no internal options — the public signature and behavior are
16
+ * unchanged.
17
+ */
18
+ declare function runAgent<TOutputs extends OutputContractMap = DefaultAgentOutputs>(intent: AgentIntent<TOutputs>, config?: LatticeConfig): Promise<AgentResult<TOutputs>>;
19
+ //#endregion
20
+ //#region src/agent/infra/cost-tracker.d.ts
21
+ type CostBudgetStatus = "ok" | "warning" | "exceeded";
22
+ interface CostTracker {
23
+ readonly kind: "cost-tracker";
24
+ /** Append a per-iteration Usage record. Mutates internal state. */
25
+ recordIteration(usage: Usage): void;
26
+ /** Returns the running sum across all recorded iterations. */
27
+ total(): Usage;
28
+ /**
29
+ * Reports budget status against `contract.budget`:
30
+ * - "ok" — under 80% of maxCostUsd.
31
+ * - "warning" — at or over 80% but under 100%.
32
+ * - "exceeded" — at or over 100% of maxCostUsd.
33
+ * Returns "ok" when no budget is declared or when cumulative cost is null.
34
+ */
35
+ budgetStatus(budget?: BudgetInvariant): CostBudgetStatus;
36
+ }
37
+ declare function createCostTracker(): CostTracker;
38
+ //#endregion
39
+ //#region src/agent/infra/transcript-store.d.ts
40
+ /**
41
+ * Token estimator used by `tailByTokens`. The default ~4 chars / token is
42
+ * the OpenAI rule of thumb for English text. Callers with provider-specific
43
+ * tokenizers can supply their own.
44
+ */
45
+ type TokenEstimator = (text: string) => number;
46
+ interface TranscriptStore {
47
+ readonly kind: "transcript-store";
48
+ append(turn: ConversationTurn): void;
49
+ all(): readonly ConversationTurn[];
50
+ /** Returns the first user turn (if any) + the most-recent `limit` turns. */
51
+ tail(limit: number): readonly ConversationTurn[];
52
+ /**
53
+ * Returns the first user turn (if any) + the most-recent turns whose
54
+ * combined token estimate fits within `maxTokens`. The default estimator
55
+ * is the ~4 chars / token rule; callers can override for provider-
56
+ * specific tokenizers.
57
+ */
58
+ tailByTokens(maxTokens: number, estimator?: TokenEstimator): readonly ConversationTurn[];
59
+ }
60
+ declare function createTranscriptStore(): TranscriptStore;
61
+ //#endregion
62
+ //#region src/agent/infra/goal-progress.d.ts
63
+ /**
64
+ * GoalProgressTracker — Phase 21 (v1.2).
65
+ *
66
+ * Stuck-detection primitive. The caller declares a goal-satisfaction
67
+ * score per iteration (0..1); the tracker reports a coarse status the
68
+ * agent loop can use to back off or surface to the human.
69
+ */
70
+ type ProgressStatus = "progressing" | "stalled" | "regressed";
71
+ interface GoalProgressOptions {
72
+ /**
73
+ * Window of recent steps used for stall + regression detection.
74
+ * Default 3. The tracker waits until it has at least this many steps
75
+ * before reporting anything other than "progressing".
76
+ */
77
+ readonly windowSize?: number;
78
+ /** Max satisfaction delta across the window to count as "stalled". Default 0.02. */
79
+ readonly stallThreshold?: number;
80
+ /** Min drop from prior max to count as "regressed". Default 0.1. */
81
+ readonly regressionThreshold?: number;
82
+ }
83
+ interface GoalProgressStep {
84
+ readonly iterationIndex: number;
85
+ readonly goalSatisfaction: number;
86
+ }
87
+ interface GoalProgressTracker {
88
+ readonly kind: "goal-progress-tracker";
89
+ recordStep(step: GoalProgressStep): void;
90
+ status(): ProgressStatus;
91
+ }
92
+ declare function createGoalProgressTracker(options?: GoalProgressOptions): GoalProgressTracker;
93
+ //#endregion
94
+ //#region src/agent/infra/action-history.d.ts
95
+ /**
96
+ * ActionHistory — Phase 21 (v1.2).
97
+ *
98
+ * Detects stuck patterns in the agent loop's tool-call sequence:
99
+ * - "consecutive-identical-tool-call" — same (toolName, argsHash) N+ times in a row
100
+ * - "ping-pong" — last 4 records alternate between 2 distinct (toolName, argsHash) pairs
101
+ * - "no-progress" — reserved for callers wiring goal-progress feedback here
102
+ *
103
+ * Standalone (no dependency on the agent runtime); callers register the
104
+ * primitive externally and pump `recordAction` from their loop or hook.
105
+ */
106
+ declare const STUCK_REASONS: readonly ["consecutive-identical-tool-call", "no-progress", "ping-pong"];
107
+ type StuckReason = typeof STUCK_REASONS[number];
108
+ interface ActionRecord {
109
+ readonly iterationIndex: number;
110
+ readonly toolName: string;
111
+ readonly argsHash: string;
112
+ }
113
+ interface ActionHistoryOptions {
114
+ /** Number of consecutive identical records that triggers the consecutive detector. Default 3. */
115
+ readonly consecutiveLimit?: number;
116
+ }
117
+ interface ActionHistory {
118
+ readonly kind: "action-history";
119
+ /**
120
+ * Append a record. Returns the latest StuckReason triggered by this
121
+ * record, or null when no detector fires. The most recent reason wins
122
+ * when multiple apply.
123
+ */
124
+ recordAction(action: ActionRecord): StuckReason | null;
125
+ history(): readonly ActionRecord[];
126
+ }
127
+ declare function createActionHistory(options?: ActionHistoryOptions): ActionHistory;
128
+ //#endregion
129
+ //#region src/agent/infra/permission-context.d.ts
130
+ interface PermissionRule {
131
+ /** Match on tool name. String = exact match; RegExp = test. Both undefined = match-any. */
132
+ readonly toolName?: string | RegExp;
133
+ /**
134
+ * Optional resource matcher. The caller passes `resource` on each
135
+ * decide() invocation; this rule fires only when the rule's resource
136
+ * matches.
137
+ */
138
+ readonly resource?: string | RegExp;
139
+ readonly verdict: "allow" | "deny";
140
+ readonly reason?: string;
141
+ }
142
+ interface PermissionDecisionInput {
143
+ readonly toolName: string;
144
+ readonly iterationIndex: number;
145
+ readonly resource?: string;
146
+ readonly args?: unknown;
147
+ }
148
+ type PermissionVerdict = {
149
+ readonly allow: true;
150
+ } | {
151
+ readonly allow: false;
152
+ readonly reason: string;
153
+ };
154
+ interface PermissionContext {
155
+ readonly kind: "permission-context";
156
+ decide(input: PermissionDecisionInput): PermissionVerdict;
157
+ }
158
+ declare function createPermissionContext(rules: readonly PermissionRule[]): PermissionContext;
159
+ /**
160
+ * Hook handler shape suitable for registering on `BEFORE_TOOL` at
161
+ * BAND.SAFETY. Reads `toolName` and `iterationIndex` from the agent
162
+ * runtime's BEFORE_TOOL context shape (`{ iterationIndex, toolName,
163
+ * args }`) and translates a deny verdict into `controls.deny(reason)`.
164
+ */
165
+ interface PermissionHookContext {
166
+ readonly iterationIndex: number;
167
+ readonly toolName: string;
168
+ readonly resource?: string;
169
+ readonly args?: unknown;
170
+ }
171
+ declare function createPermissionGuardHook(context: PermissionContext): HookHandler<PermissionHookContext>;
172
+ /**
173
+ * Convenience: returns RegisterOptions for the SAFETY-band registration.
174
+ * Callers do `pipeline.register("BEFORE_TOOL", hook, permissionGuardRegisterOptions())`.
175
+ */
176
+ declare function permissionGuardRegisterOptions(): RegisterOptions;
177
+ //#endregion
178
+ //#region src/agent/infra/rate-limit-group.d.ts
179
+ interface RateLimitGroupOptions {
180
+ /** Requests per minute. Defaults to 50 (Anthropic Tier 1). */
181
+ readonly requestsPerMinute?: number;
182
+ /** Input tokens per minute. Defaults to 30_000 (Anthropic Tier 1). */
183
+ readonly tokensPerMinute?: number;
184
+ /** Injectable clock for tests (defaults to `Date.now`). */
185
+ readonly now?: () => number;
186
+ }
187
+ interface RateLimitLease {
188
+ /**
189
+ * Reconcile the reservation against actual usage. Refunds
190
+ * `estimate - actual.promptTokens` to the token bucket when positive,
191
+ * debits the difference when negative. Idempotent — only the first call
192
+ * has an effect. Requests are never refunded.
193
+ */
194
+ release(actual: {
195
+ promptTokens: number;
196
+ }): void;
197
+ }
198
+ interface RateLimitGroup {
199
+ readonly kind: "rate-limit-group";
200
+ /**
201
+ * Reserve 1 request + `estimate.inputTokens` tokens. Resolves immediately
202
+ * when both dimensions have capacity; otherwise the caller waits (FIFO)
203
+ * until continuous drain refills the deficit.
204
+ */
205
+ acquire(estimate: {
206
+ inputTokens: number;
207
+ }): Promise<RateLimitLease>;
208
+ }
209
+ declare function createRateLimitGroup(options?: RateLimitGroupOptions): RateLimitGroup;
210
+ /**
211
+ * Wrap an `AgentTransport` so every provider call is gated through `group`.
212
+ *
213
+ * Every transport wrapped with the SAME group instance shares one bucket —
214
+ * `runAgentCrew` (39-06) wraps parent + child hosts with one shared group per
215
+ * adapter instance, structurally guaranteeing crew-wide coordination (D-13).
216
+ * `ProviderAdapter` is never modified (INV-03 parity invariant intact).
217
+ *
218
+ * - `inner` provided → dispatch nests through `inner.call(provider, request)`,
219
+ * composing with consumer transports (e.g. cross-process bridges).
220
+ * - `inner` undefined → falls through to `provider.execute(request)`, guarded
221
+ * the same way as `createNoopAgentHost` (error names the provider id only).
222
+ *
223
+ * Release policy:
224
+ * - Success → release with `normalizedUsage.promptTokens`; when usage is
225
+ * missing or non-finite, fall back to the estimate (no NaN arithmetic —
226
+ * the `costUsd: null` "unmeasured" discipline analog).
227
+ * - Throw → release with the ORIGINAL estimate (burn — no refund; the
228
+ * provider may have consumed quota despite the error) and rethrow the
229
+ * same error unchanged. Request objects and headers are never serialized
230
+ * into error paths.
231
+ */
232
+ declare function withRateLimit(group: RateLimitGroup, inner?: AgentTransport): AgentTransport;
233
+ //#endregion
234
+ export { createCostTracker as A, ProgressStatus as C, createTranscriptStore as D, TranscriptStore as E, CostBudgetStatus as O, GoalProgressTracker as S, TokenEstimator as T, STUCK_REASONS as _, withRateLimit as a, GoalProgressOptions as b, PermissionHookContext as c, createPermissionContext as d, createPermissionGuardHook as f, ActionRecord as g, ActionHistoryOptions as h, createRateLimitGroup as i, runAgent as j, CostTracker as k, PermissionRule as l, ActionHistory as m, RateLimitGroupOptions as n, PermissionContext as o, permissionGuardRegisterOptions as p, RateLimitLease as r, PermissionDecisionInput as s, RateLimitGroup as t, PermissionVerdict as u, StuckReason as v, createGoalProgressTracker as w, GoalProgressStep as x, createActionHistory as y };
235
+ //# sourceMappingURL=rate-limit-group-nDsBJqSu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit-group-nDsBJqSu.d.ts","names":[],"sources":["../src/agent/runtime.ts","../src/agent/infra/cost-tracker.ts","../src/agent/infra/transcript-store.ts","../src/agent/infra/goal-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;EK8DT,OAAA,CAAQ,QAAA;IAAY,WAAA;EAAA,IAAwB,OAAA,CAAQ,cAAA;AAAA;AAAA,iBA2BtC,oBAAA,CACd,OAAA,GAAS,qBAAA,GACR,cAAA;;;;;;AJ9FH;;;;;AAIA;;;;;;;;;;;;iBI2PgB,aAAA,CACd,KAAA,EAAO,cAAA,EACP,KAAA,GAAQ,cAAA,GACP,cAAA"}
@@ -0,0 +1,205 @@
1
+ import canonicalize from "canonicalize";
2
+ //#region src/receipts/canonical.ts
3
+ const encoder = new TextEncoder();
4
+ /**
5
+ * Convert costUsd (number | null) to its canonical string form.
6
+ * RFC 8785 requires deterministic float-to-string; using JS Number→string
7
+ * directly is unsafe across V8 versions (Grisu3 vs Dragonbox). We pin the
8
+ * format by routing through Number.prototype.toString() for FINITE numbers
9
+ * only, and treat NaN/Infinity as null. This matches "I-JSON only" from
10
+ * 09-CONTEXT.md — receipts NEVER carry non-finite floats.
11
+ */
12
+ function stringifyCostUsd(costUsd) {
13
+ if (costUsd === null) return null;
14
+ if (!Number.isFinite(costUsd)) return null;
15
+ return costUsd.toString();
16
+ }
17
+ /**
18
+ * Convert a runtime Usage (number costUsd) to its canonical receipt form
19
+ * (string costUsd). This is the single conversion site — canonical bytes
20
+ * NEVER see a raw float in the cost field.
21
+ */
22
+ function usageToCanonical(usage) {
23
+ return {
24
+ promptTokens: usage.promptTokens,
25
+ completionTokens: usage.completionTokens,
26
+ costUsd: stringifyCostUsd(usage.costUsd)
27
+ };
28
+ }
29
+ /**
30
+ * Canonicalize a receipt body to JCS bytes (RFC 8785).
31
+ *
32
+ * INVARIANT: callers MUST pass an already-redacted body. The redactor in
33
+ * redact.ts produces the input to this function — never the cleartext.
34
+ * See 09-CONTEXT.md "Redact-Then-Sign Ordering (UNRETROFITTABLE)".
35
+ *
36
+ * Throws if canonicalize returns undefined (impossible for valid bodies
37
+ * — surfaces a programmer error rather than silently producing zero
38
+ * bytes that would later fail signature verification).
39
+ */
40
+ function canonicalizeReceiptBody(body) {
41
+ const json = canonicalize(body);
42
+ if (json === void 0) throw new Error("canonicalizeReceiptBody: canonicalize returned undefined; receipt body contained a non-canonicalizable value (function/symbol/undefined).");
43
+ return encoder.encode(json);
44
+ }
45
+ //#endregion
46
+ //#region src/receipts/envelope.ts
47
+ const PAYLOAD_TYPE = "application/vnd.lattice.receipt+json";
48
+ const textEncoder = new TextEncoder();
49
+ function base64Encode(bytes) {
50
+ return Buffer.from(bytes).toString("base64");
51
+ }
52
+ function base64Decode(value) {
53
+ return new Uint8Array(Buffer.from(value, "base64"));
54
+ }
55
+ /**
56
+ * DSSE v1.0 Pre-Authentication Encoding.
57
+ *
58
+ * Reference: https://github.com/secure-systems-lab/dsse/blob/v1.0.0/protocol.md
59
+ *
60
+ * PAE = UTF-8("DSSEv1 " + len(payloadType) + " " + payloadType
61
+ * + " " + len(payload) + " " + payload)
62
+ *
63
+ * `payload` here is the BASE64-encoded string per DSSE v1.0 spec (NOT raw
64
+ * canonical bytes). Both signing and verification MUST construct PAE the
65
+ * same way; this module is the single source of truth.
66
+ *
67
+ * ASCII length is decimal (no zero-padding). e.g. length 1000 → "1000".
68
+ */
69
+ function buildPae(payloadType, payloadBase64) {
70
+ const ascii = "DSSEv1 " + payloadType.length.toString() + " " + payloadType + " " + payloadBase64.length.toString() + " " + payloadBase64;
71
+ return textEncoder.encode(ascii);
72
+ }
73
+ function encodeEnvelope(input) {
74
+ return {
75
+ payloadType: PAYLOAD_TYPE,
76
+ payload: base64Encode(input.payloadBytes),
77
+ signatures: input.signatures.map((entry) => ({
78
+ keyid: entry.keyid,
79
+ sig: base64Encode(entry.sig)
80
+ }))
81
+ };
82
+ }
83
+ function decodeEnvelope(envelope) {
84
+ if (envelope.payloadType !== "application/vnd.lattice.receipt+json") throw new Error(`envelope payloadType mismatch: expected "${PAYLOAD_TYPE}" got "${envelope.payloadType}"`);
85
+ return {
86
+ payloadType: envelope.payloadType,
87
+ payloadBytes: base64Decode(envelope.payload),
88
+ signatures: envelope.signatures.map((entry) => ({
89
+ keyid: entry.keyid,
90
+ sig: base64Decode(entry.sig)
91
+ }))
92
+ };
93
+ }
94
+ //#endregion
95
+ //#region src/receipts/redact.ts
96
+ /**
97
+ * Default redaction policy id for v1.1. Free-form string per
98
+ * 09-CONTEXT.md — registry enforcement deferred to v1.2.
99
+ */
100
+ const DEFAULT_REDACTION_POLICY_ID = "lattice.default.v1";
101
+ /**
102
+ * Redact a receipt body BEFORE canonicalization (and BEFORE signing).
103
+ *
104
+ * The signed digest commits to canonicalize(redact(body)). NEVER the
105
+ * other way around. See 09-CONTEXT.md "Redact-Then-Sign Ordering
106
+ * (UNRETROFITTABLE)" and PITFALLS.md Pitfall #1.
107
+ *
108
+ * For v1.1 the default policy is minimal — the heavy lifting already
109
+ * happened upstream:
110
+ * - Tripwire evaluator emits {detector, substring} for no-pii (T-08-01).
111
+ * - Provider responses are hashed into inputHashes/outputHash, never
112
+ * embedded raw.
113
+ * - Router reject messages do not contain PII by construction.
114
+ *
115
+ * This function therefore primarily:
116
+ * 1. Materializes the redactions[] manifest declaring what WAS elided
117
+ * upstream (so receipts are self-describing).
118
+ * 2. Provides the extension point future policies will use.
119
+ *
120
+ * Returns a NEW body — never mutates the input.
121
+ */
122
+ function redactReceiptBody(body, policyId = DEFAULT_REDACTION_POLICY_ID) {
123
+ const redactions = [];
124
+ if (body.tripwireEvidence !== void 0 && body.tripwireEvidence.kind === "no-pii") redactions.push({
125
+ path: "tripwireEvidence.observed",
126
+ reason: "no-pii-detector-substring-only"
127
+ });
128
+ const sorted = [...redactions].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
129
+ return {
130
+ body: {
131
+ ...body,
132
+ redactionPolicyId: policyId,
133
+ redactions: sorted
134
+ },
135
+ redactions: sorted
136
+ };
137
+ }
138
+ //#endregion
139
+ //#region src/receipts/receipt.ts
140
+ /**
141
+ * Build, redact, canonicalize, sign, and envelope a CapabilityReceipt.
142
+ *
143
+ * Ordering INVARIANT (09-CONTEXT.md, PITFALLS.md Pitfall #1):
144
+ * redact -> canonicalize -> PAE -> sign -> encode
145
+ *
146
+ * The signed digest commits to canonicalize(redact(body)). The function
147
+ * structure makes any other ordering impossible to write by accident —
148
+ * canonicalizeReceiptBody is ONLY called on the output of redactReceiptBody.
149
+ *
150
+ * Defense in depth:
151
+ * - body.kid is assigned from signer.kid, never from input (input has no
152
+ * kid field). The signed body and the envelope keyid CANNOT disagree by
153
+ * construction.
154
+ * - signer.kid is also written to envelope.signatures[0].keyid, so the
155
+ * verifier can cross-check (Step 7 of verifyReceipt).
156
+ *
157
+ * I-JSON guarantees: usage.costUsd is converted to string (or null) via
158
+ * usageToCanonical. Receipts NEVER carry raw floats in the canonical form.
159
+ */
160
+ async function createReceipt(input, signer) {
161
+ const policyId = input.redactionPolicyId ?? "lattice.default.v1";
162
+ const receiptId = input.receiptId ?? crypto.randomUUID();
163
+ const issuedAt = input.issuedAt ?? (/* @__PURE__ */ new Date()).toISOString();
164
+ const { body } = redactReceiptBody({
165
+ version: "lattice-receipt/v1.3",
166
+ receiptId,
167
+ runId: input.runId,
168
+ issuedAt,
169
+ kid: signer.kid,
170
+ model: input.model,
171
+ route: input.route,
172
+ ...input.modelClass !== void 0 ? { modelClass: input.modelClass } : {},
173
+ ...input.parentReceiptCid !== void 0 ? { parentReceiptCid: input.parentReceiptCid } : {},
174
+ ...input.lineageMerkleRoot !== void 0 ? { lineageMerkleRoot: input.lineageMerkleRoot } : {},
175
+ usage: usageToCanonical(input.usage),
176
+ contractVerdict: input.contractVerdict,
177
+ contractHash: input.contractHash,
178
+ inputHashes: input.inputHashes,
179
+ outputHash: input.outputHash,
180
+ redactionPolicyId: policyId,
181
+ redactions: [],
182
+ ...input.noRouteReasons !== void 0 ? { noRouteReasons: input.noRouteReasons } : {},
183
+ ...input.tripwireEvidence !== void 0 ? { tripwireEvidence: input.tripwireEvidence } : {},
184
+ ...input.stepName !== void 0 ? { stepName: input.stepName } : {},
185
+ ...input.stepIndex !== void 0 ? { stepIndex: input.stepIndex } : {},
186
+ ...input.parentStepName !== void 0 ? { parentStepName: input.parentStepName } : {},
187
+ ...input.previousStepName !== void 0 ? { previousStepName: input.previousStepName } : {},
188
+ ...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {},
189
+ ...input.timestamp !== void 0 ? { timestamp: input.timestamp } : {}
190
+ }, policyId);
191
+ const payloadBytes = canonicalizeReceiptBody(body);
192
+ const pae = buildPae(PAYLOAD_TYPE, base64Encode(payloadBytes));
193
+ const sig = await signer.sign(pae);
194
+ return encodeEnvelope({
195
+ payloadBytes,
196
+ signatures: [{
197
+ keyid: signer.kid,
198
+ sig
199
+ }]
200
+ });
201
+ }
202
+ //#endregion
203
+ export { decodeEnvelope as a, buildPae as i, PAYLOAD_TYPE as n, canonicalizeReceiptBody as o, base64Encode as r, createReceipt as t };
204
+
205
+ //# sourceMappingURL=receipt-FYouoPHv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receipt-FYouoPHv.js","names":[],"sources":["../src/receipts/canonical.ts","../src/receipts/envelope.ts","../src/receipts/redact.ts","../src/receipts/receipt.ts"],"sourcesContent":["import canonicalize from \"canonicalize\";\n\nimport type { Usage } from \"../providers/provider.js\";\nimport type {\n CapabilityReceiptBody,\n ReceiptUsageCanonical,\n} from \"./types.js\";\n\nconst encoder = new TextEncoder();\n\n/**\n * Convert costUsd (number | null) to its canonical string form.\n * RFC 8785 requires deterministic float-to-string; using JS Number→string\n * directly is unsafe across V8 versions (Grisu3 vs Dragonbox). We pin the\n * format by routing through Number.prototype.toString() for FINITE numbers\n * only, and treat NaN/Infinity as null. This matches \"I-JSON only\" from\n * 09-CONTEXT.md — receipts NEVER carry non-finite floats.\n */\nexport function stringifyCostUsd(costUsd: number | null): string | null {\n if (costUsd === null) return null;\n if (!Number.isFinite(costUsd)) return null;\n return costUsd.toString();\n}\n\n/**\n * Convert a runtime Usage (number costUsd) to its canonical receipt form\n * (string costUsd). This is the single conversion site — canonical bytes\n * NEVER see a raw float in the cost field.\n */\nexport function usageToCanonical(usage: Usage): ReceiptUsageCanonical {\n return {\n promptTokens: usage.promptTokens,\n completionTokens: usage.completionTokens,\n costUsd: stringifyCostUsd(usage.costUsd),\n };\n}\n\n/**\n * Canonicalize a receipt body to JCS bytes (RFC 8785).\n *\n * INVARIANT: callers MUST pass an already-redacted body. The redactor in\n * redact.ts produces the input to this function — never the cleartext.\n * See 09-CONTEXT.md \"Redact-Then-Sign Ordering (UNRETROFITTABLE)\".\n *\n * Throws if canonicalize returns undefined (impossible for valid bodies\n * — surfaces a programmer error rather than silently producing zero\n * bytes that would later fail signature verification).\n */\nexport function canonicalizeReceiptBody(\n body: CapabilityReceiptBody,\n): Uint8Array {\n const json = canonicalize(body);\n if (json === undefined) {\n throw new Error(\n \"canonicalizeReceiptBody: canonicalize returned undefined; receipt body contained a non-canonicalizable value (function/symbol/undefined).\",\n );\n }\n return encoder.encode(json);\n}\n","/**\n * DSSE-shaped envelope encoder/decoder + Pre-Authentication Encoding (PAE).\n *\n * This module is the single source of truth for:\n * - PAYLOAD_TYPE constant (the receipt media type)\n * - base64 (standard, NOT base64url) encoding helpers\n * - DSSE v1.0 PAE construction: signatures MUST be computed over the bytes\n * returned by buildPae(...), never over raw canonical JSON bytes.\n *\n * Reference: https://github.com/secure-systems-lab/dsse/blob/v1.0.0/protocol.md\n *\n * Reconciled in plan 09-03 to import canonical types from ./types.js (plan\n * 09-01 lands the spine). `_Local` aliases are retained as deprecated type\n * exports for backward compatibility with the Wave 1 sibling imports.\n */\n\nimport type { ReceiptEnvelope, ReceiptSignature } from \"./types.js\";\n\n/**\n * @deprecated Use ReceiptSignature from \"./types.js\". Retained as an alias\n * during the Wave 1 -> Wave 2 reconciliation.\n */\nexport type ReceiptSignature_Local = ReceiptSignature;\n\n/**\n * @deprecated Use ReceiptEnvelope from \"./types.js\". Retained as an alias\n * during the Wave 1 -> Wave 2 reconciliation.\n */\nexport type ReceiptEnvelope_Local = ReceiptEnvelope;\n\nexport const PAYLOAD_TYPE = \"application/vnd.lattice.receipt+json\" as const;\n\nconst textEncoder = new TextEncoder();\n\nexport function base64Encode(bytes: Uint8Array): string {\n return Buffer.from(bytes).toString(\"base64\");\n}\n\nexport function base64Decode(value: string): Uint8Array {\n return new Uint8Array(Buffer.from(value, \"base64\"));\n}\n\n/**\n * DSSE v1.0 Pre-Authentication Encoding.\n *\n * Reference: https://github.com/secure-systems-lab/dsse/blob/v1.0.0/protocol.md\n *\n * PAE = UTF-8(\"DSSEv1 \" + len(payloadType) + \" \" + payloadType\n * + \" \" + len(payload) + \" \" + payload)\n *\n * `payload` here is the BASE64-encoded string per DSSE v1.0 spec (NOT raw\n * canonical bytes). Both signing and verification MUST construct PAE the\n * same way; this module is the single source of truth.\n *\n * ASCII length is decimal (no zero-padding). e.g. length 1000 → \"1000\".\n */\nexport function buildPae(\n payloadType: string,\n payloadBase64: string,\n): Uint8Array {\n const ascii =\n \"DSSEv1 \" +\n payloadType.length.toString() +\n \" \" +\n payloadType +\n \" \" +\n payloadBase64.length.toString() +\n \" \" +\n payloadBase64;\n return textEncoder.encode(ascii);\n}\n\nexport interface EncodeEnvelopeInput {\n readonly payloadBytes: Uint8Array;\n readonly signatures: readonly {\n readonly keyid: string;\n readonly sig: Uint8Array;\n }[];\n}\n\nexport function encodeEnvelope(\n input: EncodeEnvelopeInput,\n): ReceiptEnvelope {\n const payload = base64Encode(input.payloadBytes);\n const signatures: ReceiptSignature[] = input.signatures.map((entry) => ({\n keyid: entry.keyid,\n sig: base64Encode(entry.sig),\n }));\n return {\n payloadType: PAYLOAD_TYPE,\n payload,\n signatures,\n };\n}\n\nexport interface DecodedEnvelope {\n readonly payloadType: string;\n readonly payloadBytes: Uint8Array;\n readonly signatures: readonly {\n readonly keyid: string;\n readonly sig: Uint8Array;\n }[];\n}\n\nexport function decodeEnvelope(\n envelope: ReceiptEnvelope,\n): DecodedEnvelope {\n if (envelope.payloadType !== PAYLOAD_TYPE) {\n throw new Error(\n `envelope payloadType mismatch: expected \"${PAYLOAD_TYPE}\" got \"${envelope.payloadType}\"`,\n );\n }\n return {\n payloadType: envelope.payloadType,\n payloadBytes: base64Decode(envelope.payload),\n signatures: envelope.signatures.map((entry) => ({\n keyid: entry.keyid,\n sig: base64Decode(entry.sig),\n })),\n };\n}\n","import type {\n CapabilityReceiptBody,\n ReceiptRedaction,\n} from \"./types.js\";\n\n/**\n * Default redaction policy id for v1.1. Free-form string per\n * 09-CONTEXT.md — registry enforcement deferred to v1.2.\n */\nexport const DEFAULT_REDACTION_POLICY_ID = \"lattice.default.v1\";\n\nexport interface RedactionResult {\n readonly body: CapabilityReceiptBody;\n readonly redactions: readonly ReceiptRedaction[];\n}\n\n/**\n * Redact a receipt body BEFORE canonicalization (and BEFORE signing).\n *\n * The signed digest commits to canonicalize(redact(body)). NEVER the\n * other way around. See 09-CONTEXT.md \"Redact-Then-Sign Ordering\n * (UNRETROFITTABLE)\" and PITFALLS.md Pitfall #1.\n *\n * For v1.1 the default policy is minimal — the heavy lifting already\n * happened upstream:\n * - Tripwire evaluator emits {detector, substring} for no-pii (T-08-01).\n * - Provider responses are hashed into inputHashes/outputHash, never\n * embedded raw.\n * - Router reject messages do not contain PII by construction.\n *\n * This function therefore primarily:\n * 1. Materializes the redactions[] manifest declaring what WAS elided\n * upstream (so receipts are self-describing).\n * 2. Provides the extension point future policies will use.\n *\n * Returns a NEW body — never mutates the input.\n */\nexport function redactReceiptBody(\n body: CapabilityReceiptBody,\n policyId: string = DEFAULT_REDACTION_POLICY_ID,\n): RedactionResult {\n const redactions: ReceiptRedaction[] = [];\n\n // Record the no-pii redaction as a declared manifest entry.\n // The tripwire kernel ALREADY redacted to {detector, substring};\n // this only declares that the redaction happened so verifiers can\n // see it in the signed body.\n if (\n body.tripwireEvidence !== undefined &&\n body.tripwireEvidence.kind === \"no-pii\"\n ) {\n redactions.push({\n path: \"tripwireEvidence.observed\",\n reason: \"no-pii-detector-substring-only\",\n });\n }\n\n // Sort redactions by path for canonical-form stability (sorted arrays\n // canonicalize identically regardless of insertion order).\n const sorted = [...redactions].sort((a, b) =>\n a.path < b.path ? -1 : a.path > b.path ? 1 : 0,\n );\n\n return {\n body: {\n ...body,\n redactionPolicyId: policyId,\n redactions: sorted,\n },\n redactions: sorted,\n };\n}\n","import type { TrainingClass } from \"../capabilities/profile.js\";\nimport type { TripwireEvidence } from \"../contract/tripwire.js\";\nimport type { RouteRejectReason } from \"../plan/plan.js\";\nimport type { Usage } from \"../providers/provider.js\";\n\nimport { canonicalizeReceiptBody, usageToCanonical } from \"./canonical.js\";\nimport {\n PAYLOAD_TYPE,\n base64Encode,\n buildPae,\n encodeEnvelope,\n} from \"./envelope.js\";\nimport { DEFAULT_REDACTION_POLICY_ID, redactReceiptBody } from \"./redact.js\";\nimport type {\n CapabilityReceiptBody,\n ContractVerdict,\n ReceiptEnvelope,\n ReceiptModel,\n ReceiptRoute,\n ReceiptSigner,\n} from \"./types.js\";\n\n/**\n * Public input to createReceipt. Mirrors CapabilityReceiptBody minus:\n * - `version` (forced to \"lattice-receipt/v1.3\" per Phase 46)\n * - `kid` (forced from signer.kid — caller cannot mismatch)\n * - `redactions[]` (populated by redactReceiptBody)\n * - `usage.costUsd` (converted to canonical string by usageToCanonical)\n *\n * receiptId and issuedAt default to runtime-generated values when omitted.\n * redactionPolicyId defaults to DEFAULT_REDACTION_POLICY_ID.\n */\nexport interface CreateReceiptInput {\n readonly runId: string;\n readonly issuedAt?: string;\n readonly receiptId?: string;\n readonly model: ReceiptModel;\n readonly route: ReceiptRoute;\n readonly modelClass?: TrainingClass;\n // Phase 39 (DELEG-06): chain-link to the parent receipt's CID\n // (`sha256:<hex>` of the parent envelope's canonical payload bytes,\n // derived via receipts/cid.ts receiptCid). Omit for root/non-crew receipts.\n readonly parentReceiptCid?: string;\n readonly lineageMerkleRoot?: string;\n readonly usage: Usage;\n readonly contractVerdict: ContractVerdict;\n readonly contractHash: string | null;\n readonly inputHashes: readonly string[];\n readonly outputHash: string | null;\n readonly redactionPolicyId?: string;\n readonly noRouteReasons?: readonly RouteRejectReason[];\n readonly tripwireEvidence?: TripwireEvidence;\n // Phase 2 v1.1 step-marker fields. All optional; populated when a step\n // transition emits a receipt. Phase 26 (CRYPTO-01) collapsed the v1/v1.1\n // version-bump heuristic to ALWAYS emit \"lattice-receipt/v1.1\" since v1\n // receipts can no longer pass verifyReceipt (receipt-downgrade defense).\n readonly stepName?: string;\n readonly stepIndex?: number;\n readonly parentStepName?: string;\n readonly previousStepName?: string;\n readonly sessionId?: string;\n readonly timestamp?: string;\n}\n\n/**\n * Build, redact, canonicalize, sign, and envelope a CapabilityReceipt.\n *\n * Ordering INVARIANT (09-CONTEXT.md, PITFALLS.md Pitfall #1):\n * redact -> canonicalize -> PAE -> sign -> encode\n *\n * The signed digest commits to canonicalize(redact(body)). The function\n * structure makes any other ordering impossible to write by accident —\n * canonicalizeReceiptBody is ONLY called on the output of redactReceiptBody.\n *\n * Defense in depth:\n * - body.kid is assigned from signer.kid, never from input (input has no\n * kid field). The signed body and the envelope keyid CANNOT disagree by\n * construction.\n * - signer.kid is also written to envelope.signatures[0].keyid, so the\n * verifier can cross-check (Step 7 of verifyReceipt).\n *\n * I-JSON guarantees: usage.costUsd is converted to string (or null) via\n * usageToCanonical. Receipts NEVER carry raw floats in the canonical form.\n */\nexport async function createReceipt(\n input: CreateReceiptInput,\n signer: ReceiptSigner,\n): Promise<ReceiptEnvelope> {\n const policyId = input.redactionPolicyId ?? DEFAULT_REDACTION_POLICY_ID;\n const receiptId = input.receiptId ?? crypto.randomUUID();\n const issuedAt = input.issuedAt ?? new Date().toISOString();\n\n // Phase 46: always emit v1.3. v1.1/v1.2 remain verifier-compatible, but\n // new receipts can carry the optional lineageMerkleRoot provenance field.\n const version: CapabilityReceiptBody[\"version\"] = \"lattice-receipt/v1.3\";\n\n // Step 1: assemble the raw body. `kid` comes from the signer — caller\n // cannot mismatch it. `usage.costUsd` is converted to string (I-JSON).\n const body0: CapabilityReceiptBody = {\n version,\n receiptId,\n runId: input.runId,\n issuedAt,\n kid: signer.kid,\n model: input.model,\n route: input.route,\n ...(input.modelClass !== undefined ? { modelClass: input.modelClass } : {}),\n ...(input.parentReceiptCid !== undefined ? { parentReceiptCid: input.parentReceiptCid } : {}),\n ...(input.lineageMerkleRoot !== undefined ? { lineageMerkleRoot: input.lineageMerkleRoot } : {}),\n usage: usageToCanonical(input.usage),\n contractVerdict: input.contractVerdict,\n contractHash: input.contractHash,\n inputHashes: input.inputHashes,\n outputHash: input.outputHash,\n redactionPolicyId: policyId,\n redactions: [],\n ...(input.noRouteReasons !== undefined\n ? { noRouteReasons: input.noRouteReasons }\n : {}),\n ...(input.tripwireEvidence !== undefined\n ? { tripwireEvidence: input.tripwireEvidence }\n : {}),\n // v1.1 step-marker fields (conditional-spread to honor exactOptionalPropertyTypes)\n ...(input.stepName !== undefined ? { stepName: input.stepName } : {}),\n ...(input.stepIndex !== undefined ? { stepIndex: input.stepIndex } : {}),\n ...(input.parentStepName !== undefined ? { parentStepName: input.parentStepName } : {}),\n ...(input.previousStepName !== undefined ? { previousStepName: input.previousStepName } : {}),\n ...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),\n ...(input.timestamp !== undefined ? { timestamp: input.timestamp } : {}),\n };\n\n // Step 2: redact BEFORE canonicalize. body now carries the redactions[]\n // manifest declaring what was elided.\n const { body } = redactReceiptBody(body0, policyId);\n\n // Step 3: canonicalize the redacted body (RFC 8785 JCS).\n const payloadBytes = canonicalizeReceiptBody(body);\n\n // Step 4: base64-encode for the envelope (DSSE wire format).\n const payload = base64Encode(payloadBytes);\n\n // Step 5: build PAE — Pre-Authentication Encoding per DSSE v1.0.\n const pae = buildPae(PAYLOAD_TYPE, payload);\n\n // Step 6: sign the PAE bytes.\n const sig = await signer.sign(pae);\n\n // Step 7: assemble the envelope. signer.kid duplicated in signatures[]\n // even though it is ALSO inside the signed body (defense in depth).\n return encodeEnvelope({\n payloadBytes,\n signatures: [{ keyid: signer.kid, sig }],\n });\n}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