xcoder-jarvis-agent 0.0.0-stage → 1.4.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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +243 -2
  3. package/dist/index.d.ts +27 -0
  4. package/dist/index.js +28 -0
  5. package/dist/jarvis/agent.d.ts +50 -0
  6. package/dist/jarvis/agent.js +305 -0
  7. package/dist/jarvis/argv.d.ts +30 -0
  8. package/dist/jarvis/argv.js +138 -0
  9. package/dist/jarvis/budget.d.ts +49 -0
  10. package/dist/jarvis/budget.js +83 -0
  11. package/dist/jarvis/chat/confirm.d.ts +23 -0
  12. package/dist/jarvis/chat/confirm.js +37 -0
  13. package/dist/jarvis/chat/lines.d.ts +41 -0
  14. package/dist/jarvis/chat/lines.js +93 -0
  15. package/dist/jarvis/chat/prompt.d.ts +10 -0
  16. package/dist/jarvis/chat/prompt.js +18 -0
  17. package/dist/jarvis/chat/session.d.ts +46 -0
  18. package/dist/jarvis/chat/session.js +121 -0
  19. package/dist/jarvis/chat/terminator.d.ts +14 -0
  20. package/dist/jarvis/chat/terminator.js +19 -0
  21. package/dist/jarvis/decision.d.ts +64 -0
  22. package/dist/jarvis/decision.js +116 -0
  23. package/dist/jarvis/exit.d.ts +17 -0
  24. package/dist/jarvis/exit.js +17 -0
  25. package/dist/jarvis/memory/store.d.ts +88 -0
  26. package/dist/jarvis/memory/store.js +189 -0
  27. package/dist/jarvis/prompt/assemble.d.ts +61 -0
  28. package/dist/jarvis/prompt/assemble.js +118 -0
  29. package/dist/jarvis/prompt/policy.d.ts +22 -0
  30. package/dist/jarvis/prompt/policy.js +80 -0
  31. package/dist/jarvis/prompt/skills.d.ts +69 -0
  32. package/dist/jarvis/prompt/skills.js +257 -0
  33. package/dist/jarvis/react-loop.d.ts +51 -0
  34. package/dist/jarvis/react-loop.js +160 -0
  35. package/dist/jarvis/telemetry/provenance.d.ts +54 -0
  36. package/dist/jarvis/telemetry/provenance.js +56 -0
  37. package/dist/jarvis/test-helpers.d.ts +14 -0
  38. package/dist/jarvis/test-helpers.js +69 -0
  39. package/dist/jarvis/tools/fs-tools.d.ts +28 -0
  40. package/dist/jarvis/tools/fs-tools.js +292 -0
  41. package/dist/jarvis/tools/memory-tools.d.ts +27 -0
  42. package/dist/jarvis/tools/memory-tools.js +83 -0
  43. package/dist/jarvis/tools/registry.d.ts +54 -0
  44. package/dist/jarvis/tools/registry.js +49 -0
  45. package/dist/jarvis/util/confirm.d.ts +28 -0
  46. package/dist/jarvis/util/confirm.js +54 -0
  47. package/dist/jarvis/util/kill.d.ts +10 -0
  48. package/dist/jarvis/util/kill.js +39 -0
  49. package/dist/jarvis/util/text.d.ts +74 -0
  50. package/dist/jarvis/util/text.js +190 -0
  51. package/dist/program.d.ts +2 -0
  52. package/dist/program.js +12 -0
  53. package/package.json +35 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Neural Node Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,244 @@
