@stigmer/cli 0.1.3 → 0.3.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/auth/browser.d.ts +7 -0
- package/auth/browser.d.ts.map +1 -0
- package/auth/browser.js +49 -0
- package/auth/browser.js.map +1 -0
- package/auth/callback-server.d.ts +8 -3
- package/auth/callback-server.d.ts.map +1 -1
- package/auth/callback-server.js +53 -19
- package/auth/callback-server.js.map +1 -1
- package/auth/device.d.ts +23 -0
- package/auth/device.d.ts.map +1 -0
- package/auth/device.js +119 -0
- package/auth/device.js.map +1 -0
- package/auth/index.d.ts +4 -3
- package/auth/index.d.ts.map +1 -1
- package/auth/index.js +4 -3
- package/auth/index.js.map +1 -1
- package/auth/login.d.ts +49 -1
- package/auth/login.d.ts.map +1 -1
- package/auth/login.js +161 -51
- package/auth/login.js.map +1 -1
- package/auth/oidc.d.ts +67 -0
- package/auth/oidc.d.ts.map +1 -0
- package/auth/oidc.js +213 -0
- package/auth/oidc.js.map +1 -0
- package/auth/token.d.ts +17 -23
- package/auth/token.d.ts.map +1 -1
- package/auth/token.js +51 -60
- package/auth/token.js.map +1 -1
- package/client/client.d.ts.map +1 -1
- package/client/client.js +4 -1
- package/client/client.js.map +1 -1
- package/client/current-organization.d.ts +5 -0
- package/client/current-organization.d.ts.map +1 -0
- package/client/current-organization.js +15 -0
- package/client/current-organization.js.map +1 -0
- package/commands/apikey/index.d.ts +16 -1
- package/commands/apikey/index.d.ts.map +1 -1
- package/commands/apikey/index.js +81 -0
- package/commands/apikey/index.js.map +1 -1
- package/commands/app-handover.d.ts +17 -0
- package/commands/app-handover.d.ts.map +1 -0
- package/commands/app-handover.js +168 -0
- package/commands/app-handover.js.map +1 -0
- package/commands/auth/index.d.ts.map +1 -1
- package/commands/auth/index.js +15 -9
- package/commands/auth/index.js.map +1 -1
- package/commands/auth/login.d.ts +7 -2
- package/commands/auth/login.d.ts.map +1 -1
- package/commands/auth/login.js +26 -23
- package/commands/auth/login.js.map +1 -1
- package/commands/auth/whoami.d.ts +15 -0
- package/commands/auth/whoami.d.ts.map +1 -1
- package/commands/auth/whoami.js +72 -2
- package/commands/auth/whoami.js.map +1 -1
- package/commands/coding-agent.d.ts +5 -0
- package/commands/coding-agent.d.ts.map +1 -0
- package/commands/coding-agent.js +30 -0
- package/commands/coding-agent.js.map +1 -0
- package/commands/config/backend.js +20 -6
- package/commands/config/backend.js.map +1 -1
- package/commands/docs/index.d.ts +9 -0
- package/commands/docs/index.d.ts.map +1 -0
- package/commands/docs/index.js +64 -0
- package/commands/docs/index.js.map +1 -0
- package/commands/embedding.d.ts +28 -0
- package/commands/embedding.d.ts.map +1 -0
- package/commands/embedding.js +170 -0
- package/commands/embedding.js.map +1 -0
- package/commands/example.d.ts +20 -0
- package/commands/example.d.ts.map +1 -0
- package/commands/example.js +136 -0
- package/commands/example.js.map +1 -0
- package/commands/help.d.ts.map +1 -1
- package/commands/help.js +19 -3
- package/commands/help.js.map +1 -1
- package/commands/list.d.ts.map +1 -1
- package/commands/list.js +13 -1
- package/commands/list.js.map +1 -1
- package/commands/load-test/burst.d.ts +64 -0
- package/commands/load-test/burst.d.ts.map +1 -0
- package/commands/load-test/burst.js +202 -0
- package/commands/load-test/burst.js.map +1 -0
- package/commands/load-test/index.d.ts +37 -0
- package/commands/load-test/index.d.ts.map +1 -0
- package/commands/load-test/index.js +154 -0
- package/commands/load-test/index.js.map +1 -0
- package/commands/load-test/report.d.ts +98 -0
- package/commands/load-test/report.d.ts.map +1 -0
- package/commands/load-test/report.js +210 -0
- package/commands/load-test/report.js.map +1 -0
- package/commands/mcp-server.d.ts +3 -3
- package/commands/mcp-server.d.ts.map +1 -1
- package/commands/mcp-server.js +16 -7
- package/commands/mcp-server.js.map +1 -1
- package/commands/provider-key/index.d.ts.map +1 -1
- package/commands/provider-key/index.js +2 -2
- package/commands/provider-key/index.js.map +1 -1
- package/commands/setup.d.ts +17 -0
- package/commands/setup.d.ts.map +1 -1
- package/commands/setup.js +71 -1
- package/commands/setup.js.map +1 -1
- package/commands/status.d.ts.map +1 -1
- package/commands/status.js +4 -3
- package/commands/status.js.map +1 -1
- package/commands/up.d.ts.map +1 -1
- package/commands/up.js +67 -9
- package/commands/up.js.map +1 -1
- package/commands/usage.d.ts +15 -0
- package/commands/usage.d.ts.map +1 -1
- package/commands/usage.js +52 -2
- package/commands/usage.js.map +1 -1
- package/config/config.d.ts +14 -7
- package/config/config.d.ts.map +1 -1
- package/config/config.js +5 -1
- package/config/config.js.map +1 -1
- package/config/index.d.ts +2 -2
- package/config/index.d.ts.map +1 -1
- package/config/index.js +2 -2
- package/config/index.js.map +1 -1
- package/config/resolve.d.ts +14 -3
- package/config/resolve.d.ts.map +1 -1
- package/config/resolve.js +30 -6
- package/config/resolve.js.map +1 -1
- package/errors/classify.d.ts.map +1 -1
- package/errors/classify.js +10 -1
- package/errors/classify.js.map +1 -1
- package/errors/cli-exit-error.d.ts +3 -1
- package/errors/cli-exit-error.d.ts.map +1 -1
- package/errors/cli-exit-error.js +6 -2
- package/errors/cli-exit-error.js.map +1 -1
- package/errors/handle.d.ts +32 -5
- package/errors/handle.d.ts.map +1 -1
- package/errors/handle.js +67 -8
- package/errors/handle.js.map +1 -1
- package/local/daemon/components.d.ts +28 -1
- package/local/daemon/components.d.ts.map +1 -1
- package/local/daemon/components.js +64 -2
- package/local/daemon/components.js.map +1 -1
- package/local/daemon/host.d.ts.map +1 -1
- package/local/daemon/host.js +6 -2
- package/local/daemon/host.js.map +1 -1
- package/local/daemon/launch.d.ts +12 -4
- package/local/daemon/launch.d.ts.map +1 -1
- package/local/daemon/launch.js +49 -16
- package/local/daemon/launch.js.map +1 -1
- package/local/daemon/types.d.ts +9 -1
- package/local/daemon/types.d.ts.map +1 -1
- package/local/key-check.d.ts +20 -0
- package/local/key-check.d.ts.map +1 -0
- package/local/key-check.js +45 -0
- package/local/key-check.js.map +1 -0
- package/local/model-key-step.d.ts +63 -0
- package/local/model-key-step.d.ts.map +1 -0
- package/local/model-key-step.js +133 -0
- package/local/model-key-step.js.map +1 -0
- package/local/runtime/node.d.ts +12 -4
- package/local/runtime/node.d.ts.map +1 -1
- package/local/runtime/node.js +73 -27
- package/local/runtime/node.js.map +1 -1
- package/local/setup/prompt.d.ts.map +1 -1
- package/local/setup/prompt.js +22 -18
- package/local/setup/prompt.js.map +1 -1
- package/local/setup/wizard.d.ts +10 -0
- package/local/setup/wizard.d.ts.map +1 -1
- package/local/setup/wizard.js +40 -17
- package/local/setup/wizard.js.map +1 -1
- package/local/state/lock.d.ts.map +1 -1
- package/local/state/lock.js +123 -36
- package/local/state/lock.js.map +1 -1
- package/local/state/pidfile.d.ts +4 -0
- package/local/state/pidfile.d.ts.map +1 -1
- package/local/state/pidfile.js +12 -3
- package/local/state/pidfile.js.map +1 -1
- package/local/status.d.ts.map +1 -1
- package/local/status.js +62 -4
- package/local/status.js.map +1 -1
- package/package.json +13 -10
- package/program.d.ts.map +1 -1
- package/program.js +12 -0
- package/program.js.map +1 -1
- package/resources/get.js +1 -1
- package/resources/get.js.map +1 -1
- package/resources/provider-key.d.ts +7 -2
- package/resources/provider-key.d.ts.map +1 -1
- package/resources/provider-key.js +18 -3
- package/resources/provider-key.js.map +1 -1
- package/resources/run/stream.d.ts.map +1 -1
- package/resources/run/stream.js +2 -1
- package/resources/run/stream.js.map +1 -1
- package/resources/runs.d.ts +10 -3
- package/resources/runs.d.ts.map +1 -1
- package/resources/runs.js +22 -4
- package/resources/runs.js.map +1 -1
- package/resources/stream/render-plaintext.d.ts +3 -0
- package/resources/stream/render-plaintext.d.ts.map +1 -1
- package/resources/stream/render-plaintext.js +20 -2
- package/resources/stream/render-plaintext.js.map +1 -1
- package/resources/usage.d.ts +8 -0
- package/resources/usage.d.ts.map +1 -1
- package/resources/usage.js +37 -0
- package/resources/usage.js.map +1 -1
- package/resources/views/agent.d.ts.map +1 -1
- package/resources/views/agent.js +18 -2
- package/resources/views/agent.js.map +1 -1
- package/runtime.d.ts +9 -0
- package/runtime.d.ts.map +1 -1
- package/runtime.js +12 -1
- package/runtime.js.map +1 -1
- package/src/auth/browser.ts +57 -0
- package/src/auth/callback-server.ts +58 -22
- package/src/auth/device.ts +151 -0
- package/src/auth/index.ts +4 -3
- package/src/auth/login.ts +243 -67
- package/src/auth/oidc.ts +270 -0
- package/src/auth/token.ts +53 -90
- package/src/client/client.ts +4 -1
- package/src/client/current-organization.ts +27 -0
- package/src/commands/apikey/index.ts +85 -0
- package/src/commands/app-handover.ts +202 -0
- package/src/commands/auth/index.ts +16 -10
- package/src/commands/auth/login.ts +30 -23
- package/src/commands/auth/whoami.ts +80 -1
- package/src/commands/coding-agent.ts +33 -0
- package/src/commands/config/backend.ts +20 -6
- package/src/commands/docs/index.ts +65 -0
- package/src/commands/embedding.ts +209 -0
- package/src/commands/example.ts +157 -0
- package/src/commands/help.ts +19 -3
- package/src/commands/list.ts +14 -1
- package/src/commands/load-test/burst.ts +291 -0
- package/src/commands/load-test/index.ts +183 -0
- package/src/commands/load-test/report.ts +302 -0
- package/src/commands/mcp-server.ts +16 -8
- package/src/commands/provider-key/index.ts +7 -1
- package/src/commands/setup.ts +76 -2
- package/src/commands/status.ts +4 -3
- package/src/commands/up.ts +76 -10
- package/src/commands/usage.ts +55 -2
- package/src/config/config.ts +18 -8
- package/src/config/index.ts +2 -0
- package/src/config/resolve.ts +31 -6
- package/src/errors/classify.ts +10 -1
- package/src/errors/cli-exit-error.ts +6 -2
- package/src/errors/handle.ts +74 -8
- package/src/local/daemon/components.ts +66 -2
- package/src/local/daemon/host.ts +6 -2
- package/src/local/daemon/launch.ts +51 -16
- package/src/local/daemon/types.ts +9 -1
- package/src/local/key-check.ts +61 -0
- package/src/local/model-key-step.ts +164 -0
- package/src/local/runtime/node.ts +95 -30
- package/src/local/setup/prompt.ts +22 -18
- package/src/local/setup/wizard.ts +45 -18
- package/src/local/state/lock.ts +116 -35
- package/src/local/state/pidfile.ts +14 -3
- package/src/local/status.ts +69 -4
- package/src/program.ts +12 -0
- package/src/resources/get.ts +1 -1
- package/src/resources/provider-key.ts +24 -3
- package/src/resources/run/stream.ts +2 -1
- package/src/resources/runs.ts +36 -4
- package/src/resources/stream/render-plaintext.ts +20 -2
- package/src/resources/usage.ts +42 -0
- package/src/resources/views/agent.ts +19 -2
- package/src/runtime.ts +17 -1
- package/auth/auth0.d.ts +0 -19
- package/auth/auth0.d.ts.map +0 -1
- package/auth/auth0.js +0 -39
- package/auth/auth0.js.map +0 -1
- package/src/auth/auth0.ts +0 -43
package/src/program.ts
CHANGED
|
@@ -30,6 +30,7 @@ import { registerGet } from "./commands/get.js";
|
|
|
30
30
|
import { registerInstall } from "./commands/install.js";
|
|
31
31
|
import { registerInternalDaemon } from "./commands/internal-daemon.js";
|
|
32
32
|
import { registerList } from "./commands/list.js";
|
|
33
|
+
import { registerLoadTest } from "./commands/load-test/index.js";
|
|
33
34
|
import { registerLogs } from "./commands/logs.js";
|
|
34
35
|
import { registerMarketplace } from "./commands/marketplace.js";
|
|
35
36
|
import { registerMcp } from "./commands/mcp.js";
|
|
@@ -52,6 +53,11 @@ import { registerUsage } from "./commands/usage.js";
|
|
|
52
53
|
import { registerValidate } from "./commands/validate.js";
|
|
53
54
|
import { registerVault } from "./commands/vault.js";
|
|
54
55
|
import { registerVersion } from "./commands/version.js";
|
|
56
|
+
import { registerDocs } from "./commands/docs/index.js";
|
|
57
|
+
import { registerAppHandover } from "./commands/app-handover.js";
|
|
58
|
+
import { registerCodingAgent } from "./commands/coding-agent.js";
|
|
59
|
+
import { registerEmbedding } from "./commands/embedding.js";
|
|
60
|
+
import { registerExample } from "./commands/example.js";
|
|
55
61
|
import { applyHelp } from "./commands/help.js";
|
|
56
62
|
import { setActionCommand, setDebug, setStandalone } from "./runtime.js";
|
|
57
63
|
import { commandPath } from "./command-tree.js";
|
|
@@ -88,6 +94,9 @@ export function buildProgram(): Command {
|
|
|
88
94
|
registerRun(program);
|
|
89
95
|
registerResume(program);
|
|
90
96
|
registerRuns(program);
|
|
97
|
+
registerAppHandover(program);
|
|
98
|
+
registerCodingAgent(program);
|
|
99
|
+
registerLoadTest(program);
|
|
91
100
|
// Your library
|
|
92
101
|
registerGet(program);
|
|
93
102
|
registerList(program);
|
|
@@ -102,6 +111,7 @@ export function buildProgram(): Command {
|
|
|
102
111
|
registerVault(program);
|
|
103
112
|
registerFile(program);
|
|
104
113
|
registerConnect(program);
|
|
114
|
+
registerExample(program);
|
|
105
115
|
// Packages
|
|
106
116
|
registerPush(program);
|
|
107
117
|
registerInstall(program);
|
|
@@ -121,6 +131,7 @@ export function buildProgram(): Command {
|
|
|
121
131
|
registerAuth(program);
|
|
122
132
|
registerApiKey(program);
|
|
123
133
|
registerServiceAccount(program);
|
|
134
|
+
registerEmbedding(program);
|
|
124
135
|
registerProviderKey(program);
|
|
125
136
|
registerAccessHistory(program);
|
|
126
137
|
registerUsage(program);
|
|
@@ -128,6 +139,7 @@ export function buildProgram(): Command {
|
|
|
128
139
|
registerConfig(program);
|
|
129
140
|
registerCompletion(program);
|
|
130
141
|
registerVersion(program);
|
|
142
|
+
registerDocs(program);
|
|
131
143
|
registerInternalDaemon(program);
|
|
132
144
|
|
|
133
145
|
// After registration, so every command is reached.
|
package/src/resources/get.ts
CHANGED
|
@@ -46,6 +46,6 @@ async function fetchOrganization(client: Stigmer, ref: ParsedReference): Promise
|
|
|
46
46
|
return { schema: OrganizationSchema, message: await client.organization.get(ref.slug) };
|
|
47
47
|
} catch (err) {
|
|
48
48
|
if (!cannotSeeOrganization(err)) throw err;
|
|
49
|
-
throw new CliExitError(`organization "${ref.slug}" not found`, ExitCode.NotFound);
|
|
49
|
+
throw new CliExitError(`organization "${ref.slug}" not found`, ExitCode.NotFound, undefined, { cause: err });
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -231,9 +231,19 @@ export function refuseKeyOnCommandLine(provider: Provider): never {
|
|
|
231
231
|
/**
|
|
232
232
|
* The key, read from stdin under `--key-stdin`, otherwise from a hidden
|
|
233
233
|
* prompt on a terminal. Off a terminal without `--key-stdin` there is no
|
|
234
|
-
* one to type it
|
|
234
|
+
* one to type it: a coding agent runs commands with no terminal, and a key
|
|
235
|
+
* typed into its chat would land in its transcript (stigmer#3229). So the
|
|
236
|
+
* refusal sends the person to the console's key page first, where the key
|
|
237
|
+
* goes from their browser to the server and is checked live, then says how
|
|
238
|
+
* to pipe it in. `consoleUrl` is the console's address when the CLI knows it
|
|
239
|
+
* for certain (`knownConsoleURL`); otherwise the page is named.
|
|
235
240
|
*/
|
|
236
|
-
export async function readProviderKey(
|
|
241
|
+
export async function readProviderKey(
|
|
242
|
+
provider: Provider,
|
|
243
|
+
keyStdin: boolean,
|
|
244
|
+
io: KeyIo,
|
|
245
|
+
consoleUrl: string | undefined,
|
|
246
|
+
): Promise<string> {
|
|
237
247
|
const name = providerDisplayName(provider);
|
|
238
248
|
let raw: string;
|
|
239
249
|
if (keyStdin) {
|
|
@@ -241,8 +251,12 @@ export async function readProviderKey(provider: Provider, keyStdin: boolean, io:
|
|
|
241
251
|
} else if (io.stdinIsTty) {
|
|
242
252
|
raw = await io.promptHidden(`${name} key`);
|
|
243
253
|
} else {
|
|
254
|
+
const consoleLine =
|
|
255
|
+
consoleUrl === undefined
|
|
256
|
+
? "Add it on the console's Models & providers page."
|
|
257
|
+
: `Add it in the console: ${withoutTrailingSlashes(consoleUrl)}/models`;
|
|
244
258
|
throw new UsageError(
|
|
245
|
-
`no terminal to type the ${name} key at\n\
|
|
259
|
+
`no terminal to type the ${name} key at\n\n${consoleLine}\nOr pipe it in: stigmer provider-key set ${provider} --key-stdin`,
|
|
246
260
|
);
|
|
247
261
|
}
|
|
248
262
|
const key = raw.trim();
|
|
@@ -250,6 +264,13 @@ export async function readProviderKey(provider: Provider, keyStdin: boolean, io:
|
|
|
250
264
|
return key;
|
|
251
265
|
}
|
|
252
266
|
|
|
267
|
+
/** `url` without trailing slashes, so a path joins it with one. */
|
|
268
|
+
function withoutTrailingSlashes(url: string): string {
|
|
269
|
+
let end = url.length;
|
|
270
|
+
while (end > 0 && url[end - 1] === "/") end--;
|
|
271
|
+
return url.slice(0, end);
|
|
272
|
+
}
|
|
273
|
+
|
|
253
274
|
/** Save the organization's key for `provider`, and say whether the provider confirmed it. */
|
|
254
275
|
export async function setProviderKey(
|
|
255
276
|
client: ProviderKeyClient,
|
|
@@ -138,7 +138,8 @@ async function runHeadless(deps: StreamDeps, renderer: HeadlessRenderer): Promis
|
|
|
138
138
|
|
|
139
139
|
try {
|
|
140
140
|
return await runHeadlessStream({
|
|
141
|
-
|
|
141
|
+
// Liveness for the one line a wait for a sandbox writes (render-plaintext.ts).
|
|
142
|
+
follow: (signal) => followSession(deps.client, deps.sessionId, { signal, previews: ["stigmer.run.liveness"] }),
|
|
142
143
|
answer: (toolUseId, answer) => submitAnswer(deps.client, deps.sessionId, toolUseId, answer),
|
|
143
144
|
approveDefault: deps.approveDefault,
|
|
144
145
|
renderer,
|
package/src/resources/runs.ts
CHANGED
|
@@ -12,12 +12,17 @@
|
|
|
12
12
|
import { create } from "@bufbuild/protobuf";
|
|
13
13
|
import { RunSchema, type Run } from "@stigmer/apis/ai/stigmer/agentic/run/v1/api_pb";
|
|
14
14
|
import { RunPhase } from "@stigmer/apis/ai/stigmer/agentic/run/v1/enum_pb";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
ListRunsByAgentRequestSchema,
|
|
17
|
+
ListRunsRequestSchema,
|
|
18
|
+
RunListSchema,
|
|
19
|
+
} from "@stigmer/apis/ai/stigmer/agentic/run/v1/io_pb";
|
|
16
20
|
import { InterruptSessionInputSchema } from "@stigmer/apis/ai/stigmer/agentic/session/v1/io_pb";
|
|
17
21
|
import { ApiResourceKind } from "@stigmer/apis/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
18
22
|
import type { Stigmer } from "@stigmer/client";
|
|
19
23
|
import type { OutputFormat } from "../output/index.js";
|
|
20
24
|
import { buildTypeInfo } from "../registry/index.js";
|
|
25
|
+
import { resolveAgent } from "./agent/resolve.js";
|
|
21
26
|
import { readCursorPages } from "./cursor-pages.js";
|
|
22
27
|
import type { ResourceResult } from "./get-bindings.js";
|
|
23
28
|
import { obj, renderListMessage, str, type TableShape } from "./render.js";
|
|
@@ -84,14 +89,14 @@ export async function getRun(client: Stigmer, id: string): Promise<ResourceResul
|
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
/**
|
|
87
|
-
* List the newest `limit` runs
|
|
88
|
-
*
|
|
92
|
+
* List the newest `limit` runs of the organization, reading as many pages as
|
|
93
|
+
* that takes.
|
|
89
94
|
*
|
|
90
95
|
* `org` scopes results to that organization; empty means permission-bounded
|
|
91
96
|
* (all orgs the caller can view — the OSS single-tenant behavior). `labels`
|
|
92
97
|
* keeps only the runs carrying every pair given.
|
|
93
98
|
*/
|
|
94
|
-
export async function
|
|
99
|
+
export async function listOrgRuns(
|
|
95
100
|
client: Stigmer,
|
|
96
101
|
limit: number,
|
|
97
102
|
org = "",
|
|
@@ -103,6 +108,33 @@ export async function listAgentRuns(
|
|
|
103
108
|
return { schema: RunListSchema, message: create(RunListSchema, { entries }) };
|
|
104
109
|
}
|
|
105
110
|
|
|
111
|
+
/** How `list runs --agent` says to set the organization a bare slug needs. */
|
|
112
|
+
const SET_ORG_WITH = [
|
|
113
|
+
"stigmer config context set --org <org>",
|
|
114
|
+
"stigmer --org <org> list runs --agent <agent>",
|
|
115
|
+
] as const;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* List the newest `limit` runs of one agent, across its conversations: the
|
|
119
|
+
* agent's last run is the first entry, whichever conversation took it.
|
|
120
|
+
* `agentRef` names the agent as `agent quality` does (an id, `org/slug`, or a
|
|
121
|
+
* slug in `org`); `labels` keeps only the runs carrying every pair given.
|
|
122
|
+
*/
|
|
123
|
+
export async function listRunsOfAgent(
|
|
124
|
+
client: Stigmer,
|
|
125
|
+
limit: number,
|
|
126
|
+
agentRef: string,
|
|
127
|
+
org: string,
|
|
128
|
+
labels: Record<string, string> = {},
|
|
129
|
+
): Promise<ResourceResult> {
|
|
130
|
+
const agent = await resolveAgent(client, agentRef, org, SET_ORG_WITH);
|
|
131
|
+
const agentId = agent.metadata?.id ?? "";
|
|
132
|
+
const entries = await readCursorPages(limit, (pageSize, pageToken) =>
|
|
133
|
+
client.run.listByAgent(create(ListRunsByAgentRequestSchema, { agentId, pageSize, pageToken, labels })),
|
|
134
|
+
);
|
|
135
|
+
return { schema: RunListSchema, message: create(RunListSchema, { entries }) };
|
|
136
|
+
}
|
|
137
|
+
|
|
106
138
|
const RUN_TABLE: TableShape = {
|
|
107
139
|
resourceName: "runs",
|
|
108
140
|
headers: ["ID", "AGENT", "STATUS", "STARTED"],
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
// console reads), a subagent's start and
|
|
10
10
|
// end with its tool uses indented beneath (its task call's line, once the
|
|
11
11
|
// call returns, carries its span: "✓ task (1m 4s)"), the platform's notes, a context
|
|
12
|
-
// compaction, the turn's errors,
|
|
12
|
+
// compaction, the turn's errors, how each ask was answered, and one line
|
|
13
|
+
// each time the turn starts waiting for a sandbox with room ("… Waiting
|
|
14
|
+
// for a sandbox", from the turn's liveness, which the stream asks for). No ANSI, no
|
|
13
15
|
// frames. Each fold is compared with the last by reference, so a turn no event
|
|
14
16
|
// touched is not walked again, and everything already written stays written.
|
|
15
17
|
|
|
16
|
-
import { backgroundEndingLine, extractShellIntent, formatElapsed, type SessionFold, type ToolUse, type Turn, type TurnItem } from "@stigmer/client";
|
|
18
|
+
import { backgroundEndingLine, extractShellIntent, formatElapsed, SANDBOX_WAIT_PHRASE, type SessionFold, type ToolUse, type Turn, type TurnItem } from "@stigmer/client";
|
|
17
19
|
import { answerWord, type ApproveDefault, type AskAnswer } from "./answer.js";
|
|
18
20
|
import type { HeadlessRenderer } from "./headless.js";
|
|
19
21
|
import type { LineWriter } from "./render-ndjson.js";
|
|
@@ -34,6 +36,8 @@ export class PlaintextRenderer implements HeadlessRenderer {
|
|
|
34
36
|
private readonly toolStates = new Map<string, string>();
|
|
35
37
|
private readonly backgroundStates = new Map<string, string>();
|
|
36
38
|
private readonly threadStates = new Map<string, string>();
|
|
39
|
+
/** The runs whose turn waits for a sandbox now, so a wait's line is written once, at its start. */
|
|
40
|
+
private readonly waitingForSandbox = new Set<string>();
|
|
37
41
|
|
|
38
42
|
constructor(private readonly opts: PlaintextRendererOptions) {}
|
|
39
43
|
|
|
@@ -57,12 +61,26 @@ export class PlaintextRenderer implements HeadlessRenderer {
|
|
|
57
61
|
if (message !== undefined && this.once(message.id)) {
|
|
58
62
|
this.opts.status.write(`\n> ${message.text}\n\n`);
|
|
59
63
|
}
|
|
64
|
+
this.renderSandboxWait(turn);
|
|
60
65
|
this.renderItems(turn.items, "", true);
|
|
61
66
|
for (const error of turn.errors) {
|
|
62
67
|
if (this.once(error.id)) this.opts.status.write(` ✗ ${error.message}\n`);
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
|
|
71
|
+
// A wait for a sandbox is said once when it starts; a later wait of the
|
|
72
|
+
// same turn (after a pause, or run again) is said again.
|
|
73
|
+
private renderSandboxWait(turn: Turn): void {
|
|
74
|
+
const waiting = !turn.ended && turn.liveness?.awaitingSandboxMs !== undefined;
|
|
75
|
+
if (!waiting) {
|
|
76
|
+
this.waitingForSandbox.delete(turn.runId);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (this.waitingForSandbox.has(turn.runId)) return;
|
|
80
|
+
this.waitingForSandbox.add(turn.runId);
|
|
81
|
+
this.opts.status.write(` … ${SANDBOX_WAIT_PHRASE}\n`);
|
|
82
|
+
}
|
|
83
|
+
|
|
66
84
|
// The primary thread's messages are the answer and go to stdout; a
|
|
67
85
|
// subagent's are its own working and are left out (its reply reaches the
|
|
68
86
|
// agent, which answers in its own words).
|
package/src/resources/usage.ts
CHANGED
|
@@ -46,6 +46,11 @@ import {
|
|
|
46
46
|
type AgentHours,
|
|
47
47
|
} from "@stigmer/apis/ai/stigmer/billing/subscription/v1/io_pb";
|
|
48
48
|
import type { Stigmer } from "@stigmer/client";
|
|
49
|
+
import {
|
|
50
|
+
GetOnboardingFunnelOutputSchema,
|
|
51
|
+
type GetOnboardingFunnelOutput,
|
|
52
|
+
} from "@stigmer/apis/ai/stigmer/platform/v1/onboarding_funnel_pb";
|
|
53
|
+
import { OnboardingStepId } from "@stigmer/apis/ai/stigmer/tenancy/organization/v1/onboarding_pb";
|
|
49
54
|
import type { OutputFormat } from "../output/index.js";
|
|
50
55
|
import { renderProtoJson, renderProtoYaml, renderTable, terminalWidth, type TerminalStream } from "../output/index.js";
|
|
51
56
|
import { formatTokenCount } from "./run-format.js";
|
|
@@ -83,6 +88,10 @@ export async function getOrgUsageReport(
|
|
|
83
88
|
);
|
|
84
89
|
}
|
|
85
90
|
|
|
91
|
+
export async function getOnboardingFunnel(client: Stigmer, range: DateRange): Promise<GetOnboardingFunnelOutput> {
|
|
92
|
+
return client.platform.getOnboardingFunnel(range);
|
|
93
|
+
}
|
|
94
|
+
|
|
86
95
|
export async function getAgentHours(client: Stigmer, org: string): Promise<AgentHours> {
|
|
87
96
|
return client.subscription.getAgentHours(create(GetAgentHoursInputSchema, { org }));
|
|
88
97
|
}
|
|
@@ -445,3 +454,36 @@ function mapPhaseToString(phase: RunPhase): string {
|
|
|
445
454
|
return "unknown";
|
|
446
455
|
}
|
|
447
456
|
}
|
|
457
|
+
|
|
458
|
+
/** Each step's name in the onboarding count, as the console's card words it. */
|
|
459
|
+
const ONBOARDING_STEP_WORDS: Readonly<Record<number, string>> = {
|
|
460
|
+
[OnboardingStepId.describe]: "Said what it should do",
|
|
461
|
+
[OnboardingStepId.key]: "Added a model key",
|
|
462
|
+
[OnboardingStepId.watch]: "Watched it work",
|
|
463
|
+
[OnboardingStepId.make_yours]: "Made it theirs",
|
|
464
|
+
[OnboardingStepId.in_app]: "Put it in their app",
|
|
465
|
+
[OnboardingStepId.others]: "Brought others in",
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* The onboarding count: how many new organizations were counted, how many
|
|
470
|
+
* were the operator's own, and how many reached each step, with its share
|
|
471
|
+
* of those counted. json and yaml are protojson.
|
|
472
|
+
*/
|
|
473
|
+
export function renderOnboardingFunnel(funnel: GetOnboardingFunnelOutput, range: DateRange, format: OutputFormat): string {
|
|
474
|
+
if (format === "json") return renderProtoJson(GetOnboardingFunnelOutputSchema, funnel);
|
|
475
|
+
if (format === "yaml") return renderProtoYaml(GetOnboardingFunnelOutputSchema, funnel);
|
|
476
|
+
|
|
477
|
+
const lines: string[] = ["", "Onboarding", `Period: ${formatInputDateRange(range.from, range.to)}`, ""];
|
|
478
|
+
const own = funnel.excluded === 0 ? "" : ` (${funnel.excluded} made by your own team left out)`;
|
|
479
|
+
lines.push(` New organizations: ${funnel.organizations}${own}`, "");
|
|
480
|
+
if (funnel.organizations > 0) {
|
|
481
|
+
const rows = funnel.steps.map((step, index) => [
|
|
482
|
+
`${index + 1} ${ONBOARDING_STEP_WORDS[step.id] ?? OnboardingStepId[step.id] ?? String(step.id)}`,
|
|
483
|
+
String(step.reached),
|
|
484
|
+
`${Math.round((step.reached / funnel.organizations) * 100)}%`,
|
|
485
|
+
]);
|
|
486
|
+
lines.push(renderTable(["STEP", "REACHED", "SHARE"], rows), "");
|
|
487
|
+
}
|
|
488
|
+
return lines.join("\n");
|
|
489
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// `get agent`: what an agent is made of, as a person reads it. Its
|
|
2
2
|
// description and when it last changed; the start of its instructions; the
|
|
3
|
-
// skills, MCP servers, tools, subagents and plugins it works with;
|
|
4
|
-
//
|
|
3
|
+
// skills, MCP servers, tools, subagents and plugins it works with; whether
|
|
4
|
+
// its conversations have a computer, the Environment they run in and the
|
|
5
|
+
// values it declares; the
|
|
5
6
|
// settings a run starts from. Everything comes from the agent itself
|
|
6
7
|
// (apis/ai/stigmer/agentic/agent/v1/spec.proto); `-o yaml` prints it whole.
|
|
7
8
|
|
|
@@ -33,6 +34,7 @@ export const agentView: KindView = {
|
|
|
33
34
|
{
|
|
34
35
|
title: "Environment",
|
|
35
36
|
fields: [
|
|
37
|
+
["Computer", computerWord(spec.computer)],
|
|
36
38
|
["Sandbox", refLabel(obj(spec, "environment_ref"), metadata, ctx)],
|
|
37
39
|
["Values", declaredValues(spec.env)],
|
|
38
40
|
],
|
|
@@ -42,6 +44,21 @@ export const agentView: KindView = {
|
|
|
42
44
|
},
|
|
43
45
|
};
|
|
44
46
|
|
|
47
|
+
// Whether the agent's conversations have a computer, as the agent records
|
|
48
|
+
// it. Only COMPUTER_NONE means none (session/v1/enum.proto, Computer); an
|
|
49
|
+
// agent saved before the setting records nothing, and the row is left out
|
|
50
|
+
// as every view leaves out what a resource does not carry.
|
|
51
|
+
function computerWord(computer: JsonValue | undefined): string | undefined {
|
|
52
|
+
switch (computer) {
|
|
53
|
+
case "COMPUTER_NONE":
|
|
54
|
+
return "no";
|
|
55
|
+
case "COMPUTER_REQUIRED":
|
|
56
|
+
return "yes";
|
|
57
|
+
default:
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
45
62
|
// The values an agent declares, by name, each marked secret or optional
|
|
46
63
|
// where it is ("GITHUB_TOKEN (secret), REGION (optional)"). A plain value's
|
|
47
64
|
// content is the agent's own setting, and `-o yaml` shows it.
|
package/src/runtime.ts
CHANGED
|
@@ -5,13 +5,19 @@
|
|
|
5
5
|
// Two records are written later, by the command itself, so an error can
|
|
6
6
|
// name what was actually tried: the server address the backend client
|
|
7
7
|
// dials (and where that address came from), recorded when the client is
|
|
8
|
-
// made, and the resource type a get, delete or download resolved.
|
|
8
|
+
// made, and the resource type a get, delete or download resolved. The
|
|
9
|
+
// client also records how to ask its server where to get help, so a
|
|
10
|
+
// failure the server answered can end with the server's help line.
|
|
9
11
|
|
|
10
12
|
let debug = false;
|
|
11
13
|
let standalone = false;
|
|
12
14
|
let actionCommand = "";
|
|
13
15
|
let serverAddress: ServerAddress | undefined;
|
|
14
16
|
let resourceType = "";
|
|
17
|
+
let helpProbe: HelpProbe | undefined;
|
|
18
|
+
|
|
19
|
+
/** Asks the dialled server where to get help (its `getServerInfo`'s `help`), sharing the client's one probe. */
|
|
20
|
+
export type HelpProbe = () => Promise<{ readonly url: string; readonly label: string } | undefined>;
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* Where the address the backend client dials came from: the active
|
|
@@ -70,3 +76,13 @@ export function setActionResourceType(type: string): void {
|
|
|
70
76
|
export function actionResourceType(): string {
|
|
71
77
|
return resourceType;
|
|
72
78
|
}
|
|
79
|
+
|
|
80
|
+
/** Record how to ask the dialled server for its help link; undefined forgets it (tests). */
|
|
81
|
+
export function setServerHelpProbe(probe: HelpProbe | undefined): void {
|
|
82
|
+
helpProbe = probe;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** How to ask the dialled server for its help link; undefined when no client was made. */
|
|
86
|
+
export function serverHelpProbe(): HelpProbe | undefined {
|
|
87
|
+
return helpProbe;
|
|
88
|
+
}
|
package/auth/auth0.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const AUTH0_DOMAIN = "https://stigmer-prod.us.auth0.com";
|
|
2
|
-
export declare const CLIENT_ID = "kIT6URf4HKn6YzrQVVFTFN63BrSJdTPM";
|
|
3
|
-
export declare const AUDIENCE = "https://api.stigmer.com/";
|
|
4
|
-
export declare const CALLBACK_PORT = 8088;
|
|
5
|
-
export declare const CALLBACK_PATH = "/auth/callback";
|
|
6
|
-
export declare const AUTHORIZE_URL = "https://stigmer-prod.us.auth0.com/authorize";
|
|
7
|
-
export declare const TOKEN_URL = "https://stigmer-prod.us.auth0.com/oauth/token";
|
|
8
|
-
/** The loopback redirect URI Auth0 calls back with the authorization code. */
|
|
9
|
-
export declare function callbackUrl(): string;
|
|
10
|
-
/**
|
|
11
|
-
* Build the Auth0 /authorize URL for the PKCE authorization-code flow.
|
|
12
|
-
* `prompt=login` forces the login page even with an active session, enabling
|
|
13
|
-
* account switching.
|
|
14
|
-
*/
|
|
15
|
-
export declare function buildAuthorizeUrl(params: {
|
|
16
|
-
state: string;
|
|
17
|
-
codeChallenge: string;
|
|
18
|
-
}): string;
|
|
19
|
-
//# sourceMappingURL=auth0.d.ts.map
|
package/auth/auth0.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth0.d.ts","sourceRoot":"","sources":["../src/auth/auth0.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,sCAAsC,CAAC;AAChE,eAAO,MAAM,SAAS,qCAAqC,CAAC;AAC5D,eAAO,MAAM,QAAQ,6BAA6B,CAAC;AACnD,eAAO,MAAM,aAAa,OAAO,CAAC;AAClC,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAI9C,eAAO,MAAM,aAAa,gDAA8B,CAAC;AACzD,eAAO,MAAM,SAAS,kDAAgC,CAAC;AAEvD,8EAA8E;AAC9E,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAY1F"}
|
package/auth/auth0.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Auth0 PKCE configuration for Stigmer Cloud.
|
|
2
|
-
//
|
|
3
|
-
// These values are public metadata for a Native/PKCE application — they are NOT
|
|
4
|
-
// secrets. An Auth0 client ID is a public identifier (like a username, not a
|
|
5
|
-
// password), and PKCE removes the need for a client secret entirely. The
|
|
6
|
-
// authorize/token endpoints are hardcoded because Auth0's URL structure is
|
|
7
|
-
// stable ({domain}/authorize, {domain}/oauth/token), saving an OIDC-discovery
|
|
8
|
-
// round-trip at login time.
|
|
9
|
-
export const AUTH0_DOMAIN = "https://stigmer-prod.us.auth0.com";
|
|
10
|
-
export const CLIENT_ID = "kIT6URf4HKn6YzrQVVFTFN63BrSJdTPM";
|
|
11
|
-
export const AUDIENCE = "https://api.stigmer.com/";
|
|
12
|
-
export const CALLBACK_PORT = 8088;
|
|
13
|
-
export const CALLBACK_PATH = "/auth/callback";
|
|
14
|
-
const SCOPES = ["openid", "profile", "email", "offline_access"];
|
|
15
|
-
export const AUTHORIZE_URL = `${AUTH0_DOMAIN}/authorize`;
|
|
16
|
-
export const TOKEN_URL = `${AUTH0_DOMAIN}/oauth/token`;
|
|
17
|
-
/** The loopback redirect URI Auth0 calls back with the authorization code. */
|
|
18
|
-
export function callbackUrl() {
|
|
19
|
-
return `http://localhost:${CALLBACK_PORT}${CALLBACK_PATH}`;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Build the Auth0 /authorize URL for the PKCE authorization-code flow.
|
|
23
|
-
* `prompt=login` forces the login page even with an active session, enabling
|
|
24
|
-
* account switching.
|
|
25
|
-
*/
|
|
26
|
-
export function buildAuthorizeUrl(params) {
|
|
27
|
-
const url = new URL(AUTHORIZE_URL);
|
|
28
|
-
url.searchParams.set("response_type", "code");
|
|
29
|
-
url.searchParams.set("client_id", CLIENT_ID);
|
|
30
|
-
url.searchParams.set("redirect_uri", callbackUrl());
|
|
31
|
-
url.searchParams.set("scope", SCOPES.join(" "));
|
|
32
|
-
url.searchParams.set("audience", AUDIENCE);
|
|
33
|
-
url.searchParams.set("state", params.state);
|
|
34
|
-
url.searchParams.set("code_challenge", params.codeChallenge);
|
|
35
|
-
url.searchParams.set("code_challenge_method", "S256");
|
|
36
|
-
url.searchParams.set("prompt", "login");
|
|
37
|
-
return url.toString();
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=auth0.js.map
|
package/auth/auth0.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth0.js","sourceRoot":"","sources":["../src/auth/auth0.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,yEAAyE;AACzE,2EAA2E;AAC3E,8EAA8E;AAC9E,4BAA4B;AAE5B,MAAM,CAAC,MAAM,YAAY,GAAG,mCAAmC,CAAC;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG,kCAAkC,CAAC;AAC5D,MAAM,CAAC,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAClC,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAE9C,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAU,CAAC;AAEzE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,YAAY,YAAY,CAAC;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,YAAY,cAAc,CAAC;AAEvD,8EAA8E;AAC9E,MAAM,UAAU,WAAW;IACzB,OAAO,oBAAoB,aAAa,GAAG,aAAa,EAAE,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAgD;IAChF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;IACnC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC9C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC7C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC;IACpD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC3C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IAC7D,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;IACtD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC"}
|
package/src/auth/auth0.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Auth0 PKCE configuration for Stigmer Cloud.
|
|
2
|
-
//
|
|
3
|
-
// These values are public metadata for a Native/PKCE application — they are NOT
|
|
4
|
-
// secrets. An Auth0 client ID is a public identifier (like a username, not a
|
|
5
|
-
// password), and PKCE removes the need for a client secret entirely. The
|
|
6
|
-
// authorize/token endpoints are hardcoded because Auth0's URL structure is
|
|
7
|
-
// stable ({domain}/authorize, {domain}/oauth/token), saving an OIDC-discovery
|
|
8
|
-
// round-trip at login time.
|
|
9
|
-
|
|
10
|
-
export const AUTH0_DOMAIN = "https://stigmer-prod.us.auth0.com";
|
|
11
|
-
export const CLIENT_ID = "kIT6URf4HKn6YzrQVVFTFN63BrSJdTPM";
|
|
12
|
-
export const AUDIENCE = "https://api.stigmer.com/";
|
|
13
|
-
export const CALLBACK_PORT = 8088;
|
|
14
|
-
export const CALLBACK_PATH = "/auth/callback";
|
|
15
|
-
|
|
16
|
-
const SCOPES = ["openid", "profile", "email", "offline_access"] as const;
|
|
17
|
-
|
|
18
|
-
export const AUTHORIZE_URL = `${AUTH0_DOMAIN}/authorize`;
|
|
19
|
-
export const TOKEN_URL = `${AUTH0_DOMAIN}/oauth/token`;
|
|
20
|
-
|
|
21
|
-
/** The loopback redirect URI Auth0 calls back with the authorization code. */
|
|
22
|
-
export function callbackUrl(): string {
|
|
23
|
-
return `http://localhost:${CALLBACK_PORT}${CALLBACK_PATH}`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Build the Auth0 /authorize URL for the PKCE authorization-code flow.
|
|
28
|
-
* `prompt=login` forces the login page even with an active session, enabling
|
|
29
|
-
* account switching.
|
|
30
|
-
*/
|
|
31
|
-
export function buildAuthorizeUrl(params: { state: string; codeChallenge: string }): string {
|
|
32
|
-
const url = new URL(AUTHORIZE_URL);
|
|
33
|
-
url.searchParams.set("response_type", "code");
|
|
34
|
-
url.searchParams.set("client_id", CLIENT_ID);
|
|
35
|
-
url.searchParams.set("redirect_uri", callbackUrl());
|
|
36
|
-
url.searchParams.set("scope", SCOPES.join(" "));
|
|
37
|
-
url.searchParams.set("audience", AUDIENCE);
|
|
38
|
-
url.searchParams.set("state", params.state);
|
|
39
|
-
url.searchParams.set("code_challenge", params.codeChallenge);
|
|
40
|
-
url.searchParams.set("code_challenge_method", "S256");
|
|
41
|
-
url.searchParams.set("prompt", "login");
|
|
42
|
-
return url.toString();
|
|
43
|
-
}
|