@dan-ai-studio/dshopencodego 0.1.37 → 0.1.38
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.en.md +3 -3
- package/README.md +3 -3
- package/lib/client.js +2 -2
- package/lib/index.js +43528 -144
- package/lib/types/adapter.js +4 -1
- package/lib/types/catalog/index.js +11 -3
- package/lib/types/conversion/stream.js +1 -1
- package/lib/types/index.js +0 -5
- package/package.json +4 -6
- package/lib/types/circular-warning.d.ts +0 -49
- package/lib/types/circular-warning.js +0 -79
package/lib/types/adapter.js
CHANGED
|
@@ -64,7 +64,10 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
64
64
|
var e = new Error(message);
|
|
65
65
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
66
66
|
});
|
|
67
|
-
|
|
67
|
+
// Subpath imports: the package root also re-exports every provider's wire
|
|
68
|
+
// implementation, which this plugin does not mount. See catalog/index.ts.
|
|
69
|
+
import { getSupportedThinkingLevels } from '@earendil-works/pi-ai/models';
|
|
70
|
+
import { normalizeContext } from '@earendil-works/pi-ai/utils/transcript';
|
|
68
71
|
import { attributionHeaders, contentHasImage, LlmAdapter, LlmError, ReasoningEffortId, resolveRetryPolicy, } from '@deepseek-ai/dsh-llm';
|
|
69
72
|
import { idleWatchdog, timeoutOf } from '@deepseek-ai/dsh-timeout';
|
|
70
73
|
import { DISPLAY_NAME, PROVIDER_ID, OpencodeGoCatalog } from "./catalog/index.js";
|
|
@@ -18,8 +18,13 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @module @dan-ai-studio/dshopencodego/catalog
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// Subpath imports on purpose. The package root re-exports `./api/lazy.js` (every
|
|
22
|
+
// provider's wire implementation) and `providers/all.js` loads every provider's
|
|
23
|
+
// model data — 991 KB under `providers/data` alone. This plugin mounts three
|
|
24
|
+
// APIs for one provider, so each symbol is taken from the narrowest public entry
|
|
25
|
+
// that exports it. Types still come from the root: they vanish at build time.
|
|
26
|
+
import { createProvider } from '@earendil-works/pi-ai/models';
|
|
27
|
+
import { OPENCODE_GO_MODELS } from '@earendil-works/pi-ai/providers/opencode-go.models';
|
|
23
28
|
import { anthropicMessagesApi } from '@earendil-works/pi-ai/api/anthropic-messages.lazy';
|
|
24
29
|
import { openAICompletionsApi } from '@earendil-works/pi-ai/api/openai-completions.lazy';
|
|
25
30
|
import { openAIResponsesApi } from '@earendil-works/pi-ai/api/openai-responses.lazy';
|
|
@@ -41,7 +46,10 @@ export { decideProtocol, inferProtocol, protocolOfNpm } from "./protocol.js";
|
|
|
41
46
|
* `compat` is what keeps DeepSeek-family reasoning replay correct.
|
|
42
47
|
*/
|
|
43
48
|
function builtinModels(baseURL) {
|
|
44
|
-
|
|
49
|
+
// `OPENCODE_GO_MODELS` is the same table `getBuiltinModels('opencode-go')`
|
|
50
|
+
// reads — verified entry for entry — reached without loading the aggregate
|
|
51
|
+
// `models.generated.js` that carries every provider.
|
|
52
|
+
return new Map(Object.values(OPENCODE_GO_MODELS).map(model => [model.id, {
|
|
45
53
|
...model,
|
|
46
54
|
provider: PROVIDER_ID,
|
|
47
55
|
baseUrl: modelBaseURLFor(model.api, baseURL),
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { brandString } from '@deepseek-ai/dsh-brand';
|
|
11
11
|
import { CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, isContextWindowExceededError, isQuotaExceededError, LlmError, } from '@deepseek-ai/dsh-llm';
|
|
12
|
-
import { isContextOverflow } from '@earendil-works/pi-ai';
|
|
12
|
+
import { isContextOverflow } from '@earendil-works/pi-ai/utils/overflow';
|
|
13
13
|
import { toPiReplayState } from "./replay.js";
|
|
14
14
|
/**
|
|
15
15
|
* Map pi-ai usage (reasoning already folded into output).
|
package/lib/types/index.js
CHANGED
|
@@ -34,7 +34,6 @@ import { LlmError } from '@deepseek-ai/dsh-llm';
|
|
|
34
34
|
import { OpencodeGoAdapter } from "./adapter.js";
|
|
35
35
|
import { DISPLAY_NAME, PROVIDER_ID, discoverCatalogModels } from "./catalog/index.js";
|
|
36
36
|
import { assertBaseURL, PlainConfig, readConfig } from "./config.js";
|
|
37
|
-
import { filterCircularWarnings } from "./circular-warning.js";
|
|
38
37
|
import { registerRemotes } from "./remotes.js";
|
|
39
38
|
import { OpencodeGoCatalogService } from "./catalog/service.js";
|
|
40
39
|
import { OpencodeGoUpdateService } from "./update/index.js";
|
|
@@ -61,10 +60,6 @@ function isLiveConfig(raw) {
|
|
|
61
60
|
* @param raw - the loader's live config, or a plain object in tests.
|
|
62
61
|
*/
|
|
63
62
|
export function apply(ctx, raw) {
|
|
64
|
-
// First statement on purpose: this is as early as a filter can be installed,
|
|
65
|
-
// since ES imports are hoisted and `pi-ai` is evaluated before any of this
|
|
66
|
-
// runs. See the module for why the warning is safe to drop.
|
|
67
|
-
filterCircularWarnings();
|
|
68
63
|
const live = isLiveConfig(raw) ? raw : undefined;
|
|
69
64
|
const constant = live === undefined ? PlainConfig((raw ?? {})) : undefined;
|
|
70
65
|
const current = () => (live === undefined ? constant : readConfig(live));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dan-ai-studio/dshopencodego",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"description": "OpenCode Go provider for DeepSeek Harness: live gateway catalog, per-conversation session header, usage",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -66,10 +66,6 @@
|
|
|
66
66
|
"prepare": "npm run build",
|
|
67
67
|
"prepack": "npm run build"
|
|
68
68
|
},
|
|
69
|
-
"dependencies": {
|
|
70
|
-
"@deepseek-ai/schemastery": "~3.18.5-alpha.2",
|
|
71
|
-
"@earendil-works/pi-ai": "~1.3.0"
|
|
72
|
-
},
|
|
73
69
|
"peerDependencies": {
|
|
74
70
|
"@deepseek-ai/cordis": "4.0.4 || 4.0.5-alpha.1 || 4.0.5-alpha.2",
|
|
75
71
|
"@deepseek-ai/dsh-api-remotes": ">=0.2.0-rc.1 <0.3.0",
|
|
@@ -145,7 +141,9 @@
|
|
|
145
141
|
"react": "^18.3.1",
|
|
146
142
|
"react-dom": "^18.3.1",
|
|
147
143
|
"typescript": "^6.0.3",
|
|
148
|
-
"vitest": "^4.1.8"
|
|
144
|
+
"vitest": "^4.1.8",
|
|
145
|
+
"@earendil-works/pi-ai": "~1.3.0",
|
|
146
|
+
"@deepseek-ai/schemastery": "~3.18.5-alpha.2"
|
|
149
147
|
},
|
|
150
148
|
"keywords": [
|
|
151
149
|
"deepseek-harness",
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Silence Node's circular-dependency property warning.
|
|
3
|
-
*
|
|
4
|
-
* `@earendil-works/pi-ai` named-imports `partial-json`:
|
|
5
|
-
*
|
|
6
|
-
* ```js
|
|
7
|
-
* import { parse as partialParse } from "partial-json";
|
|
8
|
-
* ```
|
|
9
|
-
*
|
|
10
|
-
* Resolving a named import from CommonJS makes Node enumerate the module's
|
|
11
|
-
* exports, and `partial-json`'s `index.js` and `options.js` require each
|
|
12
|
-
* other — so the enumeration reads `Allow` while its own module is still
|
|
13
|
-
* initialising. Node prints, once per read:
|
|
14
|
-
*
|
|
15
|
-
* Accessing non-existent property 'Allow' of module exports inside circular dependency
|
|
16
|
-
*
|
|
17
|
-
* The read is harmless: `parse` resolves correctly, the value is present once
|
|
18
|
-
* the pair settles, and every request this plugin makes was verified against
|
|
19
|
-
* that behaviour. What makes it worth filtering is the volume — a plugin
|
|
20
|
-
* reload re-runs the graph, and each enumeration prints again, so an update
|
|
21
|
-
* leaves a flood of identical lines in the host's log. A wall of warnings
|
|
22
|
-
* nobody can act on is how a real one gets missed.
|
|
23
|
-
*
|
|
24
|
-
* Why a message filter rather than a supported switch: Node emits this one
|
|
25
|
-
* with a bare string and **no type**, so `--disable-warning` (which matches a
|
|
26
|
-
* code or type) cannot select it. Matching the message prefix is the narrowest
|
|
27
|
-
* filter available, and it drops exactly one message — everything else reaches
|
|
28
|
-
* the default handler untouched.
|
|
29
|
-
*
|
|
30
|
-
* @module @dan-ai-studio/dshopencodego/circular-warning
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* Whether this warning is the circular-dependency one.
|
|
34
|
-
*
|
|
35
|
-
* Exported so the rule can be tested directly, without installing anything.
|
|
36
|
-
* @param warning - the first argument Node passes to `process.emitWarning`.
|
|
37
|
-
* @returns true when the warning is Node's circular-dependency notice.
|
|
38
|
-
*/
|
|
39
|
-
export declare function dropsCircularWarning(warning: unknown): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Install the filter. Safe to call on every mount; the first call wins.
|
|
42
|
-
*
|
|
43
|
-
* Called from `apply` rather than from module scope because ES module imports
|
|
44
|
-
* are hoisted — by the time any statement of this bundle runs, `pi-ai` has
|
|
45
|
-
* already been evaluated, so the first enumeration cannot be intercepted. Every
|
|
46
|
-
* later one can, and a reload is exactly what produces the flood.
|
|
47
|
-
* @param target - the process-like object to patch; defaults to the real one.
|
|
48
|
-
*/
|
|
49
|
-
export declare function filterCircularWarnings(target?: Pick<typeof process, 'emitWarning'>): void;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Silence Node's circular-dependency property warning.
|
|
3
|
-
*
|
|
4
|
-
* `@earendil-works/pi-ai` named-imports `partial-json`:
|
|
5
|
-
*
|
|
6
|
-
* ```js
|
|
7
|
-
* import { parse as partialParse } from "partial-json";
|
|
8
|
-
* ```
|
|
9
|
-
*
|
|
10
|
-
* Resolving a named import from CommonJS makes Node enumerate the module's
|
|
11
|
-
* exports, and `partial-json`'s `index.js` and `options.js` require each
|
|
12
|
-
* other — so the enumeration reads `Allow` while its own module is still
|
|
13
|
-
* initialising. Node prints, once per read:
|
|
14
|
-
*
|
|
15
|
-
* Accessing non-existent property 'Allow' of module exports inside circular dependency
|
|
16
|
-
*
|
|
17
|
-
* The read is harmless: `parse` resolves correctly, the value is present once
|
|
18
|
-
* the pair settles, and every request this plugin makes was verified against
|
|
19
|
-
* that behaviour. What makes it worth filtering is the volume — a plugin
|
|
20
|
-
* reload re-runs the graph, and each enumeration prints again, so an update
|
|
21
|
-
* leaves a flood of identical lines in the host's log. A wall of warnings
|
|
22
|
-
* nobody can act on is how a real one gets missed.
|
|
23
|
-
*
|
|
24
|
-
* Why a message filter rather than a supported switch: Node emits this one
|
|
25
|
-
* with a bare string and **no type**, so `--disable-warning` (which matches a
|
|
26
|
-
* code or type) cannot select it. Matching the message prefix is the narrowest
|
|
27
|
-
* filter available, and it drops exactly one message — everything else reaches
|
|
28
|
-
* the default handler untouched.
|
|
29
|
-
*
|
|
30
|
-
* @module @dan-ai-studio/dshopencodego/circular-warning
|
|
31
|
-
*/
|
|
32
|
-
/** The invariable opening of Node's message; the property name varies. */
|
|
33
|
-
const PREFIX = 'Accessing non-existent property';
|
|
34
|
-
/**
|
|
35
|
-
* Marks the process as filtered.
|
|
36
|
-
*
|
|
37
|
-
* A `Symbol.for` key so it survives a plugin reload: the host may evaluate
|
|
38
|
-
* this bundle again, and the filter must be installed once for the process
|
|
39
|
-
* rather than once per evaluation.
|
|
40
|
-
*/
|
|
41
|
-
const INSTALLED = Symbol.for('dshopencodego/circular-warning-filter');
|
|
42
|
-
/** The text of a warning Node may pass as a string or as an `Error`. */
|
|
43
|
-
function warningText(warning) {
|
|
44
|
-
if (typeof warning === 'string')
|
|
45
|
-
return warning;
|
|
46
|
-
const message = warning?.message;
|
|
47
|
-
return String(message ?? warning);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Whether this warning is the circular-dependency one.
|
|
51
|
-
*
|
|
52
|
-
* Exported so the rule can be tested directly, without installing anything.
|
|
53
|
-
* @param warning - the first argument Node passes to `process.emitWarning`.
|
|
54
|
-
* @returns true when the warning is Node's circular-dependency notice.
|
|
55
|
-
*/
|
|
56
|
-
export function dropsCircularWarning(warning) {
|
|
57
|
-
return warningText(warning).startsWith(PREFIX);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Install the filter. Safe to call on every mount; the first call wins.
|
|
61
|
-
*
|
|
62
|
-
* Called from `apply` rather than from module scope because ES module imports
|
|
63
|
-
* are hoisted — by the time any statement of this bundle runs, `pi-ai` has
|
|
64
|
-
* already been evaluated, so the first enumeration cannot be intercepted. Every
|
|
65
|
-
* later one can, and a reload is exactly what produces the flood.
|
|
66
|
-
* @param target - the process-like object to patch; defaults to the real one.
|
|
67
|
-
*/
|
|
68
|
-
export function filterCircularWarnings(target = process) {
|
|
69
|
-
const host = target;
|
|
70
|
-
if (host[INSTALLED] === true)
|
|
71
|
-
return;
|
|
72
|
-
host[INSTALLED] = true;
|
|
73
|
-
const original = target.emitWarning.bind(target);
|
|
74
|
-
target.emitWarning = ((warning, ...rest) => {
|
|
75
|
-
if (dropsCircularWarning(warning))
|
|
76
|
-
return;
|
|
77
|
-
original(warning, ...rest);
|
|
78
|
-
});
|
|
79
|
-
}
|