@jini-ai/registry 0.1.2 → 0.5.1
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/CHANGELOG.md +91 -0
- package/README.md +134 -0
- package/dist/database-backend.d.ts +24 -9
- package/dist/database-backend.js +18 -20
- package/dist/github-backend.d.ts +22 -9
- package/dist/github-backend.js +13 -12
- package/dist/github-client.d.ts +11 -22
- package/dist/github-client.js +52 -53
- package/dist/index.d.ts +57 -1
- package/dist/ports.d.ts +4 -0
- package/dist/ports.js +2 -0
- package/dist/static-backend.d.ts +24 -12
- package/dist/static-backend.js +25 -22
- package/dist/tool-catalog/index.d.ts +27 -0
- package/dist/tool-catalog/index.js +2 -0
- package/dist/tool-catalog/sqlite.d.ts +73 -0
- package/dist/tool-catalog/sqlite.js +87 -0
- package/dist/tool-catalog-builder/index.d.ts +4 -0
- package/dist/tool-catalog-builder/index.js +4 -0
- package/dist/tool-catalog-builder/ports.d.ts +60 -0
- package/dist/tool-catalog-builder/ports.js +2 -0
- package/dist/tool-catalog-builder/query.d.ts +32 -0
- package/dist/tool-catalog-builder/query.js +68 -0
- package/dist/tool-catalog-builder/search-enricher.d.ts +13 -0
- package/dist/tool-catalog-builder/search-enricher.js +26 -0
- package/dist/tool-catalog-builder/sqlite.d.ts +14 -0
- package/dist/tool-catalog-builder/sqlite.js +17 -0
- package/dist/trust.d.ts +14 -3
- package/dist/trust.js +5 -5
- package/dist/versioning.d.ts +8 -2
- package/dist/versioning.js +2 -2
- package/package.json +53 -6
- package/dist/database-backend.d.ts.map +0 -1
- package/dist/database-backend.js.map +0 -1
- package/dist/github-backend.d.ts.map +0 -1
- package/dist/github-backend.js.map +0 -1
- package/dist/github-client.d.ts.map +0 -1
- package/dist/github-client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/static-backend.d.ts.map +0 -1
- package/dist/static-backend.js.map +0 -1
- package/dist/trust.d.ts.map +0 -1
- package/dist/trust.js.map +0 -1
- package/dist/versioning.d.ts.map +0 -1
- package/dist/versioning.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
## 0.5.1 — 2026-10-05
|
|
2
|
+
|
|
3
|
+
- The `@jini-ai/db` peer range is `^0.2.0 || ^0.3.0` (registry uses only db's SQLite entry, which 0.3.0 leaves unchanged), so a host on db 0.3.0 installs without a peer conflict.
|
|
4
|
+
- Internal `@jini-ai/*` runtime dependencies are caret ranges (`workspace:^`) instead of exact pins.
|
|
5
|
+
|
|
6
|
+
## 0.4.0 (unpublished release candidate)
|
|
7
|
+
|
|
8
|
+
## 0.5.0 — 2026-10-02
|
|
9
|
+
|
|
10
|
+
### BREAKING
|
|
11
|
+
|
|
12
|
+
- Kernel clock types replace package-local ports and storage integration remains isolated behind public optional-driver entries.
|
|
13
|
+
- Distribution includes runtime output, release documentation and required assets only. Process records and per-job neutrality checks are no longer part of the package surface.
|
|
14
|
+
|
|
15
|
+
- SQLite tool-catalog indexing moves to tool-catalog/sqlite, with a driver-free neutral tool-catalog entry.
|
|
16
|
+
|
|
17
|
+
# @jini-ai/registry
|
|
18
|
+
|
|
19
|
+
## 0.1.2
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Add top-level `main`/`types` fields alongside the existing `exports` map. A consumer on
|
|
24
|
+
TypeScript's classic `moduleResolution: "node"` (node10) — which ignores `package.json#exports`
|
|
25
|
+
entirely — could not resolve this package's types at all (`TS2307: Cannot find module`) even
|
|
26
|
+
after the previous exports-map fix restored `require()` at runtime; type resolution and runtime
|
|
27
|
+
resolution are separate algorithms. Verified against a real external consumer (whose
|
|
28
|
+
tsconfig uses this legacy resolution mode): adding these two fields, with its tsconfig completely
|
|
29
|
+
unchanged, made the error disappear. Also fixes absolute-path `require()` (distinct from a bare
|
|
30
|
+
specifier, which already worked) for the same reason — `main` was previously absent.
|
|
31
|
+
|
|
32
|
+
Purely additive: every modern resolver (Node's own runtime `exports` resolution, TypeScript's
|
|
33
|
+
`bundler`/`node16`/`nodenext`) prefers `exports` over `main`/`types` when both are present, so
|
|
34
|
+
this changes nothing for a consumer already on a modern resolver.
|
|
35
|
+
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
- @jini-ai/protocol@0.1.2
|
|
38
|
+
|
|
39
|
+
## 0.1.1
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Add a `"default"` export condition to every published package's `exports` map — every one of
|
|
44
|
+
them lacked it, which meant `require()` failed with `ERR_PACKAGE_PATH_NOT_EXPORTED` for any
|
|
45
|
+
CommonJS consumer (found via a real external integration attempt; Node needs `require(esm)`
|
|
46
|
+
support, i.e. Node >=22.12, for this to resolve).
|
|
47
|
+
|
|
48
|
+
`@jini-ai/agent-runtime`:
|
|
49
|
+
|
|
50
|
+
- **New**: `RuntimeBuildOptions.permissionMode` (`'bypass' | 'restricted'`) lets a caller opt a
|
|
51
|
+
run OUT of the auto-approve-every-permission-prompt flag every def with one
|
|
52
|
+
(`bypassPermissions` / `--yolo` / `--dangerously-skip-permissions`) previously pushed
|
|
53
|
+
unconditionally, with no way to turn it off. Omitting it keeps today's default (bypass)
|
|
54
|
+
behavior unchanged.
|
|
55
|
+
- **New**: `ClaudeStreamEvent`, `CopilotStreamEvent`, and `QoderEvent` are now real exported
|
|
56
|
+
discriminated unions instead of `Record<string, unknown>` — a real external consumer guessed a
|
|
57
|
+
nonexistent field name (`event.text` instead of the actual `event.delta`) against the old
|
|
58
|
+
untyped sink and silently lost every streamed token with no compile or runtime error.
|
|
59
|
+
- Fixed a doc/implementation mismatch in `claude-stream.ts`: the module doc claimed `tool_result`
|
|
60
|
+
events carry `{ tool_use_id, content, is_error }`; the actual emitted shape is
|
|
61
|
+
`{ toolUseId, content, isError }`.
|
|
62
|
+
|
|
63
|
+
`@jini-ai/daemon`: `AgentExecutorRunInput.permissionMode` forwards the new
|
|
64
|
+
`RuntimeBuildOptions.permissionMode` through to `buildArgs`, so a host can actually reach the new
|
|
65
|
+
opt-out from the daemon's real run-input surface, not just from `@jini-ai/agent-runtime` in
|
|
66
|
+
isolation.
|
|
67
|
+
|
|
68
|
+
`@jini-ai/agentic`: `setAtPointer` no longer throws on a malformed (e.g. missing leading `/`)
|
|
69
|
+
`updateDataModel` path — degrades to a no-op like its sibling `getAtPointer`, matching this
|
|
70
|
+
package's own "a bad binding must not crash the renderer" contract. That path is agent-authored
|
|
71
|
+
wire data with no error boundary above it in any host, so the uncaught throw could unmount an
|
|
72
|
+
entire chat UI from ~40 bytes of malformed input.
|
|
73
|
+
|
|
74
|
+
`@jini-ai/chat-react`: a local (client-resolved) A2UI button action is no longer a silent no-op —
|
|
75
|
+
`A2uiSurfaceCard` now surfaces the resolved value. New `ExtEventErrorBoundary` confines a
|
|
76
|
+
`kind: 'ext'` event group's renderer to its own card instead of letting a render/effect-phase
|
|
77
|
+
throw from agent-controlled content unmount the whole chat root (there was no error boundary
|
|
78
|
+
anywhere in this package or its hosts before this).
|
|
79
|
+
|
|
80
|
+
- Updated dependencies
|
|
81
|
+
- @jini-ai/protocol@0.1.1
|
|
82
|
+
|
|
83
|
+
## Unreleased — C2 tool catalog ownership
|
|
84
|
+
|
|
85
|
+
- Adopt shared kernel contracts and preserve the module rationale in neutral documentation.
|
|
86
|
+
- Add ./tool-catalog-builder and its isolated SQLite store factory; convert public registry APIs to required/optional argument objects with injected clock, database and HTTP ports. Preserve SQL, FTS5/BM25 ranking, dry-run outcomes and canonical signing bytes. Reject invalid trust/backend modes.
|
|
87
|
+
- BREAKING: replace package-local clock contracts with core Clock.nowMs().
|
|
88
|
+
- BREAKING: GithubApiRegistryClient requires core HttpClientPort.send instead of the local fetch port; RegistryClockPort, RegistryHttpPort and CatalogClock are removed. Buffered body transport failures now propagate unchanged before JSON parsing; malformed JSON retains its existing error message.
|
|
89
|
+
|
|
90
|
+
- Added neutral catalog types/port and isolated borrowed-handle FTS5 adapter.
|
|
91
|
+
- Preserved all existing ranking, reseed, schema and descriptor assertions.
|
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# `@jini-ai/registry`
|
|
2
|
+
|
|
3
|
+
Three interchangeable backends for a content registry — the thing that answers "give me version
|
|
4
|
+
`^2.1.0` of the entry named `acme/theme`" — plus the semver specifier parsing and version resolution
|
|
5
|
+
they share, and real cryptographic signature verification against a GitHub Actions OIDC trust root.
|
|
6
|
+
The wire types (`RegistryEntry`, `RegistryManifest`, `RegistryBackend`, …) live in
|
|
7
|
+
`@jini-ai/protocol`; this package only adds the concrete backend logic, mirroring how
|
|
8
|
+
`@jini-ai/sqlite-chat` implements ports that `@jini-ai/protocol` defines.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @jini-ai/registry
|
|
14
|
+
|
|
15
|
+
# only if you use DatabaseRegistryBackend (native compiled addon)
|
|
16
|
+
npm install better-sqlite3
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`better-sqlite3` is an **optional peer dependency**: `database-backend.ts` needs only its *type*, and
|
|
20
|
+
the caller owns and opens the real handle. `StaticRegistryBackend`, `GithubRegistryBackend`, and the
|
|
21
|
+
resolution/trust helpers need nothing extra, so most adopters never pay the native-compile cost.
|
|
22
|
+
`@jini-ai/protocol` is a regular dependency.
|
|
23
|
+
|
|
24
|
+
## What you get
|
|
25
|
+
|
|
26
|
+
**Three backends**, all implementing `@jini-ai/protocol`'s `RegistryBackend`:
|
|
27
|
+
- `StaticRegistryBackend` / `StaticRegistryBackendOptions` — serves an in-memory
|
|
28
|
+
`RegistryManifest` you hand it. The zero-infrastructure option; also the one to reach for in tests.
|
|
29
|
+
- `GithubRegistryBackend` / `GithubRegistryBackendOptions` — reads (and, via
|
|
30
|
+
`GithubPublishMutation`, writes) a manifest stored in a GitHub repository through an injected
|
|
31
|
+
`GithubRegistryClient`. `GithubApiRegistryClient` / `GithubApiRegistryClientOptions` is the real
|
|
32
|
+
HTTP implementation of that client interface.
|
|
33
|
+
- `DatabaseRegistryBackend` / `DatabaseRegistryBackendOptions` — SQL-backed, over a database handle
|
|
34
|
+
you supply. `ensureRegistryTables(db)` creates the schema; `upsertRegistryEntry(db, entry)` writes
|
|
35
|
+
a single entry.
|
|
36
|
+
|
|
37
|
+
**Version resolution** — `parseRegistrySpecifier('acme/theme@^2.1.0')` → `ParsedRegistrySpecifier`
|
|
38
|
+
(`{ name, range? }`), and `resolveRegistryEntryVersion` → `ResolvedRegistryEntryVersion`.
|
|
39
|
+
|
|
40
|
+
**Signature trust** — `verifyRegistryEntrySignatures` and `verifyRegistrySignature` returning a
|
|
41
|
+
`SignatureVerificationResult` (never thrown, always returned), plus
|
|
42
|
+
`canonicalRegistrySigningPayload` (the exact `name@version:digest` string a signature must cover),
|
|
43
|
+
`RegistryTrustRoot` / `GithubOidcTrustRoot`, and `GITHUB_ACTIONS_OIDC_ISSUER`. Verification is
|
|
44
|
+
**opt-in and additive**: omit `trustRoot` and a backend reports `verified: false` for every entry
|
|
45
|
+
without attempting anything, which is the pre-existing default. Configure it — at minimum
|
|
46
|
+
`githubOidc.caCertificates` — and `entry.signatures[]` gets real cryptographic checking, with
|
|
47
|
+
`allowedIdentities` matched against the certificate's own `subjectAltName` URIs rather than a
|
|
48
|
+
self-reported field.
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import {
|
|
54
|
+
StaticRegistryBackend,
|
|
55
|
+
DatabaseRegistryBackend,
|
|
56
|
+
ensureRegistryTables,
|
|
57
|
+
parseRegistrySpecifier,
|
|
58
|
+
} from '@jini-ai/registry';
|
|
59
|
+
import type { RegistryManifest } from '@jini-ai/protocol';
|
|
60
|
+
import { readFileSync } from 'node:fs';
|
|
61
|
+
|
|
62
|
+
const manifest: RegistryManifest = loadManifestSomehow(); // see RegistryManifestSchema
|
|
63
|
+
|
|
64
|
+
const registry = new StaticRegistryBackend({
|
|
65
|
+
id: 'builtin',
|
|
66
|
+
kind: 'local',
|
|
67
|
+
trust: 'official', // 'official' | 'trusted' | 'restricted'
|
|
68
|
+
manifest,
|
|
69
|
+
// Opt in to real signature verification; omit entirely for the verified:false default.
|
|
70
|
+
trustRoot: {
|
|
71
|
+
githubOidc: {
|
|
72
|
+
caCertificates: [readFileSync('/etc/example/fulcio-root.pem', 'utf8')],
|
|
73
|
+
allowedIdentities: [/^https:\/\/github\.com\/acme\/themes\/\.github\/workflows\//],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const { name, range } = parseRegistrySpecifier('acme/theme@^2.1.0');
|
|
79
|
+
const resolved = await registry.resolve(name, range); // ResolvedRegistryEntry | null
|
|
80
|
+
|
|
81
|
+
// Or the SQL-backed variant, over a handle you own.
|
|
82
|
+
import Database from 'better-sqlite3';
|
|
83
|
+
const db = new Database('/var/lib/example/registry.sqlite');
|
|
84
|
+
ensureRegistryTables(db);
|
|
85
|
+
const dbRegistry = new DatabaseRegistryBackend({ id: 'local', trust: 'restricted', db });
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`RegistryBackend`'s full surface is `list` / `search` / `resolve` / `manifest` / `doctor`, plus
|
|
89
|
+
optional `publish` / `yank`. Check `RegistryManifestSchema` in `@jini-ai/protocol` for the manifest
|
|
90
|
+
shape before building one by hand.
|
|
91
|
+
|
|
92
|
+
## What's swappable
|
|
93
|
+
|
|
94
|
+
`RegistryBackend` (defined in `@jini-ai/protocol`, alongside `RegistryBackendFactory`) is the port,
|
|
95
|
+
and these three are just the implementations that ship — a fourth reading an S3 bucket or an internal
|
|
96
|
+
service plugs in with no consumer change. Inside `GithubRegistryBackend`, `GithubRegistryClient` is
|
|
97
|
+
itself an injected interface, so the GitHub API calls are replaceable (or fakeable) without touching
|
|
98
|
+
the backend logic. `DatabaseRegistryBackend` takes an already-open handle rather than a path, so
|
|
99
|
+
connection lifetime and `:memory:` testing are yours. `RegistryTrustRoot` selects the verification
|
|
100
|
+
policy. Fixed: the specifier grammar, the semver resolution rules, and
|
|
101
|
+
`canonicalRegistrySigningPayload`'s byte layout — a signature is only meaningful if every party
|
|
102
|
+
canonicalizes identically.
|
|
103
|
+
|
|
104
|
+
## Runtime
|
|
105
|
+
|
|
106
|
+
`jini.runtime: "node"` — `node:crypto` for signature verification, and `better-sqlite3` types for
|
|
107
|
+
the SQL backend.
|
|
108
|
+
ESM only — ships `"type": "module"` with no CommonJS `require` build.
|
|
109
|
+
|
|
110
|
+
## Provenance
|
|
111
|
+
|
|
112
|
+
See the archived provenance ledger for per-file provenance and scope decisions. Apache-2.0,
|
|
113
|
+
inherited from Open Design — see the repo `NOTICE`.
|
|
114
|
+
|
|
115
|
+
## Tool descriptor catalog
|
|
116
|
+
|
|
117
|
+
`./tool-catalog` exports neutral `ToolCatalogEntry`, `ToolCatalogSearchHit` and `ToolCatalogQuery`
|
|
118
|
+
types. `./tool-catalog/sqlite` exports synchronous ensure/reseed/search/describe helpers over a
|
|
119
|
+
borrowed structural host handle. This is the unchanged `tool_catalog` + external-content FTS5/BM25
|
|
120
|
+
snapshot, preserving schema/inputSchema/source, ranking and query sanitization. Reseed is atomic.
|
|
121
|
+
The adapter is isolated from the registry root and content backends; db and SQLite are optional peers,
|
|
122
|
+
with no driver value import or implicit connection acquisition.
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
## Kernel contracts
|
|
126
|
+
|
|
127
|
+
The GitHub client accepts core `HttpClientPort` and calls `send({ request })`, retaining a
|
|
128
|
+
15-second total deadline and idle budget. Responses use `status`, `headers` and `bodyText`.
|
|
129
|
+
The port buffers before status/JSON handling: body transport errors propagate unchanged;
|
|
130
|
+
malformed JSON still reports the existing GitHub non-JSON response error.
|
|
131
|
+
Backend options accept core `Clock` (`nowMs()`), while tool-catalog snapshots use `nowIso({ clock })`.
|
|
132
|
+
Import both kernel types from `@jini-ai/core/primitives`; `RegistryDatabasePort` is exported at root.
|
|
133
|
+
`tool-catalog-builder` stays universal; its `tool-catalog-builder/sqlite` factory is a Node subpath.
|
|
134
|
+
Ranking belongs to the injected backend, source/enrichment policy belongs to the host.
|
|
@@ -8,23 +8,30 @@
|
|
|
8
8
|
* call (`getManifest()` override) — simple and correct for the entry counts a
|
|
9
9
|
* registry realistically holds; `publish`/`yank` write straight to the table.
|
|
10
10
|
*/
|
|
11
|
-
import type
|
|
11
|
+
import type { Clock } from '@jini-ai/core/primitives';
|
|
12
|
+
import type { RegistryDatabasePort } from './ports.js';
|
|
12
13
|
import { type RegistryEntry, type RegistryManifest, type RegistryPublishOutcome, type RegistryPublishRequest, type RegistryTrust, type RegistryYankOutcome } from '@jini-ai/protocol';
|
|
13
14
|
import { StaticRegistryBackend } from './static-backend.js';
|
|
14
15
|
import type { RegistryTrustRoot } from './trust.js';
|
|
15
|
-
type SqliteDb =
|
|
16
|
+
type SqliteDb = RegistryDatabasePort;
|
|
16
17
|
export interface DatabaseRegistryBackendOptions {
|
|
17
|
-
id: string;
|
|
18
18
|
trust?: RegistryTrust;
|
|
19
|
-
|
|
19
|
+
clock?: Clock;
|
|
20
20
|
/** Optional `github-oidc` signature trust root — see `StaticRegistryBackendOptions.trustRoot`'s doc comment for what configuring (or omitting) this does. */
|
|
21
21
|
trustRoot?: RegistryTrustRoot | undefined;
|
|
22
22
|
}
|
|
23
23
|
export declare class DatabaseRegistryBackend extends StaticRegistryBackend {
|
|
24
24
|
readonly db: SqliteDb;
|
|
25
|
-
constructor(
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
constructor(required: {
|
|
26
|
+
id: string;
|
|
27
|
+
db: SqliteDb;
|
|
28
|
+
}, options?: DatabaseRegistryBackendOptions);
|
|
29
|
+
publish(required: Pick<RegistryPublishRequest, 'entry'>, optional?: Omit<RegistryPublishRequest, 'entry'>): Promise<RegistryPublishOutcome>;
|
|
30
|
+
yank({ name, version, reason }: {
|
|
31
|
+
name: string;
|
|
32
|
+
version: string;
|
|
33
|
+
reason: string;
|
|
34
|
+
}): Promise<RegistryYankOutcome>;
|
|
28
35
|
protected getManifest(): RegistryManifest;
|
|
29
36
|
}
|
|
30
37
|
/**
|
|
@@ -32,7 +39,9 @@ export declare class DatabaseRegistryBackend extends StaticRegistryBackend {
|
|
|
32
39
|
*
|
|
33
40
|
* @param db - The sqlite connection to migrate.
|
|
34
41
|
*/
|
|
35
|
-
export declare function ensureRegistryTables(db
|
|
42
|
+
export declare function ensureRegistryTables({ db }: {
|
|
43
|
+
db: SqliteDb;
|
|
44
|
+
}): void;
|
|
36
45
|
/**
|
|
37
46
|
* Insert or update one registry entry's row for a given backend.
|
|
38
47
|
*
|
|
@@ -41,6 +50,12 @@ export declare function ensureRegistryTables(db: SqliteDb): void;
|
|
|
41
50
|
* @param entry - The entry to store (serialized as JSON).
|
|
42
51
|
* @param now - Timestamp to record as `updated_at` (defaults to `Date.now()`).
|
|
43
52
|
*/
|
|
44
|
-
export declare function upsertRegistryEntry(db
|
|
53
|
+
export declare function upsertRegistryEntry({ db, backendId, entry }: {
|
|
54
|
+
db: SqliteDb;
|
|
55
|
+
backendId: string;
|
|
56
|
+
entry: RegistryEntry;
|
|
57
|
+
}, { now }?: {
|
|
58
|
+
now?: number;
|
|
59
|
+
}): void;
|
|
45
60
|
export {};
|
|
46
61
|
//# sourceMappingURL=database-backend.d.ts.map
|
package/dist/database-backend.js
CHANGED
|
@@ -2,25 +2,23 @@ import { RegistryEntrySchema, } from '@jini-ai/protocol';
|
|
|
2
2
|
import { assertValidPublishRequest, StaticRegistryBackend } from './static-backend.js';
|
|
3
3
|
export class DatabaseRegistryBackend extends StaticRegistryBackend {
|
|
4
4
|
db;
|
|
5
|
-
constructor(options) {
|
|
6
|
-
ensureRegistryTables(
|
|
5
|
+
constructor(required, options = {}) {
|
|
6
|
+
ensureRegistryTables({ db: required.db });
|
|
7
7
|
super({
|
|
8
|
-
id:
|
|
9
|
-
kind: 'db',
|
|
8
|
+
id: required.id,
|
|
10
9
|
trust: options.trust ?? 'restricted',
|
|
11
|
-
manifest: manifestFromDb(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.db = options.db;
|
|
10
|
+
manifest: manifestFromDb(required.db, required.id),
|
|
11
|
+
}, { kind: 'db', trustRoot: options.trustRoot, ...(options.clock ? { clock: options.clock } : {}) });
|
|
12
|
+
this.db = required.db;
|
|
15
13
|
}
|
|
16
|
-
async publish(
|
|
14
|
+
async publish(required, optional = {}) {
|
|
17
15
|
// Validate the whole request against the wire schema before writing
|
|
18
16
|
// anything: `manifestFromDb()`/`parseStoredEntry()` throw on read for
|
|
19
17
|
// any row that fails `RegistryEntrySchema`, so an unvalidated publish
|
|
20
18
|
// could write a row that permanently breaks every future
|
|
21
19
|
// `list`/`search`/`resolve`/`doctor` call for this backend (see CR-009 /
|
|
22
20
|
// `assertValidPublishRequest`'s docs in `static-backend.ts`).
|
|
23
|
-
const parsed = assertValidPublishRequest(
|
|
21
|
+
const parsed = assertValidPublishRequest(required, optional);
|
|
24
22
|
const [vendor, name] = parsed.entry.name.split('/');
|
|
25
23
|
const changedFiles = [
|
|
26
24
|
`db://${this.id}/entries/${vendor}/${name}`,
|
|
@@ -31,10 +29,10 @@ export class DatabaseRegistryBackend extends StaticRegistryBackend {
|
|
|
31
29
|
if (parsed.dryRun) {
|
|
32
30
|
return { ok: true, dryRun: true, changedFiles, warnings: [] };
|
|
33
31
|
}
|
|
34
|
-
upsertRegistryEntry(this.db, this.id, parsed.entry);
|
|
32
|
+
upsertRegistryEntry({ db: this.db, backendId: this.id, entry: parsed.entry }, { now: this.clock.nowMs() });
|
|
35
33
|
return { ok: true, dryRun: false, changedFiles, warnings: [] };
|
|
36
34
|
}
|
|
37
|
-
async yank(name, version, reason) {
|
|
35
|
+
async yank({ name, version, reason }) {
|
|
38
36
|
// Read-then-write: run as a single `IMMEDIATE` transaction rather than
|
|
39
37
|
// two separate auto-committing statements. Two bare statements leave a
|
|
40
38
|
// window — between the SELECT and the later UPSERT — where a concurrent
|
|
@@ -61,12 +59,12 @@ export class DatabaseRegistryBackend extends StaticRegistryBackend {
|
|
|
61
59
|
if (!exists) {
|
|
62
60
|
return { ok: false, name, version, reason, warnings: [`${name}@${version} not found`] };
|
|
63
61
|
}
|
|
64
|
-
const nextVersions = versions.map((item) => item.version === version ? { ...item, yanked: true, yankedAt: new Date().toISOString(), yankReason: reason } : item);
|
|
65
|
-
upsertRegistryEntry(this.db, this.id, {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
const nextVersions = versions.map((item) => item.version === version ? { ...item, yanked: true, yankedAt: new Date(this.clock.nowMs()).toISOString(), yankReason: reason } : item);
|
|
63
|
+
upsertRegistryEntry({ db: this.db, backendId: this.id, entry: {
|
|
64
|
+
...entry,
|
|
65
|
+
versions: nextVersions,
|
|
66
|
+
...(entry.version === version ? { yanked: true, yankedAt: new Date(this.clock.nowMs()).toISOString(), yankReason: reason } : {}),
|
|
67
|
+
} }, { now: this.clock.nowMs() });
|
|
70
68
|
return { ok: true, name, version, reason, warnings: [] };
|
|
71
69
|
});
|
|
72
70
|
return runYank.immediate();
|
|
@@ -80,7 +78,7 @@ export class DatabaseRegistryBackend extends StaticRegistryBackend {
|
|
|
80
78
|
*
|
|
81
79
|
* @param db - The sqlite connection to migrate.
|
|
82
80
|
*/
|
|
83
|
-
export function ensureRegistryTables(db) {
|
|
81
|
+
export function ensureRegistryTables({ db }) {
|
|
84
82
|
db.exec(`
|
|
85
83
|
CREATE TABLE IF NOT EXISTS registry_entries (
|
|
86
84
|
backend_id TEXT NOT NULL,
|
|
@@ -100,7 +98,7 @@ export function ensureRegistryTables(db) {
|
|
|
100
98
|
* @param entry - The entry to store (serialized as JSON).
|
|
101
99
|
* @param now - Timestamp to record as `updated_at` (defaults to `Date.now()`).
|
|
102
100
|
*/
|
|
103
|
-
export function upsertRegistryEntry(db, backendId, entry, now = Date.now()) {
|
|
101
|
+
export function upsertRegistryEntry({ db, backendId, entry }, { now = Date.now() } = {}) {
|
|
104
102
|
db.prepare(`
|
|
105
103
|
INSERT INTO registry_entries (backend_id, name, version, entry_json, updated_at)
|
|
106
104
|
VALUES (?, ?, ?, ?, ?)
|
package/dist/github-backend.d.ts
CHANGED
|
@@ -10,10 +10,16 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { RegistryManifest, RegistryPublishOutcome, RegistryPublishRequest, RegistryTrust, RegistryYankOutcome } from '@jini-ai/protocol';
|
|
12
12
|
import { StaticRegistryBackend } from './static-backend.js';
|
|
13
|
+
import type { Clock } from '@jini-ai/core/primitives';
|
|
13
14
|
import type { RegistryTrustRoot } from './trust.js';
|
|
14
15
|
/** Read/write access to a GitHub-hosted registry manifest, injected by the host. */
|
|
15
16
|
export interface GithubRegistryClient {
|
|
16
|
-
readManifest(
|
|
17
|
+
readManifest(required: {
|
|
18
|
+
owner: string;
|
|
19
|
+
repo: string;
|
|
20
|
+
ref: string;
|
|
21
|
+
path: string;
|
|
22
|
+
}): Promise<RegistryManifest>;
|
|
17
23
|
createPublishPullRequest?(request: GithubPublishMutation): Promise<{
|
|
18
24
|
url: string;
|
|
19
25
|
}>;
|
|
@@ -31,9 +37,7 @@ export interface GithubPublishMutation {
|
|
|
31
37
|
}>;
|
|
32
38
|
}
|
|
33
39
|
export interface GithubRegistryBackendOptions {
|
|
34
|
-
|
|
35
|
-
owner: string;
|
|
36
|
-
repo: string;
|
|
40
|
+
clock?: Clock;
|
|
37
41
|
ref?: string;
|
|
38
42
|
manifestPath?: string;
|
|
39
43
|
/**
|
|
@@ -44,7 +48,6 @@ export interface GithubRegistryBackendOptions {
|
|
|
44
48
|
* the least-privileged `'restricted'` when omitted.
|
|
45
49
|
*/
|
|
46
50
|
trust?: RegistryTrust;
|
|
47
|
-
client: GithubRegistryClient;
|
|
48
51
|
/** Optional `github-oidc` signature trust root — see `StaticRegistryBackendOptions.trustRoot`'s doc comment for what configuring (or omitting) this does. */
|
|
49
52
|
trustRoot?: RegistryTrustRoot | undefined;
|
|
50
53
|
}
|
|
@@ -58,11 +61,21 @@ export declare class GithubRegistryBackend extends StaticRegistryBackend {
|
|
|
58
61
|
/**
|
|
59
62
|
* Read the manifest from the configured GitHub path and construct the backend.
|
|
60
63
|
*
|
|
61
|
-
* @param
|
|
64
|
+
* @param required - Repo coordinates and the client to read/write through.
|
|
65
|
+
* @param options - Optional ref/path, trust policy, signature roots and clock.
|
|
62
66
|
* @returns The constructed backend, already holding its first manifest snapshot.
|
|
63
67
|
*/
|
|
64
|
-
static create(
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
static create(required: {
|
|
69
|
+
id: string;
|
|
70
|
+
owner: string;
|
|
71
|
+
repo: string;
|
|
72
|
+
client: GithubRegistryClient;
|
|
73
|
+
}, options?: GithubRegistryBackendOptions): Promise<GithubRegistryBackend>;
|
|
74
|
+
publish(required: Pick<RegistryPublishRequest, 'entry'>, optional?: Omit<RegistryPublishRequest, 'entry'>): Promise<RegistryPublishOutcome>;
|
|
75
|
+
yank({ name, version, reason }: {
|
|
76
|
+
name: string;
|
|
77
|
+
version: string;
|
|
78
|
+
reason: string;
|
|
79
|
+
}): Promise<RegistryYankOutcome>;
|
|
67
80
|
}
|
|
68
81
|
//# sourceMappingURL=github-backend.d.ts.map
|
package/dist/github-backend.js
CHANGED
|
@@ -45,7 +45,7 @@ export class GithubRegistryBackend extends StaticRegistryBackend {
|
|
|
45
45
|
// `create()`, always resolves them to concrete strings before constructing,
|
|
46
46
|
// so a `??` default in this constructor would be unreachable dead code.
|
|
47
47
|
constructor(options) {
|
|
48
|
-
super({ id: options.id,
|
|
48
|
+
super({ id: options.id, trust: options.trust ?? 'restricted', manifest: options.manifest }, { kind: 'github', trustRoot: options.trustRoot, ...(options.clock ? { clock: options.clock } : {}) });
|
|
49
49
|
this.owner = options.owner;
|
|
50
50
|
this.repo = options.repo;
|
|
51
51
|
this.ref = options.ref;
|
|
@@ -55,31 +55,32 @@ export class GithubRegistryBackend extends StaticRegistryBackend {
|
|
|
55
55
|
/**
|
|
56
56
|
* Read the manifest from the configured GitHub path and construct the backend.
|
|
57
57
|
*
|
|
58
|
-
* @param
|
|
58
|
+
* @param required - Repo coordinates and the client to read/write through.
|
|
59
|
+
* @param options - Optional ref/path, trust policy, signature roots and clock.
|
|
59
60
|
* @returns The constructed backend, already holding its first manifest snapshot.
|
|
60
61
|
*/
|
|
61
|
-
static async create(options) {
|
|
62
|
+
static async create(required, options = {}) {
|
|
62
63
|
const ref = options.ref ?? 'main';
|
|
63
64
|
const manifestPath = options.manifestPath ?? DEFAULT_MANIFEST_PATH;
|
|
64
|
-
const manifest = await
|
|
65
|
-
return new GithubRegistryBackend({ ...options, ref, manifestPath, manifest });
|
|
65
|
+
const manifest = await required.client.readManifest({ owner: required.owner, repo: required.repo, ref, path: manifestPath });
|
|
66
|
+
return new GithubRegistryBackend({ ...required, ...options, ref, manifestPath, manifest });
|
|
66
67
|
}
|
|
67
|
-
async publish(
|
|
68
|
+
async publish(required, optional = {}) {
|
|
68
69
|
// `publish` is a public method on a plain-string/JS-object boundary — an
|
|
69
70
|
// untyped caller's `name`/`version` are used to build a file path and PR
|
|
70
71
|
// branch name below, so both must be validated before that happens.
|
|
71
|
-
const [vendor, name] = assertSafeEntryName(
|
|
72
|
-
const version = assertSafeVersion(
|
|
72
|
+
const [vendor, name] = assertSafeEntryName(required.entry.name);
|
|
73
|
+
const version = assertSafeVersion(required.entry.version);
|
|
73
74
|
// Beyond the path-safety checks above, validate the *whole* request
|
|
74
75
|
// against the wire schema before any of its fields get written into the
|
|
75
76
|
// published manifest content below (see CR-009/`assertValidPublishRequest`).
|
|
76
|
-
const parsed = assertValidPublishRequest(
|
|
77
|
+
const parsed = assertValidPublishRequest(required, optional);
|
|
77
78
|
const root = `entries/${vendor}/${name}`;
|
|
78
79
|
const files = [
|
|
79
80
|
{ path: `${root}/entry.json`, content: `${JSON.stringify(parsed.entry, null, 2)}\n` },
|
|
80
81
|
{
|
|
81
82
|
path: `${root}/versions/${version}.json`,
|
|
82
|
-
content: `${JSON.stringify({ ...parsed.entry, publishedAt: new Date().toISOString(), tag: parsed.tag ?? 'latest' }, null, 2)}\n`,
|
|
83
|
+
content: `${JSON.stringify({ ...parsed.entry, publishedAt: new Date(this.clock.nowMs()).toISOString(), tag: parsed.tag ?? 'latest' }, null, 2)}\n`,
|
|
83
84
|
},
|
|
84
85
|
];
|
|
85
86
|
if (parsed.dryRun || !this.client.createPublishPullRequest) {
|
|
@@ -102,7 +103,7 @@ export class GithubRegistryBackend extends StaticRegistryBackend {
|
|
|
102
103
|
const pr = await this.client.createPublishPullRequest(mutation);
|
|
103
104
|
return { ok: true, dryRun: false, pullRequestUrl: pr.url, changedFiles: files.map((file) => file.path), warnings: [] };
|
|
104
105
|
}
|
|
105
|
-
async yank(name, version, reason) {
|
|
106
|
+
async yank({ name, version, reason }) {
|
|
106
107
|
const [vendor, entryName] = assertSafeEntryName(name);
|
|
107
108
|
const safeVersion = assertSafeVersion(version);
|
|
108
109
|
assertNoControlChars(reason, 'yank reason');
|
|
@@ -129,7 +130,7 @@ export class GithubRegistryBackend extends StaticRegistryBackend {
|
|
|
129
130
|
files: [
|
|
130
131
|
{
|
|
131
132
|
path,
|
|
132
|
-
content: `${JSON.stringify({ name, version, yanked: true, yankedAt: new Date().toISOString(), yankReason: reason }, null, 2)}\n`,
|
|
133
|
+
content: `${JSON.stringify({ name, version, yanked: true, yankedAt: new Date(this.clock.nowMs()).toISOString(), yankReason: reason }, null, 2)}\n`,
|
|
133
134
|
},
|
|
134
135
|
],
|
|
135
136
|
};
|
package/dist/github-client.d.ts
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @module github-client
|
|
3
|
-
*
|
|
4
|
-
* A concrete `GithubRegistryClient` (the interface `github-backend.ts`
|
|
5
|
-
* defines and takes as an injected dependency) implemented against GitHub's
|
|
6
|
-
* real REST API. Per `source-map.md`'s "2026-07-21 hardening pass": "No
|
|
7
|
-
* concrete `GithubRegistryClient` HTTP implementation exists in this
|
|
8
|
-
* package — `readManifest`/`createPublishPullRequest` are an injected
|
|
9
|
-
* interface with no concrete implementation anywhere in this repo." This
|
|
10
|
-
* file closes that gap.
|
|
11
|
-
*
|
|
12
|
-
* Built directly against GitHub's published REST API docs (Contents API,
|
|
13
|
-
* Git Data API, Pulls API — see each function's doc comment for the exact
|
|
14
|
-
* endpoint/behavior it was verified against), following the same "raw
|
|
15
|
-
* `fetch`, no SDK dependency" convention `@jini-ai/deploy`'s `netlify.ts`/
|
|
16
|
-
* `github-pages.ts` already establish (this package has no `@jini-ai/deploy`
|
|
17
|
-
* dependency and does not gain one — the blob/tree/commit/ref mechanics
|
|
18
|
-
* below are written fresh for this package, not shared cross-package, since
|
|
19
|
-
* there is no existing shared low-level GitHub REST helper package).
|
|
20
|
-
*/
|
|
1
|
+
import type { HttpClientPort } from '@jini-ai/core/primitives';
|
|
21
2
|
import type { RegistryManifest } from '@jini-ai/protocol';
|
|
22
3
|
import type { GithubPublishMutation, GithubRegistryClient } from './github-backend.js';
|
|
23
4
|
/** Auth/endpoint config for {@link GithubApiRegistryClient}. */
|
|
@@ -43,7 +24,10 @@ export interface GithubApiRegistryClientOptions {
|
|
|
43
24
|
export declare class GithubApiRegistryClient implements GithubRegistryClient {
|
|
44
25
|
private readonly token;
|
|
45
26
|
private readonly apiUrl;
|
|
46
|
-
|
|
27
|
+
private readonly http;
|
|
28
|
+
constructor({ http }: {
|
|
29
|
+
http: HttpClientPort;
|
|
30
|
+
}, options?: GithubApiRegistryClientOptions);
|
|
47
31
|
/**
|
|
48
32
|
* Reads `path` at `ref` via `GET /repos/{owner}/{repo}/contents/{path}`
|
|
49
33
|
* (GitHub REST "Get repository content") and JSON-parses its base64
|
|
@@ -67,7 +51,12 @@ export declare class GithubApiRegistryClient implements GithubRegistryClient {
|
|
|
67
51
|
* @throws If the file does not exist, is a directory, is too large for
|
|
68
52
|
* this endpoint's inline-content response, or is not valid JSON.
|
|
69
53
|
*/
|
|
70
|
-
readManifest(owner
|
|
54
|
+
readManifest({ owner, repo, ref, path }: {
|
|
55
|
+
owner: string;
|
|
56
|
+
repo: string;
|
|
57
|
+
ref: string;
|
|
58
|
+
path: string;
|
|
59
|
+
}): Promise<RegistryManifest>;
|
|
71
60
|
/**
|
|
72
61
|
* Pushes `request.files` as a new commit on a fresh branch (created off
|
|
73
62
|
* `request.baseRef`) via the Git Data API — create a blob per file, a tree
|