@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,73 @@
|
|
|
1
|
+
import { runOsaScript, RECORD_SEPARATOR, FIELD_SEPARATOR, } from "./common.js";
|
|
2
|
+
/**
|
|
3
|
+
* List iTerm2 windows, tabs, and sessions.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect none
|
|
6
|
+
*/
|
|
7
|
+
export async function itermListWindows(_ = {}) {
|
|
8
|
+
const lines = [
|
|
9
|
+
'tell application "iTerm2"',
|
|
10
|
+
"set rs to ASCII character 30",
|
|
11
|
+
"set fs to ASCII character 31",
|
|
12
|
+
// Avoid "rows" name collision with iTerm properties.
|
|
13
|
+
"set collectedRows to {}",
|
|
14
|
+
"repeat with aWindow in windows",
|
|
15
|
+
"set windowId to (id of aWindow) as text",
|
|
16
|
+
"set windowName to (name of aWindow) as text",
|
|
17
|
+
"set tabCount to count of tabs of aWindow",
|
|
18
|
+
"repeat with tabPos from 1 to tabCount",
|
|
19
|
+
"set aTab to tab tabPos of aWindow",
|
|
20
|
+
"set tabIdx1 to tabPos as integer",
|
|
21
|
+
"set tabIdx0 to tabIdx1 - 1",
|
|
22
|
+
"set isCurrentTab to (aTab is current tab of aWindow)",
|
|
23
|
+
"repeat with aSession in sessions of aTab",
|
|
24
|
+
"set sessionId to (id of aSession) as text",
|
|
25
|
+
"set sessionUid to (unique id of aSession) as text",
|
|
26
|
+
"set sessionName to (name of aSession) as text",
|
|
27
|
+
"set sessionTty to (tty of aSession) as text",
|
|
28
|
+
"set isCurrentSession to (aSession is current session of aWindow)",
|
|
29
|
+
"set end of collectedRows to windowId & fs & windowName & fs & (tabIdx1 as text) & fs & (tabIdx0 as text) & fs & (isCurrentTab as text) & fs & sessionId & fs & sessionUid & fs & sessionName & fs & sessionTty & fs & (isCurrentSession as text)",
|
|
30
|
+
"end repeat",
|
|
31
|
+
"end repeat",
|
|
32
|
+
"end repeat",
|
|
33
|
+
"set AppleScript's text item delimiters to rs",
|
|
34
|
+
"set outputText to collectedRows as text",
|
|
35
|
+
"set AppleScript's text item delimiters to \"\"",
|
|
36
|
+
"return outputText",
|
|
37
|
+
"end tell",
|
|
38
|
+
];
|
|
39
|
+
const output = await runOsaScript(lines);
|
|
40
|
+
const rows = output
|
|
41
|
+
? output.split(RECORD_SEPARATOR).filter(Boolean)
|
|
42
|
+
: [];
|
|
43
|
+
const sessions = rows.map((row) => {
|
|
44
|
+
const [windowId, windowName, tabIndex, tabIndexZero, isCurrentTab, sessionId, sessionUniqueId, sessionName, tty, isCurrentSession,] = row.split(FIELD_SEPARATOR);
|
|
45
|
+
return {
|
|
46
|
+
windowId: Number(windowId ?? "0"),
|
|
47
|
+
windowName: windowName ?? "",
|
|
48
|
+
tabIndex: Number(tabIndex ?? "0"),
|
|
49
|
+
tabIndexZeroBased: Number(tabIndexZero ?? "0"),
|
|
50
|
+
isCurrentTab: isCurrentTab === "true",
|
|
51
|
+
sessionId: sessionId ?? "",
|
|
52
|
+
sessionUniqueId: sessionUniqueId ?? "",
|
|
53
|
+
sessionName: sessionName ?? "",
|
|
54
|
+
tty: tty ?? "",
|
|
55
|
+
isCurrentSession: isCurrentSession === "true",
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
result: {
|
|
60
|
+
sessions,
|
|
61
|
+
count: sessions.length,
|
|
62
|
+
},
|
|
63
|
+
evidence: [
|
|
64
|
+
{
|
|
65
|
+
type: "tool",
|
|
66
|
+
ref: "itermListWindows",
|
|
67
|
+
summary: `Listed ${sessions.length} iTerm2 sessions`,
|
|
68
|
+
createdAt: new Date().toISOString(),
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=itermListWindows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermListWindows.js","sourceRoot":"","sources":["../../../src/iterm/itermListWindows.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,gBAAgB,EAChB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAEnC,EAAE;IACJ,MAAM,KAAK,GAAG;QACZ,2BAA2B;QAC3B,8BAA8B;QAC9B,8BAA8B;QAC9B,qDAAqD;QACrD,yBAAyB;QACzB,gCAAgC;QAChC,yCAAyC;QACzC,6CAA6C;QAC7C,0CAA0C;QAC1C,uCAAuC;QACvC,mCAAmC;QACnC,kCAAkC;QAClC,4BAA4B;QAC5B,sDAAsD;QACtD,0CAA0C;QAC1C,2CAA2C;QAC3C,mDAAmD;QACnD,+CAA+C;QAC/C,6CAA6C;QAC7C,kEAAkE;QAClE,kPAAkP;QAClP,YAAY;QACZ,YAAY;QAC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MAAM,kBAAkB;gBACpD,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rename iTerm2 window/tab/session targets.
|
|
3
|
+
* @tool
|
|
4
|
+
* @effect local_write
|
|
5
|
+
*/
|
|
6
|
+
export declare function itermRename(args: {
|
|
7
|
+
windowId?: number;
|
|
8
|
+
tabIndex?: number;
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
windowName?: string;
|
|
11
|
+
tabName?: string;
|
|
12
|
+
sessionName?: string;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
result: {
|
|
15
|
+
windowName: string | null;
|
|
16
|
+
tabName: string | null;
|
|
17
|
+
sessionName: string | null;
|
|
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=itermRename.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermRename.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermRename.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;;;;;;;;;;;;;;;;GAgDA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { runOsaScript, targetSelectorScript, applyOptionalNamingScript, returnTupleScript, parsePipeTuple, createTaggedError, } from "./common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Rename iTerm2 window/tab/session targets.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect local_write
|
|
6
|
+
*/
|
|
7
|
+
export async function itermRename(args) {
|
|
8
|
+
if (!args.windowName?.trim() && !args.tabName?.trim() && !args.sessionName?.trim()) {
|
|
9
|
+
throw createTaggedError("ITERM_INVALID", "At least one of windowName/tabName/sessionName is required", {});
|
|
10
|
+
}
|
|
11
|
+
const lines = [
|
|
12
|
+
'tell application "iTerm2"',
|
|
13
|
+
...targetSelectorScript({
|
|
14
|
+
windowId: args.windowId,
|
|
15
|
+
tabIndex: args.tabIndex,
|
|
16
|
+
sessionId: args.sessionId,
|
|
17
|
+
}),
|
|
18
|
+
...applyOptionalNamingScript({
|
|
19
|
+
windowName: args.windowName,
|
|
20
|
+
tabName: args.tabName,
|
|
21
|
+
sessionName: args.sessionName,
|
|
22
|
+
}),
|
|
23
|
+
...returnTupleScript({
|
|
24
|
+
windowRef: "targetWindow",
|
|
25
|
+
tabRef: "targetTab",
|
|
26
|
+
sessionRef: "targetSession",
|
|
27
|
+
}),
|
|
28
|
+
"end tell",
|
|
29
|
+
];
|
|
30
|
+
const output = await runOsaScript(lines);
|
|
31
|
+
const parsed = parsePipeTuple(output);
|
|
32
|
+
return {
|
|
33
|
+
result: {
|
|
34
|
+
...parsed,
|
|
35
|
+
windowName: args.windowName?.trim() ?? null,
|
|
36
|
+
tabName: args.tabName?.trim() ?? null,
|
|
37
|
+
sessionName: args.sessionName?.trim() ?? null,
|
|
38
|
+
},
|
|
39
|
+
evidence: [
|
|
40
|
+
{
|
|
41
|
+
type: "tool",
|
|
42
|
+
ref: "itermRename",
|
|
43
|
+
summary: `Renamed iTerm2 targets in window ${parsed.windowId}, tab ${parsed.tabIndex}`,
|
|
44
|
+
createdAt: new Date().toISOString(),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=itermRename.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermRename.js","sourceRoot":"","sources":["../../../src/iterm/itermRename.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAOjC;IACC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;QACnF,MAAM,iBAAiB,CACrB,eAAe,EACf,4DAA4D,EAC5D,EAAE,CACH,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG;QACZ,2BAA2B;QAC3B,GAAG,oBAAoB,CAAC;YACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;QACF,GAAG,yBAAyB,CAAC;YAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC;QACF,GAAG,iBAAiB,CAAC;YACnB,SAAS,EAAE,cAAc;YACzB,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,eAAe;SAC5B,CAAC;QACF,UAAU;KACX,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAEtC,OAAO;QACL,MAAM,EAAE;YACN,GAAG,MAAM;YACT,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,IAAI;YAC3C,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI;YACrC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,IAAI;SAC9C;QACD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,aAAa;gBAClB,OAAO,EAAE,oCAAoC,MAAM,CAAC,QAAQ,SAAS,MAAM,CAAC,QAAQ,EAAE;gBACtF,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resize the current iTerm2 window to a percentage of the main screen,
|
|
3
|
+
* and center it. Default: 85% width, 85% height.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect local_write
|
|
6
|
+
*/
|
|
7
|
+
export declare function itermResizeWindow(args: {
|
|
8
|
+
windowId?: number;
|
|
9
|
+
/** Width percentage of the main screen (10–100, default 85). */
|
|
10
|
+
widthPercent?: number;
|
|
11
|
+
/** Height percentage of the main screen (10–100, default 85). */
|
|
12
|
+
heightPercent?: number;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
result: {
|
|
15
|
+
widthPercent: number;
|
|
16
|
+
heightPercent: number;
|
|
17
|
+
windowId: number;
|
|
18
|
+
tabIndex: number;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
sessionUniqueId: string;
|
|
21
|
+
};
|
|
22
|
+
evidence: {
|
|
23
|
+
type: string;
|
|
24
|
+
ref: string;
|
|
25
|
+
summary: string;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
}[];
|
|
28
|
+
}>;
|
|
29
|
+
//# sourceMappingURL=itermResizeWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermResizeWindow.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermResizeWindow.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;;;;;;;;;;;;;;;GA+CA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { runOsaScript, targetSelectorScript, returnTupleScript, parsePipeTuple, } from "./common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resize the current iTerm2 window to a percentage of the main screen,
|
|
4
|
+
* and center it. Default: 85% width, 85% height.
|
|
5
|
+
* @tool
|
|
6
|
+
* @effect local_write
|
|
7
|
+
*/
|
|
8
|
+
export async function itermResizeWindow(args) {
|
|
9
|
+
const widthPercent = Math.max(10, Math.min(100, args.widthPercent ?? 85));
|
|
10
|
+
const heightPercent = Math.max(10, Math.min(100, args.heightPercent ?? 85));
|
|
11
|
+
const lines = [
|
|
12
|
+
// Get main screen bounds and compute target size/position.
|
|
13
|
+
'tell application "Finder"',
|
|
14
|
+
"set desktopBounds to bounds of window of desktop",
|
|
15
|
+
"set screenWidth to item 3 of desktopBounds",
|
|
16
|
+
"set screenHeight to item 4 of desktopBounds",
|
|
17
|
+
`set targetWidth to (screenWidth * ${widthPercent} / 100) as integer`,
|
|
18
|
+
`set targetHeight to (screenHeight * ${heightPercent} / 100) as integer`,
|
|
19
|
+
"set leftPos to ((screenWidth - targetWidth) / 2) as integer",
|
|
20
|
+
"set topPos to ((screenHeight - targetHeight) / 2) as integer",
|
|
21
|
+
"end tell",
|
|
22
|
+
// Resize and center the iTerm2 window.
|
|
23
|
+
'tell application "iTerm2"',
|
|
24
|
+
...targetSelectorScript({
|
|
25
|
+
windowId: args.windowId,
|
|
26
|
+
}),
|
|
27
|
+
"set bounds of targetWindow to {leftPos, topPos, leftPos + targetWidth, topPos + targetHeight}",
|
|
28
|
+
...returnTupleScript({
|
|
29
|
+
windowRef: "targetWindow",
|
|
30
|
+
tabRef: "targetTab",
|
|
31
|
+
sessionRef: "targetSession",
|
|
32
|
+
}),
|
|
33
|
+
"end tell",
|
|
34
|
+
];
|
|
35
|
+
const output = await runOsaScript(lines);
|
|
36
|
+
const parsed = parsePipeTuple(output);
|
|
37
|
+
return {
|
|
38
|
+
result: {
|
|
39
|
+
...parsed,
|
|
40
|
+
widthPercent,
|
|
41
|
+
heightPercent,
|
|
42
|
+
},
|
|
43
|
+
evidence: [
|
|
44
|
+
{
|
|
45
|
+
type: "tool",
|
|
46
|
+
ref: "itermResizeWindow",
|
|
47
|
+
summary: `Resized window ${parsed.windowId} to ${widthPercent}% x ${heightPercent}%`,
|
|
48
|
+
createdAt: new Date().toISOString(),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=itermResizeWindow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermResizeWindow.js","sourceRoot":"","sources":["../../../src/iterm/itermResizeWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAMvC;IACC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1E,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,CAAC;IAE5E,MAAM,KAAK,GAAG;QACZ,2DAA2D;QAC3D,2BAA2B;QAC3B,kDAAkD;QAClD,4CAA4C;QAC5C,6CAA6C;QAC7C,qCAAqC,YAAY,oBAAoB;QACrE,uCAAuC,aAAa,oBAAoB;QACxE,6DAA6D;QAC7D,8DAA8D;QAC9D,UAAU;QACV,uCAAuC;QACvC,2BAA2B;QAC3B,GAAG,oBAAoB,CAAC;YACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;QACF,+FAA+F;QAC/F,GAAG,iBAAiB,CAAC;YACnB,SAAS,EAAE,cAAc;YACzB,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,eAAe;SAC5B,CAAC;QACF,UAAU;KACX,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAEtC,OAAO;QACL,MAAM,EAAE;YACN,GAAG,MAAM;YACT,YAAY;YACZ,aAAa;SACd;QACD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,mBAAmB;gBACxB,OAAO,EAAE,kBAAkB,MAAM,CAAC,QAAQ,OAAO,YAAY,OAAO,aAAa,GAAG;gBACpF,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run a shell command in an iTerm2 session (panel).
|
|
3
|
+
* Implemented by sending one line of text via itermSendText and appending a newline.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect local_write
|
|
6
|
+
*/
|
|
7
|
+
export declare function itermRunCommandInSession(args: {
|
|
8
|
+
command: string;
|
|
9
|
+
windowId?: number;
|
|
10
|
+
tabIndex?: number;
|
|
11
|
+
sessionId?: string;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
result: {
|
|
14
|
+
command: string;
|
|
15
|
+
text: string;
|
|
16
|
+
newline: boolean;
|
|
17
|
+
windowId: number;
|
|
18
|
+
tabIndex: number;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
sessionUniqueId: string;
|
|
21
|
+
};
|
|
22
|
+
evidence: {
|
|
23
|
+
type: string;
|
|
24
|
+
ref: string;
|
|
25
|
+
summary: string;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
}[];
|
|
28
|
+
}>;
|
|
29
|
+
//# sourceMappingURL=itermRunCommandInSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermRunCommandInSession.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermRunCommandInSession.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;;;;;;;;;;;;;;;;GA6BA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { itermSendText } from "./itermSendText.js";
|
|
2
|
+
import { createTaggedError } from "./common.js";
|
|
3
|
+
/**
|
|
4
|
+
* Run a shell command in an iTerm2 session (panel).
|
|
5
|
+
* Implemented by sending one line of text via itermSendText and appending a newline.
|
|
6
|
+
* @tool
|
|
7
|
+
* @effect local_write
|
|
8
|
+
*/
|
|
9
|
+
export async function itermRunCommandInSession(args) {
|
|
10
|
+
const cmd = args.command?.trim();
|
|
11
|
+
if (!cmd) {
|
|
12
|
+
throw createTaggedError("ITERM_INVALID", "command is required", {});
|
|
13
|
+
}
|
|
14
|
+
const { result, evidence } = await itermSendText({
|
|
15
|
+
text: cmd,
|
|
16
|
+
windowId: args.windowId,
|
|
17
|
+
tabIndex: args.tabIndex,
|
|
18
|
+
sessionId: args.sessionId,
|
|
19
|
+
newline: true,
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
result: {
|
|
23
|
+
...result,
|
|
24
|
+
command: cmd,
|
|
25
|
+
},
|
|
26
|
+
evidence: [
|
|
27
|
+
...(evidence ?? []),
|
|
28
|
+
{
|
|
29
|
+
type: "tool",
|
|
30
|
+
ref: "itermRunCommandInSession",
|
|
31
|
+
summary: `Ran command in window ${result.windowId}, tab ${result.tabIndex}`,
|
|
32
|
+
createdAt: new Date().toISOString(),
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=itermRunCommandInSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermRunCommandInSession.js","sourceRoot":"","sources":["../../../src/iterm/itermRunCommandInSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAK9C;IACC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IACjC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,iBAAiB,CAAC,eAAe,EAAE,qBAAqB,EAAE,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,aAAa,CAAC;QAC/C,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;IAEH,OAAO;QACL,MAAM,EAAE;YACN,GAAG,MAAM;YACT,OAAO,EAAE,GAAG;SACb;QACD,QAAQ,EAAE;YACR,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;YACnB;gBACE,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,0BAA0B;gBAC/B,OAAO,EAAE,yBAAyB,MAAM,CAAC,QAAQ,SAAS,MAAM,CAAC,QAAQ,EAAE;gBAC3E,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send text to an iTerm2 session as if typed.
|
|
3
|
+
* @tool
|
|
4
|
+
* @effect local_write
|
|
5
|
+
*/
|
|
6
|
+
export declare function itermSendText(args: {
|
|
7
|
+
text: string;
|
|
8
|
+
windowId?: number;
|
|
9
|
+
tabIndex?: number;
|
|
10
|
+
sessionId?: string;
|
|
11
|
+
newline?: boolean;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
result: {
|
|
14
|
+
text: string;
|
|
15
|
+
newline: boolean;
|
|
16
|
+
windowId: number;
|
|
17
|
+
tabIndex: number;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
sessionUniqueId: string;
|
|
20
|
+
};
|
|
21
|
+
evidence: {
|
|
22
|
+
type: string;
|
|
23
|
+
ref: string;
|
|
24
|
+
summary: string;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
}[];
|
|
27
|
+
}>;
|
|
28
|
+
//# sourceMappingURL=itermSendText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermSendText.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermSendText.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;;;;;;;;;;;;;;;GA2CA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { runOsaScript, targetSelectorScript, returnTupleScript, parsePipeTuple, quoteAppleScriptString, createTaggedError, } from "./common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Send text to an iTerm2 session as if typed.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect local_write
|
|
6
|
+
*/
|
|
7
|
+
export async function itermSendText(args) {
|
|
8
|
+
const text = args.text;
|
|
9
|
+
if (!text || !text.trim()) {
|
|
10
|
+
throw createTaggedError("ITERM_INVALID", "text is required", {});
|
|
11
|
+
}
|
|
12
|
+
const newline = args.newline ?? true;
|
|
13
|
+
const newlineClause = newline ? "" : " newline NO";
|
|
14
|
+
const lines = [
|
|
15
|
+
'tell application "iTerm2"',
|
|
16
|
+
...targetSelectorScript({
|
|
17
|
+
windowId: args.windowId,
|
|
18
|
+
tabIndex: args.tabIndex,
|
|
19
|
+
sessionId: args.sessionId,
|
|
20
|
+
}),
|
|
21
|
+
`tell targetSession to write text ${quoteAppleScriptString(text)}${newlineClause}`,
|
|
22
|
+
...returnTupleScript({
|
|
23
|
+
windowRef: "targetWindow",
|
|
24
|
+
tabRef: "targetTab",
|
|
25
|
+
sessionRef: "targetSession",
|
|
26
|
+
}),
|
|
27
|
+
"end tell",
|
|
28
|
+
];
|
|
29
|
+
const output = await runOsaScript(lines);
|
|
30
|
+
const parsed = parsePipeTuple(output);
|
|
31
|
+
return {
|
|
32
|
+
result: {
|
|
33
|
+
...parsed,
|
|
34
|
+
text,
|
|
35
|
+
newline,
|
|
36
|
+
},
|
|
37
|
+
evidence: [
|
|
38
|
+
{
|
|
39
|
+
type: "tool",
|
|
40
|
+
ref: "itermSendText",
|
|
41
|
+
summary: `Sent ${text.length} chars to window ${parsed.windowId}, tab ${parsed.tabIndex}`,
|
|
42
|
+
createdAt: new Date().toISOString(),
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=itermSendText.js.map
|
|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E,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,eAAe;gBACpB,OAAO,EAAE,QAAQ,IAAI,CAAC,MAAM,oBAAoB,MAAM,CAAC,QAAQ,SAAS,MAAM,CAAC,QAAQ,EAAE;gBACzF,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set iTerm2 session background color.
|
|
3
|
+
* @tool
|
|
4
|
+
* @effect local_write
|
|
5
|
+
*/
|
|
6
|
+
export declare function itermSetBackgroundColor(args: {
|
|
7
|
+
windowId?: number;
|
|
8
|
+
tabIndex?: number;
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
hex?: string;
|
|
11
|
+
red?: number;
|
|
12
|
+
green?: number;
|
|
13
|
+
blue?: number;
|
|
14
|
+
alpha?: number;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
result: {
|
|
17
|
+
color: {
|
|
18
|
+
red: number;
|
|
19
|
+
green: number;
|
|
20
|
+
blue: number;
|
|
21
|
+
alpha: number;
|
|
22
|
+
};
|
|
23
|
+
windowId: number;
|
|
24
|
+
tabIndex: number;
|
|
25
|
+
sessionId: string;
|
|
26
|
+
sessionUniqueId: string;
|
|
27
|
+
};
|
|
28
|
+
evidence: {
|
|
29
|
+
type: string;
|
|
30
|
+
ref: string;
|
|
31
|
+
summary: string;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
}[];
|
|
34
|
+
}>;
|
|
35
|
+
//# sourceMappingURL=itermSetBackgroundColor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermSetBackgroundColor.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermSetBackgroundColor.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,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;;;;;;;;;;;;;;;;;;;GAoCA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { runOsaScript, targetSelectorScript, returnTupleScript, parsePipeTuple, normalizeRgb, } from "./common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Set iTerm2 session background color.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect local_write
|
|
6
|
+
*/
|
|
7
|
+
export async function itermSetBackgroundColor(args) {
|
|
8
|
+
const color = normalizeRgb(args);
|
|
9
|
+
const lines = [
|
|
10
|
+
'tell application "iTerm2"',
|
|
11
|
+
...targetSelectorScript({
|
|
12
|
+
windowId: args.windowId,
|
|
13
|
+
tabIndex: args.tabIndex,
|
|
14
|
+
sessionId: args.sessionId,
|
|
15
|
+
}),
|
|
16
|
+
`set background color of targetSession to {${color.red}, ${color.green}, ${color.blue}, ${color.alpha}}`,
|
|
17
|
+
...returnTupleScript({
|
|
18
|
+
windowRef: "targetWindow",
|
|
19
|
+
tabRef: "targetTab",
|
|
20
|
+
sessionRef: "targetSession",
|
|
21
|
+
}),
|
|
22
|
+
"end tell",
|
|
23
|
+
];
|
|
24
|
+
const output = await runOsaScript(lines);
|
|
25
|
+
const parsed = parsePipeTuple(output);
|
|
26
|
+
return {
|
|
27
|
+
result: {
|
|
28
|
+
...parsed,
|
|
29
|
+
color,
|
|
30
|
+
},
|
|
31
|
+
evidence: [
|
|
32
|
+
{
|
|
33
|
+
type: "tool",
|
|
34
|
+
ref: "itermSetBackgroundColor",
|
|
35
|
+
summary: `Set background color in window ${parsed.windowId}, tab ${parsed.tabIndex}`,
|
|
36
|
+
createdAt: new Date().toISOString(),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=itermSetBackgroundColor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermSetBackgroundColor.js","sourceRoot":"","sources":["../../../src/iterm/itermSetBackgroundColor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,YAAY,GACb,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,IAS7C;IACC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAEjC,MAAM,KAAK,GAAG;QACZ,2BAA2B;QAC3B,GAAG,oBAAoB,CAAC;YACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;QACF,6CAA6C,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,KAAK,GAAG;QACxG,GAAG,iBAAiB,CAAC;YACnB,SAAS,EAAE,cAAc;YACzB,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,eAAe;SAC5B,CAAC;QACF,UAAU;KACX,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAEtC,OAAO;QACL,MAAM,EAAE;YACN,GAAG,MAAM;YACT,KAAK;SACN;QACD,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,yBAAyB;gBAC9B,OAAO,EAAE,kCAAkC,MAAM,CAAC,QAAQ,SAAS,MAAM,CAAC,QAAQ,EAAE;gBACpF,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split an iTerm2 session into a new pane.
|
|
3
|
+
* @tool
|
|
4
|
+
* @effect local_write
|
|
5
|
+
*/
|
|
6
|
+
export declare function itermSplitPane(args: {
|
|
7
|
+
windowId?: number;
|
|
8
|
+
tabIndex?: number;
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
direction?: "horizontal" | "vertical";
|
|
11
|
+
profile?: string;
|
|
12
|
+
command?: string;
|
|
13
|
+
cmd?: string;
|
|
14
|
+
activate?: boolean;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
result: {
|
|
17
|
+
direction: string;
|
|
18
|
+
profile: string;
|
|
19
|
+
commandText: string;
|
|
20
|
+
windowId: number;
|
|
21
|
+
tabIndex: number;
|
|
22
|
+
sessionId: string;
|
|
23
|
+
sessionUniqueId: string;
|
|
24
|
+
};
|
|
25
|
+
evidence: {
|
|
26
|
+
type: string;
|
|
27
|
+
ref: string;
|
|
28
|
+
summary: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
}[];
|
|
31
|
+
}>;
|
|
32
|
+
//# sourceMappingURL=itermSplitPane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermSplitPane.d.ts","sourceRoot":"","sources":["../../../src/iterm/itermSplitPane.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;;;;;;;;;;GAqDA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { quoteAppleScriptString, runOsaScript, targetSelectorScript, returnTupleScript, parsePipeTuple, } from "./common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Split an iTerm2 session into a new pane.
|
|
4
|
+
* @tool
|
|
5
|
+
* @effect local_write
|
|
6
|
+
*/
|
|
7
|
+
export async function itermSplitPane(args) {
|
|
8
|
+
// Default to a vertical split (left/right panes) when direction is not specified.
|
|
9
|
+
const direction = args.direction === "horizontal" ? "horizontal" : "vertical";
|
|
10
|
+
const profile = args.profile?.trim();
|
|
11
|
+
const command = (args.command ?? args.cmd)?.trim();
|
|
12
|
+
const activate = args.activate ?? true;
|
|
13
|
+
const splitCommand = profile
|
|
14
|
+
? command
|
|
15
|
+
? `split ${direction === "vertical" ? "vertically" : "horizontally"} with profile ${quoteAppleScriptString(profile)} command ${quoteAppleScriptString(command)}`
|
|
16
|
+
: `split ${direction === "vertical" ? "vertically" : "horizontally"} with profile ${quoteAppleScriptString(profile)}`
|
|
17
|
+
: command
|
|
18
|
+
? `split ${direction === "vertical" ? "vertically" : "horizontally"} with default profile command ${quoteAppleScriptString(command)}`
|
|
19
|
+
: `split ${direction === "vertical" ? "vertically" : "horizontally"} with default profile`;
|
|
20
|
+
const lines = [
|
|
21
|
+
'tell application "iTerm2"',
|
|
22
|
+
...(activate ? ["activate"] : []),
|
|
23
|
+
...targetSelectorScript({
|
|
24
|
+
windowId: args.windowId,
|
|
25
|
+
tabIndex: args.tabIndex,
|
|
26
|
+
sessionId: args.sessionId,
|
|
27
|
+
}),
|
|
28
|
+
"tell targetSession",
|
|
29
|
+
`set newSession to (${splitCommand})`,
|
|
30
|
+
"end tell",
|
|
31
|
+
...returnTupleScript({
|
|
32
|
+
windowRef: "targetWindow",
|
|
33
|
+
tabRef: "targetTab",
|
|
34
|
+
sessionRef: "newSession",
|
|
35
|
+
}),
|
|
36
|
+
"end tell",
|
|
37
|
+
];
|
|
38
|
+
const output = await runOsaScript(lines);
|
|
39
|
+
const parsed = parsePipeTuple(output);
|
|
40
|
+
return {
|
|
41
|
+
result: {
|
|
42
|
+
...parsed,
|
|
43
|
+
direction,
|
|
44
|
+
profile: profile ?? "default",
|
|
45
|
+
commandText: command ?? "",
|
|
46
|
+
},
|
|
47
|
+
evidence: [
|
|
48
|
+
{
|
|
49
|
+
type: "tool",
|
|
50
|
+
ref: "itermSplitPane",
|
|
51
|
+
summary: `Split ${direction} in window ${parsed.windowId}, tab ${parsed.tabIndex}`,
|
|
52
|
+
createdAt: new Date().toISOString(),
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=itermSplitPane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itermSplitPane.js","sourceRoot":"","sources":["../../../src/iterm/itermSplitPane.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IASpC;IACC,kFAAkF;IAClF,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC;IAC9E,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,YAAY,GAAG,OAAO;QAC1B,CAAC,CAAC,OAAO;YACP,CAAC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