@intentic/sandbox-contract 1.399.0 → 1.400.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 (125) hide show
  1. package/dist/contracts/agent.contract.d.ts +9 -0
  2. package/dist/contracts/agent.contract.d.ts.map +1 -1
  3. package/dist/contracts/agents.contract.d.ts +1045 -96
  4. package/dist/contracts/agents.contract.d.ts.map +1 -1
  5. package/dist/contracts/agents.contract.js +12 -2
  6. package/dist/contracts/agents.contract.js.map +1 -1
  7. package/dist/contracts/automations.contract.d.ts +2 -0
  8. package/dist/contracts/automations.contract.d.ts.map +1 -1
  9. package/dist/contracts/endpoints.contract.d.ts +29 -0
  10. package/dist/contracts/endpoints.contract.d.ts.map +1 -1
  11. package/dist/contracts/endpoints.contract.js +22 -0
  12. package/dist/contracts/endpoints.contract.js.map +1 -1
  13. package/dist/contracts/needs.contract.d.ts +9 -0
  14. package/dist/contracts/needs.contract.d.ts.map +1 -1
  15. package/dist/contracts/privacy.contract.d.ts +17 -0
  16. package/dist/contracts/privacy.contract.d.ts.map +1 -1
  17. package/dist/contracts/privacy.contract.js +10 -1
  18. package/dist/contracts/privacy.contract.js.map +1 -1
  19. package/dist/contracts/runner.contract.d.ts +252 -246
  20. package/dist/contracts/runner.contract.d.ts.map +1 -1
  21. package/dist/contracts/seal.contract.d.ts +100 -0
  22. package/dist/contracts/seal.contract.d.ts.map +1 -1
  23. package/dist/contracts/sessions.contract.d.ts +1 -0
  24. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  25. package/dist/contracts/settings.contract.d.ts +0 -108
  26. package/dist/contracts/settings.contract.d.ts.map +1 -1
  27. package/dist/contracts/settings.contract.js +1 -10
  28. package/dist/contracts/settings.contract.js.map +1 -1
  29. package/dist/contracts/system.contract.d.ts +108 -18
  30. package/dist/contracts/system.contract.d.ts.map +1 -1
  31. package/dist/events/agent-events.d.ts +4 -0
  32. package/dist/events/agent-events.d.ts.map +1 -1
  33. package/dist/events/agent-transcript.d.ts +1 -0
  34. package/dist/events/agent-transcript.d.ts.map +1 -1
  35. package/dist/events/system-events.d.ts +84 -0
  36. package/dist/events/system-events.d.ts.map +1 -1
  37. package/dist/events/system-events.js +10 -2
  38. package/dist/events/system-events.js.map +1 -1
  39. package/dist/events/transcript.d.ts +5 -0
  40. package/dist/events/transcript.d.ts.map +1 -1
  41. package/dist/index.d.ts +3 -2
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +7 -1
  44. package/dist/index.js.map +1 -1
  45. package/dist/protocol/routes.d.ts +7 -4
  46. package/dist/protocol/routes.d.ts.map +1 -1
  47. package/dist/protocol/routes.js +80 -23
  48. package/dist/protocol/routes.js.map +1 -1
  49. package/dist/schemas/agent-people.d.ts +65 -0
  50. package/dist/schemas/agent-people.d.ts.map +1 -1
  51. package/dist/schemas/agent-people.js +45 -0
  52. package/dist/schemas/agent-people.js.map +1 -1
  53. package/dist/schemas/agents-list.d.ts +40 -0
  54. package/dist/schemas/agents-list.d.ts.map +1 -1
  55. package/dist/schemas/agents.d.ts +61 -1
  56. package/dist/schemas/agents.d.ts.map +1 -1
  57. package/dist/schemas/agents.js +10 -2
  58. package/dist/schemas/agents.js.map +1 -1
  59. package/dist/schemas/automations.d.ts +3 -0
  60. package/dist/schemas/automations.d.ts.map +1 -1
  61. package/dist/schemas/automations.js +4 -0
  62. package/dist/schemas/automations.js.map +1 -1
  63. package/dist/schemas/composer-drafts.d.ts +2 -0
  64. package/dist/schemas/composer-drafts.d.ts.map +1 -1
  65. package/dist/schemas/composer-drafts.js +3 -0
  66. package/dist/schemas/composer-drafts.js.map +1 -1
  67. package/dist/schemas/needs.d.ts +8 -0
  68. package/dist/schemas/needs.d.ts.map +1 -1
  69. package/dist/schemas/privacy.d.ts +17 -0
  70. package/dist/schemas/privacy.d.ts.map +1 -1
  71. package/dist/schemas/privacy.js +7 -1
  72. package/dist/schemas/privacy.js.map +1 -1
  73. package/dist/schemas/providers/usage.d.ts +0 -3
  74. package/dist/schemas/providers/usage.d.ts.map +1 -1
  75. package/dist/schemas/providers/usage.js +0 -3
  76. package/dist/schemas/providers/usage.js.map +1 -1
  77. package/dist/schemas/settings-history.d.ts +1 -1
  78. package/dist/schemas/settings-history.d.ts.map +1 -1
  79. package/dist/schemas/settings-history.js +1 -0
  80. package/dist/schemas/settings-history.js.map +1 -1
  81. package/dist/schemas/settings-savings.d.ts +0 -103
  82. package/dist/schemas/settings-savings.d.ts.map +1 -1
  83. package/dist/schemas/settings-savings.js +0 -12
  84. package/dist/schemas/settings-savings.js.map +1 -1
  85. package/dist/schemas/settings.d.ts +0 -6
  86. package/dist/schemas/settings.d.ts.map +1 -1
  87. package/dist/schemas/settings.js +0 -17
  88. package/dist/schemas/settings.js.map +1 -1
  89. package/dist/schemas/system-prompt.d.ts +0 -4
  90. package/dist/schemas/system-prompt.d.ts.map +1 -1
  91. package/dist/schemas/system-prompt.js +1 -1
  92. package/dist/schemas/system-prompt.js.map +1 -1
  93. package/dist/state/definition.d.ts +0 -12
  94. package/dist/state/definition.d.ts.map +1 -1
  95. package/dist/state/runtime-state.d.ts +3 -0
  96. package/dist/state/runtime-state.d.ts.map +1 -1
  97. package/dist/state/runtime-state.js +1 -0
  98. package/dist/state/runtime-state.js.map +1 -1
  99. package/dist/state/workspace-state.d.ts +0 -6
  100. package/dist/state/workspace-state.d.ts.map +1 -1
  101. package/dist/state/workspace-state.js +0 -7
  102. package/dist/state/workspace-state.js.map +1 -1
  103. package/package.json +5 -5
  104. package/src/contracts/agents.contract.ts +14 -2
  105. package/src/contracts/endpoints.contract.ts +36 -0
  106. package/src/contracts/privacy.contract.ts +12 -0
  107. package/src/contracts/settings.contract.ts +0 -12
  108. package/src/events/system-events.ts +17 -2
  109. package/src/index.ts +15 -2
  110. package/src/protocol/routes.test.ts +38 -2
  111. package/src/protocol/routes.ts +121 -28
  112. package/src/schemas/agent-people.ts +95 -0
  113. package/src/schemas/agents.ts +34 -2
  114. package/src/schemas/automations.ts +7 -0
  115. package/src/schemas/composer-drafts.ts +10 -0
  116. package/src/schemas/privacy.ts +12 -1
  117. package/src/schemas/providers/usage.ts +0 -6
  118. package/src/schemas/settings-history.ts +3 -0
  119. package/src/schemas/settings-savings.ts +1 -26
  120. package/src/schemas/settings.test.ts +7 -0
  121. package/src/schemas/settings.ts +0 -28
  122. package/src/schemas/system-prompt.ts +1 -1
  123. package/src/state/runtime-state.ts +5 -2
  124. package/src/state/workspace-state.test.ts +1 -6
  125. package/src/state/workspace-state.ts +0 -11
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { procedure } from "../protocol/route-meta.js";
3
3
  import { AgentToolChildrenSchema, SessionTranscriptSchema } from "../events/transcript.js";
