@awak-app/simy-cli 0.5.74 → 0.5.75
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/package.json +1 -1
- package/src/agent.js +15 -0
- package/src/cli-contract.js +1 -1
- package/src/desktop-host.js +8 -0
- package/src/desktop-status.js +1 -0
package/package.json
CHANGED
package/src/agent.js
CHANGED
|
@@ -2561,6 +2561,21 @@ export async function startAgent({
|
|
|
2561
2561
|
sqmLocalReviewWorker?.retry?.(); notifyDesktopStatusChange();
|
|
2562
2562
|
},
|
|
2563
2563
|
async retrySqmEnvironment() { await authorizeDesktopWork(); sqmLocalReviewWorker?.retry?.(); notifyDesktopStatusChange(); },
|
|
2564
|
+
async createDesktopWebSession() {
|
|
2565
|
+
const scope = await authorizeDesktopWork();
|
|
2566
|
+
const selected = session;
|
|
2567
|
+
if (!isSessionValid(selected, Date.now(), apiOrigin) || pendingOrganization) throw new Error("Desktop sign-in required");
|
|
2568
|
+
const response = await (dependencies.fetch || globalThis.fetch)(webApiUrl('desktop-web-session', { webOrigin: apiOrigin, apiBaseUrl: selected.api_base_url }), {
|
|
2569
|
+
method: 'POST', headers: webApiHeaders({ token: selected.token }), signal: AbortSignal.timeout(15_000), cache: 'no-store'
|
|
2570
|
+
});
|
|
2571
|
+
if (!response.ok) throw new Error("My AI sign-in is temporarily unavailable");
|
|
2572
|
+
const ticket = await response.json();
|
|
2573
|
+
await authorizeDesktopWork(scope);
|
|
2574
|
+
if (session !== selected || ticket.userId !== selected.account_id || ticket.orgSlug !== desktopAccess.snapshot().organizationSlug ||
|
|
2575
|
+
typeof ticket.code !== 'string' || ticket.code.length > 4096 || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(ticket.code) ||
|
|
2576
|
+
!Number.isFinite(ticket.expiresAt) || ticket.expiresAt <= Date.now() || ticket.expiresAt > Date.now() + 60_000) throw new Error("Desktop sign-in changed");
|
|
2577
|
+
return { code: ticket.code, expiresAt: ticket.expiresAt, userId: ticket.userId, orgSlug: ticket.orgSlug };
|
|
2578
|
+
},
|
|
2564
2579
|
getDesktopStatus,
|
|
2565
2580
|
getDesktopTask: async (key) => {
|
|
2566
2581
|
if (key?.startsWith("sqm:") || key?.startsWith("sqm-check:")) {
|
package/src/cli-contract.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./durable-local-task-steps-contract.js";
|
|
14
14
|
import { buildExecutionCapabilityContract } from "./execution-capability-contract.js";
|
|
15
15
|
|
|
16
|
-
export const CLI_VERSION = "0.5.
|
|
16
|
+
export const CLI_VERSION = "0.5.75";
|
|
17
17
|
export const CLI_API_CONTRACT_VERSION = 10;
|
|
18
18
|
|
|
19
19
|
export function withCliContract(
|
package/src/desktop-host.js
CHANGED
|
@@ -426,6 +426,14 @@ export async function startDesktopHost({ input = process.stdin, output = process
|
|
|
426
426
|
if (!desktopActionAllowed(access, command)) throw Object.assign(new Error('Desktop access is required.'), { code: 'desktop_access_required' });
|
|
427
427
|
if (desktopAccessReady(access) && !desktopActionAllowed({ state: 'unavailable' }, command)) await authorizeWork();
|
|
428
428
|
|
|
429
|
+
if (action === "my_ai_session") {
|
|
430
|
+
const ticket = await agent.createDesktopWebSession();
|
|
431
|
+
await authorizeWork(commandScope);
|
|
432
|
+
// One-use ticket goes only over the existing private host pipe, never status or disk.
|
|
433
|
+
emit({ ...ticket, type: "my_ai_session", id: command.id, requestNonce: String(command.requestNonce ?? "").slice(0, 64) });
|
|
434
|
+
emit({ type: "result", id: command.id, ok: true });
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
429
437
|
if (action === "task_detail") {
|
|
430
438
|
const task = await agent.getDesktopTask?.(command.taskKey);
|
|
431
439
|
await authorizeWork(commandScope);
|
package/src/desktop-status.js
CHANGED
|
@@ -67,6 +67,7 @@ export function desktopAuthStatus(session, { now = Date.now(), webOrigin = null
|
|
|
67
67
|
state: valid ? "signed_in" : exists ? "expired" : "signed_out",
|
|
68
68
|
expiresAt: typeof session?.expires_at === "string" ? session.expires_at : null,
|
|
69
69
|
userLabel: sessionUserLabel(session),
|
|
70
|
+
userId: valid ? (session.account_id ?? session.auth_user_id ?? null) : null,
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
|