@nextera.one/axis-server-sdk 2.2.0 → 2.2.2

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 (53) hide show
  1. package/dist/axis-sensor-GBEI3Fab.d.mts +209 -0
  2. package/dist/axis-sensor-GBEI3Fab.d.ts +209 -0
  3. package/dist/cce/index.d.mts +162 -0
  4. package/dist/cce/index.d.ts +162 -0
  5. package/dist/cce/index.js +1502 -0
  6. package/dist/cce/index.js.map +1 -0
  7. package/dist/cce/index.mjs +1442 -0
  8. package/dist/cce/index.mjs.map +1 -0
  9. package/dist/cce-pipeline-B-zUBHo3.d.mts +294 -0
  10. package/dist/cce-pipeline-DbGBSsCG.d.ts +294 -0
  11. package/dist/core/index.d.mts +23 -2
  12. package/dist/core/index.d.ts +23 -2
  13. package/dist/idel/index.d.mts +24 -0
  14. package/dist/idel/index.d.ts +24 -0
  15. package/dist/idel/index.js +306 -0
  16. package/dist/idel/index.js.map +1 -0
  17. package/dist/idel/index.mjs +279 -0
  18. package/dist/idel/index.mjs.map +1 -0
  19. package/dist/idel.types-DuUAcOnQ.d.mts +83 -0
  20. package/dist/idel.types-DuUAcOnQ.d.ts +83 -0
  21. package/dist/index-B2G6cbRL.d.mts +824 -0
  22. package/dist/index-DbSxdR0f.d.ts +824 -0
  23. package/dist/index-_S4fmVUJ.d.mts +501 -0
  24. package/dist/index-l3Hhirqb.d.ts +501 -0
  25. package/dist/index.d.mts +91 -3501
  26. package/dist/index.d.ts +91 -3501
  27. package/dist/index.js +5052 -4618
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +5018 -4597
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/needle/index.d.mts +4 -0
  32. package/dist/needle/index.d.ts +4 -0
  33. package/dist/needle/index.js +3499 -0
  34. package/dist/needle/index.js.map +1 -0
  35. package/dist/needle/index.mjs +3528 -0
  36. package/dist/needle/index.mjs.map +1 -0
  37. package/dist/sensors/index.d.mts +5 -0
  38. package/dist/sensors/index.d.ts +5 -0
  39. package/dist/sensors/index.js +12860 -0
  40. package/dist/sensors/index.js.map +1 -0
  41. package/dist/sensors/index.mjs +12928 -0
  42. package/dist/sensors/index.mjs.map +1 -0
  43. package/dist/timeline/index.d.mts +54 -0
  44. package/dist/timeline/index.d.ts +54 -0
  45. package/dist/timeline/index.js +389 -0
  46. package/dist/timeline/index.js.map +1 -0
  47. package/dist/timeline/index.mjs +362 -0
  48. package/dist/timeline/index.mjs.map +1 -0
  49. package/dist/timeline.types-Cn0aqbUj.d.mts +125 -0
  50. package/dist/timeline.types-Cn0aqbUj.d.ts +125 -0
  51. package/package.json +28 -10
  52. package/dist/index-VxXqZPuH.d.mts +0 -51
  53. package/dist/index-VxXqZPuH.d.ts +0 -51
