@easynet/agent-tool-buildin 0.0.41 → 0.0.43
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/core-tools-manifest.json +1754 -1355
- package/dist/src/iterm/common.d.ts +43 -0
- package/dist/src/iterm/common.d.ts.map +1 -0
- package/dist/src/iterm/common.js +164 -0
- package/dist/src/iterm/common.js.map +1 -0
- package/dist/src/iterm/itermCreateTab.d.ts +30 -0
- package/dist/src/iterm/itermCreateTab.d.ts.map +1 -0
- package/dist/src/iterm/itermCreateTab.js +59 -0
- package/dist/src/iterm/itermCreateTab.js.map +1 -0
- package/dist/src/iterm/itermCreateWindow.d.ts +30 -0
- package/dist/src/iterm/itermCreateWindow.d.ts.map +1 -0
- package/dist/src/iterm/itermCreateWindow.js +62 -0
- package/dist/src/iterm/itermCreateWindow.js.map +1 -0
- package/dist/src/iterm/itermGetSessionInfo.d.ts +30 -0
- package/dist/src/iterm/itermGetSessionInfo.d.ts.map +1 -0
- package/dist/src/iterm/itermGetSessionInfo.js +41 -0
- package/dist/src/iterm/itermGetSessionInfo.js.map +1 -0
- package/dist/src/iterm/itermListCurrentWindowSessions.d.ts +31 -0
- package/dist/src/iterm/itermListCurrentWindowSessions.d.ts.map +1 -0
- package/dist/src/iterm/itermListCurrentWindowSessions.js +34 -0
- package/dist/src/iterm/itermListCurrentWindowSessions.js.map +1 -0
- package/dist/src/iterm/itermListWindows.d.ts +31 -0
- package/dist/src/iterm/itermListWindows.d.ts.map +1 -0
- package/dist/src/iterm/itermListWindows.js +73 -0
- package/dist/src/iterm/itermListWindows.js.map +1 -0
- package/dist/src/iterm/itermRename.d.ts +30 -0
- package/dist/src/iterm/itermRename.d.ts.map +1 -0
- package/dist/src/iterm/itermRename.js +49 -0
- package/dist/src/iterm/itermRename.js.map +1 -0
- package/dist/src/iterm/itermResizeWindow.d.ts +29 -0
- package/dist/src/iterm/itermResizeWindow.d.ts.map +1 -0
- package/dist/src/iterm/itermResizeWindow.js +53 -0
- package/dist/src/iterm/itermResizeWindow.js.map +1 -0
- package/dist/src/iterm/itermRunCommandInSession.d.ts +29 -0
- package/dist/src/iterm/itermRunCommandInSession.d.ts.map +1 -0
- package/dist/src/iterm/itermRunCommandInSession.js +37 -0
- package/dist/src/iterm/itermRunCommandInSession.js.map +1 -0
- package/dist/src/iterm/itermSendText.d.ts +28 -0
- package/dist/src/iterm/itermSendText.d.ts.map +1 -0
- package/dist/src/iterm/itermSendText.js +47 -0
- package/dist/src/iterm/itermSendText.js.map +1 -0
- package/dist/src/iterm/itermSetBackgroundColor.d.ts +35 -0
- package/dist/src/iterm/itermSetBackgroundColor.d.ts.map +1 -0
- package/dist/src/iterm/itermSetBackgroundColor.js +41 -0
- package/dist/src/iterm/itermSetBackgroundColor.js.map +1 -0
- package/dist/src/iterm/itermSplitPane.d.ts +32 -0
- package/dist/src/iterm/itermSplitPane.d.ts.map +1 -0
- package/dist/src/iterm/itermSplitPane.js +57 -0
- package/dist/src/iterm/itermSplitPane.js.map +1 -0
- package/dist/src/iterm/itermTools.d.ts +11 -209
- package/dist/src/iterm/itermTools.d.ts.map +1 -1
- package/dist/src/iterm/itermTools.js +11 -533
- package/dist/src/iterm/itermTools.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createTaggedError } from "@easynet/agent-tool";
|
|
2
|
+
export declare const RECORD_SEPARATOR = "\u001E";
|
|
3
|
+
export declare const FIELD_SEPARATOR = "\u001F";
|
|
4
|
+
export declare function quoteAppleScriptString(input: string): string;
|
|
5
|
+
export declare function runOsaScript(lines: string[]): Promise<string>;
|
|
6
|
+
export declare function targetSelectorScript(args: {
|
|
7
|
+
windowId?: number;
|
|
8
|
+
tabIndex?: number;
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
}): string[];
|
|
11
|
+
export declare function applyOptionalNamingScript(args: {
|
|
12
|
+
windowName?: string;
|
|
13
|
+
tabName?: string;
|
|
14
|
+
sessionName?: string;
|
|
15
|
+
windowRef?: string;
|
|
16
|
+
tabRef?: string;
|
|
17
|
+
sessionRef?: string;
|
|
18
|
+
}): string[];
|
|
19
|
+
export declare function parsePipeTuple(output: string): {
|
|
20
|
+
windowId: number;
|
|
21
|
+
tabIndex: number;
|
|
22
|
+
sessionId: string;
|
|
23
|
+
sessionUniqueId: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function returnTupleScript(args: {
|
|
26
|
+
windowRef?: string;
|
|
27
|
+
tabRef?: string;
|
|
28
|
+
sessionRef?: string;
|
|
29
|
+
}): string[];
|
|
30
|
+
export declare function normalizeRgb(args: {
|
|
31
|
+
hex?: string;
|
|
32
|
+
red?: number;
|
|
33
|
+
green?: number;
|
|
34
|
+
blue?: number;
|
|
35
|
+
alpha?: number;
|
|
36
|
+
}): {
|
|
37
|
+
red: number;
|
|
38
|
+
green: number;
|
|
39
|
+
blue: number;
|
|
40
|
+
alpha: number;
|
|
41
|
+
};
|
|
42
|
+
export { createTaggedError };
|
|
43
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/iterm/common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,eAAO,MAAM,gBAAgB,WAAS,CAAC;AACvC,eAAO,MAAM,eAAe,WAAS,CAAC;AAEtC,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA+CnE;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,EAAE,CAgCX;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,EAAE,CA8BX;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB,CAQA;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,EAAE,CAoCX;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAyB9D;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createTaggedError } from "@easynet/agent-tool";
|
|
3
|
+
export const RECORD_SEPARATOR = "\x1e";
|
|
4
|
+
export const FIELD_SEPARATOR = "\x1f";
|
|
5
|
+
export function quoteAppleScriptString(input) {
|
|
6
|
+
return `"${input.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
7
|
+
}
|
|
8
|
+
export async function runOsaScript(lines) {
|
|
9
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
10
|
+
const args = [];
|
|
11
|
+
for (const line of lines) {
|
|
12
|
+
args.push("-e", line);
|
|
13
|
+
}
|
|
14
|
+
const proc = spawn("osascript", args, {
|
|
15
|
+
shell: false,
|
|
16
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
17
|
+
env: { ...process.env },
|
|
18
|
+
});
|
|
19
|
+
let stdout = "";
|
|
20
|
+
let stderr = "";
|
|
21
|
+
proc.stdout?.setEncoding("utf-8");
|
|
22
|
+
proc.stderr?.setEncoding("utf-8");
|
|
23
|
+
proc.stdout?.on("data", (chunk) => {
|
|
24
|
+
stdout += chunk;
|
|
25
|
+
});
|
|
26
|
+
proc.stderr?.on("data", (chunk) => {
|
|
27
|
+
stderr += chunk;
|
|
28
|
+
});
|
|
29
|
+
proc.on("error", (err) => {
|
|
30
|
+
rejectPromise(createTaggedError("ITERM_EXEC_ERROR", `Failed to run osascript: ${err.message}`, {}));
|
|
31
|
+
});
|
|
32
|
+
proc.on("close", (code) => {
|
|
33
|
+
if (code !== 0) {
|
|
34
|
+
rejectPromise(createTaggedError("ITERM_EXEC_FAILED", `osascript exited with ${code}: ${stderr.trim() || "unknown error"}`, { code, stderr: stderr.trim() }));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
resolvePromise(stdout.trim());
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function targetSelectorScript(args) {
|
|
42
|
+
const lines = [
|
|
43
|
+
'if (count of windows) is 0 then error "No iTerm2 windows are open"',
|
|
44
|
+
"set targetWindow to missing value",
|
|
45
|
+
"try",
|
|
46
|
+
"set targetWindow to current window",
|
|
47
|
+
"end try",
|
|
48
|
+
"if targetWindow is missing value then set targetWindow to first window",
|
|
49
|
+
];
|
|
50
|
+
if (typeof args.windowId === "number") {
|
|
51
|
+
lines.push(`set targetWindow to first window whose id is ${Math.trunc(args.windowId)}`);
|
|
52
|
+
}
|
|
53
|
+
lines.push("set targetTab to current tab of targetWindow");
|
|
54
|
+
if (typeof args.tabIndex === "number") {
|
|
55
|
+
lines.push(`set targetTab to tab ${Math.max(1, Math.trunc(args.tabIndex))} of targetWindow`);
|
|
56
|
+
}
|
|
57
|
+
lines.push("set targetSession to current session of targetTab");
|
|
58
|
+
if (typeof args.sessionId === "string" && args.sessionId.trim()) {
|
|
59
|
+
const sessionId = quoteAppleScriptString(args.sessionId.trim());
|
|
60
|
+
lines.push("try");
|
|
61
|
+
lines.push(`set targetSession to first session of targetTab whose unique id is ${sessionId}`);
|
|
62
|
+
lines.push("on error");
|
|
63
|
+
lines.push(`set targetSession to first session of targetTab whose id is ${sessionId}`);
|
|
64
|
+
lines.push("end try");
|
|
65
|
+
}
|
|
66
|
+
return lines;
|
|
67
|
+
}
|
|
68
|
+
export function applyOptionalNamingScript(args) {
|
|
69
|
+
const windowRef = args.windowRef ?? "targetWindow";
|
|
70
|
+
const tabRef = args.tabRef ?? "targetTab";
|
|
71
|
+
const sessionRef = args.sessionRef ?? "targetSession";
|
|
72
|
+
const lines = [];
|
|
73
|
+
if (args.windowName?.trim()) {
|
|
74
|
+
lines.push("try");
|
|
75
|
+
lines.push(`set name of ${windowRef} to ${quoteAppleScriptString(args.windowName.trim())}`);
|
|
76
|
+
lines.push("end try");
|
|
77
|
+
}
|
|
78
|
+
if (args.tabName?.trim()) {
|
|
79
|
+
// iTerm2 AppleScript does not expose direct tab title setter in all versions;
|
|
80
|
+
// setting current session name updates the effective tab title in common title configurations.
|
|
81
|
+
lines.push("try");
|
|
82
|
+
lines.push(`set name of current session of ${tabRef} to ${quoteAppleScriptString(args.tabName.trim())}`);
|
|
83
|
+
lines.push("end try");
|
|
84
|
+
}
|
|
85
|
+
if (args.sessionName?.trim()) {
|
|
86
|
+
lines.push("try");
|
|
87
|
+
lines.push(`set name of ${sessionRef} to ${quoteAppleScriptString(args.sessionName.trim())}`);
|
|
88
|
+
lines.push("end try");
|
|
89
|
+
}
|
|
90
|
+
return lines;
|
|
91
|
+
}
|
|
92
|
+
export function parsePipeTuple(output) {
|
|
93
|
+
const parts = output.split("|");
|
|
94
|
+
return {
|
|
95
|
+
windowId: Number(parts[0] ?? "0"),
|
|
96
|
+
tabIndex: Number(parts[1] ?? "0"),
|
|
97
|
+
sessionId: parts[2] ?? "",
|
|
98
|
+
sessionUniqueId: parts[3] ?? "",
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function returnTupleScript(args) {
|
|
102
|
+
const windowRef = args.windowRef ?? "targetWindow";
|
|
103
|
+
const tabRef = args.tabRef ?? "targetTab";
|
|
104
|
+
const sessionRef = args.sessionRef ?? "targetSession";
|
|
105
|
+
return [
|
|
106
|
+
"set windowIdText to \"\"",
|
|
107
|
+
`try`,
|
|
108
|
+
`set windowIdText to (id of ${windowRef}) as text`,
|
|
109
|
+
"end try",
|
|
110
|
+
"set tabIndexText to \"\"",
|
|
111
|
+
`try`,
|
|
112
|
+
`set refSessionUid to (unique id of current session of ${tabRef}) as text`,
|
|
113
|
+
`set tabCount to count of tabs of ${windowRef}`,
|
|
114
|
+
"repeat with i from 1 to tabCount",
|
|
115
|
+
`set loopTab to tab i of ${windowRef}`,
|
|
116
|
+
`set loopUid to (unique id of current session of loopTab) as text`,
|
|
117
|
+
"if loopUid is refSessionUid then",
|
|
118
|
+
"set tabIndexText to i as text",
|
|
119
|
+
"exit repeat",
|
|
120
|
+
"end if",
|
|
121
|
+
"end repeat",
|
|
122
|
+
"end try",
|
|
123
|
+
"set sessionIdText to \"\"",
|
|
124
|
+
`try`,
|
|
125
|
+
`set sessionIdText to (id of ${sessionRef}) as text`,
|
|
126
|
+
"on error",
|
|
127
|
+
`try`,
|
|
128
|
+
`set sessionIdText to (unique id of ${sessionRef}) as text`,
|
|
129
|
+
"end try",
|
|
130
|
+
"end try",
|
|
131
|
+
"set sessionUidText to \"\"",
|
|
132
|
+
`try`,
|
|
133
|
+
`set sessionUidText to (unique id of ${sessionRef}) as text`,
|
|
134
|
+
"end try",
|
|
135
|
+
"return windowIdText & \"|\" & tabIndexText & \"|\" & sessionIdText & \"|\" & sessionUidText",
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
export function normalizeRgb(args) {
|
|
139
|
+
const hex = args.hex?.trim();
|
|
140
|
+
if (hex) {
|
|
141
|
+
const clean = hex.startsWith("#") ? hex.slice(1) : hex;
|
|
142
|
+
if (clean.length !== 6) {
|
|
143
|
+
throw createTaggedError("ITERM_INVALID_COLOR", "hex must be #RRGGBB or RRGGBB", { hex });
|
|
144
|
+
}
|
|
145
|
+
const r8 = Number.parseInt(clean.slice(0, 2), 16);
|
|
146
|
+
const g8 = Number.parseInt(clean.slice(2, 4), 16);
|
|
147
|
+
const b8 = Number.parseInt(clean.slice(4, 6), 16);
|
|
148
|
+
return {
|
|
149
|
+
red: Math.round((r8 / 255) * 65535),
|
|
150
|
+
green: Math.round((g8 / 255) * 65535),
|
|
151
|
+
blue: Math.round((b8 / 255) * 65535),
|
|
152
|
+
alpha: typeof args.alpha === "number"
|
|
153
|
+
? Math.max(0, Math.min(65535, Math.round(args.alpha)))
|
|
154
|
+
: 0,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const red = Math.max(0, Math.min(65535, Math.round(args.red ?? 0)));
|
|
158
|
+
const green = Math.max(0, Math.min(65535, Math.round(args.green ?? 0)));
|
|
159
|
+
const blue = Math.max(0, Math.min(65535, Math.round(args.blue ?? 0)));
|
|
160
|
+
const alpha = Math.max(0, Math.min(65535, Math.round(args.alpha ?? 0)));
|
|
161
|
+
return { red, green, blue, alpha };
|
|
162
|
+
}
|
|
163
|
+
export { createTaggedError };
|
|
164
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js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C,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACrC,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new tab in an iTerm2 window.
|
|
3
|
+
* @tool
|
|
4
|
+
* @effect local_write
|
|
5
|
+
*/
|
|
6
|
+
export declare function itermCreateTab(args: {
|
|
7
|
+
windowId?: number;
|
|
8
|
+
profile?: string;
|
|
9
|
+
command?: string;
|
|
10
|
+
cmd?: string;
|
|
11
|
+
tabName?: string;
|
|
12
|
+
sessionName?: string;
|
|
13
|
+
activate?: boolean;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
result: {
|
|
16
|
+
windowId: number;
|
|
17
|
+
profile: string;
|
|
18
|
+
commandText: string;
|
|
19
|
+
tabIndex: number;
|
|
20
|
+
sessionId: string;
|
|
21
|
+
sessionUniqueId: string;
|
|
22
|
+
};
|
|
23
|
+
evidence: {
|
|
24
|
+
type: string;
|
|
25
|
+
ref: string;
|
|
26
|
+
summary: string;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
}[];
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=itermCreateTab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermCreateTab.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermCreateTab.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;;;;;;;;;GAsDA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { quoteAppleScriptString, runOsaScript, targetSelectorScript, applyOptionalNamingScript, returnTupleScript, parsePipeTuple, } from "./common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create a new tab in an iTerm2 window.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect local_write
|
|
6
|
+
*/
|
|
7
|
+
export async function itermCreateTab(args) {
|
|
8
|
+
const profile = args.profile?.trim();
|
|
9
|
+
const command = (args.command ?? args.cmd)?.trim();
|
|
10
|
+
const activate = args.activate ?? true;
|
|
11
|
+
const lines = [
|
|
12
|
+
'tell application "iTerm2"',
|
|
13
|
+
...(activate ? ["activate"] : []),
|
|
14
|
+
...targetSelectorScript({ windowId: args.windowId }),
|
|
15
|
+
"tell targetWindow",
|
|
16
|
+
profile
|
|
17
|
+
? command
|
|
18
|
+
? `set newTab to (create tab with profile ${quoteAppleScriptString(profile)} command ${quoteAppleScriptString(command)})`
|
|
19
|
+
: `set newTab to (create tab with profile ${quoteAppleScriptString(profile)})`
|
|
20
|
+
: command
|
|
21
|
+
? `set newTab to (create tab with default profile command ${quoteAppleScriptString(command)})`
|
|
22
|
+
: "set newTab to (create tab with default profile)",
|
|
23
|
+
"end tell",
|
|
24
|
+
// Some iTerm2 versions return missing value for create tab result; use current tab after creation.
|
|
25
|
+
"set targetTab to current tab of targetWindow",
|
|
26
|
+
"set targetSession to current session of targetTab",
|
|
27
|
+
...applyOptionalNamingScript({
|
|
28
|
+
tabName: args.tabName,
|
|
29
|
+
sessionName: args.sessionName,
|
|
30
|
+
tabRef: "targetTab",
|
|
31
|
+
sessionRef: "targetSession",
|
|
32
|
+
}),
|
|
33
|
+
...returnTupleScript({
|
|
34
|
+
windowRef: "targetWindow",
|
|
35
|
+
tabRef: "targetTab",
|
|
36
|
+
sessionRef: "targetSession",
|
|
37
|
+
}),
|
|
38
|
+
"end tell",
|
|
39
|
+
];
|
|
40
|
+
const output = await runOsaScript(lines);
|
|
41
|
+
const parsed = parsePipeTuple(output);
|
|
42
|
+
return {
|
|
43
|
+
result: {
|
|
44
|
+
...parsed,
|
|
45
|
+
windowId: parsed.windowId,
|
|
46
|
+
profile: profile ?? "default",
|
|
47
|
+
commandText: command ?? "",
|
|
48
|
+
},
|
|
49
|
+
evidence: [
|
|
50
|
+
{
|
|
51
|
+
type: "tool",
|
|
52
|
+
ref: "itermCreateTab",
|
|
53
|
+
summary: `Created iTerm2 tab ${parsed.tabIndex} in window ${parsed.windowId}`,
|
|
54
|
+
createdAt: new Date().toISOString(),
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=itermCreateTab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermCreateTab.js","sourceRoot":"","sources":["../../../src/iterm/itermCreateTab.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAQpC;IACC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;IAEvC,MAAM,KAAK,GAAG;QACZ,2BAA2B;QAC3B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAA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AAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new iTerm2 window, optionally with profile/command and initial names.
|
|
3
|
+
* @tool
|
|
4
|
+
* @effect local_write
|
|
5
|
+
*/
|
|
6
|
+
export declare function itermCreateWindow(args: {
|
|
7
|
+
profile?: string;
|
|
8
|
+
command?: string;
|
|
9
|
+
cmd?: string;
|
|
10
|
+
activate?: boolean;
|
|
11
|
+
windowName?: string;
|
|
12
|
+
tabName?: string;
|
|
13
|
+
sessionName?: string;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
result: {
|
|
16
|
+
profile: string;
|
|
17
|
+
commandText: string;
|
|
18
|
+
windowId: number;
|
|
19
|
+
tabIndex: number;
|
|
20
|
+
sessionId: string;
|
|
21
|
+
sessionUniqueId: string;
|
|
22
|
+
};
|
|
23
|
+
evidence: {
|
|
24
|
+
type: string;
|
|
25
|
+
ref: string;
|
|
26
|
+
summary: string;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
}[];
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=itermCreateWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermCreateWindow.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermCreateWindow.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;;;;;;;;;;;;GAyDA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { quoteAppleScriptString, runOsaScript, applyOptionalNamingScript, returnTupleScript, parsePipeTuple, } from "./common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create a new iTerm2 window, optionally with profile/command and initial names.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect local_write
|
|
6
|
+
*/
|
|
7
|
+
export async function itermCreateWindow(args) {
|
|
8
|
+
const profile = args.profile?.trim();
|
|
9
|
+
const command = (args.command ?? args.cmd)?.trim();
|
|
10
|
+
const activate = args.activate ?? true;
|
|
11
|
+
const lines = [
|
|
12
|
+
'tell application "iTerm2"',
|
|
13
|
+
...(activate ? ["activate"] : []),
|
|
14
|
+
profile
|
|
15
|
+
? command
|
|
16
|
+
? `create window with profile ${quoteAppleScriptString(profile)} command ${quoteAppleScriptString(command)}`
|
|
17
|
+
: `create window with profile ${quoteAppleScriptString(profile)}`
|
|
18
|
+
: command
|
|
19
|
+
? `create window with default profile command ${quoteAppleScriptString(command)}`
|
|
20
|
+
: "create window with default profile",
|
|
21
|
+
// Some iTerm2 versions return missing value for create window result; use current window after creation.
|
|
22
|
+
"set targetWindow to missing value",
|
|
23
|
+
"try",
|
|
24
|
+
"set targetWindow to current window",
|
|
25
|
+
"end try",
|
|
26
|
+
"if targetWindow is missing value then set targetWindow to first window",
|
|
27
|
+
"set targetTab to current tab of targetWindow",
|
|
28
|
+
"set targetSession to current session of targetTab",
|
|
29
|
+
...applyOptionalNamingScript({
|
|
30
|
+
windowName: args.windowName,
|
|
31
|
+
tabName: args.tabName,
|
|
32
|
+
sessionName: args.sessionName,
|
|
33
|
+
windowRef: "targetWindow",
|
|
34
|
+
tabRef: "targetTab",
|
|
35
|
+
sessionRef: "targetSession",
|
|
36
|
+
}),
|
|
37
|
+
...returnTupleScript({
|
|
38
|
+
windowRef: "targetWindow",
|
|
39
|
+
tabRef: "targetTab",
|
|
40
|
+
sessionRef: "targetSession",
|
|
41
|
+
}),
|
|
42
|
+
"end tell",
|
|
43
|
+
];
|
|
44
|
+
const output = await runOsaScript(lines);
|
|
45
|
+
const parsed = parsePipeTuple(output);
|
|
46
|
+
return {
|
|
47
|
+
result: {
|
|
48
|
+
...parsed,
|
|
49
|
+
profile: profile ?? "default",
|
|
50
|
+
commandText: command ?? "",
|
|
51
|
+
},
|
|
52
|
+
evidence: [
|
|
53
|
+
{
|
|
54
|
+
type: "tool",
|
|
55
|
+
ref: "itermCreateWindow",
|
|
56
|
+
summary: `Created iTerm2 window ${parsed.windowId}, tab ${parsed.tabIndex}`,
|
|
57
|
+
createdAt: new Date().toISOString(),
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=itermCreateWindow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermCreateWindow.js","sourceRoot":"","sources":["../../../src/iterm/itermCreateWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAQvC;IACC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;IAEvC,MAAM,KAAK,GAAG;QACZ,2BAA2B;QAC3B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,OAAO;YACL,CAAC,CAAC,OAAO;gBACP,CAAC,CAAC,8BAA8B,sBAAsB,CAAC,OAAO,CAAC,YAAY,sBAAsB,CAAC,OAAO,CAAC,EAAE;gBAC5G,CAAC,CAAC,8BAA8B,s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
5
|
+
*/
|
|
6
|
+
export declare function itermGetSessionInfo(args: {
|
|
7
|
+
sessionId?: string;
|
|
8
|
+
sessionUniqueId?: string;
|
|
9
|
+
tty?: string;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
result: {
|
|
12
|
+
windowId: number;
|
|
13
|
+
windowName: string;
|
|
14
|
+
tabIndex: number;
|
|
15
|
+
tabIndexZeroBased: number;
|
|
16
|
+
isCurrentTab: boolean;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
sessionUniqueId: string;
|
|
19
|
+
sessionName: string;
|
|
20
|
+
tty: string;
|
|
21
|
+
isCurrentSession: boolean;
|
|
22
|
+
};
|
|
23
|
+
evidence: {
|
|
24
|
+
type: string;
|
|
25
|
+
ref: string;
|
|
26
|
+
summary: string;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
}[];
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=itermGetSessionInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermGetSessionInfo.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermGetSessionInfo.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;;kBAea,MAAM;oBACJ,MAAM;kBACR,MAAM;2BACG,MAAM;sBACX,OAAO;mBACV,MAAM;yBACA,MAAM;qBACV,MAAM;aACd,MAAM;0BACO,OAAO;;;;;;;;GA6B5B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { itermListWindows } from "./itermListWindows.js";
|
|
2
|
+
import { createTaggedError } from "./common.js";
|
|
3
|
+
/**
|
|
4
|
+
* Get detailed info for a specific iTerm2 session (panel) by id / uniqueId / tty.
|
|
5
|
+
* @tool
|
|
6
|
+
* @effect none
|
|
7
|
+
*/
|
|
8
|
+
export async function itermGetSessionInfo(args) {
|
|
9
|
+
const id = args.sessionId?.trim();
|
|
10
|
+
const uid = args.sessionUniqueId?.trim();
|
|
11
|
+
const tty = args.tty?.trim();
|
|
12
|
+
if (!id && !uid && !tty) {
|
|
13
|
+
throw createTaggedError("ITERM_INVALID", "sessionId, sessionUniqueId or tty is required", {});
|
|
14
|
+
}
|
|
15
|
+
const { result } = await itermListWindows();
|
|
16
|
+
const sessions = result.sessions ?? [];
|
|
17
|
+
const match = sessions.find((s) => {
|
|
18
|
+
if (id && s.sessionId === id)
|
|
19
|
+
return true;
|
|
20
|
+
if (uid && s.sessionUniqueId === uid)
|
|
21
|
+
return true;
|
|
22
|
+
if (tty && s.tty === tty)
|
|
23
|
+
return true;
|
|
24
|
+
return false;
|
|
25
|
+
});
|
|
26
|
+
if (!match) {
|
|
27
|
+
throw createTaggedError("ITERM_SESSION_NOT_FOUND", "No matching iTerm2 session found for given identifiers", { sessionId: id, sessionUniqueId: uid, tty });
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
result: match,
|
|
31
|
+
evidence: [
|
|
32
|
+
{
|
|
33
|
+
type: "tool",
|
|
34
|
+
ref: "itermGetSessionInfo",
|
|
35
|
+
summary: `Found session ${match.sessionId} in window ${match.windowId}, tab ${match.tabIndex}`,
|
|
36
|
+
createdAt: new Date().toISOString(),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=itermGetSessionInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermGetSessionInfo.js","sourceRoot":"","sources":["../../../src/iterm/itermGetSessionInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAA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QAAQ,EAAE;gBAC9F,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List all sessions (panels) in the current iTerm2 window only.
|
|
3
|
+
* Equivalent to: first find the current window, then return all tabs/sessions under it.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect none
|
|
6
|
+
*/
|
|
7
|
+
export declare function itermListCurrentWindowSessions(_?: {}): Promise<{
|
|
8
|
+
result: {
|
|
9
|
+
windowId: number;
|
|
10
|
+
sessions: {
|
|
11
|
+
windowId: number;
|
|
12
|
+
windowName: string;
|
|
13
|
+
tabIndex: number;
|
|
14
|
+
tabIndexZeroBased: number;
|
|
15
|
+
isCurrentTab: boolean;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
sessionUniqueId: string;
|
|
18
|
+
sessionName: string;
|
|
19
|
+
tty: string;
|
|
20
|
+
isCurrentSession: boolean;
|
|
21
|
+
}[];
|
|
22
|
+
count: number;
|
|
23
|
+
};
|
|
24
|
+
evidence: {
|
|
25
|
+
type: string;
|
|
26
|
+
ref: string;
|
|
27
|
+
summary: string;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
}[];
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=itermListCurrentWindowSessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermListCurrentWindowSessions.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermListCurrentWindowSessions.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAAC,CAAC,GAAE,EAAO;;;;;;;;;;;;;;;;;;;;;;;GA2B9D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { itermListWindows } from "./itermListWindows.js";
|
|
2
|
+
import { createTaggedError } from "./common.js";
|
|
3
|
+
/**
|
|
4
|
+
* List all sessions (panels) in the current iTerm2 window only.
|
|
5
|
+
* Equivalent to: first find the current window, then return all tabs/sessions under it.
|
|
6
|
+
* @tool
|
|
7
|
+
* @effect none
|
|
8
|
+
*/
|
|
9
|
+
export async function itermListCurrentWindowSessions(_ = {}) {
|
|
10
|
+
const { result } = await itermListWindows();
|
|
11
|
+
const sessions = result.sessions ?? [];
|
|
12
|
+
const current = sessions.find((s) => s.isCurrentSession);
|
|
13
|
+
if (!current) {
|
|
14
|
+
throw createTaggedError("ITERM_NO_CURRENT_SESSION", "No current iTerm2 session found", {});
|
|
15
|
+
}
|
|
16
|
+
const windowId = current.windowId;
|
|
17
|
+
const windowSessions = sessions.filter((s) => s.windowId === windowId);
|
|
18
|
+
return {
|
|
19
|
+
result: {
|
|
20
|
+
windowId,
|
|
21
|
+
sessions: windowSessions,
|
|
22
|
+
count: windowSessions.length,
|
|
23
|
+
},
|
|
24
|
+
evidence: [
|
|
25
|
+
{
|
|
26
|
+
type: "tool",
|
|
27
|
+
ref: "itermListCurrentWindowSessions",
|
|
28
|
+
summary: `Listed ${windowSessions.length} sessions in current window ${windowId}`,
|
|
29
|
+
createdAt: new Date().toISOString(),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=itermListCurrentWindowSessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermListCurrentWindowSessions.js","sourceRoot":"","sources":["../../../src/iterm/itermListCurrentWindowSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,IAAQ,EAAE;IAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAC5C,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;IAEvC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAiC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IACzF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,iBAAiB,CAAC,0BAA0B,EAAE,iCAAiC,EAAE,EAAE,CAAC,CAAC;IAC7F,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAwB,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IAE9F,OAAO;QACL,MAAM,EAAE;YACN,QAAQ;YACR,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,cAAc,CAAC,MAAM;SAC7B;QACD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,gCAAgC;gBACrC,OAAO,EAAE,UAAU,cAAc,CAAC,MAAM,+BAA+B,QAAQ,EAAE;gBACjF,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List iTerm2 windows, tabs, and sessions.
|
|
3
|
+
* @tool
|
|
4
|
+
* @effect none
|
|
5
|
+
*/
|
|
6
|
+
export declare function itermListWindows(_?: {
|
|
7
|
+
includeSessionText?: boolean;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
result: {
|
|
10
|
+
sessions: {
|
|
11
|
+
windowId: number;
|
|
12
|
+
windowName: string;
|
|
13
|
+
tabIndex: number;
|
|
14
|
+
tabIndexZeroBased: number;
|
|
15
|
+
isCurrentTab: boolean;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
sessionUniqueId: string;
|
|
18
|
+
sessionName: string;
|
|
19
|
+
tty: string;
|
|
20
|
+
isCurrentSession: boolean;
|
|
21
|
+
}[];
|
|
22
|
+
count: number;
|
|
23
|
+
};
|
|
24
|
+
evidence: {
|
|
25
|
+
type: string;
|
|
26
|
+
ref: string;
|
|
27
|
+
summary: string;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
}[];
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=itermListWindows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermListWindows.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermListWindows.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,GAAE;IACxC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CACzB;;;;;;;;;;;;;;;;;;;;;;GAiFL"}
|