@elizaos/plugin-shell 2.0.0-alpha.2 → 2.0.0-alpha.4
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/actions/index.d.ts +1 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/processAction.d.ts +7 -0
- package/dist/actions/processAction.d.ts.map +1 -0
- package/dist/approvals/allowlist.d.ts +76 -0
- package/dist/approvals/allowlist.d.ts.map +1 -0
- package/dist/approvals/analysis.d.ts +76 -0
- package/dist/approvals/analysis.d.ts.map +1 -0
- package/dist/approvals/index.d.ts +12 -0
- package/dist/approvals/index.d.ts.map +1 -0
- package/dist/approvals/service.d.ts +121 -0
- package/dist/approvals/service.d.ts.map +1 -0
- package/dist/approvals/types.d.ts +219 -0
- package/dist/approvals/types.d.ts.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5069 -446
- package/dist/index.js.map +24 -6
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/processRegistry.d.ts +25 -0
- package/dist/services/processRegistry.d.ts.map +1 -0
- package/dist/services/shellService.d.ts +73 -6
- package/dist/services/shellService.d.ts.map +1 -1
- package/dist/types/index.d.ts +114 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/processQueue.d.ts +136 -0
- package/dist/utils/processQueue.d.ts.map +1 -0
- package/dist/utils/ptyKeys.d.ts +23 -0
- package/dist/utils/ptyKeys.d.ts.map +1 -0
- package/dist/utils/shellArgv.d.ts +37 -0
- package/dist/utils/shellArgv.d.ts.map +1 -0
- package/dist/utils/shellUtils.d.ts +103 -0
- package/dist/utils/shellUtils.d.ts.map +1 -0
- package/package.json +43 -11
- package/LICENSE +0 -21
package/dist/services/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
export { addSession, appendOutput, clearFinished, createSessionSlug, deleteSession, drainSession, getFinishedSession, getSession, listFinishedSessions, listRunningSessions, markBackgrounded, markExited, resetProcessRegistryForTests, setJobTtlMs, tail, trimWithCap, } from "./processRegistry";
|
|
1
2
|
export { ShellService } from "./shellService";
|
|
2
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,4BAA4B,EAC5B,WAAW,EACX,IAAI,EACJ,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process Registry - Manages running and finished shell sessions
|
|
3
|
+
* Ported from otto bash-process-registry.ts
|
|
4
|
+
*/
|
|
5
|
+
import type { FinishedSession, ProcessSession, ProcessStatus } from "../types";
|
|
6
|
+
export declare function createSessionSlug(isTaken?: (id: string) => boolean): string;
|
|
7
|
+
export declare function addSession(session: ProcessSession): void;
|
|
8
|
+
export declare function getSession(id: string): ProcessSession | undefined;
|
|
9
|
+
export declare function getFinishedSession(id: string): FinishedSession | undefined;
|
|
10
|
+
export declare function deleteSession(id: string): void;
|
|
11
|
+
export declare function tail(text: string, max?: number): string;
|
|
12
|
+
export declare function trimWithCap(text: string, max: number): string;
|
|
13
|
+
export declare function appendOutput(session: ProcessSession, stream: "stdout" | "stderr", chunk: string): void;
|
|
14
|
+
export declare function drainSession(session: ProcessSession): {
|
|
15
|
+
stdout: string;
|
|
16
|
+
stderr: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function markExited(session: ProcessSession, exitCode: number | null, exitSignal: NodeJS.Signals | number | null, status: ProcessStatus): void;
|
|
19
|
+
export declare function markBackgrounded(session: ProcessSession): void;
|
|
20
|
+
export declare function listRunningSessions(): ProcessSession[];
|
|
21
|
+
export declare function listFinishedSessions(): FinishedSession[];
|
|
22
|
+
export declare function clearFinished(): void;
|
|
23
|
+
export declare function resetProcessRegistryForTests(): void;
|
|
24
|
+
export declare function setJobTtlMs(value?: number): void;
|
|
25
|
+
//# sourceMappingURL=processRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processRegistry.d.ts","sourceRoot":"","sources":["../../services/processRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAuI/E,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CA4B3E;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAGxD;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEjE;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAE1E;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAG9C;AAgCD,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAO,GAAG,MAAM,CAKrD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,QAAQ,GAAG,QAAQ,EAC3B,KAAK,EAAE,MAAM,GACZ,IAAI,CA4BN;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAQxF;AAwBD,wBAAgB,UAAU,CACxB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,UAAU,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,IAAI,EAC1C,MAAM,EAAE,aAAa,GACpB,IAAI,CAMN;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAE9D;AAED,wBAAgB,mBAAmB,IAAI,cAAc,EAAE,CAEtD;AAED,wBAAgB,oBAAoB,IAAI,eAAe,EAAE,CAExD;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED,wBAAgB,4BAA4B,IAAI,IAAI,CAInD;AAED,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAOhD"}
|
|
@@ -1,24 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Shell Service with PTY, background execution, and session management
|
|
3
|
+
* Migrated from otto bash-tools.exec.ts, bash-tools.process.ts
|
|
4
|
+
*/
|
|
1
5
|
import { type IAgentRuntime, Service } from "@elizaos/core";
|
|
2
|
-
import type { CommandHistoryEntry, CommandResult } from "../types";
|
|
6
|
+
import type { CommandHistoryEntry, CommandResult, ExecResult, ExecuteOptions, FinishedSession, ProcessActionParams, ProcessSession, ShellConfig } from "../types";
|
|
3
7
|
export declare class ShellService extends Service {
|
|
4
8
|
static serviceType: string;
|
|
5
9
|
private shellConfig;
|
|
6
10
|
private currentDirectory;
|
|
7
11
|
private commandHistory;
|
|
8
12
|
private maxHistoryPerConversation;
|
|
13
|
+
private scopeKey?;
|
|
9
14
|
constructor(runtime: IAgentRuntime);
|
|
10
15
|
static start(runtime: IAgentRuntime): Promise<ShellService>;
|
|
11
16
|
stop(): Promise<void>;
|
|
12
17
|
get capabilityDescription(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Set scope key for session isolation
|
|
20
|
+
*/
|
|
21
|
+
setScopeKey(scopeKey: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Simple command execution (original API for backward compatibility)
|
|
24
|
+
*/
|
|
13
25
|
executeCommand(command: string, conversationId?: string): Promise<CommandResult>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Enhanced command execution with PTY, background support, and session management
|
|
28
|
+
* This is the main execution method that supports all advanced features
|
|
29
|
+
*/
|
|
30
|
+
exec(command: string, options?: ExecuteOptions): Promise<ExecResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Process management action handler
|
|
33
|
+
* Supports: list, poll, log, write, send-keys, submit, paste, kill, clear, remove
|
|
34
|
+
*/
|
|
35
|
+
processAction(params: ProcessActionParams): Promise<{
|
|
36
|
+
success: boolean;
|
|
37
|
+
message: string;
|
|
38
|
+
data?: Record<string, unknown>;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* List all running sessions
|
|
42
|
+
*/
|
|
43
|
+
listRunningSessions(): ProcessSession[];
|
|
44
|
+
/**
|
|
45
|
+
* List all finished sessions
|
|
46
|
+
*/
|
|
47
|
+
listFinishedSessions(): FinishedSession[];
|
|
48
|
+
/**
|
|
49
|
+
* Get a specific session by ID
|
|
50
|
+
*/
|
|
51
|
+
getSession(id: string): ProcessSession | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get a specific finished session by ID
|
|
54
|
+
*/
|
|
55
|
+
getFinishedSession(id: string): FinishedSession | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Kill a session by ID
|
|
58
|
+
*/
|
|
59
|
+
killSessionById(id: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Get command history for a conversation
|
|
62
|
+
*/
|
|
19
63
|
getCommandHistory(conversationId: string, limit?: number): CommandHistoryEntry[];
|
|
64
|
+
/**
|
|
65
|
+
* Clear command history for a conversation
|
|
66
|
+
*/
|
|
20
67
|
clearCommandHistory(conversationId: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Get current working directory
|
|
70
|
+
*/
|
|
21
71
|
getCurrentDirectory(_conversationId?: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* Set current working directory
|
|
74
|
+
*/
|
|
75
|
+
setCurrentDirectory(directory: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Get allowed directory
|
|
78
|
+
*/
|
|
22
79
|
getAllowedDirectory(): string;
|
|
80
|
+
/**
|
|
81
|
+
* Get shell configuration
|
|
82
|
+
*/
|
|
83
|
+
getShellConfig(): ShellConfig;
|
|
84
|
+
private handleCdCommand;
|
|
85
|
+
private runCommandSimple;
|
|
86
|
+
private runExecProcess;
|
|
87
|
+
private addToHistory;
|
|
88
|
+
private detectFileOperations;
|
|
89
|
+
private resolvePath;
|
|
23
90
|
}
|
|
24
91
|
//# sourceMappingURL=shellService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shellService.d.ts","sourceRoot":"","sources":["../../services/shellService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shellService.d.ts","sourceRoot":"","sources":["../../services/shellService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,aAAa,EAAU,OAAO,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,cAAc,EAGd,eAAe,EACf,mBAAmB,EACnB,cAAc,EAGd,WAAW,EACZ,MAAM,UAAU,CAAC;AAoDlB,qBAAa,YAAa,SAAQ,OAAO;IACvC,OAAc,WAAW,SAAW;IACpC,OAAO,CAAC,WAAW,CAAc;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AC,cAAc,EAAE,MAAM,GAAG,IAAI;IAKjD;;OAEG;IACH,mBAAmB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM;IAIrD;;OAEG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAa/C;;OAEG;IACH,mBAAmB,IAAI,MAAM;IAI7B;;OAEG;IACH,cAAc,IAAI,WAAW;YAMf,eAAe;YAyCf,gBAAgB;YAwFhB,cAAc;IAyU5B,OAAO,CAAC,YAAY;IAiCpB,OAAO,CAAC,oBAAoB;IA6C5B,OAAO,CAAC,WAAW;CAMpB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
|
1
2
|
export interface CommandResult {
|
|
2
3
|
success: boolean;
|
|
3
4
|
stdout: string;
|
|
@@ -26,5 +27,118 @@ export interface ShellConfig {
|
|
|
26
27
|
allowedDirectory: string;
|
|
27
28
|
timeout: number;
|
|
28
29
|
forbiddenCommands: string[];
|
|
30
|
+
maxOutputChars: number;
|
|
31
|
+
pendingMaxOutputChars: number;
|
|
32
|
+
defaultBackgroundMs: number;
|
|
33
|
+
allowBackground: boolean;
|
|
29
34
|
}
|
|
35
|
+
export type ProcessStatus = "running" | "completed" | "failed" | "killed";
|
|
36
|
+
export type SessionStdin = {
|
|
37
|
+
write: (data: string, cb?: (err?: Error | null) => void) => void;
|
|
38
|
+
end: () => void;
|
|
39
|
+
destroyed?: boolean;
|
|
40
|
+
};
|
|
41
|
+
export interface ProcessSession {
|
|
42
|
+
id: string;
|
|
43
|
+
command: string;
|
|
44
|
+
scopeKey?: string;
|
|
45
|
+
sessionKey?: string;
|
|
46
|
+
notifyOnExit?: boolean;
|
|
47
|
+
exitNotified?: boolean;
|
|
48
|
+
child?: ChildProcessWithoutNullStreams;
|
|
49
|
+
stdin?: SessionStdin;
|
|
50
|
+
pid?: number;
|
|
51
|
+
startedAt: number;
|
|
52
|
+
cwd?: string;
|
|
53
|
+
maxOutputChars: number;
|
|
54
|
+
pendingMaxOutputChars?: number;
|
|
55
|
+
totalOutputChars: number;
|
|
56
|
+
pendingStdout: string[];
|
|
57
|
+
pendingStderr: string[];
|
|
58
|
+
pendingStdoutChars: number;
|
|
59
|
+
pendingStderrChars: number;
|
|
60
|
+
aggregated: string;
|
|
61
|
+
tail: string;
|
|
62
|
+
exitCode?: number | null;
|
|
63
|
+
exitSignal?: NodeJS.Signals | number | null;
|
|
64
|
+
exited: boolean;
|
|
65
|
+
truncated: boolean;
|
|
66
|
+
backgrounded: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface FinishedSession {
|
|
69
|
+
id: string;
|
|
70
|
+
command: string;
|
|
71
|
+
scopeKey?: string;
|
|
72
|
+
startedAt: number;
|
|
73
|
+
endedAt: number;
|
|
74
|
+
cwd?: string;
|
|
75
|
+
status: ProcessStatus;
|
|
76
|
+
exitCode?: number | null;
|
|
77
|
+
exitSignal?: NodeJS.Signals | number | null;
|
|
78
|
+
aggregated: string;
|
|
79
|
+
tail: string;
|
|
80
|
+
truncated: boolean;
|
|
81
|
+
totalOutputChars: number;
|
|
82
|
+
}
|
|
83
|
+
export interface ExecuteOptions {
|
|
84
|
+
workdir?: string;
|
|
85
|
+
env?: Record<string, string>;
|
|
86
|
+
yieldMs?: number;
|
|
87
|
+
background?: boolean;
|
|
88
|
+
timeout?: number;
|
|
89
|
+
pty?: boolean;
|
|
90
|
+
conversationId?: string;
|
|
91
|
+
scopeKey?: string;
|
|
92
|
+
sessionKey?: string;
|
|
93
|
+
notifyOnExit?: boolean;
|
|
94
|
+
onUpdate?: (session: ProcessSession) => void;
|
|
95
|
+
}
|
|
96
|
+
export type ExecResult = {
|
|
97
|
+
status: "running";
|
|
98
|
+
sessionId: string;
|
|
99
|
+
pid?: number;
|
|
100
|
+
startedAt: number;
|
|
101
|
+
cwd?: string;
|
|
102
|
+
tail?: string;
|
|
103
|
+
} | {
|
|
104
|
+
status: "completed" | "failed";
|
|
105
|
+
exitCode: number | null;
|
|
106
|
+
durationMs: number;
|
|
107
|
+
aggregated: string;
|
|
108
|
+
cwd?: string;
|
|
109
|
+
timedOut?: boolean;
|
|
110
|
+
reason?: string;
|
|
111
|
+
};
|
|
112
|
+
export type ProcessAction = "list" | "poll" | "log" | "write" | "send-keys" | "submit" | "paste" | "kill" | "clear" | "remove";
|
|
113
|
+
export interface ProcessActionParams {
|
|
114
|
+
action: ProcessAction;
|
|
115
|
+
sessionId?: string;
|
|
116
|
+
data?: string;
|
|
117
|
+
keys?: string[];
|
|
118
|
+
hex?: string[];
|
|
119
|
+
literal?: string;
|
|
120
|
+
text?: string;
|
|
121
|
+
bracketed?: boolean;
|
|
122
|
+
eof?: boolean;
|
|
123
|
+
offset?: number;
|
|
124
|
+
limit?: number;
|
|
125
|
+
}
|
|
126
|
+
export type PtyExitEvent = {
|
|
127
|
+
exitCode: number;
|
|
128
|
+
signal?: number;
|
|
129
|
+
};
|
|
130
|
+
export type PtyListener<T> = (event: T) => void;
|
|
131
|
+
export type PtyHandle = {
|
|
132
|
+
pid: number;
|
|
133
|
+
write: (data: string | Buffer) => void;
|
|
134
|
+
onData: (listener: PtyListener<string>) => void;
|
|
135
|
+
onExit: (listener: PtyListener<PtyExitEvent>) => void;
|
|
136
|
+
};
|
|
137
|
+
export type PtySpawn = (file: string, args: string[] | string, options: {
|
|
138
|
+
name?: string;
|
|
139
|
+
cols?: number;
|
|
140
|
+
rows?: number;
|
|
141
|
+
cwd?: string;
|
|
142
|
+
env?: Record<string, string>;
|
|
143
|
+
}) => PtyHandle;
|
|
30
144
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CA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3,"file":"config.d.ts","sourceRoot":"","sources":["../../utils/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../utils/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAa5C,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EA0B9C,CAAC;AAEX,wBAAgB,eAAe,IAAI,WAAW,CAwD7C"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export { DEFAULT_FORBIDDEN_COMMANDS, loadShellConfig } from "./config";
|
|
2
2
|
export { extractBaseCommand, isForbiddenCommand, isSafeCommand, validatePath, } from "./pathUtils";
|
|
3
|
+
export { attachChildProcessBridge, type ChildProcessBridgeOptions, CommandLane, type CommandLane as CommandLaneType, type CommandOptions, clearCommandLane, enqueueCommand, enqueueCommandInLane, getQueueSize, getTotalQueueSize, runCommandWithTimeout, runExec, type SpawnResult, setCommandLaneConcurrency, } from "./processQueue";
|
|
4
|
+
export { BRACKETED_PASTE_END, BRACKETED_PASTE_START, buildCursorPositionResponse, encodeKeySequence, encodePaste, type KeyEncodingRequest, type KeyEncodingResult, stripDsrRequests, } from "./ptyKeys";
|
|
5
|
+
export { splitShellArgs } from "./shellArgv";
|
|
6
|
+
export { chunkString, clampNumber, coerceEnv, deriveSessionName, formatDuration, getShellConfig, killProcessTree, killSession, pad, readEnvInt, resolveWorkdir, sanitizeBinaryOutput, sliceLogLines, sliceUtf16Safe, truncateMiddle, } from "./shellUtils";
|
|
3
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,wBAAwB,EACxB,KAAK,yBAAyB,EAC9B,WAAW,EACX,KAAK,WAAW,IAAI,eAAe,EACnC,KAAK,cAAc,EACnB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,OAAO,EACP,KAAK,WAAW,EAChB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,iBAAiB,EACjB,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,eAAe,EACf,WAAW,EACX,GAAG,EACH,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process execution utilities with command queuing.
|
|
3
|
+
*
|
|
4
|
+
* Provides cross-platform child process execution with:
|
|
5
|
+
* - Windows command resolution (.cmd extension handling)
|
|
6
|
+
* - Timeout support
|
|
7
|
+
* - Lane-based command queuing for serialization
|
|
8
|
+
* - Signal forwarding between parent and child processes
|
|
9
|
+
*
|
|
10
|
+
* @module utils/processQueue
|
|
11
|
+
*/
|
|
12
|
+
import { type ChildProcess } from "node:child_process";
|
|
13
|
+
/**
|
|
14
|
+
* Command execution lanes for organizing concurrent command execution.
|
|
15
|
+
* Lanes allow serialization within a lane while permitting parallelism across lanes.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CommandLane: {
|
|
18
|
+
readonly Main: "main";
|
|
19
|
+
readonly Cron: "cron";
|
|
20
|
+
readonly Subagent: "subagent";
|
|
21
|
+
readonly Nested: "nested";
|
|
22
|
+
};
|
|
23
|
+
export type CommandLane = (typeof CommandLane)[keyof typeof CommandLane];
|
|
24
|
+
/**
|
|
25
|
+
* Simple promise-wrapped execFile with timeout support.
|
|
26
|
+
*
|
|
27
|
+
* @param command - The command to execute
|
|
28
|
+
* @param args - Command arguments
|
|
29
|
+
* @param opts - Timeout in ms or options object
|
|
30
|
+
* @returns Promise resolving to stdout and stderr
|
|
31
|
+
*/
|
|
32
|
+
export declare function runExec(command: string, args: string[], opts?: number | {
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
maxBuffer?: number;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
stdout: string;
|
|
37
|
+
stderr: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Result from a spawned command execution.
|
|
41
|
+
*/
|
|
42
|
+
export type SpawnResult = {
|
|
43
|
+
stdout: string;
|
|
44
|
+
stderr: string;
|
|
45
|
+
code: number | null;
|
|
46
|
+
signal: NodeJS.Signals | null;
|
|
47
|
+
killed: boolean;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Options for running a command with timeout.
|
|
51
|
+
*/
|
|
52
|
+
export type CommandOptions = {
|
|
53
|
+
timeoutMs: number;
|
|
54
|
+
cwd?: string;
|
|
55
|
+
input?: string;
|
|
56
|
+
env?: NodeJS.ProcessEnv;
|
|
57
|
+
windowsVerbatimArguments?: boolean;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Run a command with timeout, input, and environment control.
|
|
61
|
+
*
|
|
62
|
+
* @param argv - Command and arguments as array
|
|
63
|
+
* @param optionsOrTimeout - Options object or timeout in ms
|
|
64
|
+
* @returns Promise resolving to spawn result
|
|
65
|
+
*/
|
|
66
|
+
export declare function runCommandWithTimeout(argv: string[], optionsOrTimeout: number | CommandOptions): Promise<SpawnResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Set the maximum concurrency for a command lane.
|
|
69
|
+
*
|
|
70
|
+
* @param lane - The lane name
|
|
71
|
+
* @param maxConcurrent - Maximum concurrent tasks
|
|
72
|
+
*/
|
|
73
|
+
export declare function setCommandLaneConcurrency(lane: string, maxConcurrent: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* Enqueue a task to execute in a specific lane.
|
|
76
|
+
*
|
|
77
|
+
* @param lane - The lane name
|
|
78
|
+
* @param task - Async task function
|
|
79
|
+
* @param opts - Options including warning threshold and callbacks
|
|
80
|
+
* @returns Promise resolving when task completes
|
|
81
|
+
*/
|
|
82
|
+
export declare function enqueueCommandInLane<T>(lane: string, task: () => Promise<T>, opts?: {
|
|
83
|
+
warnAfterMs?: number;
|
|
84
|
+
onWait?: (waitMs: number, queuedAhead: number) => void;
|
|
85
|
+
}): Promise<T>;
|
|
86
|
+
/**
|
|
87
|
+
* Enqueue a task to execute in the main lane.
|
|
88
|
+
*
|
|
89
|
+
* @param task - Async task function
|
|
90
|
+
* @param opts - Options including warning threshold and callbacks
|
|
91
|
+
* @returns Promise resolving when task completes
|
|
92
|
+
*/
|
|
93
|
+
export declare function enqueueCommand<T>(task: () => Promise<T>, opts?: {
|
|
94
|
+
warnAfterMs?: number;
|
|
95
|
+
onWait?: (waitMs: number, queuedAhead: number) => void;
|
|
96
|
+
}): Promise<T>;
|
|
97
|
+
/**
|
|
98
|
+
* Get the current queue size for a lane (queued + active).
|
|
99
|
+
*
|
|
100
|
+
* @param lane - The lane name (defaults to main)
|
|
101
|
+
* @returns Queue size
|
|
102
|
+
*/
|
|
103
|
+
export declare function getQueueSize(lane?: string): number;
|
|
104
|
+
/**
|
|
105
|
+
* Get total queue size across all lanes.
|
|
106
|
+
*
|
|
107
|
+
* @returns Total queue size
|
|
108
|
+
*/
|
|
109
|
+
export declare function getTotalQueueSize(): number;
|
|
110
|
+
/**
|
|
111
|
+
* Clear all pending tasks in a lane.
|
|
112
|
+
*
|
|
113
|
+
* @param lane - The lane name (defaults to main)
|
|
114
|
+
* @returns Number of tasks cleared
|
|
115
|
+
*/
|
|
116
|
+
export declare function clearCommandLane(lane?: string): number;
|
|
117
|
+
/**
|
|
118
|
+
* Options for attaching a child process signal bridge.
|
|
119
|
+
*/
|
|
120
|
+
export type ChildProcessBridgeOptions = {
|
|
121
|
+
signals?: NodeJS.Signals[];
|
|
122
|
+
onSignal?: (signal: NodeJS.Signals) => void;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Attach signal forwarding from parent to child process.
|
|
126
|
+
* Signals sent to the parent will be forwarded to the child.
|
|
127
|
+
* Automatically detaches when child exits.
|
|
128
|
+
*
|
|
129
|
+
* @param child - The child process
|
|
130
|
+
* @param options - Bridge options
|
|
131
|
+
* @returns Object with detach function
|
|
132
|
+
*/
|
|
133
|
+
export declare function attachChildProcessBridge(child: ChildProcess, { signals, onSignal }?: ChildProcessBridgeOptions): {
|
|
134
|
+
detach: () => void;
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=processQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processQueue.d.ts","sourceRoot":"","sources":["../../utils/processQueue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,oBAAoB,CAAC;AASxE;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CA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AAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACxD,GACA,OAAO,CAAC,CAAC,CAAC,CAeZ;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,IAAI,CAAC,EAAE;IACL,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACxD,GACA,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,MAAyB,GAAG,MAAM,CAOpE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAM1C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,MAAyB,GAAG,MAAM,CASxE;AAMD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC;CAC7C,CAAC;AAOF;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,YAAY,EACnB,EAAE,OAAwB,EAAE,QAAQ,EAAE,GAAE,yBAA8B,GACrE;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CA8BxB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PTY Key Encoding - Terminal key sequence encoding utilities
|
|
3
|
+
* Ported from otto pty-keys.ts and pty-dsr.ts
|
|
4
|
+
*/
|
|
5
|
+
export declare const BRACKETED_PASTE_START = "\u001B[200~";
|
|
6
|
+
export declare const BRACKETED_PASTE_END = "\u001B[201~";
|
|
7
|
+
export type KeyEncodingRequest = {
|
|
8
|
+
keys?: string[];
|
|
9
|
+
hex?: string[];
|
|
10
|
+
literal?: string;
|
|
11
|
+
};
|
|
12
|
+
export type KeyEncodingResult = {
|
|
13
|
+
data: string;
|
|
14
|
+
warnings: string[];
|
|
15
|
+
};
|
|
16
|
+
export declare function encodeKeySequence(request: KeyEncodingRequest): KeyEncodingResult;
|
|
17
|
+
export declare function encodePaste(text: string, bracketed?: boolean): string;
|
|
18
|
+
export declare function stripDsrRequests(input: string): {
|
|
19
|
+
cleaned: string;
|
|
20
|
+
requests: number;
|
|
21
|
+
};
|
|
22
|
+
export declare function buildCursorPositionResponse(row?: number, col?: number): string;
|
|
23
|
+
//# sourceMappingURL=ptyKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ptyKeys.d.ts","sourceRoot":"","sources":["../../utils/ptyKeys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AACnD,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAyFjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CA0BhF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,MAAM,CAKlE;AAkKD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAOrF;AAED,wBAAgB,2BAA2B,CAAC,GAAG,SAAI,EAAE,GAAG,SAAI,GAAG,MAAM,CAEpE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell argument parsing utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides functions to split shell command strings into argument arrays,
|
|
5
|
+
* handling quotes and escape sequences.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/shellArgv
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Split a shell command string into an array of arguments.
|
|
11
|
+
*
|
|
12
|
+
* Handles:
|
|
13
|
+
* - Single quotes (literal strings)
|
|
14
|
+
* - Double quotes (literal strings)
|
|
15
|
+
* - Backslash escapes (outside quotes)
|
|
16
|
+
* - Whitespace as argument separator
|
|
17
|
+
*
|
|
18
|
+
* @param raw - The raw command string
|
|
19
|
+
* @returns Array of arguments, or null if string has unclosed quotes/escapes
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* splitShellArgs('git commit -m "fix bug"')
|
|
24
|
+
* // => ['git', 'commit', '-m', 'fix bug']
|
|
25
|
+
*
|
|
26
|
+
* splitShellArgs("echo 'hello world'")
|
|
27
|
+
* // => ['echo', 'hello world']
|
|
28
|
+
*
|
|
29
|
+
* splitShellArgs('path\\ with\\ spaces')
|
|
30
|
+
* // => ['path with spaces']
|
|
31
|
+
*
|
|
32
|
+
* splitShellArgs('"unclosed')
|
|
33
|
+
* // => null (unclosed quote)
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function splitShellArgs(raw: string): string[] | null;
|
|
37
|
+
//# sourceMappingURL=shellArgv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shellArgv.d.ts","sourceRoot":"","sources":["../../utils/shellArgv.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CA6D3D"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell Utilities - Platform-specific shell configuration and helpers
|
|
3
|
+
* Ported from otto shell-utils.ts and bash-tools.shared.ts
|
|
4
|
+
*/
|
|
5
|
+
import type { ChildProcess, ChildProcessWithoutNullStreams, SpawnOptions } from "node:child_process";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
/**
|
|
8
|
+
* Get shell configuration for the current platform
|
|
9
|
+
*/
|
|
10
|
+
export declare function getShellConfig(): {
|
|
11
|
+
shell: string;
|
|
12
|
+
args: string[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Sanitize binary output by removing control characters
|
|
16
|
+
*/
|
|
17
|
+
export declare function sanitizeBinaryOutput(text: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Kill a process tree (cross-platform)
|
|
20
|
+
*/
|
|
21
|
+
export declare function killProcessTree(pid: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Kill a session's process
|
|
24
|
+
*/
|
|
25
|
+
export declare function killSession(session: {
|
|
26
|
+
pid?: number;
|
|
27
|
+
child?: ChildProcessWithoutNullStreams;
|
|
28
|
+
}): void;
|
|
29
|
+
/**
|
|
30
|
+
* Coerce environment object to Record<string, string>
|
|
31
|
+
*/
|
|
32
|
+
export declare function coerceEnv(env?: NodeJS.ProcessEnv | Record<string, string>): Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve working directory with fallback
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveWorkdir(workdir: string, warnings: string[]): string;
|
|
37
|
+
/**
|
|
38
|
+
* Clamp a number to a range with a default value
|
|
39
|
+
*/
|
|
40
|
+
export declare function clampNumber(value: number | undefined, defaultValue: number, min: number, max: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* Read an environment variable as an integer
|
|
43
|
+
*/
|
|
44
|
+
export declare function readEnvInt(key: string): number | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Chunk a string into smaller pieces
|
|
47
|
+
*/
|
|
48
|
+
export declare function chunkString(input: string, limit?: number): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Safely slice a string respecting UTF-16 surrogate pairs
|
|
51
|
+
*/
|
|
52
|
+
export declare function sliceUtf16Safe(str: string, start: number, end?: number): string;
|
|
53
|
+
/**
|
|
54
|
+
* Truncate string in the middle with ellipsis
|
|
55
|
+
*/
|
|
56
|
+
export declare function truncateMiddle(str: string, max: number): string;
|
|
57
|
+
/**
|
|
58
|
+
* Slice log lines with optional offset and limit
|
|
59
|
+
*/
|
|
60
|
+
export declare function sliceLogLines(text: string, offset?: number, limit?: number): {
|
|
61
|
+
slice: string;
|
|
62
|
+
totalLines: number;
|
|
63
|
+
totalChars: number;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Derive a session name from a command
|
|
67
|
+
*/
|
|
68
|
+
export declare function deriveSessionName(command: string): string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Format duration in human-readable format
|
|
71
|
+
*/
|
|
72
|
+
export declare function formatDuration(ms: number): string;
|
|
73
|
+
/**
|
|
74
|
+
* Pad a string to a minimum width
|
|
75
|
+
*/
|
|
76
|
+
export declare function pad(str: string, width: number): string;
|
|
77
|
+
export type SpawnFallback = {
|
|
78
|
+
label: string;
|
|
79
|
+
options: SpawnOptions;
|
|
80
|
+
};
|
|
81
|
+
export type SpawnWithFallbackResult = {
|
|
82
|
+
child: ChildProcess;
|
|
83
|
+
usedFallback: boolean;
|
|
84
|
+
fallbackLabel?: string;
|
|
85
|
+
};
|
|
86
|
+
type SpawnWithFallbackParams = {
|
|
87
|
+
argv: string[];
|
|
88
|
+
options: SpawnOptions;
|
|
89
|
+
fallbacks?: SpawnFallback[];
|
|
90
|
+
spawnImpl?: typeof spawn;
|
|
91
|
+
retryCodes?: string[];
|
|
92
|
+
onFallback?: (err: unknown, fallback: SpawnFallback) => void;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Format a spawn error for display
|
|
96
|
+
*/
|
|
97
|
+
export declare function formatSpawnError(err: unknown): string;
|
|
98
|
+
/**
|
|
99
|
+
* Spawn a process with fallback options on certain error codes
|
|
100
|
+
*/
|
|
101
|
+
export declare function spawnWithFallback(params: SpawnWithFallbackParams): Promise<SpawnWithFallbackResult>;
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=shellUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shellUtils.d.ts","sourceRoot":"","sources":["../../utils/shellUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,8BAA8B,EAC9B,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAgD3C;;GAEG;AACH,wBAAgB,cAAc,IAAI;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CA0BlE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAsBjD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,8BAA8B,CAAC;CACxC,GAAG,IAAI,CAKP;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWxB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM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