@capybara-hq/kernel 0.1.0-rc.127 → 0.1.0-rc.128
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/dist/agents/readiness.service.d.ts +6 -0
- package/dist/agents/readiness.service.js +1 -1
- 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/extensions/admin-view.d.ts +1 -3
- package/dist/extensions/admin-view.js +5 -8
- package/dist/platform/ops/agents.ops.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
@@ -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
|
|
@@ -108,12 +108,10 @@ export declare class ExtensionAdmin {
|
|
|
108
108
|
* recomputed now -> `extension.approval_stale`; a config-declared extension's `sha256` must be
|
|
109
109
|
* null (otherwise `validation_failed`);
|
|
110
110
|
* - the snapshot already covers the current permission set (nothing to approve, F-N) ->
|
|
111
|
-
* `extension.not_pending
|
|
112
|
-
* step's (the catalog's confirm re-writes it with source web).
|
|
111
|
+
* `extension.not_pending` (a snapshot the bootstrap step wrote included: the pin is consent).
|
|
113
112
|
*/
|
|
114
113
|
approve(actor: string, name: string, body: ApproveBody, opts?: {
|
|
115
114
|
actorTokenId?: string;
|
|
116
|
-
confirmBootstrap?: boolean;
|
|
117
115
|
}): Promise<AdminExtensionView>;
|
|
118
116
|
private writeApproval;
|
|
119
117
|
/** 配置声明 → 安装记录(与配置声明重名的安装记录不生效,不单列)。`only` 给出时只取这一个。 */
|
|
@@ -166,8 +166,7 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
166
166
|
* recomputed now -> `extension.approval_stale`; a config-declared extension's `sha256` must be
|
|
167
167
|
* null (otherwise `validation_failed`);
|
|
168
168
|
* - the snapshot already covers the current permission set (nothing to approve, F-N) ->
|
|
169
|
-
* `extension.not_pending
|
|
170
|
-
* step's (the catalog's confirm re-writes it with source web).
|
|
169
|
+
* `extension.not_pending` (a snapshot the bootstrap step wrote included: the pin is consent).
|
|
171
170
|
*/
|
|
172
171
|
async approve(actor, name, body, opts = {}) {
|
|
173
172
|
const s = (await this.subjects(name))[0];
|
|
@@ -182,7 +181,7 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
182
181
|
throw stale();
|
|
183
182
|
if (body.reviewHash !== reviewHash(s.set, s.warnings))
|
|
184
183
|
throw stale();
|
|
185
|
-
await this.writeApproval(actor, name, s, opts.actorTokenId, stale
|
|
184
|
+
await this.writeApproval(actor, name, s, opts.actorTokenId, stale);
|
|
186
185
|
try {
|
|
187
186
|
await this.bus.publish(PLUGINS_CHANGED_TOPIC, { plugin: name });
|
|
188
187
|
}
|
|
@@ -198,7 +197,7 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
198
197
|
}
|
|
199
198
|
return this.get(name);
|
|
200
199
|
}
|
|
201
|
-
async writeApproval(actor, name, s, actorTokenId, stale
|
|
200
|
+
async writeApproval(actor, name, s, actorTokenId, stale) {
|
|
202
201
|
const db = this.db;
|
|
203
202
|
await this.adminLock.lockAndAuthorize(actor);
|
|
204
203
|
await this.approveLock.lock(name);
|
|
@@ -218,7 +217,7 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
218
217
|
}
|
|
219
218
|
const snapRow = await db
|
|
220
219
|
.selectFrom("extension_permission_snapshots")
|
|
221
|
-
.select(["version", "permissions"
|
|
220
|
+
.select(["version", "permissions"])
|
|
222
221
|
.where("plugin", "=", name)
|
|
223
222
|
.forUpdate()
|
|
224
223
|
.executeTakeFirst();
|
|
@@ -226,9 +225,7 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
226
225
|
version: snapRow.version,
|
|
227
226
|
permissions: snapRow.permissions,
|
|
228
227
|
};
|
|
229
|
-
|
|
230
|
-
// confirmed by a person, so a covered one is still taken over
|
|
231
|
-
if (snapshotCovers(snap, s.set) && !(confirmBootstrap && snapRow?.source === "bootstrap")) {
|
|
228
|
+
if (snapshotCovers(snap, s.set)) {
|
|
232
229
|
throw new ApiError("extension.not_pending", `Extension ${name} ${s.version} has no new permissions awaiting approval`);
|
|
233
230
|
}
|
|
234
231
|
const { added, removed } = diffPermissions(snap?.permissions, s.set);
|
|
@@ -780,7 +780,7 @@ let AgentsOperations = class AgentsOperations {
|
|
|
780
780
|
}),
|
|
781
781
|
defineOperation({
|
|
782
782
|
id: "agents.readiness",
|
|
783
|
-
description: "Whether the org can run agents: modelProvider is ready when the org has a chat model an agent can pick (the list agents.create chooses from); no_models when model providers are on but none gives one (unusableProviders names each provider and its reason: list_failed with errorKind, e.g. auth for a rejected key, or no_chat_models; orgCanFix says whether an org admin can fix it on Settings > Models, else only the super admin can on the admin Models page); org_fixable when no provider is on but an org admin can make one available on Settings > Models (orgFixableProviders names each provider and its reason: not_enabled, switch it on; needs_config, fill the org's config); none when only the super admin can help; how many agents you can see, and the optional setup steps visible to your role. checklistDismissed is your own preference in this org.",
|
|
783
|
+
description: "Whether the org can run agents: modelProvider is ready when the org has a chat model an agent can pick (the list agents.create chooses from); no_models when model providers are on but none gives one (unusableProviders names each provider and its reason: list_failed with errorKind, e.g. auth for a rejected key, or no_chat_models; orgCanFix says whether an org admin can fix it on Settings > Models, else only the super admin can on the admin Models page); org_fixable when no provider is on but an org admin can make one available on Settings > Models (orgFixableProviders names each provider and its reason: not_enabled, switch it on; needs_config, fill the org's config; needsOrgConfig says whether it also needs the org's own config, such as an API key the platform left empty); none when only the super admin can help; how many agents you can see, and the optional setup steps visible to your role. checklistDismissed is your own preference in this org.",
|
|
784
784
|
input: z.object({}).strict(),
|
|
785
785
|
example: {},
|
|
786
786
|
authz: { orgAction: "org.read" },
|
package/package.json
CHANGED