@agimon-ai/doompi-core 0.0.1-alpha.72 → 0.0.1-alpha.73

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 (189) hide show
  1. package/dist/extension-file.cjs +24 -0
  2. package/dist/extension-file.d.cts +3 -0
  3. package/dist/extension-file.d.mts +3 -0
  4. package/dist/extension-file.mjs +2 -0
  5. package/dist/extensions/extensionFile.cjs +165 -0
  6. package/dist/extensions/extensionFile.cjs.map +1 -0
  7. package/dist/extensions/extensionFile.d.cts +79 -0
  8. package/dist/extensions/extensionFile.d.cts.map +1 -0
  9. package/dist/extensions/extensionFile.d.mts +79 -0
  10. package/dist/extensions/extensionFile.d.mts.map +1 -0
  11. package/dist/extensions/extensionFile.mjs +144 -0
  12. package/dist/extensions/extensionFile.mjs.map +1 -0
  13. package/dist/extensions/serverPlugin.cjs +1 -1
  14. package/dist/extensions/serverPlugin.cjs.map +1 -1
  15. package/dist/extensions/serverPlugin.mjs +1 -1
  16. package/dist/extensions/serverPlugin.mjs.map +1 -1
  17. package/dist/extensions/webPlugin.cjs +98 -0
  18. package/dist/extensions/webPlugin.cjs.map +1 -1
  19. package/dist/extensions/webPlugin.d.cts +46 -1
  20. package/dist/extensions/webPlugin.d.cts.map +1 -1
  21. package/dist/extensions/webPlugin.d.mts +46 -1
  22. package/dist/extensions/webPlugin.d.mts.map +1 -1
  23. package/dist/extensions/webPlugin.mjs +81 -1
  24. package/dist/extensions/webPlugin.mjs.map +1 -1
  25. package/dist/headless-server.cjs +34 -1
  26. package/dist/headless-server.cjs.map +1 -1
  27. package/dist/headless-server.d.cts +15 -0
  28. package/dist/headless-server.d.cts.map +1 -1
  29. package/dist/headless-server.d.mts +15 -0
  30. package/dist/headless-server.d.mts.map +1 -1
  31. package/dist/headless-server.mjs +34 -2
  32. package/dist/headless-server.mjs.map +1 -1
  33. package/dist/pi/piSessionRuntime.cjs +14 -17
  34. package/dist/pi/piSessionRuntime.cjs.map +1 -1
  35. package/dist/pi/piSessionRuntime.d.cts.map +1 -1
  36. package/dist/pi/piSessionRuntime.d.mts.map +1 -1
  37. package/dist/pi/piSessionRuntime.mjs +7 -10
  38. package/dist/pi/piSessionRuntime.mjs.map +1 -1
  39. package/dist/pi-extension.cjs +5 -0
  40. package/dist/pi-extension.d.cts +3 -3
  41. package/dist/pi-extension.d.mts +3 -3
  42. package/dist/pi-extension.mjs +2 -2
  43. package/dist/runtime-pi-extension.cjs +92 -0
  44. package/dist/runtime-pi-extension.cjs.map +1 -1
  45. package/dist/runtime-pi-extension.d.cts +60 -3
  46. package/dist/runtime-pi-extension.d.cts.map +1 -1
  47. package/dist/runtime-pi-extension.d.mts +60 -3
  48. package/dist/runtime-pi-extension.d.mts.map +1 -1
  49. package/dist/runtime-pi-extension.mjs +88 -1
  50. package/dist/runtime-pi-extension.mjs.map +1 -1
  51. package/dist/schemas/extensionFile.d.cts +136 -0
  52. package/dist/schemas/extensionFile.d.cts.map +1 -0
  53. package/dist/schemas/extensionFile.d.mts +136 -0
  54. package/dist/schemas/extensionFile.d.mts.map +1 -0
  55. package/dist/schemas/headless.cjs.map +1 -1
  56. package/dist/schemas/headless.d.cts +32 -1
  57. package/dist/schemas/headless.d.cts.map +1 -1
  58. package/dist/schemas/headless.d.mts +32 -1
  59. package/dist/schemas/headless.d.mts.map +1 -1
  60. package/dist/schemas/headless.mjs.map +1 -1
  61. package/dist/schemas/piTool.cjs +2 -1
  62. package/dist/schemas/piTool.cjs.map +1 -1
  63. package/dist/schemas/piTool.d.cts +14 -1
  64. package/dist/schemas/piTool.d.cts.map +1 -1
  65. package/dist/schemas/piTool.d.mts +14 -1
  66. package/dist/schemas/piTool.d.mts.map +1 -1
  67. package/dist/schemas/piTool.mjs +2 -1
  68. package/dist/schemas/piTool.mjs.map +1 -1
  69. package/dist/schemas/serverFacet.d.cts +2 -2
  70. package/dist/schemas/serverFacet.d.mts +2 -2
  71. package/dist/server/directHarnessRuntime.cjs +31 -9
  72. package/dist/server/directHarnessRuntime.cjs.map +1 -1
  73. package/dist/server/directHarnessRuntime.mjs +31 -9
  74. package/dist/server/directHarnessRuntime.mjs.map +1 -1
  75. package/dist/server-facet.cjs +3 -0
  76. package/dist/server-facet.d.cts +2 -1
  77. package/dist/server-facet.d.mts +2 -1
  78. package/dist/server-facet.mjs +2 -1
  79. package/dist/services/apiSurfaceAssert/index.cjs +60 -0
  80. package/dist/services/apiSurfaceAssert/index.cjs.map +1 -0
  81. package/dist/services/apiSurfaceAssert/index.d.cts +24 -0
  82. package/dist/services/apiSurfaceAssert/index.d.cts.map +1 -0
  83. package/dist/services/apiSurfaceAssert/index.d.mts +24 -0
  84. package/dist/services/apiSurfaceAssert/index.d.mts.map +1 -0
  85. package/dist/services/apiSurfaceAssert/index.mjs +60 -0
  86. package/dist/services/apiSurfaceAssert/index.mjs.map +1 -0
  87. package/dist/services/contextUsage/index.cjs +27 -0
  88. package/dist/services/contextUsage/index.cjs.map +1 -0
  89. package/dist/services/contextUsage/index.mjs +25 -0
  90. package/dist/services/contextUsage/index.mjs.map +1 -0
  91. package/dist/services/packageResource/index.cjs +54 -0
  92. package/dist/services/packageResource/index.cjs.map +1 -0
  93. package/dist/services/packageResource/index.d.cts +26 -0
  94. package/dist/services/packageResource/index.d.cts.map +1 -0
  95. package/dist/services/packageResource/index.d.mts +26 -0
  96. package/dist/services/packageResource/index.d.mts.map +1 -0
  97. package/dist/services/packageResource/index.mjs +51 -0
  98. package/dist/services/packageResource/index.mjs.map +1 -0
  99. package/dist/services/piExtensionHost/index.cjs +363 -18
  100. package/dist/services/piExtensionHost/index.cjs.map +1 -1
  101. package/dist/services/piExtensionHost/index.mjs +362 -17
  102. package/dist/services/piExtensionHost/index.mjs.map +1 -1
  103. package/dist/services/piSessionEntries/index.cjs +38 -18
  104. package/dist/services/piSessionEntries/index.cjs.map +1 -1
  105. package/dist/services/piSessionEntries/index.mjs +39 -20
  106. package/dist/services/piSessionEntries/index.mjs.map +1 -1
  107. package/dist/services/sqliteSessionHistory/index.cjs +2 -2
  108. package/dist/services/sqliteSessionHistory/index.mjs +1 -1
  109. package/dist/systems/main/adapters/headlessHost.cjs +28 -4
  110. package/dist/systems/main/adapters/headlessHost.cjs.map +1 -1
  111. package/dist/systems/main/adapters/headlessHost.d.cts +20 -1
  112. package/dist/systems/main/adapters/headlessHost.d.cts.map +1 -1
  113. package/dist/systems/main/adapters/headlessHost.d.mts +20 -1
  114. package/dist/systems/main/adapters/headlessHost.d.mts.map +1 -1
  115. package/dist/systems/main/adapters/headlessHost.mjs +28 -4
  116. package/dist/systems/main/adapters/headlessHost.mjs.map +1 -1
  117. package/dist/systems/main/adapters/headlessSessionHost.cjs +53 -12
  118. package/dist/systems/main/adapters/headlessSessionHost.cjs.map +1 -1
  119. package/dist/systems/main/adapters/headlessSessionHost.d.cts.map +1 -1
  120. package/dist/systems/main/adapters/headlessSessionHost.d.mts.map +1 -1
  121. package/dist/systems/main/adapters/headlessSessionHost.mjs +54 -13
  122. package/dist/systems/main/adapters/headlessSessionHost.mjs.map +1 -1
  123. package/dist/systems/main/types/headlessHost.d.cts +1 -1
  124. package/dist/systems/main/types/headlessHost.d.mts +1 -1
  125. package/dist/testing.cjs +2 -0
  126. package/dist/testing.d.cts +2 -1
  127. package/dist/testing.d.mts +2 -1
  128. package/dist/testing.mjs +2 -1
  129. package/dist/types/server/directHarnessRuntime.d.cts +19 -3
  130. package/dist/types/server/directHarnessRuntime.d.cts.map +1 -1
  131. package/dist/types/server/directHarnessRuntime.d.mts +19 -3
  132. package/dist/types/server/directHarnessRuntime.d.mts.map +1 -1
  133. package/dist/web/models/workspaceStore.cjs +50 -0
  134. package/dist/web/models/workspaceStore.cjs.map +1 -0
  135. package/dist/web/models/workspaceStore.d.cts +18 -0
  136. package/dist/web/models/workspaceStore.d.cts.map +1 -0
  137. package/dist/web/models/workspaceStore.d.mts +18 -0
  138. package/dist/web/models/workspaceStore.d.mts.map +1 -0
  139. package/dist/web/models/workspaceStore.mjs +50 -0
  140. package/dist/web/models/workspaceStore.mjs.map +1 -0
  141. package/dist/web/services/apiClient/index.cjs +156 -0
  142. package/dist/web/services/apiClient/index.cjs.map +1 -0
  143. package/dist/web/services/apiClient/index.d.cts +152 -0
  144. package/dist/web/services/apiClient/index.d.cts.map +1 -0
  145. package/dist/web/services/apiClient/index.d.mts +152 -0
  146. package/dist/web/services/apiClient/index.d.mts.map +1 -0
  147. package/dist/web/services/apiClient/index.mjs +154 -0
  148. package/dist/web/services/apiClient/index.mjs.map +1 -0
  149. package/dist/web/services/apiPaths/index.cjs +83 -0
  150. package/dist/web/services/apiPaths/index.cjs.map +1 -0
  151. package/dist/web/services/apiPaths/index.d.cts +81 -0
  152. package/dist/web/services/apiPaths/index.d.cts.map +1 -0
  153. package/dist/web/services/apiPaths/index.d.mts +81 -0
  154. package/dist/web/services/apiPaths/index.d.mts.map +1 -0
  155. package/dist/web/services/apiPaths/index.mjs +78 -0
  156. package/dist/web/services/apiPaths/index.mjs.map +1 -0
  157. package/dist/web/services/apiRoutes/index.cjs +33 -3
  158. package/dist/web/services/apiRoutes/index.cjs.map +1 -1
  159. package/dist/web/services/apiRoutes/index.d.cts +14 -0
  160. package/dist/web/services/apiRoutes/index.d.cts.map +1 -1
  161. package/dist/web/services/apiRoutes/index.d.mts +14 -0
  162. package/dist/web/services/apiRoutes/index.d.mts.map +1 -1
  163. package/dist/web/services/apiRoutes/index.mjs +31 -4
  164. package/dist/web/services/apiRoutes/index.mjs.map +1 -1
  165. package/dist/web/services/testing/rpcStub.cjs +58 -0
  166. package/dist/web/services/testing/rpcStub.cjs.map +1 -0
  167. package/dist/web/services/testing/rpcStub.d.cts +37 -0
  168. package/dist/web/services/testing/rpcStub.d.cts.map +1 -0
  169. package/dist/web/services/testing/rpcStub.d.mts +37 -0
  170. package/dist/web/services/testing/rpcStub.d.mts.map +1 -0
  171. package/dist/web/services/testing/rpcStub.mjs +58 -0
  172. package/dist/web/services/testing/rpcStub.mjs.map +1 -0
  173. package/dist/web/testing.cjs +2 -0
  174. package/dist/web/testing.d.cts +2 -1
  175. package/dist/web/testing.d.mts +2 -1
  176. package/dist/web/testing.mjs +2 -1
  177. package/dist/web/types/extensionFile.d.cts +56 -0
  178. package/dist/web/types/extensionFile.d.cts.map +1 -0
  179. package/dist/web/types/extensionFile.d.mts +56 -0
  180. package/dist/web/types/extensionFile.d.mts.map +1 -0
  181. package/dist/web/types/webPlugin.d.cts +22 -0
  182. package/dist/web/types/webPlugin.d.cts.map +1 -1
  183. package/dist/web/types/webPlugin.d.mts +22 -0
  184. package/dist/web/types/webPlugin.d.mts.map +1 -1
  185. package/dist/web.cjs +49 -15
  186. package/dist/web.d.cts +8 -4
  187. package/dist/web.d.mts +8 -4
  188. package/dist/web.mjs +6 -3
  189. package/package.json +305 -300