@@ -0,0 +1,306 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/idel/index.ts
20
+ var idel_exports = {};
21
+ __export(idel_exports, {
22
+ IdelCompiler: () => IdelCompiler,
23
+ IdelSchemaRegistry: () => IdelSchemaRegistry
24
+ });
25
+ module.exports = __toCommonJS(idel_exports);
26
+
27
+ // src/idel/idel.compiler.ts
28
+ var IdelSchemaRegistry = class {
29
+ constructor() {
30
+ this.schemas = /* @__PURE__ */ new Map();
31
+ this.aliases = /* @__PURE__ */ new Map();
32
+ }
33
+ register(schema) {
34
+ this.schemas.set(schema.intent, schema);
35
+ }
36
+ registerAlias(alias, intent) {
37
+ this.aliases.set(alias.toLowerCase(), intent);
38
+ }
39
+ get(intent) {
40
+ return this.schemas.get(intent);
41
+ }
42
+ resolve(raw) {
43
+ const exact = this.schemas.get(raw);
44
+ if (exact) return exact;
45
+ const aliased = this.aliases.get(raw.toLowerCase());
46
+ if (aliased) return this.schemas.get(aliased);
47
+ const candidates = [...this.schemas.keys()].filter(
48
+ (k) => k.startsWith(raw + ".") || k.toLowerCase().includes(raw.toLowerCase())
49
+ );
50
+ if (candidates.length === 1) {
51
+ return this.schemas.get(candidates[0]);
52
+ }
53
+ return void 0;
54
+ }
55
+ /**
56
+ * Find all schemas that partially match the raw input.
57
+ * Returns scored candidates for ambiguity resolution.
58
+ */
59
+ findCandidates(raw) {
60
+ const normalized = raw.toLowerCase().trim();
61
+ const results = [];
62
+ for (const [key, schema] of this.schemas) {
63
+ let score = 0;
64
+ if (key === raw) {
65
+ score = 1;
66
+ } else if (key.toLowerCase() === normalized) {
67
+ score = 0.95;
68
+ } else if (this.aliases.get(normalized) === key) {
69
+ score = 0.9;
70
+ } else if (key.toLowerCase().startsWith(normalized)) {
71
+ score = 0.7;
72
+ } else if (key.toLowerCase().includes(normalized)) {
73
+ score = 0.5;
74
+ } else if (schema.tags?.some((t) => t.toLowerCase().includes(normalized))) {
75
+ score = 0.4;
76
+ } else if (schema.description.toLowerCase().includes(normalized)) {
77
+ score = 0.3;
78
+ }
79
+ if (score > 0) {
80
+ results.push({ schema, score });
81
+ }
82
+ }
83
+ return results.sort((a, b) => b.score - a.score);
84
+ }
85
+ list() {
86
+ return [...this.schemas.values()];
87
+ }
88
+ };
89
+ var IdelCompiler = class {
90
+ constructor(registry) {
91
+ this.registry = registry;
92
+ }
93
+ /**
94
+ * Compile a raw intent proposal into a validated, executable structure.
95
+ */
96
+ compile(proposal) {
97
+ const errors = [];
98
+ const candidates = this.registry.findCandidates(proposal.raw);
99
+ if (candidates.length === 0) {
100
+ return {
101
+ ok: false,
102
+ errors: [{
103
+ code: "IDEL_UNKNOWN_INTENT",
104
+ message: `No intent found matching '${proposal.raw}'`
105
+ }]
106
+ };
107
+ }
108
+ const best = candidates[0];
109
+ const schema = best.schema;
110
+ const alternatives = candidates.slice(1, 4).filter((c) => c.score >= 0.3).map((c) => ({
111
+ intent: c.schema.intent,
112
+ confidence: c.score,
113
+ reason: c.schema.description
114
+ }));
115
+ const constraints = [];
116
+ const clarifications = [];
117
+ const params = { ...proposal.params };
118
+ for (const paramSchema of schema.params) {
119
+ const value = params[paramSchema.name];
120
+ if (paramSchema.required && value === void 0) {
121
+ if (paramSchema.default !== void 0) {
122
+ params[paramSchema.name] = paramSchema.default;
123
+ constraints.push({
124
+ kind: "required_param",
125
+ field: paramSchema.name,
126
+ description: `Defaulted to ${JSON.stringify(paramSchema.default)}`,
127
+ satisfied: true,
128
+ value: paramSchema.default
129
+ });
130
+ } else {
131
+ constraints.push({
132
+ kind: "required_param",
133
+ field: paramSchema.name,
134
+ description: `Required parameter '${paramSchema.name}' is missing`,
135
+ satisfied: false
136
+ });
137
+ clarifications.push({
138
+ id: `clarify_${paramSchema.name}`,
139
+ question: paramSchema.description ?? `What is the ${paramSchema.name}?`,
140
+ field: paramSchema.name,
141
+ options: paramSchema.enum?.map(String),
142
+ required: true
143
+ });
144
+ }
145
+ continue;
146
+ }
147
+ if (value === void 0) continue;
148
+ const typeValid = validateType(value, paramSchema.type);
149
+ constraints.push({
150
+ kind: "type_check",
151
+ field: paramSchema.name,
152
+ description: `Must be ${paramSchema.type}`,
153
+ satisfied: typeValid,
154
+ value,
155
+ expected: paramSchema.type
156
+ });
157
+ if (!typeValid) {
158
+ errors.push({
159
+ code: "IDEL_TYPE_ERROR",
160
+ message: `Parameter '${paramSchema.name}' must be ${paramSchema.type}, got ${typeof value}`,
161
+ field: paramSchema.name
162
+ });
163
+ }
164
+ if (paramSchema.min !== void 0 || paramSchema.max !== void 0) {
165
+ const numVal = typeof value === "number" ? value : Number(value);
166
+ const inRange = (paramSchema.min === void 0 || numVal >= paramSchema.min) && (paramSchema.max === void 0 || numVal <= paramSchema.max);
167
+ constraints.push({
168
+ kind: "range",
169
+ field: paramSchema.name,
170
+ description: `Must be between ${paramSchema.min ?? "-\u221E"} and ${paramSchema.max ?? "\u221E"}`,
171
+ satisfied: inRange,
172
+ value: numVal
173
+ });
174
+ }
175
+ if (paramSchema.pattern) {
176
+ const matches = new RegExp(paramSchema.pattern).test(String(value));
177
+ constraints.push({
178
+ kind: "pattern",
179
+ field: paramSchema.name,
180
+ description: `Must match ${paramSchema.pattern}`,
181
+ satisfied: matches,
182
+ value,
183
+ expected: paramSchema.pattern
184
+ });
185
+ }
186
+ if (paramSchema.enum) {
187
+ const inEnum = paramSchema.enum.some(
188
+ (e) => JSON.stringify(e) === JSON.stringify(value)
189
+ );
190
+ constraints.push({
191
+ kind: "custom",
192
+ field: paramSchema.name,
193
+ description: `Must be one of: ${paramSchema.enum.join(", ")}`,
194
+ satisfied: inEnum,
195
+ value,
196
+ expected: paramSchema.enum
197
+ });
198
+ }
199
+ }
200
+ const risk = assessRisk(schema, proposal, constraints);
201
+ const unsatisfied = constraints.filter((c) => !c.satisfied);
202
+ const needsClarification = clarifications.length > 0;
203
+ let confidence = best.score;
204
+ if (unsatisfied.length > 0) {
205
+ confidence *= 1 - unsatisfied.length / Math.max(constraints.length, 1) * 0.5;
206
+ }
207
+ if (errors.length > 0) {
208
+ confidence *= 0.5;
209
+ }
210
+ const compiled = {
211
+ intent: schema.intent,
212
+ actor_id: proposal.actor_id,
213
+ target: proposal.target,
214
+ params,
215
+ constraints,
216
+ confidence,
217
+ alternatives,
218
+ needs_clarification: needsClarification,
219
+ clarifications,
220
+ expected_outcome: schema.description,
221
+ fallback: schema.related?.[0],
222
+ risk,
223
+ metadata: {
224
+ schema_intent: schema.intent,
225
+ resolved_from: proposal.raw,
226
+ has_side_effects: schema.has_side_effects,
227
+ reversible: schema.reversible
228
+ }
229
+ };
230
+ return {
231
+ ok: errors.length === 0 && !needsClarification,
232
+ compiled,
233
+ errors
234
+ };
235
+ }
236
+ /**
237
+ * Apply clarification answers and re-compile.
238
+ */
239
+ applyClarifications(compiled, answers) {
240
+ const proposal = {
241
+ raw: compiled.intent,
242
+ actor_id: compiled.actor_id,
243
+ target: compiled.target,
244
+ params: { ...compiled.params, ...answers }
245
+ };
246
+ return this.compile(proposal);
247
+ }
248
+ };
249
+ function validateType(value, expectedType) {
250
+ switch (expectedType) {
251
+ case "string":
252
+ return typeof value === "string";
253
+ case "number":
254
+ return typeof value === "number" && Number.isFinite(value);
255
+ case "boolean":
256
+ return typeof value === "boolean";
257
+ case "object":
258
+ return typeof value === "object" && value !== null && !Array.isArray(value);
259
+ case "array":
260
+ return Array.isArray(value);
261
+ default:
262
+ return true;
263
+ }
264
+ }
265
+ function assessRisk(schema, proposal, constraints) {
266
+ const factors = [];
267
+ let score = 0;
268
+ const baseRiskMap = {
269
+ none: 0,
270
+ low: 0.1,
271
+ medium: 0.3,
272
+ high: 0.6,
273
+ critical: 0.9
274
+ };
275
+ score = baseRiskMap[schema.risk_level] ?? 0;
276
+ if (schema.risk_level !== "none") {
277
+ factors.push(`Base risk: ${schema.risk_level}`);
278
+ }
279
+ if (schema.has_side_effects) {
280
+ score += 0.1;
281
+ factors.push("Has side effects");
282
+ }
283
+ if (!schema.reversible) {
284
+ score += 0.1;
285
+ factors.push("Not reversible");
286
+ }
287
+ const failed = constraints.filter((c) => !c.satisfied);
288
+ if (failed.length > 0) {
289
+ score += 0.05 * failed.length;
290
+ factors.push(`${failed.length} unsatisfied constraint(s)`);
291
+ }
292
+ score = Math.min(score, 1);
293
+ let level;
294
+ if (score <= 0) level = "none";
295
+ else if (score <= 0.2) level = "low";
296
+ else if (score <= 0.5) level = "medium";
297
+ else if (score <= 0.8) level = "high";
298
+ else level = "critical";
299
+ return { level, score, factors };
300
+ }
301
+ // Annotate the CommonJS export names for ESM import in node:
302
+ 0 && (module.exports = {
303
+ IdelCompiler,
304
+ IdelSchemaRegistry
305
+ });
306
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/idel/index.ts","../../src/idel/idel.compiler.ts"],"sourcesContent":["export * from './idel.types';\nexport * from './idel.compiler';\n","/**\n * IDEL Compiler — Intent Description & Execution Language\n *\n * Compiles raw intent proposals into validated, executable structures.\n *\n * Pipeline:\n * 1. Resolve: match raw input to a known intent schema\n * 2. Validate: check all required params and constraints\n * 3. Assess risk: evaluate intent risk level\n * 4. Generate clarifications: if ambiguous or incomplete\n * 5. Output: CompiledIntent ready for AXIS execution\n */\n\nimport type {\n AlternativeIntent,\n ClarificationQuestion,\n CompilationError,\n CompilationResult,\n CompiledIntent,\n IntentConstraint,\n IntentParamSchema,\n IntentProposal,\n IntentRisk,\n IntentSchema,\n RiskLevel,\n} from './idel.types';\n\n// ────────────────────────────────────────────────────────────────────────────\n// Schema Registry\n// ────────────────────────────────────────────────────────────────────────────\n\nexport class IdelSchemaRegistry {\n private schemas = new Map<string, IntentSchema>();\n private aliases = new Map<string, string>();\n\n register(schema: IntentSchema): void {\n this.schemas.set(schema.intent, schema);\n }\n\n registerAlias(alias: string, intent: string): void {\n this.aliases.set(alias.toLowerCase(), intent);\n }\n\n get(intent: string): IntentSchema | undefined {\n return this.schemas.get(intent);\n }\n\n resolve(raw: string): IntentSchema | undefined {\n // Exact match\n const exact = this.schemas.get(raw);\n if (exact) return exact;\n\n // Alias match\n const aliased = this.aliases.get(raw.toLowerCase());\n if (aliased) return this.schemas.get(aliased);\n\n // Prefix match (e.g., \"payment\" → \"payment.create\")\n const candidates = [...this.schemas.keys()].filter(\n (k) => k.startsWith(raw + '.') || k.toLowerCase().includes(raw.toLowerCase()),\n );\n if (candidates.length === 1) {\n return this.schemas.get(candidates[0]);\n }\n\n return undefined;\n }\n\n /**\n * Find all schemas that partially match the raw input.\n * Returns scored candidates for ambiguity resolution.\n */\n findCandidates(raw: string): Array<{ schema: IntentSchema; score: number }> {\n const normalized = raw.toLowerCase().trim();\n const results: Array<{ schema: IntentSchema; score: number }> = [];\n\n for (const [key, schema] of this.schemas) {\n let score = 0;\n\n // Exact match\n if (key === raw) {\n score = 1.0;\n }\n // Case-insensitive exact\n else if (key.toLowerCase() === normalized) {\n score = 0.95;\n }\n // Alias match\n else if (this.aliases.get(normalized) === key) {\n score = 0.9;\n }\n // Prefix match\n else if (key.toLowerCase().startsWith(normalized)) {\n score = 0.7;\n }\n // Contains match\n else if (key.toLowerCase().includes(normalized)) {\n score = 0.5;\n }\n // Tag match\n else if (schema.tags?.some((t) => t.toLowerCase().includes(normalized))) {\n score = 0.4;\n }\n // Description match\n else if (schema.description.toLowerCase().includes(normalized)) {\n score = 0.3;\n }\n\n if (score > 0) {\n results.push({ schema, score });\n }\n }\n\n return results.sort((a, b) => b.score - a.score);\n }\n\n list(): IntentSchema[] {\n return [...this.schemas.values()];\n }\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// IDEL Compiler\n// ────────────────────────────────────────────────────────────────────────────\n\nexport class IdelCompiler {\n constructor(private readonly registry: IdelSchemaRegistry) {}\n\n /**\n * Compile a raw intent proposal into a validated, executable structure.\n */\n compile(proposal: IntentProposal): CompilationResult {\n const errors: CompilationError[] = [];\n\n // 1. Resolve intent\n const candidates = this.registry.findCandidates(proposal.raw);\n if (candidates.length === 0) {\n return {\n ok: false,\n errors: [{\n code: 'IDEL_UNKNOWN_INTENT',\n message: `No intent found matching '${proposal.raw}'`,\n }],\n };\n }\n\n const best = candidates[0];\n const schema = best.schema;\n\n // 2. Build alternatives\n const alternatives: AlternativeIntent[] = candidates\n .slice(1, 4)\n .filter((c) => c.score >= 0.3)\n .map((c) => ({\n intent: c.schema.intent,\n confidence: c.score,\n reason: c.schema.description,\n }));\n\n // 3. Validate parameters\n const constraints: IntentConstraint[] = [];\n const clarifications: ClarificationQuestion[] = [];\n const params = { ...proposal.params };\n\n for (const paramSchema of schema.params) {\n const value = params[paramSchema.name];\n\n // Required check\n if (paramSchema.required && value === undefined) {\n if (paramSchema.default !== undefined) {\n params[paramSchema.name] = paramSchema.default;\n constraints.push({\n kind: 'required_param',\n field: paramSchema.name,\n description: `Defaulted to ${JSON.stringify(paramSchema.default)}`,\n satisfied: true,\n value: paramSchema.default,\n });\n } else {\n constraints.push({\n kind: 'required_param',\n field: paramSchema.name,\n description: `Required parameter '${paramSchema.name}' is missing`,\n satisfied: false,\n });\n clarifications.push({\n id: `clarify_${paramSchema.name}`,\n question: paramSchema.description ?? `What is the ${paramSchema.name}?`,\n field: paramSchema.name,\n options: paramSchema.enum?.map(String),\n required: true,\n });\n }\n continue;\n }\n\n if (value === undefined) continue;\n\n // Type check\n const typeValid = validateType(value, paramSchema.type);\n constraints.push({\n kind: 'type_check',\n field: paramSchema.name,\n description: `Must be ${paramSchema.type}`,\n satisfied: typeValid,\n value,\n expected: paramSchema.type,\n });\n if (!typeValid) {\n errors.push({\n code: 'IDEL_TYPE_ERROR',\n message: `Parameter '${paramSchema.name}' must be ${paramSchema.type}, got ${typeof value}`,\n field: paramSchema.name,\n });\n }\n\n // Range check\n if (paramSchema.min !== undefined || paramSchema.max !== undefined) {\n const numVal = typeof value === 'number' ? value : Number(value);\n const inRange =\n (paramSchema.min === undefined || numVal >= paramSchema.min) &&\n (paramSchema.max === undefined || numVal <= paramSchema.max);\n constraints.push({\n kind: 'range',\n field: paramSchema.name,\n description: `Must be between ${paramSchema.min ?? '-∞'} and ${paramSchema.max ?? '∞'}`,\n satisfied: inRange,\n value: numVal,\n });\n }\n\n // Pattern check\n if (paramSchema.pattern) {\n const matches = new RegExp(paramSchema.pattern).test(String(value));\n constraints.push({\n kind: 'pattern',\n field: paramSchema.name,\n description: `Must match ${paramSchema.pattern}`,\n satisfied: matches,\n value,\n expected: paramSchema.pattern,\n });\n }\n\n // Enum check\n if (paramSchema.enum) {\n const inEnum = paramSchema.enum.some(\n (e) => JSON.stringify(e) === JSON.stringify(value),\n );\n constraints.push({\n kind: 'custom',\n field: paramSchema.name,\n description: `Must be one of: ${paramSchema.enum.join(', ')}`,\n satisfied: inEnum,\n value,\n expected: paramSchema.enum,\n });\n }\n }\n\n // 4. Assess risk\n const risk = assessRisk(schema, proposal, constraints);\n\n // 5. Compute confidence\n const unsatisfied = constraints.filter((c) => !c.satisfied);\n const needsClarification = clarifications.length > 0;\n let confidence = best.score;\n if (unsatisfied.length > 0) {\n confidence *= 1 - (unsatisfied.length / Math.max(constraints.length, 1)) * 0.5;\n }\n if (errors.length > 0) {\n confidence *= 0.5;\n }\n\n const compiled: CompiledIntent = {\n intent: schema.intent,\n actor_id: proposal.actor_id,\n target: proposal.target,\n params,\n constraints,\n confidence,\n alternatives,\n needs_clarification: needsClarification,\n clarifications,\n expected_outcome: schema.description,\n fallback: schema.related?.[0],\n risk,\n metadata: {\n schema_intent: schema.intent,\n resolved_from: proposal.raw,\n has_side_effects: schema.has_side_effects,\n reversible: schema.reversible,\n },\n };\n\n return {\n ok: errors.length === 0 && !needsClarification,\n compiled,\n errors,\n };\n }\n\n /**\n * Apply clarification answers and re-compile.\n */\n applyClarifications(\n compiled: CompiledIntent,\n answers: Record<string, unknown>,\n ): CompilationResult {\n const proposal: IntentProposal = {\n raw: compiled.intent,\n actor_id: compiled.actor_id,\n target: compiled.target,\n params: { ...compiled.params, ...answers },\n };\n return this.compile(proposal);\n }\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// Helpers\n// ────────────────────────────────────────────────────────────────────────────\n\nfunction validateType(value: unknown, expectedType: IntentParamSchema['type']): boolean {\n switch (expectedType) {\n case 'string':\n return typeof value === 'string';\n case 'number':\n return typeof value === 'number' && Number.isFinite(value);\n case 'boolean':\n return typeof value === 'boolean';\n case 'object':\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n case 'array':\n return Array.isArray(value);\n default:\n return true;\n }\n}\n\nfunction assessRisk(\n schema: IntentSchema,\n proposal: IntentProposal,\n constraints: IntentConstraint[],\n): IntentRisk {\n const factors: string[] = [];\n let score = 0;\n\n // Base risk from schema\n const baseRiskMap: Record<RiskLevel, number> = {\n none: 0,\n low: 0.1,\n medium: 0.3,\n high: 0.6,\n critical: 0.9,\n };\n score = baseRiskMap[schema.risk_level] ?? 0;\n if (schema.risk_level !== 'none') {\n factors.push(`Base risk: ${schema.risk_level}`);\n }\n\n // Side effects increase risk\n if (schema.has_side_effects) {\n score += 0.1;\n factors.push('Has side effects');\n }\n\n // Irreversible actions increase risk\n if (!schema.reversible) {\n score += 0.1;\n factors.push('Not reversible');\n }\n\n // Failed constraints increase risk\n const failed = constraints.filter((c) => !c.satisfied);\n if (failed.length > 0) {\n score += 0.05 * failed.length;\n factors.push(`${failed.length} unsatisfied constraint(s)`);\n }\n\n // Clamp\n score = Math.min(score, 1.0);\n\n let level: RiskLevel;\n if (score <= 0) level = 'none';\n else if (score <= 0.2) level = 'low';\n else if (score <= 0.5) level = 'medium';\n else if (score <= 0.8) level = 'high';\n else level = 'critical';\n\n return { level, score, factors };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC+BO,IAAM,qBAAN,MAAyB;AAAA,EAAzB;AACL,SAAQ,UAAU,oBAAI,IAA0B;AAChD,SAAQ,UAAU,oBAAI,IAAoB;AAAA;AAAA,EAE1C,SAAS,QAA4B;AACnC,SAAK,QAAQ,IAAI,OAAO,QAAQ,MAAM;AAAA,EACxC;AAAA,EAEA,cAAc,OAAe,QAAsB;AACjD,SAAK,QAAQ,IAAI,MAAM,YAAY,GAAG,MAAM;AAAA,EAC9C;AAAA,EAEA,IAAI,QAA0C;AAC5C,WAAO,KAAK,QAAQ,IAAI,MAAM;AAAA,EAChC;AAAA,EAEA,QAAQ,KAAuC;AAE7C,UAAM,QAAQ,KAAK,QAAQ,IAAI,GAAG;AAClC,QAAI,MAAO,QAAO;AAGlB,UAAM,UAAU,KAAK,QAAQ,IAAI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,OAAO,SAAS,GAAG;AACrB,aAAS,OAAO,OAAO;AACvB,YAAQ,KAAK,GAAG,OAAO,MAAM,4BAA4B;AAAA,EAC3D;AAGA,UAAQ,KAAK,IAAI,OAAO,CAAG;AAE3B,MAAI;AACJ,MAAI,SAAS,EAAG,SAAQ;AAAA,WACf,SAAS,IAAK,SAAQ;AAAA,WACtB,SAAS,IAAK,SAAQ;AAAA,WACtB,SAAS,IAAK,SAAQ;AAAA,MAC1B,SAAQ;AAEb,SAAO,EAAE,OAAO,OAAO,QAAQ;AACjC;","names":[]}
@@ -0,0 +1,279 @@
1
+ // src/idel/idel.compiler.ts
2
+ var IdelSchemaRegistry = class {
3
+ constructor() {
4
+ this.schemas = /* @__PURE__ */ new Map();
5
+ this.aliases = /* @__PURE__ */ new Map();
6
+ }
7
+ register(schema) {
8
+ this.schemas.set(schema.intent, schema);
9
+ }
10
+ registerAlias(alias, intent) {
11
+ this.aliases.set(alias.toLowerCase(), intent);
12
+ }
13
+ get(intent) {
14
+ return this.schemas.get(intent);
15
+ }
16
+ resolve(raw) {
17
+ const exact = this.schemas.get(raw);
18
+ if (exact) return exact;
19
+ const aliased = this.aliases.get(raw.toLowerCase());
20
+ if (aliased) return this.schemas.get(aliased);
21
+ const candidates = [...this.schemas.keys()].filter(
22
+ (k) => k.startsWith(raw + ".") || k.toLowerCase().includes(raw.toLowerCase())
23
+ );
24
+ if (candidates.length === 1) {
25
+ return this.schemas.get(candidates[0]);
26
+ }
27
+ return void 0;
28
+ }
29
+ /**
30
+ * Find all schemas that partially match the raw input.
31
+ * Returns scored candidates for ambiguity resolution.
32
+ */
33
+ findCandidates(raw) {
34
+ const normalized = raw.toLowerCase().trim();
35
+ const results = [];
36
+ for (const [key, schema] of this.schemas) {
37
+ let score = 0;
38
+ if (key === raw) {
39
+ score = 1;
40
+ } else if (key.toLowerCase() === normalized) {
41
+ score = 0.95;
42
+ } else if (this.aliases.get(normalized) === key) {
43
+ score = 0.9;
44
+ } else if (key.toLowerCase().startsWith(normalized)) {
45
+ score = 0.7;
46
+ } else if (key.toLowerCase().includes(normalized)) {
47
+ score = 0.5;
48
+ } else if (schema.tags?.some((t) => t.toLowerCase().includes(normalized))) {
49
+ score = 0.4;
50
+ } else if (schema.description.toLowerCase().includes(normalized)) {
51
+ score = 0.3;
52
+ }
53
+ if (score > 0) {
54
+ results.push({ schema, score });
55
+ }
56
+ }
57
+ return results.sort((a, b) => b.score - a.score);
58
+ }
59
+ list() {
60
+ return [...this.schemas.values()];
61
+ }
62
+ };
63
+ var IdelCompiler = class {
64
+ constructor(registry) {
65
+ this.registry = registry;
66
+ }
67
+ /**
68
+ * Compile a raw intent proposal into a validated, executable structure.
69
+ */
70
+ compile(proposal) {
71
+ const errors = [];
72
+ const candidates = this.registry.findCandidates(proposal.raw);
73
+ if (candidates.length === 0) {
74
+ return {
75
+ ok: false,
76
+ errors: [{
77
+ code: "IDEL_UNKNOWN_INTENT",
78
+ message: `No intent found matching '${proposal.raw}'`
79
+ }]
80
+ };
81
+ }
82
+ const best = candidates[0];
83
+ const schema = best.schema;
84
+ const alternatives = candidates.slice(1, 4).filter((c) => c.score >= 0.3).map((c) => ({
85
+ intent: c.schema.intent,
86
+ confidence: c.score,
87
+ reason: c.schema.description
88
+ }));
89
+ const constraints = [];
90
+ const clarifications = [];
91
+ const params = { ...proposal.params };
92
+ for (const paramSchema of schema.params) {
93
+ const value = params[paramSchema.name];
94
+ if (paramSchema.required && value === void 0) {
95
+ if (paramSchema.default !== void 0) {
96
+ params[paramSchema.name] = paramSchema.default;
97
+ constraints.push({
98
+ kind: "required_param",
99
+ field: paramSchema.name,
100
+ description: `Defaulted to ${JSON.stringify(paramSchema.default)}`,
101
+ satisfied: true,
102
+ value: paramSchema.default
103
+ });
104
+ } else {
105
+ constraints.push({
106
+ kind: "required_param",
107
+ field: paramSchema.name,
108
+ description: `Required parameter '${paramSchema.name}' is missing`,
109
+ satisfied: false
110
+ });
111
+ clarifications.push({
112
+ id: `clarify_${paramSchema.name}`,
113
+ question: paramSchema.description ?? `What is the ${paramSchema.name}?`,
114
+ field: paramSchema.name,
115
+ options: paramSchema.enum?.map(String),
116
+ required: true
117
+ });
118
+ }
119
+ continue;
120
+ }
121
+ if (value === void 0) continue;
122
+ const typeValid = validateType(value, paramSchema.type);
123
+ constraints.push({
124
+ kind: "type_check",
125
+ field: paramSchema.name,
126
+ description: `Must be ${paramSchema.type}`,
127
+ satisfied: typeValid,
128
+ value,
129
+ expected: paramSchema.type
130
+ });
131
+ if (!typeValid) {
132
+ errors.push({
133
+ code: "IDEL_TYPE_ERROR",
134
+ message: `Parameter '${paramSchema.name}' must be ${paramSchema.type}, got ${typeof value}`,
135
+ field: paramSchema.name
136
+ });
137
+ }
138
+ if (paramSchema.min !== void 0 || paramSchema.max !== void 0) {
139
+ const numVal = typeof value === "number" ? value : Number(value);
140
+ const inRange = (paramSchema.min === void 0 || numVal >= paramSchema.min) && (paramSchema.max === void 0 || numVal <= paramSchema.max);
141
+ constraints.push({
142
+ kind: "range",
143
+ field: paramSchema.name,
144
+ description: `Must be between ${paramSchema.min ?? "-\u221E"} and ${paramSchema.max ?? "\u221E"}`,
145
+ satisfied: inRange,
146
+ value: numVal
147
+ });
148
+ }
149
+ if (paramSchema.pattern) {
150
+ const matches = new RegExp(paramSchema.pattern).test(String(value));
151
+ constraints.push({
152
+ kind: "pattern",
153
+ field: paramSchema.name,
154
+ description: `Must match ${paramSchema.pattern}`,
155
+ satisfied: matches,
156
+ value,
157
+ expected: paramSchema.pattern
158
+ });
159
+ }
160
+ if (paramSchema.enum) {
161
+ const inEnum = paramSchema.enum.some(
162
+ (e) => JSON.stringify(e) === JSON.stringify(value)
163
+ );
164
+ constraints.push({
165
+ kind: "custom",
166
+ field: paramSchema.name,
167
+ description: `Must be one of: ${paramSchema.enum.join(", ")}`,
168
+ satisfied: inEnum,
169
+ value,
170
+ expected: paramSchema.enum
171
+ });
172
+ }
173
+ }
174
+ const risk = assessRisk(schema, proposal, constraints);
175
+ const unsatisfied = constraints.filter((c) => !c.satisfied);
176
+ const needsClarification = clarifications.length > 0;
177
+ let confidence = best.score;
178
+ if (unsatisfied.length > 0) {
179
+ confidence *= 1 - unsatisfied.length / Math.max(constraints.length, 1) * 0.5;
180
+ }
181
+ if (errors.length > 0) {
182
+ confidence *= 0.5;
183
+ }
184
+ const compiled = {
185
+ intent: schema.intent,
186
+ actor_id: proposal.actor_id,
187
+ target: proposal.target,
188
+ params,
189
+ constraints,
190
+ confidence,
191
+ alternatives,
192
+ needs_clarification: needsClarification,
193
+ clarifications,
194
+ expected_outcome: schema.description,
195
+ fallback: schema.related?.[0],
196
+ risk,
197
+ metadata: {
198
+ schema_intent: schema.intent,
199
+ resolved_from: proposal.raw,
200
+ has_side_effects: schema.has_side_effects,
201
+ reversible: schema.reversible
202
+ }
203
+ };
204
+ return {
205
+ ok: errors.length === 0 && !needsClarification,
206
+ compiled,
207
+ errors
208
+ };
209
+ }
210
+ /**
211
+ * Apply clarification answers and re-compile.
212
+ */
213
+ applyClarifications(compiled, answers) {
214
+ const proposal = {
215
+ raw: compiled.intent,
216
+ actor_id: compiled.actor_id,
217
+ target: compiled.target,
218
+ params: { ...compiled.params, ...answers }
219
+ };
220
+ return this.compile(proposal);
221
+ }
222
+ };
223
+ function validateType(value, expectedType) {
224
+ switch (expectedType) {
225
+ case "string":
226
+ return typeof value === "string";
227
+ case "number":
228
+ return typeof value === "number" && Number.isFinite(value);
229
+ case "boolean":
230
+ return typeof value === "boolean";
231
+ case "object":
232
+ return typeof value === "object" && value !== null && !Array.isArray(value);
233
+ case "array":
234
+ return Array.isArray(value);
235
+ default:
236
+ return true;
237
+ }
238
+ }
239
+ function assessRisk(schema, proposal, constraints) {
240
+ const factors = [];
241
+ let score = 0;
242
+ const baseRiskMap = {
243
+ none: 0,
244
+ low: 0.1,
245
+ medium: 0.3,
246
+ high: 0.6,
247
+ critical: 0.9
248
+ };
249
+ score = baseRiskMap[schema.risk_level] ?? 0;
250
+ if (schema.risk_level !== "none") {
251
+ factors.push(`Base risk: ${schema.risk_level}`);
252
+ }
253
+ if (schema.has_side_effects) {
254
+ score += 0.1;
255
+ factors.push("Has side effects");
256
+ }
257
+ if (!schema.reversible) {
258
+ score += 0.1;
259
+ factors.push("Not reversible");
260
+ }
261
+ const failed = constraints.filter((c) => !c.satisfied);
262
+ if (failed.length > 0) {
263
+ score += 0.05 * failed.length;
264
+ factors.push(`${failed.length} unsatisfied constraint(s)`);
265
+ }
266
+ score = Math.min(score, 1);
267
+ let level;
268
+ if (score <= 0) level = "none";
269
+ else if (score <= 0.2) level = "low";
270
+ else if (score <= 0.5) level = "medium";
271
+ else if (score <= 0.8) level = "high";
272
+ else level = "critical";
273
+ return { level, score, factors };
274
+ }
275
+ export {
276
+ IdelCompiler,
277
+ IdelSchemaRegistry
278
+ };
279
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/idel/idel.compiler.ts"],"sourcesContent":["/**\n * IDEL Compiler — Intent Description & Execution Language\n *\n * Compiles raw intent proposals into validated, executable structures.\n *\n * Pipeline:\n * 1. Resolve: match raw input to a known intent schema\n * 2. Validate: check all required params and constraints\n * 3. Assess risk: evaluate intent risk level\n * 4. Generate clarifications: if ambiguous or incomplete\n * 5. Output: CompiledIntent ready for AXIS execution\n */\n\nimport type {\n AlternativeIntent,\n ClarificationQuestion,\n CompilationError,\n CompilationResult,\n CompiledIntent,\n IntentConstraint,\n IntentParamSchema,\n IntentProposal,\n IntentRisk,\n IntentSchema,\n RiskLevel,\n} from './idel.types';\n\n// ────────────────────────────────────────────────────────────────────────────\n// Schema Registry\n// ────────────────────────────────────────────────────────────────────────────\n\nexport class IdelSchemaRegistry {\n private schemas = new Map<string, IntentSchema>();\n private aliases = new Map<string, string>();\n\n register(schema: IntentSchema): void {\n this.schemas.set(schema.intent, schema);\n }\n\n registerAlias(alias: string, intent: string): void {\n this.aliases.set(alias.toLowerCase(), intent);\n }\n\n get(intent: string): IntentSchema | undefined {\n return this.schemas.get(intent);\n }\n\n resolve(raw: string): IntentSchema | undefined {\n // Exact match\n const exact = this.schemas.get(raw);\n if (exact) return exact;\n\n // Alias match\n const aliased = this.aliases.get(raw.toLowerCase());\n if (aliased) return this.schemas.get(aliased);\n\n // Prefix match (e.g., \"payment\" → \"payment.create\")\n const candidates = [...this.schemas.keys()].filter(\n (k) => k.startsWith(raw + '.') || k.toLowerCase().includes(raw.toLowerCase()),\n );\n if (candidates.length === 1) {\n return this.schemas.get(candidates[0]);\n }\n\n return undefined;\n }\n\n /**\n * Find all schemas that partially match the raw input.\n * Returns scored candidates for ambiguity resolution.\n */\n findCandidates(raw: string): Array<{ schema: IntentSchema; score: number }> {\n const normalized = raw.toLowerCase().trim();\n const results: Array<{ schema: IntentSchema; score: number }> = [];\n\n for (const [key, schema] of this.schemas) {\n let score = 0;\n\n // Exact match\n if (key === raw) {\n score = 1.0;\n }\n // Case-insensitive exact\n else if (key.toLowerCase() === normalized) {\n score = 0.95;\n }\n // Alias match\n else if (this.aliases.get(normalized) === key) {\n score = 0.9;\n }\n // Prefix match\n else if (key.toLowerCase().startsWith(normalized)) {\n score = 0.7;\n }\n // Contains match\n else if (key.toLowerCase().includes(normalized)) {\n score = 0.5;\n }\n // Tag match\n else if (schema.tags?.some((t) => t.toLowerCase().includes(normalized))) {\n score = 0.4;\n }\n // Description match\n else if (schema.description.toLowerCase().includes(normalized)) {\n score = 0.3;\n }\n\n if (score > 0) {\n results.push({ schema, score });\n }\n }\n\n return results.sort((a, b) => b.score - a.score);\n }\n\n list(): IntentSchema[] {\n return [...this.schemas.values()];\n }\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// IDEL Compiler\n// ────────────────────────────────────────────────────────────────────────────\n\nexport class IdelCompiler {\n constructor(private readonly registry: IdelSchemaRegistry) {}\n\n /**\n * Compile a raw intent proposal into a validated, executable structure.\n */\n compile(proposal: IntentProposal): CompilationResult {\n const errors: CompilationError[] = [];\n\n // 1. Resolve intent\n const candidates = this.registry.findCandidates(proposal.raw);\n if (candidates.length === 0) {\n return {\n ok: false,\n errors: [{\n code: 'IDEL_UNKNOWN_INTENT',\n message: `No intent found matching '${proposal.raw}'`,\n }],\n };\n }\n\n const best = candidates[0];\n const schema = best.schema;\n\n // 2. Build alternatives\n const alternatives: AlternativeIntent[] = candidates\n .slice(1, 4)\n .filter((c) => c.score >= 0.3)\n .map((c) => ({\n intent: c.schema.intent,\n confidence: c.score,\n reason: c.schema.description,\n }));\n\n // 3. Validate parameters\n const constraints: IntentConstraint[] = [];\n const clarifications: ClarificationQuestion[] = [];\n const params = { ...proposal.params };\n\n for (const paramSchema of schema.params) {\n const value = params[paramSchema.name];\n\n // Required check\n if (paramSchema.required && value === undefined) {\n if (paramSchema.default !== undefined) {\n params[paramSchema.name] = paramSchema.default;\n constraints.push({\n kind: 'required_param',\n field: paramSchema.name,\n description: `Defaulted to ${JSON.stringify(paramSchema.default)}`,\n satisfied: true,\n value: paramSchema.default,\n });\n } else {\n constraints.push({\n kind: 'required_param',\n field: paramSchema.name,\n description: `Required parameter '${paramSchema.name}' is missing`,\n satisfied: false,\n });\n clarifications.push({\n id: `clarify_${paramSchema.name}`,\n question: paramSchema.description ?? `What is the ${paramSchema.name}?`,\n field: paramSchema.name,\n options: paramSchema.enum?.map(String),\n required: true,\n });\n }\n continue;\n }\n\n if (value === undefined) continue;\n\n // Type check\n const typeValid = validateType(value, paramSchema.type);\n constraints.push({\n kind: 'type_check',\n field: paramSchema.name,\n description: `Must be ${paramSchema.type}`,\n satisfied: typeValid,\n value,\n expected: paramSchema.type,\n });\n if (!typeValid) {\n errors.push({\n code: 'IDEL_TYPE_ERROR',\n message: `Parameter '${paramSchema.name}' must be ${paramSchema.type}, got ${typeof value}`,\n field: paramSchema.name,\n });\n }\n\n // Range check\n if (paramSchema.min !== undefined || paramSchema.max !== undefined) {\n const numVal = typeof value === 'number' ? value : Number(value);\n const inRange =\n (paramSchema.min === undefined || numVal >= paramSchema.min) &&\n (paramSchema.max === undefined || numVal <= paramSchema.max);\n constraints.push({\n kind: 'range',\n field: paramSchema.name,\n description: `Must be between ${paramSchema.min ?? '-∞'} and ${paramSchema.max ?? '∞'}`,\n satisfied: inRange,\n value: numVal,\n });\n }\n\n // Pattern check\n if (paramSchema.pattern) {\n const matches = new RegExp(paramSchema.pattern).test(String(value));\n constraints.push({\n kind: 'pattern',\n field: paramSchema.name,\n description: `Must match ${paramSchema.pattern}`,\n satisfied: matches,\n value,\n expected: paramSchema.pattern,\n });\n }\n\n // Enum check\n if (paramSchema.enum) {\n const inEnum = paramSchema.enum.some(\n (e) => JSON.stringify(e) === JSON.stringify(value),\n );\n constraints.push({\n kind: 'custom',\n field: paramSchema.name,\n description: `Must be one of: ${paramSchema.enum.join(', ')}`,\n satisfied: inEnum,\n value,\n expected: paramSchema.enum,\n });\n }\n }\n\n // 4. Assess risk\n const risk = assessRisk(schema, proposal, constraints);\n\n // 5. Compute confidence\n const unsatisfied = constraints.filter((c) => !c.satisfied);\n const needsClarification = clarifications.length > 0;\n let confidence = best.score;\n if (unsatisfied.length > 0) {\n confidence *= 1 - (unsatisfied.length / Math.max(constraints.length, 1)) * 0.5;\n }\n if (errors.length > 0) {\n confidence *= 0.5;\n }\n\n const compiled: CompiledIntent = {\n intent: schema.intent,\n actor_id: proposal.actor_id,\n target: proposal.target,\n params,\n constraints,\n confidence,\n alternatives,\n needs_clarification: needsClarification,\n clarifications,\n expected_outcome: schema.description,\n fallback: schema.related?.[0],\n risk,\n metadata: {\n schema_intent: schema.intent,\n resolved_from: proposal.raw,\n has_side_effects: schema.has_side_effects,\n reversible: schema.reversible,\n },\n };\n\n return {\n ok: errors.length === 0 && !needsClarification,\n compiled,\n errors,\n };\n }\n\n /**\n * Apply clarification answers and re-compile.\n */\n applyClarifications(\n compiled: CompiledIntent,\n answers: Record<string, unknown>,\n ): CompilationResult {\n const proposal: IntentProposal = {\n raw: compiled.intent,\n actor_id: compiled.actor_id,\n target: compiled.target,\n params: { ...compiled.params, ...answers },\n };\n return this.compile(proposal);\n }\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// Helpers\n// ────────────────────────────────────────────────────────────────────────────\n\nfunction validateType(value: unknown, expectedType: IntentParamSchema['type']): boolean {\n switch (expectedType) {\n case 'string':\n return typeof value === 'string';\n case 'number':\n return typeof value === 'number' && Number.isFinite(value);\n case 'boolean':\n return typeof value === 'boolean';\n case 'object':\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n case 'array':\n return Array.isArray(value);\n default:\n return true;\n }\n}\n\nfunction assessRisk(\n schema: IntentSchema,\n proposal: IntentProposal,\n constraints: IntentConstraint[],\n): IntentRisk {\n const factors: string[] = [];\n let score = 0;\n\n // Base risk from schema\n const baseRiskMap: Record<RiskLevel, number> = {\n none: 0,\n low: 0.1,\n medium: 0.3,\n high: 0.6,\n critical: 0.9,\n };\n score = baseRiskMap[schema.risk_level] ?? 0;\n if (schema.risk_level !== 'none') {\n factors.push(`Base risk: ${schema.risk_level}`);\n }\n\n // Side effects increase risk\n if (schema.has_side_effects) {\n score += 0.1;\n factors.push('Has side effects');\n }\n\n // Irreversible actions increase risk\n if (!schema.reversible) {\n score += 0.1;\n factors.push('Not reversible');\n }\n\n // Failed constraints increase risk\n const failed = constraints.filter((c) => !c.satisfied);\n if (failed.length > 0) {\n score += 0.05 * failed.length;\n factors.push(`${failed.length} unsatisfied constraint(s)`);\n }\n\n // Clamp\n score = Math.min(score, 1.0);\n\n let level: RiskLevel;\n if (score <= 0) level = 'none';\n else if (score <= 0.2) level = 'low';\n else if (score <= 0.5) level = 'medium';\n else if (score <= 0.8) level = 'high';\n else level = 'critical';\n\n return { level, score, factors };\n}\n"],"mappings":";AA+BO,IAAM,qBAAN,MAAyB;AAAA,EAAzB;AACL,SAAQ,UAAU,oBAAI,IAA0B;AAChD,SAAQ,UAAU,oBAAI,IAAoB;AAAA;AAAA,EAE1C,SAAS,QAA4B;AACnC,SAAK,QAAQ,IAAI,OAAO,QAAQ,MAAM;AAAA,EACxC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