@agimon-ai/po-build 0.0.0-alpha.3 → 0.0.0-alpha.30

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 (52) hide show
  1. package/LICENSE +149 -22
  2. package/dist/constants/contributions.cjs +1 -1
  3. package/dist/constants/contributions.cjs.map +1 -1
  4. package/dist/constants/contributions.mjs +1 -1
  5. package/dist/constants/contributions.mjs.map +1 -1
  6. package/dist/constants/layout.cjs +1 -1
  7. package/dist/constants/layout.cjs.map +1 -1
  8. package/dist/constants/layout.d.mts +2 -0
  9. package/dist/constants/layout.d.mts.map +1 -1
  10. package/dist/constants/layout.mjs +1 -1
  11. package/dist/constants/layout.mjs.map +1 -1
  12. package/dist/services/generate/index.cjs.map +1 -1
  13. package/dist/services/generate/index.mjs.map +1 -1
  14. package/dist/services/renderClient/index.cjs.map +1 -1
  15. package/dist/services/renderClient/index.mjs.map +1 -1
  16. package/dist/services/renderEntry/index.cjs +3 -3
  17. package/dist/services/renderEntry/index.cjs.map +1 -1
  18. package/dist/services/renderEntry/index.d.mts +10 -4
  19. package/dist/services/renderEntry/index.d.mts.map +1 -1
  20. package/dist/services/renderEntry/index.mjs +3 -3
  21. package/dist/services/renderEntry/index.mjs.map +1 -1
  22. package/dist/services/renderEntry/type.d.mts +1 -1
  23. package/dist/services/renderMcpWidgets/index.cjs +1 -1
  24. package/dist/services/renderMcpWidgets/index.cjs.map +1 -1
  25. package/dist/services/renderMcpWidgets/index.mjs +1 -1
  26. package/dist/services/renderMcpWidgets/index.mjs.map +1 -1
  27. package/dist/services/resolveTarget/index.cjs +1 -1
  28. package/dist/services/resolveTarget/index.cjs.map +1 -1
  29. package/dist/services/resolveTarget/index.mjs +1 -1
  30. package/dist/services/resolveTarget/index.mjs.map +1 -1
  31. package/dist/services/resolveTarget/type.d.mts +2 -0
  32. package/dist/services/resolveTarget/type.d.mts.map +1 -1
  33. package/dist/services/serverContracts/index.cjs +3 -0
  34. package/dist/services/serverContracts/index.cjs.map +1 -0
  35. package/dist/services/serverContracts/index.mjs +3 -0
  36. package/dist/services/serverContracts/index.mjs.map +1 -0
  37. package/dist/services/serverContracts/type.d.mts +8 -0
  38. package/dist/services/serverContracts/type.d.mts.map +1 -0
  39. package/dist/services/syncManifest/index.cjs +1 -1
  40. package/dist/services/syncManifest/index.cjs.map +1 -1
  41. package/dist/services/syncManifest/index.d.mts.map +1 -1
  42. package/dist/services/syncManifest/index.mjs +1 -1
  43. package/dist/services/syncManifest/index.mjs.map +1 -1
  44. package/dist/services/syncManifest/type.d.mts +3 -0
  45. package/dist/services/syncManifest/type.d.mts.map +1 -1
  46. package/dist/services/tsdownPreset/index.cjs +1 -1
  47. package/dist/services/tsdownPreset/index.cjs.map +1 -1
  48. package/dist/services/tsdownPreset/index.d.mts +1 -1
  49. package/dist/services/tsdownPreset/index.d.mts.map +1 -1
  50. package/dist/services/tsdownPreset/index.mjs +1 -1
  51. package/dist/services/tsdownPreset/index.mjs.map +1 -1
  52. package/package.json +5 -5
package/LICENSE CHANGED
@@ -1,22 +1,149 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Vuong Ngo
4
- Copyright (c) 2026 pulseaiclub
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- 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.
@@ -1,2 +1,2 @@
1
- const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,mode:`minorModes`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`minorModes`,channel:`channels`,tab:`tabs`,template:`templates`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,"selection-axis":`selectionAxes`,setting:`settingsSections`,action:`userMessageActions`,lifecycle:`start`,template:`nativeTemplates`,store:``},i={section:`settingsSections`,panel:`settingsPanels`},a={context:`contextActions`,message:`userMessageActions`},o={message:`userMessageActions`};exports.ACTION_FIELDS=a,exports.MCP_FIELDS=t,exports.NATIVE_ACTION_FIELDS=o,exports.NATIVE_FIELDS=r,exports.SERVER_FIELDS=e,exports.SETTING_FIELDS=i,exports.WEB_FIELDS=n;
1
+ const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,mode:`minorModes`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`minorModes`,channel:`channels`,tab:`tabs`,template:`templates`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,"file-links":`fileLinks`,"selection-axis":`selectionAxes`,setting:`settingsSections`,action:`userMessageActions`,lifecycle:`start`,template:`nativeTemplates`,store:``},i={section:`settingsSections`,panel:`settingsPanels`},a={context:`contextActions`,message:`userMessageActions`},o={message:`userMessageActions`};exports.ACTION_FIELDS=a,exports.MCP_FIELDS=t,exports.NATIVE_ACTION_FIELDS=o,exports.NATIVE_FIELDS=r,exports.SERVER_FIELDS=e,exports.SETTING_FIELDS=i,exports.WEB_FIELDS=n;
2
2
  //# sourceMappingURL=contributions.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contributions.cjs","names":["SERVER_FIELDS","MCP_FIELDS","WEB_FIELDS","NATIVE_FIELDS","SETTING_FIELDS","ACTION_FIELDS","NATIVE_ACTION_FIELDS"],"sources":["../../src/constants/contributions.ts"],"sourcesContent":["/**\n * Which contribution field each surface produces, per host and side.\n *\n * The surface names the concept; the host decides which array carries it.\n * A surface missing from a host's table is legitimately absent there, such\n * as api/ on MCP, and is skipped without complaint.\n */\n\n/** A surface that produces nothing registrable, but is still published. */\nexport const NOT_A_CONTRIBUTION = '';\n\nexport const SERVER_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n 'tool-restriction': 'toolRestrictions',\n command: 'commands',\n hook: 'hooks',\n mode: 'minorModes',\n api: 'api',\n channel: 'channels',\n method: 'methods',\n resource: 'resources',\n};\n\nexport const MCP_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n skill: 'skills',\n resource: 'uiResources',\n};\n\nexport const WEB_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n command: 'paletteCommands',\n mode: 'minorModes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n dock: 'dockFaces',\n setting: 'settingsSections',\n slot: 'slots',\n // Every fill is a slot fill. The cockpit declares its own regions as slots\n // (overlay, rail, context, activity and so on), so the build tooling needs\n // to know none of their names.\n fill: 'fills',\n action: 'contextActions',\n 'activity-group': 'activityGroups',\n leader: 'leaderBindings',\n 'selection-axis': 'selectionAxes',\n lifecycle: 'start',\n 'file-links': 'fileLinks',\n 'repository-settings-panel': 'repositorySettingsPanel',\n api: NOT_A_CONTRIBUTION,\n method: NOT_A_CONTRIBUTION,\n store: NOT_A_CONTRIBUTION,\n};\n\n/**\n * The subset of the cockpit's fields the native app installs.\n *\n * The values match WEB_FIELDS because the native app reuses the cockpit's\n * plugin registry: a native plugin is a web plugin definition built from\n * `.native` files.\n */\nexport const NATIVE_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n 'selection-axis': 'selectionAxes',\n setting: 'settingsSections',\n // Only the message shape: see NATIVE_ACTION_FIELDS.\n action: 'userMessageActions',\n lifecycle: 'start',\n // Its own field: a phone layout has a different contract from a cockpit template.\n template: 'nativeTemplates',\n store: NOT_A_CONTRIBUTION,\n};\n\n/** Disambiguates the two shapes a `setting/` file can take. */\nexport const SETTING_FIELDS: Readonly<Record<string, string>> = {\n section: 'settingsSections',\n panel: 'settingsPanels',\n};\n\n/** Disambiguates the two shapes an `action/` file can take. */\nexport const ACTION_FIELDS: Readonly<Record<string, string>> = {\n context: 'contextActions',\n message: 'userMessageActions',\n};\n\n/**\n * The `action/` shapes the native app installs. A phone has no context items,\n * so a context action, named or defaulted, stays unsupported there.\n */\nexport const NATIVE_ACTION_FIELDS: Readonly<Record<string, string>> = {\n message: 'userMessageActions',\n};\n"],"mappings":"AAWA,MAAaA,EAAkD,CAC7D,KAAM,QACN,mBAAoB,mBACpB,QAAS,WACT,KAAM,QACN,KAAM,aACN,IAAK,MACL,QAAS,WACT,OAAQ,UACR,SAAU,WACZ,EAEaC,EAA+C,CAC1D,KAAM,QACN,MAAO,SACP,SAAU,aACZ,EAEaC,EAA+C,CAC1D,KAAM,gBACN,QAAS,kBACT,KAAM,aACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAClB,iBAAkB,gBAClB,QAAS,mBAET,OAAQ,qBACR,UAAW,QAEX,SAAU,kBACV,MAAA,EACF,EAGaC,EAAmD,CAC9D,QAAS,mBACT,MAAO,gBACT,EAGaC,EAAkD,CAC7D,QAAS,iBACT,QAAS,oBACX,EAMaC,EAAyD,CACpE,QAAS,oBACX"}
1
+ {"version":3,"file":"contributions.cjs","names":["SERVER_FIELDS","MCP_FIELDS","WEB_FIELDS","NATIVE_FIELDS","SETTING_FIELDS","ACTION_FIELDS","NATIVE_ACTION_FIELDS"],"sources":["../../src/constants/contributions.ts"],"sourcesContent":["/**\n * Which contribution field each surface produces, per host and side.\n *\n * The surface names the concept; the host decides which array carries it.\n * A surface missing from a host's table is legitimately absent there, such\n * as api/ on MCP, and is skipped without complaint.\n */\n\n/** A surface that produces nothing registrable, but is still published. */\nexport const NOT_A_CONTRIBUTION = '';\n\nexport const SERVER_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n 'tool-restriction': 'toolRestrictions',\n command: 'commands',\n hook: 'hooks',\n mode: 'minorModes',\n api: 'api',\n channel: 'channels',\n method: 'methods',\n resource: 'resources',\n};\n\nexport const MCP_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n skill: 'skills',\n resource: 'uiResources',\n};\n\nexport const WEB_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n command: 'paletteCommands',\n mode: 'minorModes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n dock: 'dockFaces',\n setting: 'settingsSections',\n slot: 'slots',\n // Every fill is a slot fill. The cockpit declares its own regions as slots\n // (overlay, rail, context, activity and so on), so the build tooling needs\n // to know none of their names.\n fill: 'fills',\n action: 'contextActions',\n 'activity-group': 'activityGroups',\n leader: 'leaderBindings',\n 'selection-axis': 'selectionAxes',\n lifecycle: 'start',\n 'file-links': 'fileLinks',\n 'repository-settings-panel': 'repositorySettingsPanel',\n api: NOT_A_CONTRIBUTION,\n method: NOT_A_CONTRIBUTION,\n store: NOT_A_CONTRIBUTION,\n};\n\n/**\n * The subset of the cockpit's fields the native app installs.\n *\n * The values match WEB_FIELDS because the native app reuses the cockpit's\n * plugin registry: a native plugin is a web plugin definition built from\n * `.native` files.\n */\nexport const NATIVE_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n // Paths in message text and tool cards open the plugin's file view on the phone, as in the cockpit.\n 'file-links': 'fileLinks',\n 'selection-axis': 'selectionAxes',\n setting: 'settingsSections',\n // Only the message shape: see NATIVE_ACTION_FIELDS.\n action: 'userMessageActions',\n lifecycle: 'start',\n // Its own field: a phone layout has a different contract from a cockpit template.\n template: 'nativeTemplates',\n store: NOT_A_CONTRIBUTION,\n};\n\n/** Disambiguates the two shapes a `setting/` file can take. */\nexport const SETTING_FIELDS: Readonly<Record<string, string>> = {\n section: 'settingsSections',\n panel: 'settingsPanels',\n};\n\n/** Disambiguates the two shapes an `action/` file can take. */\nexport const ACTION_FIELDS: Readonly<Record<string, string>> = {\n context: 'contextActions',\n message: 'userMessageActions',\n};\n\n/**\n * The `action/` shapes the native app installs. A phone has no context items,\n * so a context action, named or defaulted, stays unsupported there.\n */\nexport const NATIVE_ACTION_FIELDS: Readonly<Record<string, string>> = {\n message: 'userMessageActions',\n};\n"],"mappings":"AAWA,MAAaA,EAAkD,CAC7D,KAAM,QACN,mBAAoB,mBACpB,QAAS,WACT,KAAM,QACN,KAAM,aACN,IAAK,MACL,QAAS,WACT,OAAQ,UACR,SAAU,WACZ,EAEaC,EAA+C,CAC1D,KAAM,QACN,MAAO,SACP,SAAU,aACZ,EAEaC,EAA+C,CAC1D,KAAM,gBACN,QAAS,kBACT,KAAM,aACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAElB,aAAc,YACd,iBAAkB,gBAClB,QAAS,mBAET,OAAQ,qBACR,UAAW,QAEX,SAAU,kBACV,MAAA,EACF,EAGaC,EAAmD,CAC9D,QAAS,mBACT,MAAO,gBACT,EAGaC,EAAkD,CAC7D,QAAS,iBACT,QAAS,oBACX,EAMaC,EAAyD,CACpE,QAAS,oBACX"}
@@ -1,2 +1,2 @@
1
- const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,mode:`minorModes`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`minorModes`,channel:`channels`,tab:`tabs`,template:`templates`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,"selection-axis":`selectionAxes`,setting:`settingsSections`,action:`userMessageActions`,lifecycle:`start`,template:`nativeTemplates`,store:``},i={section:`settingsSections`,panel:`settingsPanels`},a={context:`contextActions`,message:`userMessageActions`},o={message:`userMessageActions`};export{a as ACTION_FIELDS,t as MCP_FIELDS,o as NATIVE_ACTION_FIELDS,r as NATIVE_FIELDS,e as SERVER_FIELDS,i as SETTING_FIELDS,n as WEB_FIELDS};
1
+ const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,mode:`minorModes`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`minorModes`,channel:`channels`,tab:`tabs`,template:`templates`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,"file-links":`fileLinks`,"selection-axis":`selectionAxes`,setting:`settingsSections`,action:`userMessageActions`,lifecycle:`start`,template:`nativeTemplates`,store:``},i={section:`settingsSections`,panel:`settingsPanels`},a={context:`contextActions`,message:`userMessageActions`},o={message:`userMessageActions`};export{a as ACTION_FIELDS,t as MCP_FIELDS,o as NATIVE_ACTION_FIELDS,r as NATIVE_FIELDS,e as SERVER_FIELDS,i as SETTING_FIELDS,n as WEB_FIELDS};
2
2
  //# sourceMappingURL=contributions.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contributions.mjs","names":["SERVER_FIELDS","MCP_FIELDS","WEB_FIELDS","NATIVE_FIELDS","SETTING_FIELDS","ACTION_FIELDS","NATIVE_ACTION_FIELDS"],"sources":["../../src/constants/contributions.ts"],"sourcesContent":["/**\n * Which contribution field each surface produces, per host and side.\n *\n * The surface names the concept; the host decides which array carries it.\n * A surface missing from a host's table is legitimately absent there, such\n * as api/ on MCP, and is skipped without complaint.\n */\n\n/** A surface that produces nothing registrable, but is still published. */\nexport const NOT_A_CONTRIBUTION = '';\n\nexport const SERVER_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n 'tool-restriction': 'toolRestrictions',\n command: 'commands',\n hook: 'hooks',\n mode: 'minorModes',\n api: 'api',\n channel: 'channels',\n method: 'methods',\n resource: 'resources',\n};\n\nexport const MCP_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n skill: 'skills',\n resource: 'uiResources',\n};\n\nexport const WEB_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n command: 'paletteCommands',\n mode: 'minorModes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n dock: 'dockFaces',\n setting: 'settingsSections',\n slot: 'slots',\n // Every fill is a slot fill. The cockpit declares its own regions as slots\n // (overlay, rail, context, activity and so on), so the build tooling needs\n // to know none of their names.\n fill: 'fills',\n action: 'contextActions',\n 'activity-group': 'activityGroups',\n leader: 'leaderBindings',\n 'selection-axis': 'selectionAxes',\n lifecycle: 'start',\n 'file-links': 'fileLinks',\n 'repository-settings-panel': 'repositorySettingsPanel',\n api: NOT_A_CONTRIBUTION,\n method: NOT_A_CONTRIBUTION,\n store: NOT_A_CONTRIBUTION,\n};\n\n/**\n * The subset of the cockpit's fields the native app installs.\n *\n * The values match WEB_FIELDS because the native app reuses the cockpit's\n * plugin registry: a native plugin is a web plugin definition built from\n * `.native` files.\n */\nexport const NATIVE_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n 'selection-axis': 'selectionAxes',\n setting: 'settingsSections',\n // Only the message shape: see NATIVE_ACTION_FIELDS.\n action: 'userMessageActions',\n lifecycle: 'start',\n // Its own field: a phone layout has a different contract from a cockpit template.\n template: 'nativeTemplates',\n store: NOT_A_CONTRIBUTION,\n};\n\n/** Disambiguates the two shapes a `setting/` file can take. */\nexport const SETTING_FIELDS: Readonly<Record<string, string>> = {\n section: 'settingsSections',\n panel: 'settingsPanels',\n};\n\n/** Disambiguates the two shapes an `action/` file can take. */\nexport const ACTION_FIELDS: Readonly<Record<string, string>> = {\n context: 'contextActions',\n message: 'userMessageActions',\n};\n\n/**\n * The `action/` shapes the native app installs. A phone has no context items,\n * so a context action, named or defaulted, stays unsupported there.\n */\nexport const NATIVE_ACTION_FIELDS: Readonly<Record<string, string>> = {\n message: 'userMessageActions',\n};\n"],"mappings":"AAWA,MAAaA,EAAkD,CAC7D,KAAM,QACN,mBAAoB,mBACpB,QAAS,WACT,KAAM,QACN,KAAM,aACN,IAAK,MACL,QAAS,WACT,OAAQ,UACR,SAAU,WACZ,EAEaC,EAA+C,CAC1D,KAAM,QACN,MAAO,SACP,SAAU,aACZ,EAEaC,EAA+C,CAC1D,KAAM,gBACN,QAAS,kBACT,KAAM,aACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAClB,iBAAkB,gBAClB,QAAS,mBAET,OAAQ,qBACR,UAAW,QAEX,SAAU,kBACV,MAAA,EACF,EAGaC,EAAmD,CAC9D,QAAS,mBACT,MAAO,gBACT,EAGaC,EAAkD,CAC7D,QAAS,iBACT,QAAS,oBACX,EAMaC,EAAyD,CACpE,QAAS,oBACX"}
