@agimon-ai/po-mcp 0.0.0-alpha.4 → 0.0.0-alpha.41

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 (49) hide show
  1. package/LICENSE +149 -21
  2. package/README.md +89 -12
  3. package/dist/apiContracts.cjs +53 -0
  4. package/dist/apiContracts.cjs.map +1 -1
  5. package/dist/apiContracts.d.mts.map +1 -1
  6. package/dist/apiContracts.mjs +53 -0
  7. package/dist/apiContracts.mjs.map +1 -1
  8. package/dist/extensions/mcp.cjs +29 -13
  9. package/dist/extensions/mcp.cjs.map +1 -1
  10. package/dist/extensions/mcp.mjs +29 -13
  11. package/dist/extensions/mcp.mjs.map +1 -1
  12. package/dist/extensions/native.mjs +1438 -0
  13. package/dist/extensions/native.mjs.map +1 -0
  14. package/dist/extensions/server.cjs +987 -117
  15. package/dist/extensions/server.cjs.map +1 -1
  16. package/dist/extensions/server.d.mts +2 -2
  17. package/dist/extensions/server.d.mts.map +1 -1
  18. package/dist/extensions/server.mjs +980 -110
  19. package/dist/extensions/server.mjs.map +1 -1
  20. package/dist/extensions/web.mjs +530 -64
  21. package/dist/extensions/web.mjs.map +1 -1
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.d.mts +3 -3
  24. package/dist/index.d.mts.map +1 -1
  25. package/dist/index.mjs +1 -1
  26. package/dist/{mcpCatalog-BHoE4gfz.cjs → mcpCatalog-CRc1Km4f.cjs} +21 -11
  27. package/dist/mcpCatalog-CRc1Km4f.cjs.map +1 -0
  28. package/dist/{mcpCatalog-Bp-mLZM1.mjs → mcpCatalog-ZXofPcJu.mjs} +13 -9
  29. package/dist/mcpCatalog-ZXofPcJu.mjs.map +1 -0
  30. package/dist/{mcpConfig-lHsIQ2fZ.d.mts → mcpConfig-CrnMo7fA.d.mts} +2 -2
  31. package/dist/{mcpConfig-lHsIQ2fZ.d.mts.map → mcpConfig-CrnMo7fA.d.mts.map} +1 -1
  32. package/dist/projection-Bj7Soute.cjs +64 -0
  33. package/dist/projection-Bj7Soute.cjs.map +1 -0
  34. package/dist/projection-ouVnOTJm.mjs +56 -0
  35. package/dist/projection-ouVnOTJm.mjs.map +1 -0
  36. package/dist/projection.cjs +1 -1
  37. package/dist/projection.d.mts +8 -2
  38. package/dist/projection.d.mts.map +1 -1
  39. package/dist/projection.mjs +1 -1
  40. package/llms.txt +2 -1
  41. package/package.json +33 -17
  42. package/src/prompts/codemode-how-to-mcp/SKILL.md +46 -0
  43. package/src/prompts/{po-use-mcp → help-how-to-mcp}/SKILL.md +38 -10
  44. package/dist/mcpCatalog-BHoE4gfz.cjs.map +0 -1
  45. package/dist/mcpCatalog-Bp-mLZM1.mjs.map +0 -1
  46. package/dist/projection-gyAA2jRB.mjs +0 -43
  47. package/dist/projection-gyAA2jRB.mjs.map +0 -1
  48. package/dist/projection-w3XxXmVi.cjs +0 -51
  49. package/dist/projection-w3XxXmVi.cjs.map +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,149 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Vuong Ngo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
2
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
3
+
4
+ Parameters
5
+
6
+ Licensor: Agimon Pty Ltd
7
+ Licensed Work: Po, the software in the Po source repository and the
8
+ packages released from it, in each version released by
9
+ the Licensor.
10
+ The Licensed Work is (c) 2026 Agimon Pty Ltd.
11
+ Material identified as third-party in the "Third-party
12
+ components" section at the end of this file or in a
13
+ NOTICE file, and any package or directory whose own
14
+ license file grants a different license, is not part of
15
+ the Licensed Work and remains under its own license.
16
+ Additional Use Grant: You may make production use of the Licensed Work if
17
+ your use is Eligible Use. "Eligible Use" is production use that falls
18
+ within at least one of the following:
19
+
20
+ (a) Personal Use. Use by an individual for their own personal purposes,
21
+ and not on behalf of, or for the benefit of, an employer, client, or
22
+ other Organization. Use by an individual in the course of employment
23
+ or engagement by an Organization is use by that Organization.
24
+
25
+ (b) Small Organization Use. Use by or on behalf of an Organization whose
26
+ Annual Revenue is less than USD 1,000,000.
27
+
28
+ (c) Non-profit, Education and Research Use. Use, regardless of Annual
29
+ Revenue, by (i) an Organization registered or recognized as a
30
+ non-profit or charitable organization under the laws of its
31
+ jurisdiction, for its non-profit purposes; (ii) an accredited school,
32
+ college, or university, for teaching, learning, or academic research;
33
+ or (iii) a publicly funded research institution, for its research.
34
+
35
+ (d) Service Provider Use. Use by a consultant, contractor, agency, or other
36
+ service provider, regardless of its own Annual Revenue, solely to
37
+ build, deploy, host, operate, or support the Licensed Work for a client
38
+ whose own use would be Eligible Use under (a), (b), or (c). A service
39
+ provider's use for its own purposes is Eligible Use only if the service
40
+ provider itself qualifies under (b) or (c).
41
+
42
+
43
+ Hosted services. Offering the Licensed Work to third parties as a hosted
44
+ or managed service whose primary value is the Licensed Work is Eligible
45
+ Use only if each such third party's own use would be Eligible Use.
46
+
47
+ Definitions. "Organization" means any company, partnership, sole
48
+ proprietorship, trust, association, government body, or other entity, and
49
+ includes an individual acting in a business or professional capacity.
50
+ "Affiliate" means any entity that directly or indirectly controls, is
51
+ controlled by, or is under common control with an Organization, where
52
+ "control" means ownership of more than 50% of the voting interests of an
53
+ entity or the power to direct its management and policies by contract or
54
+ otherwise. "Annual Revenue" means the total gross revenue of an
55
+ Organization and all of its Affiliates combined, from all sources and
56
+ whether or not related to the Licensed Work, for its most recently
57
+ completed fiscal year, or, if it has not completed a fiscal year, for the
58
+ twelve months before the use (or since its formation, if shorter),
59
+ converted into US dollars at the average exchange rate for that period.
60
+ Proceeds of equity or debt financing are not revenue.
61
+
62
+ Threshold. If an Organization stops qualifying under (b), its existing
63
+ production use remains Eligible Use for 90 days after it stops
64
+ qualifying, after which it must obtain a commercial license or stop
65
+ production use. Use that was Eligible Use when it occurred never requires
66
+ a commercial license after the fact.
67
+ Change Date: Four years from the date a version of the Licensed Work
68
+ is first publicly released by the Licensor.
69
+ Change License: Apache License, Version 2.0
70
+
71
+ For information about alternative licensing arrangements for the Licensed
72
+ Work, please visit: https://agimon.ai/licensing
73
+
74
+ Notice
75
+
76
+ The Business Source License (this document, or the "License") is not an Open
77
+ Source license. However, the Licensed Work will eventually be made available
78
+ under an Open Source License, as stated in this License.
79
+
80
+ -----------------------------------------------------------------------------
81
+
82
+ Business Source License 1.1
83
+
84
+ Terms
85
+
86
+ The Licensor hereby grants you the right to copy, modify, create derivative
87
+ works, redistribute, and make non-production use of the Licensed Work. The
88
+ Licensor may make an Additional Use Grant, above, permitting limited
89
+ production use.
90
+
91
+ Effective on the Change Date, or the fourth anniversary of the first publicly
92
+ available distribution of a specific version of the Licensed Work under this
93
+ License, whichever comes first, the Licensor hereby grants you rights under
94
+ the terms of the Change License, and the rights granted in the paragraph
95
+ above terminate.
96
+
97
+ If your use of the Licensed Work does not comply with the requirements
98
+ currently in effect as described in this License, you must purchase a
99
+ commercial license from the Licensor, its affiliated entities, or authorized
100
+ resellers, or you must refrain from using the Licensed Work.
101
+
102
+ All copies of the original and modified Licensed Work, and derivative works
103
+ of the Licensed Work, are subject to this License. This License applies
104
+ separately for each version of the Licensed Work and the Change Date may vary
105
+ for each version of the Licensed Work released by Licensor.
106
+
107
+ You must conspicuously display this License on each original or modified copy
108
+ of the Licensed Work. If you receive the Licensed Work in original or
109
+ modified form from a third party, the terms and conditions set forth in this
110
+ License apply to your use of that work.
111
+
112
+ Any use of the Licensed Work in violation of this License will automatically
113
+ terminate your rights under this License for the current and all other
114
+ versions of the Licensed Work.
115
+
116
+ This License does not grant you any right in any trademark or logo of
117
+ Licensor or its affiliates (provided that you may use a trademark or logo of
118
+ Licensor as expressly required by this License).
119
+
120
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
121
+ AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
122
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
123
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
124
+ TITLE.
125
+
126
+ MariaDB hereby grants you permission to use this License’s text to license
127
+ your works, and to refer to it using the trademark “Business Source License”,
128
+ as long as you comply with the Covenants of Licensor below.
129
+
130
+ Covenants of Licensor
131
+
132
+ In consideration of the right to use this License’s text and the “Business
133
+ Source License” name and trademark, Licensor covenants to MariaDB, and to all
134
+ other recipients of the licensed work to be provided by Licensor:
135
+
136
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
137
+ or a license that is compatible with GPL Version 2.0 or a later version,
138
+ where “compatible” means that software provided under the Change License can
139
+ be included in a program with software provided under GPL Version 2.0 or a
140
+ later version. Licensor may specify additional Change Licenses without
141
+ limitation.
142
+
143
+ 2. To either: (a) specify an additional grant of rights to use that does not
144
+ impose any additional restriction on the right granted in this License, as
145
+ the Additional Use Grant; or (b) insert the text “None”.
146
+
147
+ 3. To specify a Change Date.
148
+
149
+ 4. Not to modify this License in any other way.
package/README.md CHANGED
@@ -39,6 +39,15 @@ Repository `.mcp.json` entries describe direct MCP servers:
39
39
  }
