neoctl 0.2.47 → 0.2.48

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.
Files changed (36) hide show
  1. package/README.md +59 -59
  2. package/dist/agents/agent-activity.js +1 -1
  3. package/dist/agents/agent-activity.js.map +1 -1
  4. package/dist/context/prompts.js +3 -4
  5. package/dist/context/prompts.js.map +1 -1
  6. package/dist/context/system.md +16 -16
  7. package/dist/core/message-pipeline.js +2 -2
  8. package/dist/core/message-pipeline.js.map +1 -1
  9. package/dist/core/query-engine.d.ts +6 -0
  10. package/dist/core/query-engine.js +60 -3
  11. package/dist/core/query-engine.js.map +1 -1
  12. package/dist/execution/filesystem.js +22 -22
  13. package/dist/execution/process.js +44 -44
  14. package/dist/model/model-metadata.json +137 -137
  15. package/dist/repl/index.js +30 -30
  16. package/dist/repl/index.js.map +1 -1
  17. package/dist/session/tool-result-memory.js +2 -2
  18. package/dist/session/tool-result-memory.js.map +1 -1
  19. package/dist/tools/builtins/image-capabilities.d.ts +2 -2
  20. package/dist/tools/builtins/image-capabilities.js +3 -3
  21. package/dist/tools/builtins/image-capabilities.js.map +1 -1
  22. package/dist/tools/builtins/image-generation-tool.js +1 -1
  23. package/dist/tools/builtins/image-generation-tool.js.map +1 -1
  24. package/dist/tools/builtins/image-loader-tool.js +2 -1
  25. package/dist/tools/builtins/image-loader-tool.js.map +1 -1
  26. package/dist/web/demo-tools.js +1 -1
  27. package/dist/web/demo-tools.js.map +1 -1
  28. package/dist/web/html.js +5 -5
  29. package/dist/web/index.d.ts +1 -0
  30. package/dist/web/index.js +15 -5
  31. package/dist/web/index.js.map +1 -1
  32. package/dist/web/terminal-presentation.js +1 -1
  33. package/dist/web/terminal-presentation.js.map +1 -1
  34. package/docs/prompt-config.md +86 -86
  35. package/package.json +1 -1
  36. package/scripts/copy-prompt-resources.mjs +5 -5
@@ -46,7 +46,7 @@ export function terminalPreviews(data, limit = 1400) {
46
46
  const value = data[stream];
47
47
  if (typeof value !== 'string')
48
48
  continue;
49
- previews.push({ label: `${stream}${data.tty === true && stream === 'stdout' ? '(TTY 合流)' : ''}${value.length > limit ? ' · 预览已截断' : ''}`, kind: 'code', content: value.length > limit ? value.slice(0, limit) : value });
49
+ previews.push({ label: `${stream}${data.tty === true && stream === 'stdout' ? '(TTY 合流)' : ''}${value.length > limit ? '(预览已截断)' : ''}`, kind: 'code', content: value.length > limit ? value.slice(0, limit) : value });
50
50
  }
51
51
  return previews;
