@intentic/extension-manifest 1.431.0 → 1.433.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 +48 -2
  2. package/dist/manifest.d.ts +296 -0
  3. package/dist/manifest.d.ts.map +1 -1
  4. package/dist/manifest.js +105 -1
  5. package/dist/manifest.js.map +1 -1
  6. package/dist/permissions.d.ts +27 -0
  7. package/dist/permissions.d.ts.map +1 -1
  8. package/dist/permissions.js +32 -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 +587 -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 +12 -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 +1398 -34
  51. package/package.json +2 -2
  52. package/src/manifest.ts +145 -1
  53. package/src/permissions.test.ts +48 -1
  54. package/src/permissions.ts +99 -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 +16 -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 +116 -8
@@ -0,0 +1,203 @@
1
+ import { z } from "zod";
2
+
3
+ // A cli card's credential gateway declaration (`broker`): its routes, the method and path rules its credential is held
4
+ // to, and the outward actions its requests perform. Split from capabilities.ts, which holds the card shapes it rides on.
5
+
6
+ // How a cli card's credential reaches the services it is for without ever reaching the agent: the sandbox's credential
7
+ // gateway, a loopback-only listener the agent's shell calls instead of the service. The gateway picks the upstream from
8
+ // this declaration (never from the request), attaches the credential the way the service takes it, checks the card's
9
+ // rules and gates, and forwards. The agent's env holds the gateway's address and, where a tool insists on a token
10
+ // variable, an inert placeholder.
11
+ const BrokerRouteSchema = z.object({
12
+ upstream: z
13
+ .string()
14
+ .min(1)
15
+ .describe(
16
+ "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.",
17
+ ),
18
+ env: z
19
+ .string()
20
+ .regex(/^[A-Z][A-Z0-9_]*$/)
21
+ .optional()
22
+ .describe(
23
+ "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.",
24
+ ),
25
+ headers: z
26
+ .record(z.string(), z.string())
27
+ .optional()
28
+ .describe(
29
+ '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.',
30
+ ),
31
+ basic: z
32
+ .object({ username: z.string(), password: z.string() })
33
+ .optional()
34
+ .describe(
35
+ "HTTP Basic credentials, templated over the fields, for a service that takes them (git over HTTPS: `x-access-token` and `${token}`).",
36
+ ),
37
+ form: z
38
+ .record(z.string(), z.string())
39
+ .optional()
40
+ .describe(
41
+ "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.",
42
+ ),
43
+ pathPrefix: z
44
+ .string()
45
+ .startsWith("/")
46
+ .optional()
47
+ .describe(
48
+ "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}`).",
49
+ ),
50
+ git: z
51
+ .boolean()
52
+ .optional()
53
+ .describe(
54
+ "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.",
55
+ ),
56
+ });
57
+ export type BrokerRoute = z.infer<typeof BrokerRouteSchema>;
58
+
59
+ export const BrokerRuleSchema = z.object({
60
+ methods: z
61
+ .array(z.string().regex(/^[A-Z]+$/))
62
+ .optional()
63
+ .describe("The HTTP methods it covers (`DELETE`, `PUT`); absent covers every method."),
64
+ paths: z
65
+ .array(z.string().startsWith("/"))
66
+ .optional()
67
+ .describe(
68
+ "The paths it covers, below the route's upstream: `*` matches one segment, `**` any number of them (`/repos/*/*/hooks/**`). Absent covers every path.",
69
+ ),
70
+ action: z.enum(["allow", "ask", "deny"]).describe("`allow` forwards it, `ask` holds it on a card for the owner, `deny` refuses it."),
71
+ why: z.string().optional().describe("One line on what the rule protects, shown on the card or in the refusal."),
72
+ });
73
+ export type BrokerRule = z.infer<typeof BrokerRuleSchema>;
74
+
75
+ // An outward action's key below its card's id (`message.send`). The sandbox names it `<card id>.<action>`
76
+ // (`slack.message.send`): the key the owner's action rules are written under and the Guardrails page offers.
77
+ export const OUTWARD_ACTION_KEY = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*$/;
78
+ const OutwardActionKeySchema = z
79
+ .string()
80
+ .regex(OUTWARD_ACTION_KEY)
81
+ .describe(
82
+ "The action's key below the card's id (`message.send`, `reaction.add`): the sandbox names it `<card id>.<action>`, which is the key the owner's action rules (Guardrails) are written under.",
83
+ );
84
+
85
+ const ReadsOnlySchema = z
86
+ .boolean()
87
+ .optional()
88
+ .describe(
89
+ "This action only reads. It is recorded and held to a rule written for it like any other, but Guardrails does not offer it: a rule there would hold the bot reading its own channel.",
90
+ );
91
+
92
+ // Where one request names what it acts on: a field of its query or body, or the path segment after a fixed one.
93
+ const RequestValueSchema = z.union([
94
+ z.object({
95
+ field: z
96
+ .string()
97
+ .min(1)
98
+ .describe("A top-level field of the request's JSON, url-encoded or multipart body, else of its query (`channel`, `chat_id`)."),
99
+ }),
100
+ z.object({
101
+ after: z.string().min(1).describe("The path segment that follows this one (`channels` reads `123` from `/channels/123/messages`)."),
102
+ }),
103
+ ]);
104
+
105
+ // One outward action a brokered card's requests perform, recognised by the gateway on the request itself: the gateway
106
+ // classifies, records and gates it, so the sandbox needs to know no provider by name.
107
+ export const BrokerActionSchema = z.object({
108
+ action: OutwardActionKeySchema,
109
+ methods: z
110
+ .array(z.string().regex(/^[A-Z]+$/))
111
+ .optional()
112
+ .describe("The HTTP methods that perform it; absent is every method."),
113
+ paths: z
114
+ .array(z.string().startsWith("/"))
115
+ .optional()
116
+ .describe(
117
+ "The paths that perform it, below the route's upstream, in the rules' globs: `*` one segment, `**` any number (`/channels/*/messages`). Absent is every path.",
118
+ ),
119
+ read: ReadsOnlySchema,
120
+ channel: RequestValueSchema.optional().describe("Where the request names the channel, chat or recipient it acts on, for its Activity row."),
121
+ content: z
122
+ .object({ field: z.string().min(1).describe("A top-level field of the request's body (`text`, `content`).") })
123
+ .optional()
124
+ .describe(
125
+ "Where the request carries what it says, for its Activity row. A JSON body without that field is recorded whole; a file upload never is.",
126
+ ),
127
+ });
128
+ export type BrokerAction = z.infer<typeof BrokerActionSchema>;
129
+
130
+ // Which of a command's arguments carries a value, counted from 0 after the command's own words.
131
+ const CommandValueSchema = z.object({
132
+ arg: z.number().int().nonnegative().describe("The argument's position after the command's own words, counted from 0."),
133
+ rest: z.boolean().optional().describe("Take every argument from there on, joined by spaces (a message typed unquoted)."),
134
+ });
135
+
136
+ // One outward action a command-line tool of the extension performs for this card, recognised in the commands an agent
137
+ // runs: the command guard holds it to the owner's action rules before it runs, and the turn records it once it ends.
138
+ export const CommandActionSchema = z.object({
139
+ action: OutwardActionKeySchema,
140
+ command: z
141
+ .array(z.string().regex(/^\S+$/))
142
+ .min(1)
143
+ .describe("The program and the words that select the command (`[\"whatsapp\", \"send\"]`), matched at the start of an invocation."),
144
+ read: ReadsOnlySchema,
145
+ channel: CommandValueSchema.omit({ rest: true }).optional().describe("The argument naming the chat or recipient, for its Activity row."),
146
+ content: CommandValueSchema.optional().describe("The argument carrying what it says, for its Activity row."),
147
+ // (2026-11-26, extension API 2.52.0) Who decides the rule, said outright. Until then a backend-gated sender declared
148
+ // `selfGated`, which also made it hold while no rule named it, so one flag carried two answers.
149
+ gatedBy: z
150
+ .enum(["sandbox", "backend"])
151
+ .optional()
152
+ .describe(
153
+ "Who holds the command to the owner's action rule. `sandbox` (the default): the command guard refuses a command the rule denies or holds before it runs, and the turn records it in Activity once it ends. `backend`: the card's own backend carries the action out and asks the sandbox's outward-action door first (`POST /capabilities/{id}/outward-action`), which decides, records it in Activity and turns a hold into an approvals item the backend performs once a person says yes; the command guard lets the command run, so a held send reaches the door that drafts its approval.",
154
+ ),
155
+ unruled: z
156
+ .enum(["allow", "hold"])
157
+ .optional()
158
+ .describe(
159
+ "What the action comes to while no action rule names it. `allow` (the default) lets it go. `hold` waits for the owner's yes until a rule says otherwise: the command guard refuses it with the way to draft an approval, or, for `gatedBy: \"backend\"`, the outward-action door drafts it. Guardrails shows it as the action's default. Declarations of one action that differ hold it if any says `hold`.",
160
+ ),
161
+ selfGated: z
162
+ .boolean()
163
+ .optional()
164
+ .describe(
165
+ 'Deprecated since 2.52.0: declare `gatedBy: "backend"` and `unruled: "hold"`, which is how `true` is still read (an `unruled` beside it wins).',
166
+ ),
167
+ });
168
+ export type CommandAction = z.infer<typeof CommandActionSchema>;
169
+
170
+ // Who decides a command action's rule and what it comes to while none names it, the deprecated `selfGated` read as the two
171
+ // it stood for: a backend's door, holding while unruled.
172
+ export interface CommandActionGate {
173
+ readonly gatedBy: "sandbox" | "backend";
174
+ readonly unruled: "allow" | "hold";
175
+ }
176
+
177
+ export const commandActionGate = (entry: Pick<CommandAction, "gatedBy" | "unruled" | "selfGated">): CommandActionGate => {
178
+ const legacy = entry.selfGated === true;
179
+ return { gatedBy: entry.gatedBy ?? (legacy ? "backend" : "sandbox"), unruled: entry.unruled ?? (legacy ? "hold" : "allow") };
180
+ };
181
+
182
+ /** Whether an action waits for the owner's yes while no rule names it: one of its declarations says `hold`. */
183
+ export const holdsUnruled = (entries: readonly Pick<CommandAction, "gatedBy" | "unruled" | "selfGated">[]): boolean =>
184
+ entries.some((entry) => commandActionGate(entry).unruled === "hold");
185
+
186
+ export const BrokerSchema = z.object({
187
+ routes: z.array(BrokerRouteSchema).min(1),
188
+ rules: z
189
+ .array(BrokerRuleSchema)
190
+ .optional()
191
+ .describe(
192
+ "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.",
193
+ ),
194
+ // (2026-11-25) Declared here rather than matched in the daemon by a provider's address: the chat skills reach their
195
+ // services through the gateway's variables, which no address pattern sees.
196
+ actions: z
197
+ .array(BrokerActionSchema)
198
+ .optional()
199
+ .describe(
200
+ "The outward actions this card's requests perform (send, edit, react), checked in order against each request the gateway sees; the first that covers it names it. The gateway records each request of a card that declares any in Activity (one no action covers as `api.call`) and holds it to the owner's action rules for `<card id>.<action>`.",
201
+ ),
202
+ });
203
+ export type Broker = z.infer<typeof BrokerSchema>;
@@ -0,0 +1,38 @@
1
+ import { CapabilityContributionSchema } from "./capabilities.js";
2
+
3
+ // What a card declares about its platform: a message limit, which targets its backend publishes to, what a publishing
4
+ // turn reads, where people's data goes, and that its status is its listener's report. Each is optional and describes.
5
+
6
+ const CARD = {
7
+ id: "chat",
8
+ kind: "cli",
9
+ catalog: { name: "Chat", description: "A chat.", category: "communication" },
10
+ fields: [{ key: "token", label: "Token", secret: true }],
11
+ env: { CHAT_TOKEN: "${token}" },
12
+ skill: "skills/chat/SKILL.md",
13
+ };
14
+
15
+ const issues = (declared: object): string[] =>
16
+ CapabilityContributionSchema.safeParse({ ...CARD, ...declared }).error?.issues.map((issue) => issue.message) ?? [];
17
+
18
+ test("a card declares its platform's facts, each on its own", () => {
19
+ expect(issues({})).toEqual([]);
20
+ expect(issues({ channel: { messageLimit: 2_000, publish: { target: "^\\d{5,}$" }, posting: "Replies nest." } })).toEqual([]);
21
+ expect(issues({ processors: [{ flow: "team-chat", operator: "Chat Inc.", region: "US", thirdCountry: true, hosts: ["chat.example"] }] })).toEqual([]);
22
+ expect(issues({ processors: [{ flow: "email-imap", hostField: "host" }] })).toEqual([]);
23
+ expect(issues({ status: { from: "listener", pairingSteps: "on the phone" } })).toEqual([]);
24
+ });
25
+
26
+ test("a target pattern must compile, a limit is a positive whole number, and a path names a flow the page words", () => {
27
+ expect(issues({ channel: { publish: { target: "(" } } })).toEqual(["publish.target must be a regular expression that compiles"]);
28
+ expect(issues({ channel: { messageLimit: 0 } })).toHaveLength(1);
29
+ expect(issues({ channel: { messageLimit: 1.5 } })).toHaveLength(1);
30
+ expect(issues({ processors: [{ flow: "carrier-pigeon" }] })).toHaveLength(1);
31
+ expect(issues({ processors: [] })).toHaveLength(1);
32
+ expect(issues({ status: { from: "probe" } })).toHaveLength(1);
33
+ });
34
+
35
+ test("a site the agent acts on in the browser declares its limit and its posting note the same way", () => {
36
+ const site = { id: "forum", kind: "browser", catalog: CARD.catalog, fields: [], skill: "skills/forum/SKILL.md", channel: { messageLimit: 280, posting: "A reply nests." } };
37
+ expect(CapabilityContributionSchema.safeParse(site).success).toBe(true);
38
+ });
@@ -0,0 +1,119 @@
1
+ import { isWhenExpression } from "@intentic/base/when";
2
+ import { z } from "zod";
3
+
4
+ // (2026-11-26) WHAT A CARD'S OWN EXTENSION KNOWS ABOUT THE PLATFORM BEHIND IT, declared on the card so the core reads it
5
+ // in place of tables keyed by provider name: how long one message may be there, whether the extension publishes an
6
+ // approved post there itself and which targets it can address, what a publishing turn should know about posting there,
7
+ // and where the card sends people's data, for the Data protection page. Each fact is optional; a card that declares
8
+ // none is treated as before, with no known cap, posts published by a turn, and a connector's generic data path.
9
+
10
+ // The longest a `publish.target` pattern may be, and a sentence a publishing turn reads.
11
+ const PATTERN_MAX = 200;
12
+ const POSTING_MAX = 1_000;
13
+
14
+ // Whether `source` compiles as a JavaScript regular expression.
15
+ const compiles = (source: string): boolean => {
16
+ try {
17
+ return new RegExp(source, "u") instanceof RegExp;
18
+ } catch {
19
+ // allow(silent-catch): a pattern that does not compile is exactly what `false` reports
20
+ return false;
21
+ }
22
+ };
23
+
24
+ export const ChannelFactsSchema = z.object({
25
+ messageLimit: z
26
+ .number()
27
+ .int()
28
+ .min(1)
29
+ .max(10_000_000)
30
+ .optional()
31
+ .describe(
32
+ "The longest one message may be on this platform, in JavaScript string length (UTF-16 code units). The approvals inbox counts a post against it, and your own gateway splits a reply there. Absent: no known cap.",
33
+ ),
34
+ publish: z
35
+ .object({
36
+ target: z
37
+ .string()
38
+ .min(1)
39
+ .max(PATTERN_MAX)
40
+ .refine(compiles, { message: "publish.target must be a regular expression that compiles" })
41
+ .describe(
42
+ 'The targets your backend can address, as a regular expression a post\'s whole `target` must match (`^\\\\d{5,}$` for a channel id). A post with another target, or with attachments, goes to an agent turn instead.',
43
+ ),
44
+ })
45
+ .optional()
46
+ .describe(
47
+ "Your backend publishes this platform's approved posts itself (`api.approvals.publish`), handed over by the approvals queue only after the person's yes was matched and spent, instead of an agent turn driving the logged-in browser. Needs `server`.",
48
+ ),
49
+ posting: z
50
+ .string()
51
+ .min(1)
52
+ .max(POSTING_MAX)
53
+ .optional()
54
+ .describe(
55
+ "What an agent turn publishing an approved post on this platform should know beyond its skill, said once in the turn's brief: how a reply nests, what a target means here.",
56
+ ),
57
+ });
58
+ export type ChannelFacts = z.infer<typeof ChannelFactsSchema>;
59
+
60
+ // The data paths the Data protection page words (the contract's DATA_FLOW_KINDS a card can open): a team chat, mail read
61
+ // over IMAP, mail sent over SMTP, or any other connector.
62
+ export const PROCESSOR_FLOWS = ["team-chat", "email-imap", "email-smtp", "connector"] as const;
63
+ export type ProcessorFlow = (typeof PROCESSOR_FLOWS)[number];
64
+
65
+ export const ProcessorFactsSchema = z.object({
66
+ flow: z
67
+ .enum(PROCESSOR_FLOWS)
68
+ .describe(
69
+ "Which kind of path this is: `team-chat` (people's messages, both ways), `email-imap` (mail read from a server), `email-smtp` (mail sent through one), `connector` (whatever the agent chose to send).",
70
+ ),
71
+ operator: z.string().min(1).optional().describe("Who runs the service, as its terms name them (`Discord Inc.`). Absent: the office is asked."),
72
+ region: z.string().min(1).optional().describe("Where the operator says it processes the data (`US`, `EU`, `EU/US`), only where it publishes one."),
73
+ thirdCountry: z
74
+ .boolean()
75
+ .optional()
76
+ .describe("True when the operator processes the data outside the European Economic Area, which makes this a transfer to a third country."),
77
+ hosts: z
78
+ .array(z.string().min(1))
79
+ .optional()
80
+ .describe("Every host data is sent to on this path, beyond the card's `hosts`: a realtime gateway, a file CDN."),
81
+ hostField: z
82
+ .string()
83
+ .regex(/^[a-zA-Z][a-zA-Z0-9]*$/)
84
+ .optional()
85
+ .describe("The card's field naming the server this path reaches (an IMAP card's `host`). The path exists only once that field is filled in."),
86
+ // (2026-11-27) A path the owner opens per connection (Discord's consent to Intentic holding the bot while it sleeps).
87
+ when: z
88
+ .string()
89
+ .refine(isWhenExpression, { message: "not a valid `when` condition" })
90
+ .optional()
91
+ .describe(
92
+ "The path exists only while this condition over the card's answers holds, in the field `when`'s grammar (`wakeOnMention == 'on'`): for a path a connection opens only on its owner's yes.",
93
+ ),
94
+ });
95
+ export type ProcessorFacts = z.infer<typeof ProcessorFactsSchema>;
96
+
97
+ export const ProcessorsSchema = z
98
+ .array(ProcessorFactsSchema)
99
+ .min(1)
100
+ .describe(
101
+ "Where a card of this kind sends people's data, one entry per path out, for the Data protection page and the documents it drafts. Absent: one generic connector path over the card's `hosts`.",
102
+ );
103
+
104
+ // (2026-11-26) A card whose state only its listener knows (a linked phone, a paired device): the card reads as connected
105
+ // only once its gateway reports the connection ready, and while it pairs it shows the code the gateway reports.
106
+ export const ListenerCardStatusSchema = z
107
+ .object({
108
+ from: z.literal("listener").describe("The card's status is whatever this extension's listener last reported for it."),
109
+ pairingSteps: z
110
+ .string()
111
+ .min(1)
112
+ .max(300)
113
+ .optional()
114
+ .describe('Where a person types the pairing code the listener reports, as the card says it: "Type this code <pairingSteps>."'),
115
+ })
116
+ .describe(
117
+ "Take this card's status from your listener's report (`POST /listeners/<provider>/status`, its `connections` and `pairing`), for a card whose settings anyone could type but only the gateway knows whether they work.",
118
+ );
119
+ export type ListenerCardStatus = z.infer<typeof ListenerCardStatusSchema>;
@@ -9,29 +9,38 @@ import { documentsPoint } from "./documents.js";
9
9
  import { environmentPoint } from "./environment.js";
