@standardagents/code 0.9.7 → 0.9.8
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/index.js +43 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7867,18 +7867,8 @@ ${c3.dim}Press Control-C again to exit${c3.reset}
|
|
|
7867
7867
|
selectedAgent = picked;
|
|
7868
7868
|
}
|
|
7869
7869
|
if (selectedAgent === OPENSAMA_AGENT_ID) {
|
|
7870
|
-
const
|
|
7871
|
-
|
|
7872
|
-
connecting.stop();
|
|
7873
|
-
if (!hasKey) {
|
|
7874
|
-
stdout.write(
|
|
7875
|
-
`${c3.yellow}Sama One needs your ChatGPT account connected first.${c3.reset}
|
|
7876
|
-
Opening ${c3.teal}https://standardcode.ai/app${c3.reset} \u2014 connect ChatGPT there, then run standardcode again.
|
|
7877
|
-
`
|
|
7878
|
-
);
|
|
7879
|
-
openUrl("https://standardcode.ai/app");
|
|
7880
|
-
process.exit(0);
|
|
7881
|
-
}
|
|
7870
|
+
const ok = await ensureSamaAuth(tui, api);
|
|
7871
|
+
if (!ok) process.exit(0);
|
|
7882
7872
|
}
|
|
7883
7873
|
const home = os7.homedir();
|
|
7884
7874
|
const tildeDir = projectDir.startsWith(home) ? "~" + projectDir.slice(home.length) : projectDir;
|
|
@@ -7985,6 +7975,45 @@ Opening ${c3.teal}https://standardcode.ai/app${c3.reset} \u2014 connect ChatGPT
|
|
|
7985
7975
|
function shortenPath(p, max = 38) {
|
|
7986
7976
|
return p.length > max ? "\u2026" + p.slice(-(max - 1)) : p;
|
|
7987
7977
|
}
|
|
7978
|
+
async function ensureSamaAuth(tui, api) {
|
|
7979
|
+
const checking = startLoader("Checking your ChatGPT connection");
|
|
7980
|
+
const already = await api.openSamaStatus().catch(() => false);
|
|
7981
|
+
checking.stop();
|
|
7982
|
+
if (already) return true;
|
|
7983
|
+
const picked = await tui.select(
|
|
7984
|
+
`${c3.bold}${gradientText("Authenticate with ChatGPT")}${c3.reset} ${c3.dim}Sama One runs on OpenAI using your own ChatGPT Pro account${c3.reset}`,
|
|
7985
|
+
[
|
|
7986
|
+
{
|
|
7987
|
+
label: "Continue with ChatGPT",
|
|
7988
|
+
hint: "connect once \u2014 unlocks your whole account",
|
|
7989
|
+
value: "continue"
|
|
7990
|
+
},
|
|
7991
|
+
{ label: "Not now", hint: "go back", value: "cancel" }
|
|
7992
|
+
]
|
|
7993
|
+
);
|
|
7994
|
+
if (picked !== "continue") return false;
|
|
7995
|
+
openUrl("https://standardcode.ai/app?connect=sama");
|
|
7996
|
+
tui.print(
|
|
7997
|
+
`${c3.dim}Finish connecting ChatGPT in the browser \u2014 waiting here for the authorization to land on your account\u2026${c3.reset}`
|
|
7998
|
+
);
|
|
7999
|
+
const waiting = startLoader("Waiting for your ChatGPT authorization");
|
|
8000
|
+
const deadline = Date.now() + 5 * 60 * 1e3;
|
|
8001
|
+
while (Date.now() < deadline) {
|
|
8002
|
+
await new Promise((r) => setTimeout(r, 3e3));
|
|
8003
|
+
if (await api.openSamaStatus().catch(() => false)) {
|
|
8004
|
+
waiting.stop();
|
|
8005
|
+
tui.print(
|
|
8006
|
+
`${c3.green}\u2713${c3.reset} ChatGPT connected \u2014 Sama One is now unlocked on your account (terminal, web, and macOS app).`
|
|
8007
|
+
);
|
|
8008
|
+
return true;
|
|
8009
|
+
}
|
|
8010
|
+
}
|
|
8011
|
+
waiting.stop();
|
|
8012
|
+
tui.print(
|
|
8013
|
+
`${c3.yellow}Still not connected.${c3.reset} Finish the flow at ${c3.teal}standardcode.ai/app${c3.reset} and pick Sama One again.`
|
|
8014
|
+
);
|
|
8015
|
+
return false;
|
|
8016
|
+
}
|
|
7988
8017
|
async function runAgentSwitchMenu(tui, api, threadId) {
|
|
7989
8018
|
const picked = await tui.select(
|
|
7990
8019
|
`${c3.bold}${gradientText("Switch agent")}${c3.reset} ${c3.dim}takes effect on the next message${c3.reset}`,
|
|
@@ -7997,14 +8026,8 @@ async function runAgentSwitchMenu(tui, api, threadId) {
|
|
|
7997
8026
|
);
|
|
7998
8027
|
if (!picked) return;
|
|
7999
8028
|
if (picked === OPENSAMA_AGENT_ID) {
|
|
8000
|
-
const
|
|
8001
|
-
if (!
|
|
8002
|
-
tui.print(
|
|
8003
|
-
`${c3.yellow}Sama One needs your ChatGPT account connected first \u2014 opening ${c3.teal}standardcode.ai/app${c3.reset}${c3.yellow}.${c3.reset}`
|
|
8004
|
-
);
|
|
8005
|
-
openUrl("https://standardcode.ai/app");
|
|
8006
|
-
return;
|
|
8007
|
-
}
|
|
8029
|
+
const ok = await ensureSamaAuth(tui, api);
|
|
8030
|
+
if (!ok) return;
|
|
8008
8031
|
}
|
|
8009
8032
|
const title = AGENT_CHOICES.find((choice) => choice.id === picked)?.title ?? picked;
|
|
8010
8033
|
try {
|