@felan-ai/ext-codex 0.0.0
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/LICENSE +22 -0
- package/NOTICE +18 -0
- package/README.md +63 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +67 -0
- package/dist/config.js.map +1 -0
- package/dist/exec-session-manager.d.ts +34 -0
- package/dist/exec-session-manager.d.ts.map +1 -0
- package/dist/exec-session-manager.js +374 -0
- package/dist/exec-session-manager.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/model-policy.d.ts +5 -0
- package/dist/model-policy.d.ts.map +1 -0
- package/dist/model-policy.js +14 -0
- package/dist/model-policy.js.map +1 -0
- package/dist/patch.d.ts +15 -0
- package/dist/patch.d.ts.map +1 -0
- package/dist/patch.js +350 -0
- package/dist/patch.js.map +1 -0
- package/dist/request-options.d.ts +4 -0
- package/dist/request-options.d.ts.map +1 -0
- package/dist/request-options.js +15 -0
- package/dist/request-options.js.map +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +219 -0
- package/dist/tools.js.map +1 -0
- package/dist/transport.d.ts +6 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +29 -0
- package/dist/transport.js.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Felan contributors
|
|
4
|
+
Copyright (c) 2026 Umberto B.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@felan-ai/ext-codex
|
|
2
|
+
|
|
3
|
+
Includes selected code and behavior adapted from
|
|
4
|
+
@howaboua/pi-codex-conversion 3.0.8,
|
|
5
|
+
https://github.com/IgorWarzocha/howaboua-pi-stuff/tree/main/packages/pi-codex-conversion.
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 Umberto B.
|
|
8
|
+
Licensed under the MIT License included in this package.
|
|
9
|
+
|
|
10
|
+
Adapted portions include structured tool schemas and output conventions,
|
|
11
|
+
patch parsing and matching, model activation policy, OpenAI request options,
|
|
12
|
+
and cached WebSocket transport selection. Felan implements process and file
|
|
13
|
+
operations against AgentRuntime and uses Pi 0.84.0's native OpenAI Codex
|
|
14
|
+
transport for connection reuse and cached continuation.
|
|
15
|
+
|
|
16
|
+
This package uses TypeBox 1.1.38 from
|
|
17
|
+
https://github.com/sinclairzx81/typebox, licensed under the MIT License.
|
|
18
|
+
Copyright (c) 2017-2026 Haydn Paterson.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @felan-ai/ext-codex
|
|
2
|
+
|
|
3
|
+
First-party Felan support for the compact structured tool surface used by GPT
|
|
4
|
+
coding models. It activates only when the selected model ID is GPT-family and
|
|
5
|
+
the provider is exactly `openai` or `openai-codex`.
|
|
6
|
+
|
|
7
|
+
Active mode replaces `read`, `bash`, `edit`, and `write` with
|
|
8
|
+
`exec_command`, `write_stdin`, and `apply_patch`; image-capable models also get
|
|
9
|
+
`view_image`. Other Felan tools remain active. Switching to another model
|
|
10
|
+
restores the ordinary tools. All shell and filesystem operations use the
|
|
11
|
+
current `AgentRuntime`.
|
|
12
|
+
Runtimes without persistent-process support keep Felan's ordinary coding tools.
|
|
13
|
+
|
|
14
|
+
Optional settings live at `$FELAN_AGENT_DIR/codex.json`:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"fast": false,
|
|
19
|
+
"verbosity": "low",
|
|
20
|
+
"forceCachedWebSockets": true
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`fast` and `verbosity` modify eligible OpenAI Responses requests through a
|
|
25
|
+
session-scoped stream wrapper and the provider-request event. For the OpenAI
|
|
26
|
+
Codex provider, `forceCachedWebSockets` upgrades an explicit `websocket`
|
|
27
|
+
preference to Pi's native `websocket-cached` transport. Explicit `sse` and
|
|
28
|
+
`auto` remain unchanged. Pi owns connection reuse, SSE fallback, cached
|
|
29
|
+
continuation, and session cleanup. The extension does not register or replace
|
|
30
|
+
providers.
|
|
31
|
+
|
|
32
|
+
`view_image` is active only when the selected model declares image input. Raw
|
|
33
|
+
image reads are limited to 20 MiB, then Pi decodes and resizes supported images
|
|
34
|
+
to at most 2000×2000 with a base64 payload below 4 MiB. Malformed,
|
|
35
|
+
unsupported, and unresizable images are rejected.
|
|
36
|
+
|
|
37
|
+
`tty: true` allocates a real operating-system PTY through the runtime terminal
|
|
38
|
+
capability. `write_stdin` sends terminal input; for non-TTY sessions, the exact
|
|
39
|
+
Ctrl-C byte interrupts the process group and other input is rejected. Process
|
|
40
|
+
output is decoded incrementally and terminal control sequences are removed
|
|
41
|
+
before tool text is returned to the model.
|
|
42
|
+
|
|
43
|
+
Initial commands wait 250-30000 ms and default to 10000 ms; Windows uses a
|
|
44
|
+
10000 ms minimum. Non-empty `write_stdin` calls wait 250-30000 ms and default
|
|
45
|
+
to 250 ms; empty polls wait 5000-300000 ms and default to 5000 ms.
|
|
46
|
+
Interactions targeting one session are serialized. Cancelling a tool wait
|
|
47
|
+
leaves its process available for a later `write_stdin` call, while session
|
|
48
|
+
shutdown terminates all remaining processes. Sessions are in-memory and do
|
|
49
|
+
not survive application restart.
|
|
50
|
+
|
|
51
|
+
The extension excludes restart-durable jobs, web access, image generation,
|
|
52
|
+
Code Mode/Responses Lite, prompt replacement, compaction, voice, and UI
|
|
53
|
+
widgets.
|
|
54
|
+
|
|
55
|
+
## Development
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
pnpm --filter @felan-ai/ext-codex build
|
|
59
|
+
pnpm --filter @felan-ai/ext-codex type-check
|
|
60
|
+
pnpm --filter @felan-ai/ext-codex test
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
See [NOTICE](NOTICE) for upstream attribution.
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AgentRuntime } from '@felan-ai/agent-core';
|
|
2
|
+
export type CodexVerbosity = 'low' | 'medium' | 'high';
|
|
3
|
+
export interface CodexConfig {
|
|
4
|
+
readonly fast: boolean;
|
|
5
|
+
readonly verbosity: CodexVerbosity;
|
|
6
|
+
readonly forceCachedWebSockets: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const DEFAULT_CODEX_CONFIG: CodexConfig;
|
|
9
|
+
export declare function readCodexConfig(runtime: AgentRuntime, agentDir: string): Promise<CodexConfig>;
|
|
10
|
+
export declare function validateCodexConfig(value: unknown, source?: string): CodexConfig;
|
|
11
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEvD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;CACzC;AAED,eAAO,MAAM,oBAAoB,EAAE,WAIlC,CAAC;AAQF,wBAAsB,eAAe,CACnC,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAiBtB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,SAAe,GAAG,WAAW,CAyBtF"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const DEFAULT_CODEX_CONFIG = {
|
|
2
|
+
fast: false,
|
|
3
|
+
verbosity: 'low',
|
|
4
|
+
forceCachedWebSockets: true,
|
|
5
|
+
};
|
|
6
|
+
const CONFIG_FIELDS = new Set([
|
|
7
|
+
'fast',
|
|
8
|
+
'verbosity',
|
|
9
|
+
'forceCachedWebSockets',
|
|
10
|
+
]);
|
|
11
|
+
export async function readCodexConfig(runtime, agentDir) {
|
|
12
|
+
if (!runtime.readAgentFile)
|
|
13
|
+
return DEFAULT_CODEX_CONFIG;
|
|
14
|
+
let content;
|
|
15
|
+
try {
|
|
16
|
+
content = await runtime.readAgentFile('codex.json');
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (isMissingFile(error))
|
|
20
|
+
return DEFAULT_CODEX_CONFIG;
|
|
21
|
+
throw new Error(`Failed to read ${agentDir}/codex.json: ${errorMessage(error)}`, { cause: error });
|
|
22
|
+
}
|
|
23
|
+
let parsed;
|
|
24
|
+
try {
|
|
25
|
+
parsed = JSON.parse(new TextDecoder().decode(content));
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new Error(`Invalid ${agentDir}/codex.json: ${errorMessage(error)}`, { cause: error });
|
|
29
|
+
}
|
|
30
|
+
return validateCodexConfig(parsed, `${agentDir}/codex.json`);
|
|
31
|
+
}
|
|
32
|
+
export function validateCodexConfig(value, source = 'codex.json') {
|
|
33
|
+
if (!isRecord(value))
|
|
34
|
+
throw new Error(`${source} must contain a JSON object`);
|
|
35
|
+
for (const field of Object.keys(value)) {
|
|
36
|
+
if (!CONFIG_FIELDS.has(field))
|
|
37
|
+
throw new Error(`${source} contains unknown field: ${field}`);
|
|
38
|
+
}
|
|
39
|
+
if (value.fast !== undefined && typeof value.fast !== 'boolean') {
|
|
40
|
+
throw new Error(`${source}.fast must be a boolean`);
|
|
41
|
+
}
|
|
42
|
+
if (value.forceCachedWebSockets !== undefined && typeof value.forceCachedWebSockets !== 'boolean') {
|
|
43
|
+
throw new Error(`${source}.forceCachedWebSockets must be a boolean`);
|
|
44
|
+
}
|
|
45
|
+
if (value.verbosity !== undefined
|
|
46
|
+
&& value.verbosity !== 'low'
|
|
47
|
+
&& value.verbosity !== 'medium'
|
|
48
|
+
&& value.verbosity !== 'high') {
|
|
49
|
+
throw new Error(`${source}.verbosity must be low, medium, or high`);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
fast: value.fast ?? DEFAULT_CODEX_CONFIG.fast,
|
|
53
|
+
verbosity: value.verbosity ?? DEFAULT_CODEX_CONFIG.verbosity,
|
|
54
|
+
forceCachedWebSockets: value.forceCachedWebSockets
|
|
55
|
+
?? DEFAULT_CODEX_CONFIG.forceCachedWebSockets,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function isRecord(value) {
|
|
59
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
60
|
+
}
|
|
61
|
+
function isMissingFile(error) {
|
|
62
|
+
return error instanceof Error && 'code' in error && error.code === 'ENOENT';
|
|
63
|
+
}
|
|
64
|
+
function errorMessage(error) {
|
|
65
|
+
return error instanceof Error ? error.message : String(error);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,KAAK;IAChB,qBAAqB,EAAE,IAAI;CAC5B,CAAC;AAEF,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC;IACjD,MAAM;IACN,WAAW;IACX,uBAAuB;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAqB,EACrB,QAAgB;IAEhB,IAAI,CAAC,OAAO,CAAC,aAAa;QAAE,OAAO,oBAAoB,CAAC;IACxD,IAAI,OAAmB,CAAC;IACxB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,aAAa,CAAC,KAAK,CAAC;YAAE,OAAO,oBAAoB,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,kBAAkB,QAAQ,gBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACrG,CAAC;IAED,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC;IAAC,OAAO,K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,EAAE,KAAK,CAAC,IAAI,IAAI,oBAAoB,CAAC,IAAI;QAC7C,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,oBAAoB,CAAC,SAAS;QAC5D,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;eAC7C,oBAAoB,CAAC,qBAAqB;KAChD,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9E,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AgentRuntime } from '@felan-ai/agent-core';
|
|
2
|
+
export interface ExecCommandInput {
|
|
3
|
+
readonly cmd: string;
|
|
4
|
+
readonly workdir?: string;
|
|
5
|
+
readonly shell?: string;
|
|
6
|
+
readonly tty?: boolean;
|
|
7
|
+
readonly yield_time_ms?: number;
|
|
8
|
+
readonly max_output_tokens?: number;
|
|
9
|
+
readonly login?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface WriteStdinInput {
|
|
12
|
+
readonly session_id: number;
|
|
13
|
+
readonly chars?: string;
|
|
14
|
+
readonly yield_time_ms?: number;
|
|
15
|
+
readonly max_output_tokens?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface UnifiedExecResult {
|
|
18
|
+
readonly chunk_id: string;
|
|
19
|
+
readonly wall_time_seconds: number;
|
|
20
|
+
readonly output: string;
|
|
21
|
+
readonly exit_code?: number;
|
|
22
|
+
readonly session_id?: number;
|
|
23
|
+
readonly original_token_count?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare class ExecSessionManager {
|
|
26
|
+
#private;
|
|
27
|
+
private readonly runtime;
|
|
28
|
+
constructor(runtime: AgentRuntime);
|
|
29
|
+
exec(input: ExecCommandInput, signal?: AbortSignal, onUpdate?: (result: UnifiedExecResult) => void): Promise<UnifiedExecResult>;
|
|
30
|
+
write(input: WriteStdinInput, signal?: AbortSignal, onUpdate?: (result: UnifiedExecResult) => void): Promise<UnifiedExecResult>;
|
|
31
|
+
shutdown(): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export declare function formatExecResult(result: UnifiedExecResult): string;
|
|
34
|
+
//# sourceMappingURL=exec-session-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-session-manager.d.ts","sourceRoot":"","sources":["../src/exec-session-manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,sBAAsB,CAAC;AAE9E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACxC;AA0BD,qBAAa,kBAAkB;;IAIjB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY;IAE5C,IAAI,CACR,KAAK,EAAE,gBAAgB,EACvB,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAC7C,OAAO,CAAC,iBAAiB,CAAC;IAoDvB,KAAK,CACT,KAAK,EAAE,eAAe,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAC7C,OAAO,CAAC,iBAAiB,CAAC;IA0CvB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CA0HhC;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAalE"}
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { randomBytes, randomInt } from 'node:crypto';
|
|
2
|
+
const DEFAULT_EXEC_YIELD_MS = 10_000;
|
|
3
|
+
const DEFAULT_WRITE_YIELD_MS = 250;
|
|
4
|
+
const MIN_YIELD_MS = 250;
|
|
5
|
+
const MIN_EMPTY_POLL_YIELD_MS = 5_000;
|
|
6
|
+
const MAX_YIELD_MS = 30_000;
|
|
7
|
+
const MAX_EMPTY_POLL_YIELD_MS = 300_000;
|
|
8
|
+
const DEFAULT_MAX_OUTPUT_TOKENS = 10_000;
|
|
9
|
+
const MAX_RETAINED_OUTPUT_CHARS = 4 * 1024 * 1024;
|
|
10
|
+
const COMPLETED_HISTORY_LIMIT = 32;
|
|
11
|
+
const SESSION_ID_MIN = 1_000;
|
|
12
|
+
const SESSION_ID_MAX_EXCLUSIVE = 100_000;
|
|
13
|
+
export class ExecSessionManager {
|
|
14
|
+
runtime;
|
|
15
|
+
#sessions = new Map();
|
|
16
|
+
#completed = new Map();
|
|
17
|
+
constructor(runtime) {
|
|
18
|
+
this.runtime = runtime;
|
|
19
|
+
}
|
|
20
|
+
async exec(input, signal, onUpdate) {
|
|
21
|
+
const processes = this.runtime.processes;
|
|
22
|
+
if (!processes)
|
|
23
|
+
throw new Error('exec_command requires runtime process support');
|
|
24
|
+
if (signal?.aborted)
|
|
25
|
+
throw new Error('exec_command aborted');
|
|
26
|
+
const startedAt = Date.now();
|
|
27
|
+
const processOptions = {
|
|
28
|
+
...(input.workdir === undefined ? {} : { cwd: input.workdir }),
|
|
29
|
+
...(input.shell === undefined ? {} : { shell: input.shell }),
|
|
30
|
+
...(input.login === undefined ? {} : { login: input.login }),
|
|
31
|
+
};
|
|
32
|
+
const process = input.tty === true
|
|
33
|
+
? await this.#startTerminal(input.cmd, processOptions)
|
|
34
|
+
: await processes.startShell(input.cmd, processOptions);
|
|
35
|
+
const session = {
|
|
36
|
+
id: this.#allocateSessionId(),
|
|
37
|
+
process,
|
|
38
|
+
tty: input.tty === true,
|
|
39
|
+
decoder: new TextDecoder(),
|
|
40
|
+
sanitizer: new TerminalSanitizer(),
|
|
41
|
+
interactionTail: Promise.resolve(),
|
|
42
|
+
offset: 0,
|
|
43
|
+
pendingOutput: '',
|
|
44
|
+
pendingOriginalCharCount: 0,
|
|
45
|
+
};
|
|
46
|
+
this.#sessions.set(session.id, session);
|
|
47
|
+
try {
|
|
48
|
+
return await this.#withInteraction(session, async () => {
|
|
49
|
+
onUpdate?.(this.#emptyResult(session, startedAt));
|
|
50
|
+
const snapshot = await readFor(session, 0, execYield(input.yield_time_ms), input.max_output_tokens, signal);
|
|
51
|
+
session.offset = snapshot.nextOffset;
|
|
52
|
+
if (signal?.aborted) {
|
|
53
|
+
await this.#preserveAbortedRead(session, snapshot, startedAt);
|
|
54
|
+
throw new Error(`exec_command aborted; process continues as session ${session.id}`);
|
|
55
|
+
}
|
|
56
|
+
const result = this.#consumeRead(session, snapshot, startedAt, input.max_output_tokens);
|
|
57
|
+
if (!snapshot.running)
|
|
58
|
+
await this.#complete(session, result);
|
|
59
|
+
return result;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (signal?.aborted && !String(error).includes(`session ${session.id}`)) {
|
|
64
|
+
throw new Error(`exec_command aborted; process continues as session ${session.id}`, { cause: error });
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async write(input, signal, onUpdate) {
|
|
70
|
+
const session = this.#sessions.get(input.session_id);
|
|
71
|
+
if (!session) {
|
|
72
|
+
return this.#completedResult(input);
|
|
73
|
+
}
|
|
74
|
+
const startedAt = Date.now();
|
|
75
|
+
try {
|
|
76
|
+
return await this.#withInteraction(session, async () => {
|
|
77
|
+
if (this.#sessions.get(input.session_id) !== session)
|
|
78
|
+
return this.#completedResult(input);
|
|
79
|
+
const chars = input.chars ?? '';
|
|
80
|
+
if (chars) {
|
|
81
|
+
this.#validateInput(session, chars);
|
|
82
|
+
await this.#writeInput(session, chars);
|
|
83
|
+
}
|
|
84
|
+
if (signal?.aborted) {
|
|
85
|
+
throw new Error(`write_stdin aborted; session ${session.id} remains available`);
|
|
86
|
+
}
|
|
87
|
+
onUpdate?.(this.#emptyResult(session, startedAt));
|
|
88
|
+
const snapshot = await readFor(session, session.offset, writeYield(chars, input.yield_time_ms), input.max_output_tokens, signal);
|
|
89
|
+
session.offset = snapshot.nextOffset;
|
|
90
|
+
if (signal?.aborted) {
|
|
91
|
+
await this.#preserveAbortedRead(session, snapshot, startedAt);
|
|
92
|
+
throw new Error(`write_stdin aborted; session ${session.id} remains available`);
|
|
93
|
+
}
|
|
94
|
+
const result = this.#consumeRead(session, snapshot, startedAt, input.max_output_tokens);
|
|
95
|
+
if (!snapshot.running)
|
|
96
|
+
await this.#complete(session, result);
|
|
97
|
+
return result;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (signal?.aborted && !String(error).includes(`session ${session.id}`)) {
|
|
102
|
+
throw new Error(`write_stdin aborted; session ${session.id} remains available`, { cause: error });
|
|
103
|
+
}
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async shutdown() {
|
|
108
|
+
const sessions = [...this.#sessions.values()];
|
|
109
|
+
this.#sessions.clear();
|
|
110
|
+
this.#completed.clear();
|
|
111
|
+
await Promise.allSettled(sessions.map((session) => session.process.dispose()));
|
|
112
|
+
}
|
|
113
|
+
#emptyResult(session, startedAt) {
|
|
114
|
+
return {
|
|
115
|
+
chunk_id: chunkId(),
|
|
116
|
+
wall_time_seconds: (Date.now() - startedAt) / 1_000,
|
|
117
|
+
output: '',
|
|
118
|
+
session_id: session.id,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
async #complete(session, result) {
|
|
122
|
+
if (this.#sessions.get(session.id) === session)
|
|
123
|
+
this.#sessions.delete(session.id);
|
|
124
|
+
this.#completed.set(session.id, result);
|
|
125
|
+
while (this.#completed.size > COMPLETED_HISTORY_LIMIT) {
|
|
126
|
+
const oldest = this.#completed.keys().next().value;
|
|
127
|
+
if (oldest === undefined)
|
|
128
|
+
break;
|
|
129
|
+
this.#completed.delete(oldest);
|
|
130
|
+
}
|
|
131
|
+
await session.process.dispose();
|
|
132
|
+
}
|
|
133
|
+
async #startTerminal(command, options) {
|
|
134
|
+
if (!this.runtime.terminals) {
|
|
135
|
+
throw new Error('exec_command with tty=true requires runtime terminal support');
|
|
136
|
+
}
|
|
137
|
+
return this.runtime.terminals.startShell(command, options);
|
|
138
|
+
}
|
|
139
|
+
async #writeInput(session, chars) {
|
|
140
|
+
if (session.tty) {
|
|
141
|
+
await session.process.write(new TextEncoder().encode(chars));
|
|
142
|
+
await delay(100);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
await session.process.interrupt();
|
|
146
|
+
}
|
|
147
|
+
#validateInput(session, chars) {
|
|
148
|
+
if (session.tty)
|
|
149
|
+
return;
|
|
150
|
+
if (chars !== '\u0003') {
|
|
151
|
+
throw new Error('stdin is closed for this session; rerun exec_command with tty=true to keep stdin open');
|
|
152
|
+
}
|
|
153
|
+
if (!session.process.interrupt)
|
|
154
|
+
throw new Error('Runtime process interruption is unavailable');
|
|
155
|
+
}
|
|
156
|
+
#completedResult(input) {
|
|
157
|
+
const completed = this.#completed.get(input.session_id);
|
|
158
|
+
if (completed && !(input.chars ?? ''))
|
|
159
|
+
return truncateResult(completed, input.max_output_tokens);
|
|
160
|
+
if (completed)
|
|
161
|
+
throw new Error(`Process id ${input.session_id} already exited; cannot write stdin`);
|
|
162
|
+
throw new Error(`Unknown process id ${input.session_id}`);
|
|
163
|
+
}
|
|
164
|
+
#consumeRead(session, read, startedAt, maxOutputTokens) {
|
|
165
|
+
const output = `${session.pendingOutput}${read.output}`;
|
|
166
|
+
const originalCharCount = session.pendingOriginalCharCount + read.originalCharCount;
|
|
167
|
+
session.pendingOutput = '';
|
|
168
|
+
session.pendingOriginalCharCount = 0;
|
|
169
|
+
return resultFromRead(session, { ...read, output, originalCharCount }, startedAt, maxOutputTokens);
|
|
170
|
+
}
|
|
171
|
+
async #preserveAbortedRead(session, read, startedAt) {
|
|
172
|
+
const combined = `${session.pendingOutput}${read.output}`;
|
|
173
|
+
session.pendingOutput = tail(combined, MAX_RETAINED_OUTPUT_CHARS);
|
|
174
|
+
session.pendingOriginalCharCount += read.originalCharCount;
|
|
175
|
+
if (!read.running) {
|
|
176
|
+
const result = this.#consumeRead(session, { ...read, output: '', originalCharCount: 0 }, startedAt, MAX_RETAINED_OUTPUT_CHARS / 4);
|
|
177
|
+
await this.#complete(session, result);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async #withInteraction(session, operation) {
|
|
181
|
+
const previous = session.interactionTail;
|
|
182
|
+
let release;
|
|
183
|
+
const gate = new Promise((resolveGate) => { release = resolveGate; });
|
|
184
|
+
session.interactionTail = previous.then(() => gate);
|
|
185
|
+
try {
|
|
186
|
+
await previous;
|
|
187
|
+
return await operation();
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
release();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
#allocateSessionId() {
|
|
194
|
+
for (let attempt = 0; attempt < 1_000; attempt += 1) {
|
|
195
|
+
const id = randomInt(SESSION_ID_MIN, SESSION_ID_MAX_EXCLUSIVE);
|
|
196
|
+
if (!this.#sessions.has(id) && !this.#completed.has(id))
|
|
197
|
+
return id;
|
|
198
|
+
}
|
|
199
|
+
throw new Error('Unable to allocate a unified exec session id');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
export function formatExecResult(result) {
|
|
203
|
+
const sections = [];
|
|
204
|
+
sections.push(`Chunk ID: ${result.chunk_id}`);
|
|
205
|
+
sections.push(`Wall time: ${result.wall_time_seconds.toFixed(4)} seconds`);
|
|
206
|
+
if (result.exit_code !== undefined)
|
|
207
|
+
sections.push(`Process exited with code ${result.exit_code}`);
|
|
208
|
+
if (result.session_id !== undefined) {
|
|
209
|
+
sections.push(`Process running with session ID ${result.session_id}`);
|
|
210
|
+
}
|
|
211
|
+
if (result.original_token_count !== undefined) {
|
|
212
|
+
sections.push(`Original token count: ${result.original_token_count}`);
|
|
213
|
+
}
|
|
214
|
+
sections.push('Output:', result.output);
|
|
215
|
+
return sections.join('\n');
|
|
216
|
+
}
|
|
217
|
+
function resultFromRead(session, read, startedAt, maxOutputTokens) {
|
|
218
|
+
const truncated = truncateOutput(read.output, maxOutputTokens, read.originalCharCount);
|
|
219
|
+
return {
|
|
220
|
+
chunk_id: chunkId(),
|
|
221
|
+
wall_time_seconds: (Date.now() - startedAt) / 1_000,
|
|
222
|
+
...truncated,
|
|
223
|
+
...(read.running ? { session_id: session.id } : { exit_code: read.exitCode ?? 1 }),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
async function readFor(session, afterOffset, waitMs, maxOutputTokens, signal) {
|
|
227
|
+
const deadline = Date.now() + waitMs;
|
|
228
|
+
const maxChars = maxCharsForTokens(maxOutputTokens);
|
|
229
|
+
let output = '';
|
|
230
|
+
let originalCharCount = 0;
|
|
231
|
+
let offset = afterOffset;
|
|
232
|
+
let snapshot = await session.process.read(offset);
|
|
233
|
+
while (true) {
|
|
234
|
+
const decoded = session.decoder.decode(snapshot.output, { stream: snapshot.running });
|
|
235
|
+
const sanitized = session.sanitizer.write(decoded, !snapshot.running);
|
|
236
|
+
originalCharCount += sanitized.length;
|
|
237
|
+
output = tail(`${output}${sanitized}`, maxChars);
|
|
238
|
+
offset = snapshot.nextOffset;
|
|
239
|
+
if (!snapshot.running || signal?.aborted)
|
|
240
|
+
break;
|
|
241
|
+
const remaining = deadline - Date.now();
|
|
242
|
+
if (remaining <= 0)
|
|
243
|
+
break;
|
|
244
|
+
snapshot = await session.process.read(offset, {
|
|
245
|
+
waitMs: remaining,
|
|
246
|
+
...(signal === undefined ? {} : { signal }),
|
|
247
|
+
});
|
|
248
|
+
if (snapshot.output.length === 0 && snapshot.running)
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
output,
|
|
253
|
+
originalCharCount,
|
|
254
|
+
nextOffset: snapshot.nextOffset,
|
|
255
|
+
running: snapshot.running,
|
|
256
|
+
...(snapshot.exitCode === undefined ? {} : { exitCode: snapshot.exitCode }),
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function truncateResult(result, maxOutputTokens) {
|
|
260
|
+
const originalCharCount = result.original_token_count === undefined
|
|
261
|
+
? result.output.length
|
|
262
|
+
: result.original_token_count * 4;
|
|
263
|
+
return { ...result, ...truncateOutput(result.output, maxOutputTokens, originalCharCount) };
|
|
264
|
+
}
|
|
265
|
+
function truncateOutput(output, maxOutputTokens = DEFAULT_MAX_OUTPUT_TOKENS, originalCharCount = output.length) {
|
|
266
|
+
const maxChars = maxCharsForTokens(maxOutputTokens);
|
|
267
|
+
const originalTokenCount = Math.ceil(Math.max(output.length, originalCharCount) / 4);
|
|
268
|
+
if (output.length <= maxChars) {
|
|
269
|
+
return output || originalCharCount > 0
|
|
270
|
+
? { output, original_token_count: originalTokenCount }
|
|
271
|
+
: { output };
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
output: tail(output, maxChars),
|
|
275
|
+
original_token_count: originalTokenCount,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function maxCharsForTokens(maxOutputTokens = DEFAULT_MAX_OUTPUT_TOKENS) {
|
|
279
|
+
const requested = Number.isFinite(maxOutputTokens)
|
|
280
|
+
? Math.max(256, Math.floor(maxOutputTokens * 4))
|
|
281
|
+
: DEFAULT_MAX_OUTPUT_TOKENS * 4;
|
|
282
|
+
return Math.min(MAX_RETAINED_OUTPUT_CHARS, requested);
|
|
283
|
+
}
|
|
284
|
+
function tail(output, maxChars) {
|
|
285
|
+
let start = Math.max(0, output.length - maxChars);
|
|
286
|
+
if (start > 0 && /[\uDC00-\uDFFF]/u.test(output[start]))
|
|
287
|
+
start += 1;
|
|
288
|
+
return output.slice(start);
|
|
289
|
+
}
|
|
290
|
+
function execYield(value) {
|
|
291
|
+
const minimum = process.platform === 'win32' ? DEFAULT_EXEC_YIELD_MS : MIN_YIELD_MS;
|
|
292
|
+
return clampYield(value ?? DEFAULT_EXEC_YIELD_MS, minimum, MAX_YIELD_MS);
|
|
293
|
+
}
|
|
294
|
+
function writeYield(chars, value) {
|
|
295
|
+
const requested = value ?? DEFAULT_WRITE_YIELD_MS;
|
|
296
|
+
return chars
|
|
297
|
+
? clampYield(requested, MIN_YIELD_MS, MAX_YIELD_MS)
|
|
298
|
+
: clampYield(requested, MIN_EMPTY_POLL_YIELD_MS, MAX_EMPTY_POLL_YIELD_MS);
|
|
299
|
+
}
|
|
300
|
+
function clampYield(value, minimum, maximum) {
|
|
301
|
+
if (!Number.isFinite(value))
|
|
302
|
+
return minimum;
|
|
303
|
+
return Math.min(maximum, Math.max(minimum, Math.floor(value)));
|
|
304
|
+
}
|
|
305
|
+
function chunkId() {
|
|
306
|
+
return randomBytes(3).toString('hex');
|
|
307
|
+
}
|
|
308
|
+
function delay(ms) {
|
|
309
|
+
return new Promise((resolveDelay) => setTimeout(resolveDelay, ms));
|
|
310
|
+
}
|
|
311
|
+
class TerminalSanitizer {
|
|
312
|
+
#state = 'text';
|
|
313
|
+
write(input, final) {
|
|
314
|
+
let output = '';
|
|
315
|
+
for (const character of input) {
|
|
316
|
+
const code = character.codePointAt(0);
|
|
317
|
+
switch (this.#state) {
|
|
318
|
+
case 'text':
|
|
319
|
+
if (code === 0x1b)
|
|
320
|
+
this.#state = 'escape';
|
|
321
|
+
else if (code === 0x9b)
|
|
322
|
+
this.#state = 'csi';
|
|
323
|
+
else if (code === 0x9d)
|
|
324
|
+
this.#state = 'osc';
|
|
325
|
+
else if ([0x90, 0x98, 0x9e, 0x9f].includes(code))
|
|
326
|
+
this.#state = 'string';
|
|
327
|
+
else if (character === '\t' || character === '\n' || (code >= 0x20 && code !== 0x7f && !(code >= 0x80 && code <= 0x9f))) {
|
|
328
|
+
output += character;
|
|
329
|
+
}
|
|
330
|
+
break;
|
|
331
|
+
case 'escape':
|
|
332
|
+
if (character === '[')
|
|
333
|
+
this.#state = 'csi';
|
|
334
|
+
else if (character === ']')
|
|
335
|
+
this.#state = 'osc';
|
|
336
|
+
else if (character === 'P' || character === 'X' || character === '^' || character === '_')
|
|
337
|
+
this.#state = 'string';
|
|
338
|
+
else if (code >= 0x20 && code <= 0x2f)
|
|
339
|
+
this.#state = 'escape-intermediate';
|
|
340
|
+
else
|
|
341
|
+
this.#state = 'text';
|
|
342
|
+
break;
|
|
343
|
+
case 'escape-intermediate':
|
|
344
|
+
if (code >= 0x30 && code <= 0x7e)
|
|
345
|
+
this.#state = 'text';
|
|
346
|
+
break;
|
|
347
|
+
case 'csi':
|
|
348
|
+
if (code >= 0x40 && code <= 0x7e)
|
|
349
|
+
this.#state = 'text';
|
|
350
|
+
break;
|
|
351
|
+
case 'osc':
|
|
352
|
+
if (code === 0x07)
|
|
353
|
+
this.#state = 'text';
|
|
354
|
+
else if (code === 0x1b)
|
|
355
|
+
this.#state = 'osc-escape';
|
|
356
|
+
break;
|
|
357
|
+
case 'osc-escape':
|
|
358
|
+
this.#state = character === '\\' ? 'text' : 'osc';
|
|
359
|
+
break;
|
|
360
|
+
case 'string':
|
|
361
|
+
if (code === 0x1b)
|
|
362
|
+
this.#state = 'string-escape';
|
|
363
|
+
break;
|
|
364
|
+
case 'string-escape':
|
|
365
|
+
this.#state = character === '\\' ? 'text' : 'string';
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (final)
|
|
370
|
+
this.#state = 'text';
|
|
371
|
+
return output;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=exec-session-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-session-manager.js","sourceRoot":"","sources":["../src/exec-session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAyCrD,MAAM,qBAAqB,GAAG,MAAM,CAAC;AACrC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,uBAAuB,GAAG,KAAK,CAAC;AACtC,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,MAAM,uBAAuB,GAAG,OAAO,CAAC;AACxC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AACzC,MAAM,yBAAyB,GAA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,QAAQ;oBACX,IAAI,IAAI,KAAK,IAAI;wBAAE,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC;oBACjD,MAAM;gBACR,KAAK,eAAe;oBAClB,IAAI,CAAC,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;oBACrD,MAAM;YACV,CAAC;QACH,CAAC;QACD,IAAI,KAAK;YAAE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAChC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FelanExtension } from '@felan-ai/agent-core';
|
|
2
|
+
declare const codexExtension: FelanExtension;
|
|
3
|
+
export { DEFAULT_CODEX_CONFIG, readCodexConfig, validateCodexConfig } from './config.js';
|
|
4
|
+
export type { CodexConfig, CodexVerbosity } from './config.js';
|
|
5
|
+
export { ExecSessionManager, formatExecResult } from './exec-session-manager.js';
|
|
6
|
+
export type { ExecCommandInput, UnifiedExecResult, WriteStdinInput } from './exec-session-manager.js';
|
|
7
|
+
export { supportsCodexModel, supportsCodexResponsesRequest } from './model-policy.js';
|
|
8
|
+
export { applyCodexRequestOptions } from './request-options.js';
|
|
9
|
+
export { CODEX_TOOL_NAMES, MAX_VIEW_IMAGE_INPUT_BYTES, createCodexTools } from './tools.js';
|
|
10
|
+
export { createCodexStreamFunctionWrapper, resolveCodexStreamOptions, resolveCodexTransport, } from './transport.js';
|
|
11
|
+
export default codexExtension;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,sBAAsB,CAAC;AAU9B,QAAA,MAAM,cAAc,EAAE,cAgCrB,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACzF,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACjF,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,EACL,gCAAgC,EAChC,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,eAAe,cAAc,CAAC"}
|