@corenel/tools-node 0.3.7 → 0.5.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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/openBrowser.d.ts +2 -0
- package/dist/openBrowser.d.ts.map +1 -0
- package/dist/openBrowser.js +46 -0
- package/dist/openBrowser.js.map +1 -0
- package/dist/promptHost.d.ts.map +1 -1
- package/dist/promptHost.js +15 -0
- package/dist/promptHost.js.map +1 -1
- package/dist/toolGuidance.d.ts +10 -0
- package/dist/toolGuidance.d.ts.map +1 -0
- package/dist/toolGuidance.js +53 -0
- package/dist/toolGuidance.js.map +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { NodeFileService } from './fileService';
|
|
|
2
2
|
export { corenelDir, sidecarDir, authTokenPath, credentialDir, tokenFilePath, credentialFilePath, writeAuthToken, readAuthToken, readAuthTokenRead, readCredentialFile, readCredentialFileRead, clearAuthToken, clearAllCredentials, resolveNodeCredential, nodeAuthToken, maskToken, maskAccount, TOKEN_ENV, writeLoginCredential, resolveApiBase, API_BASE_ENV, type StoredCredential, type CredentialSource, type ResolvedCredential, type ResolveCredentialOptions, type CredentialRead, type ApiBaseSource, type ResolvedApiBase, type ResolveApiBaseOptions, } from './auth';
|
|
3
3
|
export { nodePromptHost } from './promptHost';
|
|
4
4
|
export { migrateHomeLayout, type MigrationReport } from './migrateHome';
|
|
5
|
+
export { openBrowser } from './openBrowser';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,UAAU,EAAE,UAAU,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M,eAAe,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { NodeFileService } from './fileService';
|
|
|
3
3
|
export { corenelDir, sidecarDir, authTokenPath, credentialDir, tokenFilePath, credentialFilePath, writeAuthToken, readAuthToken, readAuthTokenRead, readCredentialFile, readCredentialFileRead, clearAuthToken, clearAllCredentials, resolveNodeCredential, nodeAuthToken, maskToken, maskAccount, TOKEN_ENV, writeLoginCredential, resolveApiBase, API_BASE_ENV, } from './auth';
|
|
4
4
|
export { nodePromptHost } from './promptHost';
|
|
5
5
|
export { migrateHomeLayout } from './migrateHome';
|
|
6
|
+
export { openBrowser } from './openBrowser';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EACvF,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,sBAAsB,EAC5F,cAAc,EAAE,mBAAmB,EACnC,qBAAqB,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EACvE,oBAAoB,EAAE,cAAc,EAAE,YAAY,GAInD,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAwB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EACvF,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,sBAAsB,EAC5F,cAAc,EAAE,mBAAmB,EACnC,qBAAqB,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EACvE,oBAAoB,EAAE,cAAc,EAAE,YAAY,GAInD,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAwB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openBrowser.d.ts","sourceRoot":"","sources":["../openBrowser.ts"],"names":[],"mappings":"AAgCA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAa7C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Open a URL in the user's default browser, per platform. */
|
|
2
|
+
/**
|
|
3
|
+
* Open `url` in the user's browser.
|
|
4
|
+
*
|
|
5
|
+
* NOT `cmd /c start` ON WINDOWS, and this is the whole reason this function has
|
|
6
|
+
* a comment. cmd RE-PARSES the command line it is given, and `&` is its command
|
|
7
|
+
* separator -- so an OAuth authorization URL, which is nothing but `&`, arrived
|
|
8
|
+
* at the browser truncated at the first one:
|
|
9
|
+
*
|
|
10
|
+
* in https://mcp.notion.com/authorize?response_type=code&client_id=...&state=...
|
|
11
|
+
* out https://mcp.notion.com/authorize?response_type=code
|
|
12
|
+
*
|
|
13
|
+
* with cmd additionally trying to RUN `client_id=...` as a command. The server
|
|
14
|
+
* then answers `invalid_request: Missing client_id parameter`, which reads as a
|
|
15
|
+
* bug in the request we built -- and the request was fine. Every OAuth sign-in
|
|
16
|
+
* on Windows failed this way, while the same URL pasted by hand worked, which
|
|
17
|
+
* is what made it look like a server problem for so long.
|
|
18
|
+
*
|
|
19
|
+
* Quoting does not fix it: Node escapes the quotes on the way in, so the
|
|
20
|
+
* browser receives them literally. The fix is to not involve a shell at all.
|
|
21
|
+
* `rundll32 url.dll,FileProtocolHandler` hands the URL to the default handler
|
|
22
|
+
* through CreateProcess, where argv is passed as-is and `&` is just a character.
|
|
23
|
+
*
|
|
24
|
+
* LIVES IN @corenel/tools-node, NOT auth.ts or an mcp package, because BOTH
|
|
25
|
+
* @corenel/sidecar's own `corenel login` and @corenel/mcp's OAuth flow
|
|
26
|
+
* (packages/mcp/src/oauth/login.ts's default `openBrowser`) need exactly this
|
|
27
|
+
* function, and both already depend on this package. A copy in each would be
|
|
28
|
+
* two implementations of one Windows workaround to keep in sync by hand --
|
|
29
|
+
* this file is the fix for that, not a second one.
|
|
30
|
+
*/
|
|
31
|
+
import { spawn } from 'node:child_process';
|
|
32
|
+
export function openBrowser(url) {
|
|
33
|
+
const [cmd, args] = process.platform === 'win32'
|
|
34
|
+
? ['rundll32', ['url.dll,FileProtocolHandler', url]]
|
|
35
|
+
: process.platform === 'darwin'
|
|
36
|
+
? ['open', [url]]
|
|
37
|
+
: ['xdg-open', [url]];
|
|
38
|
+
// `shell: false` (the default) is load-bearing here -- a shell would
|
|
39
|
+
// reintroduce exactly the re-parsing this avoids.
|
|
40
|
+
const child = spawn(cmd, args, { detached: true, stdio: 'ignore' });
|
|
41
|
+
// Never let a failure to open a browser take down the caller: the URL has
|
|
42
|
+
// already been surfaced to the user, who can open it themselves.
|
|
43
|
+
child.on('error', () => { });
|
|
44
|
+
child.unref();
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=openBrowser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openBrowser.js","sourceRoot":"","sources":["../openBrowser.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO;QAC9C,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;QACpD,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ;YAC7B,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,qEAAqE;IACrE,kDAAkD;IAClD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAa,EAAE,IAAgB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1F,0EAA0E;IAC1E,iEAAiE;IACjE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAsD,CAAC,CAAC,CAAC;IAChF,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC"}
|
package/dist/promptHost.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promptHost.d.ts","sourceRoot":"","sources":["../promptHost.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"promptHost.d.ts","sourceRoot":"","sources":["../promptHost.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,+BAA+B,CAAC;AAwC/E;+EAC+E;AAC/E,wBAAgB,cAAc,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,UAAU,CAqCxF"}
|
package/dist/promptHost.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* logic; this provides where the files live and how they compile. */
|
|
7
7
|
import { PrompdParser, PrompdCompiler, MemoryFileSystem, HybridFileSystem } from '@prompd/core';
|
|
8
8
|
import { normalizeFilePath, flattenFiles } from '@corenel/protocol';
|
|
9
|
+
import { nodeToolGuidance } from './toolGuidance';
|
|
9
10
|
const parser = new PrompdParser();
|
|
10
11
|
const compiler = new PrompdCompiler();
|
|
11
12
|
/** Stream non-source files (context assets) to the compiler from a FileService. */
|
|
@@ -72,6 +73,20 @@ export function nodePromptHost(workspace, project) {
|
|
|
72
73
|
return compile('', values, new HybridFileSystem(sources, backend(workspace)), '/' + p);
|
|
73
74
|
},
|
|
74
75
|
siteIndex: () => '', // no site index in node (the help chat is browser-only)
|
|
76
|
+
/* Who the agent says it IS. Without this, `composeAgentSystem` falls back
|
|
77
|
+
* to its `'Prompd'` default and the `corenel` binary's agent introduced
|
|
78
|
+
* itself as "the Prompd assistant" -- the same leak already fixed for the
|
|
79
|
+
* browser help chat (composeHelpSystem) and missed here, because the node
|
|
80
|
+
* host is the one PromptHost that never implemented the hook.
|
|
81
|
+
*
|
|
82
|
+
* Constant, not a parameter: every node consumer of this host (the CLI and
|
|
83
|
+
* the sidecar) IS Corenel. A host that is not should implement its own. */
|
|
84
|
+
appName: () => 'Corenel',
|
|
85
|
+
/* The product's guidance for the tools this run actually has -- the shell,
|
|
86
|
+
* long-running processes, and deferred MCP tools. Gated per tool inside
|
|
87
|
+
* nodeToolGuidance, because this same host serves the sidecar, whose shell
|
|
88
|
+
* is behind --allow-shell. */
|
|
89
|
+
toolGuidance: (names) => nodeToolGuidance(names),
|
|
75
90
|
};
|
|
76
91
|
}
|
|
77
92
|
//# sourceMappingURL=promptHost.js.map
|
package/dist/promptHost.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promptHost.js","sourceRoot":"","sources":["../promptHost.ts"],"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E,CAAC,SAAS;QACxB;;;sCAG8B;QAC9B,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC;KACjD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const SHELL_TOOL = "shell";
|
|
2
|
+
export declare const PROC_TOOLS: readonly ["proc_start", "proc_stop", "proc_list"];
|
|
3
|
+
/**
|
|
4
|
+
* Assemble the guidance for the tools this run actually has.
|
|
5
|
+
*
|
|
6
|
+
* Returns '' when none of them are present, which composes to no block at all
|
|
7
|
+
* rather than an empty heading.
|
|
8
|
+
*/
|
|
9
|
+
export declare function nodeToolGuidance(toolNames: string[]): string;
|
|
10
|
+
//# sourceMappingURL=toolGuidance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolGuidance.d.ts","sourceRoot":"","sources":["../toolGuidance.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,UAAU,mDAAoD,CAAC;AAc5E;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAQ5D"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* The node faces' own tool guidance (PromptHost.toolGuidance).
|
|
2
|
+
*
|
|
3
|
+
* THE GAP this fills: running commands is the headline capability of a
|
|
4
|
+
* terminal agent and the shared base prompt said nothing about it -- not when
|
|
5
|
+
* to prefer a command over the file tools, not that a long-running one needs a
|
|
6
|
+
* different tool, not that some tools are deliberately withheld until searched
|
|
7
|
+
* for. The base prompt could not say it, because the browser has no shell and
|
|
8
|
+
* a shared prompt that describes one is how `search_packages` came to be
|
|
9
|
+
* advertised to a CLI that never registers it.
|
|
10
|
+
*
|
|
11
|
+
* EVERY BLOCK IS GATED ON ITS TOOL. The sidecar runs on this same host with
|
|
12
|
+
* its shell behind `--allow-shell`, and a `--acp-policy read-only` run has
|
|
13
|
+
* fewer tools still, so "this is node, therefore there is a shell" is false.
|
|
14
|
+
* Each paragraph below appears only when the tool it describes was handed to
|
|
15
|
+
* this run; a run with none of them contributes nothing at all.
|
|
16
|
+
*/
|
|
17
|
+
/* Tools whose presence unlocks a paragraph.
|
|
18
|
+
*
|
|
19
|
+
* `tool_search` comes from the constant the loop itself registers. `shell` and
|
|
20
|
+
* the proc tools cannot: `shellTool` lives in @corenel/cli and `procTools` is
|
|
21
|
+
* registered by the CLI too, and tools-node depends on neither. The literals
|
|
22
|
+
* below are therefore a COPY, and a copy drifts -- so cli's
|
|
23
|
+
* toolGuidance.names.test.ts pins them against the real tool objects, from a
|
|
24
|
+
* package that can import both. Change a name here and that test fails. */
|
|
25
|
+
export const SHELL_TOOL = 'shell';
|
|
26
|
+
export const PROC_TOOLS = ['proc_start', 'proc_stop', 'proc_list'];
|
|
27
|
+
/* NO DEFERRED-TOOLS BLOCK HERE, deliberately. Explaining that MCP tools are
|
|
28
|
+
* withheld until searched for belongs to `serverIndex()` (harness/tools/
|
|
29
|
+
* toolSearch.ts), which the LOOP appends to the system prompt -- and only when
|
|
30
|
+
* deferred tools actually exist. It also lists the connected servers, which
|
|
31
|
+
* this module cannot know. A copy here would be strictly worse AND would
|
|
32
|
+
* render at the wrong times: `tool_search` is registered by the loop, not by
|
|
33
|
+
* the host, so it is never in the names this function is handed. */
|
|
34
|
+
const SHELL = `Running a command is often the shortest correct answer: use \`${SHELL_TOOL}\` for anything a command already does well -- listing, searching, git, package managers, build and test runners -- instead of reconstructing it from file reads. It waits for the command to finish and returns its output, so it is the wrong tool for anything that does not exit on its own.`;
|
|
35
|
+
const PROCS = `A command that keeps running (a dev server, a watcher, a queue worker) belongs to \`${PROC_TOOLS[0]}\`, not \`${SHELL_TOOL}\` -- starting one with \`${SHELL_TOOL}\` hangs the turn until it is killed. Use \`${PROC_TOOLS[2]}\` to see what is already running before starting anything, and \`${PROC_TOOLS[1]}\` to stop what you started. Do not stop a process you did not start.`;
|
|
36
|
+
/**
|
|
37
|
+
* Assemble the guidance for the tools this run actually has.
|
|
38
|
+
*
|
|
39
|
+
* Returns '' when none of them are present, which composes to no block at all
|
|
40
|
+
* rather than an empty heading.
|
|
41
|
+
*/
|
|
42
|
+
export function nodeToolGuidance(toolNames) {
|
|
43
|
+
const has = new Set(toolNames);
|
|
44
|
+
const parts = [];
|
|
45
|
+
if (has.has(SHELL_TOOL))
|
|
46
|
+
parts.push(SHELL);
|
|
47
|
+
// Any one of the three is enough: they are registered together, and naming a
|
|
48
|
+
// sibling in the text is harmless next to the one that is actually there.
|
|
49
|
+
if (PROC_TOOLS.some((t) => has.has(t)))
|
|
50
|
+
parts.push(PROCS);
|
|
51
|
+
return parts.join('\n\n');
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=toolGuidance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolGuidance.js","sourceRoot":"","sources":["../toolGuidance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;2EAO2E;AAC3E,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC;AAClC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,CAAU,CAAC;AAE5E;;;;;;oEAMoE;AAEpE,MAAM,KAAK,GAAG,iEAAiE,UAAU,kSAAkS,CAAC;AAE5X,MAAM,KAAK,GAAG,uFAAuF,UAAU,CAAC,CAAC,CAAC,aAAa,UAAU,6BAA6B,UAAU,+CAA+C,UAAU,CAAC,CAAC,CAAC,qEAAqE,UAAU,CAAC,CAAC,CAAC,uEAAuE,CAAC;AAEtY;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAmB;IAClD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,6EAA6E;IAC7E,0EAA0E;IAC1E,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1D,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corenel/tools-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "Elastic-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Corenel node capabilities — the tools-web twin. A disk-backed FileService (the harness file tools + node PromptHost workspace) over node:fs, confined to a root. Shell/secrets/~/.corenel to follow.",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@prompd/core": "0.5.0-beta.10",
|
|
19
|
-
"@corenel/
|
|
20
|
-
"@corenel/
|
|
19
|
+
"@corenel/protocol": "0.8.0",
|
|
20
|
+
"@corenel/harness": "0.9.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^24.13.1",
|