@pentoshi/clai 3.9.4 → 3.9.5

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 (91) hide show
  1. package/dist/app/controllers/session-controller.d.ts +0 -8
  2. package/dist/app/controllers/session-controller.js +4 -20
  3. package/dist/app/controllers/session-controller.js.map +1 -1
  4. package/dist/index.js +8 -21
  5. package/dist/index.js.map +1 -1
  6. package/dist/repl.js +0 -10
  7. package/dist/repl.js.map +1 -1
  8. package/dist/tools/definitions.js +0 -95
  9. package/dist/tools/definitions.js.map +1 -1
  10. package/dist/tools/jobs.js +70 -2
  11. package/dist/tools/jobs.js.map +1 -1
  12. package/dist/tools/registry.js +0 -4
  13. package/dist/tools/registry.js.map +1 -1
  14. package/dist/tui-v2/bootstrap/composition-root.d.ts +0 -3
  15. package/dist/tui-v2/bootstrap/composition-root.js +0 -3
  16. package/dist/tui-v2/bootstrap/composition-root.js.map +1 -1
  17. package/dist/tui-v2/bootstrap/start-tui-v2.js +0 -10
  18. package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -1
  19. package/dist/types.d.ts +0 -5
  20. package/dist/version.generated.d.ts +2 -2
  21. package/dist/version.generated.js +2 -2
  22. package/package.json +1 -1
  23. package/dist/app/adapters/current-interactive-sessions-adapter.d.ts +0 -4
  24. package/dist/app/adapters/current-interactive-sessions-adapter.js +0 -11
  25. package/dist/app/adapters/current-interactive-sessions-adapter.js.map +0 -1
  26. package/dist/app/controllers/cancel-all-result.d.ts +0 -8
  27. package/dist/app/controllers/cancel-all-result.js +0 -32
  28. package/dist/app/controllers/cancel-all-result.js.map +0 -1
  29. package/dist/app/ports/interactive-sessions-port.d.ts +0 -21
  30. package/dist/app/ports/interactive-sessions-port.js +0 -9
  31. package/dist/app/ports/interactive-sessions-port.js.map +0 -1
  32. package/dist/interactive-session/artifact-writer.d.ts +0 -54
  33. package/dist/interactive-session/artifact-writer.js +0 -161
  34. package/dist/interactive-session/artifact-writer.js.map +0 -1
  35. package/dist/interactive-session/cleanup.d.ts +0 -36
  36. package/dist/interactive-session/cleanup.js +0 -157
  37. package/dist/interactive-session/cleanup.js.map +0 -1
  38. package/dist/interactive-session/config.d.ts +0 -118
  39. package/dist/interactive-session/config.js +0 -141
  40. package/dist/interactive-session/config.js.map +0 -1
  41. package/dist/interactive-session/input-policy.d.ts +0 -41
  42. package/dist/interactive-session/input-policy.js +0 -163
  43. package/dist/interactive-session/input-policy.js.map +0 -1
  44. package/dist/interactive-session/manager.d.ts +0 -107
  45. package/dist/interactive-session/manager.js +0 -927
  46. package/dist/interactive-session/manager.js.map +0 -1
  47. package/dist/interactive-session/output-store.d.ts +0 -81
  48. package/dist/interactive-session/output-store.js +0 -239
  49. package/dist/interactive-session/output-store.js.map +0 -1
  50. package/dist/interactive-session/output-view.d.ts +0 -20
  51. package/dist/interactive-session/output-view.js +0 -142
  52. package/dist/interactive-session/output-view.js.map +0 -1
  53. package/dist/interactive-session/recovery-journal.d.ts +0 -55
  54. package/dist/interactive-session/recovery-journal.js +0 -115
  55. package/dist/interactive-session/recovery-journal.js.map +0 -1
  56. package/dist/interactive-session/registry.d.ts +0 -59
  57. package/dist/interactive-session/registry.js +0 -170
  58. package/dist/interactive-session/registry.js.map +0 -1
  59. package/dist/interactive-session/runtime.d.ts +0 -107
  60. package/dist/interactive-session/runtime.js +0 -191
  61. package/dist/interactive-session/runtime.js.map +0 -1
  62. package/dist/interactive-session/session-runtime.d.ts +0 -50
  63. package/dist/interactive-session/session-runtime.js +0 -63
  64. package/dist/interactive-session/session-runtime.js.map +0 -1
  65. package/dist/interactive-session/streaming-redactor.d.ts +0 -53
  66. package/dist/interactive-session/streaming-redactor.js +0 -263
  67. package/dist/interactive-session/streaming-redactor.js.map +0 -1
  68. package/dist/interactive-session/telemetry.d.ts +0 -30
  69. package/dist/interactive-session/telemetry.js +0 -47
  70. package/dist/interactive-session/telemetry.js.map +0 -1
  71. package/dist/interactive-session/transport-factory.d.ts +0 -8
  72. package/dist/interactive-session/transport-factory.js +0 -16
  73. package/dist/interactive-session/transport-factory.js.map +0 -1
  74. package/dist/interactive-session/transport-node-pty.d.ts +0 -49
  75. package/dist/interactive-session/transport-node-pty.js +0 -219
  76. package/dist/interactive-session/transport-node-pty.js.map +0 -1
  77. package/dist/interactive-session/transport-pipe.d.ts +0 -9
  78. package/dist/interactive-session/transport-pipe.js +0 -215
  79. package/dist/interactive-session/transport-pipe.js.map +0 -1
  80. package/dist/interactive-session/transport.d.ts +0 -104
  81. package/dist/interactive-session/transport.js +0 -89
  82. package/dist/interactive-session/transport.js.map +0 -1
  83. package/dist/interactive-session/types.d.ts +0 -254
  84. package/dist/interactive-session/types.js +0 -191
  85. package/dist/interactive-session/types.js.map +0 -1
  86. package/dist/os/process-identity.d.ts +0 -46
  87. package/dist/os/process-identity.js +0 -147
  88. package/dist/os/process-identity.js.map +0 -1
  89. package/dist/tools/interactive-session-tools.d.ts +0 -11
  90. package/dist/tools/interactive-session-tools.js +0 -261
  91. package/dist/tools/interactive-session-tools.js.map +0 -1
