@ouispec/agent-worker 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +175 -0
  3. package/dist/approvals/client.d.ts +29 -0
  4. package/dist/approvals/client.d.ts.map +1 -0
  5. package/dist/approvals/client.js +50 -0
  6. package/dist/approvals/client.js.map +1 -0
  7. package/dist/approvals/continuation.d.ts +28 -0
  8. package/dist/approvals/continuation.d.ts.map +1 -0
  9. package/dist/approvals/continuation.js +43 -0
  10. package/dist/approvals/continuation.js.map +1 -0
  11. package/dist/approvals/preview.d.ts +15 -0
  12. package/dist/approvals/preview.d.ts.map +1 -0
  13. package/dist/approvals/preview.js +33 -0
  14. package/dist/approvals/preview.js.map +1 -0
  15. package/dist/approvals/requirement.d.ts +15 -0
  16. package/dist/approvals/requirement.d.ts.map +1 -0
  17. package/dist/approvals/requirement.js +26 -0
  18. package/dist/approvals/requirement.js.map +1 -0
  19. package/dist/authz/tool-policy.d.ts +63 -0
  20. package/dist/authz/tool-policy.d.ts.map +1 -0
  21. package/dist/authz/tool-policy.js +23 -0
  22. package/dist/authz/tool-policy.js.map +1 -0
  23. package/dist/container/server.d.ts +24 -0
  24. package/dist/container/server.d.ts.map +1 -0
  25. package/dist/container/server.js +119 -0
  26. package/dist/container/server.js.map +1 -0
  27. package/dist/emit/http-adapter.d.ts +15 -0
  28. package/dist/emit/http-adapter.d.ts.map +1 -0
  29. package/dist/emit/http-adapter.js +35 -0
  30. package/dist/emit/http-adapter.js.map +1 -0
  31. package/dist/emit/types.d.ts +9 -0
  32. package/dist/emit/types.d.ts.map +1 -0
  33. package/dist/emit/types.js +7 -0
  34. package/dist/emit/types.js.map +1 -0
  35. package/dist/events/http-waiter.d.ts +19 -0
  36. package/dist/events/http-waiter.d.ts.map +1 -0
  37. package/dist/events/http-waiter.js +20 -0
  38. package/dist/events/http-waiter.js.map +1 -0
  39. package/dist/index.d.ts +60 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +45 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/lambda/handler.d.ts +38 -0
  44. package/dist/lambda/handler.d.ts.map +1 -0
  45. package/dist/lambda/handler.js +26 -0
  46. package/dist/lambda/handler.js.map +1 -0
  47. package/dist/model.d.ts +33 -0
  48. package/dist/model.d.ts.map +1 -0
  49. package/dist/model.js +15 -0
  50. package/dist/model.js.map +1 -0
  51. package/dist/openapi/document.d.ts +87 -0
  52. package/dist/openapi/document.d.ts.map +1 -0
  53. package/dist/openapi/document.js +117 -0
  54. package/dist/openapi/document.js.map +1 -0
  55. package/dist/openapi/executor.d.ts +51 -0
  56. package/dist/openapi/executor.d.ts.map +1 -0
  57. package/dist/openapi/executor.js +140 -0
  58. package/dist/openapi/executor.js.map +1 -0
  59. package/dist/openapi/index.d.ts +14 -0
  60. package/dist/openapi/index.d.ts.map +1 -0
  61. package/dist/openapi/index.js +9 -0
  62. package/dist/openapi/index.js.map +1 -0
  63. package/dist/openapi/loader.d.ts +81 -0
  64. package/dist/openapi/loader.d.ts.map +1 -0
  65. package/dist/openapi/loader.js +361 -0
  66. package/dist/openapi/loader.js.map +1 -0
  67. package/dist/openapi/x-agent.d.ts +34 -0
  68. package/dist/openapi/x-agent.d.ts.map +1 -0
  69. package/dist/openapi/x-agent.js +102 -0
  70. package/dist/openapi/x-agent.js.map +1 -0
  71. package/dist/orchestrator.d.ts +12 -0
  72. package/dist/orchestrator.d.ts.map +1 -0
  73. package/dist/orchestrator.js +1019 -0
  74. package/dist/orchestrator.js.map +1 -0
  75. package/dist/prompt/builder.d.ts +29 -0
  76. package/dist/prompt/builder.d.ts.map +1 -0
  77. package/dist/prompt/builder.js +129 -0
  78. package/dist/prompt/builder.js.map +1 -0
  79. package/dist/prompt/index.d.ts +15 -0
  80. package/dist/prompt/index.d.ts.map +1 -0
  81. package/dist/prompt/index.js +13 -0
  82. package/dist/prompt/index.js.map +1 -0
  83. package/dist/prompt/rules/base.d.ts +6 -0
  84. package/dist/prompt/rules/base.d.ts.map +1 -0
  85. package/dist/prompt/rules/base.js +38 -0
  86. package/dist/prompt/rules/base.js.map +1 -0
  87. package/dist/prompt/rules/communication.d.ts +7 -0
  88. package/dist/prompt/rules/communication.d.ts.map +1 -0
  89. package/dist/prompt/rules/communication.js +53 -0
  90. package/dist/prompt/rules/communication.js.map +1 -0
  91. package/dist/prompt/rules/tool-strategy.d.ts +6 -0
  92. package/dist/prompt/rules/tool-strategy.d.ts.map +1 -0
  93. package/dist/prompt/rules/tool-strategy.js +42 -0
  94. package/dist/prompt/rules/tool-strategy.js.map +1 -0
  95. package/dist/prompt/rules/ui-control.d.ts +10 -0
  96. package/dist/prompt/rules/ui-control.d.ts.map +1 -0
  97. package/dist/prompt/rules/ui-control.js +44 -0
  98. package/dist/prompt/rules/ui-control.js.map +1 -0
  99. package/dist/prompt/types.d.ts +85 -0
  100. package/dist/prompt/types.d.ts.map +1 -0
  101. package/dist/prompt/types.js +10 -0
  102. package/dist/prompt/types.js.map +1 -0
  103. package/dist/realtime/long-poll.d.ts +21 -0
  104. package/dist/realtime/long-poll.d.ts.map +1 -0
  105. package/dist/realtime/long-poll.js +36 -0
  106. package/dist/realtime/long-poll.js.map +1 -0
  107. package/dist/runtime/config.d.ts +4 -0
  108. package/dist/runtime/config.d.ts.map +1 -0
  109. package/dist/runtime/config.js +29 -0
  110. package/dist/runtime/config.js.map +1 -0
  111. package/dist/runtime/turn-runner.d.ts +32 -0
  112. package/dist/runtime/turn-runner.d.ts.map +1 -0
  113. package/dist/runtime/turn-runner.js +216 -0
  114. package/dist/runtime/turn-runner.js.map +1 -0
  115. package/dist/runtime/types.d.ts +244 -0
  116. package/dist/runtime/types.d.ts.map +1 -0
  117. package/dist/runtime/types.js +2 -0
  118. package/dist/runtime/types.js.map +1 -0
  119. package/dist/testing/desk-events.d.ts +12 -0
  120. package/dist/testing/desk-events.d.ts.map +1 -0
  121. package/dist/testing/desk-events.js +62 -0
  122. package/dist/testing/desk-events.js.map +1 -0
  123. package/dist/testing/index.d.ts +8 -0
  124. package/dist/testing/index.d.ts.map +1 -0
  125. package/dist/testing/index.js +7 -0
  126. package/dist/testing/index.js.map +1 -0
  127. package/dist/testing/openapi-fixture.d.ts +47 -0
  128. package/dist/testing/openapi-fixture.d.ts.map +1 -0
  129. package/dist/testing/openapi-fixture.js +370 -0
  130. package/dist/testing/openapi-fixture.js.map +1 -0
  131. package/dist/tools/async-binding.d.ts +71 -0
  132. package/dist/tools/async-binding.d.ts.map +1 -0
  133. package/dist/tools/async-binding.js +104 -0
  134. package/dist/tools/async-binding.js.map +1 -0
  135. package/dist/tools/builtin-tools.d.ts +20 -0
  136. package/dist/tools/builtin-tools.d.ts.map +1 -0
  137. package/dist/tools/builtin-tools.js +108 -0
  138. package/dist/tools/builtin-tools.js.map +1 -0
  139. package/dist/tools/entity-tools.d.ts +6 -0
  140. package/dist/tools/entity-tools.d.ts.map +1 -0
  141. package/dist/tools/entity-tools.js +227 -0
  142. package/dist/tools/entity-tools.js.map +1 -0
  143. package/dist/tools/input-validation.d.ts +16 -0
  144. package/dist/tools/input-validation.d.ts.map +1 -0
  145. package/dist/tools/input-validation.js +75 -0
  146. package/dist/tools/input-validation.js.map +1 -0
  147. package/dist/tools/load-all-tools.d.ts +12 -0
  148. package/dist/tools/load-all-tools.d.ts.map +1 -0
  149. package/dist/tools/load-all-tools.js +42 -0
  150. package/dist/tools/load-all-tools.js.map +1 -0
  151. package/dist/tools/schema-loader.d.ts +24 -0
  152. package/dist/tools/schema-loader.d.ts.map +1 -0
  153. package/dist/tools/schema-loader.js +267 -0
  154. package/dist/tools/schema-loader.js.map +1 -0
  155. package/dist/tools/types.d.ts +85 -0
  156. package/dist/tools/types.d.ts.map +1 -0
  157. package/dist/tools/types.js +22 -0
  158. package/dist/tools/types.js.map +1 -0
  159. package/dist/turn-policy.d.ts +68 -0
  160. package/dist/turn-policy.d.ts.map +1 -0
  161. package/dist/turn-policy.js +21 -0
  162. package/dist/turn-policy.js.map +1 -0
  163. package/dist/types.d.ts +151 -0
  164. package/dist/types.d.ts.map +1 -0
  165. package/dist/types.js +2 -0
  166. package/dist/types.js.map +1 -0
  167. package/dist/ui/channel.d.ts +64 -0
  168. package/dist/ui/channel.d.ts.map +1 -0
  169. package/dist/ui/channel.js +81 -0
  170. package/dist/ui/channel.js.map +1 -0
  171. package/dist/ui/knowledge.d.ts +30 -0
  172. package/dist/ui/knowledge.d.ts.map +1 -0
  173. package/dist/ui/knowledge.js +66 -0
  174. package/dist/ui/knowledge.js.map +1 -0
  175. package/dist/ui/observations.d.ts +41 -0
  176. package/dist/ui/observations.d.ts.map +1 -0
  177. package/dist/ui/observations.js +236 -0
  178. package/dist/ui/observations.js.map +1 -0
  179. package/dist/ui/snapshot.d.ts +33 -0
  180. package/dist/ui/snapshot.d.ts.map +1 -0
  181. package/dist/ui/snapshot.js +75 -0
  182. package/dist/ui/snapshot.js.map +1 -0
  183. package/dist/ui/ui-sequence.d.ts +75 -0
  184. package/dist/ui/ui-sequence.d.ts.map +1 -0
  185. package/dist/ui/ui-sequence.js +73 -0
  186. package/dist/ui/ui-sequence.js.map +1 -0
  187. package/dist/ui/ui-tools.d.ts +59 -0
  188. package/dist/ui/ui-tools.d.ts.map +1 -0
  189. package/dist/ui/ui-tools.js +244 -0
  190. package/dist/ui/ui-tools.js.map +1 -0
  191. package/package.json +78 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Async tools bound to declared events (W9, ADR-0227 §2.4).
