@caplets/core 0.18.8 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/attach/options.d.ts +10 -0
  2. package/dist/attach/server.d.ts +5 -0
  3. package/dist/caplet-files-bundle.d.ts +415 -0
  4. package/dist/caplet-files.d.ts +3 -266
  5. package/dist/caplet-source/bundle.d.ts +7 -0
  6. package/dist/caplet-source/filesystem.d.ts +7 -0
  7. package/dist/caplet-source/filesystem.js +2 -0
  8. package/dist/caplet-source/index.d.ts +4 -0
  9. package/dist/caplet-source/parse.d.ts +35 -0
  10. package/dist/caplet-source/types.d.ts +9 -0
  11. package/dist/caplet-source.js +11231 -0
  12. package/dist/cli/commands.d.ts +9 -2
  13. package/dist/cli/doctor.d.ts +18 -0
  14. package/dist/cli/setup-caplet.d.ts +12 -0
  15. package/dist/cli/setup.d.ts +23 -0
  16. package/dist/cli.d.ts +9 -1
  17. package/dist/cloud/apply.d.ts +36 -0
  18. package/dist/cloud/client.d.ts +30 -0
  19. package/dist/cloud/presence.d.ts +29 -0
  20. package/dist/cloud/project-root.d.ts +2 -0
  21. package/dist/cloud/runtime-adapter.d.ts +23 -0
  22. package/dist/cloud/runtime-http.d.ts +6 -0
  23. package/dist/cloud/sync.d.ts +10 -0
  24. package/dist/cloud-auth/client.d.ts +42 -0
  25. package/dist/cloud-auth/errors.d.ts +11 -0
  26. package/dist/cloud-auth/open-url.d.ts +7 -0
  27. package/dist/cloud-auth/store.d.ts +35 -0
  28. package/dist/cloud-auth/types.d.ts +66 -0
  29. package/dist/{completion-DvWQk5qR.js → completion-brgziz4L.js} +32 -6
  30. package/dist/config-runtime.d.ts +174 -0
  31. package/dist/config-runtime.js +392 -0
  32. package/dist/config.d.ts +42 -0
  33. package/dist/filesystem-Kkg32TOJ.js +66 -0
  34. package/dist/generated-tool-input-schema.d.ts +9 -9
  35. package/dist/generated-tool-input-schema.js +161 -1
  36. package/dist/index.d.ts +35 -0
  37. package/dist/index.js +6132 -3196
  38. package/dist/native/options.d.ts +22 -3
  39. package/dist/native/remote.d.ts +2 -1
  40. package/dist/native/service.d.ts +7 -3
  41. package/dist/native.js +2 -430
  42. package/dist/project-binding/attach.d.ts +46 -0
  43. package/dist/project-binding/errors.d.ts +17 -0
  44. package/dist/project-binding/gitignore.d.ts +5 -0
  45. package/dist/project-binding/mutagen.d.ts +65 -0
  46. package/dist/project-binding/routes.d.ts +9 -0
  47. package/dist/project-binding/session.d.ts +82 -0
  48. package/dist/project-binding/sync-filter.d.ts +19 -0
  49. package/dist/project-binding/sync-size.d.ts +27 -0
  50. package/dist/project-binding/transport.d.ts +21 -0
  51. package/dist/project-binding/types.d.ts +31 -0
  52. package/dist/project-binding/workspaces.d.ts +60 -0
  53. package/dist/remote/options.d.ts +42 -0
  54. package/dist/remote/selection.d.ts +26 -0
  55. package/dist/remote-control/types.d.ts +1 -1
  56. package/dist/runtime-plan/features.d.ts +7 -0
  57. package/dist/runtime-plan/index.d.ts +4 -0
  58. package/dist/runtime-plan/planner.d.ts +5 -0
  59. package/dist/runtime-plan/resources.d.ts +11 -0
  60. package/dist/runtime-plan/types.d.ts +82 -0
  61. package/dist/runtime-plan.js +275 -0
  62. package/dist/{generated-tool-input-schema-MbYF5jMW.js → schemas-BZ6BBrh7.js} +1 -161
  63. package/dist/serve/daemon/config.d.ts +8 -0
  64. package/dist/serve/daemon/index.d.ts +16 -0
  65. package/dist/serve/daemon/paths.d.ts +3 -0
  66. package/dist/serve/daemon/platform-darwin.d.ts +2 -0
  67. package/dist/serve/daemon/platform-linux.d.ts +2 -0
  68. package/dist/serve/daemon/platform-windows.d.ts +2 -0
  69. package/dist/serve/daemon/platform.d.ts +9 -0
  70. package/dist/serve/daemon/process.d.ts +5 -0
  71. package/dist/serve/daemon/types.d.ts +86 -0
  72. package/dist/serve/http.d.ts +8 -0
  73. package/dist/serve/index.d.ts +5 -1
  74. package/dist/serve/native-session.d.ts +19 -0
  75. package/dist/serve/options.d.ts +1 -0
  76. package/dist/server/options.d.ts +1 -1
  77. package/dist/{options--RoZwWjs.js → service-BXcE4Rv8.js} +9932 -2218
  78. package/dist/setup/hash.d.ts +3 -0
  79. package/dist/setup/local-store.d.ts +34 -0
  80. package/dist/setup/runner.d.ts +40 -0
  81. package/dist/setup/types.d.ts +52 -0
  82. package/dist/tools.d.ts +17 -2
  83. package/dist/validation-BBG4skZf.js +153 -0
  84. package/package.json +21 -5