@@ -0,0 +1,24 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_extensionFile = require("./extensions/extensionFile.cjs");
3
+ exports.composeRootHooks = require_extensionFile.composeRootHooks;
4
+ exports.defineActivity = require_extensionFile.defineActivity;
5
+ exports.defineChannel = require_extensionFile.defineChannel;
6
+ exports.defineCliCommand = require_extensionFile.defineCliCommand;
7
+ exports.defineCliHook = require_extensionFile.defineCliHook;
8
+ exports.defineCliTool = require_extensionFile.defineCliTool;
9
+ exports.defineCommand = require_extensionFile.defineCommand;
10
+ exports.defineHook = require_extensionFile.defineHook;
11
+ exports.defineMethod = require_extensionFile.defineMethod;
12
+ exports.defineMode = require_extensionFile.defineMode;
13
+ exports.defineOverlay = require_extensionFile.defineOverlay;
14
+ exports.defineProvider = require_extensionFile.defineProvider;
15
+ exports.defineResource = require_extensionFile.defineResource;
16
+ exports.defineRoot = require_extensionFile.defineRoot;
17
+ exports.defineRoute = require_extensionFile.defineRoute;
18
+ exports.defineRoutedContribution = require_extensionFile.defineRoutedContribution;
19
+ exports.defineServerCommand = require_extensionFile.defineServerCommand;
20
+ exports.defineServerTool = require_extensionFile.defineServerTool;
21
+ exports.defineService = require_extensionFile.defineService;
22
+ exports.defineShortcut = require_extensionFile.defineShortcut;
23
+ exports.defineTool = require_extensionFile.defineTool;
24
+ exports.defineToolRestriction = require_extensionFile.defineToolRestriction;
@@ -0,0 +1,3 @@
1
+ import { ActivityFile, ChannelFile, CliCommandFile, CliHookFile, CliHookHandler, CliToolFile, CommandContribution, CommandFile, HookFile, MethodFile, OrFactory, OverlayFile, PathSupplied, RootDeclaration, RootFile, RouteFile, RoutedCardinality, RoutedFileOptions, ServerCommandFile, ServerToolFile, ServiceFile, ToolContribution, ToolFile, WithRoot } from "./schemas/extensionFile.cjs";
2
+ import { composeRootHooks, defineActivity, defineChannel, defineCliCommand, defineCliHook, defineCliTool, defineCommand, defineHook, defineMethod, defineMode, defineOverlay, defineProvider, defineResource, defineRoot, defineRoute, defineRoutedContribution, defineServerCommand, defineServerTool, defineService, defineShortcut, defineTool, defineToolRestriction } from "./extensions/extensionFile.cjs";
3
+ export { type ActivityFile, type ChannelFile, type CliCommandFile, type CliHookFile, type CliHookHandler, type CliToolFile, type CommandContribution, type CommandFile, type HookFile, type MethodFile, type OrFactory, type OverlayFile, type PathSupplied, type RootDeclaration, type RootFile, type RouteFile, type RoutedCardinality, type RoutedFileOptions, type ServerCommandFile, type ServerToolFile, type ServiceFile, type ToolContribution, type ToolFile, type WithRoot, composeRootHooks, defineActivity, defineChannel, defineCliCommand, defineCliHook, defineCliTool, defineCommand, defineHook, defineMethod, defineMode, defineOverlay, defineProvider, defineResource, defineRoot, defineRoute, defineRoutedContribution, defineServerCommand, defineServerTool, defineService, defineShortcut, defineTool, defineToolRestriction };
@@ -0,0 +1,3 @@
1
+ import { ActivityFile, ChannelFile, CliCommandFile, CliHookFile, CliHookHandler, CliToolFile, CommandContribution, CommandFile, HookFile, MethodFile, OrFactory, OverlayFile, PathSupplied, RootDeclaration, RootFile, RouteFile, RoutedCardinality, RoutedFileOptions, ServerCommandFile, ServerToolFile, ServiceFile, ToolContribution, ToolFile, WithRoot } from "./schemas/extensionFile.mjs";
2
+ import { composeRootHooks, defineActivity, defineChannel, defineCliCommand, defineCliHook, defineCliTool, defineCommand, defineHook, defineMethod, defineMode, defineOverlay, defineProvider, defineResource, defineRoot, defineRoute, defineRoutedContribution, defineServerCommand, defineServerTool, defineService, defineShortcut, defineTool, defineToolRestriction } from "./extensions/extensionFile.mjs";
3
+ export { type ActivityFile, type ChannelFile, type CliCommandFile, type CliHookFile, type CliHookHandler, type CliToolFile, type CommandContribution, type CommandFile, type HookFile, type MethodFile, type OrFactory, type OverlayFile, type PathSupplied, type RootDeclaration, type RootFile, type RouteFile, type RoutedCardinality, type RoutedFileOptions, type ServerCommandFile, type ServerToolFile, type ServiceFile, type ToolContribution, type ToolFile, type WithRoot, composeRootHooks, defineActivity, defineChannel, defineCliCommand, defineCliHook, defineCliTool, defineCommand, defineHook, defineMethod, defineMode, defineOverlay, defineProvider, defineResource, defineRoot, defineRoute, defineRoutedContribution, defineServerCommand, defineServerTool, defineService, defineShortcut, defineTool, defineToolRestriction };
@@ -0,0 +1,2 @@
1
+ import { composeRootHooks, defineActivity, defineChannel, defineCliCommand, defineCliHook, defineCliTool, defineCommand, defineHook, defineMethod, defineMode, defineOverlay, defineProvider, defineResource, defineRoot, defineRoute, defineRoutedContribution, defineServerCommand, defineServerTool, defineService, defineShortcut, defineTool, defineToolRestriction } from "./extensions/extensionFile.mjs";
2
+ export { composeRootHooks, defineActivity, defineChannel, defineCliCommand, defineCliHook, defineCliTool, defineCommand, defineHook, defineMethod, defineMode, defineOverlay, defineProvider, defineResource, defineRoot, defineRoute, defineRoutedContribution, defineServerCommand, defineServerTool, defineService, defineShortcut, defineTool, defineToolRestriction };
@@ -0,0 +1,165 @@
1
+ //#region src/extensions/extensionFile.ts
2
+ /**
3
+ * Identity helpers for folder-routed backend files, one per surface.
4
+ *
5
+ * A routed file's default export is its whole contract with the host, and
6
+ * nothing else validates it: the generated entry merges the path's identity in
7
+ * and hands the result to a contribution array, where an excess or misspelled
8
+ * key is invisible. These make the shape checkable at the point it is written,
9
+ * and give the factory form a typed context instead of an implicit any.
10
+ *
11
+ * Most return their argument unchanged, so the value is entirely in the
12
+ * position they check and the inference they supply. The two that do not,
13
+ * `defineTool` and `defineCommand`, add the discriminant the host reads to
14
+ * tell a portable contribution from a raw host declaration.
15
+ */
16
+ /** Declares non-default route cardinality while preserving the routed surface's inferred host type. */
17
+ function defineRoutedContribution(file, _options) {
18
+ return file;
19
+ }
20
+ /** `provider/<name>.cli.ts`. Declares one Pi provider tuple. */
21
+ function defineProvider(file) {
22
+ return file;
23
+ }
24
+ /** `resource/<name>.ts`. Declares one package resource. */
25
+ function defineResource(file) {
26
+ return file;
27
+ }
28
+ /** `shortcut/<name>.cli.ts`. Declares one Pi keyboard shortcut. */
29
+ function defineShortcut(file) {
30
+ return file;
31
+ }
32
+ /** `tool-restriction/<name>.ts`. Declares one tool restriction. */
33
+ function defineToolRestriction(file) {
34
+ return file;
35
+ }
36
+ /** Declares one mode when it is not represented by a mode gate file. */
37
+ function defineMode(file) {
38
+ return file;
39
+ }
40
+ /** `overlay/<name>.cli.ts`. A terminal view opened directly by a command. */
41
+ function defineOverlay(file) {
42
+ return file;
43
+ }
44
+ /** `tool/<name>.ts`. Adds the discriminant the contribution array expects. */
45
+ function defineTool(file) {
46
+ return typeof file === "function" ? (context) => ({
47
+ kind: "tool",
48
+ ...file(context)
49
+ }) : {
50
+ kind: "tool",
51
+ ...file
52
+ };
53
+ }
54
+ /** `tool/<name>.server.ts`. A native headless tool, handed to the host untouched. */
55
+ function defineServerTool(file) {
56
+ return file;
57
+ }
58
+ /**
59
+ * `root.ts`. Constructs one scope and names what its subtree shares.
60
+ *
61
+ * The answer to a package whose surfaces all read one per-mount object graph.
62
+ * The root builds that graph once, and every routed file beneath it receives
63
+ * it as `context.root`, so the package decomposes into a file per surface
64
+ * without either rebuilding the graph per file or reaching for a module-level
65
+ * singleton.
66
+ */
67
+ function defineRoot(file) {
68
+ return file;
69
+ }
70
+ /**
71
+ * Folds every root in a scope chain into one set of lifecycle hooks.
72
+ *
73
+ * Start outermost first and tear down innermost first, which is the order the
74
+ * roots were constructed in and the only order in which an inner scope can
75
+ * still rely on its outer one while stopping.
76
+ */
77
+ function composeRootHooks(...roots) {
78
+ const reversed = [...roots].reverse();
79
+ return {
80
+ async onStart(context) {
81
+ for (const root of roots) await root.onStart?.(context);
82
+ },
83
+ async onStop(context) {
84
+ for (const root of reversed) await root.onStop?.(context);
85
+ },
86
+ async onDispose(context) {
87
+ for (const root of reversed) await root.onDispose?.(context);
88
+ }
89
+ };
90
+ }
91
+ /** `tool/<name>.cli.ts`. A native interactive tool, handed to Pi untouched. */
92
+ function defineCliTool(file) {
93
+ return file;
94
+ }
95
+ /** `command/<name>.cli.ts`. A native Pi command or portable Doom command. */
96
+ function defineCliCommand(file) {
97
+ return file;
98
+ }
99
+ /** `command/<name>.server.ts`. A native headless or portable Doom command. */
100
+ function defineServerCommand(file) {
101
+ return file;
102
+ }
103
+ /** `command/<name>.ts`. Adds the discriminant the contribution array expects. */
104
+ function defineCommand(file) {
105
+ return typeof file === "function" ? (context) => ({
106
+ kind: "command",
107
+ ...file(context)
108
+ }) : {
109
+ kind: "command",
110
+ ...file
111
+ };
112
+ }
113
+ /** `hook/<event>.cli.ts`. A native Pi event handler factory. */
114
+ function defineCliHook(file) {
115
+ return file;
116
+ }
117
+ /** `hook/<event>.ts`. Name the event here too when the handler needs a precise payload. */
118
+ function defineHook(file) {
119
+ return file;
120
+ }
121
+ /** A Cordis service factory for a scope root. */
122
+ function defineService(file) {
123
+ return file;
124
+ }
125
+ /** `channel/<frameType>.ts`. The contribution array holds factories, so this is one. */
126
+ function defineChannel(file) {
127
+ return file;
128
+ }
129
+ /** `api/<segments>/route.ts`. The folder path is the route. */
130
+ function defineRoute(file) {
131
+ return file;
132
+ }
133
+ /** `method/<member>.ts`. Build the value with `defineServerMethod` to keep schema inference. */
134
+ function defineMethod(file) {
135
+ return file;
136
+ }
137
+ /** A server activity declaration for a session root. */
138
+ function defineActivity(file) {
139
+ return file;
140
+ }
141
+ //#endregion
142
+ exports.composeRootHooks = composeRootHooks;
143
+ exports.defineActivity = defineActivity;
144
+ exports.defineChannel = defineChannel;
145
+ exports.defineCliCommand = defineCliCommand;
146
+ exports.defineCliHook = defineCliHook;
147
+ exports.defineCliTool = defineCliTool;
148
+ exports.defineCommand = defineCommand;
149
+ exports.defineHook = defineHook;
150
+ exports.defineMethod = defineMethod;
151
+ exports.defineMode = defineMode;
152
+ exports.defineOverlay = defineOverlay;
153
+ exports.defineProvider = defineProvider;
154
+ exports.defineResource = defineResource;
155
+ exports.defineRoot = defineRoot;
156
+ exports.defineRoute = defineRoute;
157
+ exports.defineRoutedContribution = defineRoutedContribution;
158
+ exports.defineServerCommand = defineServerCommand;
159
+ exports.defineServerTool = defineServerTool;
160
+ exports.defineService = defineService;
161
+ exports.defineShortcut = defineShortcut;
162
+ exports.defineTool = defineTool;
163
+ exports.defineToolRestriction = defineToolRestriction;
164
+
165
+ //# sourceMappingURL=extensionFile.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensionFile.cjs","names":[],"sources":["../../src/extensions/extensionFile.ts"],"sourcesContent":["import type { TSchema } from 'typebox';\n\nimport type {\n ActivityFile,\n ChannelFile,\n CliCommandFile,\n CliHookFile,\n CliHookHandler,\n CliToolFile,\n CommandContribution,\n CommandFile,\n HookFile,\n MethodFile,\n OverlayFile,\n RootFile,\n RoutedFileOptions,\n RouteFile,\n ServerCommandFile,\n ServerToolFile,\n ServiceFile,\n ToolContribution,\n ToolFile,\n} from '../schemas/extensionFile';\nimport type { DoomHeadlessEventName } from '../schemas/headless';\nimport type { PluginLifecycleHooks } from '../services/pluginLifecycle';\n\n/**\n * Identity helpers for folder-routed backend files, one per surface.\n *\n * A routed file's default export is its whole contract with the host, and\n * nothing else validates it: the generated entry merges the path's identity in\n * and hands the result to a contribution array, where an excess or misspelled\n * key is invisible. These make the shape checkable at the point it is written,\n * and give the factory form a typed context instead of an implicit any.\n *\n * Most return their argument unchanged, so the value is entirely in the\n * position they check and the inference they supply. The two that do not,\n * `defineTool` and `defineCommand`, add the discriminant the host reads to\n * tell a portable contribution from a raw host declaration.\n */\n\n/** Declares non-default route cardinality while preserving the routed surface's inferred host type. */\nexport function defineRoutedContribution<T>(file: T, _options: RoutedFileOptions): T {\n return file;\n}\n\n/** `provider/<name>.cli.ts`. Declares one Pi provider tuple. */\nexport function defineProvider<T>(file: T): T {\n return file;\n}\n\n/** `resource/<name>.ts`. Declares one package resource. */\nexport function defineResource<T>(file: T): T {\n return file;\n}\n\n/** `shortcut/<name>.cli.ts`. Declares one Pi keyboard shortcut. */\nexport function defineShortcut<T>(file: T): T {\n return file;\n}\n\n/** `tool-restriction/<name>.ts`. Declares one tool restriction. */\nexport function defineToolRestriction<T>(file: T): T {\n return file;\n}\n\n/** Declares one mode when it is not represented by a mode gate file. */\nexport function defineMode<T>(file: T): T {\n return file;\n}\n\n/** `overlay/<name>.cli.ts`. A terminal view opened directly by a command. */\nexport function defineOverlay<T extends OverlayFile>(file: T): T {\n return file;\n}\n/** `tool/<name>.ts`. Adds the discriminant the contribution array expects. */\nexport function defineTool<TContext = unknown>(file: ToolFile<TContext>): ToolContribution<TContext> {\n return typeof file === 'function'\n ? (context) => ({ kind: 'tool' as const, ...file(context) })\n : { kind: 'tool' as const, ...file };\n}\n\n/** `tool/<name>.server.ts`. A native headless tool, handed to the host untouched. */\nexport function defineServerTool<TParameters extends TSchema = TSchema, TContext = unknown>(\n file: ServerToolFile<TParameters, TContext>,\n): ServerToolFile<TParameters, TContext> {\n return file;\n}\n\n/**\n * `root.ts`. Constructs one scope and names what its subtree shares.\n *\n * The answer to a package whose surfaces all read one per-mount object graph.\n * The root builds that graph once, and every routed file beneath it receives\n * it as `context.root`, so the package decomposes into a file per surface\n * without either rebuilding the graph per file or reaching for a module-level\n * singleton.\n */\nexport function defineRoot<TValue, TContext = unknown>(file: RootFile<TValue, TContext>): RootFile<TValue, TContext> {\n return file;\n}\n\n/**\n * Folds every root in a scope chain into one set of lifecycle hooks.\n *\n * Start outermost first and tear down innermost first, which is the order the\n * roots were constructed in and the only order in which an inner scope can\n * still rely on its outer one while stopping.\n */\nexport function composeRootHooks<TContext>(\n ...roots: readonly PluginLifecycleHooks<TContext>[]\n): Required<PluginLifecycleHooks<TContext>> {\n const reversed = [...roots].reverse();\n return {\n async onStart(context) {\n for (const root of roots) await root.onStart?.(context);\n },\n async onStop(context) {\n for (const root of reversed) await root.onStop?.(context);\n },\n async onDispose(context) {\n for (const root of reversed) await root.onDispose?.(context);\n },\n };\n}\n\n/** `tool/<name>.cli.ts`. A native interactive tool, handed to Pi untouched. */\nexport function defineCliTool<TContext = unknown>(file: CliToolFile<TContext>): CliToolFile<TContext> {\n return file;\n}\n\n/** `command/<name>.cli.ts`. A native Pi command or portable Doom command. */\nexport function defineCliCommand<TContext = unknown>(file: CliCommandFile<TContext>): CliCommandFile<TContext> {\n return file;\n}\n\n/** `command/<name>.server.ts`. A native headless or portable Doom command. */\nexport function defineServerCommand<TContext = unknown>(\n file: ServerCommandFile<TContext>,\n): ServerCommandFile<TContext> {\n return file;\n}\n\n/** `command/<name>.ts`. Adds the discriminant the contribution array expects. */\nexport function defineCommand<TContext = unknown>(file: CommandFile<TContext>): CommandContribution<TContext> {\n return typeof file === 'function'\n ? (context) => ({ kind: 'command' as const, ...file(context) })\n : { kind: 'command' as const, ...file };\n}\n\n/** `hook/<event>.cli.ts`. A native Pi event handler factory. */\nexport function defineCliHook<TContext, THandler extends CliHookHandler>(\n file: (context: TContext) => THandler,\n): CliHookFile<TContext, CliHookHandler> {\n return file;\n}\n\n/** `hook/<event>.ts`. Name the event here too when the handler needs a precise payload. */\nexport function defineHook<TEvent extends DoomHeadlessEventName = DoomHeadlessEventName, TContext = unknown>(\n file: HookFile<TEvent, TContext>,\n): HookFile<TEvent, TContext> {\n return file;\n}\n\n/** A Cordis service factory for a scope root. */\nexport function defineService<TContext = unknown>(file: ServiceFile<TContext>): ServiceFile<TContext> {\n return file;\n}\n\n/** `channel/<frameType>.ts`. The contribution array holds factories, so this is one. */\nexport function defineChannel(file: ChannelFile): ChannelFile {\n return file;\n}\n\n/** `api/<segments>/route.ts`. The folder path is the route. */\nexport function defineRoute<TContext = unknown>(file: RouteFile<TContext>): RouteFile<TContext> {\n return file;\n}\n\n/** `method/<member>.ts`. Build the value with `defineServerMethod` to keep schema inference. */\nexport function defineMethod<TContext = unknown>(file: MethodFile<TContext>): MethodFile<TContext> {\n return file;\n}\n\n/** A server activity declaration for a session root. */\nexport function defineActivity<TContext = unknown>(file: ActivityFile<TContext>): ActivityFile<TContext> {\n return file;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,SAAgB,yBAA4B,MAAS,UAAgC;CACnF,OAAO;AACT;;AAGA,SAAgB,eAAkB,MAAY;CAC5C,OAAO;AACT;;AAGA,SAAgB,eAAkB,MAAY;CAC5C,OAAO;AACT;;AAGA,SAAgB,eAAkB,MAAY;CAC5C,OAAO;AACT;;AAGA,SAAgB,sBAAyB,MAAY;CACnD,OAAO;AACT;;AAGA,SAAgB,WAAc,MAAY;CACxC,OAAO;AACT;;AAGA,SAAgB,cAAqC,MAAY;CAC/D,OAAO;AACT;;AAEA,SAAgB,WAA+B,MAAsD;CACnG,OAAO,OAAO,SAAS,cAClB,aAAa;EAAE,MAAM;EAAiB,GAAG,KAAK,OAAO;CAAE,KACxD;EAAE,MAAM;EAAiB,GAAG;CAAK;AACvC;;AAGA,SAAgB,iBACd,MACuC;CACvC,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,WAAuC,MAA8D;CACnH,OAAO;AACT;;;;;;;;AASA,SAAgB,iBACd,GAAG,OACuC;CAC1C,MAAM,WAAW,CAAC,GAAG,KAAK,CAAC,CAAC,QAAQ;CACpC,OAAO;EACL,MAAM,QAAQ,SAAS;GACrB,KAAK,MAAM,QAAQ,OAAO,MAAM,KAAK,UAAU,OAAO;EACxD;EACA,MAAM,OAAO,SAAS;GACpB,KAAK,MAAM,QAAQ,UAAU,MAAM,KAAK,SAAS,OAAO;EAC1D;EACA,MAAM,UAAU,SAAS;GACvB,KAAK,MAAM,QAAQ,UAAU,MAAM,KAAK,YAAY,OAAO;EAC7D;CACF;AACF;;AAGA,SAAgB,cAAkC,MAAoD;CACpG,OAAO;AACT;;AAGA,SAAgB,iBAAqC,MAA0D;CAC7G,OAAO;AACT;;AAGA,SAAgB,oBACd,MAC6B;CAC7B,OAAO;AACT;;AAGA,SAAgB,cAAkC,MAA4D;CAC5G,OAAO,OAAO,SAAS,cAClB,aAAa;EAAE,MAAM;EAAoB,GAAG,KAAK,OAAO;CAAE,KAC3D;EAAE,MAAM;EAAoB,GAAG;CAAK;AAC1C;;AAGA,SAAgB,cACd,MACuC;CACvC,OAAO;AACT;;AAGA,SAAgB,WACd,MAC4B;CAC5B,OAAO;AACT;;AAGA,SAAgB,cAAkC,MAAoD;CACpG,OAAO;AACT;;AAGA,SAAgB,cAAc,MAAgC;CAC5D,OAAO;AACT;;AAGA,SAAgB,YAAgC,MAAgD;CAC9F,OAAO;AACT;;AAGA,SAAgB,aAAiC,MAAkD;CACjG,OAAO;AACT;;AAGA,SAAgB,eAAmC,MAAsD;CACvG,OAAO;AACT"}
@@ -0,0 +1,79 @@
1
+ import { PluginLifecycleHooks } from "../services/pluginLifecycle/index.cjs";
2
+ import { DoomHeadlessEventName } from "../schemas/headless.cjs";
3
+ import { ActivityFile, ChannelFile, CliCommandFile, CliHookFile, CliHookHandler, CliToolFile, CommandContribution, CommandFile, HookFile, MethodFile, OverlayFile, RootFile, RouteFile, RoutedFileOptions, ServerCommandFile, ServerToolFile, ServiceFile, ToolContribution, ToolFile } from "../schemas/extensionFile.cjs";
4
+ import { TSchema } from "typebox";
5
+ //#region src/extensions/extensionFile.d.ts
6
+ /**
7
+ * Identity helpers for folder-routed backend files, one per surface.
8
+ *
9
+ * A routed file's default export is its whole contract with the host, and
10
+ * nothing else validates it: the generated entry merges the path's identity in
11
+ * and hands the result to a contribution array, where an excess or misspelled
12
+ * key is invisible. These make the shape checkable at the point it is written,
13
+ * and give the factory form a typed context instead of an implicit any.
14
+ *
15
+ * Most return their argument unchanged, so the value is entirely in the
16
+ * position they check and the inference they supply. The two that do not,
17
+ * `defineTool` and `defineCommand`, add the discriminant the host reads to
18
+ * tell a portable contribution from a raw host declaration.
19
+ */
20
+ /** Declares non-default route cardinality while preserving the routed surface's inferred host type. */
21
+ export declare function defineRoutedContribution<T>(file: T, _options: RoutedFileOptions): T;
22
+ /** `provider/<name>.cli.ts`. Declares one Pi provider tuple. */
23
+ export declare function defineProvider<T>(file: T): T;
24
+ /** `resource/<name>.ts`. Declares one package resource. */
25
+ export declare function defineResource<T>(file: T): T;
26
+ /** `shortcut/<name>.cli.ts`. Declares one Pi keyboard shortcut. */
27
+ export declare function defineShortcut<T>(file: T): T;
28
+ /** `tool-restriction/<name>.ts`. Declares one tool restriction. */
29
+ export declare function defineToolRestriction<T>(file: T): T;
30
+ /** Declares one mode when it is not represented by a mode gate file. */
31
+ export declare function defineMode<T>(file: T): T;
32
+ /** `overlay/<name>.cli.ts`. A terminal view opened directly by a command. */
33
+ export declare function defineOverlay<T extends OverlayFile>(file: T): T;
34
+ /** `tool/<name>.ts`. Adds the discriminant the contribution array expects. */
35
+ export declare function defineTool<TContext = unknown>(file: ToolFile<TContext>): ToolContribution<TContext>;
36
+ /** `tool/<name>.server.ts`. A native headless tool, handed to the host untouched. */
37
+ export declare function defineServerTool<TParameters extends TSchema = TSchema, TContext = unknown>(file: ServerToolFile<TParameters, TContext>): ServerToolFile<TParameters, TContext>;
38
+ /**
39
+ * `root.ts`. Constructs one scope and names what its subtree shares.
40
+ *
41
+ * The answer to a package whose surfaces all read one per-mount object graph.
42
+ * The root builds that graph once, and every routed file beneath it receives
43
+ * it as `context.root`, so the package decomposes into a file per surface
44
+ * without either rebuilding the graph per file or reaching for a module-level
45
+ * singleton.
46
+ */
47
+ export declare function defineRoot<TValue, TContext = unknown>(file: RootFile<TValue, TContext>): RootFile<TValue, TContext>;
48
+ /**
49
+ * Folds every root in a scope chain into one set of lifecycle hooks.
50
+ *
51
+ * Start outermost first and tear down innermost first, which is the order the
52
+ * roots were constructed in and the only order in which an inner scope can
53
+ * still rely on its outer one while stopping.
54
+ */
55
+ export declare function composeRootHooks<TContext>(...roots: readonly PluginLifecycleHooks<TContext>[]): Required<PluginLifecycleHooks<TContext>>;
56
+ /** `tool/<name>.cli.ts`. A native interactive tool, handed to Pi untouched. */
57
+ export declare function defineCliTool<TContext = unknown>(file: CliToolFile<TContext>): CliToolFile<TContext>;
58
+ /** `command/<name>.cli.ts`. A native Pi command or portable Doom command. */
59
+ export declare function defineCliCommand<TContext = unknown>(file: CliCommandFile<TContext>): CliCommandFile<TContext>;
60
+ /** `command/<name>.server.ts`. A native headless or portable Doom command. */
61
+ export declare function defineServerCommand<TContext = unknown>(file: ServerCommandFile<TContext>): ServerCommandFile<TContext>;
62
+ /** `command/<name>.ts`. Adds the discriminant the contribution array expects. */
63
+ export declare function defineCommand<TContext = unknown>(file: CommandFile<TContext>): CommandContribution<TContext>;
64
+ /** `hook/<event>.cli.ts`. A native Pi event handler factory. */
65
+ export declare function defineCliHook<TContext, THandler extends CliHookHandler>(file: (context: TContext) => THandler): CliHookFile<TContext, CliHookHandler>;
66
+ /** `hook/<event>.ts`. Name the event here too when the handler needs a precise payload. */
67
+ export declare function defineHook<TEvent extends DoomHeadlessEventName = DoomHeadlessEventName, TContext = unknown>(file: HookFile<TEvent, TContext>): HookFile<TEvent, TContext>;
68
+ /** A Cordis service factory for a scope root. */
69
+ export declare function defineService<TContext = unknown>(file: ServiceFile<TContext>): ServiceFile<TContext>;
70
+ /** `channel/<frameType>.ts`. The contribution array holds factories, so this is one. */
71
+ export declare function defineChannel(file: ChannelFile): ChannelFile;
72
+ /** `api/<segments>/route.ts`. The folder path is the route. */
73
+ export declare function defineRoute<TContext = unknown>(file: RouteFile<TContext>): RouteFile<TContext>;
74
+ /** `method/<member>.ts`. Build the value with `defineServerMethod` to keep schema inference. */
75
+ export declare function defineMethod<TContext = unknown>(file: MethodFile<TContext>): MethodFile<TContext>;
76
+ /** A server activity declaration for a session root. */
77
+ export declare function defineActivity<TContext = unknown>(file: ActivityFile<TContext>): ActivityFile<TContext>;
78
+ //#endregion
79
+ //# sourceMappingURL=extensionFile.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensionFile.d.cts","names":[],"sources":["../../src/extensions/extensionFile.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;wBA0CgB,yBAAyB,GAAG,MAAM,GAAG,UAAU,oBAAoB;;wBAKnE,eAAe,GAAG,MAAM,IAAI;;wBAK5B,eAAe,GAAG,MAAM,IAAI;;wBAK5B,eAAe,GAAG,MAAM,IAAI;;wBAK5B,sBAAsB,GAAG,MAAM,IAAI;;wBAKnC,WAAW,GAAG,MAAM,IAAI;;wBAKxB,cAAc,UAAU,aAAa,MAAM,IAAI;;wBAI/C,WAAW,oBAAoB,MAAM,SAAS,YAAY,iBAAiB;;wBAO3E,iBAAiB,oBAAoB,UAAU,SAAS,oBACtE,MAAM,eAAe,aAAa,YACjC,eAAe,aAAa;;;;;;;;;;wBAaf,WAAW,QAAQ,oBAAoB,MAAM,SAAS,QAAQ,YAAY,SAAS,QAAQ;;;;;;;;wBAW3F,iBAAiB,aAC5B,gBAAgB,qBAAqB,cACvC,SAAS,qBAAqB;;wBAgBjB,cAAc,oBAAoB,MAAM,YAAY,YAAY,YAAY;;wBAK5E,iBAAiB,oBAAoB,MAAM,eAAe,YAAY,eAAe;;wBAKrF,oBAAoB,oBAClC,MAAM,kBAAkB,YACvB,kBAAkB;;wBAKL,cAAc,oBAAoB,MAAM,YAAY,YAAY,oBAAoB;;wBAOpF,cAAc,UAAU,iBAAiB,gBACvD,OAAO,SAAS,aAAa,WAC5B,YAAY,UAAU;;wBAKT,WAAW,eAAe,wBAAwB,uBAAuB,oBACvF,MAAM,SAAS,QAAQ,YACtB,SAAS,QAAQ;;wBAKJ,cAAc,oBAAoB,MAAM,YAAY,YAAY,YAAY;;wBAK5E,cAAc,MAAM,cAAc;;wBAKlC,YAAY,oBAAoB,MAAM,UAAU,YAAY,UAAU;;wBAKtE,aAAa,oBAAoB,MAAM,WAAW,YAAY,WAAW;;wBAKzE,eAAe,oBAAoB,MAAM,aAAa,YAAY,aAAa"}
@@ -0,0 +1,79 @@
1
+ import { PluginLifecycleHooks } from "../services/pluginLifecycle/index.mjs";
2
+ import { DoomHeadlessEventName } from "../schemas/headless.mjs";
3
+ import { ActivityFile, ChannelFile, CliCommandFile, CliHookFile, CliHookHandler, CliToolFile, CommandContribution, CommandFile, HookFile, MethodFile, OverlayFile, RootFile, RouteFile, RoutedFileOptions, ServerCommandFile, ServerToolFile, ServiceFile, ToolContribution, ToolFile } from "../schemas/extensionFile.mjs";
4
+ import { TSchema } from "typebox";
5
+ //#region src/extensions/extensionFile.d.ts
6
+ /**
7
+ * Identity helpers for folder-routed backend files, one per surface.
8
+ *
9
+ * A routed file's default export is its whole contract with the host, and
10
+ * nothing else validates it: the generated entry merges the path's identity in
11
+ * and hands the result to a contribution array, where an excess or misspelled
12
+ * key is invisible. These make the shape checkable at the point it is written,
13
+ * and give the factory form a typed context instead of an implicit any.
14
+ *
15
+ * Most return their argument unchanged, so the value is entirely in the
16
+ * position they check and the inference they supply. The two that do not,
17
+ * `defineTool` and `defineCommand`, add the discriminant the host reads to
18
+ * tell a portable contribution from a raw host declaration.
19
+ */
20
+ /** Declares non-default route cardinality while preserving the routed surface's inferred host type. */
21
+ export declare function defineRoutedContribution<T>(file: T, _options: RoutedFileOptions): T;
22
+ /** `provider/<name>.cli.ts`. Declares one Pi provider tuple. */
23
+ export declare function defineProvider<T>(file: T): T;
24
+ /** `resource/<name>.ts`. Declares one package resource. */
25
+ export declare function defineResource<T>(file: T): T;
26
+ /** `shortcut/<name>.cli.ts`. Declares one Pi keyboard shortcut. */
27
+ export declare function defineShortcut<T>(file: T): T;
28
+ /** `tool-restriction/<name>.ts`. Declares one tool restriction. */
29
+ export declare function defineToolRestriction<T>(file: T): T;
30
+ /** Declares one mode when it is not represented by a mode gate file. */
31
+ export declare function defineMode<T>(file: T): T;
32
+ /** `overlay/<name>.cli.ts`. A terminal view opened directly by a command. */
33
+ export declare function defineOverlay<T extends OverlayFile>(file: T): T;
34
+ /** `tool/<name>.ts`. Adds the discriminant the contribution array expects. */
35
+ export declare function defineTool<TContext = unknown>(file: ToolFile<TContext>): ToolContribution<TContext>;
36
+ /** `tool/<name>.server.ts`. A native headless tool, handed to the host untouched. */
37
+ export declare function defineServerTool<TParameters extends TSchema = TSchema, TContext = unknown>(file: ServerToolFile<TParameters, TContext>): ServerToolFile<TParameters, TContext>;
38
+ /**
39
+ * `root.ts`. Constructs one scope and names what its subtree shares.
40
+ *
41
+ * The answer to a package whose surfaces all read one per-mount object graph.
42
+ * The root builds that graph once, and every routed file beneath it receives
43
+ * it as `context.root`, so the package decomposes into a file per surface
44
+ * without either rebuilding the graph per file or reaching for a module-level
45
+ * singleton.
46
+ */
47
+ export declare function defineRoot<TValue, TContext = unknown>(file: RootFile<TValue, TContext>): RootFile<TValue, TContext>;
48
+ /**
49
+ * Folds every root in a scope chain into one set of lifecycle hooks.
50
+ *
51
+ * Start outermost first and tear down innermost first, which is the order the
52
+ * roots were constructed in and the only order in which an inner scope can
53
+ * still rely on its outer one while stopping.
54
+ */
55
+ export declare function composeRootHooks<TContext>(...roots: readonly PluginLifecycleHooks<TContext>[]): Required<PluginLifecycleHooks<TContext>>;
56
+ /** `tool/<name>.cli.ts`. A native interactive tool, handed to Pi untouched. */
57
+ export declare function defineCliTool<TContext = unknown>(file: CliToolFile<TContext>): CliToolFile<TContext>;
58
+ /** `command/<name>.cli.ts`. A native Pi command or portable Doom command. */
59
+ export declare function defineCliCommand<TContext = unknown>(file: CliCommandFile<TContext>): CliCommandFile<TContext>;
60
+ /** `command/<name>.server.ts`. A native headless or portable Doom command. */
61
+ export declare function defineServerCommand<TContext = unknown>(file: ServerCommandFile<TContext>): ServerCommandFile<TContext>;
62
+ /** `command/<name>.ts`. Adds the discriminant the contribution array expects. */
63
+ export declare function defineCommand<TContext = unknown>(file: CommandFile<TContext>): CommandContribution<TContext>;
64
+ /** `hook/<event>.cli.ts`. A native Pi event handler factory. */
65
+ export declare function defineCliHook<TContext, THandler extends CliHookHandler>(file: (context: TContext) => THandler): CliHookFile<TContext, CliHookHandler>;
66
+ /** `hook/<event>.ts`. Name the event here too when the handler needs a precise payload. */
67
+ export declare function defineHook<TEvent extends DoomHeadlessEventName = DoomHeadlessEventName, TContext = unknown>(file: HookFile<TEvent, TContext>): HookFile<TEvent, TContext>;
68
+ /** A Cordis service factory for a scope root. */
69
+ export declare function defineService<TContext = unknown>(file: ServiceFile<TContext>): ServiceFile<TContext>;
70
+ /** `channel/<frameType>.ts`. The contribution array holds factories, so this is one. */
71
+ export declare function defineChannel(file: ChannelFile): ChannelFile;
72
+ /** `api/<segments>/route.ts`. The folder path is the route. */
73
+ export declare function defineRoute<TContext = unknown>(file: RouteFile<TContext>): RouteFile<TContext>;
74
+ /** `method/<member>.ts`. Build the value with `defineServerMethod` to keep schema inference. */
75
+ export declare function defineMethod<TContext = unknown>(file: MethodFile<TContext>): MethodFile<TContext>;
76
+ /** A server activity declaration for a session root. */
77
+ export declare function defineActivity<TContext = unknown>(file: ActivityFile<TContext>): ActivityFile<TContext>;
78
+ //#endregion
79
+ //# sourceMappingURL=extensionFile.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensionFile.d.mts","names":[],"sources":["../../src/extensions/extensionFile.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;wBA0CgB,yBAAyB,GAAG,MAAM,GAAG,UAAU,oBAAoB;;wBAKnE,eAAe,GAAG,MAAM,IAAI;;wBAK5B,eAAe,GAAG,MAAM,IAAI;;wBAK5B,eAAe,GAAG,MAAM,IAAI;;wBAK5B,sBAAsB,GAAG,MAAM,IAAI;;wBAKnC,WAAW,GAAG,MAAM,IAAI;;wBAKxB,cAAc,UAAU,aAAa,MAAM,IAAI;;wBAI/C,WAAW,oBAAoB,MAAM,SAAS,YAAY,iBAAiB;;wBAO3E,iBAAiB,oBAAoB,UAAU,SAAS,oBACtE,MAAM,eAAe,aAAa,YACjC,eAAe,aAAa;;;;;;;;;;wBAaf,WAAW,QAAQ,oBAAoB,MAAM,SAAS,QAAQ,YAAY,SAAS,QAAQ;;;;;;;;wBAW3F,iBAAiB,aAC5B,gBAAgB,qBAAqB,cACvC,SAAS,qBAAqB;;wBAgBjB,cAAc,oBAAoB,MAAM,YAAY,YAAY,YAAY;;wBAK5E,iBAAiB,oBAAoB,MAAM,eAAe,YAAY,eAAe;;wBAKrF,oBAAoB,oBAClC,MAAM,kBAAkB,YACvB,kBAAkB;;wBAKL,cAAc,oBAAoB,MAAM,YAAY,YAAY,oBAAoB;;wBAOpF,cAAc,UAAU,iBAAiB,gBACvD,OAAO,SAAS,aAAa,WAC5B,YAAY,UAAU;;wBAKT,WAAW,eAAe,wBAAwB,uBAAuB,oBACvF,MAAM,SAAS,QAAQ,YACtB,SAAS,QAAQ;;wBAKJ,cAAc,oBAAoB,MAAM,YAAY,YAAY,YAAY;;wBAK5E,cAAc,MAAM,cAAc;;wBAKlC,YAAY,oBAAoB,MAAM,UAAU,YAAY,UAAU;;wBAKtE,aAAa,oBAAoB,MAAM,WAAW,YAAY,WAAW;;wBAKzE,eAAe,oBAAoB,MAAM,aAAa,YAAY,aAAa"}
@@ -0,0 +1,144 @@
1
+ //#region src/extensions/extensionFile.ts
2
+ /**
3
+ * Identity helpers for folder-routed backend files, one per surface.
4
+ *
5
+ * A routed file's default export is its whole contract with the host, and
6
+ * nothing else validates it: the generated entry merges the path's identity in
7
+ * and hands the result to a contribution array, where an excess or misspelled
8
+ * key is invisible. These make the shape checkable at the point it is written,
9
+ * and give the factory form a typed context instead of an implicit any.
10
+ *
11
+ * Most return their argument unchanged, so the value is entirely in the
12
+ * position they check and the inference they supply. The two that do not,
13
+ * `defineTool` and `defineCommand`, add the discriminant the host reads to
14
+ * tell a portable contribution from a raw host declaration.
15
+ */
16
+ /** Declares non-default route cardinality while preserving the routed surface's inferred host type. */
17
+ function defineRoutedContribution(file, _options) {
18
+ return file;
19
+ }
20
+ /** `provider/<name>.cli.ts`. Declares one Pi provider tuple. */
21
+ function defineProvider(file) {
22
+ return file;
23
+ }
24
+ /** `resource/<name>.ts`. Declares one package resource. */
25
+ function defineResource(file) {
26
+ return file;
27
+ }
28
+ /** `shortcut/<name>.cli.ts`. Declares one Pi keyboard shortcut. */
29
+ function defineShortcut(file) {
30
+ return file;
31
+ }
32
+ /** `tool-restriction/<name>.ts`. Declares one tool restriction. */
33
+ function defineToolRestriction(file) {
34
+ return file;
35
+ }
36
+ /** Declares one mode when it is not represented by a mode gate file. */
37
+ function defineMode(file) {
38
+ return file;
39
+ }
40
+ /** `overlay/<name>.cli.ts`. A terminal view opened directly by a command. */
41
+ function defineOverlay(file) {
42
+ return file;
43
+ }
44
+ /** `tool/<name>.ts`. Adds the discriminant the contribution array expects. */
45
+ function defineTool(file) {
46
+ return typeof file === "function" ? (context) => ({
47
+ kind: "tool",
48
+ ...file(context)
49
+ }) : {
50
+ kind: "tool",
51
+ ...file
52
+ };
53
+ }
54
+ /** `tool/<name>.server.ts`. A native headless tool, handed to the host untouched. */
55
+ function defineServerTool(file) {
56
+ return file;
57
+ }
58
+ /**
59
+ * `root.ts`. Constructs one scope and names what its subtree shares.
60
+ *
61
+ * The answer to a package whose surfaces all read one per-mount object graph.
62
+ * The root builds that graph once, and every routed file beneath it receives
63
+ * it as `context.root`, so the package decomposes into a file per surface
64
+ * without either rebuilding the graph per file or reaching for a module-level
65
+ * singleton.
66
+ */
67
+ function defineRoot(file) {
68
+ return file;
69
+ }
70
+ /**
71
+ * Folds every root in a scope chain into one set of lifecycle hooks.
72
+ *
73
+ * Start outermost first and tear down innermost first, which is the order the
74
+ * roots were constructed in and the only order in which an inner scope can
75
+ * still rely on its outer one while stopping.
76
+ */
77
+ function composeRootHooks(...roots) {
78
+ const reversed = [...roots].reverse();
79
+ return {
80
+ async onStart(context) {
81
+ for (const root of roots) await root.onStart?.(context);
82
+ },
83
+ async onStop(context) {
84
+ for (const root of reversed) await root.onStop?.(context);
85
+ },
86
+ async onDispose(context) {
87
+ for (const root of reversed) await root.onDispose?.(context);
88
+ }
89
+ };
90
+ }
91
+ /** `tool/<name>.cli.ts`. A native interactive tool, handed to Pi untouched. */
92
+ function defineCliTool(file) {
93
+ return file;
94
+ }
95
+ /** `command/<name>.cli.ts`. A native Pi command or portable Doom command. */
96
+ function defineCliCommand(file) {
97
+ return file;
98
+ }
99
+ /** `command/<name>.server.ts`. A native headless or portable Doom command. */
100
+ function defineServerCommand(file) {
101
+ return file;
102
+ }
103
+ /** `command/<name>.ts`. Adds the discriminant the contribution array expects. */
104
+ function defineCommand(file) {
105
+ return typeof file === "function" ? (context) => ({
106
+ kind: "command",
107
+ ...file(context)
108
+ }) : {
109
+ kind: "command",
110
+ ...file
111
+ };
112
+ }
113
+ /** `hook/<event>.cli.ts`. A native Pi event handler factory. */
114
+ function defineCliHook(file) {
115
+ return file;
116
+ }
117
+ /** `hook/<event>.ts`. Name the event here too when the handler needs a precise payload. */
118
+ function defineHook(file) {
119
+ return file;
120
+ }
121
+ /** A Cordis service factory for a scope root. */
122
+ function defineService(file) {
123
+ return file;
124
+ }
125
+ /** `channel/<frameType>.ts`. The contribution array holds factories, so this is one. */
126
+ function defineChannel(file) {
127
+ return file;
128
+ }
129
+ /** `api/<segments>/route.ts`. The folder path is the route. */
130
+ function defineRoute(file) {
131
+ return file;
132
+ }
133
+ /** `method/<member>.ts`. Build the value with `defineServerMethod` to keep schema inference. */
134
+ function defineMethod(file) {
135
+ return file;
136
+ }
137
+ /** A server activity declaration for a session root. */
138
+ function defineActivity(file) {
139
+ return file;
140
+ }
141
+ //#endregion
142
+ export { composeRootHooks, defineActivity, defineChannel, defineCliCommand, defineCliHook, defineCliTool, defineCommand, defineHook, defineMethod, defineMode, defineOverlay, defineProvider, defineResource, defineRoot, defineRoute, defineRoutedContribution, defineServerCommand, defineServerTool, defineService, defineShortcut, defineTool, defineToolRestriction };
143
+
144
+ //# sourceMappingURL=extensionFile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensionFile.mjs","names":[],"sources":["../../src/extensions/extensionFile.ts"],"sourcesContent":["import type { TSchema } from 'typebox';\n\nimport type {\n ActivityFile,\n ChannelFile,\n CliCommandFile,\n CliHookFile,\n CliHookHandler,\n CliToolFile,\n CommandContribution,\n CommandFile,\n HookFile,\n MethodFile,\n OverlayFile,\n RootFile,\n RoutedFileOptions,\n RouteFile,\n ServerCommandFile,\n ServerToolFile,\n ServiceFile,\n ToolContribution,\n ToolFile,\n} from '../schemas/extensionFile';\nimport type { DoomHeadlessEventName } from '../schemas/headless';\nimport type { PluginLifecycleHooks } from '../services/pluginLifecycle';\n\n/**\n * Identity helpers for folder-routed backend files, one per surface.\n *\n * A routed file's default export is its whole contract with the host, and\n * nothing else validates it: the generated entry merges the path's identity in\n * and hands the result to a contribution array, where an excess or misspelled\n * key is invisible. These make the shape checkable at the point it is written,\n * and give the factory form a typed context instead of an implicit any.\n *\n * Most return their argument unchanged, so the value is entirely in the\n * position they check and the inference they supply. The two that do not,\n * `defineTool` and `defineCommand`, add the discriminant the host reads to\n * tell a portable contribution from a raw host declaration.\n */\n\n/** Declares non-default route cardinality while preserving the routed surface's inferred host type. */\nexport function defineRoutedContribution<T>(file: T, _options: RoutedFileOptions): T {\n return file;\n}\n\n/** `provider/<name>.cli.ts`. Declares one Pi provider tuple. */\nexport function defineProvider<T>(file: T): T {\n return file;\n}\n\n/** `resource/<name>.ts`. Declares one package resource. */\nexport function defineResource<T>(file: T): T {\n return file;\n}\n\n/** `shortcut/<name>.cli.ts`. Declares one Pi keyboard shortcut. */\nexport function defineShortcut<T>(file: T): T {\n return file;\n}\n\n/** `tool-restriction/<name>.ts`. Declares one tool restriction. */\nexport function defineToolRestriction<T>(file: T): T {\n return file;\n}\n\n/** Declares one mode when it is not represented by a mode gate file. */\nexport function defineMode<T>(file: T): T {\n return file;\n}\n\n/** `overlay/<name>.cli.ts`. A terminal view opened directly by a command. */\nexport function defineOverlay<T extends OverlayFile>(file: T): T {\n return file;\n}\n/** `tool/<name>.ts`. Adds the discriminant the contribution array expects. */\nexport function defineTool<TContext = unknown>(file: ToolFile<TContext>): ToolContribution<TContext> {\n return typeof file === 'function'\n ? (context) => ({ kind: 'tool' as const, ...file(context) })\n : { kind: 'tool' as const, ...file };\n}\n\n/** `tool/<name>.server.ts`. A native headless tool, handed to the host untouched. */\nexport function defineServerTool<TParameters extends TSchema = TSchema, TContext = unknown>(\n file: ServerToolFile<TParameters, TContext>,\n): ServerToolFile<TParameters, TContext> {\n return file;\n}\n\n/**\n * `root.ts`. Constructs one scope and names what its subtree shares.\n *\n * The answer to a package whose surfaces all read one per-mount object graph.\n * The root builds that graph once, and every routed file beneath it receives\n * it as `context.root`, so the package decomposes into a file per surface\n * without either rebuilding the graph per file or reaching for a module-level\n * singleton.\n */\nexport function defineRoot<TValue, TContext = unknown>(file: RootFile<TValue, TContext>): RootFile<TValue, TContext> {\n return file;\n}\n\n/**\n * Folds every root in a scope chain into one set of lifecycle hooks.\n *\n * Start outermost first and tear down innermost first, which is the order the\n * roots were constructed in and the only order in which an inner scope can\n * still rely on its outer one while stopping.\n */\nexport function composeRootHooks<TContext>(\n ...roots: readonly PluginLifecycleHooks<TContext>[]\n): Required<PluginLifecycleHooks<TContext>> {\n const reversed = [...roots].reverse();\n return {\n async onStart(context) {\n for (const root of roots) await root.onStart?.(context);\n },\n async onStop(context) {\n for (const root of reversed) await root.onStop?.(context);\n },\n async onDispose(context) {\n for (const root of reversed) await root.onDispose?.(context);\n },\n };\n}\n\n/** `tool/<name>.cli.ts`. A native interactive tool, handed to Pi untouched. */\nexport function defineCliTool<TContext = unknown>(file: CliToolFile<TContext>): CliToolFile<TContext> {\n return file;\n}\n\n/** `command/<name>.cli.ts`. A native Pi command or portable Doom command. */\nexport function defineCliCommand<TContext = unknown>(file: CliCommandFile<TContext>): CliCommandFile<TContext> {\n return file;\n}\n\n/** `command/<name>.server.ts`. A native headless or portable Doom command. */\nexport function defineServerCommand<TContext = unknown>(\n file: ServerCommandFile<TContext>,\n): ServerCommandFile<TContext> {\n return file;\n}\n\n/** `command/<name>.ts`. Adds the discriminant the contribution array expects. */\nexport function defineCommand<TContext = unknown>(file: CommandFile<TContext>): CommandContribution<TContext> {\n return typeof file === 'function'\n ? (context) => ({ kind: 'command' as const, ...file(context) })\n : { kind: 'command' as const, ...file };\n}\n\n/** `hook/<event>.cli.ts`. A native Pi event handler factory. */\nexport function defineCliHook<TContext, THandler extends CliHookHandler>(\n file: (context: TContext) => THandler,\n): CliHookFile<TContext, CliHookHandler> {\n return file;\n}\n\n/** `hook/<event>.ts`. Name the event here too when the handler needs a precise payload. */\nexport function defineHook<TEvent extends DoomHeadlessEventName = DoomHeadlessEventName, TContext = unknown>(\n file: HookFile<TEvent, TContext>,\n): HookFile<TEvent, TContext> {\n return file;\n}\n\n/** A Cordis service factory for a scope root. */\nexport function defineService<TContext = unknown>(file: ServiceFile<TContext>): ServiceFile<TContext> {\n return file;\n}\n\n/** `channel/<frameType>.ts`. The contribution array holds factories, so this is one. */\nexport function defineChannel(file: ChannelFile): ChannelFile {\n return file;\n}\n\n/** `api/<segments>/route.ts`. The folder path is the route. */\nexport function defineRoute<TContext = unknown>(file: RouteFile<TContext>): RouteFile<TContext> {\n return file;\n}\n\n/** `method/<member>.ts`. Build the value with `defineServerMethod` to keep schema inference. */\nexport function defineMethod<TContext = unknown>(file: MethodFile<TContext>): MethodFile<TContext> {\n return file;\n}\n\n/** A server activity declaration for a session root. */\nexport function defineActivity<TContext = unknown>(file: ActivityFile<TContext>): ActivityFile<TContext> {\n return file;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,SAAgB,yBAA4B,MAAS,UAAgC;CACnF,OAAO;AACT;;AAGA,SAA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gB,WACd,MAC4B;CAC5B,OAAO;AACT;;AAGA,SAAgB,cAAkC,MAAoD;CACpG,OAAO;AACT;;AAGA,SAAgB,cAAc,MAAgC;CAC5D,OAAO;AACT;;AAGA,SAAgB,YAAgC,MAAgD;CAC9F,OAAO;AACT;;AAGA,SAAgB,aAAiC,MAAkD;CACjG,OAAO;AACT;;AAGA,SAAgB,eAAmC,MAAsD;CACvG,OAAO;AACT"}
@@ -55,7 +55,7 @@ function defineServerPlugin(plugin) {
55
55
  const unsubscribe = restriction.subscribe?.(refresh);
56
56
  if (unsubscribe) lifecycle.own(unsubscribe);
57
57
  }
