@hraness/sponge 0.2.6 → 0.3.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/README.md +21 -9
- package/bin/sponge.js +8 -7
- package/dist/contracts/index.js +24 -6
- package/dist/contracts/validate.js +106 -29
- package/dist/migrations/008.d.ts +3 -0
- package/dist/migrations/008.js +5 -0
- package/dist/migrations/009.d.ts +3 -0
- package/dist/migrations/009.js +8 -0
- package/dist/migrations/010.d.ts +3 -0
- package/dist/migrations/010.js +11 -0
- package/dist/migrations/index.d.ts +15 -0
- package/dist/migrations/index.js +39 -0
- package/dist/src/acquisition/capture.js +87 -28
- package/dist/src/acquisition/cleanup.d.ts +0 -4
- package/dist/src/acquisition/cleanup.js +3 -5
- package/dist/src/acquisition/errors.js +17 -2
- package/dist/src/acquisition/files.d.ts +0 -1
- package/dist/src/acquisition/files.js +14 -11
- package/dist/src/acquisition/index.d.ts +2 -3
- package/dist/src/acquisition/index.js +1 -2
- package/dist/src/acquisition/lock.js +1 -1
- package/dist/src/acquisition/normalize.js +57 -18
- package/dist/src/acquisition/pins.js +22 -4
- package/dist/src/acquisition/process.js +67 -29
- package/dist/src/acquisition/runtime.d.ts +5 -7
- package/dist/src/acquisition/runtime.js +129 -68
- package/dist/src/acquisition/verify-helper.js +10 -3
- package/dist/src/annotations/quote.js +40 -12
- package/dist/src/annotations/store.d.ts +0 -1
- package/dist/src/annotations/store.js +66 -14
- package/dist/src/app/article.d.ts +2 -1
- package/dist/src/app/article.js +66 -70
- package/dist/src/app/bundle-files.d.ts +0 -4
- package/dist/src/app/bundle-files.js +11 -14
- package/dist/src/app/markdown.js +18 -6
- package/dist/src/app/source.d.ts +0 -4
- package/dist/src/app/source.js +18 -14
- package/dist/src/cli/arguments.d.ts +2 -8
- package/dist/src/cli/arguments.js +67 -80
- package/dist/src/cli/commands.d.ts +42 -0
- package/dist/src/cli/commands.js +795 -0
- package/dist/src/cli/config.js +12 -9
- package/dist/src/cli/digest.d.ts +1 -1
- package/dist/src/cli/digest.js +38 -16
- package/dist/src/cli/import.js +25 -4
- package/dist/src/cli/indexing.d.ts +2 -0
- package/dist/src/cli/indexing.js +26 -9
- package/dist/src/cli/main.js +47 -386
- package/dist/src/cli/portability.d.ts +0 -2
- package/dist/src/cli/portability.js +13 -8
- package/dist/src/cli/queue.js +12 -8
- package/dist/src/cli/runtimes.d.ts +1 -3
- package/dist/src/cli/runtimes.js +13 -6
- package/dist/src/cli/terminal.js +1 -1
- package/dist/src/cli/worker.d.ts +7 -0
- package/dist/src/cli/worker.js +54 -15
- package/dist/src/derivations/kinds.d.ts +34 -0
- package/dist/src/derivations/kinds.js +14 -0
- package/dist/src/derivations/types.d.ts +48 -0
- package/dist/src/derivations/types.js +1 -0
- package/dist/src/digest/derivation.d.ts +25 -0
- package/dist/src/digest/derivation.js +124 -0
- package/dist/src/digest/editorial.d.ts +9 -46
- package/dist/src/digest/editorial.js +57 -49
- package/dist/src/digest/endpoint.js +63 -27
- package/dist/src/digest/pipeline.d.ts +49 -28
- package/dist/src/digest/pipeline.js +369 -102
- package/dist/src/digest/schema.d.ts +11 -25
- package/dist/src/digest/schema.js +86 -18
- package/dist/src/errors.d.ts +46 -0
- package/dist/src/errors.js +117 -0
- package/dist/src/identity/query-policy.d.ts +0 -5
- package/dist/src/identity/query-policy.js +61 -9
- package/dist/src/identity/uri.d.ts +6 -5
- package/dist/src/identity/uri.js +37 -18
- package/dist/src/identity/visibility.d.ts +11 -1
- package/dist/src/identity/visibility.js +81 -17
- package/dist/src/importers/apply.js +104 -36
- package/dist/src/importers/custody.js +27 -9
- package/dist/src/importers/inspect.js +125 -38
- package/dist/src/importers/jungle-digest.d.ts +3 -6
- package/dist/src/importers/jungle-digest.js +196 -69
- package/dist/src/importers/jungle-store.d.ts +19 -6
- package/dist/src/importers/jungle-store.js +124 -28
- package/dist/src/importers/jungle.d.ts +14 -14
- package/dist/src/importers/jungle.js +142 -31
- package/dist/src/importers/manifest.js +57 -21
- package/dist/src/importers/verify-helper.js +18 -4
- package/dist/src/indexing/image.js +29 -10
- package/dist/src/indexing/index.d.ts +37 -6
- package/dist/src/indexing/index.js +360 -124
- package/dist/src/indexing/jobs.js +156 -47
- package/dist/src/indexing/prune-run.d.ts +2 -0
- package/dist/src/indexing/prune-run.js +69 -26
- package/dist/src/indexing/prune.d.ts +12 -3
- package/dist/src/indexing/prune.js +85 -35
- package/dist/src/indexing/runner.d.ts +2 -1
- package/dist/src/indexing/runner.js +83 -40
- package/dist/src/indexing/upgrade.d.ts +9 -0
- package/dist/src/indexing/upgrade.js +79 -0
- package/dist/src/inference/asr/bridge.js +6 -2
- package/dist/src/inference/asr/protocol.js +109 -19
- package/dist/src/inference/asr/runtime.js +58 -21
- package/dist/src/inference/asr/windows.js +9 -5
- package/dist/src/inference/embedding/index.d.ts +2 -6
- package/dist/src/inference/embedding/index.js +89 -29
- package/dist/src/ingest/attempt.d.ts +29 -0
- package/dist/src/ingest/attempt.js +55 -0
- package/dist/src/media/capture-helper.js +7 -2
- package/dist/src/media/capture.d.ts +2 -1
- package/dist/src/media/capture.js +124 -43
- package/dist/src/media/handler.d.ts +4 -2
- package/dist/src/media/handler.js +88 -70
- package/dist/src/media/transcribe.js +63 -21
- package/dist/src/metadata/article.js +49 -17
- package/dist/src/models/artifacts.d.ts +10 -8
- package/dist/src/models/artifacts.js +237 -106
- package/dist/src/models/catalog.d.ts +2 -5
- package/dist/src/models/catalog.js +94 -25
- package/dist/src/models/download.js +55 -15
- package/dist/src/models/runtime.d.ts +0 -2
- package/dist/src/models/runtime.js +69 -33
- package/dist/src/pdf/capture-helper.js +3 -1
- package/dist/src/pdf/capture.d.ts +2 -1
- package/dist/src/pdf/capture.js +95 -27
- package/dist/src/pdf/errors.js +12 -1
- package/dist/src/pdf/handler.d.ts +2 -1
- package/dist/src/pdf/handler.js +70 -71
- package/dist/src/pdf/index.d.ts +1 -3
- package/dist/src/pdf/index.js +0 -2
- package/dist/src/pdf/input.js +12 -7
- package/dist/src/pdf/normalize.js +80 -21
- package/dist/src/pdf/source-identity.js +3 -2
- package/dist/src/pdf/source.js +12 -8
- package/dist/src/pdf/verify-helper.js +15 -3
- package/dist/src/portability/backup.d.ts +2 -9
- package/dist/src/portability/backup.js +106 -22
- package/dist/src/portability/database.js +51 -17
- package/dist/src/portability/export.js +35 -9
- package/dist/src/portability/files.d.ts +1 -4
- package/dist/src/portability/files.js +127 -67
- package/dist/src/portability/gc.js +65 -22
- package/dist/src/publish/component.js +1 -1
- package/dist/src/publish/feed.d.ts +2 -2
- package/dist/src/publish/feed.js +75 -29
- package/dist/src/publish/identity.d.ts +5 -1
- package/dist/src/publish/identity.js +31 -11
- package/dist/src/publish/index.d.ts +2 -3
- package/dist/src/publish/index.js +34 -21
- package/dist/src/publish/projection.d.ts +2 -9
- package/dist/src/publish/projection.js +21 -14
- package/dist/src/search/extension.js +3 -1
- package/dist/src/search/hybrid.d.ts +3 -8
- package/dist/src/search/hybrid.js +45 -11
- package/dist/src/search/lexical.js +18 -4
- package/dist/src/search/query.js +56 -25
- package/dist/src/search/vector.js +37 -10
- package/dist/src/service/launch-agent.d.ts +5 -3
- package/dist/src/service/launch-agent.js +272 -83
- package/dist/src/service/lifetime.js +47 -14
- package/dist/src/service/loop.d.ts +3 -3
- package/dist/src/service/loop.js +47 -19
- package/dist/src/store/annotations.d.ts +32 -0
- package/dist/src/store/annotations.js +44 -0
- package/dist/src/store/backups.d.ts +18 -0
- package/dist/src/store/backups.js +110 -0
- package/dist/src/store/blobs.d.ts +24 -0
- package/dist/src/store/blobs.js +139 -0
- package/dist/src/store/changes.d.ts +5 -12
- package/dist/src/store/changes.js +108 -56
- package/dist/src/store/context.d.ts +15 -0
- package/dist/src/store/context.js +19 -0
- package/dist/src/store/derivations.d.ts +42 -0
- package/dist/src/store/derivations.js +104 -0
- package/dist/src/store/files.d.ts +0 -2
- package/dist/src/store/files.js +19 -24
- package/dist/src/store/ids.d.ts +30 -0
- package/dist/src/store/ids.js +34 -0
- package/dist/src/store/imports.d.ts +26 -0
- package/dist/src/store/imports.js +57 -0
- package/dist/src/store/index.d.ts +3 -186
- package/dist/src/store/index.js +2 -809
- package/dist/src/store/lease.d.ts +20 -0
- package/dist/src/store/lease.js +62 -0
- package/dist/src/store/library.d.ts +75 -0
- package/dist/src/store/library.js +174 -0
- package/dist/src/store/open.d.ts +7 -0
- package/dist/src/store/open.js +183 -0
- package/dist/src/store/queue.d.ts +65 -0
- package/dist/src/store/queue.js +327 -0
- package/dist/src/store/revisions.d.ts +12 -0
- package/dist/src/store/revisions.js +189 -0
- package/dist/src/store/search-index.d.ts +63 -0
- package/dist/src/store/search-index.js +190 -0
- package/dist/src/store/sync-ready.d.ts +6 -0
- package/dist/src/store/sync-ready.js +121 -0
- package/dist/src/store/types.d.ts +1 -5
- package/dist/src/store/types.js +1 -8
- package/dist/src/util/canonical.d.ts +2 -0
- package/dist/src/util/canonical.js +17 -0
- package/dist/src/util/exact.d.ts +2 -0
- package/dist/src/util/exact.js +9 -0
- package/dist/src/util/fsync.d.ts +4 -0
- package/dist/src/util/fsync.js +22 -0
- package/dist/src/util/hash.d.ts +4 -0
- package/dist/src/util/hash.js +8 -0
- package/dist/src/worker/basic.d.ts +0 -1
- package/dist/src/worker/basic.js +23 -7
- package/dist/src/worker/custody.d.ts +4 -1
- package/dist/src/worker/custody.js +111 -38
- package/dist/src/worker/engine.d.ts +2 -1
- package/dist/src/worker/engine.js +42 -20
- package/dist/src/worker/identity.js +13 -5
- package/dist/src/worker/journal.d.ts +1 -1
- package/dist/src/worker/journal.js +54 -24
- package/dist/src/worker/lock.d.ts +18 -0
- package/dist/src/worker/lock.js +196 -0
- package/dist/src/worker/runtime-gc.d.ts +4 -3
- package/dist/src/worker/runtime-gc.js +68 -41
- package/dist/src/worker/supervisor-child.js +19 -6
- package/dist/src/worker/supervisor.js +41 -8
- package/native/runtime-manifest.json +4 -4
- package/package.json +10 -2
- package/dist/src/digest/store.d.ts +0 -57
- package/dist/src/digest/store.js +0 -79
- package/dist/src/store/foundation.d.ts +0 -7
- package/dist/src/store/foundation.js +0 -7
package/dist/src/cli/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { lstat } from 'node:fs/promises';
|
|
2
2
|
import { readConfined } from '../acquisition/files.js';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { sha256 } from '../util/hash.js';
|
|
5
|
+
import { SpongeError } from '../errors.js';
|
|
6
6
|
/** Local references only. Tokens, cookies and passwords never belong in this file. */
|
|
7
7
|
export async function readConnections(root) {
|
|
8
8
|
const path = join(root, 'connections.json');
|
|
@@ -10,7 +10,7 @@ export async function readConnections(root) {
|
|
|
10
10
|
try {
|
|
11
11
|
const stat = await lstat(path);
|
|
12
12
|
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1 || stat.size > 65536 || (stat.mode & 0o077) !== 0)
|
|
13
|
-
throw new
|
|
13
|
+
throw new SpongeError('invalid-input');
|
|
14
14
|
bytes = await readConfined(root, 'connections.json', 65536);
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
@@ -23,23 +23,26 @@ export async function readConnections(root) {
|
|
|
23
23
|
config = JSON.parse(bytes.toString('utf8'));
|
|
24
24
|
}
|
|
25
25
|
catch {
|
|
26
|
-
throw new
|
|
26
|
+
throw new SpongeError('invalid-input');
|
|
27
27
|
}
|
|
28
28
|
if (config?.schemaVersion !== 1 || !Array.isArray(config.connections) || config.connections.length > 100)
|
|
29
|
-
throw new
|
|
29
|
+
throw new SpongeError('invalid-input');
|
|
30
30
|
const ids = new Set();
|
|
31
31
|
return config.connections.map((entry) => {
|
|
32
32
|
if (!entry || typeof entry.id !== 'string' || !/^[a-zA-Z0-9_-]{1,64}$/.test(entry.id) || ids.has(entry.id))
|
|
33
|
-
throw new
|
|
33
|
+
throw new SpongeError('invalid-input');
|
|
34
34
|
ids.add(entry.id);
|
|
35
35
|
let capture;
|
|
36
|
-
if (entry.kind === 'account' &&
|
|
36
|
+
if (entry.kind === 'account' &&
|
|
37
|
+
typeof entry.stateHome === 'string' &&
|
|
38
|
+
entry.stateHome.startsWith('/') &&
|
|
39
|
+
typeof entry.accountId === 'string')
|
|
37
40
|
capture = { kind: 'account', stateHome: entry.stateHome, accountId: entry.accountId };
|
|
38
41
|
else if (entry.kind === 'cdp' && typeof entry.endpoint === 'string')
|
|
39
42
|
capture = { kind: 'cdp', endpoint: entry.endpoint };
|
|
40
43
|
else
|
|
41
|
-
throw new
|
|
42
|
-
const realm = 'connection:' +
|
|
44
|
+
throw new SpongeError('invalid-input');
|
|
45
|
+
const realm = 'connection:' + sha256(JSON.stringify([entry.id, capture]));
|
|
43
46
|
return { id: entry.id, realm, capture };
|
|
44
47
|
});
|
|
45
48
|
}
|
package/dist/src/cli/digest.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Derivation, DigestReview } from '../
|
|
1
|
+
import type { Derivation, DigestReview } from '../digest/derivation.js';
|
|
2
2
|
/** Review targets: `all`, `gist`, `idea:N` or `quote:N.M` (0-based), comma-separated. */
|
|
3
3
|
export declare const reviewSpec: RegExp;
|
|
4
4
|
/**
|
package/dist/src/cli/digest.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SpongeError } from '../errors.js';
|
|
2
2
|
/** Review targets: `all`, `gist`, `idea:N` or `quote:N.M` (0-based), comma-separated. */
|
|
3
3
|
export const reviewSpec = /^(?:all|gist|idea:\d{1,2}|quote:\d{1,2}\.\d)(?:,(?:all|gist|idea:\d{1,2}|quote:\d{1,2}\.\d)){0,63}$/;
|
|
4
4
|
/**
|
|
@@ -7,19 +7,27 @@ export const reviewSpec = /^(?:all|gist|idea:\d{1,2}|quote:\d{1,2}\.\d)(?:,(?:al
|
|
|
7
7
|
*/
|
|
8
8
|
export function reviewFromSpec(d, accept, reject) {
|
|
9
9
|
if (accept === undefined && reject === undefined)
|
|
10
|
-
throw new
|
|
11
|
-
const ideas = d.output.ideas, review = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
throw new SpongeError('invalid-input');
|
|
11
|
+
const ideas = d.output.ideas, review = {
|
|
12
|
+
gist: d.review.gist,
|
|
13
|
+
ideas: ideas.map((_, i) => d.review.ideas?.[i] ?? null),
|
|
14
|
+
quotes: ideas.map((idea, i) => idea.quotes.map((_, j) => d.review.quotes?.[i]?.[j] ?? null)),
|
|
15
|
+
};
|
|
16
|
+
const parse = (spec) => {
|
|
17
|
+
if (spec === undefined)
|
|
18
|
+
return [];
|
|
19
|
+
if (!reviewSpec.test(spec))
|
|
20
|
+
throw new SpongeError('invalid-input');
|
|
21
|
+
return [...new Set(spec.split(','))];
|
|
22
|
+
};
|
|
15
23
|
const a = parse(accept), r = parse(reject);
|
|
16
|
-
if (a.some(t => r.includes(t)))
|
|
17
|
-
throw new
|
|
24
|
+
if (a.some((t) => r.includes(t)))
|
|
25
|
+
throw new SpongeError('invalid-input');
|
|
18
26
|
const set = (target, status) => {
|
|
19
27
|
if (target === 'all') {
|
|
20
28
|
review.gist = status;
|
|
21
29
|
review.ideas = review.ideas.map(() => status);
|
|
22
|
-
review.quotes = review.quotes.map(q => q.map(() => status));
|
|
30
|
+
review.quotes = review.quotes.map((q) => q.map(() => status));
|
|
23
31
|
return;
|
|
24
32
|
}
|
|
25
33
|
if (target === 'gist') {
|
|
@@ -28,20 +36,26 @@ export function reviewFromSpec(d, accept, reject) {
|
|
|
28
36
|
}
|
|
29
37
|
const [, kind, i, j] = /^(idea|quote):(\d+)(?:\.(\d+))?$/.exec(target), n = Number(i);
|
|
30
38
|
if (n >= ideas.length)
|
|
31
|
-
throw new
|
|
39
|
+
throw new SpongeError('invalid-input');
|
|
32
40
|
if (kind === 'idea') {
|
|
33
41
|
review.ideas[n] = status;
|
|
34
42
|
return;
|
|
35
43
|
}
|
|
36
44
|
if (Number(j) >= ideas[n].quotes.length)
|
|
37
|
-
throw new
|
|
45
|
+
throw new SpongeError('invalid-input');
|
|
38
46
|
review.quotes[n][Number(j)] = status;
|
|
39
47
|
};
|
|
40
|
-
for (const [targets, status] of [
|
|
48
|
+
for (const [targets, status] of [
|
|
49
|
+
[a, 'accepted'],
|
|
50
|
+
[r, 'rejected'],
|
|
51
|
+
])
|
|
41
52
|
for (const t of targets)
|
|
42
53
|
if (t === 'all')
|
|
43
54
|
set(t, status);
|
|
44
|
-
for (const [targets, status] of [
|
|
55
|
+
for (const [targets, status] of [
|
|
56
|
+
[a, 'accepted'],
|
|
57
|
+
[r, 'rejected'],
|
|
58
|
+
])
|
|
45
59
|
for (const t of targets)
|
|
46
60
|
if (t !== 'all')
|
|
47
61
|
set(t, status);
|
|
@@ -51,12 +65,20 @@ const mark = (s) => s === 'accepted' ? '[accepted]' : s === 'rejected' ? '[rejec
|
|
|
51
65
|
/** Plain-text digest with the review targets `sponge review` accepts. */
|
|
52
66
|
export function digestText(d) {
|
|
53
67
|
const o = d.output, producer = d.producer;
|
|
54
|
-
const lines = [
|
|
68
|
+
const lines = [
|
|
69
|
+
`Digest ${d.id} (${o.form}${producer?.model?.model ? `, ${producer.model.model}` : ''}${producer?.promptVersion ? `, ${producer.promptVersion}` : ''})`,
|
|
70
|
+
'',
|
|
71
|
+
`gist ${mark(d.review.gist)} ${o.gist.lead}`,
|
|
72
|
+
];
|
|
55
73
|
if (o.gist.context)
|
|
56
74
|
lines.push(` ${o.gist.context}`);
|
|
57
75
|
o.ideas.forEach((idea, i) => {
|
|
58
|
-
lines.push('', `idea:${i} ${mark(d.review.ideas?.[i])} ${idea.claim}`, ...(idea.kind || idea.voice
|
|
59
|
-
|
|
76
|
+
lines.push('', `idea:${i} ${mark(d.review.ideas?.[i])} ${idea.claim}`, ...(idea.kind || idea.voice
|
|
77
|
+
? [
|
|
78
|
+
` ${[idea.kind, idea.voice && (idea.voice.type === 'author' ? 'author' : `${idea.voice.type}: ${idea.voice.name}`)].filter(Boolean).join('; ')}`,
|
|
79
|
+
]
|
|
80
|
+
: []), ` ${idea.detail}`);
|
|
81
|
+
idea.quotes.forEach((q, j) => lines.push(` quote:${i}.${j} ${mark(d.review.quotes?.[i]?.[j])} “${q.text.replace(/\s+/g, ' ')}”${(q.attribution ?? q.speaker) ? ` (${q.attribution ?? q.speaker})` : ''}`));
|
|
60
82
|
});
|
|
61
83
|
lines.push('', `Tags: ${o.tags.join(', ') || 'none'}`);
|
|
62
84
|
return lines.join('\n');
|
package/dist/src/cli/import.js
CHANGED
|
@@ -2,12 +2,33 @@ import { importManifest } from '../importers/apply.js';
|
|
|
2
2
|
import { releasedBundleVerifier } from '../importers/inspect.js';
|
|
3
3
|
import { importJungle } from '../importers/jungle.js';
|
|
4
4
|
/** A source manifest is explicit; default execution produces a private dry-run report. */
|
|
5
|
-
export function importAction(store, path, options) {
|
|
5
|
+
export function importAction(store, path, options) {
|
|
6
|
+
return importManifest(store, path, options);
|
|
7
|
+
}
|
|
6
8
|
/** Jungle is read in place; only an applied import needs the capture runtime, to reverify each bundle. */
|
|
7
9
|
export function jungleAction(store, path, options) {
|
|
8
|
-
return importJungle(store, path, {
|
|
10
|
+
return importJungle(store, path, {
|
|
11
|
+
dryRun: options.dryRun,
|
|
12
|
+
limit: options.limit,
|
|
13
|
+
offset: options.offset,
|
|
14
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
15
|
+
...(options.runtime ? { verify: releasedBundleVerifier(options.runtime, store.root, options.signal) } : {}),
|
|
16
|
+
});
|
|
9
17
|
}
|
|
10
|
-
const tally = (m) => Object.entries(m)
|
|
18
|
+
const tally = (m) => Object.entries(m)
|
|
19
|
+
.sort()
|
|
20
|
+
.map(([k, n]) => `${k} ${n}`)
|
|
21
|
+
.join(', ') || 'none';
|
|
11
22
|
export function jungleText(r) {
|
|
12
|
-
return [
|
|
23
|
+
return [
|
|
24
|
+
`Jungle ${r.dryRun ? 'dry run (captures verified on --apply)' : 'import'}: ${r.entries.length} of ${r.notes} notes`,
|
|
25
|
+
`Items: ${r.counts.newItems} new, ${r.counts.existingItems} existing`,
|
|
26
|
+
`Editorial: ${tally(r.counts.editorial)}`,
|
|
27
|
+
`Digest v2: ${tally(r.counts.digest)}`,
|
|
28
|
+
...(Object.keys(r.counts.digestIssues).length ? [`Not convertible because: ${tally(r.counts.digestIssues)}`] : []),
|
|
29
|
+
`Quotes: ${r.counts.quotes.assigned} assigned, dropped ${tally(r.counts.quotes.dropped)}`,
|
|
30
|
+
`Visibility: ${tally(r.counts.visibility)}`,
|
|
31
|
+
`Skipped: ${tally(r.counts.skipped)}`,
|
|
32
|
+
...(r.nextOffset !== null ? [`Next offset: ${r.nextOffset}`] : []),
|
|
33
|
+
].join('\n');
|
|
13
34
|
}
|
|
@@ -8,3 +8,5 @@ export declare function indexAction(store: LibraryStore, action: string, id: str
|
|
|
8
8
|
dryRun?: boolean;
|
|
9
9
|
vacuum?: boolean;
|
|
10
10
|
}): Promise<Record<string, unknown>>;
|
|
11
|
+
/** `index status` with no generation: the active one's coverage and what is still to embed. */
|
|
12
|
+
export declare function overviewText(result: ReturnType<LibraryStore['index']['overview']>): string;
|
package/dist/src/cli/indexing.js
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
1
|
import { indexSpace } from '../inference/embedding/index.js';
|
|
2
2
|
import { drainIndexQueue } from '../indexing/runner.js';
|
|
3
|
-
import { StoreError } from '../store/index.js';
|
|
4
|
-
import { NativeCatalogError } from '../models/catalog.js';
|
|
5
3
|
import { pruneIndex } from '../indexing/prune-run.js';
|
|
4
|
+
import { SpongeError } from '../errors.js';
|
|
6
5
|
export async function indexAction(store, action, id, options = {}) {
|
|
7
6
|
if (action === 'status')
|
|
8
|
-
return { generation: store.
|
|
7
|
+
return id ? { generation: store.index.status(id) } : store.index.overview(options.profile);
|
|
9
8
|
if (action === 'rollback') {
|
|
10
|
-
const generation = store.
|
|
9
|
+
const generation = store.index.status(id);
|
|
11
10
|
if (!['active', 'retired'].includes(generation.state))
|
|
12
|
-
throw new
|
|
13
|
-
return { generation: store.
|
|
11
|
+
throw new SpongeError('invalid-input');
|
|
12
|
+
return { generation: store.index.activate(id) };
|
|
14
13
|
}
|
|
15
14
|
if (action === 'prune')
|
|
16
15
|
return { prune: await pruneIndex(store, { keep: options.keep, dryRun: options.dryRun, vacuum: options.vacuum }) };
|
|
17
16
|
if (!options.runtime)
|
|
18
|
-
throw new
|
|
17
|
+
throw new SpongeError('runtime-missing');
|
|
19
18
|
if (action === 'create') {
|
|
20
|
-
const space = indexSpace(options.runtime.helperSha256), generation = store.
|
|
21
|
-
|
|
19
|
+
const space = indexSpace(options.runtime.helperSha256), generation = store.index.create({
|
|
20
|
+
profileId: options.profile ?? 'default',
|
|
21
|
+
fingerprint: space.fingerprint,
|
|
22
|
+
identity: space.identity,
|
|
23
|
+
dimensions: space.dimensions,
|
|
24
|
+
});
|
|
25
|
+
return { generation, job: store.index.submitJob(generation.id) };
|
|
22
26
|
}
|
|
23
27
|
return { results: await drainIndexQueue(store, { runtime: options.runtime, signal: options.signal }) };
|
|
24
28
|
}
|
|
29
|
+
/** `index status` with no generation: the active one's coverage and what is still to embed. */
|
|
30
|
+
export function overviewText(result) {
|
|
31
|
+
const { generation: g, job } = result;
|
|
32
|
+
if (!g)
|
|
33
|
+
return 'No active index. Run sponge index create, then sponge index run.';
|
|
34
|
+
return [
|
|
35
|
+
`Active generation: ${g.id} (${g.profileId})`,
|
|
36
|
+
`Items: ${g.items}`,
|
|
37
|
+
`Chunks and images: ${g.completed} of ${g.expected} embedded, ${g.pending} pending`,
|
|
38
|
+
`Job: ${job ? `${job.id} ${job.state}${job.reason ? ` (${job.reason})` : ''}` : 'none'}`,
|
|
39
|
+
...(g.pending ? ['Run sponge index run (or let the worker) to embed only the pending ones.'] : []),
|
|
40
|
+
].join('\n');
|
|
41
|
+
}
|