@capybara-hq/kernel 0.1.0-rc.127 → 0.1.0-rc.129
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 +3 -3
- package/dist/admin/admin.schemas.d.ts +14 -0
- package/dist/agents/readiness.service.d.ts +6 -0
- package/dist/agents/readiness.service.js +1 -1
- package/dist/automations/automations.service.js +15 -21
- package/dist/automations/effective-settings.d.ts +3 -9
- package/dist/automations/effective-settings.js +3 -5
- package/dist/automations/fire.js +0 -11
- package/dist/automations/grant-rules.d.ts +7 -10
- package/dist/automations/grant-rules.js +9 -18
- package/dist/automations/unattended.d.ts +1 -4
- package/dist/automations/unattended.js +0 -2
- package/dist/catalog/catalog-items.d.ts +7 -4
- package/dist/catalog/catalog-items.js +8 -7
- package/dist/catalog/catalog-scope.service.d.ts +3 -2
- package/dist/catalog/catalog-scope.service.js +5 -4
- package/dist/catalog/org-extension.controller.d.ts +1 -20
- package/dist/catalog/org-extension.controller.js +1 -48
- package/dist/catalog/org-extension.schemas.d.ts +1 -9
- package/dist/catalog/org-extension.schemas.js +1 -17
- package/dist/config/schema.d.ts +12 -0
- package/dist/config/schema.js +16 -0
- package/dist/conversations/approval-profile.d.ts +8 -1
- package/dist/conversations/approval-profile.js +20 -0
- package/dist/conversations/conversations.service.d.ts +1 -1
- package/dist/conversations/conversations.service.js +8 -3
- package/dist/conversations/events.d.ts +25 -1
- package/dist/conversations/events.js +7 -2
- package/dist/conversations/permission-profiles.controller.d.ts +4 -0
- package/dist/conversations/permission-profiles.schemas.d.ts +5 -0
- package/dist/conversations/permission-profiles.schemas.js +8 -0
- package/dist/conversations/permission-profiles.service.d.ts +8 -1
- package/dist/conversations/permission-profiles.service.js +13 -1
- package/dist/db/kernel-schema.d.ts +21 -0
- package/dist/device-access/device-access.service.d.ts +4 -1
- package/dist/device-access/device-access.service.js +26 -7
- package/dist/device-access/viewer.d.ts +3 -1
- package/dist/device-access/viewer.js +18 -9
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/extensions/admin-view.d.ts +1 -3
- package/dist/extensions/admin-view.js +5 -8
- package/dist/git/gateway.d.ts +8 -1
- package/dist/git/gateway.js +68 -11
- package/dist/git/git.module.d.ts +2 -3
- package/dist/git/git.module.js +4 -4
- package/dist/http/api.module.js +3 -3
- package/dist/identity/settings.d.ts +20 -5
- package/dist/identity/settings.js +52 -9
- package/dist/infra/config/kernel-config.service.js +4 -0
- package/dist/orgs/orgs.module.js +12 -1
- package/dist/orgs/orgs.schemas.js +3 -0
- package/dist/orgs/security-settings.service.d.ts +94 -0
- package/dist/orgs/security-settings.service.js +223 -0
- package/dist/orgs/settings.controller.d.ts +33 -0
- package/dist/orgs/settings.controller.js +41 -1
- package/dist/orgs/settings.service.d.ts +48 -63
- package/dist/orgs/settings.service.js +86 -103
- package/dist/platform/exclusions.js +1 -1
- package/dist/platform/operation.js +4 -0
- package/dist/platform/ops/admin.ops.js +18 -4
- package/dist/platform/ops/agents.ops.js +1 -1
- package/dist/platform/ops/connectors.ops.js +2 -2
- package/dist/platform/ops/extensions.ops.d.ts +1 -3
- package/dist/platform/ops/extensions.ops.js +4 -131
- package/dist/platform/ops/org-settings.ops.d.ts +3 -1
- package/dist/platform/ops/org-settings.ops.js +76 -3
- package/dist/platform/ops/orgs.ops.js +2 -0
- package/dist/runtime/context/permission-profile.js +6 -0
- package/dist/runtime/subagents/dispatch.d.ts +3 -0
- package/dist/runtime/subagents/dispatch.js +2 -1
- package/dist/runtime/subagents/messages.d.ts +3 -1
- package/dist/runtime/subagents/messages.js +9 -6
- package/dist/sandbox/device-sandbox-settings.d.ts +55 -1
- package/dist/sandbox/device-sandbox-settings.js +64 -1
- package/dist/sandbox/device-sandbox.d.ts +9 -1
- package/dist/sandbox/device-sandbox.js +17 -2
- package/dist/sandbox/device-services.d.ts +26 -3
- package/dist/sandbox/device-services.js +95 -16
- package/dist/sandbox/loopback-grant-records.d.ts +3 -2
- package/dist/sandbox/loopback-grant-records.js +32 -5
- package/dist/sandbox/operation-authority.d.ts +3 -2
- package/dist/sandbox/operation-authority.js +21 -1
- package/dist/sandbox/operation-intents.js +5 -1
- package/dist/sandbox/permission-call-types.d.ts +2 -1
- package/dist/sandbox/permission-ceiling-writes.d.ts +14 -5
- package/dist/sandbox/permission-ceiling-writes.js +122 -13
- package/dist/sandbox/permission-config-publication.d.ts +10 -0
- package/dist/sandbox/permission-config-publication.js +27 -5
- package/dist/sandbox/permission-facts.d.ts +21 -2
- package/dist/sandbox/permission-facts.js +101 -9
- package/dist/sandbox/permission-transitions.d.ts +1 -1
- package/dist/sandbox/sandbox.service.d.ts +2 -2
- package/dist/sandbox/sandbox.service.js +7 -3
- package/dist/tools/admin-connectors.js +2 -2
- package/dist/tools/approvals.service.d.ts +7 -2
- package/dist/tools/approvals.service.js +39 -7
- package/dist/tools/builtin-names.d.ts +0 -6
- package/dist/tools/builtin-names.js +0 -11
- package/dist/tools/builtins/sandbox/index.d.ts +3 -5
- package/dist/tools/builtins/sandbox/index.js +3 -5
- package/dist/tools/connector-account-policies.js +7 -4
- package/dist/tools/connectors.controller.d.ts +0 -6
- package/dist/tools/connectors.schemas.d.ts +1 -8
- package/dist/tools/connectors.schemas.js +1 -4
- package/dist/tools/connectors.service.d.ts +3 -7
- package/dist/tools/connectors.service.js +29 -44
- package/dist/tools/drift.js +12 -4
- package/dist/tools/git-push-policy.d.ts +1 -4
- package/dist/tools/git-push-policy.js +4 -5
- package/dist/tools/org-tool-policies.d.ts +24 -0
- package/dist/tools/org-tool-policies.js +113 -0
- package/dist/tools/org-tool-switches.d.ts +5 -70
- package/dist/tools/org-tool-switches.js +13 -141
- package/dist/tools/pipeline.d.ts +11 -5
- package/dist/tools/pipeline.js +173 -38
- package/dist/tools/policy.d.ts +3 -7
- package/dist/tools/policy.js +29 -48
- package/dist/tools/registry.d.ts +5 -0
- package/dist/tools/registry.js +44 -13
- package/package.json +1 -1
- package/src/migrations/0212_org_security_policy.sql +234 -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": "28d1cfdacc69af3ed2020622d973c681e9f7fc10"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
@@ -98,8 +98,8 @@
|
|
|
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.19",
|
|
102
|
+
"integrity": "sha512-2v2iT3YWZJs42PYXSDZQ9lrU7vALnb7aYRHlYLvWw+kFmrDb51ZlyXKWPjgi1WhzUTk3Zcp5f2WNcnbjiTm97Q==",
|
|
103
103
|
"required": false,
|
|
104
104
|
"scope": "all"
|
|
105
105
|
},
|
|
@@ -74,6 +74,20 @@ export declare const DeploymentSettingsBody: z.ZodObject<{
|
|
|
74
74
|
open: "open";
|
|
75
75
|
}>>>;
|
|
76
76
|
}, z.core.$strict>>;
|
|
77
|
+
devicesAllowedProfiles: z.ZodOptional<z.ZodObject<{
|
|
78
|
+
value: z.ZodNullable<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
|
79
|
+
"approve-for-me": "approve-for-me";
|
|
80
|
+
"full-access": "full-access";
|
|
81
|
+
"request-approval": "request-approval";
|
|
82
|
+
}>>, z.ZodTransform<("approve-for-me" | "full-access" | "request-approval")[], ("approve-for-me" | "full-access" | "request-approval")[]>>>;
|
|
83
|
+
}, z.core.$strict>>;
|
|
84
|
+
devicesProjectReach: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
ceiling: z.ZodNullable<z.ZodEnum<{
|
|
86
|
+
machine: "machine";
|
|
87
|
+
paths: "paths";
|
|
88
|
+
workspace: "workspace";
|
|
89
|
+
}>>;
|
|
90
|
+
}, z.core.$strict>>;
|
|
77
91
|
devicesDefaultProvider: z.ZodOptional<z.ZodObject<{
|
|
78
92
|
provider: z.ZodNullable<z.ZodString>;
|
|
79
93
|
}, z.core.$strict>>;
|
|
@@ -13,6 +13,12 @@ import { OnboardingChecklist, type OnboardingStatus } from "./onboarding-checkli
|
|
|
13
13
|
export interface OrgFixableProvider {
|
|
14
14
|
provider: string;
|
|
15
15
|
reason: "not_enabled" | "needs_config";
|
|
16
|
+
/**
|
|
17
|
+
* The provider waits for the org's own config (an API key the platform left empty), whether or
|
|
18
|
+
* not it is on: false means the platform configured a connection the org only switches on. The
|
|
19
|
+
* setup home says "the platform provides models" only then (#1226).
|
|
20
|
+
*/
|
|
21
|
+
needsOrgConfig: boolean;
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
18
24
|
* A model provider that is on in the org with a valid config but gives an agent no model to pick
|
|
@@ -28,12 +28,12 @@ import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
|
28
28
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
29
29
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
30
30
|
import { can, roleAtLeast } from "../orgs/roles.js";
|
|
31
|
-
import { FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR } from "../orgs/settings.service.js";
|
|
32
31
|
import { ProviderRegistry } from "../runtime/providers.js";
|
|
33
32
|
import { orgHostOutsideCeiling } from "../sandbox/modes.js";
|
|
34
33
|
import { orgAllows } from "../sandbox/network-grants.js";
|
|
35
34
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
36
35
|
import { isTimeZone } from "../time-zone.js";
|
|
36
|
+
import { readOrgGitPushDenials, readOrgToolPolicies, readOrgToolPolicy, } from "../tools/org-tool-policies.js";
|
|
37
37
|
import { ToolRegistry } from "../tools/registry.js";
|
|
38
38
|
import { assembleCalendar, CALENDAR_LIMITS, CALENDAR_RANGE_DAYS, CALENDAR_TASK_RANGE_DAYS, calendarRunReadLimit, } from "./calendar.js";
|
|
39
39
|
import { readAutomationSettings } from "./effective-settings.js";
|
|
@@ -158,7 +158,7 @@ let AutomationsService = class AutomationsService {
|
|
|
158
158
|
};
|
|
159
159
|
await this.checkPick(orgId, accountId, agent, target.mode, pick);
|
|
160
160
|
const expiresAt = expiryOf(input.expiresAt ?? null, trigger, now, settings);
|
|
161
|
-
const grants = await this.resolveGrants(orgId, role, agent,
|
|
161
|
+
const grants = await this.resolveGrants(orgId, role, agent, input.grants ?? [], await this.taskDeviceOf(orgId, { ...target, deviceId: pick.deviceId }), source);
|
|
162
162
|
const id = randomUUID();
|
|
163
163
|
const jitter = jitterForGap(id, gap);
|
|
164
164
|
const task = await this.store.insertTask(t, {
|
|
@@ -226,7 +226,7 @@ let AutomationsService = class AutomationsService {
|
|
|
226
226
|
// too (refused, so the creator sees which), and takes the new agent's definition; network
|
|
227
227
|
// and git and sandbox tier grants belong to no tool and stay as they are
|
|
228
228
|
const held = (await this.store.listGrants(t, task.id)).filter((g) => !isNonToolGrantKey(g.toolKey));
|
|
229
|
-
const regranted = await this.resolveGrants(orgId, role, agent,
|
|
229
|
+
const regranted = await this.resolveGrants(orgId, role, agent, held.map((g) => ({
|
|
230
230
|
toolKey: g.toolKey,
|
|
231
231
|
...(g.connectorId !== null && { connectorId: g.connectorId }),
|
|
232
232
|
})), null);
|
|
@@ -665,7 +665,8 @@ let AutomationsService = class AutomationsService {
|
|
|
665
665
|
async grantableTools(orgId, accountId, agentId) {
|
|
666
666
|
const role = await this.liveRole(orgId, accountId);
|
|
667
667
|
const agent = await this.agents.get(orgId, agentId, accountId);
|
|
668
|
-
const
|
|
668
|
+
const policies = await readOrgToolPolicies(this.db.db, orgId);
|
|
669
|
+
const byKey = new Map(policies.map((r) => [r.toolKey, r]));
|
|
669
670
|
const d = agent.definition;
|
|
670
671
|
const { tools } = await this.tools.forAgent(orgId, {
|
|
671
672
|
disabledTools: d.disabledTools ?? [],
|
|
@@ -674,12 +675,11 @@ let AutomationsService = class AutomationsService {
|
|
|
674
675
|
// no conversation at hand: a web one's tools; a run elsewhere still refuses by spec.sources
|
|
675
676
|
source: "web",
|
|
676
677
|
});
|
|
677
|
-
const ctx = {
|
|
678
|
-
role,
|
|
679
|
-
forbiddenTools: settings.forbiddenTools,
|
|
680
|
-
};
|
|
681
678
|
return tools.map((tool) => {
|
|
682
|
-
const
|
|
679
|
+
const row = byKey.get(tool.key);
|
|
680
|
+
const pair = [row?.policy, row?.unattendedPolicy];
|
|
681
|
+
const orgPolicy = pair.includes("deny") ? "deny" : pair.includes("ask") ? "ask" : "allow";
|
|
682
|
+
const why = grantRefusalOf(tool.key, tool, { role, orgPolicy });
|
|
683
683
|
return {
|
|
684
684
|
key: tool.key,
|
|
685
685
|
title: tool.spec.title ?? null,
|
|
@@ -725,9 +725,8 @@ let AutomationsService = class AutomationsService {
|
|
|
725
725
|
const { role } = await this.orgLock.lockAndAuthorize(orgId, accountId, "automations.use");
|
|
726
726
|
const t = this.db.db;
|
|
727
727
|
const task = await this.lockOwn(orgId, accountId, role, id);
|
|
728
|
-
const settings = await readAutomationSettings(t, this.config, orgId);
|
|
729
728
|
const agent = await this.agents.get(orgId, task.agentId, accountId);
|
|
730
|
-
const resolved = await this.resolveGrants(orgId, role, agent,
|
|
729
|
+
const resolved = await this.resolveGrants(orgId, role, agent, grants, await this.taskDeviceOf(orgId, task), source);
|
|
731
730
|
for (const g of resolved)
|
|
732
731
|
await this.store.addGrant(t, task.id, g);
|
|
733
732
|
await audit(t, {
|
|
@@ -1180,13 +1179,9 @@ let AutomationsService = class AutomationsService {
|
|
|
1180
1179
|
* lower-cased) is refused by {@link gitGrantRefusal} and stored with `spec_hash` `git` and no
|
|
1181
1180
|
* connector, also only when `source.fromSession`. Duplicates keep the last.
|
|
1182
1181
|
*/
|
|
1183
|
-
async resolveGrants(orgId, role, agent,
|
|
1182
|
+
async resolveGrants(orgId, role, agent, grants, _deviceId, source = {}) {
|
|
1184
1183
|
if (grants.length === 0)
|
|
1185
1184
|
return [];
|
|
1186
|
-
// fail closed: no grant can be checked against a list that cannot be read
|
|
1187
|
-
if (settings.forbiddenToolsUnreadable) {
|
|
1188
|
-
throw grantNotAllowed(FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR);
|
|
1189
|
-
}
|
|
1190
1185
|
const out = new Map();
|
|
1191
1186
|
const network = grants.filter((g) => isNetworkGrantKey(g.toolKey));
|
|
1192
1187
|
if (network.length > 0) {
|
|
@@ -1210,12 +1205,13 @@ let AutomationsService = class AutomationsService {
|
|
|
1210
1205
|
// a push is the creator's decision, never an agent's or a token's (as network domains)
|
|
1211
1206
|
if (source.fromSession !== true)
|
|
1212
1207
|
throw grantNotAllowed(GIT_GRANT_NEEDS_PERSON);
|
|
1208
|
+
const gitDenials = await readOrgGitPushDenials(this.db.db, orgId);
|
|
1213
1209
|
for (const g of git) {
|
|
1214
1210
|
if (g.connectorId !== undefined) {
|
|
1215
1211
|
throw grantNotAllowed(`${g.toolKey} is a git push and comes from no connector`);
|
|
1216
1212
|
}
|
|
1217
1213
|
const toolKey = normalizeGitGrantKey(g.toolKey);
|
|
1218
|
-
const why = gitGrantRefusal(toolKey, {
|
|
1214
|
+
const why = gitGrantRefusal(toolKey, { gitDenials });
|
|
1219
1215
|
if (why !== null)
|
|
1220
1216
|
throw grantNotAllowed(why.message);
|
|
1221
1217
|
out.set(toolKey, { toolKey, specHash: GIT_GRANT_SPEC_HASH, connectorId: null });
|
|
@@ -1234,10 +1230,8 @@ let AutomationsService = class AutomationsService {
|
|
|
1234
1230
|
});
|
|
1235
1231
|
for (const g of toolGrants) {
|
|
1236
1232
|
const tool = tools.find((x) => x.key === g.toolKey);
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
forbiddenTools: settings.forbiddenTools,
|
|
1240
|
-
});
|
|
1233
|
+
const policy = await readOrgToolPolicy(this.db.db, orgId, tool?.key ?? g.toolKey, g.toolKey, true);
|
|
1234
|
+
const why = grantRefusal(g.toolKey, tool, { role, orgPolicy: policy.policy });
|
|
1241
1235
|
if (why !== null || !tool)
|
|
1242
1236
|
throw grantNotAllowed(why ?? `${g.toolKey} cannot be approved`);
|
|
1243
1237
|
const connectorId = tool.source.kind === "connector" ? tool.source.connectorId : null;
|
|
@@ -11,18 +11,12 @@ export interface AutomationBounds {
|
|
|
11
11
|
coalesceSecondsCap: number;
|
|
12
12
|
maxEventRunsPerSubjectPerHourCap: number;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
* the stored list cannot be read (`invalidStoredForbiddenTools`); `forbiddenTools` is then `[]`
|
|
17
|
-
* and unattended runs of the org must fail instead of running with nothing forbidden.
|
|
18
|
-
*/
|
|
19
|
-
export type EffectiveAutomationSettings = AutomationsSettings & {
|
|
20
|
-
forbiddenToolsUnreadable: boolean;
|
|
21
|
-
};
|
|
14
|
+
/** The org's automation settings after clamping to the platform bounds. */
|
|
15
|
+
export type EffectiveAutomationSettings = AutomationsSettings;
|
|
22
16
|
/**
|
|
23
17
|
* An org value outside the platform bounds is clamped: the interval up, the counts, the event
|
|
24
18
|
* chain depth and the coalescing window down.
|
|
25
19
|
*/
|
|
26
|
-
export declare function effectiveAutomationSettings(org: AutomationsSettings, bounds: AutomationBounds
|
|
20
|
+
export declare function effectiveAutomationSettings(org: AutomationsSettings, bounds: AutomationBounds): EffectiveAutomationSettings;
|
|
27
21
|
/** Read the org's effective settings live (PG and the current kernel config). */
|
|
28
22
|
export declare function readAutomationSettings(db: KernelSchemaDb, config: Pick<KernelConfigService, "get">, orgId: string): Promise<EffectiveAutomationSettings>;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseOrgSettings, readStoredOrgSettings, } from "../orgs/settings.service.js";
|
|
2
2
|
/**
|
|
3
3
|
* An org value outside the platform bounds is clamped: the interval up, the counts, the event
|
|
4
4
|
* chain depth and the coalescing window down.
|
|
5
5
|
*/
|
|
6
|
-
export function effectiveAutomationSettings(org, bounds
|
|
6
|
+
export function effectiveAutomationSettings(org, bounds) {
|
|
7
7
|
return {
|
|
8
8
|
...org,
|
|
9
|
-
forbiddenTools: [...org.forbiddenTools],
|
|
10
9
|
eventSourcesOff: [...org.eventSourcesOff],
|
|
11
|
-
forbiddenToolsUnreadable,
|
|
12
10
|
minIntervalMinutes: Math.max(org.minIntervalMinutes, bounds.minIntervalFloorMinutes),
|
|
13
11
|
maxTasksPerMember: Math.min(org.maxTasksPerMember, bounds.maxTasksPerMemberCap),
|
|
14
12
|
maxTasksPerOrg: Math.min(org.maxTasksPerOrg, bounds.maxTasksPerOrgCap),
|
|
@@ -21,5 +19,5 @@ export function effectiveAutomationSettings(org, bounds, forbiddenToolsUnreadabl
|
|
|
21
19
|
/** Read the org's effective settings live (PG and the current kernel config). */
|
|
22
20
|
export async function readAutomationSettings(db, config, orgId) {
|
|
23
21
|
const raw = await readStoredOrgSettings(db, orgId);
|
|
24
|
-
return effectiveAutomationSettings(parseOrgSettings(raw).automations, config.get().automations
|
|
22
|
+
return effectiveAutomationSettings(parseOrgSettings(raw).automations, config.get().automations);
|
|
25
23
|
}
|
package/dist/automations/fire.js
CHANGED
|
@@ -29,7 +29,6 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
29
29
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
30
30
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
31
31
|
import { OrgLock, OrgLockModule } from "../orgs/org-lock.js";
|
|
32
|
-
import { FORBIDDEN_TOOLS_UNREADABLE_ERROR } from "../orgs/settings.service.js";
|
|
33
32
|
import { AUTOMATION_EVENT_HEAD, AUTOMATION_EVENT_TAIL } from "../runtime/context/run-context.js";
|
|
34
33
|
import { RuntimeModule } from "../runtime/runtime.module.js";
|
|
35
34
|
import { DeviceProviders, servesDialIn } from "../sandbox/providers.js";
|
|
@@ -285,16 +284,6 @@ let AutomationFirer = class AutomationFirer {
|
|
|
285
284
|
}
|
|
286
285
|
if (!resumed && !settings.enabled)
|
|
287
286
|
return skip("org_disabled");
|
|
288
|
-
// an unattended run must not run with nothing forbidden (a trial run is attended)
|
|
289
|
-
if (!resumed && !run.trial && settings.forbiddenToolsUnreadable) {
|
|
290
|
-
this.log.warn("automation run failed: the org's forbidden tool list is unreadable", {
|
|
291
|
-
orgId,
|
|
292
|
-
taskId: task.id,
|
|
293
|
-
taskRunId: run.id,
|
|
294
|
-
});
|
|
295
|
-
await this.tracker.failStartIn(run.id, FORBIDDEN_TOOLS_UNREADABLE_ERROR);
|
|
296
|
-
return null;
|
|
297
|
-
}
|
|
298
287
|
if (!resumed && !(await this.creatorActive(orgId, task.accountId))) {
|
|
299
288
|
return skip("creator_inactive");
|
|
300
289
|
}
|
|
@@ -9,11 +9,12 @@ import type { ResolvedTool } from "../tools/registry.js";
|
|
|
9
9
|
/** Who asks for a grant and where: the inputs of {@link grantRefusalOf}. */
|
|
10
10
|
export interface GrantContext {
|
|
11
11
|
role: OrgRole;
|
|
12
|
-
|
|
12
|
+
orgPolicy?: "allow" | "ask" | "deny";
|
|
13
|
+
gitDenials?: readonly string[];
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Why a tool can't be a task's grant, as a code the UI words: `forbidden` (the org's
|
|
16
|
-
*
|
|
17
|
+
* tool ceiling), `not_grantable` (by design: a Platform call that changes the agent's
|
|
17
18
|
* skills, or any other per-call key such as `Platform:<operation>`), `not_available` (not one of the agent's tools now), `needs_role` (a
|
|
18
19
|
* `requiredRole` above the creator's), `fixed_ask` (always asks a person). A network grant
|
|
19
20
|
* (`network:<host>`, {@link networkGrantRefusal}) adds `needs_admin` (outside the org's network
|
|
@@ -85,20 +86,16 @@ export declare const isGitGrantKey: (key: string) => boolean;
|
|
|
85
86
|
export declare const gitPushGrantKey: (repo?: string) => string;
|
|
86
87
|
/**
|
|
87
88
|
* Why a git push grant key cannot be one of a task's grants, or null when it can: the org forbids
|
|
88
|
-
* it (
|
|
89
|
+
* it (the repository or every repository is denied) or the repository is not `<owner>/<repo>`
|
|
89
90
|
* (`not_grantable`). The key is compared as given (callers normalize it with
|
|
90
91
|
* {@link normalizeGitGrantKey} first).
|
|
91
92
|
*/
|
|
92
|
-
export declare function gitGrantRefusal(key: string, ctx: Pick<GrantContext, "
|
|
93
|
+
export declare function gitGrantRefusal(key: string, ctx: Pick<GrantContext, "gitDenials">): {
|
|
93
94
|
code: GrantRefusalCode;
|
|
94
95
|
message: string;
|
|
95
96
|
} | null;
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
* `git:push` or the key, each entry compared normalized (`git:push:Acme/App` forbids
|
|
99
|
-
* `git:push:acme/app`).
|
|
100
|
-
*/
|
|
101
|
-
export declare function gitPushForbidden(forbiddenTools: readonly string[], key: string): boolean;
|
|
97
|
+
/** Whether the normalized repository target is denied by the organization's Git policy. */
|
|
98
|
+
export declare function gitPushForbidden(targets: readonly string[], key: string): boolean;
|
|
102
99
|
/**
|
|
103
100
|
* A git push grant key as stored: the repository normalized ({@link normalizeGitRepo}); the key
|
|
104
101
|
* unchanged when its repository is not of the shape (then {@link gitGrantRefusal} refuses it).
|
|
@@ -16,8 +16,7 @@ export function grantRefusalOf(toolKey, tool, ctx) {
|
|
|
16
16
|
// a git push grant belongs to no tool (sandbox git credentials spec §7)
|
|
17
17
|
if (isGitGrantKey(toolKey))
|
|
18
18
|
return gitGrantRefusal(toolKey, ctx);
|
|
19
|
-
if (ctx.
|
|
20
|
-
(tool !== undefined && ctx.forbiddenTools.includes(tool.key))) {
|
|
19
|
+
if (ctx.orgPolicy === "deny") {
|
|
21
20
|
return {
|
|
22
21
|
code: "forbidden",
|
|
23
22
|
message: `The organization does not allow ${toolKey} in scheduled runs`,
|
|
@@ -44,7 +43,7 @@ export function grantRefusalOf(toolKey, tool, ctx) {
|
|
|
44
43
|
message: `${toolKey} needs the ${tool.requiredRole} role to approve; you cannot approve it for the task`,
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
|
-
if (isFixedAsk(tool)) {
|
|
46
|
+
if (ctx.orgPolicy === "ask" || isFixedAsk(tool)) {
|
|
48
47
|
return {
|
|
49
48
|
code: "fixed_ask",
|
|
50
49
|
message: `${toolKey} always asks a person and cannot be approved in advance`,
|
|
@@ -120,12 +119,12 @@ export const isGitGrantKey = (key) => key === GIT_PUSH_GRANT || key.startsWith(G
|
|
|
120
119
|
export const gitPushGrantKey = (repo) => repo === undefined ? GIT_PUSH_GRANT : `${GIT_PUSH_REPO_GRANT_PREFIX}${repo}`;
|
|
121
120
|
/**
|
|
122
121
|
* Why a git push grant key cannot be one of a task's grants, or null when it can: the org forbids
|
|
123
|
-
* it (
|
|
122
|
+
* it (the repository or every repository is denied) or the repository is not `<owner>/<repo>`
|
|
124
123
|
* (`not_grantable`). The key is compared as given (callers normalize it with
|
|
125
124
|
* {@link normalizeGitGrantKey} first).
|
|
126
125
|
*/
|
|
127
126
|
export function gitGrantRefusal(key, ctx) {
|
|
128
|
-
if (gitPushForbidden(ctx.
|
|
127
|
+
if (gitPushForbidden(ctx.gitDenials ?? [], key)) {
|
|
129
128
|
return {
|
|
130
129
|
code: "forbidden",
|
|
131
130
|
message: `The organization does not allow ${key} in scheduled runs`,
|
|
@@ -142,19 +141,11 @@ export function gitGrantRefusal(key, ctx) {
|
|
|
142
141
|
}
|
|
143
142
|
return null;
|
|
144
143
|
}
|
|
145
|
-
/**
|
|
146
|
-
|
|
147
|
-
*
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
export function gitPushForbidden(forbiddenTools, key) {
|
|
151
|
-
return forbiddenTools.some((entry) => {
|
|
152
|
-
const lowered = entry.trim().toLowerCase();
|
|
153
|
-
if (!isGitGrantKey(lowered))
|
|
154
|
-
return false;
|
|
155
|
-
const e = normalizeGitGrantKey(lowered);
|
|
156
|
-
return e === GIT_PUSH_GRANT || e === key;
|
|
157
|
-
});
|
|
144
|
+
/** Whether the normalized repository target is denied by the organization's Git policy. */
|
|
145
|
+
export function gitPushForbidden(targets, key) {
|
|
146
|
+
return (targets.includes("*") ||
|
|
147
|
+
(key.startsWith(GIT_PUSH_REPO_GRANT_PREFIX) &&
|
|
148
|
+
targets.includes(key.slice(GIT_PUSH_REPO_GRANT_PREFIX.length))));
|
|
158
149
|
}
|
|
159
150
|
/**
|
|
160
151
|
* A git push grant key as stored: the repository normalized ({@link normalizeGitRepo}); the key
|
|
@@ -59,16 +59,13 @@ export declare const networkGrantKey: (host: string) => string;
|
|
|
59
59
|
/**
|
|
60
60
|
* What the tool policy knows of the automation run a kernel run serves (`PolicyContext`): the
|
|
61
61
|
* task (its grants), the task run (its `missing_grants`), whether it is a trial run (attended), and
|
|
62
|
-
* the org
|
|
62
|
+
* the org’s unattended approval mode, read live.
|
|
63
63
|
*/
|
|
64
64
|
export interface UnattendedRun {
|
|
65
65
|
taskId: string;
|
|
66
66
|
taskRunId: string;
|
|
67
67
|
trial: boolean;
|
|
68
68
|
unattendedAsk: "fail" | "wait";
|
|
69
|
-
forbiddenTools: string[];
|
|
70
|
-
/** The org's stored `forbiddenTools` cannot be read: every tool call of the run is refused. */
|
|
71
|
-
forbiddenToolsUnreadable?: boolean;
|
|
72
69
|
}
|
|
73
70
|
/** An unattended run that is not a trial run: the §7 rules apply. */
|
|
74
71
|
export declare const unattendedRules: (u: UnattendedRun | null | undefined) => u is UnattendedRun;
|
|
@@ -180,8 +180,6 @@ export async function unattendedRunOf(db, config, orgId, runId) {
|
|
|
180
180
|
return {
|
|
181
181
|
...run,
|
|
182
182
|
unattendedAsk: own?.unattended_ask ?? s.unattendedAsk,
|
|
183
|
-
forbiddenTools: s.forbiddenTools,
|
|
184
|
-
forbiddenToolsUnreadable: s.forbiddenToolsUnreadable,
|
|
185
183
|
};
|
|
186
184
|
}
|
|
187
185
|
/**
|
|
@@ -242,10 +242,13 @@ export type ItemConfirmations = ReadonlyMap<string, {
|
|
|
242
242
|
}>;
|
|
243
243
|
/**
|
|
244
244
|
* Per item id: is its extension waiting for a person's confirmation (pending) and the permission
|
|
245
|
-
* digest to confirm. Pending when the extension is not installed on the deployment, when the
|
|
246
|
-
* installed version's permission set is not covered by the stored snapshot
|
|
247
|
-
*
|
|
248
|
-
* version
|
|
245
|
+
* digest to confirm. Pending when the extension is not installed on the deployment, or when the
|
|
246
|
+
* installed version's permission set is not covered by the stored snapshot. A snapshot the
|
|
247
|
+
* bootstrap step wrote is consent like any other: the super admin's bootstrap manifests pin that
|
|
248
|
+
* version, so it covers exactly the pinned version's permissions (audited
|
|
249
|
+
* `extension.permissions_approved`, source `bootstrap`), and a version off the pin asking for more
|
|
250
|
+
* is pending as for any install (core#1226). Items whose latest version has no extension are never
|
|
251
|
+
* pending.
|
|
249
252
|
*/
|
|
250
253
|
export declare function itemConfirmations(admin: ExtensionAdmin, items: {
|
|
251
254
|
id: string;
|
|
@@ -511,10 +511,13 @@ export function ownerOnlyFacts(owner) {
|
|
|
511
511
|
const NO_FACTS = ownerOnlyFacts(PLATFORM_OWNER);
|
|
512
512
|
/**
|
|
513
513
|
* Per item id: is its extension waiting for a person's confirmation (pending) and the permission
|
|
514
|
-
* digest to confirm. Pending when the extension is not installed on the deployment, when the
|
|
515
|
-
* installed version's permission set is not covered by the stored snapshot
|
|
516
|
-
*
|
|
517
|
-
* version
|
|
514
|
+
* digest to confirm. Pending when the extension is not installed on the deployment, or when the
|
|
515
|
+
* installed version's permission set is not covered by the stored snapshot. A snapshot the
|
|
516
|
+
* bootstrap step wrote is consent like any other: the super admin's bootstrap manifests pin that
|
|
517
|
+
* version, so it covers exactly the pinned version's permissions (audited
|
|
518
|
+
* `extension.permissions_approved`, source `bootstrap`), and a version off the pin asking for more
|
|
519
|
+
* is pending as for any install (core#1226). Items whose latest version has no extension are never
|
|
520
|
+
* pending.
|
|
518
521
|
*/
|
|
519
522
|
export async function itemConfirmations(admin, items, versions) {
|
|
520
523
|
const out = new Map();
|
|
@@ -537,9 +540,7 @@ export async function itemConfirmations(admin, items, versions) {
|
|
|
537
540
|
out.set(item.id, { pending: true, permissionsHash: await admin.packageReviewHash(sha) });
|
|
538
541
|
continue;
|
|
539
542
|
}
|
|
540
|
-
const pending = v.snapshot === null ||
|
|
541
|
-
blockingKeys(v.added).length > 0 ||
|
|
542
|
-
(item.builtin && v.snapshot.source === "bootstrap");
|
|
543
|
+
const pending = v.snapshot === null || blockingKeys(v.added).length > 0;
|
|
543
544
|
out.set(item.id, {
|
|
544
545
|
pending,
|
|
545
546
|
permissionsHash: pending && v.error === undefined ? v.reviewHash : null,
|
|
@@ -109,8 +109,9 @@ export declare class CatalogScopeService {
|
|
|
109
109
|
* permission set with snapshot source `web` (`permissionsHash` is the item view's, the extension
|
|
110
110
|
* review digest; a changed set -> 409 `extension.approval_stale`); an extension that was never
|
|
111
111
|
* deployed (no install record) is installed and enabled first (the package is in the package
|
|
112
|
-
* store from the import). Nothing waiting (a covered snapshot a person approved
|
|
113
|
-
*
|
|
112
|
+
* store from the import). Nothing waiting (a covered snapshot, whether a person approved it or
|
|
113
|
+
* the bootstrap step wrote it for the pinned version; an item without an extension) -> 409
|
|
114
|
+
* `extension.not_pending`. The item's scope sync is owed by the
|
|
114
115
|
* approval of an enabled extension, or by the enable.
|
|
115
116
|
*/
|
|
116
117
|
confirmPermissions(actor: string, itemId: string, permissionsHash: string, opts?: ActorOpts): Promise<CatalogItemView>;
|
|
@@ -120,8 +120,9 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
120
120
|
* permission set with snapshot source `web` (`permissionsHash` is the item view's, the extension
|
|
121
121
|
* review digest; a changed set -> 409 `extension.approval_stale`); an extension that was never
|
|
122
122
|
* deployed (no install record) is installed and enabled first (the package is in the package
|
|
123
|
-
* store from the import). Nothing waiting (a covered snapshot a person approved
|
|
124
|
-
*
|
|
123
|
+
* store from the import). Nothing waiting (a covered snapshot, whether a person approved it or
|
|
124
|
+
* the bootstrap step wrote it for the pinned version; an item without an extension) -> 409
|
|
125
|
+
* `extension.not_pending`. The item's scope sync is owed by the
|
|
125
126
|
* approval of an enabled extension, or by the enable.
|
|
126
127
|
*/
|
|
127
128
|
async confirmPermissions(actor, itemId, permissionsHash, opts = {}) {
|
|
@@ -129,7 +130,7 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
129
130
|
throw notFound();
|
|
130
131
|
const item = await this.db
|
|
131
132
|
.selectFrom("catalog_items")
|
|
132
|
-
.select(["id", "name", "latest_version", "
|
|
133
|
+
.select(["id", "name", "latest_version", "owner_org_id", "scope"])
|
|
133
134
|
.where("id", "=", itemId)
|
|
134
135
|
.where("deleted_at", "is", null)
|
|
135
136
|
.executeTakeFirst();
|
|
@@ -168,7 +169,7 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
168
169
|
// A disabled install is what an earlier confirm that stopped before the enable left behind
|
|
169
170
|
const disabled = current.desired?.state === "disabled";
|
|
170
171
|
try {
|
|
171
|
-
await this.extensions.approve(actor, item.name, { sha256: current.sha256, reviewHash: permissionsHash },
|
|
172
|
+
await this.extensions.approve(actor, item.name, { sha256: current.sha256, reviewHash: permissionsHash }, opts);
|
|
172
173
|
}
|
|
173
174
|
catch (e) {
|
|
174
175
|
// Already approved but not enabled yet: carry on to the enable; else nothing to confirm
|
|
@@ -7,10 +7,9 @@ import { OrgOverrides, type OrgOverrideView } from "../extensions/org-overrides.
|
|
|
7
7
|
import { PluginIcons } from "../extensions/plugin-icons.js";
|
|
8
8
|
import { type Principal } from "../identity/principal.js";
|
|
9
9
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
10
|
-
import { type OrgToolSwitch, OrgToolSwitches, type OrgToolSwitchResult } from "../tools/org-tool-switches.js";
|
|
11
10
|
import { AppearanceApplyBody } from "./appearance.schemas.js";
|
|
12
11
|
import { type AppearanceResult, AppearanceService } from "./appearance.service.js";
|
|
13
|
-
import { OrgExtensionParams as ExtensionParams, OrgOverridesPut as OverridesPut, OrgOverridesTake as OverridesTake, OrgExtensionPut as PutBody
|
|
12
|
+
import { OrgExtensionParams as ExtensionParams, OrgOverridesPut as OverridesPut, OrgOverridesTake as OverridesTake, OrgExtensionPut as PutBody } from "./org-extension.schemas.js";
|
|
14
13
|
/**
|
|
15
14
|
* One extension of the org list: the org view plus the plugin's display name, the URL of its
|
|
16
15
|
* plugin's icon on the org's catalog route (null without one or when the org may not see the
|
|
@@ -89,21 +88,3 @@ export declare class OrgExtensionOverridesController {
|
|
|
89
88
|
/** Takes the platform's current values of non-secret overridable fields into the copy. */
|
|
90
89
|
take(principal: Principal, org: OrgContext, { extension }: z.infer<typeof ExtensionParams>, body: z.infer<typeof OverridesTake>): Promise<OrgOverrideView>;
|
|
91
90
|
}
|
|
92
|
-
/**
|
|
93
|
-
* The org's switches of an extension's single tools (layering spec A §7): members read them, org
|
|
94
|
-
* admins turn a tool off (previewed with the agents that selected it, PCM §5 rule 8) or on.
|
|
95
|
-
*/
|
|
96
|
-
export declare class OrgExtensionToolSwitchesController {
|
|
97
|
-
private readonly switches;
|
|
98
|
-
constructor(switches: OrgToolSwitches);
|
|
99
|
-
/** Every tool the extension registers, with its switch (on unless the org turned it off). */
|
|
100
|
-
list(org: OrgContext, { extension }: z.infer<typeof ExtensionParams>): Promise<{
|
|
101
|
-
tools: OrgToolSwitch[];
|
|
102
|
-
}>;
|
|
103
|
-
/**
|
|
104
|
-
* Switches one tool: on applies at once; off answers `{ applied: false, affectedAgents, confirm }`
|
|
105
|
-
* until `confirm` carries the hash (a changed preview -> 409 `plugin.switch_stale`). A tool the
|
|
106
|
-
* extension does not register -> 404 `extension.tool_not_found`.
|
|
107
|
-
*/
|
|
108
|
-
set(principal: Principal, org: OrgContext, { extension, tool }: z.infer<typeof ToolParams>, body: z.infer<typeof ToolSwitchPut>): Promise<OrgToolSwitchResult>;
|
|
109
|
-
}
|
|
@@ -18,20 +18,15 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
|
18
18
|
import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
19
19
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
20
20
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
21
|
-
import { OrgToolSwitches, } from "../tools/org-tool-switches.js";
|
|
22
21
|
import { AppearanceApplyBody } from "./appearance.schemas.js";
|
|
23
22
|
import { AppearanceService } from "./appearance.service.js";
|
|
24
|
-
import { OrgExtensionParams as ExtensionParams, OrgOverridesPut as OverridesPut, OrgOverridesTake as OverridesTake, OrgExtensionPut as PutBody,
|
|
23
|
+
import { OrgExtensionParams as ExtensionParams, OrgOverridesPut as OverridesPut, OrgOverridesTake as OverridesTake, OrgExtensionPut as PutBody, } from "./org-extension.schemas.js";
|
|
25
24
|
/** The audit detail of a switch made on the org's Extensions or Models page. */
|
|
26
25
|
const ORG_SWITCH = { reason: "org_switch" };
|
|
27
26
|
class OrgExtensionPutBody extends createZodDto(PutBody, "OrgExtensionPutBody") {
|
|
28
27
|
}
|
|
29
|
-
class OrgToolSwitchPutBody extends createZodDto(ToolSwitchPut, "OrgToolSwitchPutBody") {
|
|
30
|
-
}
|
|
31
28
|
class OrgExtensionParamsDto extends createZodDto(ExtensionParams, "OrgExtensionParams") {
|
|
32
29
|
}
|
|
33
|
-
class OrgExtensionToolParamsDto extends createZodDto(ToolParams, "OrgExtensionToolParams") {
|
|
34
|
-
}
|
|
35
30
|
class OrgAppearanceApplyBody extends createZodDto(AppearanceApplyBody, "OrgAppearanceApplyBody") {
|
|
36
31
|
}
|
|
37
32
|
class OrgOverridesPutBody extends createZodDto(OverridesPut, "OrgOverridesPutBody") {
|
|
@@ -232,45 +227,3 @@ OrgExtensionOverridesController = __decorate([
|
|
|
232
227
|
__param(0, Inject(OrgOverrides))
|
|
233
228
|
], OrgExtensionOverridesController);
|
|
234
229
|
export { OrgExtensionOverridesController };
|
|
235
|
-
/**
|
|
236
|
-
* The org's switches of an extension's single tools (layering spec A §7): members read them, org
|
|
237
|
-
* admins turn a tool off (previewed with the agents that selected it, PCM §5 rule 8) or on.
|
|
238
|
-
*/
|
|
239
|
-
let OrgExtensionToolSwitchesController = class OrgExtensionToolSwitchesController {
|
|
240
|
-
switches;
|
|
241
|
-
constructor(switches) {
|
|
242
|
-
this.switches = switches;
|
|
243
|
-
}
|
|
244
|
-
/** Every tool the extension registers, with its switch (on unless the org turned it off). */
|
|
245
|
-
async list(org, { extension }) {
|
|
246
|
-
return { tools: await this.switches.list(org.orgId, extension) };
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Switches one tool: on applies at once; off answers `{ applied: false, affectedAgents, confirm }`
|
|
250
|
-
* until `confirm` carries the hash (a changed preview -> 409 `plugin.switch_stale`). A tool the
|
|
251
|
-
* extension does not register -> 404 `extension.tool_not_found`.
|
|
252
|
-
*/
|
|
253
|
-
set(principal, org, { extension, tool }, body) {
|
|
254
|
-
const p = requireUser(principal);
|
|
255
|
-
return this.switches.set(org.orgId, extension, tool, body.enabled, { accountId: p.account.id, tokenId: patTokenId(p) }, body.confirm);
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
__decorate([
|
|
259
|
-
Get(),
|
|
260
|
-
OrgAction("org.extensions.read"),
|
|
261
|
-
__param(0, CurrentOrg()),
|
|
262
|
-
__param(1, ZParam(OrgExtensionParamsDto))
|
|
263
|
-
], OrgExtensionToolSwitchesController.prototype, "list", null);
|
|
264
|
-
__decorate([
|
|
265
|
-
Put(":tool"),
|
|
266
|
-
OrgAction("org.extensions.manage"),
|
|
267
|
-
__param(0, CurrentPrincipal()),
|
|
268
|
-
__param(1, CurrentOrg()),
|
|
269
|
-
__param(2, ZParam(OrgExtensionToolParamsDto)),
|
|
270
|
-
__param(3, ZBody(OrgToolSwitchPutBody))
|
|
271
|
-
], OrgExtensionToolSwitchesController.prototype, "set", null);
|
|
272
|
-
OrgExtensionToolSwitchesController = __decorate([
|
|
273
|
-
Controller("api/v1/orgs/:orgId/extensions/:extension/tools"),
|
|
274
|
-
__param(0, Inject(OrgToolSwitches))
|
|
275
|
-
], OrgExtensionToolSwitchesController);
|
|
276
|
-
export { OrgExtensionToolSwitchesController };
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
-
/** Route parameters of the overrides and
|
|
3
|
+
/** Route parameters of the overrides and enablement routes (decision R20). */
|
|
4
4
|
export declare const OrgExtensionParams: z.ZodObject<{
|
|
5
5
|
extension: z.ZodString;
|
|
6
6
|
}, z.core.$strip>;
|
|
7
|
-
export declare const OrgExtensionToolParams: z.ZodObject<{
|
|
8
|
-
extension: z.ZodString;
|
|
9
|
-
tool: z.ZodString;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
export declare const OrgToolSwitchPut: z.ZodObject<{
|
|
12
|
-
enabled: z.ZodBoolean;
|
|
13
|
-
confirm: z.ZodOptional<z.ZodString>;
|
|
14
|
-
}, z.core.$strict>;
|
|
15
7
|
/** `PUT /orgs/:orgId/extensions/:extension`: enablement (an org's config is its copy: `…/overrides`). */
|
|
16
8
|
export declare const OrgExtensionPut: z.ZodObject<{
|
|
17
9
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { secret } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
/** Route parameters of the overrides and
|
|
3
|
+
/** Route parameters of the overrides and enablement routes (decision R20). */
|
|
4
4
|
export const OrgExtensionParams = z.object({ extension: z.string().min(1).max(64) });
|
|
5
|
-
export const OrgExtensionToolParams = OrgExtensionParams.extend({
|
|
6
|
-
tool: z.string().min(1).max(64),
|
|
7
|
-
});
|
|
8
|
-
export const OrgToolSwitchPut = z
|
|
9
|
-
.object({
|
|
10
|
-
enabled: z.boolean(),
|
|
11
|
-
/** The hash of the switch-off preview, to confirm turning the tool off. */
|
|
12
|
-
confirm: z.string().min(1).max(128).optional(),
|
|
13
|
-
})
|
|
14
|
-
.strict();
|
|
15
5
|
/** `PUT /orgs/:orgId/extensions/:extension`: enablement (an org's config is its copy: `…/overrides`). */
|
|
16
6
|
export const OrgExtensionPut = z
|
|
17
7
|
.object({
|
|
@@ -54,12 +44,6 @@ export const OrgOverridesTake = z
|
|
|
54
44
|
.strict();
|
|
55
45
|
export const ORG_EXTENSION_ROUTES = [
|
|
56
46
|
{ route: "GET /api/v1/orgs/:orgId/extensions" },
|
|
57
|
-
{ route: "GET /api/v1/orgs/:orgId/extensions/:extension/tools", params: OrgExtensionParams },
|
|
58
|
-
{
|
|
59
|
-
route: "PUT /api/v1/orgs/:orgId/extensions/:extension/tools/:tool",
|
|
60
|
-
params: OrgExtensionToolParams,
|
|
61
|
-
body: OrgToolSwitchPut,
|
|
62
|
-
},
|
|
63
47
|
{
|
|
64
48
|
route: "PUT /api/v1/orgs/:orgId/extensions/:extension",
|
|
65
49
|
params: OrgExtensionParams,
|