aai-gateway 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +231 -0
- package/dist/cli.js +93 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/server-B0zE5-Fp.js +8691 -0
- package/dist/server-B0zE5-Fp.js.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 Bob
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# AAI Gateway
|
|
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.
|
|
4
|
+
|
|
5
|
+
Reference implementation of the [AAI Protocol](https://github.com/gybob/aai-protocol).
|
|
6
|
+
|
|
7
|
+
### Key Features
|
|
8
|
+
|
|
9
|
+
- **Zero intrusion**. Uses existing OS automation (AppleScript, COM, DBus) — no app modification required.
|
|
10
|
+
- **Progressive discovery**. Apps discovered on-demand via MCP resources, avoiding context explosion.
|
|
11
|
+
- **Native security**. Leverages OS-level consent (TCC, UAC, Polkit) and secure storage (Keychain, Credential Manager).
|
|
12
|
+
- **Cross-platform**. Supports macOS today, Linux and Windows planned.
|
|
13
|
+
|
|
14
|
+
### Requirements
|
|
15
|
+
|
|
16
|
+
- Node.js 18 or newer
|
|
17
|
+
- macOS (Linux and Windows support planned)
|
|
18
|
+
- VS Code, Cursor, Windsurf, Claude Desktop, or any MCP client
|
|
19
|
+
|
|
20
|
+
### Getting started
|
|
21
|
+
|
|
22
|
+
Add AAI Gateway to your MCP client configuration.
|
|
23
|
+
|
|
24
|
+
**Standard config:**
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"mcpServers": {
|
|
29
|
+
"aai-gateway": {
|
|
30
|
+
"command": "npx",
|
|
31
|
+
"args": ["aai-gateway"]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
<details>
|
|
38
|
+
<summary>Claude Code</summary>
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
claude mcp add aai-gateway npx aai-gateway
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
</details>
|
|
45
|
+
|
|
46
|
+
<details>
|
|
47
|
+
<summary>Claude Desktop</summary>
|
|
48
|
+
|
|
49
|
+
Follow the MCP install [guide](https://modelcontextprotocol.io/quickstart/user), use the standard config above. Config file location: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
50
|
+
|
|
51
|
+
</details>
|
|
52
|
+
|
|
53
|
+
<details>
|
|
54
|
+
<summary>Copilot / VS Code</summary>
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
code --add-mcp '{"name":"aai-gateway","command":"npx","args":["aai-gateway"]}'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or add manually to your MCP settings.
|
|
61
|
+
|
|
62
|
+
</details>
|
|
63
|
+
|
|
64
|
+
<details>
|
|
65
|
+
<summary>Cursor</summary>
|
|
66
|
+
|
|
67
|
+
Go to `Cursor Settings` -> `MCP` -> `Add new MCP Server`. Name: `aai-gateway`, type: `command`, command: `npx aai-gateway`.
|
|
68
|
+
|
|
69
|
+
</details>
|
|
70
|
+
|
|
71
|
+
</details>
|
|
72
|
+
|
|
73
|
+
<details>
|
|
74
|
+
<summary>OpenCode</summary>
|
|
75
|
+
|
|
76
|
+
Add to `~/.config/opencode/opencode.json`:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"$schema": "https://opencode.ai/config.json",
|
|
81
|
+
"mcp": {
|
|
82
|
+
"aai-gateway": {
|
|
83
|
+
"type": "local",
|
|
84
|
+
"command": ["npx", "aai-gateway"],
|
|
85
|
+
"enabled": true
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
With `--dev` flag:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"$schema": "https://opencode.ai/config.json",
|
|
96
|
+
"mcp": {
|
|
97
|
+
"aai-gateway": {
|
|
98
|
+
"type": "local",
|
|
99
|
+
"command": ["npx", "aai-gateway", "--dev"],
|
|
100
|
+
"enabled": true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
</details>
|
|
107
|
+
|
|
108
|
+
### Configuration
|
|
109
|
+
|
|
110
|
+
AAI Gateway supports the following command-line arguments:
|
|
111
|
+
|
|
112
|
+
| Option | Description |
|
|
113
|
+
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
114
|
+
| `--dev` | Enable development mode. Scans Xcode build directories for apps in development: `~/Library/Developer/Xcode/DerivedData/*/Build/Products/{Debug,Release}/*.app` |
|
|
115
|
+
| `--scan` | Scan for AAI-enabled apps and exit (for debugging) |
|
|
116
|
+
| `--version` | Show version |
|
|
117
|
+
| `--help` | Show help |
|
|
118
|
+
|
|
119
|
+
**Development mode example:**
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"mcpServers": {
|
|
124
|
+
"aai-gateway": {
|
|
125
|
+
"command": "npx",
|
|
126
|
+
"args": ["aai-gateway", "--dev"]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Use `--dev` when developing AAI-enabled applications in Xcode to discover apps before they're installed to `/Applications`.
|
|
133
|
+
|
|
134
|
+
### MCP Interface
|
|
135
|
+
|
|
136
|
+
AAI Gateway exposes three MCP primitives. Agents discover tools progressively through resources — no `tools/list` — to avoid context explosion.
|
|
137
|
+
|
|
138
|
+
#### `resources/list`
|
|
139
|
+
|
|
140
|
+
Returns all AAI-enabled apps discovered on the current machine.
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"resources": [
|
|
145
|
+
{
|
|
146
|
+
"uri": "app:com.acme.crm",
|
|
147
|
+
"name": "Acme CRM",
|
|
148
|
+
"description": "Customer relationship management"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"uri": "app:com.acme.invoice",
|
|
152
|
+
"name": "Acme Invoice",
|
|
153
|
+
"description": "Invoice and billing management"
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### `resources/read`
|
|
160
|
+
|
|
161
|
+
Accepts two URI types:
|
|
162
|
+
|
|
163
|
+
- **`app:<bundle-id>`** — reads the descriptor for a locally installed desktop app
|
|
164
|
+
- **`https://<domain>`** — fetches `/.well-known/aai.json` from a web service (cached 24h)
|
|
165
|
+
|
|
166
|
+
Returns the full `aai.json` descriptor including the app's tool list and schemas.
|
|
167
|
+
|
|
168
|
+
#### `tools/call`
|
|
169
|
+
|
|
170
|
+
Tool name format: `<app-id>:<tool-name>`
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"name": "com.acme.crm:create_contact",
|
|
175
|
+
"arguments": { "name": "Alice", "email": "alice@example.com", "company": "Example Inc." }
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Execution flow:**
|
|
180
|
+
|
|
181
|
+
1. Resolve app descriptor (local registry or web fetch)
|
|
182
|
+
2. Validate tool and arguments
|
|
183
|
+
3. Show native consent dialog — user approves/denies (remembered per tool or globally)
|
|
184
|
+
4. Execute: desktop apps via native IPC, web apps via HTTP with OAuth 2.1 PKCE token
|
|
185
|
+
5. Return result
|
|
186
|
+
|
|
187
|
+
### Platform Support
|
|
188
|
+
|
|
189
|
+
| Platform | Discovery | IPC Executor | Consent Dialog | Secure Storage |
|
|
190
|
+
| -------- | ------------------------- | ------------------------ | ----------------- | --------------------- |
|
|
191
|
+
| macOS | ✅ | ✅ Apple Events | ✅ osascript | ✅ Keychain |
|
|
192
|
+
| Linux | 🔜 | 🔜 DBus | 🔜 zenity/kdialog | 🔜 libsecret |
|
|
193
|
+
| Windows | 🔜 | 🔜 COM | 🔜 PowerShell | 🔜 Credential Manager |
|
|
194
|
+
| Web | ✅ `.well-known/aai.json` | ✅ HTTP + OAuth 2.1 PKCE | — | ✅ (via platform) |
|
|
195
|
+
|
|
196
|
+
### For App Developers
|
|
197
|
+
|
|
198
|
+
To make your app discoverable by AAI Gateway, ship an `aai.json` descriptor:
|
|
199
|
+
|
|
200
|
+
**macOS:** `<App>.app/Contents/Resources/aai.json`
|
|
201
|
+
|
|
202
|
+
**Web:** `https://<your-domain>/.well-known/aai.json`
|
|
203
|
+
|
|
204
|
+
See the [AAI Protocol Spec](https://github.com/gybob/aai-protocol) for the full `aai.json` schema.
|
|
205
|
+
|
|
206
|
+
### Debugging
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# List discovered AAI-enabled apps
|
|
210
|
+
npx aai-gateway --scan
|
|
211
|
+
|
|
212
|
+
# Include Xcode build products
|
|
213
|
+
npx aai-gateway --scan --dev
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Development
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
npm install
|
|
220
|
+
npm run typecheck
|
|
221
|
+
npm test
|
|
222
|
+
npm run build
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Links
|
|
226
|
+
|
|
227
|
+
- [AAI Protocol Spec](https://github.com/gybob/aai-protocol)
|
|
228
|
+
|
|
229
|
+
### License
|
|
230
|
+
|
|
231
|
+
Apache-2.0
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { b as createDesktopDiscovery, d as createGatewayServer, l as logger } from "./server-B0zE5-Fp.js";
|
|
3
|
+
const VERSION = "0.1.0";
|
|
4
|
+
function parseArgs(args) {
|
|
5
|
+
return {
|
|
6
|
+
scan: args.includes("--scan"),
|
|
7
|
+
dev: args.includes("--dev"),
|
|
8
|
+
version: args.includes("--version"),
|
|
9
|
+
help: args.includes("--help") || args.includes("-h")
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
async function main() {
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
const options = parseArgs(args);
|
|
15
|
+
if (options.help) {
|
|
16
|
+
console.log(`
|
|
17
|
+
AAI Gateway - Agent App Interface Protocol Gateway
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
aai-gateway [options]
|
|
21
|
+
|
|
22
|
+
Options:
|
|
23
|
+
--scan Scan for AAI-enabled desktop apps and exit
|
|
24
|
+
--dev Enable development mode (scan Xcode build directories)
|
|
25
|
+
--version Show version
|
|
26
|
+
--help, -h Show this help message
|
|
27
|
+
|
|
28
|
+
Environment Variables:
|
|
29
|
+
AAI_LOG_LEVEL Log level (debug, info, warn, error)
|
|
30
|
+
|
|
31
|
+
Development Mode:
|
|
32
|
+
When --dev is used with --scan or MCP server, the gateway will also scan
|
|
33
|
+
Xcode build directories for apps in development:
|
|
34
|
+
~/Library/Developer/Xcode/DerivedData/*/Build/Products/Debug
|
|
35
|
+
~/Library/Developer/Xcode/DerivedData/*/Build/Products/Release
|
|
36
|
+
|
|
37
|
+
Default mode starts an MCP server over stdio.
|
|
38
|
+
`);
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
if (options.version) {
|
|
42
|
+
console.log(`aai-gateway v${VERSION}`);
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
if (options.scan) {
|
|
46
|
+
try {
|
|
47
|
+
const discovery = createDesktopDiscovery();
|
|
48
|
+
const apps = await discovery.scan({ devMode: options.dev });
|
|
49
|
+
console.log("\nDiscovered AAI-enabled Applications:");
|
|
50
|
+
console.log("=====================================\n");
|
|
51
|
+
if (apps.length === 0) {
|
|
52
|
+
console.log("No applications found.");
|
|
53
|
+
if (options.dev) {
|
|
54
|
+
console.log("Apps must ship /Applications/<Name>.app/Contents/Resources/aai.json");
|
|
55
|
+
console.log(
|
|
56
|
+
"Or in Xcode build: ~/Library/Developer/Xcode/DerivedData/*/Build/Products/Debug/<Name>.app/Contents/Resources/aai.json"
|
|
57
|
+
);
|
|
58
|
+
} else {
|
|
59
|
+
console.log("Apps must ship /Applications/<Name>.app/Contents/Resources/aai.json");
|
|
60
|
+
console.log("Tip: Use --dev to also scan Xcode build directories.");
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
for (const app of apps) {
|
|
64
|
+
console.log(` ${app.appId}`);
|
|
65
|
+
console.log(` Name: ${app.name}`);
|
|
66
|
+
console.log(` Bundle: ${app.bundlePath}`);
|
|
67
|
+
console.log(` Description: ${app.description}`);
|
|
68
|
+
console.log("");
|
|
69
|
+
}
|
|
70
|
+
console.log(`Total: ${apps.length} application(s)`);
|
|
71
|
+
if (options.dev) {
|
|
72
|
+
console.log("(Development mode: scanned Xcode build directories)");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.error("Scan failed:", err);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
process.exit(0);
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const gateway = await createGatewayServer({ devMode: options.dev });
|
|
83
|
+
await gateway.start();
|
|
84
|
+
} catch (err) {
|
|
85
|
+
logger.fatal({ err }, "Failed to start AAI Gateway");
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
main().catch((err) => {
|
|
90
|
+
console.error("Fatal error:", err);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +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.1.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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAsBf;AACG,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI,QAAQ,SAAS;AACnB,YAAQ,IAAI,gBAAgB,OAAO,EAAE;AACrC,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI,QAAQ,MAAM;AAChB,QAAI;AACF,YAAM,YAAY,uBAAA;AAClB,YAAM,OAAO,MAAM,UAAU,KAAK,EAAE,SAAS,QAAQ,KAAK;AAE1D,cAAQ,IAAI,wCAAwC;AACpD,cAAQ,IAAI,yCAAyC;AAErD,UAAI,KAAK,WAAW,GAAG;AACrB,gBAAQ,IAAI,wBAAwB;AACpC,YAAI,QAAQ,KAAK;AACf,kBAAQ,IAAI,qEAAqE;AACjF,kBAAQ;AAAA,YACN;AAAA,UAAA;AAAA,QAEJ,OAAO;AACL,kBAAQ,IAAI,qEAAqE;AACjF,kBAAQ,IAAI,sDAAsD;AAAA,QACpE;AAAA,MACF,OAAO;AACL,mBAAW,OAAO,MAAM;AACtB,kBAAQ,IAAI,KAAK,IAAI,KAAK,EAAE;AAC5B,kBAAQ,IAAI,aAAa,IAAI,IAAI,EAAE;AACnC,kBAAQ,IAAI,eAAe,IAAI,UAAU,EAAE;AAC3C,kBAAQ,IAAI,oBAAoB,IAAI,WAAW,EAAE;AACjD,kBAAQ,IAAI,EAAE;AAAA,QAChB;AACA,gBAAQ,IAAI,UAAU,KAAK,MAAM,iBAAiB;AAClD,YAAI,QAAQ,KAAK;AACf,kBAAQ,IAAI,qDAAqD;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
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { A, a, C, T, c, b, d, e, f, g, h, i, l, p, s } from "./server-B0zE5-Fp.js";
|
|
2
|
+
export {
|
|
3
|
+
A as AaiError,
|
|
4
|
+
a as AaiGatewayServer,
|
|
5
|
+
C as ConsentManager,
|
|
6
|
+
T as TokenManager,
|
|
7
|
+
c as createConsentDialog,
|
|
8
|
+
b as createDesktopDiscovery,
|
|
9
|
+
d as createGatewayServer,
|
|
10
|
+
e as createIpcExecutor,
|
|
11
|
+
f as createSecureStorage,
|
|
12
|
+
g as executeWebTool,
|
|
13
|
+
h as fetchWebDescriptor,
|
|
14
|
+
i as getCurrentPlatform,
|
|
15
|
+
l as logger,
|
|
16
|
+
p as parseAaiJson,
|
|
17
|
+
s as startOAuthFlow
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|