@@ -0,0 +1,275 @@
1
+ //#region src/runtime-plan/types.ts
2
+ const HIDDEN_REASON_CODES = [
3
+ "setup_required",
4
+ "setup_running",
5
+ "setup_failed",
6
+ "verify_failed",
7
+ "backend_auth_required",
8
+ "backend_check_failed",
9
+ "project_binding_required",
10
+ "project_binding_syncing",
11
+ "project_binding_blocked",
12
+ "project_binding_stale",
13
+ "provider_unavailable",
14
+ "provider_capacity_exhausted",
15
+ "provider_queue_timeout",
16
+ "policy_denied",
17
+ "billing_required",
18
+ "subscription_past_due",
19
+ "usage_limit_reached",
20
+ "email_verification_required",
21
+ "docker_required",
22
+ "docker_denied",
23
+ "browser_required",
24
+ "browser_denied",
25
+ "resource_class_denied",
26
+ "local_only",
27
+ "invalid_bundle",
28
+ "unsupported_backend"
29
+ ];
30
+ //#endregion
31
+ //#region src/runtime-plan/features.ts
32
+ function inferRuntimeFeatures(caplet) {
33
+ const provenance = [];
34
+ for (const feature of explicitFeatures(caplet)) provenance.push({
35
+ feature,
36
+ source: "explicit",
37
+ matched: "runtime.features"
38
+ });
39
+ for (const command of commandRecords(caplet)) {
40
+ const text = [command.command, ...command.args].join(" ");
41
+ const dockerMatch = matchDocker(command.command, command.args);
42
+ if (dockerMatch) provenance.push({
43
+ feature: "docker",
44
+ source: command.source,
45
+ matched: dockerMatch,
46
+ command: text
47
+ });
48
+ const browserMatch = matchBrowser(command.command, command.args);
49
+ if (browserMatch) provenance.push({
50
+ feature: "browser",
51
+ source: command.source,
52
+ matched: browserMatch,
53
+ command: text
54
+ });
55
+ }
56
+ return {
57
+ features: orderedFeatures([...new Set(provenance.map((entry) => entry.feature))]),
58
+ provenance
59
+ };
60
+ }
61
+ function explicitFeatures(caplet) {
62
+ const runtime = caplet.runtime;
63
+ if (!runtime || typeof runtime !== "object" || Array.isArray(runtime)) return [];
64
+ const features = runtime.features;
65
+ return Array.isArray(features) ? features.filter((feature) => feature === "docker" || feature === "browser") : [];
66
+ }
67
+ function commandRecords(caplet) {
68
+ return [
69
+ ...setupCommands(caplet.setup, "setup.commands"),
70
+ ...setupCommands(caplet.setup, "setup.verify", true),
71
+ ...mcpCommands(caplet),
72
+ ...cliCommands(caplet)
73
+ ];
74
+ }
75
+ function setupCommands(setup, source, verify = false) {
76
+ if (!setup || typeof setup !== "object" || Array.isArray(setup)) return [];
77
+ const values = setup[verify ? "verify" : "commands"];
78
+ if (!Array.isArray(values)) return [];
79
+ return values.flatMap((value) => commandRecordFrom(value, source));
80
+ }
81
+ function mcpCommands(caplet) {
82
+ if (caplet.backend !== "mcp" || typeof caplet.command !== "string") return [];
83
+ return [{
84
+ source: "mcp.command",
85
+ command: caplet.command,
86
+ args: stringArray(caplet.args)
87
+ }];
88
+ }
89
+ function cliCommands(caplet) {
90
+ if (caplet.backend !== "cli") return [];
91
+ const records = [];
92
+ if (typeof caplet.command === "string") records.push({
93
+ source: "cli.command",
94
+ command: caplet.command,
95
+ args: stringArray(caplet.args)
96
+ });
97
+ const actions = caplet.actions;
98
+ if (actions && typeof actions === "object" && !Array.isArray(actions)) for (const action of Object.values(actions)) records.push(...commandRecordFrom(action, "cli.action"));
99
+ return records;
100
+ }
101
+ function commandRecordFrom(value, source) {
102
+ if (!value || typeof value !== "object" || Array.isArray(value)) return [];
103
+ const command = value.command;
104
+ if (typeof command !== "string") return [];
105
+ return [{
106
+ source,
107
+ command,
108
+ args: stringArray(value.args)
109
+ }];
110
+ }
111
+ function stringArray(value) {
112
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
113
+ }
114
+ function matchDocker(command, args) {
115
+ const text = [command, ...args].join(" ").toLowerCase();
116
+ if (text.includes("docker-mcp")) return "docker-mcp";
117
+ if (/\bdocker(?:-compose)?\b/u.test(text)) return command === "docker" ? command : text;
118
+ return text.includes("docker mcp") ? "docker mcp" : void 0;
119
+ }
120
+ function matchBrowser(command, args) {
121
+ const text = [command, ...args].join(" ").toLowerCase();
122
+ if (text.includes("@playwright/mcp")) return "@playwright/mcp";
123
+ if (text.includes("playwright install")) return "playwright install";
124
+ if (text.includes("playwright")) return "playwright";
125
+ if (text.includes("browser-use")) return "browser-use";
126
+ if (text.includes("puppeteer")) return "puppeteer";
127
+ if (text.includes("chromium")) return "chromium";
128
+ return /\bchrome\b/u.test(text) ? "chrome" : void 0;
129
+ }
130
+ function orderedFeatures(features) {
131
+ return ["docker", "browser"].filter((feature) => features.includes(feature));
132
+ }
133
+ //#endregion
134
+ //#region src/runtime-plan/resources.ts
135
+ const defaults = {
136
+ small: {
137
+ class: "small",
138
+ cpu: 1,
139
+ memoryMb: 1024,
140
+ diskMb: 4096
141
+ },
142
+ medium: {
143
+ class: "medium",
144
+ cpu: 2,
145
+ memoryMb: 4096,
146
+ diskMb: 8192
147
+ },
148
+ standard: {
149
+ class: "standard",
150
+ cpu: 2,
151
+ memoryMb: 4096,
152
+ diskMb: 8192
153
+ },
154
+ large: {
155
+ class: "large",
156
+ cpu: 4,
157
+ memoryMb: 8192,
158
+ diskMb: 20480
159
+ },
160
+ heavy: {
161
+ class: "heavy",
162
+ cpu: 8,
163
+ memoryMb: 16384,
164
+ diskMb: 40960
165
+ }
166
+ };
167
+ const rank = {
168
+ small: 0,
169
+ standard: 1,
170
+ medium: 1,
171
+ large: 2,
172
+ heavy: 3
173
+ };
174
+ function resolveRuntimeResources(inputOrCaplet, features, policy) {
175
+ const caplet = inputOrCaplet;
176
+ const input = features === void 0 ? inputOrCaplet : {
177
+ backend: typeof caplet.backend === "string" ? caplet.backend : void 0,
178
+ features,
179
+ explicitClass: explicitResourceClass$1(caplet),
180
+ setupRequired: Boolean(caplet.setup),
181
+ policy
182
+ };
183
+ const requested = input.explicitClass ?? defaultResourceClass(input);
184
+ const capped = capClass(requested, input.policy?.maxClass);
185
+ return {
186
+ ...defaults[capped] ?? defaults.standard,
187
+ ...requested !== capped ? { cappedByPolicy: input.policy?.maxClass } : {}
188
+ };
189
+ }
190
+ function defaultResourceClass(input) {
191
+ const hasDocker = input.features.includes("docker");
192
+ const hasBrowser = input.features.includes("browser");
193
+ if (hasDocker && hasBrowser) return "heavy";
194
+ if (hasDocker || hasBrowser) return "large";
195
+ if (input.backend === "cli" || input.backend === "mcp" || input.setupRequired) return "medium";
196
+ return "small";
197
+ }
198
+ function explicitResourceClass$1(caplet) {
199
+ const runtime = caplet.runtime;
200
+ if (!runtime || typeof runtime !== "object" || Array.isArray(runtime)) return void 0;
201
+ const resources = runtime.resources;
202
+ if (!resources || typeof resources !== "object" || Array.isArray(resources)) return void 0;
203
+ const value = resources.class;
204
+ return typeof value === "string" ? value : void 0;
205
+ }
206
+ function capClass(requested, maxClass) {
207
+ if (!maxClass) return requested;
208
+ return (rank[requested] ?? 0) > (rank[maxClass] ?? 0) ? maxClass : requested;
209
+ }
210
+ //#endregion
211
+ //#region src/runtime-plan/planner.ts
212
+ function planCapletRuntimeRoutes(caplets, options = {}) {
213
+ return caplets.map((caplet) => planSingleCaplet(caplet, options));
214
+ }
215
+ function planCapletRuntimeRoute(caplet, options = {}) {
216
+ return planCapletRuntimeRoutes([caplet], options)[0] ?? planSingleCaplet(caplet, options);
217
+ }
218
+ function planSingleCaplet(caplet, options) {
219
+ const route = classifyCapletRuntimeRoute(caplet);
220
+ const setupRequired = Boolean(caplet.setup);
221
+ const projectBindingRequired = projectBindingRequiredFor(caplet);
222
+ const features = inferRuntimeFeatures(caplet);
223
+ const runtime = {
224
+ features: features.features,
225
+ featureProvenance: features.provenance,
226
+ resources: resolveRuntimeResources({
227
+ backend: typeof caplet.backend === "string" ? caplet.backend : void 0,
228
+ features: features.features,
229
+ explicitClass: explicitResourceClass(caplet),
230
+ policy: options.resourcePolicy,
231
+ setupRequired
232
+ })
233
+ };
234
+ return {
235
+ id: String(caplet.server ?? ""),
236
+ backend: typeof caplet.backend === "string" ? caplet.backend : "unknown",
237
+ route,
238
+ setupRequired,
239
+ authRequired: authRequired("auth" in caplet ? caplet.auth : void 0),
240
+ ...route === "process" || route === "project_bound_process" ? { setupTarget: setupTargetFor(options.deployment) } : {},
241
+ projectBindingRequired,
242
+ runtime,
243
+ caplet
244
+ };
245
+ }
246
+ function classifyCapletRuntimeRoute(caplet) {
247
+ if (projectBindingRequiredFor(caplet)) return "project_bound_process";
248
+ if (caplet.setup) return "process";
249
+ if (caplet.backend === "cli") return "process";
250
+ if (caplet.backend === "mcp") return caplet.transport === "stdio" || Boolean(caplet.command) ? "process" : "worker_safe";
251
+ if (caplet.backend === "openapi" || caplet.backend === "graphql" || caplet.backend === "http") return "worker_safe";
252
+ if (caplet.backend === "caplets") return "worker_safe";
253
+ return "local_only";
254
+ }
255
+ function setupTargetFor(deployment) {
256
+ if (deployment === "local") return "local_host";
257
+ return deployment === "self_hosted" ? "remote_host" : "hosted_sandbox";
258
+ }
259
+ function authRequired(auth) {
260
+ return auth !== null && typeof auth === "object" && "type" in auth && auth.type !== "none";
261
+ }
262
+ function projectBindingRequiredFor(caplet) {
263
+ const projectBinding = caplet.projectBinding;
264
+ return Boolean(projectBinding) && typeof projectBinding === "object" && !Array.isArray(projectBinding) && projectBinding.required === true;
265
+ }
266
+ function explicitResourceClass(caplet) {
267
+ const runtime = caplet.runtime;
268
+ if (!runtime || typeof runtime !== "object" || Array.isArray(runtime)) return void 0;
269
+ const resources = runtime.resources;
270
+ if (!resources || typeof resources !== "object" || Array.isArray(resources)) return void 0;
271
+ const value = resources.class;
272
+ return value === "small" || value === "medium" || value === "standard" || value === "large" || value === "heavy" ? value : void 0;
273
+ }
274
+ //#endregion
275
+ export { HIDDEN_REASON_CODES, classifyCapletRuntimeRoute, inferRuntimeFeatures, planCapletRuntimeRoute, planCapletRuntimeRoutes, resolveRuntimeResources };
@@ -4557,164 +4557,4 @@ function preprocess(fn, schema) {
4557
4557
  });