1
- # Temporary Holding Version
1
+ <!-- xcoder:version 7 | xcoder:task task-691585 | xcoder:updated 2026-11-05T05:50:24.571Z | xcoder:subtask code-st-b5251b -->
2
+ # xcoder-jarvis-agent
2
3
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
+ Jarvis is a ReAct agent that runs as a local CLI inside a developer's
5
+ workspace. It reasons in a bounded loop, reads the workspace through a small
6
+ allowlist of read-only tools, remembers short notes across sessions, and
7
+ assembles its system prompt at runtime from versioned policy plus skill packs.
8
+
9
+ It is built on `xcoder-dna` and follows the same workspace conventions: ESM,
10
+ TypeScript, npm workspaces, vitest.
11
+
12
+ ## Install and run
13
+
14
+ ```bash
15
+ npm run build -w xcoder-jarvis-agent
16
+ node packages/jarvis-agent/dist/program.js "summarise how the llm client picks a transport"
17
+ ```
18
+
19
+ Once published, the binaries are `jarvis`.
20
+
21
+ ### Reaching jarvis through `xcoder`
22
+
23
+ `xcoder` forwards a `jarvis` command to this binary, so you do not have to
24
+ leave it or remember a dist path:
25
+
26
+ ```bash
27
+ xcoder jarvis --chat
28
+ ```
29
+
30
+ Every argument is handed over verbatim, stdio is inherited (a chat session
31
+ keeps your terminal), and the exit code is jarvis's own — `xcoder` adds only
32
+ `127` when the binary cannot be found and `130` when the run was interrupted.
33
+ No jarvis flag is re-documented there: run `xcoder jarvis --help` for the
34
+ authoritative list. `jarvis` is one of only three delegable targets, alongside
35
+ `litebro` and `bugfinder`; anything else is refused. Jarvis keeps its own
36
+ environment variables, kill switch and run budget — delegation adds none.
37
+ See [DELEGATION.md](https://github.com/org/xcoder-sdlc/blob/main/docs/DELEGATION.md)
38
+ and [LICENSE](./LICENSE).
39
+
40
+ ### Flags
41
+
42
+ | Flag | Meaning | Default |
43
+ |---|---|---|
44
+ | `--skill NAME` | load only this skill pack (repeatable) | all discovered packs |
45
+ | `--max-iterations N` | reasoning steps, clamped to 1..8 | 8 |
46
+ | `--chat` | multi-turn mode: read turns from stdin until `exit`/`quit`/`bye` or EOF | off |
47
+ | `--max-turns N` | chat turns, clamped to 1..200 | 50 |
48
+ | `--no-memory` | skip loading and writing memory | memory on |
49
+ | `--session ID` | session label | generated |
50
+ | `--user ID` | memory scope label | OS user |
51
+ | `--json` | emit one line of JSON | off |
52
+ | `--help` | usage, exit 0 | |
53
+
54
+ ### Exit codes
55
+
56
+ | Code | Meaning |
57
+ |---|---|
58
+ | 0 | answered |
59
+ | 1 | error (bad flags, no task, model failure) |
60
+ | 2 | iteration limit reached |
61
+ | 3 | budget exceeded (in chat: also `--max-turns` reached) |
62
+ | 4 | aborted by the kill switch |
63
+
64
+ Code 2 is always a per-turn outcome in chat mode: a turn that hits its
65
+ iteration limit is reported and the conversation continues.
66
+
67
+ ## Chat mode
68
+
69
+ ```bash
70
+ node packages/jarvis-agent/dist/program.js --chat
71
+ ```
72
+
73
+ Each line you type is one turn. The session ends when you type `exit`, `quit`
74
+ or `bye` on a line by itself (case-insensitive, surrounding spaces ignored) or
75
+ send EOF (Ctrl-D / Ctrl-Z). A line that merely *contains* one of those words —
76
+ `exit now`, `how do I quit a program?` — is an ordinary turn.
77
+
78
+ - **Continuity comes from memory, not from a growing transcript.** Every turn
79
+ re-reads the same memory session and re-assembles the prompt from it, so the
80
+ agent can recall earlier turns up to the memory window limit (~20 entries).
81
+ A very long chat therefore forgets its distant past; use `--session` to name
82
+ a conversation you want to return to.
83
+ - **Each turn is one ordinary run.** It gets its own budget, its own `runId` and
84
+ exactly one provenance record, and the shared `session` label ties the turns
85
+ together. A turn that fails is reported and the loop continues.
86
+ - **Blank lines are inert** — no model call, no memory write, no provenance.
87
+ - **Lines over 8 KiB are rejected before the model sees them**, and only the
88
+ byte count is echoed, never the text.
89
+ - **Ctrl-C and the kill switch still work.** `XCODER_JARVIS_KILL=1` or a
90
+ `.xcoder/jarvis/STOP` file is re-checked at every turn boundary and exits 4.
91
+ - **`--json` emits one JSON object per executed turn** on stdout, so the stream
92
+ stays machine-readable; the session banner goes to stderr only.
93
+ - **`--chat` plus a positional task is an error**, not a seed: a silently
94
+ discarded task looks like a model bug.
95
+
96
+ A tool that needs confirmation prompts on stdin through the same reader the
97
+ loop uses, so a prompt can never swallow a turn. Typing a terminator at a
98
+ confirmation prompt denies that tool and ends the session at the next turn
99
+ boundary — quitting is never blocked by a pending approval.
100
+
101
+ ## How it is built
102
+
103
+ ```
104
+ argv -> runJarvisAgent
105
+ |-- discoverSkills -> skill packs (data, not instructions)
106
+ |-- assembleSystemPrompt -> trusted policy + delimited data blocks
107
+ |-- runReactLoop
108
+ | |-- createLlmClient (xcoder-dna)
109
+ | |-- parseDecision (zod)
110
+ | `-- ToolRegistry (allowlist enforced in code)
111
+ |-- MemoryStore (scoped JSONL, redacted at write)
112
+ `-- writeProvenance (.xcoder/jarvis/runs/[runId].jsonl)
113
+ ```
114
+
115
+ The ReAct loop is owned in-package rather than reusing
116
+ `GenesisReActOrchestrator`, because that orchestrator's tool registry is
117
+ internal and cannot be constrained to Jarvis's allowlist — reusing it would
118
+ mean shipping an agent whose tool surface we do not control.
119
+
120
+ ### Tools
121
+
122
+ Only six tools exist, and the list is enforced in code:
123
+
124
+ | Tool | Risk | Notes |
125
+ |---|---|---|
126
+ | `read_file` | read | workspace-confined, symlink-resolved, secret-path denylist, 256 KiB cap |
127
+ | `glob` | read | `*`, `**`, `?`, `{a,b}` only; 200 results |
128
+ | `grep` | read | regex, 200 chars max; 100 matches; binary skipped |
129
+ | `search_workspace` | read | path substring search |
130
+ | `remember` | write | through `MemoryStore`, redacted before write |
131
+ | `recall` | read | current scope's window |
132
+
133
+ Deliberately absent: shell/exec, file write or delete, network fetch, git
134
+ push, and any SQL. There is no irreversible tool in this build, so nothing
135
+ needs human approval to run. The confirmation seam exists anyway and fails
136
+ closed (deny) when stdin is not a TTY, so adding an irreversible tool later
137
+ cannot silently skip approval.
138
+
139
+ ## Security model
140
+
141
+ Jarvis is designed against the OWASP LLM Top 10. The controls that matter:
142
+
143
+ **Prompt injection (LLM01).** The instruction region is a versioned constant,
144
+ `POLICY`, in `src/jarvis/prompt/policy.ts`. Its sha256 is recorded in every
145
+ run's provenance. Skill packs, memory entries and tool observations are
146
+ treated as untrusted data: they are normalised (zero-width and bidi controls
147
+ stripped), placed in `<untrusted-skill>` / `<untrusted-memory>` /
148
+ `<untrusted-observation>` blocks, and any literal closing delimiter inside
149
+ them is entity-escaped so it cannot end its own block.
150
+
151
+ **Policy is enforced in code, not prose (PRM-09).** A prompt instruction is
152
+ not a security boundary. The tool allowlist lives in `ToolRegistry.get()`,
153
+ which returns `undefined` for any name that is not both registered and
154
+ allowed. Iteration, token and wall-clock caps live in `RunBudget`. Model
155
+ output is validated by a zod discriminated union before it can reach any
156
+ tool.
157
+
158
+ **Insecure output handling (LLM02).** Parsed decisions are the only thing
159
+ that leaves `parseDecision`; raw model text is never passed to a shell, SQL,
160
+ eval, HTML or a file path. There is no `eval` or `Function` constructor in the
161
+ package.
162
+
163
+ **Sensitive information (LLM06).** `read_file` refuses a denylist of
164
+ secret-bearing paths (dotenv files, PEM/key files, ssh identities, npmrc,
165
+ credential files). Anything read is run through `redactSecrets` before it
166
+ enters the transcript, and memory values are redacted before they are
167
+ written to disk.
168
+
169
+ **Excessive agency (LLM08).** At most 8 iterations, one request in flight, a
170
+ read-mostly tool surface, and a kill switch.
171
+
172
+ **Cost and DoS (LLM10).** `RunBudget` caps input/output tokens, iterations and
173
+ wall-clock time. A run over any cap returns exit 3 with no partial answer.
174
+
175
+ ### Kill switch
176
+
177
+ Either signal aborts the run, checked before every LLM call and every tool
178
+ dispatch, and failing closed:
179
+
180
+ ```bash
181
+ export XCODER_JARVIS_KILL=1 # environment
182
+ touch .xcoder/jarvis/STOP # file in the workspace
183
+ ```
184
+
185
+ An aborted run writes no memory entry and still records provenance with
186
+ outcome `aborted`.
187
+
188
+ ### What is logged
189
+
190
+ `.xcoder/jarvis/runs/[runId].jsonl` — one record per run, mode 0600 where the
191
+ platform supports it. The schema holds identifiers, hashes and counts only:
192
+ no prompt text, no model replies, no file contents, no tokens. The one
193
+ free-text field is `error`, which is redacted and capped at 500 characters.
194
+ Records older than 90 days are pruned off the hot path. Set `JARVIS_DEBUG=1`
195
+ to print a stack trace to stderr on an unexpected error (never to the run
196
+ log).
197
+
198
+ ## Memory
199
+
200
+ Memory is append-only JSONL at
201
+ `.xcoder/jarvis/memory/[workspaceId]/[userId].jsonl`, scoped by a hash of the
202
+ resolved workspace path and a sanitised user label. Compaction is
203
+ deterministic and never calls a model: it keeps the newest entry per key,
204
+ then fills remaining capacity newest-first. A torn final line is dropped on
205
+ read rather than throwing, so a killed process cannot corrupt the store.
206
+
207
+ > **Accepted risk — scope is a label, not authentication.** `--user` selects
208
+ > which memory file to use; it does not authenticate anyone. Anyone who can
209
+ > run the CLI can read their own memory file, and anyone with filesystem
210
+ > access can read the others. Real isolation requires separate OS accounts,
211
+ > which is out of scope for a local CLI. Owner: platform team.
212
+
213
+ > **File modes are best-effort on Windows.** The store requests mode 0700/0600
214
+ > but Windows ignores POSIX permission bits; the protections there come from
215
+ the user profile directory's ACLs.
216
+
217
+ ## Skill packs
218
+
219
+ Packs are `SKILL.md` files with YAML frontmatter (`name`, `role`,
220
+ `description`, `triggers`, `version`, `requires_tools`, `composes_with`).
221
+ Discovery searches, first match wins: `$XCODER_SKILLS_DIR`, then
222
+ `.xcoder/skills` in the workspace, then `~/.xcoder/skills` (seeded from the
223
+ shipped packs on first run), then the bundled `xcoder-dna` packs.
224
+
225
+ The frontmatter parser is a line-based YAML subset — no generic YAML
226
+ dependency and no code execution. A pack that fails to parse is skipped and
227
+ recorded in provenance; it never aborts a run. Unknown frontmatter keys are
228
+ dropped rather than reaching the prompt.
229
+
230
+ Because user-level packs are writable by the user, treat pack text as
231
+ untrusted: review a pack before enabling it, exactly as you would review a
232
+ script you were about to run.
233
+
234
+ ## Development
235
+
236
+ ```bash
237
+ npm run typecheck -w xcoder-jarvis-agent
238
+ npm test # full workspace suite
239
+ npx vitest run packages/jarvis-agent # just this package
240
+ npm run check:boundaries # dependency rules
241
+ ```
242
+
243
+ Tests live in `packages/*/src/**/*.test.ts` — the workspace vitest config only
244
+ discovers that pattern.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Public barrel for `@xcoder/jarvis-agent`.
3
+ *
4
+ * The CLI is the primary consumer, but everything the agent does is
5
+ * importable so a test (or a future orchestrator) can drive the loop, the
6
+ * memory store and the prompt assembler directly without spawning a process.
7
+ */
8
+ export { JARVIS_AGENT_NAME, EXIT, runJarvisAgent, type JarvisDeps, type JarvisResult, } from "./jarvis/agent.js";
9
+ export { MAX_ITERATIONS, runReactLoop, type LlmCompleter, type ReactLoopInput, type ReactLoopOutput, } from "./jarvis/react-loop.js";
10
+ export { ActionDecision, FinalDecision, MAX_ARGS, MAX_ANSWER, MAX_THOUGHT, ReactDecision, ReactParseError, TOOL_NAME_RE, extractJsonObject, isValidToolName, parseDecision, type ReactDecision as ReactDecisionValue, } from "./jarvis/decision.js";
11
+ export { BudgetExceeded, DEFAULT_CAPS, RunBudget, clampIterations, type BudgetCaps, type BudgetSnapshot } from "./jarvis/budget.js";
12
+ export { ArgvError, MAX_TURNS_CEILING, MAX_TURNS_DEFAULT, USAGE, parseArgv, type JarvisRunRequest, } from "./jarvis/argv.js";
13
+ export { MAX_LINE_BYTES, createArrayLineSource, createStdinLineSource, type LineResult, type LineSource, } from "./jarvis/chat/lines.js";
14
+ export { TERMINATORS, isIgnorable, isTerminator, type TerminatorWord } from "./jarvis/chat/terminator.js";
15
+ export { createChatConfirm, type ChatConfirm } from "./jarvis/chat/confirm.js";
16
+ export { CHAT_DIRECTIVE } from "./jarvis/chat/prompt.js";
17
+ export { runChatSession, runChatSessionDetailed, turnArgv, type ChatResult, type StopReason, } from "./jarvis/chat/session.js";
18
+ export { DEFAULT_MAX_BYTES, DEFAULT_MAX_ENTRIES, DEFAULT_WINDOW_ENTRIES, MemoryStore, resolveUserId, workspaceScopeId, type MemoryEntry, type MemoryKind, type MemoryScope, type MemorySource, } from "./jarvis/memory/store.js";
19
+ export { assembleSystemPrompt, wrapObservation, JARVIS_ROLE, UNTRUSTED_MEMORY_TAG, UNTRUSTED_OBSERVATION_TAG, UNTRUSTED_SKILL_TAG, type AssembledPrompt, type PromptProvenance, } from "./jarvis/prompt/assemble.js";
20
+ export { POLICY_VERSION, POLICY, REFUSAL_RULES, renderPolicy } from "./jarvis/prompt/policy.js";
21
+ export { DEFAULT_MAX_PACKS, DEFAULT_MAX_PACK_BYTES, DEFAULT_MAX_TOTAL_BYTES, discoverSkills, parseFrontmatter, type DiscoverSkillsOptions, type DiscoverSkillsResult, type SkillPack, type SkippedSkill, } from "./jarvis/prompt/skills.js";
22
+ export { ALLOWED_TOOLS, DEFAULT_LIMITS, createToolRegistry, type AllowedToolName, type ToolContext, type ToolDescriptor, type ToolLimits, type ToolObservation, type ToolRegistry, } from "./jarvis/tools/registry.js";
23
+ export { FS_TOOLS, globToRegExp, isSecretPath } from "./jarvis/tools/fs-tools.js";
24
+ export { MEMORY_TOOLS } from "./jarvis/tools/memory-tools.js";
25
+ export { RETENTION_DAYS, pruneProvenance, writeProvenance, type JarvisOutcome, type ProvenanceRecord, } from "./jarvis/telemetry/provenance.js";
26
+ export { createConfirm, denyWhenNotTty, requireConfirmation, type ConfirmFn, type ConfirmRequest, type ToolRisk } from "./jarvis/util/confirm.js";
27
+ export { createKillProbe, readKillState, stopFilePath, type KillState } from "./jarvis/util/kill.js";
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ // xcoder:version 2 | xcoder:task task-482677 | xcoder:updated 2026-11-05T03:49:01.166Z | xcoder:subtask code-st-729fd8
2
+ /**
3
+ * Public barrel for `@xcoder/jarvis-agent`.
4
+ *
5
+ * The CLI is the primary consumer, but everything the agent does is
6
+ * importable so a test (or a future orchestrator) can drive the loop, the
7
+ * memory store and the prompt assembler directly without spawning a process.
8
+ */
9
+ export { JARVIS_AGENT_NAME, EXIT, runJarvisAgent, } from "./jarvis/agent.js";
10
+ export { MAX_ITERATIONS, runReactLoop, } from "./jarvis/react-loop.js";
11
+ export { ActionDecision, FinalDecision, MAX_ARGS, MAX_ANSWER, MAX_THOUGHT, ReactDecision, ReactParseError, TOOL_NAME_RE, extractJsonObject, isValidToolName, parseDecision, } from "./jarvis/decision.js";
12
+ export { BudgetExceeded, DEFAULT_CAPS, RunBudget, clampIterations } from "./jarvis/budget.js";
13
+ export { ArgvError, MAX_TURNS_CEILING, MAX_TURNS_DEFAULT, USAGE, parseArgv, } from "./jarvis/argv.js";
14
+ export { MAX_LINE_BYTES, createArrayLineSource, createStdinLineSource, } from "./jarvis/chat/lines.js";
15
+ export { TERMINATORS, isIgnorable, isTerminator } from "./jarvis/chat/terminator.js";
16
+ export { createChatConfirm } from "./jarvis/chat/confirm.js";
17
+ export { CHAT_DIRECTIVE } from "./jarvis/chat/prompt.js";
18
+ export { runChatSession, runChatSessionDetailed, turnArgv, } from "./jarvis/chat/session.js";
19
+ export { DEFAULT_MAX_BYTES, DEFAULT_MAX_ENTRIES, DEFAULT_WINDOW_ENTRIES, MemoryStore, resolveUserId, workspaceScopeId, } from "./jarvis/memory/store.js";
20
+ export { assembleSystemPrompt, wrapObservation, JARVIS_ROLE, UNTRUSTED_MEMORY_TAG, UNTRUSTED_OBSERVATION_TAG, UNTRUSTED_SKILL_TAG, } from "./jarvis/prompt/assemble.js";
21
+ export { POLICY_VERSION, POLICY, REFUSAL_RULES, renderPolicy } from "./jarvis/prompt/policy.js";
22
+ export { DEFAULT_MAX_PACKS, DEFAULT_MAX_PACK_BYTES, DEFAULT_MAX_TOTAL_BYTES, discoverSkills, parseFrontmatter, } from "./jarvis/prompt/skills.js";
23
+ export { ALLOWED_TOOLS, DEFAULT_LIMITS, createToolRegistry, } from "./jarvis/tools/registry.js";
24
+ export { FS_TOOLS, globToRegExp, isSecretPath } from "./jarvis/tools/fs-tools.js";
25
+ export { MEMORY_TOOLS } from "./jarvis/tools/memory-tools.js";
26
+ export { RETENTION_DAYS, pruneProvenance, writeProvenance, } from "./jarvis/telemetry/provenance.js";
27
+ export { createConfirm, denyWhenNotTty, requireConfirmation } from "./jarvis/util/confirm.js";
28
+ export { createKillProbe, readKillState, stopFilePath } from "./jarvis/util/kill.js";
@@ -0,0 +1,50 @@
1
+ import type { LineSource } from "./chat/lines.js";
2
+ import { type LlmCompleter } from "./react-loop.js";
3
+ import { type JarvisOutcome } from "./telemetry/provenance.js";
4
+ import { type ConfirmFn } from "./util/confirm.js";
5
+ import { type ToolDescriptor } from "./tools/registry.js";
6
+ export declare const JARVIS_AGENT_NAME: "jarvis-agent";
7
+ export { EXIT, type ExitCode } from "./exit.js";
8
+ export interface JarvisDeps {
9
+ createClient?: () => LlmCompleter;
10
+ now?: () => Date;
11
+ workspaceRoot?: string;
12
+ memoryRoot?: string;
13
+ runLogRoot?: string;
14
+ tools?: readonly ToolDescriptor<any>[];
15
+ confirm?: ConfirmFn;
16
+ stdout?: NodeJS.WritableStream;
17
+ stderr?: NodeJS.WritableStream;
18
+ /** Injected for tests, so skill discovery never reads the real home dir. */
19
+ env?: NodeJS.ProcessEnv;
20
+ /** Chat seam: replaces process.stdin. Production builds a LineSource from it. */
21
+ stdin?: NodeJS.ReadableStream & {
22
+ isTTY?: boolean;
23
+ };
24
+ /** Chat seam: an explicit LineSource, so loop tests need no process or TTY. */
25
+ lines?: LineSource;
26
+ /** Chat seam: overrides TTY detection for the confirmation gate. */
27
+ isInteractive?: boolean;
28
+ /** Set by the chat loop: record this turn's user line before the run (T4). */
29
+ chatTurn?: boolean;
30
+ }
31
+ export interface JarvisResult {
32
+ outcome: JarvisOutcome;
33
+ answer?: string;
34
+ exitCode: number;
35
+ iterations: number;
36
+ runId: string;
37
+ session: string;
38
+ skills: string[];
39
+ provenancePath?: string;
40
+ error?: string;
41
+ }
42
+ /**
43
+ * Runs one Jarvis invocation and returns a process exit code.
44
+ *
45
+ * Never throws for expected conditions: a bad flag, a missing key, a model
46
+ * failure, a tripped kill switch and an exhausted budget all become a number
47
+ * plus a redacted message (T7). Provenance is written in a `finally` so an
48
+ * aborted run still leaves an audit record.
49
+ */
50
+ export declare function runJarvisAgent(argv: readonly string[], deps?: JarvisDeps): Promise<number>;