@corenel/term 0.2.9 → 0.3.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/{chunk-L4KCEKIT.js → chunk-2MGDL3I4.js} +7 -2
- package/dist/chunk-5RPHYXND.js +138 -0
- package/dist/{chunk-QZJTOVZL.js → chunk-HUVRQX53.js} +513 -34
- package/dist/commands.d.ts +39 -0
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +11 -3
- package/dist/contextText.d.ts +37 -0
- package/dist/contextText.d.ts.map +1 -0
- package/dist/ink/App.d.ts +14 -0
- package/dist/ink/App.d.ts.map +1 -1
- package/dist/ink/ContextOverlay.d.ts +18 -0
- package/dist/ink/ContextOverlay.d.ts.map +1 -0
- package/dist/ink/HelpOverlay.d.ts +12 -0
- package/dist/ink/HelpOverlay.d.ts.map +1 -0
- package/dist/ink/McpOverlay.d.ts +12 -0
- package/dist/ink/McpOverlay.d.ts.map +1 -0
- package/dist/ink/Modal.d.ts +7 -2
- package/dist/ink/Modal.d.ts.map +1 -1
- package/dist/ink/index.d.ts.map +1 -1
- package/dist/ink/index.js +253 -77
- package/dist/ink/scroll.d.ts.map +1 -1
- package/dist/mcpText.d.ts +20 -0
- package/dist/mcpText.d.ts.map +1 -0
- package/dist/session.d.ts +172 -6
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +3 -3
- package/dist/state.d.ts +83 -2
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-VTJEWHM3.js +0 -65
package/dist/session.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import type { AgentEvent, AgentTool, AskAnswers, AskQuestion, CompressionConfig,
|
|
|
4
4
|
import { type RunAgentArgs, type RunAgentResult } from '@corenel/harness/core/loop';
|
|
5
5
|
import { type ModelRates } from '@corenel/harness/core/pricing';
|
|
6
6
|
import type { PermissionService } from '@corenel/harness/guardrail/permission-service';
|
|
7
|
-
import { type CommittedItem, type PaletteEntry, type TuiState } from './state';
|
|
7
|
+
import { type CommittedItem, type McpServerView, type PaletteEntry, type TuiState } from './state';
|
|
8
|
+
import { type ContextSnapshot } from './contextText';
|
|
8
9
|
import { type ReadExisting } from './writePreview';
|
|
9
10
|
import { type SessionPersistence } from './persist';
|
|
10
11
|
import type { PolicySource } from './policySource';
|
|
@@ -35,6 +36,29 @@ export interface TermSessionDeps {
|
|
|
35
36
|
* (or returning null) means no cost is displayed at all -- see TuiState's
|
|
36
37
|
* `costUsd` for why that is silence rather than $0.00. */
|
|
37
38
|
rates?: () => ModelRates | null;
|
|
39
|
+
/** The model's context window in tokens, or `null` when nothing sizes it --
|
|
40
|
+
* for `/context`'s fill fraction. A GETTER, for the same reason `rates` is
|
|
41
|
+
* one just above: this codebase keeps reintroducing the bug of a value
|
|
42
|
+
* captured once at construction going stale. The model itself is fixed for
|
|
43
|
+
* a session (`/model <id>` refuses -- see `listModels`'s field doc), so in
|
|
44
|
+
* practice this returns the same number every time today; the getter
|
|
45
|
+
* exists so that fact stays a consequence of how the loop is wired, not
|
|
46
|
+
* something this package has to assume. Absent, or returning `null`, means
|
|
47
|
+
* `/context` shows the raw token count sent and says the window is unknown
|
|
48
|
+
* -- see contextText.ts's honesty rule -- never a percentage against a
|
|
49
|
+
* guess. */
|
|
50
|
+
contextWindow?: () => number | null;
|
|
51
|
+
/** The models this host knows about, for `/model` (list only). The model is
|
|
52
|
+
* FIXED once a session begins -- `resolveContextWindow(model)` runs ONCE at
|
|
53
|
+
* launch (packages/cli/src/cli.ts's `resolvedWindow`) and sizes rung-2
|
|
54
|
+
* compaction from it; switching to a model with a SMALLER window mid-session
|
|
55
|
+
* would leave compaction sized for the larger one and the loop would meet
|
|
56
|
+
* the context wall as a fatal 400 instead of compacting in time. So `/model
|
|
57
|
+
* <id>` refuses (see `runModelCommand`) and there is no `setModel` dep --
|
|
58
|
+
* changing the model requires reprocessing the session, which is not
|
|
59
|
+
* implemented (see docs/BACKLOG.md section 5). `/model` with no id still
|
|
60
|
+
* lists what's available -- that's read-only. */
|
|
61
|
+
listModels?: () => Promise<PaletteEntry[]>;
|
|
38
62
|
/** The agent modes the host has configured, for `/mode` (list + validate). */
|
|
39
63
|
listModes?: () => Promise<PaletteEntry[]>;
|
|
40
64
|
/** Switch the CURRENT mode. Only takes effect once `system` (above) is next
|
|
@@ -96,6 +120,11 @@ export interface TermSessionDeps {
|
|
|
96
120
|
* no node dependency — the same pattern as `persistence` and `toolCtx`. Omit
|
|
97
121
|
* to run with offload disabled, same as before this dep existed. */
|
|
98
122
|
compression?: CompressionConfig;
|
|
123
|
+
/** Rung-2 history compaction, forwarded to the loop the same way
|
|
124
|
+
* `compression` is. A REPL conversation is long by nature, so this is the
|
|
125
|
+
* face most likely to reach the wall; omit it and the session behaves as it
|
|
126
|
+
* did before — which is to say it dies on a fatal 400 when it gets there. */
|
|
127
|
+
compaction?: RunAgentArgs['compaction'];
|
|
99
128
|
/** Told the conversation's session id whenever it becomes known or changes —
|
|
100
129
|
* once after `resume()` loads an existing session, and again after every
|
|
101
130
|
* `persist()` assigns/confirms one. A host that offloads tool results into a
|
|
@@ -119,6 +148,17 @@ export interface TermSessionDeps {
|
|
|
119
148
|
* every other host-supplied command in this file. */
|
|
120
149
|
policy?: Policy;
|
|
121
150
|
policySource?: PolicySource;
|
|
151
|
+
/** The MCP servers this host can see, for `/mcp`. Absent means the command
|
|
152
|
+
* reports itself unavailable, exactly like /policy without a policy. */
|
|
153
|
+
listMcpServers?: () => Promise<McpServerView[]>;
|
|
154
|
+
addMcpServer?: (name: string, url: string) => Promise<void>;
|
|
155
|
+
removeMcpServer?: (name: string) => Promise<void>;
|
|
156
|
+
loginMcpServer?: (name: string, onUrl: (url: string) => void) => Promise<void>;
|
|
157
|
+
refreshMcpServer?: (server?: string) => Promise<void>;
|
|
158
|
+
/** Clear the stored OAuth client registration for a server, so the next
|
|
159
|
+
* `/mcp login` registers afresh. See the CLI's `McpAdmin.forget` for why
|
|
160
|
+
* this is always a local write. */
|
|
161
|
+
forgetMcpServer?: (name: string) => Promise<void>;
|
|
122
162
|
}
|
|
123
163
|
/** Deltas arrive per token; re-rendering React that often thrashes for output
|
|
124
164
|
* no eye can follow. They coalesce on this interval instead. */
|
|
@@ -181,6 +221,13 @@ export declare class TermSession {
|
|
|
181
221
|
* reach a renderer. */
|
|
182
222
|
private pendingSkill;
|
|
183
223
|
wantsExit: boolean;
|
|
224
|
+
/** The last line that was WARNED ABOUT rather than sent, because its first
|
|
225
|
+
* word after `/` looked like a command but wasn't one -- see `submit`. Set
|
|
226
|
+
* on the warn, cleared the moment anything else happens (a different line,
|
|
227
|
+
* a real command, an empty line): only an EXACT resubmission of this same
|
|
228
|
+
* text counts as "I meant it, send it anyway". `null` means nothing is
|
|
229
|
+
* pending. */
|
|
230
|
+
private lastRejectedLine;
|
|
184
231
|
constructor(deps: TermSessionDeps);
|
|
185
232
|
attachPermission(p: PermissionService): void;
|
|
186
233
|
historyForTest(): ChatCompletionMessageParam[];
|
|
@@ -256,7 +303,28 @@ export declare class TermSession {
|
|
|
256
303
|
* no ordinal to show. */
|
|
257
304
|
private ordFor;
|
|
258
305
|
handleEvent(e: AgentEvent): void;
|
|
259
|
-
/**
|
|
306
|
+
/** Whether calling `submit(text)` right now would warn-and-refuse rather
|
|
307
|
+
* than run a command or send a message -- i.e. `text`'s first word after a
|
|
308
|
+
* leading `/` looks like a command attempt but isn't one, AND this isn't
|
|
309
|
+
* already the resend of a line that was just warned about. PURE: does not
|
|
310
|
+
* touch `lastRejectedLine` or commit anything, so a caller can check it
|
|
311
|
+
* before deciding what to do with the input box (see ink/index.tsx's
|
|
312
|
+
* onSubmit, which must NOT clear the box for the line this reports true
|
|
313
|
+
* for) without racing `submit`'s own mutation of the same state. */
|
|
314
|
+
willReject(text: string): boolean;
|
|
315
|
+
/** Route one line: a command runs here; anything else is a turn -- UNLESS
|
|
316
|
+
* the first word after a leading `/` looks like a command attempt and
|
|
317
|
+
* isn't one (see commands.ts's `isKnownCommandWord`), in which case the
|
|
318
|
+
* FIRST Enter on that exact text warns and stops rather than paying for a
|
|
319
|
+
* model call on a typo (`/context` before Feature 2 added it, `/toosl`,
|
|
320
|
+
* `/hepl`, ...). A SECOND Enter on the identical, unchanged line is taken
|
|
321
|
+
* as "I meant it" and sent as an ordinary message -- tracked in
|
|
322
|
+
* `lastRejectedLine`, which both faces share automatically since it lives
|
|
323
|
+
* here rather than in either face's own state: the Ink face keeps the text
|
|
324
|
+
* in the input box (ink/index.tsx checks `willReject` before clearing it)
|
|
325
|
+
* so retyping Enter resubmits the SAME string; the readline face has no
|
|
326
|
+
* input box to hold onto, so there the "second Enter" is the user
|
|
327
|
+
* retyping the line themselves -- an honest equivalent, not a shortcut. */
|
|
260
328
|
submit(text: string): Promise<void>;
|
|
261
329
|
/** Run `line` as a turn now, or queue it, exactly like `submit` does for
|
|
262
330
|
* ordinary text -- factored out so `/strategy` (runCommand) can send its
|
|
@@ -279,14 +347,112 @@ export declare class TermSession {
|
|
|
279
347
|
* host call here, not just the two that are known to need it, means the
|
|
280
348
|
* NEXT one added can't reintroduce the same gap by omission. */
|
|
281
349
|
private safeCall;
|
|
282
|
-
/** Shared `/mode
|
|
350
|
+
/** Shared `/mode`/`/persona` shape: no id lists what's configured, an
|
|
283
351
|
* unknown id reports the valid options (never silently no-ops, never sends
|
|
284
|
-
* a typo through to the model), a real id applies immediately
|
|
285
|
-
*
|
|
286
|
-
*
|
|
352
|
+
* a typo through to the model), a real id applies immediately.
|
|
353
|
+
*
|
|
354
|
+
* "applies" means `deps.system` will pick it up on the NEXT
|
|
355
|
+
* `resolveSystem()` call, not this instant (see the field docs on
|
|
356
|
+
* TermSessionDeps.system) -- `opts.apply` (the host's `setMode`/
|
|
357
|
+
* `setPersona`) is the whole story there.
|
|
358
|
+
*
|
|
359
|
+
* `/model` does NOT go through here -- see `runModelCommand`: the model is
|
|
360
|
+
* fixed for a session, so there is nothing for it to apply. */
|
|
287
361
|
private switchIdentity;
|
|
362
|
+
/** `/model` -- READ-ONLY. No id lists what's available (see `listModels`'s
|
|
363
|
+
* field doc for why); an id refuses rather than switching, because the
|
|
364
|
+
* model is fixed for the life of a session -- `resolveContextWindow(model)`
|
|
365
|
+
* runs once at launch and sizes rung-2 compaction from it, so a downward
|
|
366
|
+
* switch would leave compaction believing it has a bigger window than the
|
|
367
|
+
* model actually has and the conversation would meet the context wall as a
|
|
368
|
+
* fatal 400 instead of compacting in time. Changing the model requires
|
|
369
|
+
* reprocessing the session, which is not implemented (docs/BACKLOG.md
|
|
370
|
+
* section 5) -- the remedy is a restart with `--model <id>`, not this
|
|
371
|
+
* command. Routed through `safeCall` for the listing, same guard every
|
|
372
|
+
* other identity command uses. */
|
|
373
|
+
private runModelCommand;
|
|
288
374
|
private armSkillCommand;
|
|
289
375
|
private runStrategyCommand;
|
|
376
|
+
/** Like `safeCall`, but for `/mcp`'s own host calls -- a SEPARATE wrapper,
|
|
377
|
+
* not a shared message, because the failure shape is different in kind.
|
|
378
|
+
* `safeCall`'s "not available -- could not read the config workspace"
|
|
379
|
+
* framing was written for `/mode`/`/persona`: there, a throw really does
|
|
380
|
+
* mean the config workspace itself is broken. An MCP host call throwing is
|
|
381
|
+
* usually something else entirely -- `McpAdmin`'s write methods
|
|
382
|
+
* (packages/cli/src/mcpAdmin.ts) return `Promise<void>` with no result
|
|
383
|
+
* channel, so a REFUSAL (a duplicate name, a daemon saying no, a failed
|
|
384
|
+
* sign-in) surfaces as a thrown Error too, indistinguishable by shape from
|
|
385
|
+
* a real transport failure. Telling the user the command is "not
|
|
386
|
+
* available" when it ran and was refused is actively wrong -- it says "try
|
|
387
|
+
* nothing" when the honest answer is "try something else, here is why this
|
|
388
|
+
* attempt didn't work". So this wrapper names the ACTION and reports the
|
|
389
|
+
* underlying reason verbatim, and leaves `safeCall` untouched for the four
|
|
390
|
+
* callers whose failure really is "could not read the config workspace". */
|
|
391
|
+
private safeMcpCall;
|
|
392
|
+
/** `/mcp` and its subcommands -- what is connected, and sign in or add one.
|
|
393
|
+
* `listMcpServers` gates the whole command, the same way `deps.policy` gates
|
|
394
|
+
* `/policy`: a host that wires none of the five deps reports `/mcp` itself
|
|
395
|
+
* unavailable rather than half-working. Each mutating subcommand ALSO checks
|
|
396
|
+
* its own specific dep, so a host that wires read-only `listMcpServers` still
|
|
397
|
+
* gets a working `/mcp list` instead of every subcommand failing alike.
|
|
398
|
+
*
|
|
399
|
+
* `unknown` carries a subcommand `parseCommand` did not recognize -- see
|
|
400
|
+
* commands.ts's `mcp` case. It is rejected BY NAME rather than aliased to
|
|
401
|
+
* `list` (a typo must never produce ordinary-looking output with nothing
|
|
402
|
+
* to say it was not understood) and rather than reaching here as `null`
|
|
403
|
+
* from the parser (which would send it to the model as a chat message --
|
|
404
|
+
* worse still: a silent misfire that LOOKS like an answer). */
|
|
405
|
+
private runMcpCommand;
|
|
406
|
+
/** `/mcp` with no argument, from the Ink face only -- see the module doc
|
|
407
|
+
* above. Fetches the current servers and opens the manager. */
|
|
408
|
+
openMcpManager(): Promise<void>;
|
|
409
|
+
/** esc, or any other reason the overlay should close -- a no-op unless the
|
|
410
|
+
* manager is actually the modal open right now, so it can never steal a
|
|
411
|
+
* permission or question modal's close. */
|
|
412
|
+
closeMcpManager(): void;
|
|
413
|
+
/** `/help` with no argument, from the Ink face only -- see the module doc
|
|
414
|
+
* above. */
|
|
415
|
+
openHelp(): void;
|
|
416
|
+
/** esc, or any other reason the overlay should close -- a no-op unless the
|
|
417
|
+
* help overlay is actually the modal open right now, so it can never steal
|
|
418
|
+
* a permission, question, or MCP modal's close. */
|
|
419
|
+
closeHelp(): void;
|
|
420
|
+
/** The data `formatContext` (contextText.ts) needs, assembled from
|
|
421
|
+
* `TuiState`'s own accumulators and the two host-supplied static facts
|
|
422
|
+
* (`deps.tools.length`, `deps.contextWindow()`) -- called fresh by both
|
|
423
|
+
* `runCommand`'s `'context'` case and the Ink overlay's render, never
|
|
424
|
+
* cached, so neither face can show a stale window size after `/context`'s
|
|
425
|
+
* OWN state changes mid-turn. */
|
|
426
|
+
contextSnapshot(): ContextSnapshot;
|
|
427
|
+
/** `/context` with no argument, from the Ink face only -- see the module
|
|
428
|
+
* doc above. Needs no host dep and nothing to fetch -- opening it is just
|
|
429
|
+
* setting the modal. */
|
|
430
|
+
openContext(): void;
|
|
431
|
+
/** esc, or any other reason the context overlay should close -- a no-op
|
|
432
|
+
* unless the context overlay is actually the modal open right now, so it
|
|
433
|
+
* can never steal a permission, question, help, or MCP modal's close. */
|
|
434
|
+
closeContext(): void;
|
|
435
|
+
/** Up/down inside the overlay -- wraps, and does nothing with zero rows. */
|
|
436
|
+
moveMcpSelection(delta: number): void;
|
|
437
|
+
/** `x` inside the overlay -- removes the selected row via the same
|
|
438
|
+
* `removeMcpServer` dep `/mcp remove` uses, then refreshes the list. */
|
|
439
|
+
removeMcpSelection(): Promise<void>;
|
|
440
|
+
/** `l` inside the overlay -- signs the selected row in via the same
|
|
441
|
+
* `loginMcpServer` dep `/mcp login` uses. The consent URL genuinely
|
|
442
|
+
* arrives before the sign-in itself completes (a daemon message, or a
|
|
443
|
+
* synchronous callback locally), so `modal.login.url` is updated live as
|
|
444
|
+
* it arrives rather than buffered until the whole call resolves. */
|
|
445
|
+
loginMcpSelection(): Promise<void>;
|
|
446
|
+
/** `r` inside the overlay -- refreshes the selected row via the same
|
|
447
|
+
* `refreshMcpServer` dep `/mcp refresh` uses, then refreshes the list so
|
|
448
|
+
* the updated tool count and age show without the user reopening the
|
|
449
|
+
* overlay. Same shape as `removeMcpSelection` above. */
|
|
450
|
+
refreshMcpSelection(): Promise<void>;
|
|
451
|
+
/** Re-fetches `listMcpServers` and replaces the overlay's snapshot,
|
|
452
|
+
* clamping the selection into range -- used after add/remove/login
|
|
453
|
+
* succeed so the overlay never shows a server list that mutation just
|
|
454
|
+
* made stale. */
|
|
455
|
+
private refreshMcpManager;
|
|
290
456
|
/** Save after the turn, never during: a half-written turn is a lie on disk. */
|
|
291
457
|
private persist;
|
|
292
458
|
/** Reopen a conversation: `id` if given, otherwise the most recent. */
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpJ,OAAO,EAAY,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAA0B,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpJ,OAAO,EAAY,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAA0B,KAAK,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 -2,9 +2,9 @@ import {
|
|
|
2
2
|
DELTA_FLUSH_MS,
|
|
3
3
|
TOOL_DELTA_CAP,
|
|
4
4
|
TermSession
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-HUVRQX53.js";
|
|
6
|
+
import "./chunk-2MGDL3I4.js";
|
|
7
|
+
import "./chunk-5RPHYXND.js";
|
|
8
8
|
import "./chunk-M44CET5L.js";
|
|
9
9
|
import "./chunk-I44FC7PE.js";
|
|
10
10
|
import "./chunk-TYP4MMO7.js";
|
package/dist/state.d.ts
CHANGED
|
@@ -96,7 +96,40 @@ export interface UserAsk {
|
|
|
96
96
|
kind: 'user';
|
|
97
97
|
questions: AskQuestion[];
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
/** The `/mcp` overlay's own state -- presentation over the SAME `/mcp`
|
|
100
|
+
* dispatch the text commands use (TermSession.runMcpCommand), not a second
|
|
101
|
+
* copy of it. `servers` is a snapshot fetched when the manager opens (and
|
|
102
|
+
* refreshed after a mutation succeeds), never something the view itself
|
|
103
|
+
* caches or recomputes -- see McpOverlay.tsx. */
|
|
104
|
+
export interface McpManager {
|
|
105
|
+
kind: 'mcp';
|
|
106
|
+
servers: McpServerView[];
|
|
107
|
+
selected: number;
|
|
108
|
+
/** Set while a login is in flight; the consent URL once the daemon returns
|
|
109
|
+
* one. The URL genuinely arrives before the browser round-trip finishes on
|
|
110
|
+
* both write routes (daemon and local), so this is real, live state, not
|
|
111
|
+
* something the view can buffer or wait out. */
|
|
112
|
+
login: {
|
|
113
|
+
server: string;
|
|
114
|
+
url: string | null;
|
|
115
|
+
} | null;
|
|
116
|
+
}
|
|
117
|
+
/** Declared here, not in Task 10, because a discriminated union has to name
|
|
118
|
+
* all its variants at once to typecheck -- Task 10 builds the view that
|
|
119
|
+
* consumes this. */
|
|
120
|
+
export interface HelpView {
|
|
121
|
+
kind: 'help';
|
|
122
|
+
}
|
|
123
|
+
/** `/context`'s overlay. Carries no snapshot of its own -- unlike `McpManager`,
|
|
124
|
+
* which caches a fetched server list, `/context` has nothing to fetch: every
|
|
125
|
+
* field it shows already lives on `TuiState` (see `sentTokens`, `offloaded`,
|
|
126
|
+
* `checkpoints`, `toolNames` below), updated live as events arrive. So the
|
|
127
|
+
* view just reads `TuiState` directly while this stays open, and a turn that
|
|
128
|
+
* lands while the overlay is up updates it without anyone re-opening it. */
|
|
129
|
+
export interface ContextView {
|
|
130
|
+
kind: 'context';
|
|
131
|
+
}
|
|
132
|
+
export type Modal = PermissionAsk | UserAsk | McpManager | HelpView | ContextView;
|
|
100
133
|
export type TodoStatus = 'pending' | 'in_progress' | 'completed' | 'blocked';
|
|
101
134
|
/** A local mirror of the harness's `todo_write` tool contract (see
|
|
102
135
|
* packages/harness/tools/todo.ts) — kept local rather than imported so this
|
|
@@ -112,6 +145,12 @@ export interface TodoItem {
|
|
|
112
145
|
export interface TuiState {
|
|
113
146
|
/** Bumped on every change so subscribers using useSyncExternalStore refresh. */
|
|
114
147
|
seq: number;
|
|
148
|
+
/** The model this session is using, for the status row (see ink/App.tsx's
|
|
149
|
+
* fitStatus call). Set from `TermSessionDeps.model` at construction and
|
|
150
|
+
* never written again -- the model is fixed for a session (see
|
|
151
|
+
* @corenel/term's TermSessionDeps.listModels field doc for why `/model
|
|
152
|
+
* <id>` refuses rather than mutating this). */
|
|
153
|
+
model: string;
|
|
115
154
|
transcriptGen: number;
|
|
116
155
|
committed: CommittedItem[];
|
|
117
156
|
live: {
|
|
@@ -152,8 +191,50 @@ export interface TuiState {
|
|
|
152
191
|
* so the effect is never silent, and it is cleared the moment that message
|
|
153
192
|
* is sent (see TermSession.runTurn), not when the turn finishes. */
|
|
154
193
|
pendingSkill: string | null;
|
|
194
|
+
/** What was actually sent on the LAST model call -- overwritten by every
|
|
195
|
+
* `usage` event, not accumulated the way `usage`/`turnUsage` are: this
|
|
196
|
+
* answers "what's in the window right now", not "what has this
|
|
197
|
+
* conversation cost so far". `null` before any model call has completed. */
|
|
198
|
+
sentTokens: number | null;
|
|
199
|
+
/** Tool results offloaded to save context, oldest first -- recallable with
|
|
200
|
+
* `/expand`. Appended to by every `offload` event; never removed, since a
|
|
201
|
+
* `/clear` empties this the same way it empties `committed`. */
|
|
202
|
+
offloaded: {
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
bytes: number;
|
|
206
|
+
}[];
|
|
207
|
+
/** Compaction seams -- history collapsed into a checkpoint -- oldest first,
|
|
208
|
+
* appended to by every `checkpoint` event alongside the note it already
|
|
209
|
+
* commits (see TermSession.handleEvent's `checkpoint` case). */
|
|
210
|
+
checkpoints: {
|
|
211
|
+
collapsed: number;
|
|
212
|
+
checkpoint: string;
|
|
213
|
+
}[];
|
|
214
|
+
/** The MCP tool set's current names, as of the last `tools-loaded` event --
|
|
215
|
+
* REPLACED wholesale each time (the event carries the whole list), not
|
|
216
|
+
* appended to. */
|
|
217
|
+
toolNames: string[];
|
|
218
|
+
}
|
|
219
|
+
/** One configured MCP server, as `/mcp` needs it -- joined from config
|
|
220
|
+
* (`readMcpServers`, the source of truth: see mcpRegistry.ts's
|
|
221
|
+
* `mcpServerViews`), the live registry's connection status, credential
|
|
222
|
+
* presence, and the on-disk tool cache's age. A server never touched this
|
|
223
|
+
* process (no `ensureConnected` yet) still appears here, just with
|
|
224
|
+
* `connected: false` and a cache-derived (or zero) `toolCount` -- config, not
|
|
225
|
+
* the registry, decides who is enumerated. */
|
|
226
|
+
export interface McpServerView {
|
|
227
|
+
name: string;
|
|
228
|
+
url: string;
|
|
229
|
+
connected: boolean;
|
|
230
|
+
signedIn: boolean;
|
|
231
|
+
toolCount: number;
|
|
232
|
+
/** Epoch ms of the cached tool list, or null when never fetched. */
|
|
233
|
+
fetchedAt: number | null;
|
|
234
|
+
hosted: boolean;
|
|
235
|
+
error?: string;
|
|
155
236
|
}
|
|
156
|
-
export declare function emptyState(): TuiState;
|
|
237
|
+
export declare function emptyState(model?: string): TuiState;
|
|
157
238
|
/** Parse a `todo_write` call's `args` into the list this face renders.
|
|
158
239
|
*
|
|
159
240
|
* This is MODEL OUTPUT, not a value our own code produced, so it is parsed
|
package/dist/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;2EAG2E;AAC3E,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,oFAAoF;AACpF,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAC5C;;;;;;;;;;;;;;;;;;;;mBAoBe;IACf,YAAY,CAAC,EAAE,IAAI,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IACrF,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACzG;;;;;kDAK8C;IAC9C,QAAQ,CAAC,EAAE,IAAI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B/C;AAQD;;;;;;;;;0BAS0B;AAC1B,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,EAAE,CAiBpD"}
|
package/dist/state.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corenel/term",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Corenel's terminal face — a headless chat controller plus its Ink views. `./session` is ink-free and shared with the CLI's readline fallback; only `./ink` pulls React. dist/ is bundled (see build.mjs), but @corenel/harness and @corenel/protocol stay EXTERNAL to that bundle — they are real runtime dependencies, declared below, so the CLI and term share exactly one harness module instance (see build.mjs for why two instances is a governance hole, not a cosmetic bug).",
|
|
6
6
|
"exports": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"ink-text-input": "^6.0.0",
|
|
47
47
|
"openai": "^4.77.0",
|
|
48
48
|
"react": "^18.3.1",
|
|
49
|
-
"@corenel/harness": "0.
|
|
49
|
+
"@corenel/harness": "0.8.0",
|
|
50
50
|
"@corenel/protocol": "0.7.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"esbuild": "^0.21.5",
|
|
56
56
|
"ink-testing-library": "^4.0.0",
|
|
57
57
|
"typescript": "^5.9.3",
|
|
58
|
-
"@corenel/tools-node": "0.
|
|
58
|
+
"@corenel/tools-node": "0.4.0"
|
|
59
59
|
},
|
|
60
60
|
"license": "Elastic-2.0",
|
|
61
61
|
"engines": {
|
package/dist/chunk-VTJEWHM3.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// src/commands.ts
|
|
2
|
-
var TERM_COMMANDS = [
|
|
3
|
-
{ name: "help", summary: "what you can type here" },
|
|
4
|
-
{ name: "tools", summary: "what the agent can do, and what it can change" },
|
|
5
|
-
{ name: "policy", summary: "how this session is governed -- levels, caps, and what actually confines it" },
|
|
6
|
-
{ name: "expand", args: "<#n>", summary: "re-print a tool result in full" },
|
|
7
|
-
{ name: "resume", args: "[id]", summary: "reopen an earlier conversation" },
|
|
8
|
-
{ name: "clear", summary: "forget the conversation" },
|
|
9
|
-
{ name: "exit", summary: "leave" },
|
|
10
|
-
// -- config-workspace commands: what these do to the NEXT turn is real, see
|
|
11
|
-
// TermSessionDeps.system in ./session (the re-derivable system prompt) and
|
|
12
|
-
// the `mode`/`persona`/`skill`/`strategy` cases in runCommand.
|
|
13
|
-
{ name: "mode", args: "<id>", summary: "switch the agent mode (takes effect next turn); no id lists what is configured" },
|
|
14
|
-
{ name: "persona", args: "<id>", summary: "switch persona (takes effect next turn); no id lists what is configured" },
|
|
15
|
-
{ name: "skill", args: "<name>", summary: "apply a skill to your NEXT message only, then it clears; no name lists what is installed" },
|
|
16
|
-
{ name: "strategy", args: "<name>", summary: "run a saved strategy from .prompd/strategies; no name lists what is saved" }
|
|
17
|
-
];
|
|
18
|
-
var ALIASES = { quit: "exit" };
|
|
19
|
-
function parseCommand(line) {
|
|
20
|
-
const t = line.trim();
|
|
21
|
-
if (!t.startsWith("/")) return null;
|
|
22
|
-
const [wordRaw, ...rest] = t.slice(1).split(/\s+/);
|
|
23
|
-
const word = ALIASES[wordRaw.toLowerCase()] ?? wordRaw.toLowerCase();
|
|
24
|
-
const arg = rest.join(" ").trim();
|
|
25
|
-
switch (word) {
|
|
26
|
-
case "help":
|
|
27
|
-
return { cmd: "help" };
|
|
28
|
-
case "tools":
|
|
29
|
-
return { cmd: "tools" };
|
|
30
|
-
case "policy":
|
|
31
|
-
return { cmd: "policy" };
|
|
32
|
-
case "clear":
|
|
33
|
-
return { cmd: "clear" };
|
|
34
|
-
case "exit":
|
|
35
|
-
return { cmd: "exit" };
|
|
36
|
-
case "expand": {
|
|
37
|
-
const m = /^#?(\d+)$/.exec(arg);
|
|
38
|
-
return m ? { cmd: "expand", ord: Number(m[1]) } : { cmd: "expand" };
|
|
39
|
-
}
|
|
40
|
-
case "resume":
|
|
41
|
-
return arg ? { cmd: "resume", id: arg } : { cmd: "resume" };
|
|
42
|
-
case "mode":
|
|
43
|
-
return arg ? { cmd: "mode", id: arg } : { cmd: "mode" };
|
|
44
|
-
case "persona":
|
|
45
|
-
return arg ? { cmd: "persona", id: arg } : { cmd: "persona" };
|
|
46
|
-
case "skill":
|
|
47
|
-
return arg ? { cmd: "skill", id: arg } : { cmd: "skill" };
|
|
48
|
-
case "strategy":
|
|
49
|
-
return arg ? { cmd: "strategy", id: arg } : { cmd: "strategy" };
|
|
50
|
-
default:
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function filterCommands(input) {
|
|
55
|
-
const t = input.trim();
|
|
56
|
-
if (!t.startsWith("/")) return [];
|
|
57
|
-
const prefix = t.slice(1).split(/\s+/)[0].toLowerCase();
|
|
58
|
-
return TERM_COMMANDS.filter((c) => c.name.startsWith(prefix));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
TERM_COMMANDS,
|
|
63
|
-
parseCommand,
|
|
64
|
-
filterCommands
|
|
65
|
-
};
|