52
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"terminal-presentation.js","sourceRoot":"","sources":["../../src/web/terminal-presentation.ts"],"names":[],"mappings":"AAGA,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3G,MAAM,UAAU,cAAc,CAAC,IAA6B;IAC1D,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,OAAO,CAAC;IAC3C,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACnF,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7L,IAAI,IAAI,CAAC,kBAAkB,KAAK,QAAQ,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,IAAI,IAA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I,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1N,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AACD,MAAM,UAAU,kBAAkB,CAAC,IAA6B;IAC9D,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC5E,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9J,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
@@ -1,86 +1,86 @@
1
- # Versioned global system prompt configuration
2
-
3
- The core runtime, not the browser, owns the global base system prompt. `DefaultContextManager` (including the default used by `QueryEngine`, CLI and web runtimes) reads it on **every context build**. Saving affects future builds in all sessions using this baseline, without a restart. It does not mutate a request already sent to a provider. Session-specific prompt controls, when used, are a separate scope and do not write this file.
4
-
5
- ## Files and packaging
6
-
7
- - The current version's complete natural-language baseline is `src/context/system.md`, not a TypeScript string or an empty override.
8
- - `npm run build` copies it to `dist/context/system.md`; npm's existing `files: ["dist", ...]` includes that file. `prepare`/`prepack` run the build. The standalone distribution verifies and copies it with `dist`, and copies `package.json` for the version identity.
9
- - On the first GET/build, core copies this Markdown into `~/.neoctl/prompts/<package-version>/system.md` (`%USERPROFILE%\.neoctl` on Windows). Subsequent reads and saves use **that same writable file**. Existing files, including invalid/empty files, are never reset to defaults. Each package version initializes its own file and leaves older versions untouched; migration between versions is an explicit user action.
10
- - Trusted hosts/tests can set `NEO_SYSTEM_PROMPT_PATH` to an isolated file, or construct `PromptConfigStore({filePath})` and pass it as `DefaultContextManager({promptConfigStore})`. `homeDir`/`version` are also host-only store options. The HTTP client cannot select a path or version.
11
-
12
- The Markdown contains Agent Scaffold, Doing Tasks, generic tool-use etiquette, and Tone And Output. Core still appends current tool availability, tool-result budgets, image loading/generation capability instructions, and secret-handling instructions. Plugin sections, application prompts, and Runtime agent/session context retain their existing composition chain. Global editing is **not** implemented with `overrideSystemPrompt`, so changing the baseline does not replace plugin/app/runtime sections.
13
-
14
- ## HTTP protocol
15
-
16
- Handled by the engine's actual HTTP router **before** selecting/initializing a session. The outer web proxy needs no special route.
17
-
18
- ### `GET /api/prompt-config`
19
-
20
- 200 JSON, `Cache-Control: no-store`:
21
-
22
- ```json
23
- {"content":"## Agent Scaffold\n...","revision":"<64 lowercase SHA-256 hex characters>","version":"0.2.37","path":"<absolute server-owned system.md path>"}
24
- ```
25
-
26
- ### `POST /api/prompt-config`
27
-
28
- Accepts only `{"content":"...","revision":"<revision from GET>"}`. Content must be a string, contain non-whitespace text, and occupy at most **200000 UTF-8 bytes**. Original whitespace/newlines are preserved. Success is 200 JSON:
29
-
30
- ```json
31
- {"ok":true,"content":"...","revision":"<new SHA-256>","version":"0.2.37","path":"<same path>"}
32
- ```
33
-
34
- Errors always use non-2xx HTTP status and `{"errorCode":"...","error":"..."}`:
35
-
36
- | HTTP | errorCode | Meaning |
37
- |---|---|---|
38
- | 400 | `PROMPT_CONFIG_INVALID` | Invalid JSON/fields/content/revision, or client-supplied path/version |
39
- | 409 | `PROMPT_CONFIG_CONFLICT` | File revision changed or file disappeared; reload before retrying |
40
- | 413 | `PROMPT_CONFIG_TOO_LARGE` | Content or bounded JSON request envelope too large |
41
- | 405 | `PROMPT_CONFIG_METHOD_NOT_ALLOWED` | Only GET and POST supported |
42
- | 503 | `PROMPT_CONFIG_BUSY` | Could not acquire writer lock within ten seconds |
43
- | 500 | `PROMPT_CONFIG_STORAGE_ERROR` | Filesystem/storage failure |
44
-
45
- Clients should retain unsaved drafts on failure; never automatically overwrite after a 409. Fetch the latest revision and let the user decide. Identical content has the same revision, including after a restart; external edits change the hash.
46
-
47
- ## Concurrency and recovery
48
-
49
- Reads use the actual file, not a process content cache. Initialization and compare-and-save acquire an atomic sibling `<file>.lock` directory, serializing participating writers across sessions, store objects, and OS processes. The revision comparison happens inside this lock. Writes create a unique same-directory temporary file, flush it, and atomically rename it into place. Readers therefore see an old or new complete file, not a partly written body. Normal completion removes the lock and temporary file.
50
-
51
- The lock is deliberately **not stolen based on age** (which could allow two live writers). After a crashed/killed writer, an administrator may remove the leftover `.lock` directory only after confirming that no writer is active. The prior complete `system.md` remains readable; orphan `.tmp` files can likewise be removed. External editors should save atomically; the API detects edits made before its locked revision check, but cannot coordinate an external editor that ignores the lock and writes concurrently.
52
-
53
- ## Layered session instructions
54
-
55
- `GET /api/session-prompt?tabId=...&sessionId=...` returns `{content, mode, override, revision, effectiveContent, effectiveRevision}`. **content is only the editable session instruction**, empty when inheriting; `effectiveContent` is a read-only composition without internal cache markers. Clients must never save the effective preview as editable content.
56
-
57
- Modes:
58
-
59
- - `inherit`: no session instruction; follows the latest global file.
60
- - `append`: latest global baseline plus session instructions (default for new edits).
61
- - `replace_base`: replaces only sections tagged `source: "global"`, preserving runtime/tool/plugin/application sections. Embedded custom context managers must tag their global sections to opt into replacement.
62
- - `legacy_full_override`: existing transcripts without a mode retain their exact historical full replacement. No automatic text stripping or migration occurs. The UI warns and requires confirmation before switching modes; new sessions cannot create this mode. Old clients editing an existing legacy prompt without specifying mode retain legacy semantics.
63
-
64
- `POST` accepts `{content, mode?, revision}` or `{reset:true, revision}`. Success adds `{ok:true, deferred}` to the GET shape. Reset returns to inherit and clears only session configuration. Empty custom text, internal markers, invalid modes, unknown fields, and content over 256 Ki characters are rejected (400 / `SESSION_PROMPT_INVALID`). Competing session edits return 409 / `SESSION_PROMPT_CONFLICT`; storage failures return 500 / `SESSION_PROMPT_FAILED`.
65
-
66
- `revision` covers the session configuration and its owner, not generated text. Global/tool/plugin changes update `effectiveRevision` and the preview without invalidating a session draft. Global editing retains its independent file CAS. Clients preserve drafts on failed saves and runtime preview updates.
67
-
68
- Session content and mode persist in the transcript and restore in the same session only. Accepted busy edits persist immediately but become active at the next model-turn boundary; in-flight requests do not change. Runtime context exposes active `mode`, `effectiveRevision`, and queued `pendingMode`/`deferred`, separately from the editor's desired state.
69
-
70
- ## Tool-dependent context
71
-
72
- Effective tool definitions are captured once per model request and used both for capability instructions and the provider tools list. Plugin prompt sections may declare `requiresTools: ["tool_name"]`; such sections are included only when all dependencies are in the effective tool set. General plugin instructions remain independent. The downloads plugin uses this for `expose_downloads`. Disabled tools do not rewrite arbitrary user-authored text; runtime instructions explicitly explain that text cannot enable an unavailable tool.
73
-
74
- Web hosts provide `resolveGlobalToolOverrides` alongside persistence. Existing runtimes re-read this shared source at the next model-turn boundary or idle preview/tool-list refresh, so `inherit` follows global changes without reconstructing the session. Explicit session enable/disable settings retain precedence. Busy previews never change the executing tool registry. This is lazy refresh within the host, not a cross-process file watcher or a push update to every browser tab. Tool settings publish only after successful persistence; concurrent global/session writes are serialized.
75
-
76
- ## Validation
77
-
78
- All tests use OS temporary directories and never touch real user configuration:
79
-
80
- ```sh
81
- node --import tsx --test tests/context/prompt-config.test.ts tests/web/prompt-config-protocol.test.ts
82
- npm run typecheck
83
- npm run build
84
- ```
85
-
86
- Coverage includes exact Markdown initialization, preservation/reload, restart/separate-process reads, cross-process CAS, concurrent initialization, illegal content and byte limits, actual ContextManager composition and QueryEngine future requests, real HTTP handler GET/POST/error semantics, and global route placement before session initialization.
1
+ # Versioned global system prompt configuration
2
+
3
+ The core runtime, not the browser, owns the global base system prompt. `DefaultContextManager` (including the default used by `QueryEngine`, CLI and web runtimes) reads it on **every context build**. Saving affects future builds in all sessions using this baseline, without a restart. It does not mutate a request already sent to a provider. Session-specific prompt controls, when used, are a separate scope and do not write this file.
4
+
5
+ ## Files and packaging
6
+
7
+ - The current version's complete natural-language baseline is `src/context/system.md`, not a TypeScript string or an empty override.
8
+ - `npm run build` copies it to `dist/context/system.md`; npm's existing `files: ["dist", ...]` includes that file. `prepare`/`prepack` run the build. The standalone distribution verifies and copies it with `dist`, and copies `package.json` for the version identity.
9
+ - On the first GET/build, core copies this Markdown into `~/.neoctl/prompts/<package-version>/system.md` (`%USERPROFILE%\.neoctl` on Windows). Subsequent reads and saves use **that same writable file**. Existing files, including invalid/empty files, are never reset to defaults. Each package version initializes its own file and leaves older versions untouched; migration between versions is an explicit user action.
10
+ - Trusted hosts/tests can set `NEO_SYSTEM_PROMPT_PATH` to an isolated file, or construct `PromptConfigStore({filePath})` and pass it as `DefaultContextManager({promptConfigStore})`. `homeDir`/`version` are also host-only store options. The HTTP client cannot select a path or version.
11
+
12
+ The Markdown contains Agent Scaffold, Doing Tasks, generic tool-use etiquette, and Tone And Output. Core still appends current tool availability, tool-result budgets, missing-image-capability notices, and secret-handling instructions. Image usage guidance lives in the enabled tools' descriptions; download/video plugins also keep their delivery contracts in tool descriptions rather than duplicate prompt sections. Plugin sections, application prompts, and Runtime agent/session context retain their existing composition chain. Global editing is **not** implemented with `overrideSystemPrompt`, so changing the baseline does not replace plugin/app/runtime sections.
13
+
14
+ ## HTTP protocol
15
+
16
+ Handled by the engine's actual HTTP router **before** selecting/initializing a session. The outer web proxy needs no special route.
17
+
18
+ ### `GET /api/prompt-config`
19
+
20
+ 200 JSON, `Cache-Control: no-store`:
21
+
22
+ ```json
23
+ {"content":"## Agent Scaffold\n...","revision":"<64 lowercase SHA-256 hex characters>","version":"0.2.37","path":"<absolute server-owned system.md path>"}
24
+ ```
25
+
26
+ ### `POST /api/prompt-config`
27
+
28
+ Accepts only `{"content":"...","revision":"<revision from GET>"}`. Content must be a string, contain non-whitespace text, and occupy at most **200000 UTF-8 bytes**. Original whitespace/newlines are preserved. Success is 200 JSON:
29
+
30
+ ```json
31
+ {"ok":true,"content":"...","revision":"<new SHA-256>","version":"0.2.37","path":"<same path>"}
32
+ ```
33
+
34
+ Errors always use non-2xx HTTP status and `{"errorCode":"...","error":"..."}`:
35
+
36
+ | HTTP | errorCode | Meaning |
37
+ |---|---|---|
38
+ | 400 | `PROMPT_CONFIG_INVALID` | Invalid JSON/fields/content/revision, or client-supplied path/version |
39
+ | 409 | `PROMPT_CONFIG_CONFLICT` | File revision changed or file disappeared; reload before retrying |
40
+ | 413 | `PROMPT_CONFIG_TOO_LARGE` | Content or bounded JSON request envelope too large |
41
+ | 405 | `PROMPT_CONFIG_METHOD_NOT_ALLOWED` | Only GET and POST supported |
42
+ | 503 | `PROMPT_CONFIG_BUSY` | Could not acquire writer lock within ten seconds |
43
+ | 500 | `PROMPT_CONFIG_STORAGE_ERROR` | Filesystem/storage failure |
44
+
45
+ Clients should retain unsaved drafts on failure; never automatically overwrite after a 409. Fetch the latest revision and let the user decide. Identical content has the same revision, including after a restart; external edits change the hash.
46
+
47
+ ## Concurrency and recovery
48
+
49
+ Reads use the actual file, not a process content cache. Initialization and compare-and-save acquire an atomic sibling `<file>.lock` directory, serializing participating writers across sessions, store objects, and OS processes. The revision comparison happens inside this lock. Writes create a unique same-directory temporary file, flush it, and atomically rename it into place. Readers therefore see an old or new complete file, not a partly written body. Normal completion removes the lock and temporary file.
50
+
51
+ The lock is deliberately **not stolen based on age** (which could allow two live writers). After a crashed/killed writer, an administrator may remove the leftover `.lock` directory only after confirming that no writer is active. The prior complete `system.md` remains readable; orphan `.tmp` files can likewise be removed. External editors should save atomically; the API detects edits made before its locked revision check, but cannot coordinate an external editor that ignores the lock and writes concurrently.
52
+
53
+ ## Layered session instructions
54
+
55
+ `GET /api/session-prompt?tabId=...&sessionId=...` returns `{content, mode, override, revision, effectiveContent, effectiveRevision}`. **content is only the editable session instruction**, empty when inheriting; `effectiveContent` is a read-only composition without internal cache markers. Clients must never save the effective preview as editable content.
56
+
57
+ Modes:
58
+
59
+ - `inherit`: no session instruction; follows the latest global file.
60
+ - `append`: latest global baseline plus session instructions (default for new edits).
61
+ - `replace_base`: replaces only sections tagged `source: "global"`, preserving runtime/tool/plugin/application sections. Embedded custom context managers must tag their global sections to opt into replacement.
62
+ - `legacy_full_override`: existing transcripts without a mode retain their exact historical full replacement. No automatic text stripping or migration occurs. The UI labels the historical instructions and preserves their existing mode when editing; it does not offer a mode selector. New sessions use append and cannot create this mode. Old clients editing an existing legacy prompt without specifying mode retain legacy semantics.
63
+
64
+ `POST` accepts `{content, mode?, revision}` or `{reset:true, revision}`. Success adds `{ok:true, deferred}` to the GET shape. Reset returns to inherit and clears only session configuration. Empty custom text, internal markers, invalid modes, unknown fields, and content over 256 Ki characters are rejected (400 / `SESSION_PROMPT_INVALID`). Competing session edits return 409 / `SESSION_PROMPT_CONFLICT`; storage failures return 500 / `SESSION_PROMPT_FAILED`.
65
+
66
+ `revision` covers the session configuration and its owner, not generated text. Global/tool/plugin changes update `effectiveRevision` and the preview without invalidating a session draft. Global editing retains its independent file CAS. Clients preserve drafts on failed saves and runtime preview updates.
67
+
68
+ Session content and mode persist in the transcript and restore in the same session only. Accepted busy edits persist immediately but become active at the next model-turn boundary; in-flight requests do not change. Runtime context exposes active `mode`, `effectiveRevision`, and queued `pendingMode`/`deferred`, separately from the editor's desired state.
69
+
70
+ ## Tool-dependent context
71
+
72
+ Effective tool definitions are captured once per model request and used both for capability instructions and the provider tools list. Plugin prompt sections may declare `requiresTools: ["tool_name"]`; such sections are included only when all dependencies are in the effective tool set. General plugin instructions remain independent. The downloads plugin uses this for `expose_downloads`. Disabled tools do not rewrite arbitrary user-authored text; runtime instructions explicitly explain that text cannot enable an unavailable tool.
73
+
74
+ Web hosts provide `resolveGlobalToolOverrides` alongside persistence. Existing runtimes re-read this shared source at the next model-turn boundary or idle preview/tool-list refresh, so `inherit` follows global changes without reconstructing the session. Explicit session enable/disable settings retain precedence. Busy previews never change the executing tool registry. This is lazy refresh within the host, not a cross-process file watcher or a push update to every browser tab. Tool settings publish only after successful persistence; concurrent global/session writes are serialized.
75
+
76
+ ## Validation
77
+
78
+ All tests use OS temporary directories and never touch real user configuration:
79
+
80
+ ```sh
81
+ node --import tsx --test tests/context/prompt-config.test.ts tests/web/prompt-config-protocol.test.ts
82
+ npm run typecheck
83
+ npm run build
84
+ ```
85
+
86
+ Coverage includes exact Markdown initialization, preservation/reload, restart/separate-process reads, cross-process CAS, concurrent initialization, illegal content and byte limits, actual ContextManager composition and QueryEngine future requests, real HTTP handler GET/POST/error semantics, and global route placement before session initialization.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neoctl",
3
- "version": "0.2.47",
3
+ "version": "0.2.48",
4
4
  "description": "TypeScript scaffold for a streaming agent runtime with a REPL UI layer.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,5 +1,5 @@
1
- import { copyFile, mkdir } from "node:fs/promises";
2
-
3
- const destination = new URL("../dist/context/", import.meta.url);
4
- await mkdir(destination, { recursive: true });
5
- await copyFile(new URL("../src/context/system.md", import.meta.url), new URL("system.md", destination));
1
+ import { copyFile, mkdir } from "node:fs/promises";
2
+
3
+ const destination = new URL("../dist/context/", import.meta.url);
4
+ await mkdir(destination, { recursive: true });
5
+ await copyFile(new URL("../src/context/system.md", import.meta.url), new URL("system.md", destination));