@getpaseo/protocol 0.1.84
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 +12 -0
- package/dist/agent-attention-notification.d.ts +41 -0
- package/dist/agent-attention-notification.js +140 -0
- package/dist/agent-labels.d.ts +2 -0
- package/dist/agent-labels.js +2 -0
- package/dist/agent-lifecycle.d.ts +3 -0
- package/dist/agent-lifecycle.js +8 -0
- package/dist/agent-state-bucket.d.ts +13 -0
- package/dist/agent-state-bucket.js +41 -0
- package/dist/agent-title-limits.d.ts +3 -0
- package/dist/agent-title-limits.js +3 -0
- package/dist/agent-types.d.ts +421 -0
- package/dist/agent-types.js +22 -0
- package/dist/binary-frames/file-transfer.d.ts +56 -0
- package/dist/binary-frames/file-transfer.js +108 -0
- package/dist/binary-frames/index.d.ts +3 -0
- package/dist/binary-frames/index.js +3 -0
- package/dist/binary-frames/terminal.d.ts +37 -0
- package/dist/binary-frames/terminal.js +101 -0
- package/dist/chat/rpc-schemas.d.ts +728 -0
- package/dist/chat/rpc-schemas.js +103 -0
- package/dist/chat/types.d.ts +75 -0
- package/dist/chat/types.js +22 -0
- package/dist/client-capabilities.d.ts +6 -0
- package/dist/client-capabilities.js +9 -0
- package/dist/connection-offer.d.ts +80 -0
- package/dist/connection-offer.js +53 -0
- package/dist/daemon-endpoints.d.ts +47 -0
- package/dist/daemon-endpoints.js +201 -0
- package/dist/error-utils.d.ts +11 -0
- package/dist/error-utils.js +27 -0
- package/dist/git-remote.d.ts +16 -0
- package/dist/git-remote.js +72 -0
- package/dist/host-connection-schema.d.ts +23 -0
- package/dist/host-connection-schema.js +9 -0
- package/dist/importable-providers.d.ts +7 -0
- package/dist/importable-providers.js +7 -0
- package/dist/literal-union.d.ts +2 -0
- package/dist/literal-union.js +2 -0
- package/dist/loop/rpc-schemas.d.ts +3005 -0
- package/dist/loop/rpc-schemas.js +163 -0
- package/dist/messages.d.ts +144995 -0
- package/dist/messages.js +3338 -0
- package/dist/paseo-config-schema.d.ts +915 -0
- package/dist/paseo-config-schema.js +77 -0
- package/dist/path-utils.d.ts +2 -0
- package/dist/path-utils.js +16 -0
- package/dist/provider-config.d.ts +602 -0
- package/dist/provider-config.js +123 -0
- package/dist/provider-manifest.d.ts +33 -0
- package/dist/provider-manifest.js +219 -0
- package/dist/schedule/rpc-schemas.d.ts +3993 -0
- package/dist/schedule/rpc-schemas.js +151 -0
- package/dist/schedule/types.d.ts +745 -0
- package/dist/schedule/types.js +74 -0
- package/dist/terminal-input-mode.d.ts +26 -0
- package/dist/terminal-input-mode.js +151 -0
- package/dist/terminal-key-input.d.ts +13 -0
- package/dist/terminal-key-input.js +201 -0
- package/dist/terminal-snapshot.d.ts +3 -0
- package/dist/terminal-snapshot.js +165 -0
- package/dist/terminal-stream-protocol.d.ts +2 -0
- package/dist/terminal-stream-protocol.js +2 -0
- package/dist/tool-call-display.d.ts +11 -0
- package/dist/tool-call-display.js +135 -0
- package/dist/tool-name-normalization.d.ts +9 -0
- package/dist/tool-name-normalization.js +82 -0
- package/package.json +34 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AgentProviderSchema } from "@getpaseo/protocol/provider-manifest";
|
|
3
|
+
export const ScheduleStatusSchema = z.enum(["active", "paused", "completed"]);
|
|
4
|
+
export const ScheduleCadenceSchema = z.discriminatedUnion("type", [
|
|
5
|
+
z.object({
|
|
6
|
+
type: z.literal("every"),
|
|
7
|
+
everyMs: z.number().int().positive(),
|
|
8
|
+
}),
|
|
9
|
+
z.object({
|
|
10
|
+
type: z.literal("cron"),
|
|
11
|
+
expression: z.string().trim().min(1),
|
|
12
|
+
}),
|
|
13
|
+
]);
|
|
14
|
+
export const ScheduleTargetSchema = z.discriminatedUnion("type", [
|
|
15
|
+
z.object({
|
|
16
|
+
type: z.literal("agent"),
|
|
17
|
+
agentId: z.string().uuid(),
|
|
18
|
+
}),
|
|
19
|
+
z.object({
|
|
20
|
+
type: z.literal("new-agent"),
|
|
21
|
+
config: z.object({
|
|
22
|
+
provider: AgentProviderSchema,
|
|
23
|
+
cwd: z.string().trim().min(1),
|
|
24
|
+
modeId: z.string().trim().min(1).optional(),
|
|
25
|
+
model: z.string().trim().min(1).optional(),
|
|
26
|
+
thinkingOptionId: z.string().trim().min(1).optional(),
|
|
27
|
+
title: z.string().trim().min(1).nullable().optional(),
|
|
28
|
+
approvalPolicy: z.string().trim().min(1).optional(),
|
|
29
|
+
sandboxMode: z.string().trim().min(1).optional(),
|
|
30
|
+
networkAccess: z.boolean().optional(),
|
|
31
|
+
webSearch: z.boolean().optional(),
|
|
32
|
+
featureValues: z.record(z.unknown()).optional(),
|
|
33
|
+
extra: z
|
|
34
|
+
.object({
|
|
35
|
+
codex: z.record(z.unknown()).optional(),
|
|
36
|
+
claude: z.record(z.unknown()).optional(),
|
|
37
|
+
})
|
|
38
|
+
.partial()
|
|
39
|
+
.optional(),
|
|
40
|
+
systemPrompt: z.string().optional(),
|
|
41
|
+
mcpServers: z.record(z.unknown()).optional(),
|
|
42
|
+
}),
|
|
43
|
+
}),
|
|
44
|
+
]);
|
|
45
|
+
export const ScheduleRunSchema = z.object({
|
|
46
|
+
id: z.string(),
|
|
47
|
+
scheduledFor: z.string(),
|
|
48
|
+
startedAt: z.string(),
|
|
49
|
+
endedAt: z.string().nullable(),
|
|
50
|
+
status: z.enum(["running", "succeeded", "failed"]),
|
|
51
|
+
agentId: z.string().uuid().nullable(),
|
|
52
|
+
output: z.string().nullable(),
|
|
53
|
+
error: z.string().nullable(),
|
|
54
|
+
});
|
|
55
|
+
export const StoredScheduleSchema = z.object({
|
|
56
|
+
id: z.string(),
|
|
57
|
+
name: z.string().nullable(),
|
|
58
|
+
prompt: z.string().min(1),
|
|
59
|
+
cadence: ScheduleCadenceSchema,
|
|
60
|
+
target: ScheduleTargetSchema,
|
|
61
|
+
status: ScheduleStatusSchema,
|
|
62
|
+
createdAt: z.string(),
|
|
63
|
+
updatedAt: z.string(),
|
|
64
|
+
nextRunAt: z.string().nullable(),
|
|
65
|
+
lastRunAt: z.string().nullable(),
|
|
66
|
+
pausedAt: z.string().nullable(),
|
|
67
|
+
expiresAt: z.string().nullable(),
|
|
68
|
+
maxRuns: z.number().int().positive().nullable(),
|
|
69
|
+
runs: z.array(ScheduleRunSchema),
|
|
70
|
+
});
|
|
71
|
+
export const ScheduleSummarySchema = StoredScheduleSchema.omit({
|
|
72
|
+
runs: true,
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface TerminalInputModeFeedResult {
|
|
2
|
+
changed: boolean;
|
|
3
|
+
responses: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface TerminalInputModeState {
|
|
6
|
+
kittyKeyboardFlags: number;
|
|
7
|
+
win32InputMode: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const DEFAULT_TERMINAL_INPUT_MODE_STATE: TerminalInputModeState;
|
|
10
|
+
export declare function terminalInputModeSupportsModifiedEnter(state: TerminalInputModeState): boolean;
|
|
11
|
+
export declare function terminalInputModeStatesEqual(left: TerminalInputModeState, right: TerminalInputModeState): boolean;
|
|
12
|
+
export declare class TerminalInputModeTracker {
|
|
13
|
+
private kittyKeyboardFlags;
|
|
14
|
+
private win32InputMode;
|
|
15
|
+
private readonly kittyKeyboardStack;
|
|
16
|
+
private pending;
|
|
17
|
+
feed(data: string): TerminalInputModeFeedResult;
|
|
18
|
+
reset(): void;
|
|
19
|
+
getState(): TerminalInputModeState;
|
|
20
|
+
getKittyKeyboardFlags(): number;
|
|
21
|
+
supportsModifiedEnter(): boolean;
|
|
22
|
+
getPreamble(): string;
|
|
23
|
+
private applyKittyKeyboardSequence;
|
|
24
|
+
private applyPrivateModeSequence;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=terminal-input-mode.d.ts.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export const DEFAULT_TERMINAL_INPUT_MODE_STATE = {
|
|
2
|
+
kittyKeyboardFlags: 0,
|
|
3
|
+
win32InputMode: false,
|
|
4
|
+
};
|
|
5
|
+
const ESC = String.fromCharCode(0x1b);
|
|
6
|
+
const WIN32_INPUT_MODE = 9001;
|
|
7
|
+
const CSI_INPUT_MODE_SEQUENCE = new RegExp(`${ESC}\\[(?:([<>=?]?)([0-9;]*)u|\\?([0-9;]*)([hl]))`, "g");
|
|
8
|
+
const INCOMPLETE_CSI_INPUT_MODE_SEQUENCE = new RegExp(`${ESC}\\[[<>=?]?[0-9;]*$`);
|
|
9
|
+
function parseFirstParam(params) {
|
|
10
|
+
const first = params.split(";")[0];
|
|
11
|
+
if (!first || !/^\d+$/.test(first)) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return Number(first);
|
|
15
|
+
}
|
|
16
|
+
function parseSecondParam(params) {
|
|
17
|
+
const second = params.split(";")[1];
|
|
18
|
+
if (!second || !/^\d+$/.test(second)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return Number(second);
|
|
22
|
+
}
|
|
23
|
+
function parsePrivateModeParams(params) {
|
|
24
|
+
const modes = new Set();
|
|
25
|
+
for (const param of params.split(";")) {
|
|
26
|
+
if (/^\d+$/.test(param)) {
|
|
27
|
+
modes.add(Number(param));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return modes;
|
|
31
|
+
}
|
|
32
|
+
export function terminalInputModeSupportsModifiedEnter(state) {
|
|
33
|
+
return state.kittyKeyboardFlags > 0 || state.win32InputMode;
|
|
34
|
+
}
|
|
35
|
+
export function terminalInputModeStatesEqual(left, right) {
|
|
36
|
+
return (left.kittyKeyboardFlags === right.kittyKeyboardFlags &&
|
|
37
|
+
left.win32InputMode === right.win32InputMode);
|
|
38
|
+
}
|
|
39
|
+
export class TerminalInputModeTracker {
|
|
40
|
+
constructor() {
|
|
41
|
+
this.kittyKeyboardFlags = 0;
|
|
42
|
+
this.win32InputMode = false;
|
|
43
|
+
this.kittyKeyboardStack = [];
|
|
44
|
+
this.pending = "";
|
|
45
|
+
}
|
|
46
|
+
feed(data) {
|
|
47
|
+
if (data.length === 0) {
|
|
48
|
+
return { changed: false, responses: [] };
|
|
49
|
+
}
|
|
50
|
+
const text = `${this.pending}${data}`;
|
|
51
|
+
this.pending = "";
|
|
52
|
+
let changed = false;
|
|
53
|
+
const responses = [];
|
|
54
|
+
let consumedUntil = 0;
|
|
55
|
+
CSI_INPUT_MODE_SEQUENCE.lastIndex = 0;
|
|
56
|
+
for (;;) {
|
|
57
|
+
const match = CSI_INPUT_MODE_SEQUENCE.exec(text);
|
|
58
|
+
if (!match) {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
consumedUntil = CSI_INPUT_MODE_SEQUENCE.lastIndex;
|
|
62
|
+
if (match[4]) {
|
|
63
|
+
changed = this.applyPrivateModeSequence(match[3] ?? "", match[4]) || changed;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const result = this.applyKittyKeyboardSequence(match[1] ?? "", match[2] ?? "");
|
|
67
|
+
changed = changed || result.changed;
|
|
68
|
+
responses.push(...result.responses);
|
|
69
|
+
}
|
|
70
|
+
const tail = text.slice(consumedUntil);
|
|
71
|
+
const pendingStart = tail.lastIndexOf(`${ESC}[`);
|
|
72
|
+
if (pendingStart >= 0) {
|
|
73
|
+
const pending = tail.slice(pendingStart);
|
|
74
|
+
if (INCOMPLETE_CSI_INPUT_MODE_SEQUENCE.test(pending)) {
|
|
75
|
+
this.pending = pending;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { changed, responses };
|
|
79
|
+
}
|
|
80
|
+
reset() {
|
|
81
|
+
this.kittyKeyboardFlags = 0;
|
|
82
|
+
this.win32InputMode = false;
|
|
83
|
+
this.kittyKeyboardStack.length = 0;
|
|
84
|
+
this.pending = "";
|
|
85
|
+
}
|
|
86
|
+
getState() {
|
|
87
|
+
return {
|
|
88
|
+
kittyKeyboardFlags: this.kittyKeyboardFlags,
|
|
89
|
+
win32InputMode: this.win32InputMode,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
getKittyKeyboardFlags() {
|
|
93
|
+
return this.kittyKeyboardFlags;
|
|
94
|
+
}
|
|
95
|
+
supportsModifiedEnter() {
|
|
96
|
+
return terminalInputModeSupportsModifiedEnter(this.getState());
|
|
97
|
+
}
|
|
98
|
+
getPreamble() {
|
|
99
|
+
const parts = [];
|
|
100
|
+
if (this.kittyKeyboardFlags > 0) {
|
|
101
|
+
parts.push(`\x1b[=${this.kittyKeyboardFlags};1u`);
|
|
102
|
+
}
|
|
103
|
+
if (this.win32InputMode) {
|
|
104
|
+
parts.push("\x1b[?9001h");
|
|
105
|
+
}
|
|
106
|
+
return parts.join("");
|
|
107
|
+
}
|
|
108
|
+
applyKittyKeyboardSequence(prefix, params) {
|
|
109
|
+
const previousFlags = this.kittyKeyboardFlags;
|
|
110
|
+
switch (prefix) {
|
|
111
|
+
case ">": {
|
|
112
|
+
this.kittyKeyboardStack.push(this.kittyKeyboardFlags);
|
|
113
|
+
this.kittyKeyboardFlags = parseFirstParam(params) ?? 1;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case "=": {
|
|
117
|
+
const mode = parseSecondParam(params) ?? 1;
|
|
118
|
+
this.kittyKeyboardFlags = mode === 0 ? 0 : (parseFirstParam(params) ?? 0);
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case "<": {
|
|
122
|
+
const count = Math.max(1, parseFirstParam(params) ?? 1);
|
|
123
|
+
for (let index = 0; index < count; index += 1) {
|
|
124
|
+
this.kittyKeyboardFlags = this.kittyKeyboardStack.pop() ?? 0;
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case "?":
|
|
129
|
+
return {
|
|
130
|
+
changed: false,
|
|
131
|
+
responses: [`\x1b[?${this.kittyKeyboardFlags}u`],
|
|
132
|
+
};
|
|
133
|
+
default:
|
|
134
|
+
return { changed: false, responses: [] };
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
changed: this.kittyKeyboardFlags !== previousFlags,
|
|
138
|
+
responses: [],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
applyPrivateModeSequence(params, final) {
|
|
142
|
+
const modes = parsePrivateModeParams(params);
|
|
143
|
+
if (!modes.has(WIN32_INPUT_MODE)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const previous = this.win32InputMode;
|
|
147
|
+
this.win32InputMode = final === "h";
|
|
148
|
+
return this.win32InputMode !== previous;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=terminal-input-mode.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TerminalInputModeState } from "./terminal-input-mode.js";
|
|
2
|
+
export interface TerminalKeyInput {
|
|
3
|
+
key: string;
|
|
4
|
+
ctrl?: boolean;
|
|
5
|
+
alt?: boolean;
|
|
6
|
+
shift?: boolean;
|
|
7
|
+
meta?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface TerminalKeyInputEncodingOptions {
|
|
10
|
+
inputMode?: TerminalInputModeState;
|
|
11
|
+
}
|
|
12
|
+
export declare function encodeTerminalKeyInput(input: TerminalKeyInput, options?: TerminalKeyInputEncodingOptions): string;
|
|
13
|
+
//# sourceMappingURL=terminal-key-input.d.ts.map
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
const WIN32_LEFT_ALT_PRESSED = 0x0002;
|
|
2
|
+
const WIN32_LEFT_CTRL_PRESSED = 0x0008;
|
|
3
|
+
const WIN32_SHIFT_PRESSED = 0x0010;
|
|
4
|
+
function modifierParam(input) {
|
|
5
|
+
let value = 1;
|
|
6
|
+
if (input.shift)
|
|
7
|
+
value += 1;
|
|
8
|
+
if (input.alt)
|
|
9
|
+
value += 2;
|
|
10
|
+
if (input.ctrl)
|
|
11
|
+
value += 4;
|
|
12
|
+
if (input.meta)
|
|
13
|
+
value += 8;
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
function win32ControlKeyState(input) {
|
|
17
|
+
let value = 0;
|
|
18
|
+
if (input.shift)
|
|
19
|
+
value += WIN32_SHIFT_PRESSED;
|
|
20
|
+
if (input.ctrl)
|
|
21
|
+
value += WIN32_LEFT_CTRL_PRESSED;
|
|
22
|
+
if (input.alt)
|
|
23
|
+
value += WIN32_LEFT_ALT_PRESSED;
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
function shouldUseWin32InputMode(input, options) {
|
|
27
|
+
if (!options.inputMode?.win32InputMode) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return Boolean(input.shift || input.ctrl || input.alt);
|
|
31
|
+
}
|
|
32
|
+
function shouldUseKittyKeyboardMode(input, options) {
|
|
33
|
+
if ((options.inputMode?.kittyKeyboardFlags ?? 0) <= 0) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return Boolean(input.shift || input.ctrl || input.alt || input.meta);
|
|
37
|
+
}
|
|
38
|
+
function encodeWin32EnterKeyInput(input) {
|
|
39
|
+
const controlKeyState = win32ControlKeyState(input);
|
|
40
|
+
// ConPTY Win32 input mode: CSI Vk;Sc;Uc;Kd;Cs;Rc _
|
|
41
|
+
return `\x1b[13;28;13;1;${controlKeyState};1_`;
|
|
42
|
+
}
|
|
43
|
+
function applyAltLikePrefix(sequence, input) {
|
|
44
|
+
return input.alt ? `\x1b${sequence}` : sequence;
|
|
45
|
+
}
|
|
46
|
+
function ctrlSymbolCode(char) {
|
|
47
|
+
switch (char) {
|
|
48
|
+
case " ":
|
|
49
|
+
case "@":
|
|
50
|
+
case "2":
|
|
51
|
+
return "\x00";
|
|
52
|
+
case "[":
|
|
53
|
+
case "3":
|
|
54
|
+
return "\x1b";
|
|
55
|
+
case "\\":
|
|
56
|
+
case "4":
|
|
57
|
+
return "\x1c";
|
|
58
|
+
case "]":
|
|
59
|
+
case "5":
|
|
60
|
+
return "\x1d";
|
|
61
|
+
case "^":
|
|
62
|
+
case "6":
|
|
63
|
+
return "\x1e";
|
|
64
|
+
case "_":
|
|
65
|
+
case "/":
|
|
66
|
+
case "7":
|
|
67
|
+
return "\x1f";
|
|
68
|
+
case "8":
|
|
69
|
+
case "?":
|
|
70
|
+
return "\x7f";
|
|
71
|
+
default:
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function encodeCtrlChar(char, input) {
|
|
76
|
+
const upper = char.toUpperCase();
|
|
77
|
+
if (upper.length === 1 && upper >= "A" && upper <= "Z") {
|
|
78
|
+
return applyAltLikePrefix(String.fromCharCode(upper.charCodeAt(0) - 64), input);
|
|
79
|
+
}
|
|
80
|
+
const symbol = ctrlSymbolCode(char);
|
|
81
|
+
if (symbol !== null) {
|
|
82
|
+
return applyAltLikePrefix(symbol, input);
|
|
83
|
+
}
|
|
84
|
+
if (char.length === 1) {
|
|
85
|
+
const code = char.charCodeAt(0) & 0x1f;
|
|
86
|
+
return applyAltLikePrefix(String.fromCharCode(code), input);
|
|
87
|
+
}
|
|
88
|
+
return applyAltLikePrefix(char, input);
|
|
89
|
+
}
|
|
90
|
+
function encodePrintableKey(input) {
|
|
91
|
+
const raw = input.key;
|
|
92
|
+
const char = input.shift ? raw.toUpperCase() : raw;
|
|
93
|
+
if (input.ctrl) {
|
|
94
|
+
return encodeCtrlChar(char, input);
|
|
95
|
+
}
|
|
96
|
+
return applyAltLikePrefix(char, input);
|
|
97
|
+
}
|
|
98
|
+
function csiWithModifier(finalByte, input) {
|
|
99
|
+
const mod = modifierParam(input);
|
|
100
|
+
return mod === 1 ? `\x1b[${finalByte}` : `\x1b[1;${mod}${finalByte}`;
|
|
101
|
+
}
|
|
102
|
+
function csiTilde(base, input) {
|
|
103
|
+
const mod = modifierParam(input);
|
|
104
|
+
return mod === 1 ? `\x1b[${base}~` : `\x1b[${base};${mod}~`;
|
|
105
|
+
}
|
|
106
|
+
function encodeFunctionKey(key, input) {
|
|
107
|
+
switch (key) {
|
|
108
|
+
case "F1":
|
|
109
|
+
return modifierParam(input) === 1 ? "\x1bOP" : csiWithModifier("P", input);
|
|
110
|
+
case "F2":
|
|
111
|
+
return modifierParam(input) === 1 ? "\x1bOQ" : csiWithModifier("Q", input);
|
|
112
|
+
case "F3":
|
|
113
|
+
return modifierParam(input) === 1 ? "\x1bOR" : csiWithModifier("R", input);
|
|
114
|
+
case "F4":
|
|
115
|
+
return modifierParam(input) === 1 ? "\x1bOS" : csiWithModifier("S", input);
|
|
116
|
+
case "F5":
|
|
117
|
+
return csiTilde(15, input);
|
|
118
|
+
case "F6":
|
|
119
|
+
return csiTilde(17, input);
|
|
120
|
+
case "F7":
|
|
121
|
+
return csiTilde(18, input);
|
|
122
|
+
case "F8":
|
|
123
|
+
return csiTilde(19, input);
|
|
124
|
+
case "F9":
|
|
125
|
+
return csiTilde(20, input);
|
|
126
|
+
case "F10":
|
|
127
|
+
return csiTilde(21, input);
|
|
128
|
+
case "F11":
|
|
129
|
+
return csiTilde(23, input);
|
|
130
|
+
case "F12":
|
|
131
|
+
return csiTilde(24, input);
|
|
132
|
+
default:
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function encodeNavigationKey(key, input) {
|
|
137
|
+
switch (key) {
|
|
138
|
+
case "ArrowUp":
|
|
139
|
+
return csiWithModifier("A", input);
|
|
140
|
+
case "ArrowDown":
|
|
141
|
+
return csiWithModifier("B", input);
|
|
142
|
+
case "ArrowRight":
|
|
143
|
+
return csiWithModifier("C", input);
|
|
144
|
+
case "ArrowLeft":
|
|
145
|
+
return csiWithModifier("D", input);
|
|
146
|
+
case "Home":
|
|
147
|
+
return csiWithModifier("H", input);
|
|
148
|
+
case "End":
|
|
149
|
+
return csiWithModifier("F", input);
|
|
150
|
+
case "Insert":
|
|
151
|
+
return csiTilde(2, input);
|
|
152
|
+
case "Delete":
|
|
153
|
+
return csiTilde(3, input);
|
|
154
|
+
case "PageUp":
|
|
155
|
+
return csiTilde(5, input);
|
|
156
|
+
case "PageDown":
|
|
157
|
+
return csiTilde(6, input);
|
|
158
|
+
default:
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export function encodeTerminalKeyInput(input, options = {}) {
|
|
163
|
+
const key = input.key;
|
|
164
|
+
if (!key) {
|
|
165
|
+
return "";
|
|
166
|
+
}
|
|
167
|
+
if (key.length === 1) {
|
|
168
|
+
return encodePrintableKey(input);
|
|
169
|
+
}
|
|
170
|
+
switch (key) {
|
|
171
|
+
case "Enter": {
|
|
172
|
+
const mod = modifierParam(input);
|
|
173
|
+
if (mod > 1 && shouldUseWin32InputMode(input, options)) {
|
|
174
|
+
return encodeWin32EnterKeyInput(input);
|
|
175
|
+
}
|
|
176
|
+
if (mod > 1 && shouldUseKittyKeyboardMode(input, options)) {
|
|
177
|
+
return `\x1b[13;${mod}u`;
|
|
178
|
+
}
|
|
179
|
+
return "\r";
|
|
180
|
+
}
|
|
181
|
+
case "Tab":
|
|
182
|
+
if (input.shift && !input.ctrl && !input.alt && !input.meta) {
|
|
183
|
+
return "\x1b[Z";
|
|
184
|
+
}
|
|
185
|
+
return applyAltLikePrefix("\t", input);
|
|
186
|
+
case "Backspace":
|
|
187
|
+
return applyAltLikePrefix("\x7f", input);
|
|
188
|
+
case "Escape":
|
|
189
|
+
return "\x1b";
|
|
190
|
+
default:
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
const nav = encodeNavigationKey(key, input);
|
|
194
|
+
if (nav !== null)
|
|
195
|
+
return nav;
|
|
196
|
+
const fn = encodeFunctionKey(key, input);
|
|
197
|
+
if (fn !== null)
|
|
198
|
+
return fn;
|
|
199
|
+
return "";
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=terminal-key-input.js.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
const DEFAULT_STYLE = {
|
|
2
|
+
fg: undefined,
|
|
3
|
+
bg: undefined,
|
|
4
|
+
fgMode: undefined,
|
|
5
|
+
bgMode: undefined,
|
|
6
|
+
bold: false,
|
|
7
|
+
italic: false,
|
|
8
|
+
underline: false,
|
|
9
|
+
dim: false,
|
|
10
|
+
inverse: false,
|
|
11
|
+
strikethrough: false,
|
|
12
|
+
};
|
|
13
|
+
export function renderTerminalSnapshotToAnsi(state) {
|
|
14
|
+
const rows = [...state.scrollback, ...state.grid];
|
|
15
|
+
const lines = ["\u001b[?7l"];
|
|
16
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
17
|
+
const row = rows[rowIndex] ?? [];
|
|
18
|
+
lines.push(renderTerminalRow(row));
|
|
19
|
+
if (rowIndex < rows.length - 1) {
|
|
20
|
+
lines.push("\r\n");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
lines.push("\u001b[0m");
|
|
24
|
+
const cursorPresentationAnsi = renderCursorPresentationToAnsi(state.cursor);
|
|
25
|
+
if (cursorPresentationAnsi) {
|
|
26
|
+
lines.push(cursorPresentationAnsi);
|
|
27
|
+
}
|
|
28
|
+
lines.push(`\u001b[${state.cursor.row + 1};${state.cursor.col + 1}H`);
|
|
29
|
+
lines.push(state.cursor.hidden ? "\u001b[?25l" : "\u001b[?25h");
|
|
30
|
+
lines.push("\u001b[?7h");
|
|
31
|
+
return lines.join("");
|
|
32
|
+
}
|
|
33
|
+
function renderCursorPresentationToAnsi(cursor) {
|
|
34
|
+
if (!cursor.style) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const cursorStyleCode = (() => {
|
|
38
|
+
if (cursor.style === "block") {
|
|
39
|
+
return cursor.blink === false ? 2 : 1;
|
|
40
|
+
}
|
|
41
|
+
if (cursor.style === "underline") {
|
|
42
|
+
return cursor.blink === false ? 4 : 3;
|
|
43
|
+
}
|
|
44
|
+
return cursor.blink === false ? 6 : 5;
|
|
45
|
+
})();
|
|
46
|
+
return `\u001b[${cursorStyleCode} q`;
|
|
47
|
+
}
|
|
48
|
+
function renderTerminalRow(row) {
|
|
49
|
+
const output = [];
|
|
50
|
+
const length = getTerminalRowLength(row);
|
|
51
|
+
let previousStyle = DEFAULT_STYLE;
|
|
52
|
+
for (let index = 0; index < length; index += 1) {
|
|
53
|
+
const cell = row[index] ?? { char: " " };
|
|
54
|
+
const nextStyle = getTerminalStyle(cell);
|
|
55
|
+
if (!terminalStylesEqual(previousStyle, nextStyle)) {
|
|
56
|
+
output.push(styleToAnsi(nextStyle));
|
|
57
|
+
previousStyle = nextStyle;
|
|
58
|
+
}
|
|
59
|
+
output.push(cell.char || " ");
|
|
60
|
+
}
|
|
61
|
+
if (!terminalStylesEqual(previousStyle, DEFAULT_STYLE)) {
|
|
62
|
+
output.push("\u001b[0m");
|
|
63
|
+
}
|
|
64
|
+
return output.join("");
|
|
65
|
+
}
|
|
66
|
+
function getTerminalRowLength(row) {
|
|
67
|
+
for (let index = row.length - 1; index >= 0; index -= 1) {
|
|
68
|
+
const cell = row[index];
|
|
69
|
+
if (!cell) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (cell.char !== " ") {
|
|
73
|
+
return index + 1;
|
|
74
|
+
}
|
|
75
|
+
if (cell.fg !== undefined ||
|
|
76
|
+
cell.bg !== undefined ||
|
|
77
|
+
cell.fgMode !== undefined ||
|
|
78
|
+
cell.bgMode !== undefined ||
|
|
79
|
+
cell.bold ||
|
|
80
|
+
cell.italic ||
|
|
81
|
+
cell.underline ||
|
|
82
|
+
cell.dim ||
|
|
83
|
+
cell.inverse ||
|
|
84
|
+
cell.strikethrough) {
|
|
85
|
+
return index + 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
function getTerminalStyle(cell) {
|
|
91
|
+
return {
|
|
92
|
+
fg: cell.fg,
|
|
93
|
+
bg: cell.bg,
|
|
94
|
+
fgMode: cell.fgMode,
|
|
95
|
+
bgMode: cell.bgMode,
|
|
96
|
+
bold: Boolean(cell.bold),
|
|
97
|
+
italic: Boolean(cell.italic),
|
|
98
|
+
underline: Boolean(cell.underline),
|
|
99
|
+
dim: Boolean(cell.dim),
|
|
100
|
+
inverse: Boolean(cell.inverse),
|
|
101
|
+
strikethrough: Boolean(cell.strikethrough),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function terminalStylesEqual(left, right) {
|
|
105
|
+
return (left.fg === right.fg &&
|
|
106
|
+
left.bg === right.bg &&
|
|
107
|
+
left.fgMode === right.fgMode &&
|
|
108
|
+
left.bgMode === right.bgMode &&
|
|
109
|
+
left.bold === right.bold &&
|
|
110
|
+
left.italic === right.italic &&
|
|
111
|
+
left.underline === right.underline &&
|
|
112
|
+
left.dim === right.dim &&
|
|
113
|
+
left.inverse === right.inverse &&
|
|
114
|
+
left.strikethrough === right.strikethrough);
|
|
115
|
+
}
|
|
116
|
+
function styleToAnsi(style) {
|
|
117
|
+
const codes = ["0"];
|
|
118
|
+
if (style.bold) {
|
|
119
|
+
codes.push("1");
|
|
120
|
+
}
|
|
121
|
+
if (style.dim) {
|
|
122
|
+
codes.push("2");
|
|
123
|
+
}
|
|
124
|
+
if (style.italic) {
|
|
125
|
+
codes.push("3");
|
|
126
|
+
}
|
|
127
|
+
if (style.underline) {
|
|
128
|
+
codes.push("4");
|
|
129
|
+
}
|
|
130
|
+
if (style.inverse) {
|
|
131
|
+
codes.push("7");
|
|
132
|
+
}
|
|
133
|
+
if (style.strikethrough) {
|
|
134
|
+
codes.push("9");
|
|
135
|
+
}
|
|
136
|
+
if (style.fg !== undefined && style.fgMode !== undefined) {
|
|
137
|
+
codes.push(...colorToSgr(style.fgMode, style.fg, false));
|
|
138
|
+
}
|
|
139
|
+
if (style.bg !== undefined && style.bgMode !== undefined) {
|
|
140
|
+
codes.push(...colorToSgr(style.bgMode, style.bg, true));
|
|
141
|
+
}
|
|
142
|
+
return `\u001b[${codes.join(";")}m`;
|
|
143
|
+
}
|
|
144
|
+
function colorToSgr(mode, value, background) {
|
|
145
|
+
if (mode === 1) {
|
|
146
|
+
if (value >= 8) {
|
|
147
|
+
return [String((background ? 100 : 90) + (value - 8))];
|
|
148
|
+
}
|
|
149
|
+
return [String((background ? 40 : 30) + value)];
|
|
150
|
+
}
|
|
151
|
+
if (mode === 2) {
|
|
152
|
+
return [background ? "48" : "38", "5", String(value)];
|
|
153
|
+
}
|
|
154
|
+
if (mode === 3) {
|
|
155
|
+
return [
|
|
156
|
+
background ? "48" : "38",
|
|
157
|
+
"2",
|
|
158
|
+
String((value >> 16) & 0xff),
|
|
159
|
+
String((value >> 8) & 0xff),
|
|
160
|
+
String(value & 0xff),
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=terminal-snapshot.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ToolCallTimelineItem } from "./agent-types.js";
|
|
2
|
+
export type ToolCallDisplayInput = Pick<ToolCallTimelineItem, "name" | "status" | "error" | "metadata" | "detail"> & {
|
|
3
|
+
cwd?: string;
|
|
4
|
+
};
|
|
5
|
+
export interface ToolCallDisplayModel {
|
|
6
|
+
displayName: string;
|
|
7
|
+
summary?: string;
|
|
8
|
+
errorText?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function buildToolCallDisplayModel(input: ToolCallDisplayInput): ToolCallDisplayModel;
|
|
11
|
+
//# sourceMappingURL=tool-call-display.d.ts.map
|