1
+ {"version":3,"file":"contributions.mjs","names":["SERVER_FIELDS","MCP_FIELDS","WEB_FIELDS","NATIVE_FIELDS","SETTING_FIELDS","ACTION_FIELDS","NATIVE_ACTION_FIELDS"],"sources":["../../src/constants/contributions.ts"],"sourcesContent":["/**\n * Which contribution field each surface produces, per host and side.\n *\n * The surface names the concept; the host decides which array carries it.\n * A surface missing from a host's table is legitimately absent there, such\n * as api/ on MCP, and is skipped without complaint.\n */\n\n/** A surface that produces nothing registrable, but is still published. */\nexport const NOT_A_CONTRIBUTION = '';\n\nexport const SERVER_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n 'tool-restriction': 'toolRestrictions',\n command: 'commands',\n hook: 'hooks',\n mode: 'minorModes',\n api: 'api',\n channel: 'channels',\n method: 'methods',\n resource: 'resources',\n};\n\nexport const MCP_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n skill: 'skills',\n resource: 'uiResources',\n};\n\nexport const WEB_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n command: 'paletteCommands',\n mode: 'minorModes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n dock: 'dockFaces',\n setting: 'settingsSections',\n slot: 'slots',\n // Every fill is a slot fill. The cockpit declares its own regions as slots\n // (overlay, rail, context, activity and so on), so the build tooling needs\n // to know none of their names.\n fill: 'fills',\n action: 'contextActions',\n 'activity-group': 'activityGroups',\n leader: 'leaderBindings',\n 'selection-axis': 'selectionAxes',\n lifecycle: 'start',\n 'file-links': 'fileLinks',\n 'repository-settings-panel': 'repositorySettingsPanel',\n api: NOT_A_CONTRIBUTION,\n method: NOT_A_CONTRIBUTION,\n store: NOT_A_CONTRIBUTION,\n};\n\n/**\n * The subset of the cockpit's fields the native app installs.\n *\n * The values match WEB_FIELDS because the native app reuses the cockpit's\n * plugin registry: a native plugin is a web plugin definition built from\n * `.native` files.\n */\nexport const NATIVE_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n // Paths in message text and tool cards open the plugin's file view on the phone, as in the cockpit.\n 'file-links': 'fileLinks',\n 'selection-axis': 'selectionAxes',\n setting: 'settingsSections',\n // Only the message shape: see NATIVE_ACTION_FIELDS.\n action: 'userMessageActions',\n lifecycle: 'start',\n // Its own field: a phone layout has a different contract from a cockpit template.\n template: 'nativeTemplates',\n store: NOT_A_CONTRIBUTION,\n};\n\n/** Disambiguates the two shapes a `setting/` file can take. */\nexport const SETTING_FIELDS: Readonly<Record<string, string>> = {\n section: 'settingsSections',\n panel: 'settingsPanels',\n};\n\n/** Disambiguates the two shapes an `action/` file can take. */\nexport const ACTION_FIELDS: Readonly<Record<string, string>> = {\n context: 'contextActions',\n message: 'userMessageActions',\n};\n\n/**\n * The `action/` shapes the native app installs. A phone has no context items,\n * so a context action, named or defaulted, stays unsupported there.\n */\nexport const NATIVE_ACTION_FIELDS: Readonly<Record<string, string>> = {\n message: 'userMessageActions',\n};\n"],"mappings":"AAWA,MAAaA,EAAkD,CAC7D,KAAM,QACN,mBAAoB,mBACpB,QAAS,WACT,KAAM,QACN,KAAM,aACN,IAAK,MACL,QAAS,WACT,OAAQ,UACR,SAAU,WACZ,EAEaC,EAA+C,CAC1D,KAAM,QACN,MAAO,SACP,SAAU,aACZ,EAEaC,EAA+C,CAC1D,KAAM,gBACN,QAAS,kBACT,KAAM,aACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAElB,aAAc,YACd,iBAAkB,gBAClB,QAAS,mBAET,OAAQ,qBACR,UAAW,QAEX,SAAU,kBACV,MAAA,EACF,EAGaC,EAAmD,CAC9D,QAAS,mBACT,MAAO,gBACT,EAGaC,EAAkD,CAC7D,QAAS,iBACT,QAAS,oBACX,EAMaC,EAAyD,CACpE,QAAS,oBACX"}
@@ -1,2 +1,2 @@
1
- const e=[`mode`,`domain`],t={server:`server`,web:`web`,native:`native`,mcp:`mcp`},n=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],r=[`server`,`mcp`],i=[`web`,`native`,`ios`,`android`,`desktop`],a=[`server`,`web`,`native`,`mcp`],o=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`],s=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],c=[`fill`,`action`],l=[`api`],u=[`ts`,`tsx`,`mts`,`cts`],d=[`test`,`spec`,`stories`,`edge`];exports.API_ROUTES_MODULE=`src/types/apiRoutes.ts`,exports.BACKEND_GROUP=`backend`,exports.BACKEND_PLATFORMS=r,exports.BACKEND_SURFACES=o,exports.BUILD_TARGET_PLATFORMS=a,exports.DEFAULT_ROUTING_ROOT=`src/extensions`,exports.EXCLUDED_INFIXES=d,exports.FRONTEND_GROUP=`frontend`,exports.FRONTEND_PLATFORMS=i,exports.FRONTEND_SURFACES=s,exports.GATE_SEGMENTS=e,exports.GENERATED_CLIENT_NAME=`client`,exports.GENERATED_DIR=`generated`,exports.GENERATED_ENTRY_FILENAMES=t,exports.GENERATED_ENTRY_NAMES=n,exports.GENERATED_NATIVE_CLIENT_NAME=`client.native`,exports.NATIVE_PLATFORM=`native`,exports.ROOT_FILE_NAME=`root`,exports.ROUTED_SURFACES=l,exports.ROUTE_FILE_NAME=`route`,exports.ROUTING_ROOT_ALIAS=`src/extension`,exports.SESSION_SEGMENT=`sessions`,exports.SOURCE_EXTENSIONS=u,exports.TARGETED_SURFACES=c,exports.WORKSPACE_SEGMENT=`workspaces`;
1
+ const e=[`mode`,`domain`],t={server:`server`,web:`web`,native:`native`,mcp:`mcp`},n=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],r=[`server`,`mcp`],i=[`web`,`native`,`ios`,`android`,`desktop`],a=[`server`,`web`,`native`,`mcp`],o=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`,`contract`],s=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],c=[`fill`,`action`],l=[`api`],u=[`ts`,`tsx`,`mts`,`cts`],d=[`test`,`spec`,`stories`,`edge`];exports.API_ROUTES_MODULE=`src/types/apiRoutes.ts`,exports.BACKEND_GROUP=`backend`,exports.BACKEND_PLATFORMS=r,exports.BACKEND_SURFACES=o,exports.BUILD_TARGET_PLATFORMS=a,exports.CONTRACT_SURFACE=`contract`,exports.DEFAULT_ROUTING_ROOT=`src/extensions`,exports.EXCLUDED_INFIXES=d,exports.FRONTEND_GROUP=`frontend`,exports.FRONTEND_PLATFORMS=i,exports.FRONTEND_SURFACES=s,exports.GATE_SEGMENTS=e,exports.GENERATED_CLIENT_NAME=`client`,exports.GENERATED_DIR=`generated`,exports.GENERATED_ENTRY_FILENAMES=t,exports.GENERATED_ENTRY_NAMES=n,exports.GENERATED_NATIVE_CLIENT_NAME=`client.native`,exports.NATIVE_PLATFORM=`native`,exports.ROOT_FILE_NAME=`root`,exports.ROUTED_SURFACES=l,exports.ROUTE_FILE_NAME=`route`,exports.ROUTING_ROOT_ALIAS=`src/extension`,exports.SERVER_DIST=`./dist/extensions/server.mjs`,exports.SESSION_SEGMENT=`sessions`,exports.SOURCE_EXTENSIONS=u,exports.TARGETED_SURFACES=c,exports.WORKSPACE_SEGMENT=`workspaces`;
2
2
  //# sourceMappingURL=layout.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.cjs","names":["GATE_SEGMENTS","GENERATED_ENTRY_FILENAMES","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Every name here is part of the authoring contract in\n * docs/extension-layout.md. Adding a surface means adding it to both.\n */\n\n/** Where the scan starts, package-relative. */\nexport const DEFAULT_ROUTING_ROOT = 'src/extensions';\n/** Accepted spelling of the same root, for packages that prefer the singular. */\nexport const ROUTING_ROOT_ALIAS = 'src/extension';\n\n/** Group folders that also select a build side. */\nexport const BACKEND_GROUP = 'backend';\nexport const FRONTEND_GROUP = 'frontend';\n\n/** Scope segments, in nesting order below the routing root. */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The same client for a `.native` file, which may import neither the browser\n * contract nor the browser's sealed transport. Imported by its full name: the\n * native build is not Metro and resolves no platform suffix.\n */\nexport const GENERATED_NATIVE_CLIENT_NAME = 'client.native';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = [\n 'pi',\n 'server',\n 'web',\n 'native',\n 'mcp',\n 'client',\n 'client.native',\n];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n];\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'dock',\n 'setting',\n 'slot',\n 'fill',\n 'action',\n 'store',\n 'activity-group',\n 'leader',\n 'selection-axis',\n 'lifecycle',\n 'file-links',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/**\n * Filename infixes excluded everywhere, whatever their position. `edge` marks a\n * workerd variant of its base sibling, resolved only by the private Worker build.\n */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories', 'edge'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAaaA,EAAmC,CAAC,OAAQ,QAAQ,EA+BpDC,EAA4B,CAAE,OAAQ,SAAU,IAAK,MAAO,OAAQ,SAAU,IAAK,KAAM,EAsCzFC,EAA2C,CACtD,KACA,SACA,MACA,SACA,MACA,SACA,eACF,EAWaC,EAAuC,CAAC,SAAU,KAAK,EACvDC,EAAwC,CAAC,MAAO,SAAU,MAAO,UAAW,SAAS,EAWrFC,EAA4C,CAAC,SAAU,MAAO,SAAU,KAAK,EAQ7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,UACF,EAKaC,EAAuC,CAClD,OACA,UACA,MACA,UACA,SACA,MACA,WACA,OACA,UACA,OACA,OACA,SACA,QACA,iBACA,SACA,iBACA,YACA,aACA,2BACF,EAGaC,EAAuC,CAAC,OAAQ,QAAQ,EAGxDC,EAAqC,CAAC,KAAK,EAG3CC,EAAuC,CAAC,KAAM,MAAO,MAAO,KAAK,EAMjEC,EAAsC,CAAC,OAAQ,OAAQ,UAAW,MAAM"}
