@datagrok/grokky 1.0.4 → 1.1.0
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/.claude/skills/deploy-grokky/SKILL.md +193 -0
- package/.grokignore +2 -0
- package/.turbo/turbo-build.log +24 -0
- package/.vscode/settings.json +16 -0
- package/CHANGELOG.md +151 -8
- package/CLAUDE.md +284 -0
- package/CREDITS.md +173 -0
- package/LICENSE.md +16 -0
- package/README.md +24 -0
- package/bdd/bdd.config.json +1 -0
- package/bdd/bindings/elements.ts +9 -0
- package/bdd/bindings/steps.ts +787 -0
- package/bdd/features/ai-panel/platform-work.feature +63 -0
- package/bdd/features/ai-panel/session.feature +69 -0
- package/bdd/features/ai-panel/table-work.feature +99 -0
- package/bdd/generated/ai-panel/platform-work.test.ts +103 -0
- package/bdd/generated/ai-panel/session.test.ts +100 -0
- package/bdd/generated/ai-panel/table-work.test.ts +150 -0
- package/bdd/package.json +1 -0
- package/bdd/tsconfig.json +13 -0
- package/css/ai.css +637 -49
- package/dist/package-test.js +4 -1707
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +742 -92317
- package/dist/package.js.map +1 -1
- package/dockerfiles/claude-runtime/.dockerignore +1 -0
- package/{.eslintrc.json → dockerfiles/claude-runtime/.eslintrc.json} +7 -16
- package/dockerfiles/claude-runtime/Dockerfile +73 -13
- package/dockerfiles/claude-runtime/agent/grokky_agent/__init__.py +0 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/__main__.py +80 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/browser_tools.py +180 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/config.py +26 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/formats.py +155 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/guard.py +87 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/hermes.py +212 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/hermes.yaml +45 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/hermes_plugin/__init__.py +8 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/hermes_plugin/plugin.yaml +3 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/protocol.py +174 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/__init__.py +21 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/anthropic.py +21 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/azure.py +46 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/base.py +127 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/bedrock.py +46 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/custom.py +40 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/databricks.py +54 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/openai_platform.py +41 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/providers/openrouter.py +46 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/session.py +471 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/skills.py +44 -0
- package/dockerfiles/claude-runtime/agent/grokky_agent/structured.py +40 -0
- package/dockerfiles/claude-runtime/container.json +2 -2
- package/dockerfiles/claude-runtime/entrypoint.sh +20 -0
- package/dockerfiles/claude-runtime/package-lock.json +1721 -306
- package/dockerfiles/claude-runtime/package.json +20 -5
- package/dockerfiles/claude-runtime/plugin/.claude-plugin/plugin.json +5 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-calc-column/SKILL.md +92 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-chem-data/SKILL.md +250 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-chem-toolkit/SKILL.md +395 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-df-and-columns/SKILL.md +454 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-entities/SKILL.md +38 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-exec/SKILL.md +209 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-filtering/SKILL.md +185 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-grid-customization/SKILL.md +270 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-projects/SKILL.md +100 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-selection/SKILL.md +344 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-undo/SKILL.md +78 -0
- package/dockerfiles/claude-runtime/plugin/skills/datagrok-viewers/SKILL.md +303 -0
- package/dockerfiles/claude-runtime/pyproject.toml +18 -0
- package/dockerfiles/claude-runtime/src/agent/pool.ts +411 -0
- package/dockerfiles/claude-runtime/src/agent/turn.ts +153 -0
- package/dockerfiles/claude-runtime/src/constants.ts +20 -0
- package/dockerfiles/claude-runtime/src/credentials.ts +45 -0
- package/dockerfiles/claude-runtime/src/grounding.ts +104 -0
- package/dockerfiles/claude-runtime/src/help-index.ts +118 -0
- package/dockerfiles/claude-runtime/src/privileges.ts +8 -0
- package/dockerfiles/claude-runtime/src/prompts.ts +211 -0
- package/dockerfiles/claude-runtime/src/server.ts +134 -234
- package/dockerfiles/claude-runtime/src/session.ts +328 -0
- package/dockerfiles/claude-runtime/src/shared-api-client.ts +112 -0
- package/dockerfiles/claude-runtime/src/stream-filter.ts +80 -0
- package/dockerfiles/claude-runtime/src/sync/home-files.ts +80 -0
- package/dockerfiles/claude-runtime/src/sync/orchestrator.ts +214 -0
- package/dockerfiles/claude-runtime/src/sync/packages.ts +145 -0
- package/dockerfiles/claude-runtime/src/sync/shared-connections.ts +87 -0
- package/dockerfiles/claude-runtime/src/sync/workspace.ts +68 -0
- package/dockerfiles/claude-runtime/src/tasks.ts +124 -0
- package/dockerfiles/claude-runtime/src/tool-summary.ts +66 -0
- package/dockerfiles/claude-runtime/src/types.ts +142 -23
- package/dockerfiles/claude-runtime/src/user/installed-packages.ts +17 -0
- package/dockerfiles/claude-runtime/src/user/staged-workspace.ts +80 -0
- package/dockerfiles/claude-runtime/src/user/user-dir.ts +108 -0
- package/dockerfiles/claude-runtime/src/verify.ts +136 -0
- package/dockerfiles/claude-runtime/src/watchdog.ts +115 -0
- package/dockerfiles/claude-runtime/test/credentials.test.js +43 -0
- package/dockerfiles/claude-runtime/test/grounding.test.js +191 -0
- package/dockerfiles/claude-runtime/test/help-index.test.js +115 -0
- package/dockerfiles/claude-runtime/test/plugin-skills.test.js +57 -0
- package/dockerfiles/claude-runtime/test/prompts.test.js +62 -0
- package/dockerfiles/claude-runtime/test/reaper.test.js +60 -0
- package/dockerfiles/claude-runtime/test/stream-filter.test.js +132 -0
- package/dockerfiles/claude-runtime/test/tasks.test.js +74 -0
- package/dockerfiles/claude-runtime/test/user-dir.test.js +71 -0
- package/dockerfiles/claude-runtime/test/verify.test.js +187 -0
- package/dockerfiles/claude-runtime/test/watchdog.test.js +43 -0
- package/dockerfiles/mcp-server/.eslintrc.json +39 -0
- package/dockerfiles/mcp-server/Dockerfile +10 -2
- package/dockerfiles/mcp-server/package-lock.json +1743 -98
- package/dockerfiles/mcp-server/package.json +27 -5
- package/dockerfiles/mcp-server/src/api-client.ts +123 -66
- package/dockerfiles/mcp-server/src/format.ts +51 -0
- package/dockerfiles/mcp-server/src/index.ts +44 -113
- package/dockerfiles/mcp-server/src/ops.ts +325 -0
- package/dockerfiles/mcp-server/src/shared-api-client.ts +81 -0
- package/dockerfiles/mcp-server/test/format.test.js +62 -0
- package/dockerfiles/mcp-server/test/ops.test.js +84 -0
- package/dockerfiles/mcp-server/test/shared-api-client.test.js +35 -0
- package/dockerfiles/queue/Dockerfile +2 -0
- package/dockerfiles/queue/container.json +7 -0
- package/docs/AUDIT-2026-08-03.md +1064 -0
- package/docs/BENCHMARK.md +292 -0
- package/docs/CLAUDE_CODE_FLOW.md +746 -0
- package/docs/EXAMPLES.md +82 -0
- package/docs/FEATURES.md +71 -0
- package/docs/IMPLEMENTATION.md +128 -0
- package/docs/LATENCY.md +170 -0
- package/docs/VISION.md +36 -0
- package/files/benchmark/suite.yaml +404 -0
- package/files/scripts/process-cro-results.md +14 -0
- package/files/suggestions.yaml +344 -0
- package/package.json +39 -97
- package/src/ai/ai-window.ts +157 -0
- package/src/ai/benchmark/benchmark.ts +737 -0
- package/src/ai/db-view-functions.ts +56 -0
- package/src/ai/engine.ts +98 -0
- package/src/ai/gemma-engine.ts +81 -0
- package/src/ai/panel.ts +1385 -0
- package/src/ai/prompt-suggestions.ts +209 -0
- package/src/ai/search/combined-search.ts +244 -0
- package/src/{llm-utils → ai/search}/query-matching.ts +46 -167
- package/src/{llm-utils → ai}/storage.ts +0 -1
- package/src/ai/table-tools.ts +145 -0
- package/src/ai/ui.ts +720 -0
- package/src/ai/usage-limiter.ts +105 -0
- package/src/ai/view-tools.ts +352 -0
- package/src/claude/ai-feature.ts +16 -0
- package/src/claude/exec-blocks.ts +176 -0
- package/src/claude/queue-task.ts +84 -0
- package/src/claude/runtime-client.ts +310 -0
- package/src/claude/turn-log.ts +114 -0
- package/src/claude/undoable.ts +105 -0
- package/src/{llm-utils → db}/db-index-tools.ts +24 -32
- package/src/db/sql-tools.ts +336 -0
- package/src/depr/LLM-client.ts +251 -0
- package/src/depr/ai-panel.ts +174 -0
- package/src/depr/chatgpt-assistant.ts +257 -0
- package/src/depr/creds.ts +30 -0
- package/src/depr/deepwikiclient.ts +118 -0
- package/src/depr/indexes/dg-repository-index.ts +266 -0
- package/src/depr/interfaces.ts +170 -0
- package/src/depr/is-help-request.ts +39 -0
- package/src/depr/prompt-engine.ts +52 -0
- package/src/depr/rendering-tools.ts +103 -0
- package/src/depr/script-tools.ts +785 -0
- package/src/depr/tableview-tools.ts +746 -0
- package/src/depr/viewers-ai.ts +67 -0
- package/src/package-api.ts +87 -28
- package/src/package-test.ts +1 -0
- package/src/package.g.ts +98 -48
- package/src/package.ts +211 -157
- package/src/polyfills.ts +12 -0
- package/src/utils.ts +128 -0
- package/tsconfig.json +8 -70
- package/webpack.config.js +3 -49
- package/.eslintignore +0 -2
- package/src/ai-panel.ts +0 -174
- package/src/claude-code/claude-panel.ts +0 -34
- package/src/claude-code/claude-runtime-client.ts +0 -148
- package/src/llm-utils/LLM-client.ts +0 -251
- package/src/llm-utils/combined-search.ts +0 -162
- package/src/llm-utils/creds.ts +0 -30
- package/src/llm-utils/deepwikiclient.ts +0 -118
- package/src/llm-utils/indexes/dg-repository-index.ts +0 -266
- package/src/llm-utils/panel.ts +0 -866
- package/src/llm-utils/script-tools.ts +0 -784
- package/src/llm-utils/sql-tools.ts +0 -840
- package/src/llm-utils/tableview-tools.ts +0 -704
- package/src/llm-utils/ui.ts +0 -315
- package/src/prompt-engine/chatgpt-assistant.ts +0 -257
- package/src/prompt-engine/interfaces.ts +0 -170
- package/src/prompt-engine/prompt-engine.ts +0 -52
- package/src/prompt-engine/rendering-tools.ts +0 -103
- package/src/prompts/is-help-request.ts +0 -26
- package/src/viewers-ai.ts +0 -67
- /package/src/{llm-utils → db}/indexes/biologics-index.ts +0 -0
- /package/src/{llm-utils → db}/indexes/chembl-index.ts +0 -0
- /package/src/{llm-utils → db}/query-meta-utils.ts +0 -0
- /package/src/{llm-utils/depr → depr}/AI-API-providers/openai-chat-completions-provider.ts +0 -0
- /package/src/{llm-utils/depr → depr}/AI-API-providers/openai-responses-provider.ts +0 -0
- /package/src/{llm-utils/depr → depr}/AI-API-providers/types.ts +0 -0
- /package/src/{llm-utils/depr → depr}/depr.ts +0 -0
- /package/src/{llm-utils/depr → depr}/embeddings.ts +0 -0
- /package/src/{llm-utils/depr → depr}/sql-utils.ts +0 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// emitFiltered — the fence-aware chunk filter that turns the model's text deltas into client `chunk`
|
|
2
|
+
// messages. It must never lose or duplicate a character: what the browser accumulates has to
|
|
3
|
+
// equal what the model emitted. Fence state is keyed per session id, so each test uses its own.
|
|
4
|
+
|
|
5
|
+
const test = require('node:test');
|
|
6
|
+
const assert = require('node:assert');
|
|
7
|
+
const {emitFiltered, flushFenceState} = require('../dist/stream-filter.js');
|
|
8
|
+
|
|
9
|
+
let seq = 0;
|
|
10
|
+
// Collects emitted chunks for one throwaway session, and reassembles what the browser would show.
|
|
11
|
+
function sink() {
|
|
12
|
+
const sid = `t${seq++}`;
|
|
13
|
+
const chunks = [];
|
|
14
|
+
const ws = {send: (s) => {
|
|
15
|
+
const m = JSON.parse(s);
|
|
16
|
+
if (m.type === 'chunk')
|
|
17
|
+
chunks.push(m.content);
|
|
18
|
+
}};
|
|
19
|
+
return {
|
|
20
|
+
sid, ws, chunks,
|
|
21
|
+
feed: (...deltas) => deltas.forEach((d) => emitFiltered(ws, sid, d)),
|
|
22
|
+
flush: () => flushFenceState(ws, sid),
|
|
23
|
+
get text() { return chunks.join(''); },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
test('plain prose passes through unchanged', () => {
|
|
28
|
+
const s = sink();
|
|
29
|
+
s.feed('Hello, ', 'world.\n');
|
|
30
|
+
s.flush();
|
|
31
|
+
assert.equal(s.text, 'Hello, world.\n');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('text split mid-word across deltas reassembles exactly', () => {
|
|
35
|
+
const s = sink();
|
|
36
|
+
s.feed('The quick ', 'brown fo', 'x jumps.\n');
|
|
37
|
+
s.flush();
|
|
38
|
+
assert.equal(s.text, 'The quick brown fox jumps.\n');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('a fenced code block survives intact', () => {
|
|
42
|
+
const s = sink();
|
|
43
|
+
const src = 'Here:\n```js\nconst a = 1;\n```\nDone.\n';
|
|
44
|
+
s.feed(src);
|
|
45
|
+
s.flush();
|
|
46
|
+
assert.equal(s.text, src);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('a fence arriving one character at a time is not mangled', () => {
|
|
50
|
+
const s = sink();
|
|
51
|
+
const src = 'a\n```js\nx\n```\nb\n';
|
|
52
|
+
for (const ch of src)
|
|
53
|
+
s.feed(ch);
|
|
54
|
+
s.flush();
|
|
55
|
+
assert.equal(s.text, src, 'char-by-char streaming must reassemble byte-identically');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('a partial trailing line starting with a backtick is held back until resolved', () => {
|
|
59
|
+
const s = sink();
|
|
60
|
+
s.feed('text\n', '``');
|
|
61
|
+
assert.ok(!s.text.includes('``'), 'a possible fence marker must not be emitted early');
|
|
62
|
+
s.feed('`js\n');
|
|
63
|
+
s.flush();
|
|
64
|
+
assert.equal(s.text, 'text\n```js\n');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('inline backticks mid-line are not mistaken for a fence', () => {
|
|
68
|
+
const s = sink();
|
|
69
|
+
const src = 'Use the `grok.shell.v` global here.\n';
|
|
70
|
+
s.feed(src);
|
|
71
|
+
s.flush();
|
|
72
|
+
assert.equal(s.text, src);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('a line that merely starts with a backtick but is not a fence still emits', () => {
|
|
76
|
+
const s = sink();
|
|
77
|
+
s.feed('`not a fence` really\n');
|
|
78
|
+
s.flush();
|
|
79
|
+
assert.equal(s.text, '`not a fence` really\n');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('multi-line deltas batch into few emits rather than one per line', () => {
|
|
83
|
+
const s = sink();
|
|
84
|
+
s.feed('a\nb\nc\nd\ne\nf\n');
|
|
85
|
+
s.flush();
|
|
86
|
+
assert.equal(s.text, 'a\nb\nc\nd\ne\nf\n');
|
|
87
|
+
assert.ok(s.chunks.length <= 2, `expected batching, got ${s.chunks.length} chunks`);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('flush emits a held-back partial so nothing is lost at end of turn', () => {
|
|
91
|
+
const s = sink();
|
|
92
|
+
s.feed('done\n', '`lonely');
|
|
93
|
+
assert.ok(!s.text.includes('lonely'), 'held back while it could still become a fence');
|
|
94
|
+
s.flush();
|
|
95
|
+
assert.equal(s.text, 'done\n`lonely', 'flush must release it');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('flushing twice does not duplicate the carry', () => {
|
|
99
|
+
const s = sink();
|
|
100
|
+
s.feed('x\n', '`held');
|
|
101
|
+
s.flush();
|
|
102
|
+
s.flush();
|
|
103
|
+
assert.equal(s.text, 'x\n`held');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('sessions do not leak fence state into each other', () => {
|
|
107
|
+
const a = sink();
|
|
108
|
+
const b = sink();
|
|
109
|
+
a.feed('```js\n'); // a is now inside a fence
|
|
110
|
+
b.feed('plain text\n'); // b must be unaffected
|
|
111
|
+
a.feed('code\n```\n');
|
|
112
|
+
a.flush();
|
|
113
|
+
b.flush();
|
|
114
|
+
assert.equal(a.text, '```js\ncode\n```\n');
|
|
115
|
+
assert.equal(b.text, 'plain text\n');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('consecutive fenced blocks toggle mode correctly', () => {
|
|
119
|
+
const s = sink();
|
|
120
|
+
const src = '```js\none\n```\nmid\n```py\ntwo\n```\nend\n';
|
|
121
|
+
s.feed(src);
|
|
122
|
+
s.flush();
|
|
123
|
+
assert.equal(s.text, src);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('a fence marker with no language is handled', () => {
|
|
127
|
+
const s = sink();
|
|
128
|
+
const src = 'a\n```\nraw\n```\nb\n';
|
|
129
|
+
s.feed(src);
|
|
130
|
+
s.flush();
|
|
131
|
+
assert.equal(s.text, src);
|
|
132
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const test = require('node:test');
|
|
2
|
+
const assert = require('node:assert');
|
|
3
|
+
const {claimTask, waitForClaim, endTask, releaseTask} = require('../dist/tasks');
|
|
4
|
+
|
|
5
|
+
let n = 0;
|
|
6
|
+
const freshId = () => `task-${++n}`;
|
|
7
|
+
|
|
8
|
+
test('worker claim resolves when the turn ends', async () => {
|
|
9
|
+
const id = freshId();
|
|
10
|
+
const claim = claimTask(id, 's1');
|
|
11
|
+
endTask(id);
|
|
12
|
+
assert.deepEqual(await claim, {status: 'ended'});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('a claim after the turn already ended resolves immediately', async () => {
|
|
16
|
+
const id = freshId();
|
|
17
|
+
waitForClaim(id, 's1', new AbortController().signal);
|
|
18
|
+
endTask(id);
|
|
19
|
+
assert.deepEqual(await claimTask(id, 's1'), {status: 'ended'});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('turn holds until the worker claims', async () => {
|
|
23
|
+
const id = freshId();
|
|
24
|
+
const held = waitForClaim(id, 's1', new AbortController().signal);
|
|
25
|
+
claimTask(id, 's1');
|
|
26
|
+
assert.equal(await held, true);
|
|
27
|
+
endTask(id);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('abort while holding resolves false and the task still ends cleanly', async () => {
|
|
31
|
+
const id = freshId();
|
|
32
|
+
const ac = new AbortController();
|
|
33
|
+
const held = waitForClaim(id, 's1', ac.signal);
|
|
34
|
+
ac.abort();
|
|
35
|
+
assert.equal(await held, false);
|
|
36
|
+
endTask(id);
|
|
37
|
+
assert.deepEqual(await claimTask(id, 's1'), {status: 'ended'});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('release frees both waiters and reports the session to abort', async () => {
|
|
41
|
+
const id = freshId();
|
|
42
|
+
const held = waitForClaim(id, 's1', new AbortController().signal);
|
|
43
|
+
const claim = claimTask(id, 's1');
|
|
44
|
+
assert.equal(releaseTask(id), 's1');
|
|
45
|
+
assert.equal(await held, true); // was claimed before the release
|
|
46
|
+
assert.deepEqual(await claim, {status: 'released'});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('a busy queue holds the turn past the fail-open window; a dead one fails open', async (t) => {
|
|
50
|
+
// Start the mocked clock well past any real worker poll recorded by earlier tests.
|
|
51
|
+
t.mock.timers.enable({apis: ['setTimeout', 'Date'], now: Date.now() + 600_000});
|
|
52
|
+
const id = freshId();
|
|
53
|
+
let result = null;
|
|
54
|
+
waitForClaim(id, 's1', new AbortController().signal).then((r) => { result = r; });
|
|
55
|
+
claimTask(freshId(), 'other-session'); // a worker polling for another task — the pool is alive
|
|
56
|
+
t.mock.timers.tick(60_000);
|
|
57
|
+
await new Promise((r) => setImmediate(r));
|
|
58
|
+
assert.equal(result, null); // workers live → still waiting
|
|
59
|
+
t.mock.timers.tick(60_000); // no polls for 120s now — the pool looks dead
|
|
60
|
+
await new Promise((r) => setImmediate(r));
|
|
61
|
+
assert.equal(result, false);
|
|
62
|
+
endTask(id);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('end after release keeps the released status; release after end is a no-op', async () => {
|
|
66
|
+
const id = freshId();
|
|
67
|
+
claimTask(id, 's1');
|
|
68
|
+
releaseTask(id);
|
|
69
|
+
endTask(id);
|
|
70
|
+
assert.deepEqual(await claimTask(id, 's1'), {status: 'released'});
|
|
71
|
+
const id2 = freshId();
|
|
72
|
+
endTask(id2 /* unknown task */);
|
|
73
|
+
assert.equal(releaseTask(id2), null);
|
|
74
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const test = require('node:test');
|
|
2
|
+
const assert = require('node:assert');
|
|
3
|
+
const http = require('node:http');
|
|
4
|
+
const {userDirs, UserDirectory} = require('../dist/user/user-dir.js');
|
|
5
|
+
|
|
6
|
+
const GOOD_ID = 'a1b2c3d4-0000-1111-2222-333344445555';
|
|
7
|
+
const users = new Map([
|
|
8
|
+
['good-token', {id: GOOD_ID}],
|
|
9
|
+
['evil-token', {id: '../workspace'}],
|
|
10
|
+
['pin-token', {id: GOOD_ID}],
|
|
11
|
+
['dedup-token', {id: GOOD_ID}],
|
|
12
|
+
]);
|
|
13
|
+
let requests = 0;
|
|
14
|
+
const server = http.createServer((req, res) => {
|
|
15
|
+
requests++;
|
|
16
|
+
const user = req.url === '/users/current' ? users.get(req.headers['authorization']) : undefined;
|
|
17
|
+
if (!user) {
|
|
18
|
+
res.statusCode = 401;
|
|
19
|
+
return res.end('Unauthorized');
|
|
20
|
+
}
|
|
21
|
+
res.setHeader('content-type', 'application/json');
|
|
22
|
+
res.end(JSON.stringify(user));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
let apiUrl;
|
|
26
|
+
test.before(() => new Promise((r) => server.listen(0, '127.0.0.1', () => {
|
|
27
|
+
server.unref();
|
|
28
|
+
apiUrl = `http://127.0.0.1:${server.address().port}`;
|
|
29
|
+
r();
|
|
30
|
+
})));
|
|
31
|
+
|
|
32
|
+
test('id comes from the server, is cached, and is re-verified after the TTL', async () => {
|
|
33
|
+
assert.equal(await userDirs.resolveUserId('good-token', apiUrl), GOOD_ID);
|
|
34
|
+
const before = requests;
|
|
35
|
+
await userDirs.resolveUserId('good-token');
|
|
36
|
+
assert.equal(requests, before);
|
|
37
|
+
userDirs.verified.get('good-token').at = 0;
|
|
38
|
+
assert.equal(await userDirs.resolveUserId('good-token'), GOOD_ID);
|
|
39
|
+
assert.equal(requests, before + 1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('a rejected token (forged JWT payloads included) resolves no identity and is not retried within the rejection window', async () => {
|
|
43
|
+
const forged = 'x.' + Buffer.from(JSON.stringify({sub: GOOD_ID})).toString('base64url') + '.y';
|
|
44
|
+
await assert.rejects(() => userDirs.resolveUserId(forged), /HTTP 401/);
|
|
45
|
+
const before = requests;
|
|
46
|
+
await assert.rejects(() => userDirs.resolveUserId(forged), /HTTP 401/);
|
|
47
|
+
assert.equal(requests, before);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('a path-unsafe id from the server is rejected, not joined into /users', async () => {
|
|
51
|
+
await assert.rejects(() => userDirs.resolveUserId('evil-token'), /invalid id/);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('later client input cannot repoint verification at another server', async () => {
|
|
55
|
+
assert.equal(await userDirs.resolveUserId('pin-token', 'http://127.0.0.1:1'), GOOD_ID);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('concurrent calls with an unseen token share one verification request', async () => {
|
|
59
|
+
const before = requests;
|
|
60
|
+
const ids = await Promise.all([userDirs.resolveUserId('dedup-token'), userDirs.resolveUserId('dedup-token')]);
|
|
61
|
+
assert.deepEqual(ids, [GOOD_ID, GOOD_ID]);
|
|
62
|
+
assert.equal(requests, before + 1);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('DATAGROK_API_URL wins over client-supplied URLs; with neither, no identity resolves', async () => {
|
|
66
|
+
process.env.DATAGROK_API_URL = apiUrl;
|
|
67
|
+
const dirs = new UserDirectory();
|
|
68
|
+
delete process.env.DATAGROK_API_URL;
|
|
69
|
+
assert.equal(await dirs.resolveUserId('good-token', 'http://127.0.0.1:1'), GOOD_ID);
|
|
70
|
+
await assert.rejects(() => new UserDirectory().resolveUserId('good-token'), /no Datagrok API URL/);
|
|
71
|
+
});
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// Verifier gate — the state machine that decides whether a turn may Stop.
|
|
2
|
+
// Tests run against the compiled dist/, so `npm test` builds first.
|
|
3
|
+
|
|
4
|
+
const test = require('node:test');
|
|
5
|
+
const assert = require('node:assert');
|
|
6
|
+
const {Verifier, isActionTool, isReadonlyTool, bareToolName} = require('../dist/verify.js');
|
|
7
|
+
|
|
8
|
+
const blocked = (feedback) => feedback !== undefined;
|
|
9
|
+
|
|
10
|
+
const EXEC = 'datagrok_exec';
|
|
11
|
+
const VERIFY = 'datagrok_verify';
|
|
12
|
+
|
|
13
|
+
test('bareToolName strips the mcp server prefix', () => {
|
|
14
|
+
assert.equal(bareToolName('mcp__datagrok__call_function'), 'call_function');
|
|
15
|
+
assert.equal(bareToolName('mcp__datagrok-browser__datagrok_exec'), 'datagrok_exec');
|
|
16
|
+
assert.equal(bareToolName('mcp__datagrok__datagrok_spaces'), 'datagrok_spaces');
|
|
17
|
+
assert.equal(bareToolName(EXEC), 'datagrok_exec');
|
|
18
|
+
assert.equal(bareToolName('read_file'), 'read_file');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('isReadonlyTool recognises the read-only name prefixes', () => {
|
|
22
|
+
for (const n of ['list_functions', 'get_project', 'search_project', 'read_space_file', 'download_file', 'whoami'])
|
|
23
|
+
assert.ok(isReadonlyTool(n), `${n} should be read-only`);
|
|
24
|
+
assert.ok(isReadonlyTool('datagrok_show_entities'), 'show_entities is a render, not a mutation');
|
|
25
|
+
for (const n of ['create_project', 'upload_file', 'delete_space', 'call_function'])
|
|
26
|
+
assert.ok(!isReadonlyTool(n), `${n} should not be read-only`);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Domain tools are one tool name covering both reads and mutations, so the gate has to read the
|
|
30
|
+
// op. Getting this wrong is silent: a mutating call classified read-only skips verification.
|
|
31
|
+
test('isReadonlyTool reads the op for domain tools, not the tool name', () => {
|
|
32
|
+
for (const op of ['list', 'get', 'list_children', 'read_file', 'search', 'whoami'])
|
|
33
|
+
assert.ok(isReadonlyTool('datagrok_spaces', {op}), `op ${op} should be read-only`);
|
|
34
|
+
for (const op of ['create', 'delete', 'write_file', 'add_entity', 'remove_entity', 'share'])
|
|
35
|
+
assert.ok(!isReadonlyTool('datagrok_spaces', {op}), `op ${op} should count as an action`);
|
|
36
|
+
assert.ok(isReadonlyTool('datagrok_spaces', {}), 'no op = asking for the catalog');
|
|
37
|
+
assert.ok(isReadonlyTool('datagrok_projects', {op: 'list', args: {filter: 'x'}}));
|
|
38
|
+
assert.ok(!isReadonlyTool('datagrok_projects', {op: 'create', args: {name: 'x'}}));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('isActionTool: exec and mutating mcp tools count, mcp reads do not', () => {
|
|
42
|
+
assert.ok(isActionTool(EXEC));
|
|
43
|
+
assert.ok(isActionTool('mcp__datagrok__datagrok_functions', {op: 'call', args: {name: 'X:y'}}));
|
|
44
|
+
assert.ok(isActionTool('mcp__datagrok__datagrok_functions', {op: 'create_script', args: {script: 'x'}}));
|
|
45
|
+
assert.ok(!isActionTool('mcp__datagrok__datagrok_functions', {op: 'list'}));
|
|
46
|
+
assert.ok(!isActionTool('mcp__datagrok__datagrok_platform', {op: 'whoami'}));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('the agent\'s own tools and read-only browser and view tools are not actions', () => {
|
|
50
|
+
for (const n of ['read_file', 'write_file', 'patch', 'search_files', 'terminal', 'process_manage', 'skills_list',
|
|
51
|
+
'skill_view', 'skill_manage', 'web_search', 'web_extract', 'AskUserQuestion', 'datagrok_show_entities',
|
|
52
|
+
'list_view_functions', 'list_view_widgets', 'get_view_function_result'])
|
|
53
|
+
assert.ok(!isActionTool(n, {}), `${n} should not be an action`);
|
|
54
|
+
for (const n of [EXEC, 'call_view_function', 'mcp__datagrok-view__call_view_function'])
|
|
55
|
+
assert.ok(isActionTool(n, {}), `${n} should be an action`);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Fail-closed: a domain tool whose op we do not recognise must count as an action so the verify
|
|
59
|
+
// gate over-asks, rather than letting an unverified mutation through.
|
|
60
|
+
test('isActionTool treats an unrecognised domain op as an action', () => {
|
|
61
|
+
assert.ok(isActionTool('mcp__datagrok__datagrok_spaces', {op: 'reticulate'}));
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('an unverified action blocks the Stop', () => {
|
|
65
|
+
const v = new Verifier();
|
|
66
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true}));
|
|
67
|
+
assert.ok(blocked(v.atStop()));
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('a turn with no actions never blocks', () => {
|
|
71
|
+
const v = new Verifier();
|
|
72
|
+
v.afterTool('read_file', {}, '');
|
|
73
|
+
v.afterTool('mcp__datagrok__list_functions', {}, JSON.stringify([]));
|
|
74
|
+
assert.ok(!blocked(v.atStop()));
|
|
75
|
+
assert.ok(!v.hadActions);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('a self-verifying exec satisfies the gate without a separate verify round-trip', () => {
|
|
79
|
+
const v = new Verifier();
|
|
80
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true, verified: {passed: true, observed: 1}}));
|
|
81
|
+
assert.ok(!blocked(v.atStop()), 'in-round-trip verification should count as a pass');
|
|
82
|
+
assert.equal(JSON.parse(v.statsLine()).passes, 1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('a self-verifying exec that FAILED still blocks', () => {
|
|
86
|
+
const v = new Verifier();
|
|
87
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true, verified: {passed: false}}));
|
|
88
|
+
assert.ok(blocked(v.atStop()));
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('a passing datagrok_verify clears everything pending', () => {
|
|
92
|
+
const v = new Verifier();
|
|
93
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true}));
|
|
94
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true}));
|
|
95
|
+
v.afterTool(VERIFY, {}, JSON.stringify({passed: true}));
|
|
96
|
+
assert.ok(!blocked(v.atStop()), 'one passing verify covers all pending actions in the turn');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Regression: an earlier unverified exec used to keep pendingActions > 0 through a later
|
|
100
|
+
// self-verified exec, so the turn paid a hidden revision + verify round-trip for nothing.
|
|
101
|
+
test('a self-verified exec pass clears earlier pending actions like a datagrok_verify pass', () => {
|
|
102
|
+
const v = new Verifier();
|
|
103
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true, verified: {passed: false}}));
|
|
104
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true, verified: {passed: true, observed: 4}}));
|
|
105
|
+
assert.ok(!blocked(v.atStop()), 'the passing self-verify covers the turn');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('a failing verify blocks with a reason that forbids redoing the action', () => {
|
|
109
|
+
const v = new Verifier();
|
|
110
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true}));
|
|
111
|
+
v.afterTool(VERIFY, {}, JSON.stringify({passed: false}));
|
|
112
|
+
const r = v.atStop();
|
|
113
|
+
assert.ok(blocked(r));
|
|
114
|
+
assert.match(r, /Verification has failed/);
|
|
115
|
+
assert.match(r, /NEVER redo a state-changing action/);
|
|
116
|
+
assert.match(r, /assertion itself was faulty/);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('the first (no-failure) block also forbids redoing the actions', () => {
|
|
120
|
+
const v = new Verifier();
|
|
121
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true}));
|
|
122
|
+
const r = v.atStop();
|
|
123
|
+
assert.ok(blocked(r));
|
|
124
|
+
assert.match(r, /Do NOT redo the actions/);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('block reasons are framed as internal feedback the model must not quote', () => {
|
|
128
|
+
const v = new Verifier();
|
|
129
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true}));
|
|
130
|
+
const r = v.atStop();
|
|
131
|
+
assert.match(r, /never mention, quote, or allude to it/);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('the gate gives up after 3 blocks and marks the turn unverified', () => {
|
|
135
|
+
const v = new Verifier();
|
|
136
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true}));
|
|
137
|
+
for (let i = 0; i < 3; i++)
|
|
138
|
+
assert.ok(blocked(v.atStop()), `block ${i + 1} should still gate`);
|
|
139
|
+
assert.ok(!blocked(v.atStop()), 'fourth Stop is allowed through');
|
|
140
|
+
assert.ok(v.exhausted, 'and the turn is flagged unverified for the UI');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('onBlock fires once per block so the runtime can start a hidden revision', () => {
|
|
144
|
+
let calls = 0;
|
|
145
|
+
const v = new Verifier(() => calls++);
|
|
146
|
+
v.afterTool(EXEC, {}, JSON.stringify({success: true}));
|
|
147
|
+
v.atStop();
|
|
148
|
+
v.atStop();
|
|
149
|
+
assert.equal(calls, 2);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('a malformed tool response does not crash the gate', () => {
|
|
153
|
+
const v = new Verifier();
|
|
154
|
+
v.afterTool(EXEC, {}, 'not json');
|
|
155
|
+
v.afterTool(EXEC, {}, '');
|
|
156
|
+
assert.ok(blocked(v.atStop()), 'unparseable means unverified, not verified');
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('a view function call blocks the Stop until a verify passes; listing and reading do not', () => {
|
|
160
|
+
const v = new Verifier();
|
|
161
|
+
v.afterTool('list_view_functions', {query: 'range'}, JSON.stringify({success: true, functions: []}));
|
|
162
|
+
v.afterTool('get_view_function_result', {name: 'getRange', parameters: {}}, JSON.stringify({success: true}));
|
|
163
|
+
assert.ok(!blocked(v.atStop()));
|
|
164
|
+
v.afterTool('call_view_function', {name: 'setRange', parameters: {min: 1}}, JSON.stringify({success: true}));
|
|
165
|
+
assert.ok(blocked(v.atStop()));
|
|
166
|
+
v.afterTool(VERIFY, {assertion: 'return 1', description: 'range set'}, JSON.stringify({passed: true}));
|
|
167
|
+
assert.ok(!blocked(v.atStop()));
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test('a Datagrok domain tool blocks the Stop by its op', () => {
|
|
171
|
+
const r = new Verifier();
|
|
172
|
+
r.afterTool('mcp__datagrok__datagrok_spaces', {op: 'list'}, JSON.stringify({ok: true}));
|
|
173
|
+
r.afterTool('mcp__datagrok__datagrok_functions', {op: 'get', args: {name: 'Chem:smilesToMw'}}, '{}');
|
|
174
|
+
r.afterTool('mcp__datagrok__datagrok_functions', {}, '{"ops": []}');
|
|
175
|
+
assert.ok(!blocked(r.atStop()));
|
|
176
|
+
const w = new Verifier();
|
|
177
|
+
w.afterTool('mcp__datagrok__datagrok_spaces', {op: 'delete', args: {id: 's'}}, JSON.stringify({ok: true}));
|
|
178
|
+
assert.ok(blocked(w.atStop()));
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// The agent's browser tools report a call that failed or was aborted as {passed: false, error}.
|
|
182
|
+
test('a verify call the browser never answered counts as a failed verify', () => {
|
|
183
|
+
const v = new Verifier();
|
|
184
|
+
v.afterTool(EXEC, {code: 'x'}, JSON.stringify({success: false, error: 'aborted'}));
|
|
185
|
+
v.afterTool(VERIFY, {assertion: 'a', description: 'd'}, JSON.stringify({passed: false, error: 'aborted'}));
|
|
186
|
+
assert.match(v.atStop(), /Verification has failed 1 time/);
|
|
187
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const test = require('node:test');
|
|
2
|
+
const assert = require('node:assert');
|
|
3
|
+
const {raceIdle, IDLE, processTable} = require('../dist/watchdog');
|
|
4
|
+
|
|
5
|
+
const after = (ms, value) => new Promise((r) => setTimeout(() => r(value), ms));
|
|
6
|
+
|
|
7
|
+
test('passes through a value that settles in time', async () => {
|
|
8
|
+
assert.equal(await raceIdle(after(10, 'event'), 200), 'event');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('reports IDLE when nothing settles in time', async () => {
|
|
12
|
+
assert.equal(await raceIdle(after(200, 'event'), 20), IDLE);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('IDLE is distinguishable from a legitimate falsy value', async () => {
|
|
16
|
+
// A turn can legitimately yield undefined/null; conflating that with a timeout would kill
|
|
17
|
+
// healthy turns, so the sentinel must not be falsy-equal to anything real.
|
|
18
|
+
assert.notEqual(await raceIdle(after(5, undefined), 200), IDLE);
|
|
19
|
+
assert.notEqual(await raceIdle(after(5, null), 200), IDLE);
|
|
20
|
+
assert.notEqual(await raceIdle(after(5, 0), 200), IDLE);
|
|
21
|
+
assert.notEqual(await raceIdle(after(5, false), 200), IDLE);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('rejection propagates rather than being swallowed as a timeout', async () => {
|
|
25
|
+
await assert.rejects(() => raceIdle(Promise.reject(new Error('boom')), 200), /boom/);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('does not hold the event loop open after resolving early', async () => {
|
|
29
|
+
// If the idle timer were left pending, a finished process would hang for the timeout duration.
|
|
30
|
+
const t0 = Date.now();
|
|
31
|
+
await raceIdle(after(5, 'x'), 60000);
|
|
32
|
+
assert.ok(Date.now() - t0 < 1000, 'resolved promptly');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('processTable returns an array and never throws off-Linux', () => {
|
|
36
|
+
const table = processTable();
|
|
37
|
+
assert.ok(Array.isArray(table));
|
|
38
|
+
for (const p of table) {
|
|
39
|
+
assert.equal(typeof p.pid, 'number');
|
|
40
|
+
assert.equal(typeof p.ppid, 'number');
|
|
41
|
+
assert.equal(typeof p.command, 'string');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"env": {
|
|
4
|
+
"node": true,
|
|
5
|
+
"es2022": true
|
|
6
|
+
},
|
|
7
|
+
"extends": [
|
|
8
|
+
"google"
|
|
9
|
+
],
|
|
10
|
+
"parser": "@typescript-eslint/parser",
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"ecmaVersion": 2022,
|
|
13
|
+
"sourceType": "module"
|
|
14
|
+
},
|
|
15
|
+
"plugins": [
|
|
16
|
+
"@typescript-eslint"
|
|
17
|
+
],
|
|
18
|
+
"rules": {
|
|
19
|
+
"indent": ["error", 2, {"SwitchCase": 1}],
|
|
20
|
+
"max-len": ["error", 120],
|
|
21
|
+
"max-params": ["warn", 7],
|
|
22
|
+
"no-throw-literal": "error",
|
|
23
|
+
"no-unused-vars": "off",
|
|
24
|
+
"@typescript-eslint/no-unused-vars": ["warn", {"varsIgnorePattern": "^_", "argsIgnorePattern": "^_"}],
|
|
25
|
+
"require-jsdoc": "off",
|
|
26
|
+
"valid-jsdoc": "off",
|
|
27
|
+
"spaced-comment": "off",
|
|
28
|
+
"linebreak-style": "off",
|
|
29
|
+
"quote-props": "off",
|
|
30
|
+
"curly": ["error", "multi-or-nest"],
|
|
31
|
+
"brace-style": ["error", "1tbs", {"allowSingleLine": true}],
|
|
32
|
+
"block-spacing": [2, "always"],
|
|
33
|
+
"comma-dangle": "off",
|
|
34
|
+
"comma-spacing": "error",
|
|
35
|
+
"comma-style": "error",
|
|
36
|
+
"guard-for-in": "off",
|
|
37
|
+
"space-infix-ops": "error"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
FROM node:
|
|
1
|
+
FROM node:22.23.4-alpine AS build
|
|
2
2
|
WORKDIR /app
|
|
3
3
|
COPY package.json package-lock.json* ./
|
|
4
4
|
RUN npm ci
|
|
5
5
|
COPY tsconfig.json ./
|
|
6
6
|
COPY src ./src
|
|
7
|
-
RUN npx tsc &&
|
|
7
|
+
RUN npx tsc && npm prune --production
|
|
8
|
+
|
|
9
|
+
# node 20 is EOL since 2026-04
|
|
10
|
+
FROM node:22.23.4-alpine
|
|
11
|
+
RUN apk upgrade --no-cache && rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx /opt/yarn* /usr/local/bin/yarn /usr/local/bin/yarnpkg
|
|
12
|
+
WORKDIR /app
|
|
13
|
+
COPY --from=build /app/package.json ./
|
|
14
|
+
COPY --from=build /app/node_modules ./node_modules
|
|
15
|
+
COPY --from=build /app/dist ./dist
|
|
8
16
|
USER node
|
|
9
17
|
EXPOSE 3003
|
|
10
18
|
HEALTHCHECK --interval=5s --timeout=3s --start-period=10s --retries=3 \
|