@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,75 @@
1
+ /**
2
+ * Validate a tool call's input against the tool's declared input schema before it runs.
3
+ *
4
+ * The orchestrator hands tools to the model as raw JSON Schema (`jsonSchema(rawSchema)`),
5
+ * which carries no validator, and a tool call's arguments are whatever the model
6
+ * produced. Without this check a host's tool receives undeclared and mistyped fields:
7
+ * a generated entity update tool passed every key the model supplied straight to a
8
+ * database write.
9
+ *
10
+ * Validation is by the schema as declared. A tool that must refuse undeclared
11
+ * properties says so with `additionalProperties: false`, as the schema loader and the
12
+ * entity tool generator now do.
13
+ */
14
+ import { Ajv } from 'ajv';
15
+ import formatsPlugin from 'ajv-formats';
16
+ // ajv-formats is CommonJS; under ESM interop its function is on `default`.
17
+ const addFormats = formatsPlugin.default ??
18
+ formatsPlugin;
19
+ /**
20
+ * Top-level keys removed before compiling:
21
+ * - `sideEffects`: the SDK's own flag, stored on the input schema; not JSON Schema.
22
+ * - `$schema`: hosts emit different drafts (e.g. 2020-12 from zod); the keywords tools
23
+ * use are the same across them, and an unknown draft must not stop a tool working.
24
+ * - `$id`: two tools declaring the same id would collide in the compiler.
25
+ */
26
+ const NON_VALIDATION_KEYS = ['sideEffects', '$schema', '$id'];
27
+ const ajv = new Ajv({ allErrors: true, strict: false, useDefaults: false, coerceTypes: false });
28
+ addFormats(ajv);
29
+ function describeError(error) {
30
+ const at = error.instancePath || '(input)';
31
+ const params = error.params;
32
+ if (error.keyword === 'additionalProperties') {
33
+ return `${at} has a property this tool does not accept: "${String(params.additionalProperty)}"`;
34
+ }
35
+ if (error.keyword === 'required') {
36
+ return `${at} is missing required property "${String(params.missingProperty)}"`;
37
+ }
38
+ return `${at} ${error.message ?? 'is invalid'}`;
39
+ }
40
+ /**
41
+ * Compile a validator for a tool's input schema.
42
+ *
43
+ * A schema that cannot be compiled yields a validator that rejects every call: a tool
44
+ * whose input cannot be checked does not run.
45
+ */
46
+ export function createToolInputValidator(inputSchema) {
47
+ const schema = { ...(inputSchema ?? { type: 'object', properties: {} }) };
48
+ for (const key of NON_VALIDATION_KEYS)
49
+ delete schema[key];
50
+ let validate;
51
+ try {
52
+ validate = ajv.compile(schema);
53
+ }
54
+ catch (err) {
55
+ const reason = err instanceof Error ? err.message : String(err);
56
+ return () => ({ ok: false, errors: [`this tool's input schema is invalid (${reason})`] });
57
+ }
58
+ const required = new Set(Array.isArray(schema.required) ? schema.required.map(String) : []);
59
+ return (input) => {
60
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) {
61
+ return { ok: false, errors: ['(input) must be an object'] };
62
+ }
63
+ // Models often send null for an optional argument they mean to leave out.
64
+ const value = {};
65
+ for (const [key, entry] of Object.entries(input)) {
66
+ if (entry === null && !required.has(key))
67
+ continue;
68
+ value[key] = entry;
69
+ }
70
+ if (validate(value))
71
+ return { ok: true, value };
72
+ return { ok: false, errors: (validate.errors ?? []).map(describeError) };
73
+ };
74
+ }
75
+ //# sourceMappingURL=input-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-validation.js","sourceRoot":"","sources":["../../src/tools/input-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,GAAG,EAA2C,MAAM,KAAK,CAAC;AACnE,OAAO,aAAa,MAAM,aAAa,CAAC;AAGxC,2EAA2E;AAC3E,MAAM,UAAU,GACb,aAAwD,CAAC,OAAO;IAChE,aAA0C,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,CAAC,aAAa,EAAE,SAAS,EAAE,KAAK,CAAU,CAAC;AAQvE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;AAChG,UAAU,CAAC,GAAG,CAAC,CAAC;AAEhB,SAAS,aAAa,CAAC,KAAkB;IACvC,MAAM,EAAE,GAAG,KAAK,CAAC,YAAY,IAAI,SAAS,CAAC;IAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAiC,CAAC;IACvD,IAAI,KAAK,CAAC,OAAO,KAAK,sBAAsB,EAAE,CAAC;QAC7C,OAAO,GAAG,EAAE,+CAA+C,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC;IAClG,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,GAAG,EAAE,kCAAkC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC;IAClF,CAAC;IACD,OA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,GAA4B,EAAE,CAAC;QAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC5E,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,SAAS;YACnD,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACrB,CAAC;QACD,IAAI,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAChD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { RegisteredTool } from './types.js';
2
+ import type { LoadToolsOptions } from './schema-loader.js';
3
+ export interface LoadAllToolsOptions extends LoadToolsOptions {
4
+ /** Path to the schema directory (e.g. ./schemas/my-app/) */
5
+ schemasDir: string;
6
+ }
7
+ /**
8
+ * Generate the complete tool registry from schema + built-ins.
9
+ * This is the only tool-loading function a host worker should call.
10
+ */
11
+ export declare function loadAllTools(options: LoadAllToolsOptions): Promise<RegisteredTool[]>;
12
+ //# sourceMappingURL=load-all-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-all-tools.d.ts","sourceRoot":"","sources":["../../src/tools/load-all-tools.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAuB1F"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * loadAllTools — the single entry point for generating the complete tool
3
+ * registry from schema. Combines:
4
+ * 1. Intent tools (from intents/*.yaml) → apiSurface.executeIntent
5
+ * 2. Entity CRUD tools (from entities/*.yaml) → apiSurface.queryEntities/mutateEntity
6
+ * 3. Built-in interaction tools (SDK-owned, generic)
7
+ *
8
+ * This replaces hand-authored tool definitions entirely. The host provides
9
+ * schemas (generated by introspection) + an apiSurface binding; the SDK
10
+ * generates every tool.
11
+ *
12
+ * @see docs/reference/integration-contract.md §4
13
+ */
14
+ import { loadToolsFromSchema } from './schema-loader.js';
15
+ import { loadEntityToolsFromSchema } from './entity-tools.js';
16
+ import { loadBuiltinTools } from './builtin-tools.js';
17
+ /**
18
+ * Generate the complete tool registry from schema + built-ins.
19
+ * This is the only tool-loading function a host worker should call.
20
+ */
21
+ export async function loadAllTools(options) {
22
+ const [intentTools, entityTools] = await Promise.all([
23
+ loadToolsFromSchema(options.schemasDir, {
24
+ ...(options.events ? { events: options.events } : {}),
25
+ ...(options.waiter ? { waiter: options.waiter } : {}),
26
+ }),
27
+ loadEntityToolsFromSchema(options.schemasDir),
28
+ ]);
29
+ const builtinTools = loadBuiltinTools();
30
+ // Merge, deduping by name (entity CRUD may overlap with intent tools for
31
+ // entities that also have explicit intents like create-character)
32
+ const seen = new Set();
33
+ const all = [];
34
+ for (const tool of [...intentTools, ...entityTools, ...builtinTools]) {
35
+ if (!seen.has(tool.name)) {
36
+ seen.add(tool.name);
37
+ all.push(tool);
38
+ }
39
+ }
40
+ return all;
41
+ }
42
+ //# sourceMappingURL=load-all-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-all-tools.js","sourceRoot":"","sources":["../../src/tools/load-all-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAA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
3
+ export interface LoadToolsOptions {
4
+ /**
5
+ * The product's event declarations. Required when any intent waits
6
+ * (`execution.subscribe`): each names declared events, or the tools fail to
7
+ * load, naming the intent and the event.
8
+ */
9
+ events?: EventCatalog;
10
+ /**
11
+ * How an async intent waits for its job to settle
12
+ * (`createHttpEventWaiter`, or the host's own). Without it an async intent
13
+ * returns its dispatch at once, with the job id.
14
+ */
15
+ waiter?: EventWaiter;
16
+ }
17
+ /**
18
+ * Load intent schemas from a directory and compile them into RegisteredTool[].
19
+ *
20
+ * @param schemasDir Path to the schema directory (e.g. './schemas/my-app/')
21
+ * @param options Optional subscription adapter for async intent resolution
22
+ */
23
+ export declare function loadToolsFromSchema(schemasDir: string, options?: LoadToolsOptions): Promise<RegisteredTool[]>;
24
+ //# sourceMappingURL=schema-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-loader.d.ts","sourceRoot":"","sources":["../../src/tools/schema-loader.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGvE,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAWD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,cAAc,EAAE,CAAC,CAK3B"}
@@ -0,0 +1,267 @@
1
+ /**
2
+ * loadToolsFromSchema — generates a RegisteredTool[] from declarative intent
3
+ * schemas (intents/*.yaml). This is the schema-driven replacement for
4
+ * hand-authored tool definitions.
5
+ *
6
+ * Each generated tool's `execute` calls the host's AgentApiSurface binding
7
+ * (`ctx.apiSurface.executeIntent(intentId, params)`) — the host never writes
8
+ * a tool body. An async intent's `subscribe:` block names the declared events
9
+ * that settle its job (W9): they are checked against the product's event
10
+ * declarations when the tools load, and with a waiter the tool waits for the
11
+ * job to complete or fail.
12
+ *
13
+ * @see docs/reference/integration-contract.md §1b, §4
14
+ */
15
+ import { loadSchemas } from '@ouispec/agent-core';
16
+ import { asyncToolResult, awaitAsyncTool, bindAsyncTool, parseWaitTimeout } from './async-binding.js';
17
+ /**
18
+ * Load intent schemas from a directory and compile them into RegisteredTool[].
19
+ *
20
+ * @param schemasDir Path to the schema directory (e.g. './schemas/my-app/')
21
+ * @param options Optional subscription adapter for async intent resolution
22
+ */
23
+ export async function loadToolsFromSchema(schemasDir, options) {
24
+ const documents = await loadSchemas(schemasDir);
25
+ const intents = extractIntents(documents);
26
+ return intents.map((intent) => compileIntentToTool(intent, bindIntent(intent, options ?? {}), options?.waiter));
27
+ }
28
+ /**
29
+ * Bind an intent's `subscribe` block to the declarations, or throw naming the
30
+ * intent and what is wrong. Null for an intent that does not wait.
31
+ */
32
+ function bindIntent(intent, options) {
33
+ const sub = intent.execution?.subscribe;
34
+ if (!sub)
35
+ return null;
36
+ const usedBy = `intent '${intent.id}'`;
37
+ if (!options.events) {
38
+ throw new Error(`[agent-sdk] ${usedBy} waits on '${sub.event}', but no event declarations were given (LoadToolsOptions.events)`);
39
+ }
40
+ const filter = Object.entries(sub.filter ?? {});
41
+ if (filter.length !== 1) {
42
+ throw new Error(`[agent-sdk] ${usedBy}: subscribe.filter must name exactly one field, the job id of '${sub.event}' (it names ${filter.length})`);
43
+ }
44
+ const [[correlation, idFrom]] = filter;
45
+ const bound = bindAsyncTool(options.events, {
46
+ usedBy,
47
+ completion: sub.event,
48
+ ...(sub.failure !== undefined ? { failure: sub.failure } : {}),
49
+ correlation,
50
+ timeoutMs: parseWaitTimeout(usedBy, 'subscribe.timeout', sub.timeout),
51
+ ...(sub.resultMapping ? { resultMapping: sub.resultMapping } : {}),
52
+ mappingLabel: 'subscribe.resultMapping',
53
+ });
54
+ return { bound, idFrom, events: options.events, waiter: options.waiter };
55
+ }
56
+ /**
57
+ * Flatten all intent definitions from loaded schema documents.
58
+ * Intents appear either as top-level `doc.intent` or nested in
59
+ * `doc.domain.intents[]` (after $ref resolution).
60
+ */
61
+ function extractIntents(documents) {
62
+ const intents = [];
63
+ for (const doc of documents) {
64
+ if (doc.intent) {
65
+ intents.push(doc.intent);
66
+ }
67
+ if (doc.domain?.intents) {
68
+ for (const i of doc.domain.intents) {
69
+ if (typeof i === 'object' && i !== null && 'id' in i) {
70
+ intents.push(i);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ // Deduplicate by id (domain $ref + standalone file may overlap)
76
+ const seen = new Set();
77
+ return intents.filter((i) => {
78
+ if (seen.has(i.id))
79
+ return false;
80
+ seen.add(i.id);
81
+ return true;
82
+ });
83
+ }
84
+ /**
85
+ * Compile a single intent schema into a RegisteredTool.
86
+ */
87
+ function compileIntentToTool(intent, asyncIntent, waiter) {
88
+ const inputSchema = convertParameters(intent.parameters);
89
+ // Thread the sideEffects flag into the inputSchema so the orchestrator's
90
+ // quota check (`inputSchema.sideEffects !== false`) reads a real value
91
+ // instead of always getting `undefined` (which fail-closed to side-effecting).
92
+ if (intent.sideEffects === false) {
93
+ inputSchema.sideEffects = false;
94
+ }
95
+ return {
96
+ name: intent.id,
97
+ description: buildDescription(intent, !!(asyncIntent && waiter)),
98
+ inputSchema,
99
+ async execute(input, ctx) {
100
+ return executeIntent(intent, input, ctx, asyncIntent);
101
+ },
102
+ };
103
+ }
104
+ /**
105
+ * Build the tool description from the intent, enriching with async/duration
106
+ * hints so the LLM knows what to expect.
107
+ */
108
+ function buildDescription(intent, waits) {
109
+ let desc = intent.description;
110
+ if (intent.outcome?.async) {
111
+ desc += `\n\nAsync: returns a jobId. Estimated duration: ${intent.outcome.estimatedDuration ?? 'unknown'}.`;
112
+ // Promise the event only when the tool will actually wait for it.
113
+ if (waits && intent.execution?.subscribe) {
114
+ desc += ` The result arrives via the ${intent.execution.subscribe.event} realtime event.`;
115
+ }
116
+ }
117
+ if (intent.outcome?.produces) {
118
+ desc += `\nProduces: ${intent.outcome.produces}.`;
119
+ }
120
+ return desc;
121
+ }
122
+ /**
123
+ * Convert RawParameterSchema (YAML) into a JSON Schema object for the LLM.
124
+ * Entity-typed parameters become string references (the LLM passes an entity ID).
125
+ */
126
+ function convertParameters(parameters) {
127
+ const properties = {};
128
+ const required = [];
129
+ for (const [name, param] of Object.entries(parameters)) {
130
+ properties[name] = convertProperty(param);
131
+ if (param.required) {
132
+ required.push(name);
133
+ }
134
+ }
135
+ return {
136
+ type: 'object',
137
+ properties,
138
+ ...(required.length > 0 ? { required } : {}),
139
+ // An intent accepts exactly the parameters it declares. The orchestrator
140
+ // validates calls against this, so an undeclared argument never reaches the host.
141
+ additionalProperties: false,
142
+ };
143
+ }
144
+ function convertProperty(param) {
145
+ const schema = {};
146
+ // Entity-typed params are string IDs at the LLM layer
147
+ if (param.type === 'entity') {
148
+ schema.type = 'string';
149
+ if (param.entity) {
150
+ schema.description = param.description
151
+ ? `${param.description} (entity: ${param.entity} — pass the ID)`
152
+ : `Entity reference (${param.entity}) — pass the ID`;
153
+ }
154
+ }
155
+ else if (param.type === 'enum') {
156
+ schema.type = 'string';
157
+ if (param.values)
158
+ schema.enum = param.values;
159
+ }
160
+ else if (param.type === 'array') {
161
+ schema.type = 'array';
162
+ if (param.items)
163
+ schema.items = convertProperty(param.items);
164
+ }
165
+ else {
166
+ schema.type = param.type;
167
+ }
168
+ if (param.description && param.type !== 'entity') {
169
+ schema.description = param.description;
170
+ }
171
+ if (param.maxLength !== undefined)
172
+ schema.maxLength = param.maxLength;
173
+ if (param.minLength !== undefined)
174
+ schema.minLength = param.minLength;
175
+ if (param.default !== undefined)
176
+ schema.default = param.default;
177
+ return schema;
178
+ }
179
+ /**
180
+ * Execute an intent via the host's AgentApiSurface binding.
181
+ *
182
+ * This is the heart of the schema-driven model: the tool body is generated,
183
+ * not hand-authored. It calls `ctx.apiSurface.executeIntent(intentId, params)`
184
+ * — the host's binding decides whether that hits a REST route, a gateway
185
+ * inference endpoint, or anything else.
186
+ */
187
+ async function executeIntent(intent, input, ctx, asyncIntent) {
188
+ const apiSurface = ctx.apiSurface;
189
+ if (!apiSurface) {
190
+ return {
191
+ success: false,
192
+ error: `Intent '${intent.id}' requires an AgentApiSurface binding in the tool execution context. Provide apiSurface in the worker config.`,
193
+ };
194
+ }
195
+ let result;
196
+ try {
197
+ result = await apiSurface.executeIntent(intent.id, input);
198
+ }
199
+ catch (err) {
200
+ return {
201
+ success: false,
202
+ error: `Intent '${intent.id}' threw: ${err instanceof Error ? err.message : String(err)}`,
203
+ };
204
+ }
205
+ if (!result.success) {
206
+ return {
207
+ success: false,
208
+ error: result.error?.message ?? `Intent '${intent.id}' failed`,
209
+ data: result,
210
+ };
211
+ }
212
+ const exec = intent.execution;
213
+ const mapped = applyResultMapping(exec, result);
214
+ if (!result.async?.jobId || !asyncIntent?.waiter) {
215
+ // Sync intent, or async without a waiter: the dispatch, with clean field names.
216
+ return { success: true, data: mapped };
217
+ }
218
+ // Wait for the job to settle: its declared completion or failure.
219
+ const dispatchData = result.data ?? {};
220
+ const id = resolveTemplateString(String(asyncIntent.idFrom), { response: dispatchData });
221
+ const settled = await awaitAsyncTool(asyncIntent.events, asyncIntent.waiter, asyncIntent.bound, id, ctx.abortSignal);
222
+ return asyncToolResult(mapped, settled, { ...dispatchData, jobId: result.async.jobId });
223
+ }
224
+ /**
225
+ * Apply execution.resultMapping to the dispatch response so the LLM sees
226
+ * clean field names (jobId, imageId, status) rather than raw response shapes.
227
+ */
228
+ function applyResultMapping(exec, result) {
229
+ const base = {
230
+ ...(result.data ?? {}),
231
+ };
232
+ if (result.async) {
233
+ base.jobId = result.async.jobId;
234
+ base.status = result.async.jobId ? (result.data?.status ?? 'dispatched') : base.status;
235
+ }
236
+ if (exec?.resultMapping) {
237
+ const mapped = {};
238
+ const rMapping = exec.resultMapping;
239
+ for (const [target, sourceExpr] of Object.entries(rMapping)) {
240
+ const sourcePath = sourceExpr.replace(/\$\{\s*response\./, '').replace(/\s*\}/, '').trim();
241
+ mapped[target] = getByPath(base, sourcePath);
242
+ }
243
+ // Merge mapped fields over base so both raw + mapped are available
244
+ return { ...base, ...mapped };
245
+ }
246
+ return base;
247
+ }
248
+ // ─── template helpers ──────────────────────────────────────────────────────
249
+ function resolveTemplateString(str, ctx) {
250
+ const match = str.match(/^\$\{\s*(\w+)\.([^}]+?)\s*\}$/);
251
+ if (!match)
252
+ return str;
253
+ const [, ns, path] = match;
254
+ const root = ctx[ns];
255
+ if (root === undefined)
256
+ return undefined;
257
+ return getByPath(root, path);
258
+ }
259
+ function getByPath(obj, path) {
260
+ return path.split('.').reduce((acc, key) => {
261
+ if (acc && typeof acc === 'object') {
262
+ return acc[key];
263
+ }
264
+ return undefined;
265
+ }, obj);
266
+ }
267
+ //# sourceMappingURL=schema-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-loader.js","sourceRoot":"","sources":["../../src/tools/schema-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAclD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAuB,MAAM,oBAAoB,CAAC;AA0B3H;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAkB,EAClB,OAA0B;IAE1B,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAE1C,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAClH,CAAC;AAED;;;GAGG;AACH,SAAS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AAED,SAAS,SAAS,CAAC,GAA4B,EAAE,IAAY;IAC3D,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAU,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAClD,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAQ,GAA+B,CAAC,GAAG,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC"}
@@ -0,0 +1,85 @@
1
+ import type { ActionRequestApproval, AgentApiSurface } from '@ouispec/agent-core';
2
+ import type { EffectOrKind } from '@ouispec/bindings';
3
+ import type { UISlot } from '../ui/ui-sequence.js';
4
+ /**
5
+ * Tool registry — platforms register their tools here.
6
+ * The worker calls tools by name during the orchestration loop.
7
+ */
8
+ /**
9
+ * What a tool declares it does (ADR-0226 §2.6): a host or API tool's full
10
+ * effect, or, for a UI action, the effect kind its OUI surface carries.
11
+ */
12
+ export type ToolEffect = EffectOrKind;
13
+ export interface RegisteredTool {
14
+ name: string;
15
+ /**
16
+ * `ui`: an action on the client's UI, run as the user in their own session
17
+ * (ADR-0209). Bounded by the turn's round cap rather than the backend
18
+ * side-effect quota. Default `backend`.
19
+ */
20
+ kind?: 'ui' | 'backend';
21
+ /**
22
+ * What calling the tool changes (ADR-0226 §2.6). A tool that declares none is
23
+ * treated as a write. Approvals key on this and `destructive` (ADR-0228).
24
+ */
25
+ effect?: ToolEffect;
26
+ /** The call removes or replaces something the person made (ADR-0228). */
27
+ destructive?: boolean;
28
+ description: string;
29
+ inputSchema: Record<string, unknown>;
30
+ execute: (input: Record<string, unknown>, ctx: ToolExecutionContext) => Promise<ToolExecutionResult>;
31
+ /** Its name as a person reads it, for the approval card. Default: `name`. */
32
+ title?: string;
33
+ /** What running it does, for the approval card. Default: `description`. */
34
+ consequence?: string;
35
+ /**
36
+ * Whether its arguments are kept out of logs. Default true: an approval's
37
+ * arguments are logged only when its declaration says they are not sensitive.
38
+ */
39
+ argsSensitive?: boolean;
40
+ }
41
+ export interface ToolExecutionContext {
42
+ userId: string;
43
+ accountId: string;
44
+ turnId: string;
45
+ conversationId: string;
46
+ userToken?: string;
47
+ /**
48
+ * The host's AgentApiSurface binding. Schema-generated tools call
49
+ * `apiSurface.executeIntent(intentId, params)` instead of hand-rolled bodies.
50
+ * Optional only for tools that don't need host API access (e.g. pure UI actions).
51
+ */
52
+ apiSurface?: AgentApiSurface;
53
+ /** AbortSignal tied to the turn deadline — tools should observe this for cancellation. */
54
+ abortSignal?: AbortSignal;
55
+ /** The model's id for this call. UI tools use it as the OUI request id. */
56
+ toolCallId?: string;
57
+ /** The turn's realtime room, where the client that sent the turn listens. */
58
+ socketRoom?: string;
59
+ /**
60
+ * A UI tool's place in the turn's UI order, taken by the orchestrator when the
61
+ * model's call arrived (ui-sequence.ts). A UI tool runs its action in it.
62
+ */
63
+ uiSlot?: UISlot;
64
+ /**
65
+ * Set when the call is one the user approved (ADR-0228): a UI action's
66
+ * request carries it, and the browser runs the action only when it matches
67
+ * the grant from the user's own click.
68
+ */
69
+ approval?: ActionRequestApproval;
70
+ [key: string]: unknown;
71
+ }
72
+ export interface ToolExecutionResult {
73
+ success: boolean;
74
+ data?: unknown;
75
+ error?: string;
76
+ }
77
+ export interface ToolRegistry {
78
+ tools: RegisteredTool[];
79
+ execute(name: string, input: Record<string, unknown>, ctx: ToolExecutionContext): Promise<ToolExecutionResult>;
80
+ }
81
+ /**
82
+ * Creates a tool registry from a list of registered tools.
83
+ */
84
+ export declare function createToolRegistry(tools: RegisteredTool[]): ToolRegistry;
85
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,KAAK,EAAE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C,EAAE,qBAAqB,CAAC;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAChH;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,YAAY,CAiBxE"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Creates a tool registry from a list of registered tools.
3
+ */
4
+ export function createToolRegistry(tools) {
5
+ const toolMap = new Map(tools.map(t => [t.name, t]));
6
+ return {
7
+ tools,
8
+ async execute(name, input, ctx) {
9
+ const tool = toolMap.get(name);
10
+ if (!tool) {
11
+ return { success: false, error: `Unknown tool: ${name}` };
12
+ }
13
+ try {
14
+ return await tool.execute(input, ctx);
15
+ }
16
+ catch (err) {
17
+ return { success: false, error: err instanceof Error ? err.message : String(err) };
18
+ }
19
+ },
20
+ };
21
+ }
22
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAuFA;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAuB;IACxD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAErD,OAAO;QACL,KAAK;QACL,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,KAA8B,EAAE,GAAyB;YACnF,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,iBAAiB,IAAI,EAAE,EAAE,CAAC;YAC5D,CAAC;YACD,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACxC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACrF,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * TurnPolicy — controls per-step tool selection and constraints.
3
+ *
4
+ * Integrators provide their own policy to encode product-specific orchestration
5
+ * behavior (e.g. forced tool sequences for onboarding, navigation-first flows).
6
+ * The SDK provides a safe, product-neutral default.
7
+ *
8
+ * The policy is consulted at two points:
9
+ * 1. classifyTurn — called once at turn start to classify the user's intent
10
+ * 2. prepareStep — called before each LLM step to control tool selection
11
+ */
12
+ export interface TurnPolicy {
13
+ /**
14
+ * Classify the current turn to determine orchestration behavior.
15
+ * Returns a string label that `prepareStep` uses to apply constraints.
16
+ * The SDK does not interpret the label — it's opaque to the orchestrator.
17
+ */
18
+ classifyTurn(content: string, history?: Array<{
19
+ role: string;
20
+ content: string;
21
+ }>): string;
22
+ /**
23
+ * Called before each step to control tool selection.
24
+ * Returns overrides for toolChoice and activeTools, or empty object for no constraint.
25
+ */
26
+ prepareStep(ctx: {
27
+ steps: Array<{
28
+ toolCalls?: Array<{
29
+ toolName: string;
30
+ }>;
31
+ }>;
32
+ turnClass: string;
33
+ allToolNames: string[];
34
+ }): Promise<{
35
+ toolChoice?: 'auto' | 'none' | 'required' | {
36
+ type: 'tool';
37
+ toolName: string;
38
+ };
39
+ activeTools?: string[];
40
+ /**
41
+ * An instruction for this step only, added after the system prompt. Say why
42
+ * the step is constrained when the model cannot tell: a model made to hand
43
+ * back at a step limit, without being told, invents a reason (on dev: "I
44
+ * navigated away before filling in the text", about text it had filled).
45
+ */
46
+ note?: string;
47
+ }>;
48
+ /**
49
+ * Optional: called after turn classification to perform side effects
50
+ * (e.g. emitting deterministic navigation events).
51
+ * The SDK calls this if defined, passing the emit adapter and turn context.
52
+ */
53
+ onTurnClassified?: (ctx: {
54
+ turnClass: string;
55
+ content: string;
56
+ emit: {
57
+ emit: (room: string, event: string, data: unknown) => Promise<void>;
58
+ };
59
+ socketRoom: string;
60
+ }) => Promise<void>;
61
+ }
62
+ /**
63
+ * Default turn policy — product-neutral, safe defaults.
64
+ * No forced tool sequences, no product-specific constraints.
65
+ * The orchestrator's existing step count and token limits provide the safety net.
66
+ */
67
+ export declare const defaultTurnPolicy: TurnPolicy;
68
+ //# sourceMappingURL=turn-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-policy.d.ts","sourceRoot":"","sources":["../src/turn-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,YAAY,CACV,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,GACjD,MAAM,CAAC;IAEV;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE;QACf,KAAK,EAAE,KAAK,CAAC;YAAE,SAAS,CAAC,EAAE,KAAK,CAAC;gBAAE,QAAQ,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SAAE,CAAC,CAAC;QAC1D,SAAS,EAAE,MAAM,CAAC;Q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