58
- for (const resource of session.resources ?? []) own(agent.registerResource(resource));
58
+ for (const resource of session.resources ?? []) if (resource !== void 0) own(agent.registerResource(resource));
59
59
  for (const tool of session.tools ?? []) if ("kind" in tool) own(agent.registerTool({
60
60
  ...tool,
61
61
  async execute(toolCallId, input, signal, update, execution) {
@@ -1 +1 @@
1
- {"version":3,"file":"serverPlugin.cjs","names":["DOOM_SERVER_HOST_SERVICE","requireDoomServerHost","readDoomHeadlessHost","createPluginLifecycle"],"sources":["../../src/extensions/serverPlugin.ts"],"sourcesContent":["import { readDoomHeadlessHost } from '../schemas/headless';\nimport {\n DOOM_SERVER_HOST_SERVICE,\n requireDoomServerHost,\n type DoomServerFacet,\n type DoomServerPluginDefinition,\n type DoomServerPluginContext,\n type DoomServerSessionPlugin,\n} from '../schemas/serverFacet';\nimport { createPluginLifecycle } from '../services/pluginLifecycle';\n\nexport function defineServerPlugin(plugin: DoomServerPluginDefinition): DoomServerFacet {\n return {\n inject: [...new Set([DOOM_SERVER_HOST_SERVICE, ...(plugin.inject ?? [])])],\n async apply(context) {\n const host = requireDoomServerHost(context);\n const declaration = plugin[host.scope];\n if (!declaration) return;\n const agent = host.scope === 'session' ? readDoomHeadlessHost(context) : undefined;\n const lifecycle = createPluginLifecycle<DoomServerPluginContext>((signal) => ({ context, host, agent, signal }));\n context.effect(() => () => lifecycle.dispose());\n const own = <T extends { dispose(): void | Promise<void>; mounted?: boolean }>(registration: T): void => {\n lifecycle.own(() => registration.dispose());\n if ('mounted' in registration && registration.mounted === false)\n throw new Error('Server plugin registration was refused.');\n };\n await lifecycle.mount(\n () => (typeof declaration === 'function' ? declaration(lifecycle.context) : declaration),\n async (scope) => {\n for (const service of scope.services ?? []) {\n const fiber = context.plugin(service);\n lifecycle.own(() => fiber.dispose());\n await fiber;\n }\n for (const channel of scope.channels ?? []) own(host.registerChannel(channel()));\n for (const api of scope.api ?? []) own(host.registerApi(api));\n for (const method of scope.methods ?? []) own(method.register(host));\n if (!agent) return;\n const session: DoomServerSessionPlugin = scope;\n for (const restriction of session.toolRestrictions ?? []) {\n if (!('restrict' in restriction)) {\n own(agent.registerToolRestriction(restriction));\n continue;\n }\n let registration: ReturnType<typeof agent.registerToolRestriction> | undefined;\n lifecycle.own(() => {\n const current = registration;\n registration = undefined;\n return current?.dispose();\n });\n const refresh = (): void => {\n if (lifecycle.context.signal.aborted) return;\n const previous = registration;\n registration = undefined;\n previous?.dispose();\n registration = agent.registerToolRestriction(restriction.restrict());\n if ('mounted' in registration && registration.mounted === false)\n throw new Error(`Server tool restriction ${restriction.source} was refused.`);\n };\n refresh();\n const unsubscribe = restriction.subscribe?.(refresh);\n if (unsubscribe) lifecycle.own(unsubscribe);\n }\n for (const resource of session.resources ?? []) own(agent.registerResource(resource));\n for (const tool of session.tools ?? []) {\n if ('kind' in tool) {\n own(\n agent.registerTool({\n ...tool,\n async execute(toolCallId, input, signal, update, execution) {\n const invocationSignal = signal\n ? AbortSignal.any([signal, lifecycle.context.signal])\n : lifecycle.context.signal;\n invocationSignal.throwIfAborted();\n try {\n return await tool.execute(input, {\n toolCallId,\n signal: invocationSignal,\n cwd: execution.cwd,\n update: (result) => update?.(result),\n notify: (request) => execution.client.notify(request),\n });\n } catch (error) {\n return {\n content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }],\n isError: true,\n };\n }\n },\n }),\n );\n } else own(agent.registerTool(tool));\n }\n for (const command of session.commands ?? []) {\n if ('kind' in command) {\n own(\n agent.registerCommand({\n ...command,\n execute: (args, execution) => {\n lifecycle.context.signal.throwIfAborted();\n return command.execute(args, {\n cwd: execution.cwd,\n signal: lifecycle.context.signal,\n notify: (request) => execution.client.notify(request),\n });\n },\n }),\n );\n } else own(agent.registerCommand(command));\n }\n for (const hook of session.hooks ?? []) own(agent.registerHook(hook));\n for (const activity of session.activities ?? []) own(agent.registerActivity(activity));\n },\n );\n return () => lifecycle.dispose();\n },\n };\n}\n"],"mappings":";;;;AAWA,SAAgB,mBAAmB,QAAqD;CACtF,OAAO;EACL,QAAQ,CAAC,mBAAG,IAAI,IAAI,CAACA,oBAAAA,0BAA0B,GAAI,OAAO,UAAU,CAAC,CAAE,CAAC,CAAC;EACzE,MAAM,MAAM,SAAS;GACnB,MAAM,OAAOC,oBAAAA,sBAAsB,OAAO;GAC1C,MAAM,cAAc,OAAO,KAAK;GAChC,IAAI,CAAC,aAAa;GAClB,MAAM,QAAQ,KAAK,UAAU,YAAYC,iBAAAA,qBAAqB,OAAO,IAAI,KAAA;GACzE,MAAM,YAAYC,cAAAA,uBAAgD,YAAY;IAAE;IAAS;IAAM;IAAO;GAAO,EAAE;GAC/G,QAAQ,mBAAmB,UAAU,QAAQ,CAAC;GAC9C,MAAM,OAAyE,iBAA0B;IACvG,UAAU,UAAU,aAAa,QAAQ,CAAC;IAC1C,IAAI,aAAa,gBAAgB,aAAa,YAAY,OACxD,MAAM,IAAI,MAAM,yCAAyC;GAC7D;GACA,MAAM,UAAU,YACP,OAAO,gBAAgB,aAAa,YAAY,UAAU,OAAO,IAAI,aAC5E,OAAO,UAAU;IACf,KAAK,MAAM,WAAW,MAAM,YAAY,CAAC,GAAG;KAC1C,MAAM,QAAQ,QAAQ,OAAO,OAAO;KACpC,UAAU,UAAU,MAAM,QAAQ,CAAC;KACnC,MAAM;IACR;IACA,KAAK,MAAM,WAAW,MAAM,YAAY,CAAC,GAAG,IAAI,KAAK,g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AAU;QACf,SAAS,WAAW,SAAS,MAAM;QACnC,SAAS,YAAY,UAAU,OAAO,OAAO,OAAO;OACtD,CAAC;MACH,SAAS,OAAO;OACd,OAAO;QACL,SAAS,CAAC;SAAE,MAAM;SAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;QAAE,CAAC;QACxF,SAAS;OACX;MACF;KACF;IACF,CAAC,CACH;SACK,IAAI,MAAM,aAAa,IAAI,CAAC;IAErC,KAAK,MAAM,WAAW,QAAQ,YAAY,CAAC,GACzC,IAAI,UAAU,SACZ,IACE,MAAM,gBAAgB;KACpB,GAAG;KACH,UAAU,MAAM,cAAc;MAC5B,UAAU,QAAQ,OAAO,eAAe;MACxC,OAAO,QAAQ,QAAQ,MAAM;OAC3B,KAAK,UAAU;OACf,QAAQ,UAAU,QAAQ;OAC1B,SAAS,YAAY,UAAU,OAAO,OAAO,OAAO;MACtD,CAAC;KACH;IACF,CAAC,CACH;SACK,IAAI,MAAM,gBAAgB,OAAO,CAAC;IAE3C,KAAK,MAAM,QAAQ,QAAQ,SAAS,CAAC,GAAG,IAAI,MAAM,aAAa,IAAI,CAAC;IACpE,KAAK,MAAM,YAAY,QAAQ,cAAc,CAAC,GAAG,IAAI,MAAM,iBAAiB,QAAQ,CAAC;GACvF,CACF;GACA,aAAa,UAAU,QAAQ;EACjC;CACF;AACF"}
1
+ {"version":3,"file":"serverPlugin.cjs","names":["DOOM_SERVER_HOST_SERVICE","requireDoomServerHost","readDoomHeadlessHost","createPluginLifecycle"],"sources":["../../src/extensions/serverPlugin.ts"],"sourcesContent":["import { readDoomHeadlessHost } from '../schemas/headless';\nimport {\n DOOM_SERVER_HOST_SERVICE,\n requireDoomServerHost,\n type DoomServerFacet,\n type DoomServerPluginDefinition,\n type DoomServerPluginContext,\n type DoomServerSessionPlugin,\n} from '../schemas/serverFacet';\nimport { createPluginLifecycle } from '../services/pluginLifecycle';\n\nexport function defineServerPlugin(plugin: DoomServerPluginDefinition): DoomServerFacet {\n return {\n inject: [...new Set([DOOM_SERVER_HOST_SERVICE, ...(plugin.inject ?? [])])],\n async apply(context) {\n const host = requireDoomServerHost(context);\n const declaration = plugin[host.scope];\n if (!declaration) return;\n const agent = host.scope === 'session' ? readDoomHeadlessHost(context) : undefined;\n const lifecycle = createPluginLifecycle<DoomServerPluginContext>((signal) => ({ context, host, agent, signal }));\n context.effect(() => () => lifecycle.dispose());\n const own = <T extends { dispose(): void | Promise<void>; mounted?: boolean }>(registration: T): void => {\n lifecycle.own(() => registration.dispose());\n if ('mounted' in registration && registration.mounted === false)\n throw new Error('Server plugin registration was refused.');\n };\n await lifecycle.mount(\n () => (typeof declaration === 'function' ? declaration(lifecycle.context) : declaration),\n async (scope) => {\n for (const service of scope.services ?? []) {\n const fiber = context.plugin(service);\n lifecycle.own(() => fiber.dispose());\n await fiber;\n }\n for (const channel of scope.channels ?? []) own(host.registerChannel(channel()));\n for (const api of scope.api ?? []) own(host.registerApi(api));\n for (const method of scope.methods ?? []) own(method.register(host));\n if (!agent) return;\n const session: DoomServerSessionPlugin = scope;\n for (const restriction of session.toolRestrictions ?? []) {\n if (!('restrict' in restriction)) {\n own(agent.registerToolRestriction(restriction));\n continue;\n }\n let registration: ReturnType<typeof agent.registerToolRestriction> | undefined;\n lifecycle.own(() => {\n const current = registration;\n registration = undefined;\n return current?.dispose();\n });\n const refresh = (): void => {\n if (lifecycle.context.signal.aborted) return;\n const previous = registration;\n registration = undefined;\n previous?.dispose();\n registration = agent.registerToolRestriction(restriction.restrict());\n if ('mounted' in registration && registration.mounted === false)\n throw new Error(`Server tool restriction ${restriction.source} was refused.`);\n };\n refresh();\n const unsubscribe = restriction.subscribe?.(refresh);\n if (unsubscribe) lifecycle.own(unsubscribe);\n }\n for (const resource of session.resources ?? []) {\n // Generated optional and many-valued contributions can leave an undefined\n // member when a package has no resource for the current runtime.\n if (resource !== undefined) own(agent.registerResource(resource));\n }\n for (const tool of session.tools ?? []) {\n if ('kind' in tool) {\n own(\n agent.registerTool({\n ...tool,\n async execute(toolCallId, input, signal, update, execution) {\n const invocationSignal = signal\n ? AbortSignal.any([signal, lifecycle.context.signal])\n : lifecycle.context.signal;\n invocationSignal.throwIfAborted();\n try {\n return await tool.execute(input, {\n toolCallId,\n signal: invocationSignal,\n cwd: execution.cwd,\n update: (result) => update?.(result),\n notify: (request) => execution.client.notify(request),\n });\n } catch (error) {\n return {\n content: [{ type: 'text', text: error instanceof Error ? error.message : String(error) }],\n isError: true,\n };\n }\n },\n }),\n );\n } else own(agent.registerTool(tool));\n }\n for (const command of session.commands ?? []) {\n if ('kind' in command) {\n own(\n agent.registerCommand({\n ...command,\n execute: (args, execution) => {\n lifecycle.context.signal.throwIfAborted();\n return command.execute(args, {\n cwd: execution.cwd,\n signal: lifecycle.context.signal,\n notify: (request) => execution.client.notify(request),\n });\n },\n }),\n );\n } else own(agent.registerCommand(command));\n }\n for (const hook of session.hooks ?? []) own(agent.registerHook(hook));\n for (const activity of session.activities ?? []) own(agent.registerActivity(activity));\n },\n );\n return () => lifecycle.dispose();\n },\n };\n}\n"],"mappings":";;;;AAWA,SAAgB,mBAAmB,QAAqD;CACtF,OAAO;EACL,QAAQ,CAAC,mBAAG,IAAI,IAAI,CAACA,oBAAAA,0BAA0B,GAAI,OAAO,UAAU,CAAC,CAAE,CAAC,CAAC;EACzE,MAAM,MAAM,SAAS;GACnB,MAAM,OAAOC,oBAAAA,sBAAsB,OAAO;GAC1C,MAAM,cAAc,OAAO,KAAK;GAChC,IAAI,CAAC,aAAa;GAClB,MAAM,QAAQ,KAAK,UAAU,YAAYC,iBAAAA,qBAAqB,OAAO,IAAI,KAAA;GACzE,MAAM,YAAYC,cAAAA,uBAAgD,YAAY;IAAE;IAAS;IAAM;IAAO;GAAO,EAAE;GAC/G,QAAQ,mBAAmB,UAAU,QAAQ,CAAC;GAC9C,MAAM,OAAyE,iBAA0B;IACvG,UAAU,UAAU,aAAa,QAAQ,CAAC;IAC1C,IAAI,aAAa,gBAAgB,aAA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erPlugin(plugin) {
55
55
  const unsubscribe = restriction.subscribe?.(refresh);
56
56
  if (unsubscribe) lifecycle.own(unsubscribe);
57
57
  }
58
- for (const resource of session.resources ?? []) own(agent.registerResource(resource));
58
+ for (const resource of session.resources ?? []) if (resource !== void 0) own(agent.registerResource(resource));
59
59
  for (const tool of session.tools ?? []) if ("kind" in tool) own(agent.registerTool({
60
60
  ...tool,
61
61
  async execute(toolCallId, input, signal, update, execution) {