10
10
  import { filesPoint } from "./files.js";
11
11
  import { listenerPoint } from "./listener.js";
12
+ import { modelRolesPoint } from "./model-roles.js";
12
13
  import { processesPoint } from "./processes.js";
14
+ import { publicRoutesPoint } from "./public-routes.js";
13
15
  import { settingsPoint } from "./settings.js";
14
16
  import { sideViewsPoint } from "./side-views.js";
15
17
  import { toolsPoint } from "./tools.js";
16
18
  import { viewersPoint } from "./viewers.js";
17
19
  import { viewsPoint } from "./views.js";
20
+ import { watchKindsPoint } from "./watch-kinds.js";
18
21
 
19
22
  export * from "./agent.js";
20
23
  export * from "./automation-templates.js";
21
24
  export * from "./bin.js";
22
25
  export * from "./capabilities.js";
26
+ export * from "./capability-broker.js";
23
27
  export * from "./capability-field-shapes.js";
28
+ export * from "./channel-facts.js";
29
+ export * from "./sleep-watch.js";
24
30
  export * from "./commands.js";
25
31
  export * from "./documents.js";
26
32
  export * from "./environment.js";
27
33
  export * from "./files.js";
28
34
  export * from "./listener.js";
35
+ export * from "./model-roles.js";
29
36
  export * from "./processes.js";
