usegrunt 0.6.5 → 0.6.7
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 +20 -7
- package/dist/local/beatapi-setup.js +83 -0
- package/dist/local/beatapi.js +298 -0
- package/dist/local/clixad-preload.js +177 -0
- package/dist/local/clixad-setup.js +345 -0
- package/dist/local/clixad.js +398 -0
- package/dist/local/data-sharing.js +18 -2
- package/dist/local/fallback-setup.js +112 -33
- package/dist/local/freebuff.js +5 -1
- package/dist/local/freellmapi.js +3 -5
- package/dist/local/kilo.js +209 -0
- package/dist/local/main.js +62 -20
- package/dist/local/managed-router.js +4 -2
- package/dist/local/opencode.js +38 -18
- package/dist/local/parallel.js +2 -0
- package/dist/local/perch-process.js +377 -0
- package/dist/local/perch-setup.js +297 -0
- package/dist/local/perch.js +480 -0
- package/dist/local/pollinations-setup.js +109 -0
- package/dist/local/pollinations.js +324 -0
- package/dist/local/registry.js +4 -4
- package/dist/local/routing.js +5 -1
- package/dist/local/setup-session.js +232 -0
- package/dist/local/setup.js +343 -62
- package/dist/local/source.js +34 -4
- package/dist/local/wizard.js +283 -109
- package/dist/registry/adapters.json +57 -33
- package/dist/registry.js +4 -2
- package/package.json +1 -1
package/dist/local/source.js
CHANGED
|
@@ -13,20 +13,27 @@ export class SourceError extends Error {
|
|
|
13
13
|
export const answeredBy = new WeakMap();
|
|
14
14
|
export class Sources {
|
|
15
15
|
sources;
|
|
16
|
+
disabledModels;
|
|
16
17
|
router;
|
|
17
18
|
// Adapters whose background setup has not finished yet.
|
|
18
19
|
preparing = new Set();
|
|
19
|
-
|
|
20
|
+
// Foreground signups must not probe or dispatch incomplete sources. Routine
|
|
21
|
+
// background checks remain metadata and do not interrupt already-bound work.
|
|
22
|
+
pending = new Set();
|
|
23
|
+
// An exact-ID setup probe may run without admitting that source to the pool.
|
|
24
|
+
verifying = new Set();
|
|
25
|
+
constructor(sources, routing, disabledModels = new Set()) {
|
|
20
26
|
this.sources = sources;
|
|
21
|
-
|
|
27
|
+
this.disabledModels = disabledModels;
|
|
28
|
+
if ((!sources.length && !disabledModels.size) || new Set(sources.map(s => s.id)).size !== sources.length)
|
|
22
29
|
throw new Error('Configure distinct grunt sources');
|
|
23
30
|
if (routing)
|
|
24
|
-
this.router = new StickyRouter(sources, routing);
|
|
31
|
+
this.router = new StickyRouter(sources, { ...routing, pending: this.pending });
|
|
25
32
|
}
|
|
26
33
|
healthy(id) { this.router?.healthy(id); }
|
|
27
34
|
async models() {
|
|
28
35
|
const available = await Promise.all(this.sources.map(async (s) => {
|
|
29
|
-
if (this.router && !this.router.listed(s.id) || !await s.available())
|
|
36
|
+
if (this.pending.has(s.id) || this.router && !this.router.listed(s.id) || !await s.available())
|
|
30
37
|
return null;
|
|
31
38
|
if (this.router?.needsHealthCheck(s.id) && await s.healthCheck?.().catch(() => false))
|
|
32
39
|
this.healthy(s.id);
|
|
@@ -35,6 +42,27 @@ export class Sources {
|
|
|
35
42
|
return [...(this.router ? ['grunt'] : []), 'milo', ...available.filter((id) => id !== null)];
|
|
36
43
|
}
|
|
37
44
|
async complete(request, signal) {
|
|
45
|
+
signal.throwIfAborted();
|
|
46
|
+
if (this.disabledModels.has(request.model))
|
|
47
|
+
throw new SourceError('refused', `${request.model} routing is disabled`);
|
|
48
|
+
if (this.pending.has(request.model)) {
|
|
49
|
+
if (!this.verifying.has(request.model))
|
|
50
|
+
throw new SourceError('not_installed', `${request.model} setup is still in progress`);
|
|
51
|
+
const source = this.sources.find(source => source.id === request.model);
|
|
52
|
+
if (!source)
|
|
53
|
+
throw new SourceError('not_installed', `No source for model ${request.model}`);
|
|
54
|
+
if (this.router && !this.router.listed(source.id))
|
|
55
|
+
throw new SourceError('not_installed', `${request.model} is not in the current provider registry`);
|
|
56
|
+
if (this.router && !this.router.supportsInput(source.id, request.imageInput))
|
|
57
|
+
throw new SourceError('refused', `${request.model} does not support this input modality`);
|
|
58
|
+
// A setup probe is one exact-source call, never sticky failover or a
|
|
59
|
+
// retry of a provider refusal. The source retains every normal guard.
|
|
60
|
+
const completion = await source.complete(request, signal);
|
|
61
|
+
signal.throwIfAborted();
|
|
62
|
+
this.router?.verified(source.id);
|
|
63
|
+
answeredBy.set(completion, source.id);
|
|
64
|
+
return completion;
|
|
65
|
+
}
|
|
38
66
|
if (this.router)
|
|
39
67
|
return this.router.complete(request, signal);
|
|
40
68
|
const known = this.sources.some(s => s.id === request.model);
|
|
@@ -44,6 +72,8 @@ export class Sources {
|
|
|
44
72
|
let last = new SourceError('not_installed', `No source for model ${request.model}`);
|
|
45
73
|
for (const source of candidates) {
|
|
46
74
|
signal.throwIfAborted();
|
|
75
|
+
if (this.pending.has(source.id))
|
|
76
|
+
continue;
|
|
47
77
|
let completion;
|
|
48
78
|
try {
|
|
49
79
|
completion = await source.complete(request, signal);
|