@@ -1,41 +0,0 @@
1
- /**
2
- * Contextual policy for later interactive input.
3
- *
4
- * Generic tool classification cannot decide this: the risk of a keystroke depends
5
- * on the owning session, the exact bytes, and whether they are being submitted.
6
- * Risk is monotonic with the shell boundary — a command sent into a session is
7
- * never rated lower than the same command run through `shell.exec`.
8
- */
9
- import type { RiskDecision } from "../safety/classifier.js";
10
- import type { EngagementScope } from "../store/scope.js";
11
- import type { SessionInput, SessionTransportKind } from "./types.js";
12
- export interface InputPolicyContext {
13
- readonly ownerId: string;
14
- readonly sessionId: string;
15
- readonly transport: SessionTransportKind;
16
- readonly input: SessionInput;
17
- readonly scope?: EngagementScope | undefined;
18
- }
19
- export declare function classifyInteractiveInput(context: InputPolicyContext): RiskDecision;
20
- /** Redacted, bounded description shown in a confirmation preview. */
21
- export declare function describeInput(input: SessionInput): string;
22
- export interface ApprovalBinding {
23
- readonly ownerId: string;
24
- readonly sessionId: string;
25
- readonly input: SessionInput;
26
- readonly decision: RiskDecision["level"];
27
- }
28
- export declare class ApprovalTokenVault {
29
- private readonly now;
30
- private readonly tokens;
31
- constructor(now?: () => number);
32
- mint(binding: ApprovalBinding): string;
33
- /**
34
- * Validate and invalidate atomically. Any change to owner, session, bytes,
35
- * kind, submit behavior, or decision fails, and a token is single-use so a
36
- * concurrent replay cannot deliver the same input twice.
37
- */
38
- consume(token: string | undefined, binding: ApprovalBinding): boolean;
39
- /** Expiry sweep; single-use semantics make stale tokens unusable anyway. */
40
- private sweep;
41
- }
@@ -1,163 +0,0 @@
1
- /**
2
- * Contextual policy for later interactive input.
3
- *
4
- * Generic tool classification cannot decide this: the risk of a keystroke depends
5
- * on the owning session, the exact bytes, and whether they are being submitted.
6
- * Risk is monotonic with the shell boundary — a command sent into a session is
7
- * never rated lower than the same command run through `shell.exec`.
8
- */
9
- import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
10
- import { classifyShellCommand } from "../safety/classifier.js";
11
- import { maskSecret } from "../llm/provider.js";
12
- /** Controls that only move a cursor or redraw a prompt carry no risk. */
13
- const SAFE_CONTROLS = new Set([
14
- "escape",
15
- "tab",
16
- "backspace",
17
- "up",
18
- "down",
19
- "left",
20
- "right",
21
- "interrupt",
22
- "suspend",
23
- "eof",
24
- ]);
25
- /**
26
- * Short, unambiguous REPL answers. Everything outside this set is treated as
27
- * unknown submitted text and therefore requires confirmation.
28
- */
29
- const RECOGNIZED_ANSWER_RE = /^(y|n|yes|no|q|quit|exit|:q|:q!|help|\?|\d+(\.\d+)?|true|false|none|null)$/i;
30
- /** REPL constructs that destroy data or escape the interpreter irreversibly. */
31
- const REPL_DESTRUCTIVE_PATTERNS = [
32
- /\bshutil\s*\.\s*rmtree\b/i,
33
- /\bos\s*\.\s*(remove|unlink|rmdir)\b/i,
34
- /\bfs\s*\.\s*(unlink|rm|rmdir)Sync?\b/i,
35
- /\bDROP\s+(TABLE|DATABASE|SCHEMA)\b/i,
36
- /\bTRUNCATE\s+TABLE\b/i,
37
- /\bDELETE\s+FROM\b(?![\s\S]*\bWHERE\b)/i,
38
- /\bRemove-Item\b[\s\S]*-Recurse/i,
39
- ];
40
- /** REPL constructs that mutate state or reach outside the interpreter. */
41
- const REPL_MUTATOR_PATTERNS = [
42
- /\bos\s*\.\s*system\b/i,
43
- /\bsubprocess\s*\.\s*(run|call|Popen|check_output)\b/i,
44
- /\bchild_process\b/i,
45
- /\brequire\s*\(\s*['"]fs['"]\s*\)/i,
46
- /\b(eval|exec)\s*\(/i,
47
- /\bopen\s*\([^)]*['"][wa]\+?['"]/i,
48
- /\bInvoke-(Expression|WebRequest|RestMethod)\b/i,
49
- /\b(UPDATE|INSERT\s+INTO|ALTER\s+TABLE|GRANT|REVOKE)\b/i,
50
- /\bpip\s+install\b|\bnpm\s+(install|i)\b/i,
51
- ];
52
- const EXFILTRATION_PATTERNS = [
53
- /\b(curl|wget)\b[\s\S]*\|\s*(sh|bash|zsh|python)/i,
54
- /\bbase64\b[\s\S]*\|\s*(curl|wget|nc)\b/i,
55
- ];
56
- export function classifyInteractiveInput(context) {
57
- const { input } = context;
58
- if (input.kind === "eof") {
59
- return { level: "safe", reason: "Closing session input has no command effect" };
60
- }
61
- if (input.kind === "control") {
62
- return SAFE_CONTROLS.has(input.control)
63
- ? { level: "safe", reason: "Terminal navigation control" }
64
- : { level: "confirm", reason: "Unrecognized terminal control" };
65
- }
66
- const text = input.text;
67
- if (text.trim().length === 0) {
68
- return { level: "safe", reason: "Whitespace-only input has no command effect" };
69
- }
70
- if (EXFILTRATION_PATTERNS.some((pattern) => pattern.test(text))) {
71
- return {
72
- level: "block",
73
- reason: "Input pipes remote content into an interpreter or exports local data",
74
- };
75
- }
76
- if (REPL_DESTRUCTIVE_PATTERNS.some((pattern) => pattern.test(text))) {
77
- return { level: "block", reason: "Input matches a destructive REPL pattern" };
78
- }
79
- // Never rate an interactive command below the shell boundary for the same text.
80
- const shellDecision = classifyShellCommand(text, context.scope ? { scope: context.scope } : {});
81
- if (shellDecision.level !== "safe")
82
- return shellDecision;
83
- if (REPL_MUTATOR_PATTERNS.some((pattern) => pattern.test(text))) {
84
- return { level: "confirm", reason: "Input mutates state through an interpreter" };
85
- }
86
- if (RECOGNIZED_ANSWER_RE.test(text.trim())) {
87
- return { level: "safe", reason: "Recognized prompt answer" };
88
- }
89
- return {
90
- level: "confirm",
91
- reason: "Submitted interactive text is not recognized as read-only",
92
- };
93
- }
94
- /** Redacted, bounded description shown in a confirmation preview. */
95
- export function describeInput(input) {
96
- if (input.kind === "eof")
97
- return "close session input (EOF)";
98
- if (input.kind === "control")
99
- return `control: ${input.control}`;
100
- const trimmed = input.text.trim();
101
- const preview = trimmed.length > 120 ? `${trimmed.slice(0, 120)}…` : trimmed;
102
- const body = /^[\x20-\x7e]*$/.test(preview) ? preview : maskSecret(preview);
103
- return `${input.submit === "enter" ? "submit" : "type"}: ${body}`;
104
- }
105
- // --- Approval tokens ----------------------------------------------------
106
- const TOKEN_TTL_MS = 60_000;
107
- /** Per-process key: digests are never persisted, logged, or returned. */
108
- const digestKey = randomBytes(32);
109
- function bindingDigest(binding) {
110
- const { input } = binding;
111
- const parts = [
112
- binding.ownerId,
113
- binding.sessionId,
114
- input.kind,
115
- input.kind === "text" ? input.text : input.kind === "control" ? input.control : "",
116
- input.kind === "text" ? input.submit : "",
117
- binding.decision,
118
- ];
119
- return createHmac("sha256", digestKey).update(parts.join("\u0000")).digest("hex");
120
- }
121
- export class ApprovalTokenVault {
122
- now;
123
- tokens = new Map();
124
- constructor(now = Date.now) {
125
- this.now = now;
126
- }
127
- mint(binding) {
128
- this.sweep();
129
- const token = randomBytes(24).toString("base64url");
130
- this.tokens.set(token, {
131
- digest: bindingDigest(binding),
132
- expiresAt: this.now() + TOKEN_TTL_MS,
133
- });
134
- return token;
135
- }
136
- /**
137
- * Validate and invalidate atomically. Any change to owner, session, bytes,
138
- * kind, submit behavior, or decision fails, and a token is single-use so a
139
- * concurrent replay cannot deliver the same input twice.
140
- */
141
- consume(token, binding) {
142
- if (!token)
143
- return false;
144
- const entry = this.tokens.get(token);
145
- if (!entry)
146
- return false;
147
- this.tokens.delete(token);
148
- if (entry.expiresAt <= this.now())
149
- return false;
150
- const expected = Buffer.from(bindingDigest(binding), "utf8");
151
- const actual = Buffer.from(entry.digest, "utf8");
152
- return expected.length === actual.length && timingSafeEqual(expected, actual);
153
- }
154
- /** Expiry sweep; single-use semantics make stale tokens unusable anyway. */
155
- sweep() {
156
- const now = this.now();
157
- for (const [token, entry] of this.tokens) {
158
- if (entry.expiresAt <= now)
159
- this.tokens.delete(token);
160
- }
161
- }
162
- }
163
- //# sourceMappingURL=input-policy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input-policy.js","sourceRoot":"","sources":["../../src/interactive-session/input-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAWhD,yEAAyE;AACzE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,QAAQ;IACR,KAAK;IACL,WAAW;IACX,IAAI;IACJ,MAAM;IACN,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACT,KAAK;CACN,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,oBAAoB,GACxB,6EAA6E,CAAC;AAEhF,gFAAgF;AAChF,MAAM,yBAAyB,GAAsB;IACnD,2BAA2B;IAC3B,sCAAsC;IACtC,uCAAuC;IACvC,qCAAqC;IACrC,uBAAuB;IACvB,wCAAwC;IACxC,iCAAiC;CAClC,CAAC;AAEF,0EAA0E;AAC1E,MAAM,qBAAqB,GAAsB;IAC/C,uBAAuB;IACvB,sDAAsD;IACtD,oBAAoB;IACpB,mCAAmC;IACnC,qBAAqB;IACrB,kCAAkC;I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F"}
@@ -1,107 +0,0 @@
1
- /**
2
- * Interactive session manager: the single owner of persistent interactive
3
- * process lifecycle.
4
- *
5
- * Ownership is conversation-scoped. Every operation requires an owner id, and a
6
- * lookup for another owner is indistinguishable from a missing session so the
7
- * manager cannot be used as an existence oracle. Direct user-terminal handoff is
8
- * outside this contract by design.
9
- */
10
- import type { EngagementScope } from "../store/scope.js";
11
- import { type InteractiveSessionConfig, type InteractiveSessionOverrides } from "./config.js";
12
- import { RecoveryJournal, type ReconciliationEntry } from "./recovery-journal.js";
13
- import { type Clock } from "./runtime.js";
14
- import { SessionTelemetry } from "./telemetry.js";
15
- import { type SessionTransportFactory } from "./transport.js";
16
- import { type CloseAllResult, type CloseOwnerResult, type CloseRequest, type CloseResult, type ListResult, type ReadRequest, type ReadResult, type ResizeRequest, type ResizeResult, type SendRequest, type SendResult, type SessionInput, type SessionOperation, type StartRequest, type StartResult, type StatusResult, type TerminationReason } from "./types.js";
17
- /** Confirmation surface for a `confirm`-level action. Previews are redacted. */
18
- export type ConfirmPreview = (request: {
19
- readonly title: string;
20
- readonly description: string;
21
- readonly reason: string;
22
- }) => Promise<boolean>;
23
- export interface ManagerRequestExtras {
24
- readonly confirm?: ConfirmPreview | undefined;
25
- readonly scope?: EngagementScope | undefined;
26
- }
27
- export interface InteractiveSessionManagerDeps {
28
- readonly config?: InteractiveSessionOverrides | undefined;
29
- readonly transports?: SessionTransportFactory | undefined;
30
- readonly clock?: Clock | undefined;
31
- readonly journal?: RecoveryJournal | undefined;
32
- readonly telemetry?: SessionTelemetry | undefined;
33
- readonly artifactBaseDir?: string | undefined;
34
- }
35
- export declare class InteractiveSessionManager {
36
- private readonly registry;
37
- private readonly runtimes;
38
- private readonly approvals;
39
- private readonly telemetry;
40
- private readonly journal;
41
- private readonly cleanup;
42
- private readonly transports;
43
- private readonly clock;
44
- private readonly baseConfig;
45
- private readonly artifactBaseDir;
46
- private readonly ownerCloses;
47
- constructor(deps?: InteractiveSessionManagerDeps);
48
- get config(): InteractiveSessionConfig;
49
- /** Reconcile crashed-session records. Must run before tools are enabled. */
50
- reconcileOrphans(): ReconciliationEntry[];
51
- ptyCapability(): Promise<{
52
- available: boolean;
53
- reason?: string | undefined;
54
- }>;
55
- start(request: StartRequest & ManagerRequestExtras): Promise<StartResult>;
56
- private launchError;
57
- private launchWithDeadline;
58
- send(request: SendRequest & ManagerRequestExtras): Promise<SendResult>;
59
- private sendError;
60
- /**
61
- * Acceptance is all-or-nothing under the mutation lock: either the whole action
62
- * is reserved within the backpressure bound, or no sequence or queue state
63
- * changes at all.
64
- */
65
- private accept;
66
- private assertControlSupported;
67
- /**
68
- * Quiet detection starts at delivery completion: only output observed after
69
- * this point resets the quiet timer, while the absolute deadline never extends.
70
- */
71
- private gather;
72
- read(request: ReadRequest): Promise<ReadResult>;
73
- private waitForOutput;
74
- status(request: {
75
- ownerId: string;
76
- id: string;
77
- }): StatusResult;
78
- list(request: {
79
- ownerId: string;
80
- }): ListResult;
81
- resize(request: ResizeRequest): Promise<ResizeResult>;
82
- close(request: CloseRequest): Promise<CloseResult>;
83
- /** Owner cancellation: closes every live session owned by a conversation. */
84
- cancelOwner(ownerId: string): Promise<CloseOwnerResult>;
85
- /**
86
- * Fence an owner synchronously, then start one tracked close. Callers rebinding
87
- * a conversation id must fence before the old id becomes unreachable.
88
- */
89
- beginCloseOwner(ownerId: string, reason?: TerminationReason): Promise<CloseOwnerResult>;
90
- /** Await any teardown already started for an owner. */
91
- awaitOwnerClose(ownerId: string): Promise<void>;
92
- closeAll(reason?: TerminationReason): Promise<CloseAllResult>;
93
- private closeOwnerSessions;
94
- private finalizeRecord;
95
- private finalize;
96
- private authorizeCommand;
97
- private authorizeInput;
98
- private assertOwner;
99
- private assertNotFenced;
100
- private assertEnabled;
101
- private notFound;
102
- private requireRuntime;
103
- }
104
- /** Strict validation of the dependent input fields before acceptance. */
105
- export declare function validateInput(input: SessionInput | undefined, operation: SessionOperation): SessionInput;
106
- /** Process-wide manager, mirroring the existing process-wide job manager. */
107
- export declare const interactiveSessionManager: InteractiveSessionManager;