@pentoshi/clai 3.11.7 → 3.11.9
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/README.md +15 -0
- package/dist/agent/confirm-port.d.ts +4 -0
- package/dist/agent/confirm-port.js +9 -1
- package/dist/agent/confirm-port.js.map +1 -1
- package/dist/agent/finalize-gate.d.ts +57 -0
- package/dist/agent/finalize-gate.js +146 -0
- package/dist/agent/finalize-gate.js.map +1 -0
- package/dist/agent/runner.js +71 -179
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/tool-call-parser.js +3 -0
- package/dist/agent/tool-call-parser.js.map +1 -1
- package/dist/app/adapters/current-interactive-sessions-adapter.d.ts +4 -0
- package/dist/app/adapters/current-interactive-sessions-adapter.js +12 -0
- package/dist/app/adapters/current-interactive-sessions-adapter.js.map +1 -0
- package/dist/app/controllers/cancel-all-result.d.ts +8 -0
- package/dist/app/controllers/cancel-all-result.js +32 -0
- package/dist/app/controllers/cancel-all-result.js.map +1 -0
- package/dist/app/controllers/session-controller.d.ts +3 -0
- package/dist/app/controllers/session-controller.js +22 -6
- package/dist/app/controllers/session-controller.js.map +1 -1
- package/dist/app/ports/interactive-sessions-port.d.ts +22 -0
- package/dist/app/ports/interactive-sessions-port.js +9 -0
- package/dist/app/ports/interactive-sessions-port.js.map +1 -0
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/dist/interactive-session/artifact-writer.d.ts +54 -0
- package/dist/interactive-session/artifact-writer.js +161 -0
- package/dist/interactive-session/artifact-writer.js.map +1 -0
- package/dist/interactive-session/cleanup.d.ts +37 -0
- package/dist/interactive-session/cleanup.js +191 -0
- package/dist/interactive-session/cleanup.js.map +1 -0
- package/dist/interactive-session/config.d.ts +118 -0
- package/dist/interactive-session/config.js +141 -0
- package/dist/interactive-session/config.js.map +1 -0
- package/dist/interactive-session/input-policy.d.ts +26 -0
- package/dist/interactive-session/input-policy.js +70 -0
- package/dist/interactive-session/input-policy.js.map +1 -0
- package/dist/interactive-session/manager.d.ts +118 -0
- package/dist/interactive-session/manager.js +1214 -0
- package/dist/interactive-session/manager.js.map +1 -0
- package/dist/interactive-session/output-store.d.ts +81 -0
- package/dist/interactive-session/output-store.js +239 -0
- package/dist/interactive-session/output-store.js.map +1 -0
- package/dist/interactive-session/output-view.d.ts +20 -0
- package/dist/interactive-session/output-view.js +142 -0
- package/dist/interactive-session/output-view.js.map +1 -0
- package/dist/interactive-session/recovery-journal.d.ts +53 -0
- package/dist/interactive-session/recovery-journal.js +167 -0
- package/dist/interactive-session/recovery-journal.js.map +1 -0
- package/dist/interactive-session/registry.d.ts +59 -0
- package/dist/interactive-session/registry.js +170 -0
- package/dist/interactive-session/registry.js.map +1 -0
- package/dist/interactive-session/runtime.d.ts +107 -0
- package/dist/interactive-session/runtime.js +191 -0
- package/dist/interactive-session/runtime.js.map +1 -0
- package/dist/interactive-session/session-runtime.d.ts +53 -0
- package/dist/interactive-session/session-runtime.js +65 -0
- package/dist/interactive-session/session-runtime.js.map +1 -0
- package/dist/interactive-session/streaming-redactor.d.ts +53 -0
- package/dist/interactive-session/streaming-redactor.js +271 -0
- package/dist/interactive-session/streaming-redactor.js.map +1 -0
- package/dist/interactive-session/telemetry.d.ts +30 -0
- package/dist/interactive-session/telemetry.js +47 -0
- package/dist/interactive-session/telemetry.js.map +1 -0
- package/dist/interactive-session/transport-factory.d.ts +8 -0
- package/dist/interactive-session/transport-factory.js +16 -0
- package/dist/interactive-session/transport-factory.js.map +1 -0
- package/dist/interactive-session/transport-node-pty.d.ts +38 -0
- package/dist/interactive-session/transport-node-pty.js +390 -0
- package/dist/interactive-session/transport-node-pty.js.map +1 -0
- package/dist/interactive-session/transport-pipe.d.ts +9 -0
- package/dist/interactive-session/transport-pipe.js +267 -0
- package/dist/interactive-session/transport-pipe.js.map +1 -0
- package/dist/interactive-session/transport.d.ts +110 -0
- package/dist/interactive-session/transport.js +89 -0
- package/dist/interactive-session/transport.js.map +1 -0
- package/dist/interactive-session/types.d.ts +258 -0
- package/dist/interactive-session/types.js +191 -0
- package/dist/interactive-session/types.js.map +1 -0
- package/dist/os/process-identity.d.ts +46 -0
- package/dist/os/process-identity.js +147 -0
- package/dist/os/process-identity.js.map +1 -0
- package/dist/os/process-tree.d.ts +1 -0
- package/dist/os/process-tree.js +11 -0
- package/dist/os/process-tree.js.map +1 -1
- package/dist/prompts/embedded.js +1 -1
- package/dist/prompts/embedded.js.map +1 -1
- package/dist/prompts/index.d.ts +7 -0
- package/dist/prompts/index.js +23 -0
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/system.agent.md +3 -0
- package/dist/repl.js +16 -1
- package/dist/repl.js.map +1 -1
- package/dist/safety/classifier.d.ts +9 -0
- package/dist/safety/classifier.js +119 -18
- package/dist/safety/classifier.js.map +1 -1
- package/dist/safety/engagement-policy.d.ts +13 -0
- package/dist/safety/engagement-policy.js +129 -34
- package/dist/safety/engagement-policy.js.map +1 -1
- package/dist/tools/definitions.js +94 -0
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/interactive-session-tools.d.ts +11 -0
- package/dist/tools/interactive-session-tools.js +276 -0
- package/dist/tools/interactive-session-tools.js.map +1 -0
- package/dist/tools/registry.js +3 -0
- package/dist/tools/registry.js.map +1 -1
- package/dist/tui-v2/bootstrap/composition-root.d.ts +3 -0
- package/dist/tui-v2/bootstrap/composition-root.js +3 -0
- package/dist/tui-v2/bootstrap/composition-root.js.map +1 -1
- package/dist/tui-v2/bootstrap/start-tui-v2.js +8 -0
- package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/version.generated.d.ts +2 -2
- package/dist/version.generated.js +2 -2
- package/package.json +7 -6
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive-session configuration: documented defaults, validated ranges, and
|
|
3
|
+
* a runtime kill switch. Every value is validated before a slot is reserved or a
|
|
4
|
+
* process is launched so an out-of-range setting can never produce a live child.
|
|
5
|
+
*/
|
|
6
|
+
import { type SessionOperation, type TerminalDimensions } from "./types.js";
|
|
7
|
+
export interface InteractiveSessionConfig {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
liveSessionLimit: number;
|
|
10
|
+
quietIntervalMs: number;
|
|
11
|
+
startDeadlineMs: number;
|
|
12
|
+
sendDeadlineMs: number;
|
|
13
|
+
closeDeadlineMs: number;
|
|
14
|
+
gracefulCloseMs: number;
|
|
15
|
+
pageBytes: number;
|
|
16
|
+
memoryWindowBytes: number;
|
|
17
|
+
queuedInputBytes: number;
|
|
18
|
+
artifactCaptureBytes: number;
|
|
19
|
+
artifactChunkBytes: number;
|
|
20
|
+
persistenceQueueBytes: number;
|
|
21
|
+
/** Undefined disables the timeout. */
|
|
22
|
+
idleTimeoutMs: number | undefined;
|
|
23
|
+
lifetimeTimeoutMs: number | undefined;
|
|
24
|
+
/** Behavior when artifact capture reaches its limit. */
|
|
25
|
+
onOutputLimit: "terminate" | "continue";
|
|
26
|
+
/** Max bytes retained for cross-chunk secret matching. */
|
|
27
|
+
redactionOverlapBytes: number;
|
|
28
|
+
}
|
|
29
|
+
interface Range {
|
|
30
|
+
readonly min: number;
|
|
31
|
+
readonly max: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const INTERACTIVE_SESSION_RANGES: {
|
|
34
|
+
readonly liveSessionLimit: {
|
|
35
|
+
readonly min: 1;
|
|
36
|
+
readonly max: 32;
|
|
37
|
+
};
|
|
38
|
+
readonly quietIntervalMs: {
|
|
39
|
+
readonly min: 25;
|
|
40
|
+
readonly max: 5000;
|
|
41
|
+
};
|
|
42
|
+
readonly startDeadlineMs: {
|
|
43
|
+
readonly min: 100;
|
|
44
|
+
readonly max: 120000;
|
|
45
|
+
};
|
|
46
|
+
readonly sendDeadlineMs: {
|
|
47
|
+
readonly min: 100;
|
|
48
|
+
readonly max: 120000;
|
|
49
|
+
};
|
|
50
|
+
readonly closeDeadlineMs: {
|
|
51
|
+
readonly min: 100;
|
|
52
|
+
readonly max: 120000;
|
|
53
|
+
};
|
|
54
|
+
readonly gracefulCloseMs: {
|
|
55
|
+
readonly min: 0;
|
|
56
|
+
readonly max: 30000;
|
|
57
|
+
};
|
|
58
|
+
readonly pageBytes: {
|
|
59
|
+
readonly min: 1024;
|
|
60
|
+
readonly max: 1048576;
|
|
61
|
+
};
|
|
62
|
+
readonly memoryWindowBytes: {
|
|
63
|
+
readonly min: 65536;
|
|
64
|
+
readonly max: 16777216;
|
|
65
|
+
};
|
|
66
|
+
readonly queuedInputBytes: {
|
|
67
|
+
readonly min: 1024;
|
|
68
|
+
readonly max: 1048576;
|
|
69
|
+
};
|
|
70
|
+
readonly artifactCaptureBytes: {
|
|
71
|
+
readonly min: 1048576;
|
|
72
|
+
readonly max: 1073741824;
|
|
73
|
+
};
|
|
74
|
+
readonly artifactChunkBytes: {
|
|
75
|
+
readonly min: 65536;
|
|
76
|
+
readonly max: 16777216;
|
|
77
|
+
};
|
|
78
|
+
readonly persistenceQueueBytes: {
|
|
79
|
+
readonly min: 65536;
|
|
80
|
+
readonly max: 16777216;
|
|
81
|
+
};
|
|
82
|
+
readonly idleTimeoutMs: {
|
|
83
|
+
readonly min: 1000;
|
|
84
|
+
readonly max: 86400000;
|
|
85
|
+
};
|
|
86
|
+
readonly lifetimeTimeoutMs: {
|
|
87
|
+
readonly min: 1000;
|
|
88
|
+
readonly max: 604800000;
|
|
89
|
+
};
|
|
90
|
+
readonly redactionOverlapBytes: {
|
|
91
|
+
readonly min: 256;
|
|
92
|
+
readonly max: 65536;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export type RangedConfigField = keyof typeof INTERACTIVE_SESSION_RANGES;
|
|
96
|
+
export declare const DIMENSION_RANGE: Range;
|
|
97
|
+
export declare const DEFAULT_DIMENSIONS: TerminalDimensions;
|
|
98
|
+
/** Hard cap for a blocking read wait, independent of send deadlines. */
|
|
99
|
+
export declare const MAX_READ_WAIT_MS = 30000;
|
|
100
|
+
export declare const MAX_LIST_SUMMARIES = 50;
|
|
101
|
+
export declare const INTERACTIVE_SESSION_DEFAULTS: InteractiveSessionConfig;
|
|
102
|
+
/** Env kill switch. Disables only the seven interactive tools. */
|
|
103
|
+
export declare const KILL_SWITCH_ENV = "CLAI_DISABLE_INTERACTIVE_SESSIONS";
|
|
104
|
+
export type InteractiveSessionOverrides = Partial<InteractiveSessionConfig>;
|
|
105
|
+
/**
|
|
106
|
+
* Resolve the effective configuration. Throws `INVALID_CONFIGURATION` for any
|
|
107
|
+
* out-of-range value so callers fail before allocating resources.
|
|
108
|
+
*/
|
|
109
|
+
export declare function resolveInteractiveSessionConfig(overrides?: InteractiveSessionOverrides, operation?: SessionOperation): InteractiveSessionConfig;
|
|
110
|
+
export declare function isInteractiveSessionsEnabled(config?: InteractiveSessionConfig): boolean;
|
|
111
|
+
/** Per-operation timeout override, validated against the same bounds. */
|
|
112
|
+
export declare function resolveDeadline(field: "startDeadlineMs" | "sendDeadlineMs" | "closeDeadlineMs", override: number | undefined, config: InteractiveSessionConfig, operation: SessionOperation): number;
|
|
113
|
+
export declare function resolveQuietInterval(override: number | undefined, config: InteractiveSessionConfig, operation: SessionOperation): number;
|
|
114
|
+
export declare function resolveOptionalTimeout(field: "idleTimeoutMs" | "lifetimeTimeoutMs", override: number | undefined, config: InteractiveSessionConfig, operation: SessionOperation): number | undefined;
|
|
115
|
+
/** Validate requested dimensions before any lookup or process mutation. */
|
|
116
|
+
export declare function resolveDimensions(columns: number | undefined, rows: number | undefined, operation: SessionOperation): TerminalDimensions;
|
|
117
|
+
export declare function clampReadWait(waitMs: number | undefined): number;
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive-session configuration: documented defaults, validated ranges, and
|
|
3
|
+
* a runtime kill switch. Every value is validated before a slot is reserved or a
|
|
4
|
+
* process is launched so an out-of-range setting can never produce a live child.
|
|
5
|
+
*/
|
|
6
|
+
import { throwSessionError, } from "./types.js";
|
|
7
|
+
export const INTERACTIVE_SESSION_RANGES = {
|
|
8
|
+
liveSessionLimit: { min: 1, max: 32 },
|
|
9
|
+
quietIntervalMs: { min: 25, max: 5_000 },
|
|
10
|
+
startDeadlineMs: { min: 100, max: 120_000 },
|
|
11
|
+
sendDeadlineMs: { min: 100, max: 120_000 },
|
|
12
|
+
closeDeadlineMs: { min: 100, max: 120_000 },
|
|
13
|
+
gracefulCloseMs: { min: 0, max: 30_000 },
|
|
14
|
+
pageBytes: { min: 1_024, max: 1_048_576 },
|
|
15
|
+
memoryWindowBytes: { min: 65_536, max: 16_777_216 },
|
|
16
|
+
queuedInputBytes: { min: 1_024, max: 1_048_576 },
|
|
17
|
+
artifactCaptureBytes: { min: 1_048_576, max: 1_073_741_824 },
|
|
18
|
+
artifactChunkBytes: { min: 65_536, max: 16_777_216 },
|
|
19
|
+
persistenceQueueBytes: { min: 65_536, max: 16_777_216 },
|
|
20
|
+
idleTimeoutMs: { min: 1_000, max: 86_400_000 },
|
|
21
|
+
lifetimeTimeoutMs: { min: 1_000, max: 604_800_000 },
|
|
22
|
+
redactionOverlapBytes: { min: 256, max: 65_536 },
|
|
23
|
+
};
|
|
24
|
+
export const DIMENSION_RANGE = { min: 2, max: 1_000 };
|
|
25
|
+
export const DEFAULT_DIMENSIONS = { columns: 80, rows: 24 };
|
|
26
|
+
/** Hard cap for a blocking read wait, independent of send deadlines. */
|
|
27
|
+
export const MAX_READ_WAIT_MS = 30_000;
|
|
28
|
+
export const MAX_LIST_SUMMARIES = 50;
|
|
29
|
+
export const INTERACTIVE_SESSION_DEFAULTS = {
|
|
30
|
+
enabled: true,
|
|
31
|
+
liveSessionLimit: 4,
|
|
32
|
+
quietIntervalMs: 250,
|
|
33
|
+
startDeadlineMs: 10_000,
|
|
34
|
+
sendDeadlineMs: 30_000,
|
|
35
|
+
closeDeadlineMs: 10_000,
|
|
36
|
+
gracefulCloseMs: 2_000,
|
|
37
|
+
pageBytes: 12_000,
|
|
38
|
+
memoryWindowBytes: 1_048_576,
|
|
39
|
+
queuedInputBytes: 65_536,
|
|
40
|
+
artifactCaptureBytes: 67_108_864,
|
|
41
|
+
artifactChunkBytes: 1_048_576,
|
|
42
|
+
persistenceQueueBytes: 1_048_576,
|
|
43
|
+
idleTimeoutMs: undefined,
|
|
44
|
+
lifetimeTimeoutMs: undefined,
|
|
45
|
+
onOutputLimit: "terminate",
|
|
46
|
+
redactionOverlapBytes: 4_096,
|
|
47
|
+
};
|
|
48
|
+
/** Env kill switch. Disables only the seven interactive tools. */
|
|
49
|
+
export const KILL_SWITCH_ENV = "CLAI_DISABLE_INTERACTIVE_SESSIONS";
|
|
50
|
+
function envDisabled() {
|
|
51
|
+
const raw = process.env[KILL_SWITCH_ENV];
|
|
52
|
+
if (raw === undefined)
|
|
53
|
+
return false;
|
|
54
|
+
const normalized = raw.trim().toLowerCase();
|
|
55
|
+
return normalized === "1" || normalized === "true" || normalized === "yes";
|
|
56
|
+
}
|
|
57
|
+
function invalid(field, message, operation) {
|
|
58
|
+
throwSessionError({
|
|
59
|
+
code: "INVALID_CONFIGURATION",
|
|
60
|
+
operation,
|
|
61
|
+
message,
|
|
62
|
+
details: { field },
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function checkRange(field, value, operation) {
|
|
66
|
+
const { min, max } = INTERACTIVE_SESSION_RANGES[field];
|
|
67
|
+
if (!Number.isInteger(value) || value < min || value > max) {
|
|
68
|
+
invalid(field, `${field} must be an integer between ${min} and ${max}.`, operation);
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolve the effective configuration. Throws `INVALID_CONFIGURATION` for any
|
|
74
|
+
* out-of-range value so callers fail before allocating resources.
|
|
75
|
+
*/
|
|
76
|
+
export function resolveInteractiveSessionConfig(overrides = {}, operation = "start") {
|
|
77
|
+
const merged = { ...INTERACTIVE_SESSION_DEFAULTS, ...overrides };
|
|
78
|
+
for (const field of Object.keys(INTERACTIVE_SESSION_RANGES)) {
|
|
79
|
+
const value = merged[field];
|
|
80
|
+
if (value === undefined)
|
|
81
|
+
continue;
|
|
82
|
+
if (typeof value !== "number") {
|
|
83
|
+
invalid(field, `${field} must be a number.`, operation);
|
|
84
|
+
}
|
|
85
|
+
checkRange(field, value, operation);
|
|
86
|
+
}
|
|
87
|
+
if (merged.artifactChunkBytes > merged.artifactCaptureBytes) {
|
|
88
|
+
invalid("artifactChunkBytes", "artifactChunkBytes cannot exceed artifactCaptureBytes.", operation);
|
|
89
|
+
}
|
|
90
|
+
if (merged.onOutputLimit !== "terminate" && merged.onOutputLimit !== "continue") {
|
|
91
|
+
invalid("onOutputLimit", "onOutputLimit must be terminate or continue.", operation);
|
|
92
|
+
}
|
|
93
|
+
return { ...merged, enabled: merged.enabled && !envDisabled() };
|
|
94
|
+
}
|
|
95
|
+
export function isInteractiveSessionsEnabled(config = resolveInteractiveSessionConfig()) {
|
|
96
|
+
return config.enabled;
|
|
97
|
+
}
|
|
98
|
+
/** Per-operation timeout override, validated against the same bounds. */
|
|
99
|
+
export function resolveDeadline(field, override, config, operation) {
|
|
100
|
+
if (override === undefined)
|
|
101
|
+
return config[field];
|
|
102
|
+
return checkRange(field, override, operation);
|
|
103
|
+
}
|
|
104
|
+
export function resolveQuietInterval(override, config, operation) {
|
|
105
|
+
if (override === undefined)
|
|
106
|
+
return config.quietIntervalMs;
|
|
107
|
+
return checkRange("quietIntervalMs", override, operation);
|
|
108
|
+
}
|
|
109
|
+
export function resolveOptionalTimeout(field, override, config, operation) {
|
|
110
|
+
if (override === undefined)
|
|
111
|
+
return config[field];
|
|
112
|
+
return checkRange(field, override, operation);
|
|
113
|
+
}
|
|
114
|
+
/** Validate requested dimensions before any lookup or process mutation. */
|
|
115
|
+
export function resolveDimensions(columns, rows, operation) {
|
|
116
|
+
const resolved = {
|
|
117
|
+
columns: columns ?? DEFAULT_DIMENSIONS.columns,
|
|
118
|
+
rows: rows ?? DEFAULT_DIMENSIONS.rows,
|
|
119
|
+
};
|
|
120
|
+
for (const [field, value] of Object.entries(resolved)) {
|
|
121
|
+
if (!Number.isInteger(value) ||
|
|
122
|
+
value < DIMENSION_RANGE.min ||
|
|
123
|
+
value > DIMENSION_RANGE.max) {
|
|
124
|
+
throwSessionError({
|
|
125
|
+
code: "INVALID_REQUEST",
|
|
126
|
+
operation,
|
|
127
|
+
message: `${field} must be an integer between ${DIMENSION_RANGE.min} and ${DIMENSION_RANGE.max}.`,
|
|
128
|
+
details: { field },
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return resolved;
|
|
133
|
+
}
|
|
134
|
+
export function clampReadWait(waitMs) {
|
|
135
|
+
if (waitMs === undefined)
|
|
136
|
+
return 0;
|
|
137
|
+
if (!Number.isFinite(waitMs) || waitMs < 0)
|
|
138
|
+
return 0;
|
|
139
|
+
return Math.min(Math.floor(waitMs), MAX_READ_WAIT_MS);
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/interactive-session/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,GAGlB,MAAM,YAAY,CAAC;AA8BpB,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IACrC,eAAe,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;IACxC,eAAe,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE;IAC3C,cAAc,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE;IAC1C,eAAe,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE;IAC3C,eAAe,EAAE,EAAE,GAAG,EAAE,CA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ACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAA0B;IACtD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IACnC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type RiskDecision } from "../safety/classifier.js";
|
|
2
|
+
import type { EngagementScope } from "../store/scope.js";
|
|
3
|
+
import type { SessionInput, SessionTransportKind } from "./types.js";
|
|
4
|
+
export interface InputPolicyContext {
|
|
5
|
+
readonly ownerId: string;
|
|
6
|
+
readonly sessionId: string;
|
|
7
|
+
readonly transport: SessionTransportKind;
|
|
8
|
+
readonly input: SessionInput;
|
|
9
|
+
readonly scope?: EngagementScope | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function classifyInteractiveInput(context: InputPolicyContext): RiskDecision;
|
|
12
|
+
export declare function describeInput(input: SessionInput): string;
|
|
13
|
+
export interface ApprovalBinding {
|
|
14
|
+
readonly ownerId: string;
|
|
15
|
+
readonly sessionId: string;
|
|
16
|
+
readonly input: SessionInput;
|
|
17
|
+
readonly decision: RiskDecision["level"];
|
|
18
|
+
}
|
|
19
|
+
export declare class ApprovalTokenVault {
|
|
20
|
+
private readonly now;
|
|
21
|
+
private readonly tokens;
|
|
22
|
+
constructor(now?: () => number);
|
|
23
|
+
mint(binding: ApprovalBinding): string;
|
|
24
|
+
consume(token: string | undefined, binding: ApprovalBinding): boolean;
|
|
25
|
+
private sweep;
|
|
26
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { maskSecret } from "../llm/provider.js";
|
|
3
|
+
import { classifyInteractiveInput as classifyInput, } from "../safety/classifier.js";
|
|
4
|
+
export function classifyInteractiveInput(context) {
|
|
5
|
+
return classifyInput(context);
|
|
6
|
+
}
|
|
7
|
+
export function describeInput(input) {
|
|
8
|
+
if (input.kind === "eof")
|
|
9
|
+
return "close session input (EOF)";
|
|
10
|
+
if (input.kind === "control")
|
|
11
|
+
return `control: ${input.control}`;
|
|
12
|
+
if (input.kind === "secret") {
|
|
13
|
+
return `${input.submit === "enter" ? "submit" : "type"}: [secret]`;
|
|
14
|
+
}
|
|
15
|
+
const trimmed = input.text.trim();
|
|
16
|
+
const preview = trimmed.length > 120 ? `${trimmed.slice(0, 120)}…` : trimmed;
|
|
17
|
+
const body = /^[\x20-\x7e]*$/.test(preview) ? preview : maskSecret(preview);
|
|
18
|
+
return `${input.submit === "enter" ? "submit" : "type"}: ${body}`;
|
|
19
|
+
}
|
|
20
|
+
const TOKEN_TTL_MS = 60_000;
|
|
21
|
+
const digestKey = randomBytes(32);
|
|
22
|
+
function bindingDigest(binding) {
|
|
23
|
+
const { input } = binding;
|
|
24
|
+
const parts = [
|
|
25
|
+
binding.ownerId,
|
|
26
|
+
binding.sessionId,
|
|
27
|
+
input.kind,
|
|
28
|
+
input.kind === "text" ? input.text : input.kind === "secret" ? input.value : input.kind === "control" ? input.control : "",
|
|
29
|
+
input.kind === "text" || input.kind === "secret" ? input.submit : "",
|
|
30
|
+
binding.decision,
|
|
31
|
+
];
|
|
32
|
+
return createHmac("sha256", digestKey).update(parts.join("\u0000")).digest("hex");
|
|
33
|
+
}
|
|
34
|
+
export class ApprovalTokenVault {
|
|
35
|
+
now;
|
|
36
|
+
tokens = new Map();
|
|
37
|
+
constructor(now = Date.now) {
|
|
38
|
+
this.now = now;
|
|
39
|
+
}
|
|
40
|
+
mint(binding) {
|
|
41
|
+
this.sweep();
|
|
42
|
+
const token = randomBytes(24).toString("base64url");
|
|
43
|
+
this.tokens.set(token, {
|
|
44
|
+
digest: bindingDigest(binding),
|
|
45
|
+
expiresAt: this.now() + TOKEN_TTL_MS,
|
|
46
|
+
});
|
|
47
|
+
return token;
|
|
48
|
+
}
|
|
49
|
+
consume(token, binding) {
|
|
50
|
+
if (!token)
|
|
51
|
+
return false;
|
|
52
|
+
const entry = this.tokens.get(token);
|
|
53
|
+
if (!entry)
|
|
54
|
+
return false;
|
|
55
|
+
this.tokens.delete(token);
|
|
56
|
+
if (entry.expiresAt <= this.now())
|
|
57
|
+
return false;
|
|
58
|
+
const expected = Buffer.from(bindingDigest(binding), "utf8");
|
|
59
|
+
const actual = Buffer.from(entry.digest, "utf8");
|
|
60
|
+
return expected.length === actual.length && timingSafeEqual(expected, actual);
|
|
61
|
+
}
|
|
62
|
+
sweep() {
|
|
63
|
+
const now = this.now();
|
|
64
|
+
for (const [token, entry] of this.tokens) {
|
|
65
|
+
if (entry.expiresAt <= now)
|
|
66
|
+
this.tokens.delete(token);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=input-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-policy.js","sourceRoot":"","sources":["../../src/interactive-session/input-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACL,wBAAwB,IAAI,aAAa,GAG1C,MAAM,yBAAyB,CAAC;AAYjC,MAAM,UAAU,wBAAwB,CACtC,OAA2B;IAE3B,OAAO,aAAa,CAAC,OAAwC,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAmB;IAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK;QAAE,OAAO,2BAA2B,CAAC;IAC7D,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,YAAY,KAAK,CAAC,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AI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,IAAI,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAChF,CAAC;IAEO,KAAK;QACX,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACzC,IAAI,KAAK,CAAC,SAAS,IAAI,GAAG;gBAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
private readonly ownerActivations;
|
|
48
|
+
private readonly pendingStarts;
|
|
49
|
+
private readonly lateLaunches;
|
|
50
|
+
constructor(deps?: InteractiveSessionManagerDeps);
|
|
51
|
+
get config(): InteractiveSessionConfig;
|
|
52
|
+
/** Reconcile crashed-session records. Must run before tools are enabled. */
|
|
53
|
+
reconcileOrphans(): ReconciliationEntry[];
|
|
54
|
+
ptyCapability(): Promise<{
|
|
55
|
+
available: boolean;
|
|
56
|
+
reason?: string | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
start(request: StartRequest & ManagerRequestExtras): Promise<StartResult>;
|
|
59
|
+
private startManaged;
|
|
60
|
+
private launchError;
|
|
61
|
+
private launchWithDeadline;
|
|
62
|
+
send(request: SendRequest & ManagerRequestExtras): Promise<SendResult>;
|
|
63
|
+
private sendError;
|
|
64
|
+
/**
|
|
65
|
+
* Acceptance is all-or-nothing under the mutation lock: either the whole action
|
|
66
|
+
* is reserved within the backpressure bound, or no sequence or queue state
|
|
67
|
+
* changes at all.
|
|
68
|
+
*/
|
|
69
|
+
private accept;
|
|
70
|
+
private assertControlSupported;
|
|
71
|
+
/**
|
|
72
|
+
* Quiet detection starts at delivery completion: only output observed after
|
|
73
|
+
* this point resets the quiet timer, while the absolute deadline never extends.
|
|
74
|
+
*/
|
|
75
|
+
private gather;
|
|
76
|
+
read(request: ReadRequest): Promise<ReadResult>;
|
|
77
|
+
private waitForOutput;
|
|
78
|
+
status(request: {
|
|
79
|
+
ownerId: string;
|
|
80
|
+
id: string;
|
|
81
|
+
}): StatusResult;
|
|
82
|
+
list(request: {
|
|
83
|
+
ownerId: string;
|
|
84
|
+
}): ListResult;
|
|
85
|
+
resize(request: ResizeRequest): Promise<ResizeResult>;
|
|
86
|
+
close(request: CloseRequest): Promise<CloseResult>;
|
|
87
|
+
/** Owner cancellation: closes every live session owned by a conversation. */
|
|
88
|
+
cancelOwner(ownerId: string): Promise<CloseOwnerResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Fence an owner synchronously, then start one tracked close. Callers rebinding
|
|
91
|
+
* a conversation id must fence before the old id becomes unreachable.
|
|
92
|
+
*/
|
|
93
|
+
beginCloseOwner(ownerId: string, reason?: TerminationReason): Promise<CloseOwnerResult>;
|
|
94
|
+
/** Await any teardown already started for an owner. */
|
|
95
|
+
awaitOwnerClose(ownerId: string): Promise<void>;
|
|
96
|
+
activateOwner(ownerId: string): Promise<void>;
|
|
97
|
+
private awaitOwnerActivation;
|
|
98
|
+
closeAll(reason?: TerminationReason): Promise<CloseAllResult>;
|
|
99
|
+
private closeOwnerSessions;
|
|
100
|
+
private finalizeRecord;
|
|
101
|
+
private finalize;
|
|
102
|
+
private authorizeCommand;
|
|
103
|
+
private authorizeInput;
|
|
104
|
+
private registerPendingStart;
|
|
105
|
+
private trackLateLaunch;
|
|
106
|
+
private cancelPendingStarts;
|
|
107
|
+
private releaseUnmanagedTransport;
|
|
108
|
+
private throwIfCancelled;
|
|
109
|
+
private assertOwner;
|
|
110
|
+
private assertNotFenced;
|
|
111
|
+
private assertEnabled;
|
|
112
|
+
private notFound;
|
|
113
|
+
private requireRuntime;
|
|
114
|
+
}
|
|
115
|
+
/** Strict validation of the dependent input fields before acceptance. */
|
|
116
|
+
export declare function validateInput(input: SessionInput | undefined, operation: SessionOperation): SessionInput;
|
|
117
|
+
/** Process-wide manager, mirroring the existing process-wide job manager. */
|
|
118
|
+
export declare const interactiveSessionManager: InteractiveSessionManager;
|