@intentic/sandbox-contract 1.409.0 → 1.410.1

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 (103) hide show
  1. package/dist/contracts/accounts.contract.d.ts +0 -16
  2. package/dist/contracts/accounts.contract.d.ts.map +1 -1
  3. package/dist/contracts/agent.contract.d.ts +5 -0
  4. package/dist/contracts/agent.contract.d.ts.map +1 -1
  5. package/dist/contracts/capabilities.contract.d.ts +0 -12
  6. package/dist/contracts/capabilities.contract.d.ts.map +1 -1
  7. package/dist/contracts/hub.contract.d.ts +121 -0
  8. package/dist/contracts/hub.contract.d.ts.map +1 -0
  9. package/dist/contracts/hub.contract.js +32 -0
  10. package/dist/contracts/hub.contract.js.map +1 -0
  11. package/dist/contracts/secrets.contract.d.ts +1 -73
  12. package/dist/contracts/secrets.contract.d.ts.map +1 -1
  13. package/dist/contracts/secrets.contract.js +4 -20
  14. package/dist/contracts/secrets.contract.js.map +1 -1
  15. package/dist/events/sandbox-notice.d.ts +1 -0
  16. package/dist/events/sandbox-notice.d.ts.map +1 -1
  17. package/dist/events/sandbox-notice.js +1 -1
  18. package/dist/events/sandbox-notice.js.map +1 -1
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +2 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/protocol/doors/runner-wake.d.ts +46 -0
  24. package/dist/protocol/doors/runner-wake.d.ts.map +1 -0
  25. package/dist/protocol/doors/runner-wake.js +21 -0
  26. package/dist/protocol/doors/runner-wake.js.map +1 -0
  27. package/dist/protocol/raw/raw-json-routes.d.ts +14 -145
  28. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  29. package/dist/protocol/raw/raw-json-routes.js +1 -6
  30. package/dist/protocol/raw/raw-json-routes.js.map +1 -1
  31. package/dist/protocol/raw/raw-routes.d.ts +4 -16
  32. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  33. package/dist/protocol/raw/raw-routes.js +1 -4
  34. package/dist/protocol/raw/raw-routes.js.map +1 -1
  35. package/dist/schemas/agent.d.ts +3 -0
  36. package/dist/schemas/agent.d.ts.map +1 -1
  37. package/dist/schemas/agent.js +4 -0
  38. package/dist/schemas/agent.js.map +1 -1
  39. package/dist/schemas/capabilities.d.ts +0 -8
  40. package/dist/schemas/capabilities.d.ts.map +1 -1
  41. package/dist/schemas/capabilities.js +0 -4
  42. package/dist/schemas/capabilities.js.map +1 -1
  43. package/dist/schemas/connection-hub.d.ts +347 -0
  44. package/dist/schemas/connection-hub.d.ts.map +1 -0
  45. package/dist/schemas/connection-hub.js +118 -0
  46. package/dist/schemas/connection-hub.js.map +1 -0
  47. package/dist/schemas/diagnostics.d.ts +22 -1
  48. package/dist/schemas/diagnostics.d.ts.map +1 -1
  49. package/dist/schemas/diagnostics.js +13 -1
  50. package/dist/schemas/diagnostics.js.map +1 -1
  51. package/dist/schemas/links.d.ts +0 -21
  52. package/dist/schemas/links.d.ts.map +1 -1
  53. package/dist/schemas/links.js +1 -9
  54. package/dist/schemas/links.js.map +1 -1
  55. package/dist/schemas/providers/plan-limits.d.ts +5 -0
  56. package/dist/schemas/providers/plan-limits.d.ts.map +1 -1
  57. package/dist/schemas/providers/plan-limits.js +4 -0
  58. package/dist/schemas/providers/plan-limits.js.map +1 -1
  59. package/dist/schemas/providers/provider-oauth.d.ts +0 -16
  60. package/dist/schemas/providers/provider-oauth.d.ts.map +1 -1
  61. package/dist/schemas/providers/provider-oauth.js +0 -4
  62. package/dist/schemas/providers/provider-oauth.js.map +1 -1
  63. package/dist/schemas/sandbox-passwords.d.ts +0 -142
  64. package/dist/schemas/sandbox-passwords.d.ts.map +1 -1
  65. package/dist/schemas/sandbox-passwords.js +1 -33
  66. package/dist/schemas/sandbox-passwords.js.map +1 -1
  67. package/dist/state/auth-state.d.ts.map +1 -1
  68. package/dist/state/auth-state.js +1 -0
  69. package/dist/state/auth-state.js.map +1 -1
  70. package/dist/state/definition.d.ts +0 -8
  71. package/dist/state/definition.d.ts.map +1 -1
  72. package/dist/text/notice-rows.d.ts.map +1 -1
  73. package/dist/text/notice-rows.js +1 -0
  74. package/dist/text/notice-rows.js.map +1 -1
  75. package/package.json +5 -5
  76. package/src/contracts/hub.contract.ts +39 -0
  77. package/src/contracts/secrets.contract.ts +5 -21
  78. package/src/events/sandbox-notice.ts +5 -4
  79. package/src/index.ts +3 -3
  80. package/src/protocol/doors/runner-wake.ts +36 -0
  81. package/src/protocol/raw/raw-json-routes.ts +0 -10
  82. package/src/protocol/raw/raw-routes.ts +2 -7
  83. package/src/schemas/agent.ts +8 -0
  84. package/src/schemas/capabilities.ts +0 -6
  85. package/src/schemas/connection-hub.test.ts +28 -0
  86. package/src/schemas/connection-hub.ts +191 -0
  87. package/src/schemas/diagnostics.ts +19 -2
  88. package/src/schemas/links.ts +4 -15
  89. package/src/schemas/providers/plan-limits.ts +6 -0
  90. package/src/schemas/providers/provider-oauth.ts +0 -6
  91. package/src/schemas/sandbox-passwords.ts +5 -46
  92. package/src/state/auth-state.ts +3 -0
  93. package/src/text/notice-rows.ts +2 -0
  94. package/dist/contracts/sharing.contract.d.ts +0 -58
  95. package/dist/contracts/sharing.contract.d.ts.map +0 -1
  96. package/dist/contracts/sharing.contract.js +0 -41
  97. package/dist/contracts/sharing.contract.js.map +0 -1
  98. package/dist/schemas/providers/account-sharing.d.ts +0 -277
  99. package/dist/schemas/providers/account-sharing.d.ts.map +0 -1
  100. package/dist/schemas/providers/account-sharing.js +0 -68
  101. package/dist/schemas/providers/account-sharing.js.map +0 -1
  102. package/src/contracts/sharing.contract.ts +0 -54
  103. package/src/schemas/providers/account-sharing.ts +0 -123