4
4
  import { AgentTranscriptSchema } from "../events/agent-transcript.js";
5
- import { AgentAssignSchema, AgentAutoLandSchema, AgentBreakPolicySchema, AgentFileDiffQuerySchema, AgentIdSchema, AgentToolChildrenQuerySchema, AgentTranscriptQuerySchema, AgentIdsSchema, AgentLandSchema, AgentReactSchema, AgentRenameSchema, AgentStopJobSchema, AgentStopWatchingSchema, AgentSubagentQuerySchema, AgentsArchivedSchema, AgentsMovedSchema, AgentsRemovedSchema, AgentSummarySchema, AgentUnsentSchema, LandResultSchema } from "../schemas/agents.js";
5
+ import { AgentAssignSchema, AgentAutoLandSchema, AgentNotifySchema, AgentBreakPolicySchema, AgentFileDiffQuerySchema, AgentIdSchema, AgentToolChildrenQuerySchema, AgentTranscriptQuerySchema, AgentIdsSchema, AgentLandSchema, AgentReactSchema, AgentRenameSchema, AgentStopJobSchema, AgentStopWatchingSchema, AgentSubagentQuerySchema, AgentsArchivedSchema, AgentsMovedSchema, AgentsRemovedSchema, AgentSummarySchema, AgentUnsentSchema, LandResultSchema } from "../schemas/agents.js";
6
6
  import { AgentSearchQuerySchema, AgentSearchResultSchema } from "../schemas/agent-search.js";
7
7
  import { AgentsAttentionSchema, AgentsListSchema, HomeConversationSchema } from "../schemas/agents-list.js";
8
8
  import { AgentChangesSchema, AgentConflictsSchema, AgentIgnoredSchema, AgentScratchSchema, AgentHistorySchema } from "../schemas/git/git.js";
@@ -136,7 +136,7 @@ export const agentsContract = {
136
136
  path: "/agents/{id}/system-prompt",
137
137
  summary: "What this conversation is told before it is asked anything",
138
138
  description:
139
- "The system prompt the most recent turn of this conversation actually ran on: which base it was, and every piece the sandbox added to it — this product's guidance, the persona, the field notes, the workspace's own standing rules — each with the exact words the model received. None of this appears in the transcript, so this is the only way to read it.",
139
+ "The system prompt the most recent turn of this conversation actually ran on: which base it was, and every piece the sandbox added to it — this product's guidance, the persona, the workspace's own standing rules — each with the exact words the model received. None of this appears in the transcript, so this is the only way to read it.",
140
140
  })
141
141
  .input(AgentIdSchema)
142
142
  .output(ConversationPromptSchema),
