@neuralnomads/codenomad-dev 0.18.0-dev-20260716-40cee071 → 0.18.0-dev-20260718-8f6aa44b
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/dist/auth/manager.js +1 -1
- package/dist/filesystem/__tests__/search-cache.test.js +5 -5
- package/dist/filesystem/search-cache.js +1 -1
- package/dist/index.js +25 -0
- package/dist/index.test.js +40 -10
- package/dist/opencode-update/service.js +150 -0
- package/dist/opencode-update/service.test.js +107 -0
- package/dist/server/__tests__/remote-proxy.test.js +64 -56
- package/dist/server/http-server.js +7 -1
- package/dist/server/remote-proxy.js +68 -98
- package/dist/server/routes/opencode-update.js +37 -0
- package/dist/server/routes/opencode-update.test.js +34 -0
- package/dist/server/routes/remote-servers.js +1 -1
- package/dist/server/routes/workspaces.test.js +38 -0
- package/dist/server/tls.js +2 -2
- package/dist/settings/binaries.test.js +2 -7
- package/dist/shutdown.js +67 -59
- package/dist/shutdown.test.js +115 -78
- package/dist/ui/remote-ui.js +2 -2
- package/dist/usage/providers/api-key.js +3 -3
- package/dist/usage/providers/google.js +1 -1
- package/dist/usage/providers/special.js +3 -3
- package/dist/usage/service.js +1 -1
- package/dist/usage/service.test.js +1 -1
- package/dist/usage/shared.js +4 -4
- package/dist/usage/shared.test.js +1 -1
- package/dist/workspaces/__tests__/spawn.test.js +2 -2
- package/dist/workspaces/__tests__/workspace-identity.test.js +94 -286
- package/dist/workspaces/binary-path.test.js +10 -0
- package/dist/workspaces/instance-client.js +4 -3
- package/dist/workspaces/launch-cleanup.test.js +21 -25
- package/dist/workspaces/manager.js +300 -351
- package/dist/workspaces/manager.test.js +209 -237
- package/dist/workspaces/process-identity.darwin.test.js +88 -0
- package/dist/workspaces/process-identity.js +172 -149
- package/dist/workspaces/process-identity.test.js +86 -140
- package/dist/workspaces/runtime.js +261 -373
- package/dist/workspaces/runtime.test.js +222 -547
- package/package.json +1 -1
- package/public/assets/{FilesTab-BjztpSdj.js → FilesTab-B0-DlSCT.js} +2 -2
- package/public/assets/{GitChangesTab-B9XraSoR.js → GitChangesTab-CxjbNBVr.js} +2 -2
- package/public/assets/{SplitFilePanel-Cu_5-Z-E.js → SplitFilePanel-CLQb-6uX.js} +1 -1
- package/public/assets/{StatusTab-D_IE79r-.js → StatusTab-CBGAuhmp.js} +1 -1
- package/public/assets/{align-justify-BKS9gyRk.js → align-justify-s5mnjsP0.js} +1 -1
- package/public/assets/{bundle-full-CXGXXlzR.js → bundle-full-lwIMY5om.js} +1 -1
- package/public/assets/{diff-viewer-CSNOYoEB.js → diff-viewer-CDtmFe6e.js} +1 -1
- package/public/assets/index-6ABz_Izb.js +1 -0
- package/public/assets/index-BPdjM9ZI.css +1 -0
- package/public/assets/index-BQK8um1r.js +1 -0
- package/public/assets/index-BkUAI4ZY.js +1 -0
- package/public/assets/index-D8bkUvEd.js +2 -0
- package/public/assets/index-DY_sbCt9.js +1 -0
- package/public/assets/index-DhmUOdAI.js +1 -0
- package/public/assets/{index-sLe9hEfQ.js → index-DupnEKCQ.js} +1 -1
- package/public/assets/index-HhZzWWha.js +1 -0
- package/public/assets/{index-DVc4ls8c.js → index-lBAEWdAF.js} +1 -1
- package/public/assets/index-nVII4VJz.js +1 -0
- package/public/assets/index-p1Sble5V.js +1 -0
- package/public/assets/{loading-CDmt9OJU.js → loading-h8DvUqqc.js} +1 -1
- package/public/assets/main-BxUSjoWA.js +68 -0
- package/public/assets/{markdown-1ZLSxCFT.js → markdown-Djug_spc.js} +3 -3
- package/public/assets/{monaco-viewer-D6JgH76W.js → monaco-viewer-lkUcsK65.js} +2 -2
- package/public/assets/{tool-call-CyXb63LH.js → tool-call-C4YH896w.js} +3 -3
- package/public/assets/{unified-picker-DCCdSVwI.js → unified-picker-DwNZOVlY.js} +1 -1
- package/public/assets/{wrap-text-pNMdTIq3.js → wrap-text-BLVYxvcj.js} +1 -1
- package/public/index.html +4 -4
- package/public/loading.html +4 -4
- package/public/sw.js +1 -1
- package/dist/workspaces/launch-cleanup.js +0 -132
- package/public/assets/index-B3YjNCh4.js +0 -1
- package/public/assets/index-B3ZD2_SU.js +0 -1
- package/public/assets/index-Bh2ofaQo.js +0 -1
- package/public/assets/index-CM0c9xRZ.js +0 -1
- package/public/assets/index-CdDxouJl.js +0 -2
- package/public/assets/index-D06Y2cFq.js +0 -1
- package/public/assets/index-PmE51vPh.js +0 -1
- package/public/assets/index-Qj63IiSj.css +0 -1
- package/public/assets/index-VY_zwmsG.js +0 -1
- package/public/assets/index-qiiH7egV.js +0 -1
- package/public/assets/main-CTN6Wwz1.js +0 -68
package/dist/shutdown.test.js
CHANGED
|
@@ -1,110 +1,147 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
|
-
import { createServerShutdownHandler, orchestrateServerShutdown,
|
|
4
|
-
const logger = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
stopInstanceEventBridge: () => undefined,
|
|
12
|
-
stopSidecars: () => undefined,
|
|
13
|
-
stopClientConnections: () => undefined,
|
|
14
|
-
stopRemoteProxySessions: () => undefined,
|
|
15
|
-
stopWorkspaces: () => undefined,
|
|
16
|
-
stopHttpServers: () => undefined,
|
|
17
|
-
stopReleaseMonitor: () => undefined,
|
|
18
|
-
...overrides,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
3
|
+
import { createServerShutdownHandler, orchestrateServerShutdown, SERVER_SHUTDOWN_COMPLETE, SERVER_SHUTDOWN_INCOMPLETE, } from "./shutdown";
|
|
4
|
+
const logger = { info() { }, warn() { }, error() { } };
|
|
5
|
+
const operations = (overrides = {}) => ({
|
|
6
|
+
stopInstanceEventBridge() { }, stopSidecars() { }, stopClientConnections() { },
|
|
7
|
+
stopRemoteProxySessions() { }, stopWorkspaces() { }, stopHttpServers() { }, stopReleaseMonitor() { },
|
|
8
|
+
...overrides,
|
|
9
|
+
});
|
|
21
10
|
describe("server shutdown orchestration", () => {
|
|
22
|
-
it("retries workspace cleanup
|
|
11
|
+
it("retries workspace cleanup and preserves shutdown order", async () => {
|
|
12
|
+
const calls = [];
|
|
23
13
|
let attempts = 0;
|
|
24
14
|
await orchestrateServerShutdown(operations({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
}), logger);
|
|
31
|
-
assert.equal(attempts, 2);
|
|
32
|
-
});
|
|
33
|
-
it("stops remote proxy sessions before workspace and HTTP shutdown", async () => {
|
|
34
|
-
const closed = [];
|
|
35
|
-
await orchestrateServerShutdown(operations({
|
|
36
|
-
stopRemoteProxySessions: () => { closed.push("remote-proxy"); },
|
|
37
|
-
stopWorkspaces: () => { closed.push("workspaces"); },
|
|
38
|
-
stopHttpServers: () => { closed.push("http"); },
|
|
15
|
+
stopRemoteProxySessions: () => { calls.push("remote-proxy"); },
|
|
16
|
+
stopWorkspaces: () => { calls.push(`workspaces-${++attempts}`); if (attempts === 1)
|
|
17
|
+
throw new Error("still alive"); },
|
|
18
|
+
stopHttpServers: () => { calls.push("http"); },
|
|
39
19
|
}), logger);
|
|
40
|
-
assert.deepEqual(
|
|
20
|
+
assert.deepEqual(calls, ["workspaces-1", "remote-proxy", "workspaces-2", "http"]);
|
|
41
21
|
});
|
|
42
|
-
it("closes
|
|
22
|
+
it("closes remaining resources and aggregates the concrete current error", async () => {
|
|
23
|
+
const failure = new Error("workspace abc POSIX process group is still alive");
|
|
43
24
|
const closed = [];
|
|
44
|
-
const cleanupFailure = new Error("workspace abc POSIX process group is still alive");
|
|
45
25
|
let attempts = 0;
|
|
46
26
|
await assert.rejects(orchestrateServerShutdown(operations({
|
|
47
|
-
stopWorkspaces: () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
stopHttpServers: () => {
|
|
52
|
-
closed.push("http");
|
|
53
|
-
},
|
|
54
|
-
stopReleaseMonitor: () => {
|
|
55
|
-
closed.push("release-monitor");
|
|
56
|
-
},
|
|
27
|
+
stopWorkspaces: () => { attempts++; throw failure; },
|
|
28
|
+
stopHttpServers: () => { closed.push("http"); },
|
|
29
|
+
stopReleaseMonitor: () => { closed.push("release-monitor"); },
|
|
57
30
|
}), logger), (error) => {
|
|
58
|
-
assert.ok(error instanceof
|
|
59
|
-
assert.equal(error.
|
|
60
|
-
assert.
|
|
31
|
+
assert.ok(error instanceof AggregateError);
|
|
32
|
+
assert.equal(error.errors.length, 1);
|
|
33
|
+
assert.match(error.errors[0].message, /^stopWorkspaces failed:/);
|
|
34
|
+
assert.strictEqual(error.errors[0].cause, failure);
|
|
61
35
|
return true;
|
|
62
36
|
});
|
|
63
|
-
assert.
|
|
64
|
-
|
|
37
|
+
assert.deepEqual([attempts, closed], [2, ["http", "release-monitor"]]);
|
|
38
|
+
});
|
|
39
|
+
it("starts workspace cleanup without waiting for preliminary shutdown", async () => {
|
|
40
|
+
let releasePreliminary;
|
|
41
|
+
const preliminary = new Promise((resolve) => { releasePreliminary = resolve; });
|
|
42
|
+
let workspaceStarted = false;
|
|
43
|
+
const shutdown = orchestrateServerShutdown(operations({
|
|
44
|
+
stopRemoteProxySessions: () => preliminary,
|
|
45
|
+
stopWorkspaces: () => { workspaceStarted = true; },
|
|
46
|
+
}), logger);
|
|
47
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
48
|
+
assert.equal(workspaceStarted, true);
|
|
49
|
+
releasePreliminary();
|
|
50
|
+
await shutdown;
|
|
65
51
|
});
|
|
66
52
|
});
|
|
67
53
|
describe("server shutdown signal boundary", () => {
|
|
68
|
-
it("
|
|
54
|
+
it("reports incomplete cleanup and holds for final tree enforcement", async () => {
|
|
69
55
|
const calls = [];
|
|
70
56
|
const exits = [];
|
|
57
|
+
const statuses = [];
|
|
58
|
+
let releaseHold;
|
|
59
|
+
const hold = new Promise((resolve) => { releaseHold = resolve; });
|
|
71
60
|
const handler = createServerShutdownHandler({
|
|
72
|
-
shutdown: async () => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
error: () => calls.push("error"),
|
|
80
|
-
},
|
|
81
|
-
forceExit: (code) => {
|
|
82
|
-
calls.push("force-exit");
|
|
83
|
-
exits.push(code);
|
|
84
|
-
},
|
|
61
|
+
shutdown: async () => { calls.push("cleanup"); throw new Error("retained child survived"); },
|
|
62
|
+
logger: { info: () => calls.push("info"), warn() { }, error: () => calls.push("error") },
|
|
63
|
+
forceExit: (code) => { calls.push("force-exit"); exits.push(code); },
|
|
64
|
+
setExitCode: () => undefined,
|
|
65
|
+
reportStatus: (status) => statuses.push(status),
|
|
66
|
+
holdAfterFailure: () => hold,
|
|
67
|
+
retryAttempts: 0,
|
|
85
68
|
});
|
|
86
|
-
|
|
69
|
+
const pending = handler("SIGTERM");
|
|
70
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
71
|
+
assert.deepEqual([exits, statuses, calls], [[], [SERVER_SHUTDOWN_INCOMPLETE], ["info", "cleanup", "error", "error"]]);
|
|
72
|
+
handler("SIGTERM");
|
|
87
73
|
assert.deepEqual(exits, [1]);
|
|
88
|
-
|
|
74
|
+
releaseHold();
|
|
75
|
+
await pending;
|
|
89
76
|
});
|
|
90
|
-
it("
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
77
|
+
it("reports complete cleanup before allowing natural exit", async () => {
|
|
78
|
+
const statuses = [], exitCodes = [];
|
|
79
|
+
const handler = createServerShutdownHandler({
|
|
80
|
+
shutdown: async () => undefined,
|
|
81
|
+
logger,
|
|
82
|
+
reportStatus: (status) => statuses.push(status),
|
|
83
|
+
setExitCode: (code) => exitCodes.push(code),
|
|
94
84
|
});
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
await handler("stdin");
|
|
86
|
+
assert.deepEqual(statuses, [SERVER_SHUTDOWN_COMPLETE]);
|
|
87
|
+
assert.deepEqual(exitCodes, [0]);
|
|
88
|
+
});
|
|
89
|
+
it("keeps retrying identity-aware cleanup during the final enforcement budget", async () => {
|
|
90
|
+
let attempts = 0;
|
|
91
|
+
const statuses = [], exitCodes = [];
|
|
92
|
+
const handler = createServerShutdownHandler({
|
|
93
|
+
shutdown: async () => {
|
|
94
|
+
attempts++;
|
|
95
|
+
if (attempts === 1)
|
|
96
|
+
throw new Error("detached group still alive");
|
|
97
|
+
},
|
|
98
|
+
logger,
|
|
99
|
+
reportStatus: (status) => statuses.push(status),
|
|
100
|
+
setExitCode: (code) => exitCodes.push(code),
|
|
101
|
+
retryDelayMs: 0,
|
|
102
|
+
});
|
|
103
|
+
await handler("stdin");
|
|
104
|
+
assert.equal(attempts, 2);
|
|
105
|
+
assert.deepEqual(statuses, [SERVER_SHUTDOWN_COMPLETE]);
|
|
106
|
+
assert.deepEqual(exitCodes, [0]);
|
|
107
|
+
});
|
|
108
|
+
it("preserves containment after the standalone cleanup retry budget", async () => {
|
|
109
|
+
let attempts = 0;
|
|
110
|
+
const statuses = [], exitCodes = [], forcedExits = [];
|
|
111
|
+
let releaseHold;
|
|
112
|
+
const hold = new Promise((resolve) => { releaseHold = resolve; });
|
|
97
113
|
const handler = createServerShutdownHandler({
|
|
98
|
-
shutdown: () =>
|
|
114
|
+
shutdown: async () => { attempts++; throw new Error("process tree remains alive"); },
|
|
99
115
|
logger,
|
|
100
|
-
|
|
116
|
+
reportStatus: (status) => statuses.push(status),
|
|
101
117
|
setExitCode: (code) => exitCodes.push(code),
|
|
118
|
+
forceExit: (code) => forcedExits.push(code),
|
|
119
|
+
holdAfterFailure: () => hold,
|
|
120
|
+
retryDelayMs: 0,
|
|
121
|
+
retryAttempts: 2,
|
|
102
122
|
});
|
|
103
|
-
const
|
|
104
|
-
|
|
123
|
+
const pending = handler("stdin");
|
|
124
|
+
while (attempts < 3)
|
|
125
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
126
|
+
assert.equal(attempts, 3);
|
|
127
|
+
assert.deepEqual(statuses, [SERVER_SHUTDOWN_INCOMPLETE]);
|
|
128
|
+
assert.deepEqual(exitCodes, [1]);
|
|
129
|
+
assert.deepEqual(forcedExits, []);
|
|
130
|
+
handler("SIGTERM");
|
|
131
|
+
assert.deepEqual(forcedExits, [1]);
|
|
132
|
+
releaseHold();
|
|
133
|
+
await pending;
|
|
134
|
+
});
|
|
135
|
+
it("escalates a second signal while sharing first-signal cleanup", async () => {
|
|
136
|
+
let finish;
|
|
137
|
+
const cleanup = new Promise((resolve) => { finish = resolve; });
|
|
138
|
+
const exits = [], exitCodes = [];
|
|
139
|
+
const handler = createServerShutdownHandler({ shutdown: () => cleanup, logger,
|
|
140
|
+
forceExit: (code) => exits.push(code), setExitCode: (code) => exitCodes.push(code), reportStatus: () => undefined });
|
|
141
|
+
const first = handler("SIGINT"), second = handler("SIGTERM");
|
|
105
142
|
assert.strictEqual(first, second);
|
|
106
143
|
assert.deepEqual(exits, [1]);
|
|
107
|
-
|
|
144
|
+
finish();
|
|
108
145
|
await first;
|
|
109
146
|
assert.deepEqual(exitCodes, [0]);
|
|
110
147
|
});
|
package/dist/ui/remote-ui.js
CHANGED
|
@@ -7,8 +7,8 @@ import { Readable } from "stream";
|
|
|
7
7
|
import { fetch } from "undici";
|
|
8
8
|
import yauzl from "yauzl";
|
|
9
9
|
const DEFAULT_MANIFEST_URL = "https://ui.codenomad.neuralnomads.ai/version.json";
|
|
10
|
-
const MANIFEST_TIMEOUT_MS =
|
|
11
|
-
const ZIP_TIMEOUT_MS =
|
|
10
|
+
const MANIFEST_TIMEOUT_MS = 5_000;
|
|
11
|
+
const ZIP_TIMEOUT_MS = 30_000;
|
|
12
12
|
export async function resolveUi(options) {
|
|
13
13
|
const manifestUrl = options.manifestUrl ?? DEFAULT_MANIFEST_URL;
|
|
14
14
|
if (options.uiDevServerUrl) {
|
|
@@ -25,7 +25,7 @@ const kimi = {
|
|
|
25
25
|
for (const item of Array.isArray(payload?.limits) ? payload.limits : []) {
|
|
26
26
|
const duration = toNumber(item?.window?.duration);
|
|
27
27
|
const unit = item?.window?.timeUnit;
|
|
28
|
-
const multiplier = unit === "TIME_UNIT_MINUTE" ? 60 : unit === "TIME_UNIT_HOUR" ? 3600 : unit === "TIME_UNIT_DAY" ?
|
|
28
|
+
const multiplier = unit === "TIME_UNIT_MINUTE" ? 60 : unit === "TIME_UNIT_HOUR" ? 3600 : unit === "TIME_UNIT_DAY" ? 86_400 : null;
|
|
29
29
|
const seconds = duration !== null && multiplier ? duration * multiplier : null;
|
|
30
30
|
const limit = toNumber(item?.detail?.limit);
|
|
31
31
|
const remaining = toNumber(item?.detail?.remaining);
|
|
@@ -61,7 +61,7 @@ const nanoGpt = {
|
|
|
61
61
|
const limit = toNumber(source.limit ?? source.limits?.[label]);
|
|
62
62
|
windows[label] = toUsageWindow({
|
|
63
63
|
usedPercent: fraction !== null ? fraction * 100 : used !== null && limit ? (used / limit) * 100 : null,
|
|
64
|
-
windowSeconds: label === "daily" ?
|
|
64
|
+
windowSeconds: label === "daily" ? 86_400 : null,
|
|
65
65
|
resetAt: toTimestamp(source.resetAt ?? payload?.period?.currentPeriodEnd),
|
|
66
66
|
});
|
|
67
67
|
}
|
|
@@ -112,7 +112,7 @@ function createTokenLimitProvider(input) {
|
|
|
112
112
|
if (limit?.type !== "TOKENS_LIMIT" && limit?.type !== "TIME_LIMIT")
|
|
113
113
|
continue;
|
|
114
114
|
const duration = toNumber(limit.number);
|
|
115
|
-
const seconds = limit.type === "TIME_LIMIT" ? 30 *
|
|
115
|
+
const seconds = limit.type === "TIME_LIMIT" ? 30 * 86_400 : limit.unit === 3 && duration ? duration * 3600 : null;
|
|
116
116
|
const label = limit.type === "TIME_LIMIT" ? "mcp-tools" : resolveWindowLabel(seconds);
|
|
117
117
|
windows[label] = toUsageWindow({
|
|
118
118
|
usedPercent: toNumber(limit.percentage),
|
|
@@ -92,7 +92,7 @@ function transformModel(sourceId, modelId, data) {
|
|
|
92
92
|
windows: {
|
|
93
93
|
[label]: toUsageWindow({
|
|
94
94
|
usedPercent: fraction === null ? null : 100 - fraction * 100,
|
|
95
|
-
windowSeconds: label === "daily" ?
|
|
95
|
+
windowSeconds: label === "daily" ? 86_400 : 5 * 3600,
|
|
96
96
|
resetAt,
|
|
97
97
|
}),
|
|
98
98
|
},
|
|
@@ -15,7 +15,7 @@ async function resolveCursorToken() {
|
|
|
15
15
|
const accessToken = getString(process.env.CURSOR_ACCESS_TOKEN) ?? getString(process.env.CURSOR_TOKEN);
|
|
16
16
|
const refreshToken = getString(process.env.CURSOR_REFRESH_TOKEN);
|
|
17
17
|
const expiresAt = accessToken ? decodeJwtExpiration(accessToken) : null;
|
|
18
|
-
if (accessToken && (!expiresAt || expiresAt > Date.now() + 5 *
|
|
18
|
+
if (accessToken && (!expiresAt || expiresAt > Date.now() + 5 * 60_000))
|
|
19
19
|
return accessToken;
|
|
20
20
|
if (!refreshToken)
|
|
21
21
|
return accessToken;
|
|
@@ -94,7 +94,7 @@ const ollamaCloud = {
|
|
|
94
94
|
const response = await fetch("https://ollama.com/settings", {
|
|
95
95
|
headers: { Cookie: cookie, "User-Agent": "CodeNomad usage provider" },
|
|
96
96
|
redirect: "manual",
|
|
97
|
-
signal: AbortSignal.timeout(
|
|
97
|
+
signal: AbortSignal.timeout(15_000),
|
|
98
98
|
});
|
|
99
99
|
if (!response.ok)
|
|
100
100
|
throw new Error(`Provider returned HTTP ${response.status}`);
|
|
@@ -134,7 +134,7 @@ const openCodeGo = {
|
|
|
134
134
|
const response = await fetch(`https://opencode.ai/workspace/${encodeURIComponent(workspaceId)}/go`, {
|
|
135
135
|
headers: { Cookie: `auth=${authCookie.replace(/^auth=/, "")}`, "User-Agent": "CodeNomad usage provider" },
|
|
136
136
|
redirect: "manual",
|
|
137
|
-
signal: AbortSignal.timeout(
|
|
137
|
+
signal: AbortSignal.timeout(15_000),
|
|
138
138
|
});
|
|
139
139
|
if (!response.ok)
|
|
140
140
|
throw new Error(`Provider returned HTTP ${response.status}`);
|
package/dist/usage/service.js
CHANGED
|
@@ -3,7 +3,7 @@ import { googleProviders } from "./providers/google";
|
|
|
3
3
|
import { miniMaxProviders } from "./providers/minimax";
|
|
4
4
|
import { oauthProviders } from "./providers/oauth";
|
|
5
5
|
import { specialProviders } from "./providers/special";
|
|
6
|
-
const CACHE_TTL_MS =
|
|
6
|
+
const CACHE_TTL_MS = 60_000;
|
|
7
7
|
const providers = [...oauthProviders, ...apiKeyProviders, ...miniMaxProviders, ...googleProviders, ...specialProviders];
|
|
8
8
|
const registry = new Map();
|
|
9
9
|
for (const provider of providers) {
|
|
@@ -42,7 +42,7 @@ test("selects model-specific windows by normalized model id", () => {
|
|
|
42
42
|
models: {
|
|
43
43
|
"gemini/gemini-2.5-flash": {
|
|
44
44
|
windows: {
|
|
45
|
-
daily: { usedPercent: 25, remainingPercent: 75, windowSeconds:
|
|
45
|
+
daily: { usedPercent: 25, remainingPercent: 75, windowSeconds: 86_400, resetAt: null },
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
},
|
package/dist/usage/shared.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import os from "os";
|
|
3
3
|
import path from "path";
|
|
4
|
-
const REQUEST_TIMEOUT_MS =
|
|
4
|
+
const REQUEST_TIMEOUT_MS = 15_000;
|
|
5
5
|
function authFileCandidates() {
|
|
6
6
|
const home = os.homedir();
|
|
7
7
|
const candidates = [
|
|
@@ -68,7 +68,7 @@ export function toNumber(value) {
|
|
|
68
68
|
}
|
|
69
69
|
export function toTimestamp(value) {
|
|
70
70
|
if (typeof value === "number" && Number.isFinite(value))
|
|
71
|
-
return value <
|
|
71
|
+
return value < 1_000_000_000_000 ? value * 1000 : value;
|
|
72
72
|
if (typeof value === "string" && value.trim()) {
|
|
73
73
|
const parsed = Date.parse(value);
|
|
74
74
|
return Number.isNaN(parsed) ? null : parsed;
|
|
@@ -88,8 +88,8 @@ export function toUsageWindow(input) {
|
|
|
88
88
|
export function resolveWindowLabel(windowSeconds) {
|
|
89
89
|
if (!windowSeconds)
|
|
90
90
|
return "usage";
|
|
91
|
-
if (windowSeconds %
|
|
92
|
-
const days = windowSeconds /
|
|
91
|
+
if (windowSeconds % 86_400 === 0) {
|
|
92
|
+
const days = windowSeconds / 86_400;
|
|
93
93
|
return days === 7 ? "weekly" : `${days}d`;
|
|
94
94
|
}
|
|
95
95
|
if (windowSeconds % 3600 === 0)
|
|
@@ -41,7 +41,7 @@ describe("buildWindowsSpawnSpec", () => {
|
|
|
41
41
|
it("conservatively classifies bare commands as wrappers", () => {
|
|
42
42
|
assert.equal(buildWindowsSpawnSpec("opencode", []).processKind, "windows-wrapper");
|
|
43
43
|
});
|
|
44
|
-
it("resolves a bare cmd shim from a quoted PATH entry and wraps its absolute path", () => {
|
|
44
|
+
it("resolves a bare cmd shim from a quoted PATH entry and wraps its absolute path", { skip: process.platform !== "win32" }, () => {
|
|
45
45
|
const root = mkdtempSync(path.join(tmpdir(), "codenomad-spawn-"));
|
|
46
46
|
const cwd = path.join(root, "workspace");
|
|
47
47
|
const bin = path.join(root, "bin with spaces");
|
|
@@ -63,7 +63,7 @@ describe("buildWindowsSpawnSpec", () => {
|
|
|
63
63
|
rmSync(root, { recursive: true, force: true });
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
it("honors PATHEXT precedence when both native and shim files exist", () => {
|
|
66
|
+
it("honors PATHEXT precedence when both native and shim files exist", { skip: process.platform !== "win32" }, () => {
|
|
67
67
|
const root = mkdtempSync(path.join(tmpdir(), "codenomad-spawn-"));
|
|
68
68
|
writeFileSync(path.join(root, "opencode.cmd"), "@echo off\r\n");
|
|
69
69
|
writeFileSync(path.join(root, "opencode.exe"), "");
|