@@ -0,0 +1,191 @@
1
+ import { z } from "zod";
2
+ import { KEYRING_NAME_RE } from "./keyring.js";
3
+
4
+ // THE CONNECTIONS HUB: the keyring on one of the owner's computers as the place their connections live, so a sandbox can
5
+ // put one there and any other of their sandboxes can take it. Nothing new runs on the computer: a hub item is an
6
+ // ordinary keyring `text` entry whose value is the envelope below, put there through the keyring's inbox (a person's
7
+ // yes at the computer) and shared back in `copy` mode, so a sandbox holds a sealed copy that works with the computer off
8
+ // and changes when the entry does. The sandbox turns each copy it holds into the card or account the envelope describes,
9
+ // and takes it away again when the computer stops sharing it.
10
+ //
11
+ // Only credentials that do not rotate travel. A sign-in whose refresh token is renewed (a Claude or Codex subscription,
12
+ // an OAuth card) would sign the other copies out at its first renewal, so each sandbox signs in to those itself.
13
+
14
+ // Every hub entry's name starts so; the rest is a readable slug and a random tail, since a sandbox cannot see the entries
15
+ // another put there and an inbox item under a name already taken replaces that entry.
16
+ export const HUB_ENTRY_PREFIX = "CONNECTION_";
17
+ export const isHubEntryName = (name: string): boolean => name.startsWith(HUB_ENTRY_PREFIX) && KEYRING_NAME_RE.test(name);
18
+
19
+ /** The keyring copies an agent may spend by name: every one but the hub's own, which only the daemon reads. */
20
+ export const withoutHubEntries = (copies: Readonly<Record<string, string>>): Readonly<Record<string, string>> =>
21
+ Object.fromEntries(Object.entries(copies).filter(([name]) => !isHubEntryName(name)));
22
+
23
+ // The guard a hub entry carries as its only host. `.invalid` never resolves (RFC 2606), so the copy, which the sandbox
24
+ // keeps like any secret, can never be sent anywhere by a `{{secret:…}}` reference; and a sandbox asking for one finds it
25
+ // by this host through the keyring's ordinary need, which matches entries by host.
26
+ export const HUB_HOST_SUFFIX = "connections.invalid";
27
+
28
+ // The card kinds that travel: a CLI connector (its provider's own card), a remote tool server, a model endpoint. Every
29
+ // other kind is tied to where it was made (a computer, a disk, a link) or runs something of its own.
30
+ export const HubCardKindSchema = z.enum(["cli", "mcp", "endpoint"]);
31
+ export type HubCardKind = z.infer<typeof HubCardKindSchema>;
32
+
33
+ // The model providers whose account is a key that does not rotate: what a sign-in there would write is the whole
34
+ // account: Cursor and Devin keys, and the minted Z.ai and Meta keys. (Endpoints are cards, above.)
35
+ export const HUB_ACCOUNT_PROVIDERS = ["cursor", "devin", "zai", "meta"] as const;
36
+ export const HubAccountProviderSchema = z.enum(HUB_ACCOUNT_PROVIDERS);
37
+ export type HubAccountProvider = z.infer<typeof HubAccountProviderSchema>;
38
+
39
+ // One static account, the fields every static store keeps. Only a sandbox's daemon ever reads one.
40
+ export const StaticAccountCopySchema = z.object({
41
+ label: z.string().max(200).optional(),
42
+ email: z.string().max(320).optional(),
43
+ variant: z.string().max(100).optional().describe("Which sign-in estate a minted key belongs to (Z.ai's international or mainland plan)."),
44
+ plan: z.string().max(100).optional(),
45
+ apiKey: z.string().min(1).max(8192),
46
+ apiKeyExpiresAtMs: z.number().optional(),
47
+ backendUrl: z.string().max(500).optional(),
48
+ });
49
+ export type StaticAccountCopy = z.infer<typeof StaticAccountCopySchema>;
50
+
51
+ const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,40}$/u;
52
+
53
+ // What one hub entry holds. `card.config` carries the card's credential fields beside its settings, which the receiving
54
+ // sandbox vaults exactly as a card added there would be; it is checked against that sandbox's own card schema there.
55
+ export const HubCardItemSchema = z
56
+ .object({
57
+ type: z.literal("card"),
58
+ id: z.string().min(1).max(60).describe("The card's id where it was saved, kept where it is free."),
59
+ kind: HubCardKindSchema,
60
+ connector: z.string().regex(SLUG_RE).optional().describe("A CLI card's connector (its `provider`), which another sandbox asks for it by."),
61
+ config: z.record(z.string(), z.unknown()),
62
+ })
63
+ .strict();
64
+ export const HubAccountItemSchema = z.object({ type: z.literal("account"), provider: HubAccountProviderSchema, account: StaticAccountCopySchema }).strict();
65
+ export const HubItemSchema = z.discriminatedUnion("type", [HubCardItemSchema, HubAccountItemSchema]);
66
+ export type HubItem = z.infer<typeof HubItemSchema>;
67
+
68
+ export const ConnectionEnvelopeSchema = z
69
+ .object({
70
+ intentic: z.literal("connection"),
71
+ v: z.literal(1),
72
+ label: z.string().min(1).max(200).describe("What the connection is called, for the rows that list it."),
73
+ from: z.object({ sandbox: z.string().max(200), at: z.number() }).strict().describe("Where and when it was saved."),
74
+ item: HubItemSchema,
75
+ })
76
+ .strict();
77
+ export type ConnectionEnvelope = z.infer<typeof ConnectionEnvelopeSchema>;
78
+
79
+ // What a sandbox asks the computer for: one connector's card, any card of a kind that has no connector (a tool server,
80
+ // a model endpoint), or one provider's static account.
81
+ export const HubWantSchema = z.discriminatedUnion("type", [
82
+ z.object({ type: z.literal("card"), kind: HubCardKindSchema, connector: z.string().regex(SLUG_RE).optional() }).strict(),
83
+ z.object({ type: z.literal("account"), provider: HubAccountProviderSchema }).strict(),
84
+ ]);
85
+ export type HubWant = z.infer<typeof HubWantSchema>;
86
+
87
+ /** The host a hub entry for `want` carries, and a need for it asks by. A connector's card is found by its connector alone. */
88
+ export const hubHostOf = (want: HubWant): string => {
89
+ if (want.type === "account") {
90
+ return `${want.provider}.account.${HUB_HOST_SUFFIX}`;
91
+ }
92
+ return want.kind === "cli" && want.connector !== undefined ? `${hubSlug(want.connector)}.cli.${HUB_HOST_SUFFIX}` : `${want.kind}.${HUB_HOST_SUFFIX}`;
93
+ };
94
+
95
+ /** What a hub item answers to: the want a sandbox would ask with to be offered it. */
96
+ export const wantOfItem = (item: HubItem): HubWant => {
97
+ if (item.type === "account") {
98
+ return { type: "account", provider: item.provider };
99
+ }
100
+ return item.kind === "cli" && item.connector !== undefined ? { type: "card", kind: item.kind, connector: item.connector } : { type: "card", kind: item.kind };
101
+ };
102
+
103
+ /** A fresh entry name for an item: readable in the Passwords app, and unlikely to meet another sandbox's. */
104
+ export const hubEntryName = (item: HubItem, tail: string): string => {
105
+ const what = item.type === "account" ? item.provider : (item.connector ?? item.kind);
106
+ const readable = what
107
+ .toUpperCase()
108
+ .replace(/[^A-Z0-9]+/gu, "_")
109
+ .replace(/^_+|_+$/gu, "")
110
+ .slice(0, 40);
111
+ return `${HUB_ENTRY_PREFIX}${readable === "" ? "ITEM" : readable}_${tail.toUpperCase().replace(/[^A-Z0-9]/gu, "")}`;
112
+ };
113
+
114
+ /** A connector id as a hub slug: lower case, letters, digits and dashes. */
115
+ export const hubSlug = (value: string): string =>
116
+ value
117
+ .toLowerCase()
118
+ .replace(/[^a-z0-9-]+/gu, "-")
119
+ .replace(/^-+|-+$/gu, "")
120
+ .slice(0, 40) || "x";
121
+
122
+ /* THE ROUTES, called by the owner's editor. */
123
+
124
+ // What a saved or taken connection is here: a card by its id, or a provider's account by its id there.
125
+ export const HubTargetSchema = z.discriminatedUnion("type", [
126
+ z.object({ type: z.literal("card"), id: z.string().min(1).max(60) }).strict(),
127
+ z.object({ type: z.literal("account"), provider: HubAccountProviderSchema, id: z.string().min(1).max(200) }).strict(),
128
+ ]);
129
+ export type HubTarget = z.infer<typeof HubTargetSchema>;
130
+ export const sameHubTarget = (a: HubTarget, b: HubTarget): boolean =>
131
+ a.type === "card" ? b.type === "card" && a.id === b.id : b.type === "account" && a.provider === b.provider && a.id === b.id;
132
+
133
+ // A computer whose keyring could hold the hub.
134
+ export const HubComputerSchema = z.object({
135
+ machine: z.string(),
136
+ online: z.boolean(),
137
+ setUp: z.boolean().describe("Its keyring is installed and set up, so it can take a connection in."),
138
+ locked: z.boolean().optional(),
139
+ });
140
+ export type HubComputer = z.infer<typeof HubComputerSchema>;
141
+
142
+ // One card or account held here, and whether it can go to the hub.
143
+ export const HubHoldingSchema = z.object({
144
+ target: HubTargetSchema,
145
+ label: z.string(),
146
+ want: HubWantSchema.optional().describe("What another sandbox asks with to be offered it. Absent when it cannot go."),
147
+ reason: z.string().optional().describe("Why it cannot go to the hub, in words a person can act on. Absent when it can."),
148
+ saved: z
149
+ .object({
150
+ entry: z.string().regex(KEYRING_NAME_RE),
151
+ machine: z.string(),
152
+ at: z.number(),
153
+ pending: z.boolean().describe("It waits for a yes at the computer (the keyring was locked when it was sent)."),
154
+ })
155
+ .optional()
156
+ .describe("It was saved to the hub from here: which entry, on which computer."),
157
+ from: z
158
+ .object({ entry: z.string(), machine: z.string().optional() })
159
+ .optional()
160
+ .describe("It was made here from a hub entry: which, and the computer that shares it. It goes when that computer stops sharing it."),
161
+ });
162
+ export type HubHolding = z.infer<typeof HubHoldingSchema>;
163
+
164
+ // A hub entry shared here that could not be turned into a connection, with why.
165
+ export const HubFailureSchema = z.object({ entry: z.string(), machine: z.string().optional(), message: z.string(), at: z.number() });
166
+ export type HubFailure = z.infer<typeof HubFailureSchema>;
167
+
168
+ export const HubStateSchema = z.object({
169
+ computers: z.array(HubComputerSchema),
170
+ holdings: z.array(HubHoldingSchema),
171
+ failures: z.array(HubFailureSchema),
172
+ });
173
+ export type HubState = z.infer<typeof HubStateSchema>;
174
+
175
+ export const HubSaveSchema = z.object({ target: HubTargetSchema, machine: z.string().min(1).max(128) }).strict();
176
+ export type HubSave = z.infer<typeof HubSaveSchema>;
177
+ export const HubSavedSchema = z.object({
178
+ entry: z.string(),
179
+ machine: z.string(),
180
+ pending: z.boolean().describe("It waits for the next unlock at that computer, where the person says yes."),
181
+ });
182
+ export type HubSaved = z.infer<typeof HubSavedSchema>;
183
+
184
+ export const HubTakeSchema = z.object({ want: HubWantSchema, why: z.string().min(1).max(300).optional() }).strict();
185
+ export type HubTake = z.infer<typeof HubTakeSchema>;
186
+ export const HubTakenSchema = z.object({
187
+ outcome: z.enum(["taken", "waiting", "none"]).describe("Shared and made here; waiting for a yes at the computer; nothing saved there answers it."),
188
+ message: z.string(),
189
+ target: HubTargetSchema.optional().describe("What it was made into here, once taken."),
190
+ });
191
+ export type HubTaken = z.infer<typeof HubTakenSchema>;
@@ -1,7 +1,8 @@
1
1
  import { z } from "zod";