4558
4558
  }
4559
4559
  //#endregion
4560
- //#region src/generated-tool-input-schema.ts
4561
- const operations = [
4562
- "get_caplet",
4563
- "check_backend",
4564
- "list_tools",
4565
- "search_tools",
4566
- "get_tool",
4567
- "call_tool"
4568
- ];
4569
- const mcpOperations = [
4570
- ...operations,
4571
- "list_resources",
4572
- "search_resources",
4573
- "list_resource_templates",
4574
- "read_resource",
4575
- "list_prompts",
4576
- "search_prompts",
4577
- "get_prompt",
4578
- "complete"
4579
- ];
4580
- const generatedToolInputDescriptions = {
4581
- operation: "Wrapper operation: get_caplet, check_backend, list_tools, search_tools, get_tool, call_tool. MCP Caplets also expose resources, prompts, and completions.",
4582
- query: "Required for search operations only.",
4583
- limit: "Optional list/search result limit.",
4584
- tool: "Exact downstream tool name for get_tool or call_tool.",
4585
- arguments: "JSON object for call_tool arguments/downstream inputs or get_prompt arguments.",
4586
- fields: "Optional call_tool structured output paths when outputSchema allows it.",
4587
- uri: "Exact downstream resource URI for read_resource.",
4588
- prompt: "Exact downstream prompt name for get_prompt.",
4589
- ref: "Completion target reference for complete.",
4590
- argument: "Completion argument object for complete."
4591
- };
4592
- const completionRefSchema = union([object({
4593
- type: literal("prompt"),
4594
- name: string().min(1)
4595
- }).strict(), object({
4596
- type: literal("resourceTemplate"),
4597
- uri: string().min(1)
4598
- }).strict()]);
4599
- const completionArgumentSchema = object({
4600
- name: string().min(1),
4601
- value: string()
4602
- }).strict();
4603
- const baseShape = {
4604
- query: string().optional().describe(generatedToolInputDescriptions.query),
4605
- limit: number().int().positive().optional().describe(generatedToolInputDescriptions.limit),
4606
- tool: string().optional().describe(generatedToolInputDescriptions.tool),
4607
- arguments: object({}).catchall(any()).optional().describe(generatedToolInputDescriptions.arguments),
4608
- fields: array(string().min(1)).min(1).optional().describe(generatedToolInputDescriptions.fields)
4609
- };
4610
- function generatedToolInputSchemaForCaplet(caplet) {
4611
- return object({
4612
- operation: (caplet.backend === "mcp" ? _enum(mcpOperations) : _enum(operations)).describe(generatedToolInputDescriptions.operation),
4613
- ...baseShape,
4614
- ...caplet.backend === "mcp" ? {
4615
- uri: string().optional().describe(generatedToolInputDescriptions.uri),
4616
- prompt: string().optional().describe(generatedToolInputDescriptions.prompt),
4617
- ref: completionRefSchema.optional().describe(generatedToolInputDescriptions.ref),
4618
- argument: completionArgumentSchema.optional().describe(generatedToolInputDescriptions.argument)
4619
- } : {}
4620
- }).strict();
4621
- }
4622
- const generatedToolInputSchema = object({
4623
- operation: _enum(operations).describe(generatedToolInputDescriptions.operation),
4624
- ...baseShape
4625
- }).strict();
4626
- function generatedToolInputJsonSchemaForCaplet(caplet) {
4627
- const mcp = caplet.backend === "mcp";
4628
- return {
4629
- type: "object",
4630
- properties: {
4631
- operation: {
4632
- type: "string",
4633
- enum: mcp ? mcpOperations : operations,
4634
- description: generatedToolInputDescriptions.operation
4635
- },
4636
- query: {
4637
- type: "string",
4638
- description: generatedToolInputDescriptions.query
4639
- },
4640
- limit: {
4641
- type: "integer",
4642
- minimum: 1,
4643
- description: generatedToolInputDescriptions.limit
4644
- },
4645
- tool: {
4646
- type: "string",
4647
- description: generatedToolInputDescriptions.tool
4648
- },
4649
- arguments: {
4650
- type: "object",
4651
- description: generatedToolInputDescriptions.arguments
4652
- },
4653
- fields: {
4654
- type: "array",
4655
- items: {
4656
- type: "string",
4657
- minLength: 1
4658
- },
4659
- minItems: 1,
4660
- description: generatedToolInputDescriptions.fields
4661
- },
4662
- ...mcp ? {
4663
- uri: {
4664
- type: "string",
4665
- description: generatedToolInputDescriptions.uri
4666
- },
4667
- prompt: {
4668
- type: "string",
4669
- description: generatedToolInputDescriptions.prompt
4670
- },
4671
- ref: {
4672
- oneOf: [{
4673
- type: "object",
4674
- properties: {
4675
- type: { const: "prompt" },
4676
- name: {
4677
- type: "string",
4678
- minLength: 1
4679
- }
4680
- },
4681
- required: ["type", "name"],
4682
- additionalProperties: false
4683
- }, {
4684
- type: "object",
4685
- properties: {
4686
- type: { const: "resourceTemplate" },
4687
- uri: {
4688
- type: "string",
4689
- minLength: 1
4690
- }
4691
- },
4692
- required: ["type", "uri"],
4693
- additionalProperties: false
4694
- }],
4695
- description: generatedToolInputDescriptions.ref
4696
- },
4697
- argument: {
4698
- type: "object",
4699
- properties: {
4700
- name: {
4701
- type: "string",
4702
- minLength: 1
4703
- },
4704
- value: { type: "string" }
4705
- },
4706
- required: ["name", "value"],
4707
- additionalProperties: false,
4708
- description: generatedToolInputDescriptions.argument
4709
- }
4710
- } : {}
4711
- },
4712
- required: ["operation"],
4713
- additionalProperties: false
4714
- };
4715
- }
4716
- function generatedToolInputJsonSchema() {
4717
- return generatedToolInputJsonSchemaForCaplet({ backend: "tool" });
4718
- }
4719
- //#endregion
4720
- export { url as A, clone as B, object as C, string as D, record as E, $ZodType as F, normalizeParams as H, parse$1 as I, parseAsync$1 as L, toJSONSchema as M, _coercedNumber as N, union as O, $ZodObject as P, safeParse$1 as R, number as S, preprocess as T, $constructor as U, defineLazy as V, NEVER as W, custom as _, generatedToolInputJsonSchemaForCaplet as a, literal as b, mcpOperations as c, ZodOptional as d, _enum as f, boolean as g, array as h, generatedToolInputJsonSchema as i, datetime as j, unknown as k, operations as l, any as m, completionRefSchema as n, generatedToolInputSchema as o, _null as p, generatedToolInputDescriptions as r, generatedToolInputSchemaForCaplet as s, completionArgumentSchema as t, ZodNumber as u, discriminatedUnion as v, optional as w, looseObject as x, intersection as y, safeParseAsync$1 as z };
4560
+ export { safeParseAsync$1 as A, toJSONSchema as C, parse$1 as D, $ZodType as E, NEVER as F, defineLazy as M, normalizeParams as N, parseAsync$1 as O, $constructor as P, datetime as S, $ZodObject as T, record as _, any as a, unknown as b, custom as c, literal as d, looseObject as f, preprocess as g, optional as h, _null as i, clone as j, safeParse$1 as k, discriminatedUnion as l, object as m, ZodOptional as n, array as o, number as p, _enum as r, boolean as s, ZodNumber as t, intersection as u, string as v, _coercedNumber as w, url as x, union as y };
@@ -0,0 +1,8 @@
1
+ import type { DaemonCommandPlan, ServeDaemonConfig, ServeDaemonPaths, ServeDaemonState, ServeDaemonStatus } from "./types";
2
+ export declare function readDaemonConfig(paths: ServeDaemonPaths): ServeDaemonConfig | undefined;
3
+ export declare function writeDaemonConfig(paths: ServeDaemonPaths, serve: ServeDaemonConfig["serve"], command: DaemonCommandPlan, now?: Date): ServeDaemonConfig;
4
+ export declare function readDaemonState(paths: ServeDaemonPaths): ServeDaemonState | undefined;
5
+ export declare function writeDaemonState(paths: ServeDaemonPaths, state: Omit<ServeDaemonState, "instance" | "updatedAt"> & {
6
+ updatedAt?: string;
7
+ }, now?: Date): ServeDaemonState;
8
+ export declare function redactDaemonStatus(status: ServeDaemonStatus): ServeDaemonStatus;
@@ -0,0 +1,16 @@
1
+ import { type RawServeOptions } from "../options";
2
+ import type { DaemonPlatformDescriptor, ServeDaemonOperationOptions, ServeDaemonOperationResult, ServeDaemonStatus } from "./types";
3
+ export type ServeDaemonServiceResult = {
4
+ enabled: boolean;
5
+ descriptor: DaemonPlatformDescriptor;
6
+ status: ServeDaemonStatus;
7
+ };
8
+ export declare function startDaemon(raw?: RawServeOptions, options?: ServeDaemonOperationOptions): Promise<ServeDaemonOperationResult>;
9
+ export declare function stopDaemon(options?: ServeDaemonOperationOptions): Promise<ServeDaemonOperationResult>;
10
+ export declare function restartDaemon(raw?: RawServeOptions, options?: ServeDaemonOperationOptions): Promise<ServeDaemonOperationResult>;
11
+ export declare function daemonStatus(options?: ServeDaemonOperationOptions): Promise<ServeDaemonStatus>;
12
+ export declare function enableDaemon(options?: ServeDaemonOperationOptions): Promise<ServeDaemonServiceResult>;
13
+ export declare function disableDaemon(options?: ServeDaemonOperationOptions): Promise<ServeDaemonServiceResult>;
14
+ export { buildDaemonPlatformDescriptor } from "./platform";
15
+ export { resolveServeDaemonPaths } from "./paths";
16
+ export type { DaemonPlatformDescriptor, DaemonProcessRunner, ServeDaemonConfig, ServeDaemonOperationOptions, ServeDaemonPaths, ServeDaemonState, ServeDaemonStatus, } from "./types";
@@ -0,0 +1,3 @@
1
+ import type { ServeDaemonOperationOptions, ServeDaemonPaths } from "./types";
2
+ export declare function resolveServeDaemonPaths(options?: Pick<ServeDaemonOperationOptions, "env" | "home" | "platform">): ServeDaemonPaths;
3
+ export declare function daemonServiceDescriptorPath(paths: ServeDaemonPaths, platform: NodeJS.Platform): string;
@@ -0,0 +1,2 @@
1
+ import type { DaemonCommandPlan, LaunchdUserAgentDescriptor, ServeDaemonPaths } from "./types";
2
+ export declare function buildLaunchdUserAgentDescriptor(paths: ServeDaemonPaths, command: DaemonCommandPlan): LaunchdUserAgentDescriptor;
@@ -0,0 +1,2 @@
1
+ import type { DaemonCommandPlan, ManualServiceDescriptor, ServeDaemonPaths, SystemdUserServiceDescriptor } from "./types";
2
+ export declare function buildLinuxServiceDescriptor(paths: ServeDaemonPaths, command: DaemonCommandPlan, serviceAvailable?: boolean): SystemdUserServiceDescriptor | ManualServiceDescriptor;
@@ -0,0 +1,2 @@
1
+ import type { DaemonCommandPlan, WindowsScheduledTaskDescriptor } from "./types";
2
+ export declare function buildWindowsScheduledTaskDescriptor(command: DaemonCommandPlan): WindowsScheduledTaskDescriptor;
@@ -0,0 +1,9 @@
1
+ import type { DaemonCommandPlan, DaemonPlatformDescriptor, ServeDaemonPaths } from "./types";
2
+ export type BuildDaemonPlatformDescriptorOptions = {
3
+ platform?: NodeJS.Platform;
4
+ serviceAvailable?: boolean;
5
+ paths: ServeDaemonPaths;
6
+ command: DaemonCommandPlan;
7
+ };
8
+ export declare function buildDaemonPlatformDescriptor(options: BuildDaemonPlatformDescriptorOptions): DaemonPlatformDescriptor;
9
+ export declare function escapeXml(value: string): string;
@@ -0,0 +1,5 @@
1
+ import type { HttpServeOptions } from "../options";
2
+ import type { DaemonCommandPlan, DaemonProcessRunner } from "./types";
3
+ export declare function daemonServeCommand(options: HttpServeOptions): DaemonCommandPlan;
4
+ export declare function daemonServeArgs(options: HttpServeOptions): string[];
5
+ export declare function createNodeDaemonProcessRunner(): DaemonProcessRunner;
@@ -0,0 +1,86 @@
1
+ import type { HttpServeOptions, RawServeOptions } from "../options";
2
+ export type ServeDaemonInstance = "default";
3
+ export type ServeDaemonPaths = {
4
+ instance: ServeDaemonInstance;
5
+ stateDir: string;
6
+ logDir: string;
7
+ stateFile: string;
8
+ pidFile: string;
9
+ stdoutLog: string;
10
+ stderrLog: string;
11
+ configFile: string;
12
+ };
13
+ export type ServeDaemonConfig = {
14
+ instance: ServeDaemonInstance;
15
+ serve: HttpServeOptions;
16
+ command: DaemonCommandPlan;
17
+ paths: ServeDaemonPaths;
18
+ updatedAt: string;
19
+ };
20
+ export type ServeDaemonState = {
21
+ instance: ServeDaemonInstance;
22
+ running: boolean;
23
+ pid?: number;
24
+ startedAt?: string;
25
+ updatedAt: string;
26
+ enabled: boolean;
27
+ };
28
+ export type ServeDaemonStatus = ServeDaemonState & {
29
+ paths: ServeDaemonPaths;
30
+ config?: ServeDaemonConfig;
31
+ };
32
+ export type DaemonCommandPlan = {
33
+ executable: string;
34
+ args: string[];
35
+ };
36
+ export type DaemonProcessStart = {
37
+ args: string[];
38
+ stdoutLog: string;
39
+ stderrLog: string;
40
+ configFile: string;
41
+ };
42
+ export type DaemonProcessRunner = {
43
+ isRunning(pid: number): Promise<boolean>;
44
+ start(command: DaemonProcessStart): Promise<number>;
45
+ stop(pid: number): Promise<void>;
46
+ };
47
+ export type ServeDaemonOperationOptions = {
48
+ env?: NodeJS.ProcessEnv | Record<string, string | undefined>;
49
+ home?: string;
50
+ platform?: NodeJS.Platform;
51
+ process?: DaemonProcessRunner;
52
+ serviceAvailable?: boolean;
53
+ };
54
+ export type ServeDaemonStartOptions = ServeDaemonOperationOptions & {
55
+ raw?: RawServeOptions;
56
+ };
57
+ export type ServeDaemonOperationResult = {
58
+ status: ServeDaemonStatus;
59
+ };
60
+ export type LaunchdUserAgentDescriptor = {
61
+ kind: "launchd-user-agent";
62
+ label: string;
63
+ path: string;
64
+ plist: string;
65
+ };
66
+ export type SystemdUserServiceDescriptor = {
67
+ kind: "systemd-user";
68
+ unitName: string;
69
+ path: string;
70
+ unit: string;
71
+ };
72
+ export type ManualServiceDescriptor = {
73
+ kind: "manual";
74
+ reason: string;
75
+ command: DaemonCommandPlan;
76
+ };
77
+ export type WindowsScheduledTaskDescriptor = {
78
+ kind: "windows-scheduled-task";
79
+ taskName: string;
80
+ commands: {
81
+ register: string;
82
+ unregister: string;
83
+ query: string;
84
+ };
85
+ };
86
+ export type DaemonPlatformDescriptor = LaunchdUserAgentDescriptor | SystemdUserServiceDescriptor | ManualServiceDescriptor | WindowsScheduledTaskDescriptor;
@@ -1,3 +1,4 @@
1
+ import { StreamableHTTPTransport } from "@hono/mcp";
1
2
  import { Hono } from "hono";
