@dan-ai-studio/dshopencodego 0.1.54 → 0.1.55
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/lib/client.js +1 -1
- package/lib/index.js +46 -15
- package/lib/types/catalog/go-doc-discovery.d.ts +28 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -1412,7 +1412,7 @@ function failureOf(error) {
|
|
|
1412
1412
|
}
|
|
1413
1413
|
return { message: "", retainPrevious: false };
|
|
1414
1414
|
}
|
|
1415
|
-
var POLL_MS = 6e4;
|
|
1415
|
+
var POLL_MS = 5 * 6e4;
|
|
1416
1416
|
var MAX_UNPRICED_IDS = 3;
|
|
1417
1417
|
function formatUSD(value) {
|
|
1418
1418
|
if (value === 0) return "$0.0000";
|
package/lib/index.js
CHANGED
|
@@ -42640,6 +42640,7 @@ var DISCOVERY_MAX_BYTES = 8 * 1024 * 1024;
|
|
|
42640
42640
|
var DISCOVERY_TIMEOUT_MS = 1e4;
|
|
42641
42641
|
var CACHE_FILE = "go-doc-paths.json";
|
|
42642
42642
|
var CACHE_VERSION = 1;
|
|
42643
|
+
var DISCOVERY_COOLDOWN_MS = 60 * 6e4;
|
|
42643
42644
|
function selectDocumentPaths(paths) {
|
|
42644
42645
|
const selected = [];
|
|
42645
42646
|
for (const path5 of paths) {
|
|
@@ -42700,6 +42701,31 @@ function rememberPaths(cacheDir, discovered) {
|
|
|
42700
42701
|
}
|
|
42701
42702
|
return merged;
|
|
42702
42703
|
}
|
|
42704
|
+
function discoveryAllowed(cacheDir) {
|
|
42705
|
+
if (cacheDir === void 0) return true;
|
|
42706
|
+
try {
|
|
42707
|
+
const parsed = JSON.parse(readFileSync(join2(cacheDir, CACHE_FILE), "utf8"));
|
|
42708
|
+
if (typeof parsed.lastAttemptAt !== "number") return true;
|
|
42709
|
+
return Date.now() - parsed.lastAttemptAt >= DISCOVERY_COOLDOWN_MS;
|
|
42710
|
+
} catch {
|
|
42711
|
+
return true;
|
|
42712
|
+
}
|
|
42713
|
+
}
|
|
42714
|
+
function rememberAttempt(cacheDir) {
|
|
42715
|
+
if (cacheDir === void 0) return;
|
|
42716
|
+
try {
|
|
42717
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
42718
|
+
const file = {
|
|
42719
|
+
version: CACHE_VERSION,
|
|
42720
|
+
paths: readCachedPaths(cacheDir),
|
|
42721
|
+
updatedAt: Date.now(),
|
|
42722
|
+
lastAttemptAt: Date.now()
|
|
42723
|
+
};
|
|
42724
|
+
writeFileSync(join2(cacheDir, CACHE_FILE), `${JSON.stringify(file, null, 2)}
|
|
42725
|
+
`, "utf8");
|
|
42726
|
+
} catch {
|
|
42727
|
+
}
|
|
42728
|
+
}
|
|
42703
42729
|
|
|
42704
42730
|
// src/catalog/go-doc-cache.ts
|
|
42705
42731
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
@@ -42776,11 +42802,11 @@ function protocolOfEndpoint(endpoint) {
|
|
|
42776
42802
|
return void 0;
|
|
42777
42803
|
}
|
|
42778
42804
|
function tableRows(lines, required) {
|
|
42779
|
-
const start = lines.findIndex((line) => line.startsWith("|") && line.includes(required));
|
|
42805
|
+
const start = lines.findIndex((line) => line.trimStart().startsWith("|") && line.includes(required));
|
|
42780
42806
|
if (start < 0) return [];
|
|
42781
42807
|
const rows = [];
|
|
42782
42808
|
for (let index = start + 2; index < lines.length; index++) {
|
|
42783
|
-
const line = lines[index] ?? "";
|
|
42809
|
+
const line = (lines[index] ?? "").trimStart();
|
|
42784
42810
|
if (!line.startsWith("|")) break;
|
|
42785
42811
|
rows.push(line.split("|").slice(1, -1).map((entry) => entry.trim()));
|
|
42786
42812
|
}
|
|
@@ -42863,18 +42889,23 @@ async function fetchGoDocument(signal, options = {}) {
|
|
|
42863
42889
|
failures.push(...cached.failures);
|
|
42864
42890
|
}
|
|
42865
42891
|
const discover = options.discover ?? discoverDocumentPaths;
|
|
42866
|
-
|
|
42867
|
-
|
|
42868
|
-
failures.push("the provider repository named no document");
|
|
42892
|
+
if (options.discover === void 0 && !discoveryAllowed(options.cacheDir)) {
|
|
42893
|
+
failures.push("the provider repository was not asked again; it was asked within the hour");
|
|
42869
42894
|
} else {
|
|
42870
|
-
|
|
42871
|
-
const
|
|
42872
|
-
if (
|
|
42873
|
-
failures.push("the provider repository named
|
|
42895
|
+
if (options.discover === void 0) rememberAttempt(options.cacheDir);
|
|
42896
|
+
const discovered = await discover(signal);
|
|
42897
|
+
if (discovered.length === 0) {
|
|
42898
|
+
failures.push("the provider repository named no document");
|
|
42874
42899
|
} else {
|
|
42875
|
-
const
|
|
42876
|
-
|
|
42877
|
-
|
|
42900
|
+
const merged = rememberPaths(options.cacheDir, discovered);
|
|
42901
|
+
const fresh = merged.filter((path5) => !GO_DOC_URLS.some((url) => url.endsWith(path5))).flatMap(mirrorsOf);
|
|
42902
|
+
if (fresh.length === 0) {
|
|
42903
|
+
failures.push("the provider repository named the path that was already tried");
|
|
42904
|
+
} else {
|
|
42905
|
+
const result = await readSources(fresh, signal, options.cacheDir);
|
|
42906
|
+
if (result.document !== void 0) return result.document;
|
|
42907
|
+
failures.push(...result.failures);
|
|
42908
|
+
}
|
|
42878
42909
|
}
|
|
42879
42910
|
}
|
|
42880
42911
|
throw new LlmError3(
|
|
@@ -43698,8 +43729,8 @@ function inferFamily(id) {
|
|
|
43698
43729
|
return ["grok", "gpt", "muse"].some((family) => lower.startsWith(family)) ? "openai-responses" : "openai-completions";
|
|
43699
43730
|
}
|
|
43700
43731
|
async function discoverCatalogModels(catalog, signal) {
|
|
43701
|
-
const snapshot2 = await catalog.snapshot(
|
|
43702
|
-
if (
|
|
43732
|
+
const snapshot2 = await catalog.snapshot(false, signal);
|
|
43733
|
+
if (snapshot2.listingFailure !== void 0) {
|
|
43703
43734
|
const detail = snapshot2.listingFailure instanceof LlmError4 ? snapshot2.listingFailure.message : "the live model listing is unreachable";
|
|
43704
43735
|
throw new LlmError4(`dshopencodego: ${detail}; refresh the model list to retry`, "DISCOVERY_FAILED", {
|
|
43705
43736
|
cause: snapshot2.listingFailure
|
|
@@ -46208,7 +46239,7 @@ function createUpdateChecker(deps) {
|
|
|
46208
46239
|
}
|
|
46209
46240
|
|
|
46210
46241
|
// src/update/version.ts
|
|
46211
|
-
var PLUGIN_VERSION = true ? "0.1.
|
|
46242
|
+
var PLUGIN_VERSION = true ? "0.1.55" : "0.0.0-dev";
|
|
46212
46243
|
|
|
46213
46244
|
// src/update/service.ts
|
|
46214
46245
|
import { TypertRemoteService as TypertRemoteService2 } from "@deepseek-ai/dsh-typert-protocol";
|
|
@@ -24,6 +24,16 @@
|
|
|
24
24
|
*/
|
|
25
25
|
/** A repository listing is large; the cap keeps a hostile response bounded. */
|
|
26
26
|
export declare const DISCOVERY_MAX_BYTES: number;
|
|
27
|
+
/**
|
|
28
|
+
* How long the repository listing waits before it is asked again.
|
|
29
|
+
*
|
|
30
|
+
* The listing is unauthenticated, and an unauthenticated GitHub API allows
|
|
31
|
+
* sixty requests an hour. The listing is also large — the provider's whole
|
|
32
|
+
* tree, thousands of entries. Asking it on every build would spend that
|
|
33
|
+
* budget on a provider that is merely unreachable, and would make every
|
|
34
|
+
* build slower for a question with the same answer.
|
|
35
|
+
*/
|
|
36
|
+
export declare const DISCOVERY_COOLDOWN_MS: number;
|
|
27
37
|
/**
|
|
28
38
|
* The repository paths a discovery run found.
|
|
29
39
|
*
|
|
@@ -76,3 +86,21 @@ export declare function readCachedPaths(cacheDir: string | undefined): readonly
|
|
|
76
86
|
* @returns the merged set, in the order it should be tried.
|
|
77
87
|
*/
|
|
78
88
|
export declare function rememberPaths(cacheDir: string | undefined, discovered: readonly string[]): readonly string[];
|
|
89
|
+
/**
|
|
90
|
+
* Whether the repository may be asked again.
|
|
91
|
+
*
|
|
92
|
+
* The question is worth at most an hour: a provider whose document has
|
|
93
|
+
* moved is found within the hour, and one that is merely down is not asked
|
|
94
|
+
* again every minute while it is down.
|
|
95
|
+
* @param cacheDir - the plugin's cache directory.
|
|
96
|
+
* @returns true when the repository may be asked.
|
|
97
|
+
*/
|
|
98
|
+
export declare function discoveryAllowed(cacheDir: string | undefined): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Record that the repository was asked, whether or not it answered.
|
|
101
|
+
*
|
|
102
|
+
* The attempt is what the budget is spent on, so a question that came back
|
|
103
|
+
* empty counts as a question.
|
|
104
|
+
* @param cacheDir - the plugin's cache directory.
|
|
105
|
+
*/
|
|
106
|
+
export declare function rememberAttempt(cacheDir: string | undefined): void;
|
package/package.json
CHANGED