37
+ export * from "./public-routes.js";
30
38
  export * from "./settings.js";
31
39
  export * from "./side-views.js";
32
40
  export * from "./tools.js";
33
41
  export * from "./viewers.js";
34
42
  export * from "./views.js";
43
+ export * from "./watch-kinds.js";
35
44
 
36
45
  // Everything a manifest may declare. `contributes` (manifest.ts), the authoring schema (json-schema.ts) and the SDK's
37
46
  // surface guard are all generated from this list, so the three can't disagree about what this build supports. Adding a
@@ -50,8 +59,11 @@ export const CONTRIBUTION_POINTS = [
50
59
  capabilitiesPoint,
51
60
  listenerPoint,
52
61
  automationTemplatesPoint,
62
+ watchKindsPoint,
63
+ modelRolesPoint,
53
64
  binPoint,
54
65
  toolsPoint,
66
+ publicRoutesPoint,
55
67
  ] as const satisfies readonly ContributionPoint[];
56
68
 
57
69
  // The `contributes` shape those points assemble to. A mapped type rather than a widened record, so
@@ -1,6 +1,15 @@
1
1
  import { z } from "zod";
2
2
  import type { ContributionPoint } from "../contribution-point.js";
3
3
 
4
+ // (2026-11-26) Who reaches a source that anyone on the internet can, without the owner wiring each sender in, and so
5
+ // which of the owner's admission floors (Guardrails ▸ Work started from outside) its wakes answer to: `visitor`, someone
6
+ // talking with an assistant (the floor for a website visitor), `report`, a stranger's report setting work going (the
7
+ // floor for a bug report, held by default). Read by the daemon in place of a table of provider names. (2026-11-27)
8
+ // `contact`, a sandbox that is not a contact yet asking to become one (the floor for a contact request, held by
9
+ // default): only its `contact.request` reaches the source unasked, everything else comes from a contact a person accepted.
10
+ export const LISTENER_STRANGERS = ["visitor", "report", "contact"] as const;
11
+ export type ListenerStrangers = (typeof LISTENER_STRANGERS)[number];
12
+
4
13
  // One narrowing field the generic automation editor draws for a source (a channel, a branch).
