@dxos/compute 0.16.0 → 0.17.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 (136) hide show
  1. package/dist/lib/AiMetering.mjs +1 -0
  2. package/dist/lib/Hook.mjs +1 -0
  3. package/dist/lib/Operation.mjs +3 -3
  4. package/dist/lib/Process.mjs +2 -2
  5. package/dist/lib/Trace.mjs +1 -1
  6. package/dist/lib/chunk-AgentIdentity.mjs +1 -1
  7. package/dist/lib/chunk-AgentService.mjs.map +1 -1
  8. package/dist/lib/chunk-AiMetering.mjs +77 -0
  9. package/dist/lib/chunk-AiMetering.mjs.map +1 -0
  10. package/dist/lib/chunk-Cancellation.mjs +1 -1
  11. package/dist/lib/chunk-Hook.mjs +78 -0
  12. package/dist/lib/chunk-Hook.mjs.map +1 -0
  13. package/dist/lib/chunk-Instructions.mjs +1 -1
  14. package/dist/lib/chunk-Operation.mjs +169 -5
  15. package/dist/lib/chunk-Operation.mjs.map +1 -1
  16. package/dist/lib/chunk-OperationHandlerSet.mjs +1 -1
  17. package/dist/lib/chunk-OperationRegistry.mjs +1 -1
  18. package/dist/lib/chunk-OperationRegistry.mjs.map +1 -1
  19. package/dist/lib/chunk-Process.mjs +18 -10
  20. package/dist/lib/chunk-Process.mjs.map +1 -1
  21. package/dist/lib/chunk-Project.mjs +52 -24
  22. package/dist/lib/chunk-Project.mjs.map +1 -1
  23. package/dist/lib/chunk-Reducer.mjs +827 -0
  24. package/dist/lib/chunk-Reducer.mjs.map +1 -0
  25. package/dist/lib/chunk-Routine.mjs +1 -1
  26. package/dist/lib/chunk-Runnable.mjs +1 -1
  27. package/dist/lib/chunk-ServiceResolver.mjs +1 -1
  28. package/dist/lib/chunk-Skill.mjs +10 -47
  29. package/dist/lib/chunk-Skill.mjs.map +1 -1
  30. package/dist/lib/chunk-Spec.mjs +49 -0
  31. package/dist/lib/chunk-Spec.mjs.map +1 -0
  32. package/dist/lib/chunk-SpecReview.mjs +98 -0
  33. package/dist/lib/chunk-SpecReview.mjs.map +1 -0
  34. package/dist/lib/chunk-SqlService.mjs.map +1 -1
  35. package/dist/lib/chunk-StorageService.mjs +1 -1
  36. package/dist/lib/chunk-Template.mjs +2 -2
  37. package/dist/lib/chunk-Trace.mjs +97 -13
  38. package/dist/lib/chunk-Trace.mjs.map +1 -1
  39. package/dist/lib/chunk-Trajectory.mjs +326 -0
  40. package/dist/lib/chunk-Trajectory.mjs.map +1 -0
  41. package/dist/lib/chunk-Transcript.mjs +84 -0
  42. package/dist/lib/chunk-Transcript.mjs.map +1 -0
  43. package/dist/lib/chunk-definitions.mjs +1 -1
  44. package/dist/lib/errors.mjs +3 -1
  45. package/dist/lib/errors.mjs.map +1 -1
  46. package/dist/lib/index.mjs +14 -8
  47. package/dist/lib/testing.mjs +2 -2
  48. package/dist/lib/trajectory/Reducer.mjs +1 -0
  49. package/dist/lib/trajectory/Trajectory.mjs +1 -0
  50. package/dist/lib/trajectory/Transcript.mjs +1 -0
  51. package/dist/lib/types/Project.mjs +1 -1
  52. package/dist/lib/types/Skill.mjs +1 -1
  53. package/dist/lib/types/Spec.mjs +1 -0
  54. package/dist/lib/types/SpecReview.mjs +1 -0
  55. package/dist/types/src/AgentService.d.ts +9 -0
  56. package/dist/types/src/AgentService.d.ts.map +1 -1
  57. package/dist/types/src/AiMetering.d.ts +23 -0
  58. package/dist/types/src/AiMetering.d.ts.map +1 -0
  59. package/dist/types/src/AiMetering.test.d.ts +2 -0
  60. package/dist/types/src/AiMetering.test.d.ts.map +1 -0
  61. package/dist/types/src/Hook.d.ts +84 -0
  62. package/dist/types/src/Hook.d.ts.map +1 -0
  63. package/dist/types/src/Hook.test.d.ts +2 -0
  64. package/dist/types/src/Hook.test.d.ts.map +1 -0
  65. package/dist/types/src/Operation.d.ts +276 -2
  66. package/dist/types/src/Operation.d.ts.map +1 -1
  67. package/dist/types/src/Process.d.ts +26 -4
  68. package/dist/types/src/Process.d.ts.map +1 -1
  69. package/dist/types/src/Script.test.d.ts +2 -0
  70. package/dist/types/src/Script.test.d.ts.map +1 -0
  71. package/dist/types/src/Trace.d.ts +103 -1
  72. package/dist/types/src/Trace.d.ts.map +1 -1
  73. package/dist/types/src/errors.d.ts +30 -0
  74. package/dist/types/src/errors.d.ts.map +1 -1
  75. package/dist/types/src/index.d.ts +3 -1
  76. package/dist/types/src/index.d.ts.map +1 -1
  77. package/dist/types/src/trajectory/Reducer.d.ts +191 -0
  78. package/dist/types/src/trajectory/Reducer.d.ts.map +1 -0
  79. package/dist/types/src/trajectory/Reducer.test.d.ts +2 -0
  80. package/dist/types/src/trajectory/Reducer.test.d.ts.map +1 -0
  81. package/dist/types/src/trajectory/Trajectory.d.ts +3211 -0
  82. package/dist/types/src/trajectory/Trajectory.d.ts.map +1 -0
  83. package/dist/types/src/trajectory/Trajectory.test.d.ts +2 -0
  84. package/dist/types/src/trajectory/Trajectory.test.d.ts.map +1 -0
  85. package/dist/types/src/trajectory/Transcript.d.ts +40 -0
  86. package/dist/types/src/trajectory/Transcript.d.ts.map +1 -0
  87. package/dist/types/src/trajectory/index.d.ts +4 -0
  88. package/dist/types/src/trajectory/index.d.ts.map +1 -0
  89. package/dist/types/src/trajectory/light-threads.test.d.ts +2 -0
  90. package/dist/types/src/trajectory/light-threads.test.d.ts.map +1 -0
  91. package/dist/types/src/trajectory/samples.test.d.ts +2 -0
  92. package/dist/types/src/trajectory/samples.test.d.ts.map +1 -0
  93. package/dist/types/src/types/Project.d.ts +11 -12
  94. package/dist/types/src/types/Project.d.ts.map +1 -1
  95. package/dist/types/src/types/Skill.d.ts +6 -51
  96. package/dist/types/src/types/Skill.d.ts.map +1 -1
  97. package/dist/types/src/types/Spec.d.ts +26 -0
  98. package/dist/types/src/types/Spec.d.ts.map +1 -0
  99. package/dist/types/src/types/SpecReview.d.ts +76 -0
  100. package/dist/types/src/types/SpecReview.d.ts.map +1 -0
  101. package/dist/types/src/types/index.d.ts +2 -0
  102. package/dist/types/src/types/index.d.ts.map +1 -1
  103. package/dist/types/tsconfig.tsbuildinfo +1 -1
  104. package/package.json +59 -26
  105. package/src/AgentService.ts +9 -0
  106. package/src/AiMetering.test.ts +89 -0
  107. package/src/AiMetering.ts +93 -0
  108. package/src/Hook.test.ts +75 -0
  109. package/src/Hook.ts +154 -0
  110. package/src/Operation.test.ts +23 -0
  111. package/src/Operation.ts +334 -0
  112. package/src/Process.ts +33 -6
  113. package/src/Script.test.ts +74 -0
  114. package/src/Trace.ts +97 -4
  115. package/src/errors.ts +3 -0
  116. package/src/index.ts +3 -1
  117. package/src/trajectory/Reducer.test.ts +575 -0
  118. package/src/trajectory/Reducer.ts +1026 -0
  119. package/src/trajectory/Trajectory.test.ts +114 -0
  120. package/src/trajectory/Trajectory.ts +440 -0
  121. package/src/trajectory/Transcript.ts +113 -0
  122. package/src/trajectory/index.ts +7 -0
  123. package/src/trajectory/light-threads.test.ts +310 -0
  124. package/src/trajectory/samples.test.ts +285 -0
  125. package/src/types/Project.test.ts +2 -1
  126. package/src/types/Project.ts +43 -27
  127. package/src/types/Skill.ts +6 -61
  128. package/src/types/Spec.ts +68 -0
  129. package/src/types/SpecReview.ts +98 -0
  130. package/src/types/index.ts +2 -0
  131. package/dist/lib/McpServer.mjs +0 -1
  132. package/dist/lib/chunk-McpServer.mjs +0 -124
  133. package/dist/lib/chunk-McpServer.mjs.map +0 -1
  134. package/dist/types/src/McpServer.d.ts +0 -113
  135. package/dist/types/src/McpServer.d.ts.map +0 -1
  136. package/src/McpServer.ts +0 -142
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-Transcript.mjs","names":[],"sources":["../../src/trajectory/Transcript.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { type ContentBlock } from '@dxos/types';\n\n/**\n * One thread as another thread's prompt shows it: text only, because another thread's tool calls may still be\n * waiting for results, and a provider rejects a prompt holding a call without its result.\n */\nexport type Thread = {\n readonly id: string;\n readonly purpose?: string;\n readonly owner?: string;\n readonly status: 'running' | 'done';\n readonly entries: readonly {\n readonly role: string;\n readonly name?: string;\n readonly blocks: readonly ContentBlock.Any[];\n }[];\n};\n\n/** Entries a snapshot keeps from the end of a long thread; its first entry (the request) is always kept. */\nexport const TAIL_ENTRIES = 12;\n\n/** Characters a tool call's arguments or result keep. */\nexport const TOOL_TEXT = 300;\n\n/** Characters a single text block keeps. */\nexport const BLOCK_TEXT = 2_000;\n\nconst cut = (text: string, max: number): string => (text.length > max ? `${text.slice(0, max)}… (cut)` : text);\n\nconst renderBlock = (block: ContentBlock.Any): string | undefined => {\n switch (block._tag) {\n case 'text':\n return block.text.trim().length > 0 ? cut(block.text.trim(), BLOCK_TEXT) : undefined;\n case 'toolCall':\n return `[calls ${block.name}(${cut(block.input, TOOL_TEXT)})]`;\n case 'toolResult':\n return `[${block.name} returned: ${cut(\n typeof block.result === 'string'\n ? block.result\n : block.result === undefined\n ? 'an error'\n : JSON.stringify(block.result),\n TOOL_TEXT,\n )}]`;\n case 'reasoning':\n case 'stats':\n case 'status':\n case 'toolkit':\n return undefined;\n default:\n return `[${block._tag}]`;\n }\n};\n\n/**\n * The lines of a thread's transcript; a long thread keeps its first entry and its last {@link TAIL_ENTRIES}.\n */\nexport const lines = (entries: Thread['entries']): string[] => {\n const kept =\n entries.length > TAIL_ENTRIES + 1 ? [entries[0], undefined, ...entries.slice(-TAIL_ENTRIES)] : [...entries];\n return kept.flatMap((entry) => {\n if (entry === undefined) {\n return [`(${entries.length - TAIL_ENTRIES - 1} earlier entries left out)`];\n }\n const text = entry.blocks.flatMap((block) => renderBlock(block) ?? []).join('\\n');\n return text.length > 0 ? [`${entry.name ?? entry.role}: ${text}`] : [];\n });\n};\n\n/**\n * One thread wrapped in its delimiters.\n */\nexport const render = (thread: Thread): string => {\n const attributes = [\n `id=\"${thread.id}\"`,\n ...(thread.purpose ? [`title=\"${thread.purpose.replaceAll('\"', \"'\")}\"`] : []),\n ...(thread.owner ? [`owner=\"${thread.owner}\"`] : []),\n `status=\"${thread.status}\"`,\n ].join(' ');\n return [`<thread ${attributes}>`, ...lines(thread.entries), '</thread>'].join('\\n');\n};\n\n/**\n * What a light thread starts with: the work of every thread running beside it, then the separator that tells the\n * model that work is not its own.\n */\nexport const snapshot = (siblings: readonly Thread[], self: string): string =>\n [\n ...siblings.map(render),\n '',\n siblings.length === 1\n ? 'The thread above is a separate request that is still running in parallel with this one.'\n : 'The threads above are separate requests that are still running in parallel with this one.',\n 'Their work is not yours: do not repeat, continue or answer it.',\n `You are thread ${self}. Answer only the request that follows.`,\n \"If it depends on a result one of those threads has not produced yet, call `thread_wait` with that thread's id;\",\n 'it returns once the thread ends, with what the thread did.',\n ].join('\\n');\n\n/**\n * One line of the latest state of a running thread, appended after the history when a turn starts.\n */\nexport const status = (thread: Thread): string => {\n const last = thread.entries.at(-1);\n const latest = last ? lines([last]).join(' ').replaceAll('\\n', ' ') : 'nothing yet';\n return `Thread ${thread.id}${thread.purpose ? ` (\"${thread.purpose}\")` : ''} is ${thread.status}; latest: ${cut(latest, TOOL_TEXT)}`;\n};\n"],"mappings":";;;;;;;;;;;;AAyBA,IAAa,eAAe;;AAG5B,IAAa,YAAY;;AAGzB,IAAa,aAAa;AAE1B,IAAM,OAAO,MAAc,QAAyB,KAAK,SAAS,MAAM,GAAG,KAAK,MAAM,GAAG,GAAG,EAAE,WAAW;AAEzG,IAAM,eAAe,UAAgD;CACnE,QAAQ,MAAM,MAAd;EACE,KAAK,QACH,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,SAAS,IAAI,IAAI,MAAM,KAAK,KAAK,GAAG,UAAU,IAAI,KAAA;EAC7E,KAAK,YACH,OAAO,UAAU,MAAM,KAAK,GAAG,IAAI,MAAM,OAAA,GAAgB,EAAE;EAC7D,KAAK,cACH,OAAO,IAAI,MAAM,KAAK,aAAa,IACjC,OAAO,MAAM,WAAW,WACpB,MAAM,SACN,MAAM,WAAW,KAAA,IACf,aACA,KAAK,UAAU,MAAM,MAAM,GAAA,G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AC,KAAK,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG,IAAI;CACtE,OAAO,UAAU,OAAO,KAAK,OAAO,UAAU,MAAM,OAAO,QAAQ,MAAM,GAAG,MAAM,OAAO,OAAO,YAAY,IAAI,QAAA,GAAiB;AACnI"}
@@ -1,4 +1,4 @@
1
- import { j as make } from "./chunk-Operation.mjs";
1
+ import { K as make } from "./chunk-Operation.mjs";
2
2
  import * as Schema from "effect/Schema";
