orizu 0.5.28 → 0.5.30
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 +41 -2
- package/dist/account-directory.d.ts +132 -0
- package/dist/account-directory.d.ts.map +1 -0
- package/dist/account-directory.js +434 -0
- package/dist/app-commands.d.ts +29 -0
- package/dist/app-commands.d.ts.map +1 -0
- package/dist/app-commands.js +375 -0
- package/dist/auth-commands.d.ts +11 -0
- package/dist/auth-commands.d.ts.map +1 -0
- package/dist/auth-commands.js +321 -0
- package/dist/cli-console-output.d.ts +12 -0
- package/dist/cli-console-output.d.ts.map +1 -0
- package/dist/cli-console-output.js +57 -0
- package/dist/cli-project-slug.d.ts +20 -0
- package/dist/cli-project-slug.d.ts.map +1 -0
- package/dist/cli-project-slug.js +36 -0
- package/dist/command-line-arguments.d.ts +15 -0
- package/dist/command-line-arguments.d.ts.map +1 -0
- package/dist/command-line-arguments.js +77 -0
- package/dist/credentials.d.ts +6 -0
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +58 -4
- package/dist/dataset-commands.d.ts +16 -0
- package/dist/dataset-commands.d.ts.map +1 -0
- package/dist/dataset-commands.js +634 -0
- package/dist/dataset-download.d.ts.map +1 -1
- package/dist/dataset-download.js +4 -3
- package/dist/egress-policy.d.ts +8 -5
- package/dist/egress-policy.d.ts.map +1 -1
- package/dist/egress-policy.js +18 -7
- package/dist/feedback-cli.d.ts +14 -0
- package/dist/feedback-cli.d.ts.map +1 -0
- package/dist/feedback-cli.js +615 -0
- package/dist/feedback-contract.d.ts +79 -0
- package/dist/feedback-contract.d.ts.map +1 -0
- package/dist/feedback-contract.js +428 -0
- package/dist/feedback-scrub.d.ts +16 -0
- package/dist/feedback-scrub.d.ts.map +1 -0
- package/dist/feedback-scrub.js +610 -0
- package/dist/gepa-engine-dispatch.d.ts.map +1 -1
- package/dist/gepa-engine-dispatch.js +12 -2
- package/dist/global-flags.d.ts +1 -0
- package/dist/global-flags.d.ts.map +1 -1
- package/dist/global-flags.js +7 -0
- package/dist/headless-login.d.ts +2 -0
- package/dist/headless-login.d.ts.map +1 -1
- package/dist/headless-login.js +14 -11
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +103 -2
- package/dist/hosted-boot.d.ts +5 -0
- package/dist/hosted-boot.d.ts.map +1 -1
- package/dist/hosted-boot.js +12 -3
- package/dist/hosted-environment.d.ts +10 -0
- package/dist/hosted-environment.d.ts.map +1 -1
- package/dist/hosted-environment.js +81 -0
- package/dist/hosted-gepa-cli.d.ts.map +1 -1
- package/dist/hosted-gepa-cli.js +37 -5
- package/dist/hosted-harness-claude.d.ts +1 -2
- package/dist/hosted-harness-claude.d.ts.map +1 -1
- package/dist/hosted-harness-claude.js +8 -4
- package/dist/hosted-harness-opencode.d.ts +15 -10
- package/dist/hosted-harness-opencode.d.ts.map +1 -1
- package/dist/hosted-harness-opencode.js +27 -14
- package/dist/hosted-optimization-refusals.d.ts +6 -1
- package/dist/hosted-optimization-refusals.d.ts.map +1 -1
- package/dist/hosted-optimization-refusals.js +8 -2
- package/dist/hosted-optimization.d.ts.map +1 -1
- package/dist/hosted-optimization.js +40 -10
- package/dist/hosted-provider-credentials.d.ts +16 -0
- package/dist/hosted-provider-credentials.d.ts.map +1 -0
- package/dist/hosted-provider-credentials.js +36 -0
- package/dist/hosted-provider-settings.d.ts +7 -4
- package/dist/hosted-provider-settings.d.ts.map +1 -1
- package/dist/hosted-provider-settings.js +16 -13
- package/dist/http.d.ts +16 -3
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +57 -27
- package/dist/index.d.ts +3 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +382 -3686
- package/dist/instruction-set-sync/index.d.ts +1 -0
- package/dist/instruction-set-sync/index.d.ts.map +1 -1
- package/dist/instruction-set-sync/index.js +15 -6
- package/dist/last-error-caps.d.ts +7 -0
- package/dist/last-error-caps.d.ts.map +1 -0
- package/dist/last-error-caps.js +6 -0
- package/dist/last-error-record.d.ts +37 -0
- package/dist/last-error-record.d.ts.map +1 -0
- package/dist/last-error-record.js +316 -0
- package/dist/model-config-fields.d.ts +2 -4
- package/dist/model-config-fields.d.ts.map +1 -1
- package/dist/model-config-fields.js +26 -9
- package/dist/model-config-price.d.ts +17 -0
- package/dist/model-config-price.d.ts.map +1 -0
- package/dist/model-config-price.js +42 -0
- package/dist/model-configs-cli.d.ts +2 -0
- package/dist/model-configs-cli.d.ts.map +1 -1
- package/dist/model-configs-cli.js +47 -4
- package/dist/optimization-export-cli.d.ts.map +1 -1
- package/dist/optimization-export-cli.js +19 -0
- package/dist/preview-runtime.d.ts.map +1 -1
- package/dist/preview-runtime.js +11 -4
- package/dist/prompt-length-wire.d.ts +1 -1
- package/dist/prompt-length-wire.d.ts.map +1 -1
- package/dist/prompt-length-wire.js +1 -0
- package/dist/provider-lookup.d.ts +24 -0
- package/dist/provider-lookup.d.ts.map +1 -0
- package/dist/provider-lookup.js +43 -0
- package/dist/provider-probe.d.ts +24 -0
- package/dist/provider-probe.d.ts.map +1 -0
- package/dist/provider-probe.js +88 -0
- package/dist/provider-refusals.d.ts +83 -0
- package/dist/provider-refusals.d.ts.map +1 -0
- package/dist/provider-refusals.js +48 -0
- package/dist/provider-registry.d.ts +146 -0
- package/dist/provider-registry.d.ts.map +1 -0
- package/dist/provider-registry.js +155 -0
- package/dist/providers-cli.d.ts +3 -0
- package/dist/providers-cli.d.ts.map +1 -0
- package/dist/providers-cli.js +178 -0
- package/dist/runner-env-allowlist.d.ts +4 -0
- package/dist/runner-env-allowlist.d.ts.map +1 -0
- package/dist/runner-env-allowlist.js +36 -0
- package/dist/runner-env.d.ts +7 -0
- package/dist/runner-env.d.ts.map +1 -0
- package/dist/runner-env.js +52 -0
- package/dist/self-update.d.ts +42 -0
- package/dist/self-update.d.ts.map +1 -0
- package/dist/self-update.js +506 -0
- package/dist/setup-and-skills-commands.d.ts +11 -0
- package/dist/setup-and-skills-commands.d.ts.map +1 -0
- package/dist/setup-and-skills-commands.js +1055 -0
- package/dist/task-commands.d.ts +13 -0
- package/dist/task-commands.d.ts.map +1 -0
- package/dist/task-commands.js +512 -0
- package/dist/workspace.d.ts +1 -0
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +11 -0
- package/package.json +1 -1
- package/src/account-directory.ts +751 -0
- package/src/app-commands.ts +520 -0
- package/src/auth-commands.ts +388 -0
- package/src/cli-console-output.ts +83 -0
- package/src/cli-project-slug.ts +53 -0
- package/src/command-line-arguments.ts +111 -0
- package/src/credentials.ts +62 -4
- package/src/dataset-commands.ts +863 -0
- package/src/dataset-download.ts +4 -3
- package/src/egress-policy.ts +19 -8
- package/src/feedback-cli.ts +778 -0
- package/src/feedback-contract.ts +492 -0
- package/src/feedback-scrub.ts +799 -0
- package/src/gepa-engine-dispatch.ts +16 -2
- package/src/global-flags.ts +8 -0
- package/src/headless-login.ts +25 -11
- package/src/help.ts +103 -2
- package/src/hosted-boot.ts +21 -3
- package/src/hosted-environment.ts +70 -0
- package/src/hosted-gepa-cli.ts +35 -5
- package/src/hosted-harness-claude.ts +9 -4
- package/src/hosted-harness-opencode.ts +28 -14
- package/src/hosted-optimization-refusals.ts +11 -3
- package/src/hosted-optimization.ts +42 -12
- package/src/hosted-provider-credentials.js +2 -0
- package/src/hosted-provider-credentials.ts +42 -0
- package/src/hosted-provider-settings.ts +21 -13
- package/src/http.ts +75 -26
- package/src/index.ts +1134 -5348
- package/src/instruction-set-sync/index.ts +25 -6
- package/src/last-error-caps.js +4 -0
- package/src/last-error-caps.ts +6 -0
- package/src/last-error-record.ts +415 -0
- package/src/model-config-fields.ts +29 -10
- package/src/model-config-price.js +2 -0
- package/src/model-config-price.ts +55 -0
- package/src/model-configs-cli.ts +41 -4
- package/src/optimization-export-cli.ts +23 -0
- package/src/preview-runtime.ts +11 -4
- package/src/prompt-length-wire.ts +1 -0
- package/src/provider-lookup.js +2 -0
- package/src/provider-lookup.ts +73 -0
- package/src/provider-probe.ts +101 -0
- package/src/provider-refusals.ts +53 -0
- package/src/provider-registry.js +4 -0
- package/src/provider-registry.ts +186 -0
- package/src/providers-cli.ts +153 -0
- package/src/runner-env-allowlist.js +4 -0
- package/src/runner-env-allowlist.ts +38 -0
- package/src/runner-env.js +4 -0
- package/src/runner-env.ts +58 -0
- package/src/secret-redaction.js +4 -0
- package/src/self-update.ts +548 -0
- package/src/setup-and-skills-commands.ts +1242 -0
- package/src/task-commands.ts +703 -0
- package/src/workspace.ts +11 -0
- package/vendor/orizu-gepa/pyproject.toml +7 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/callbacks.py +77 -39
- package/vendor/orizu-gepa/src/orizu_gepa_connector/providers.generated.json +32 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/reflection.py +5 -3
- package/vendor/orizu-gepa/src/orizu_gepa_connector/runtime.py +16 -2
- package/vendor/orizu-gepa/src/orizu_gepa_connector/skilled_proposer_bridge.py +14 -1
- package/vendor/orizu-gepa/src/orizu_gepa_connector/translator.py +91 -24
- package/vendor/orizu-gepa-python/pyproject.toml +7 -0
- package/vendor/orizu-gepa-python/src/orizu_gepa/local_log.py +3 -0
- package/vendor/orizu-gepa-python/src/orizu_gepa/providers.generated.json +32 -0
- package/vendor/orizu-gepa-python/src/orizu_gepa/providers.py +321 -0
- package/vendor/orizu-gepa-python/src/orizu_gepa/reflection.py +269 -89
- package/vendor/orizu-gepa-python/src/orizu_gepa/runner.py +40 -6
- package/vendor/skills/orizu/SKILL.md +26 -22
- package/vendor/skills/orizu/flows/expand.md +2 -0
- package/vendor/skills/orizu/flows/first-win.md +2 -0
- package/vendor/skills/orizu/flows/onboard.md +2 -0
- package/vendor/skills/orizu/flows/promote.md +5 -3
- package/vendor/skills/orizu/flows/recurse.md +2 -0
- package/vendor/skills/orizu/flows/triage.md +7 -5
- package/vendor/skills/orizu/references/assess-and-plan.md +16 -16
- package/vendor/skills/orizu/references/authority-map.md +1 -0
- package/vendor/skills/orizu/references/building-apps.md +92 -92
- package/vendor/skills/orizu/references/building-judges.md +6 -6
- package/vendor/skills/orizu/references/cli-reference.md +80 -14
- package/vendor/skills/orizu/references/dataset-design.md +3 -3
- package/vendor/skills/orizu/references/eval-strategy.md +8 -8
- package/vendor/skills/orizu/references/feedback.md +113 -0
- package/vendor/skills/orizu/references/instructions-after-prompts.md +5 -5
- package/vendor/skills/orizu/references/migrate-existing-gepa-setup.md +15 -15
- package/vendor/skills/orizu/references/migrate-hand-rolled-instruction-layout.md +4 -4
- package/vendor/skills/orizu/references/optimization-reports.md +5 -5
- package/vendor/skills/orizu/references/optimization-with-gepa.md +41 -35
- package/vendor/skills/orizu/references/orizu-in-your-codebase.md +8 -8
- package/vendor/skills/orizu/references/primer.md +42 -42
- package/vendor/skills/orizu/references/prompt-control-plane.md +29 -29
- package/vendor/skills/orizu/references/vocabulary.md +18 -18
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
// ORI-2044: moved from index.ts to keep auth commands together.
|
|
2
|
+
import { randomBytes, createHash } from 'crypto';
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { createServer } from 'http';
|
|
5
|
+
import { sanitizeTerminalText, parseJsonResponse } from './json-response.js';
|
|
6
|
+
import { isInteractiveTerminal, hasArg, hasJsonFlag, getArg } from './command-line-arguments.js';
|
|
7
|
+
import { getBaseUrl, resolveLoginTarget, resolveLogoutTarget, assertSecureTokenTransport, authedFetch, credentialRequestRedirectPolicy, } from './http.js';
|
|
8
|
+
import { hasResolvableAuth, rememberProcessSecret, saveServerCredentials, getServerCredentials, clearServerCredentials, resolveAuthTokenForBaseUrl, } from './credentials.js';
|
|
9
|
+
import { printJson, printLine, printLoginProgress } from './cli-console-output.js';
|
|
10
|
+
import { shouldUseHeadlessLogin, waitForHeadlessAuthorization } from './headless-login.js';
|
|
11
|
+
import { renderCliAuthBrowserPage } from './cli-auth-browser-page.js';
|
|
12
|
+
import { describeLogoutHttpFailure, describeLogoutTransportFailure } from './logout-diagnostic.js';
|
|
13
|
+
import { resolveProjectSelection } from './account-directory.js';
|
|
14
|
+
function isNodeError(error) {
|
|
15
|
+
return error instanceof Error;
|
|
16
|
+
}
|
|
17
|
+
function createCodeVerifier() {
|
|
18
|
+
return randomBytes(32).toString('base64url');
|
|
19
|
+
}
|
|
20
|
+
export function createCodeChallenge(verifier) {
|
|
21
|
+
return createHash('sha256').update(verifier).digest('base64url');
|
|
22
|
+
}
|
|
23
|
+
function isStandardOrizuOrigin(url) {
|
|
24
|
+
return url.protocol === 'https:' && !url.port && !url.username && !url.password &&
|
|
25
|
+
url.hostname.length <= 253 &&
|
|
26
|
+
/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*orizu\.ai$/.test(url.hostname);
|
|
27
|
+
}
|
|
28
|
+
export function validateBrowserUrl(url, expectedOrigin) {
|
|
29
|
+
let parsed;
|
|
30
|
+
try {
|
|
31
|
+
parsed = new URL(url);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
throw new Error('Server returned an invalid browser URL.');
|
|
35
|
+
}
|
|
36
|
+
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
|
|
37
|
+
throw new Error('Server returned an unsupported browser URL scheme.');
|
|
38
|
+
}
|
|
39
|
+
if (parsed.username || parsed.password) {
|
|
40
|
+
throw new Error('Server returned a browser URL containing credentials.');
|
|
41
|
+
}
|
|
42
|
+
if (expectedOrigin && parsed.origin !== expectedOrigin) {
|
|
43
|
+
const allowsOrizuHandoff = isStandardOrizuOrigin(parsed) && isStandardOrizuOrigin(new URL(expectedOrigin));
|
|
44
|
+
if (!allowsOrizuHandoff) {
|
|
45
|
+
throw new Error('Server returned a browser URL for an unexpected origin.');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return parsed;
|
|
49
|
+
}
|
|
50
|
+
function openInBrowser(url) {
|
|
51
|
+
const parsed = validateBrowserUrl(url);
|
|
52
|
+
const platform = process.platform;
|
|
53
|
+
const href = parsed.href;
|
|
54
|
+
if (platform === 'darwin') {
|
|
55
|
+
spawn('open', [href], {
|
|
56
|
+
detached: true,
|
|
57
|
+
stdio: 'ignore',
|
|
58
|
+
}).unref();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (platform === 'win32') {
|
|
62
|
+
spawn('rundll32.exe', ['url.dll,FileProtocolHandler', href], {
|
|
63
|
+
detached: true,
|
|
64
|
+
stdio: 'ignore',
|
|
65
|
+
windowsHide: true,
|
|
66
|
+
}).unref();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
spawn('xdg-open', [href], {
|
|
70
|
+
detached: true,
|
|
71
|
+
stdio: 'ignore',
|
|
72
|
+
}).unref();
|
|
73
|
+
}
|
|
74
|
+
export function formatTerminalLink(url) {
|
|
75
|
+
const safeUrl = sanitizeTerminalText(url);
|
|
76
|
+
try {
|
|
77
|
+
const parsed = validateBrowserUrl(safeUrl);
|
|
78
|
+
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
|
|
79
|
+
return safeUrl;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return safeUrl;
|
|
84
|
+
}
|
|
85
|
+
if (!isInteractiveTerminal()) {
|
|
86
|
+
return safeUrl;
|
|
87
|
+
}
|
|
88
|
+
return `\u001B]8;;${safeUrl}\u0007${safeUrl}\u001B]8;;\u0007`;
|
|
89
|
+
}
|
|
90
|
+
function shellQuote(value) {
|
|
91
|
+
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
92
|
+
}
|
|
93
|
+
const DEFAULT_AUTH_CALLBACK_PORT = 43123;
|
|
94
|
+
function resolveAuthCallbackPort() {
|
|
95
|
+
const envPort = process.env.ORIZU_AUTH_PORT;
|
|
96
|
+
if (!envPort) {
|
|
97
|
+
return DEFAULT_AUTH_CALLBACK_PORT;
|
|
98
|
+
}
|
|
99
|
+
const parsed = parseInt(envPort, 10);
|
|
100
|
+
if (Number.isNaN(parsed) || parsed < 1024 || parsed > 65535) {
|
|
101
|
+
throw new Error(`Invalid ORIZU_AUTH_PORT: '${envPort}'. Must be a number between 1024 and 65535.`);
|
|
102
|
+
}
|
|
103
|
+
return parsed;
|
|
104
|
+
}
|
|
105
|
+
async function login(baseUrlOverride) {
|
|
106
|
+
const target = baseUrlOverride !== undefined
|
|
107
|
+
? { baseUrl: baseUrlOverride, isDefault: false }
|
|
108
|
+
: hasArg('--no-prompt-if-logged-in')
|
|
109
|
+
? { baseUrl: getBaseUrl(), isDefault: false }
|
|
110
|
+
: resolveLoginTarget();
|
|
111
|
+
const { baseUrl } = target;
|
|
112
|
+
let loginData;
|
|
113
|
+
try {
|
|
114
|
+
loginData = await authenticateAtBaseUrl(baseUrl);
|
|
115
|
+
if (!loginData)
|
|
116
|
+
return;
|
|
117
|
+
saveServerCredentials(baseUrl, {
|
|
118
|
+
credentialType: 'pat',
|
|
119
|
+
apiKey: loginData.apiKey,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (target.isDefault) {
|
|
124
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
125
|
+
throw new Error(`${detail} Check connectivity to https://app.orizu.ai, then retry \`orizu login\`.`, { cause: error });
|
|
126
|
+
}
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
if (hasJsonFlag()) {
|
|
130
|
+
printJson({
|
|
131
|
+
status: 'logged-in',
|
|
132
|
+
server: baseUrl,
|
|
133
|
+
user: { id: loginData.user.id, email: loginData.user.email ?? null },
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
printLine(`Logged in as ${sanitizeTerminalText(loginData.user.email ?? loginData.user.id)}`);
|
|
138
|
+
}
|
|
139
|
+
async function authenticateAtBaseUrl(baseUrl) {
|
|
140
|
+
assertSecureTokenTransport(baseUrl);
|
|
141
|
+
// hasResolvableAuth (ALI-1090): an env bearer (ORIZU_TOKEN / ORIZU_TOKEN_FILE)
|
|
142
|
+
// counts as logged in — a pre-authenticated hosted sandbox must not fall into
|
|
143
|
+
// the interactive browser flow.
|
|
144
|
+
if (hasArg('--no-prompt-if-logged-in') && hasResolvableAuth(baseUrl)) {
|
|
145
|
+
if (hasJsonFlag()) {
|
|
146
|
+
printJson({ status: 'already-logged-in', server: baseUrl });
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
printLine(`Already logged in to ${sanitizeTerminalText(baseUrl)}.`);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const codeVerifier = rememberProcessSecret(createCodeVerifier());
|
|
153
|
+
const codeChallenge = createCodeChallenge(codeVerifier);
|
|
154
|
+
const isHeadlessLogin = shouldUseHeadlessLogin({ isForced: hasArg('--headless') });
|
|
155
|
+
const callbackPort = isHeadlessLogin ? undefined : resolveAuthCallbackPort();
|
|
156
|
+
const redirectUri = callbackPort === undefined ? undefined : `http://127.0.0.1:${callbackPort}/callback`;
|
|
157
|
+
const callbackCode = isHeadlessLogin
|
|
158
|
+
? await waitForHeadlessAuthorization({ baseUrl, codeChallenge }, {
|
|
159
|
+
parseJsonResponse,
|
|
160
|
+
printProgress: printLoginProgress,
|
|
161
|
+
sanitizeTerminalText,
|
|
162
|
+
validateBrowserUrl,
|
|
163
|
+
})
|
|
164
|
+
: await new Promise((resolve, reject) => {
|
|
165
|
+
const server = createServer((request, response) => {
|
|
166
|
+
try {
|
|
167
|
+
const url = new URL(request.url || '/', `http://127.0.0.1:${callbackPort}`);
|
|
168
|
+
const code = url.searchParams.get('code');
|
|
169
|
+
if (!code) {
|
|
170
|
+
response.statusCode = 400;
|
|
171
|
+
response.setHeader('content-type', 'text/html; charset=utf-8');
|
|
172
|
+
response.end(renderCliAuthBrowserPage('error'));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
response.statusCode = 200;
|
|
176
|
+
response.setHeader('content-type', 'text/html; charset=utf-8');
|
|
177
|
+
response.end(renderCliAuthBrowserPage('success'));
|
|
178
|
+
server.close();
|
|
179
|
+
resolve(code);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
server.close();
|
|
183
|
+
reject(error);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
server.on('error', (error) => {
|
|
187
|
+
if (error.code === 'EADDRINUSE') {
|
|
188
|
+
reject(new Error(`Port ${callbackPort} is already in use. Set ORIZU_AUTH_PORT to a different port (1024–65535) and retry.`));
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
reject(error);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
server.listen(callbackPort, '127.0.0.1', async () => {
|
|
195
|
+
try {
|
|
196
|
+
const response = await fetch(`${baseUrl}/api/cli/auth/start`, {
|
|
197
|
+
method: 'POST',
|
|
198
|
+
headers: { 'Content-Type': 'application/json' },
|
|
199
|
+
body: JSON.stringify({ codeChallenge, redirectUri }),
|
|
200
|
+
});
|
|
201
|
+
if (!response.ok) {
|
|
202
|
+
const text = await response.text();
|
|
203
|
+
server.close();
|
|
204
|
+
reject(new Error(`Failed to start login: ${text}`));
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const { authorizeUrl } = await parseJsonResponse(response, 'CLI auth start');
|
|
208
|
+
const safeAuthorizeUrl = validateBrowserUrl(authorizeUrl, baseUrl).href;
|
|
209
|
+
printLoginProgress(`Opening browser for login: ${sanitizeTerminalText(safeAuthorizeUrl)}`);
|
|
210
|
+
openInBrowser(safeAuthorizeUrl);
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
server.close();
|
|
214
|
+
reject(error);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
rememberProcessSecret(callbackCode);
|
|
219
|
+
const exchangeResponse = await fetch(`${baseUrl}/api/cli/auth/exchange`, {
|
|
220
|
+
method: 'POST',
|
|
221
|
+
headers: { 'Content-Type': 'application/json' },
|
|
222
|
+
body: JSON.stringify({ code: callbackCode, codeVerifier, redirectUri }),
|
|
223
|
+
});
|
|
224
|
+
if (!exchangeResponse.ok) {
|
|
225
|
+
const text = await exchangeResponse.text();
|
|
226
|
+
throw new Error(`Failed to exchange auth code: ${text}`);
|
|
227
|
+
}
|
|
228
|
+
const loginData = await parseJsonResponse(exchangeResponse, 'CLI auth exchange');
|
|
229
|
+
if (!loginData.apiKey) {
|
|
230
|
+
throw new Error('Server did not return an API key. Upgrade the Orizu server and run `orizu login` again.');
|
|
231
|
+
}
|
|
232
|
+
return { ...loginData, apiKey: loginData.apiKey };
|
|
233
|
+
}
|
|
234
|
+
async function whoami() {
|
|
235
|
+
const response = await authedFetch('/api/cli/auth/whoami');
|
|
236
|
+
if (!response.ok) {
|
|
237
|
+
throw new Error(`whoami failed: ${await response.text()}`);
|
|
238
|
+
}
|
|
239
|
+
const data = await response.json();
|
|
240
|
+
if (hasJsonFlag()) {
|
|
241
|
+
printJson({ user: data.user, server: getBaseUrl() });
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
printLine(sanitizeTerminalText(data.user.email ?? data.user.id));
|
|
245
|
+
}
|
|
246
|
+
async function logout(baseUrlOverride) {
|
|
247
|
+
const { baseUrl, credentialBaseUrl } = resolveLogoutTarget(baseUrlOverride);
|
|
248
|
+
const credentials = getServerCredentials(credentialBaseUrl);
|
|
249
|
+
if (!credentials) {
|
|
250
|
+
if (hasJsonFlag()) {
|
|
251
|
+
printJson({ status: 'already-logged-out', server: baseUrl });
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
printLine(`Already logged out for ${sanitizeTerminalText(baseUrl)}.`);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const authorizationToken = 'accessToken' in credentials
|
|
258
|
+
? credentials.accessToken
|
|
259
|
+
: credentials.apiKey;
|
|
260
|
+
const logoutSecrets = [
|
|
261
|
+
authorizationToken,
|
|
262
|
+
...('refreshToken' in credentials ? [credentials.refreshToken] : []),
|
|
263
|
+
];
|
|
264
|
+
let remoteLogoutError = null;
|
|
265
|
+
try {
|
|
266
|
+
assertSecureTokenTransport(baseUrl);
|
|
267
|
+
const response = await fetch(`${baseUrl}/api/cli/auth/logout`, {
|
|
268
|
+
method: 'POST',
|
|
269
|
+
headers: {
|
|
270
|
+
'Content-Type': 'application/json',
|
|
271
|
+
Authorization: `Bearer ${authorizationToken}`,
|
|
272
|
+
},
|
|
273
|
+
body: 'refreshToken' in credentials
|
|
274
|
+
? JSON.stringify({ refreshToken: credentials.refreshToken })
|
|
275
|
+
: undefined,
|
|
276
|
+
...credentialRequestRedirectPolicy(),
|
|
277
|
+
});
|
|
278
|
+
if (!response.ok) {
|
|
279
|
+
remoteLogoutError = await describeLogoutHttpFailure(response, logoutSecrets);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
remoteLogoutError = describeLogoutTransportFailure(error, logoutSecrets);
|
|
284
|
+
}
|
|
285
|
+
clearServerCredentials(credentialBaseUrl);
|
|
286
|
+
if (hasJsonFlag()) {
|
|
287
|
+
printJson({ status: 'logged-out', server: baseUrl, remoteLogoutError });
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (remoteLogoutError) {
|
|
291
|
+
console.warn(`Warning: remote logout failed: ${remoteLogoutError}`);
|
|
292
|
+
}
|
|
293
|
+
printLine(`Logged out from ${sanitizeTerminalText(baseUrl)}.`);
|
|
294
|
+
}
|
|
295
|
+
async function printEnv() {
|
|
296
|
+
const baseUrl = getBaseUrl();
|
|
297
|
+
// Uniform resolution (ALI-1090): env bearer (ORIZU_TOKEN / ORIZU_TOKEN_FILE)
|
|
298
|
+
// wins over credentials.json, so `orizu env` works in hosted sandboxes that
|
|
299
|
+
// never ran `orizu login`.
|
|
300
|
+
const token = resolveAuthTokenForBaseUrl(baseUrl);
|
|
301
|
+
const projectArg = getArg('--project');
|
|
302
|
+
const project = projectArg ? await resolveProjectSelection(projectArg) : null;
|
|
303
|
+
const projectId = project?.id || getArg('--project-id') || process.env.ORIZU_PROJECT_ID || '';
|
|
304
|
+
const projectSlug = project ? `${project.teamSlug}/${project.slug}` : process.env.ORIZU_PROJECT || '';
|
|
305
|
+
if (hasJsonFlag()) {
|
|
306
|
+
printJson({
|
|
307
|
+
ORIZU_API_URL: baseUrl,
|
|
308
|
+
ORIZU_TOKEN: token,
|
|
309
|
+
ORIZU_PROJECT_ID: projectId,
|
|
310
|
+
...(projectSlug ? { ORIZU_PROJECT: projectSlug } : {}),
|
|
311
|
+
});
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
printLine(`export ORIZU_API_URL=${shellQuote(baseUrl)}`);
|
|
315
|
+
printLine(`export ORIZU_TOKEN=${shellQuote(token)}`);
|
|
316
|
+
printLine(`export ORIZU_PROJECT_ID=${shellQuote(projectId)}`);
|
|
317
|
+
if (projectSlug) {
|
|
318
|
+
printLine(`export ORIZU_PROJECT=${shellQuote(projectSlug)}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
export { isNodeError, login, shellQuote, logout, whoami, printEnv };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare function getErrorMessage(error: unknown): string;
|
|
2
|
+
declare function getCliVersion(): string;
|
|
3
|
+
declare function printLine(message?: string): void;
|
|
4
|
+
declare function printVersion(): void;
|
|
5
|
+
declare function printBannerIfInteractive(): void;
|
|
6
|
+
declare function printUsage(): void;
|
|
7
|
+
declare function printError(message: string): void;
|
|
8
|
+
declare function printLoginProgress(message: string): void;
|
|
9
|
+
declare function printPushDisclosures(data: Record<string, unknown>): void;
|
|
10
|
+
declare function printJson(value: Record<string, unknown>): void;
|
|
11
|
+
export { getErrorMessage, printJson, printLine, printPushDisclosures, getCliVersion, printBannerIfInteractive, printVersion, printUsage, printError, printLoginProgress, };
|
|
12
|
+
//# sourceMappingURL=cli-console-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-console-output.d.ts","sourceRoot":"","sources":["../src/cli-console-output.ts"],"names":[],"mappings":"AAUA,iBAAS,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE/C;AAED,iBAAS,aAAa,IAAI,MAAM,CAU/B;AAED,iBAAS,SAAS,CAAC,OAAO,SAAK,QAE9B;AAED,iBAAS,YAAY,SAEpB;AAED,iBAAS,wBAAwB,SAMhC;AAED,iBAAS,UAAU,SAGlB;AAED,iBAAS,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEzC;AAED,iBAAS,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAMjD;AAED,iBAAS,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAMjE;AAED,iBAAS,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAEhD;AAED,OAAO,EACL,eAAe,EACf,SAAS,EACT,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,kBAAkB,GACnB,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// ORI-2044: moved from index.ts to keep cli console output together.
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import { stdout as output } from 'process';
|
|
4
|
+
import { renderBanner } from './banner.js';
|
|
5
|
+
import { renderRootHelp } from './help.js';
|
|
6
|
+
import { sanitizeTerminalText } from './json-response.js';
|
|
7
|
+
import { hasJsonFlag } from './command-line-arguments.js';
|
|
8
|
+
import { reportReplacementWarning } from './report-replacement-warning.js';
|
|
9
|
+
function getErrorMessage(error) {
|
|
10
|
+
return error instanceof Error ? error.message : String(error);
|
|
11
|
+
}
|
|
12
|
+
function getCliVersion() {
|
|
13
|
+
const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
14
|
+
if (typeof packageJson.version !== 'string' || packageJson.version.length === 0) {
|
|
15
|
+
throw new Error('Unable to read orizu CLI version.');
|
|
16
|
+
}
|
|
17
|
+
return packageJson.version;
|
|
18
|
+
}
|
|
19
|
+
function printLine(message = '') {
|
|
20
|
+
output.write(`${message}\n`);
|
|
21
|
+
}
|
|
22
|
+
function printVersion() {
|
|
23
|
+
printLine(`orizu ${getCliVersion()}`);
|
|
24
|
+
}
|
|
25
|
+
function printBannerIfInteractive() {
|
|
26
|
+
if (!process.stdout.isTTY) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
printLine(renderBanner());
|
|
30
|
+
printLine('');
|
|
31
|
+
}
|
|
32
|
+
function printUsage() {
|
|
33
|
+
printBannerIfInteractive();
|
|
34
|
+
printLine(renderRootHelp());
|
|
35
|
+
}
|
|
36
|
+
function printError(message) {
|
|
37
|
+
console.error(sanitizeTerminalText(message));
|
|
38
|
+
}
|
|
39
|
+
function printLoginProgress(message) {
|
|
40
|
+
if (hasJsonFlag()) {
|
|
41
|
+
printError(message);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
printLine(message);
|
|
45
|
+
}
|
|
46
|
+
function printPushDisclosures(data) {
|
|
47
|
+
const warning = reportReplacementWarning(data);
|
|
48
|
+
if (warning)
|
|
49
|
+
printError(warning);
|
|
50
|
+
if (data.metadata_updated === true) {
|
|
51
|
+
printError('Updated prompt metadata on the identical existing version');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function printJson(value) {
|
|
55
|
+
printLine(JSON.stringify(value));
|
|
56
|
+
}
|
|
57
|
+
export { getErrorMessage, printJson, printLine, printPushDisclosures, getCliVersion, printBannerIfInteractive, printVersion, printUsage, printError, printLoginProgress, };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const RESERVED_ROUTING_SLUGS: readonly string[];
|
|
2
|
+
export declare function isReservedRoutingSlug(slug: string): boolean;
|
|
3
|
+
export declare function isReservedRoutingName(name: string): boolean;
|
|
4
|
+
export interface ParsedProjectSlug {
|
|
5
|
+
teamSlug: string;
|
|
6
|
+
projectSlug: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SplitProjectArg {
|
|
9
|
+
/** null when the caller passed a bare project slug. */
|
|
10
|
+
teamSlug: string | null;
|
|
11
|
+
projectSlug: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function normalizeSlugInput(slug: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Accept a `--project` value in either documented form: `teamSlug/projectSlug`
|
|
16
|
+
* or a bare `projectSlug` (resolved within the caller's team).
|
|
17
|
+
*/
|
|
18
|
+
export declare function splitCliProjectArg(value: string): SplitProjectArg | null;
|
|
19
|
+
export declare function parseCliProjectSlug(projectSlug: string): ParsedProjectSlug | null;
|
|
20
|
+
//# sourceMappingURL=cli-project-slug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-project-slug.d.ts","sourceRoot":"","sources":["../src/cli-project-slug.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAInD,CAAA;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG3D;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAQxE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAQjF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const RESERVED_ROUTING_SLUGS = [
|
|
2
|
+
'account', 'teams', 'projects', 'task', 'preview', 'api', 'auth', 'login', 'logout', 'signup', 'signin',
|
|
3
|
+
'settings', 'new', 'admin', 'docs', 'learn', 'd', 'agents', 'subprocessors', 'llms.txt',
|
|
4
|
+
'_next', 'robots.txt', 'sitemap.xml', 'favicon.ico',
|
|
5
|
+
];
|
|
6
|
+
export function isReservedRoutingSlug(slug) {
|
|
7
|
+
return RESERVED_ROUTING_SLUGS.includes(normalizeSlugInput(slug));
|
|
8
|
+
}
|
|
9
|
+
export function isReservedRoutingName(name) {
|
|
10
|
+
const stem = normalizeSlugInput(name).replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
11
|
+
return isReservedRoutingSlug(name) || isReservedRoutingSlug(stem);
|
|
12
|
+
}
|
|
13
|
+
export function normalizeSlugInput(slug) {
|
|
14
|
+
return slug.trim().toLowerCase();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Accept a `--project` value in either documented form: `teamSlug/projectSlug`
|
|
18
|
+
* or a bare `projectSlug` (resolved within the caller's team).
|
|
19
|
+
*/
|
|
20
|
+
export function splitCliProjectArg(value) {
|
|
21
|
+
if (!value.includes('/')) {
|
|
22
|
+
const projectSlug = normalizeSlugInput(value);
|
|
23
|
+
return projectSlug ? { teamSlug: null, projectSlug } : null;
|
|
24
|
+
}
|
|
25
|
+
const parsed = parseCliProjectSlug(value);
|
|
26
|
+
return parsed ? { teamSlug: parsed.teamSlug, projectSlug: parsed.projectSlug } : null;
|
|
27
|
+
}
|
|
28
|
+
export function parseCliProjectSlug(projectSlug) {
|
|
29
|
+
const segments = projectSlug.split('/');
|
|
30
|
+
if (segments.length !== 2)
|
|
31
|
+
return null;
|
|
32
|
+
const [teamSlug, project] = segments.map(normalizeSlugInput);
|
|
33
|
+
if (!teamSlug || !project)
|
|
34
|
+
return null;
|
|
35
|
+
return { teamSlug, projectSlug: project };
|
|
36
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare let cliArgs: string[];
|
|
2
|
+
declare function getArg(name: string): string | null;
|
|
3
|
+
declare function getArchiveListStatus(command: string): string;
|
|
4
|
+
declare function getArgs(name: string): string[];
|
|
5
|
+
declare function getOptionalArgValue(name: string): string | null;
|
|
6
|
+
declare function rejectDashPrefixedOptionValue(name: string, value: string | null): void;
|
|
7
|
+
export declare function normalizeSlugInput(slug: string): string;
|
|
8
|
+
declare function isInteractiveTerminal(): boolean;
|
|
9
|
+
declare function hasArg(name: string): boolean;
|
|
10
|
+
export declare function expandHomePath(path: string): string;
|
|
11
|
+
declare function getPositionalArg(index: number): string | null;
|
|
12
|
+
declare function hasJsonFlag(): boolean;
|
|
13
|
+
export { cliArgs, getArg, hasJsonFlag, getArchiveListStatus, getPositionalArg, hasArg, isInteractiveTerminal, getArgs, getOptionalArgValue, rejectDashPrefixedOptionValue, };
|
|
14
|
+
export declare function setCommandLineArguments(args: string[], jsonOutput: boolean): void;
|
|
15
|
+
//# sourceMappingURL=command-line-arguments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-line-arguments.d.ts","sourceRoot":"","sources":["../src/command-line-arguments.ts"],"names":[],"mappings":"AAEA,QAAA,IAAI,OAAO,UAAwB,CAAA;AAGnC,iBAAS,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO3C;AAED,iBAAS,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CASrD;AAED,iBAAS,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBvC;AAED,iBAAS,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYxD;AAED,iBAAS,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,QAIxE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,iBAAS,qBAAqB,YAE7B;AAED,iBAAS,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOnD;AAED,iBAAS,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGtD;AAED,iBAAS,WAAW,IAAI,OAAO,CAE9B;AAED,OAAO,EACL,OAAO,EACP,MAAM,EACN,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,MAAM,EACN,qBAAqB,EACrB,OAAO,EACP,mBAAmB,EACnB,6BAA6B,GAC9B,CAAA;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAGjF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// ORI-2044: moved from index.ts to keep command line arguments together.
|
|
2
|
+
let cliArgs = process.argv.slice(2);
|
|
3
|
+
let cliJsonOutput = false;
|
|
4
|
+
function getArg(name) {
|
|
5
|
+
const index = cliArgs.indexOf(name);
|
|
6
|
+
if (index === -1 || index + 1 >= cliArgs.length) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return cliArgs[index + 1];
|
|
10
|
+
}
|
|
11
|
+
function getArchiveListStatus(command) {
|
|
12
|
+
const status = getArg('--status') || 'active';
|
|
13
|
+
if (!['active', 'archived', 'all'].includes(status)) {
|
|
14
|
+
throw new Error(`Usage: orizu ${command} list [--project <team/project>] ` +
|
|
15
|
+
'[--status active|archived|all]');
|
|
16
|
+
}
|
|
17
|
+
return status;
|
|
18
|
+
}
|
|
19
|
+
function getArgs(name) {
|
|
20
|
+
const values = [];
|
|
21
|
+
for (let index = 0; index < cliArgs.length; index += 1) {
|
|
22
|
+
if (cliArgs[index] !== name) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const value = cliArgs[index + 1];
|
|
26
|
+
if (!value || value.startsWith('-')) {
|
|
27
|
+
throw new Error(`Usage: ${name} <value>`);
|
|
28
|
+
}
|
|
29
|
+
values.push(value);
|
|
30
|
+
index += 1;
|
|
31
|
+
}
|
|
32
|
+
return values;
|
|
33
|
+
}
|
|
34
|
+
function getOptionalArgValue(name) {
|
|
35
|
+
const index = cliArgs.indexOf(name);
|
|
36
|
+
if (index === -1 || index + 1 >= cliArgs.length) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const value = cliArgs[index + 1];
|
|
40
|
+
if (!value || value.startsWith('-')) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
function rejectDashPrefixedOptionValue(name, value) {
|
|
46
|
+
if (value && value.startsWith('-')) {
|
|
47
|
+
throw new Error(`Invalid value for ${name}: option values cannot start with a dash`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function normalizeSlugInput(slug) {
|
|
51
|
+
return slug.trim().toLowerCase();
|
|
52
|
+
}
|
|
53
|
+
function isInteractiveTerminal() {
|
|
54
|
+
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
55
|
+
}
|
|
56
|
+
function hasArg(name) {
|
|
57
|
+
return cliArgs.includes(name);
|
|
58
|
+
}
|
|
59
|
+
export function expandHomePath(path) {
|
|
60
|
+
if (path.startsWith('~/')) {
|
|
61
|
+
const home = process.env.HOME || '';
|
|
62
|
+
return `${home}/${path.slice(2)}`;
|
|
63
|
+
}
|
|
64
|
+
return path;
|
|
65
|
+
}
|
|
66
|
+
function getPositionalArg(index) {
|
|
67
|
+
const value = cliArgs[index];
|
|
68
|
+
return value && !value.startsWith('--') ? value : null;
|
|
69
|
+
}
|
|
70
|
+
function hasJsonFlag() {
|
|
71
|
+
return cliJsonOutput || hasArg('--json');
|
|
72
|
+
}
|
|
73
|
+
export { cliArgs, getArg, hasJsonFlag, getArchiveListStatus, getPositionalArg, hasArg, isInteractiveTerminal, getArgs, getOptionalArgValue, rejectDashPrefixedOptionValue, };
|
|
74
|
+
export function setCommandLineArguments(args, jsonOutput) {
|
|
75
|
+
cliArgs = args;
|
|
76
|
+
cliJsonOutput = jsonOutput;
|
|
77
|
+
}
|
package/dist/credentials.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ServerCredentials, StoredCredentialsV2, StoredCredentialsV3 } from './types.js';
|
|
2
|
+
export declare function getConfigDir(): string;
|
|
2
3
|
/**
|
|
3
4
|
* Runs a synchronous credentials transaction under the one process-wide and
|
|
4
5
|
* cross-process lock. Exported so real-process fixtures can hold the production
|
|
@@ -18,6 +19,11 @@ export declare function updateServerCredentials(baseUrl: string, credentials: Se
|
|
|
18
19
|
export declare function credentialsEqual(left: ServerCredentials, right: ServerCredentials): boolean;
|
|
19
20
|
export declare function updateServerCredentialsIfCurrent(baseUrl: string, expected: ServerCredentials, replacement: ServerCredentials): boolean;
|
|
20
21
|
export declare function getActiveBaseUrl(): string | null;
|
|
22
|
+
/** Resolve the selected server and move a retired production credential atomically. */
|
|
23
|
+
export declare function resolveCredentialServer(selected?: string): string | null;
|
|
24
|
+
export declare function rememberProcessSecret(secret: string): string;
|
|
25
|
+
export declare function rememberResolvedBearer(bearer: string): string;
|
|
26
|
+
export declare function getSecretsSeenThisProcess(): readonly string[];
|
|
21
27
|
/**
|
|
22
28
|
* In-sandbox bearer resolution (ALI-1044). Resolves a bearer supplied out-of-band
|
|
23
29
|
* to the hosted agent, WITHOUT consulting credentials.json:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,iBAAiB,EAEjB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAMnB,wBAAgB,YAAY,IAAI,MAAM,CAKrC;AA0HD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAgCvE;AAED;;;;GAIG;AACH,wBAAsB,mCAAmC,CAAC,CAAC,EACzD,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC,CAiDZ;AAwGD,wBAAgB,qBAAqB,IAAI,mBAAmB,GAAG,mBAAmB,GAAG,IAAI,CA8BxF;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAW9E;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,QAepF;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,QAatF;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAO3F;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAUT;AAED,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAGhD;AAED,uFAAuF;AACvF,wBAAgB,uBAAuB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqCxE;AAID,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,wBAAgB,yBAAyB,IAAI,SAAS,MAAM,EAAE,CAE7D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,IAAI,CA0BrD;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAclE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAS1D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,QAMtD;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAWT;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAc/D;AAED,wBAAgB,oBAAoB,SAKnC"}
|