2
2
 
3
3
  // THE DIAGNOSTICS QUERIES: read-only questions over what a sandbox's daemon already recorded (its log, the editor's
4
- // reports, slow spans and rollups, the turn ledger, the resource series, its boots, one conversation's timeline). One
4
+ // reports, slow spans and rollups, the turn ledger, the resource series, its boots, one conversation's timeline, the
5
+ // commands agents ran that failed). One
5
6
  // set of arguments serves every door that asks them: the `diagnostics` tools a turn mounts, the `diagnostics` command on
6
7
  // the agent's PATH (POST /diagnostics), and a linked sandbox reading this one's records (POST /link/records/diagnostics).
7
8
  // Each answers with text written to be read, never the raw lines, and each takes a window.
@@ -102,6 +103,21 @@ export const DiagnosticsTimelineArgs = {
102
103
  limit: z.number().int().min(1).max(DIAGNOSTICS_MAX_LINES).optional().describe("The newest this many events. Defaults to 100."),
103
104
  };
104
105
 
106
+ /** `failures`: the shell commands agents ran that failed, kept a month, grouped by kind across conversations. */
107
+ export const DiagnosticsFailuresArgs = {
108
+ sinceMinutes: minutes().describe("How far back to look. Leave it out for everything kept (about a month)."),
109
+ conversationId: z.string().max(200).optional().describe("Narrow to one conversation; its failures are then listed one by one."),
110
+ contains: z.string().max(200).optional().describe("Case-insensitive substring of the failure's line: a program, a path, an error."),
111
+ group: z
112
+ .boolean()
113
+ .optional()
114
+ .describe(
115
+ "true: one row per kind of failure (program and error), most widespread first, each marked ongoing, stopped or quiet. " +
116
+ "false: every failure, newest first. Left out, kinds are grouped unless a conversation is named.",
117
+ ),
118
+ limit: limit(),
119
+ };
120
+
105
121
  // One query, named by `query`, with that query's own arguments.
