@extentos/mcp-server 0.0.75 → 0.0.78

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 (83) hide show
  1. package/dist/tools/data/codeExamples.d.ts +53 -0
  2. package/dist/tools/data/codeExamples.d.ts.map +1 -1
  3. package/dist/tools/data/codeExamples.js +254 -62
  4. package/dist/tools/data/codeExamples.js.map +1 -1
  5. package/dist/tools/definitions.d.ts.map +1 -1
  6. package/dist/tools/definitions.js +6 -8
  7. package/dist/tools/definitions.js.map +1 -1
  8. package/dist/tools/docs/index.d.ts.map +1 -1
  9. package/dist/tools/docs/index.js +38 -24
  10. package/dist/tools/docs/index.js.map +1 -1
  11. package/dist/tools/handlers/createSimulatorSession.d.ts.map +1 -1
  12. package/dist/tools/handlers/createSimulatorSession.js +16 -4
  13. package/dist/tools/handlers/createSimulatorSession.js.map +1 -1
  14. package/dist/tools/handlers/generateConnectionModule.d.ts.map +1 -1
  15. package/dist/tools/handlers/generateConnectionModule.js +20 -13
  16. package/dist/tools/handlers/generateConnectionModule.js.map +1 -1
  17. package/dist/tools/handlers/getCodeExample.d.ts.map +1 -1
  18. package/dist/tools/handlers/getCodeExample.js +11 -1
  19. package/dist/tools/handlers/getCodeExample.js.map +1 -1
  20. package/dist/tools/handlers/getCredentialGuide.js +57 -8
  21. package/dist/tools/handlers/getCredentialGuide.js.map +1 -1
  22. package/dist/tools/handlers/getEventLog.d.ts.map +1 -1
  23. package/dist/tools/handlers/getEventLog.js +8 -10
  24. package/dist/tools/handlers/getEventLog.js.map +1 -1
  25. package/dist/tools/handlers/inspectIntegration.d.ts.map +1 -1
  26. package/dist/tools/handlers/inspectIntegration.js +8 -3
  27. package/dist/tools/handlers/inspectIntegration.js.map +1 -1
  28. package/dist/tools/handlers/validateIntegration.d.ts.map +1 -1
  29. package/dist/tools/handlers/validateIntegration.js +9 -3
  30. package/dist/tools/handlers/validateIntegration.js.map +1 -1
  31. package/dist/tools/util/generatedHash.d.ts +24 -8
  32. package/dist/tools/util/generatedHash.d.ts.map +1 -1
  33. package/dist/tools/util/generatedHash.js +88 -11
  34. package/dist/tools/util/generatedHash.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/tools/data/examplePatterns.d.ts +0 -4
  37. package/dist/tools/data/examplePatterns.d.ts.map +0 -1
  38. package/dist/tools/data/examplePatterns.js +0 -546
  39. package/dist/tools/data/examplePatterns.js.map +0 -1
  40. package/dist/tools/data/presetTriggers.d.ts +0 -4
  41. package/dist/tools/data/presetTriggers.d.ts.map +0 -1
  42. package/dist/tools/data/presetTriggers.js +0 -47
  43. package/dist/tools/data/presetTriggers.js.map +0 -1
  44. package/dist/tools/handlers/generateConsumer.d.ts +0 -3
  45. package/dist/tools/handlers/generateConsumer.d.ts.map +0 -1
  46. package/dist/tools/handlers/generateConsumer.js +0 -477
  47. package/dist/tools/handlers/generateConsumer.js.map +0 -1
  48. package/dist/tools/handlers/getExampleSpec.d.ts +0 -3
  49. package/dist/tools/handlers/getExampleSpec.d.ts.map +0 -1
  50. package/dist/tools/handlers/getExampleSpec.js +0 -50
  51. package/dist/tools/handlers/getExampleSpec.js.map +0 -1
  52. package/dist/tools/handlers/initSpec.d.ts +0 -3
  53. package/dist/tools/handlers/initSpec.d.ts.map +0 -1
  54. package/dist/tools/handlers/initSpec.js +0 -350
  55. package/dist/tools/handlers/initSpec.js.map +0 -1
  56. package/dist/tools/handlers/planIntegration.d.ts +0 -3
  57. package/dist/tools/handlers/planIntegration.d.ts.map +0 -1
  58. package/dist/tools/handlers/planIntegration.js +0 -293
  59. package/dist/tools/handlers/planIntegration.js.map +0 -1
  60. package/dist/tools/handlers/updateSpec.d.ts +0 -3
  61. package/dist/tools/handlers/updateSpec.d.ts.map +0 -1
  62. package/dist/tools/handlers/updateSpec.js +0 -579
  63. package/dist/tools/handlers/updateSpec.js.map +0 -1
  64. package/dist/tools/handlers/validateSpec.d.ts +0 -3
  65. package/dist/tools/handlers/validateSpec.d.ts.map +0 -1
  66. package/dist/tools/handlers/validateSpec.js +0 -33
  67. package/dist/tools/handlers/validateSpec.js.map +0 -1
  68. package/dist/tools/templates/callbackHandler.d.ts +0 -11
  69. package/dist/tools/templates/callbackHandler.d.ts.map +0 -1
  70. package/dist/tools/templates/callbackHandler.js +0 -215
  71. package/dist/tools/templates/callbackHandler.js.map +0 -1
  72. package/dist/tools/templates/streamConsumer.d.ts +0 -8
  73. package/dist/tools/templates/streamConsumer.d.ts.map +0 -1
  74. package/dist/tools/templates/streamConsumer.js +0 -322
  75. package/dist/tools/templates/streamConsumer.js.map +0 -1
  76. package/dist/tools/util/userCodeMerge.d.ts +0 -69
  77. package/dist/tools/util/userCodeMerge.d.ts.map +0 -1
  78. package/dist/tools/util/userCodeMerge.js +0 -168
  79. package/dist/tools/util/userCodeMerge.js.map +0 -1
  80. package/dist/tools/validation/validateSpec.d.ts +0 -22
  81. package/dist/tools/validation/validateSpec.d.ts.map +0 -1
  82. package/dist/tools/validation/validateSpec.js +0 -623
  83. package/dist/tools/validation/validateSpec.js.map +0 -1