3
3
  import { DXN } from "@dxos/keys";
4
4
  //#region src/testing/definitions.ts
@@ -44,6 +44,8 @@ var FunctionNotFoundError = class extends BaseError.extend("FunctionNotFound", "
44
44
  };
45
45
  var FunctionError = class extends BaseError.extend("FunctionError", "Function invocation error") {};
46
46
  var InvalidOperationInputError = class extends BaseError.extend("InvalidOperationInput", "Operation input did not match schema") {};
47
+ /** An operation declared requirements that the invoking process's guard did not admit, or the process holds no guard. */
48
+ var OperationDeniedError = class extends BaseError.extend("OperationDeniedError", "Operation denied") {};
47
49
  var InvalidOperationOutputError = class extends BaseError.extend("InvalidOperationOutput", "Operation output did not match schema") {};
48
50
  var TriggerStateNotFoundError = class extends BaseError.extend("TriggerStateNotFound", "Trigger state not found") {};
49
51
  /** A manual run was asked of a trigger that is switched off; nothing was dispatched. */
@@ -72,6 +74,6 @@ var FunctionsAiUpstreamError = class extends BaseError.extend("FunctionsAiUpstre
72
74
  */
73
75
  var FunctionsAiMemoizationMissError = class extends BaseError.extend("FunctionsAiMemoizationMissError", "No memoized AI conversation found for the given cache key") {};
74
76
  //#endregion
75
- export { FunctionError, FunctionNotFoundError, FunctionsAiMemoizationMissError, FunctionsAiUpstreamError, InvalidOperationInputError, InvalidOperationOutputError, InvokerNotInitializedError, NoHandlerError, RUN_AGAIN_ERROR_CODE, RUN_AGAIN_MESSAGE, RunAgainError, ServiceNotAvailableError, TriggerDisabledError, TriggerNotResettableError, TriggerStateNotFoundError };
77
+ export { FunctionError, FunctionNotFoundError, FunctionsAiMemoizationMissError, FunctionsAiUpstreamError, InvalidOperationInputError, InvalidOperationOutputError, InvokerNotInitializedError, NoHandlerError, OperationDeniedError, RUN_AGAIN_ERROR_CODE, RUN_AGAIN_MESSAGE, RunAgainError, ServiceNotAvailableError, TriggerDisabledError, TriggerNotResettableError, TriggerStateNotFoundError };
76
78
 
77
79
  //# sourceMappingURL=errors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../../src/errors.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\n\n/**\n * Stable code (error name) for {@link RunAgainError}. Exported so trace consumers can recognize a\n * run-again yield from a persisted `operation.end` event via its `errorCode` field, without matching\n * on the human-readable message.\n */\nexport const RUN_AGAIN_ERROR_CODE = 'RunAgainError';\n\n/**\n * Message carried by {@link RunAgainError}. Exported for backward compatibility: `operation.end`\n * events persisted before {@link RUN_AGAIN_ERROR_CODE} existed carry only this message, so trace\n * consumers fall back to it when `errorCode` is absent.\n */\nexport const RUN_AGAIN_MESSAGE = 'Run again';\n\n/**\n * Raised when a function wants to yield to the scheduler to not exceed platform limits.\n * The scheduler will re-run the function after the yield.\n * It is assumed that the function can be retried with the same input.\n * The function might have produced side-effects on the first run.\n */\nexport class RunAgainError extends BaseError.extend(RUN_AGAIN_ERROR_CODE, RUN_AGAIN_MESSAGE) {}\n\n// Errors from @dxos/operation.\n\nexport class InvokerNotInitializedError extends BaseError.extend(\n 'InvokerNotInitializedError',\n 'Invoker not initialized',\n) {}\n\nexport class NoHandlerError extends BaseError.extend('NoHandlerError', 'No handler found for operation. ') {\n constructor(operationKey: string) {\n super({ context: { operationKey } });\n }\n}\n\n// Errors from @dxos/functions.\n\nexport class ServiceNotAvailableError extends BaseError.extend('ServiceNotAvailable', 'Service not available') {\n constructor(service: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { service }, message: `Service not available: ${service}`, ...options });\n }\n}\n\nexport class FunctionNotFoundError extends BaseError.extend('FunctionNotFound', 'Function not found') {\n constructor(functionKey: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { function: functionKey }, ...options });\n }\n}\n\nexport class FunctionError extends BaseError.extend('FunctionError', 'Function invocation error') {}\n\nexport class InvalidOperationInputError extends BaseError.extend(\n 'InvalidOperationInput',\n 'Operation input did not match schema',\n) {}\n\nexport class InvalidOperationOutputError extends BaseError.extend(\n 'InvalidOperationOutput',\n 'Operation output did not match schema',\n) {}\n\nexport class TriggerStateNotFoundError extends BaseError.extend('TriggerStateNotFound', 'Trigger state not found') {}\n\n/** A manual run was asked of a trigger that is switched off; nothing was dispatched. */\nexport class TriggerDisabledError extends BaseError.extend('TriggerDisabledError', 'Trigger is disabled') {\n constructor(triggerId: string) {\n super({ context: { triggerId } });\n }\n}\n\n/** A reset was asked of a trigger that has no feed cursor to rewind (only feed triggers do). */\nexport class TriggerNotResettableError extends BaseError.extend(\n 'TriggerNotResettableError',\n 'Only feed triggers can be reset',\n) {\n constructor(triggerId: string) {\n super({ context: { triggerId } });\n }\n}\n\n/**\n * Raised when the upstream AI gateway responds with a structured JSON error envelope\n * (`{ \"type\": \"error\", \"error\": { \"type\": ..., \"message\": ... } }`). Surfaces as a typed\n * defect from `FunctionsAiHttpClient`, bypassing `@effect/ai`'s generic `HttpResponseError`\n * wrapping so callers can match on the error class directly.\n */\nexport class FunctionsAiUpstreamError extends BaseError.extend(\n 'FunctionsAiUpstreamError',\n 'Upstream AI service returned an error',\n) {}\n\n/**\n * Specialized `FunctionsAiUpstreamError` for the memoization layer: the recorded fixture for a\n * given cache key was not found and `DX_UPDATE_MODEL_FIXTURES` is unset. The `cacheKey` is exposed\n * via `context.cacheKey` to make regeneration straightforward.\n */\nexport class FunctionsAiMemoizationMissError extends BaseError.extend(\n 'FunctionsAiMemoizationMissError',\n 'No memoized AI conversation found for the given cache key',\n) {}\n"],"mappings":";;;;;;;AAWA,IAAa,uBAAuB;;;;;;AAOpC,IAAa,oBAAoB;;;;;;;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;;;;;AAQA,IAAa,2BAAb,cAA8C,UAAU,OACtD,4BACA,uCACF,CAAC,CAAC,CAAC;;;;;;AAOH,IAAa,kCAAb,cAAqD,UAAU,OAC7D,mCACA,2DACF,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../../src/errors.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\n\n/**\n * Stable code (error name) for {@link RunAgainError}. Exported so trace consumers can recognize a\n * run-again yield from a persisted `operation.end` event via its `errorCode` field, without matching\n * on the human-readable message.\n */\nexport const RUN_AGAIN_ERROR_CODE = 'RunAgainError';\n\n/**\n * Message carried by {@link RunAgainError}. Exported for backward compatibility: `operation.end`\n * events persisted before {@link RUN_AGAIN_ERROR_CODE} existed carry only this message, so trace\n * consumers fall back to it when `errorCode` is absent.\n */\nexport const RUN_AGAIN_MESSAGE = 'Run again';\n\n/**\n * Raised when a function wants to yield to the scheduler to not exceed platform limits.\n * The scheduler will re-run the function after the yield.\n * It is assumed that the function can be retried with the same input.\n * The function might have produced side-effects on the first run.\n */\nexport class RunAgainError extends BaseError.extend(RUN_AGAIN_ERROR_CODE, RUN_AGAIN_MESSAGE) {}\n\n// Errors from @dxos/operation.\n\nexport class InvokerNotInitializedError extends BaseError.extend(\n 'InvokerNotInitializedError',\n 'Invoker not initialized',\n) {}\n\nexport class NoHandlerError extends BaseError.extend('NoHandlerError', 'No handler found for operation. ') {\n constructor(operationKey: string) {\n super({ context: { operationKey } });\n }\n}\n\n// Errors from @dxos/functions.\n\nexport class ServiceNotAvailableError extends BaseError.extend('ServiceNotAvailable', 'Service not available') {\n constructor(service: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { service }, message: `Service not available: ${service}`, ...options });\n }\n}\n\nexport class FunctionNotFoundError extends BaseError.extend('FunctionNotFound', 'Function not found') {\n constructor(functionKey: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { function: functionKey }, ...options });\n }\n}\n\nexport class FunctionError extends BaseError.extend('FunctionError', 'Function invocation error') {}\n\nexport class InvalidOperationInputError extends BaseError.extend(\n 'InvalidOperationInput',\n 'Operation input did not match schema',\n) {}\n\n/** An operation declared requirements that the invoking process's guard did not admit, or the process holds no guard. */\nexport class OperationDeniedError extends BaseError.extend('OperationDeniedError', 'Operation denied') {}\n\nexport class InvalidOperationOutputError extends BaseError.extend(\n 'InvalidOperationOutput',\n 'Operation output did not match schema',\n) {}\n\nexport class TriggerStateNotFoundError extends BaseError.extend('TriggerStateNotFound', 'Trigger state not found') {}\n\n/** A manual run was asked of a trigger that is switched off; nothing was dispatched. */\nexport class TriggerDisabledError extends BaseError.extend('TriggerDisabledError', 'Trigger is disabled') {\n constructor(triggerId: string) {\n super({ context: { triggerId } });\n }\n}\n\n/** A reset was asked of a trigger that has no feed cursor to rewind (only feed triggers do). */\nexport class TriggerNotResettableError extends BaseError.extend(\n 'TriggerNotResettableError',\n 'Only feed triggers can be reset',\n) {\n constructor(triggerId: string) {\n super({ context: { triggerId } });\n }\n}\n\n/**\n * Raised when the upstream AI gateway responds with a structured JSON error envelope\n * (`{ \"type\": \"error\", \"error\": { \"type\": ..., \"message\": ... } }`). Surfaces as a typed\n * defect from `FunctionsAiHttpClient`, bypassing `@effect/ai`'s generic `HttpResponseError`\n * wrapping so callers can match on the error class directly.\n */\nexport class FunctionsAiUpstreamError extends BaseError.extend(\n 'FunctionsAiUpstreamError',\n 'Upstream AI service returned an error',\n) {}\n\n/**\n * Specialized `FunctionsAiUpstreamError` for the memoization layer: the recorded fixture for a\n * given cache key was not found and `DX_UPDATE_MODEL_FIXTURES` is unset. The `cacheKey` is exposed\n * via `context.cacheKey` to make regeneration straightforward.\n */\nexport class FunctionsAiMemoizationMissError extends BaseError.extend(\n 'FunctionsAiMemoizationMissError',\n 'No memoized AI conversation found for the given cache key',\n) {}\n"],"mappings":";;;;;;;AAWA,IAAa,uBAAuB;;;;;;AAOpC,IAA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,CAAC,CAAC;CACA,YAAY,WAAmB;EAC7B,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;CAClC;AACF;;;;;;;AAQA,IAAa,2BAAb,cAA8C,UAAU,OACtD,4BACA,uCACF,CAAC,CAAC,CAAC;;;;;;AAOH,IAAa,kCAAb,cAAqD,UAAU,OAC7D,mCACA,2DACF,CAAC,CAAC,CAAC"}
@@ -1,27 +1,33 @@
1
1
  import { t as FunctionsAiError_exports } from "./chunk-FunctionsAiError.mjs";
2
- import { n as McpServer_exports } from "./chunk-McpServer.mjs";
3
- import { u as Operation_exports } from "./chunk-Operation.mjs";
2
+ import { d as Operation_exports } from "./chunk-Operation.mjs";
4
3
  import { i as Template_exports } from "./chunk-Template.mjs";
4
+ import { i as Skill_exports } from "./chunk-Skill.mjs";
5
+ import { P as Trajectory_exports } from "./chunk-Trajectory.mjs";
6
+ import { i as Transcript_exports } from "./chunk-Transcript.mjs";
7
+ import { t as Reducer_exports } from "./chunk-Reducer.mjs";
8
+ import { r as Instructions_exports } from "./chunk-Instructions.mjs";
5
9
  import { n as Runnable_exports } from "./chunk-Runnable.mjs";
6
10
  import { f as Trigger_exports } from "./chunk-Trigger.mjs";
7
- import { o as Skill_exports } from "./chunk-Skill.mjs";
8
- import { r as Instructions_exports } from "./chunk-Instructions.mjs";
9
11
  import { r as Routine_exports } from "./chunk-Routine.mjs";
10
- import { r as Project_exports } from "./chunk-Project.mjs";
12
+ import { n as Spec_exports } from "./chunk-Spec.mjs";
13
+ import { i as Project_exports } from "./chunk-Project.mjs";
11
14
  import { n as Script_exports } from "./chunk-Script.mjs";
15
+ import { r as SpecReview_exports } from "./chunk-SpecReview.mjs";
12
16
  import { c as TriggerEvent_exports } from "./chunk-TriggerEvent.mjs";
13
17
  import { n as AgentIdentity_exports } from "./chunk-AgentIdentity.mjs";
18
+ import { F as Trace_exports } from "./chunk-Trace.mjs";
19
+ import { t as AiMetering_exports } from "./chunk-AiMetering.mjs";
14
20
  import { n as AgentService_exports } from "./chunk-AgentService.mjs";
15
21
  import { t as Cancellation_exports } from "./chunk-Cancellation.mjs";
16
22
  import { n as Credential_exports } from "./chunk-Credential.mjs";
17
23
  import { t as Header_exports } from "./chunk-Header.mjs";
24
+ import { t as Hook_exports } from "./chunk-Hook.mjs";
18
25
  import { t as LayerSpec_exports } from "./chunk-LayerSpec.mjs";
19
26
  import { n as OperationHandlerSet_exports } from "./chunk-OperationHandlerSet.mjs";
20
27
  import { t as OperationRegistry_exports } from "./chunk-OperationRegistry.mjs";
21
- import { O as Trace_exports } from "./chunk-Trace.mjs";
22
- import { s as Process_exports } from "./chunk-Process.mjs";
28
+ import { c as Process_exports } from "./chunk-Process.mjs";
23
29
  import { n as ServiceResolver_exports } from "./chunk-ServiceResolver.mjs";
24
30
  import { r as ShellService_exports } from "./chunk-ShellService.mjs";
25
31
  import { r as SqlService_exports } from "./chunk-SqlService.mjs";
26
32
  import { n as StorageService_exports } from "./chunk-StorageService.mjs";
27
- export { AgentIdentity_exports as AgentIdentity, AgentService_exports as AgentService, Cancellation_exports as Cancellation, Credential_exports as Credential, FunctionsAiError_exports as FunctionsAiError, Header_exports as Header, Instructions_exports as Instructions, LayerSpec_exports as LayerSpec, McpServer_exports as McpServer, Operation_exports as Operation, OperationHandlerSet_exports as OperationHandlerSet, OperationRegistry_exports as OperationRegistry, Process_exports as Process, Project_exports as Project, Routine_exports as Routine, Runnable_exports as Runnable, Script_exports as Script, ServiceResolver_exports as ServiceResolver, ShellService_exports as ShellService, Skill_exports as Skill, SqlService_exports as SqlService, StorageService_exports as StorageService, Template_exports as Template, Trace_exports as Trace, Trigger_exports as Trigger, TriggerEvent_exports as TriggerEvent };
33
+ export { AgentIdentity_exports as AgentIdentity, AgentService_exports as AgentService, AiMetering_exports as AiMetering, Cancellation_exports as Cancellation, Credential_exports as Credential, FunctionsAiError_exports as FunctionsAiError, Header_exports as Header, Hook_exports as Hook, Instructions_exports as Instructions, LayerSpec_exports as LayerSpec, Operation_exports as Operation, OperationHandlerSet_exports as OperationHandlerSet, OperationRegistry_exports as OperationRegistry, Process_exports as Process, Project_exports as Project, Reducer_exports as Reducer, Routine_exports as Routine, Runnable_exports as Runnable, Script_exports as Script, ServiceResolver_exports as ServiceResolver, ShellService_exports as ShellService, Skill_exports as Skill, Spec_exports as Spec, SpecReview_exports as SpecReview, SqlService_exports as SqlService, StorageService_exports as StorageService, Template_exports as Template, Trace_exports as Trace, Trajectory_exports as Trajectory, Transcript_exports as Transcript, Trigger_exports as Trigger, TriggerEvent_exports as TriggerEvent };
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
- import { A as lazyHandler, p as Service, q as withHandler } from "./chunk-Operation.mjs";
2
+ import { G as lazyHandler, ft as withHandler, x as Service } from "./chunk-Operation.mjs";
3
+ import { B as flatten, P as TraceSink, Z as testTraceService } from "./chunk-Trace.mjs";
3
4
  import { l as lazy } from "./chunk-OperationHandlerSet.mjs";
4
- import { D as TraceSink, N as flatten, W as testTraceService } from "./chunk-Trace.mjs";
5
5
  import { n as Reply, r as Sleep, t as Fibonacci } from "./chunk-definitions.mjs";
6
6
  import * as Effect from "effect/Effect";
7
7
  import * as Context from "effect/Context";
@@ -0,0 +1 @@
1
+ export { n as prompt, r as promptFor, i as run, a as session, o as thread } from "../chunk-Reducer.mjs";
@@ -0,0 +1 @@
1
+ export { t as AlarmCancel, n as AlarmFire, r as AlarmSet, i as Compact, a as ContextBind, o as ContextUnbind, s as Custom, c as Event, l as EventId, u as Fork, d as HookBegin, f as HookEnd, p as HookKind, m as MergeMode, h as Message, g as ModelChange, _ as Payload, v as PromptCancel, y as PromptConsume, b as RequestResolve, x as Rewind, S as Role, C as Sender, w as ThreadClose, T as ThreadId, E as ThreadMerge, D as ThreadMode, O as ThreadOpen, k as ThreadOrigin, A as ThreadStatus, j as ThreadWait, M as ToolBackground, N as ToolDeliver, F as TurnBegin, I as TurnEnd, L as Usage, R as is, z as make, B as threadOf } from "../chunk-Trajectory.mjs";
@@ -0,0 +1 @@
1
+ export { t as BLOCK_TEXT, n as TAIL_ENTRIES, r as TOOL_TEXT, a as lines, o as render, s as snapshot, c as status } from "../chunk-Transcript.mjs";
@@ -1 +1 @@
1
- export { t as Project, n as ProjectStatus, i as addRoutine, a as contextBindings, o as make } from "../chunk-Project.mjs";
1
+ export { t as Project, n as ProjectStatus, r as ProjectStatusOptions, a as addRoutine, o as contextBindings, s as getOwner, c as make } from "../chunk-Project.mjs";
@@ -1 +1 @@
1
- export { t as Hook, n as HookSpec, r as McpPromptAnnotation, i as NotFoundError, a as Skill, s as SkillsAnnotation, c as annotatedSkillKeys, l as annotatedSkillRefs, u as getKey, d as getVersion, f as isMcpPrompt, p as make, m as makeRef, h as registryURI, g as resolve, _ as resolveAnnotatedSkills, v as toolDefinitions, y as upsert } from "../chunk-Skill.mjs";
1
+ export { t as McpPromptAnnotation, n as NotFoundError, r as Skill, a as SkillsAnnotation, o as annotatedSkillKeys, s as annotatedSkillRefs, c as getKey, l as getVersion, u as isMcpPrompt, d as make, f as makeRef, p as registryURI, m as resolve, h as resolveAnnotatedSkills, g as toolDefinitions, _ as upsert } from "../chunk-Skill.mjs";
@@ -0,0 +1 @@
1
+ export { t as Spec, r as instanceOf, i as make } from "../chunk-Spec.mjs";
@@ -0,0 +1 @@
1
+ export { t as ReviewsAnnotation, n as SpecReview, i as Verdict, a as VerdictStatus, o as WalkthroughStep, s as byNewest, c as instanceOf, l as make, u as query, d as sameReview } from "../chunk-SpecReview.mjs";
@@ -8,6 +8,7 @@ import { DXN } from '@dxos/keys';
8
8
  import type { ContentBlock } from '@dxos/types';
9
9
  import type * as Process from './Process.ts';
10
10
  import type * as Trace from './Trace.ts';
11
+ import type * as Trajectory from './trajectory/Trajectory.ts';
11
12
  import { Instructions } from './types/index.ts';
12
13
  /**
13
14
  * Structural view of the `Chat` object (`@dxos/assistant/Chat`): the durable conversation an agent
@@ -53,6 +54,8 @@ export type PromptSender = {
53
54
  export type SubmitPromptOptions = {
54
55
  /** Recorded on the appended user message; a named sender is shown to the model as the speaker. */
55
56
  readonly sender?: PromptSender;
57
+ /** The fork to send the prompt into; main when absent. */
58
+ readonly thread?: Trajectory.ThreadId;
56
59
  };
