aai-gateway 0.2.0 → 0.3.1

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.
package/README.md CHANGED
@@ -1,22 +1,117 @@
1
1
  # AAI Gateway
2
2
 
3
- A Model Context Protocol (MCP) server that bridges AI agents to AAI-enabled desktop and web applications. Discovers apps via standard `aai.json` descriptors, invokes them through native IPC or OAuth 2.1 PKCE HTTP, with native consent dialogs and secure credential storage.
3
+ **One MCP to access all desktop and web applications.**
4
4
 
5
- Reference implementation of the [AAI Protocol](https://github.com/gybob/aai-protocol).
5
+ A Model Context Protocol (MCP) server that bridges AI agents to desktop and web applications through the [AAI Protocol](https://github.com/gybob/aai-protocol).
6
6
 
7
- ### Key Features
7
+ ## The Innovation: Progressive Disclosure
8
8
 
9
- - **Tool discovery**. All discovered app tools exposed via `tools/list` for seamless MCP client integration.
10
- - **Native security**. Leverages OS-level consent (TCC, UAC, Polkit) and secure storage (Keychain, Credential Manager).
11
- - **Cross-platform**. Supports macOS today, Linux and Windows planned.
9
+ **Problem**: Traditional MCP servers load all tools upfront, causing context explosion.
12
10
 
13
- ### Requirements
11
+ ```
12
+ Traditional: tools/list returns 1000+ tools from 50 apps
13
+ → Context window blown
14
+ → Agent confused
15
+ → Performance degraded
16
+ ```
17
+
18
+ **Our Solution**: Guide-based progressive disclosure.
19
+
20
+ ```
21
+ AAI Gateway: tools/list returns 50 app entries + 2 universal tools
22
+ → O(apps + 2) instead of O(apps × tools)
23
+ → Agent calls app:<id> to get tool guide on-demand
24
+ → Context stays minimal
25
+ ```
26
+
27
+ This innovation enables agents to discover and use thousands of tools without overwhelming the context window.
28
+
29
+ ## How It Works
30
+
31
+ ```
32
+ ┌─────────────────────────────────────────────────────────────────┐
33
+ │ Desktop App Workflow │
34
+ ├─────────────────────────────────────────────────────────────────┤
35
+ │ │
36
+ │ 1. tools/list │
37
+ │ └─→ Returns: ["app:com.apple.mail", "app:com.apple.calendar",
38
+ │ "web:discover", "aai:exec"] │
39
+ │ Only 4 entries! (Not 50+ tools) │
40
+ │ │
41
+ │ 2. User: "Send an email to John" │
42
+ │ └─→ Agent matches "email" → calls app:com.apple.mail │
43
+ │ │
44
+ │ 3. tools/call("app:com.apple.mail") │
45
+ │ └─→ Returns: Operation guide with available tools │
46
+ │ - sendEmail(to, subject, body) │
47
+ │ - readInbox(folder, limit) │
48
+ │ - ... │
49
+ │ │
50
+ │ 4. tools/call("aai:exec", {app, tool: "sendEmail", args}) │
51
+ │ └─→ Executes operation │
52
+ │ │
53
+ └─────────────────────────────────────────────────────────────────┘
54
+
55
+ ┌─────────────────────────────────────────────────────────────────┐
56
+ │ Web App Workflow │
57
+ ├─────────────────────────────────────────────────────────────────┤
58
+ │ │
59
+ │ 1. User: "Search my Notion workspace" │
60
+ │ └─→ Agent matches "Notion" → calls web:discover │
61
+ │ │
62
+ │ 2. tools/call("web:discover", {url: "notion.com"}) │
63
+ │ └─→ Returns: Operation guide with available tools │
64
+ │ - listDatabases(), queryDatabase(id), search(query) │
65
+ │ - ... │
66
+ │ │
67
+ │ 3. tools/call("aai:exec", {app: "notion.com", tool, args}) │
68
+ │ └─→ Executes operation │
69
+ │ │
70
+ └─────────────────────────────────────────────────────────────────┘
71
+ ```
72
+
73
+ **Context Efficiency**:
74
+
75
+ - Traditional: 50 apps × 20 tools = 1000 context entries
76
+ - AAI Gateway: 50 apps + 2 = 52 context entries
77
+
78
+ ## Features
79
+
80
+ - **Progressive Disclosure**. Apps expose operation guides on-demand, preventing context explosion.
81
+ - **Multi-language Support**. App names support multiple languages for better intent matching.
82
+ - **Native Security**. Leverages OS-level consent (TCC, UAC, Polkit) and secure storage (Keychain).
83
+ - **Cross-platform**. macOS today, Linux and Windows planned.
84
+
85
+ ## Supported Apps
86
+
87
+ ### Desktop Apps (AAI-enabled)
88
+
89
+ Apps shipping `aai.json` descriptor:
90
+
91
+ | App | Platform | Tools |
92
+ | --------------- | -------- | ----------------------------------------------- |
93
+ | macOS Reminders | macOS | createReminder, listReminders, completeReminder |
94
+ | Your app here | - | - |
95
+
96
+ ### Web Apps (Built-in Descriptors)
97
+
98
+ Pre-configured descriptors for cold-start scenarios when `.well-known/aai.json` is unavailable:
99
+
100
+ | App | Auth Type | Description |
101
+ | ----------------- | -------------- | ------------------------ |
102
+ | **Notion** | API Key | All-in-one workspace |
103
+ | **Yuque (语雀)** | API Key | Knowledge management |
104
+ | **Feishu (飞书)** | App Credential | Enterprise collaboration |
105
+
106
+ _More built-in descriptors being added. [Request one](https://github.com/gybob/aai-gateway/issues)_
107
+
108
+ ## Requirements
14
109
 
15
110
  - Node.js 18 or newer
16
111
  - macOS (Linux and Windows support planned)
17
112
  - VS Code, Cursor, Windsurf, Claude Desktop, or any MCP client
18
113
 
19
- ### Getting started
114
+ ## Getting Started
20
115
 
21
116
  Add AAI Gateway to your MCP client configuration.
22
117
 
@@ -67,8 +162,6 @@ Go to `Cursor Settings` -> `MCP` -> `Add new MCP Server`. Name: `aai-gateway`, t
67
162
 
68
163
  </details>
69
164
 
70
- </details>
71
-
72
165
  <details>
73
166
  <summary>OpenCode</summary>
74
167
 
@@ -104,16 +197,14 @@ With `--dev` flag:
104
197
 
105
198
  </details>
106
199
 
107
- ### Configuration
108
-
109
- AAI Gateway supports the following command-line arguments:
200
+ ## Configuration
110
201
 
111
- | Option | Description |
112
- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
113
- | `--dev` | Enable development mode. Scans Xcode build directories for apps in development: `~/Library/Developer/Xcode/DerivedData/*/Build/Products/{Debug,Release}/*.app` |
114
- | `--scan` | Scan for AAI-enabled apps and exit (for debugging) |
115
- | `--version` | Show version |
116
- | `--help` | Show help |
202
+ | Option | Description |
203
+ | ----------- | ------------------------------------------------------------------------------ |
204
+ | `--dev` | Enable development mode. Scans Xcode build directories for apps in development |
205
+ | `--scan` | Scan for AAI-enabled apps and exit (for debugging) |
206
+ | `--version` | Show version |
207
+ | `--help` | Show help |
117
208
 
118
209
  **Development mode example:**
119
210
 
@@ -128,91 +219,124 @@ AAI Gateway supports the following command-line arguments:
128
219
  }
129
220
  ```
130
221
 
131
- Use `--dev` when developing AAI-enabled applications in Xcode to discover apps before they're installed to `/Applications`.
222
+ ## MCP Interface
132
223
 
133
- ### MCP Interface
224
+ AAI Gateway exposes **tools only** (no resources). This simplifies the agent workflow.
134
225
 
135
- AAI Gateway exposes standard MCP primitives: `resources/list`, `resources/read`, `tools/list`, and `tools/call`.
136
- #### `resources/list`
226
+ ### `tools/list`
137
227
 
138
- Returns all AAI-enabled apps discovered on the current machine.
228
+ Returns discovered desktop apps plus universal tools:
139
229
 
140
230
  ```json
141
231
  {
142
- "resources": [
232
+ "tools": [
233
+ {
234
+ "name": "app:com.apple.reminders",
235
+ "description": "【Reminders|提醒事项|Rappels】macOS reminders app. Aliases: todo, 待办. Call to get guide.",
236
+ "inputSchema": { "type": "object", "properties": {} }
237
+ },
143
238
  {
144
- "uri": "app:com.acme.crm",
145
- "name": "Acme CRM",
146
- "description": "Customer relationship management"
239
+ "name": "web:discover",
240
+ "description": "Discover web app guide. Use when user mentions a web service not in list.",
241
+ "inputSchema": {
242
+ "type": "object",
243
+ "properties": {
244
+ "url": { "type": "string", "description": "Web app URL, domain, or name" }
245
+ },
246
+ "required": ["url"]
247
+ }
147
248
  },
148
249
  {
149
- "uri": "app:com.acme.invoice",
150
- "name": "Acme Invoice",
151
- "description": "Invoice and billing management"
250
+ "name": "aai:exec",
251
+ "description": "Execute app operation. Use after reading the operation guide.",
252
+ "inputSchema": {
253
+ "type": "object",
254
+ "properties": {
255
+ "app": { "type": "string", "description": "App ID or URL" },
256
+ "tool": { "type": "string", "description": "Operation name" },
257
+ "args": { "type": "object", "description": "Operation parameters" }
258
+ },
259
+ "required": ["app", "tool"]
260
+ }
152
261
  }
153
262
  ]
154
263
  }
155
264
  ```
156
265
 
157
- #### `resources/read`
266
+ ### App Tool (`app:*`)
158
267
 
159
- Accepts two URI types:
268
+ Call `app:<app-id>` to get an operation guide:
160
269
 
161
- - **`app:<bundle-id>`** — reads the descriptor for a locally installed desktop app
162
- - **`https://<domain>`** — fetches `/.well-known/aai.json` from a web service (cached 24h)
270
+ ```json
271
+ {
272
+ "name": "app:com.apple.reminders",
273
+ "arguments": {}
274
+ }
275
+ ```
163
276
 
164
- Returns the full `aai.json` descriptor including the app's tool list and schemas.
277
+ Returns a guide with available operations, parameters, and usage examples.
165
278
 
166
- #### `tools/list`
279
+ ### Web Discovery (`web:discover`)
167
280
 
168
- Returns all tools from all discovered apps. Each tool name is prefixed with the app's bundle ID to avoid collisions.
281
+ Discover web apps by URL, domain, or name:
169
282
 
170
283
  ```json
171
284
  {
172
- "tools": [
173
- {
174
- "name": "com.acme.crm:create_contact",
175
- "description": "Create a new contact in the CRM",
176
- "inputSchema": { ... }
177
- },
178
- {
179
- "name": "com.acme.invoice:send_invoice",
180
- "description": "Send an invoice to a customer",
181
- "inputSchema": { ... }
182
- }
183
- ]
285
+ "name": "web:discover",
286
+ "arguments": { "url": "notion.com" }
184
287
  }
185
288
  ```
186
289
 
187
- #### `tools/call`
290
+ Returns the web app's operation guide.
291
+
292
+ ### Tool Execution (`aai:exec`)
188
293
 
189
- Tool name format: `<app-id>:<tool-name>`
294
+ Execute operations after reading the guide:
190
295
 
191
296
  ```json
192
297
  {
193
- "name": "com.acme.crm:create_contact",
194
- "arguments": { "name": "Alice", "email": "alice@example.com", "company": "Example Inc." }
298
+ "name": "aai:exec",
299
+ "arguments": {
300
+ "app": "com.apple.reminders",
301
+ "tool": "createReminder",
302
+ "args": {
303
+ "title": "Submit report",
304
+ "due": "2024-12-31 15:00"
305
+ }
306
+ }
195
307
  }
196
308
  ```
197
309
 
198
310
  **Execution flow:**
199
311
 
200
- 1. Resolve app descriptor (local registry or web fetch)
201
- 2. Validate tool and arguments
202
- 3. Show native consent dialog — user approves/denies (remembered per tool or globally)
203
- 4. Execute: desktop apps via native IPC, web apps via HTTP with OAuth 2.1 PKCE token
204
- 5. Return result
312
+ 1. Resolve app descriptor (local, built-in, or web fetch)
313
+ 2. Show native consent dialog — user approves/denies
314
+ 3. **Auth**:
315
+ - Desktop apps: Native IPC
316
+ - Web apps: OAuth 2.1 PKCE, API Key, App Credential, or Cookie
317
+ 4. Execute and return result
318
+
319
+ ## Authentication Types
320
+
321
+ | Auth Type | Use Case | User Flow |
322
+ | --------------- | ------------------ | ---------------------------------- |
323
+ | `oauth2` | User authorization | Browser-based OAuth 2.0 with PKCE |
324
+ | `apiKey` | Static API tokens | Dialog prompts for token |
325
+ | `appCredential` | Enterprise apps | Dialog prompts for App ID + Secret |
326
+ | `cookie` | No official API | Manual cookie extraction |
205
327
 
206
- ### Platform Support
328
+ ## Platform Support
207
329
 
208
- | Platform | Discovery | IPC Executor | Consent Dialog | Secure Storage |
209
- | -------- | ------------------------- | ------------------------ | ----------------- | --------------------- |
210
- | macOS | ✅ | ✅ Apple Events | ✅ osascript | ✅ Keychain |
211
- | Linux | 🔜 | 🔜 DBus | 🔜 zenity/kdialog | 🔜 libsecret |
212
- | Windows | 🔜 | 🔜 COM | 🔜 PowerShell | 🔜 Credential Manager |
213
- | Web | ✅ `.well-known/aai.json` | ✅ HTTP + OAuth 2.1 PKCE | — | ✅ (via platform) |
330
+ | Platform | Discovery | IPC Executor | Consent Dialog | Secure Storage |
331
+ | -------- | ------------------------- | --------------- | ----------------- | --------------------- |
332
+ | macOS | ✅ | ✅ Apple Events | ✅ osascript | ✅ Keychain |
333
+ | Linux | ⚠️ XDG paths | ⚠️ DBus | ⚠️ zenity/kdialog | ⚠️ libsecret |
334
+ | Windows | ⚠️ Program Files | ⚠️ COM | ⚠️ PowerShell | ⚠️ Credential Manager |
335
+ | Web | ✅ `.well-known/aai.json` | ✅ HTTP + Auth | — | ✅ (via platform) |
214
336
 
215
- ### For App Developers
337
+ **Legend**: Fully implemented | ⚠️ Stub implementation (throws NOT_IMPLEMENTED) | 🔜 Planned
338
+
339
+ ## For App Developers
216
340
 
217
341
  To make your app discoverable by AAI Gateway, ship an `aai.json` descriptor:
218
342
 
@@ -220,9 +344,39 @@ To make your app discoverable by AAI Gateway, ship an `aai.json` descriptor:
220
344
 
221
345
  **Web:** `https://<your-domain>/.well-known/aai.json`
222
346
 
223
- See the [AAI Protocol Spec](https://github.com/gybob/aai-protocol) for the full `aai.json` schema.
347
+ **Example:**
348
+
349
+ ```json
350
+ {
351
+ "schemaVersion": "1.0",
352
+ "version": "1.0.0",
353
+ "platform": "web",
354
+ "app": {
355
+ "id": "com.example.api",
356
+ "name": {
357
+ "en": "Example App",
358
+ "zh-CN": "示例应用"
359
+ },
360
+ "defaultLang": "en",
361
+ "description": "Brief description",
362
+ "aliases": ["example", "示例"]
363
+ },
364
+ "auth": {
365
+ "type": "apiKey",
366
+ "apiKey": {
367
+ "location": "header",
368
+ "name": "Authorization",
369
+ "prefix": "Bearer",
370
+ "obtainUrl": "https://example.com/settings/tokens"
371
+ }
372
+ },
373
+ "tools": [...]
374
+ }
375
+ ```
376
+
377
+ See the [AAI Protocol Spec](https://github.com/gybob/aai-protocol) for the full schema.
224
378
 
225
- ### Debugging
379
+ ## Debugging
226
380
 
227
381
  ```bash
228
382
  # List discovered AAI-enabled apps
@@ -232,7 +386,7 @@ npx aai-gateway --scan
232
386
  npx aai-gateway --scan --dev
233
387
  ```
234
388
 
235
- ### Development
389
+ ## Development
236
390
 
237
391
  ```bash
238
392
  npm install
@@ -241,10 +395,11 @@ npm test
241
395
  npm run build
242
396
  ```
243
397
 
244
- ### Links
398
+ ## Links
245
399
 
246
400
  - [AAI Protocol Spec](https://github.com/gybob/aai-protocol)
401
+ - [Report Issues](https://github.com/gybob/aai-gateway/issues)
247
402
 
248
- ### License
403
+ ## License
249
404
 
250
405
  Apache-2.0
package/dist/cli.js CHANGED
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { b as createDesktopDiscovery, d as createGatewayServer, l as logger } from "./server-BIZIyh-I.js";
3
- const VERSION = "0.2.0";
2
+ import { b as createDesktopDiscovery, d as createGatewayServer, l as logger } from "./server-B-dyXrfc.js";
3
+ import { readFileSync } from "fs";
4
+ import { fileURLToPath } from "url";
5
+ import { dirname, join } from "path";
6
+ const __filename$1 = fileURLToPath(import.meta.url);
7
+ const __dirname$1 = dirname(__filename$1);
8
+ const packageJson = JSON.parse(readFileSync(join(__dirname$1, "../package.json"), "utf-8"));
9
+ const VERSION = packageJson.version;
4
10
  function parseArgs(args) {
5
11
  return {
6
12
  scan: args.includes("--scan"),
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { createGatewayServer } from './mcp/server.js';\nimport { createDesktopDiscovery } from './discovery/index.js';\nimport { logger } from './utils/logger.js';\n\nconst VERSION = '0.2.0';\n\ninterface CliOptions {\n scan: boolean;\n dev: boolean;\n version: boolean;\n help: boolean;\n}\n\nfunction parseArgs(args: string[]): CliOptions {\n return {\n scan: args.includes('--scan'),\n dev: args.includes('--dev'),\n version: args.includes('--version'),\n help: args.includes('--help') || args.includes('-h'),\n };\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n const options = parseArgs(args);\n\n if (options.help) {\n console.log(`\nAAI Gateway - Agent App Interface Protocol Gateway\n\nUsage:\n aai-gateway [options]\n\nOptions:\n --scan Scan for AAI-enabled desktop apps and exit\n --dev Enable development mode (scan Xcode build directories)\n --version Show version\n --help, -h Show this help message\n\nEnvironment Variables:\n AAI_LOG_LEVEL Log level (debug, info, warn, error)\n\nDevelopment Mode:\n When --dev is used with --scan or MCP server, the gateway will also scan\n Xcode build directories for apps in development:\n ~/Library/Developer/Xcode/DerivedData/*/Build/Products/Debug\n ~/Library/Developer/Xcode/DerivedData/*/Build/Products/Release\n\nDefault mode starts an MCP server over stdio.\n`);\n process.exit(0);\n }\n\n if (options.version) {\n console.log(`aai-gateway v${VERSION}`);\n process.exit(0);\n }\n\n if (options.scan) {\n try {\n const discovery = createDesktopDiscovery();\n const apps = await discovery.scan({ devMode: options.dev });\n\n console.log('\\nDiscovered AAI-enabled Applications:');\n console.log('=====================================\\n');\n\n if (apps.length === 0) {\n console.log('No applications found.');\n if (options.dev) {\n console.log('Apps must ship /Applications/<Name>.app/Contents/Resources/aai.json');\n console.log(\n 'Or in Xcode build: ~/Library/Developer/Xcode/DerivedData/*/Build/Products/Debug/<Name>.app/Contents/Resources/aai.json'\n );\n } else {\n console.log('Apps must ship /Applications/<Name>.app/Contents/Resources/aai.json');\n console.log('Tip: Use --dev to also scan Xcode build directories.');\n }\n } else {\n for (const app of apps) {\n console.log(` ${app.appId}`);\n console.log(` Name: ${app.name}`);\n console.log(` Bundle: ${app.bundlePath}`);\n console.log(` Description: ${app.description}`);\n console.log('');\n }\n console.log(`Total: ${apps.length} application(s)`);\n if (options.dev) {\n console.log('(Development mode: scanned Xcode build directories)');\n }\n }\n } catch (err) {\n console.error('Scan failed:', err);\n process.exit(1);\n }\n process.exit(0);\n }\n\n // Default: start MCP server\n try {\n const gateway = await createGatewayServer({ devMode: options.dev });\n await gateway.start();\n } catch (err) {\n logger.fatal({ err }, 'Failed to start AAI Gateway');\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error('Fatal error:', err);\n process.exit(1);\n});\n"],"names":[],"mappings":";;AAMA,MAAM,UAAU;AAShB,SAAS,UAAU,MAA4B;AAC7C,SAAO;AAAA,IACL,MAAM,KAAK,SAAS,QAAQ;AAAA,IAC5B,KAAK,KAAK,SAAS,OAAO;AAAA,IAC1B,SAAS,KAAK,SAAS,WAAW;AAAA,IAClC,MAAM,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI;AAAA,EAAA;AAEvD;AAEA,eAAe,OAAsB;AACnC,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,QAAM,UAAU,UAAU,IAAI;AAE9B,MAAI,QAAQ,MAAM;AAChB,YAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AAQ,MAAA;AAAA,EAChB,SAAS,KAAK;AACZ,WAAO,MAAM,EAAE,IAAA,GAAO,6BAA6B;AACnD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,OAAO,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,gBAAgB,GAAG;AACjC,UAAQ,KAAK,CAAC;AAChB,CAAC;"}
1
+ {"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { createGatewayServer } from './mcp/server.js';\nimport { createDesktopDiscovery } from './discovery/index.js';\nimport { logger } from './utils/logger.js';\nimport { readFileSync } from 'fs';\nimport { fileURLToPath } from 'url';\nimport { dirname, join } from 'path';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst packageJson = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));\nconst VERSION = packageJson.version;\n\n\ninterface CliOptions {\n scan: boolean;\n dev: boolean;\n version: boolean;\n help: boolean;\n}\n\nfunction parseArgs(args: string[]): CliOptions {\n return {\n scan: args.includes('--scan'),\n dev: args.includes('--dev'),\n version: args.includes('--version'),\n help: args.includes('--help') || args.includes('-h'),\n };\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n const options = parseArgs(args);\n\n if (options.help) {\n console.log(`\nAAI Gateway - Agent App Interface Protocol Gateway\n\nUsage:\n aai-gateway [options]\n\nOptions:\n --scan Scan for AAI-enabled desktop apps and exit\n --dev Enable development mode (scan Xcode build directories)\n --version Show version\n --help, -h Show this help message\n\nEnvironment Variables:\n AAI_LOG_LEVEL Log level (debug, info, warn, error)\n\nDevelopment Mode:\n When --dev is used with --scan or MCP server, the gateway will also scan\n Xcode build directories for apps in development:\n ~/Library/Developer/Xcode/DerivedData/*/Build/Products/Debug\n ~/Library/Developer/Xcode/DerivedData/*/Build/Products/Release\n\nDefault mode starts an MCP server over stdio.\n`);\n process.exit(0);\n }\n\n if (options.version) {\n console.log(`aai-gateway v${VERSION}`);\n process.exit(0);\n }\n\n if (options.scan) {\n try {\n const discovery = createDesktopDiscovery();\n const apps = await discovery.scan({ devMode: options.dev });\n\n console.log('\\nDiscovered AAI-enabled Applications:');\n console.log('=====================================\\n');\n\n if (apps.length === 0) {\n console.log('No applications found.');\n if (options.dev) {\n console.log('Apps must ship /Applications/<Name>.app/Contents/Resources/aai.json');\n console.log(\n 'Or in Xcode build: ~/Library/Developer/Xcode/DerivedData/*/Build/Products/Debug/<Name>.app/Contents/Resources/aai.json'\n );\n } else {\n console.log('Apps must ship /Applications/<Name>.app/Contents/Resources/aai.json');\n console.log('Tip: Use --dev to also scan Xcode build directories.');\n }\n } else {\n for (const app of apps) {\n console.log(` ${app.appId}`);\n console.log(` Name: ${app.name}`);\n console.log(` Bundle: ${app.bundlePath}`);\n console.log(` Description: ${app.description}`);\n console.log('');\n }\n console.log(`Total: ${apps.length} application(s)`);\n if (options.dev) {\n console.log('(Development mode: scanned Xcode build directories)');\n }\n }\n } catch (err) {\n console.error('Scan failed:', err);\n process.exit(1);\n }\n process.exit(0);\n }\n\n // Default: start MCP server\n try {\n const gateway = await createGatewayServer({ devMode: options.dev });\n await gateway.start();\n } catch (err) {\n logger.fatal({ err }, 'Failed to start AAI Gateway');\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error('Fatal error:', err);\n process.exit(1);\n});\n"],"names":["__filename","__dirname"],"mappings":";;;;;AASA,MAAMA,eAAa,cAAc,YAAY,GAAG;AAChD,MAAMC,cAAY,QAAQD,YAAU;AACpC,MAAM,cAAc,KAAK,MAAM,aAAa,KAAKC,aAAW,iBAAiB,GAAG,OAAO,CAAC;AACxF,MAAM,UAAU,YAAY;AAU5B,SAAS,UAAU,MAA4B;AAC7C,SAAO;AAAA,IACL,MAAM,KAAK,SAAS,QAAQ;AAAA,IAC5B,KAAK,KAAK,SAAS,OAAO;AAAA,IAC1B,SAAS,KAAK,SAAS,WAAW;AAAA,IAClC,MAAM,KAAK,SAAS,QAAQ,KA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D;AAAA,QACnE;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,cAAQ,MAAM,gBAAgB,GAAG;AACjC,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,MAAI;AACF,UAAM,UAAU,MAAM,oBAAoB,EAAE,SAAS,QAAQ,KAAK;AAClE,UAAM,QAAQ,MAAA;AAAA,EAChB,SAAS,KAAK;AACZ,WAAO,MAAM,EAAE,IAAA,GAAO,6BAA6B;AACnD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,OAAO,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,gBAAgB,GAAG;AACjC,UAAQ,KAAK,CAAC;AAChB,CAAC;"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A, a, C, T, c, b, d, e, f, g, h, i, l, p, s } from "./server-BIZIyh-I.js";
1
+ import { A, a, C, T, c, b, d, e, f, g, h, i, l, p, s } from "./server-B-dyXrfc.js";
2
2
  export {
3
3
  A as AaiError,
4
4
  a as AaiGatewayServer,