2
3
  import { CapletsEngine, type CapletsEngineOptions } from "../engine";
3
4
  import { type RemoteControlDispatchContext } from "../remote-control/dispatch";
@@ -7,12 +8,19 @@ type HttpServeIo = {
7
8
  writeErr?: (value: string) => void;
8
9
  control?: Omit<RemoteControlDispatchContext, "writeErr">;
9
10
  authFlowStore?: RemoteAuthFlowStore;
11
+ sessionFactory?: HttpMcpSessionFactory;
10
12
  };
13
+ type HttpMcpSession = {
14
+ connect(transport: StreamableHTTPTransport): Promise<void>;
15
+ close(): Promise<void>;
16
+ };
17
+ export type HttpMcpSessionFactory = () => HttpMcpSession | Promise<HttpMcpSession>;
11
18
  export type CapletsHttpApp = Hono & {
12
19
  closeCapletsSessions: () => Promise<void>;
13
20
  };
14
21
  export declare function createHttpServeApp(options: HttpServeOptions, engine: CapletsEngine, io?: HttpServeIo): CapletsHttpApp;
15
22
  export declare function serveHttp(options: HttpServeOptions, engineOptions?: CapletsEngineOptions, writeErr?: (value: string) => void): Promise<void>;
23
+ export declare function serveHttpWithSessionFactory(options: HttpServeOptions, createSession: HttpMcpSessionFactory, writeErr?: (value: string) => void): Promise<void>;
16
24
  export declare function routePath(base: string, path: string): string;
