@intentic/extension-manifest 1.431.0 → 1.432.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 (68) hide show
  1. package/README.md +46 -2
  2. package/dist/manifest.d.ts +294 -0
  3. package/dist/manifest.d.ts.map +1 -1
  4. package/dist/manifest.js +96 -1
  5. package/dist/manifest.js.map +1 -1
  6. package/dist/permissions.d.ts +23 -0
  7. package/dist/permissions.d.ts.map +1 -1
  8. package/dist/permissions.js +28 -1
  9. package/dist/permissions.js.map +1 -1
  10. package/dist/points/automation-templates.d.ts +68 -0
  11. package/dist/points/automation-templates.d.ts.map +1 -1
  12. package/dist/points/automation-templates.js +29 -1
  13. package/dist/points/automation-templates.js.map +1 -1
  14. package/dist/points/capabilities.d.ts +357 -50
  15. package/dist/points/capabilities.d.ts.map +1 -1
  16. package/dist/points/capabilities.js +22 -51
  17. package/dist/points/capabilities.js.map +1 -1
  18. package/dist/points/capability-broker.d.ts +110 -0
  19. package/dist/points/capability-broker.d.ts.map +1 -0
  20. package/dist/points/capability-broker.js +125 -0
  21. package/dist/points/capability-broker.js.map +1 -0
  22. package/dist/points/channel-facts.d.ts +46 -0
  23. package/dist/points/channel-facts.d.ts.map +1 -0
  24. package/dist/points/channel-facts.js +80 -0
  25. package/dist/points/channel-facts.js.map +1 -0
  26. package/dist/points/index.d.ts +585 -0
  27. package/dist/points/index.d.ts.map +1 -1
  28. package/dist/points/index.js +12 -0
  29. package/dist/points/index.js.map +1 -1
  30. package/dist/points/listener.d.ts +10 -0
  31. package/dist/points/listener.d.ts.map +1 -1
  32. package/dist/points/listener.js +6 -0
  33. package/dist/points/listener.js.map +1 -1
  34. package/dist/points/model-roles.d.ts +31 -0
  35. package/dist/points/model-roles.d.ts.map +1 -0
  36. package/dist/points/model-roles.js +27 -0
  37. package/dist/points/model-roles.js.map +1 -0
  38. package/dist/points/public-routes.d.ts +91 -0
  39. package/dist/points/public-routes.d.ts.map +1 -0
  40. package/dist/points/public-routes.js +140 -0
  41. package/dist/points/public-routes.js.map +1 -0
  42. package/dist/points/sleep-watch.d.ts +15 -0
  43. package/dist/points/sleep-watch.d.ts.map +1 -0
  44. package/dist/points/sleep-watch.js +30 -0
  45. package/dist/points/sleep-watch.js.map +1 -0
  46. package/dist/points/watch-kinds.d.ts +102 -0
  47. package/dist/points/watch-kinds.d.ts.map +1 -0
  48. package/dist/points/watch-kinds.js +118 -0
  49. package/dist/points/watch-kinds.js.map +1 -0
  50. package/intentic-extension.schema.json +1387 -36
  51. package/package.json +2 -2
  52. package/src/manifest.ts +130 -1
  53. package/src/permissions.test.ts +39 -1
  54. package/src/permissions.ts +84 -4
  55. package/src/points/automation-templates.ts +43 -5
  56. package/src/points/capabilities.ts +37 -80
  57. package/src/points/capability-broker.ts +203 -0
  58. package/src/points/channel-facts.test.ts +38 -0
  59. package/src/points/channel-facts.ts +119 -0
  60. package/src/points/index.ts +12 -0
  61. package/src/points/listener.ts +14 -0
  62. package/src/points/model-roles.ts +44 -0
  63. package/src/points/public-routes.test.ts +132 -0
  64. package/src/points/public-routes.ts +198 -0
  65. package/src/points/sleep-watch.ts +54 -0
  66. package/src/points/watch-kinds.test.ts +73 -0
  67. package/src/points/watch-kinds.ts +172 -0
  68. package/src/powers.test.ts +97 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentic/extension-manifest",
3
- "version": "1.431.0",
3
+ "version": "1.432.0",
4
4
  "description": "What an intentic extension DECLARES, the intentic-extension.json schema and the sandbox-route allowlist rule",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -43,7 +43,7 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "@intentic/base": "1.431.0",
46
+ "@intentic/base": "1.432.0",
47
47
  "zod": "4.6.7"
48
48
  },