@@ -1,350 +0,0 @@
1
- // initSpec — populate the first real spec + emit the ExtentosCallbacks dispatch template.
2
- // Spec: docs/mcp/MCP_TOOLS.md § initSpec
3
- // The MCP server has no filesystem — "refuse if spec already populated" is advisory
4
- // and enforced by the agent calling inspectIntegration first (see tool description).
5
- //
6
- // Manifest contract: when the agent passes `currentManifest` (the manifest
7
- // returned by inspectIntegration / generateConnectionModule), this tool
8
- // applies its patch in-memory and returns the full next-state manifest under
9
- // `manifest: { path, content }`. The agent overwrites the file verbatim, no
10
- // agent-side merging required. Falls back to returning only `manifestPatch`
11
- // when `currentManifest` is omitted (legacy callers).
12
- import { createHash } from "node:crypto";
13
- import { existsSync, readFileSync } from "node:fs";
14
- import { join } from "node:path";
15
- import { androidSourcePath, iosModuleName } from "../util/appPackage.js";
16
- import { validateSpec } from "../validation/validateSpec.js";
17
- import { renderAndroidCallbacks, renderIosCallbacks } from "../templates/callbackHandler.js";
18
- import { PRESET_TRIGGERS, PRESET_TRIGGER_IDS } from "../data/presetTriggers.js";
19
- import { derivesInfoPlistPatch } from "../util/permissions.js";
20
- import { applyManifestPatch, manifestPath, } from "../util/manifest.js";
21
- import { okResponse, errorResponse } from "../response.js";
22
- import { hashGeneratedContent } from "../util/generatedHash.js";
23
- import { mergeUserCodeBlocks } from "../util/userCodeMerge.js";
24
- export function handleInitSpec(raw) {
25
- const parsed = parseArgs(raw);
26
- if ("error" in parsed)
27
- return parsed.error;
28
- const args = parsed.args;
29
- const mergedTriggers = mergeTriggers(args.presetTriggers, args.triggers);
30
- const spec = {
31
- $schema: "extentos://schema/v1",
32
- extentos_version: "1.0",
33
- target: { vendor: "meta_rayban" },
34
- blocks: args.blocks,
35
- streams: args.streams,
36
- triggers: mergedTriggers,
37
- };
38
- const validation = validateSpec(spec);
39
- const specContent = JSON.stringify(spec, null, 2);
40
- const specHash = sha256(specContent);
41
- const nowIso = new Date().toISOString();
42
- const handlerNames = validation.stats.handlerNames;
43
- const rawFiles = buildFiles(args.platform, args.appPackage, handlerNames);
44
- // If the agent passed projectPath, do server-side USER-CODE merge for any
45
- // create_or_merge file that already exists on disk. The action is upgraded
46
- // to "write" (verbatim) and the manifest hash is recomputed over the merged
47
- // content so live-vs-recorded matches by construction. See
48
- // util/userCodeMerge.ts for the full contract.
49
- //
50
- // F-R3-6: compute removed handler names from the manifest diff so true
51
- // orphans (handler removed from spec) get the ORPHANED label, while
52
- // developer-created shared utility blocks are preserved silently.
53
- const removedHandlerNames = removedTrackedNamesFromManifest(args.currentManifest, handlerNames);
54
- const files = rawFiles.map((f) => maybeMerge(f, args.projectPath, removedHandlerNames));
55
- const specPath = specPathFor(args.platform, args.appPackage);
56
- const permissionsDelta = args.platform === "android"
57
- ? {
58
- added: validation.stats.permissions,
59
- manifestEntries: validation.stats.permissions.map((p) => `<uses-permission android:name="${p}" />`),
60
- }
61
- : undefined;
62
- const infoPlistPatch = args.platform === "ios" ? derivesInfoPlistPatch(spec) : undefined;
63
- // Same rationale as updateSpec: manifest.permissions reflects the spec,
64
- // full-replace via permissionsSet so an empty/stale manifest self-heals on
65
- // first init. validation.stats.permissions covers Android only — iOS uses
66
- // Info.plist keys, which derivesInfoPlistPatch surfaces separately and which
67
- // don't get tracked in manifest.permissions today.
68
- const manifestPatch = {
69
- lastUpdatedAt: nowIso,
70
- integrationAdded: {
71
- blocks: args.blocks.map((b) => b.type).filter((x) => typeof x === "string").sort(),
72
- streams: args.streams.map((s) => s.type).filter((x) => typeof x === "string").sort(),
73
- triggers: Array.from(new Set(mergedTriggers.map((t) => t.type).filter((x) => typeof x === "string"))).sort(),
74
- handlerNames,
75
- togglesOverridden: collectTogglesOverridden(mergedTriggers),
76
- },
77
- generatedFilesAdded: files.map((f) => ({
78
- path: f.path,
79
- template: "callback_handler",
80
- hash: hashGeneratedContent(f.content),
81
- generatedAt: nowIso,
82
- generatedByTool: "initSpec",
83
- })),
84
- permissionsSet: args.platform === "android" ? [...validation.stats.permissions].sort() : undefined,
85
- specUpdated: { path: specPath, hash: `sha256:${specHash}`, updatedAt: nowIso },
86
- };
87
- const summary = buildSummary(args, handlerNames, validation);
88
- const response = {
89
- spec: { path: specPath, content: spec },
90
- files,
91
- permissionsDelta,
92
- validation: {
93
- passed: validation.valid,
94
- errors: validation.errors,
95
- warnings: validation.warnings,
96
- },
97
- basedOn: { hash: `sha256:${specHash}`, timestamp: nowIso },
98
- summary,
99
- };
100
- // Manifest contract (matches updateSpec, generateConsumer):
101
- // - currentManifest supplied → return `manifest: { path, content }` (full
102
- // next-state). Agent writes that file verbatim. manifestPatch is omitted
103
- // because two sources of truth invite double-apply bugs.
104
- // - currentManifest omitted → return `manifestPatch` only. Legacy fallback
105
- // for callers who haven't migrated to the round-trip pattern.
106
- if (args.currentManifest) {
107
- const next = applyManifestPatch(args.currentManifest, manifestPatch);
108
- response.manifest = { path: manifestPath(), content: next };
109
- }
110
- else {
111
- response.manifestPatch = manifestPatch;
112
- }
113
- if (infoPlistPatch)
114
- response.infoPlistPatch = infoPlistPatch;
115
- return okResponse(response);
116
- }
117
- function parseArgs(raw) {
118
- if (!raw || typeof raw !== "object") {
119
- return {
120
- error: errorResponse({
121
- code: "invalid_arguments",
122
- message: "initSpec requires an object argument.",
123
- fixHint: "Pass { blocks, triggers, platform, appPackage, ... }.",
124
- retryable: false,
125
- }),
126
- };
127
- }
128
- const obj = raw;
129
- if (!Array.isArray(obj.blocks)) {
130
- return {
131
- error: errorResponse({
132
- code: "invalid_arguments",
133
- message: "blocks is required and must be an array (may be empty).",
134
- fixHint: "Pass blocks: []",
135
- retryable: false,
136
- }),
137
- };
138
- }
139
- if (!Array.isArray(obj.triggers)) {
140
- return {
141
- error: errorResponse({
142
- code: "invalid_arguments",
143
- message: "triggers is required and must be an array.",
144
- fixHint: "Pass triggers: [{ type, id, actions: [...] }, ...]",
145
- retryable: false,
146
- }),
147
- };
148
- }
149
- if (obj.platform !== "android" && obj.platform !== "ios") {
150
- return {
151
- error: errorResponse({
152
- code: "invalid_arguments",
153
- message: `platform must be "android" or "ios" (got ${JSON.stringify(obj.platform)}).`,
154
- fixHint: "Pass platform: \"android\" or \"ios\".",
155
- retryable: false,
156
- }),
157
- };
158
- }
159
- if (typeof obj.appPackage !== "string" || obj.appPackage.length === 0) {
160
- return {
161
- error: errorResponse({
162
- code: "invalid_arguments",
163
- message: "appPackage is required and must be a non-empty string.",
164
- fixHint: "Pass the developer's package/bundle id, e.g. com.example.myapp.",
165
- retryable: false,
166
- }),
167
- };
168
- }
169
- const streams = Array.isArray(obj.streams) ? obj.streams : [];
170
- const rawPreset = Array.isArray(obj.presetTriggers) ? obj.presetTriggers : [];
171
- const presetTriggers = [];
172
- for (const p of rawPreset) {
173
- if (typeof p !== "string" || !PRESET_TRIGGER_IDS.includes(p)) {
174
- return {
175
- error: errorResponse({
176
- code: "invalid_arguments",
177
- message: `presetTriggers contains unknown preset ${JSON.stringify(p)}.`,
178
- fixHint: `Valid presets: ${PRESET_TRIGGER_IDS.join(", ")}.`,
179
- retryable: false,
180
- }),
181
- };
182
- }
183
- presetTriggers.push(p);
184
- }
185
- const currentManifest = obj.currentManifest && typeof obj.currentManifest === "object" && !Array.isArray(obj.currentManifest)
186
- ? obj.currentManifest
187
- : undefined;
188
- const projectPath = typeof obj.projectPath === "string" && obj.projectPath ? obj.projectPath : undefined;
189
- return {
190
- args: {
191
- blocks: obj.blocks,
192
- streams,
193
- triggers: obj.triggers,
194
- presetTriggers,
195
- platform: obj.platform,
196
- appPackage: obj.appPackage,
197
- currentManifest,
198
- projectPath,
199
- },
200
- };
201
- }
202
- // Compute names that were tracked by the spec last cycle (per the manifest)
203
- // but aren't tracked now — the diff that lets the merge utility decide which
204
- // in-existing-only USER-CODE blocks are TRUE orphans (handler removed from
205
- // spec; gets ORPHANED label) vs developer-created shared utility blocks
206
- // (preserved silently). See util/userCodeMerge.ts MergeOptions.
207
- function removedTrackedNamesFromManifest(manifest, newHandlerNames) {
208
- if (!manifest)
209
- return [];
210
- const integration = manifest.integration;
211
- if (!integration)
212
- return [];
213
- const previousHandlers = Array.isArray(integration.handlerNames)
214
- ? integration.handlerNames.filter((n) => typeof n === "string")
215
- : [];
216
- const previous = new Set([...previousHandlers, "imports"]);
217
- const next = new Set([...newHandlerNames, "imports"]);
218
- return [...previous].filter((n) => !next.has(n));
219
- }
220
- // When projectPath is provided, the action upgrades to "write" — the
221
- // server has done all the merge work the agent would otherwise have to
222
- // do, so the agent writes content verbatim. Two cases:
223
- //
224
- // - File exists on disk: run the server-side USER-CODE merge,
225
- // return action "write" with merged content + mergeReport.
226
- // - File doesn't exist (fresh integration): nothing to merge, but
227
- // still return action "write" with the raw template + an empty
228
- // mergeReport. F-R3-4: previously returned "create_or_merge" in
229
- // this case, contradicting the docstring "action becomes 'write'".
230
- // Functionally equivalent (both = "write the file fresh") but the
231
- // contract was inconsistent, so a strict agent that switches code
232
- // paths on the action would do extra work for no reason.
233
- //
234
- // When projectPath is omitted, fall through to the legacy
235
- // create_or_merge contract (agent does its own merge).
236
- function maybeMerge(raw, projectPath, removedTrackedNames = []) {
237
- if (!projectPath)
238
- return { ...raw };
239
- const abs = join(projectPath, raw.path);
240
- if (!existsSync(abs)) {
241
- return {
242
- path: raw.path,
243
- content: raw.content,
244
- action: "write",
245
- mergeReport: { preserved: [], orphaned: [], extra: [], warnings: [] },
246
- };
247
- }
248
- const existing = readFileSync(abs, "utf8");
249
- const result = mergeUserCodeBlocks(existing, raw.content, { removedTrackedNames });
250
- return {
251
- path: raw.path,
252
- content: result.merged,
253
- action: "write",
254
- mergeReport: {
255
- preserved: result.preserved,
256
- orphaned: result.orphaned,
257
- extra: result.extra,
258
- warnings: result.warnings,
259
- },
260
- };
261
- }
262
- function mergeTriggers(presetIds, agentTriggers) {
263
- const agentIds = new Set(agentTriggers.map((t) => t.id).filter((x) => typeof x === "string"));
264
- const expanded = [];
265
- for (const pid of presetIds) {
266
- const preset = PRESET_TRIGGERS[pid];
267
- if (agentIds.has(preset.id))
268
- continue;
269
- expanded.push(JSON.parse(JSON.stringify(preset)));
270
- }
271
- return [...expanded, ...agentTriggers];
272
- }
273
- function buildFiles(platform, appPackage, handlerNames) {
274
- // ExtentosCallbacks.{kt,swift} always contains USER-CODE-START/END blocks
275
- // for handler bodies, so the action MUST be `create_or_merge`. Previously
276
- // emitted as `create`, which would tell the agent to overwrite — losing
277
- // the dev's handler implementations on any re-emission. generateConsumer
278
- // already emits this same file with create_or_merge; this fix aligns
279
- // initSpec with that contract. See INTEGRATION_SHAPE.md § File-level actions.
280
- if (platform === "android") {
281
- const sourcePath = androidSourcePath(appPackage);
282
- return [
283
- {
284
- path: `app/src/main/java/${sourcePath}/extentos/ExtentosCallbacks.kt`,
285
- action: "create_or_merge",
286
- content: renderAndroidCallbacks(appPackage, handlerNames),
287
- },
288
- ];
289
- }
290
- const moduleName = iosModuleName(appPackage);
291
- return [
292
- {
293
- path: `Sources/${moduleName}/Extentos/ExtentosCallbacks.swift`,
294
- action: "create_or_merge",
295
- content: renderIosCallbacks(handlerNames),
296
- },
297
- ];
298
- }
299
- function specPathFor(platform, appPackage) {
300
- if (platform === "android")
301
- return "app/src/main/assets/extentos.spec.json";
302
- const moduleName = iosModuleName(appPackage);
303
- return `Sources/${moduleName}/Resources/extentos.spec.json`;
304
- }
305
- function collectTogglesOverridden(triggers) {
306
- const keys = new Set();
307
- const visit = (actions) => {
308
- if (!Array.isArray(actions))
309
- return;
310
- for (const a of actions) {
311
- if (!a || typeof a !== "object")
312
- continue;
313
- const rec = a;
314
- if (rec.type === "set_toggle" && typeof rec.key === "string")
315
- keys.add(rec.key);
316
- if (rec.type === "branch") {
317
- visit(rec.then);
318
- visit(rec.else);
319
- }
320
- if (rec.type === "retry_with_backoff" || rec.type === "when_connected") {
321
- if (rec.action)
322
- visit([rec.action]);
323
- }
324
- }
325
- };
326
- for (const t of triggers)
327
- visit(t.actions);
328
- return [...keys].sort();
329
- }
330
- function buildSummary(args, handlerNames, validation) {
331
- const parts = [
332
- `Generated spec with ${args.blocks.length} block${plural(args.blocks.length)}`,
333
- `${args.streams.length} stream${plural(args.streams.length)}`,
334
- `${args.triggers.length + args.presetTriggers.length} trigger${plural(args.triggers.length + args.presetTriggers.length)}`,
335
- ];
336
- const handlersPart = handlerNames.length
337
- ? `Callback handler has ${handlerNames.length} handler stub${plural(handlerNames.length)}: ${handlerNames.join(", ")}.`
338
- : `No app_callback handlers in this spec; ExtentosCallbacks is empty.`;
339
- const validationPart = validation.valid
340
- ? "Validation passed."
341
- : `Validation failed with ${validation.errors.length} error${plural(validation.errors.length)} — see validation.errors.`;
342
- return `${parts.join(", ")}. ${handlersPart} ${validationPart}`;
343
- }
344
- function plural(n) {
345
- return n === 1 ? "" : "s";
346
- }
347
- function sha256(content) {
348
- return createHash("sha256").update(content).digest("hex");
349
- }
350
- //# sourceMappingURL=initSpec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initSpec.js","sourceRoot":"","sources":["../../../src/tools/handlers/initSpec.ts"],"names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AK,YAAY,IAAI,cAAc,EAAE,CAAC;AAClE,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;AAC5B,CAAC;AAED,SAAS,MAAM,CAAC,OAAe;IAC7B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type McpContent } from "../response.js";
2
- export declare function handlePlanIntegration(raw: unknown): McpContent;
3
- //# sourceMappingURL=planIntegration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"planIntegration.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/planIntegration.ts"],"names":[],"mappings":"AAGA,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAqG5E,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,CAgG9D"}
@@ -1,293 +0,0 @@
1
- // planIntegration — map NL goal to deterministic tool-call sequence + primitive suggestions.
2
- // Spec: docs/mcp/MCP_TOOLS.md § planIntegration
3
- import { okResponse, errorResponse } from "../response.js";
4
- // Order matters: more specific phrases first.
5
- const KEYWORDS = [
6
- {
7
- match: /\btranslat(e|ion|or)\b/,
8
- streams: ["transcription_incremental"],
9
- handlers: ["translate"],
10
- pattern: "live_translation",
11
- },
12
- {
13
- match: /\b(notification|notify|alerts?)\b/,
14
- triggers: ["phone_notification_forwarded"],
15
- handlers: ["summarize_notification"],
16
- pattern: "notification_reader",
17
- },
18
- {
19
- match: /\b(describe|description|what.?s|identify|recognize|object|scene|see|look|vision)\b/,
20
- blocks: ["capture_photo", "speak_text"],
21
- triggers: ["voice_command"],
22
- handlers: ["describe_image"],
23
- pattern: "scene_description",
24
- },
25
- {
26
- match: /\b(photo|picture|snapshot|capture)\b/,
27
- blocks: ["capture_photo"],
28
- triggers: ["voice_command", "capture_button"],
29
- pattern: "scene_description",
30
- },
31
- {
32
- match: /\bvideo\b/,
33
- blocks: ["capture_video"],
34
- triggers: ["voice_command"],
35
- },
36
- {
37
- match: /\b(navigat|direction|way|route|map)\b/,
38
- triggers: ["voice_command", "location_updated"],
39
- handlers: ["get_directions"],
40
- pattern: "navigation_guide",
41
- },
42
- {
43
- match: /\b(call|phone|video.?call|meeting)\b/,
44
- streams: ["outgoing_video_stream", "outgoing_audio_stream"],
45
- pattern: "video_call",
46
- },
47
- {
48
- match: /\bdetect(ion)?\b/,
49
- streams: ["video_frames"],
50
- handlers: ["detect_objects"],
51
- pattern: "object_detection",
52
- },
53
- {
54
- match: /\b(notes?|dictation|transcrib|memo)\b/,
55
- blocks: ["record_audio"],
56
- streams: ["transcription_incremental"],
57
- triggers: ["voice_command"],
58
- handlers: ["save_note"],
59
- pattern: "voice_notes",
60
- },
61
- {
62
- match: /\b(voice|speak|command|assistant|chat|ask|question)\b/,
63
- triggers: ["voice_command"],
64
- blocks: ["speak_text"],
65
- handlers: ["answer_question"],
66
- pattern: "voice_assistant",
67
- },
68
- {
69
- match: /\b(music|audio|sound)\b/,
70
- blocks: ["speak_text"],
71
- },
72
- {
73
- match: /\b(tap|gesture)\b/,
74
- triggers: ["tap"],
75
- },
76
- {
77
- match: /\b(incoming.?call|ring)\b/,
78
- triggers: ["incoming_call_detected"],
79
- },
80
- ];
81
- export function handlePlanIntegration(raw) {
82
- const parsed = parseArgs(raw);
83
- if ("error" in parsed)
84
- return parsed.error;
85
- const { goal, platform, hasExistingIntegration } = parsed;
86
- const lower = goal.toLowerCase();
87
- const blocks = new Set();
88
- const streams = new Set();
89
- const triggers = new Set();
90
- const handlers = new Set();
91
- let referencePattern = null;
92
- // Merge rule (documented in MCP_TOOLS.md § planIntegration):
93
- // 1. KEYWORDS entries with a `pattern:` field are exclusive — only the
94
- // FIRST matching pattern entry contributes its primitives. This
95
- // prevents over-suggestion when a goal mentions both "voice notes"
96
- // (matches `voice_notes`) and "voice command" (matches
97
- // `voice_assistant`) — we emit only the voice_notes pattern's
98
- // primitives, not a noisy union of both.
99
- // 2. KEYWORDS entries WITHOUT a `pattern:` field are additive (e.g.
100
- // `tap` adds the tap trigger; `music` adds speak_text). They stack
101
- // with the chosen pattern.
102
- for (const kw of KEYWORDS) {
103
- if (!kw.match.test(lower))
104
- continue;
105
- if (kw.pattern) {
106
- if (referencePattern)
107
- continue; // already locked in a pattern
108
- referencePattern = kw.pattern;
109
- }
110
- kw.blocks?.forEach((b) => blocks.add(b));
111
- kw.streams?.forEach((s) => streams.add(s));
112
- kw.triggers?.forEach((t) => triggers.add(t));
113
- kw.handlers?.forEach((h) => handlers.add(h));
114
- }
115
- if (triggers.has("voice_command") && blocks.size === 0 && streams.size === 0) {
116
- blocks.add("speak_text");
117
- }
118
- const warnings = [];
119
- const presetTriggers = [];
120
- if (triggers.has("voice_command") ||
121
- triggers.has("wake_word") ||
122
- triggers.has("push_to_talk")) {
123
- presetTriggers.push("fallback_default");
124
- }
125
- if (streams.size > 0) {
126
- presetTriggers.push("thermal_throttle");
127
- }
128
- if (streams.size > 0 && !triggers.has("connection_state_changed")) {
129
- presetTriggers.push("disconnect_announce");
130
- }
131
- if (blocks.size + streams.size + triggers.size === 0) {
132
- warnings.push("No primitives matched the goal keywords. Consider the 8 canonical patterns (use getExampleSpec) or rephrase the goal with concrete actions.");
133
- }
134
- if (triggers.has("voice_command") && blocks.has("speak_text") && handlers.size === 0) {
135
- warnings.push("Voice-in/voice-out flow without an app_callback — confirm the AI processing step is intentional or add a handler.");
136
- }
137
- const toolSequence = buildToolSequence({
138
- hasExistingIntegration: Boolean(hasExistingIntegration),
139
- platform,
140
- handlers: [...handlers],
141
- streams: [...streams],
142
- presetTriggers,
143
- referencePattern,
144
- });
145
- const response = {
146
- toolSequence,
147
- suggestedBlocks: [...blocks].sort(),
148
- suggestedStreams: [...streams].sort(),
149
- suggestedTriggers: [...triggers].sort(),
150
- suggestedPresets: [...presetTriggers],
151
- suggestedHandlers: [...handlers].sort(),
152
- warnings,
153
- estimatedSetupSteps: toolSequence.length,
154
- referencePattern,
155
- summary: buildSummary({
156
- platform,
157
- blocks: [...blocks],
158
- streams: [...streams],
159
- triggers: [...triggers],
160
- handlers: [...handlers],
161
- referencePattern,
162
- hasExistingIntegration: Boolean(hasExistingIntegration),
163
- }),
164
- };
165
- return okResponse(response);
166
- }
167
- function buildToolSequence(opts) {
168
- const seq = [];
169
- let step = 1;
170
- seq.push({
171
- step: step++,
172
- tool: "getPlatformInfo",
173
- params: { sections: ["version", "capabilities"], glasses: "meta_rayban" },
174
- note: "Fetch library version and capability surface for the current glasses target.",
175
- });
176
- if (opts.referencePattern) {
177
- seq.push({
178
- step: step++,
179
- tool: "getExampleSpec",
180
- params: { pattern: opts.referencePattern },
181
- note: `Grab the ${opts.referencePattern} reference spec as a starting point.`,
182
- });
183
- }
184
- if (!opts.hasExistingIntegration) {
185
- seq.push({
186
- step: step++,
187
- tool: "generateConnectionModule",
188
- params: { platform: opts.platform, glasses: "meta_rayban" },
189
- note: "One-shot project scaffold: bootstrap, manifest, dependency, empty spec.",
190
- });
191
- seq.push({
192
- step: step++,
193
- tool: "initSpec",
194
- params: opts.presetTriggers.length
195
- ? { platform: opts.platform, presetTriggers: opts.presetTriggers }
196
- : { platform: opts.platform },
197
- note: "Populate the first real spec with blocks/streams/triggers from the example + keyword matches.",
198
- });
199
- }
200
- else {
201
- seq.push({
202
- step: step++,
203
- tool: "inspectIntegration",
204
- note: "Read current integration state (manifest + spec + file hashes) to get the basedOn freshness token.",
205
- });
206
- seq.push({
207
- step: step++,
208
- tool: "updateSpec",
209
- note: "Apply the new primitives as patch operations against the inspected basedOn.",
210
- });
211
- }
212
- if (opts.handlers.length) {
213
- seq.push({
214
- step: step++,
215
- tool: "generateConsumer",
216
- params: {
217
- kind: "callback",
218
- platform: opts.platform,
219
- handlers: opts.handlers.map((name) => ({ name })),
220
- },
221
- note: `Stub the ${opts.handlers.length} app_callback handler${opts.handlers.length === 1 ? "" : "s"} on ${opts.platform}.`,
222
- });
223
- }
224
- if (opts.streams.length) {
225
- seq.push({
226
- step: step++,
227
- tool: "generateConsumer",
228
- params: {
229
- kind: "stream",
230
- platform: opts.platform,
231
- streams: opts.streams.map((id) => ({ id, type: id })),
232
- },
233
- note: `Generate stream consumer scaffolds for ${opts.streams.length} stream${opts.streams.length === 1 ? "" : "s"}.`,
234
- });
235
- }
236
- seq.push({
237
- step: step++,
238
- tool: "validateIntegration",
239
- note: "Pre-testing correctness gate: spec + files + manifest + permissions + handler coverage.",
240
- });
241
- seq.push({
242
- step: step++,
243
- tool: "createSimulatorSession",
244
- note: "Provision a browser simulator session to test the flow end-to-end.",
245
- });
246
- return seq;
247
- }
248
- function buildSummary(opts) {
249
- const primitives = opts.blocks.length + opts.streams.length + opts.triggers.length + opts.handlers.length;
250
- const origin = opts.hasExistingIntegration ? "existing project" : "new project";
251
- const pattern = opts.referencePattern
252
- ? ` Referenced pattern: ${opts.referencePattern}.`
253
- : "";
254
- return `Plan for ${origin} on ${opts.platform}: ${primitives} suggested primitive${primitives === 1 ? "" : "s"} (${opts.blocks.length} block${s(opts.blocks.length)}, ${opts.streams.length} stream${s(opts.streams.length)}, ${opts.triggers.length} trigger${s(opts.triggers.length)}, ${opts.handlers.length} handler${s(opts.handlers.length)}).${pattern}`;
255
- }
256
- function s(n) {
257
- return n === 1 ? "" : "s";
258
- }
259
- function parseArgs(raw) {
260
- if (!raw || typeof raw !== "object") {
261
- return {
262
- error: errorResponse({
263
- code: "invalid_arguments",
264
- message: "planIntegration requires { goal, platform, glasses }.",
265
- fixHint: 'Pass { goal: "...", platform: "android" | "ios", glasses: "meta_rayban" }.',
266
- retryable: false,
267
- }),
268
- };
269
- }
270
- const obj = raw;
271
- if (typeof obj.goal !== "string" || !obj.goal.trim()) {
272
- return errInvalid("goal is required and must be a non-empty string.", 'Pass goal: "<plain-English goal>".');
273
- }
274
- if (obj.platform !== "android" && obj.platform !== "ios") {
275
- return errInvalid(`platform must be "android" or "ios" (got ${JSON.stringify(obj.platform)}).`, 'Pass platform: "android" or "ios".');
276
- }
277
- return {
278
- goal: obj.goal,
279
- platform: obj.platform,
280
- hasExistingIntegration: typeof obj.hasExistingIntegration === "boolean" ? obj.hasExistingIntegration : undefined,
281
- };
282
- }
283
- function errInvalid(message, fixHint) {
284
- return {
285
- error: errorResponse({
286
- code: "invalid_arguments",
287
- message,
288
- fixHint,
289
- retryable: false,
290
- }),
291
- };
292
- }
293
- //# sourceMappingURL=planIntegration.js.map