agentfootprint 9.128.1 → 9.131.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CAPABILITIES.md +13 -1
- package/dist/adapters/llm/AnthropicProvider.js +10 -111
- package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/adapters/llm/BedrockProvider.js +11 -4
- package/dist/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/adapters/llm/InvokeModelGatewayProvider.js +167 -35
- package/dist/adapters/llm/InvokeModelGatewayProvider.js.map +1 -1
- package/dist/adapters/llm/OpenAIProvider.js +5 -0
- package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/adapters/llm/anthropicMessagesWire.js +20 -6
- package/dist/adapters/llm/anthropicMessagesWire.js.map +1 -1
- package/dist/adapters/llm/retryAfter.js +61 -0
- package/dist/adapters/llm/retryAfter.js.map +1 -0
- package/dist/adapters/types.js.map +1 -1
- package/dist/artifacts/datasetResult.js +2 -2
- package/dist/artifacts/datasetResult.js.map +1 -1
- package/dist/artifacts/index.js +10 -8
- package/dist/artifacts/index.js.map +1 -1
- package/dist/artifacts/minting.js +2 -2
- package/dist/artifacts/minting.js.map +1 -1
- package/dist/core/Agent.js +229 -5
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +75 -1
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/agent/arguments/ask.js +356 -14
- package/dist/core/agent/arguments/ask.js.map +1 -1
- package/dist/core/agent/arguments/declare.js +260 -45
- package/dist/core/agent/arguments/declare.js.map +1 -1
- package/dist/core/agent/arguments/dispatch.js +25 -1
- package/dist/core/agent/arguments/dispatch.js.map +1 -1
- package/dist/core/agent/arguments/resolve.js +239 -6
- package/dist/core/agent/arguments/resolve.js.map +1 -1
- package/dist/core/agent/arguments/rows.js +37 -2
- package/dist/core/agent/arguments/rows.js.map +1 -1
- package/dist/core/agent/arguments/serve.js +332 -4
- package/dist/core/agent/arguments/serve.js.map +1 -1
- package/dist/core/agent/arguments/subflow.js +46 -7
- package/dist/core/agent/arguments/subflow.js.map +1 -1
- package/dist/core/agent/assessment/assess.js +45 -6
- package/dist/core/agent/assessment/assess.js.map +1 -1
- package/dist/core/agent/assessment/compose.js +3 -0
- package/dist/core/agent/assessment/compose.js.map +1 -1
- package/dist/core/agent/assessment/reasons.js +18 -0
- package/dist/core/agent/assessment/reasons.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +31 -1
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +9 -0
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/coverage/answer.js +24 -7
- package/dist/core/agent/coverage/answer.js.map +1 -1
- package/dist/core/agent/coverage/period.js +110 -69
- package/dist/core/agent/coverage/period.js.map +1 -1
- package/dist/core/agent/coverage/timeLimitFacts.js +70 -0
- package/dist/core/agent/coverage/timeLimitFacts.js.map +1 -0
- package/dist/core/agent/coverage/timeLimits.js +72 -0
- package/dist/core/agent/coverage/timeLimits.js.map +1 -0
- package/dist/core/agent/evidence/evidenceIndex.js +48 -7
- package/dist/core/agent/evidence/evidenceIndex.js.map +1 -1
- package/dist/core/agent/evidence/gate.js +9 -4
- package/dist/core/agent/evidence/gate.js.map +1 -1
- package/dist/core/agent/evidence/normalize.js +1 -105
- package/dist/core/agent/evidence/normalize.js.map +1 -1
- package/dist/core/agent/findings/ledger.js +14 -0
- package/dist/core/agent/findings/ledger.js.map +1 -1
- package/dist/core/agent/findings/types.js.map +1 -1
- package/dist/core/agent/honesty/mounts.js +105 -4
- package/dist/core/agent/honesty/mounts.js.map +1 -1
- package/dist/core/agent/results/subflow.js +43 -11
- package/dist/core/agent/results/subflow.js.map +1 -1
- package/dist/core/agent/stages/argumentAsk.js +85 -6
- package/dist/core/agent/stages/argumentAsk.js.map +1 -1
- package/dist/core/agent/stages/callLLM.js +16 -0
- package/dist/core/agent/stages/callLLM.js.map +1 -1
- package/dist/core/agent/stages/prepareFinal.js +61 -8
- package/dist/core/agent/stages/prepareFinal.js.map +1 -1
- package/dist/core/agent/stages/route.js +64 -6
- package/dist/core/agent/stages/route.js.map +1 -1
- package/dist/core/agent/stages/seed.js +29 -6
- package/dist/core/agent/stages/seed.js.map +1 -1
- package/dist/core/agent/stages/timeLayer.js +201 -0
- package/dist/core/agent/stages/timeLayer.js.map +1 -0
- package/dist/core/agent/stages/timeLineage.js +61 -0
- package/dist/core/agent/stages/timeLineage.js.map +1 -0
- package/dist/core/agent/stages/toolCalls.js +70 -0
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/inputRequest.js +132 -5
- package/dist/core/inputRequest.js.map +1 -1
- package/dist/core/messageFrom.js +5 -2
- package/dist/core/messageFrom.js.map +1 -1
- package/dist/core/runCheckpoint.js +17 -2
- package/dist/core/runCheckpoint.js.map +1 -1
- package/dist/core/slots/buildToolsSlot.js +30 -2
- package/dist/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/core/time/ask.js +239 -0
- package/dist/core/time/ask.js.map +1 -0
- package/dist/core/time/axis.js +469 -0
- package/dist/core/time/axis.js.map +1 -0
- package/dist/core/time/bind.js +235 -0
- package/dist/core/time/bind.js.map +1 -0
- package/dist/core/time/check.js +261 -0
- package/dist/core/time/check.js.map +1 -0
- package/dist/core/time/checkRecord.js +97 -0
- package/dist/core/time/checkRecord.js.map +1 -0
- package/dist/core/time/clock.js +260 -0
- package/dist/core/time/clock.js.map +1 -0
- package/dist/core/time/convert.js +634 -0
- package/dist/core/time/convert.js.map +1 -0
- package/dist/core/time/drift.js +96 -0
- package/dist/core/time/drift.js.map +1 -0
- package/dist/core/time/duration.js +125 -0
- package/dist/core/time/duration.js.map +1 -0
- package/dist/core/time/forms.js +273 -0
- package/dist/core/time/forms.js.map +1 -0
- package/dist/core/time/instant.js +141 -0
- package/dist/core/time/instant.js.map +1 -0
- package/dist/core/time/periodForm.js +392 -0
- package/dist/core/time/periodForm.js.map +1 -0
- package/dist/core/time/present.js +312 -0
- package/dist/core/time/present.js.map +1 -0
- package/dist/core/time/range.js +267 -0
- package/dist/core/time/range.js.map +1 -0
- package/dist/core/time/reader.js +209 -0
- package/dist/core/time/reader.js.map +1 -0
- package/dist/core/time/readers/english.js +576 -0
- package/dist/core/time/readers/english.js.map +1 -0
- package/dist/core/time/readingAsk.js +94 -0
- package/dist/core/time/readingAsk.js.map +1 -0
- package/dist/core/time/resolve.js +694 -0
- package/dist/core/time/resolve.js.map +1 -0
- package/dist/core/time/resolveRecord.js +164 -0
- package/dist/core/time/resolveRecord.js.map +1 -0
- package/dist/core/time/rows.js +412 -0
- package/dist/core/time/rows.js.map +1 -0
- package/dist/core/time/rowsBuild.js +193 -0
- package/dist/core/time/rowsBuild.js.map +1 -0
- package/dist/core/time/textForms.js +133 -0
- package/dist/core/time/textForms.js.map +1 -0
- package/dist/core/time/windows.js +172 -0
- package/dist/core/time/windows.js.map +1 -0
- package/dist/core/time/wire.js +86 -0
- package/dist/core/time/wire.js.map +1 -0
- package/dist/core/time/zone.js +253 -0
- package/dist/core/time/zone.js.map +1 -0
- package/dist/core/tools.js.map +1 -1
- package/dist/esm/adapters/llm/AnthropicProvider.js +8 -109
- package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
- package/dist/esm/adapters/llm/BedrockProvider.js +11 -4
- package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/esm/adapters/llm/InvokeModelGatewayProvider.d.ts +38 -4
- package/dist/esm/adapters/llm/InvokeModelGatewayProvider.js +167 -35
- package/dist/esm/adapters/llm/InvokeModelGatewayProvider.js.map +1 -1
- package/dist/esm/adapters/llm/OpenAIProvider.js +5 -0
- package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/llm/anthropicMessagesWire.d.ts +6 -1
- package/dist/esm/adapters/llm/anthropicMessagesWire.js +20 -6
- package/dist/esm/adapters/llm/anthropicMessagesWire.js.map +1 -1
- package/dist/esm/adapters/llm/retryAfter.d.ts +27 -0
- package/dist/esm/adapters/llm/retryAfter.js +56 -0
- package/dist/esm/adapters/llm/retryAfter.js.map +1 -0
- package/dist/esm/adapters/types.d.ts +9 -0
- package/dist/esm/adapters/types.js.map +1 -1
- package/dist/esm/artifacts/datasetResult.js +1 -1
- package/dist/esm/artifacts/datasetResult.js.map +1 -1
- package/dist/esm/artifacts/index.d.ts +1 -1
- package/dist/esm/artifacts/index.js +3 -2
- package/dist/esm/artifacts/index.js.map +1 -1
- package/dist/esm/artifacts/minting.js +1 -1
- package/dist/esm/artifacts/minting.js.map +1 -1
- package/dist/esm/artifacts/types.d.ts +2 -2
- package/dist/esm/core/Agent.d.ts +64 -0
- package/dist/esm/core/Agent.js +230 -6
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +60 -0
- package/dist/esm/core/agent/AgentBuilder.js +75 -1
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/arguments/ask.d.ts +88 -5
- package/dist/esm/core/agent/arguments/ask.js +349 -8
- package/dist/esm/core/agent/arguments/ask.js.map +1 -1
- package/dist/esm/core/agent/arguments/checks.d.ts +1 -1
- package/dist/esm/core/agent/arguments/declare.d.ts +76 -15
- package/dist/esm/core/agent/arguments/declare.js +255 -44
- package/dist/esm/core/agent/arguments/declare.js.map +1 -1
- package/dist/esm/core/agent/arguments/dispatch.js +25 -1
- package/dist/esm/core/agent/arguments/dispatch.js.map +1 -1
- package/dist/esm/core/agent/arguments/resolve.d.ts +77 -7
- package/dist/esm/core/agent/arguments/resolve.js +239 -8
- package/dist/esm/core/agent/arguments/resolve.js.map +1 -1
- package/dist/esm/core/agent/arguments/rows.d.ts +31 -2
- package/dist/esm/core/agent/arguments/rows.js +35 -1
- package/dist/esm/core/agent/arguments/rows.js.map +1 -1
- package/dist/esm/core/agent/arguments/serve.d.ts +133 -4
- package/dist/esm/core/agent/arguments/serve.js +328 -4
- package/dist/esm/core/agent/arguments/serve.js.map +1 -1
- package/dist/esm/core/agent/arguments/subflow.d.ts +28 -0
- package/dist/esm/core/agent/arguments/subflow.js +47 -8
- package/dist/esm/core/agent/arguments/subflow.js.map +1 -1
- package/dist/esm/core/agent/assessment/assess.js +45 -6
- package/dist/esm/core/agent/assessment/assess.js.map +1 -1
- package/dist/esm/core/agent/assessment/compose.js +3 -0
- package/dist/esm/core/agent/assessment/compose.js.map +1 -1
- package/dist/esm/core/agent/assessment/reasons.js +18 -0
- package/dist/esm/core/agent/assessment/reasons.js.map +1 -1
- package/dist/esm/core/agent/assessment/types.d.ts +15 -1
- package/dist/esm/core/agent/buildAgentChart.d.ts +41 -0
- package/dist/esm/core/agent/buildAgentChart.js +28 -0
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.d.ts +1 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js +9 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/coverage/answer.d.ts +20 -1
- package/dist/esm/core/agent/coverage/answer.js +23 -6
- package/dist/esm/core/agent/coverage/answer.js.map +1 -1
- package/dist/esm/core/agent/coverage/period.d.ts +49 -3
- package/dist/esm/core/agent/coverage/period.js +107 -68
- package/dist/esm/core/agent/coverage/period.js.map +1 -1
- package/dist/esm/core/agent/coverage/timeLimitFacts.d.ts +56 -0
- package/dist/esm/core/agent/coverage/timeLimitFacts.js +65 -0
- package/dist/esm/core/agent/coverage/timeLimitFacts.js.map +1 -0
- package/dist/esm/core/agent/coverage/timeLimits.d.ts +46 -0
- package/dist/esm/core/agent/coverage/timeLimits.js +67 -0
- package/dist/esm/core/agent/coverage/timeLimits.js.map +1 -0
- package/dist/esm/core/agent/evidence/evidenceIndex.d.ts +25 -2
- package/dist/esm/core/agent/evidence/evidenceIndex.js +47 -7
- package/dist/esm/core/agent/evidence/evidenceIndex.js.map +1 -1
- package/dist/esm/core/agent/evidence/gate.d.ts +7 -0
- package/dist/esm/core/agent/evidence/gate.js +9 -4
- package/dist/esm/core/agent/evidence/gate.js.map +1 -1
- package/dist/esm/core/agent/evidence/normalize.d.ts +0 -34
- package/dist/esm/core/agent/evidence/normalize.js +0 -103
- package/dist/esm/core/agent/evidence/normalize.js.map +1 -1
- package/dist/esm/core/agent/evidence/types.d.ts +12 -1
- package/dist/esm/core/agent/findings/ledger.js +14 -0
- package/dist/esm/core/agent/findings/ledger.js.map +1 -1
- package/dist/esm/core/agent/findings/types.d.ts +2 -1
- package/dist/esm/core/agent/findings/types.js.map +1 -1
- package/dist/esm/core/agent/honesty/mounts.d.ts +25 -0
- package/dist/esm/core/agent/honesty/mounts.js +104 -4
- package/dist/esm/core/agent/honesty/mounts.js.map +1 -1
- package/dist/esm/core/agent/results/subflow.d.ts +34 -2
- package/dist/esm/core/agent/results/subflow.js +43 -11
- package/dist/esm/core/agent/results/subflow.js.map +1 -1
- package/dist/esm/core/agent/stages/argumentAsk.d.ts +19 -0
- package/dist/esm/core/agent/stages/argumentAsk.js +85 -6
- package/dist/esm/core/agent/stages/argumentAsk.js.map +1 -1
- package/dist/esm/core/agent/stages/callLLM.d.ts +6 -0
- package/dist/esm/core/agent/stages/callLLM.js +16 -0
- package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
- package/dist/esm/core/agent/stages/prepareFinal.d.ts +13 -1
- package/dist/esm/core/agent/stages/prepareFinal.js +59 -7
- package/dist/esm/core/agent/stages/prepareFinal.js.map +1 -1
- package/dist/esm/core/agent/stages/route.d.ts +29 -1
- package/dist/esm/core/agent/stages/route.js +64 -7
- package/dist/esm/core/agent/stages/route.js.map +1 -1
- package/dist/esm/core/agent/stages/seed.d.ts +23 -0
- package/dist/esm/core/agent/stages/seed.js +29 -6
- package/dist/esm/core/agent/stages/seed.js.map +1 -1
- package/dist/esm/core/agent/stages/timeLayer.d.ts +94 -0
- package/dist/esm/core/agent/stages/timeLayer.js +193 -0
- package/dist/esm/core/agent/stages/timeLayer.js.map +1 -0
- package/dist/esm/core/agent/stages/timeLineage.d.ts +31 -0
- package/dist/esm/core/agent/stages/timeLineage.js +57 -0
- package/dist/esm/core/agent/stages/timeLineage.js.map +1 -0
- package/dist/esm/core/agent/stages/toolCalls.d.ts +32 -0
- package/dist/esm/core/agent/stages/toolCalls.js +70 -0
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +37 -0
- package/dist/esm/core/inputRequest.d.ts +50 -6
- package/dist/esm/core/inputRequest.js +132 -5
- package/dist/esm/core/inputRequest.js.map +1 -1
- package/dist/esm/core/messageFrom.d.ts +5 -2
- package/dist/esm/core/messageFrom.js +5 -2
- package/dist/esm/core/messageFrom.js.map +1 -1
- package/dist/esm/core/runCheckpoint.js +17 -2
- package/dist/esm/core/runCheckpoint.js.map +1 -1
- package/dist/esm/core/slots/buildToolsSlot.d.ts +29 -0
- package/dist/esm/core/slots/buildToolsSlot.js +30 -2
- package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/core/time/ask.d.ts +126 -0
- package/dist/esm/core/time/ask.js +230 -0
- package/dist/esm/core/time/ask.js.map +1 -0
- package/dist/esm/core/time/axis.d.ts +224 -0
- package/dist/esm/core/time/axis.js +462 -0
- package/dist/esm/core/time/axis.js.map +1 -0
- package/dist/esm/core/time/bind.d.ts +143 -0
- package/dist/esm/core/time/bind.js +227 -0
- package/dist/esm/core/time/bind.js.map +1 -0
- package/dist/esm/core/time/check.d.ts +113 -0
- package/dist/esm/core/time/check.js +252 -0
- package/dist/esm/core/time/check.js.map +1 -0
- package/dist/esm/core/time/checkRecord.d.ts +74 -0
- package/dist/esm/core/time/checkRecord.js +90 -0
- package/dist/esm/core/time/checkRecord.js.map +1 -0
- package/dist/esm/core/time/clock.d.ts +183 -0
- package/dist/esm/core/time/clock.js +252 -0
- package/dist/esm/core/time/clock.js.map +1 -0
- package/dist/esm/core/time/convert.d.ts +178 -0
- package/dist/esm/core/time/convert.js +609 -0
- package/dist/esm/core/time/convert.js.map +1 -0
- package/dist/esm/core/time/drift.d.ts +85 -0
- package/dist/esm/core/time/drift.js +91 -0
- package/dist/esm/core/time/drift.js.map +1 -0
- package/dist/esm/core/time/duration.d.ts +71 -0
- package/dist/esm/core/time/duration.js +117 -0
- package/dist/esm/core/time/duration.js.map +1 -0
- package/dist/esm/core/time/forms.d.ts +84 -0
- package/dist/esm/core/time/forms.js +268 -0
- package/dist/esm/core/time/forms.js.map +1 -0
- package/dist/esm/core/time/instant.d.ts +75 -0
- package/dist/esm/core/time/instant.js +131 -0
- package/dist/esm/core/time/instant.js.map +1 -0
- package/dist/esm/core/time/periodForm.d.ts +184 -0
- package/dist/esm/core/time/periodForm.js +376 -0
- package/dist/esm/core/time/periodForm.js.map +1 -0
- package/dist/esm/core/time/present.d.ts +107 -0
- package/dist/esm/core/time/present.js +305 -0
- package/dist/esm/core/time/present.js.map +1 -0
- package/dist/esm/core/time/range.d.ts +127 -0
- package/dist/esm/core/time/range.js +249 -0
- package/dist/esm/core/time/range.js.map +1 -0
- package/dist/esm/core/time/reader.d.ts +162 -0
- package/dist/esm/core/time/reader.js +203 -0
- package/dist/esm/core/time/reader.js.map +1 -0
- package/dist/esm/core/time/readers/english.d.ts +99 -0
- package/dist/esm/core/time/readers/english.js +572 -0
- package/dist/esm/core/time/readers/english.js.map +1 -0
- package/dist/esm/core/time/readingAsk.d.ts +45 -0
- package/dist/esm/core/time/readingAsk.js +90 -0
- package/dist/esm/core/time/readingAsk.js.map +1 -0
- package/dist/esm/core/time/resolve.d.ts +103 -0
- package/dist/esm/core/time/resolve.js +684 -0
- package/dist/esm/core/time/resolve.js.map +1 -0
- package/dist/esm/core/time/resolveRecord.d.ts +160 -0
- package/dist/esm/core/time/resolveRecord.js +158 -0
- package/dist/esm/core/time/resolveRecord.js.map +1 -0
- package/dist/esm/core/time/rows.d.ts +297 -0
- package/dist/esm/core/time/rows.js +397 -0
- package/dist/esm/core/time/rows.js.map +1 -0
- package/dist/esm/core/time/rowsBuild.d.ts +82 -0
- package/dist/esm/core/time/rowsBuild.js +185 -0
- package/dist/esm/core/time/rowsBuild.js.map +1 -0
- package/dist/esm/core/time/textForms.d.ts +53 -0
- package/dist/esm/core/time/textForms.js +126 -0
- package/dist/esm/core/time/textForms.js.map +1 -0
- package/dist/esm/core/time/windows.d.ts +113 -0
- package/dist/esm/core/time/windows.js +166 -0
- package/dist/esm/core/time/windows.js.map +1 -0
- package/dist/esm/core/time/wire.d.ts +63 -0
- package/dist/esm/core/time/wire.js +81 -0
- package/dist/esm/core/time/wire.js.map +1 -0
- package/dist/esm/core/time/zone.d.ts +115 -0
- package/dist/esm/core/time/zone.js +242 -0
- package/dist/esm/core/time/zone.js.map +1 -0
- package/dist/esm/core/tools.d.ts +26 -4
- package/dist/esm/core/tools.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +16 -2
- package/dist/esm/index.d.ts +13 -1
- package/dist/esm/index.js +6 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/answer-account/facts/howSure.js +7 -0
- package/dist/esm/lib/answer-account/facts/howSure.js.map +1 -1
- package/dist/esm/lib/answer-account/templates.d.ts +3 -0
- package/dist/esm/lib/answer-account/templates.js +4 -0
- package/dist/esm/lib/answer-account/templates.js.map +1 -1
- package/dist/esm/lib/mcp/elicitation.d.ts +84 -0
- package/dist/esm/lib/mcp/elicitation.js +181 -0
- package/dist/esm/lib/mcp/elicitation.js.map +1 -0
- package/dist/esm/lib/mcp/mcpClient.js +9 -3
- package/dist/esm/lib/mcp/mcpClient.js.map +1 -1
- package/dist/esm/lib/mcp/mcpServe.js +6 -2
- package/dist/esm/lib/mcp/mcpServe.js.map +1 -1
- package/dist/esm/lib/mcp/mockMcpClient.d.ts +9 -1
- package/dist/esm/lib/mcp/mockMcpClient.js +5 -3
- package/dist/esm/lib/mcp/mockMcpClient.js.map +1 -1
- package/dist/esm/lib/mcp/toolExtras.d.ts +21 -2
- package/dist/esm/lib/mcp/toolExtras.js +22 -0
- package/dist/esm/lib/mcp/toolExtras.js.map +1 -1
- package/dist/esm/lib/mcp/types.d.ts +8 -0
- package/dist/esm/lib/time-travel/receipt.d.ts +1 -1
- package/dist/esm/lib/time-travel/servedView.d.ts +1 -1
- package/dist/esm/lib/time-travel/servedView.js +9 -0
- package/dist/esm/lib/time-travel/servedView.js.map +1 -1
- package/dist/esm/locales/index.d.ts +6 -0
- package/dist/esm/locales/index.js +6 -0
- package/dist/esm/locales/index.js.map +1 -1
- package/dist/esm/locales/timeAsk.d.ts +29 -0
- package/dist/esm/locales/timeAsk.js +44 -0
- package/dist/esm/locales/timeAsk.js.map +1 -0
- package/dist/esm/recorders/core/resilienceHooks.js +1 -0
- package/dist/esm/recorders/core/resilienceHooks.js.map +1 -1
- package/dist/esm/resilience/statedWait.d.ts +22 -0
- package/dist/esm/resilience/statedWait.js +35 -0
- package/dist/esm/resilience/statedWait.js.map +1 -0
- package/dist/esm/resilience/withRetry.d.ts +13 -2
- package/dist/esm/resilience/withRetry.js +16 -1
- package/dist/esm/resilience/withRetry.js.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/answer-account/facts/howSure.js +7 -0
- package/dist/lib/answer-account/facts/howSure.js.map +1 -1
- package/dist/lib/answer-account/templates.js +4 -0
- package/dist/lib/answer-account/templates.js.map +1 -1
- package/dist/lib/mcp/elicitation.js +186 -0
- package/dist/lib/mcp/elicitation.js.map +1 -0
- package/dist/lib/mcp/mcpClient.js +8 -2
- package/dist/lib/mcp/mcpClient.js.map +1 -1
- package/dist/lib/mcp/mcpServe.js +5 -1
- package/dist/lib/mcp/mcpServe.js.map +1 -1
- package/dist/lib/mcp/mockMcpClient.js +4 -2
- package/dist/lib/mcp/mockMcpClient.js.map +1 -1
- package/dist/lib/mcp/toolExtras.js +25 -1
- package/dist/lib/mcp/toolExtras.js.map +1 -1
- package/dist/lib/time-travel/servedView.js +9 -0
- package/dist/lib/time-travel/servedView.js.map +1 -1
- package/dist/locales/index.js +8 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/locales/timeAsk.js +47 -0
- package/dist/locales/timeAsk.js.map +1 -0
- package/dist/recorders/core/resilienceHooks.js +1 -0
- package/dist/recorders/core/resilienceHooks.js.map +1 -1
- package/dist/resilience/statedWait.js +39 -0
- package/dist/resilience/statedWait.js.map +1 -0
- package/dist/resilience/withRetry.js +16 -1
- package/dist/resilience/withRetry.js.map +1 -1
- package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/InvokeModelGatewayProvider.d.ts +38 -4
- package/dist/types/adapters/llm/InvokeModelGatewayProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/anthropicMessagesWire.d.ts +6 -1
- package/dist/types/adapters/llm/anthropicMessagesWire.d.ts.map +1 -1
- package/dist/types/adapters/llm/retryAfter.d.ts +28 -0
- package/dist/types/adapters/llm/retryAfter.d.ts.map +1 -0
- package/dist/types/adapters/types.d.ts +9 -0
- package/dist/types/adapters/types.d.ts.map +1 -1
- package/dist/types/artifacts/index.d.ts +1 -1
- package/dist/types/artifacts/index.d.ts.map +1 -1
- package/dist/types/artifacts/types.d.ts +2 -2
- package/dist/types/artifacts/types.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +64 -0
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts +60 -0
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/arguments/ask.d.ts +88 -5
- package/dist/types/core/agent/arguments/ask.d.ts.map +1 -1
- package/dist/types/core/agent/arguments/checks.d.ts +1 -1
- package/dist/types/core/agent/arguments/checks.d.ts.map +1 -1
- package/dist/types/core/agent/arguments/declare.d.ts +76 -15
- package/dist/types/core/agent/arguments/declare.d.ts.map +1 -1
- package/dist/types/core/agent/arguments/dispatch.d.ts.map +1 -1
- package/dist/types/core/agent/arguments/resolve.d.ts +77 -7
- package/dist/types/core/agent/arguments/resolve.d.ts.map +1 -1
- package/dist/types/core/agent/arguments/rows.d.ts +31 -2
- package/dist/types/core/agent/arguments/rows.d.ts.map +1 -1
- package/dist/types/core/agent/arguments/serve.d.ts +133 -4
- package/dist/types/core/agent/arguments/serve.d.ts.map +1 -1
- package/dist/types/core/agent/arguments/subflow.d.ts +28 -0
- package/dist/types/core/agent/arguments/subflow.d.ts.map +1 -1
- package/dist/types/core/agent/assessment/assess.d.ts.map +1 -1
- package/dist/types/core/agent/assessment/compose.d.ts.map +1 -1
- package/dist/types/core/agent/assessment/reasons.d.ts.map +1 -1
- package/dist/types/core/agent/assessment/types.d.ts +15 -1
- package/dist/types/core/agent/assessment/types.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts +41 -0
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/coverage/answer.d.ts +20 -1
- package/dist/types/core/agent/coverage/answer.d.ts.map +1 -1
- package/dist/types/core/agent/coverage/period.d.ts +49 -3
- package/dist/types/core/agent/coverage/period.d.ts.map +1 -1
- package/dist/types/core/agent/coverage/timeLimitFacts.d.ts +57 -0
- package/dist/types/core/agent/coverage/timeLimitFacts.d.ts.map +1 -0
- package/dist/types/core/agent/coverage/timeLimits.d.ts +47 -0
- package/dist/types/core/agent/coverage/timeLimits.d.ts.map +1 -0
- package/dist/types/core/agent/evidence/evidenceIndex.d.ts +25 -2
- package/dist/types/core/agent/evidence/evidenceIndex.d.ts.map +1 -1
- package/dist/types/core/agent/evidence/gate.d.ts +7 -0
- package/dist/types/core/agent/evidence/gate.d.ts.map +1 -1
- package/dist/types/core/agent/evidence/normalize.d.ts +0 -34
- package/dist/types/core/agent/evidence/normalize.d.ts.map +1 -1
- package/dist/types/core/agent/evidence/types.d.ts +12 -1
- package/dist/types/core/agent/evidence/types.d.ts.map +1 -1
- package/dist/types/core/agent/findings/ledger.d.ts.map +1 -1
- package/dist/types/core/agent/findings/types.d.ts +2 -1
- package/dist/types/core/agent/findings/types.d.ts.map +1 -1
- package/dist/types/core/agent/honesty/mounts.d.ts +25 -0
- package/dist/types/core/agent/honesty/mounts.d.ts.map +1 -1
- package/dist/types/core/agent/results/subflow.d.ts +34 -2
- package/dist/types/core/agent/results/subflow.d.ts.map +1 -1
- package/dist/types/core/agent/stages/argumentAsk.d.ts +19 -0
- package/dist/types/core/agent/stages/argumentAsk.d.ts.map +1 -1
- package/dist/types/core/agent/stages/callLLM.d.ts +6 -0
- package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
- package/dist/types/core/agent/stages/prepareFinal.d.ts +13 -1
- package/dist/types/core/agent/stages/prepareFinal.d.ts.map +1 -1
- package/dist/types/core/agent/stages/route.d.ts +29 -1
- package/dist/types/core/agent/stages/route.d.ts.map +1 -1
- package/dist/types/core/agent/stages/seed.d.ts +23 -0
- package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
- package/dist/types/core/agent/stages/timeLayer.d.ts +95 -0
- package/dist/types/core/agent/stages/timeLayer.d.ts.map +1 -0
- package/dist/types/core/agent/stages/timeLineage.d.ts +32 -0
- package/dist/types/core/agent/stages/timeLineage.d.ts.map +1 -0
- package/dist/types/core/agent/stages/toolCalls.d.ts +32 -0
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +37 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/inputRequest.d.ts +50 -6
- package/dist/types/core/inputRequest.d.ts.map +1 -1
- package/dist/types/core/messageFrom.d.ts +5 -2
- package/dist/types/core/messageFrom.d.ts.map +1 -1
- package/dist/types/core/runCheckpoint.d.ts.map +1 -1
- package/dist/types/core/slots/buildToolsSlot.d.ts +29 -0
- package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
- package/dist/types/core/time/ask.d.ts +127 -0
- package/dist/types/core/time/ask.d.ts.map +1 -0
- package/dist/types/core/time/axis.d.ts +225 -0
- package/dist/types/core/time/axis.d.ts.map +1 -0
- package/dist/types/core/time/bind.d.ts +144 -0
- package/dist/types/core/time/bind.d.ts.map +1 -0
- package/dist/types/core/time/check.d.ts +114 -0
- package/dist/types/core/time/check.d.ts.map +1 -0
- package/dist/types/core/time/checkRecord.d.ts +75 -0
- package/dist/types/core/time/checkRecord.d.ts.map +1 -0
- package/dist/types/core/time/clock.d.ts +184 -0
- package/dist/types/core/time/clock.d.ts.map +1 -0
- package/dist/types/core/time/convert.d.ts +179 -0
- package/dist/types/core/time/convert.d.ts.map +1 -0
- package/dist/types/core/time/drift.d.ts +86 -0
- package/dist/types/core/time/drift.d.ts.map +1 -0
- package/dist/types/core/time/duration.d.ts +72 -0
- package/dist/types/core/time/duration.d.ts.map +1 -0
- package/dist/types/core/time/forms.d.ts +85 -0
- package/dist/types/core/time/forms.d.ts.map +1 -0
- package/dist/types/core/time/instant.d.ts +76 -0
- package/dist/types/core/time/instant.d.ts.map +1 -0
- package/dist/types/core/time/periodForm.d.ts +185 -0
- package/dist/types/core/time/periodForm.d.ts.map +1 -0
- package/dist/types/core/time/present.d.ts +108 -0
- package/dist/types/core/time/present.d.ts.map +1 -0
- package/dist/types/core/time/range.d.ts +128 -0
- package/dist/types/core/time/range.d.ts.map +1 -0
- package/dist/types/core/time/reader.d.ts +163 -0
- package/dist/types/core/time/reader.d.ts.map +1 -0
- package/dist/types/core/time/readers/english.d.ts +100 -0
- package/dist/types/core/time/readers/english.d.ts.map +1 -0
- package/dist/types/core/time/readingAsk.d.ts +46 -0
- package/dist/types/core/time/readingAsk.d.ts.map +1 -0
- package/dist/types/core/time/resolve.d.ts +104 -0
- package/dist/types/core/time/resolve.d.ts.map +1 -0
- package/dist/types/core/time/resolveRecord.d.ts +161 -0
- package/dist/types/core/time/resolveRecord.d.ts.map +1 -0
- package/dist/types/core/time/rows.d.ts +298 -0
- package/dist/types/core/time/rows.d.ts.map +1 -0
- package/dist/types/core/time/rowsBuild.d.ts +83 -0
- package/dist/types/core/time/rowsBuild.d.ts.map +1 -0
- package/dist/types/core/time/textForms.d.ts +54 -0
- package/dist/types/core/time/textForms.d.ts.map +1 -0
- package/dist/types/core/time/windows.d.ts +114 -0
- package/dist/types/core/time/windows.d.ts.map +1 -0
- package/dist/types/core/time/wire.d.ts +64 -0
- package/dist/types/core/time/wire.d.ts.map +1 -0
- package/dist/types/core/time/zone.d.ts +116 -0
- package/dist/types/core/time/zone.d.ts.map +1 -0
- package/dist/types/core/tools.d.ts +26 -4
- package/dist/types/core/tools.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +16 -2
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/index.d.ts +13 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/answer-account/facts/howSure.d.ts.map +1 -1
- package/dist/types/lib/answer-account/templates.d.ts +3 -0
- package/dist/types/lib/answer-account/templates.d.ts.map +1 -1
- package/dist/types/lib/mcp/elicitation.d.ts +85 -0
- package/dist/types/lib/mcp/elicitation.d.ts.map +1 -0
- package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -1
- package/dist/types/lib/mcp/mockMcpClient.d.ts +9 -1
- package/dist/types/lib/mcp/mockMcpClient.d.ts.map +1 -1
- package/dist/types/lib/mcp/toolExtras.d.ts +21 -2
- package/dist/types/lib/mcp/toolExtras.d.ts.map +1 -1
- package/dist/types/lib/mcp/types.d.ts +8 -0
- package/dist/types/lib/mcp/types.d.ts.map +1 -1
- package/dist/types/lib/time-travel/receipt.d.ts +1 -1
- package/dist/types/lib/time-travel/receipt.d.ts.map +1 -1
- package/dist/types/lib/time-travel/servedView.d.ts +1 -1
- package/dist/types/lib/time-travel/servedView.d.ts.map +1 -1
- package/dist/types/locales/index.d.ts +6 -0
- package/dist/types/locales/index.d.ts.map +1 -1
- package/dist/types/locales/timeAsk.d.ts +30 -0
- package/dist/types/locales/timeAsk.d.ts.map +1 -0
- package/dist/types/recorders/core/resilienceHooks.d.ts.map +1 -1
- package/dist/types/resilience/statedWait.d.ts +23 -0
- package/dist/types/resilience/statedWait.d.ts.map +1 -0
- package/dist/types/resilience/withRetry.d.ts +13 -2
- package/dist/types/resilience/withRetry.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/artifacts/timeAxis.js +0 -218
- package/dist/artifacts/timeAxis.js.map +0 -1
- package/dist/esm/artifacts/timeAxis.d.ts +0 -114
- package/dist/esm/artifacts/timeAxis.js +0 -212
- package/dist/esm/artifacts/timeAxis.js.map +0 -1
- package/dist/types/artifacts/timeAxis.d.ts +0 -115
- package/dist/types/artifacts/timeAxis.d.ts.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core/time/checkRecord — the record half of the result checks (time design
|
|
3
|
+
* § 9.2, § 9.6, step T8): the shapes a `period` row carries
|
|
4
|
+
* (`PeriodDiffers`, `ReadSource`), the checkpoint door's tests for them
|
|
5
|
+
* (`isPeriodDiffers`, `isShifted`), and the two reads over the turn's
|
|
6
|
+
* wall-clock sources (`distinctSources`, `clocksDiffer`).
|
|
7
|
+
*
|
|
8
|
+
* Pattern: pure shapes and guards; no conversion, no drift, no clock.
|
|
9
|
+
* Role: split from `check.ts` BY FILE for the synchronous doors — the
|
|
10
|
+
* checkpoint door's row test (`coverage/period.ts` ·
|
|
11
|
+
* `periodRowIsWellFormed`) is on every agent's graph, and a bundler
|
|
12
|
+
* places a whole file there — so this file imports only
|
|
13
|
+
* `instant.ts` and the range and zone types (the optional-family
|
|
14
|
+
* law, `test/lib/trace-toolpack/browserGraph.test.ts`). `check.ts`
|
|
15
|
+
* re-exports every public name.
|
|
16
|
+
* Emits: N/A.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* clocksDiffer([
|
|
21
|
+
* { toolName: 'orders', zone: 'America/New_York' },
|
|
22
|
+
* { toolName: 'tickets', zone: 'Europe/Berlin' },
|
|
23
|
+
* ]); // { tools: ['orders', 'tickets'], zones: ['America/New_York', 'Europe/Berlin'] }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import type { TimeRange } from './range.js';
|
|
27
|
+
import type { ZoneName } from './zone.js';
|
|
28
|
+
/** Where a check's read range came from — see the module table. */
|
|
29
|
+
export type ReadSource = 'declared' | 'sent' | 'shifted' | 'asked';
|
|
30
|
+
/**
|
|
31
|
+
* `period-differs-from-asked` (§ 9.2): the range compared against, what was
|
|
32
|
+
* read, and the two lists — each piece half-open, in time order, spelled in
|
|
33
|
+
* UTC. At least one list is non-empty (an empty check is not filed).
|
|
34
|
+
*/
|
|
35
|
+
export interface PeriodDiffers {
|
|
36
|
+
/** `asked` — the call's asked range; `person` — the person's window, for a window the model chose. */
|
|
37
|
+
readonly against: 'asked' | 'person';
|
|
38
|
+
/** The range compared against. */
|
|
39
|
+
readonly asked: TimeRange;
|
|
40
|
+
/** What the call read — one range per declared period, else one. */
|
|
41
|
+
readonly read: readonly TimeRange[];
|
|
42
|
+
readonly source: ReadSource;
|
|
43
|
+
/** The step a declared inclusive end was read back with (§ 3.3) — `source: 'declared'` only. */
|
|
44
|
+
readonly stepMs?: number;
|
|
45
|
+
/** Asked but not read. */
|
|
46
|
+
readonly missing: readonly TimeRange[];
|
|
47
|
+
/** Read but not asked. */
|
|
48
|
+
readonly extra: readonly TimeRange[];
|
|
49
|
+
}
|
|
50
|
+
/** A dataset of one call whose declared time axis names a zone — a wall-clock source. */
|
|
51
|
+
export interface SourceClock {
|
|
52
|
+
readonly toolName: string;
|
|
53
|
+
readonly zone: ZoneName;
|
|
54
|
+
}
|
|
55
|
+
/** `clocks-differ` (§ 9.6): the wall-clock sources of one answer, when they declare different zones. */
|
|
56
|
+
export interface ClocksDiffer {
|
|
57
|
+
readonly tools: readonly string[];
|
|
58
|
+
readonly zones: readonly ZoneName[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The wall-clock sources of one answer, one per tool and zone in the order
|
|
62
|
+
* met — the limits block names each. Fresh plain objects.
|
|
63
|
+
*/
|
|
64
|
+
export declare function distinctSources(sources: readonly SourceClock[]): SourceClock[];
|
|
65
|
+
/**
|
|
66
|
+
* `clocks-differ` (§ 9.6) — the tools and zones when the wall-clock sources
|
|
67
|
+
* of one answer declare more than one zone; `undefined` otherwise. A label
|
|
68
|
+
* only: it changes no standing, and every comparison is made on instants.
|
|
69
|
+
*/
|
|
70
|
+
export declare function clocksDiffer(sources: readonly SourceClock[]): ClocksDiffer | undefined;
|
|
71
|
+
/** The checkpoint door's test for a row's {@link PeriodDiffers}. */
|
|
72
|
+
export declare function isPeriodDiffers(value: unknown): value is PeriodDiffers;
|
|
73
|
+
/** The checkpoint door's test for a row's `shifted`. */
|
|
74
|
+
export declare function isShifted(value: unknown): boolean;
|
|
75
|
+
//# sourceMappingURL=checkRecord.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkRecord.d.ts","sourceRoot":"","sources":["../../../../src/core/time/checkRecord.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAI1C,mEAAmE;AACnE,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,sGAAsG;IACtG,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAAC;IACrC,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,gGAAgG;IAChG,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,0BAA0B;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,0BAA0B;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;CACtC;AAED,yFAAyF;AACzF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB;AAED,wGAAwG;AACxG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CACrC;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,EAAE,CAU9E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,YAAY,GAAG,SAAS,CAKtF;AAaD,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAiBtE;AAED,wDAAwD;AACxD,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMjD"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core/time/clock — the run clock: a declared, recorded input, never a hidden read.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: normalize-or-refuse at a boundary (`core/runInput.ts`'s shape): the
|
|
5
|
+
* app's `.time({ zone })` and the run's `time: { now, zone, window }`
|
|
6
|
+
* are read here into one {@link TimeClock}, or refused by name.
|
|
7
|
+
* Role: core/ leaf (the time layer's one owner). Imports `instant.ts`,
|
|
8
|
+
* `zone.ts`, `range.ts`, `reader.ts` (the reader's check) and
|
|
9
|
+
* `resolve.ts` (the policy's) only. The Agent reads the two inputs
|
|
10
|
+
* (`Agent.run`, `Agent.resume`); seed stamps the clock once per turn
|
|
11
|
+
* (`rows.ts` · `ClockRow`); the ToolCalls resume door compares a
|
|
12
|
+
* resume's `time` with the kept clock ({@link clockChange}).
|
|
13
|
+
* Emits: N/A.
|
|
14
|
+
*
|
|
15
|
+
* ## The laws (time design § 4)
|
|
16
|
+
*
|
|
17
|
+
* - **The zone is per run; the builder's is a fallback.** The run's
|
|
18
|
+
* `time.zone` wins, `.time({ zone })` is used when the run names none, and
|
|
19
|
+
* with neither the run is REFUSED before the turn starts — never the
|
|
20
|
+
* server's zone ({@link draftClock} answers `'no-zone'`).
|
|
21
|
+
* - **`now` is the app's, else the turn's start** — admitted as
|
|
22
|
+
* `nowSource: 'default'`, like any default nobody chose.
|
|
23
|
+
* - **Frozen across a pause.** The clock is written once per turn. A resume
|
|
24
|
+
* that passes a different `time` keeps the frozen clock and records what was
|
|
25
|
+
* passed ({@link clockChange}); it is not refused, because an app that
|
|
26
|
+
* passes the current time on every call is doing nothing wrong.
|
|
27
|
+
* - **A window set in a UI is a run input** (`time.window`), recorded with
|
|
28
|
+
* `source: 'control'` — the person's own typed value, never filed as an
|
|
29
|
+
* answer to an ask.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const run = readRunTime({ now: '2026-10-09T15:40:00Z', zone: 'America/Los_Angeles' });
|
|
34
|
+
* const draft = draftClock(run.value, readTimeOptions({}).value!);
|
|
35
|
+
* // { now: '2026-10-09T15:40:00Z', zone: 'America/Los_Angeles', zoneSource: 'run' }
|
|
36
|
+
* completeClock(draft as ClockDraft, Date.parse('2026-10-09T15:40:02Z'));
|
|
37
|
+
* // { now: '2026-10-09T15:40:00Z', nowSource: 'app', zone: 'America/Los_Angeles', zoneSource: 'run' }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
import { type InstantText } from './instant.js';
|
|
41
|
+
import { type TimeRange } from './range.js';
|
|
42
|
+
import { type ZoneName } from './zone.js';
|
|
43
|
+
import { type TimeReader } from './reader.js';
|
|
44
|
+
import { type TimePolicy } from './resolveRecord.js';
|
|
45
|
+
import { type TimeAskMessages } from './ask.js';
|
|
46
|
+
/** The run's clock, stamped once per turn (time design § 4). */
|
|
47
|
+
export interface TimeClock {
|
|
48
|
+
/** The anchor for this turn — the app's `now`, else the turn's start. */
|
|
49
|
+
readonly now: InstantText;
|
|
50
|
+
/** The app passed `now`, or the library took the turn's start. */
|
|
51
|
+
readonly nowSource: 'app' | 'default';
|
|
52
|
+
/** The person's zone for this run — an IANA name. */
|
|
53
|
+
readonly zone: ZoneName;
|
|
54
|
+
/** The run's `time.zone`, else the `.time({ zone })` fallback. */
|
|
55
|
+
readonly zoneSource: 'run' | 'builder';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The run's time input — `agent.run({ message, time })`, or the options bag of
|
|
59
|
+
* `run`, `followUp`, `resume` and `resumeOnError`. Every key is optional; a
|
|
60
|
+
* run with no zone here needs the builder's fallback.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* await agent.run({ message: 'errors since 8?', time: { now: sentAt, zone: 'America/Los_Angeles' } });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export interface RunTime {
|
|
68
|
+
/**
|
|
69
|
+
* The turn's anchor — the MESSAGE's time, so a replay or a late resume
|
|
70
|
+
* reads "yesterday" the same way. An ISO 8601 instant with a zone (upper
|
|
71
|
+
* case `T` and `Z`, no leap second), or a `Date`. Omitted: the turn's start,
|
|
72
|
+
* recorded `nowSource: 'default'`.
|
|
73
|
+
*/
|
|
74
|
+
readonly now?: string | Date;
|
|
75
|
+
/** The person's IANA zone for this run (`'America/Los_Angeles'`). Never an abbreviation. */
|
|
76
|
+
readonly zone?: string;
|
|
77
|
+
/**
|
|
78
|
+
* A window set in a UI — a brushed chart range, a range picker — as a
|
|
79
|
+
* half-open `{ from, to }` of instants. Recorded with `source: 'control'`.
|
|
80
|
+
*/
|
|
81
|
+
readonly window?: TimeRange;
|
|
82
|
+
}
|
|
83
|
+
/** The builder's `.time(options)` — the fallback zone, the reader and its policy (time design § 11). */
|
|
84
|
+
export interface TimeOptions {
|
|
85
|
+
/** The fallback zone for a run that names none. Omitted: every run must name its own. */
|
|
86
|
+
readonly zone?: string;
|
|
87
|
+
/**
|
|
88
|
+
* The strategy that reads the person's words into time parts (`TimeReader`).
|
|
89
|
+
* No default: without one, the person's words are not read — no
|
|
90
|
+
* `time-reading` row is filed.
|
|
91
|
+
*/
|
|
92
|
+
readonly reader?: TimeReader;
|
|
93
|
+
/**
|
|
94
|
+
* How the library picks among a reading's candidates (needs `reader`).
|
|
95
|
+
* `dateOrder` (default `'ask'`): a numeric date's orders become choices,
|
|
96
|
+
* or the one order your people write (`'MDY'`, `'DMY'`, `'YMD'`), recorded
|
|
97
|
+
* as assumed. `year` (default `'ask'`): a date said without a year is
|
|
98
|
+
* asked, or `'current'` — the clock's year, recorded as assumed.
|
|
99
|
+
*/
|
|
100
|
+
readonly policy?: {
|
|
101
|
+
readonly dateOrder?: TimePolicy['dateOrder'];
|
|
102
|
+
readonly year?: TimePolicy['year'];
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Your words for the time ask (`defaultTimeAskMessages` keys → sentence):
|
|
106
|
+
* the reason a refused time answer is re-asked with, the ask's questions,
|
|
107
|
+
* the label on a reading to confirm. A key you leave out keeps the default.
|
|
108
|
+
*/
|
|
109
|
+
readonly messages?: Partial<TimeAskMessages>;
|
|
110
|
+
}
|
|
111
|
+
/** {@link RunTime} as read: every value checked and kept as written, a `Date` spelled in UTC. */
|
|
112
|
+
export interface ReadRunTime {
|
|
113
|
+
readonly now?: InstantText;
|
|
114
|
+
readonly zone?: ZoneName;
|
|
115
|
+
readonly window?: TimeRange;
|
|
116
|
+
}
|
|
117
|
+
/** {@link TimeOptions} as read — the policy's defaults filled in when a reader is armed. */
|
|
118
|
+
export interface ReadTimeOptions {
|
|
119
|
+
readonly zone?: ZoneName;
|
|
120
|
+
readonly reader?: TimeReader;
|
|
121
|
+
readonly policy?: TimePolicy;
|
|
122
|
+
/** The app's catalog overrides — every key one the catalog has. */
|
|
123
|
+
readonly messages?: Partial<TimeAskMessages>;
|
|
124
|
+
}
|
|
125
|
+
/** What a turn's clock is before seed knows the turn's start. */
|
|
126
|
+
export interface ClockDraft {
|
|
127
|
+
readonly now?: InstantText;
|
|
128
|
+
readonly zone: ZoneName;
|
|
129
|
+
readonly zoneSource: 'run' | 'builder';
|
|
130
|
+
readonly window?: TimeRange;
|
|
131
|
+
}
|
|
132
|
+
/** A read answer: the value, or a problem named in words. */
|
|
133
|
+
export type Read<T> = {
|
|
134
|
+
readonly value: T;
|
|
135
|
+
} | {
|
|
136
|
+
readonly problem: string;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* The run's `time` input, checked. `undefined` reads as "nothing passed".
|
|
140
|
+
* Refused, by name: a non-object, an unknown key, a zone that is not an IANA
|
|
141
|
+
* name, a `now` that is not an instant with a zone, a `window` that is not two
|
|
142
|
+
* strict instants with `from` before `to`.
|
|
143
|
+
*/
|
|
144
|
+
export declare function readRunTime(value: unknown): Read<ReadRunTime | undefined>;
|
|
145
|
+
/**
|
|
146
|
+
* The builder's `.time(options)`, checked. `undefined` reads as `{}` — the
|
|
147
|
+
* layer armed with no fallback zone, so every run names its own.
|
|
148
|
+
*/
|
|
149
|
+
export declare function readTimeOptions(value: unknown): Read<ReadTimeOptions>;
|
|
150
|
+
/**
|
|
151
|
+
* The turn's clock as far as the run's inputs decide it — or `'no-zone'`
|
|
152
|
+
* when neither the run nor the builder names a zone (the run is then refused;
|
|
153
|
+
* never the server's zone).
|
|
154
|
+
*/
|
|
155
|
+
export declare function draftClock(run: ReadRunTime | undefined, options: ReadTimeOptions): ClockDraft | 'no-zone';
|
|
156
|
+
/** The clock, once the turn's start is known: `now` is the app's, else that start. */
|
|
157
|
+
export declare function completeClock(draft: ClockDraft, turnStartMs: number): TimeClock;
|
|
158
|
+
/** What a resume passed that differs from the kept clock, and the kept values it would have replaced. */
|
|
159
|
+
export interface ClockChange {
|
|
160
|
+
readonly passed: ReadRunTime;
|
|
161
|
+
readonly kept: {
|
|
162
|
+
readonly now: InstantText;
|
|
163
|
+
readonly zone: ZoneName;
|
|
164
|
+
readonly window?: TimeRange;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The difference between a resume's `time` and the turn's frozen clock, or
|
|
169
|
+
* `undefined` when every value passed equals the kept one (a key not passed
|
|
170
|
+
* is no difference). `now` compares as text: a resume passing the same
|
|
171
|
+
* instant in another spelling is recorded, because the record keeps spellings.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* clockChange({ now: '2026-10-09T16:10:00Z' }, { now: '2026-10-09T15:40:00Z', zone: 'UTC' });
|
|
176
|
+
* // { passed: { now: '2026-10-09T16:10:00Z' }, kept: { now: '2026-10-09T15:40:00Z', zone: 'UTC' } }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export declare function clockChange(passed: ReadRunTime, kept: {
|
|
180
|
+
readonly now: InstantText;
|
|
181
|
+
readonly zone: ZoneName;
|
|
182
|
+
readonly window?: TimeRange;
|
|
183
|
+
}): ClockChange | undefined;
|
|
184
|
+
//# sourceMappingURL=clock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../../../../src/core/time/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAIrE,gEAAgE;AAChE,MAAM,WAAW,SAAS;IACxB,yEAAyE;IACzE,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,KAAK,GAAG,SAAS,CAAC;IACtC,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,KAAK,GAAG,SAAS,CAAC;CACxC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,OAAO;IACtB;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,4FAA4F;IAC5F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;CAC7B;AAED,wGAAwG;AACxG,MAAM,WAAW,WAAW;IAC1B,yFAAyF;IACzF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;QAC7C,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;KACpC,CAAC;IACF;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CAC9C;AAED,iGAAiG;AACjG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;CAC7B;AAED,4FAA4F;AAC5F,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CAC9C;AAED,iEAAiE;AACjE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,KAAK,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;CAC7B;AAED,6DAA6D;AAC7D,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI;IAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAiD3E;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC,CAsCzE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,CA+CrE;AAID;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,OAAO,EAAE,eAAe,GACvB,UAAU,GAAG,SAAS,CASxB;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,CAW/E;AAED,yGAAyG;AACzG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;QAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;QACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;KAC7B,CAAC;CACH;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,GACxF,WAAW,GAAG,SAAS,CAiBzB"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core/time/convert — a tool's period FORMS (time design § 7.1) and the EXACT
|
|
3
|
+
* conversions of one range into them (§ 7.2), with the inverse a binding reads.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: one table per direction. A tool declares every SHAPE its period
|
|
6
|
+
* takes (`PeriodForm` — two arguments, one joined string, an object,
|
|
7
|
+
* a day, a look-back); the library converts a resolved range into the
|
|
8
|
+
* first form that holds it EXACTLY ({@link convertExact}) and reads a
|
|
9
|
+
* sent value back into a range ({@link readBack}). Both cross the
|
|
10
|
+
* argument boundary of § 3.3 through `range.ts` (`boundInto` /
|
|
11
|
+
* `boundFrom` for a `to` bound; `lookbackRange` for a look-back) —
|
|
12
|
+
* never inline.
|
|
13
|
+
* Role: core/ leaf (the time layer). Imports `instant.ts`, `duration.ts`,
|
|
14
|
+
* `range.ts`, `zone.ts` and `periodForm.ts` — the declaration half
|
|
15
|
+
* (the shapes, the sugar, each form's own rules, a declared value's
|
|
16
|
+
* spelling, the tool's facts), split out for the synchronous doors
|
|
17
|
+
* (`arguments/declare.ts`, `ask.ts`, `rows.ts`) and re-exported
|
|
18
|
+
* here. Asked by `bind.ts` (the fill and the binding) and `drift.ts`,
|
|
19
|
+
* which only an armed agent loads.
|
|
20
|
+
* Emits: N/A.
|
|
21
|
+
*
|
|
22
|
+
* ## The sugar (§ 7.1)
|
|
23
|
+
*
|
|
24
|
+
* | Sugar | Means |
|
|
25
|
+
* |-------|-------|
|
|
26
|
+
* | `{ argument, spelling: 'lookback' }` | `{ kind: 'lookback', argument, signed: false }` |
|
|
27
|
+
* | `spelling: 'signed-lookback'` | the same with `signed: true` |
|
|
28
|
+
* | `spelling: 'iso-range'` | `{ kind: 'joined', argument, as: 'iso', joiner: '..', edge: 'inclusive' }` |
|
|
29
|
+
* | `'wall-range'` + `zoneArgument` | `{ kind: 'joined', argument, as: 'wall', joiner: '..', edge: 'inclusive', zone: { argument } }` |
|
|
30
|
+
* | `accepts: [a, b]` | `[sugar(a), sugar(b)]` |
|
|
31
|
+
*
|
|
32
|
+
* ## The exact rows (§ 7.2) — what {@link convertExact} sends
|
|
33
|
+
*
|
|
34
|
+
* | Asked | Form | Sent | Note |
|
|
35
|
+
* |-------|------|------|------|
|
|
36
|
+
* | a look-back | `lookback` | the same length, the sign added or removed, respelled in the form's `units` | none when no unit of `units` spells it |
|
|
37
|
+
* | a look-back | `bounds` / `joined` / `object` | `[now − L, now)` in that `as` | |
|
|
38
|
+
* | a range | `bounds` / `joined` / `object`, `as` `iso` · `epoch-ms` · `epoch-s` | the range; a `to` bound per its `edge` | `epoch-s` rounds outward to whole seconds: `rounded` |
|
|
39
|
+
* | a range | `as: 'wall'` / `'date'` + a zone | the wall times (dates) in the zone | exact only when the tool reads back the same instants (no doubled hour; a date only at midnights) |
|
|
40
|
+
* | a whole day | `day` | that day | any other range is not exact — see the inexact rows |
|
|
41
|
+
* | a range ending at now (within `granularity`) | `lookback` | the smallest spelling in `units` that covers `from` | `rounded` when it is longer |
|
|
42
|
+
*
|
|
43
|
+
* Every other row of § 7.2 is not exact, and {@link convertExact} answers
|
|
44
|
+
* `undefined` for it.
|
|
45
|
+
*
|
|
46
|
+
* ## The inexact rows (§ 7.2, step T5b) — what {@link convertWidened} sends
|
|
47
|
+
*
|
|
48
|
+
* | Asked | Form | Sent | Reads |
|
|
49
|
+
* |-------|------|------|-------|
|
|
50
|
+
* | a range inside one calendar day (in the form's zone) | `day` | that day | the whole day — the rest of it is `extra` |
|
|
51
|
+
* | a range ending before now (past the tool's step) | `lookback` | the covering look-back from now, in the form's units | `[now − L, now]` — the gap after the range (and any rounding before it) is `extra` |
|
|
52
|
+
*
|
|
53
|
+
* A form whose read would be wider than the tool's `maxRange` is skipped.
|
|
54
|
+
* The refusals are tests the binding asks: a range across days when every
|
|
55
|
+
* form is a `day` ({@link spansDaysForDayOnly}), a sent wall time the zone
|
|
56
|
+
* skips ({@link wallGapArgument}), and the facts ({@link periodFactProblem};
|
|
57
|
+
* a range only partly older than `retention` runs —
|
|
58
|
+
* {@link partlyBeyondRetention}).
|
|
59
|
+
*
|
|
60
|
+
* ## Precision and the inclusive edge
|
|
61
|
+
*
|
|
62
|
+
* An ISO or wall bound is written to the second when the instant is a whole
|
|
63
|
+
* second, else to the millisecond; an inclusive `to` is "the last instant
|
|
64
|
+
* inside at that precision" (`to − 1 s`, or `to − 1 ms`). Read back, a bound's
|
|
65
|
+
* precision is how it was written: minutes (`to + 1 min`), seconds, or a
|
|
66
|
+
* fraction (`+ 1 ms`). An epoch bound's precision is its unit; a date's is
|
|
67
|
+
* the calendar day in the zone.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const forms = sugarForms({ argument: 'window', spelling: 'iso-range' });
|
|
72
|
+
* convertExact(
|
|
73
|
+
* { range: { from: '2026-10-09T08:00:00-07:00', to: '2026-10-09T08:41:00-07:00' } },
|
|
74
|
+
* forms,
|
|
75
|
+
* { now: '2026-10-09T15:40:00Z', zone: 'America/Los_Angeles', granularityMs: 60_000 },
|
|
76
|
+
* );
|
|
77
|
+
* // { form: 0, values: { window: '2026-10-09T08:00:00-07:00..2026-10-09T08:40:59-07:00' } }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
import { type DurationText } from './duration.js';
|
|
81
|
+
import { type InstantText } from './instant.js';
|
|
82
|
+
import { sameRange, type TimeRange } from './range.js';
|
|
83
|
+
export { sameRange };
|
|
84
|
+
import { type ZoneName } from './zone.js';
|
|
85
|
+
import { type PeriodFacts, type PeriodForm } from './periodForm.js';
|
|
86
|
+
export { BOUND_AS, DEFAULT_GRANULARITY_MS, FACT_UNITS, FORM_KINDS, formArguments, formIssue, isBoundValue, needsZone, parsesUnderForm, PERIOD_SPELLINGS, periodFactProblem, primaryArgument, sugarForm, sugarForms, TIME_REFUSALS, } from './periodForm.js';
|
|
87
|
+
export type { Bound, BoundAs, FormArgument, PeriodDirection, PeriodFactProblem, PeriodFacts, PeriodForm, PeriodShapes, PeriodSpelling, TimeRefusal, ToBound, ZoneArgument, } from './periodForm.js';
|
|
88
|
+
/** What a conversion knows beyond the window: the turn's clock, the zones, the tool's step. */
|
|
89
|
+
export interface ConvertContext {
|
|
90
|
+
/** The turn's clock (§ 4) — a look-back ends here. */
|
|
91
|
+
readonly now: InstantText;
|
|
92
|
+
/** The zone a wall or date form is written in and its zone argument is sent: the window's. */
|
|
93
|
+
readonly zone: ZoneName;
|
|
94
|
+
/** The app's `.time({ zone })` — the zone of a form that declares `wallZone: 'app'` and no zone argument. */
|
|
95
|
+
readonly appZone?: ZoneName;
|
|
96
|
+
/** The tool's `granularity` in milliseconds, else {@link DEFAULT_GRANULARITY_MS}. */
|
|
97
|
+
readonly granularityMs: number;
|
|
98
|
+
}
|
|
99
|
+
/** The window to convert: its half-open range and, when it was said as one, its look-back. */
|
|
100
|
+
export interface WindowToConvert {
|
|
101
|
+
readonly range: TimeRange;
|
|
102
|
+
/** The look-back length the window was said as (`smhdw`), ending at the clock's `now`. */
|
|
103
|
+
readonly lookback?: DurationText;
|
|
104
|
+
}
|
|
105
|
+
/** One exact conversion: the form used (its index), the argument values, and whether it rounded outward. */
|
|
106
|
+
export interface Conversion {
|
|
107
|
+
readonly form: number;
|
|
108
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
109
|
+
readonly rounded?: true;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The first form (in declared order) that holds `window` EXACTLY — the exact
|
|
113
|
+
* rows of § 7.2 — as the argument values to send, or `undefined` when no form
|
|
114
|
+
* does. A form that would widen, shift or drop part of the window is never
|
|
115
|
+
* chosen here.
|
|
116
|
+
*/
|
|
117
|
+
export declare function convertExact(window: WindowToConvert, forms: readonly PeriodForm[], ctx: ConvertContext): Conversion | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* One conversion that holds MORE than the window: the form, the values, the
|
|
120
|
+
* range the tool reads with them (`sent`, half-open) and the parts of it the
|
|
121
|
+
* window did not ask for (`extra` — one or two ranges, in time order).
|
|
122
|
+
*/
|
|
123
|
+
export interface WidenedConversion extends Conversion {
|
|
124
|
+
readonly sent: TimeRange;
|
|
125
|
+
readonly extra: readonly TimeRange[];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The first form (in declared order) that holds `window` by READING MORE than
|
|
129
|
+
* it — the inexact rows of § 7.2: a range inside one calendar day → that day
|
|
130
|
+
* (`day`); a range ending before now → the covering look-back from now
|
|
131
|
+
* (`lookback`). `widestMs` (the tool's `maxRange`) skips a form whose read
|
|
132
|
+
* would be wider than the tool reads at once. Asked only after
|
|
133
|
+
* {@link convertExact} found no exact form.
|
|
134
|
+
*/
|
|
135
|
+
export declare function convertWidened(window: WindowToConvert, forms: readonly PeriodForm[], ctx: ConvertContext, widestMs?: number): WidenedConversion | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Whether every form is a `day` and the window spans more than one calendar
|
|
138
|
+
* day in the form's zone — the row § 7.2 refuses before dispatch: one call per
|
|
139
|
+
* day is the model's choice, not the library's.
|
|
140
|
+
*/
|
|
141
|
+
export declare function spansDaysForDayOnly(window: WindowToConvert, forms: readonly PeriodForm[], ctx: ConvertContext): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* The first argument of `form` whose sent value is a wall time the zone
|
|
144
|
+
* SKIPS (a spring-forward gap) — the tool would read a time that never
|
|
145
|
+
* happened; refused before dispatch (§ 7.2). `undefined` when the form reads
|
|
146
|
+
* no wall bound, the zone is unknown, or every wall value exists.
|
|
147
|
+
*/
|
|
148
|
+
export declare function wallGapArgument(args: Readonly<Record<string, unknown>>, form: PeriodForm, ctx: {
|
|
149
|
+
readonly appZone?: ZoneName;
|
|
150
|
+
}): string | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* The half-open range the arguments of `form` name — the § 3.3 conversion back
|
|
153
|
+
* from each bound — or `undefined` when they do not name one (missing,
|
|
154
|
+
* misspelled, a wall time the zone doubles or skips, `from` not before `to`).
|
|
155
|
+
* A look-back is read at the turn's clock (`lookbackRange`). The range is
|
|
156
|
+
* spelled in UTC: compare it as instants ({@link sameRange}).
|
|
157
|
+
*/
|
|
158
|
+
export declare function readBack(args: Readonly<Record<string, unknown>>, form: PeriodForm, ctx: {
|
|
159
|
+
readonly now: InstantText;
|
|
160
|
+
readonly appZone?: ZoneName;
|
|
161
|
+
}): TimeRange | undefined;
|
|
162
|
+
/**
|
|
163
|
+
* The absolute range a look-back window was sent as to a bounds form —
|
|
164
|
+
* `[now − L, now)`, which reads back one millisecond shorter than the
|
|
165
|
+
* look-back's own `[now − L, now]` — so a binding recognises either.
|
|
166
|
+
*/
|
|
167
|
+
export declare function lookbackAsBounds(now: InstantText, lookback: DurationText): TimeRange | undefined;
|
|
168
|
+
/** The tool's step in milliseconds — its `granularity`, else one minute (§ 7.4). */
|
|
169
|
+
export declare function granularityMsOf(facts: PeriodFacts | undefined): number;
|
|
170
|
+
/**
|
|
171
|
+
* Whether a half-open range is PARTLY older than what the source keeps — it
|
|
172
|
+
* starts before `now − retention` and ends after it. It dispatches as asked
|
|
173
|
+
* (§ 7.2); the result's `held` decides `partly-held`. `false` when the tool
|
|
174
|
+
* declares no `retention`.
|
|
175
|
+
*/
|
|
176
|
+
export declare function partlyBeyondRetention(range: TimeRange, facts: PeriodFacts, now: InstantText): boolean;
|
|
177
|
+
/** The widest window the tool reads at once (`maxRange`) in milliseconds, when it declares one. */
|
|
178
|
+
export declare function widestMsOf(facts: PeriodFacts | undefined): number | undefined;
|
|
179
|
+
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../../src/core/time/convert.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core/time/drift — the clock at dispatch (time design § 7.4, step T5b).
|
|
3
|
+
*
|
|
4
|
+
* Pattern: one pure decision per dispatched call. The turn's clock is frozen
|
|
5
|
+
* at the message (§ 4); a LOOK-BACK is evaluated by the tool, against
|
|
6
|
+
* its own clock, when it is handed the call. After a pause (or with
|
|
7
|
+
* an app `now` far from the wall clock) the two differ by
|
|
8
|
+
* `drift = dispatchedAt − now`. Within the tool's step nothing
|
|
9
|
+
* changes; past it, the library re-sends its OWN look-back fill as
|
|
10
|
+
* the asked range in the tool's first absolute form that holds it
|
|
11
|
+
* exactly, and records a look-back it cannot re-send — the model's
|
|
12
|
+
* own (never written over, § 7.3), or a tool with no absolute form —
|
|
13
|
+
* as shifted.
|
|
14
|
+
* Role: core/ leaf (the time layer). Imports `convert.ts` and `range.ts`
|
|
15
|
+
* types only. Asked by ToolCalls (`stages/toolCalls.ts` ·
|
|
16
|
+
* `timeAtDispatch`) at both execute sites, just before the tool
|
|
17
|
+
* runs; the answer rides the `call` row (`rows.ts` · `CallDrift`).
|
|
18
|
+
* Emits: N/A.
|
|
19
|
+
*
|
|
20
|
+
* | Drift | The call sent | Tool has an absolute form | Sent | Recorded |
|
|
21
|
+
* |-------|---------------|---------------------------|------|----------|
|
|
22
|
+
* | ≤ the tool's step (one minute when none) | — | — | as it was | nothing |
|
|
23
|
+
* | larger | the library's look-back fill | yes | the asked range in that form | `drift: { outcome: 'redrawn', form }` |
|
|
24
|
+
* | larger | the library's look-back fill | no | the look-back | `drift: { outcome: 'shifted' }` |
|
|
25
|
+
* | larger | the model's look-back | — | the look-back, as sent | `drift: { outcome: 'shifted' }` |
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* driftAtDispatch(
|
|
30
|
+
* { how: 'filled', form: 0, asked: { from: '2026-10-09T14:40:00Z', to: '2026-10-09T15:40:00.001Z' } },
|
|
31
|
+
* [{ kind: 'lookback', argument: 'window', signed: false },
|
|
32
|
+
* { kind: 'bounds', from: { argument: 'start', as: 'epoch-ms' },
|
|
33
|
+
* to: { argument: 'end', as: 'epoch-ms', edge: 'exclusive' } }],
|
|
34
|
+
* { now: '2026-10-09T15:40:00Z', dispatchedAt: '2026-10-09T16:10:00.000Z', granularityMs: 60_000 },
|
|
35
|
+
* );
|
|
36
|
+
* // { byMs: 1_800_000, outcome: 'redrawn', form: 1,
|
|
37
|
+
* // values: { start: 1791556800000, end: 1791560400001 } }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
import { type PeriodForm } from './convert.js';
|
|
41
|
+
import { type InstantText } from './instant.js';
|
|
42
|
+
import type { TimeRange } from './range.js';
|
|
43
|
+
import type { ZoneName } from './zone.js';
|
|
44
|
+
/** What a call's `call-window` row says about its window — the fields the decision reads. */
|
|
45
|
+
export interface DispatchedWindow {
|
|
46
|
+
readonly how: string;
|
|
47
|
+
readonly form?: number;
|
|
48
|
+
readonly asked?: TimeRange;
|
|
49
|
+
}
|
|
50
|
+
/** The clocks and the tool's step. */
|
|
51
|
+
export interface DispatchClock {
|
|
52
|
+
/** The turn's frozen clock. */
|
|
53
|
+
readonly now: InstantText;
|
|
54
|
+
/** The wall clock at dispatch — the `call` row's. */
|
|
55
|
+
readonly dispatchedAt: InstantText;
|
|
56
|
+
/** The tool's `granularity` in milliseconds, else one minute. */
|
|
57
|
+
readonly granularityMs: number;
|
|
58
|
+
/** The clock's zone — a wall or date form's zone argument is sent in it. */
|
|
59
|
+
readonly zone?: ZoneName;
|
|
60
|
+
/** The app's `.time({ zone })`, for a form that declares `wallZone: 'app'`. */
|
|
61
|
+
readonly appZone?: ZoneName;
|
|
62
|
+
}
|
|
63
|
+
/** The decision: nothing, a redraw (with the values to send), or a shift. */
|
|
64
|
+
export type DispatchDrift = {
|
|
65
|
+
readonly byMs: number;
|
|
66
|
+
readonly outcome: 'redrawn';
|
|
67
|
+
readonly form: number;
|
|
68
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
69
|
+
} | {
|
|
70
|
+
readonly byMs: number;
|
|
71
|
+
readonly outcome: 'shifted';
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Whether the call SENT a look-back: its `call-window` row names a form, that
|
|
75
|
+
* form is a `lookback`, and the call dispatched with a window in it (filled,
|
|
76
|
+
* bound, or the model's). The one reading of it — the drift decision here and
|
|
77
|
+
* the result checks' step allowance (`check.ts` · `differsOf`) both ask it.
|
|
78
|
+
*/
|
|
79
|
+
export declare function sentLookback(window: Pick<DispatchedWindow, 'how' | 'form'>, forms: readonly PeriodForm[]): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The drift decision for one dispatched call (the module table), or
|
|
82
|
+
* `undefined` when the call sent no look-back or the drift is within the
|
|
83
|
+
* tool's step. Pure.
|
|
84
|
+
*/
|
|
85
|
+
export declare function driftAtDispatch(window: DispatchedWindow | undefined, forms: readonly PeriodForm[], clock: DispatchClock): DispatchDrift | undefined;
|
|
86
|
+
//# sourceMappingURL=drift.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift.d.ts","sourceRoot":"","sources":["../../../../src/core/time/drift.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,6FAA6F;AAC7F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;CAC5B;AAED,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;IACnC,iEAAiE;IACjE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;CAC7B;AAED,6EAA6E;AAC7E,MAAM,MAAM,aAAa,GACrB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACpD,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;CAAE,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,MAAM,CAAC,EAC9C,KAAK,EAAE,SAAS,UAAU,EAAE,GAC3B,OAAO,CAQT;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,KAAK,EAAE,aAAa,GACnB,aAAa,GAAG,SAAS,CA8B3B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* core/time/duration — the ONE duration grammar, with a unit set per use.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: one grammar, units narrowed per use (never a second regex). A
|
|
5
|
+
* duration is a MACHINE spelling an author declared — a tool's
|
|
6
|
+
* `-40m` argument, a `retention: '30d'`, a dataset's `interval:
|
|
7
|
+
* '5m'` — never a person's words ("the last 40 minutes" is read only
|
|
8
|
+
* by an armed reader). This is the T-spellings law of the time
|
|
9
|
+
* design (`docs/design/time/README.md`, § 5.4).
|
|
10
|
+
* Role: core/ leaf (the time layer's one owner). Imports nothing. Asked by
|
|
11
|
+
* `arguments/declare.ts` · `parsesUnderSpelling` for a look-back.
|
|
12
|
+
* Emits: N/A.
|
|
13
|
+
*
|
|
14
|
+
* ## The grammar
|
|
15
|
+
*
|
|
16
|
+
* `^[1-9][0-9]*[smhdw]$` — a positive integer with no leading zero, then one
|
|
17
|
+
* unit. NO digit cap: `1000000m` is a look-back today and stays one. The UNIT
|
|
18
|
+
* SET is named by every caller, because widening it is a behaviour change:
|
|
19
|
+
*
|
|
20
|
+
* | Use | Units | Why |
|
|
21
|
+
* |-----|-------|-----|
|
|
22
|
+
* | a look-back argument ({@link LOOKBACK_UNITS}) | `mhdw` | today's spelling; a backend that never took seconds is never sent `30s` unless its tool declares `units: 'smhdw'` |
|
|
23
|
+
* | a dataset's interval ({@link AXIS_UNITS}) | `smhdw` | a series can be bucketed by the second |
|
|
24
|
+
*
|
|
25
|
+
* `d` is 24 hours and `w` is 7 days: a machine duration, not a calendar day
|
|
26
|
+
* (a calendar day in a zone with DST is `zone.ts`'s question).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* isDuration('30m', LOOKBACK_UNITS); // true
|
|
31
|
+
* isDuration('30s', LOOKBACK_UNITS); // false — seconds are opt-in
|
|
32
|
+
* isDuration('30s', AXIS_UNITS); // true
|
|
33
|
+
* durationMs('2h', LOOKBACK_UNITS); // 7200000
|
|
34
|
+
* spellDuration(7_200_000, LOOKBACK_UNITS); // '2h' — the smallest exact spelling
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
/** The one duration grammar's text: `^[1-9][0-9]*[smhdw]$`, units narrowed per use. */
|
|
38
|
+
export type DurationText = string;
|
|
39
|
+
/** One unit: second, minute, hour, day (24 h), week (7 d). */
|
|
40
|
+
export type DurationUnit = 's' | 'm' | 'h' | 'd' | 'w';
|
|
41
|
+
/** Every unit, smallest first. */
|
|
42
|
+
export declare const DURATION_UNITS: readonly DurationUnit[];
|
|
43
|
+
/** A look-back's units — today's `mhdw`; `s` only by the tool's own opt-in. */
|
|
44
|
+
export declare const LOOKBACK_UNITS = "mhdw";
|
|
45
|
+
/** A dataset interval's units. */
|
|
46
|
+
export declare const AXIS_UNITS = "smhdw";
|
|
47
|
+
/**
|
|
48
|
+
* Whether `units` is a unit set: a non-empty string of distinct letters from
|
|
49
|
+
* `smhdw`, in any order.
|
|
50
|
+
*/
|
|
51
|
+
export declare function isUnitSet(units: unknown): units is string;
|
|
52
|
+
/** The count (as written, digits) and unit of a duration, or `undefined` when it is not one under `units`. */
|
|
53
|
+
export declare function durationParts(value: unknown, units: string): {
|
|
54
|
+
readonly digits: string;
|
|
55
|
+
readonly unit: DurationUnit;
|
|
56
|
+
} | undefined;
|
|
57
|
+
/** Whether `value` is a duration under `units`. A format check: any number of digits. */
|
|
58
|
+
export declare function isDuration(value: unknown, units: string): value is DurationText;
|
|
59
|
+
/**
|
|
60
|
+
* The milliseconds a duration names, or `undefined` when it is not a duration
|
|
61
|
+
* under `units` — or names more milliseconds than a double holds exactly (the
|
|
62
|
+
* spelling is still a duration; it just cannot be measured).
|
|
63
|
+
*/
|
|
64
|
+
export declare function durationMs(value: unknown, units: string): number | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* The smallest exact spelling of `ms` in `units` — the largest unit that
|
|
67
|
+
* divides it — or `undefined` when no unit in the set divides it (or `ms` is
|
|
68
|
+
* not a positive whole number of milliseconds). `durationMs(spellDuration(x))`
|
|
69
|
+
* is `x` whenever it is defined.
|
|
70
|
+
*/
|
|
71
|
+
export declare function spellDuration(ms: number, units: string): DurationText | undefined;
|
|
72
|
+
//# sourceMappingURL=duration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../../../src/core/time/duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,8DAA8D;AAC9D,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEvD,kCAAkC;AAClC,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAA6C,CAAC;AAEhG,+EAA+E;AAC/E,eAAO,MAAM,cAAc,SAAS,CAAC;AAErC,kCAAkC;AAClC,eAAO,MAAM,UAAU,UAAU,CAAC;AAYlC;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAUzD;AAUD,8GAA8G;AAC9G,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAAE,GAAG,SAAS,CAMtE;AAED,yFAAyF;AACzF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,YAAY,CAE/E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK5E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CASjF"}
|