@flout/codex 0.4.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/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @flout/codex
2
+
3
+ Codex provider for [@flout/cli](../cli/). Implements the `Agent` interface with Codex-specific commands for authentication, project trust, local sessions, and remote-control sessions.
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ import codex from '@flout/codex';
9
+
10
+ codex.isAuthenticated(); // check login status
11
+ codex.remoteCommand('my-agent'); // get the remote-control command string
12
+ codex.encodePath('/home/dev'); // encode a path for compatibility with flout
13
+ ```
14
+
15
+ ## API
16
+
17
+ | Method | Description |
18
+ | --- | --- |
19
+ | `remoteCommand()` | Returns `codex remote-control start` |
20
+ | `startCommand()` | Returns `codex --dangerously-bypass-approvals-and-sandbox` |
21
+ | `loginCommand()` | Returns `codex login` |
22
+ | `isAuthenticated()` | Checks `codex login status` |
23
+ | `isTrusted(dir)` | Checks if directory is trusted in `~/.codex/config.toml` |
24
+ | `trustCommand()` | Returns `codex` |
25
+ | `encodePath(dir)` | Encodes paths in the same format as other flout agents |
@@ -0,0 +1,17 @@
1
+ export declare function encodePath(dir: string): string;
2
+ declare function isTrustedProject(config: string, dir: string): boolean;
3
+ declare const _default: {
4
+ name: string;
5
+ binary: string;
6
+ installHint: string;
7
+ remoteCommand(): string;
8
+ startCommand(): string;
9
+ loginCommand(): string;
10
+ isAuthenticated(): boolean;
11
+ isTrusted(dir: string): boolean;
12
+ trustCommand(): string;
13
+ encodePath: typeof encodePath;
14
+ };
15
+ export default _default;
16
+ export { isTrustedProject };
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAUD,iBAAS,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAY9D;;;;;qBAOkB,MAAM;oBAIP,MAAM;oBAIN,MAAM;uBAIH,OAAO;mBAKX,MAAM,GAAG,OAAO;oBAMf,MAAM;;;AA5BxB,wBAiCE;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { spawnSync } from 'child_process';
2
+ import fs from 'fs';
3
+ import os from 'os';
4
+ import path from 'path';
5
+ export function encodePath(dir) {
6
+ return '-' + path.resolve(dir).split('/').filter(Boolean).join('-');
7
+ }
8
+ function codexHome() {
9
+ return process.env.CODEX_HOME || path.join(os.homedir(), '.codex');
10
+ }
11
+ function tomlString(value) {
12
+ return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
13
+ }
14
+ function isTrustedProject(config, dir) {
15
+ const header = `[projects.${tomlString(path.resolve(dir))}]`;
16
+ const lines = config.split(/\r?\n/);
17
+ const start = lines.findIndex(line => line.trim() === header);
18
+ if (start === -1)
19
+ return false;
20
+ for (let i = start + 1; i < lines.length; i++) {
21
+ const line = lines[i].trim();
22
+ if (line.startsWith('['))
23
+ return false;
24
+ if (/^trust_level\s*=\s*["']trusted["']\s*$/.test(line))
25
+ return true;
26
+ }
27
+ return false;
28
+ }
29
+ export default {
30
+ name: 'codex',
31
+ binary: 'codex',
32
+ installHint: 'npm install -g @openai/codex',
33
+ remoteCommand() {
34
+ return 'codex remote-control start';
35
+ },
36
+ startCommand() {
37
+ return 'codex --dangerously-bypass-approvals-and-sandbox';
38
+ },
39
+ loginCommand() {
40
+ return 'codex login';
41
+ },
42
+ isAuthenticated() {
43
+ const result = spawnSync(this.binary, ['login', 'status']);
44
+ return result.status === 0;
45
+ },
46
+ isTrusted(dir) {
47
+ const configPath = path.join(codexHome(), 'config.toml');
48
+ if (!fs.existsSync(configPath))
49
+ return false;
50
+ return isTrustedProject(fs.readFileSync(configPath, 'utf8'), dir);
51
+ },
52
+ trustCommand() {
53
+ return 'codex';
54
+ },
55
+ encodePath,
56
+ };
57
+ export { isTrustedProject };
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC;AAClE,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc,EAAE,GAAW;IACnD,MAAM,MAAM,GAAG,aAAa,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;IAC7D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC,CAAC;IAC9D,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAE/B,KA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out/codex",
3
+ "version": "0.4.0",
4
+ "type": "module",
5
+ "description": "Codex agent adapter for flout",
6
+ "main": "dist/src/index.js",
7
+ "types": "dist/src/index.d.ts",
8
+ "files": [
9
+ "dist/src"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc --build",
13
+ "test": "node --test dist/test/*.test.js",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/bgrgicak/flout.git",
19
+ "directory": "packages/codex"
20
+ },
21
+ "homepage": "https://github.com/bgrgicak/flout",
22
+ "author": "Bero",
23
+ "keywords": [
24
+ "flout",
25
+ "codex",
26
+ "agent",
27
+ "adapter"
28
+ ],
29
+ "engines": {
30
+ "node": ">=20"
31
+ },
32
+ "license": "GPL-2.0-only",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ }
36
+ }