17
25
  export declare function servicePaths(base: string): {
18
26
  base: string;
@@ -1,9 +1,13 @@
1
1
  import type { CapletsEngineOptions } from "../engine";
2
2
  import { type RawServeOptions, type ServeOptions } from "./options";
3
3
  export { serveHttp } from "./http";
4
- export { resolveServeOptions } from "./options";
4
+ export { resolveDaemonServeOptions, resolveServeOptions } from "./options";
5
5
  export type { HttpServeOptions, RawServeOptions, ServeOptions, StdioServeOptions } from "./options";
6
+ export { NativeCapletsMcpSession } from "./native-session";
7
+ export type { NativeCapletsMcpSessionOptions, NativeToolServer } from "./native-session";
6
8
  export { serveStdio } from "./stdio";
9
+ export { buildDaemonPlatformDescriptor, daemonStatus, disableDaemon, enableDaemon, resolveServeDaemonPaths, restartDaemon, startDaemon, stopDaemon, } from "./daemon";
10
+ export type { DaemonPlatformDescriptor, DaemonProcessRunner, ServeDaemonConfig, ServeDaemonOperationOptions, ServeDaemonPaths, ServeDaemonState, ServeDaemonStatus, } from "./daemon";
7
11
  export type ServeCapletsOptions = {
8
12
  raw: RawServeOptions;
9
13
  engine?: CapletsEngineOptions;
@@ -0,0 +1,19 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp";
2
+ import type { Transport } from "@modelcontextprotocol/sdk/shared/transport";
3
+ import type { NativeCapletsService } from "../native/service";
4
+ export type NativeToolServer = Pick<McpServer, "registerTool" | "connect" | "close">;
5
+ export type NativeCapletsMcpSessionOptions = {
6
+ server?: NativeToolServer;
7
+ };
8
+ export declare class NativeCapletsMcpSession {
9
+ private readonly service;
10
+ readonly server: NativeToolServer;
11
+ private readonly tools;
12
+ private readonly unsubscribe;
13
+ private closed;
14
+ constructor(service: NativeCapletsService, options?: NativeCapletsMcpSessionOptions);
15
+ connect(transport: Transport): Promise<void>;
16
+ close(): Promise<void>;
17
+ private reconcileTools;
18
+ private definition;
19
+ }
@@ -34,4 +34,5 @@ export type HttpBasicAuthOptions = {
34
34
  export type ServeOptions = StdioServeOptions | HttpServeOptions;
35
35
  export type ServeEnv = Partial<Record<"CAPLETS_SERVER_URL" | "CAPLETS_SERVER_USER" | "CAPLETS_SERVER_PASSWORD", string>>;
36
36
  export declare function resolveServeOptions(raw: RawServeOptions, env?: ServeEnv): ServeOptions;
37
+ export declare function resolveDaemonServeOptions(raw: RawServeOptions, env?: ServeEnv): HttpServeOptions;
37
38
  export declare function isLoopbackHost(host: string): boolean;
@@ -1,5 +1,5 @@
1
1
  export type CapletsMode = "auto" | "local" | "remote";
2
- export type CapletsServerEnv = Partial<Record<"CAPLETS_MODE" | "CAPLETS_SERVER_URL" | "CAPLETS_SERVER_USER" | "CAPLETS_SERVER_PASSWORD", string>>;
2
+ export type CapletsServerEnv = Partial<Record<"CAPLETS_MODE" | "CAPLETS_SERVER_URL" | "CAPLETS_SERVER_USER" | "CAPLETS_SERVER_PASSWORD" | "CAPLETS_CLOUD_URL" | "CAPLETS_CLOUD_TOKEN" | "CAPLETS_CLOUD_WORKSPACE_ID" | "CAPLETS_PROJECT_ROOT", string>>;
3
3
  export type CapletsModeInput = {
4
4
  mode?: string;
5
5
  serverUrl?: string;