106
122
  export const DiagnosticsQuerySchema = z.discriminatedUnion("query", [
107
123
  z.object({ query: z.literal("errors"), ...DiagnosticsErrorsArgs }),
@@ -110,10 +126,11 @@ export const DiagnosticsQuerySchema = z.discriminatedUnion("query", [
110
126
  z.object({ query: z.literal("resources"), ...DiagnosticsResourcesArgs }),
111
127
  z.object({ query: z.literal("restarts"), ...DiagnosticsRestartsArgs }),
112
128
  z.object({ query: z.literal("timeline"), ...DiagnosticsTimelineArgs }),
129
+ z.object({ query: z.literal("failures"), ...DiagnosticsFailuresArgs }),
113
130
  ]);
114
131
  export type DiagnosticsQuery = z.infer<typeof DiagnosticsQuerySchema>;
115
132
  export type DiagnosticsQueryName = DiagnosticsQuery["query"];
116
- export const DIAGNOSTICS_QUERY_NAMES = ["errors", "slow", "turns", "resources", "restarts", "timeline"] as const satisfies readonly DiagnosticsQueryName[];
133
+ export const DIAGNOSTICS_QUERY_NAMES = ["errors", "slow", "turns", "resources", "restarts", "timeline", "failures"] as const satisfies readonly DiagnosticsQueryName[];
117
134
 
118
135
  // POST /diagnostics: one query of this sandbox's records, or, with `on`, of the linked sandbox that card names, read
119
136
  // through the link (its owner must share records on it).
@@ -1,7 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { AskQuestionSchema } from "../events/requests.js";
3
3
  import { entryId } from "./internal.js";
4
- import { SharedAccountRefSchema } from "./providers/account-sharing.js";
5
4
 
6
5
  // LINKED SANDBOXES: one of the owner's sandboxes handing tasks to another. The sandbox that hands work over holds a
7
6
  // `link` capability card (schemas/capabilities.ts LinkConfigSchema); the one that takes it holds an inbound link, minted
@@ -35,7 +34,7 @@ const turnsPerHourTerm = z
35
34
  .describe("How many turns the link may start in an hour, new tasks and follow-ups alike. Words said into a turn already running are not counted.");
36
35
  const tasksTerm = z
37
36
  .boolean()
38
- .describe("Whether the link may hand this sandbox tasks at all. An accounts link is minted without: it only borrows and copies the accounts below.");
37
+ .describe("Whether the link may hand this sandbox tasks at all. Without, it only reads records or operates, as those terms allow.");
39
38
  const recordsTerm = z
40
39
  .boolean()
41
40
  .describe(
@@ -46,12 +45,6 @@ const operateTerm = z
46
45
  .describe(
47
46
  "Whether the asking sandbox may operate this one as its owner does from their own terminal: run commands, and read and write files, in this sandbox's main checkout. They run as root, or, while conversations here can be private, inside the same jail every person's shell gets (the history volume out of reach). Anything the owner's terminal can do, including reading this sandbox's secrets. Every call is logged here. Off unless its owner turns it on.",
48
47
  );
49
- const accountsTerm = z
50
- .array(SharedAccountRefSchema)
51
- .max(64)
52
- .describe(
53
- "The model accounts the asking sandbox may use (schemas/providers/account-sharing.ts): a static key it may copy, a sign-in it borrows turn by turn. Empty lends nothing.",
54
- );
55
48
 
56
49
  export const LinkTermsSchema = z.object({
57
50
  actsAs: entryId
@@ -70,7 +63,6 @@ export const LinkTermsSchema = z.object({
70
63
  tasks: tasksTerm.default(true),
71
64
  records: recordsTerm.default(false),
72
65
  operate: operateTerm.default(false),
73
- accounts: accountsTerm.default([]),
74
66
  });
75
67
  export type LinkTerms = z.infer<typeof LinkTermsSchema>;
76
68
 
@@ -119,9 +111,8 @@ export const InboundLinkMintedSchema = z.object({ id: z.string(), token: z.strin
119
111
  export type InboundLinkMinted = z.infer<typeof InboundLinkMintedSchema>;
120
112
  // POST /system/links/{id}: new terms, whole fields replaced, the rest kept. `null` on the persona or the service takes it
121
113
  // off (2026-10-26): absence keeps a field, so before this neither could be cleared once set. Spelled field by field rather
122
- // than as LinkTermsSchema.partial(): zod still fills a partial's inner defaults, so a change naming only `accounts`
123
- // read as `approve: false, turnsPerHour: 20, tasks: true` and quietly turned an accounts link into one taking tasks
124
- // (2026-10-29).
114
+ // than as LinkTermsSchema.partial(): zod still fills a partial's inner defaults, so a change naming one field would read
115
+ // as `approve: false, turnsPerHour: 20, tasks: true` and quietly reset the rest (2026-10-29).
125
116
  export const InboundLinkTermsUpdateSchema = z.object({
126
117
  label: z.string().trim().min(1).max(60).optional(),
127
118
  actsAs: entryId.nullable().optional().describe("The persona every task wears; null takes it off."),
@@ -131,7 +122,6 @@ export const InboundLinkTermsUpdateSchema = z.object({
131
122
  tasks: tasksTerm.optional(),
132
123
  records: recordsTerm.optional(),
133
124
  operate: operateTerm.optional(),
134
- accounts: accountsTerm.optional(),
135
125
  });
136
126
  export type InboundLinkTermsUpdate = z.infer<typeof InboundLinkTermsUpdateSchema>;
137
127
  // POST /system/links/{id}/requests/{request}: the owner's answer to one waiting task.
@@ -148,9 +138,8 @@ export const LinkHelloSchema = z.object({
148
138
  approve: z.boolean(),
149
139
  turnsPerHour: z.number().int(),
150
140
  persona: z.string().optional().describe("The name of the persona its tasks wear, when they wear one."),
151
- // Absent from a sandbox older than accounts links, which takes tasks and lends nothing.
141
+ // Absent from a sandbox older than 2026-10-29, which takes tasks.
152
142
  tasks: z.boolean().optional(),
153
- accounts: z.number().int().nonnegative().optional().describe("How many accounts the link may use."),
154
143
  // Absent from a sandbox older than records over links, which shares none.
155
144
  records: z.boolean().optional().describe("Whether the link may read this sandbox's records (its conversations, logs and diagnostics)."),
156
145
  // Absent from a sandbox older than operating over links, which allows none.
@@ -398,6 +398,12 @@ export const ResumeRoutingSchema = z.object({
398
398
  .describe(
399
399
  "Which of that provider's accounts pays for it. Leave it out to keep the account the conversation runs on, or, on another provider, to take whichever of its accounts can serve with the most room. Moving to another account of the same provider is `switchAccount`'s job; naming one here still works.",
400
400
  ),
401
+ accountPicked: z
402
+ .boolean()
403
+ .optional()
404
+ .describe(
405
+ "Set when a person picked `account` by hand for this re-run: it goes there even where the sandbox's records call that account's allowance spent or its access refused, and the provider's own answer decides.",
406
+ ),
401
407
  // An unloaded catalog keeps the held model only on its own provider.
402
408
  model: z.string().optional().describe("Which model. Leave it out to keep the refused turn's model on the same provider, or use the new provider's default."),
403
409
  // A tier named for one model may mean nothing on another, so a move onto a ladder rung carries that rung's own.
@@ -44,12 +44,6 @@ export const OauthAccountSchema = z.object({
44
44
  usage: AccountUsageSchema.optional().describe(
45
45
  "How full its plan limits were when last measured, so a picker can show what is left before committing work to it. Absent until a reading exists, which reads as unknown rather than as nothing left.",
46
46
  ),
47
- borrowedFrom: z
48
- .object({ name: z.string(), sandboxId: z.string().optional() })
49
- .optional()
50
- .describe(
51
- "Another of the owner's sandboxes holds this sign-in and lends it here turn by turn (schemas/providers/account-sharing.ts). Absent means it is this sandbox's own.",
52
- ),
53
47
  });
54
48
  export type OauthAccount = z.infer<typeof OauthAccountSchema>;
55
49
  export const OauthAccountListSchema = z.object({
@@ -1,9 +1,10 @@
1
1
  import { z } from "zod";
2
- import { KeyringOriginSchema, KeyringRememberSchema, KeyringShareModeSchema } from "./keyring.js";
2
+ import { KeyringOriginSchema } from "./keyring.js";
3
3
 
4
4
  // THE SANDBOX'S SIDE OF PASSWORDS (2026-10-19): an agent asking for a credential by where it is to be used (`secrets
5
- // want`, `type_secret` aimed at a page or a window), and the hosted Passwords view's three reads. The vault and its
6
- // management stay on the owner's computers; what a sandbox learns of an entry is the pointer its keyring shared here.
5
+ // want`, `type_secret` aimed at a page or a window), and the wants still waiting, which the Secrets view lists. Passwords
6
+ // itself, the vault and its management, is on the owner's computers alone (2026-11-11): a sandbox deals in secrets, and
7
+ // what it learns of an entry is the pointer its keyring shared here, which the secret inventory lists like any other.
7
8
 
8
9
  /** `secrets want`: a credential by the place it is for, asked of the owner's keyrings. */
9
10
  export const SecretWantSchema = z
@@ -30,7 +31,7 @@ export const SecretWantResultSchema = z.discriminatedUnion("state", [
30
31
  ]);
31
32
  export type SecretWantResult = z.infer<typeof SecretWantResultSchema>;
32
33
 
33
- /** One need this sandbox raised, as its record and the hosted view's Requests keep it. */
34
+ /** One need this sandbox raised, as its record keeps it and the Secrets view lists it while it waits. */
34
35
  export const SandboxNeedSchema = z.object({
35
36
  id: z.string(),
36
37
  origin: KeyringOriginSchema,
@@ -44,45 +45,3 @@ export const SandboxNeedSchema = z.object({
44
45
  });
45
46
  export type SandboxNeed = z.infer<typeof SandboxNeedSchema>;
46
47
  export const SandboxNeedsSchema = z.object({ needs: z.array(SandboxNeedSchema) });
47
-
48
- /** One of the owner's computers as the hosted Passwords view shows its keyring. */
49
- export const SandboxPasswordsKeyringSchema = z.object({
50
- machine: z.string(),
51
- online: z.boolean(),
52
- setUp: z.boolean().describe("Answering, set up, and trusted by this sandbox: it can be asked."),
53
- locked: z.boolean().optional(),
54
- remember: KeyringRememberSchema.optional(),
55
- });
56
- export type SandboxPasswordsKeyring = z.infer<typeof SandboxPasswordsKeyringSchema>;
57
-
58
- /** One password this sandbox may use: a pointer one of the owner's keyrings shares here. Never a value. */
59
- export const SandboxPasswordSchema = z.object({
60
- name: z.string(),
61
- title: z.string(),
62
- kind: z.enum(["password", "text"]),
63
- origins: z.array(KeyringOriginSchema).describe("Where it works, from the entry's rules."),
64
- anyField: z.boolean(),
65
- machine: z.string().describe("The computer whose keyring keeps it."),
66
- mode: KeyringShareModeSchema.describe("How this sandbox may use it."),
67
- online: z.boolean(),
68
- updatedAt: z.number(),
69
- lastUsedAt: z.number().optional().describe("This sandbox's last use of it, from its own use ledger."),
70
- });
71
- export type SandboxPassword = z.infer<typeof SandboxPasswordSchema>;
72
-
73
- export const SandboxPasswordsSchema = z.object({
74
- sandbox: z.string().describe("This sandbox's own address, as the keyrings name it."),
75
- items: z.array(SandboxPasswordSchema),
76
- keyrings: z.array(SandboxPasswordsKeyringSchema),
77
- });
78
- export type SandboxPasswords = z.infer<typeof SandboxPasswordsSchema>;
79
-
80
- /** One use of a keyring-held password by this sandbox, from its use ledger. */
81
- export const SandboxPasswordUseSchema = z.object({
82
- at: z.number(),
83
- name: z.string(),
84
- lane: z.string(),
85
- detail: z.string().optional(),
86
- approvedBy: z.string().optional(),
87
- });
88
- export const SandboxPasswordsActivitySchema = z.object({ lines: z.array(SandboxPasswordUseSchema) });
@@ -72,6 +72,9 @@ export const AUTH_STATE_FILES: readonly StateFile[] = [
72
72
  { path: "keyring-copies.json", portability: "identity" },
73
73
  { path: "keyring-sync-mailbox.json", portability: "identity" },
74
74
  { path: "keyring-needs.json", portability: "identity" },
75
+ // What this sandbox saved to the connections hub and what it made from hub entries shared here (hub/): entry names
76
+ // and the cards they became, no credential.
77
+ { path: "connection-hub.json", portability: "identity" },
75
78
  // The credential broker's signing key and the privacy gateway's token key, each minted on first use.
76
79
  { path: "broker-session.key", portability: "identity" },
77
80
  { path: "privacy-gateway.key", portability: "identity" },
@@ -42,6 +42,8 @@ export type AccountMoved = Extract<SandboxNotice, { code: "accountMoved" }>["par
42
42
  // Each names both accounts, since "moved" alone leaves the reader to work out from where and to where.
43
43
  const MOVED_LINES = {
44
44
  refused: ({ from, to }) => `Ran on ${to}: the ${from} account's plan or organization does not allow it.`,
45
+ // Says how to overrule it: the records can be wrong (a limit reset, a plan upgraded), and a pick of the account wins.
46
+ spent: ({ from, to }) => `Ran on ${to}: the records say ${from} has used up its allowance. To run on ${from} anyway, pick it in the composer.`,
45
47
  reach: ({ from, to }) => `Ran on ${to}: the people this conversation works for may not use the ${from} account.`,
46
48
  cold: ({ from, to }) => `Moved from ${from} to ${to}, which has more room left: the cache had expired, so moving cost nothing.`,
47
49
  } as const satisfies Readonly<Record<AccountMoved["why"], (move: AccountMoved) => string>>;
@@ -1,58 +0,0 @@
1
- export declare const sharingContract: {
2
- shareable: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, import("zod").ZodObject<{
3
- sandbox: import("zod").ZodString;
4
- accounts: import("zod").ZodArray<import("zod").ZodObject<{
5
- provider: import("zod").ZodString;
6
- account: import("zod").ZodOptional<import("zod").ZodString>;
7
- label: import("zod").ZodString;
8
- email: import("zod").ZodOptional<import("zod").ZodString>;
9
- mode: import("zod").ZodEnum<{
10
- copy: "copy";
11
- lend: "lend";
12
- no: "no";
13
- }>;
14
- reason: import("zod").ZodOptional<import("zod").ZodString>;
15
- }, import("zod/v4/core").$strip>>;
16
- }, import("zod/v4/core").$strip>, Record<never, never>, import("../protocol/route-meta.js").RouteMeta & Record<never, never>>;
17
- borrow: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
18
- card: import("zod").ZodString;
19
- items: import("zod").ZodArray<import("zod").ZodObject<{
20
- provider: import("zod").ZodString;
21
- account: import("zod").ZodOptional<import("zod").ZodString>;
22
- }, import("zod/v4/core").$strip>>;
23
- }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
24
- results: import("zod").ZodArray<import("zod").ZodObject<{
25
- provider: import("zod").ZodString;
26
- account: import("zod").ZodOptional<import("zod").ZodString>;
27
- outcome: import("zod").ZodEnum<{
28
- borrowed: "borrowed";
29
- copied: "copied";
30
- failed: "failed";
31
- }>;
32
- id: import("zod").ZodOptional<import("zod").ZodString>;
33
- message: import("zod").ZodOptional<import("zod").ZodString>;
34
- }, import("zod/v4/core").$strip>>;
35
- }, import("zod/v4/core").$strip>, Record<never, never>, import("../protocol/route-meta.js").RouteMeta & Record<never, never>>;
36
- borrowed: import("@orpc/contract").ContractProcedureBuilderWithOutput<import("@orpc/contract").Schema<unknown, unknown>, import("zod").ZodObject<{
37
- accounts: import("zod").ZodArray<import("zod").ZodObject<{
38
- id: import("zod").ZodString;
39
- card: import("zod").ZodString;
40
- provider: import("zod").ZodString;
41
- remote: import("zod").ZodOptional<import("zod").ZodString>;
42
- label: import("zod").ZodString;
43
- email: import("zod").ZodOptional<import("zod").ZodString>;
44
- organization: import("zod").ZodOptional<import("zod").ZodString>;
45
- from: import("zod").ZodObject<{
46
- name: import("zod").ZodString;
47
- sandboxId: import("zod").ZodOptional<import("zod").ZodString>;
48
- }, import("zod/v4/core").$strip>;
49
- borrowedAt: import("zod").ZodNumber;
50
- }, import("zod/v4/core").$strip>>;
51
- }, import("zod/v4/core").$strip>, Record<never, never>, import("../protocol/route-meta.js").RouteMeta & Record<never, never>>;
52
- stop: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
53
- id: import("zod").ZodString;
54
- }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
55
- ok: import("zod").ZodLiteral<true>;
56
- }, import("zod/v4/core").$strip>, Record<never, never>, import("../protocol/route-meta.js").RouteMeta & Record<never, never>>;
57
- };
58
- //# sourceMappingURL=sharing.contract.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sharing.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/sharing.contract.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,eAAe;IACxB,SAAS;;;;;;;;;;;;;;;IAST,MAAM;;;;;;;;;;;;;;;;;;;IAUN,QAAQ;;;;;;;;;;;;;;;;IAQR,IAAI;;;;;CAUP,CAAC"}
@@ -1,41 +0,0 @@
1
- import { procedure } from "../protocol/route-meta.js";
2
- import { AccountsBorrowedSchema, AccountsBorrowSchema, BorrowedAccountIdSchema, BorrowedAccountsSchema, ShareableAccountsSchema, } from "../schemas/providers/account-sharing.js";
3
- import { OkSchema } from "../schemas/shared.js";
4
- const sharingRoute = procedure.meta({ floor: "maintainer", control: "never", panel: false });
5
- export const sharingContract = {
6
- shareable: sharingRoute
7
- .route({
8
- method: "GET",
9
- path: "/sharing/accounts",
10
- summary: "What this sandbox can share with another of yours",
11
- description: "Every model account held here and how it would reach another of the owner's sandboxes: copied (a key that does not rotate), lent turn by turn (a sign-in whose renewal must stay here), or not at all, with why. No credential is in the answer.",
12
- })
13
- .output(ShareableAccountsSchema),
14
- borrow: sharingRoute
15
- .route({
16
- method: "POST",
17
- path: "/sharing/borrow",
18
- summary: "Bring accounts in from another of your sandboxes",
19
- description: "Over the accounts link saved as `card`, copies each named static key into this sandbox's own stores and files each lent sign-in as borrowed. Each account answers on its own, so one that fails leaves the others in.",
20
- })
21
- .input(AccountsBorrowSchema)
22
- .output(AccountsBorrowedSchema),
23
- borrowed: sharingRoute
24
- .route({
25
- method: "GET",
26
- path: "/sharing/borrowed",
27
- summary: "Accounts this sandbox borrows",
28
- description: "Each account another of the owner's sandboxes lends here, and which link it is borrowed through. No credential is in the answer.",
29
- })
30
- .output(BorrowedAccountsSchema),
31
- stop: sharingRoute
32
- .route({
33
- method: "POST",
34
- path: "/sharing/borrowed/stop",
35
- summary: "Stop borrowing an account",
36
- description: "Forgets one borrowed account here: no turn asks the source for it again. The source's own link is changed separately, by the owner's editor or on the source.",
37
- })
38
- .input(BorrowedAccountIdSchema)
39
- .output(OkSchema),
40
- };
41
- //# sourceMappingURL=sharing.contract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sharing.contract.js","sourceRoot":"","sources":["../../src/contracts/sharing.contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EACH,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,GAC1B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKhD,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAE7F,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,SAAS,EAAE,YAAY;SAClB,KAAK,CAAC;QACH,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,mDAAmD;QAC5D,WAAW,EACP,kPAAkP;KACzP,CAAC;SACD,MAAM,CAAC,uBAAuB,CAAC;IACpC,MAAM,EAAE,YAAY;SACf,KAAK,CAAC;QACH,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,kDAAkD;QAC3D,WAAW,EACP,uNAAuN;KAC9N,CAAC;SACD,KAAK,CAAC,oBAAoB,CAAC;SAC3B,MAAM,CAAC,sBAAsB,CAAC;IACnC,QAAQ,EAAE,YAAY;SACjB,KAAK,CAAC;QACH,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,+BAA+B;QACxC,WAAW,EAAE,kIAAkI;KAClJ,CAAC;SACD,MAAM,CAAC,sBAAsB,CAAC;IACnC,IAAI,EAAE,YAAY;SACb,KAAK,CAAC;QACH,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,wBAAwB;QAC9B,OAAO,EAAE,2BAA2B;QACpC,WAAW,EACP,+JAA+J;KACtK,CAAC;SACD,KAAK,CAAC,uBAAuB,CAAC;SAC9B,MAAM,CAAC,QAAQ,CAAC;CACxB,CAAC"}