@capybara-hq/kernel 0.1.0-rc.77 → 0.1.0-rc.78
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 +6 -6
- package/dist/admin/outbox-dead.service.js +4 -1
- package/dist/agents/admin-agents.js +2 -0
- package/dist/agents/agent-lookup.js +4 -0
- package/dist/agents/agent-profile.service.js +3 -0
- package/dist/agents/agents.service.js +7 -0
- package/dist/agents/org-templates.js +1 -0
- package/dist/agents/pending-connector-requests.js +6 -0
- package/dist/agents/pending-connectors.service.js +2 -0
- package/dist/agents/readiness.service.d.ts +9 -3
- package/dist/agents/readiness.service.js +3 -3
- package/dist/agents/templates.js +1 -0
- package/dist/background/finish.js +3 -0
- package/dist/background/stop.js +2 -0
- package/dist/background/store.js +44 -0
- package/dist/background/tasks.service.js +3 -2
- package/dist/background/wake-rules.js +1 -0
- package/dist/catalog/admin-catalog.controller.d.ts +6 -0
- package/dist/catalog/admin-catalog.controller.js +13 -0
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-content.js +1 -0
- package/dist/catalog/catalog-items.js +4 -0
- package/dist/catalog/catalog-scope.service.js +4 -1
- package/dist/catalog/component-promotion.js +2 -0
- package/dist/catalog/component-scope.controller.d.ts +9 -15
- package/dist/catalog/component-scope.controller.js +14 -9
- package/dist/catalog/component-scope.service.js +5 -0
- package/dist/catalog/component-state.js +2 -0
- package/dist/catalog/marketplaces.service.d.ts +6 -1
- package/dist/catalog/marketplaces.service.js +8 -3
- package/dist/catalog/org-catalog.controller.d.ts +9 -0
- package/dist/catalog/org-catalog.controller.js +18 -0
- package/dist/catalog/org-catalog.schemas.d.ts +2 -4
- package/dist/catalog/org-catalog.schemas.js +2 -3
- package/dist/catalog/org-catalog.service.d.ts +10 -1
- package/dist/catalog/org-catalog.service.js +34 -23
- package/dist/catalog/org-extension-switch.d.ts +3 -10
- package/dist/catalog/org-extension-switch.js +14 -60
- package/dist/catalog/org-extension.controller.d.ts +6 -7
- package/dist/catalog/org-extension.controller.js +4 -4
- package/dist/catalog/org-extension.schemas.d.ts +1 -2
- package/dist/catalog/org-extension.schemas.js +1 -3
- package/dist/catalog/owned-items.js +10 -1
- package/dist/catalog/ownership.js +2 -0
- package/dist/catalog/plugin-import.js +8 -0
- package/dist/catalog/plugin-install.d.ts +1 -4
- package/dist/catalog/plugin-install.js +11 -12
- package/dist/catalog/plugin-upgrade.js +4 -1
- package/dist/catalog/request-rules.js +6 -0
- package/dist/catalog/requests.service.js +4 -0
- package/dist/catalog/scope-orgs.js +1 -0
- package/dist/catalog/scope-sync.d.ts +8 -5
- package/dist/catalog/scope-sync.js +21 -23
- package/dist/catalog/unshare.js +3 -0
- package/dist/channels/connections.service.js +1 -0
- package/dist/channels/inbound.js +1 -0
- package/dist/channels/jobs.js +1 -0
- package/dist/channels/outbound.js +6 -0
- package/dist/channels/supervisor.js +1 -0
- package/dist/channels/threads.js +1 -0
- package/dist/client/client-reports.service.js +1 -0
- package/dist/config/fields.js +20 -4
- package/dist/conversations/access.js +1 -0
- package/dist/conversations/attachments.service.js +16 -4
- package/dist/conversations/conversations.service.js +17 -3
- package/dist/conversations/event-log.js +2 -0
- package/dist/conversations/events.d.ts +1 -0
- package/dist/conversations/events.js +3 -1
- package/dist/conversations/files.js +3 -2
- package/dist/conversations/permission-profiles.service.js +1 -0
- package/dist/conversations/prompt-suggestions.js +2 -0
- package/dist/conversations/queue.js +8 -0
- package/dist/conversations/queue.service.js +6 -2
- package/dist/conversations/source.js +2 -0
- package/dist/conversations/titles.js +10 -2
- package/dist/conversations/tree.js +6 -0
- package/dist/db/kernel-schema.d.ts +3 -1
- package/dist/devices/conversation-devices.js +3 -0
- package/dist/devices/device-projects.service.js +2 -0
- package/dist/devices/devices.service.js +5 -0
- package/dist/devices/legacy-cleanup.job.js +5 -2
- package/dist/dial-in/handlers.js +2 -0
- package/dist/dial-in/machines.js +11 -2
- package/dist/dial-in/targets.d.ts +0 -2
- package/dist/dial-in/targets.js +0 -10
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +0 -1
- package/dist/evals/budget.js +14 -1
- package/dist/evals/run-replay.js +4 -0
- package/dist/evals/runs.service.js +13 -7
- package/dist/evals/sets.service.js +23 -8
- package/dist/evals/trajectory.service.d.ts +1 -1
- package/dist/evals/trajectory.service.js +1 -0
- package/dist/evals/worker.js +5 -1
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +3 -1
- package/dist/extensions/bootstrap-packages.d.ts +12 -1
- package/dist/extensions/bootstrap-packages.js +49 -9
- package/dist/extensions/bootstrap.d.ts +17 -2
- package/dist/extensions/bootstrap.js +41 -9
- package/dist/extensions/config-json-schema.d.ts +2 -2
- package/dist/extensions/config-json-schema.js +1 -3
- package/dist/extensions/deployment-config.d.ts +5 -3
- package/dist/extensions/deployment-config.js +3 -3
- package/dist/extensions/effective-config.d.ts +8 -7
- package/dist/extensions/effective-config.js +8 -7
- package/dist/extensions/enabled.js +1 -0
- package/dist/extensions/host.d.ts +4 -3
- package/dist/extensions/host.js +11 -12
- package/dist/extensions/instance.d.ts +1 -1
- package/dist/extensions/instance.js +17 -2
- package/dist/extensions/org-config.d.ts +35 -97
- package/dist/extensions/org-config.js +48 -315
- package/dist/extensions/org-levels.d.ts +22 -9
- package/dist/extensions/org-levels.js +100 -20
- package/dist/extensions/org-overrides.d.ts +14 -15
- package/dist/extensions/org-overrides.js +20 -20
- package/dist/extensions/package.js +1 -1
- package/dist/extensions/permission-set.d.ts +1 -3
- package/dist/extensions/permission-set.js +3 -7
- package/dist/extensions/permission-view.d.ts +3 -1
- package/dist/extensions/permission-view.js +5 -4
- package/dist/extensions/plugin-icons.d.ts +72 -1
- package/dist/extensions/plugin-icons.js +194 -2
- package/dist/extensions/point-defaults.d.ts +17 -18
- package/dist/extensions/point-defaults.js +25 -28
- package/dist/identity/accounts.js +6 -0
- package/dist/identity/api-tokens.js +8 -0
- package/dist/infra/outbox/outbox.dispatcher.js +4 -1
- package/dist/infra/outbox/outbox.service.js +2 -0
- package/dist/orgs/directory-sync.d.ts +9 -6
- package/dist/orgs/directory-sync.js +15 -12
- package/dist/orgs/invitations.service.js +2 -0
- package/dist/orgs/members.service.js +2 -0
- package/dist/orgs/offboarding.js +2 -0
- package/dist/packages/npm.d.ts +9 -1
- package/dist/packages/npm.js +37 -5
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin-items.ops.js +1 -0
- package/dist/platform/ops/agents.ops.js +1 -0
- package/dist/platform/ops/extensions.ops.d.ts +6 -8
- package/dist/platform/ops/extensions.ops.js +18 -97
- package/dist/platform/ops/org-plugins.ops.d.ts +3 -6
- package/dist/platform/ops/org-plugins.ops.js +14 -65
- package/dist/platform/ops/outbox.ops.js +1 -0
- package/dist/platform/ops/person-inputs.d.ts +0 -4
- package/dist/platform/ops/person-inputs.js +0 -8
- package/dist/platform/ops/plugins.ops.d.ts +4 -1
- package/dist/platform/ops/plugins.ops.js +27 -34
- package/dist/platform/person-fields.d.ts +1 -1
- package/dist/platform/person-fields.js +1 -1
- package/dist/platform/sealed-reveals.js +2 -0
- package/dist/push/recipients.js +9 -2
- package/dist/runtime/permission-context.service.js +1 -0
- package/dist/runtime/plugin-context.service.js +1 -0
- package/dist/runtime/project/knowledge.service.js +1 -0
- package/dist/runtime/run-context.service.js +1 -0
- package/dist/runtime/run-deletion.js +4 -0
- package/dist/runtime/run-execution.js +2 -0
- package/dist/runtime/run-finish.js +3 -0
- package/dist/runtime/run-jobs.js +3 -0
- package/dist/runtime/run-orphan-check.job.js +7 -0
- package/dist/runtime/run-queue.js +21 -2
- package/dist/runtime/run-worker.js +5 -0
- package/dist/runtime/step-log.js +1 -0
- package/dist/runtime/subagents/child.js +2 -0
- package/dist/runtime/subagents/deliveries.js +3 -0
- package/dist/runtime/subagents/dispatch.js +5 -1
- package/dist/runtime/subagents/messages.js +2 -0
- package/dist/runtime/subagents/org-agents.d.ts +1 -1
- package/dist/runtime/subagents/org-agents.js +2 -1
- package/dist/runtime/usage-report-jobs.js +1 -0
- package/dist/runtime/usage-report.js +3 -0
- package/dist/runtime/waits.js +5 -0
- package/dist/sandbox/cloud-permission-snapshot.js +9 -3
- package/dist/sandbox/device-reports.js +3 -0
- package/dist/sandbox/legacy-retirement.js +5 -1
- package/dist/sandbox/managed-device-context.js +1 -0
- package/dist/sandbox/modes.d.ts +5 -2
- package/dist/sandbox/modes.js +8 -4
- package/dist/sandbox/network-grants.js +2 -0
- package/dist/sandbox/operation-intents.js +58 -0
- package/dist/sandbox/operation-reconcile.job.js +2 -0
- package/dist/sandbox/permission-authority-lock.js +12 -6
- package/dist/sandbox/permission-call-grants.js +6 -0
- package/dist/sandbox/permission-ceiling-writes.js +5 -0
- package/dist/sandbox/permission-config-publication.js +5 -0
- package/dist/sandbox/permission-instance-writes.js +4 -0
- package/dist/sandbox/permission-runtime-reports.js +10 -1
- package/dist/sandbox/permission-transitions.js +3 -0
- package/dist/sandbox/review/review.service.js +8 -5
- package/dist/sandbox/sandbox.service.d.ts +14 -0
- package/dist/sandbox/sandbox.service.js +195 -29
- package/dist/sandbox/unreachable.js +4 -1
- package/dist/schedules/fire.js +9 -3
- package/dist/schedules/pause.js +2 -0
- package/dist/schedules/run-tracker.js +16 -1
- package/dist/schedules/scheduled-tasks.service.js +4 -2
- package/dist/schedules/store.js +8 -0
- package/dist/schedules/unattended.js +4 -0
- package/dist/setup/setup-checks.service.d.ts +1 -10
- package/dist/setup/setup-checks.service.js +19 -29
- package/dist/shares/share-open.service.js +1 -0
- package/dist/shares/shares.service.js +2 -0
- package/dist/skills/agent-skills.service.d.ts +1 -1
- package/dist/skills/agent-skills.service.js +13 -2
- package/dist/skills/catalog.js +3 -0
- package/dist/skills/changes.service.js +10 -2
- package/dist/skills/conversation-catalog.js +1 -0
- package/dist/skills/skills.service.js +4 -0
- package/dist/tools/approvals.service.js +40 -0
- package/dist/tools/builtins/schedules.js +11 -6
- package/dist/tools/builtins/web/fetch.js +1 -1
- package/dist/tools/builtins/web/search.js +1 -1
- package/dist/tools/connector-account-policies.js +3 -0
- package/dist/tools/connectors.controller.d.ts +20 -8
- package/dist/tools/connectors.controller.js +30 -12
- package/dist/tools/connectors.service.d.ts +8 -0
- package/dist/tools/connectors.service.js +21 -1
- package/dist/tools/drift.js +5 -0
- package/dist/tools/git-push-policy.js +3 -0
- package/dist/tools/oauth/flow.js +1 -0
- package/dist/tools/outputs.js +2 -0
- package/dist/tools/permission-approval-jobs.js +3 -0
- package/dist/tools/pipeline.js +2 -0
- package/dist/tools/policy.js +3 -0
- package/dist/tools/questions.service.js +13 -0
- package/package.json +3 -3
|
@@ -1,27 +1,99 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPlatformOnly } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* The deployment schema's object: the schema itself, or the input object of a pipe or transform
|
|
5
|
+
* root (`z.object({…}).transform(…)`), as zod's JSON Schema of the input shows its properties, so
|
|
6
|
+
* a loaded replica and one reading the static form agree. undefined for anything else.
|
|
7
|
+
*/
|
|
8
|
+
export function deploymentObject(schema) {
|
|
9
|
+
let node = schema;
|
|
10
|
+
for (let depth = 0; node !== undefined && depth < 16; depth++) {
|
|
11
|
+
if (node instanceof z.ZodObject)
|
|
12
|
+
return node;
|
|
13
|
+
node = node instanceof z.ZodPipe ? node.in : undefined;
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
/** Whether `schema` or any schema nested in it (fields, items, options, wrappers) is marked. */
|
|
18
|
+
function markedAnywhere(schema, seen = new Set()) {
|
|
19
|
+
if (seen.has(schema))
|
|
20
|
+
return false;
|
|
21
|
+
seen.add(schema);
|
|
22
|
+
if (isPlatformOnly(schema))
|
|
23
|
+
return true;
|
|
24
|
+
const def = schema._zod.def;
|
|
25
|
+
// A lazy schema's inner schema comes from its getter (`seen` stops a recursive one)
|
|
26
|
+
if (def.type === "lazy" && typeof def.getter === "function") {
|
|
27
|
+
const inner = def.getter();
|
|
28
|
+
if (inner instanceof z.ZodType && markedAnywhere(inner, seen))
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
for (const v of Object.values(def)) {
|
|
32
|
+
const children = v instanceof z.ZodType
|
|
33
|
+
? [v]
|
|
34
|
+
: Array.isArray(v)
|
|
35
|
+
? v
|
|
36
|
+
: typeof v === "object" && v !== null && Object.getPrototypeOf(v) === Object.prototype
|
|
37
|
+
? Object.values(v)
|
|
38
|
+
: [];
|
|
39
|
+
for (const c of children) {
|
|
40
|
+
if (c instanceof z.ZodType && markedAnywhere(c, seen))
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The top-level keys of a `ZodObject` deployment schema (or the input object of a pipe or
|
|
48
|
+
* transform root, {@link deploymentObject}) with their level; empty otherwise.
|
|
49
|
+
*/
|
|
4
50
|
export function fieldLevels(schema) {
|
|
5
51
|
const out = new Map();
|
|
6
|
-
|
|
52
|
+
const obj = deploymentObject(schema);
|
|
53
|
+
if (schema === undefined || obj === undefined)
|
|
7
54
|
return out;
|
|
8
|
-
|
|
9
|
-
|
|
55
|
+
const root = isPlatformOnly(schema) || isPlatformOnly(obj);
|
|
56
|
+
for (const [key, field] of Object.entries(obj.shape)) {
|
|
57
|
+
out.set(key, root || markedAnywhere(field) ? "platform" : "override");
|
|
10
58
|
}
|
|
11
59
|
return out;
|
|
12
60
|
}
|
|
61
|
+
const markedPlatformOnly = (node) => node?.["x-platform-only"] === true;
|
|
62
|
+
/**
|
|
63
|
+
* Whether a JSON Schema node or anything below it carries `"x-platform-only": true`, following
|
|
64
|
+
* local `$ref`s (`#/…`) into `root`.
|
|
65
|
+
*/
|
|
66
|
+
function jsonMarkedAnywhere(node, root, seen = new Set()) {
|
|
67
|
+
if (typeof node !== "object" || node === null || seen.has(node))
|
|
68
|
+
return false;
|
|
69
|
+
seen.add(node);
|
|
70
|
+
if (markedPlatformOnly(node))
|
|
71
|
+
return true;
|
|
72
|
+
const ref = node.$ref;
|
|
73
|
+
if (typeof ref === "string" && ref.startsWith("#/")) {
|
|
74
|
+
let target = root;
|
|
75
|
+
for (const part of ref.slice(2).split("/")) {
|
|
76
|
+
const k = part.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
77
|
+
target = typeof target === "object" && target !== null ? target[k] : undefined;
|
|
78
|
+
}
|
|
79
|
+
if (jsonMarkedAnywhere(target, root, seen))
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return Object.values(node).some((v) => jsonMarkedAnywhere(v, root, seen));
|
|
83
|
+
}
|
|
13
84
|
/**
|
|
14
|
-
* The same levels read from a package's static form schema (`x-
|
|
15
|
-
* an install record whose module
|
|
85
|
+
* The same levels read from a package's static form schema (`x-platform-only` on the root, a
|
|
86
|
+
* top-level property or, failing closed, anywhere below one), for an install record whose module
|
|
87
|
+
* this replica has not loaded.
|
|
16
88
|
*/
|
|
17
89
|
export function jsonSchemaFieldLevels(schema) {
|
|
18
90
|
const out = new Map();
|
|
19
91
|
const props = schema?.properties;
|
|
20
92
|
if (typeof props !== "object" || props === null)
|
|
21
93
|
return out;
|
|
94
|
+
const root = markedPlatformOnly(schema);
|
|
22
95
|
for (const [key, prop] of Object.entries(props)) {
|
|
23
|
-
|
|
24
|
-
out.set(key, v === "readonly" || v === "override" ? v : "hidden");
|
|
96
|
+
out.set(key, root || jsonMarkedAnywhere(prop, schema) ? "platform" : "override");
|
|
25
97
|
}
|
|
26
98
|
return out;
|
|
27
99
|
}
|
|
@@ -29,22 +101,29 @@ const overrideKeys = (schema) => [...fieldLevels(schema)].filter(([, l]) => l ==
|
|
|
29
101
|
/**
|
|
30
102
|
* The platform's relaxed schema (§5.4a): a plain object rebuilt from the shape with every
|
|
31
103
|
* `override` key optional, so the platform may leave overridable fields empty (each org then
|
|
32
|
-
* brings its own);
|
|
104
|
+
* brings its own); platform-only fields stay as declared. Object-level refinements
|
|
33
105
|
* (`.refine` / `.superRefine`) are not carried over: they may read the absent fields, and zod
|
|
34
106
|
* refuses `.extend()` on a refined object. The identity when there is no `override` key. Parse
|
|
35
107
|
* through {@link parseLoadGate}, which uses this only when an overridable field is missing.
|
|
36
108
|
*/
|
|
37
109
|
export function relaxOverridable(schema) {
|
|
38
110
|
const keys = overrideKeys(schema);
|
|
39
|
-
if (keys.length === 0)
|
|
111
|
+
if (keys.length === 0 || deploymentObject(schema) === undefined)
|
|
40
112
|
return schema;
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
113
|
+
// A pipe or transform root keeps its output side(s) on the relaxed input object
|
|
114
|
+
const rebuild = (node) => {
|
|
115
|
+
if (node instanceof z.ZodPipe) {
|
|
116
|
+
return rebuild(node.in).pipe(node.out);
|
|
117
|
+
}
|
|
118
|
+
const obj = node;
|
|
119
|
+
const shape = { ...obj.shape };
|
|
120
|
+
for (const k of keys)
|
|
121
|
+
shape[k] = shape[k].optional();
|
|
122
|
+
const plain = z.object(shape);
|
|
123
|
+
const catchall = obj._zod.def.catchall;
|
|
124
|
+
return catchall ? plain.catchall(catchall) : plain;
|
|
125
|
+
};
|
|
126
|
+
return rebuild(schema);
|
|
48
127
|
}
|
|
49
128
|
/**
|
|
50
129
|
* The platform's load gate (§5.4a): the original schema, refinements included, whenever the
|
|
@@ -63,9 +142,10 @@ export function parseLoadGate(schema, raw) {
|
|
|
63
142
|
*/
|
|
64
143
|
export function missingOverridable(schema, raw) {
|
|
65
144
|
const keys = overrideKeys(schema);
|
|
66
|
-
|
|
145
|
+
const obj = deploymentObject(schema);
|
|
146
|
+
if (keys.length === 0 || obj === undefined)
|
|
67
147
|
return [];
|
|
68
|
-
const shape =
|
|
148
|
+
const shape = obj.shape;
|
|
69
149
|
const value = typeof raw === "object" && raw !== null ? raw : {};
|
|
70
150
|
return keys.filter((k) => value[k] === undefined && !shape[k].safeParse(undefined).success);
|
|
71
151
|
}
|
|
@@ -9,10 +9,9 @@ import { type SecretEntry } from "./deployment-config.js";
|
|
|
9
9
|
import { EffectiveConfigs } from "./effective-config.js";
|
|
10
10
|
import { ExtensionHost } from "./host.js";
|
|
11
11
|
import { type FieldLevel } from "./org-levels.js";
|
|
12
|
-
/** One field of {@link OrgOverrideView}:
|
|
12
|
+
/** One field of {@link OrgOverrideView}: an overridable deployment field (the only kind listed). */
|
|
13
13
|
export interface OrgOverrideField {
|
|
14
14
|
path: string;
|
|
15
|
-
level: "readonly" | "override";
|
|
16
15
|
secret: boolean;
|
|
17
16
|
/** The platform's current value (non-secret) or only whether it is set (secret). */
|
|
18
17
|
platform: {
|
|
@@ -29,16 +28,16 @@ export interface OrgOverrideField {
|
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* What an org admin sees of an extension's two-level config (spec A §5.3 to §5.6): whether the org
|
|
32
|
-
* follows the platform or keeps a copy, the
|
|
33
|
-
*
|
|
31
|
+
* follows the platform or keeps a copy, the overridable fields (platform-only fields never appear),
|
|
32
|
+
* and whether the effective config is valid. Secrets give `set` only, never a value, and
|
|
34
33
|
* are never compared.
|
|
35
34
|
*/
|
|
36
35
|
export interface OrgOverrideView {
|
|
37
36
|
state: "following" | "copy";
|
|
38
37
|
/**
|
|
39
|
-
* The deployment form JSON Schema restricted to the
|
|
40
|
-
*
|
|
41
|
-
*
|
|
38
|
+
* The deployment form JSON Schema restricted to the overridable top-level properties (as the
|
|
39
|
+
* platform form gets it, with `x-ui`, `x-secret`); platform-only properties, their `required`
|
|
40
|
+
* entries and hints naming them are removed. Null when the extension has no
|
|
42
41
|
* deployment schema or it cannot be converted.
|
|
43
42
|
*/
|
|
44
43
|
schema: JsonSchema | null;
|
|
@@ -91,13 +90,13 @@ export declare class OrgOverrides {
|
|
|
91
90
|
* plugin without it) is answered like an unknown one, so its platform values never reach it.
|
|
92
91
|
*/
|
|
93
92
|
private runningFor;
|
|
94
|
-
/** The org's view (
|
|
93
|
+
/** The org's view (overridable fields, the copy state and validity). */
|
|
95
94
|
view(orgId: string, plugin: string): Promise<OrgOverrideView>;
|
|
96
95
|
/**
|
|
97
96
|
* Saves overridable fields (`values` keyed by field dot path: `null` clears, omitted keeps;
|
|
98
97
|
* secret fields too, as in the platform form) and secret record entries. The first save creates
|
|
99
98
|
* the copy from the platform's non-secret overridable values plus `values` (secret fields start
|
|
100
|
-
* empty). A path that is not an overridable field of the schema (
|
|
99
|
+
* empty). A path that is not an overridable field of the schema (platform-only, unknown) ->
|
|
101
100
|
* 400 `extension.field_not_overridable`; an invalid result (an empty required secret included)
|
|
102
101
|
* -> 400 `extension.config_invalid`, nothing written. Audits `extension.org_override_saved`.
|
|
103
102
|
*/
|
|
@@ -105,7 +104,7 @@ export declare class OrgOverrides {
|
|
|
105
104
|
private writeSave;
|
|
106
105
|
/**
|
|
107
106
|
* Takes the platform's current values of non-secret overridable fields into the copy (spec A
|
|
108
|
-
* §5.5); the copy stays a copy. A secret,
|
|
107
|
+
* §5.5); the copy stays a copy. A secret, platform-only or unknown path -> 400
|
|
109
108
|
* `extension.field_not_overridable`; no copy -> 404 `extension.no_org_override`. Audits
|
|
110
109
|
* `extension.org_override_taken`.
|
|
111
110
|
*/
|
|
@@ -139,15 +138,15 @@ export declare class OrgOverrides {
|
|
|
139
138
|
private secretPathsHeld;
|
|
140
139
|
}
|
|
141
140
|
/**
|
|
142
|
-
* The form JSON Schema an org may see (spec A §5.6,
|
|
143
|
-
* all
|
|
144
|
-
*
|
|
141
|
+
* The form JSON Schema an org may see (spec A §5.6, platform-only fields are not sent to the org
|
|
142
|
+
* at all): a copy with only the overridable top-level properties, `required` limited to them, and
|
|
143
|
+
* root `x-ui` hints naming a platform-only field dropped (`secrets[]` by path; `order` lists
|
|
145
144
|
* none). Values are never in it: `configJsonSchema` already strips secret defaults and examples.
|
|
146
145
|
*/
|
|
147
146
|
export declare function orgFormSchema(js: JsonSchema, levels: Map<string, FieldLevel>): JsonSchema;
|
|
148
147
|
/**
|
|
149
|
-
* Issues as an org may see them: an issue on a
|
|
150
|
-
* sees, so those collapse into one root issue.
|
|
148
|
+
* Issues as an org may see them: an issue on a platform-only field would name a field the org
|
|
149
|
+
* never sees, so those collapse into one root issue.
|
|
151
150
|
*/
|
|
152
151
|
export declare function orgIssues(issues: ConfigIssue[], levels: Map<string, FieldLevel>): ConfigIssue[];
|
|
153
152
|
export {};
|
|
@@ -27,7 +27,8 @@ import { EffectiveConfigs, mergeCopy, OVERRIDE_SECRETS_NAMESPACE, overrideSecret
|
|
|
27
27
|
import { ExtensionHost } from "./host.js";
|
|
28
28
|
import { extensionVisibleTo } from "./org-config.js";
|
|
29
29
|
import { fieldLevels } from "./org-levels.js";
|
|
30
|
-
|
|
30
|
+
/** A path's level: its top-level key's; a key the schema does not list is `platform` (not shown). */
|
|
31
|
+
const levelOf = (levels, path) => levels.get(path.split(".")[0]) ?? "platform";
|
|
31
32
|
const notOverridable = (plugin, paths) => new ApiError("extension.field_not_overridable", `These config fields of extension ${plugin} cannot be set by an organization: ${paths.join(", ")}`, paths.map((path) => ({ path })));
|
|
32
33
|
const noCopy = (plugin) => new ApiError("extension.no_org_override", `This organization follows the platform configuration of extension ${plugin}`);
|
|
33
34
|
/**
|
|
@@ -77,7 +78,7 @@ let OrgOverrides = class OrgOverrides {
|
|
|
77
78
|
}
|
|
78
79
|
return run;
|
|
79
80
|
}
|
|
80
|
-
/** The org's view (
|
|
81
|
+
/** The org's view (overridable fields, the copy state and validity). */
|
|
81
82
|
async view(orgId, plugin) {
|
|
82
83
|
return this.render(orgId, await this.runningFor(orgId, plugin));
|
|
83
84
|
}
|
|
@@ -85,7 +86,7 @@ let OrgOverrides = class OrgOverrides {
|
|
|
85
86
|
* Saves overridable fields (`values` keyed by field dot path: `null` clears, omitted keeps;
|
|
86
87
|
* secret fields too, as in the platform form) and secret record entries. The first save creates
|
|
87
88
|
* the copy from the platform's non-secret overridable values plus `values` (secret fields start
|
|
88
|
-
* empty). A path that is not an overridable field of the schema (
|
|
89
|
+
* empty). A path that is not an overridable field of the schema (platform-only, unknown) ->
|
|
89
90
|
* 400 `extension.field_not_overridable`; an invalid result (an empty required secret included)
|
|
90
91
|
* -> 400 `extension.config_invalid`, nothing written. Audits `extension.org_override_saved`.
|
|
91
92
|
*/
|
|
@@ -193,7 +194,7 @@ let OrgOverrides = class OrgOverrides {
|
|
|
193
194
|
}
|
|
194
195
|
/**
|
|
195
196
|
* Takes the platform's current values of non-secret overridable fields into the copy (spec A
|
|
196
|
-
* §5.5); the copy stays a copy. A secret,
|
|
197
|
+
* §5.5); the copy stays a copy. A secret, platform-only or unknown path -> 400
|
|
197
198
|
* `extension.field_not_overridable`; no copy -> 404 `extension.no_org_override`. Audits
|
|
198
199
|
* `extension.org_override_taken`.
|
|
199
200
|
*/
|
|
@@ -404,22 +405,21 @@ let OrgOverrides = class OrgOverrides {
|
|
|
404
405
|
.where("org_id", "=", orgId)
|
|
405
406
|
.executeTakeFirst();
|
|
406
407
|
const held = row ? new Set(await this.secretPathsHeld(orgId, run.inst.name)) : new Set();
|
|
407
|
-
//
|
|
408
|
-
//
|
|
408
|
+
// secret state as the running instance has it; non-secret values raw, as a copy stores and
|
|
409
|
+
// `take` copies them, else as the running instance has them (defaults applied, as the
|
|
410
|
+
// platform form shows)
|
|
409
411
|
const parsed = run.inst.config;
|
|
410
412
|
const raw = await this.host.rawDeploymentConfig(run.inst.name);
|
|
411
413
|
const fields = [];
|
|
412
414
|
for (const f of run.schema ? configFields(run.schema) : []) {
|
|
413
|
-
|
|
414
|
-
if (level === "hidden")
|
|
415
|
+
if (levelOf(run.levels, f.path) !== "override")
|
|
415
416
|
continue;
|
|
416
417
|
const secret = f.meta?.secret === true;
|
|
417
|
-
const pv =
|
|
418
|
-
?
|
|
419
|
-
: getPath(parsed, f.path);
|
|
418
|
+
const pv = secret
|
|
419
|
+
? getPath(parsed, f.path)
|
|
420
|
+
: (getPath(raw, f.path) ?? getPath(parsed, f.path));
|
|
420
421
|
const field = {
|
|
421
422
|
path: f.path,
|
|
422
|
-
level,
|
|
423
423
|
secret,
|
|
424
424
|
platform: secret
|
|
425
425
|
? { set: pv !== undefined }
|
|
@@ -427,7 +427,7 @@ let OrgOverrides = class OrgOverrides {
|
|
|
427
427
|
? {}
|
|
428
428
|
: { value: structuredClone(pv) },
|
|
429
429
|
};
|
|
430
|
-
if (row
|
|
430
|
+
if (row) {
|
|
431
431
|
if (secret)
|
|
432
432
|
field.org = { set: held.has(f.path) };
|
|
433
433
|
else {
|
|
@@ -478,14 +478,14 @@ OrgOverrides = __decorate([
|
|
|
478
478
|
], OrgOverrides);
|
|
479
479
|
export { OrgOverrides };
|
|
480
480
|
/**
|
|
481
|
-
* The form JSON Schema an org may see (spec A §5.6,
|
|
482
|
-
* all
|
|
483
|
-
*
|
|
481
|
+
* The form JSON Schema an org may see (spec A §5.6, platform-only fields are not sent to the org
|
|
482
|
+
* at all): a copy with only the overridable top-level properties, `required` limited to them, and
|
|
483
|
+
* root `x-ui` hints naming a platform-only field dropped (`secrets[]` by path; `order` lists
|
|
484
484
|
* none). Values are never in it: `configJsonSchema` already strips secret defaults and examples.
|
|
485
485
|
*/
|
|
486
486
|
export function orgFormSchema(js, levels) {
|
|
487
487
|
const out = structuredClone(js);
|
|
488
|
-
const shown = (key) =>
|
|
488
|
+
const shown = (key) => levels.get(key) === "override";
|
|
489
489
|
const props = out.properties;
|
|
490
490
|
if (typeof props === "object" && props !== null) {
|
|
491
491
|
out.properties = Object.fromEntries(Object.entries(props).filter(([k]) => shown(k)));
|
|
@@ -507,11 +507,11 @@ function touchedPaths(values, entries) {
|
|
|
507
507
|
return [...Object.keys(values), ...entries.map((e) => e.path)];
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
|
-
* Issues as an org may see them: an issue on a
|
|
511
|
-
* sees, so those collapse into one root issue.
|
|
510
|
+
* Issues as an org may see them: an issue on a platform-only field would name a field the org
|
|
511
|
+
* never sees, so those collapse into one root issue.
|
|
512
512
|
*/
|
|
513
513
|
export function orgIssues(issues, levels) {
|
|
514
|
-
const shown = issues.filter((i) => i.path !== "" && levelOf(levels, i.path)
|
|
514
|
+
const shown = issues.filter((i) => i.path !== "" && levelOf(levels, i.path) === "override");
|
|
515
515
|
if (shown.length === issues.length)
|
|
516
516
|
return issues;
|
|
517
517
|
return [
|
|
@@ -186,7 +186,7 @@ export function permissionSetOfSection(section, migrationSql) {
|
|
|
186
186
|
provides: m.provides,
|
|
187
187
|
requires: m.requires,
|
|
188
188
|
optional: m.optional,
|
|
189
|
-
config: { deployment: strip(m.config.deployment)
|
|
189
|
+
config: { deployment: strip(m.config.deployment) },
|
|
190
190
|
tables,
|
|
191
191
|
permissions: m.permissions,
|
|
192
192
|
warningsDigest: warningsDigest(migrationWarnings(migrationSql, m.name)),
|
|
@@ -15,7 +15,6 @@ export interface PermissionSet {
|
|
|
15
15
|
optional: string[];
|
|
16
16
|
config: {
|
|
17
17
|
deployment: PermissionConfigField[];
|
|
18
|
-
org: PermissionConfigField[];
|
|
19
18
|
};
|
|
20
19
|
/** 插件迁移里 `CREATE TABLE` 的表名(插件自己 schema 下的不带前缀)。 */
|
|
21
20
|
tables: string[];
|
|
@@ -108,7 +107,6 @@ export declare function buildPermissionSet(input: {
|
|
|
108
107
|
optional?: readonly string[] | undefined;
|
|
109
108
|
config: {
|
|
110
109
|
deployment: PermissionConfigField[];
|
|
111
|
-
org: PermissionConfigField[];
|
|
112
110
|
};
|
|
113
111
|
tables: readonly string[];
|
|
114
112
|
permissions?: ExtensionPermissions | undefined;
|
|
@@ -116,7 +114,7 @@ export declare function buildPermissionSet(input: {
|
|
|
116
114
|
}): PermissionSet;
|
|
117
115
|
/**
|
|
118
116
|
* The stable string keys of a permission set (sorted), such as `provides:channel@1`,
|
|
119
|
-
* `config.
|
|
117
|
+
* `config.deployment.secret:apiKey`, `table:todos`, `permissions.tools:write`,
|
|
120
118
|
* `permissions.http.<access>:<METHOD> <path>` (`permissions.http.public:POST /events`),
|
|
121
119
|
* `ui.view:tasks`, `ui.embed:board`, `permissions.client`, `ui.component:hud`,
|
|
122
120
|
* `permissions.dialin:capybara-device/6`.
|
|
@@ -69,7 +69,6 @@ export async function computePermissionSet(manifest, pluginDir) {
|
|
|
69
69
|
optional: manifest.optional,
|
|
70
70
|
config: {
|
|
71
71
|
deployment: fieldsOf(manifest.config?.deployment),
|
|
72
|
-
org: fieldsOf(manifest.config?.org),
|
|
73
72
|
},
|
|
74
73
|
tables,
|
|
75
74
|
permissions: manifest.permissions,
|
|
@@ -88,7 +87,6 @@ export function buildPermissionSet(input) {
|
|
|
88
87
|
optional: sortedUnique(input.optional),
|
|
89
88
|
config: {
|
|
90
89
|
deployment: [...input.config.deployment].sort(byPath),
|
|
91
|
-
org: [...input.config.org].sort(byPath),
|
|
92
90
|
},
|
|
93
91
|
tables: sortedUnique(input.tables),
|
|
94
92
|
permissions: {
|
|
@@ -125,7 +123,7 @@ export function buildPermissionSet(input) {
|
|
|
125
123
|
}
|
|
126
124
|
/**
|
|
127
125
|
* The stable string keys of a permission set (sorted), such as `provides:channel@1`,
|
|
128
|
-
* `config.
|
|
126
|
+
* `config.deployment.secret:apiKey`, `table:todos`, `permissions.tools:write`,
|
|
129
127
|
* `permissions.http.<access>:<METHOD> <path>` (`permissions.http.public:POST /events`),
|
|
130
128
|
* `ui.view:tasks`, `ui.embed:board`, `permissions.client`, `ui.component:hud`,
|
|
131
129
|
* `permissions.dialin:capybara-device/6`.
|
|
@@ -141,10 +139,8 @@ export function permissionKeys(set) {
|
|
|
141
139
|
keys.push(`requires:${r}`);
|
|
142
140
|
for (const r of s.optional ?? [])
|
|
143
141
|
keys.push(`optional:${r}`);
|
|
144
|
-
for (const
|
|
145
|
-
|
|
146
|
-
keys.push(`config.${level}${f.secret ? ".secret" : ""}:${f.path || "<root>"}`);
|
|
147
|
-
}
|
|
142
|
+
for (const f of s.config?.deployment ?? []) {
|
|
143
|
+
keys.push(`config.deployment${f.secret ? ".secret" : ""}:${f.path || "<root>"}`);
|
|
148
144
|
}
|
|
149
145
|
for (const t of s.tables ?? [])
|
|
150
146
|
keys.push(`table:${t}`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LocalizedName, UiDropReason } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { PluginScope } from "../catalog/scope.js";
|
|
3
|
+
import type { ReportBodyInput } from "../client/client.schemas.js";
|
|
3
4
|
import { type PermissionSet } from "./permission-set.js";
|
|
4
5
|
import type { ExtensionSource } from "./sources.js";
|
|
5
6
|
/**
|
|
@@ -180,7 +181,8 @@ export interface AdminExtensionView {
|
|
|
180
181
|
clientReports: {
|
|
181
182
|
orgId: string | null;
|
|
182
183
|
contribution: string | null;
|
|
183
|
-
kind
|
|
184
|
+
/** As the report was sent (`ReportBody.kind`). */
|
|
185
|
+
kind: ReportBodyInput["kind"];
|
|
184
186
|
count: number;
|
|
185
187
|
firstAt: string;
|
|
186
188
|
lastAt: string;
|
|
@@ -144,10 +144,11 @@ export function permissionGroups(set) {
|
|
|
144
144
|
// older snapshots lack `ui`, `ui.components` and `client` (read as empty / false)
|
|
145
145
|
const ui = p.ui ?? { views: [], embeds: [], components: [] };
|
|
146
146
|
const components = ui.components ?? [];
|
|
147
|
-
// Level-prefixed like the config group
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
// Level-prefixed like the config group (`deployment:<path>`).
|
|
148
|
+
const secretFields = set.config.deployment
|
|
149
|
+
.filter((f) => f.secret)
|
|
150
|
+
.map((f) => `deployment:${f.path || "<root>"}`);
|
|
151
|
+
const configFields = set.config.deployment.map((f) => `deployment:${f.path || "<root>"}`);
|
|
151
152
|
const secretItems = [...(p.secrets ? ["secret store"] : []), ...secretFields];
|
|
152
153
|
const groups = [
|
|
153
154
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CatalogIcon } from "../catalog/catalog-content.js";
|
|
1
2
|
import { type PluginScope } from "../catalog/scope.js";
|
|
2
3
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
4
|
import { type OrgRole } from "../orgs/roles.js";
|
|
@@ -13,7 +14,14 @@ export type PluginIconScope = {
|
|
|
13
14
|
export declare const orgIconScope: (org: {
|
|
14
15
|
orgId: string;
|
|
15
16
|
role: OrgRole;
|
|
16
|
-
}) => PluginIconScope
|
|
17
|
+
}) => Extract<PluginIconScope, {
|
|
18
|
+
kind: "org";
|
|
19
|
+
}>;
|
|
20
|
+
/** What a connector or connector template shows an icon for: its platform template and plugin. */
|
|
21
|
+
export interface IconRef {
|
|
22
|
+
templateId: string | null;
|
|
23
|
+
itemId: string | null;
|
|
24
|
+
}
|
|
17
25
|
/** The catalog item columns {@link orgVisibleItems} reads. */
|
|
18
26
|
export interface OrgVisibilityRow {
|
|
19
27
|
id: string;
|
|
@@ -50,5 +58,68 @@ export declare class PluginIcons {
|
|
|
50
58
|
many(names: string[], scope: PluginIconScope): Promise<Map<string, string>>;
|
|
51
59
|
/** Catalog item id -> its icon's URL (a list of items); items without one are absent. */
|
|
52
60
|
ofItems(ids: string[], scope: PluginIconScope): Promise<Map<string, string>>;
|
|
61
|
+
/**
|
|
62
|
+
* Platform connector template id -> the URL of the template's own icon (`ConnectorTemplateFile.
|
|
63
|
+
* icon`, stored as a catalog display file of the template's current version); templates without
|
|
64
|
+
* one, or that the reader may not see, are absent. The admin scope gets
|
|
65
|
+
* `GET /api/v1/admin/catalog/connector-templates/:templateId/icon` for every live template; an org
|
|
66
|
+
* gets `GET /api/v1/orgs/:orgId/connector-templates/:templateId/icon` only when its catalog shows
|
|
67
|
+
* the template's plugin (the gate of the plugin icon) and the template passes the share gate.
|
|
68
|
+
* The URL carries the template's version (the platform's one version of it).
|
|
69
|
+
*/
|
|
70
|
+
ofTemplates(ids: string[], scope: PluginIconScope): Promise<Map<string, string>>;
|
|
71
|
+
/**
|
|
72
|
+
* The icon of each connector template shown (in the order given): its own icon
|
|
73
|
+
* ({@link ofTemplates}), else its plugin's ({@link ofItems}), else null. One lookup each for all
|
|
74
|
+
* rows.
|
|
75
|
+
*/
|
|
76
|
+
ofTemplatesOrItems(refs: IconRef[], scope: PluginIconScope): Promise<(string | null)[]>;
|
|
77
|
+
/**
|
|
78
|
+
* The icon of each connector template of a catalog item, by template file id (`connectors/<id>.
|
|
79
|
+
* json`, as the item detail lists them): the platform template's own icon, else the plugin's,
|
|
80
|
+
* else null ({@link ofTemplatesOrItems}). A file id without a live platform template gets the
|
|
81
|
+
* plugin's icon.
|
|
82
|
+
*/
|
|
83
|
+
ofItemTemplates(itemId: string, templateIds: string[], scope: PluginIconScope): Promise<Map<string, string | null>>;
|
|
84
|
+
/**
|
|
85
|
+
* The icon of each of an org's connectors (in the order given), resolved as
|
|
86
|
+
* {@link ofTemplatesOrItems} (its platform template's own icon, else its plugin's, else null)
|
|
87
|
+
* but always served by the connector's own route, `GET /api/v1/orgs/:orgId/connectors/:id/icon`
|
|
88
|
+
* (`connectors.use`, see {@link readConnectorIcon}): everyone who sees the connector pages,
|
|
89
|
+
* guests included, can load it, while the catalog's icon route stays `catalog.read`. The URL
|
|
90
|
+
* carries where the icon comes from and its version, so a new icon is not stale-cached.
|
|
91
|
+
*/
|
|
92
|
+
ofConnectors(rows: (IconRef & {
|
|
93
|
+
id: string;
|
|
94
|
+
})[], scope: Extract<PluginIconScope, {
|
|
95
|
+
kind: "org";
|
|
96
|
+
}>): Promise<(string | null)[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Reads the icon a connector shows ({@link ofConnectors}); the caller has checked that the
|
|
99
|
+
* connector is the org's. No icon the reader may see -> `catalog.icon_not_found`.
|
|
100
|
+
*/
|
|
101
|
+
readConnectorIcon(ref: IconRef, scope: PluginIconScope): Promise<CatalogIcon>;
|
|
102
|
+
/**
|
|
103
|
+
* Reads a connector template's own icon (served only through kernel routes with nosniff and a
|
|
104
|
+
* CSP sandbox, like the plugin icon). A template that is unknown, removed or not visible to the
|
|
105
|
+
* reader -> `component.not_found` (decided before any file is read, so "no icon" never reveals
|
|
106
|
+
* that it exists); no icon of its own -> `catalog.icon_not_found`; stored content that is not a
|
|
107
|
+
* valid svg / png (checked at import; this guards against tampered storage) -> `internal`.
|
|
108
|
+
*/
|
|
109
|
+
readTemplateIcon(templateId: string, scope: PluginIconScope): Promise<CatalogIcon>;
|
|
110
|
+
/** Where each ref's icon comes from: its template's own icon, else its plugin's, else none. */
|
|
111
|
+
private sources;
|
|
112
|
+
/** The URL of an icon source on the reader's routes (template or catalog item route). */
|
|
113
|
+
private sourceUrl;
|
|
114
|
+
/** Template id -> its version, for the templates with an own icon the reader may see. */
|
|
115
|
+
private templateIconVersions;
|
|
116
|
+
/** Live platform connector templates (of live items) with their item's visibility columns. */
|
|
117
|
+
private templateRows;
|
|
118
|
+
/**
|
|
119
|
+
* The templates the reader may see: every one for the admin scope; for an org, those whose
|
|
120
|
+
* plugin its catalog shows ({@link orgVisibleItems}) and that pass the template's own share gate
|
|
121
|
+
* (the platform's, the org's own, or shared by its owner).
|
|
122
|
+
*/
|
|
123
|
+
private visibleTemplates;
|
|
53
124
|
private resolve;
|
|
54
125
|
}
|