1
+ {"version":3,"file":"layout.cjs","names":["GATE_SEGMENTS","GENERATED_ENTRY_FILENAMES","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Every name here is part of the authoring contract in\n * docs/extension-layout.md. Adding a surface means adding it to both.\n */\n\n/** Where the scan starts, package-relative. */\nexport const DEFAULT_ROUTING_ROOT = 'src/extensions';\n/** Accepted spelling of the same root, for packages that prefer the singular. */\nexport const ROUTING_ROOT_ALIAS = 'src/extension';\n\n/** Group folders that also select a build side. */\nexport const BACKEND_GROUP = 'backend';\nexport const FRONTEND_GROUP = 'frontend';\n\n/** Scope segments, in nesting order below the routing root. */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/** The built server entry a host imports, package-relative, as `poServer.dist` names it. */\nexport const SERVER_DIST = './dist/extensions/server.mjs';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The same client for a `.native` file, which may import neither the browser\n * contract nor the browser's sealed transport. Imported by its full name: the\n * native build is not Metro and resolves no platform suffix.\n */\nexport const GENERATED_NATIVE_CLIENT_NAME = 'client.native';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = [\n 'pi',\n 'server',\n 'web',\n 'native',\n 'mcp',\n 'client',\n 'client.native',\n];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n * `contract` is not a contribution either: each file declares one service\n * contract its level provides, which the plugin lists as `provides`.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n 'contract',\n];\n\n/** The backend surface whose files declare the service contracts a level provides. */\nexport const CONTRACT_SURFACE = 'contract';\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'dock',\n 'setting',\n 'slot',\n 'fill',\n 'action',\n 'store',\n 'activity-group',\n 'leader',\n 'selection-axis',\n 'lifecycle',\n 'file-links',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/**\n * Filename infixes excluded everywhere, whatever their position. `edge` marks a\n * workerd variant of its base sibling, resolved only by the private Worker build.\n */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories', 'edge'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAaaA,EAAmC,CAAC,OAAQ,QAAQ,EAkCpDC,EAA4B,CAAE,OAAQ,SAAU,IAAK,MAAO,OAAQ,SAAU,IAAK,KAAM,EAsCzFC,EAA2C,CACtD,KACA,SACA,MACA,SACA,MACA,SACA,eACF,EAWaC,EAAuC,CAAC,SAAU,KAAK,EACvDC,EAAwC,CAAC,MAAO,SAAU,MAAO,UAAW,SAAS,EAWrFC,EAA4C,CAAC,SAAU,MAAO,SAAU,KAAK,EAU7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,WACA,UACF,EAQaC,EAAuC,CAClD,OACA,UACA,MACA,UACA,SACA,MACA,WACA,OACA,UACA,OACA,OACA,SACA,QACA,iBACA,SACA,iBACA,YACA,aACA,2BACF,EAGaC,EAAuC,CAAC,OAAQ,QAAQ,EAGxDC,EAAqC,CAAC,KAAK,EAG3CC,EAAuC,CAAC,KAAM,MAAO,MAAO,KAAK,EAMjEC,EAAsC,CAAC,OAAQ,OAAQ,UAAW,MAAM"}
@@ -42,6 +42,8 @@ export declare const NATIVE_PLATFORM = "native";
42
42
  *
43
43
  * `mode` is absent on purpose: it is a gate folder, so it is consumed before
44
44
  * the surface check and its declaration file synthesises the surface instead.
45
+ * `contract` is not a contribution either: each file declares one service
46
+ * contract its level provides, which the plugin lists as `provides`.
45
47
  */
46
48
  export declare const BACKEND_SURFACES: readonly string[];
47
49
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.mts","names":[],"sources":["../../src/constants/layout.ts"],"mappings":";;;;;;;;qBAQa;;qBAEA;;qBAWA;;qBAGA;;;;;;;;;qBAoBA;;;;;;;qBAiEA;qBACA;;;;;;;qBAQA;;;;;;;qBAWA;;;;qBAgBA;;qBAuBA;;qBAGA"}
1
+ {"version":3,"file":"layout.d.mts","names":[],"sources":["../../src/constants/layout.ts"],"mappings":";;;;;;;;qBAQa;;qBAEA;;qBAWA;;qBAGA;;;;;;;;;qBAoBA;;;;;;;qBAoEA;qBACA;;;;;;;qBAQA;;;;;;;;;qBAaA;;;;qBAoBA;;qBAuBA;;qBAGA"}
@@ -1,2 +1,2 @@
1
- const e=`src/extensions`,t=`src/extension`,n=`backend`,r=`frontend`,i=`workspaces`,a=`sessions`,o=[`mode`,`domain`],s=`route`,c=`root`,l=`generated`,u={server:`server`,web:`web`,native:`native`,mcp:`mcp`},d=`client`,f=`client.native`,p=`src/types/apiRoutes.ts`,m=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],h=[`server`,`mcp`],g=[`web`,`native`,`ios`,`android`,`desktop`],_=`native`,v=[`server`,`web`,`native`,`mcp`],y=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`],b=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],x=[`fill`,`action`],S=[`api`],C=[`ts`,`tsx`,`mts`,`cts`],w=[`test`,`spec`,`stories`,`edge`];export{p as API_ROUTES_MODULE,n as BACKEND_GROUP,h as BACKEND_PLATFORMS,y as BACKEND_SURFACES,v as BUILD_TARGET_PLATFORMS,e as DEFAULT_ROUTING_ROOT,w as EXCLUDED_INFIXES,r as FRONTEND_GROUP,g as FRONTEND_PLATFORMS,b as FRONTEND_SURFACES,o as GATE_SEGMENTS,d as GENERATED_CLIENT_NAME,l as GENERATED_DIR,u as GENERATED_ENTRY_FILENAMES,m as GENERATED_ENTRY_NAMES,f as GENERATED_NATIVE_CLIENT_NAME,_ as NATIVE_PLATFORM,c as ROOT_FILE_NAME,S as ROUTED_SURFACES,s as ROUTE_FILE_NAME,t as ROUTING_ROOT_ALIAS,a as SESSION_SEGMENT,C as SOURCE_EXTENSIONS,x as TARGETED_SURFACES,i as WORKSPACE_SEGMENT};
1
+ const e=`src/extensions`,t=`src/extension`,n=`backend`,r=`frontend`,i=`workspaces`,a=`sessions`,o=[`mode`,`domain`],s=`route`,c=`root`,l=`generated`,u=`./dist/extensions/server.mjs`,d={server:`server`,web:`web`,native:`native`,mcp:`mcp`},f=`client`,p=`client.native`,m=`src/types/apiRoutes.ts`,h=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],g=[`server`,`mcp`],_=[`web`,`native`,`ios`,`android`,`desktop`],v=`native`,y=[`server`,`web`,`native`,`mcp`],b=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`,`contract`],x=`contract`,S=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],C=[`fill`,`action`],w=[`api`],T=[`ts`,`tsx`,`mts`,`cts`],E=[`test`,`spec`,`stories`,`edge`];export{m as API_ROUTES_MODULE,n as BACKEND_GROUP,g as BACKEND_PLATFORMS,b as BACKEND_SURFACES,y as BUILD_TARGET_PLATFORMS,x as CONTRACT_SURFACE,e as DEFAULT_ROUTING_ROOT,E as EXCLUDED_INFIXES,r as FRONTEND_GROUP,_ as FRONTEND_PLATFORMS,S as FRONTEND_SURFACES,o as GATE_SEGMENTS,f as GENERATED_CLIENT_NAME,l as GENERATED_DIR,d as GENERATED_ENTRY_FILENAMES,h as GENERATED_ENTRY_NAMES,p as GENERATED_NATIVE_CLIENT_NAME,v as NATIVE_PLATFORM,c as ROOT_FILE_NAME,w as ROUTED_SURFACES,s as ROUTE_FILE_NAME,t as ROUTING_ROOT_ALIAS,u as SERVER_DIST,a as SESSION_SEGMENT,T as SOURCE_EXTENSIONS,C as TARGETED_SURFACES,i as WORKSPACE_SEGMENT};
2
2
  //# sourceMappingURL=layout.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.mjs","names":["DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","BACKEND_GROUP","FRONTEND_GROUP","WORKSPACE_SEGMENT","SESSION_SEGMENT","GATE_SEGMENTS","ROUTE_FILE_NAME","ROOT_FILE_NAME","GENERATED_DIR","GENERATED_ENTRY_FILENAMES","GENERATED_CLIENT_NAME","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","NATIVE_PLATFORM","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Every name here is part of the authoring contract in\n * docs/extension-layout.md. Adding a surface means adding it to both.\n */\n\n/** Where the scan starts, package-relative. */\nexport const DEFAULT_ROUTING_ROOT = 'src/extensions';\n/** Accepted spelling of the same root, for packages that prefer the singular. */\nexport const ROUTING_ROOT_ALIAS = 'src/extension';\n\n/** Group folders that also select a build side. */\nexport const BACKEND_GROUP = 'backend';\nexport const FRONTEND_GROUP = 'frontend';\n\n/** Scope segments, in nesting order below the routing root. */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The same client for a `.native` file, which may import neither the browser\n * contract nor the browser's sealed transport. Imported by its full name: the\n * native build is not Metro and resolves no platform suffix.\n */\nexport const GENERATED_NATIVE_CLIENT_NAME = 'client.native';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = [\n 'pi',\n 'server',\n 'web',\n 'native',\n 'mcp',\n 'client',\n 'client.native',\n];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n];\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'dock',\n 'setting',\n 'slot',\n 'fill',\n 'action',\n 'store',\n 'activity-group',\n 'leader',\n 'selection-axis',\n 'lifecycle',\n 'file-links',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/**\n * Filename infixes excluded everywhere, whatever their position. `edge` marks a\n * workerd variant of its base sibling, resolved only by the private Worker build.\n */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories', 'edge'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAAaA,EAAuB,iBAEvBC,EAAqB,gBAGrBC,EAAgB,UAChBC,EAAiB,WAGjBC,EAAoB,aACpBC,EAAkB,WAGlBC,EAAmC,CAAC,OAAQ,QAAQ,EAGpDC,EAAkB,QAUlBC,EAAiB,OAUjBC,EAAgB,YAQhBC,EAA4B,CAAE,OAAQ,SAAU,IAAK,MAAO,OAAQ,SAAU,IAAK,KAAM,EAUzFC,EAAwB,SAOxBC,EAA+B,gBAS/BC,EAAoB,yBAYpBC,EAA2C,CACtD,KACA,SACA,MACA,SACA,MACA,SACA,eACF,EAWaC,EAAuC,CAAC,SAAU,KAAK,EACvDC,EAAwC,CAAC,MAAO,SAAU,MAAO,UAAW,SAAS,EAQrFC,EAAkB,SAGlBC,EAA4C,CAAC,SAAU,MAAO,SAAU,KAAK,EAQ7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,UACF,EAKaC,EAAuC,CAClD,OACA,UACA,MACA,UACA,SACA,MACA,WACA,OACA,UACA,OACA,OACA,SACA,QACA,iBACA,SACA,iBACA,YACA,aACA,2BACF,EAGaC,EAAuC,CAAC,OAAQ,QAAQ,EAGxDC,EAAqC,CAAC,KAAK,EAG3CC,EAAuC,CAAC,KAAM,MAAO,MAAO,KAAK,EAMjEC,EAAsC,CAAC,OAAQ,OAAQ,UAAW,MAAM"}
