@capybara-hq/kernel 0.1.0-rc.72 → 0.1.0-rc.74
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.
- package/bootstrap.json +5 -5
- package/dist/catalog/admin-catalog.schemas.d.ts +3 -1
- package/dist/catalog/admin-catalog.schemas.js +6 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.schemas.d.ts +3 -1
- package/dist/catalog/org-catalog.schemas.js +3 -1
- package/dist/catalog/plugin-package.js +7 -5
- package/dist/catalog/reserved-names.js +3 -9
- package/dist/channels/actions.js +4 -0
- package/dist/channels/cards.d.ts +10 -7
- package/dist/channels/cards.js +23 -12
- package/dist/channels/phrases.d.ts +24 -2
- package/dist/channels/phrases.js +12 -2
- package/dist/ctx/secrets.d.ts +4 -2
- package/dist/ctx/secrets.js +19 -5
- package/dist/db/kernel-schema.d.ts +14 -0
- package/dist/devices/conversation-devices.d.ts +3 -2
- package/dist/devices/conversation-devices.js +9 -4
- package/dist/devices/device-projects.service.d.ts +22 -27
- package/dist/devices/device-projects.service.js +36 -41
- package/dist/devices/devices.controller.d.ts +3 -5
- package/dist/devices/devices.controller.js +4 -17
- package/dist/devices/devices.schemas.d.ts +1 -1
- package/dist/devices/devices.schemas.js +1 -1
- package/dist/devices/devices.service.d.ts +72 -52
- package/dist/devices/devices.service.js +158 -93
- package/dist/devices/project-rules.d.ts +6 -8
- package/dist/devices/project-rules.js +5 -11
- package/dist/dial-in/auth.controller.d.ts +1 -1
- package/dist/dial-in/auth.controller.js +1 -1
- package/dist/dial-in/auth.service.d.ts +4 -0
- package/dist/dial-in/auth.service.js +16 -2
- package/dist/dial-in/machines.d.ts +5 -4
- package/dist/dial-in/machines.js +5 -4
- package/dist/errors.d.ts +8 -3
- package/dist/errors.js +8 -3
- package/dist/extensions/admin-ops.js +2 -1
- package/dist/extensions/bootstrap-extra.d.ts +11 -1
- package/dist/extensions/bootstrap-extra.js +21 -1
- package/dist/extensions/bootstrap-manifest.d.ts +14 -0
- package/dist/extensions/bootstrap-manifest.js +23 -0
- package/dist/extensions/bootstrap-packages.d.ts +87 -0
- package/dist/extensions/bootstrap-packages.js +263 -0
- package/dist/extensions/bootstrap.d.ts +27 -71
- package/dist/extensions/bootstrap.js +85 -329
- package/dist/extensions/guide-places.d.ts +9 -0
- package/dist/extensions/guide-places.js +32 -22
- package/dist/extensions/permission-set.d.ts +1 -1
- package/dist/extensions/permission-set.js +1 -1
- package/dist/extensions/plugin-guides.d.ts +20 -2
- package/dist/extensions/plugin-guides.js +39 -14
- package/dist/identity/sso-paths.d.ts +7 -0
- package/dist/identity/sso-paths.js +13 -0
- package/dist/identity/sso.js +3 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +2 -2
- package/dist/platform/exclusions.js +2 -7
- package/dist/platform/ops/devices.ops.js +11 -7
- package/dist/platform/ops/setup.ops.js +1 -1
- package/dist/runtime/project/knowledge.service.js +6 -5
- package/dist/sandbox/device-sandbox.d.ts +11 -0
- package/dist/sandbox/device-sandbox.js +29 -0
- package/dist/sandbox/modes.d.ts +16 -4
- package/dist/sandbox/modes.js +12 -0
- package/dist/sandbox/permission-facts.d.ts +12 -2
- package/dist/sandbox/permission-facts.js +14 -4
- package/dist/sandbox/sandbox.service.d.ts +18 -11
- package/dist/sandbox/sandbox.service.js +51 -24
- package/dist/setup/setup-guides.service.d.ts +2 -2
- package/dist/setup/setup-guides.service.js +1 -1
- package/dist/tools/approvals.service.d.ts +31 -11
- package/dist/tools/approvals.service.js +55 -19
- package/dist/tools/builtins/sandbox/common.d.ts +2 -2
- package/dist/tools/builtins/sandbox/common.js +2 -2
- package/dist/tools/network-asks.d.ts +103 -20
- package/dist/tools/network-asks.js +133 -18
- package/dist/tools/pipeline.d.ts +5 -0
- package/dist/tools/pipeline.js +15 -8
- package/package.json +3 -3
- package/src/migrations/0178_bootstrap_run_extra.sql +17 -0
package/bootstrap.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"schemaVersion": 1,
|
|
4
4
|
"marketplace": {
|
|
5
5
|
"url": "https://github.com/capybara-hq/plugins.git",
|
|
6
|
-
"commit": "
|
|
6
|
+
"commit": "80dbc32d9fa23df5bf61ed7cc764cb996de0773b"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
@@ -90,16 +90,16 @@
|
|
|
90
90
|
"name": "device-docker",
|
|
91
91
|
"source": "npm",
|
|
92
92
|
"npm": "@capybara-hq/plugin-device-docker",
|
|
93
|
-
"version": "0.1.0-rc.
|
|
94
|
-
"integrity": "sha512-
|
|
93
|
+
"version": "0.1.0-rc.23",
|
|
94
|
+
"integrity": "sha512-xR28dC3NPIsRaG4jprsvWa7nFZkc7aURbl7o16TTP7j0oNBEhkkZcj2EQRRfz3/XpRMKSxqVT2tdK3KMK3y0AQ==",
|
|
95
95
|
"required": false
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
"name": "device-local",
|
|
99
99
|
"source": "npm",
|
|
100
100
|
"npm": "@capybara-hq/plugin-device-local",
|
|
101
|
-
"version": "0.1.0-rc.
|
|
102
|
-
"integrity": "sha512
|
|
101
|
+
"version": "0.1.0-rc.3",
|
|
102
|
+
"integrity": "sha512-/Xqh/qqWiIbLWHHV/5/p1bGRi76dGH/0V0u4ZyT8L0ZL3rKz+Bq4o9QrNyEf56ojNcp3LIbIP8H3bSxbMaSNqw==",
|
|
103
103
|
"required": false,
|
|
104
104
|
"scope": "all"
|
|
105
105
|
},
|
|
@@ -76,12 +76,14 @@ export declare const CatalogShownBody: z.ZodObject<{
|
|
|
76
76
|
}, z.core.$strict>;
|
|
77
77
|
/**
|
|
78
78
|
* `GET :itemId/guides/:guideId`, the super admin's preview of a setup guide (spec
|
|
79
|
-
* 2026-11-09-setup-guides-v2-design.md §9.3):
|
|
79
|
+
* 2026-11-09-setup-guides-v2-design.md §9.3): the document language and, for a connector-template
|
|
80
|
+
* guide covering several templates, the template to show it for; no org, no target.
|
|
80
81
|
*/
|
|
81
82
|
export declare const AdminCatalogGuideQuery: z.ZodObject<{
|
|
82
83
|
locale: z.ZodOptional<z.ZodEnum<{
|
|
83
84
|
en: "en";
|
|
84
85
|
zh: "zh";
|
|
85
86
|
}>>;
|
|
87
|
+
templateId: z.ZodOptional<z.ZodString>;
|
|
86
88
|
}, z.core.$strict>;
|
|
87
89
|
export declare const ADMIN_CATALOG_ROUTES: readonly RouteSchemas[];
|
|
@@ -58,10 +58,14 @@ export const CatalogDisabledBody = z
|
|
|
58
58
|
export const CatalogShownBody = z.object({ shownToOthers: z.boolean() }).strict();
|
|
59
59
|
/**
|
|
60
60
|
* `GET :itemId/guides/:guideId`, the super admin's preview of a setup guide (spec
|
|
61
|
-
* 2026-11-09-setup-guides-v2-design.md §9.3):
|
|
61
|
+
* 2026-11-09-setup-guides-v2-design.md §9.3): the document language and, for a connector-template
|
|
62
|
+
* guide covering several templates, the template to show it for; no org, no target.
|
|
62
63
|
*/
|
|
63
64
|
export const AdminCatalogGuideQuery = z
|
|
64
|
-
.object({
|
|
65
|
+
.object({
|
|
66
|
+
locale: z.enum(["en", "zh"]).optional(),
|
|
67
|
+
templateId: z.string().min(1).max(64).optional(),
|
|
68
|
+
})
|
|
65
69
|
.strict();
|
|
66
70
|
export const ADMIN_CATALOG_ROUTES = [
|
|
67
71
|
// the plugin package is the raw body (no schema)
|
|
@@ -203,7 +203,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
|
|
|
203
203
|
/** The host versions (an entry's `minKernel` is judged against them). */
|
|
204
204
|
export declare const HOST_VERSIONS: {
|
|
205
205
|
readonly kernel: string;
|
|
206
|
-
readonly sdk: "0.1.0-rc.
|
|
206
|
+
readonly sdk: "0.1.0-rc.59";
|
|
207
207
|
};
|
|
208
208
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
209
209
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
|
@@ -141,7 +141,8 @@ export declare const CatalogRequestsListQuery: z.ZodObject<{
|
|
|
141
141
|
* `GET catalog/:itemId/guides/:guideId` (spec 2026-11-09-setup-guides-v2-design.md §7.2): the mode
|
|
142
142
|
* and audience to render (the place's, checked by the service), the document language, and the
|
|
143
143
|
* target: a channel connection or the name typed so far on 新建渠道 (`channel-connection`), a
|
|
144
|
-
* connector made from the template
|
|
144
|
+
* connector made from the template and which of the guide's templates to render for
|
|
145
|
+
* (`connector-template`; a guide may cover several).
|
|
145
146
|
*/
|
|
146
147
|
export declare const CatalogGuideQuery: z.ZodObject<{
|
|
147
148
|
mode: z.ZodOptional<z.ZodString>;
|
|
@@ -156,5 +157,6 @@ export declare const CatalogGuideQuery: z.ZodObject<{
|
|
|
156
157
|
connectionId: z.ZodOptional<z.ZodString>;
|
|
157
158
|
name: z.ZodOptional<z.ZodString>;
|
|
158
159
|
connectorId: z.ZodOptional<z.ZodString>;
|
|
160
|
+
templateId: z.ZodOptional<z.ZodString>;
|
|
159
161
|
}, z.core.$strict>;
|
|
160
162
|
export declare const ORG_CATALOG_ROUTES: readonly RouteSchemas[];
|
|
@@ -127,7 +127,8 @@ export const CatalogRequestsListQuery = z.object({
|
|
|
127
127
|
* `GET catalog/:itemId/guides/:guideId` (spec 2026-11-09-setup-guides-v2-design.md §7.2): the mode
|
|
128
128
|
* and audience to render (the place's, checked by the service), the document language, and the
|
|
129
129
|
* target: a channel connection or the name typed so far on 新建渠道 (`channel-connection`), a
|
|
130
|
-
* connector made from the template
|
|
130
|
+
* connector made from the template and which of the guide's templates to render for
|
|
131
|
+
* (`connector-template`; a guide may cover several).
|
|
131
132
|
*/
|
|
132
133
|
export const CatalogGuideQuery = z
|
|
133
134
|
.object({
|
|
@@ -137,6 +138,7 @@ export const CatalogGuideQuery = z
|
|
|
137
138
|
connectionId: z.string().min(1).max(100).optional(),
|
|
138
139
|
name: z.string().max(100).optional(),
|
|
139
140
|
connectorId: z.string().min(1).max(100).optional(),
|
|
141
|
+
templateId: z.string().min(1).max(64).optional(),
|
|
140
142
|
})
|
|
141
143
|
.strict();
|
|
142
144
|
export const ORG_CATALOG_ROUTES = [
|
|
@@ -396,7 +396,7 @@ export function readPluginFiles(files, opts) {
|
|
|
396
396
|
// Setup guides v2 (spec 2026-11-09-setup-guides-v2-design.md §4.5): the documents are text
|
|
397
397
|
// within the limits and pass the SDK validator (an unknown variable is accepted: it renders as
|
|
398
398
|
// written); a channel guide needs a channel extension, which the manifest parser checks when the
|
|
399
|
-
// extension section is there; a template guide names
|
|
399
|
+
// extension section is there; a template guide names only the plugin's connector templates
|
|
400
400
|
const templateIds = new Set(connectorTemplates.map((t) => t.id));
|
|
401
401
|
manifest.setupGuides?.forEach((g, i) => {
|
|
402
402
|
const at = `setupGuides.${i} (${g.id})`;
|
|
@@ -404,10 +404,12 @@ export function readPluginFiles(files, opts) {
|
|
|
404
404
|
issues.push(`${at}: a channel-connection guide needs the plugin's extension to provide channel@1`);
|
|
405
405
|
}
|
|
406
406
|
// a listed template is checked by the manifest parser; scanned ones only here
|
|
407
|
-
if (
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
407
|
+
if (manifest.connectorTemplates === undefined) {
|
|
408
|
+
for (const t of g.templates ?? []) {
|
|
409
|
+
if (!templateIds.has(t)) {
|
|
410
|
+
issues.push(`${at}: template ${t} is not one of the plugin's connector templates`);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
411
413
|
}
|
|
412
414
|
const docs = {};
|
|
413
415
|
for (const locale of ["en", "zh"]) {
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
2
|
import { parseBootstrapManifest } from "@capybara-hq/plugin-sdk";
|
|
4
3
|
import { ApiError } from "../errors.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* `extensions/bootstrap.ts`'s `BOOTSTRAP_MANIFEST_FILE`, which this module does not import: that
|
|
8
|
-
* module depends on the plugin import).
|
|
9
|
-
*/
|
|
10
|
-
const BUNDLED_BOOTSTRAP_MANIFEST = fileURLToPath(new URL("../../bootstrap.json", import.meta.url));
|
|
11
|
-
/** The plugin names of the bundled bootstrap manifest (an unreadable or invalid one: none). */
|
|
4
|
+
import { BOOTSTRAP_MANIFEST_FILE } from "../extensions/bootstrap-manifest.js";
|
|
5
|
+
/** The plugin names of the bootstrap manifest shipped with the kernel (an unreadable or invalid one: none). */
|
|
12
6
|
async function bootstrapNames() {
|
|
13
7
|
let raw;
|
|
14
8
|
try {
|
|
15
|
-
raw = JSON.parse(await readFile(
|
|
9
|
+
raw = JSON.parse(await readFile(BOOTSTRAP_MANIFEST_FILE, "utf8"));
|
|
16
10
|
}
|
|
17
11
|
catch {
|
|
18
12
|
return [];
|
package/dist/channels/actions.js
CHANGED
|
@@ -24,6 +24,10 @@ const REPLY_FOR = {
|
|
|
24
24
|
"approval.not_yours": "cannotHandle",
|
|
25
25
|
// an approval with person fields is approved only on the web (platform web parity spec R5)
|
|
26
26
|
"auth.session_required": "cannotHandle",
|
|
27
|
+
// "add to this device's list" refused: the device can no longer take the host, or is gone or
|
|
28
|
+
// no longer the clicker's
|
|
29
|
+
"device.network_not_allowed": "invalidAction",
|
|
30
|
+
"device.not_found": "cannotHandle",
|
|
27
31
|
};
|
|
28
32
|
/**
|
|
29
33
|
* IM 卡片上的按钮操作(Review Focus 2):点击者按入站同样的规则映射到账号(未绑定 → 私聊回绑定卡片、群里只提示去私聊),
|
package/dist/channels/cards.d.ts
CHANGED
|
@@ -67,11 +67,13 @@ export interface NetworkCardText {
|
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* A network ask's card text: the title names the host (or the number of hosts); the preview lists
|
|
70
|
-
* the hosts, then the command clipped to {@link CARD_SUMMARY_MAX}
|
|
71
|
-
* decision applies to all of them (an IM card has no per-host choice)
|
|
72
|
-
*
|
|
70
|
+
* the hosts, then the command clipped to {@link CARD_SUMMARY_MAX}, for several hosts that the
|
|
71
|
+
* decision applies to all of them (an IM card has no per-host choice) and, when `scopes` offers
|
|
72
|
+
* "add to this device's list", when that applies (device-provider spec §6.3). Model-controlled
|
|
73
|
+
* values are redacted by `redact` (the connection's secret values); the description stays on the
|
|
74
|
+
* web.
|
|
73
75
|
*/
|
|
74
|
-
export declare function networkCardText(detail: Pick<NetworkAskView, "hosts" | "command"
|
|
76
|
+
export declare function networkCardText(detail: Pick<NetworkAskView, "hosts" | "command"> & Partial<Pick<NetworkAskView, "appliesAt">>, locale: ChannelLocale, redact?: (s: string) => string, scopes?: readonly string[]): NetworkCardText;
|
|
75
77
|
/**
|
|
76
78
|
* A git push ask's card text (sandbox git credentials spec §7): the title names the repository;
|
|
77
79
|
* the preview is `<host>/<repo>`, the refs (`refs/heads/` dropped) and the command clipped to
|
|
@@ -101,9 +103,10 @@ export declare function personFieldsCard(d: CardDeps, approvalId: string, base:
|
|
|
101
103
|
}> | undefined>;
|
|
102
104
|
/**
|
|
103
105
|
* The approval card in the approval's current state; undefined when the approval does not exist.
|
|
104
|
-
* A role escalation offers only "once". A network ask names its hosts and command
|
|
105
|
-
* scopes ({@link networkCardText}); a command
|
|
106
|
-
* command (a write: its path) and labels its
|
|
106
|
+
* A role escalation offers only "once". A network ask names its hosts and command, labels its
|
|
107
|
+
* scopes and says when "add to this device's list" applies ({@link networkCardText}); a command
|
|
108
|
+
* review ask names the review's reason and the held command (a write: its path) and labels its
|
|
109
|
+
* scopes ({@link commandCardText}). `webUrl` = `http.publicUrl` + the conversation path.
|
|
107
110
|
*/
|
|
108
111
|
export declare function approvalCard(d: CardDeps, approvalId: string, base: string, locale: ChannelLocale, redact?: (s: string) => string): Promise<Extract<ChannelCard, {
|
|
109
112
|
kind: "approval";
|
package/dist/channels/cards.js
CHANGED
|
@@ -197,25 +197,36 @@ async function displayName(db, accountId) {
|
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
199
|
* A network ask's card text: the title names the host (or the number of hosts); the preview lists
|
|
200
|
-
* the hosts, then the command clipped to {@link CARD_SUMMARY_MAX}
|
|
201
|
-
* decision applies to all of them (an IM card has no per-host choice)
|
|
202
|
-
*
|
|
200
|
+
* the hosts, then the command clipped to {@link CARD_SUMMARY_MAX}, for several hosts that the
|
|
201
|
+
* decision applies to all of them (an IM card has no per-host choice) and, when `scopes` offers
|
|
202
|
+
* "add to this device's list", when that applies (device-provider spec §6.3). Model-controlled
|
|
203
|
+
* values are redacted by `redact` (the connection's secret values); the description stays on the
|
|
204
|
+
* web.
|
|
203
205
|
*/
|
|
204
|
-
export function networkCardText(detail, locale, redact = (s) => s) {
|
|
206
|
+
export function networkCardText(detail, locale, redact = (s) => s, scopes = []) {
|
|
205
207
|
const hosts = [...new Set(detail.hosts.map((h) => redact(h.host)))];
|
|
206
208
|
const title = hosts.length === 1
|
|
207
209
|
? phrase("networkTitleOne", locale).replace("{host}", hosts[0])
|
|
208
210
|
: phrase("networkTitleMany", locale).replace("{n}", String(hosts.length));
|
|
209
211
|
const command = cut(redact(detail.command.trim()), CARD_SUMMARY_MAX);
|
|
212
|
+
const applies = scopes.includes("always") && detail.appliesAt !== undefined
|
|
213
|
+
? phrase("networkAppliesLine", locale)
|
|
214
|
+
.replace("{label}", phrase("networkAddToDevice", locale))
|
|
215
|
+
.replace("{applies}", phrase(`networkApplies.${detail.appliesAt}`, locale))
|
|
216
|
+
: null;
|
|
210
217
|
return {
|
|
211
218
|
title,
|
|
212
219
|
inputPreview: [
|
|
213
220
|
...hosts,
|
|
214
221
|
...(command !== "" ? ["", command] : []),
|
|
215
222
|
...(hosts.length > 1 ? ["", phrase("networkAllHosts", locale)] : []),
|
|
223
|
+
...(applies !== null ? ["", applies] : []),
|
|
216
224
|
].join("\n"),
|
|
217
|
-
//
|
|
218
|
-
scopeLabels: {
|
|
225
|
+
// what the device's provider enforces: a run grant, the device's own list, or both
|
|
226
|
+
scopeLabels: {
|
|
227
|
+
once: phrase("networkAllowOnce", locale),
|
|
228
|
+
always: phrase("networkAddToDevice", locale),
|
|
229
|
+
},
|
|
219
230
|
};
|
|
220
231
|
}
|
|
221
232
|
/**
|
|
@@ -316,9 +327,10 @@ export async function personFieldsCard(d, approvalId, base, locale) {
|
|
|
316
327
|
}
|
|
317
328
|
/**
|
|
318
329
|
* The approval card in the approval's current state; undefined when the approval does not exist.
|
|
319
|
-
* A role escalation offers only "once". A network ask names its hosts and command
|
|
320
|
-
* scopes ({@link networkCardText}); a command
|
|
321
|
-
* command (a write: its path) and labels its
|
|
330
|
+
* A role escalation offers only "once". A network ask names its hosts and command, labels its
|
|
331
|
+
* scopes and says when "add to this device's list" applies ({@link networkCardText}); a command
|
|
332
|
+
* review ask names the review's reason and the held command (a write: its path) and labels its
|
|
333
|
+
* scopes ({@link commandCardText}). `webUrl` = `http.publicUrl` + the conversation path.
|
|
322
334
|
*/
|
|
323
335
|
export async function approvalCard(d, approvalId, base, locale, redact) {
|
|
324
336
|
const v = await d.approvals.describe(approvalId);
|
|
@@ -328,7 +340,7 @@ export async function approvalCard(d, approvalId, base, locale, redact) {
|
|
|
328
340
|
const decidedBy = await displayName(d.db, v.decidedBy);
|
|
329
341
|
// a network, git or command ask names what it asks about instead of a tool call (same shape)
|
|
330
342
|
const network = v.kind === "network" && v.detail !== null
|
|
331
|
-
? networkCardText(v.detail, locale, redact)
|
|
343
|
+
? networkCardText(v.detail, locale, redact, v.scopes)
|
|
332
344
|
: v.kind === "git" && v.git != null
|
|
333
345
|
? gitCardText(v.git, locale, redact)
|
|
334
346
|
: null;
|
|
@@ -358,8 +370,7 @@ export async function approvalCard(d, approvalId, base, locale, redact) {
|
|
|
358
370
|
.filter((l) => l !== "")
|
|
359
371
|
.join("\n"),
|
|
360
372
|
// the scopes the approval allows (the kernel stores them for per-call policies); a network,
|
|
361
|
-
// git or command ask offers only those it labels
|
|
362
|
-
// `always`, which the decision refuses)
|
|
373
|
+
// git or command ask offers only those it labels
|
|
363
374
|
scopes: special !== null ? v.scopes.filter((k) => Object.hasOwn(special.scopeLabels, k)) : v.scopes,
|
|
364
375
|
// the labels of the scopes offered only
|
|
365
376
|
...(special !== null && {
|
|
@@ -107,12 +107,34 @@ export declare const CHANNEL_PHRASES: {
|
|
|
107
107
|
readonly zh: "这个决定对以上所有域名生效";
|
|
108
108
|
readonly en: "This decision applies to all the domains above";
|
|
109
109
|
};
|
|
110
|
-
/** A network ask's
|
|
110
|
+
/** A network ask's "once" button: a run grant (only with per-operation hosts). */
|
|
111
111
|
readonly networkAllowOnce: {
|
|
112
112
|
readonly zh: "这次允许";
|
|
113
113
|
readonly en: "Allow this time";
|
|
114
114
|
};
|
|
115
|
-
/** A network ask's
|
|
115
|
+
/** A network ask's "always" button: the hosts join the device's own network list. */
|
|
116
|
+
readonly networkAddToDevice: {
|
|
117
|
+
readonly zh: "加入此设备的列表";
|
|
118
|
+
readonly en: "Add to this device's list";
|
|
119
|
+
};
|
|
120
|
+
/** The preview line saying when "always" applies (`{label}`, `{applies}`). */
|
|
121
|
+
readonly networkAppliesLine: {
|
|
122
|
+
readonly zh: "{label}:{applies}";
|
|
123
|
+
readonly en: "{label}: {applies}";
|
|
124
|
+
};
|
|
125
|
+
/** When hosts added to the device's list apply (device-provider spec §6.3), as the web says. */
|
|
126
|
+
readonly "networkApplies.next-command": {
|
|
127
|
+
readonly zh: "从下一条命令起生效";
|
|
128
|
+
readonly en: "Applies from the next command";
|
|
129
|
+
};
|
|
130
|
+
readonly "networkApplies.next-use": {
|
|
131
|
+
readonly zh: "下次使用这台设备时生效";
|
|
132
|
+
readonly en: "Applies the next time the device is used";
|
|
133
|
+
};
|
|
134
|
+
readonly "networkApplies.files-reset": {
|
|
135
|
+
readonly zh: "重建文件后生效";
|
|
136
|
+
readonly en: "Applies after the files are rebuilt";
|
|
137
|
+
};
|
|
116
138
|
/** A git push ask's card title (`{repo}`; sandbox git credentials spec §7). */
|
|
117
139
|
readonly gitTitle: {
|
|
118
140
|
readonly zh: "智能体想推送到 {repo},允许吗?";
|
package/dist/channels/phrases.js
CHANGED
|
@@ -93,9 +93,19 @@ export const CHANNEL_PHRASES = {
|
|
|
93
93
|
zh: "这个决定对以上所有域名生效",
|
|
94
94
|
en: "This decision applies to all the domains above",
|
|
95
95
|
},
|
|
96
|
-
/** A network ask's
|
|
96
|
+
/** A network ask's "once" button: a run grant (only with per-operation hosts). */
|
|
97
97
|
networkAllowOnce: { zh: "这次允许", en: "Allow this time" },
|
|
98
|
-
/** A network ask's
|
|
98
|
+
/** A network ask's "always" button: the hosts join the device's own network list. */
|
|
99
|
+
networkAddToDevice: { zh: "加入此设备的列表", en: "Add to this device's list" },
|
|
100
|
+
/** The preview line saying when "always" applies (`{label}`, `{applies}`). */
|
|
101
|
+
networkAppliesLine: { zh: "{label}:{applies}", en: "{label}: {applies}" },
|
|
102
|
+
/** When hosts added to the device's list apply (device-provider spec §6.3), as the web says. */
|
|
103
|
+
"networkApplies.next-command": { zh: "从下一条命令起生效", en: "Applies from the next command" },
|
|
104
|
+
"networkApplies.next-use": {
|
|
105
|
+
zh: "下次使用这台设备时生效",
|
|
106
|
+
en: "Applies the next time the device is used",
|
|
107
|
+
},
|
|
108
|
+
"networkApplies.files-reset": { zh: "重建文件后生效", en: "Applies after the files are rebuilt" },
|
|
99
109
|
/** A git push ask's card title (`{repo}`; sandbox git credentials spec §7). */
|
|
100
110
|
gitTitle: {
|
|
101
111
|
zh: "智能体想推送到 {repo},允许吗?",
|
package/dist/ctx/secrets.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export interface RewrapResult {
|
|
|
50
50
|
initialPasswords: number;
|
|
51
51
|
/** Unexpired sealed Platform reveals (`platform_sealed_reveals`, invitation links) now sealed with it. */
|
|
52
52
|
sealedReveals: number;
|
|
53
|
+
/** Unexpired sealed approval card values (`platform_sealed_inputs`) now sealed with it. */
|
|
54
|
+
sealedInputs: number;
|
|
53
55
|
/** Mobile app push tokens (`push_registrations`) now sealed with it. */
|
|
54
56
|
pushTokens: number;
|
|
55
57
|
}
|
|
@@ -75,8 +77,8 @@ type RewrapHandles = {
|
|
|
75
77
|
};
|
|
76
78
|
/**
|
|
77
79
|
* Rewraps everything sealed with a master key other than the keyring's current one (org data keys,
|
|
78
|
-
* unexpired initial passwords and sealed
|
|
79
|
-
* transaction, until none is left. Checks first that the keyring holds every master key in use and
|
|
80
|
+
* unexpired initial passwords, sealed reveals and sealed inputs, push tokens) with the current
|
|
81
|
+
* key, `batchSize` rows per transaction, until none is left. Checks first that the keyring holds every master key in use and
|
|
80
82
|
* throws (naming row ids and key ids, never key material) before writing anything when it does not.
|
|
81
83
|
* Idempotent: a second run finds nothing; concurrent runs lock the same rows and skip the ones
|
|
82
84
|
* already done.
|
package/dist/ctx/secrets.js
CHANGED
|
@@ -181,6 +181,14 @@ const MASTER_KEYED = [
|
|
|
181
181
|
aad: platformSealedRevealAad,
|
|
182
182
|
hasExpiresAt: true,
|
|
183
183
|
},
|
|
184
|
+
{
|
|
185
|
+
table: "platform_sealed_inputs",
|
|
186
|
+
idColumn: "approval_id",
|
|
187
|
+
dataColumn: "ciphertext",
|
|
188
|
+
aadColumns: ["paths"],
|
|
189
|
+
aad: (id, row) => platformSealedInputAad(id, row.paths),
|
|
190
|
+
hasExpiresAt: true,
|
|
191
|
+
},
|
|
184
192
|
{
|
|
185
193
|
table: "push_registrations",
|
|
186
194
|
idColumn: "id",
|
|
@@ -207,8 +215,8 @@ function assertKnown(t, keyring, rows) {
|
|
|
207
215
|
}
|
|
208
216
|
/**
|
|
209
217
|
* Rewraps everything sealed with a master key other than the keyring's current one (org data keys,
|
|
210
|
-
* unexpired initial passwords and sealed
|
|
211
|
-
* transaction, until none is left. Checks first that the keyring holds every master key in use and
|
|
218
|
+
* unexpired initial passwords, sealed reveals and sealed inputs, push tokens) with the current
|
|
219
|
+
* key, `batchSize` rows per transaction, until none is left. Checks first that the keyring holds every master key in use and
|
|
212
220
|
* throws (naming row ids and key ids, never key material) before writing anything when it does not.
|
|
213
221
|
* Idempotent: a second run finds nothing; concurrent runs lock the same rows and skip the ones
|
|
214
222
|
* already done.
|
|
@@ -233,7 +241,12 @@ export async function rewrapToCurrentMasterKey(handles, keyring, opts = {}) {
|
|
|
233
241
|
const done = await handles.txHost.run(async () => {
|
|
234
242
|
const trx = db();
|
|
235
243
|
const rows = await staleRows(trx, t, keyring)
|
|
236
|
-
.select([
|
|
244
|
+
.select([
|
|
245
|
+
`${t.idColumn} as id`,
|
|
246
|
+
"master_key_id as mk",
|
|
247
|
+
`${t.dataColumn} as data`,
|
|
248
|
+
...(t.aadColumns ?? []),
|
|
249
|
+
])
|
|
237
250
|
.orderBy(t.idColumn)
|
|
238
251
|
.limit(batchSize)
|
|
239
252
|
.forUpdate()
|
|
@@ -243,13 +256,13 @@ export async function rewrapToCurrentMasterKey(handles, keyring, opts = {}) {
|
|
|
243
256
|
for (const r of rows) {
|
|
244
257
|
let plain;
|
|
245
258
|
try {
|
|
246
|
-
plain = keyring.unwrap(r.mk, Buffer.from(r.data), t.aad(r.id));
|
|
259
|
+
plain = keyring.unwrap(r.mk, Buffer.from(r.data), t.aad(r.id, r));
|
|
247
260
|
}
|
|
248
261
|
catch (e) {
|
|
249
262
|
const why = e instanceof Error ? e.message : String(e);
|
|
250
263
|
throw new Error(`secrets: cannot unwrap ${t.table}.${t.idColumn}=${r.id}: ${why}`);
|
|
251
264
|
}
|
|
252
|
-
const w = keyring.wrap(plain, t.aad(r.id));
|
|
265
|
+
const w = keyring.wrap(plain, t.aad(r.id, r));
|
|
253
266
|
plain.fill(0);
|
|
254
267
|
await trx
|
|
255
268
|
.withSchema("capybara")
|
|
@@ -270,6 +283,7 @@ export async function rewrapToCurrentMasterKey(handles, keyring, opts = {}) {
|
|
|
270
283
|
dataKeys: counts.get("org_data_keys") ?? 0,
|
|
271
284
|
initialPasswords: counts.get("account_initial_passwords") ?? 0,
|
|
272
285
|
sealedReveals: counts.get("platform_sealed_reveals") ?? 0,
|
|
286
|
+
sealedInputs: counts.get("platform_sealed_inputs") ?? 0,
|
|
273
287
|
pushTokens: counts.get("push_registrations") ?? 0,
|
|
274
288
|
};
|
|
275
289
|
}
|
|
@@ -1763,6 +1763,7 @@ export interface KernelDatabase {
|
|
|
1763
1763
|
plugin_install_components: PluginInstallComponentsTable;
|
|
1764
1764
|
extension_catalog_sources: ExtensionCatalogSourcesTable;
|
|
1765
1765
|
bootstrap_runs: BootstrapRunsTable;
|
|
1766
|
+
bootstrap_run_started: BootstrapRunStartedTable;
|
|
1766
1767
|
org_notices: OrgNoticesTable;
|
|
1767
1768
|
platform_notices: PlatformNoticesTable;
|
|
1768
1769
|
plugin_scope_sync_failures: PluginScopeSyncFailuresTable;
|
|
@@ -1875,6 +1876,19 @@ export interface BootstrapRunsTable {
|
|
|
1875
1876
|
manifest_sha256: string;
|
|
1876
1877
|
completed_at: Ts;
|
|
1877
1878
|
results: ColumnType<unknown, string, string>;
|
|
1879
|
+
/**
|
|
1880
|
+
* 0178: sha256 (hex) of the extra manifest's part of the run (`bootstrapExtraSha256`); null
|
|
1881
|
+
* without an extra manifest and in older rows.
|
|
1882
|
+
*/
|
|
1883
|
+
extra_sha256: ColumnType<string | null, string | null | undefined, string | null>;
|
|
1884
|
+
}
|
|
1885
|
+
/** 0178: the bootstrap run that has started writing and not completed (at most one row). */
|
|
1886
|
+
export interface BootstrapRunStartedTable {
|
|
1887
|
+
singleton: ColumnType<boolean, boolean | undefined, never>;
|
|
1888
|
+
manifest_sha256: string;
|
|
1889
|
+
/** The names of the run's entries from the extra manifest (a JSON array of strings). */
|
|
1890
|
+
extra_plugins: ColumnType<unknown, string, string>;
|
|
1891
|
+
started_at: Ts;
|
|
1878
1892
|
}
|
|
1879
1893
|
/** 0034_directory.sql, renamed in 0042, one kind (plugin) since 0044: platform catalog items. */
|
|
1880
1894
|
export interface CatalogItemsTable {
|
|
@@ -135,7 +135,7 @@ export declare class ConversationDevices {
|
|
|
135
135
|
* it can (no binding, no access check): `provider-off` when the device the conversation is bound
|
|
136
136
|
* to (an unbound IM thread: its owner's IM default; any unbound one: its owner's default device)
|
|
137
137
|
* has its provider off in the org or not installed (its files are kept); `no-device` when there
|
|
138
|
-
* is no device and no default provider to make one while device providers are on in the org;
|
|
138
|
+
* is no device and no default provider to make one (a dial-in default makes none) while device providers are on in the org;
|
|
139
139
|
* `none` when no device provider is on in the org at all. A forbidden or gone device still counts as usable: the call
|
|
140
140
|
* then says why.
|
|
141
141
|
*/
|
|
@@ -145,7 +145,8 @@ export declare class ConversationDevices {
|
|
|
145
145
|
/**
|
|
146
146
|
* The person's IM default when `im` and it is still theirs, live, in this org and usable (the
|
|
147
147
|
* table has no such guard), else their default device (created when missing); null when
|
|
148
|
-
* that is needed and there is none and no default provider on in the org to make it
|
|
148
|
+
* that is needed and there is none and no default provider on in the org to make it (a dial-in
|
|
149
|
+
* default provider makes none: its devices come from a machine signing in). The owner
|
|
149
150
|
* having left the org reads as `device.not_found`.
|
|
150
151
|
*/
|
|
151
152
|
private defaultFor;
|
|
@@ -14,11 +14,13 @@ import { TransactionHost, withTransactionFencePrelude, } from "../infra/database
|
|
|
14
14
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
15
15
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
16
16
|
import { PermissionFacts } from "../sandbox/permission-facts.js";
|
|
17
|
+
import { servesDialIn } from "../sandbox/providers.js";
|
|
17
18
|
import { homeOf } from "../sandbox/review/rules.js";
|
|
18
|
-
import {
|
|
19
|
+
import { sandboxUnavailable } from "../sandbox/sandbox.service.js";
|
|
19
20
|
import { DeviceAccess } from "./access.js";
|
|
20
21
|
import { DeviceProviderSelection } from "./device-provider-selection.js";
|
|
21
22
|
import { DevicesService } from "./devices.service.js";
|
|
23
|
+
import { deviceNotFound } from "./errors.js";
|
|
22
24
|
import { workingRootOf } from "./working-root.js";
|
|
23
25
|
/** `details[0].reason` of the error an anonymous IM conversation's sandbox call gets. */
|
|
24
26
|
export const ANONYMOUS_NO_DEVICE = "anonymous";
|
|
@@ -193,7 +195,7 @@ let ConversationDevices = class ConversationDevices {
|
|
|
193
195
|
* it can (no binding, no access check): `provider-off` when the device the conversation is bound
|
|
194
196
|
* to (an unbound IM thread: its owner's IM default; any unbound one: its owner's default device)
|
|
195
197
|
* has its provider off in the org or not installed (its files are kept); `no-device` when there
|
|
196
|
-
* is no device and no default provider to make one while device providers are on in the org;
|
|
198
|
+
* is no device and no default provider to make one (a dial-in default makes none) while device providers are on in the org;
|
|
197
199
|
* `none` when no device provider is on in the org at all. A forbidden or gone device still counts as usable: the call
|
|
198
200
|
* then says why.
|
|
199
201
|
*/
|
|
@@ -233,7 +235,9 @@ let ConversationDevices = class ConversationDevices {
|
|
|
233
235
|
.executeTakeFirst();
|
|
234
236
|
if (own)
|
|
235
237
|
return onOrOff(own.id);
|
|
236
|
-
|
|
238
|
+
// a dial-in default provider makes no default device (DevicesService.ensureDefault)
|
|
239
|
+
const fallback = await this.selection.defaultFor(orgId);
|
|
240
|
+
if (fallback !== undefined && !servesDialIn(fallback))
|
|
237
241
|
return null;
|
|
238
242
|
return (await this.selection.onInOrg(orgId)).length > 0 ? "no-device" : "none";
|
|
239
243
|
}
|
|
@@ -251,7 +255,8 @@ let ConversationDevices = class ConversationDevices {
|
|
|
251
255
|
/**
|
|
252
256
|
* The person's IM default when `im` and it is still theirs, live, in this org and usable (the
|
|
253
257
|
* table has no such guard), else their default device (created when missing); null when
|
|
254
|
-
* that is needed and there is none and no default provider on in the org to make it
|
|
258
|
+
* that is needed and there is none and no default provider on in the org to make it (a dial-in
|
|
259
|
+
* default provider makes none: its devices come from a machine signing in). The owner
|
|
255
260
|
* having left the org reads as `device.not_found`.
|
|
256
261
|
*/
|
|
257
262
|
async defaultFor(orgId, accountId, im) {
|