40
40
  ```
41
41
 
42
+ Your own servers live in `mcp.json` in your Po home (`~/.po/mcp.json`, or under `PO_HOME`), in the
43
+ same shape. Po loads them into every repository's sessions, first, so a repository, plugin or
44
+ domain entry with the same name wins.
45
+
46
+ Add a server from the cockpit without editing either file: **Add server** on a repository's MCP
47
+ servers page writes that repository's `.mcp.json`, and **Settings, MCP servers** writes your own
48
+ config. Remote servers take a URL and optional headers. A local command also needs the trust
49
+ confirmation, which the hub checks again. Adding never replaces an existing name or rewrites a
50
+ file that is not valid JSON.
42
51
  Selected legacy plugins may also provide root `.mcp.json`. A schema-gated Agent Plugin v1 instead
43
52
  provides root `mcp.json`. Po validates its portable contract, supplies private persistent
44
53
  `PLUGIN_DATA`, and resolves plugin-relative stdio commands and working directories. It also
@@ -63,7 +72,7 @@ should load.
63
72
 
64
73
  Within Po, this package consumes the immutable `poMcpProjection` service published on the
65
74
  session Cordis root.
66
- Downstream clients run in-process through `@agimon-ai/mcp-proxy`; this adapter does not start its
75
+ Downstream clients run in-process through `@agimon-ai/po-mcp-proxy`; this adapter does not start its
67
76
  Hono server.
68
77
 
69
78
  ## Direct tools and configured identity
@@ -81,12 +90,80 @@ original downstream tool name; tool prefixes are not parsed to route calls.
81
90
  Children borrow the parent runtime. Requested `mcp` or `mcp_use` groups expand into permitted
82
91
  direct tools; `mcpDirectTools` selectors (`*`, a configured server, or `server/tool`) narrow that
83
92
  set. Capability ceilings must explicitly allow MCP and still constrain the selected tools.
84
- Children cannot manage the parent's connections. Remote `mcp_use` remains a compatibility route,
85
- not the default native model declaration.
93
+ The direct connection-management tool is main-agent-only. Borrowed trusted `exec` still uses
94
+ parent-session bindings, including Help-only `mcpTest`. Remote `mcp_use` remains a compatibility
95
+ route, not the default native model declaration.
86
96
 
87
- Full schemas cost context tokens. Select domains and child subsets rather than hiding tool
88
- availability or repeating catalogs in prompt prose. Codemode and tool search remain disabled;
89
- the Pi 1.0.0 source review did not measure savings or justify enabling them.
97
+ Select domains and child subsets to control tool availability. Keep catalogs out of prompt prose.
98
+
99
+ ## Po MCP namespace
100
+
101
+ Po's own `discover` and `exec` tools (`@agimon-ai/po-codemode`) enable the `mcp`
102
+ namespace alongside namespaces such as `browser`. Pi's internal MCP codemode and tool
103
+ search remain disabled. These are separate mechanisms, also distinct from code mode
104
+ run by a remote MCP client. While code mode is bound, the main agent's direct tool
105
+ declarations for these servers are withdrawn, since the namespace reaches every one and
106
+ their schemas would only cost context; they show as inactive in Context. A tool that carries
107
+ an MCP App keeps its direct tool for the inline UI. Without code mode every direct tool stays,
108
+ and the `mcp_use` compatibility route remains. Native child sessions still receive the
109
+ direct tools they are granted. The namespace does not change MCP access grants.
110
+
111
+ The always-active `codemode-how-to-mcp` skill teaches agents this flow and, when loaded, lists the session's servers and tool names.
112
+
113
+ Start with `discover({ namespace: 'mcp' })` to inspect the permitted catalog and typed
114
+ signatures. If the declaration output exceeds 24,000 characters, narrow discovery
115
+ with `discover({ query: 'github/search_issues' })` before calling a tool. Use only
116
+ names and argument schemas returned by discovery, never guessed names.
117
+
118
+ Inside `exec`, call a typed wrapper such as `await mcp.github.search_issues(args)`,
119
+ where `args` matches the discovered input schema. Names are exact configured server
120
+ and original tool names, not normalized direct-tool prefixes. Use bracket access
121
+ for names that need it, for example `await mcp['work-github']['search-issues'](args)`.
122
+ The generic route is `await mcp.call(server, tool, args)`, using the exact discovered
123
+ server and tool names. Both routes use the same permitted session connections and
124
+ admission checks as direct calls.
125
+
126
+ Results expose `text`, `images`, `structuredContent`, and `blocks`. Inspect the text
127
+ or structured content in the script; use `image(result)` to emit its images from
128
+ `exec`. Upstream `isError` results reject with the upstream text rather than
129
+ returning a successful result.
130
+
131
+ Outbound file parameters still require consent. Time waiting for that consent counts
132
+ against the `exec` timeout: 30 seconds by default, with `timeoutMs` up to 120 seconds.
133
+ After a runtime swap, an old run cannot access the replacement runtime. Discover again
134
+ and retry in a new `exec`, not in the old run.
135
+
136
+ MCP Apps stay on direct tools so their inline UI and interaction lifecycle remain
137
+ available. Use a direct call when an App is needed, not the namespace route.
138
+
139
+ ## Session-only URL test servers
140
+
141
+ In Help mode, ask permission, then discover `mcpTest` and add a URL server:
142
+
143
+ ```ts
144
+ await mcpTest.add({ name: 'test', url: 'https://example.com/mcp', type: 'http' });
145
+ ```
146
+
147
+ HTTP and SSE servers accept optional headers and OAuth client settings. Sign-in links appear
148
+ in the existing MCP panel. Add waits for completion and respects cancellation. With no code
149
+ mode, the main-agent-only `mcp_test_server` tool supports `add`, `remove` and `list` instead.
150
+ These management surfaces disappear when Help turns off, but connected test servers remain.
151
+ `mcpTest.remove(name)` disconnects and forgets one while Help is on.
152
+
153
+ Test server configuration, headers and credentials stay in memory, including across MCP
154
+ reloads. They are not written to config, keyring, credential files or the shared tool cache,
155
+ and a new session does not inherit them. They cannot replace configured names or override
156
+ `--no-mcp`. Stdio and `/mcp add` are deliberately unsupported.
157
+
158
+ Memory-only storage does not redact tool arguments or conversation history. Never paste
159
+ literal secrets into management calls. Use `${ENV_VAR}` references from the session's
160
+ admitted environment for sensitive headers or OAuth client settings.
161
+
162
+ Configured-server credentials continue using keyring with encrypted-file fallback. A recovered
163
+ keyring reconciles newer fallback credentials on reads; the next successful write retires the
164
+ fallback copy. Near-expiry tokens refresh before requests, with no idle timer. Healthy durable
165
+ stores coordinate refresh across processes; degraded or explicit memory stores synchronize
166
+ only within their process.
90
167
 
91
168
  ## Inline Apps (development)
92
169
 
@@ -106,17 +183,17 @@ Reopening a widget reads its retained result and state, never reruns the origina
106
183
  built on the ChatGPT SDK work too. Only ChatGPT widgets receive `toolOutput` globals updates
107
184
  after their own `callTool`. Each App root gets a `light`/`dark` class, `data-theme` and
108
185
  `color-scheme` (an App's own class or `data-theme` is kept), and theme changes sync live.
109
- A tool result that rendered an App stays behind the card toggle unless the call failed.
186
+ An MCP tool card starts collapsed; an App stays visible. Expanding the card shows the call's input, then its result.
110
187
 
111
188
  The ChatGPT adapter implements tool input/output and private metadata globals, globals
112
189
  updates, `callTool`, `setWidgetState`, `sendFollowUpMessage`, inline display mode, height,
113
190
  close, and confirmed external links. File libraries, checkout, accounts, modal/fullscreen
114
191
  modes, stable custom origins, sampling, and automatic model-context updates are unsupported.
115
192
 
116
- The runtime pins published `@agimon-ai/mcp-proxy@0.32.12` for Apps capability
117
- negotiation, private result capture before output guarding, and upstream request
118
- cancellation. Model-facing output remains guarded; retained App results are bounded
119
- separately. No local proxy dependency or spill-file reads are used.
193
+ The runtime uses workspace-owned `@agimon-ai/po-mcp-proxy` from
194
+ `packages/utils/po-mcp-proxy` for Apps capability negotiation, private result capture
195
+ before output guarding, and upstream request cancellation. Model-facing output remains
196
+ guarded; retained App results are bounded separately. No spill-file reads are used.
120
197
 
121
198
  Run from the repository root:
122
199
 
@@ -189,7 +266,7 @@ Maintained by [Agimon](https://agimon.ai/about).
189
266
 
190
267
  ## License
191
268
 
192
- MIT
269
+ Business Source License 1.1: free for personal use, organisations under USD 1M revenue, non-profits and education. See [LICENSE](LICENSE) and https://agimon.ai/licensing.
193
270
 
194
271
  Named routed `src/extensions/` entries declare host contributions and delegate to services. MCP session state and connection behavior live in named service folders, and `src/exports/` exposes reusable public APIs.
195
272
 
@@ -74,6 +74,31 @@ const McpSessionToolSchema = typebox.Type.Object({
74
74
  inputSchema: typebox.Type.Record(S, typebox.Type.Unknown()),
75
75
  tokens: N
76
76
  });
77
+ const StringPairs = typebox.Type.Record(S, S);
78
+ const McpServerEntrySchema = typebox.Type.Union([typebox.Type.Object({
79
+ type: typebox.Type.Literal("http"),
80
+ url: typebox.Type.String({ maxLength: 2048 }),
81
+ headers: O(StringPairs)
82
+ }), typebox.Type.Object({
83
+ command: typebox.Type.String({
84
+ minLength: 1,
85
+ maxLength: 1024
86
+ }),
87
+ args: typebox.Type.Array(S),
88
+ env: O(StringPairs)
89
+ })]);
90
+ const McpAddServerSchema = typebox.Type.Object({
91
+ scope: literals(["repository", "global"]),
92
+ repositoryId: O(RepositoryId),
93
+ name: typebox.Type.String({ pattern: "^[A-Za-z0-9_-]{1,64}$" }),
94
+ entry: McpServerEntrySchema,
95
+ trusted: O(B)
96
+ });
97
+ const McpGlobalServersSchema = typebox.Type.Object({ servers: typebox.Type.Array(typebox.Type.Object({
98
+ name: S,
99
+ kind: literals(["remote", "local"]),
100
+ target: S
101
+ })) });
77
102
  const SessionToolQuery = [{
78
103
  name: "server",
79
104
  in: "query",
@@ -153,6 +178,34 @@ const apiContracts = (0, _agimon_ai_po_core_apiContracts.defineApiContract)({
153
178
  },
154
179
  responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(McpAuthorizationSchema, 202)
155
180
  },
181
+ {
182
+ id: "mcp.server.add",
183
+ scope,
184
+ basePath: "mcp",
185
+ path: "/servers",
186
+ method: "POST",
187
+ authentication: "owner",
188
+ description: "Add one MCP server to the repository's .mcp.json or the person's own config.",
189
+ body: {
190
+ required: true,
191
+ contentType: "application/json",
192
+ schema: McpAddServerSchema
193
+ },
194
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(typebox.Type.Object({
195
+ scope: literals(["repository", "global"]),
196
+ name: S
197
+ }), 201)
198
+ },
199
+ {
200
+ id: "mcp.servers.global",
201
+ scope,
202
+ basePath: "mcp",
203
+ path: "/servers/global",
204
+ method: "GET",
205
+ authentication: "owner",
206
+ description: "List the servers in the person's own MCP config, without headers or environment.",
207
+ responses: (0, _agimon_ai_po_core_apiContracts.jsonApiResponses)(McpGlobalServersSchema)
208
+ },
156
209
  ...["GET", "DELETE"].map((method) => ({
157
210
  id: `mcp.authorization.${method}`,
158
211
  scope,
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.cjs","names":["Type","defineApiContract","jsonApiResponses","Type","definePoPluginMethod"],"sources":["../src/schemas/apiContracts.ts","../src/schemas/mcpApps.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst literals = <T extends string>(values: T[]) => Type.Union(values.map((value) => Type.Literal(value)));\nconst RepositoryId = Type.String({\n pattern: '^(?:[a-f0-9]{32}|repo-[A-Za-z0-9_-]{24}|[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$',\n});\nconst RepositoryQuery = [{ name: 'repositoryId', in: 'query' as const, required: true, schema: RepositoryId }];\nexport const McpCatalogSchema = Type.Object({\n repositoryId: S,\n sync: Type.Object({ fresh: B, reasons: Type.Array(S) }),\n servers: Type.Array(\n Type.Object({\n name: S,\n state: literals(['not-connected', 'connecting', 'connected', 'degraded', 'needs-auth', 'failed', 'closed']),\n source: literals(['cached', 'live', 'configured']),\n credentialPresent: B,\n tools: Type.Array(Type.Object({ name: S, piName: S, description: O(S) })),\n error: O(S),\n }),\n ),\n droppedServers: Type.Array(S),\n diagnostics: Type.Array(S),\n});\nexport const McpAuthorizationSchema = Type.Object({\n id: S,\n repositoryId: S,\n serverName: S,\n status: literals(['starting', 'waiting', 'completed', 'failed', 'cancelled', 'expired']),\n authorizationUrl: O(S),\n error: O(S),\n expiresAt: N,\n});\nexport const McpSessionToolSchema = Type.Object({\n server: S,\n tool: S,\n description: O(S),\n inputSchema: Type.Record(S, Type.Unknown()),\n tokens: N,\n});\nconst SessionToolQuery = [\n { name: 'server', in: 'query' as const, required: true, schema: Type.String({ minLength: 1, maxLength: 160 }) },\n { name: 'tool', in: 'query' as const, required: true, schema: Type.String({ minLength: 1, maxLength: 256 }) },\n];\ntype HttpContract = Parameters<typeof defineApiContract>[0]['http'][number];\nexport const apiContracts = defineApiContract({\n version: 1,\n sockets: [],\n dynamic: [],\n http: [\n {\n id: 'mcp.session.tool',\n scope: 'session',\n basePath: 'mcp-session',\n path: '/tool',\n method: 'GET',\n authentication: 'owner',\n description: 'Read one tool the session reaches through mcp_use: its description, schema, and token cost.',\n parameters: SessionToolQuery,\n responses: jsonApiResponses(McpSessionToolSchema),\n },\n ...(['global', 'workspace'] as const).flatMap((scope): HttpContract[] => [\n {\n id: 'mcp.catalog',\n scope,\n basePath: 'mcp',\n path: '/repository',\n method: 'GET',\n authentication: 'owner',\n description: 'Read the synced MCP repository catalog.',\n parameters: RepositoryQuery,\n responses: jsonApiResponses(McpCatalogSchema),\n },\n {\n id: 'mcp.discover',\n scope,\n basePath: 'mcp',\n path: '/repository/discover',\n method: 'POST',\n authentication: 'owner',\n description: 'Discover repository MCP servers.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ repositoryId: RepositoryId }) },\n responses: jsonApiResponses(McpCatalogSchema),\n },\n {\n id: 'mcp.authorize',\n scope,\n basePath: 'mcp',\n path: '/repository/authorize',\n method: 'POST',\n authentication: 'owner',\n description: 'Start MCP authorization.',\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({\n repositoryId: RepositoryId,\n serverName: Type.String({ minLength: 1, maxLength: 160 }),\n }),\n },\n responses: jsonApiResponses(McpAuthorizationSchema, 202),\n },\n ...(['GET', 'DELETE'] as const).map((method) => ({\n id: `mcp.authorization.${method}`,\n scope,\n basePath: 'mcp',\n path: '/repository/authorize/{flowId}',\n method,\n authentication: 'owner' as const,\n description: method === 'GET' ? 'Read an authorization flow.' : 'Cancel an authorization flow.',\n parameters: RepositoryQuery,\n responses: jsonApiResponses(McpAuthorizationSchema),\n })),\n ]),\n ],\n});\nexport default apiContracts;\n","import { definePoPluginMethod } from '@agimon-ai/po-core/pluginProtocol';\nimport { Type } from 'typebox';\n\nexport type { McpAppOpenResult } from '../types/webMcp';\n\nconst Lease = Type.String({ minLength: 1, maxLength: 128 });\nconst JsonObject = Type.Record(Type.String(), Type.Unknown());\nconst Empty = Type.Object({}, { additionalProperties: false });\nconst Result = Type.Object({\n content: Type.Array(Type.Unknown()),\n structuredContent: Type.Optional(Type.Unknown()),\n _meta: Type.Optional(JsonObject),\n isError: Type.Optional(Type.Boolean()),\n});\nconst Address = { service: 'mcp.apps', scope: 'session', direction: 'client-to-server' } as const;\n\nexport const mcpAppOpenMethod = definePoPluginMethod({\n ...Address,\n method: 'open',\n input: Type.Object({ toolCallId: Type.String({ minLength: 1, maxLength: 512 }) }, { additionalProperties: false }),\n output: Type.Object({\n leaseId: Lease,\n html: Type.String(),\n resourceUri: Type.String(),\n protocol: Type.Union([Type.Literal('mcp'), Type.Literal('openai')]),\n resourceMeta: JsonObject,\n tool: Type.Object({\n name: Type.String(),\n description: Type.String(),\n inputSchema: Type.Object({ type: Type.Literal('object') }, { additionalProperties: true }),\n _meta: JsonObject,\n }),\n args: JsonObject,\n result: Result,\n state: Type.Unknown(),\n readOnly: Type.Boolean(),\n }),\n});\n\nexport const mcpAppActivateMethod = definePoPluginMethod({\n ...Address,\n method: 'activate',\n input: Type.Object({ leaseId: Lease }, { additionalProperties: false }),\n output: Type.Object({ readOnly: Type.Literal(false) }),\n});\nexport const mcpAppCallToolMethod = definePoPluginMethod({\n ...Address,\n method: 'callTool',\n input: Type.Object(\n { leaseId: Lease, name: Type.String({ minLength: 1, maxLength: 256 }), arguments: JsonObject },\n { additionalProperties: false },\n ),\n output: Result,\n});\nexport const mcpAppSetStateMethod = definePoPluginMethod({\n ...Address,\n method: 'setState',\n input: Type.Object({ leaseId: Lease, state: Type.Unknown() }, { additionalProperties: false }),\n output: Empty,\n});\nexport const mcpAppFollowUpMethod = definePoPluginMethod({\n ...Address,\n method: 'followUp',\n input: Type.Object(\n { leaseId: Lease, prompt: Type.String({ minLength: 1, maxLength: 16000 }) },\n { additionalProperties: false },\n ),\n output: Empty,\n});\nexport const mcpAppCloseMethod = definePoPluginMethod({\n ...Address,\n method: 'close',\n input: Type.Object({ leaseId: Lease }, { additionalProperties: false }),\n output: Empty,\n});\nexport const mcpAppMethods = [\n mcpAppOpenMethod,\n mcpAppActivateMethod,\n mcpAppCallToolMethod,\n mcpAppSetStateMethod,\n mcpA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;CACvD,GAAG;CACH,QAAQ;CACR,OAAOD,QAAAA,KAAK,OAAO;EAAE,SAAS;EAAO,OAAOA,QAAAA,KAAK,QAAQ;CAAE,GAAG,EAAE,sBAAsB,MAAM,CAAC;CAC7F,QAAQ;AACV,CAAC;AACD,MAAa,wBAAA,GAAuBC,kCAAAA,qBAAAA,CAAqB;CACvD,GAAG;CACH,QAAQ;CACR,OAAOD,QAAAA,KAAK,OACV;EAAE,SAAS;EAAO,QAAQA,QAAAA,KAAK,OAAO;GAAE,WAAW;GAAG,WAAW;EAAM,CAAC;CAAE,GAC1E,EAAE,sBAAsB,MAAM,CAChC;CACA,QAAQ;AACV,CAAC;AACD,MAAa,qBAAA,GAAoBC,kCAAAA,qBAAAA,CAAqB;CACpD,GAAG;CACH,QAAQ;CACR,OAAOD,QAAAA,KAAK,OAAO,EAAE,SAAS,MAAM,GAAG,EAAE,sBAAsB,MAAM,CAAC;CACtE,QAAQ;AACV,CAAC"}
1
+ {"version":3,"file":"apiContracts.cjs","names":["Type","defineApiContract","jsonApiResponses","Type","definePoPluginMethod"],"sources":["../src/schemas/apiContracts.ts","../src/schemas/mcpApps.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst literals = <T extends string>(values: T[]) => Type.Union(values.map((value) => Type.Literal(value)));\nconst RepositoryId = Type.String({\n pattern: '^(?:[a-f0-9]{32}|repo-[A-Za-z0-9_-]{24}|[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$',\n});\nconst RepositoryQuery = [{ name: 'repositoryId', in: 'query' as const, required: true, schema: RepositoryId }];\nexport const McpCatalogSchema = Type.Object({\n repositoryId: S,\n sync: Type.Object({ fresh: B, reasons: Type.Array(S) }),\n servers: Type.Array(\n Type.Object({\n name: S,\n state: literals(['not-connected', 'connecting', 'connected', 'degraded', 'needs-auth', 'failed', 'closed']),\n source: literals(['cached', 'live', 'configured']),\n credentialPresent: B,\n tools: Type.Array(Type.Object({ name: S, piName: S, description: O(S) })),\n error: O(S),\n }),\n ),\n droppedServers: Type.Array(S),\n diagnostics: Type.Array(S),\n});\nexport const McpAuthorizationSchema = Type.Object({\n id: S,\n repositoryId: S,\n serverName: S,\n status: literals(['starting', 'waiting', 'completed', 'failed', 'cancelled', 'expired']),\n authorizationUrl: O(S),\n error: O(S),\n expiresAt: N,\n});\nexport const McpSessionToolSchema = Type.Object({\n server: S,\n tool: S,\n description: O(S),\n inputSchema: Type.Record(S, Type.Unknown()),\n tokens: N,\n});\nconst StringPairs = Type.Record(S, S);\nexport const McpServerEntrySchema = Type.Union([\n Type.Object({ type: Type.Literal('http'), url: Type.String({ maxLength: 2048 }), headers: O(StringPairs) }),\n Type.Object({ command: Type.String({ minLength: 1, maxLength: 1024 }), args: Type.Array(S), env: O(StringPairs) }),\n]);\nexport const McpAddServerSchema = Type.Object({\n scope: literals(['repository', 'global']),\n repositoryId: O(RepositoryId),\n name: Type.String({ pattern: '^[A-Za-z0-9_-]{1,64}$' }),\n entry: McpServerEntrySchema,\n trusted: O(B),\n});\nexport const McpGlobalServersSchema = Type.Object({\n servers: Type.Array(Type.Object({ name: S, kind: literals(['remote', 'local']), target: S })),\n});\nconst SessionToolQuery = [\n { name: 'server', in: 'query' as const, required: true, schema: Type.String({ minLength: 1, maxLength: 160 }) },\n { name: 'tool', in: 'query' as const, required: true, schema: Type.String({ minLength: 1, maxLength: 256 }) },\n];\ntype HttpContract = Parameters<typeof defineApiContract>[0]['http'][number];\nexport const apiContracts = defineApiContract({\n version: 1,\n sockets: [],\n dynamic: [],\n http: [\n {\n id: 'mcp.session.tool',\n scope: 'session',\n basePath: 'mcp-session',\n path: '/tool',\n method: 'GET',\n authentication: 'owner',\n description: 'Read one tool the session reaches through mcp_use: its description, schema, and token cost.',\n parameters: SessionToolQuery,\n responses: jsonApiResponses(McpSessionToolSchema),\n },\n ...(['global', 'workspace'] as const).flatMap((scope): HttpContract[] => [\n {\n id: 'mcp.catalog',\n scope,\n basePath: 'mcp',\n path: '/repository',\n method: 'GET',\n authentication: 'owner',\n description: 'Read the synced MCP repository catalog.',\n parameters: RepositoryQuery,\n responses: jsonApiResponses(McpCatalogSchema),\n },\n {\n id: 'mcp.discover',\n scope,\n basePath: 'mcp',\n path: '/repository/discover',\n method: 'POST',\n authentication: 'owner',\n description: 'Discover repository MCP servers.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ repositoryId: RepositoryId }) },\n responses: jsonApiResponses(McpCatalogSchema),\n },\n {\n id: 'mcp.authorize',\n scope,\n basePath: 'mcp',\n path: '/repository/authorize',\n method: 'POST',\n authentication: 'owner',\n description: 'Start MCP authorization.',\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({\n repositoryId: RepositoryId,\n serverName: Type.String({ minLength: 1, maxLength: 160 }),\n }),\n },\n responses: jsonApiResponses(McpAuthorizationSchema, 202),\n },\n {\n id: 'mcp.server.add',\n scope,\n basePath: 'mcp',\n path: '/servers',\n method: 'POST',\n authentication: 'owner',\n description: \"Add one MCP server to the repository's .mcp.json or the person's own config.\",\n body: { required: true, contentType: 'application/json', schema: McpAddServerSchema },\n responses: jsonApiResponses(Type.Object({ scope: literals(['repository', 'global']), name: S }), 201),\n },\n {\n id: 'mcp.servers.global',\n scope,\n basePath: 'mcp',\n path: '/servers/global',\n method: 'GET',\n authentication: 'owner',\n description: \"List the servers in the person's own MCP config, without headers or environment.\",\n responses: jsonApiResponses(McpGlobalServersSchema),\n },\n ...(['GET', 'DELETE'] as const).map((method) => ({\n id: `mcp.authorization.${method}`,\n scope,\n basePath: 'mcp',\n path: '/repository/authorize/{flowId}',\n method,\n authentication: 'owner' as const,\n description: method === 'GET' ? 'Read an authorization flow.' : 'Cancel an authorization flow.',\n parameters: RepositoryQuery,\n responses: jsonApiResponses(McpAuthorizationSchema),\n })),\n ]),\n ],\n});\nexport default apiContracts;\n","import { definePoPluginMethod } from '@agimon-ai/po-core/pluginProtocol';\nimport { Type } from 'typebox';\n\nexport type { McpAppOpenResult } from '../types/webMcp';\n\nconst Lease = Type.String({ minLength: 1, maxLength: 128 });\nconst JsonObject = Type.Record(Type.String(), Type.Unknown());\nconst Empty = Type.Object({}, { additionalProperties: false });\nconst Result = Type.Object({\n content: Type.Array(Type.Unknown()),\n structuredContent: Type.Optional(Type.Unknown()),\n _meta: Type.Optional(JsonObject),\n isError: Type.Optional(Type.Boolean()),\n});\nconst Address = { service: 'mcp.apps', scope: 'session', direction: 'client-to-server' } as const;\n\nexport const mcpAppOpenMethod = definePoPluginMethod({\n ...Address,\n method: 'open',\n input: Type.Object({ toolCallId: Type.String({ minLength: 1, maxLength: 512 }) }, { additionalProperties: false }),\n output: Type.Object({\n leaseId: Lease,\n html: Type.String(),\n resourceUri: Type.String(),\n protocol: Type.Union([Type.Literal('mcp'), Type.Literal('openai')]),\n resourceMeta: JsonObject,\n tool: Type.Object({\n name: Type.String(),\n description: Type.String(),\n inputSchema: Type.Object({ type: Type.Literal('object') }, { additionalProperties: true }),\n _meta: JsonObject,\n }),\n args: JsonObject,\n result: Result,\n state: Type.Unknown(),\n readOnly: Type.Boolean(),\n }),\n});\n\nexport const mcpAppActivateMethod = definePoPluginMethod({\n ...Address,\n method: 'activate',\n input: Type.Object({ leaseId: Lease }, { additionalProperties: false }),\n output: Type.Object({ readOnly: Type.Literal(false) }),\n});\nexport const mcpAppCallToolMethod = definePoPluginMethod({\n ...Address,\n method: 'callTool',\n input: Type.Object(\n { leaseId: Lease, name: Type.String({ minLength: 1, maxLength: 256 }), arguments: JsonObject },\n { additionalProperties: false },\n ),\n output: Result,\n});\nexport const mcpAppSetStateMethod = definePoPluginMethod({\n ...Address,\n method: 'setState',\n input: Type.Object({ leaseId: Lease, state: Type.Unknown() }, { additionalProperties: false }),\n output: Empty,\n});\nexport const mcpAppFollowUpMethod = definePoPluginMethod({\n ...Address,\n method: 'followUp',\n input: Type.Object(\n { leaseId: Lease, prompt: Type.String({ minLength: 1, maxLength: 16000 }) },\n { additionalProperties: false },\n ),\n output: Empty,\n});\nexport const mcpAppCloseMethod = definePoPluginMethod({\n ...Address,\n method: 'close',\n input: Type.Object({ leaseId: Lease }, { additionalProperties: false }),\n output: Empty,\n});\nexport const mcpAppMethods = [\n mcpAppOpenMethod,\n mcpAppActivateMethod,\n mcpAppCallToolMethod,\n mcpAppSetStateMethod,\n mcpAppFollowUpMethod,\n mcpAppCloseMethod,\n] as const;\n"],"mappings":";;;;;;;;AAGA,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK,OAAO;AACtB,MAAM,IAAIA,QAAAA,KAAK,QAAQ;AACvB,MAAM,IAAIA,QAAAA,KAAK;AACf,MAAM,YAA8B,WAAgBA,QAAAA,KAAK,MAAM,OAAO,KAAK,UAAUA,QAAAA,KAAK,QAAQ,KAAK,CAAC,CAAC;AACzG,MAAM,eAAeA,QAAAA,KAAK,OAAO,EAC/B,SAAS,yGACX,CAAC;AACD,MAAM,kBAAkB,CAAC;CAAE,MAAM;CAAgB,IAAI;CAAkB,UAAU;CAAM,QAAQ;AAAa,CAAC;AAC7G,MAAa,mBAAmBA,QAAAA,KAAK,OAAO;CAC1C,cAAc;CACd,MAAMA,QAAAA,KAAK,OAAO;EAAE,OAAO;EAAG,SAASA,QAAAA,KAAK,MAAM,CAAC;CAAE,CAAC;CACtD,SAASA,QAAAA,KAAK,MACZA,QAAAA,KAAK,OAAO;EACV,MAAM;EACN,OAAO,SAAS;GAAC;GAAiB;GAAc;GAAa;GAAY;GAAc;GAAU;EAAQ,CAAC;EAC1G,QAAQ,SAAS;GAAC;GAAU;GAAQ;EAAY,CAAC;EACjD,mBAAmB;EACnB,OAAOA,QAAAA,KAAK,MAAMA,QAAAA,KAAK,OAAO;GAAE,MAAM;GAAG,QAAQ;GAAG,aAAa,EAAE,CAAC;EAAE,CA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KAAK,EAAE,CAAC;AACvD,CAAC;AACD,MAAa,wBAAA,GAAuBC,kCAAAA,qBAAAA,CAAqB;CACvD,GAAG;CACH,QAAQ;CACR,OAAOD,QAAAA,KAAK,OACV;EAAE,SAAS;EAAO,MAAMA,QAAAA,KAAK,OAAO;GAAE,WAAW;GAAG,WAAW;EAAI,CAAC;EAAG,WAAW;CAAW,GAC7F,EAAE,sBAAsB,MAAM,CAChC;CACA,QAAQ;AACV,CAAC;AACD,MAAa,wBAAA,GAAuBC,kCAAAA,qBAAAA,CAAqB;CACvD,GAAG;CACH,QAAQ;CACR,OAAOD,QAAAA,KAAK,OAAO;EAAE,SAAS;EAAO,OAAOA,QAAAA,KAAK,QAAQ;CAAE,GAAG,EAAE,sBAAsB,MAAM,CAAC;CAC7F,QAAQ;AACV,CAAC;AACD,MAAa,wBAAA,GAAuBC,kCAAAA,qBAAAA,CAAqB;CACvD,GAAG;CACH,QAAQ;CACR,OAAOD,QAAAA,KAAK,OACV;EAAE,SAAS;EAAO,QAAQA,QAAAA,KAAK,OAAO;GAAE,WAAW;GAAG,WAAW;EAAM,CAAC;CAAE,GAC1E,EAAE,sBAAsB,MAAM,CAChC;CACA,QAAQ;AACV,CAAC;AACD,MAAa,qBAAA,GAAoBC,kCAAAA,qBAAAA,CAAqB;CACpD,GAAG;CACH,QAAQ;CACR,OAAOD,QAAAA,KAAK,OAAO,EAAE,SAAS,MAAM,GAAG,EAAE,sBAAsB,MAAM,CAAC;CACtE,QAAQ;AACV,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts","../src/types/webMcp.ts","../src/schemas/mcpApps.ts"],"mappings":";;;;qBAiDa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UCvCI;EACf;EACA;EACA;EACA;EACA,cAAc;EACd;IACE;IACA;IACA;MAAe;OAAiB;;IAChC,OAAO;;EAET,MAAM;EACN;IAAU;IAAoB;IAA6B,QAAQ;IAAyB;;EAC5F;EACA;;;;qBCTW,8DAAgB,eAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;qBAuBhB,kEAAoB,eAAA,KAAA;;;;;qBAMpB,kEAAoB,eAAA,KAAA;;;;;;;;;;qBASpB,kEAAoB,eAAA,KAAA;;;IAK/B,KAAA;qBACW,kEAAoB,eAAA,KAAA;;;IAQ/B,KAAA;qBACW,+DAAiB,eAAA,KAAA;;IAK5B,KAAA"}
1
+ {"version":3,"file":"apiContracts.d.mts","names":[],"sources":["../src/schemas/apiContracts.ts","../src/types/webMcp.ts","../src/schemas/mcpApps.ts"],"mappings":";;;;qBAgEa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UCtDI;EACf;EACA;EACA;EACA;EACA,cAAc;EACd;IACE;IACA;IACA;MAAe;OAAiB;;IAChC,OAAO;;EAET,MAAM;EACN;IAAU;IAAoB;IAA6B,QAAQ;IAAyB;;EAC5F;EACA;;;;qBCTW,8DAAgB,eAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;qBAuBhB,kEAAoB,eAAA,KAAA;;;;;qBAMpB,kEAAoB,eAAA,KAAA;;;;;;;;;;qBASpB,kEAAoB,eAAA,KAAA;;;IAK/B,KAAA;qBACW,kEAAoB,eAAA,KAAA;;;IAQ/B,KAAA;qBACW,+DAAiB,eAAA,KAAA;;IAK5B,KAAA"}
@@ -70,6 +70,31 @@ const McpSessionToolSchema = Type.Object({
70
70
  inputSchema: Type.Record(S, Type.Unknown()),
71
71
  tokens: N
72
72
  });
73
+ const StringPairs = Type.Record(S, S);
74
+ const McpServerEntrySchema = Type.Union([Type.Object({
75
+ type: Type.Literal("http"),
76
+ url: Type.String({ maxLength: 2048 }),
77
+ headers: O(StringPairs)
78
+ }), Type.Object({
79
+ command: Type.String({
80
+ minLength: 1,
81
+ maxLength: 1024
82
+ }),
83
+ args: Type.Array(S),
84
+ env: O(StringPairs)
85
+ })]);
86
+ const McpAddServerSchema = Type.Object({
87
+ scope: literals(["repository", "global"]),
88
+ repositoryId: O(RepositoryId),
89
+ name: Type.String({ pattern: "^[A-Za-z0-9_-]{1,64}$" }),
90
+ entry: McpServerEntrySchema,
91
+ trusted: O(B)
92
+ });
93
+ const McpGlobalServersSchema = Type.Object({ servers: Type.Array(Type.Object({
94
+ name: S,
95
+ kind: literals(["remote", "local"]),
96
+ target: S
97
+ })) });
73
98
  const SessionToolQuery = [{
74
99
  name: "server",
75
100
  in: "query",
@@ -149,6 +174,34 @@ const apiContracts = defineApiContract({
149
174
  },
150
175
  responses: jsonApiResponses(McpAuthorizationSchema, 202)
151
176
  },
177
+ {
178
+ id: "mcp.server.add",
179
+ scope,
180
+ basePath: "mcp",
181
+ path: "/servers",
182
+ method: "POST",
183
+ authentication: "owner",
184
+ description: "Add one MCP server to the repository's .mcp.json or the person's own config.",
185
+ body: {
186
+ required: true,
187
+ contentType: "application/json",
188
+ schema: McpAddServerSchema
189
+ },
190
+ responses: jsonApiResponses(Type.Object({
191
+ scope: literals(["repository", "global"]),
192
+ name: S
193
+ }), 201)
194
+ },
195
+ {
196
+ id: "mcp.servers.global",
197
+ scope,
198
+ basePath: "mcp",
199
+ path: "/servers/global",
200
+ method: "GET",
201
+ authentication: "owner",
202
+ description: "List the servers in the person's own MCP config, without headers or environment.",
203
+ responses: jsonApiResponses(McpGlobalServersSchema)
204
+ },
152
205
  ...["GET", "DELETE"].map((method) => ({
153
206
  id: `mcp.authorization.${method}`,
154
207
  scope,
@@ -1 +1 @@
1
- {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts","../src/schemas/mcpApps.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst literals = <T extends string>(values: T[]) => Type.Union(values.map((value) => Type.Literal(value)));\nconst RepositoryId = Type.String({\n pattern: '^(?:[a-f0-9]{32}|repo-[A-Za-z0-9_-]{24}|[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$',\n});\nconst RepositoryQuery = [{ name: 'repositoryId', in: 'query' as const, required: true, schema: RepositoryId }];\nexport const McpCatalogSchema = Type.Object({\n repositoryId: S,\n sync: Type.Object({ fresh: B, reasons: Type.Array(S) }),\n servers: Type.Array(\n Type.Object({\n name: S,\n state: literals(['not-connected', 'connecting', 'connected', 'degraded', 'needs-auth', 'failed', 'closed']),\n source: literals(['cached', 'live', 'configured']),\n credentialPresent: B,\n tools: Type.Array(Type.Object({ name: S, piName: S, description: O(S) })),\n error: O(S),\n }),\n ),\n droppedServers: Type.Array(S),\n diagnostics: Type.Array(S),\n});\nexport const McpAuthorizationSchema = Type.Object({\n id: S,\n repositoryId: S,\n serverName: S,\n status: literals(['starting', 'waiting', 'completed', 'failed', 'cancelled', 'expired']),\n authorizationUrl: O(S),\n error: O(S),\n expiresAt: N,\n});\nexport const McpSessionToolSchema = Type.Object({\n server: S,\n tool: S,\n description: O(S),\n inputSchema: Type.Record(S, Type.Unknown()),\n tokens: N,\n});\nconst SessionToolQuery = [\n { name: 'server', in: 'query' as const, required: true, schema: Type.String({ minLength: 1, maxLength: 160 }) },\n { name: 'tool', in: 'query' as const, required: true, schema: Type.String({ minLength: 1, maxLength: 256 }) },\n];\ntype HttpContract = Parameters<typeof defineApiContract>[0]['http'][number];\nexport const apiContracts = defineApiContract({\n version: 1,\n sockets: [],\n dynamic: [],\n http: [\n {\n id: 'mcp.session.tool',\n scope: 'session',\n basePath: 'mcp-session',\n path: '/tool',\n method: 'GET',\n authentication: 'owner',\n description: 'Read one tool the session reaches through mcp_use: its description, schema, and token cost.',\n parameters: SessionToolQuery,\n responses: jsonApiResponses(McpSessionToolSchema),\n },\n ...(['global', 'workspace'] as const).flatMap((scope): HttpContract[] => [\n {\n id: 'mcp.catalog',\n scope,\n basePath: 'mcp',\n path: '/repository',\n method: 'GET',\n authentication: 'owner',\n description: 'Read the synced MCP repository catalog.',\n parameters: RepositoryQuery,\n responses: jsonApiResponses(McpCatalogSchema),\n },\n {\n id: 'mcp.discover',\n scope,\n basePath: 'mcp',\n path: '/repository/discover',\n method: 'POST',\n authentication: 'owner',\n description: 'Discover repository MCP servers.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ repositoryId: RepositoryId }) },\n responses: jsonApiResponses(McpCatalogSchema),\n },\n {\n id: 'mcp.authorize',\n scope,\n basePath: 'mcp',\n path: '/repository/authorize',\n method: 'POST',\n authentication: 'owner',\n description: 'Start MCP authorization.',\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({\n repositoryId: RepositoryId,\n serverName: Type.String({ minLength: 1, maxLength: 160 }),\n }),\n },\n responses: jsonApiResponses(McpAuthorizationSchema, 202),\n },\n ...(['GET', 'DELETE'] as const).map((method) => ({\n id: `mcp.authorization.${method}`,\n scope,\n basePath: 'mcp',\n path: '/repository/authorize/{flowId}',\n method,\n authentication: 'owner' as const,\n description: method === 'GET' ? 'Read an authorization flow.' : 'Cancel an authorization flow.',\n parameters: RepositoryQuery,\n responses: jsonApiResponses(McpAuthorizationSchema),\n })),\n ]),\n ],\n});\nexport default apiContracts;\n","import { definePoPluginMethod } from '@agimon-ai/po-core/pluginProtocol';\nimport { Type } from 'typebox';\n\nexport type { McpAppOpenResult } from '../types/webMcp';\n\nconst Lease = Type.String({ minLength: 1, maxLength: 128 });\nconst JsonObject = Type.Record(Type.String(), Type.Unknown());\nconst Empty = Type.Object({}, { additionalProperties: false });\nconst Result = Type.Object({\n content: Type.Array(Type.Unknown()),\n structuredContent: Type.Optional(Type.Unknown()),\n _meta: Type.Optional(JsonObject),\n isError: Type.Optional(Type.Boolean()),\n});\nconst Address = { service: 'mcp.apps', scope: 'session', direction: 'client-to-server' } as const;\n\nexport const mcpAppOpenMethod = definePoPluginMethod({\n ...Address,\n method: 'open',\n input: Type.Object({ toolCallId: Type.String({ minLength: 1, maxLength: 512 }) }, { additionalProperties: false }),\n output: Type.Object({\n leaseId: Lease,\n html: Type.String(),\n resourceUri: Type.String(),\n protocol: Type.Union([Type.Literal('mcp'), Type.Literal('openai')]),\n resourceMeta: JsonObject,\n tool: Type.Object({\n name: Type.String(),\n description: Type.String(),\n inputSchema: Type.Object({ type: Type.Literal('object') }, { additionalProperties: true }),\n _meta: JsonObject,\n }),\n args: JsonObject,\n result: Result,\n state: Type.Unknown(),\n readOnly: Type.Boolean(),\n }),\n});\n\nexport const mcpAppActivateMethod = definePoPluginMethod({\n ...Address,\n method: 'activate',\n input: Type.Object({ leaseId: Lease }, { additionalProperties: false }),\n output: Type.Object({ readOnly: Type.Literal(false) }),\n});\nexport const mcpAppCallToolMethod = definePoPluginMethod({\n ...Address,\n method: 'callTool',\n input: Type.Object(\n { leaseId: Lease, name: Type.String({ minLength: 1, maxLength: 256 }), arguments: JsonObject },\n { additionalProperties: false },\n ),\n output: Result,\n});\nexport const mcpAppSetStateMethod = definePoPluginMethod({\n ...Address,\n method: 'setState',\n input: Type.Object({ leaseId: Lease, state: Type.Unknown() }, { additionalProperties: false }),\n output: Empty,\n});\nexport const mcpAppFollowUpMethod = definePoPluginMethod({\n ...Address,\n method: 'followUp',\n input: Type.Object(\n { leaseId: Lease, prompt: Type.String({ minLength: 1, maxLength: 16000 }) },\n { additionalProperties: false },\n ),\n output: Empty,\n});\nexport const mcpAppCloseMethod = definePoPluginMethod({\n ...Address,\n method: 'close',\n input: Type.Object({ leaseId: Lease }, { additionalProperties: false }),\n output: Empty,\n});\nexport const mcpAppMethods = [\n mcpAppOpenMethod,\n mcpAppActivateMethod,\n mcpAppCallToolMethod,\n mcpAppSetStateMethod,\n mcpAppFollowUpMethod,\n mcpAppCloseMethod,\n] as const;\n"],"mappings":";;;;AAGA,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,Q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O,KAAK,OAAO,EAAE,SAAS,MAAM,GAAG,EAAE,sBAAsB,MAAM,CAAC;CACtE,QAAQ,KAAK,OAAO,EAAE,UAAU,KAAK,QAAQ,KAAK,EAAE,CAAC;AACvD,CAAC;AACD,MAAa,uBAAuB,qBAAqB;CACvD,GAAG;CACH,QAAQ;CACR,OAAO,KAAK,OACV;EAAE,SAAS;EAAO,MAAM,KAAK,OAAO;GAAE,WAAW;GAAG,WAAW;EAAI,CAAC;EAAG,WAAW;CAAW,GAC7F,EAAE,sBAAsB,MAAM,CAChC;CACA,QAAQ;AACV,CAAC;AACD,MAAa,uBAAuB,qBAAqB;CACvD,GAAG;CACH,QAAQ;CACR,OAAO,KAAK,OAAO;EAAE,SAAS;EAAO,OAAO,KAAK,QAAQ;CAAE,GAAG,EAAE,sBAAsB,MAAM,CAAC;CAC7F,QAAQ;AACV,CAAC;AACD,MAAa,uBAAuB,qBAAqB;CACvD,GAAG;CACH,QAAQ;CACR,OAAO,KAAK,OACV;EAAE,SAAS;EAAO,QAAQ,KAAK,OAAO;GAAE,WAAW;GAAG,WAAW;EAAM,CAAC;CAAE,GAC1E,EAAE,sBAAsB,MAAM,CAChC;CACA,QAAQ;AACV,CAAC;AACD,MAAa,oBAAoB,qBAAqB;CACpD,GAAG;CACH,QAAQ;CACR,OAAO,KAAK,OAAO,EAAE,SAAS,MAAM,GAAG,EAAE,sBAAsB,MAAM,CAAC;CACtE,QAAQ;AACV,CAAC"}
1
+ {"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts","../src/schemas/mcpApps.ts"],"sourcesContent":["import { defineApiContract, jsonApiResponses } from '@agimon-ai/po-core/apiContracts';\nimport { Type } from 'typebox';\n\nconst S = Type.String();\nconst N = Type.Number();\nconst B = Type.Boolean();\nconst O = Type.Optional;\nconst literals = <T extends string>(values: T[]) => Type.Union(values.map((value) => Type.Literal(value)));\nconst RepositoryId = Type.String({\n pattern: '^(?:[a-f0-9]{32}|repo-[A-Za-z0-9_-]{24}|[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$',\n});\nconst RepositoryQuery = [{ name: 'repositoryId', in: 'query' as const, required: true, schema: RepositoryId }];\nexport const McpCatalogSchema = Type.Object({\n repositoryId: S,\n sync: Type.Object({ fresh: B, reasons: Type.Array(S) }),\n servers: Type.Array(\n Type.Object({\n name: S,\n state: literals(['not-connected', 'connecting', 'connected', 'degraded', 'needs-auth', 'failed', 'closed']),\n source: literals(['cached', 'live', 'configured']),\n credentialPresent: B,\n tools: Type.Array(Type.Object({ name: S, piName: S, description: O(S) })),\n error: O(S),\n }),\n ),\n droppedServers: Type.Array(S),\n diagnostics: Type.Array(S),\n});\nexport const McpAuthorizationSchema = Type.Object({\n id: S,\n repositoryId: S,\n serverName: S,\n status: literals(['starting', 'waiting', 'completed', 'failed', 'cancelled', 'expired']),\n authorizationUrl: O(S),\n error: O(S),\n expiresAt: N,\n});\nexport const McpSessionToolSchema = Type.Object({\n server: S,\n tool: S,\n description: O(S),\n inputSchema: Type.Record(S, Type.Unknown()),\n tokens: N,\n});\nconst StringPairs = Type.Record(S, S);\nexport const McpServerEntrySchema = Type.Union([\n Type.Object({ type: Type.Literal('http'), url: Type.String({ maxLength: 2048 }), headers: O(StringPairs) }),\n Type.Object({ command: Type.String({ minLength: 1, maxLength: 1024 }), args: Type.Array(S), env: O(StringPairs) }),\n]);\nexport const McpAddServerSchema = Type.Object({\n scope: literals(['repository', 'global']),\n repositoryId: O(RepositoryId),\n name: Type.String({ pattern: '^[A-Za-z0-9_-]{1,64}$' }),\n entry: McpServerEntrySchema,\n trusted: O(B),\n});\nexport const McpGlobalServersSchema = Type.Object({\n servers: Type.Array(Type.Object({ name: S, kind: literals(['remote', 'local']), target: S })),\n});\nconst SessionToolQuery = [\n { name: 'server', in: 'query' as const, required: true, schema: Type.String({ minLength: 1, maxLength: 160 }) },\n { name: 'tool', in: 'query' as const, required: true, schema: Type.String({ minLength: 1, maxLength: 256 }) },\n];\ntype HttpContract = Parameters<typeof defineApiContract>[0]['http'][number];\nexport const apiContracts = defineApiContract({\n version: 1,\n sockets: [],\n dynamic: [],\n http: [\n {\n id: 'mcp.session.tool',\n scope: 'session',\n basePath: 'mcp-session',\n path: '/tool',\n method: 'GET',\n authentication: 'owner',\n description: 'Read one tool the session reaches through mcp_use: its description, schema, and token cost.',\n parameters: SessionToolQuery,\n responses: jsonApiResponses(McpSessionToolSchema),\n },\n ...(['global', 'workspace'] as const).flatMap((scope): HttpContract[] => [\n {\n id: 'mcp.catalog',\n scope,\n basePath: 'mcp',\n path: '/repository',\n method: 'GET',\n authentication: 'owner',\n description: 'Read the synced MCP repository catalog.',\n parameters: RepositoryQuery,\n responses: jsonApiResponses(McpCatalogSchema),\n },\n {\n id: 'mcp.discover',\n scope,\n basePath: 'mcp',\n path: '/repository/discover',\n method: 'POST',\n authentication: 'owner',\n description: 'Discover repository MCP servers.',\n body: { required: true, contentType: 'application/json', schema: Type.Object({ repositoryId: RepositoryId }) },\n responses: jsonApiResponses(McpCatalogSchema),\n },\n {\n id: 'mcp.authorize',\n scope,\n basePath: 'mcp',\n path: '/repository/authorize',\n method: 'POST',\n authentication: 'owner',\n description: 'Start MCP authorization.',\n body: {\n required: true,\n contentType: 'application/json',\n schema: Type.Object({\n repositoryId: RepositoryId,\n serverName: Type.String({ minLength: 1, maxLength: 160 }),\n }),\n },\n responses: jsonApiResponses(McpAuthorizationSchema, 202),\n },\n {\n id: 'mcp.server.add',\n scope,\n basePath: 'mcp',\n path: '/servers',\n method: 'POST',\n authentication: 'owner',\n description: \"Add one MCP server to the repository's .mcp.json or the person's own config.\",\n body: { required: true, contentType: 'application/json', schema: McpAddServerSchema },\n responses: jsonApiResponses(Type.Object({ scope: literals(['repository', 'global']), name: S }), 201),\n },\n {\n id: 'mcp.servers.global',\n scope,\n basePath: 'mcp',\n path: '/servers/global',\n method: 'GET',\n authentication: 'owner',\n description: \"List the servers in the person's own MCP config, without headers or environment.\",\n responses: jsonApiResponses(McpGlobalServersSchema),\n },\n ...(['GET', 'DELETE'] as const).map((method) => ({\n id: `mcp.authorization.${method}`,\n scope,\n basePath: 'mcp',\n path: '/repository/authorize/{flowId}',\n method,\n authentication: 'owner' as const,\n description: method === 'GET' ? 'Read an authorization flow.' : 'Cancel an authorization flow.',\n parameters: RepositoryQuery,\n responses: jsonApiResponses(McpAuthorizationSchema),\n })),\n ]),\n ],\n});\nexport default apiContracts;\n","import { definePoPluginMethod } from '@agimon-ai/po-core/pluginProtocol';\nimport { Type } from 'typebox';\n\nexport type { McpAppOpenResult } from '../types/webMcp';\n\nconst Lease = Type.String({ minLength: 1, maxLength: 128 });\nconst JsonObject = Type.Record(Type.String(), Type.Unknown());\nconst Empty = Type.Object({}, { additionalProperties: false });\nconst Result = Type.Object({\n content: Type.Array(Type.Unknown()),\n structuredContent: Type.Optional(Type.Unknown()),\n _meta: Type.Optional(JsonObject),\n isError: Type.Optional(Type.Boolean()),\n});\nconst Address = { service: 'mcp.apps', scope: 'session', direction: 'client-to-server' } as const;\n\nexport const mcpAppOpenMethod = definePoPluginMethod({\n ...Address,\n method: 'open',\n input: Type.Object({ toolCallId: Type.String({ minLength: 1, maxLength: 512 }) }, { additionalProperties: false }),\n output: Type.Object({\n leaseId: Lease,\n html: Type.String(),\n resourceUri: Type.String(),\n protocol: Type.Union([Type.Literal('mcp'), Type.Literal('openai')]),\n resourceMeta: JsonObject,\n tool: Type.Object({\n name: Type.String(),\n description: Type.String(),\n inputSchema: Type.Object({ type: Type.Literal('object') }, { additionalProperties: true }),\n _meta: JsonObject,\n }),\n args: JsonObject,\n result: Result,\n state: Type.Unknown(),\n readOnly: Type.Boolean(),\n }),\n});\n\nexport const mcpAppActivateMethod = definePoPluginMethod({\n ...Address,\n method: 'activate',\n input: Type.Object({ leaseId: Lease }, { additionalProperties: false }),\n output: Type.Object({ readOnly: Type.Literal(false) }),\n});\nexport const mcpAppCallToolMethod = definePoPluginMethod({\n ...Address,\n method: 'callTool',\n input: Type.Object(\n { leaseId: Lease, name: Type.String({ minLength: 1, maxLength: 256 }), arguments: JsonObject },\n { additionalProperties: false },\n ),\n output: Result,\n});\nexport const mcpAppSetStateMethod = definePoPluginMethod({\n ...Address,\n method: 'setState',\n input: Type.Object({ leaseId: Lease, state: Type.Unknown() }, { additionalProperties: false }),\n output: Empty,\n});\nexport const mcpAppFollowUpMethod = definePoPluginMethod({\n ...Address,\n method: 'followUp',\n input: Type.Object(\n { leaseId: Lease, prompt: Type.String({ minLength: 1, maxLength: 16000 }) },\n { additionalProperties: false },\n ),\n output: Empty,\n});\nexport const mcpAppCloseMethod = definePoPluginMethod({\n ...Address,\n method: 'close',\n input: Type.Object({ leaseId: Lease }, { additionalProperties: false }),\n output: Empty,\n});\nexport const mcpAppMethods = [\n mcpAppOpenMethod,\n mcpAppActivateMethod,\n mcpAppCallToolMethod,\n mcpAppSetStateMethod,\n mcpAppFollowUpMethod,\n mcpAppCloseMethod,\n] as const;\n"],"mappings":";;;;AAGA,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,OAAO;AACtB,MAAM,IAAI,KAAK,QAAQ;AACvB,MAAM,IAAI,KAAK;AACf,MAAM,YAA8B,WAAgB,KAAK,MAAM,OAAO,KAAK,UAAU,KAAK,QAAQ,KAAK,CAAC,CAAC;AACzG,MAAM,eAAe,KAAK,OAAO,EAC/B,SAAS,yGACX,CAAC;AACD,MAAM,kBAAkB,CAAC;CAAE,MAAM;CAAgB,IAAI;CAAkB,UAAU;CAAM,QAAQ;AAAa,CAAC;AAC7G,MAAa,mBAAmB,KAAK,OAAO;CAC1C,cAAc;CACd,MAAM,KAAK,OAAO;EAAE,OAAO;EAAG,SAAS,KAAK,MAAM,CAAC;CAAE,CAAC;CACtD,SAAS,KAAK,MACZ,KAAK,OAAO;EACV,MAAM;EACN,OAAO,SAAS;GAAC;GAAiB;GAAc;GAAa;GAAY;GAAc;GAAU;EAAQ,CAAC;EAC1G,QAAQ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