1
+ {"version":3,"file":"layout.mjs","names":["DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","BACKEND_GROUP","FRONTEND_GROUP","WORKSPACE_SEGMENT","SESSION_SEGMENT","GATE_SEGMENTS","ROUTE_FILE_NAME","ROOT_FILE_NAME","GENERATED_DIR","SERVER_DIST","GENERATED_ENTRY_FILENAMES","GENERATED_CLIENT_NAME","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","NATIVE_PLATFORM","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","CONTRACT_SURFACE","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Every name here is part of the authoring contract in\n * docs/extension-layout.md. Adding a surface means adding it to both.\n */\n\n/** Where the scan starts, package-relative. */\nexport const DEFAULT_ROUTING_ROOT = 'src/extensions';\n/** Accepted spelling of the same root, for packages that prefer the singular. */\nexport const ROUTING_ROOT_ALIAS = 'src/extension';\n\n/** Group folders that also select a build side. */\nexport const BACKEND_GROUP = 'backend';\nexport const FRONTEND_GROUP = 'frontend';\n\n/** Scope segments, in nesting order below the routing root. */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/** The built server entry a host imports, package-relative, as `poServer.dist` names it. */\nexport const SERVER_DIST = './dist/extensions/server.mjs';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The same client for a `.native` file, which may import neither the browser\n * contract nor the browser's sealed transport. Imported by its full name: the\n * native build is not Metro and resolves no platform suffix.\n */\nexport const GENERATED_NATIVE_CLIENT_NAME = 'client.native';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = [\n 'pi',\n 'server',\n 'web',\n 'native',\n 'mcp',\n 'client',\n 'client.native',\n];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n * `contract` is not a contribution either: each file declares one service\n * contract its level provides, which the plugin lists as `provides`.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n 'contract',\n];\n\n/** The backend surface whose files declare the service contracts a level provides. */\nexport const CONTRACT_SURFACE = 'contract';\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'dock',\n 'setting',\n 'slot',\n 'fill',\n 'action',\n 'store',\n 'activity-group',\n 'leader',\n 'selection-axis',\n 'lifecycle',\n 'file-links',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/**\n * Filename infixes excluded everywhere, whatever their position. `edge` marks a\n * workerd variant of its base sibling, resolved only by the private Worker build.\n */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories', 'edge'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAAaA,EAAuB,iBAEvBC,EAAqB,gBAGrBC,EAAgB,UAChBC,EAAiB,WAGjBC,EAAoB,aACpBC,EAAkB,WAGlBC,EAAmC,CAAC,OAAQ,QAAQ,EAGpDC,EAAkB,QAUlBC,EAAiB,OAUjBC,EAAgB,YAGhBC,EAAc,+BAQdC,EAA4B,CAAE,OAAQ,SAAU,IAAK,MAAO,OAAQ,SAAU,IAAK,KAAM,EAUzFC,EAAwB,SAOxBC,EAA+B,gBAS/BC,EAAoB,yBAYpBC,EAA2C,CACtD,KACA,SACA,MACA,SACA,MACA,SACA,eACF,EAWaC,EAAuC,CAAC,SAAU,KAAK,EACvDC,EAAwC,CAAC,MAAO,SAAU,MAAO,UAAW,SAAS,EAQrFC,EAAkB,SAGlBC,EAA4C,CAAC,SAAU,MAAO,SAAU,KAAK,EAU7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,WACA,UACF,EAGaC,EAAmB,WAKnBC,EAAuC,CAClD,OACA,UACA,MACA,UACA,SACA,MACA,WACA,OACA,UACA,OACA,OACA,SACA,QACA,iBACA,SACA,iBACA,YACA,aACA,2BACF,EAGaC,EAAuC,CAAC,OAAQ,QAAQ,EAGxDC,EAAqC,CAAC,KAAK,EAG3CC,EAAuC,CAAC,KAAM,MAAO,MAAO,KAAK,EAMjEC,EAAsC,CAAC,OAAQ,OAAQ,UAAW,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["fs","path","renderServerEntry","renderWebEntry","renderNativeEntry","renderMcpEntry","GENERATED_ENTRY_FILENAMES","scanExtensions","renderMcpWidgets","GENERATED_DIR","BUILD_TARGET_PLATFORMS","RETIRED_PLATFORM_NOTICE","resolveTarget","renderApiClient","GENERATED_CLIENT_NAME","renderNativeApiClient","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","writeGenerated","require_runtime","require_layout","require_index","require_index$1","require_index$2","require_index$3","require_index$4","require_index$5","node_fs","node_path","defaultPluginId","packageName","readPackageName","manifest","packageDir","RENDERERS","ENTRY_FILENAME","generateExtension","options","pluginId","graph","notices","files","targets","mcpWidgets","entry","retired","notice","requestedTargets","target","resolution","render","source","hasRouteTable","hasBrowserHalf","client","hasNativeHalf","nativeClient","managed","name"],"sources":["../../../src/services/generate/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n API_ROUTES_MODULE,\n BUILD_TARGET_PLATFORMS,\n GENERATED_CLIENT_NAME,\n GENERATED_DIR,\n GENERATED_ENTRY_FILENAMES,\n GENERATED_ENTRY_NAMES,\n GENERATED_NATIVE_CLIENT_NAME,\n} from '../../constants/layout';\nimport type { ExtensionGraph, ExtensionNotice } from '../../types/extensionGraph';\nimport { renderApiClient, renderNativeApiClient } from '../renderClient';\nimport { renderMcpEntry, renderNativeEntry, renderServerEntry, renderWebEntry } from '../renderEntry';\nimport { renderMcpWidgets } from '../renderMcpWidgets';\nimport { resolveTarget } from '../resolveTarget';\nimport type { BuildTarget } from '../resolveTarget/type';\nimport { RETIRED_PLATFORM_NOTICE, scanExtensions } from '../scan';\nimport { writeGenerated } from '../writeGenerated';\nimport type { GenerateOptions, GenerateResult } from './type';\n\n/** `@agimon-ai/po-plan` becomes `plan`. */\nexport function defaultPluginId(packageName: string): string {\n return packageName.replace(/^@[^/]+\\//u, '').replace(/^po-/u, '');\n}\n\nfunction readPackageName(packageDir: string): string {\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name !== 'string') throw new Error(`${packageDir}/package.json has no name`);\n return manifest.name;\n}\n\nconst RENDERERS: Readonly<Record<BuildTarget, typeof renderServerEntry>> = {\n server: renderServerEntry,\n web: renderWebEntry,\n native: renderNativeEntry,\n mcp: renderMcpEntry,\n};\n\nconst ENTRY_FILENAME: Readonly<Record<BuildTarget, string>> = GENERATED_ENTRY_FILENAMES;\n\n/**\n * Scans a package and renders every entry its tree calls for.\n *\n * A target with nothing in it produces no file, so a backend-only package\n * never grows an empty cockpit entry. Notices from the scan and from each\n * resolution are gathered rather than thrown: an unrecognised folder costs\n * that folder, never the build.\n */\nexport function generateExtension(options: GenerateOptions): GenerateResult {\n const packageName = options.packageName ?? readPackageName(options.packageDir);\n const pluginId = options.pluginId ?? defaultPluginId(packageName);\n\n const graph: ExtensionGraph = scanExtensions(options);\n const notices: ExtensionNotice[] = [...graph.notices];\n const files = new Map<string, string>();\n const targets: BuildTarget[] = [];\n const mcpWidgets = options.target === 'mcp' ? renderMcpWidgets(graph, packageName, GENERATED_DIR) : undefined;\n if (mcpWidgets?.source !== undefined) files.set(`${GENERATED_DIR}/mcp-ui.ts`, mcpWidgets.source);\n\n // Here rather than in the scan, deliberately. The doomRoutedFilePosition lint\n // rule calls scanExtensions() directly, so a scan notice would make `.ios` a\n // hard preflight failure and cost us the forward-looking platforms we kept on\n // purpose. resolveTarget runs once per target, which would repeat it per target.\n for (const entry of graph.entries) {\n if (entry.platform === undefined || BUILD_TARGET_PLATFORMS.includes(entry.platform)) continue;\n notices.push({\n path: entry.file,\n message: `'${entry.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`,\n });\n }\n\n const retired = graph.notices.filter((notice) => notice.message === RETIRED_PLATFORM_NOTICE);\n if (retired.length > 0) {\n throw new Error(\n `${packageName}: ${RETIRED_PLATFORM_NOTICE}\\n${retired.map((notice) => ` ${notice.path}`).join('\\n')}`,\n );\n }\n\n const requestedTargets = options.target === undefined ? (['server', 'web', 'native'] as const) : [options.target];\n for (const target of requestedTargets) {\n const resolution = resolveTarget(graph, target);\n notices.push(...resolution.notices);\n if (resolution.contributions.length === 0 && resolution.escapeHatches.length === 0 && resolution.roots.length === 0)\n continue;\n\n targets.push(target);\n const render = RENDERERS[target];\n const source = render(resolution, {\n packageName,\n pluginId,\n root: graph.root,\n entryDir: GENERATED_DIR,\n mcpWidgets: mcpWidgets?.declarations,\n });\n files.set(`${GENERATED_DIR}/${ENTRY_FILENAME[target]}.ts`, source);\n }\n\n // Not another build target: no host loads it as an entry, and adding one to\n // the target loop would mean a resolution pass and a contribution field for\n // something that is only ever imported by a routed frontend file.\n //\n // Only for a package that has a browser half. The client exists to be called\n // from a page and it carries the sealed transport, so emitting one into a\n // node-only package asks that package to depend on a browser runtime it never\n // loads, to satisfy a file nothing imports.\n const hasRouteTable = options.target === undefined && fs.existsSync(path.join(options.packageDir, API_ROUTES_MODULE));\n const hasBrowserHalf = targets.includes('web');\n const client =\n hasRouteTable && hasBrowserHalf\n ? renderApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (client !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_CLIENT_NAME}.ts`, client);\n\n // The native half gets its own file rather than a shared one, because the\n // browser client's two imports are exactly what the native host refuses.\n const hasNativeHalf = targets.includes('native');\n const nativeClient =\n hasRouteTable && hasNativeHalf\n ? renderNativeApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (nativeClient !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_NATIVE_CLIENT_NAME}.ts`, nativeClient);\n if (hasRouteTable && (hasBrowserHalf || hasNativeHalf) && client === undefined && nativeClient === undefined) {\n notices.push({\n path: API_ROUTES_MODULE,\n message: 'declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted',\n });\n }\n\n const managed =\n options.target === undefined\n ? GENERATED_ENTRY_NAMES.filter(\n (name) => name !== 'mcp' || !fs.existsSync(path.join(options.packageDir, 'tsdown.mcp.config.ts')),\n ).map((name) => `${GENERATED_DIR}/${name}.ts`)\n : [\n `${GENERATED_DIR}/${ENTRY_FILENAME[options.target]}.ts`,\n ...(options.target === 'mcp' ? [`${GENERATED_DIR}/mcp-ui.ts`] : []),\n ];\n const { changed } = writeGenerated(options.packageDir, files, options.check, managed);\n return { graph, packageName, pluginId, files, changed, notices, targets };\n}\n"],"mappings":"8ZAuBA,SAAgB8B,EAAgB,EAA6B,CAC3D,OAAOC,EAAY,QAAQ,aAAc,EAAE,CAAC,CAAC,QAAQ,QAAS,EAAE,CAClE,CAEA,SAASC,EAAgB,EAA4B,CACnD,IAAMC,EAAW,KAAK,MAAMjC,EAAAA,QAAG,aAAaC,EAAAA,QAAK,KAAKiC,EAAY,cAAc,EAAG,MAAM,CAAC,EAC1F,GAAI,OAAOD,EAAS,MAAS,SAAU,MAAU,MAAM,GAAGC,EAAW,0BAA0B,EAC/F,OAAOD,EAAS,IAClB,CAEA,MAAME,EAAqE,CACzE,OAAQjC,EAAAA,kBACR,IAAKC,EAAAA,eACL,OAAQC,EAAAA,kBACR,IAAKC,EAAAA,cACP,EAEM+B,EAAwD9B,EAAAA,0BAU9D,S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,GAAG2B,EAAeE,EAAQ,QAAQ,KACnD,GAAIA,EAAQ,SAAW,MAAQ,CAAC,GAAG7B,EAAAA,cAAc,WAAW,EAAI,CAAC,CACnE,EACA,CAAE,WAAYU,EAAAA,eAAemB,EAAQ,WAAYI,EAAOJ,EAAQ,MAAOoB,CAAO,EACpF,MAAO,CAAE,QAAO,cAAa,WAAU,QAAO,UAAS,UAAS,SAAQ,CAC1E"}
1
+ {"version":3,"file":"index.cjs","names":["fs","path","renderServerEntry","renderWebEntry","renderNativeEntry","renderMcpEntry","GENERATED_ENTRY_FILENAMES","scanExtensions","renderMcpWidgets","GENERATED_DIR","BUILD_TARGET_PLATFORMS","RETIRED_PLATFORM_NOTICE","resolveTarget","renderApiClient","GENERATED_CLIENT_NAME","renderNativeApiClient","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","writeGenerated","require_runtime","require_layout","require_index","require_index$1","require_index$2","require_index$3","require_index$4","require_index$5","node_fs","node_path","defaultPluginId","packageName","readPackageName","manifest","packageDir","RENDERERS","ENTRY_FILENAME","generateExtension","options","pluginId","graph","notices","files","targets","mcpWidgets","entry","retired","notice","requestedTargets","target","resolution","render","source","hasRouteTable","hasBrowserHalf","client","hasNativeHalf","nativeClient","managed","name"],"sources":["../../../src/services/generate/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n API_ROUTES_MODULE,\n BUILD_TARGET_PLATFORMS,\n GENERATED_CLIENT_NAME,\n GENERATED_DIR,\n GENERATED_ENTRY_FILENAMES,\n GENERATED_ENTRY_NAMES,\n GENERATED_NATIVE_CLIENT_NAME,\n} from '../../constants/layout';\nimport type { ExtensionGraph, ExtensionNotice } from '../../types/extensionGraph';\nimport { renderApiClient, renderNativeApiClient } from '../renderClient';\nimport { renderMcpEntry, renderNativeEntry, renderServerEntry, renderWebEntry } from '../renderEntry';\nimport { renderMcpWidgets } from '../renderMcpWidgets';\nimport { resolveTarget } from '../resolveTarget';\nimport type { BuildTarget } from '../resolveTarget/type';\nimport { RETIRED_PLATFORM_NOTICE, scanExtensions } from '../scan';\nimport { writeGenerated } from '../writeGenerated';\nimport type { GenerateOptions, GenerateResult } from './type';\n\n/** `@agimon-ai/po-plan` becomes `plan`. */\nexport function defaultPluginId(packageName: string): string {\n return packageName.replace(/^@[^/]+\\//u, '').replace(/^po-/u, '');\n}\n\nfunction readPackageName(packageDir: string): string {\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name !== 'string') throw new Error(`${packageDir}/package.json has no name`);\n return manifest.name;\n}\n\nconst RENDERERS: Readonly<Record<BuildTarget, typeof renderServerEntry>> = {\n server: renderServerEntry,\n web: renderWebEntry,\n native: renderNativeEntry,\n mcp: renderMcpEntry,\n};\n\nconst ENTRY_FILENAME: Readonly<Record<BuildTarget, string>> = GENERATED_ENTRY_FILENAMES;\n\n/**\n * Scans a package and renders every entry its tree calls for.\n *\n * A target with nothing in it produces no file, so a backend-only package\n * never grows an empty cockpit entry. Notices from the scan and from each\n * resolution are gathered rather than thrown: an unrecognised folder costs\n * that folder, never the build.\n */\nexport function generateExtension(options: GenerateOptions): GenerateResult {\n const packageName = options.packageName ?? readPackageName(options.packageDir);\n const pluginId = options.pluginId ?? defaultPluginId(packageName);\n\n const graph: ExtensionGraph = scanExtensions(options);\n const notices: ExtensionNotice[] = [...graph.notices];\n const files = new Map<string, string>();\n const targets: BuildTarget[] = [];\n const mcpWidgets = options.target === 'mcp' ? renderMcpWidgets(graph, packageName, GENERATED_DIR) : undefined;\n if (mcpWidgets?.source !== undefined) files.set(`${GENERATED_DIR}/mcp-ui.ts`, mcpWidgets.source);\n\n // Here rather than in the scan, deliberately. The poRoutedFilePosition lint\n // rule calls scanExtensions() directly, so a scan notice would make `.ios` a\n // hard preflight failure and cost us the forward-looking platforms we kept on\n // purpose. resolveTarget runs once per target, which would repeat it per target.\n for (const entry of graph.entries) {\n if (entry.platform === undefined || BUILD_TARGET_PLATFORMS.includes(entry.platform)) continue;\n notices.push({\n path: entry.file,\n message: `'${entry.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`,\n });\n }\n\n const retired = graph.notices.filter((notice) => notice.message === RETIRED_PLATFORM_NOTICE);\n if (retired.length > 0) {\n throw new Error(\n `${packageName}: ${RETIRED_PLATFORM_NOTICE}\\n${retired.map((notice) => ` ${notice.path}`).join('\\n')}`,\n );\n }\n\n const requestedTargets = options.target === undefined ? (['server', 'web', 'native'] as const) : [options.target];\n for (const target of requestedTargets) {\n const resolution = resolveTarget(graph, target);\n notices.push(...resolution.notices);\n if (resolution.contributions.length === 0 && resolution.escapeHatches.length === 0 && resolution.roots.length === 0)\n continue;\n\n targets.push(target);\n const render = RENDERERS[target];\n const source = render(resolution, {\n packageName,\n pluginId,\n root: graph.root,\n entryDir: GENERATED_DIR,\n mcpWidgets: mcpWidgets?.declarations,\n });\n files.set(`${GENERATED_DIR}/${ENTRY_FILENAME[target]}.ts`, source);\n }\n\n // Not another build target: no host loads it as an entry, and adding one to\n // the target loop would mean a resolution pass and a contribution field for\n // something that is only ever imported by a routed frontend file.\n //\n // Only for a package that has a browser half. The client exists to be called\n // from a page and it carries the sealed transport, so emitting one into a\n // node-only package asks that package to depend on a browser runtime it never\n // loads, to satisfy a file nothing imports.\n const hasRouteTable = options.target === undefined && fs.existsSync(path.join(options.packageDir, API_ROUTES_MODULE));\n const hasBrowserHalf = targets.includes('web');\n const client =\n hasRouteTable && hasBrowserHalf\n ? renderApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (client !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_CLIENT_NAME}.ts`, client);\n\n // The native half gets its own file rather than a shared one, because the\n // browser client's two imports are exactly what the native host refuses.\n const hasNativeHalf = targets.includes('native');\n const nativeClient =\n hasRouteTable && hasNativeHalf\n ? renderNativeApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (nativeClient !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_NATIVE_CLIENT_NAME}.ts`, nativeClient);\n if (hasRouteTable && (hasBrowserHalf || hasNativeHalf) && client === undefined && nativeClient === undefined) {\n notices.push({\n path: API_ROUTES_MODULE,\n message: 'declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted',\n });\n }\n\n const managed =\n options.target === undefined\n ? GENERATED_ENTRY_NAMES.filter(\n (name) => name !== 'mcp' || !fs.existsSync(path.join(options.packageDir, 'tsdown.mcp.config.ts')),\n ).map((name) => `${GENERATED_DIR}/${name}.ts`)\n : [\n `${GENERATED_DIR}/${ENTRY_FILENAME[options.target]}.ts`,\n ...(options.target === 'mcp' ? [`${GENERATED_DIR}/mcp-ui.ts`] : []),\n ];\n const { changed } = writeGenerated(options.packageDir, files, options.check, managed);\n return { graph, packageName, pluginId, files, changed, notices, targets };\n}\n"],"mappings":"8ZAuBA,SAAgB8B,EAAgB,EAA6B,CAC3D,OAAOC,EAAY,QAAQ,aAAc,EAAE,CAAC,CAAC,QAAQ,QAAS,EAAE,CAClE,CAEA,SAASC,EAAgB,EAA4B,CACnD,IAAMC,EAAW,KAAK,MAAMjC,EAAAA,QAAG,aAAaC,EAAAA,QAAK,KAAKiC,EAAY,cAAc,EAAG,MAAM,CAAC,EAC1F,GAAI,OAAOD,EAAS,MAAS,SAAU,MAAU,MAAM,GAAGC,EAAW,0BAA0B,EAC/F,OAAOD,EAAS,IAClB,CAEA,MAAME,EAAqE,CACzE,OAAQjC,EAAAA,kBACR,IAAKC,EAAAA,eACL,OAAQC,EAAAA,kBACR,IAAKC,EAAAA,cACP,EAEM+B,EAAwD9B,EAAAA,0BAU9D,SAAgB+B,EAAkB,EAA0C,CAC1E,IAAMN,EAAcO,EAAQ,aAAeN,EAAgBM,EAAQ,UAAU,EACvEC,EAAWD,EAAQ,UAAYR,EAAgBC,CAAW,EAE1DS,EAAwBjC,EAAAA,eAAe+B,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AAYI,EAAOJ,EAAQ,MAAOoB,CAAO,EACpF,MAAO,CAAE,QAAO,cAAa,WAAU,QAAO,UAAS,UAAS,SAAQ,CAC1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["fs","path","defaultPluginId","packageName","readPackageName","manifest","packageDir","RENDERERS","renderServerEntry","renderWebEntry","renderNativeEntry","renderMcpEntry","ENTRY_FILENAME","GENERATED_ENTRY_FILENAMES","generateExtension","options","pluginId","graph","scanExtensions","notices","files","targets","mcpWidgets","renderMcpWidgets","GENERATED_DIR","entry","BUILD_TARGET_PLATFORMS","retired","notice","RETIRED_PLATFORM_NOTICE","requestedTargets","target","resolution","resolveTarget","render","source","hasRouteTable","hasBrowserHalf","client","renderApiClient","GENERATED_CLIENT_NAME","hasNativeHalf","nativeClient","renderNativeApiClient","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","managed","GENERATED_ENTRY_NAMES","name","writeGenerated"],"sources":["../../../src/services/generate/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n API_ROUTES_MODULE,\n BUILD_TARGET_PLATFORMS,\n GENERATED_CLIENT_NAME,\n GENERATED_DIR,\n GENERATED_ENTRY_FILENAMES,\n GENERATED_ENTRY_NAMES,\n GENERATED_NATIVE_CLIENT_NAME,\n} from '../../constants/layout';\nimport type { ExtensionGraph, ExtensionNotice } from '../../types/extensionGraph';\nimport { renderApiClient, renderNativeApiClient } from '../renderClient';\nimport { renderMcpEntry, renderNativeEntry, renderServerEntry, renderWebEntry } from '../renderEntry';\nimport { renderMcpWidgets } from '../renderMcpWidgets';\nimport { resolveTarget } from '../resolveTarget';\nimport type { BuildTarget } from '../resolveTarget/type';\nimport { RETIRED_PLATFORM_NOTICE, scanExtensions } from '../scan';\nimport { writeGenerated } from '../writeGenerated';\nimport type { GenerateOptions, GenerateResult } from './type';\n\n/** `@agimon-ai/po-plan` becomes `plan`. */\nexport function defaultPluginId(packageName: string): string {\n return packageName.replace(/^@[^/]+\\//u, '').replace(/^po-/u, '');\n}\n\nfunction readPackageName(packageDir: string): string {\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name !== 'string') throw new Error(`${packageDir}/package.json has no name`);\n return manifest.name;\n}\n\nconst RENDERERS: Readonly<Record<BuildTarget, typeof renderServerEntry>> = {\n server: renderServerEntry,\n web: renderWebEntry,\n native: renderNativeEntry,\n mcp: renderMcpEntry,\n};\n\nconst ENTRY_FILENAME: Readonly<Record<BuildTarget, string>> = GENERATED_ENTRY_FILENAMES;\n\n/**\n * Scans a package and renders every entry its tree calls for.\n *\n * A target with nothing in it produces no file, so a backend-only package\n * never grows an empty cockpit entry. Notices from the scan and from each\n * resolution are gathered rather than thrown: an unrecognised folder costs\n * that folder, never the build.\n */\nexport function generateExtension(options: GenerateOptions): GenerateResult {\n const packageName = options.packageName ?? readPackageName(options.packageDir);\n const pluginId = options.pluginId ?? defaultPluginId(packageName);\n\n const graph: ExtensionGraph = scanExtensions(options);\n const notices: ExtensionNotice[] = [...graph.notices];\n const files = new Map<string, string>();\n const targets: BuildTarget[] = [];\n const mcpWidgets = options.target === 'mcp' ? renderMcpWidgets(graph, packageName, GENERATED_DIR) : undefined;\n if (mcpWidgets?.source !== undefined) files.set(`${GENERATED_DIR}/mcp-ui.ts`, mcpWidgets.source);\n\n // Here rather than in the scan, deliberately. The doomRoutedFilePosition lint\n // rule calls scanExtensions() directly, so a scan notice would make `.ios` a\n // hard preflight failure and cost us the forward-looking platforms we kept on\n // purpose. resolveTarget runs once per target, which would repeat it per target.\n for (const entry of graph.entries) {\n if (entry.platform === undefined || BUILD_TARGET_PLATFORMS.includes(entry.platform)) continue;\n notices.push({\n path: entry.file,\n message: `'${entry.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`,\n });\n }\n\n const retired = graph.notices.filter((notice) => notice.message === RETIRED_PLATFORM_NOTICE);\n if (retired.length > 0) {\n throw new Error(\n `${packageName}: ${RETIRED_PLATFORM_NOTICE}\\n${retired.map((notice) => ` ${notice.path}`).join('\\n')}`,\n );\n }\n\n const requestedTargets = options.target === undefined ? (['server', 'web', 'native'] as const) : [options.target];\n for (const target of requestedTargets) {\n const resolution = resolveTarget(graph, target);\n notices.push(...resolution.notices);\n if (resolution.contributions.length === 0 && resolution.escapeHatches.length === 0 && resolution.roots.length === 0)\n continue;\n\n targets.push(target);\n const render = RENDERERS[target];\n const source = render(resolution, {\n packageName,\n pluginId,\n root: graph.root,\n entryDir: GENERATED_DIR,\n mcpWidgets: mcpWidgets?.declarations,\n });\n files.set(`${GENERATED_DIR}/${ENTRY_FILENAME[target]}.ts`, source);\n }\n\n // Not another build target: no host loads it as an entry, and adding one to\n // the target loop would mean a resolution pass and a contribution field for\n // something that is only ever imported by a routed frontend file.\n //\n // Only for a package that has a browser half. The client exists to be called\n // from a page and it carries the sealed transport, so emitting one into a\n // node-only package asks that package to depend on a browser runtime it never\n // loads, to satisfy a file nothing imports.\n const hasRouteTable = options.target === undefined && fs.existsSync(path.join(options.packageDir, API_ROUTES_MODULE));\n const hasBrowserHalf = targets.includes('web');\n const client =\n hasRouteTable && hasBrowserHalf\n ? renderApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (client !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_CLIENT_NAME}.ts`, client);\n\n // The native half gets its own file rather than a shared one, because the\n // browser client's two imports are exactly what the native host refuses.\n const hasNativeHalf = targets.includes('native');\n const nativeClient =\n hasRouteTable && hasNativeHalf\n ? renderNativeApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (nativeClient !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_NATIVE_CLIENT_NAME}.ts`, nativeClient);\n if (hasRouteTable && (hasBrowserHalf || hasNativeHalf) && client === undefined && nativeClient === undefined) {\n notices.push({\n path: API_ROUTES_MODULE,\n message: 'declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted',\n });\n }\n\n const managed =\n options.target === undefined\n ? GENERATED_ENTRY_NAMES.filter(\n (name) => name !== 'mcp' || !fs.existsSync(path.join(options.packageDir, 'tsdown.mcp.config.ts')),\n ).map((name) => `${GENERATED_DIR}/${name}.ts`)\n : [\n `${GENERATED_DIR}/${ENTRY_FILENAME[options.target]}.ts`,\n ...(options.target === 'mcp' ? [`${GENERATED_DIR}/mcp-ui.ts`] : []),\n ];\n const { changed } = writeGenerated(options.packageDir, files, options.check, managed);\n return { graph, packageName, pluginId, files, changed, notices, targets };\n}\n"],"mappings":"ivBAuBA,SAAgBE,EAAgB,EAA6B,CAC3D,OAAOC,EAAY,QAAQ,aAAc,EAAE,CAAC,CAAC,QAAQ,QAAS,EAAE,CAClE,CAEA,SAASC,EAAgB,EAA4B,CACnD,IAAMC,EAAW,KAAK,MAAML,EAAG,aAAaC,EAAK,KAAKK,EAAY,cAAc,EAAG,MAAM,CAAC,EAC1F,GAAI,OAAOD,EAAS,MAAS,SAAU,MAAU,MAAM,GAAGC,EAAW,0BAA0B,EAC/F,OAAOD,EAAS,IAClB,CAEA,MAAME,EAAqE,CACzE,OAAQC,EACR,IAAKC,EACL,OAAQC,EACR,IAAKC,CACP,EAEMC,EAAwDC,EAU9D,SAAgBC,EAAkB,EAA0C,CAC1E,IAAMX,EAAcY,EAAQ,aAAeX,EAAgBW,EAAQ,UAAU,EACvEC,EAAWD,EAAQ,UAAYb,EAAgBC,CAAW,EAE1Dc,EAAwBC,EAAeH,CAAO,EAC9CI,EAA6B,CAAC,GAAGF,EAAM,OAAO,EAC9CG,kBAAQ,IAAI,IACZC,EAAyB,CAAC,EAC1BC,EAAaP,EAAQ,SAAW,MAAQQ,EAAiBN,EAAOd,EAAaqB,CAAa,EAAI,IAAA,GAChGF,GAAY,SAAW,IAAA,IAAWF,EAAM,IAAI,GAAGI,EAAc,YAAaF,EAAW,MAAM,EAM/F,IAAK,IAAMG,KAASR,EAAM,QAC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1F,IAAMG,EAAgBpB,EAAQ,SAAS,QAAQ,EACzCqB,EACJN,GAAiBK,EACbE,EAAsB1B,EAAO,CAAE,cAAa,WAAU,KAAMA,EAAM,KAAM,SAAUO,CAAc,CAAC,EACjG,IAAA,GACFkB,IAAiB,IAAA,IAAWtB,EAAM,IAAI,GAAGI,EAAc,GAAGoB,EAA6B,KAAMF,CAAY,EACzGN,IAAkBC,GAAkBI,IAAkBH,IAAW,IAAA,IAAaI,IAAiB,IAAA,IACjGvB,EAAQ,KAAK,CACX,KAAM0B,EACN,QAAS,2FACX,CAAC,EAGH,IAAMC,EACJ/B,EAAQ,SAAW,IAAA,GACfgC,EAAsB,OACnB,GAASC,IAAS,OAAS,CAAChD,EAAG,WAAWC,EAAK,KAAKc,EAAQ,WAAY,sBAAsB,CAAC,CAClG,CAAC,CAAC,IAAK,GAAS,GAAGS,EAAc,GAAGwB,EAAK,IAAI,EAC7C,CACE,GAAGxB,EAAc,GAAGZ,EAAeG,EAAQ,QAAQ,KACnD,GAAIA,EAAQ,SAAW,MAAQ,CAAC,GAAGS,EAAc,WAAW,EAAI,CAAC,CACnE,EACA,CAAE,WAAYyB,EAAelC,EAAQ,WAAYK,EAAOL,EAAQ,MAAO+B,CAAO,EACpF,MAAO,CAAE,QAAO,cAAa,WAAU,QAAO,UAAS,UAAS,SAAQ,CAC1E"}
1
+ {"version":3,"file":"index.mjs","names":["fs","path","defaultPluginId","packageName","readPackageName","manifest","packageDir","RENDERERS","renderServerEntry","renderWebEntry","renderNativeEntry","renderMcpEntry","ENTRY_FILENAME","GENERATED_ENTRY_FILENAMES","generateExtension","options","pluginId","graph","scanExtensions","notices","files","targets","mcpWidgets","renderMcpWidgets","GENERATED_DIR","entry","BUILD_TARGET_PLATFORMS","retired","notice","RETIRED_PLATFORM_NOTICE","requestedTargets","target","resolution","resolveTarget","render","source","hasRouteTable","hasBrowserHalf","client","renderApiClient","GENERATED_CLIENT_NAME","hasNativeHalf","nativeClient","renderNativeApiClient","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","managed","GENERATED_ENTRY_NAMES","name","writeGenerated"],"sources":["../../../src/services/generate/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n API_ROUTES_MODULE,\n BUILD_TARGET_PLATFORMS,\n GENERATED_CLIENT_NAME,\n GENERATED_DIR,\n GENERATED_ENTRY_FILENAMES,\n GENERATED_ENTRY_NAMES,\n GENERATED_NATIVE_CLIENT_NAME,\n} from '../../constants/layout';\nimport type { ExtensionGraph, ExtensionNotice } from '../../types/extensionGraph';\nimport { renderApiClient, renderNativeApiClient } from '../renderClient';\nimport { renderMcpEntry, renderNativeEntry, renderServerEntry, renderWebEntry } from '../renderEntry';\nimport { renderMcpWidgets } from '../renderMcpWidgets';\nimport { resolveTarget } from '../resolveTarget';\nimport type { BuildTarget } from '../resolveTarget/type';\nimport { RETIRED_PLATFORM_NOTICE, scanExtensions } from '../scan';\nimport { writeGenerated } from '../writeGenerated';\nimport type { GenerateOptions, GenerateResult } from './type';\n\n/** `@agimon-ai/po-plan` becomes `plan`. */\nexport function defaultPluginId(packageName: string): string {\n return packageName.replace(/^@[^/]+\\//u, '').replace(/^po-/u, '');\n}\n\nfunction readPackageName(packageDir: string): string {\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name !== 'string') throw new Error(`${packageDir}/package.json has no name`);\n return manifest.name;\n}\n\nconst RENDERERS: Readonly<Record<BuildTarget, typeof renderServerEntry>> = {\n server: renderServerEntry,\n web: renderWebEntry,\n native: renderNativeEntry,\n mcp: renderMcpEntry,\n};\n\nconst ENTRY_FILENAME: Readonly<Record<BuildTarget, string>> = GENERATED_ENTRY_FILENAMES;\n\n/**\n * Scans a package and renders every entry its tree calls for.\n *\n * A target with nothing in it produces no file, so a backend-only package\n * never grows an empty cockpit entry. Notices from the scan and from each\n * resolution are gathered rather than thrown: an unrecognised folder costs\n * that folder, never the build.\n */\nexport function generateExtension(options: GenerateOptions): GenerateResult {\n const packageName = options.packageName ?? readPackageName(options.packageDir);\n const pluginId = options.pluginId ?? defaultPluginId(packageName);\n\n const graph: ExtensionGraph = scanExtensions(options);\n const notices: ExtensionNotice[] = [...graph.notices];\n const files = new Map<string, string>();\n const targets: BuildTarget[] = [];\n const mcpWidgets = options.target === 'mcp' ? renderMcpWidgets(graph, packageName, GENERATED_DIR) : undefined;\n if (mcpWidgets?.source !== undefined) files.set(`${GENERATED_DIR}/mcp-ui.ts`, mcpWidgets.source);\n\n // Here rather than in the scan, deliberately. The poRoutedFilePosition lint\n // rule calls scanExtensions() directly, so a scan notice would make `.ios` a\n // hard preflight failure and cost us the forward-looking platforms we kept on\n // purpose. resolveTarget runs once per target, which would repeat it per target.\n for (const entry of graph.entries) {\n if (entry.platform === undefined || BUILD_TARGET_PLATFORMS.includes(entry.platform)) continue;\n notices.push({\n path: entry.file,\n message: `'${entry.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`,\n });\n }\n\n const retired = graph.notices.filter((notice) => notice.message === RETIRED_PLATFORM_NOTICE);\n if (retired.length > 0) {\n throw new Error(\n `${packageName}: ${RETIRED_PLATFORM_NOTICE}\\n${retired.map((notice) => ` ${notice.path}`).join('\\n')}`,\n );\n }\n\n const requestedTargets = options.target === undefined ? (['server', 'web', 'native'] as const) : [options.target];\n for (const target of requestedTargets) {\n const resolution = resolveTarget(graph, target);\n notices.push(...resolution.notices);\n if (resolution.contributions.length === 0 && resolution.escapeHatches.length === 0 && resolution.roots.length === 0)\n continue;\n\n targets.push(target);\n const render = RENDERERS[target];\n const source = render(resolution, {\n packageName,\n pluginId,\n root: graph.root,\n entryDir: GENERATED_DIR,\n mcpWidgets: mcpWidgets?.declarations,\n });\n files.set(`${GENERATED_DIR}/${ENTRY_FILENAME[target]}.ts`, source);\n }\n\n // Not another build target: no host loads it as an entry, and adding one to\n // the target loop would mean a resolution pass and a contribution field for\n // something that is only ever imported by a routed frontend file.\n //\n // Only for a package that has a browser half. The client exists to be called\n // from a page and it carries the sealed transport, so emitting one into a\n // node-only package asks that package to depend on a browser runtime it never\n // loads, to satisfy a file nothing imports.\n const hasRouteTable = options.target === undefined && fs.existsSync(path.join(options.packageDir, API_ROUTES_MODULE));\n const hasBrowserHalf = targets.includes('web');\n const client =\n hasRouteTable && hasBrowserHalf\n ? renderApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (client !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_CLIENT_NAME}.ts`, client);\n\n // The native half gets its own file rather than a shared one, because the\n // browser client's two imports are exactly what the native host refuses.\n const hasNativeHalf = targets.includes('native');\n const nativeClient =\n hasRouteTable && hasNativeHalf\n ? renderNativeApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (nativeClient !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_NATIVE_CLIENT_NAME}.ts`, nativeClient);\n if (hasRouteTable && (hasBrowserHalf || hasNativeHalf) && client === undefined && nativeClient === undefined) {\n notices.push({\n path: API_ROUTES_MODULE,\n message: 'declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted',\n });\n }\n\n const managed =\n options.target === undefined\n ? GENERATED_ENTRY_NAMES.filter(\n (name) => name !== 'mcp' || !fs.existsSync(path.join(options.packageDir, 'tsdown.mcp.config.ts')),\n ).map((name) => `${GENERATED_DIR}/${name}.ts`)\n : [\n `${GENERATED_DIR}/${ENTRY_FILENAME[options.target]}.ts`,\n ...(options.target === 'mcp' ? [`${GENERATED_DIR}/mcp-ui.ts`] : []),\n ];\n const { changed } = writeGenerated(options.packageDir, files, options.check, managed);\n return { graph, packageName, pluginId, files, changed, notices, targets };\n}\n"],"mappings":"ivBAuBA,SAAgBE,EAAgB,EAA6B,CAC3D,OAAOC,EAAY,QAAQ,aAAc,EAAE,CAAC,CAAC,QAAQ,QAAS,EAAE,CAClE,CAEA,SAASC,EAAgB,EA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AC,IAAK,GAAS,GAAGS,EAAc,GAAGwB,EAAK,IAAI,EAC7C,CACE,GAAGxB,EAAc,GAAGZ,EAAeG,EAAQ,QAAQ,KACnD,GAAIA,EAAQ,SAAW,MAAQ,CAAC,GAAGS,EAAc,WAAW,EAAI,CAAC,CACnE,EACA,CAAE,WAAYyB,EAAelC,EAAQ,WAAYK,EAAOL,EAAQ,MAAO+B,CAAO,EACpF,MAAO,CAAE,QAAO,cAAa,WAAU,QAAO,UAAS,UAAS,SAAQ,CAC1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["toKebab","posix","require_index","node_path","SCOPE_ORDER","identifierFor","multiple","camel","basePath","word","index","baseSegmentOf","first","entry","mountsOf","scopesByBase","graph","held","bases","declared","shallowest","scope","routesSpecifier","relative","entryDir","BROWSER_CLIENT","NATIVE_CLIENT","renderMount","scopes","mount","suffix","flavor","renderClient","mounts","options","renderApiClient","renderNativeApiClient"],"sources":["../../../src/services/renderClient/index.ts"],"sourcesContent":["import { posix } from 'node:path';\n\nimport { GENERATED_DIR } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionScope } from '../../types/extensionGraph';\nimport { toKebab } from '../identity';\nimport type { RenderOptions } from '../renderEntry/type';\n\n/**\n * Renders the typed client a cockpit plugin calls its own API through.\n *\n * The two facts this injects are the two a package kept restating and getting\n * wrong: which scopes its API mounts at, and under which base path. Both are\n * read off the folder tree, so `api/file-edits/route.server.ts` at the session\n * scope is the whole declaration. A package that writes them out again is a\n * package that can disagree with itself, and several did.\n *\n * The route list is not read here. It is authored as plain data in\n * `src/types/apiRoutes.ts`, because this build evaluates no TypeScript and must\n * not learn how: it has no dependencies at all, and every specifier below is\n * emitted as text.\n */\n\nconst HEADER = '// Generated by @agimon-ai/po-build. Do not edit by hand.';\n\n/** Server scopes cascade outward-in, the way the generated server entry mounts them. */\nconst SCOPE_ORDER: readonly ExtensionScope[] = ['global', 'workspace', 'session'];\n\n/** One mount the tree declares: a base path, and the scopes it is reachable at. */\ninterface ClientMount {\n readonly basePath: string;\n readonly scopes: readonly ExtensionScope[];\n /** A valid identifier for the exported factory, when a package has several mounts. */\n readonly identifier: string;\n}\n\nfunction identifierFor(basePath: string, multiple: boolean): string {\n if (!multiple) return 'api';\n const camel = toKebab(basePath)\n .split('-')\n .filter((word) => word.length > 0)\n .map((word, index) => (index === 0 ? word : word[0]?.toUpperCase() + word.slice(1)))\n .join('');\n return /^[A-Za-z_]/u.test(camel) ? camel : `api${camel}`;\n}\n\n/**\n * The base path an api entry mounts at: the first literal segment below `api/`.\n *\n * An entry with no segment is the flat `api/route.server.ts` shape that predates\n * this convention. Its base path lives in a hand-written `DoomApi` the build\n * cannot read, so it contributes no client and keeps its hand-built URLs until\n * the folder is renamed.\n */\nfunction baseSegmentOf(entry: ExtensionEntry): string | undefined {\n const first = entry.route[0];\n if (first === undefined || !('literal' in first)) return undefined;\n return first.literal;\n}\n\nfunction mountsOf(graph: ExtensionGraph): ClientMount[] {\n const scopesByBase = new Map<string, Set<ExtensionScope>>();\n for (const entry of graph.entries) {\n if (entry.side !== 'backend' || entry.surface !== 'api' || entry.role !== 'contribution') continue;\n const basePath = baseSegmentOf(entry);\n if (basePath === undefined) continue;\n const held = scopesByBase.get(basePath) ?? new Set<ExtensionScope>();\n held.add(entry.scope);\n scopesByBase.set(basePath, held);\n }\n\n const bases = [...scopesByBase.keys()].sort();\n return bases.map((basePath) => {\n const declared = scopesByBase.get(basePath) as Set<ExtensionScope>;\n // A facet mounts a contribution at its own scope and every scope below it,\n // so a global API answers workspace and session requests too.\n const shallowest = SCOPE_ORDER.findIndex((scope) => declared.has(scope));\n return {\n basePath,\n scopes: SCOPE_ORDER.slice(shallowest),\n identifier: identifierFor(basePath, bases.length > 1),\n };\n });\n}\n\n/** The extensionless relative specifier from the generated directory to the route table. */\nfunction routesSpecifier(entryDir: string): string {\n const relative = posix.relative(entryDir, 'src/types/apiRoutes');\n return relative.startsWith('.') ? relative : `./${relative}`;\n}\n\n/** What differs between the browser and native clients: where the runtime comes from, and how a call leaves. */\ninterface ClientFlavor {\n readonly imports: readonly string[];\n readonly transport: string;\n}\n\nconst BROWSER_CLIENT: ClientFlavor = {\n imports: [\n \"import { createApiClient, sessionApiAddress } from '@agimon-ai/po-core/web';\",\n \"import { sealedTransport } from '@agimon-ai/po-web-security/browser';\",\n ],\n transport: '(input, init) => sealedTransport.fetch(input, init)',\n};\n\n/**\n * Only `@agimon-ai/po-core/native`, the one Po module on the native host list.\n * The phone's sealed channel and step-up live in the app shell, which binds\n * them behind `nativeApiTransport`.\n */\nconst NATIVE_CLIENT: ClientFlavor = {\n imports: [\"import { createApiClient, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';\"],\n transport: 'nativeApiTransport',\n};\n\nfunction renderMount(mount: ClientMount, flavor: ClientFlavor): string[] {\n const scopes = mount.scopes.map((scope) => `'${scope}'`).join(', ');\n const suffix = mount.identifier === 'api' ? '' : ` for the ${mount.basePath} mount`;\n return [\n `/** Scopes the tree mounts '${mount.basePath}' at${suffix}. */`,\n `export const ${mount.identifier}Scopes = [${scopes}] as const;`,\n '',\n `export const ${mount.identifier} = createApiClient(routes, {`,\n ` scopes: ${mount.identifier}Scopes,`,\n ` basePath: '${mount.basePath}',`,\n ` transport: ${flavor.transport},`,\n ' sessionAddress: sessionApiAddress,',\n '});',\n '',\n ];\n}\n\nfunction renderClient(graph: ExtensionGraph, options: RenderOptions, flavor: ClientFlavor): string | undefined {\n const mounts = mountsOf(graph);\n if (mounts.length === 0) return undefined;\n\n const lines = [\n HEADER,\n ...flavor.imports,\n '',\n `import routes from '${routesSpecifier(options.entryDir ?? GENERATED_DIR)}';`,\n '',\n ...mounts.flatMap((mount) => renderMount(mount, flavor)),\n ];\n return `${lines.join('\\n').replace(/\\n+$/u, '')}\\n`;\n}\n\n/**\n * The client source, or undefined when the tree declares no `api/<base-path>/`.\n *\n * `options.entryDir` is where the file will be written, so the relative import\n * of the route table is computed against it rather than assumed.\n */\nexport function renderApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, BROWSER_CLIENT);\n}\n\n/**\n * The same mounts and the same route table for a `.native` file.\n *\n * The route table is imported, never restated, so it must itself import only\n * what the native host provides: a table that imports `@agimon-ai/po-core/web`\n * is refused by the native composition build, which is the intended failure.\n */\nexport function renderNativeApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, NATIVE_CLIENT);\n}\n"],"mappings":"0GAsBA,MAGMI,EAAyC,CAAC,SAAU,YAAa,SAAS,EAUhF,SAASC,EAAc,EAAkB,EAA2B,CAClE,GAAI,CAACC,EAAU,MAAO,MACtB,IAAMC,EAAQP,EAAAA,QAAQQ,CAAQ,CAAC,CAC5B,MAAM,GAAG,CAAC,CACV,OAAQ,GAASC,EAAK,OAAS,CAAC,CAAC,CACjC,KAAK,EAAM,IAAWC,IAAU,EAAID,EAAOA,EAAK,EAAE,EAAE,YAAY,EAAIA,EAAK,MAAM,CAAC,CAAE,CAAC,CACnF,KAAK,EAAE,EACV,MAAO,cAAc,KAAKF,CAAK,EAAIA,EAAQ,MAAMA,GACnD,CAUA,SAASI,EAAc,EAA2C,CAChE,IAAMC,EAAQC,EAAM,MAAM,GAC1B,GAAID,IAAU,IAAA,IAAe,YAAaA,EAC1C,OAAOA,EAAM,OACf,CAEA,SAASE,EAAS,EAAsC,CACtD,IAAMC,kBAAe,IAAI,IACzB,IAAK,IAAMF,KAASG,EAAM,QAAS,CACjC,GAAIH,EAAM,OAAS,WAAaA,EAAM,UAAY,OAASA,EAAM,OAAS,eAAgB,SAC1F,IAAML,EAAWG,EAAcE,CAAK,EACpC,GAAIL,IAAa,IAAA,GAAW,SAC5B,IAAMS,EAAOF,EAAa,IAAIP,CAAQ,mBAAK,IAAI,IAC/CS,EAAK,IAAIJ,EAAM,KAAK,EACpBE,EAAa,IAAIP,EAAUS,CAAI,CACjC,CAEA,IAAMC,EAAQ,CAAC,GAAGH,EAAa,KAAK,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,CAAC,CAAC,KAAK;CAAI,CAAC,CAAC,QAAQ,QAAS,EAAE,EAAE,GAClD,CAQA,SAAgBI,EAAgB,EAAuB,EAA4C,CACjG,OAAOH,EAAahB,EAAOkB,EAAST,CAAc,CACpD,CASA,SAAgBW,EAAsB,EAAuB,EAA4C,CACvG,OAAOJ,EAAahB,EAAOkB,EAASR,CAAa,CACnD"}
1
+ {"version":3,"file":"index.cjs","names":["toKebab","posix","require_index","node_path","SCOPE_ORDER","identifierFor","multiple","camel","basePath","word","index","baseSegmentOf","first","entry","mountsOf","scopesByBase","graph","held","bases","declared","shallowest","scope","routesSpecifier","relative","entryDir","BROWSER_CLIENT","NATIVE_CLIENT","renderMount","scopes","mount","suffix","flavor","renderClient","mounts","options","renderApiClient","renderNativeApiClient"],"sources":["../../../src/services/renderClient/index.ts"],"sourcesContent":["import { posix } from 'node:path';\n\nimport { GENERATED_DIR } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionScope } from '../../types/extensionGraph';\nimport { toKebab } from '../identity';\nimport type { RenderOptions } from '../renderEntry/type';\n\n/**\n * Renders the typed client a cockpit plugin calls its own API through.\n *\n * The two facts this injects are the two a package kept restating and getting\n * wrong: which scopes its API mounts at, and under which base path. Both are\n * read off the folder tree, so `api/file-edits/route.server.ts` at the session\n * scope is the whole declaration. A package that writes them out again is a\n * package that can disagree with itself, and several did.\n *\n * The route list is not read here. It is authored as plain data in\n * `src/types/apiRoutes.ts`, because this build evaluates no TypeScript and must\n * not learn how: it has no dependencies at all, and every specifier below is\n * emitted as text.\n */\n\nconst HEADER = '// Generated by @agimon-ai/po-build. Do not edit by hand.';\n\n/** Server scopes cascade outward-in, the way the generated server entry mounts them. */\nconst SCOPE_ORDER: readonly ExtensionScope[] = ['global', 'workspace', 'session'];\n\n/** One mount the tree declares: a base path, and the scopes it is reachable at. */\ninterface ClientMount {\n readonly basePath: string;\n readonly scopes: readonly ExtensionScope[];\n /** A valid identifier for the exported factory, when a package has several mounts. */\n readonly identifier: string;\n}\n\nfunction identifierFor(basePath: string, multiple: boolean): string {\n if (!multiple) return 'api';\n const camel = toKebab(basePath)\n .split('-')\n .filter((word) => word.length > 0)\n .map((word, index) => (index === 0 ? word : word[0]?.toUpperCase() + word.slice(1)))\n .join('');\n return /^[A-Za-z_]/u.test(camel) ? camel : `api${camel}`;\n}\n\n/**\n * The base path an api entry mounts at: the first literal segment below `api/`.\n *\n * An entry with no segment is the flat `api/route.server.ts` shape that predates\n * this convention. Its base path lives in a hand-written `PoApi` the build\n * cannot read, so it contributes no client and keeps its hand-built URLs until\n * the folder is renamed.\n */\nfunction baseSegmentOf(entry: ExtensionEntry): string | undefined {\n const first = entry.route[0];\n if (first === undefined || !('literal' in first)) return undefined;\n return first.literal;\n}\n\nfunction mountsOf(graph: ExtensionGraph): ClientMount[] {\n const scopesByBase = new Map<string, Set<ExtensionScope>>();\n for (const entry of graph.entries) {\n if (entry.side !== 'backend' || entry.surface !== 'api' || entry.role !== 'contribution') continue;\n const basePath = baseSegmentOf(entry);\n if (basePath === undefined) continue;\n const held = scopesByBase.get(basePath) ?? new Set<ExtensionScope>();\n held.add(entry.scope);\n scopesByBase.set(basePath, held);\n }\n\n const bases = [...scopesByBase.keys()].sort();\n return bases.map((basePath) => {\n const declared = scopesByBase.get(basePath) as Set<ExtensionScope>;\n // A server plugin offers a contribution at its own scope and every scope below it,\n // so a global API answers workspace and session requests too.\n const shallowest = SCOPE_ORDER.findIndex((scope) => declared.has(scope));\n return {\n basePath,\n scopes: SCOPE_ORDER.slice(shallowest),\n identifier: identifierFor(basePath, bases.length > 1),\n };\n });\n}\n\n/** The extensionless relative specifier from the generated directory to the route table. */\nfunction routesSpecifier(entryDir: string): string {\n const relative = posix.relative(entryDir, 'src/types/apiRoutes');\n return relative.startsWith('.') ? relative : `./${relative}`;\n}\n\n/** What differs between the browser and native clients: where the runtime comes from, and how a call leaves. */\ninterface ClientFlavor {\n readonly imports: readonly string[];\n readonly transport: string;\n}\n\nconst BROWSER_CLIENT: ClientFlavor = {\n imports: [\n \"import { createApiClient, sessionApiAddress } from '@agimon-ai/po-core/web';\",\n \"import { sealedTransport } from '@agimon-ai/po-web-security/browser';\",\n ],\n transport: '(input, init) => sealedTransport.fetch(input, init)',\n};\n\n/**\n * Only `@agimon-ai/po-core/native`, the one Po module on the native host list.\n * The phone's sealed channel and step-up live in the app shell, which binds\n * them behind `nativeApiTransport`.\n */\nconst NATIVE_CLIENT: ClientFlavor = {\n imports: [\"import { createApiClient, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';\"],\n transport: 'nativeApiTransport',\n};\n\nfunction renderMount(mount: ClientMount, flavor: ClientFlavor): string[] {\n const scopes = mount.scopes.map((scope) => `'${scope}'`).join(', ');\n const suffix = mount.identifier === 'api' ? '' : ` for the ${mount.basePath} mount`;\n return [\n `/** Scopes the tree mounts '${mount.basePath}' at${suffix}. */`,\n `export const ${mount.identifier}Scopes = [${scopes}] as const;`,\n '',\n `export const ${mount.identifier} = createApiClient(routes, {`,\n ` scopes: ${mount.identifier}Scopes,`,\n ` basePath: '${mount.basePath}',`,\n ` transport: ${flavor.transport},`,\n ' sessionAddress: sessionApiAddress,',\n '});',\n '',\n ];\n}\n\nfunction renderClient(graph: ExtensionGraph, options: RenderOptions, flavor: ClientFlavor): string | undefined {\n const mounts = mountsOf(graph);\n if (mounts.length === 0) return undefined;\n\n const lines = [\n HEADER,\n ...flavor.imports,\n '',\n `import routes from '${routesSpecifier(options.entryDir ?? GENERATED_DIR)}';`,\n '',\n ...mounts.flatMap((mount) => renderMount(mount, flavor)),\n ];\n return `${lines.join('\\n').replace(/\\n+$/u, '')}\\n`;\n}\n\n/**\n * The client source, or undefined when the tree declares no `api/<base-path>/`.\n *\n * `options.entryDir` is where the file will be written, so the relative import\n * of the route table is computed against it rather than assumed.\n */\nexport function renderApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, BROWSER_CLIENT);\n}\n\n/**\n * The same mounts and the same route table for a `.native` file.\n *\n * The route table is imported, never restated, so it must itself import only\n * what the native host provides: a table that imports `@agimon-ai/po-core/web`\n * is refused by the native composition build, which is the intended failure.\n */\nexport function renderNativeApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, NATIVE_CLIENT);\n}\n"],"mappings":"0GAsBA,MAGMI,EAAyC,CAAC,SAAU,YAAa,SAAS,EAUhF,SAASC,EAAc,EAAkB,EAA2B,CAClE,GAAI,CAACC,EAAU,MAAO,MACtB,IAAMC,EAAQP,EAAAA,QAAQQ,CAAQ,CAAC,CAC5B,MAAM,GAAG,CAAC,CACV,OAAQ,GAASC,EAAK,OAAS,CAAC,CAAC,CACjC,KAAK,EAAM,IAAWC,IAAU,EAAID,EAAOA,EAAK,EAAE,EAAE,YAAY,EAAIA,EAAK,MAAM,CAAC,CAAE,CAAC,CACnF,KAAK,EAAE,EACV,MAAO,cAAc,KAAKF,CAAK,EAAIA,EAAQ,MAAMA,GACnD,CAUA,SAASI,EAAc,EAA2C,CAChE,IAAMC,EAAQC,EAAM,MAAM,GAC1B,GAAID,IAAU,IAAA,IAAe,YAAaA,EAC1C,OAAOA,EAAM,OACf,CAEA,SAASE,EAAS,EAAsC,CACtD,IAAMC,kBAAe,IAAI,IACzB,IAAK,IAAMF,KAASG,EAAM,QAAS,CACjC,GAAIH,EAAM,OAAS,WAAaA,EAAM,UAAY,OAASA,EAAM,OAAS,eAAgB,SAC1F,IAAML,EAAWG,EAAcE,CAAK,EACpC,GAAIL,IAAa,IAAA,GAAW,SAC5B,IAAMS,EAAOF,EAAa,IAAIP,CAAQ,mBAAK,IAAI,IAC/CS,EAAK,IAAIJ,EAAM,KAAK,EACpBE,EAAa,IAAIP,EAAUS,CAAI,CACjC,CAEA,IAAMC,EAAQ,CAAC,GAAGH,EAAa,KAAK,CAAC,CAAC,CAAC,KAAK,EAC5C,OAAOG,EAAM,IAAK,GAAa,CAC7B,IAAMC,EAAWJ,EAAa,IAAIP,CAAQ,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A4C,CACjG,OAAOH,EAAahB,EAAOkB,EAAST,CAAc,CACpD,CASA,SAAgBW,EAAsB,EAAuB,EAA4C,CACvG,OAAOJ,EAAahB,EAAOkB,EAASR,CAAa,CACnD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["SCOPE_ORDER","identifierFor","multiple","camel","toKebab","basePath","word","index","baseSegmentOf","first","entry","mountsOf","scopesByBase","graph","held","bases","declared","shallowest","scope","routesSpecifier","relative","posix","entryDir","BROWSER_CLIENT","NATIVE_CLIENT","renderMount","scopes","mount","suffix","flavor","renderClient","mounts","options","renderApiClient","renderNativeApiClient"],"sources":["../../../src/services/renderClient/index.ts"],"sourcesContent":["import { posix } from 'node:path';\n\nimport { GENERATED_DIR } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionScope } from '../../types/extensionGraph';\nimport { toKebab } from '../identity';\nimport type { RenderOptions } from '../renderEntry/type';\n\n/**\n * Renders the typed client a cockpit plugin calls its own API through.\n *\n * The two facts this injects are the two a package kept restating and getting\n * wrong: which scopes its API mounts at, and under which base path. Both are\n * read off the folder tree, so `api/file-edits/route.server.ts` at the session\n * scope is the whole declaration. A package that writes them out again is a\n * package that can disagree with itself, and several did.\n *\n * The route list is not read here. It is authored as plain data in\n * `src/types/apiRoutes.ts`, because this build evaluates no TypeScript and must\n * not learn how: it has no dependencies at all, and every specifier below is\n * emitted as text.\n */\n\nconst HEADER = '// Generated by @agimon-ai/po-build. Do not edit by hand.';\n\n/** Server scopes cascade outward-in, the way the generated server entry mounts them. */\nconst SCOPE_ORDER: readonly ExtensionScope[] = ['global', 'workspace', 'session'];\n\n/** One mount the tree declares: a base path, and the scopes it is reachable at. */\ninterface ClientMount {\n readonly basePath: string;\n readonly scopes: readonly ExtensionScope[];\n /** A valid identifier for the exported factory, when a package has several mounts. */\n readonly identifier: string;\n}\n\nfunction identifierFor(basePath: string, multiple: boolean): string {\n if (!multiple) return 'api';\n const camel = toKebab(basePath)\n .split('-')\n .filter((word) => word.length > 0)\n .map((word, index) => (index === 0 ? word : word[0]?.toUpperCase() + word.slice(1)))\n .join('');\n return /^[A-Za-z_]/u.test(camel) ? camel : `api${camel}`;\n}\n\n/**\n * The base path an api entry mounts at: the first literal segment below `api/`.\n *\n * An entry with no segment is the flat `api/route.server.ts` shape that predates\n * this convention. Its base path lives in a hand-written `DoomApi` the build\n * cannot read, so it contributes no client and keeps its hand-built URLs until\n * the folder is renamed.\n */\nfunction baseSegmentOf(entry: ExtensionEntry): string | undefined {\n const first = entry.route[0];\n if (first === undefined || !('literal' in first)) return undefined;\n return first.literal;\n}\n\nfunction mountsOf(graph: ExtensionGraph): ClientMount[] {\n const scopesByBase = new Map<string, Set<ExtensionScope>>();\n for (const entry of graph.entries) {\n if (entry.side !== 'backend' || entry.surface !== 'api' || entry.role !== 'contribution') continue;\n const basePath = baseSegmentOf(entry);\n if (basePath === undefined) continue;\n const held = scopesByBase.get(basePath) ?? new Set<ExtensionScope>();\n held.add(entry.scope);\n scopesByBase.set(basePath, held);\n }\n\n const bases = [...scopesByBase.keys()].sort();\n return bases.map((basePath) => {\n const declared = scopesByBase.get(basePath) as Set<ExtensionScope>;\n // A facet mounts a contribution at its own scope and every scope below it,\n // so a global API answers workspace and session requests too.\n const shallowest = SCOPE_ORDER.findIndex((scope) => declared.has(scope));\n return {\n basePath,\n scopes: SCOPE_ORDER.slice(shallowest),\n identifier: identifierFor(basePath, bases.length > 1),\n };\n });\n}\n\n/** The extensionless relative specifier from the generated directory to the route table. */\nfunction routesSpecifier(entryDir: string): string {\n const relative = posix.relative(entryDir, 'src/types/apiRoutes');\n return relative.startsWith('.') ? relative : `./${relative}`;\n}\n\n/** What differs between the browser and native clients: where the runtime comes from, and how a call leaves. */\ninterface ClientFlavor {\n readonly imports: readonly string[];\n readonly transport: string;\n}\n\nconst BROWSER_CLIENT: ClientFlavor = {\n imports: [\n \"import { createApiClient, sessionApiAddress } from '@agimon-ai/po-core/web';\",\n \"import { sealedTransport } from '@agimon-ai/po-web-security/browser';\",\n ],\n transport: '(input, init) => sealedTransport.fetch(input, init)',\n};\n\n/**\n * Only `@agimon-ai/po-core/native`, the one Po module on the native host list.\n * The phone's sealed channel and step-up live in the app shell, which binds\n * them behind `nativeApiTransport`.\n */\nconst NATIVE_CLIENT: ClientFlavor = {\n imports: [\"import { createApiClient, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';\"],\n transport: 'nativeApiTransport',\n};\n\nfunction renderMount(mount: ClientMount, flavor: ClientFlavor): string[] {\n const scopes = mount.scopes.map((scope) => `'${scope}'`).join(', ');\n const suffix = mount.identifier === 'api' ? '' : ` for the ${mount.basePath} mount`;\n return [\n `/** Scopes the tree mounts '${mount.basePath}' at${suffix}. */`,\n `export const ${mount.identifier}Scopes = [${scopes}] as const;`,\n '',\n `export const ${mount.identifier} = createApiClient(routes, {`,\n ` scopes: ${mount.identifier}Scopes,`,\n ` basePath: '${mount.basePath}',`,\n ` transport: ${flavor.transport},`,\n ' sessionAddress: sessionApiAddress,',\n '});',\n '',\n ];\n}\n\nfunction renderClient(graph: ExtensionGraph, options: RenderOptions, flavor: ClientFlavor): string | undefined {\n const mounts = mountsOf(graph);\n if (mounts.length === 0) return undefined;\n\n const lines = [\n HEADER,\n ...flavor.imports,\n '',\n `import routes from '${routesSpecifier(options.entryDir ?? GENERATED_DIR)}';`,\n '',\n ...mounts.flatMap((mount) => renderMount(mount, flavor)),\n ];\n return `${lines.join('\\n').replace(/\\n+$/u, '')}\\n`;\n}\n\n/**\n * The client source, or undefined when the tree declares no `api/<base-path>/`.\n *\n * `options.entryDir` is where the file will be written, so the relative import\n * of the route table is computed against it rather than assumed.\n */\nexport function renderApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, BROWSER_CLIENT);\n}\n\n/**\n * The same mounts and the same route table for a `.native` file.\n *\n * The route table is imported, never restated, so it must itself import only\n * what the native host provides: a table that imports `@agimon-ai/po-core/web`\n * is refused by the native composition build, which is the intended failure.\n */\nexport function renderNativeApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, NATIVE_CLIENT);\n}\n"],"mappings":"qHAsBA,MAGMA,EAAyC,CAAC,SAAU,YAAa,SAAS,EAUhF,SAASC,EAAc,EAAkB,EAA2B,CAClE,GAAI,CAACC,EAAU,MAAO,MACtB,IAAMC,EAAQC,EAAQC,CAAQ,CAAC,CAC5B,MAAM,GAAG,CAAC,CACV,OAAQ,GAASC,EAAK,OAAS,CAAC,CAAC,CACjC,KAAK,EAAM,IAAWC,IAAU,EAAID,EAAOA,EAAK,EAAE,EAAE,YAAY,EAAIA,EAAK,MAAM,CAAC,CAAE,CAAC,CACnF,KAAK,EAAE,EACV,MAAO,cAAc,KAAKH,CAAK,EAAIA,EAAQ,MAAMA,GACnD,CAUA,SAASK,EAAc,EAA2C,CAChE,IAAMC,EAAQC,EAAM,MAAM,GAC1B,GAAID,IAAU,IAAA,IAAe,YAAaA,EAC1C,OAAOA,EAAM,OACf,CAEA,SAASE,EAAS,EAAsC,CACtD,IAAMC,kBAAe,IAAI,IACzB,IAAK,IAAMF,KAASG,EAAM,QAAS,CACjC,GAAIH,EAAM,OAAS,WAAaA,EAAM,UAAY,OAASA,EAAM,OAAS,eAAgB,SAC1F,IAAML,EAAWG,EAAcE,CAAK,EACpC,GAAIL,IAAa,IAAA,GAAW,SAC5B,IAAMS,EAAOF,EAAa,IAAIP,CAAQ,mBAAK,IAAI,IAC/CS,EAAK,IAAIJ,EAAM,KAAK,EACpBE,EAAa,IAAIP,EAAUS,CAAI,CACjC,CAEA,IAAMC,EAAQ,CAAC,GAAGH,EAAa,KAAK,CAAC,CAAC,CAAC,KAAK,EAC5C,OAAOG,EAAM,IAAK,GAAa,CAC7B,IAAMC,EAAWJ,EAAa,IAAIP,CAAQ,EAGpCY,EAAajB,EAAY,UAAW,GAAUgB,EAAS,IAAIE,CAAK,CAAC,EACvE,MAAO,CACL,WACA,OAAQlB,EAAY,MAAMiB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AOmB,EAASR,CAAa,CACnD"}
1
+ {"version":3,"file":"index.mjs","names":["SCOPE_ORDER","identifierFor","multiple","camel","toKebab","basePath","word","index","baseSegmentOf","first","entry","mountsOf","scopesByBase","graph","held","bases","declared","shallowest","scope","routesSpecifier","relative","posix","entryDir","BROWSER_CLIENT","NATIVE_CLIENT","renderMount","scopes","mount","suffix","flavor","renderClient","mounts","options","renderApiClient","renderNativeApiClient"],"sources":["../../../src/services/renderClient/index.ts"],"sourcesContent":["import { posix } from 'node:path';\n\nimport { GENERATED_DIR } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionScope } from '../../types/extensionGraph';\nimport { toKebab } from '../identity';\nimport type { RenderOptions } from '../renderEntry/type';\n\n/**\n * Renders the typed client a cockpit plugin calls its own API through.\n *\n * The two facts this injects are the two a package kept restating and getting\n * wrong: which scopes its API mounts at, and under which base path. Both are\n * read off the folder tree, so `api/file-edits/route.server.ts` at the session\n * scope is the whole declaration. A package that writes them out again is a\n * package that can disagree with itself, and several did.\n *\n * The route list is not read here. It is authored as plain data in\n * `src/types/apiRoutes.ts`, because this build evaluates no TypeScript and must\n * not learn how: it has no dependencies at all, and every specifier below is\n * emitted as text.\n */\n\nconst HEADER = '// Generated by @agimon-ai/po-build. Do not edit by hand.';\n\n/** Server scopes cascade outward-in, the way the generated server entry mounts them. */\nconst SCOPE_ORDER: readonly ExtensionScope[] = ['global', 'workspace', 'session'];\n\n/** One mount the tree declares: a base path, and the scopes it is reachable at. */\ninterface ClientMount {\n readonly basePath: string;\n readonly scopes: readonly ExtensionScope[];\n /** A valid identifier for the exported factory, when a package has several mounts. */\n readonly identifier: string;\n}\n\nfunction identifierFor(basePath: string, multiple: boolean): string {\n if (!multiple) return 'api';\n const camel = toKebab(basePath)\n .split('-')\n .filter((word) => word.length > 0)\n .map((word, index) => (index === 0 ? word : word[0]?.toUpperCase() + word.slice(1)))\n .join('');\n return /^[A-Za-z_]/u.test(camel) ? camel : `api${camel}`;\n}\n\n/**\n * The base path an api entry mounts at: the first literal segment below `api/`.\n *\n * An entry with no segment is the flat `api/route.server.ts` shape that predates\n * this convention. Its base path lives in a hand-written `PoApi` the build\n * cannot read, so it contributes no client and keeps its hand-built URLs until\n * the folder is renamed.\n */\nfunction baseSegmentOf(entry: ExtensionEntry): string | undefined {\n const first = entry.route[0];\n if (first === undefined || !('literal' in first)) return undefined;\n return first.literal;\n}\n\nfunction mountsOf(graph: ExtensionGraph): ClientMount[] {\n const scopesByBase = new Map<string, Set<ExtensionScope>>();\n for (const entry of graph.entries) {\n if (entry.side !== 'backend' || entry.surface !== 'api' || entry.role !== 'contribution') continue;\n const basePath = baseSegmentOf(entry);\n if (basePath === undefined) continue;\n const held = scopesByBase.get(basePath) ?? new Set<ExtensionScope>();\n held.add(entry.scope);\n scopesByBase.set(basePath, held);\n }\n\n const bases = [...scopesByBase.keys()].sort();\n return bases.map((basePath) => {\n const declared = scopesByBase.get(basePath) as Set<ExtensionScope>;\n // A server plugin offers a contribution at its own scope and every scope below it,\n // so a global API answers workspace and session requests too.\n const shallowest = SCOPE_ORDER.findIndex((scope) => declared.has(scope));\n return {\n basePath,\n scopes: SCOPE_ORDER.slice(shallowest),\n identifier: identifierFor(basePath, bases.length > 1),\n };\n });\n}\n\n/** The extensionless relative specifier from the generated directory to the route table. */\nfunction routesSpecifier(entryDir: string): string {\n const relative = posix.relative(entryDir, 'src/types/apiRoutes');\n return relative.startsWith('.') ? relative : `./${relative}`;\n}\n\n/** What differs between the browser and native clients: where the runtime comes from, and how a call leaves. */\ninterface ClientFlavor {\n readonly imports: readonly string[];\n readonly transport: string;\n}\n\nconst BROWSER_CLIENT: ClientFlavor = {\n imports: [\n \"import { createApiClient, sessionApiAddress } from '@agimon-ai/po-core/web';\",\n \"import { sealedTransport } from '@agimon-ai/po-web-security/browser';\",\n ],\n transport: '(input, init) => sealedTransport.fetch(input, init)',\n};\n\n/**\n * Only `@agimon-ai/po-core/native`, the one Po module on the native host list.\n * The phone's sealed channel and step-up live in the app shell, which binds\n * them behind `nativeApiTransport`.\n */\nconst NATIVE_CLIENT: ClientFlavor = {\n imports: [\"import { createApiClient, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';\"],\n transport: 'nativeApiTransport',\n};\n\nfunction renderMount(mount: ClientMount, flavor: ClientFlavor): string[] {\n const scopes = mount.scopes.map((scope) => `'${scope}'`).join(', ');\n const suffix = mount.identifier === 'api' ? '' : ` for the ${mount.basePath} mount`;\n return [\n `/** Scopes the tree mounts '${mount.basePath}' at${suffix}. */`,\n `export const ${mount.identifier}Scopes = [${scopes}] as const;`,\n '',\n `export const ${mount.identifier} = createApiClient(routes, {`,\n ` scopes: ${mount.identifier}Scopes,`,\n ` basePath: '${mount.basePath}',`,\n ` transport: ${flavor.transport},`,\n ' sessionAddress: sessionApiAddress,',\n '});',\n '',\n ];\n}\n\nfunction renderClient(graph: ExtensionGraph, options: RenderOptions, flavor: ClientFlavor): string | undefined {\n const mounts = mountsOf(graph);\n if (mounts.length === 0) return undefined;\n\n const lines = [\n HEADER,\n ...flavor.imports,\n '',\n `import routes from '${routesSpecifier(options.entryDir ?? GENERATED_DIR)}';`,\n '',\n ...mounts.flatMap((mount) => renderMount(mount, flavor)),\n ];\n return `${lines.join('\\n').replace(/\\n+$/u, '')}\\n`;\n}\n\n/**\n * The client source, or undefined when the tree declares no `api/<base-path>/`.\n *\n * `options.entryDir` is where the file will be written, so the relative import\n * of the route table is computed against it rather than assumed.\n */\nexport function renderApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, BROWSER_CLIENT);\n}\n\n/**\n * The same mounts and the same route table for a `.native` file.\n *\n * The route table is imported, never restated, so it must itself import only\n * what the native host provides: a table that imports `@agimon-ai/po-core/web`\n * is refused by the native composition build, which is the intended failure.\n */\nexport function renderNativeApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, NATIVE_CLIENT);\n}\n"],"mappings":"qHAsBA,MAGMA,EA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