@poncho-ai/cli 0.30.8 → 0.32.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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +28 -0
- package/dist/chunk-73C227HM.js +13462 -0
- package/dist/chunk-DK5P34JS.js +13643 -0
- package/dist/chunk-FHWZIOBN.js +13485 -0
- package/dist/chunk-UUMBWQCK.js +13458 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/run-interactive-ink-6KMR5BI2.js +2115 -0
- package/dist/run-interactive-ink-IF3TLLQB.js +2115 -0
- package/dist/run-interactive-ink-OKE5AV3N.js +2115 -0
- package/dist/run-interactive-ink-TQQ4KWVI.js +2115 -0
- package/package.json +4 -4
- package/src/auth-codex.ts +123 -0
- package/src/index.ts +656 -101
- package/src/init-onboarding.ts +38 -15
- package/src/web-ui-client.ts +106 -71
- package/test/auth-codex.test.ts +34 -0
- package/test/init-onboarding.contract.test.ts +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poncho-ai/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "CLI for building and deploying AI agents",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"react": "^19.2.4",
|
|
28
28
|
"react-devtools-core": "^6.1.5",
|
|
29
29
|
"yaml": "^2.8.1",
|
|
30
|
-
"@poncho-ai/harness": "0.
|
|
31
|
-
"@poncho-ai/
|
|
32
|
-
"@poncho-ai/
|
|
30
|
+
"@poncho-ai/harness": "0.31.0",
|
|
31
|
+
"@poncho-ai/messaging": "0.7.5",
|
|
32
|
+
"@poncho-ai/sdk": "1.7.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/busboy": "^1.5.4",
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
completeOpenAICodexDeviceAuth,
|
|
3
|
+
deleteOpenAICodexSession,
|
|
4
|
+
getOpenAICodexAccessToken,
|
|
5
|
+
getOpenAICodexAuthFilePath,
|
|
6
|
+
getOpenAICodexRequiredScopes,
|
|
7
|
+
readOpenAICodexSession,
|
|
8
|
+
startOpenAICodexDeviceAuth,
|
|
9
|
+
writeOpenAICodexSession,
|
|
10
|
+
} from "@poncho-ai/harness";
|
|
11
|
+
|
|
12
|
+
type ExportFormat = "env" | "json";
|
|
13
|
+
|
|
14
|
+
const getSource = async (): Promise<"env" | "file" | "none"> => {
|
|
15
|
+
if (process.env.OPENAI_CODEX_REFRESH_TOKEN) {
|
|
16
|
+
return "env";
|
|
17
|
+
}
|
|
18
|
+
const fileSession = await readOpenAICodexSession();
|
|
19
|
+
return fileSession ? "file" : "none";
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const loginOpenAICodex = async (options: { device?: boolean } = {}): Promise<void> => {
|
|
23
|
+
if (options.device === false) {
|
|
24
|
+
throw new Error("Only device auth flow is currently supported for openai-codex.");
|
|
25
|
+
}
|
|
26
|
+
const started = await startOpenAICodexDeviceAuth();
|
|
27
|
+
process.stdout.write(
|
|
28
|
+
`Open this URL in your browser: ${started.verificationUrl}\nEnter this code: ${started.userCode}\nWaiting for authorization...\n`,
|
|
29
|
+
);
|
|
30
|
+
const session = await completeOpenAICodexDeviceAuth(started);
|
|
31
|
+
await writeOpenAICodexSession(session);
|
|
32
|
+
process.stdout.write("OpenAI Codex login successful. Credentials saved to local auth store.\n");
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const statusOpenAICodex = async (): Promise<void> => {
|
|
36
|
+
const source = await getSource();
|
|
37
|
+
if (source === "none") {
|
|
38
|
+
process.stdout.write(
|
|
39
|
+
"No OpenAI Codex credentials found. Run `poncho auth login --provider openai-codex --device`.\n",
|
|
40
|
+
);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
process.stdout.write(`Credential source: ${source}\n`);
|
|
44
|
+
if (source === "file") {
|
|
45
|
+
process.stdout.write(`Auth file: ${getOpenAICodexAuthFilePath()}\n`);
|
|
46
|
+
}
|
|
47
|
+
process.stdout.write(`Required scopes: ${getOpenAICodexRequiredScopes().join(", ")}\n`);
|
|
48
|
+
try {
|
|
49
|
+
const token = await getOpenAICodexAccessToken();
|
|
50
|
+
process.stdout.write("Token status: valid\n");
|
|
51
|
+
if (token.accountId) {
|
|
52
|
+
process.stdout.write(`Account ID: ${token.accountId}\n`);
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
process.stdout.write(
|
|
56
|
+
`Token status: invalid (${error instanceof Error ? error.message : String(error)})\n`,
|
|
57
|
+
);
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const logoutOpenAICodex = async (): Promise<void> => {
|
|
63
|
+
await deleteOpenAICodexSession();
|
|
64
|
+
process.stdout.write("Removed local OpenAI Codex credentials.\n");
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const readExportableSession = async (): Promise<{
|
|
68
|
+
refreshToken: string;
|
|
69
|
+
accountId?: string;
|
|
70
|
+
accessToken?: string;
|
|
71
|
+
accessTokenExpiresAt?: number;
|
|
72
|
+
}> => {
|
|
73
|
+
if (process.env.OPENAI_CODEX_REFRESH_TOKEN) {
|
|
74
|
+
return {
|
|
75
|
+
refreshToken: process.env.OPENAI_CODEX_REFRESH_TOKEN,
|
|
76
|
+
accountId: process.env.OPENAI_CODEX_ACCOUNT_ID,
|
|
77
|
+
accessToken: process.env.OPENAI_CODEX_ACCESS_TOKEN,
|
|
78
|
+
accessTokenExpiresAt: process.env.OPENAI_CODEX_ACCESS_TOKEN_EXPIRES_AT
|
|
79
|
+
? Number.parseInt(process.env.OPENAI_CODEX_ACCESS_TOKEN_EXPIRES_AT, 10)
|
|
80
|
+
: undefined,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const session = await readOpenAICodexSession();
|
|
85
|
+
if (!session) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
"No OpenAI Codex credentials available to export. Run `poncho auth login --provider openai-codex --device` first.",
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
return session;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const exportOpenAICodex = async (format: ExportFormat): Promise<void> => {
|
|
94
|
+
const session = await readExportableSession();
|
|
95
|
+
if (format === "json") {
|
|
96
|
+
process.stdout.write(
|
|
97
|
+
`${JSON.stringify(
|
|
98
|
+
{
|
|
99
|
+
provider: "openai-codex",
|
|
100
|
+
refreshToken: session.refreshToken,
|
|
101
|
+
accountId: session.accountId ?? null,
|
|
102
|
+
accessToken: session.accessToken ?? null,
|
|
103
|
+
accessTokenExpiresAt: session.accessTokenExpiresAt ?? null,
|
|
104
|
+
},
|
|
105
|
+
null,
|
|
106
|
+
2,
|
|
107
|
+
)}\n`,
|
|
108
|
+
);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const lines = [
|
|
113
|
+
`OPENAI_CODEX_REFRESH_TOKEN=${session.refreshToken}`,
|
|
114
|
+
`OPENAI_CODEX_ACCOUNT_ID=${session.accountId ?? ""}`,
|
|
115
|
+
];
|
|
116
|
+
if (session.accessToken) {
|
|
117
|
+
lines.push(`OPENAI_CODEX_ACCESS_TOKEN=${session.accessToken}`);
|
|
118
|
+
}
|
|
119
|
+
if (session.accessTokenExpiresAt) {
|
|
120
|
+
lines.push(`OPENAI_CODEX_ACCESS_TOKEN_EXPIRES_AT=${session.accessTokenExpiresAt}`);
|
|
121
|
+
}
|
|
122
|
+
process.stdout.write(`${lines.join("\n")}\n`);
|
|
123
|
+
};
|