3
+ *
4
+ * A tool whose work outlives its call (a GPU job, an export) names the
5
+ * declared completion it waits on, and optionally its failure and the field
6
+ * its dispatch returns the job's id in. `bindAsyncTool` checks all of it
7
+ * against the product's declarations when the tools load; `awaitAsyncTool`
8
+ * waits for the job to settle when the tool runs. Intent tools use both
9
+ * (schema-loader.ts), and so do tools generated from any other source, such
10
+ * as an OpenAPI operation's async binding.
11
+ */
12
+ import type { ToolExecutionResult } from './types.js';
13
+ import { type AsyncBinding, type EventCatalog, type EventWaiter } from '@ouispec/agent-events';
14
+ export interface AsyncToolSpec {
15
+ /** Who is binding, for errors: `intent 'generate-image'`, `operation POST /reports/export`. */
16
+ usedBy: string;
17
+ /** The declared completion the tool waits on. */
18
+ completion: string;
19
+ /** Its declared failure. Default: the one the declarations pair with the completion. */
20
+ failure?: string;
21
+ /** The field the dispatch returns the job's id in. Default: the completion's correlation field. */
22
+ correlation?: string;
23
+ timeoutMs: number;
24
+ /**
25
+ * Fields for the model, each read from the completion's payload with a
26
+ * `${ event.path }` expression. Default: the completion's declared result.
27
+ */
28
+ resultMapping?: Readonly<Record<string, string>>;
29
+ /** What the mapping is called where it is written, for errors. Default `resultMapping`. */
30
+ mappingLabel?: string;
31
+ }
32
+ export interface BoundAsyncTool {
33
+ binding: AsyncBinding;
34
+ timeoutMs: number;
35
+ /** Target field → path in the completion's payload; null for the declared result. */
36
+ fields: Readonly<Record<string, string>> | null;
37
+ }
38
+ /** How the job the tool started ended, as the model is told. */
39
+ export type AsyncToolSettlement = {
40
+ status: 'complete';
41
+ fields: Record<string, unknown>;
42
+ } | {
43
+ status: 'failed';
44
+ reason: string;
45
+ } | {
46
+ status: 'dispatched';
47
+ warning: string;
48
+ };
49
+ /** Check an async tool against the declarations, or throw naming the tool and what is wrong. */
50
+ export declare function bindAsyncTool(events: EventCatalog, spec: AsyncToolSpec): BoundAsyncTool;
51
+ /**
52
+ * Wait for the job `id` names to settle, and say how it ended. Never throws:
53
+ * a wait that could not happen, or did not end in time, is `dispatched` with
54
+ * the reason, so the model keeps the job id and knows the job may still run.
55
+ */
56
+ export declare function awaitAsyncTool(events: EventCatalog, waiter: EventWaiter, bound: BoundAsyncTool, id: unknown, signal?: AbortSignal): Promise<AsyncToolSettlement>;
57
+ /**
58
+ * A wait's timeout as written in a declaration: `60s`, `2m`. Absent: `fallbackMs`
59
+ * (60 s). Anything else fails the load, naming who wrote it and where.
60
+ */
61
+ export declare function parseWaitTimeout(usedBy: string, where: string, timeout: unknown, fallbackMs?: number): number;
62
+ /**
63
+ * What an async tool returns once its wait ends, for every kind of async tool:
64
+ * - complete: the dispatch with the completion's fields, `status: 'complete'`;
65
+ * - failed: a failed call with the declared reason, and the dispatch with `status: 'failed'`;
66
+ * - dispatched: the job may still be running, so the model keeps the dispatch
67
+ * (`onDispatched`, default the dispatch) and is told why the wait ended. The
68
+ * call itself did not fail, so it is not retried.
69
+ */
70
+ export declare function asyncToolResult(dispatch: Readonly<Record<string, unknown>>, settled: AsyncToolSettlement, onDispatched?: Readonly<Record<string, unknown>>): ToolExecutionResult;
71
+ //# sourceMappingURL=async-binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-binding.d.ts","sourceRoot":"","sources":["../../src/tools/async-binding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,aAAa;IAC5B,+FAA+F;IAC/F,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mGAAmG;IACnG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,YAAY,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;CACjD;AAED,gEAAgE;AAChE,MAAM,MAAM,mBAAmB,GAC3B;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACvD;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAI9C,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,GAAG,cAAc,CAmCvF;AAMD;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,cAAc,EACrB,EAAE,EAAE,OAAO,EACX,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAwB9B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,SAAS,GAAG,MAAM,CAM7G;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC3C,OAAO,EAAE,mBAAmB,EAC5B,YAAY,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAY,GACzD,mBAAmB,CASrB"}
@@ -0,0 +1,104 @@
1
+ import { payloadShape, } from '@ouispec/agent-events';
2
+ const TEMPLATE = /^\$\{\s*(\w+)\.([^}]+?)\s*\}$/;
3
+ /** Check an async tool against the declarations, or throw naming the tool and what is wrong. */
4
+ export function bindAsyncTool(events, spec) {
5
+ const binding = events.asyncBinding({
6
+ usedBy: spec.usedBy,
7
+ completion: spec.completion,
8
+ ...(spec.failure !== undefined ? { failure: spec.failure } : {}),
9
+ ...(spec.correlation !== undefined ? { correlation: spec.correlation } : {}),
10
+ });
11
+ const label = spec.mappingLabel ?? 'resultMapping';
12
+ if (!Number.isFinite(spec.timeoutMs) || spec.timeoutMs <= 0) {
13
+ throw new Error(`[agent-sdk] ${spec.usedBy}: its wait needs a positive timeout, got ${spec.timeoutMs}`);
14
+ }
15
+ if (!spec.resultMapping)
16
+ return { binding, timeoutMs: spec.timeoutMs, fields: null };
17
+ const completion = events.require(spec.completion, spec.usedBy);
18
+ const carried = [...payloadShape(completion.payload, completion.defs).properties.keys()];
19
+ const fields = {};
20
+ for (const [target, expression] of Object.entries(spec.resultMapping)) {
21
+ if (target === 'status') {
22
+ throw new Error(`[agent-sdk] ${spec.usedBy}: ${label} maps 'status', which the SDK sets to how the job ended`);
23
+ }
24
+ const template = TEMPLATE.exec(String(expression));
25
+ if (!template || template[1] !== 'event') {
26
+ throw new Error(`[agent-sdk] ${spec.usedBy}: ${label}.${target} reads '${expression}'; a subscribe mapping reads the completion, so it must be \${ event.… }`);
27
+ }
28
+ const path = template[2];
29
+ if (!carried.includes(path.split('.')[0])) {
30
+ throw new Error(`[agent-sdk] ${spec.usedBy}: ${label}.${target} reads '${expression}', and ${completion.name} carries no '${path.split('.')[0]}' (it carries: ${carried.join(', ')})`);
31
+ }
32
+ fields[target] = path;
33
+ }
34
+ return { binding, timeoutMs: spec.timeoutMs, fields };
35
+ }
36
+ function getByPath(obj, path) {
37
+ return path.split('.').reduce((acc, key) => (acc && typeof acc === 'object' ? acc[key] : undefined), obj);
38
+ }
39
+ /**
40
+ * Wait for the job `id` names to settle, and say how it ended. Never throws:
41
+ * a wait that could not happen, or did not end in time, is `dispatched` with
42
+ * the reason, so the model keeps the job id and knows the job may still run.
43
+ */
44
+ export async function awaitAsyncTool(events, waiter, bound, id, signal) {
45
+ const { binding, timeoutMs } = bound;
46
+ if (typeof id !== 'string' || id.length === 0) {
47
+ return { status: 'dispatched', warning: `The dispatch returned no '${binding.correlation}', so its ${binding.completion} cannot be waited on.` };
48
+ }
49
+ let settlement;
50
+ try {
51
+ settlement = await waiter.waitForSettlement({ binding, id, timeoutMs, ...(signal ? { signal } : {}) });
52
+ }
53
+ catch (err) {
54
+ return { status: 'dispatched', warning: `Waiting for ${binding.completion} failed: ${err instanceof Error ? err.message : String(err)}` };
55
+ }
56
+ if (!settlement || settlement.kind !== binding.kind || settlement.id !== id) {
57
+ const missing = binding.failure ? `Neither ${binding.completion} nor ${binding.failure} arrived` : `${binding.completion} did not arrive`;
58
+ return {
59
+ status: 'dispatched',
60
+ warning: `${missing} for ${binding.correlation} ${id} within ${Math.round(timeoutMs / 1000)}s: the job is still running.`,
61
+ };
62
+ }
63
+ const outcome = events.outcome(settlement);
64
+ if (outcome.status === 'failed')
65
+ return { status: 'failed', reason: outcome.reason };
66
+ if (!bound.fields)
67
+ return { status: 'complete', fields: { ...outcome.result } };
68
+ const fields = {};
69
+ for (const [target, path] of Object.entries(bound.fields))
70
+ fields[target] = getByPath(settlement.payload, path);
71
+ return { status: 'complete', fields };
72
+ }
73
+ /**
74
+ * A wait's timeout as written in a declaration: `60s`, `2m`. Absent: `fallbackMs`
75
+ * (60 s). Anything else fails the load, naming who wrote it and where.
76
+ */
77
+ export function parseWaitTimeout(usedBy, where, timeout, fallbackMs = 60_000) {
78
+ if (timeout === undefined)
79
+ return fallbackMs;
80
+ const match = typeof timeout === 'string' ? /^(\d+)(s|m)$/.exec(timeout) : null;
81
+ if (!match)
82
+ throw new Error(`[agent-sdk] ${usedBy}: ${where} '${String(timeout)}' is not a duration like 60s or 2m`);
83
+ const [, num, unit] = match;
84
+ return unit === 'm' ? parseInt(num, 10) * 60_000 : parseInt(num, 10) * 1_000;
85
+ }
86
+ /**
87
+ * What an async tool returns once its wait ends, for every kind of async tool:
88
+ * - complete: the dispatch with the completion's fields, `status: 'complete'`;
89
+ * - failed: a failed call with the declared reason, and the dispatch with `status: 'failed'`;
90
+ * - dispatched: the job may still be running, so the model keeps the dispatch
91
+ * (`onDispatched`, default the dispatch) and is told why the wait ended. The
92
+ * call itself did not fail, so it is not retried.
93
+ */
94
+ export function asyncToolResult(dispatch, settled, onDispatched = dispatch) {
95
+ switch (settled.status) {
96
+ case 'complete':
97
+ return { success: true, data: { ...dispatch, ...settled.fields, status: 'complete' } };
98
+ case 'failed':
99
+ return { success: false, error: settled.reason, data: { ...dispatch, status: 'failed' } };
100
+ case 'dispatched':
101
+ return { success: true, data: { ...onDispatched, status: 'dispatched', warning: settled.warning } };
102
+ }
103
+ }
104
+ //# sourceMappingURL=async-binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-binding.js","sourceRoot":"","sources":["../../src/tools/async-binding.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,YAAY,GAIb,MAAM,uBAAuB,CAAC;AAkC/B,MAAM,QAAQ,GAAG,+BAA+B,CAAC;AAEjD,gGAAgG;AAChG,MAAM,UAAU,aAAa,CAAC,MAAoB,EAAE,IAAmB;IACrE,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC;QAClC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7E,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,IAAI,eAAe,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,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AAC;QACzF,KAAK,QAAQ;YACX,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;QAC5F,KAAK,YAAY;YACf,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;IACxG,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Built-in SDK tools — interaction tools that every platform gets for free.
3
+ * These are SDK-owned (contract §2) and generated, not hand-authored by the host.
4
+ *
5
+ * Interaction tools return `{ __present_options: true, ... }` which the client
6
+ * SDK handles natively to present choices to the user.
7
+ *
8
+ * UI control tools (navigate_to, fill_form, submit_form, trigger_action,
9
+ * show_toast, control_player, open_entity, highlight_entity) were removed per
10
+ * ADR-0137 — they used the deprecated CustomEvent dispatch pattern that nothing
11
+ * handles. Navigation and UI control is now exclusively handled by OUI surfaces
12
+ * registered by the client app at runtime.
13
+ */
14
+ import type { RegisteredTool } from './types.js';
15
+ /**
16
+ * Generate the built-in interaction tools.
17
+ * These are the same tools every platform needs — present options, confirm, request decision.
18
+ */
19
+ export declare function loadBuiltinTools(): RegisteredTool[];
20
+ //# sourceMappingURL=builtin-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtin-tools.d.ts","sourceRoot":"","sources":["../../src/tools/builtin-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,cAAc,EAAE,CAEnD"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Generate the built-in interaction tools.
3
+ * These are the same tools every platform needs — present options, confirm, request decision.
4
+ */
5
+ export function loadBuiltinTools() {
6
+ return loadInteractionTools();
7
+ }
8
+ function loadInteractionTools() {
9
+ return [
10
+ {
11
+ name: 'present_options',
12
+ description: 'Present a set of options to the user as clickable choices. Use when the user needs to pick from a discrete set (e.g. which item to use, a style, a name). Returns the selected value.',
13
+ inputSchema: {
14
+ type: 'object',
15
+ properties: {
16
+ prompt: { type: 'string', description: 'Question or prompt for the user' },
17
+ options: {
18
+ type: 'array',
19
+ items: {
20
+ type: 'object',
21
+ properties: {
22
+ label: { type: 'string', description: 'Option label' },
23
+ value: { type: 'string', description: 'Option value (returned on selection)' },
24
+ description: { type: 'string', description: 'Optional description' },
25
+ },
26
+ required: ['label', 'value'],
27
+ },
28
+ },
29
+ style: { type: 'string', enum: ['buttons', 'list', 'cards'], description: 'Presentation style', default: 'buttons' },
30
+ allowCustom: { type: 'boolean', description: 'Allow custom user input', default: false },
31
+ },
32
+ required: ['prompt', 'options'],
33
+ },
34
+ async execute(input) {
35
+ return {
36
+ __present_options: true,
37
+ prompt: input.prompt,
38
+ options: input.options,
39
+ style: input.style ?? 'buttons',
40
+ ...(input.allowCustom ? { allowCustom: input.allowCustom } : {}),
41
+ };
42
+ },
43
+ },
44
+ {
45
+ name: 'confirm_action',
46
+ description: 'Ask the user a quick yes-or-no before something significant that needs no approval ("Ready to generate?"). ' +
47
+ 'Never use it for a tool marked "Needs the user\'s approval": call that tool directly, and its approval card asks. ' +
48
+ 'An answer here never approves anything. Returns true (confirmed) or false (cancelled).',
49
+ inputSchema: {
50
+ type: 'object',
51
+ properties: {
52
+ message: { type: 'string', description: 'What you are about to do' },
53
+ details: { type: 'string', description: 'Additional context about the consequences' },
54
+ confirmLabel: { type: 'string', description: 'Label for the confirm button', default: 'Confirm' },
55
+ cancelLabel: { type: 'string', description: 'Label for the cancel button', default: 'Cancel' },
56
+ },
57
+ required: ['message'],
58
+ },
59
+ async execute(input) {
60
+ return {
61
+ __present_options: true,
62
+ prompt: input.message,
63
+ options: [
64
+ { label: input.confirmLabel ?? 'Confirm', value: 'true' },
65
+ { label: input.cancelLabel ?? 'Cancel', value: 'false' },
66
+ ],
67
+ style: 'buttons',
68
+ };
69
+ },
70
+ },
71
+ {
72
+ name: 'request_user_decision',
73
+ description: 'Request a decision from the user when the agent needs direction (e.g. which approach to take, whether to proceed). More open-ended than present_options.',
74
+ inputSchema: {
75
+ type: 'object',
76
+ properties: {
77
+ question: { type: 'string', description: 'The question to ask' },
78
+ context: { type: 'string', description: 'Background context for the decision' },
79
+ options: {
80
+ type: 'array',
81
+ items: {
82
+ type: 'object',
83
+ properties: {
84
+ label: { type: 'string' },
85
+ value: { type: 'string' },
86
+ description: { type: 'string' },
87
+ },
88
+ required: ['label', 'value'],
89
+ },
90
+ description: 'Optional choices; if omitted, the user gives free-form input',
91
+ },
92
+ },
93
+ required: ['question'],
94
+ },
95
+ async execute(input) {
96
+ return {
97
+ __present_options: true,
98
+ prompt: input.question,
99
+ ...(input.context ? { context: input.context } : {}),
100
+ ...(input.options ? { options: input.options } : { options: [{ label: 'Proceed', value: 'proceed' }] }),
101
+ style: 'list',
102
+ allowCustom: true,
103
+ };
104
+ },
105
+ },
106
+ ];
107
+ }
108
+ //# sourceMappingURL=builtin-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtin-tools.js","sourceRoot":"","sources":["../../src/tools/builtin-tools.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,oBAAoB,EAAE,CAAC;AAChC,CAAC;AAED,SAAS,oBAAoB;IAC3B,OAAO;QACL;YACE,IAAI,EAAE,iBAAiB;YACvB,WAAW,EACT,uLAAuL;YACzL,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iCAAiC,EAAE;oBAC1E,OAAO,EAAE;wBACP,IAAI,EAAE,OAAO;wBACb,KAAK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,EAAE,QAAQ,EAAE;6BAChC;4BACD,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;yBAC7B;wBACD,WAAW,EAAE,8DAA8D;qBAC5E;iBACF;gBACD,QAAQ,EAAE,CAAC,UAAU,CAAC;aACvB;YACD,KAAK,CAAC,OAAO,CAAC,KAAK;gBACjB,OAAO;oBACL,iBAAiB,EAAE,IAAI;oBACvB,MAAM,EAAE,KAAK,CAAC,QAAQ;oBACtB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACpD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;oBACvG,KAAK,EAAE,MAAM;oBACb,WAAW,EAAE,IAAI;iBACuE,CAAC;YAC7F,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { RegisteredTool } from './types.js';
2
+ /**
3
+ * Load entity schemas and generate CRUD tools for each entity type.
4
+ */
5
+ export declare function loadEntityToolsFromSchema(schemasDir: string): Promise<RegisteredTool[]>;
6
+ //# sourceMappingURL=entity-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-tools.d.ts","sourceRoot":"","sources":["../../src/tools/entity-tools.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,YAAY,CAAC;AAGvE;;GAEG;AACH,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAS7F"}
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Entity CRUD tool generation — auto-generates list/get/create/update/delete
3
+ * tools for each entity type defined in the schema.
4
+ *
5
+ * Instead of hand-authoring `list_characters`, `get_character`, `create_character`,
6
+ * etc., the SDK generates them from `entities/*.yaml`. Each tool's `execute`
7
+ * calls the corresponding `AgentApiSurface` method:
8
+ * - list_<entity> → apiSurface.queryEntities(type, filter)
9
+ * - get_<entity> → apiSurface.getEntity(type, id)
10
+ * - create_<entity> → apiSurface.mutateEntity(type, id, { create: true, set })
11
+ * - update_<entity> → apiSurface.mutateEntity(type, id, { set })
12
+ * - delete_<entity> → apiSurface.mutateEntity(type, id, {}) with delete semantics
13
+ *
14
+ * @see docs/reference/integration-contract.md §1b
15
+ */
16
+ import { loadSchemas } from '@ouispec/agent-core';
17
+ /**
18
+ * Load entity schemas and generate CRUD tools for each entity type.
19
+ */
20
+ export async function loadEntityToolsFromSchema(schemasDir) {
21
+ const documents = await loadSchemas(schemasDir);
22
+ const entities = extractEntities(documents);
23
+ const tools = [];
24
+ for (const entity of entities) {
25
+ tools.push(...generateEntityCrudTools(entity));
26
+ }
27
+ return tools;
28
+ }
29
+ function extractEntities(documents) {
30
+ const entities = [];
31
+ const seen = new Set();
32
+ for (const doc of documents) {
33
+ if (doc.entity && !seen.has(doc.entity.id)) {
34
+ entities.push(doc.entity);
35
+ seen.add(doc.entity.id);
36
+ }
37
+ if (doc.domain?.entities) {
38
+ for (const e of doc.domain.entities) {
39
+ if (typeof e === 'object' && e !== null && 'id' in e) {
40
+ const ent = e;
41
+ if (!seen.has(ent.id)) {
42
+ entities.push(ent);
43
+ seen.add(ent.id);
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ return entities;
50
+ }
51
+ function generateEntityCrudTools(entity) {
52
+ const type = entity.id;
53
+ const lower = type.toLowerCase();
54
+ const plural = pluralize(lower);
55
+ const props = entity.properties ?? {};
56
+ return [
57
+ generateListTool(type, plural, entity),
58
+ generateGetTool(type, lower, entity),
59
+ generateCreateTool(type, lower, entity, props),
60
+ generateUpdateTool(type, lower, entity, props),
61
+ generateDeleteTool(type, lower, entity),
62
+ ];
63
+ }
64
+ function generateListTool(type, lower, entity) {
65
+ return {
66
+ name: `list-${lower}`,
67
+ description: `List ${entity.description ?? type + 's'} with optional filtering and search.`,
68
+ inputSchema: {
69
+ type: 'object',
70
+ properties: {
71
+ search: { type: 'string', description: 'Search by name/title' },
72
+ limit: { type: 'integer', description: 'Max results', default: 20 },
73
+ offset: { type: 'integer', description: 'Pagination offset', default: 0 },
74
+ },
75
+ additionalProperties: false,
76
+ },
77
+ async execute(input, ctx) {
78
+ const apiSurface = ctx.apiSurface;
79
+ if (!apiSurface)
80
+ return noSurfaceError(`list-${lower}`);
81
+ const filter = {};
82
+ if (input.search)
83
+ filter.search = input.search;
84
+ if (input.limit)
85
+ filter.limit = input.limit;
86
+ if (input.offset)
87
+ filter.offset = input.offset;
88
+ const results = await apiSurface.queryEntities(type, filter);
89
+ return { success: true, data: results };
90
+ },
91
+ };
92
+ }
93
+ function generateGetTool(type, lower, _entity) {
94
+ return {
95
+ name: `get-${lower}`,
96
+ description: `Get a single ${type} by ID.`,
97
+ inputSchema: {
98
+ type: 'object',
99
+ properties: {
100
+ id: { type: 'string', description: `The ${type} ID` },
101
+ },
102
+ required: ['id'],
103
+ additionalProperties: false,
104
+ },
105
+ async execute(input, ctx) {
106
+ const apiSurface = ctx.apiSurface;
107
+ if (!apiSurface)
108
+ return noSurfaceError(`get-${lower}`);
109
+ const result = await apiSurface.getEntity(type, input.id);
110
+ return { success: true, data: result };
111
+ },
112
+ };
113
+ }
114
+ function generateCreateTool(type, lower, entity, props) {
115
+ const { properties, required } = convertEntityProperties(props);
116
+ return {
117
+ name: `create-${lower}`,
118
+ description: `Create a new ${type}.`,
119
+ inputSchema: {
120
+ type: 'object',
121
+ properties,
122
+ ...(required.length ? { required } : {}),
123
+ additionalProperties: false,
124
+ },
125
+ async execute(input, ctx) {
126
+ const apiSurface = ctx.apiSurface;
127
+ if (!apiSurface)
128
+ return noSurfaceError(`create-${lower}`);
129
+ const result = await apiSurface.mutateEntity(type, '', { create: true, set: input });
130
+ return { success: true, data: result };
131
+ },
132
+ };
133
+ }
134
+ function generateUpdateTool(type, lower, entity, props) {
135
+ const { properties } = convertEntityProperties(props, true);
136
+ return {
137
+ name: `update-${lower}`,
138
+ description: `Update properties of an existing ${type}.`,
139
+ inputSchema: {
140
+ type: 'object',
141
+ properties: {
142
+ id: { type: 'string', description: `The ${type} ID to update` },
143
+ ...properties,
144
+ },
145
+ required: ['id'],
146
+ additionalProperties: false,
147
+ },
148
+ async execute(input, ctx) {
149
+ const apiSurface = ctx.apiSurface;
150
+ if (!apiSurface)
151
+ return noSurfaceError(`update-${lower}`);
152
+ const { id, ...set } = input;
153
+ const result = await apiSurface.mutateEntity(type, id, { set });
154
+ return { success: true, data: result };
155
+ },
156
+ };
157
+ }
158
+ function generateDeleteTool(type, lower, _entity) {
159
+ return {
160
+ name: `delete-${lower}`,
161
+ description: `Delete a ${type} by ID.`,
162
+ inputSchema: {
163
+ type: 'object',
164
+ properties: {
165
+ id: { type: 'string', description: `The ${type} ID to delete` },
166
+ },
167
+ required: ['id'],
168
+ additionalProperties: false,
169
+ },
170
+ async execute(input, ctx) {
171
+ const apiSurface = ctx.apiSurface;
172
+ if (!apiSurface)
173
+ return noSurfaceError(`delete-${lower}`);
174
+ // mutateEntity with disconnect signals deletion; hosts interpret accordingly
175
+ await apiSurface.mutateEntity(type, input.id, { disconnect: ['*'] });
176
+ return { success: true, data: { deleted: true, id: input.id } };
177
+ },
178
+ };
179
+ }
180
+ // ─── helpers ────────────────────────────────────────────────────────────────
181
+ function convertEntityProperties(props, allOptional = false) {
182
+ const properties = {};
183
+ const required = [];
184
+ for (const [name, prop] of Object.entries(props)) {
185
+ // Skip relation properties at the CRUD layer (they're managed via link/unlink)
186
+ if (prop.type === 'relation')
187
+ continue;
188
+ properties[name] = convertEntityProperty(prop);
189
+ if (prop.required && !allOptional) {
190
+ required.push(name);
191
+ }
192
+ }
193
+ return { properties, required };
194
+ }
195
+ function convertEntityProperty(prop) {
196
+ const schema = {};
197
+ if (prop.type === 'enum') {
198
+ schema.type = 'string';
199
+ if (prop.values)
200
+ schema.enum = prop.values;
201
+ }
202
+ else if (prop.type === 'array') {
203
+ schema.type = 'array';
204
+ if (prop.items)
205
+ schema.items = { type: prop.items.type };
206
+ }
207
+ else {
208
+ schema.type = prop.type;
209
+ }
210
+ if (prop.description)
211
+ schema.description = prop.description;
212
+ return schema;
213
+ }
214
+ function pluralize(word) {
215
+ if (word.endsWith('s') || word.endsWith('x') || word.endsWith('z'))
216
+ return word + 'es';
217
+ if (word.endsWith('y') && !'aeiou'.includes(word[word.length - 2]))
218
+ return word.slice(0, -1) + 'ies';
219
+ return word + 's';
220
+ }
221
+ function noSurfaceError(toolName) {
222
+ return {
223
+ success: false,
224
+ error: `Tool '${toolName}' requires an AgentApiSurface binding. Provide apiSurface in the worker config.`,
225
+ };
226
+ }
227
+ //# sourceMappingURL=entity-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-tools.js","sourceRoot":"","sources":["../../src/tools/entity-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKlD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,UAAkB;IAChE,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAE5C,MAAM,KAAK,GAAqB,EAAE,CAAC;IACnC,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,SAA8B;IACrD,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,M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AAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,GAAG,IAAI,CAAC;IACvF,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACrG,OAAO,IAAI,GAAG,GAAG,CAAC;AACpB,CAAC;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,SAAS,QAAQ,iFAAiF;KAC1G,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ export type ToolInputValidation = {
2
+ ok: true;
3
+ value: Record<string, unknown>;
4
+ } | {
5
+ ok: false;
6
+ errors: string[];
7
+ };
8
+ export type ToolInputValidator = (input: unknown) => ToolInputValidation;
9
+ /**
10
+ * Compile a validator for a tool's input schema.
11
+ *
12
+ * A schema that cannot be compiled yields a validator that rejects every call: a tool
13
+ * whose input cannot be checked does not run.
14
+ */
15
+ export declare function createToolInputValidator(inputSchema: Record<string, unknown> | undefined): ToolInputValidator;
16
+ //# sourceMappingURL=input-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-validation.d.ts","sourceRoot":"","sources":["../../src/tools/input-validation.ts"],"names":[],"mappings":"AA+BA,MAAM,MAAM,mBAAmB,GAC3B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAC5C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEpC,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,mBAAmB,CAAC;AAiBzE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC/C,kBAAkB,CA6BpB"}