@capybara-hq/kernel 0.1.0-rc.62 → 0.1.0-rc.63
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/app.d.ts +2 -0
- package/dist/catalog/catalog.service.d.ts +13 -0
- package/dist/catalog/catalog.service.js +17 -8
- package/dist/catalog/git-source.d.ts +8 -0
- package/dist/catalog/git-source.js +14 -6
- package/dist/catalog/marketplaces.controller.d.ts +3 -2
- package/dist/catalog/marketplaces.controller.js +5 -2
- package/dist/catalog/marketplaces.schemas.d.ts +7 -0
- package/dist/catalog/marketplaces.schemas.js +13 -0
- package/dist/catalog/marketplaces.service.d.ts +65 -11
- package/dist/catalog/marketplaces.service.js +208 -30
- package/dist/config/schema.d.ts +2 -0
- package/dist/config/schema.js +21 -1
- package/dist/db/kernel-schema.d.ts +4 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.js +7 -0
- package/dist/extensions/bootstrap-defaults.d.ts +24 -0
- package/dist/extensions/bootstrap-defaults.js +78 -0
- package/dist/extensions/bootstrap-extra.d.ts +74 -0
- package/dist/extensions/bootstrap-extra.js +131 -0
- package/dist/extensions/bootstrap.d.ts +77 -13
- package/dist/extensions/bootstrap.js +282 -48
- package/dist/identity/settings.d.ts +10 -0
- package/dist/identity/settings.js +46 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/kernel.module.js +3 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +7 -1
- package/dist/lifecycle/kernel-lifecycle.js +69 -16
- package/dist/platform/ops/marketplaces.ops.js +27 -4
- package/package.json +4 -4
- package/src/migrations/0174_marketplace_managed_username.sql +4 -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": "895bfc11d7ed76726b20e2e6140764b7fadc6598"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"name": "sandbox-docker",
|
|
91
91
|
"source": "npm",
|
|
92
92
|
"npm": "@capybara-hq/plugin-sandbox-docker",
|
|
93
|
-
"version": "0.1.0-rc.
|
|
94
|
-
"integrity": "sha512-
|
|
93
|
+
"version": "0.1.0-rc.21",
|
|
94
|
+
"integrity": "sha512-os0kmtDtTPUyBEJUNQdxfuYCwet6X7lZrIq6Dyo2hXLCV0ZkPPfONY8ctRh6+qzD52PjHC1YWKAZQesYW5I6ww==",
|
|
95
95
|
"required": false
|
|
96
96
|
},
|
|
97
97
|
{
|
package/dist/app.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export interface KernelAppOptions {
|
|
|
33
33
|
*/
|
|
34
34
|
bootstrap?: {
|
|
35
35
|
dir?: string;
|
|
36
|
+
/** Path of the extra bootstrap manifest merged into the built-in one (already resolved). */
|
|
37
|
+
extraManifest?: string;
|
|
36
38
|
};
|
|
37
39
|
/** The bootstrap manifest; default the `bootstrap.json` shipped with the kernel package. */
|
|
38
40
|
bootstrapManifest?: BootstrapManifest;
|
|
@@ -9,6 +9,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
9
9
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
10
10
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
11
11
|
import type { TranslationReport } from "./claude/report.js";
|
|
12
|
+
import { type GitLocation } from "./git-source.js";
|
|
12
13
|
import { MarketplacesService } from "./marketplaces.service.js";
|
|
13
14
|
import { type Owner } from "./ownership.js";
|
|
14
15
|
import { PluginImport, type PluginReview } from "./plugin-import.js";
|
|
@@ -219,6 +220,18 @@ export declare function repoOwner(url: string): string;
|
|
|
219
220
|
* leading zero are not valid semver.
|
|
220
221
|
*/
|
|
221
222
|
export declare const gitFallbackVersion: (commit: string) => string;
|
|
223
|
+
/**
|
|
224
|
+
* The recorded git location and the `source_ref` text of a git import. A marketplace `path` entry
|
|
225
|
+
* passes the marketplace's URL, ref and the entry's path with `pinned` false; the bootstrap step
|
|
226
|
+
* records an extra-manifest git entry with the same arguments, so both are one source.
|
|
227
|
+
*/
|
|
228
|
+
export declare function marketplaceGitSource(loc: GitLocation, read: {
|
|
229
|
+
commit: string;
|
|
230
|
+
tree: string | undefined;
|
|
231
|
+
}, pinned: boolean): {
|
|
232
|
+
detail: GitSourceDetail;
|
|
233
|
+
ref: string;
|
|
234
|
+
};
|
|
222
235
|
/** Default / largest page size of the list. */
|
|
223
236
|
export declare const CATALOG_LIST_DEFAULT_LIMIT = 200;
|
|
224
237
|
export declare const CATALOG_LIST_MAX_LIMIT = 1000;
|
|
@@ -60,8 +60,12 @@ export function repoOwner(url) {
|
|
|
60
60
|
* leading zero are not valid semver.
|
|
61
61
|
*/
|
|
62
62
|
export const gitFallbackVersion = (commit) => `0.0.0-git.g${commit.slice(0, 12)}`;
|
|
63
|
-
/**
|
|
64
|
-
|
|
63
|
+
/**
|
|
64
|
+
* The recorded git location and the `source_ref` text of a git import. A marketplace `path` entry
|
|
65
|
+
* passes the marketplace's URL, ref and the entry's path with `pinned` false; the bootstrap step
|
|
66
|
+
* records an extra-manifest git entry with the same arguments, so both are one source.
|
|
67
|
+
*/
|
|
68
|
+
export function marketplaceGitSource(loc, read, pinned) {
|
|
65
69
|
const commit = read.commit;
|
|
66
70
|
const u = new URL(loc.url);
|
|
67
71
|
const path = normalGitPath(loc.path);
|
|
@@ -241,16 +245,20 @@ let CatalogService = class CatalogService {
|
|
|
241
245
|
...(src.git.path !== undefined && { path: src.git.path }),
|
|
242
246
|
};
|
|
243
247
|
}
|
|
244
|
-
const token = marketplace.builtin
|
|
245
|
-
?
|
|
246
|
-
: await this.marketplaces.
|
|
248
|
+
const { token, username } = marketplace.builtin
|
|
249
|
+
? {}
|
|
250
|
+
: await this.marketplaces.credentials(input.marketplaceId);
|
|
247
251
|
const read = await this.readGit(loc, {
|
|
248
|
-
...(token !== undefined && {
|
|
252
|
+
...(token !== undefined && {
|
|
253
|
+
token,
|
|
254
|
+
tokenOrigin: new URL(marketplace.url).origin,
|
|
255
|
+
...(username !== undefined && { username }),
|
|
256
|
+
}),
|
|
249
257
|
...(opts.signal !== undefined && { signal: opts.signal }),
|
|
250
258
|
});
|
|
251
259
|
// path entries follow the marketplace's ref; git entries follow theirs unless a commit is pinned
|
|
252
260
|
const pinned = "git" in src && src.git.commit !== undefined;
|
|
253
|
-
const where =
|
|
261
|
+
const where = marketplaceGitSource("path" in src && marketplace.ref !== null ? { ...loc, ref: marketplace.ref } : loc, read, pinned);
|
|
254
262
|
staged = await this.pluginImport.prepareGit(actor, read.files, {
|
|
255
263
|
kind: "git",
|
|
256
264
|
ref: `${input.marketplaceId}:${where.ref}`,
|
|
@@ -299,7 +307,7 @@ let CatalogService = class CatalogService {
|
|
|
299
307
|
};
|
|
300
308
|
const read = await this.readGit(loc, opts.signal !== undefined ? { signal: opts.signal } : {});
|
|
301
309
|
const pinned = input.ref !== undefined && /^[0-9a-f]{40}$/i.test(input.ref);
|
|
302
|
-
const where =
|
|
310
|
+
const where = marketplaceGitSource(loc, read, pinned);
|
|
303
311
|
const segment = where.detail.path === "."
|
|
304
312
|
? (new URL(url).pathname
|
|
305
313
|
.split("/")
|
|
@@ -326,6 +334,7 @@ let CatalogService = class CatalogService {
|
|
|
326
334
|
signal: o.signal ?? new AbortController().signal,
|
|
327
335
|
...(o.token !== undefined && { token: o.token }),
|
|
328
336
|
...(o.tokenOrigin !== undefined && { tokenOrigin: o.tokenOrigin }),
|
|
337
|
+
...(o.username !== undefined && { username: o.username }),
|
|
329
338
|
};
|
|
330
339
|
try {
|
|
331
340
|
const commit = await resolveGitCommit(loc, options);
|
|
@@ -45,6 +45,11 @@ export type GitLocation = {
|
|
|
45
45
|
export type GitOptions = {
|
|
46
46
|
net: NetPolicy;
|
|
47
47
|
token?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The Basic auth username sent with `token` (empty or absent:
|
|
50
|
+
* {@link GIT_MARKETPLACE_USERNAME_DEFAULT}); one outside `GIT_USERNAME_RE` is refused.
|
|
51
|
+
*/
|
|
52
|
+
username?: string;
|
|
48
53
|
/** The token is sent only to this origin (the marketplace URL's). */
|
|
49
54
|
tokenOrigin?: string;
|
|
50
55
|
signal: AbortSignal;
|
|
@@ -69,10 +74,13 @@ export declare class GitSourceError extends Error {
|
|
|
69
74
|
readonly code: GitSourceErrorCode;
|
|
70
75
|
readonly netCode: MarketplaceNetCode | undefined;
|
|
71
76
|
readonly detail: GitErrorDetail;
|
|
77
|
+
/** The pinned commit the server would not send by its sha (the message advises a ref tip). */
|
|
78
|
+
readonly refusedCommit: string | undefined;
|
|
72
79
|
constructor(code: GitSourceErrorCode, message: string, options?: {
|
|
73
80
|
cause?: unknown;
|
|
74
81
|
netCode?: MarketplaceNetCode;
|
|
75
82
|
detail?: GitErrorDetail;
|
|
83
|
+
refusedCommit?: string;
|
|
76
84
|
});
|
|
77
85
|
}
|
|
78
86
|
/**
|
|
@@ -2,6 +2,7 @@ import * as fsp from "node:fs/promises";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { inflateSync } from "node:zlib";
|
|
5
|
+
import { GIT_MARKETPLACE_USERNAME_DEFAULT, GIT_USERNAME_RE } from "@capybara-hq/plugin-sdk";
|
|
5
6
|
import git, {} from "isomorphic-git";
|
|
6
7
|
import { NetDeniedError } from "../net/public-address.js";
|
|
7
8
|
import { NetBodyTooLargeError, safeFetch } from "../net/safe-fetch.js";
|
|
@@ -51,12 +52,15 @@ export class GitSourceError extends Error {
|
|
|
51
52
|
code;
|
|
52
53
|
netCode;
|
|
53
54
|
detail;
|
|
55
|
+
/** The pinned commit the server would not send by its sha (the message advises a ref tip). */
|
|
56
|
+
refusedCommit;
|
|
54
57
|
constructor(code, message, options) {
|
|
55
58
|
super(message, options);
|
|
56
59
|
this.code = code;
|
|
57
60
|
this.name = "GitSourceError";
|
|
58
61
|
this.netCode = options?.netCode;
|
|
59
62
|
this.detail = options?.detail ?? {};
|
|
63
|
+
this.refusedCommit = options?.refusedCommit;
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
66
|
/**
|
|
@@ -115,10 +119,14 @@ function startOp(loc, o) {
|
|
|
115
119
|
if (problem !== null)
|
|
116
120
|
throw failed(`invalid git URL: ${problem}`);
|
|
117
121
|
const signal = AbortSignal.any([o.signal, AbortSignal.timeout(GIT_LIMITS.timeoutMs)]);
|
|
122
|
+
// A ':' in the username would move the split of the Basic credential
|
|
123
|
+
if (o.username !== undefined && o.username !== "" && !GIT_USERNAME_RE.test(o.username)) {
|
|
124
|
+
throw failed("invalid git username");
|
|
125
|
+
}
|
|
118
126
|
const state = { overLimit: false };
|
|
119
127
|
const auth = o.token === undefined
|
|
120
128
|
? undefined
|
|
121
|
-
: `Basic ${Buffer.from(
|
|
129
|
+
: `Basic ${Buffer.from(`${o.username || GIT_MARKETPLACE_USERNAME_DEFAULT}:${o.token}`).toString("base64")}`;
|
|
122
130
|
const http = {
|
|
123
131
|
async request(req) {
|
|
124
132
|
const target = new URL(req.url);
|
|
@@ -337,8 +345,8 @@ function scanningFs(maxUnpacked) {
|
|
|
337
345
|
},
|
|
338
346
|
};
|
|
339
347
|
}
|
|
340
|
-
/**
|
|
341
|
-
const refusedCommit = (commit) =>
|
|
348
|
+
/** A pinned commit the server would not send. */
|
|
349
|
+
const refusedCommit = (what, commit, cause) => new GitSourceError("marketplace.git_failed", `${what}: the server refused to serve commit ${commit}; pin a branch or tag tip instead`, { ...(cause !== undefined && { cause }), refusedCommit: commit });
|
|
342
350
|
/** isomorphic-git's error for a want the server did not answer (an unknown or unadvertised sha). */
|
|
343
351
|
function refusedWant(e) {
|
|
344
352
|
const code = e?.code;
|
|
@@ -413,11 +421,11 @@ export async function readGitTreeAndOids(loc, o) {
|
|
|
413
421
|
// A commit that is not a ref tip needs the server to allow reachable-sha wants (GitHub does;
|
|
414
422
|
// GitLab / Gitea depend on their configuration); the server then sends nothing for it
|
|
415
423
|
if (refusedWant(e))
|
|
416
|
-
throw
|
|
424
|
+
throw refusedCommit(what, commit, e);
|
|
417
425
|
throw e;
|
|
418
426
|
}
|
|
419
427
|
if (res.fetchHead !== commit)
|
|
420
|
-
throw
|
|
428
|
+
throw refusedCommit(what, commit);
|
|
421
429
|
op.signal.throwIfAborted();
|
|
422
430
|
let c;
|
|
423
431
|
try {
|
|
@@ -426,7 +434,7 @@ export async function readGitTreeAndOids(loc, o) {
|
|
|
426
434
|
catch (e) {
|
|
427
435
|
// the server answered the fetch without the commit
|
|
428
436
|
if (refusedWant(e))
|
|
429
|
-
throw
|
|
437
|
+
throw refusedCommit(what, commit, e);
|
|
430
438
|
throw e;
|
|
431
439
|
}
|
|
432
440
|
let tree = c.tree;
|
|
@@ -51,12 +51,13 @@ export declare class MarketplacesController {
|
|
|
51
51
|
icon(id: string, sha256: string, reply: FastifyReply): Promise<void>;
|
|
52
52
|
/**
|
|
53
53
|
* Updates a marketplace (official only takes `enabled`, anything else -> 409
|
|
54
|
-
* `marketplace.builtin`;
|
|
54
|
+
* `marketplace.builtin`; a config-managed one likewise -> 409 `marketplace.config_managed`;
|
|
55
|
+
* `token: null` clears the token, `username: null` or `""` the username).
|
|
55
56
|
*/
|
|
56
57
|
update(principal: Principal, id: string, body: z.infer<typeof PatchBody>): Promise<MarketplaceView>;
|
|
57
58
|
/**
|
|
58
59
|
* Deletes a custom marketplace (imported catalog items are kept); official -> 409
|
|
59
|
-
* `marketplace.builtin`.
|
|
60
|
+
* `marketplace.builtin`, config-managed -> 409 `marketplace.config_managed`.
|
|
60
61
|
*/
|
|
61
62
|
remove(principal: Principal, id: string): Promise<void>;
|
|
62
63
|
/**
|
|
@@ -74,6 +74,7 @@ let MarketplacesController = class MarketplacesController {
|
|
|
74
74
|
...(body.ref !== undefined && { ref: body.ref }),
|
|
75
75
|
...(body.mirrors !== undefined && { mirrors: body.mirrors }),
|
|
76
76
|
...(body.token !== undefined && { token: body.token }),
|
|
77
|
+
...(body.username !== undefined && { username: body.username }),
|
|
77
78
|
}, actorOpts(actor));
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
@@ -109,7 +110,8 @@ let MarketplacesController = class MarketplacesController {
|
|
|
109
110
|
}
|
|
110
111
|
/**
|
|
111
112
|
* Updates a marketplace (official only takes `enabled`, anything else -> 409
|
|
112
|
-
* `marketplace.builtin`;
|
|
113
|
+
* `marketplace.builtin`; a config-managed one likewise -> 409 `marketplace.config_managed`;
|
|
114
|
+
* `token: null` clears the token, `username: null` or `""` the username).
|
|
113
115
|
*/
|
|
114
116
|
update(principal, id, body) {
|
|
115
117
|
const actor = requireUser(principal);
|
|
@@ -121,11 +123,12 @@ let MarketplacesController = class MarketplacesController {
|
|
|
121
123
|
...(body.mirrors !== undefined && { mirrors: body.mirrors }),
|
|
122
124
|
...(body.enabled !== undefined && { enabled: body.enabled }),
|
|
123
125
|
...(body.token !== undefined && { token: body.token }),
|
|
126
|
+
...(body.username !== undefined && { username: body.username }),
|
|
124
127
|
}, actorOpts(actor));
|
|
125
128
|
}
|
|
126
129
|
/**
|
|
127
130
|
* Deletes a custom marketplace (imported catalog items are kept); official -> 409
|
|
128
|
-
* `marketplace.builtin`.
|
|
131
|
+
* `marketplace.builtin`, config-managed -> 409 `marketplace.config_managed`.
|
|
129
132
|
*/
|
|
130
133
|
async remove(principal, id) {
|
|
131
134
|
const actor = requireUser(principal);
|
|
@@ -6,6 +6,11 @@ export declare const MarketplaceForm: z.ZodEnum<{
|
|
|
6
6
|
http: "http";
|
|
7
7
|
}>;
|
|
8
8
|
export declare const MarketplaceRef: z.ZodString;
|
|
9
|
+
/**
|
|
10
|
+
* The Basic auth username sent with a git marketplace's token (`GIT_USERNAME_RE`; empty: the
|
|
11
|
+
* default `x-access-token`).
|
|
12
|
+
*/
|
|
13
|
+
export declare const MarketplaceUsername: z.ZodString;
|
|
9
14
|
export declare const MarketplaceAddBody: z.ZodObject<{
|
|
10
15
|
name: z.ZodString;
|
|
11
16
|
url: z.ZodString;
|
|
@@ -16,6 +21,7 @@ export declare const MarketplaceAddBody: z.ZodObject<{
|
|
|
16
21
|
ref: z.ZodOptional<z.ZodString>;
|
|
17
22
|
mirrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
23
|
token: z.ZodOptional<z.ZodString>;
|
|
24
|
+
username: z.ZodOptional<z.ZodString>;
|
|
19
25
|
}, z.core.$strip>;
|
|
20
26
|
export declare const MarketplaceEntriesQuery: z.ZodObject<{
|
|
21
27
|
sourceId: z.ZodOptional<z.ZodString>;
|
|
@@ -32,6 +38,7 @@ export declare const MarketplacePatchBody: z.ZodObject<{
|
|
|
32
38
|
mirrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
39
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
34
40
|
token: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
42
|
}, z.core.$strict>;
|
|
36
43
|
export declare const MarketplaceImportBody: z.ZodObject<{
|
|
37
44
|
version: z.ZodOptional<z.ZodString>;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
import { GIT_USERNAME_RE } from "@capybara-hq/plugin-sdk";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { MARKETPLACE_MAX_MIRRORS } from "../config/schema.js";
|
|
3
4
|
export const MarketplaceUrl = z.string().min(1).max(2000);
|
|
4
5
|
export const MarketplaceForm = z.enum(["http", "git"]);
|
|
5
6
|
export const MarketplaceRef = z.string().min(1).max(256);
|
|
7
|
+
/**
|
|
8
|
+
* The Basic auth username sent with a git marketplace's token (`GIT_USERNAME_RE`; empty: the
|
|
9
|
+
* default `x-access-token`).
|
|
10
|
+
*/
|
|
11
|
+
export const MarketplaceUsername = z
|
|
12
|
+
.string()
|
|
13
|
+
.max(64)
|
|
14
|
+
.regex(new RegExp(`^$|${GIT_USERNAME_RE.source}`), {
|
|
15
|
+
message: "username must be empty or match ^[A-Za-z0-9._-]{1,64}$",
|
|
16
|
+
});
|
|
6
17
|
export const MarketplaceAddBody = z.object({
|
|
7
18
|
name: z.string().min(1).max(100),
|
|
8
19
|
url: MarketplaceUrl,
|
|
@@ -10,6 +21,7 @@ export const MarketplaceAddBody = z.object({
|
|
|
10
21
|
ref: MarketplaceRef.optional(),
|
|
11
22
|
mirrors: z.array(MarketplaceUrl).max(MARKETPLACE_MAX_MIRRORS).optional(),
|
|
12
23
|
token: z.string().min(1).max(4096).optional(),
|
|
24
|
+
username: MarketplaceUsername.optional(),
|
|
13
25
|
});
|
|
14
26
|
export const MarketplaceEntriesQuery = z.object({
|
|
15
27
|
sourceId: z.string().min(1).max(100).optional(),
|
|
@@ -24,6 +36,7 @@ export const MarketplacePatchBody = z
|
|
|
24
36
|
mirrors: z.array(MarketplaceUrl).max(MARKETPLACE_MAX_MIRRORS).optional(),
|
|
25
37
|
enabled: z.boolean().optional(),
|
|
26
38
|
token: z.string().min(1).max(4096).nullable().optional(),
|
|
39
|
+
username: MarketplaceUsername.nullable().optional(),
|
|
27
40
|
})
|
|
28
41
|
.strict();
|
|
29
42
|
export const MarketplaceImportBody = z.object({ version: z.string().min(1).max(256).optional() });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MarketplaceEntry, type MarketplaceSource } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { type BootstrapExtraMarketplace, type MarketplaceEntry, type MarketplaceSource } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { type KernelConfig } from "../config/schema.js";
|
|
3
3
|
import { type Keyring } from "../ctx/secrets.js";
|
|
4
4
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
@@ -12,6 +12,8 @@ import { type MarketplaceSkipReason } from "./claude/marketplace.js";
|
|
|
12
12
|
import { CatalogSourceLock } from "./locks.js";
|
|
13
13
|
/** 官方清单来源的 id。 */
|
|
14
14
|
export declare const OFFICIAL_MARKETPLACE_ID = "official";
|
|
15
|
+
/** The id prefix of a marketplace the deployment config owns (`config:<name>`). */
|
|
16
|
+
export declare const CONFIG_MARKETPLACE_PREFIX = "config:";
|
|
15
17
|
/** 拉取一份清单的超时。 */
|
|
16
18
|
export declare const MARKETPLACE_FETCH_TIMEOUT_MS = 30000;
|
|
17
19
|
/**
|
|
@@ -44,6 +46,13 @@ export interface MarketplaceView {
|
|
|
44
46
|
enabled: boolean;
|
|
45
47
|
/** official 被配置关闭(离线模式);企业清单恒为 false。 */
|
|
46
48
|
disabledByConfig: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* `config`: owned by the deployment config (bootstrap.extraManifest; only `enabled` can change
|
|
51
|
+
* here, its token comes from `marketplaces.tokens`); null for official and custom marketplaces.
|
|
52
|
+
*/
|
|
53
|
+
managed: "config" | null;
|
|
54
|
+
/** The Basic auth username sent with the git token (null: `x-access-token`). */
|
|
55
|
+
username: string | null;
|
|
47
56
|
hasToken: boolean;
|
|
48
57
|
etag: string | null;
|
|
49
58
|
lastRefreshedAt: string | null;
|
|
@@ -126,6 +135,12 @@ export interface MarketplaceEntryView {
|
|
|
126
135
|
*/
|
|
127
136
|
contentChanged: boolean;
|
|
128
137
|
}
|
|
138
|
+
/** A marketplace's credential: a token (Bearer over http, Basic `username:token` over git). */
|
|
139
|
+
export interface MarketplaceCredentials {
|
|
140
|
+
token?: string;
|
|
141
|
+
/** The Basic auth username (absent: `x-access-token`). */
|
|
142
|
+
username?: string;
|
|
143
|
+
}
|
|
129
144
|
export interface ActorOpts {
|
|
130
145
|
actorTokenId?: string;
|
|
131
146
|
/** Merged into the audit detail (a write made through the Platform tool: `via`, …). */
|
|
@@ -188,7 +203,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
|
|
|
188
203
|
/** The host versions (an entry's `minKernel` is judged against them). */
|
|
189
204
|
export declare const HOST_VERSIONS: {
|
|
190
205
|
readonly kernel: string;
|
|
191
|
-
readonly sdk: "0.1.0-rc.
|
|
206
|
+
readonly sdk: "0.1.0-rc.48";
|
|
192
207
|
};
|
|
193
208
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
194
209
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
|
@@ -288,6 +303,31 @@ export declare class MarketplacesService {
|
|
|
288
303
|
* without the schema).
|
|
289
304
|
*/
|
|
290
305
|
syncOfficialFromConfig(): Promise<void>;
|
|
306
|
+
/**
|
|
307
|
+
* Upserts the marketplaces of the extra bootstrap manifest (spec 2026-11-20 §5): one row
|
|
308
|
+
* `config:<name>` each with `managed = 'config'`; name, URL (its form per
|
|
309
|
+
* {@link marketplaceForm}), ref and username follow the file, the admin's enable switch is left
|
|
310
|
+
* alone, and a changed URL, form or ref drops the ETag and the last commit. The token stays in
|
|
311
|
+
* `marketplaces.tokens[name]`, never in the secrets table (a token an admin set while the row
|
|
312
|
+
* was demoted is deleted when it becomes managed again). A managed row whose name left the
|
|
313
|
+
* file is kept as an ordinary custom marketplace (`managed = NULL`, so no token). Called by
|
|
314
|
+
* every replica at start; idempotent. An invalid entry -> {@link ConfigError}, nothing written.
|
|
315
|
+
* `undefined` (this process has no extra manifest) writes nothing and demotes nothing: such a
|
|
316
|
+
* process may have read no managed row before another replica's sync committed (ruling R16), so
|
|
317
|
+
* only a configured extra manifest (an empty one included) removes a marketplace. Returns the
|
|
318
|
+
* names of the rows it demoted.
|
|
319
|
+
*/
|
|
320
|
+
syncExtraFromConfig(marketplaces: readonly BootstrapExtraMarketplace[] | undefined): Promise<string[]>;
|
|
321
|
+
/**
|
|
322
|
+
* Names the managed marketplace on the platform items the bootstrap step imported from it before
|
|
323
|
+
* its row existed (`capybara bootstrap` runs before the first start, and `marketplace_id` is a
|
|
324
|
+
* foreign key): a live item without a marketplace whose latest version came from the bootstrap
|
|
325
|
+
* with a `source_ref` of `<id>:…` (a git entry of that marketplace). Then the catalog tracks its
|
|
326
|
+
* updates like an import from the marketplace. Idempotent.
|
|
327
|
+
*/
|
|
328
|
+
private backfillBootstrapItems;
|
|
329
|
+
/** The row of one extra-manifest marketplace, checked as an admin add is (else ConfigError). */
|
|
330
|
+
private extraMarketplaceRow;
|
|
291
331
|
/** 全部来源(official 在前,其余按创建时间)。 */
|
|
292
332
|
list(): Promise<MarketplaceView[]>;
|
|
293
333
|
get(id: string): Promise<MarketplaceView>;
|
|
@@ -303,6 +343,8 @@ export declare class MarketplacesService {
|
|
|
303
343
|
ref?: string;
|
|
304
344
|
mirrors?: string[];
|
|
305
345
|
token?: string;
|
|
346
|
+
/** The Basic auth username of the git token (empty: the default `x-access-token`). */
|
|
347
|
+
username?: string;
|
|
306
348
|
}, opts?: ActorOpts): Promise<MarketplaceView>;
|
|
307
349
|
/**
|
|
308
350
|
* The read-only checks of {@link add}, for the `Platform` tool's precheck (before the card): the
|
|
@@ -321,12 +363,13 @@ export declare class MarketplacesService {
|
|
|
321
363
|
private writeAdd;
|
|
322
364
|
/**
|
|
323
365
|
* Updates a custom marketplace (audit `marketplace.updated`, listing the changed fields, the
|
|
324
|
-
* token's value never recorded; not written when unchanged). `token: null` clears the token
|
|
325
|
-
* Official only takes `enabled`, any other field ->
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
* the
|
|
366
|
+
* token's value never recorded; not written when unchanged). `token: null` clears the token,
|
|
367
|
+
* `username: null` or `""` the username. Official only takes `enabled`, any other field ->
|
|
368
|
+
* `marketplace.builtin`; a config-managed marketplace likewise -> `marketplace.config_managed`.
|
|
369
|
+
* Changing the URL, form or ref clears the ETag and the last commit (the next refresh reads
|
|
370
|
+
* everything again); a new URL gets its form from {@link marketplaceForm} unless `form` is
|
|
371
|
+
* given. `ref: null` follows the remote HEAD. Switching the form clears the other form's field
|
|
372
|
+
* (the ref when becoming http, the mirrors when becoming git) unless the patch sets it.
|
|
330
373
|
*/
|
|
331
374
|
update(actor: string, id: string, patch: {
|
|
332
375
|
name?: string;
|
|
@@ -336,12 +379,14 @@ export declare class MarketplacesService {
|
|
|
336
379
|
mirrors?: string[];
|
|
337
380
|
enabled?: boolean;
|
|
338
381
|
token?: string | null;
|
|
382
|
+
username?: string | null;
|
|
339
383
|
}, opts?: ActorOpts): Promise<MarketplaceView>;
|
|
340
384
|
private writeUpdate;
|
|
341
385
|
/**
|
|
342
386
|
* Deletes a custom marketplace (audit `marketplace.removed`): its cached entries and token
|
|
343
387
|
* are deleted; imported catalog items are kept (their marketplace becomes null). Official can
|
|
344
|
-
* only be disabled -> `marketplace.builtin
|
|
388
|
+
* only be disabled -> `marketplace.builtin`; a config-managed one ->
|
|
389
|
+
* `marketplace.config_managed`.
|
|
345
390
|
*/
|
|
346
391
|
remove(actor: string, id: string, opts?: ActorOpts): Promise<void>;
|
|
347
392
|
/**
|
|
@@ -409,8 +454,15 @@ export declare class MarketplacesService {
|
|
|
409
454
|
contentType: "image/svg+xml" | "image/png";
|
|
410
455
|
data: Uint8Array;
|
|
411
456
|
}>;
|
|
412
|
-
/**
|
|
413
|
-
|
|
457
|
+
/**
|
|
458
|
+
* The git / http credential of a marketplace: none for official; a config-managed one's token
|
|
459
|
+
* from `marketplaces.tokens[name]` (never the secrets table); a custom one's from secrets. The
|
|
460
|
+
* username is the stored one (absent: the default `x-access-token`). Missing -> `{}`.
|
|
461
|
+
*/
|
|
462
|
+
credentials(id: string): Promise<MarketplaceCredentials>;
|
|
463
|
+
private credentialsOf;
|
|
464
|
+
/** The `marketplaces.tokens` entry of a config-managed marketplace (`config:<name>`). */
|
|
465
|
+
private configToken;
|
|
414
466
|
/** Refreshes every effective marketplace (maintenance job `catalogs-refresh`), one failing not stopping the rest. */
|
|
415
467
|
refreshAll(signal: AbortSignal): Promise<void>;
|
|
416
468
|
/**
|
|
@@ -445,6 +497,8 @@ export declare class MarketplacesService {
|
|
|
445
497
|
private checkUrls;
|
|
446
498
|
/** A git marketplace has no mirrors; only a git marketplace has a ref. */
|
|
447
499
|
private checkGitFields;
|
|
500
|
+
/** A username outside `GIT_USERNAME_RE` -> `validation_failed`; empty or absent -> null. */
|
|
501
|
+
private checkUsername;
|
|
448
502
|
private checkToken;
|
|
449
503
|
}
|
|
450
504
|
export {};
|