57
60
  /**
58
61
  * Handle to an agent session.
@@ -115,6 +118,12 @@ export interface GetSessionOptions {
115
118
  * @default 'local'
116
119
  */
117
120
  readonly location?: AgentLocation;
121
+ /**
122
+ * Admits the operations the agent and its tool calls invoke that declare requirements
123
+ * (`Process.SpawnOptions.guard`). Bound at spawn, so a session asked for with a different guard
124
+ * runs on a fresh process. A guard is a closure and never reaches an `edge` process.
125
+ */
126
+ readonly guard?: Process.Guard;
118
127
  }
119
128
  export type AgentLocation = 'local' | 'edge';
120
129
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"AgentService.d.ts","sourceRoot":"","sources":["../../../src/AgentService.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,KAAK,OAAO,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,YAAa,SAAQ,GAAG,CAAC,OAAO;IAC/C,QAAQ,CAAC,IAAI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Trace from './Trace.ts';
4
+ /**
5
+ * An `AiService` that writes a {@link Trace.ModelCall} event for every language-model call made
6
+ * through the `AiService` below it, so a run's token usage (and, with catalog prices, its cost) can
7
+ * be read back from its trace. Lives here rather than in `@dxos/ai`, which cannot depend on the trace.
8
+ */
9
+ export declare const metered: Layer.Layer<AiService.AiService, never, AiService.AiService | Trace.TraceService>;
10
+ /** Token and dollar totals for one model (and stage), as {@link summarize} reports them. */
11
+ export type Total = AiUsage.Tokens & {
12
+ readonly model: string;
13
+ readonly stage?: string;
14
+ readonly calls: number;
15
+ /** USD at the catalog's list price; undefined when the catalog has no price for the model. */
16
+ readonly cost?: number;
17
+ };
18
+ /**
19
+ * Totals of the {@link Trace.ModelCall} events among `events`, one per model and stage, priced from
20
+ * the model catalog.
21
+ */
22
+ export declare const summarize: (events: Iterable<Trace.Event>) => Total[];
23
+ //# sourceMappingURL=AiMetering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiMetering.d.ts","sourceRoot":"","sources":["../../../src/AiMetering.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,CA2BrG,CAAC;AAEF,4FAA4F;AAC5F,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,WAAY,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAG,KAAK,EA+B9D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AiMetering.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AiMetering.test.d.ts","sourceRoot":"","sources":["../../../src/AiMetering.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,84 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import { Annotation, Obj } from '@dxos/echo';
3
+ import type * as Operation from './Operation.ts';
4
+ /**
5
+ * A lifecycle hook an agent host can run, contributed by a plugin beside its skills rather than declared on a
6
+ * {@link Skill}, so a skill stays to the Agent Skills spec's fields. Static: a hook is code, never stored in a
7
+ * space. Whether it runs is up to its plugin's {@link SettingsAnnotation} entry (see {@link resolve}).
8
+ */
9
+ export type Definition = {
10
+ /** Stable id the trace names the hook by, e.g. `org.dxos.hook.planning.planReminder`. */
11
+ key: string;
12
+ /** Id of the plugin that contributes the hook; settings turn hooks on and off by plugin. */
13
+ plugin: string;
14
+ /**
15
+ * When the hook fires. `end-request` is after the model has driven a request to completion: the
16
+ * series of agent/tool turns a prompt starts.
17
+ */
18
+ event: 'end-request';
19
+ /** Key of a skill that must be bound to the conversation for the hook to fire; absent ⇒ every conversation. */
20
+ skill?: string;
21
+ /** Runs with the conversation in its environment; may return {@link Output}. */
22
+ operation: Operation.Definition.Any;
23
+ /** Passed as the operation's input. */
24
+ input?: Record<string, unknown>;
25
+ /**
26
+ * Run in the background: the request settles without waiting for the hook, and the agent process
27
+ * awaits it before it finishes. For work the user should not wait on, e.g. reviewing the turn that
28
+ * just ended.
29
+ */
30
+ async?: boolean;
31
+ };
32
+ /**
33
+ * What a hook returns. A `followUp` is queued to the agent as a synthetic prompt, so the request
34
+ * continues instead of ending — e.g. a reminder that the plan still has open tasks.
35
+ */
36
+ export declare const Output: Schema.Struct<{
37
+ readonly followUp: Schema.optional<Schema.String>;
38
+ }>;
39
+ export type Output = Schema.Schema.Type<typeof Output>;
40
+ /** A hook as a plugin declares it; the plugin adds its id when it contributes the hook ({@link forPlugin}). */
41
+ export type Declaration = Omit<Definition, 'plugin'>;
42
+ /** `hooks` as `plugin` contributes them. */
43
+ export declare const forPlugin: (plugin: string, hooks: readonly Declaration[]) => Definition[];
44
+ /** Plugin ids whose hooks are turned on (`true`) or off (`false`); a plugin not listed has its default. */
45
+ export type Settings = Readonly<Record<string, boolean>>;
46
+ /**
47
+ * Which plugins' hooks run, on a space's properties (for every agent in the space, wherever it runs) and on an
48
+ * agent's instructions (for runs with those instructions, overriding the space plugin by plugin).
49
+ */
50
+ export declare const SettingsAnnotation: Annotation.Annotation<{
51
+ readonly [x: string]: boolean;
52
+ }>;
53
+ /** Turns `plugin`'s hooks on or off in `target`'s settings (a space's properties or an agent's instructions). */
54
+ export declare const setEnabled: (target: Obj.Unknown, plugin: string, enabled: boolean) => void;
55
+ /**
56
+ * Whether `plugin`'s hooks run when no setting names it: only if every one of them is gated by a skill, so a
57
+ * host that has every plugin (EDGE) runs nothing a conversation did not opt into by binding the skill.
58
+ */
59
+ export declare const isOnByDefault: (catalog: readonly Definition[], plugin: string) => boolean;
60
+ /** The hooks one request runs, and what the trace records about the rest. */
61
+ export type Resolution = {
62
+ /** On, available on this host, and their skill condition holds. */
63
+ run: Definition[];
64
+ /** Keys of the hooks in `run` that are on by their plugin's default rather than a setting. */
65
+ byDefault: string[];
66
+ /** Keys of hooks a setting turns on whose skill is not bound. */
67
+ inactive: string[];
68
+ /** Plugins a setting turns on that contribute no hook on this host (e.g. not enabled here). */
69
+ missing: string[];
70
+ };
71
+ /**
72
+ * The hooks for `event` whose plugin `space` and `instructions` leave on, given the skills bound to the
73
+ * conversation. Hooks run in catalog order.
74
+ */
75
+ export declare const resolve: ({ catalog, event, space, instructions, skillKeys, }: {
76
+ catalog: readonly Definition[];
77
+ event: Definition['event'];
78
+ space?: Settings;
79
+ instructions?: Settings;
80
+ skillKeys: ReadonlySet<string>;
81
+ }) => Resolution;
82
+ /** The follow-up a hook's output asks for; anything else, including no output, asks for none. */
83
+ export declare const followUp: (output: unknown) => string | undefined;
84
+ //# sourceMappingURL=Hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hook.d.ts","sourceRoot":"","sources":["../../../src/Hook.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,yFAAyF;IACzF,GAAG,EAAE,MAAM,CAAC;IAEZ,4FAA4F;IAC5F,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,KAAK,EAAE,aAAa,CAAC;IAErB,+GAA+G;IAC/G,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,gFAAgF;IAChF,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;IAEpC,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEhC;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,MAAM;;EAEjB,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,MAAM,CAAC,CAAC;AAEvD,+GAA+G;AAC/G,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAErD,4CAA4C;AAC5C,eAAO,MAAM,SAAS,WAAY,MAAM,SAAS,SAAS,WAAW,EAAE,KAAG,UAAU,EACxC,CAAC;AAE7C,2GAA2G;AAC3G,MAAM,MAAM,Q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