5
14
  const TriggerFieldContributionSchema = z.object({
6
15
  label: z.string().min(1),
@@ -31,6 +40,13 @@ export const ListenerContributionSchema = z.object({
31
40
  message: "listener event types must be unique",
32
41
  })
33
42
  .describe("The event types this source can fire, with the wording the automation editor offers them under. The daemon accepts no others."),
43
+ strangers: z
44
+ .enum(LISTENER_STRANGERS)
45
+ .meta({ power: { key: "listener-strangers:${provider}", sentence: 'anyone on the internet can wake an agent through its "${provider}" listener' } })
46
+ .optional()
47
+ .describe(
48
+ "Set when anyone on the internet can reach this source without the owner adding them (a chat on a public page, a crash reporter), which holds its wakes to the owner's floor for strangers: `visitor`, someone talking with an assistant; `report`, a stranger's report setting work going, held for approval unless the owner says otherwise; `contact`, a sandbox that is not a contact yet asking to become one, held for approval unless the owner says otherwise. Absent: its senders are people the owner connected, held to the floor for a team chat message.",
49
+ ),
34
50
  automation: z
35
51
  .object({
36
52
  label: z.string().min(1),
@@ -0,0 +1,44 @@
1
+ import { z } from "zod";
2
+ import type { ContributionPoint } from "../contribution-point.js";
3
+
4
+ // (2026-11-26) A MODEL ROLE: one job an extension starts agent runs for (Pipelines' Fix, a documentation pass), which the
5
+ // owner puts on a model setup in Sandbox ▸ Agent ▸ Models like the sandbox's own jobs. The daemon merges the enabled
6
+ // extensions' roles with its own table (@intentic/sandbox-contract/models/model-roles) and serves them to that page, and a
7
+ // run the extension starts names its role as `job`, which picks the setup's model when the run names none. Before
8
+ // this the core's table listed every extension's jobs, so a job could not come and go with its extension.
9
+
10
+ // A role's id, as the owner's choice is stored under it (`roleSetups`) and a run names it (`job`): lowercase words
11
+ // joined by dashes.
12
+ export const MODEL_ROLE_ID = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;
13
+ export const MODEL_ROLE_ID_MAX = 40;
14
+
15
+ export const ModelRoleContributionSchema = z.object({
16
+ id: z
17
+ .string()
18
+ .max(MODEL_ROLE_ID_MAX)
19
+ .regex(MODEL_ROLE_ID, "a model role's id is lowercase words joined by dashes")
20
+ .describe(
21
+ "The job's id: what the owner's choice of setup is stored under, and what a run this extension starts names as `job` on POST /agent. Keep it once shipped: a stored choice names it. An id the sandbox's own jobs or an earlier extension already use is not taken.",
22
+ ),
23
+ label: z.string().min(1).max(40).describe("What the settings page calls the job, in the owner's words: `Pipeline fixes`."),
24
+ explanation: z
25
+ .string()
26
+ .min(1)
27
+ .max(300)
28
+ .describe("One sentence under the label on what starts the job, saying more than the label does: `The agent started by Fix on a failed pipeline.`"),
29
+ icon: z.string().min(1).optional().describe("A name from the host's icon set for the job's chip. Absent draws a wrench."),
30
+ setup: z
31
+ .enum(["low", "medium", "high"])
32
+ .optional()
33
+ .describe(
34
+ "The setup the job is suggested: where a sandbox that never placed its jobs runs it, and where the settings page puts it when the owner places it again. What the work needs, not what it costs today. Absent is `medium`.",
35
+ ),
36
+ });
37
+ export type ModelRoleContribution = z.infer<typeof ModelRoleContributionSchema>;
38
+
39
+ export const modelRolesPoint = {
40
+ name: "modelRoles",
41
+ description:
42
+ "The jobs this extension starts agent runs for, each of which the owner puts on a model setup in Sandbox ▸ Agent ▸ Models beside the sandbox's own: a run you start through `POST /agent` names its job as `job`, and runs on that setup's model when it names none of its own (an id the sandbox's own table held until 2026-11-26 may ride as `runRole`, which a sandbox from before reads too). Switching the extension off hides its jobs on that page and keeps the owner's choices for them.",
43
+ schema: z.array(ModelRoleContributionSchema),
44
+ } as const satisfies ContributionPoint;
@@ -0,0 +1,132 @@
1
+ import { ExtensionManifestSchema } from "../manifest.js";
2
+ import { powersOf } from "../powers-diff.js";
3
+ import { publicRouteAutomationOf, publicRouteFor, PublicRouteContributionSchema } from "./public-routes.js";
4
+
5
+ // A public route's declaration: the grammar of its path, which protections need which others, what the owner is asked
6
+ // to approve, and which declared route a request lands on, which the daemon's door reads through `publicRouteFor`.
7
+
8
+ const LISTENER = {
9
+ provider: "crashes",
10
+ events: [{ type: "report", label: "Reports" }],
11
+ automation: { label: "Crashes", channel: { label: "Site", placeholder: "every site" }, starterPrompt: "A crash arrived." },
12
+ };
13
+
14
+ const manifestWith = (fields: object) => ({ publisher: "acme", name: "doors", version: "1.0.0", engines: { intentic: "^2.53.0" }, ...fields });
15
+
16
+ const issues = (declared: object): string[] => PublicRouteContributionSchema.safeParse(declared).error?.issues.map((issue) => issue.message) ?? [];
17
+
18
+ test("a path is lowercase words or a lone `*`, never a dot segment, a slash at either end, or a glob inside a word", () => {
19
+ expect(issues({ path: "hook", methods: ["POST"] })).toEqual([]);
20
+ expect(issues({ path: "*/report", methods: ["POST"] })).toEqual([]);
21
+ expect(issues({ path: "sdk.js", methods: ["GET"] })).toEqual([]);
22
+ for (const path of ["", "/hook", "hook/", "..", "a/../b", "Hook", "a*", "**", "a/b/c/d/e/f/g/h/i"]) {
23
+ expect(issues({ path, methods: ["POST"] })).toHaveLength(1);
24
+ }
25
+ expect(issues({ path: "hook", methods: [] })).toHaveLength(1);
26
+ expect(issues({ path: "hook", methods: ["OPTIONS"] })).toHaveLength(1);
27
+ });
28
+
29
+ test("a key stands in for an unlisted browser only on a route that takes a key, and a day goes uncounted only on a GET-only route", () => {
30
+ const keyed = { path: "*/report", methods: ["POST"], automation: true, origins: "listed", key: true };
31
+ expect(issues({ ...keyed, keyFromBrowsers: true })).toEqual([]);
32
+ expect(issues({ ...keyed, key: undefined, keyFromBrowsers: true })).toEqual(["`keyFromBrowsers` lets the key stand in for an unlisted browser, so it needs `key: true`"]);
33
+ expect(issues({ path: "sdk.js", methods: ["GET"], dailyMax: "none" })).toEqual([]);
34
+ expect(issues({ path: "hook", methods: ["GET", "POST"], dailyMax: "none" })).toEqual([
35
+ '`dailyMax: "none"` is for a route that only serves what a page loads, so its methods must be GET alone',
36
+ ]);
37
+ expect(issues({ path: "sdk.js", methods: ["GET"], dailyMax: "unlimited" })).toHaveLength(1);
38
+ });
39
+
40
+ test("a Turnstile check names the sandbox secret it is verified with, never a value", () => {
41
+ expect(issues({ path: "chat", methods: ["POST"], turnstile: { secret: "TURNSTILE_SECRET" } })).toEqual([]);
42
+ expect(issues({ path: "chat", methods: ["POST"], turnstile: { secret: "0x4AAA-not-a-name" } })).toHaveLength(1);
43
+ expect(issues({ path: "chat", methods: ["POST"], turnstile: {} })).toHaveLength(1);
44
+ });
45
+
46
+ test("an allowlist reads an automation's origins, and a key stands in for a listed origin only", () => {
47
+ expect(issues({ path: "hook", methods: ["POST"], origins: "listed" })).toEqual([
48
+ '`origins: "listed"` checks an automation\'s allowed origins, so it needs `automation: true`',
49
+ ]);
50
+ expect(issues({ path: "*/report", methods: ["POST"], automation: true, key: true })).toEqual([
51
+ '`key` admits a caller in place of a listed Origin, so it needs `origins: "listed"`',
52
+ ]);
53
+ expect(issues({ path: "report", methods: ["POST"], automation: true })).toEqual([
54
+ "`automation` reads the automation's id from the path's first `*`, which this path has none of",
55
+ ]);
56
+ expect(issues({ path: "*/report", methods: ["POST"], automation: true, origins: "listed", key: true, proofOfWork: true, dailyMax: 500 })).toEqual([]);
57
+ });
58
+
59
+ test("ceilings are bounded: no body past a mebibyte, no window past 600 a minute", () => {
60
+ expect(issues({ path: "hook", methods: ["POST"], bodyMax: 1024 * 1024 + 1 })).toHaveLength(1);
61
+ expect(issues({ path: "hook", methods: ["POST"], rate: 601 })).toHaveLength(1);
62
+ expect(issues({ path: "hook", methods: ["POST"], rate: 0 })).toHaveLength(1);
63
+ expect(issues({ path: "hook", methods: ["POST"], signature: { scheme: "github", secret: "not a name" } })).toHaveLength(1);
64
+ expect(issues({ path: "hook", methods: ["POST"], signature: { scheme: "gitlab", secret: "HOOK" } })).toHaveLength(1);
65
+ });
66
+
67
+ test("a manifest's public routes need a backend, unique paths, and its own listener for an automation's route", () => {
68
+ const routes = [{ path: "*/report", methods: ["POST"], automation: true }];
69
+ const messages = (manifest: object): string[] => ExtensionManifestSchema.safeParse(manifest).error?.issues.map((issue) => issue.message) ?? [];
70
+ expect(messages(manifestWith({ contributes: { publicRoutes: routes, listener: LISTENER } }))).toEqual(["public routes need a `server` bundle to answer them"]);
71
+ expect(messages(manifestWith({ server: "dist/server.js", contributes: { publicRoutes: routes } }))).toEqual([
72
+ "a route scoped to an automation reads it from this extension's own `contributes.listener`, which it does not declare",
73
+ ]);
74
+ expect(messages(manifestWith({ server: "dist/server.js", contributes: { publicRoutes: [...routes, ...routes], listener: LISTENER } }))).toEqual([
75
+ "public route paths must be unique",
76
+ ]);
77
+ expect(messages(manifestWith({ server: "dist/server.js", contributes: { publicRoutes: routes, listener: LISTENER } }))).toEqual([]);
78
+ });
79
+
80
+ test("each route is a power the owner approves, naming the secret a signed one is checked against", () => {
81
+ const manifest = ExtensionManifestSchema.parse(
82
+ manifestWith({
83
+ server: "dist/server.js",
84
+ contributes: {
85
+ publicRoutes: [
86
+ { path: "stripe", methods: ["POST"], signature: { scheme: "stripe", secret: "STRIPE_WEBHOOK_SECRET" } },
87
+ { path: "ping", methods: ["GET", "POST"] },
88
+ ],
89
+ listener: { ...LISTENER, strangers: "report" },
90
+ },
91
+ }),
92
+ );
93
+ const sentences = [...powersOf(manifest).values()];
94
+ expect(sentences).toContain("anyone on the internet can call its backend at POST /stripe when signed with your secret STRIPE_WEBHOOK_SECRET");
95
+ expect(sentences).toContain("anyone on the internet can call its backend at GET, POST /ping");
96
+ expect(sentences).toContain('anyone on the internet can wake an agent through its "crashes" listener');
97
+ });
98
+
99
+ test("a request lands on the first declared route its method and every segment match, and an automation is read from the first `*`", () => {
100
+ const routes = [
101
+ { path: "hook", methods: ["POST" as const] },
102
+ { path: "*/report", methods: ["POST" as const], automation: true as const },
103
+ { path: "*/config", methods: ["GET" as const] },
104
+ ];
105
+ expect(publicRouteFor(routes, "post", ["hook"])?.path).toBe("hook");
106
+ expect(publicRouteFor(routes, "GET", ["hook"])).toBeUndefined();
107
+ expect(publicRouteFor(routes, "POST", ["bugs-1", "report"])?.path).toBe("*/report");
108
+ expect(publicRouteFor(routes, "POST", ["hook", "extra"])).toBeUndefined();
109
+ expect(publicRouteFor(routes, "POST", ["..", "report"])).toBeUndefined();
110
+ expect(publicRouteFor(routes, "POST", ["", "report"])).toBeUndefined();
111
+ const report = routes[1];
112
+ expect(report === undefined ? undefined : publicRouteAutomationOf(report, ["bugs-1", "report"])).toBe("bugs-1");
113
+ expect(publicRouteAutomationOf({ path: "*/config" }, ["bugs-1", "config"])).toBeUndefined();
114
+ });
115
+
116
+ test("a route that wakes the sandbox names one path, its only `*` an automation's, and waking is a power of its own", () => {
117
+ expect(issues({ path: "hook", methods: ["POST"], wakes: true })).toEqual([]);
118
+ expect(issues({ path: "*/events", methods: ["POST"], automation: true, wakes: true })).toEqual([]);
119
+ expect(issues({ path: "*/events", methods: ["POST"], wakes: true })).toEqual([
120
+ "a route that wakes the sandbox names one path: its only `*` is an automation's, with `automation: true`",
121
+ ]);
122
+ expect(issues({ path: "*/events/*", methods: ["POST"], automation: true, wakes: true })).toEqual([
123
+ "a route that wakes the sandbox names one path: its only `*` is an automation's, with `automation: true`",
124
+ ]);
125
+ expect(issues({ path: "hook", methods: ["POST"], wakes: false })).toHaveLength(1);
126
+ const manifest = ExtensionManifestSchema.parse(
127
+ manifestWith({ server: "dist/server.js", contributes: { publicRoutes: [{ path: "*/events", methods: ["POST"], automation: true, wakes: true }], listener: LISTENER } }),
128
+ );
129
+ const powers = powersOf(manifest);
130
+ expect(powers.get("wakes:*/events")).toBe("a call to /*/events wakes the sandbox while it sleeps, which spends its awake hours");
131
+ expect([...powers.keys()]).toContain("public:*/events");
132
+ });