@@ -458,6 +458,18 @@ export const agentsContract = {
458
458
  .meta({ floor: "viewer", guest: true })
459
459
  .input(AgentReactSchema)
460
460
  .output(AgentSummarySchema),
461
+ // Floored like `react`: what reaches a person's own devices is their own business, not operating authority.
462
+ notify: procedure
463
+ .route({
464
+ method: "POST",
465
+ path: "/agents/{id}/notify",
466
+ summary: "Choose how much of a conversation reaches you",
467
+ description:
468
+ "Sets how much of this conversation's news reaches your devices, your browser tab and the app's sounds: every finished turn and every card, only the cards that wait on you, or nothing. Clearing it goes back to the default, which is everything for a conversation you took part in and nothing for one you did not. Only you see your answer.",
469
+ })
470
+ .meta({ floor: "viewer", guest: true })
471
+ .input(AgentNotifySchema)
472
+ .output(AgentSummarySchema),
461
473
  discard: procedure
462
474
  .route({
463
475
  method: "POST",
@@ -30,6 +30,30 @@ export const TrialStatusSchema = z.object({
30
30
  });
31
31
  export type TrialStatusResponse = z.infer<typeof TrialStatusSchema>;
32
32
 
33
+ // What is left to spend on a vendor's API key: the per-token counterpart of a sign-in's plan limits. Only some vendors
34
+ // tell an ordinary key (Moonshot, DeepSeek, an OpenRouter key with a cap); the rest keep billing behind an admin key, and
35
+ // the sandbox never asks for one.
36
+ export const KeyBalanceSchema = z.object({
37
+ remaining: z.number().describe("What is left to spend, in `currency`. Zero or below is where the vendor refuses the next request."),
38
+ currency: z.string().describe("The ISO 4217 code the vendor counts in: USD, CNY."),
39
+ limit: z
40
+ .number()
41
+ .optional()
42
+ .describe(
43
+ "The cap `remaining` counts down from, where it is a cap set on the key (an OpenRouter key's credit limit, or a budget its organisation set) rather than the account's whole credit, which no vendor states a ceiling for.",
44
+ ),
45
+ resetsAt: z.number().optional().describe("When the cap starts over, in epoch seconds, for a cap that does; absent for a balance that only a top-up refills."),
46
+ measuredAt: z.number().describe("When the vendor was asked, in milliseconds."),
47
+ });
48
+ export type KeyBalance = z.infer<typeof KeyBalanceSchema>;
49
+
50
+ export const EndpointBalanceSchema = z.object({
51
+ balance: KeyBalanceSchema.optional().describe(
52
+ "Absent when the endpoint's vendor tells an ordinary key nothing about its credit (Anthropic, OpenAI, Gemini, xAI and any server of the owner's), when an OpenRouter key has no cap of its own, and when the vendor could not be read just now.",
53
+ ),
54
+ });
55
+ export type EndpointBalance = z.infer<typeof EndpointBalanceSchema>;
56
+
33
57
  // A model server found running on the computer that hosts the sandbox.
34
58
  export const HostModelServerSchema = z.object({
35
59
  kind: z.enum(["ollama", "lmstudio", "llamacpp", "vllm"]).describe("Which program usually listens on the port it answered on."),
@@ -111,6 +135,18 @@ export const endpointsContract = {
111
135
  })
112
136
  .input(CapabilityIdParamSchema)
113
137
  .output(ModelsSchema),
138
+ // Read from the vendor with the key itself, held a short while: it moves with every turn, and the composer asks
139
+ // again as each one ends.
140
+ balance: procedure
141
+ .route({
142
+ method: "GET",
143
+ path: "/endpoints/{id}/balance",
144
+ summary: "What is left to spend on a connected API key",
145
+ description:
146
+ "Asks the vendor of one connected API key how much credit is left on it, the per-token counterpart of a sign-in's plan limits. Only some vendors tell an ordinary key (Moonshot, DeepSeek, and OpenRouter for a key with a cap of its own); for the rest, and for any server of your own, the answer is that nothing is known, never a zero. Held for half a minute, so asking again right away reads the same figure.",
147
+ })
148
+ .input(CapabilityIdParamSchema)
149
+ .output(EndpointBalanceSchema),
114
150
  trial: procedure
115
151
  .route({
116
152
  method: "GET",
@@ -11,6 +11,8 @@ import {
11
11
  PRIVACY_PREVIEW_MAX,
12
12
  PrivacyPreviewSchema,
13
13
  PrivacyRevealSchema,
14
+ PRIVACY_SHIELDED_MAX,
15
+ PrivacyShieldedValueSchema,
14
16
  PrivacyShieldPolicySchema,
15
17
  PrivacyShieldStatusSchema,
16
18
  } from "../schemas/privacy.js";
@@ -60,6 +62,16 @@ export const privacyContract = {
60
62
  "Each model request the gateway handled: which provider, whether it was trusted, how many of each kind of personal data it found, and the tokens it gave with the masked text around them. Never the values.",
61
63
  })
62
64
  .output(z.array(PrivacyLedgerEntrySchema)),
65
+ shielded: procedure
66
+ .route({
67
+ method: "GET",
68
+ path: "/privacy/shielded",
69
+ summary: "Words a conversation's model never read",
70
+ description:
71
+ "The values in the conversation's replies that its model wrote as tokens, each with the token it wrote, so the chat can tell them from the model's own words. Empty while the shield does not mask the conversation's provider. Only someone who can read the conversation may ask.",
72
+ })
73
+ .input(z.object({ conversationId: z.string().min(1).max(200) }))
74
+ .output(z.array(PrivacyShieldedValueSchema).max(PRIVACY_SHIELDED_MAX)),
63
75
  reveal: procedure
64
76
  .route({
65
77
  method: "POST",
@@ -1,5 +1,4 @@
1
1
  import { AiLiteracyConfirmSchema, AiLiteracyListSchema, AiLiteracyQuerySchema, AiLiteracyStatusSchema } from "../schemas/ai-literacy.js";
2
- import { FIELD_NOTES_FILE } from "@intentic/constants";
3
2
  import { procedure } from "../protocol/route-meta.js";
4
3
  import {
5
4
  AgentDomainPolicySchema,
@@ -10,7 +9,6 @@ import {
10
9
  CommitIdentityStateSchema,
11
10
  MemberAudienceSchema,
12
11
  BuiltinPromptTextSchema,
13
- FieldNotesStatusSchema,
14
12
  GettingStartedSchema,
15
13
  REPO_CHECKS_FILE,
16
14
  RepoChecksAdoptSchema,
@@ -102,16 +100,6 @@ export const settingsContract = {
102
100
  description: `Every repository that declares its own checks at \`${REPO_CHECKS_FILE}\`, what it declares, and whether you have switched it on. A repository declares what to run because the command belongs beside the scripts it names; nothing it declares runs until you say so.`,
103
101
  })
104
102
  .output(RepoChecksListSchema),
105
- // Read off the file and the automation store rather than the settings manifest: nothing here is a choice anyone
106
- // made, so storing it would only give it a second place to be wrong.
107
- fieldNotes: procedure
108
- .route({
109
- method: "GET",
110
- path: "/settings/field-notes",
111
- summary: "The state of this sandbox's field notes",
112
- description: `Whether \`${FIELD_NOTES_FILE}\` exists, when it was last rewritten, how much of it the current budget reaches, and whether a monthly rewrite is scheduled.`,
113
- })
114
- .output(FieldNotesStatusSchema),
115
103
  // Its own route rather than a field on `set`, for one reason: this is the only write that must NOT overwrite. The
116
104
  // browser offers the zone it is in; the daemon takes it only if nobody has chosen one. Folding it into the
117
105
  // whole-object `set` would mean the second machine to open the workspace silently moved every schedule to its own
@@ -134,12 +134,27 @@ export type CheckoutChanged = z.infer<typeof CheckoutChangedSchema>;
134
134
 
135
135
  // Repos whose refs moved (commit, checkout, branch, rebase); a repo's git dir lives outside /work and the watcher
136
136
  // ignores `.git`, so no workspace path can say this. Diff, not snapshot: an absent repo didn't move, it didn't vanish.
137
- export const RefsChangedSchema = z.object({ kind: z.literal("refsChanged"), repos: z.array(z.string()) });
137
+ // `conversations` is present only when every ref that moved was some conversation's own (its branch `agent/<id>`, the
138
+ // shelf an archive parks it on, the pins its carry and drop leave, a runner's delivery of its turn): those
139
+ // conversations, whose reviews (and their children's) are all such a move can change. Absent when anything else moved
140
+ // (the main line, a named branch, a tag, a fetch) or the daemon cannot say, which reaches every review.
141
+ export const RefsChangedSchema = z.object({
142
+ kind: z.literal("refsChanged"),
143
+ repos: z.array(z.string()),
144
+ conversations: z.array(z.string()).optional(),
145
+ });
138
146
  export type RefsChanged = z.infer<typeof RefsChangedSchema>;
139
147
 
140
148
  // Which running-thing domain just moved (a session, a port, a browser, a subagent); none of it lives on disk, so
141
149
  // `workspaceChanged` can't name it. Carries only the domain, never the roster, so an uninvolved tab pays no request.
142
- export const RuntimeChangedSchema = z.object({ kind: z.literal("runtimeChanged"), domains: z.array(z.string()) });
150
+ // `draftsGeneration`, beside a `drafts` domain: how many times the reader's own drafts and marks had moved in this
151
+ // daemon's run as the frame went out (a write or a clear answers with the count it made), so a window that made every
152
+ // one of those moves itself holds them already and has nothing to read back.
153
+ export const RuntimeChangedSchema = z.object({
154
+ kind: z.literal("runtimeChanged"),
155
+ domains: z.array(z.string()),
156
+ draftsGeneration: z.number().int().nonnegative().optional(),
157
+ });
143
158
  export type RuntimeChanged = z.infer<typeof RuntimeChangedSchema>;
144
159
 
145
160
  // One connected browser tab of a sandbox member; identity from the verified Google ID token, activity from the tab's
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ import { getEventIteratorSchemaDetails, isContractProcedure } from "@orpc/contra
2
2
  import type { z } from "zod";
3
3
  import { RAW_JSON_ROUTES } from "./protocol/raw/raw-json-routes.js";
4
4
  import { RAW_ROUTE_LIST } from "./protocol/raw/raw-routes.js";
5
- import { type ContractRoute,contractRoutes,rawRouteFingerprintsOf,requestPathFor,routeForProcedure,routeNameForRequest,routePrintsOf,type RoutePrints,routeShapes,servedRoute } from "./protocol/routes.js";
5
+ import { type ContractRoute,contractRoutes,rawRouteFingerprintsOf,requestPathFor,routeForProcedure,routeNameForRequest,routePrintsOf,type RoutePrints,routeShapes,routeSurfaceOf,type RouteSurface,servedRoute } from "./protocol/routes.js";
6
6
  import { accessProfilesContract } from "./contracts/access-profiles.contract.js";
7
7
  import { accountsContract } from "./contracts/accounts.contract.js";
8
8
  import { activityContract } from "./contracts/activity.contract.js";
@@ -199,7 +199,20 @@ export const rawRouteFingerprints = (): Readonly<Record<string, string>> => (raw
199
199
  // memoised like the first, for the same startup reason.
200
200
  let routePrints: Readonly<Record<string, RoutePrints>> | undefined;
201
201
  export const sandboxRoutePrints = (): Readonly<Record<string, RoutePrints>> => (routePrints ??= routePrintsOf(sandboxContract, RAW_JSON_ROUTES));
202
- export type { RoutePrints };
202
+ export type { RoutePrints, RouteSurface };
203
+
204
+ // All three of the above for the daemon, whose every /events connection opens with them (the hello frame): worked out
205
+ // together in short slices with the thread handed back between them, and kept in the same three memos. Measured
206
+ // 2026-11-06: worked out one map after another, they held the daemon's main thread for 0.4-0.9 s on its first hello
207
+ // after each boot, while every other request waited; together, each route's schemas are converted once, not up to six
208
+ // times.
209
+ let surface: Promise<RouteSurface> | undefined;
210
+ export const sandboxRouteSurface = (): Promise<RouteSurface> =>
211
+ (surface ??= routeSurfaceOf(sandboxContract, RAW_JSON_ROUTES).then((worked) => ({
212
+ fingerprints: (fingerprints ??= worked.fingerprints),
213
+ rawFingerprints: (rawFingerprints ??= worked.rawFingerprints),
214
+ prints: (routePrints ??= worked.prints),
215
+ })));
203
216
 
204
217
  // The contract route a concrete browser request belongs to, bound to this build's route table.
205
218
  export const sandboxRouteName = (method: string, pathWithQuery: string): string | undefined =>
@@ -1,9 +1,9 @@
1
1
  import { eventIterator, oc } from "@orpc/contract";
2
2
  import { z } from "zod";
3
3
  import { RAW_JSON_ROUTES } from "./raw/raw-json-routes.js";
4
- import { RAW_ROUTE_NAMES, rawRouteFingerprints, SANDBOX_ROUTE_NAMES, SANDBOX_ROUTES, sandboxRouteName, sandboxRouteFingerprints, sandboxRoutePrints } from "../index.js";
4
+ import { RAW_ROUTE_NAMES, rawRouteFingerprints, SANDBOX_ROUTE_NAMES, SANDBOX_ROUTES, sandboxContract, sandboxRouteFingerprints, sandboxRouteName, sandboxRoutePrints, sandboxRouteSurface } from "../index.js";
5
5
  import { procedure } from "./route-meta.js";
6
- import { contractRoutes, routeNameForRequest, routePrintsOf, routeShapes, servedRoute, streamOf } from "./routes.js";
6
+ import { contractRoutes, rawRouteFingerprintsOf, routeNameForRequest, routePrintsOf, routeShapes, routeSurfaceOf, servedRoute, streamOf } from "./routes.js";
7
7
 
8
8
  const fixture = {
9
9
  vpn: {
@@ -295,6 +295,42 @@ describe(`routePrintsOf`, () => {
295
295
  });
296
296
  });
297
297
 
298
+ describe(`routeSurfaceOf`, () => {
299
+ // A streamed route, a route oRPC's bare eventIterator leaves inexpressible, and raw routes beside them.
300
+ const contract = {
301
+ vpn: {
302
+ list: oc.route({ method: "GET", path: "/vpn" }).input(z.object({ q: z.string().default(`x`) })).output(z.object({ a: z.string() })),
303
+ watch: oc.route({ method: "GET", path: "/vpn/watch" }).output(streamOf(z.object({ a: z.string() }))),
304
+ hidden: oc.route({ method: "GET", path: "/vpn/hidden" }).output(eventIterator(z.object({ a: z.string() }))),
305
+ },
306
+ };
307
+ const raw = { "GET /x": { output: z.object({ a: z.string() }) }, "POST /y": { input: z.object({ b: z.number() }), output: z.object({}) } };
308
+
309
+ it(`is the three maps it stands for, entry for entry and in their order`, async () => {
310
+ const surface = await routeSurfaceOf(contract, raw);
311
+ expect(Object.entries(surface.fingerprints)).toEqual(Object.entries(routeShapes(contract)));
312
+ expect(Object.entries(surface.rawFingerprints)).toEqual(Object.entries(rawRouteFingerprintsOf(raw)));
313
+ expect(Object.entries(surface.prints)).toEqual(Object.entries(routePrintsOf(contract, raw)));
314
+ expect(Object.keys(surface.fingerprints)).toEqual([`vpn.list`, `vpn.watch`]);
315
+ expect(Object.keys(surface.prints)).toEqual([`vpn.list`, `vpn.watch`, `GET /x`, `POST /y`]);
316
+ });
317
+
318
+ it(`hands the thread back between slices, so a timer set before it runs before it ends`, async () => {
319
+ const order: string[] = [];
320
+ setTimeout(() => order.push(`timer`), 0);
321
+ await routeSurfaceOf(contract, raw, 0).then(() => order.push(`surface`));
322
+ expect(order).toEqual([`timer`, `surface`]);
323
+ });
324
+
325
+ // The daemon's hello reads the sliced surface and a browser the three maps one by one: one print each, or a
326
+ // browser would read its own daemon as drifted.
327
+ it(`prints the real contract exactly as the three maps do`, async () => {
328
+ const surface = await routeSurfaceOf(sandboxContract, RAW_JSON_ROUTES);
329
+ expect(surface).toEqual({ fingerprints: routeShapes(sandboxContract), rawFingerprints: rawRouteFingerprintsOf(RAW_JSON_ROUTES), prints: routePrintsOf(sandboxContract, RAW_JSON_ROUTES) });
330
+ expect(await sandboxRouteSurface()).toEqual({ fingerprints: sandboxRouteFingerprints(), rawFingerprints: rawRouteFingerprints(), prints: sandboxRoutePrints() });
331
+ });
332
+ });
333
+
298
334
  describe(`the real sandbox contract`, () => {
299
335
  it(`fingerprints every route, streams included`, () => {
300
336
  // Nothing may opt out: a route with no fingerprint is a route the browser can never tell has drifted, and the
@@ -1,3 +1,4 @@
1
+ import { sleep } from "@intentic/base/async";
1
2
  import { z } from "zod";
2
3
  import type { RouteMeta } from "./route-meta.js";
3
4
  import { fillRoutePath } from "./raw/route-path.js";
@@ -186,31 +187,68 @@ interface RawRouteSchemas {
186
187
  readonly output?: unknown;
187
188
  }
188
189
 
189
- // One side of a route as JSON for the prints. SAFETY: wireShape is z.toJSONSchema's output (or a `{ stream }` wrapper
190
- // around it, or undefined for a side with no schema), which is JSON by construction; undefined becomes null so the
191
- // side still counts.
192
- const sideOf = (route: RawRouteSchemas, side: keyof RawRouteSchemas, io: "input" | "output"): Json => (wireShape(route[side], io) ?? null) as Json;
190
+ // The schema one side of a route declares, as oRPC or a raw table carries it (read structurally, like `~orpc` above).
191
+ type SideSchema = RawRouteSchemas["input"];
192
+ // One side of a route as JSON for the prints, or undefined for a side with no schema.
193
+ type SideJson = Json | undefined;
194
+ // How a walk turns a side into its JSON: each time afresh, or once per route (convertingOnce).
195
+ type SideConverter = (schema: SideSchema, io: "input" | "output") => SideJson;
196
+
197
+ // SAFETY: wireShape is z.toJSONSchema's output (or a `{ stream }` wrapper around it, or undefined for a side with no
198
+ // schema), which is JSON by construction.
199
+ const convertEach: SideConverter = (schema, io) => wireShape(schema, io) as SideJson;
200
+
201
+ // convertEach remembering its answers, made for one route and dropped with it. The prints read that route's input as
202
+ // input three times and its output as output twice, and a hand-written route is printed into two maps; z.toJSONSchema
203
+ // is nearly all of a print's cost (measured 2026-11-06: 0.4-0.9 s of a daemon's main thread on its first hello), and
204
+ // every reader here only reads what it returns. A conversion that throws is not remembered, so it throws again for every
205
+ // print that asks, as it did before.
206
+ const convertingOnce = (): SideConverter => {
207
+ const known = new Map<SideSchema, Map<"input" | "output", SideJson>>();
208
+ return (schema, io) => {
209
+ const sides = known.get(schema) ?? new Map<"input" | "output", SideJson>();
210
+ known.set(schema, sides);
211
+ if (!sides.has(io)) {
212
+ sides.set(io, convertEach(schema, io));
213
+ }
214
+ return sides.get(io);
215
+ };
216
+ };
217
+
218
+ // One side of a route as JSON for the prints; undefined becomes null so the side still counts.
219
+ const sideOf = (route: RawRouteSchemas, side: keyof RawRouteSchemas, io: "input" | "output", convert: SideConverter): Json => convert(route[side], io) ?? null;
193
220
 
194
221
  // Both prints of one route's two sides. The wire reads each side as the first print does (a `.default()` field is
195
222
  // optional in, required out); the core reads both as a parser does.
196
- const printsOf = (route: RawRouteSchemas): RoutePrints => [
197
- fingerprint(pruned({ in: sideOf(route, "input", "input"), out: sideOf(route, "output", "output") }, false)),
198
- fingerprint(pruned({ in: sideOf(route, "input", "input"), out: sideOf(route, "output", "input") }, true)),
223
+ const printsOf = (route: RawRouteSchemas, convert: SideConverter = convertingOnce()): RoutePrints => [
224
+ fingerprint(pruned({ in: sideOf(route, "input", "input", convert), out: sideOf(route, "output", "output", convert) }, false)),
225
+ fingerprint(pruned({ in: sideOf(route, "input", "input", convert), out: sideOf(route, "output", "input", convert) }, true)),
199
226
  ];
200
227
 
201
- // One route's wire shape, or undefined if it can't be expressed at all.
202
- const procedureShape = (value: unknown): string | undefined => {
203
- if (typeof value !== "object" || value === null || !("~orpc" in value)) {
228
+ // Both prints, or undefined if the route's shape can't be expressed at all.
229
+ const printsOrNone = (route: RawRouteSchemas, convert?: SideConverter): RoutePrints | undefined => {
230
+ try {
231
+ return printsOf(route, convert);
232
+ } catch {
233
+ // allow(silent-catch): a schema z.toJSONSchema cannot express (z.custom, oRPC's bare eventIterator) leaves its route unprinted, never the walk failed.
204
234
  return undefined;
205
235
  }
206
- const { inputSchema, outputSchema } = (value as ContractSchemasLike)["~orpc"];
236
+ };
237
+
238
+ // The first print of a route's two sides, or undefined if they can't be expressed at all. A `text` or `bytes` raw route
239
+ // declares no input schema; its body is the document or the bytes, and the print is its answer alone.
240
+ const firstPrintOf = (route: RawRouteSchemas, convert: SideConverter = convertEach): string | undefined => {
207
241
  try {
208
- return fingerprint({ in: wireShape(inputSchema, "input"), out: wireShape(outputSchema, "output") });
242
+ return fingerprint({ in: convert(route.input, "input"), out: convert(route.output, "output") });
209
243
  } catch {
244
+ // allow(silent-catch): as printsOrNone, a route whose schema cannot be expressed keeps its name and loses only its print.
210
245
  return undefined;
211
246
  }
212
247
  };
213
248
 
249
+ // A procedure's two schemas, as oRPC hangs them off it.
250
+ const schemasOf = (procedure: ContractSchemasLike): RawRouteSchemas => ({ input: procedure["~orpc"].inputSchema, output: procedure["~orpc"].outputSchema });
251
+
214
252
  // Every procedure of a contract that has a route, as `group.name` → procedure; the one walk every print shares.
215
253
  function* routedProcedures(contract: Record<string, unknown>): Generator<readonly [string, ContractSchemasLike]> {
216
254
  for (const [group, procedures] of Object.entries(contract)) {
@@ -231,7 +269,7 @@ function* routedProcedures(contract: Record<string, unknown>): Generator<readonl
231
269
  export const routeShapes = (contract: Record<string, unknown>): Record<string, string> => {
232
270
  const shapes: Record<string, string> = {};
233
271
  for (const [name, procedure] of routedProcedures(contract)) {
234
- const shape = procedureShape(procedure);
272
+ const shape = firstPrintOf(schemasOf(procedure));
235
273
  if (shape !== undefined) {
236
274
  shapes[name] = shape;
237
275
  }
@@ -244,15 +282,11 @@ export const routeShapes = (contract: Record<string, unknown>): Record<string, s
244
282
  // above.
245
283
  export const routePrintsOf = (contract: Record<string, unknown>, raw: Readonly<Record<string, RawRouteSchemas>>) => {
246
284
  const prints: Record<string, RoutePrints> = {};
247
- const sides: (readonly [string, RawRouteSchemas])[] = [
248
- ...[...routedProcedures(contract)].map(([name, procedure]) => [name, { input: procedure["~orpc"].inputSchema, output: procedure["~orpc"].outputSchema }] as const),
249
- ...Object.entries(raw),
250
- ];
285
+ const sides: (readonly [string, RawRouteSchemas])[] = [...[...routedProcedures(contract)].map(([name, procedure]) => [name, schemasOf(procedure)] as const), ...Object.entries(raw)];
251
286
  for (const [name, route] of sides) {
252
- try {
253
- prints[name] = printsOf(route);
254
- } catch {
255
- continue;
287
+ const both = printsOrNone(route);
288
+ if (both !== undefined) {
289
+ prints[name] = both;
256
290
  }
257
291
  }
258
292
  return prints;
@@ -262,20 +296,79 @@ export const routePrintsOf = (contract: Record<string, unknown>, raw: Readonly<R
262
296
  // rather than through oRPC, so they need their own walk — and without one they were the half of the surface no version
263
297
  // check could see: a browser calling a raw route an older daemon predates got a bare 404 with nothing to say about it.
264
298
  // The table is passed in rather than imported, so this file stays free of the raw tables that read its types.
265
- export const rawRouteFingerprintsOf = (table: Record<string, { readonly input?: unknown; readonly output?: unknown }>) => {
299
+ export const rawRouteFingerprintsOf = (table: Record<string, RawRouteSchemas>) => {
266
300
  const prints: Record<string, string> = {};
267
301
  for (const [name, route] of Object.entries(table)) {
268
- try {
269
- // A `text` or `bytes` route declares no input schema; its body is the document or the bytes, and the
270
- // fingerprint is its answer alone.
271
- prints[name] = fingerprint({ in: wireShape(route.input, "input"), out: wireShape(route.output, "output") });
272
- } catch {
273
- continue;
302
+ const print = firstPrintOf(route);
303
+ if (print !== undefined) {
304
+ prints[name] = print;
274
305
  }
275
306
  }
276
307
  return prints;
277
308
  };
278
309
 
310
+ // All three maps above at once, what a daemon's hello carries: `fingerprints` is routeShapes, `rawFingerprints`
311
+ // rawRouteFingerprintsOf and `prints` routePrintsOf, entry for entry and in the same order.
312
+ export interface RouteSurface {
313
+ readonly fingerprints: Readonly<Record<string, string>>;
314
+ readonly rawFingerprints: Readonly<Record<string, string>>;
315
+ readonly prints: Readonly<Record<string, RoutePrints>>;
316
+ }
317
+
318
+ // The surface worked out one route per step, each route's schemas converted once for all its prints; whoever drives it
319
+ // decides when to hand the thread back between steps (routeSurfaceOf).
320
+ function* surfaceSteps(contract: Readonly<Record<string, object>>, raw: Readonly<Record<string, RawRouteSchemas>>): Generator<undefined, RouteSurface> {
321
+ const fingerprints: Record<string, string> = {};
322
+ const rawFingerprints: Record<string, string> = {};
323
+ const prints: Record<string, RoutePrints> = {};
324
+ for (const [name, procedure] of routedProcedures(contract)) {
325
+ const route = schemasOf(procedure);
326
+ const convert = convertingOnce();
327
+ const first = firstPrintOf(route, convert);
328
+ if (first !== undefined) {
329
+ fingerprints[name] = first;
330
+ }
331
+ const both = printsOrNone(route, convert);
332
+ if (both !== undefined) {
333
+ prints[name] = both;
334
+ }
335
+ yield undefined;
336
+ }
337
+ for (const [name, route] of Object.entries(raw)) {
338
+ const convert = convertingOnce();
339
+ const both = printsOrNone(route, convert);
340
+ if (both !== undefined) {
341
+ prints[name] = both;
342
+ }
343
+ const print = firstPrintOf(route, convert);
344
+ if (print !== undefined) {
345
+ rawFingerprints[name] = print;
346
+ }
347
+ yield undefined;
348
+ }
349
+ return { fingerprints, rawFingerprints, prints };
350
+ }
351
+
352
+ // How long the surface keeps the thread before handing it back: a few routes' worth, so a daemon's first hello is many
353
+ // short tasks between its other work rather than one block of half a second or more.
354
+ const SURFACE_SLICE_MS = 8;
355
+
356
+ // The surface, worked out in slices of `sliceMs` with a timer's turn between them, so I/O and timers run while it is.
357
+ export const routeSurfaceOf = async (contract: Readonly<Record<string, object>>, raw: Readonly<Record<string, RawRouteSchemas>>, sliceMs = SURFACE_SLICE_MS): Promise<RouteSurface> => {
358
+ const steps = surfaceSteps(contract, raw);
359
+ let sliceStart = performance.now();
360
+ for (;;) {
361
+ const step = steps.next();
362
+ if (step.done === true) {
363
+ return step.value;
364
+ }
365
+ if (performance.now() - sliceStart >= sliceMs) {
366
+ await sleep(0);
367
+ sliceStart = performance.now();
368
+ }
369
+ }
370
+ };
371
+
279
372
  // A template split once: a literal segment, or undefined for a `{param}`; `tail` for a raw route's trailing `/*`.
280
373
  interface Pattern {
281
374
  readonly route: ContractRoute;
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { starterLook } from "../models/agent-starter.js";
2
3
 
3
4
  // THE PEOPLE ON A CONVERSATION'S CARD: who answers for it, and who marked it. Their own module so agents.ts, the fleet's
4
5
  // summary, stays within its size; agents.ts re-exports every name, so importers keep reading them from there.
@@ -34,3 +35,97 @@ export const AgentReactionSchema = z.object({
34
35
  ),
35
36
  });
36
37
  export type AgentReaction = z.infer<typeof AgentReactionSchema>;
38
+
39
+ // WHO HEARS A CONVERSATION'S NEWS (the rule below reads both lists): the people who took part, and each
40
+ // person's own answer to how much of it they want. Only the people who took part hear it by default, not everyone
41
+ // sharing the sandbox.
42
+ export const PARTICIPATIONS = ["prompt", "answer", "land", "mention"] as const;
43
+ export const ParticipationSchema = z.enum(PARTICIPATIONS);
44
+ export type Participation = z.infer<typeof ParticipationSchema>;
45
+ export const ParticipantSchema = z.object({
46
+ email: z.string().describe("Who took part, lowercased, as the sandbox verified them (or as a prompt named them)."),
47
+ name: z.string().optional().describe("What to call them, when their sign-in carried a name."),
48
+ since: z.number().describe("When they first took part, in milliseconds."),
49
+ via: ParticipationSchema.describe(
50
+ "How they first took part: they sent it a message, answered one of its cards, asked to land it, or a message named them with @ and their address.",
51
+ ),
52
+ });
53
+ export type Participant = z.infer<typeof ParticipantSchema>;
54
+
55
+ // How much of one conversation's news reaches one person's devices, tab and sounds. `all`: every turn it finishes and
56
+ // every card it waits on; `asks`: only when it waits on them; `none`: nothing.
57
+ export const NOTIFY_LEVELS = ["all", "asks", "none"] as const;
58
+ export const NotifyLevelSchema = z.enum(NOTIFY_LEVELS);
59
+ export type NotifyLevel = z.infer<typeof NotifyLevelSchema>;
60
+ export const NotifyChoiceSchema = z.object({
61
+ email: z.string().describe("Whose answer it is, lowercased."),
62
+ level: NotifyLevelSchema.describe("What they asked to hear of this conversation."),
63
+ at: z.number().describe("When they chose it, in milliseconds."),
64
+ });
65
+ export type NotifyChoice = z.infer<typeof NotifyChoiceSchema>;
66
+ export const AgentNotifySchema = z.object({
67
+ id: z.string().min(1).describe("Which conversation."),
68
+ level: NotifyLevelSchema.nullable().describe(
69
+ "What you want to hear of it: `all` (every finished turn and every card), `asks` (only cards waiting on you), `none` (nothing). Null clears your answer and goes back to the default: `all` if you took part in it, else nothing.",
70
+ ),
71
+ });
72
+ export type AgentNotify = z.infer<typeof AgentNotifySchema>;
73
+
74
+ // WHO A CONVERSATION'S NEWS IS FOR, decided once for the daemon's pushes (push/audience.ts) and the editor's chime, tab
75
+ // and badge (browserTab.ts), so a phone and a tab never disagree about whether something was yours to hear.
76
+ // The people who took part hear it: whoever answers for it, whoever started it, and everyone who sent it a message,
77
+ // answered its cards, asked to land it or was named in one of its messages. Each person can say how much of it they
78
+ // want: everything, only what waits on them, or nothing. Anyone else hears nothing unless they asked to follow it.
79
+ // Whether they may see the conversation at all is a separate check, made where the roster is known (push.ts).
80
+
81
+ // What happened: a turn it finished, or a card it waits on a person to answer.
82
+ export type ConversationNews = "finished" | "asks";
83
+
84
+ // The facts on a conversation's summary and record this reads; both shapes carry them under these names.
85
+ export interface AudienceFacts {
86
+ readonly owner?: { readonly email: string } | undefined;
87
+ readonly startedBy?: string | undefined;
88
+ readonly participants?: readonly Pick<Participant, "email">[] | undefined;
89
+ readonly notify?: readonly Pick<NotifyChoice, "email" | "level">[] | undefined;
90
+ }
91
+
92
+ const same = (left: string, right: string): boolean => left.toLowerCase() === right.toLowerCase();
93
+
94
+ // A person's address, not a program's token label or a parent conversation (agent-starter.ts).
95
+ const personStarter = (startedBy: string | undefined): string | undefined =>
96
+ startedBy !== undefined && startedBy.includes("@") && starterLook(startedBy) === undefined ? startedBy : undefined;
97
+
98
+ /** Whether this person took part in the conversation: answers for it, started it, or is among its participants. */
99
+ export const tookPart = (facts: AudienceFacts, email: string): boolean =>
100
+ (facts.owner !== undefined && same(facts.owner.email, email)) ||
101
+ (personStarter(facts.startedBy) !== undefined && same(facts.startedBy ?? "", email)) ||
102
+ (facts.participants?.some((person) => same(person.email, email)) ?? false);
103
+
104
+ /** How much of this conversation reaches this person: their own answer, else everything if they took part, else nothing. */
105
+ export const notifyLevelOf = (facts: AudienceFacts, email: string): NotifyLevel =>
106
+ facts.notify?.find((choice) => same(choice.email, email))?.level ?? (tookPart(facts, email) ? "all" : "none");
107
+
108
+ /** Whether this news of the conversation is for this person. */
109
+ export const hears = (facts: AudienceFacts, email: string, news: ConversationNews): boolean => {
110
+ const level = notifyLevelOf(facts, email);
111
+ return level === "all" || (level === "asks" && news === "asks");
112
+ };
113
+
114
+ /** The facts the rule reads, off a stored conversation record (the daemon's registry entry). */
115
+ export const recordFacts = (record: { readonly identity: { readonly startedBy?: string | undefined }; readonly social: Omit<AudienceFacts, "startedBy"> }): AudienceFacts => ({
116
+ owner: record.social.owner,
117
+ startedBy: record.identity.startedBy,
118
+ participants: record.social.participants,
119
+ notify: record.social.notify,
120
+ });
121
+
122
+ /** Everyone this news is for, lowercased, each once, in the order they came to it. */
123
+ export const audienceOf = (facts: AudienceFacts, news: ConversationNews): string[] => {
124
+ const candidates = [
125
+ facts.owner?.email,
126
+ personStarter(facts.startedBy),
127
+ ...(facts.participants ?? []).map((person) => person.email),
128
+ ...(facts.notify ?? []).map((choice) => choice.email),
129
+ ].flatMap((email) => (email === undefined ? [] : [email.toLowerCase()]));
130
+ return [...new Set(candidates)].filter((email) => hears(facts, email, news));
131
+ };
@@ -14,10 +14,29 @@ import { StrandedCloneSchema } from "./stranded-clone.js";
14
14
  import { EMOJI_MAX_LENGTH, isSingleEmoji } from "../text/emoji.js";
15
15
  import { ProgramAskSchema } from "../events/requests.js";
16
16
  import { ReviewTallySchema, TurnProofSchema } from "./work-assurance.js";
17
- import { AgentReactionSchema, SessionOwnerSchema } from "./agent-people.js";
17
+ import { AgentReactionSchema, NotifyChoiceSchema, ParticipantSchema, SessionOwnerSchema } from "./agent-people.js";
18
18
  import { SEAL_VIEW_DESCRIPTION, SealViewSchema } from "./seal.js";
19
19
  import { LandConflictReasonSchema } from "./agent-land.js";
20
- export { AgentReactionSchema, ReactorSchema, SessionOwnerSchema, type AgentReaction, type Reactor, type SessionOwner } from "./agent-people.js";
20
+ export {
21
+ AgentNotifySchema,
22
+ AgentReactionSchema,
23
+ NOTIFY_LEVELS,
24
+ NotifyChoiceSchema,
25
+ NotifyLevelSchema,
26
+ PARTICIPATIONS,
27
+ ParticipantSchema,
28
+ ParticipationSchema,
29
+ ReactorSchema,
30
+ SessionOwnerSchema,
31
+ type AgentNotify,
32
+ type AgentReaction,
33
+ type NotifyChoice,
34
+ type NotifyLevel,
35
+ type Participant,
36
+ type Participation,
37
+ type Reactor,
38
+ type SessionOwner,
39
+ } from "./agent-people.js";
21
40
  // A fleet agent is any conversation with a registry entry, keyed by conversationId. Isolated ones own a git worktree
22
41
  // (branch agent/<id>); workspace conversations have none, but both share one status/activity/cost lifecycle.
23
42
 
@@ -401,6 +420,19 @@ export const AgentSummarySchema = z.object({
401
420
  owner: SessionOwnerSchema.optional().describe(
402
421
  "The member answerable for this conversation: set from whoever started it, inherited from the parent by a spawned child, moved by handing it over. Absent means nobody has claimed it yet.",
403
422
  ),
423
+ // Who hears its news beside its owner and starter, and how much each asked to (schemas/agent-people.ts).
424
+ participants: z
425
+ .array(ParticipantSchema)
426
+ .optional()
427
+ .describe(
428
+ "The people who took part in it besides whoever started it: sent it a message, answered its cards, asked to land it, or were named in a message. They hear its news by default. Absent means nobody beyond its starter and owner has.",
429
+ ),
430
+ notify: z
431
+ .array(NotifyChoiceSchema)
432
+ .optional()
433
+ .describe(
434
+ "Your own answer to how much of this conversation's news reaches you, when you gave one; nobody else's answer is shown to you. Absent means you follow the default: everything if you took part in it, else nothing.",
435
+ ),
404
436
  // Recorded once on the fork's first turn and never cleared; rides the summary so the link survives closing and
405
437
  // reopening either tab.
406
438
  forkedFrom: ForkedFromSchema.optional().describe(
@@ -438,6 +438,13 @@ export const AutomationSchema = z.object({
438
438
  "Which shelf of the Automations panel it is filed on, like 'Marketing' or 'Releases'. Automations naming the same group are listed together. Absent files it under its persona, or with the code chores.",
439
439
  ),
440
440
  enabled: z.boolean().describe("Whether it fires at all."),
441
+ // Stamped by the sandbox on its first save (automation-save.ts), whatever a request sends: who its notices are for.
442
+ createdBy: z
443
+ .string()
444
+ .optional()
445
+ .describe(
446
+ "Who made it, as the sandbox recorded it: a member's email, or agent:<conversation id> for one an agent proposed and a person approved. Its notices (a watch firing or ending, a one-time wake done) go to them. Set by the sandbox; a value sent with a save is ignored. Absent on one made before it was kept, whose notices go to the sandbox's owner and maintainers.",
447
+ ),
441
448
  });
442
449
  export type Automation = z.infer<typeof AutomationSchema>;
443
450
  // A wake held for owner approval (automation-holds/<id>.json on the history volume); snapshots the trigger payload so an approved