49
49
  "devDependencies": {
package/src/manifest.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { MARK_FIELDS } from "./mark.js";
3
- import { permissionProblem } from "./permissions.js";
3
+ import { declaredReachOf, EXTENSION_FIRE_HANDLER, permissionProblem } from "./permissions.js";
4
4
  import { contributesSchema } from "./points/index.js";
5
5
 
6
6
  // The extension manifest (`intentic-extension.json`, not under .claude-plugin/): the approval surface the install
@@ -74,6 +74,77 @@ const ManifestShape = z.object({
74
74
  .describe(
75
75
  "Daemon routes your SERVER half may call. Separate from `sandbox` because the two halves run as different principals: the UI as the owner's session, the backend as a minted per-extension token, so a grant to one must never quietly widen the other.",
76
76
  ),
77
+ // (2026-11-26) What the backend and processes may hear, hold, run and be woken by beyond their routes
78
+ // (permissions.ts EXTENSION_DECLARED_EVENTS and the rest); the daemon refuses each undeclared.
79
+ events: z
80
+ .array(
81
+ z.union([
82
+ z.literal("run").meta({ power: { key: "events:run", sentence: "its backend hears when a conversation it started finishes a turn" } }),
83
+ z
84
+ .literal("activity")
85
+ .meta({ power: { key: "events:activity", sentence: "its backend hears whether any agent turn is running in the sandbox" } }),
86
+ // (2026-11-26) The CI feed's frames, as the core hears them from the forges.
87
+ z
88
+ .literal("ci")
89
+ .meta({ power: { key: "events:ci", sentence: "its backend hears every CI run and job the workspace's forges report" } }),
90
+ ]),
91
+ )
92
+ .optional()
93
+ .describe(
94
+ "Events your backend hears through `api.events` beyond its settings and the workspace's changes: `run`, a turn ending in a conversation it started through POST /agent with its own token; `activity`, whether any agent turn is running in the sandbox; `ci`, each run and job the workspace's GitHub and GitLab forges report as it is heard (the CI feed).",
95
+ ),
96
+ work: z
97
+ .boolean()
98
+ .meta({ power: { key: "work", sentence: "its backend keeps the sandbox awake, and a restart waiting, while it holds work in flight" } })
99
+ .optional()
100
+ .describe(
101
+ "Whether your backend may hold work in flight with `api.work.hold(label)`: while held, the sandbox stays awake and an update or restart waits for it, as for an agent's turn.",
102
+ ),
103
+ exec: z
104
+ .array(
105
+ z.union([
106
+ z.literal("command").meta({ power: { key: "exec:command", sentence: "its backend runs commands, admitted like an agent's" } }),
107
+ z
108
+ .literal("toolchain")
109
+ .meta({ power: { key: "exec:toolchain", sentence: "its backend runs heavy tools, queued with the sandbox's builds and tests" } }),
110
+ ]),
111
+ )
112
+ .optional()
113
+ .describe(
114
+ "The workload classes `api.exec` may run a command under: `command`, admitted and ranked as an agent's shell command; `toolchain`, a heavy tool (a build, a test run, an analyser), which also takes turns in the sandbox's heavy-command queue.",
115
+ ),
116
+ fires: z
117
+ .array(
118
+ z
119
+ .string()
120
+ .regex(EXTENSION_FIRE_HANDLER, "a handler is a lowercase word: letters, digits and dashes")
121
+ .meta({ power: { key: "fires:${value}", sentence: 'the sandbox\'s automations wake its backend\'s "${value}" handler' } }),
122
+ )
123
+ .optional()
124
+ .describe(
125
+ "Handlers an automation may fire in your backend (`api.automations.onFire(name, handler)`): an automation whose target is `{ kind: \"extension\" }` names this extension and one of these, and fires it on its trigger under the scheduler's admission, holds and journal, without an agent.",
126
+ ),
127
+ // (2026-11-26) What its agent tools may do with the calling turn's grants (permissions.ts
128
+ // EXTENSION_TURN_POWERS); the daemon refuses each undeclared, and anything the turn does not hold either way.
129
+ turn: z
130
+ .array(
131
+ z.union([
132
+ z.literal("browser").meta({
133
+ power: {
134
+ key: "turn:browser",
135
+ sentence: "its agent tools drive the sandbox's signed-in browsers, for the accounts the calling turn holds and on those accounts' own sites",
136
+ },
137
+ }),
138
+ z
139
+ .literal("owner-browser")
140
+ .meta({ power: { key: "turn:owner-browser", sentence: "its agent tools use the owner's own browser when the calling turn holds it" } }),
141
+ z.literal("jobs").meta({ power: { key: "turn:jobs", sentence: "its agent tools start background jobs in the calling conversation" } }),
142
+ ]),
143
+ )
144
+ .optional()
145
+ .describe(
146
+ "What your agent tools (`contributes.tools`, served by `api.tools.serve`) may do with the grants of the turn that calls them: `browser`, drive the sandbox's signed-in browser of an account the turn holds, on that account's own sites (`api.browser.call`); `owner-browser`, call the owner's own browser the turn holds (`api.ownerBrowser.call`); `jobs`, start a background job in the calling conversation that the agent collects with `wait` (`api.jobs.start`). Never more than the turn holds.",
147
+ ),
77
148
  })
78
149
  .optional()
79
150
  .describe(
@@ -82,6 +153,54 @@ const ManifestShape = z.object({
82
153
  contributes: contributesSchema.optional(),
83
154
  });
84
155
 
156
+ // (2026-11-26) A watch kind's check is answered by the backend, and the cards whose gateway addresses it is handed are
157
+ // this extension's own: one extension never reaches another's connections through a check.
158
+ const servedChecks = (manifest: z.infer<typeof ManifestShape>, ctx: z.RefinementCtx): void => {
159
+ const kinds = manifest.contributes?.watchKinds ?? [];
160
+ if (kinds.length > 0 && manifest.server === undefined) {
161
+ ctx.addIssue({ code: "custom", path: ["contributes", "watchKinds"], message: "watch kinds need a `server` bundle to answer their checks" });
162
+ }
163
+ const cards = new Set((manifest.contributes?.capabilities ?? []).map((card) => card.id));
164
+ for (const [index, kind] of kinds.entries()) {
165
+ const foreign = (kind.capabilities ?? []).find((card) => !cards.has(card));
166
+ if (foreign !== undefined) {
167
+ ctx.addIssue({ code: "custom", path: ["contributes", "watchKinds", index, "capabilities"], message: `"${foreign}" is not one of this extension's own capability cards` });
168
+ }
169
+ }
170
+ const ids = kinds.map((kind) => kind.id);
171
+ const doubled = ids.find((id, index) => ids.indexOf(id) !== index);
172
+ if (doubled !== undefined) {
173
+ ctx.addIssue({ code: "custom", path: ["contributes", "watchKinds"], message: `the watch kind "${doubled}" is declared twice` });
174
+ }
175
+ };
176
+
177
+ // One job per id within a manifest: a second declaration of an id would name the same stored choice twice.
178
+ const declaredRoles = (manifest: z.infer<typeof ManifestShape>, ctx: z.RefinementCtx): void => {
179
+ const ids = (manifest.contributes?.modelRoles ?? []).map((role) => role.id);
180
+ const doubled = ids.find((id, index) => ids.indexOf(id) !== index);
181
+ if (doubled !== undefined) {
182
+ ctx.addIssue({ code: "custom", path: ["contributes", "modelRoles"], message: `the model role "${doubled}" is declared twice` });
183
+ }
184
+ };
185
+
186
+ // (2026-11-26) A public route is answered by the backend, and one scoped to an automation reads that automation from this
187
+ // extension's own listener provider: a door never opens onto another extension's automations.
188
+ const servedPublicRoutes = (manifest: z.infer<typeof ManifestShape>, ctx: z.RefinementCtx): void => {
189
+ const routes = manifest.contributes?.publicRoutes ?? [];
190
+ if (routes.length > 0 && manifest.server === undefined) {
191
+ ctx.addIssue({ code: "custom", path: ["contributes", "publicRoutes"], message: "public routes need a `server` bundle to answer them" });
192
+ }
193
+ for (const [index, route] of routes.entries()) {
194
+ if (route.automation === true && manifest.contributes?.listener === undefined) {
195
+ ctx.addIssue({
196
+ code: "custom",
197
+ path: ["contributes", "publicRoutes", index, "automation"],
198
+ message: "a route scoped to an automation reads it from this extension's own `contributes.listener`, which it does not declare",
199
+ });
200
+ }
201
+ }
202
+ };
203
+
85
204
  // What each field means taken together, which no one field's schema can say: tools need something to serve them.
86
205
  const servedTools = (manifest: z.infer<typeof ManifestShape>, ctx: z.RefinementCtx): void => {
87
206
  const contributes = manifest.contributes;
@@ -92,6 +211,9 @@ const servedTools = (manifest: z.infer<typeof ManifestShape>, ctx: z.RefinementC
92
211
  ctx.addIssue({ code: "custom", path: ["contributes", "capabilities"], message: `card "${card.id}" declares \`mcp\`, which only a \`server\` bundle can answer` });
93
212
  }
94
213
  }
214
+ servedChecks(manifest, ctx);
215
+ declaredRoles(manifest, ctx);
216
+ servedPublicRoutes(manifest, ctx);
95
217
  if (tools === undefined) {
96
218
  return;
97
219
  }
@@ -118,6 +240,13 @@ const servedTools = (manifest: z.infer<typeof ManifestShape>, ctx: z.RefinementC
118
240
  export const ExtensionManifestSchema = ManifestShape.superRefine(servedTools);
119
241
  export type ExtensionManifest = z.infer<typeof ExtensionManifestSchema>;
120
242
 
243
+ // (2026-11-26) What a manifest declares its backend may hear, hold, run and be woken by (its `permissions`), and the
244
+ // watch kinds whose checks it answers, as the backend host is told them.
245
+ export const declaredOfBackend = (manifest: Pick<ExtensionManifest, "permissions" | "contributes">) => ({
246
+ declared: declaredReachOf(manifest.permissions),
247
+ watchKinds: (manifest.contributes?.watchKinds ?? []).map((kind) => kind.id),
248
+ });
249
+
121
250
  // The extension's identity everywhere (capability entries, /ext routes, settings namespaces); derived, never declared,
122
251
  // so it can't contradict the manifest's publisher/name.
123
252
  export const extensionIdOf = (manifest: Pick<ExtensionManifest, "publisher" | "name">): string => `${manifest.publisher}.${manifest.name}`;
@@ -1,5 +1,5 @@
1
1
  import { ExtensionManifestSchema } from "./manifest.js";
2
- import { extensionRouteReach, permissionProblem, sandboxRouteAllowed } from "./permissions.js";
2
+ import { declaredReachOf, extensionRouteReach, permissionProblem, sandboxRouteAllowed } from "./permissions.js";
3
3
 
4
4
  // The glob grammar: each segment of the declared path is literal or a lone `*`, and a `*` matches one whole segment
5
5
  // that the URL layer would route rather than resolve away.
@@ -103,6 +103,10 @@ describe("extensionRouteReach", () => {
103
103
  ["its own settings, undeclared", "GET", "/extension/settings", true],
104
104
  ["its own event stream, undeclared", "GET", "/extension/events", true],
105
105
  ["no write through its own routes", "POST", "/extension/settings", false],
106
+ // Reached by the token; each door then checks its own declaration (`permissions.work`, `permissions.exec`).
107
+ ["the work-hold door, judged by the daemon against `work`", "POST", "/extension/work/hold", true],
108
+ ["the exec door, judged by the daemon against `exec`", "POST", "/extension/exec", true],
109
+ ["no read through a door", "GET", "/extension/exec", false],
106
110
  ["what it declared", "GET", "/ports", true],
107
111
  ["what it did not declare", "GET", "/agents", false],
108
112
  ["its own provider's listener route", "GET", "/listeners/slack/state", true],
@@ -116,3 +120,37 @@ describe("extensionRouteReach", () => {
116
120
  expect(extensionRouteReach({ permissions: ["GET /listeners/*/state"] }, "GET", "/listeners/slack/state")).toBe(false);
117
121
  });
118
122
  });
123
+
124
+ describe("declaredReachOf", () => {
125
+ test("nothing declared reaches nothing", () => {
126
+ expect(declaredReachOf(undefined)).toEqual({ events: [], work: false, exec: [], fires: [], turn: [] });
127
+ });
128
+
129
+ test("reads each declaration off a parsed manifest's permissions", () => {
130
+ const manifest = ExtensionManifestSchema.parse({
131
+ publisher: "acme",
132
+ name: "demo",
133
+ version: "1.0.0",
134
+ engines: { intentic: "^2.50.0" },
135
+ server: "dist/server.js",
136
+ permissions: { events: ["run", "activity", "ci"], work: true, exec: ["toolchain"], fires: ["sweep", "nightly-report"], turn: ["browser", "jobs"] },
137
+ });
138
+ expect(declaredReachOf(manifest.permissions)).toEqual({
139
+ events: ["run", "activity", "ci"],
140
+ work: true,
141
+ exec: ["toolchain"],
142
+ fires: ["sweep", "nightly-report"],
143
+ turn: ["browser", "jobs"],
144
+ });
145
+ });
146
+
147
+ test.each([
148
+ ["an event kind nobody serves", { events: ["deployment"] }],
149
+ ["a class outside the two", { exec: ["service"] }],
150
+ ["a handler that is not a lowercase word", { fires: ["Sweep Now"] }],
151
+ ["a turn power nobody serves", { turn: ["devices"] }],
152
+ ])("the manifest refuses %s", (_name, permissions) => {
153
+ const parsed = ExtensionManifestSchema.safeParse({ publisher: "acme", name: "demo", version: "1.0.0", engines: { intentic: "^2.50.0" }, permissions });
154
+ expect(parsed.success).toBe(false);
155
+ });
156
+ });
@@ -91,10 +91,90 @@ export const sandboxRouteAllowed = (permissions: readonly string[], method: stri
91
91
  });
92
92
  };
93
93
 
94
- // The routes every extension's own token reaches without declaring them: what the host tells an extension about
95
- // itself, its own settings (secrets included) and its own event stream. Each answers only about the extension asking,
96
- // so declaring them would grant nothing a reviewer could weigh.
97
- export const EXTENSION_OWN_ROUTES: readonly string[] = ["GET /extension/settings", "GET /extension/events"];
94
+ // The routes every extension's own token reaches without listing them in `permissions.daemon`: what the host tells an
95
+ // extension about itself, its own settings (secrets included) and its own event stream, and the two doors the rest of
96
+ // its `permissions` open, holding work in flight (`work`) and running a command under a workload class (`exec`). Each
97
+ // answers only about the extension asking, and a door checks its own declaration, so listing them would grant nothing
98
+ // a reviewer could weigh.
99
+ // (2026-11-26) And the doors an agent tool's call opens onto the turn that made it (`permissions.turn`): each answers only
100
+ // a call ticket the daemon minted for that extension's own tool call, or a job that call started.
101
+ export const EXTENSION_OWN_ROUTES: readonly string[] = [
102
+ "GET /extension/settings",
103
+ "GET /extension/events",
104
+ "POST /extension/work/hold",
105
+ "POST /extension/exec",
106
+ "POST /extension/turn/browser",
107
+ "POST /extension/turn/owner-browser",
108
+ "POST /extension/jobs",
109
+ "POST /extension/jobs/*",
110
+ // (2026-11-26) A row in the sandbox's activity feed, written as the extension's own.
111
+ "POST /extension/activity",
112
+ // (2026-11-27) Hosted sleep: its own `wakes` routes' URLs, what this boot follows, and the before-sleep watch.
113
+ "POST /extension/sleep/wake-url",
114
+ "GET /extension/sleep/boot",
115
+ "POST /extension/sleep/watch",
116
+ "POST /extension/sleep/ready",
117
+ // (2026-11-27) What the platform's sleep watch heard for its own connections while the sandbox slept.
118
+ "POST /extension/sleep/heard",
119
+ ];
120
+
121
+ // (2026-11-26) What an extension's own code may hear, hold and run beyond its routes, each a power its manifest declares
122
+ // under `permissions` and the daemon refuses undeclared (core-and-extensions.md, the gaps these close). Kept here, free
123
+ // of zod, since the contract's extension protocol and the SDK's runtime read the same words.
124
+
125
+ // Events a backend hears only by declaring them (`permissions.events`): `run`, a run ending in a conversation the
126
+ // extension itself started through POST /agent with its own token; `activity`, whether any agent turn runs in the
127
+ // sandbox; (2026-11-26) `ci`, each frame of the CI feed, a run that finished or a job that ended as the forges report
128
+ // them. Its settings and the workspace's file, ref and repository changes need no declaration.
129
+ export const EXTENSION_DECLARED_EVENTS = ["run", "activity", "ci"] as const;
130
+ export type ExtensionDeclaredEvent = (typeof EXTENSION_DECLARED_EVENTS)[number];
131
+
132
+ // The workload classes `api.exec` runs a command under (`permissions.exec`): `command`, admitted and ranked as an agent's
133
+ // shell command is; `toolchain`, a heavy tool (a build, a test run, an analyser over a repository), which also takes a
134
+ // slot in the sandbox's heavy-command queue, taking turns with every agent's builds.
135
+ export const EXTENSION_EXEC_CLASSES = ["command", "toolchain"] as const;
136
+ export type ExtensionExecClass = (typeof EXTENSION_EXEC_CLASSES)[number];
137
+
138
+ // A handler an automation may fire (`permissions.fires`): a lowercase word, as the automation's target names it.
139
+ export const EXTENSION_FIRE_HANDLER = /^[a-z0-9][a-z0-9-]{0,63}$/u;
140
+
141
+ // (2026-11-26) What an extension's agent tools may do with the grants of the turn that calls them (`permissions.turn`):
142
+ // `browser`, drive the sandbox's signed-in browser of an account the turn holds, on that account's own sites;
143
+ // `owner-browser`, call the owner's own browser when the turn holds it; `jobs`, start a background job in the calling
144
+ // conversation that the agent collects with `wait`. Never more than the turn holds, whatever is declared.
145
+ export const EXTENSION_TURN_POWERS = ["browser", "owner-browser", "jobs"] as const;
146
+ export type ExtensionTurnPower = (typeof EXTENSION_TURN_POWERS)[number];
147
+
148
+ // The rest of an extension's declared reach, read off its manifest's `permissions`.
149
+ export interface ExtensionDeclaredReach {
150
+ readonly events: readonly ExtensionDeclaredEvent[];
151
+ // Whether it may hold work in flight, which keeps the sandbox awake and a restart waiting.
152
+ readonly work: boolean;
153
+ readonly exec: readonly ExtensionExecClass[];
154
+ readonly fires: readonly string[];
155
+ // What its agent tools may do with the calling turn's grants.
156
+ readonly turn: readonly ExtensionTurnPower[];
157
+ }
158
+
159
+ // The fields of a manifest's `permissions` this reads, as parsed.
160
+ export interface DeclaredPermissions {
161
+ readonly events?: readonly ExtensionDeclaredEvent[] | undefined;
162
+ readonly work?: boolean | undefined;
163
+ readonly exec?: readonly ExtensionExecClass[] | undefined;
164
+ readonly fires?: readonly string[] | undefined;
165
+ readonly turn?: readonly ExtensionTurnPower[] | undefined;
166
+ }
167
+
168
+ export const declaredReachOf = (permissions: DeclaredPermissions | undefined): ExtensionDeclaredReach => ({
169
+ events: permissions?.events ?? [],
170
+ work: permissions?.work === true,
171
+ exec: permissions?.exec ?? [],
172
+ fires: permissions?.fires ?? [],
173
+ turn: permissions?.turn ?? [],
174
+ });
175
+
176
+ // Nothing declared: what an extension with no such `permissions` holds.
177
+ export const NO_DECLARED_REACH: ExtensionDeclaredReach = declaredReachOf(undefined);
98
178
 
99
179
  // What an extension token's reach is judged by: the manifest's `permissions.daemon`, and the provider its
100
180
  // `contributes.listener` names, when the extension owns that listener.
@@ -1,9 +1,9 @@
1
1
  import { z } from "zod";
2
2
  import type { ContributionPoint } from "../contribution-point.js";
3
3
 
4
- // A starting point in the automation composer: a trigger, a prompt written for that trigger's payload, and any guard
5
- // that makes it safe to leave on. Pure prefill, creating one makes an ordinary automation. The daemon validates each
6
- // against the real trigger schema when building the catalogue and drops what doesn't parse.
4
+ // A starting point in the automation composer: a trigger, a prompt written for that trigger's payload, and any guard or
5
+ // ready-made check that makes it safe to leave on. Pure prefill, creating one makes an ordinary automation. The daemon
6
+ // validates each against its own template schema when building the catalogue and drops what doesn't parse.
7
7
  export const AutomationTemplateContributionSchema = z.object({
8
8
  // Prefills the automation name and is what "does one exist already" is asked by, so spell it as an id, not prose.
9
9
  id: z
@@ -22,16 +22,33 @@ export const AutomationTemplateContributionSchema = z.object({
22
22
  "Capability providers that make this template work: any one connected is enough (fixing CI rides github or gitlab). Omitted ⇒ nothing to connect, so it is always offered.",
23
23
  ),
24
24
  // Shaped loosely here and parsed strictly at the merge, since this package can't see the daemon's real trigger
25
- // union.
25
+ // union. (2026-11-26) Every field the daemon's own templates carry, so any of them could be declared here.
26
26
  trigger: z
27
27
  .object({
28
- kind: z.enum(["schedule", "event", "listener", "workspace"]),
28
+ kind: z.enum(["schedule", "once", "event", "listener", "workspace"]),
29
+ // schedule
29
30
  cron: z.string().min(1).optional(),
31
+ tz: z.string().min(1).optional().describe("Which clock the cron's times mean, as a zone name. Absent: the sandbox's own."),
32
+ afterSessions: z.number().int().positive().optional().describe("Fire only once this many new sessions have run since the last wake."),
33
+ // once
34
+ at: z.number().int().positive().optional(),
35
+ // event (a webhook)
36
+ dailyMax: z.number().int().positive().optional().describe("How many webhook calls a day may wake it."),
37
+ signature: z
38
+ .object({ scheme: z.string().min(1), secret: z.string().min(1) })
39
+ .optional()
40
+ .describe("Require the sender's signature: its scheme, and the name of the sandbox secret holding the signing secret."),
41
+ // listener
30
42
  provider: z.string().min(1).optional(),
43
+ channelId: z.string().min(1).optional(),
31
44
  eventType: z.string().min(1).optional(),
32
45
  // A listener that answers only what is addressed to it (a mention, a reply, a direct message).
33
46
  mentioned: z.boolean().optional(),
47
+ branch: z.string().min(1).optional(),
48
+ allowedOrigins: z.array(z.string()).optional(),
49
+ // workspace
34
50
  event: z.string().min(1).optional(),
51
+ repo: z.string().min(1).optional(),
35
52
  })
36
53
  .describe(
37
54
  "What wakes it. Checked against the real trigger schema when the daemon builds the catalogue, so a template can never offer one that would be refused.",
@@ -41,6 +58,27 @@ export const AutomationTemplateContributionSchema = z.object({
41
58
  .min(1)
42
59
  .optional()
43
60
  .describe("A condition that must hold before the turn runs: what makes a template safe to leave switched on."),
61
+ // (2026-11-26) A watch: a ready-made check instead of a guard, when it fires, whether it retires, and what it sets off.
62
+ source: z
63
+ .object({ kind: z.string().min(1) })
64
+ .catchall(z.union([z.string(), z.boolean()]))
65
+ .optional()
66
+ .describe(
67
+ "A ready-made check instead of a guard: `{ kind: \"url\", url, select? }`, the sandbox's own, or a kind an enabled extension declares in `watchKinds`, its parameters beside `kind`.",
68
+ ),
69
+ fireOn: z.enum(["pass", "change"]).optional().describe("Fire on every passing check, or only when what it saw changed."),
70
+ until: z.enum(["first-fire"]).optional().describe("Switch it off the first time it fires."),
71
+ target: z
72
+ .object({
73
+ kind: z.enum(["agent", "conversation", "notify", "extension"]),
74
+ conversationId: z.string().min(1).optional(),
75
+ extension: z.string().min(1).optional(),
76
+ handler: z.string().min(1).optional(),
77
+ })
78
+ .optional()
79
+ .describe(
80
+ "What a passing check sets off: a new agent (the default), only a notification, or (`extension`) a handler of this extension's own backend, which only this extension can save.",
81
+ ),
44
82
  holdForSeconds: z.number().int().positive().optional().describe("Wait this long and coalesce repeats, rather than firing on every event."),
45
83
  prompt: z.string().min(1).describe("The turn this starts. You own the trigger's payload vocabulary, so you own the prompt that reads it."),
46
84
  note: z.string().min(1).optional(),
@@ -3,8 +3,11 @@ import { z } from "zod";
3
3
  import type { ContributionPoint } from "../contribution-point.js";
4
4
  import { TOOL_PATH } from "./tools.js";
5
5
  import { MARK_FIELDS } from "../mark.js";
6
+ import { BrokerSchema, CommandActionSchema } from "./capability-broker.js";
6
7
  import { ConnectionRefSchema, ConnectProbeSchema, KeyRequestSchema } from "./capability-field-shapes.js";
8
+ import { ChannelFactsSchema, ListenerCardStatusSchema, ProcessorsSchema } from "./channel-facts.js";
7
9
  import { type EffectMeaning, fieldMeanings, unwrapMeaning } from "../meaning.js";
10
+ import { SleepWatchSchema, sleepWatchProblems } from "./sleep-watch.js";
8
11
 
9
12
  // A field the install dialog's config form renders (key, label, secret/optional flags, a select, a `when` gate);
10
13
  // mirrors the platform catalog's own field shape.
@@ -38,6 +41,14 @@ export const CapabilityFieldSchema = z.object({
38
41
  .describe(
39
42
  "Shown on hover behind an (i) beside the label, never as text under the control: for what the label alone cannot say, a host requirement, when a value takes effect. The card's own `hint` speaks for the whole card; this one is bound to the field it qualifies.",
40
43
  ),
44
+ // (2026-11-27) Drawn only on a sandbox the platform hosts: for a setting that means something only there, such as a
45
+ // card's consent to `sleepWatch`.
46
+ hosted: z
47
+ .boolean()
48
+ .optional()
49
+ .describe(
50
+ "Show this field only on a sandbox Intentic hosts, never on one on the owner's own computer: for a setting that only means something there, such as the consent a card's `sleepWatch` names. Elsewhere it is not drawn and its answer is ignored.",
51
+ ),
41
52
  // Value only takes effect after a sandbox rebuild (rides the image overlay); shown as a chip since two
42
53
  // otherwise-identical switches can cost very differently.
43
54
  rebuild: z
@@ -189,86 +200,6 @@ const DeviceCodeSchema = z.object({
189
200
  ),
190
201
  });
191
202
 
192
- // How a cli card's credential reaches the services it is for without ever reaching the agent: the sandbox's credential
193
- // gateway, a loopback-only listener the agent's shell calls instead of the service. The gateway picks the upstream from
194
- // this declaration (never from the request), attaches the credential the way the service takes it, checks the card's
195
- // rules and gates, and forwards. The agent's env holds the gateway's address and, where a tool insists on a token
196
- // variable, an inert placeholder.
197
- const BrokerRouteSchema = z.object({
198
- upstream: z
199
- .string()
200
- .min(1)
201
- .describe(
202
- "The service's base URL, a template over the fields like `env` (`https://api.github.com`, `${url}`). What is sent to this route's gateway address goes here and nowhere else.",
203
- ),
204
- env: z
205
- .string()
206
- .regex(/^[A-Z][A-Z0-9_]*$/)
207
- .optional()
208
- .describe(
209
- "The variable the agent's shell finds this route's gateway address in (`GITHUB_API_URL`), suffixed per instance like `env`. Naming one of `env`'s own variables (`GITLAB_URL`) points it at the gateway instead of the service, so a skill written against it needs no change.",
210
- ),
211
- headers: z
212
- .record(z.string(), z.string())
213
- .optional()
214
- .describe(
215
- 'The headers that carry the credential, templated over the fields (`{"authorization": "Bearer ${token}"}`). The gateway sets them on every request it forwards, replacing any the agent sent under the same name.',
216
- ),
217
- basic: z
218
- .object({ username: z.string(), password: z.string() })
219
- .optional()
220
- .describe(
221
- "HTTP Basic credentials, templated over the fields, for a service that takes them (git over HTTPS: `x-access-token` and `${token}`).",
222
- ),
223
- form: z
224
- .record(z.string(), z.string())
225
- .optional()
226
- .describe(
227
- "Fields the gateway sets in a request's url-encoded form body, templated over the fields, for a service that takes its credential there: an OAuth token exchange's `client_secret` or `refresh_token`. What the exchange answers (a short-lived access token) is the agent's to use; the long-lived secret never is.",
228
- ),
229
- pathPrefix: z
230
- .string()
231
- .startsWith("/")
232
- .optional()
233
- .describe(
234
- "A path the gateway puts before the agent's own, templated over the fields, for a service that takes its credential in the path (Telegram's `/bot${token}`).",
235
- ),
236
- git: z
237
- .boolean()
238
- .optional()
239
- .describe(
240
- "This upstream serves git over HTTP: the agent's git is pointed at the gateway for it (`url.<gateway>.insteadOf`), so a clone, fetch or push needs no credential in the agent's hands.",
241
- ),
242
- });
243
- export type BrokerRoute = z.infer<typeof BrokerRouteSchema>;
244
-
245
- export const BrokerRuleSchema = z.object({
246
- methods: z
247
- .array(z.string().regex(/^[A-Z]+$/))
248
- .optional()
249
- .describe("The HTTP methods it covers (`DELETE`, `PUT`); absent covers every method."),
250
- paths: z
251
- .array(z.string().startsWith("/"))
252
- .optional()
253
- .describe(
254
- "The paths it covers, below the route's upstream: `*` matches one segment, `**` any number of them (`/repos/*/*/hooks/**`). Absent covers every path.",
255
- ),
256
- action: z.enum(["allow", "ask", "deny"]).describe("`allow` forwards it, `ask` holds it on a card for the owner, `deny` refuses it."),
257
- why: z.string().optional().describe("One line on what the rule protects, shown on the card or in the refusal."),
258
- });
259
- export type BrokerRule = z.infer<typeof BrokerRuleSchema>;
260
-
261
- export const BrokerSchema = z.object({
262
- routes: z.array(BrokerRouteSchema).min(1),
263
- rules: z
264
- .array(BrokerRuleSchema)
265
- .optional()
266
- .describe(
267
- "What the credential may do, checked in order against each request the gateway forwards; the first rule covering a request decides, and one no rule covers is allowed. The owner's own rules for a card replace these.",
268
- ),
269
- });
270
- export type Broker = z.infer<typeof BrokerSchema>;
271
-
272
203
  // The install-dialog card: how it looks in the grid and how the user gets its credential. Shared by every kind below.
273
204
  const CatalogSchema = z.object({
274
205
  name: z.string().min(1),
@@ -327,6 +258,12 @@ const contributionBase = {
327
258
  id: z.string().regex(/^[a-z0-9][a-z0-9-]*$/),
328
259
  catalog: CatalogSchema,
329
260
  fields: z.array(CapabilityFieldSchema),
261
+ // (2026-11-26) Facts about the platform the card reaches, read by the core in place of its tables keyed by provider
262
+ // name (channel-facts.ts). Each only describes; none grants the extension anything.
263
+ channel: ChannelFactsSchema.optional().describe(
264
+ "Facts about the platform this card reaches: its one-message limit, whether your backend publishes approved posts there itself and to which targets, and what a publishing turn should know about posting there. A post's `platform` names this card's id.",
265
+ ),
266
+ processors: ProcessorsSchema.optional(),
330
267
  };
331
268
 
332
269
  // A capability card as data; kinds with genuine device privilege (docker, vpn, extension) live in the platform
@@ -400,6 +337,18 @@ export const CapabilityContributionSchema = z
400
337
  broker: BrokerSchema.optional().describe(
401
338
  "Route the credential through the sandbox's credential gateway instead of handing it to the agent: per upstream, the variable carrying the gateway's address and how the credential is attached, plus optional method and path rules. Every `env` variable whose template names a secret field then holds an inert placeholder. Declare it on every card whose service is spoken to over HTTP.",
402
339
  ),
340
+ // Only says where the card's status is read from, so it carries no effect.
341
+ status: ListenerCardStatusSchema.optional(),
342
+ // (2026-11-27) The one exception to credentials staying in the sandbox, per connection and only on its owner's
343
+ // yes: grants the extension nothing (the daemon decides, from the consent field), so it carries no power.
344
+ sleepWatch: SleepWatchSchema.optional(),
345
+ // Only names what a command does, so it carries no effect: the sandbox holds the command to the owner's rules.
346
+ commandActions: z
347
+ .array(CommandActionSchema)
348
+ .optional()
349
+ .describe(
350
+ "The outward actions this card's command-line tools perform (`whatsapp send` sends a message), for a tool that reaches its service some other way than the gateway. Each is offered on Guardrails as `<card id>.<action>`. The sandbox refuses a command the owner's rule denies or holds before it runs and records it in Activity once it ends, unless the card's backend carries it out (`gatedBy: \"backend\"`), which then asks the outward-action door instead.",
351
+ ),
403
352
  // The first way a card served tools, kept one release as an alias of `contributes.tools` with this card as
404
353
  // `perCard` and this value as `path` (points/tools.ts); a manifest declaring both is served by `tools`.
405
354
  mcp: z
@@ -514,6 +463,14 @@ export const CapabilityContributionSchema = z
514
463
  }
515
464
  }
516
465
  })
466
+ // A card's `sleepWatch` must stand against its own fields (sleep-watch.ts).
467
+ .superRefine((spec, ctx) => {
468
+ if (spec.kind === "cli" && spec.sleepWatch !== undefined) {
469
+ for (const message of sleepWatchProblems(spec.sleepWatch, spec.fields)) {
470
+ ctx.addIssue({ code: "custom", message });
471
+ }
472
+ }
473
+ })
517
474
  .meta({ power: { key: "capability:${id}", sentence: 'a ${kind} capability card "${catalog.name}"' } });
518
475
  export type CapabilityContribution = z.infer<typeof CapabilityContributionSchema>;
519
476
  // Arms carrying a per-instance SKILL.md, templated and installed identically by the daemon.