orizu 0.5.51 → 0.5.53
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/app-commands.d.ts.map +1 -1
- package/dist/app-commands.js +4 -12
- package/dist/auth-commands.d.ts.map +1 -1
- package/dist/auth-commands.js +5 -108
- package/dist/cli-console-output.d.ts +7 -1
- package/dist/cli-console-output.d.ts.map +1 -1
- package/dist/cli-console-output.js +16 -3
- package/dist/cli-stops.d.ts +14 -0
- package/dist/cli-stops.d.ts.map +1 -0
- package/dist/cli-stops.js +22 -0
- package/dist/cli-write-commands.d.ts +143 -0
- package/dist/cli-write-commands.d.ts.map +1 -0
- package/dist/cli-write-commands.js +123 -0
- package/dist/egress-allowlist-cli.d.ts +29 -2
- package/dist/egress-allowlist-cli.d.ts.map +1 -1
- package/dist/egress-allowlist-cli.js +16 -89
- package/dist/egress-allowlist-workflow.d.ts +17 -0
- package/dist/egress-allowlist-workflow.d.ts.map +1 -0
- package/dist/egress-allowlist-workflow.js +183 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -50
- package/dist/instruction-delivery.d.ts +4 -4
- package/dist/instruction-delivery.d.ts.map +1 -1
- package/dist/instruction-delivery.js +32 -46
- package/dist/instruction-prune.d.ts +24 -0
- package/dist/instruction-prune.d.ts.map +1 -0
- package/dist/instruction-prune.js +33 -0
- package/dist/instruction-set-sync/index.d.ts +0 -2
- package/dist/instruction-set-sync/index.d.ts.map +1 -1
- package/dist/instruction-set-sync/index.js +3 -36
- package/dist/instruction-set-update/index.d.ts +41 -3
- package/dist/instruction-set-update/index.d.ts.map +1 -1
- package/dist/instruction-set-update/index.js +156 -132
- package/dist/instruction-sets-cli.d.ts.map +1 -1
- package/dist/instruction-sets-cli.js +21 -2
- package/dist/instruction-sync-lock.d.ts +9 -0
- package/dist/instruction-sync-lock.d.ts.map +1 -0
- package/dist/instruction-sync-lock.js +24 -0
- package/dist/json-output-scrub.d.ts +3 -0
- package/dist/json-output-scrub.d.ts.map +1 -0
- package/dist/json-output-scrub.js +70 -0
- package/dist/last-error-record.d.ts +7 -0
- package/dist/last-error-record.d.ts.map +1 -1
- package/dist/last-error-record.js +14 -2
- package/dist/login-flow.d.ts +37 -0
- package/dist/login-flow.d.ts.map +1 -0
- package/dist/login-flow.js +295 -0
- package/dist/logout-diagnostic.d.ts.map +1 -1
- package/dist/logout-diagnostic.js +2 -1
- package/dist/manifests-cli.d.ts.map +1 -1
- package/dist/manifests-cli.js +36 -22
- package/dist/one-request-write.d.ts +59 -0
- package/dist/one-request-write.d.ts.map +1 -0
- package/dist/one-request-write.js +150 -0
- package/dist/provider-write-workflow.d.ts +12 -0
- package/dist/provider-write-workflow.d.ts.map +1 -0
- package/dist/provider-write-workflow.js +110 -0
- package/dist/providers-cli.d.ts.map +1 -1
- package/dist/providers-cli.js +27 -23
- package/dist/scores-accept-cli.d.ts +1 -1
- package/dist/scores-accept-cli.d.ts.map +1 -1
- package/dist/scores-accept-cli.js +4 -28
- package/dist/task-commands.d.ts.map +1 -1
- package/dist/task-commands.js +26 -62
- package/dist/workbench-cli.d.ts +2 -1
- package/dist/workbench-cli.d.ts.map +1 -1
- package/dist/workbench-cli.js +79 -593
- package/dist/workbench-workflows.d.ts +56 -0
- package/dist/workbench-workflows.d.ts.map +1 -0
- package/dist/workbench-workflows.js +665 -0
- package/dist/workspace-sync-workflow.d.ts +115 -0
- package/dist/workspace-sync-workflow.d.ts.map +1 -0
- package/dist/workspace-sync-workflow.js +642 -0
- package/dist/workspace-sync.d.ts +45 -97
- package/dist/workspace-sync.d.ts.map +1 -1
- package/dist/workspace-sync.js +53 -494
- package/package.json +1 -1
- package/src/app-commands.ts +3 -18
- package/src/auth-commands.ts +8 -127
- package/src/cli-console-output.ts +16 -2
- package/src/cli-stops.ts +27 -0
- package/src/cli-write-commands.ts +143 -0
- package/src/egress-allowlist-cli.ts +18 -90
- package/src/egress-allowlist-workflow.ts +198 -0
- package/src/index.ts +23 -57
- package/src/instruction-delivery.ts +31 -47
- package/src/instruction-prune.ts +59 -0
- package/src/instruction-set-sync/index.ts +3 -43
- package/src/instruction-set-update/index.ts +173 -122
- package/src/instruction-sets-cli.ts +23 -2
- package/src/instruction-sync-lock.ts +27 -0
- package/src/json-output-scrub.ts +73 -0
- package/src/last-error-record.ts +16 -2
- package/src/login-flow.ts +368 -0
- package/src/logout-diagnostic.ts +2 -1
- package/src/manifests-cli.ts +36 -23
- package/src/one-request-write.ts +184 -0
- package/src/provider-write-workflow.ts +117 -0
- package/src/providers-cli.ts +24 -17
- package/src/scores-accept-cli.ts +4 -46
- package/src/task-commands.ts +22 -115
- package/src/workbench-cli.ts +83 -684
- package/src/workbench-workflows.ts +815 -0
- package/src/workspace-sync-workflow.ts +838 -0
- package/src/workspace-sync.ts +63 -630
- package/dist/headless-login.d.ts +0 -19
- package/dist/headless-login.d.ts.map +0 -1
- package/dist/headless-login.js +0 -108
- package/src/headless-login.ts +0 -192
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-commands.d.ts","sourceRoot":"","sources":["../src/app-commands.ts"],"names":[],"mappings":"AAuCA,iBAAe,QAAQ,kBActB;AAED,iBAAS,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAU/C;AAED,iBAAS,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAUhD;AAED,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE9D;AAeD,iBAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElE;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG1F;AAED,iBAAS,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,E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B,CAAA"}
|
package/dist/app-commands.js
CHANGED
|
@@ -433,18 +433,10 @@ async function linkAppDataset() {
|
|
|
433
433
|
const selected = await selectAppIdInteractively(project);
|
|
434
434
|
appId = selected.appId;
|
|
435
435
|
}
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
datasetId,
|
|
441
|
-
versionNum,
|
|
442
|
-
}),
|
|
443
|
-
});
|
|
444
|
-
if (!response.ok) {
|
|
445
|
-
throw new Error(`Failed to link dataset: ${await response.text()}`);
|
|
446
|
-
}
|
|
447
|
-
const data = await parseJsonResponse(response, 'App link dataset');
|
|
436
|
+
const writes = await import('./cli-write-commands.js');
|
|
437
|
+
const data = await writes.sendCommandWrite(writes.appLinkDataset(appId, { datasetId, ...(versionNum === undefined ? {} : { versionNum }) }), { json: hasJsonFlag(), print: printLine });
|
|
438
|
+
if (!data)
|
|
439
|
+
return;
|
|
448
440
|
if (hasJsonFlag()) {
|
|
449
441
|
printJson({ app: data.app, linkedDataset: data.linkedDataset, versionNum: data.versionNum });
|
|
450
442
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-commands.d.ts","sourceRoot":"","sources":["../src/auth-commands.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth-commands.d.ts","sourceRoot":"","sources":["../src/auth-commands.ts"],"names":[],"mappings":"AAyBA,iBAAS,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,cAAc,CAEnE;AAMD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5D;AAQD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,GAAG,CAwB5E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAgBtD;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzC;AA4BD,iBAAe,KAAK,CAAC,eAAe,CAAC,EAAE,MAAM,iBAoC5C;AA4BD,iBAAe,MAAM,kBAWpB;AAED,iBAAe,MAAM,CAAC,eAAe,CAAC,EAAE,MAAM,iBAwC7C;AAED,iBAAe,QAAQ,kBA0BtB;AAED,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA"}
|
package/dist/auth-commands.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
// ORI-2044: moved from index.ts to keep auth commands together.
|
|
2
2
|
import { randomBytes, createHash } from 'crypto';
|
|
3
|
-
import { spawn } from 'child_process';
|
|
4
|
-
import { createServer } from 'http';
|
|
5
3
|
import { sanitizeTerminalText, parseJsonResponse } from './json-response.js';
|
|
6
4
|
import { isInteractiveTerminal, hasArg, hasJsonFlag, getArg } from './command-line-arguments.js';
|
|
7
5
|
import { getBaseUrl, resolveLoginTarget, resolveLogoutTarget, assertSecureTokenTransport, authedFetch, } from './http.js';
|
|
8
6
|
import { clearUnreadableServerCredentials, hasResolvableAuth, rememberProcessSecret, saveServerCredentials, getServerCredentials, 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';
|
|
7
|
+
import { printJson, printJsonWithHeldSecrets, printLine, printLoginProgress } from './cli-console-output.js';
|
|
12
8
|
import { resolveProjectSelection } from './account-directory.js';
|
|
13
9
|
function isNodeError(error) {
|
|
14
10
|
return error instanceof Error;
|
|
@@ -46,30 +42,6 @@ export function validateBrowserUrl(url, expectedOrigin) {
|
|
|
46
42
|
}
|
|
47
43
|
return parsed;
|
|
48
44
|
}
|
|
49
|
-
function openInBrowser(url) {
|
|
50
|
-
const parsed = validateBrowserUrl(url);
|
|
51
|
-
const platform = process.platform;
|
|
52
|
-
const href = parsed.href;
|
|
53
|
-
if (platform === 'darwin') {
|
|
54
|
-
spawn('open', [href], {
|
|
55
|
-
detached: true,
|
|
56
|
-
stdio: 'ignore',
|
|
57
|
-
}).unref();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (platform === 'win32') {
|
|
61
|
-
spawn('rundll32.exe', ['url.dll,FileProtocolHandler', href], {
|
|
62
|
-
detached: true,
|
|
63
|
-
stdio: 'ignore',
|
|
64
|
-
windowsHide: true,
|
|
65
|
-
}).unref();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
spawn('xdg-open', [href], {
|
|
69
|
-
detached: true,
|
|
70
|
-
stdio: 'ignore',
|
|
71
|
-
}).unref();
|
|
72
|
-
}
|
|
73
45
|
export function formatTerminalLink(url) {
|
|
74
46
|
const safeUrl = sanitizeTerminalText(url);
|
|
75
47
|
try {
|
|
@@ -154,85 +126,10 @@ async function authenticateAtBaseUrl(baseUrl) {
|
|
|
154
126
|
}
|
|
155
127
|
const codeVerifier = rememberProcessSecret(createCodeVerifier());
|
|
156
128
|
const codeChallenge = createCodeChallenge(codeVerifier);
|
|
129
|
+
// Effect loads here, after the already-logged-in check (ORI-2422).
|
|
130
|
+
const { completeLogin, shouldUseHeadlessLogin } = await import('./login-flow.js');
|
|
157
131
|
const isHeadlessLogin = shouldUseHeadlessLogin({ isForced: hasArg('--headless') });
|
|
158
|
-
|
|
159
|
-
const redirectUri = callbackPort === undefined ? undefined : `http://127.0.0.1:${callbackPort}/callback`;
|
|
160
|
-
const callbackCode = isHeadlessLogin
|
|
161
|
-
? await waitForHeadlessAuthorization({ baseUrl, codeChallenge }, {
|
|
162
|
-
parseJsonResponse,
|
|
163
|
-
printProgress: printLoginProgress,
|
|
164
|
-
sanitizeTerminalText,
|
|
165
|
-
validateBrowserUrl,
|
|
166
|
-
})
|
|
167
|
-
: await new Promise((resolve, reject) => {
|
|
168
|
-
const server = createServer((request, response) => {
|
|
169
|
-
try {
|
|
170
|
-
const url = new URL(request.url || '/', `http://127.0.0.1:${callbackPort}`);
|
|
171
|
-
const code = url.searchParams.get('code');
|
|
172
|
-
if (!code) {
|
|
173
|
-
response.statusCode = 400;
|
|
174
|
-
response.setHeader('content-type', 'text/html; charset=utf-8');
|
|
175
|
-
response.end(renderCliAuthBrowserPage('error'));
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
response.statusCode = 200;
|
|
179
|
-
response.setHeader('content-type', 'text/html; charset=utf-8');
|
|
180
|
-
response.end(renderCliAuthBrowserPage('success'));
|
|
181
|
-
server.close();
|
|
182
|
-
resolve(code);
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
server.close();
|
|
186
|
-
reject(error);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
server.on('error', (error) => {
|
|
190
|
-
if (error.code === 'EADDRINUSE') {
|
|
191
|
-
reject(new Error(`Port ${callbackPort} is already in use. Set ORIZU_AUTH_PORT to a different port (1024–65535) and retry.`));
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
reject(error);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
server.listen(callbackPort, '127.0.0.1', async () => {
|
|
198
|
-
try {
|
|
199
|
-
const response = await fetch(`${baseUrl}/api/cli/auth/start`, {
|
|
200
|
-
method: 'POST',
|
|
201
|
-
headers: { 'Content-Type': 'application/json' },
|
|
202
|
-
body: JSON.stringify({ codeChallenge, redirectUri }),
|
|
203
|
-
});
|
|
204
|
-
if (!response.ok) {
|
|
205
|
-
const text = await response.text();
|
|
206
|
-
server.close();
|
|
207
|
-
reject(new Error(`Failed to start login: ${text}`));
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
const { authorizeUrl } = await parseJsonResponse(response, 'CLI auth start');
|
|
211
|
-
const safeAuthorizeUrl = validateBrowserUrl(authorizeUrl, baseUrl).href;
|
|
212
|
-
printLoginProgress(`Opening browser for login: ${sanitizeTerminalText(safeAuthorizeUrl)}`);
|
|
213
|
-
openInBrowser(safeAuthorizeUrl);
|
|
214
|
-
}
|
|
215
|
-
catch (error) {
|
|
216
|
-
server.close();
|
|
217
|
-
reject(error);
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
rememberProcessSecret(callbackCode);
|
|
222
|
-
const exchangeResponse = await fetch(`${baseUrl}/api/cli/auth/exchange`, {
|
|
223
|
-
method: 'POST',
|
|
224
|
-
headers: { 'Content-Type': 'application/json' },
|
|
225
|
-
body: JSON.stringify({ code: callbackCode, codeVerifier, redirectUri }),
|
|
226
|
-
});
|
|
227
|
-
if (!exchangeResponse.ok) {
|
|
228
|
-
const text = await exchangeResponse.text();
|
|
229
|
-
throw new Error(`Failed to exchange auth code: ${text}`);
|
|
230
|
-
}
|
|
231
|
-
const loginData = await parseJsonResponse(exchangeResponse, 'CLI auth exchange');
|
|
232
|
-
if (!loginData.apiKey) {
|
|
233
|
-
throw new Error('Server did not return an API key. Upgrade the Orizu server and run `orizu login` again.');
|
|
234
|
-
}
|
|
235
|
-
return { ...loginData, apiKey: loginData.apiKey };
|
|
132
|
+
return completeLogin({ baseUrl, codeVerifier, codeChallenge, callbackPort: isHeadlessLogin ? undefined : resolveAuthCallbackPort() }, { parseJsonResponse, printProgress: printLoginProgress, sanitizeTerminalText, validateBrowserUrl });
|
|
236
133
|
}
|
|
237
134
|
async function whoami() {
|
|
238
135
|
const response = await authedFetch('/api/cli/auth/whoami');
|
|
@@ -299,7 +196,7 @@ async function printEnv() {
|
|
|
299
196
|
const projectId = project?.id || getArg('--project-id') || process.env.ORIZU_PROJECT_ID || '';
|
|
300
197
|
const projectSlug = project ? `${project.teamSlug}/${project.slug}` : process.env.ORIZU_PROJECT || '';
|
|
301
198
|
if (hasJsonFlag()) {
|
|
302
|
-
|
|
199
|
+
printJsonWithHeldSecrets({
|
|
303
200
|
ORIZU_API_URL: baseUrl,
|
|
304
201
|
ORIZU_TOKEN: token,
|
|
305
202
|
ORIZU_PROJECT_ID: projectId,
|
|
@@ -8,5 +8,11 @@ declare function printError(message: string): void;
|
|
|
8
8
|
declare function printLoginProgress(message: string): void;
|
|
9
9
|
declare function printPushDisclosures(data: Record<string, unknown>): void;
|
|
10
10
|
declare function printJson(value: Record<string, unknown>): void;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The one --json output allowed to carry a held secret: `orizu env --json`
|
|
13
|
+
* prints the token so a script can export it. Any new caller needs its own
|
|
14
|
+
* reviewed change and a case in cli-json-output-scrub-process.test.ts.
|
|
15
|
+
*/
|
|
16
|
+
declare function printJsonWithHeldSecrets(value: Record<string, unknown>): void;
|
|
17
|
+
export { getErrorMessage, printJson, printJsonWithHeldSecrets, printLine, printPushDisclosures, getCliVersion, printBannerIfInteractive, printVersion, printUsage, printError, printLoginProgress, };
|
|
12
18
|
//# sourceMappingURL=cli-console-output.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-console-output.d.ts","sourceRoot":"","sources":["../src/cli-console-output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-console-output.d.ts","sourceRoot":"","sources":["../src/cli-console-output.ts"],"names":[],"mappings":"AAWA,iBAAS,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE/C;AAED,iBAAS,aAAa,IAAI,MAAM,CAU/B;AAGD,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;;;;GAIG;AACH,iBAAS,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAI/D;AAED,OAAO,EACL,eAAe,EACf,SAAS,EACT,wBAAwB,EACxB,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,kBAAkB,GACnB,CAAA"}
|
|
@@ -4,7 +4,8 @@ import { stdout as output } from 'process';
|
|
|
4
4
|
import { renderBanner } from './banner.js';
|
|
5
5
|
import { renderRootHelp } from './help.js';
|
|
6
6
|
import { sanitizeTerminalText } from './json-response.js';
|
|
7
|
-
import { hasJsonFlag } from './command-line-arguments.js';
|
|
7
|
+
import { cliArgs, hasJsonFlag } from './command-line-arguments.js';
|
|
8
|
+
import { hideHeldSecrets } from './json-output-scrub.js';
|
|
8
9
|
import { reportReplacementWarning } from './report-replacement-warning.js';
|
|
9
10
|
function getErrorMessage(error) {
|
|
10
11
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -16,8 +17,9 @@ function getCliVersion() {
|
|
|
16
17
|
}
|
|
17
18
|
return packageJson.version;
|
|
18
19
|
}
|
|
20
|
+
// ORI-2744: under --json, stdout never carries a secret this process holds.
|
|
19
21
|
function printLine(message = '') {
|
|
20
|
-
output.write(`${message}\n`);
|
|
22
|
+
output.write(`${hasJsonFlag() ? hideHeldSecrets(message) : message}\n`);
|
|
21
23
|
}
|
|
22
24
|
function printVersion() {
|
|
23
25
|
printLine(`orizu ${getCliVersion()}`);
|
|
@@ -54,4 +56,15 @@ function printPushDisclosures(data) {
|
|
|
54
56
|
function printJson(value) {
|
|
55
57
|
printLine(JSON.stringify(value));
|
|
56
58
|
}
|
|
57
|
-
|
|
59
|
+
/**
|
|
60
|
+
* The one --json output allowed to carry a held secret: `orizu env --json`
|
|
61
|
+
* prints the token so a script can export it. Any new caller needs its own
|
|
62
|
+
* reviewed change and a case in cli-json-output-scrub-process.test.ts.
|
|
63
|
+
*/
|
|
64
|
+
function printJsonWithHeldSecrets(value) {
|
|
65
|
+
// Any other command is scrubbed as usual, so a wrong caller can't leak.
|
|
66
|
+
if (cliArgs[0] !== 'env')
|
|
67
|
+
return printJson(value);
|
|
68
|
+
output.write(`${JSON.stringify(value)}\n`);
|
|
69
|
+
}
|
|
70
|
+
export { getErrorMessage, printJson, printJsonWithHeldSecrets, printLine, printPushDisclosures, getCliVersion, printBannerIfInteractive, printVersion, printUsage, printError, printLoginProgress, };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
export interface Interrupted {
|
|
3
|
+
interrupted: 130 | 143;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Runs the program with Ctrl-C and SIGTERM turned into an interrupt, and says
|
|
7
|
+
* which stop arrived, if any. `once`: a second signal falls through to Node's
|
|
8
|
+
* default kill. The handlers are removed before this returns.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runWithStops<A>(program: (signal: AbortSignal) => Effect.Effect<A, unknown>): Promise<{
|
|
11
|
+
exit: import("effect/Exit").Exit<A, unknown>;
|
|
12
|
+
interrupted: 130 | 143 | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=cli-stops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-stops.d.ts","sourceRoot":"","sources":["../src/cli-stops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAK/B,MAAM,WAAW,WAAW;IAAG,WAAW,EAAE,GAAG,GAAG,GAAG,CAAA;CAAE;AAEvD;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;;;GAchG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
/**
|
|
3
|
+
* Runs the program with Ctrl-C and SIGTERM turned into an interrupt, and says
|
|
4
|
+
* which stop arrived, if any. `once`: a second signal falls through to Node's
|
|
5
|
+
* default kill. The handlers are removed before this returns.
|
|
6
|
+
*/
|
|
7
|
+
export async function runWithStops(program) {
|
|
8
|
+
const controller = new AbortController();
|
|
9
|
+
let interrupted;
|
|
10
|
+
const handleInterrupt = () => { interrupted ??= 130; controller.abort(); };
|
|
11
|
+
const handleTerminate = () => { interrupted ??= 143; controller.abort(); };
|
|
12
|
+
process.once('SIGINT', handleInterrupt);
|
|
13
|
+
process.once('SIGTERM', handleTerminate);
|
|
14
|
+
try {
|
|
15
|
+
const exit = await Effect.runPromiseExit(program(controller.signal), { signal: controller.signal });
|
|
16
|
+
return { exit, interrupted };
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
process.removeListener('SIGINT', handleInterrupt);
|
|
20
|
+
process.removeListener('SIGTERM', handleTerminate);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { type OneRequestWrite } from './one-request-write.js';
|
|
3
|
+
type Write<A> = Pick<OneRequestWrite<A>, 'label' | 'name' | 'path' | 'method' | 'body' | 'reply' | 'mayAlreadyBeSaved' | 'describeError'>;
|
|
4
|
+
declare const TaskCreated: Schema.Struct<{
|
|
5
|
+
readonly task: Schema.Struct<{
|
|
6
|
+
readonly id: Schema.String;
|
|
7
|
+
readonly title: Schema.String;
|
|
8
|
+
readonly status: Schema.String;
|
|
9
|
+
readonly requiredAssignmentsPerRow: Schema.Number;
|
|
10
|
+
readonly versionId: Schema.String;
|
|
11
|
+
readonly versionNum: Schema.Number;
|
|
12
|
+
}>;
|
|
13
|
+
readonly assignmentsCreated: Schema.Number;
|
|
14
|
+
readonly assignmentShortfall: Schema.optionalKey<Schema.Number>;
|
|
15
|
+
readonly warning: Schema.optionalKey<Schema.String>;
|
|
16
|
+
}>;
|
|
17
|
+
/** Running it again makes a second task (and, with --publish, emails labellers again). */
|
|
18
|
+
export declare const taskCreate: (body: Record<string, unknown>, describeError: Write<typeof TaskCreated.Type>["describeError"]) => Write<typeof TaskCreated.Type>;
|
|
19
|
+
declare const TaskUpdated: Schema.Struct<{
|
|
20
|
+
readonly task: Schema.Struct<{
|
|
21
|
+
readonly id: Schema.String;
|
|
22
|
+
readonly title: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
23
|
+
readonly status: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
24
|
+
readonly dataset_id: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
25
|
+
readonly app_id: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
26
|
+
readonly version_id: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
27
|
+
readonly required_assignments_per_row: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
|
|
28
|
+
}>;
|
|
29
|
+
readonly assignmentMode: Schema.optionalKey<Schema.String>;
|
|
30
|
+
readonly assignmentsCreated: Schema.optionalKey<Schema.Number>;
|
|
31
|
+
}>;
|
|
32
|
+
/** Sets the same values again, so a repeat is safe. */
|
|
33
|
+
export declare const taskUpdate: (id: string, body: Record<string, unknown>) => Write<typeof TaskUpdated.Type>;
|
|
34
|
+
declare const Discarded: Schema.Struct<{
|
|
35
|
+
readonly success: Schema.Boolean;
|
|
36
|
+
}>;
|
|
37
|
+
/** Once the draft is gone, a repeat is refused as "not found". */
|
|
38
|
+
export declare const taskDiscard: (id: string) => Write<typeof Discarded.Type>;
|
|
39
|
+
declare const Published: Schema.Struct<{
|
|
40
|
+
readonly assignmentsProcessed: Schema.Number;
|
|
41
|
+
readonly assignmentsCreated: Schema.Number;
|
|
42
|
+
readonly assignmentsRemoved: Schema.optionalKey<Schema.Number>;
|
|
43
|
+
readonly assignmentShortfall: Schema.optionalKey<Schema.Number>;
|
|
44
|
+
readonly warning: Schema.optionalKey<Schema.String>;
|
|
45
|
+
readonly task: Schema.Struct<{
|
|
46
|
+
readonly id: Schema.String;
|
|
47
|
+
readonly status: Schema.String;
|
|
48
|
+
}>;
|
|
49
|
+
}>;
|
|
50
|
+
/** Once published, a repeat is refused as "must be a draft". */
|
|
51
|
+
export declare const taskPublish: (id: string, body: Record<string, unknown>) => Write<typeof Published.Type>;
|
|
52
|
+
declare const Assigned: Schema.Struct<{
|
|
53
|
+
assignmentsCreated: Schema.Number;
|
|
54
|
+
assignmentsProcessed: Schema.optionalKey<Schema.Number>;
|
|
55
|
+
assignmentsRemoved: Schema.optionalKey<Schema.Number>;
|
|
56
|
+
assignmentShortfall: Schema.optionalKey<Schema.Number>;
|
|
57
|
+
warning: Schema.optionalKey<Schema.String>;
|
|
58
|
+
}>;
|
|
59
|
+
/** Adds only missing pairs and emails only new people, so a repeat is safe. */
|
|
60
|
+
export declare const taskAssign: (id: string, body: Record<string, unknown>) => Write<typeof Assigned.Type>;
|
|
61
|
+
declare const StatusChanged: Schema.Struct<{
|
|
62
|
+
readonly task: Schema.Struct<{
|
|
63
|
+
readonly id: Schema.String;
|
|
64
|
+
readonly status: Schema.String;
|
|
65
|
+
}>;
|
|
66
|
+
}>;
|
|
67
|
+
/** Setting the status a task already has changes nothing. */
|
|
68
|
+
export declare const taskStatus: (id: string, verb: string, status: string) => Write<typeof StatusChanged.Type>;
|
|
69
|
+
declare const RunStarted: Schema.Struct<{
|
|
70
|
+
readonly optimization_run_id: Schema.String;
|
|
71
|
+
readonly optimizationRun: Schema.Struct<{
|
|
72
|
+
readonly id: Schema.String;
|
|
73
|
+
readonly status: Schema.String;
|
|
74
|
+
readonly startedAt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
75
|
+
readonly createdAt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
76
|
+
}>;
|
|
77
|
+
}>;
|
|
78
|
+
/** The server picks a new run id per request, so running it again starts a second run. */
|
|
79
|
+
export declare const optimizationStart: (project: string, body: Record<string, unknown>) => Write<typeof RunStarted.Type>;
|
|
80
|
+
declare const RunChanged: Schema.Struct<{
|
|
81
|
+
readonly optimizationRun: Schema.Struct<{
|
|
82
|
+
readonly id: Schema.String;
|
|
83
|
+
readonly status: Schema.optionalKey<Schema.String>;
|
|
84
|
+
readonly startedAt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
85
|
+
readonly finishedAt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
86
|
+
readonly bestScore: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
|
|
87
|
+
readonly bestCandidateId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
88
|
+
readonly resultPromptVersionId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
89
|
+
readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
90
|
+
}>;
|
|
91
|
+
readonly cancellationStatus: Schema.optionalKey<Schema.Literal<"already_terminal">>;
|
|
92
|
+
}>;
|
|
93
|
+
/** Writing the status a run already has again converges, so a repeat is safe. */
|
|
94
|
+
export declare const optimizationLifecycle: (runId: string, body: Record<string, unknown>) => Write<typeof RunChanged.Type>;
|
|
95
|
+
declare const EventLogged: Schema.Struct<{
|
|
96
|
+
readonly eventId: Schema.String;
|
|
97
|
+
}>;
|
|
98
|
+
/** A repeat with the same event id changes nothing; a new id is refused as a sequence clash. */
|
|
99
|
+
export declare const optimizationEvent: (runId: string, body: Record<string, unknown> & {
|
|
100
|
+
eventId: string;
|
|
101
|
+
}) => Write<typeof EventLogged.Type>;
|
|
102
|
+
declare const Linked: Schema.Struct<{
|
|
103
|
+
readonly app: Schema.Struct<{
|
|
104
|
+
readonly id: Schema.String;
|
|
105
|
+
readonly name: Schema.String;
|
|
106
|
+
}>;
|
|
107
|
+
readonly linkedDataset: Schema.Struct<{
|
|
108
|
+
readonly id: Schema.String;
|
|
109
|
+
readonly name: Schema.String;
|
|
110
|
+
}>;
|
|
111
|
+
readonly versionNum: Schema.Number;
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* A plain overwrite, so a repeat is safe; without --version it links the
|
|
115
|
+
* app's current version at the time, which may have moved on.
|
|
116
|
+
*/
|
|
117
|
+
export declare const appLinkDataset: (appId: string, body: {
|
|
118
|
+
datasetId: string;
|
|
119
|
+
versionNum?: number;
|
|
120
|
+
}) => Write<typeof Linked.Type>;
|
|
121
|
+
declare const Accepted: Schema.Struct<{
|
|
122
|
+
readonly scoreRun: Schema.Struct<{
|
|
123
|
+
readonly id: Schema.String;
|
|
124
|
+
readonly provenance: Schema.String;
|
|
125
|
+
readonly acceptedByUserId: Schema.NullOr<Schema.String>;
|
|
126
|
+
readonly acceptedAt: Schema.NullOr<Schema.String>;
|
|
127
|
+
readonly alreadyAccepted: Schema.Boolean;
|
|
128
|
+
}>;
|
|
129
|
+
}>;
|
|
130
|
+
/** The first acceptance is kept and a repeat says "already accepted". */
|
|
131
|
+
export declare const scoreAccept: (project: string, scoreRunId: string) => Write<typeof Accepted.Type>;
|
|
132
|
+
declare const ManifestRejected: Schema.Struct<{
|
|
133
|
+
readonly manifest: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
134
|
+
}>;
|
|
135
|
+
/** Once rejected, a repeat is refused, so the advice is to look first. */
|
|
136
|
+
export declare const manifestReject: (id: string) => Write<typeof ManifestRejected.Type>;
|
|
137
|
+
/** Sends a write with this command's `--json` setting and output. Ctrl-C sets the exit code and returns null. */
|
|
138
|
+
export declare function sendCommandWrite<A>(write: Write<A>, io: {
|
|
139
|
+
json: boolean;
|
|
140
|
+
print: (line: string) => void;
|
|
141
|
+
}): Promise<A | null>;
|
|
142
|
+
export {};
|
|
143
|
+
//# sourceMappingURL=cli-write-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-write-commands.d.ts","sourceRoot":"","sources":["../src/cli-write-commands.ts"],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QAAQ;;;;;;;;EAEZ,CAAA;AACF,yEAAyE;AACzE,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,EAAE,YAAY,MAAM,KAAG,KAAK,CAAC,OAAO,QAAQ,CAAC,IAAI,CAG1F,CAAA;AAEF,QAAA,MAAM,gBAAgB;;EAAmE,CAAA;AACzF,0EAA0E;AAC1E,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,KAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAG5E,CAAA;AAEF,iHAAiH;AACjH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAKlI"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { sendOneRequestWrite } from './one-request-write.js';
|
|
3
|
+
// ORI-2726: what each one-request write command sends, the reply it expects,
|
|
4
|
+
// and what to tell a person when the write may already be saved. The advice
|
|
5
|
+
// follows what the server does when the same request arrives twice. Loaded
|
|
6
|
+
// only through `await import(...)`, so commands that never write skip Effect.
|
|
7
|
+
const SAFE = 'running the same command again is safe';
|
|
8
|
+
const note = (thing, done, advice) => ({ thing, done, advice });
|
|
9
|
+
const task = (id) => `/api/cli/tasks/${encodeURIComponent(id)}`;
|
|
10
|
+
const Count = Schema.Number;
|
|
11
|
+
const Text = Schema.String;
|
|
12
|
+
const Assignments = {
|
|
13
|
+
assignmentsCreated: Count,
|
|
14
|
+
assignmentsProcessed: Schema.optionalKey(Count),
|
|
15
|
+
assignmentsRemoved: Schema.optionalKey(Count),
|
|
16
|
+
assignmentShortfall: Schema.optionalKey(Count),
|
|
17
|
+
warning: Schema.optionalKey(Text),
|
|
18
|
+
};
|
|
19
|
+
const TaskCreated = Schema.Struct({
|
|
20
|
+
task: Schema.Struct({ id: Text, title: Text, status: Text, requiredAssignmentsPerRow: Count, versionId: Text, versionNum: Count }),
|
|
21
|
+
assignmentsCreated: Count,
|
|
22
|
+
assignmentShortfall: Schema.optionalKey(Count),
|
|
23
|
+
warning: Schema.optionalKey(Text),
|
|
24
|
+
});
|
|
25
|
+
/** Running it again makes a second task (and, with --publish, emails labellers again). */
|
|
26
|
+
export const taskCreate = (body, describeError) => ({
|
|
27
|
+
label: 'create task', name: 'Task create', path: '/api/cli/tasks', method: 'POST', body, reply: TaskCreated, describeError,
|
|
28
|
+
mayAlreadyBeSaved: note('task', 'created', 'check `orizu tasks list` before creating it again (running it again makes a second task)'),
|
|
29
|
+
});
|
|
30
|
+
const Nullable = (schema) => Schema.optionalKey(Schema.NullOr(schema));
|
|
31
|
+
const TaskUpdated = Schema.Struct({
|
|
32
|
+
task: Schema.Struct({
|
|
33
|
+
id: Text, title: Nullable(Text), status: Nullable(Text), dataset_id: Nullable(Text), app_id: Nullable(Text),
|
|
34
|
+
version_id: Nullable(Text), required_assignments_per_row: Nullable(Count),
|
|
35
|
+
}),
|
|
36
|
+
assignmentMode: Schema.optionalKey(Text),
|
|
37
|
+
assignmentsCreated: Schema.optionalKey(Count),
|
|
38
|
+
});
|
|
39
|
+
/** Sets the same values again, so a repeat is safe. */
|
|
40
|
+
export const taskUpdate = (id, body) => ({
|
|
41
|
+
label: 'update task', name: 'Task update', path: task(id), method: 'PATCH', body, reply: TaskUpdated, mayAlreadyBeSaved: note('task change', 'saved', SAFE),
|
|
42
|
+
});
|
|
43
|
+
const Discarded = Schema.Struct({ success: Schema.Boolean });
|
|
44
|
+
/** Once the draft is gone, a repeat is refused as "not found". */
|
|
45
|
+
export const taskDiscard = (id) => ({
|
|
46
|
+
label: 'discard draft task', name: 'Draft discard', path: task(id), method: 'DELETE', reply: Discarded,
|
|
47
|
+
mayAlreadyBeSaved: note('draft', 'discarded', 'check `orizu tasks list`; once it is gone, running it again answers "Task not found or access denied"'),
|
|
48
|
+
});
|
|
49
|
+
const Published = Schema.Struct({ task: Schema.Struct({ id: Text, status: Text }), ...Assignments, assignmentsProcessed: Count });
|
|
50
|
+
/** Once published, a repeat is refused as "must be a draft". */
|
|
51
|
+
export const taskPublish = (id, body) => ({
|
|
52
|
+
label: 'publish task', name: 'Task publish', path: `${task(id)}/publish`, method: 'POST', body, reply: Published,
|
|
53
|
+
mayAlreadyBeSaved: note('task', 'published', `check \`orizu tasks status --task ${id}\`; once published, running it again answers "Task must be a draft before publishing"`),
|
|
54
|
+
});
|
|
55
|
+
const Assigned = Schema.Struct(Assignments);
|
|
56
|
+
/** Adds only missing pairs and emails only new people, so a repeat is safe. */
|
|
57
|
+
export const taskAssign = (id, body) => ({
|
|
58
|
+
label: 'assign task', name: 'Task assign', path: `${task(id)}/assign`, method: 'POST', body, reply: Assigned, mayAlreadyBeSaved: note('assignments', 'saved', SAFE),
|
|
59
|
+
});
|
|
60
|
+
const StatusChanged = Schema.Struct({ task: Schema.Struct({ id: Text, status: Text }) });
|
|
61
|
+
/** Setting the status a task already has changes nothing. */
|
|
62
|
+
export const taskStatus = (id, verb, status) => ({
|
|
63
|
+
label: `${verb} task`, name: `Task ${verb}`, path: `${task(id)}/status`, method: 'PATCH', body: { status }, reply: StatusChanged,
|
|
64
|
+
mayAlreadyBeSaved: note('task status change', 'saved', SAFE),
|
|
65
|
+
});
|
|
66
|
+
const RunStarted = Schema.Struct({
|
|
67
|
+
optimization_run_id: Text,
|
|
68
|
+
optimizationRun: Schema.Struct({ id: Text, status: Text, startedAt: Nullable(Text), createdAt: Nullable(Text) }),
|
|
69
|
+
});
|
|
70
|
+
/** The server picks a new run id per request, so running it again starts a second run. */
|
|
71
|
+
export const optimizationStart = (project, body) => ({
|
|
72
|
+
label: 'start optimization run', name: 'Optimization run start', path: `/api/cli/optimization-runs?project=${encodeURIComponent(project)}`, method: 'POST', body, reply: RunStarted,
|
|
73
|
+
mayAlreadyBeSaved: note('run', 'started', 'check `orizu optimizations list` before starting again (running it again starts a second run)'),
|
|
74
|
+
});
|
|
75
|
+
const RunChanged = Schema.Struct({
|
|
76
|
+
optimizationRun: Schema.Struct({
|
|
77
|
+
id: Text, status: Schema.optionalKey(Text), startedAt: Nullable(Text), finishedAt: Nullable(Text), bestScore: Nullable(Count),
|
|
78
|
+
bestCandidateId: Nullable(Text), resultPromptVersionId: Nullable(Text), metadata: Schema.optionalKey(Schema.Record(Text, Schema.Unknown)),
|
|
79
|
+
}),
|
|
80
|
+
cancellationStatus: Schema.optionalKey(Schema.Literal('already_terminal')),
|
|
81
|
+
});
|
|
82
|
+
/** Writing the status a run already has again converges, so a repeat is safe. */
|
|
83
|
+
export const optimizationLifecycle = (runId, body) => ({
|
|
84
|
+
label: 'update optimization run', name: 'Optimization run update', path: `/api/cli/optimization-runs/${encodeURIComponent(runId)}`, method: 'PATCH', body, reply: RunChanged,
|
|
85
|
+
mayAlreadyBeSaved: note('run status change', 'saved', SAFE),
|
|
86
|
+
});
|
|
87
|
+
const EventLogged = Schema.Struct({ eventId: Text });
|
|
88
|
+
/** A repeat with the same event id changes nothing; a new id is refused as a sequence clash. */
|
|
89
|
+
export const optimizationEvent = (runId, body) => ({
|
|
90
|
+
label: 'log event', name: 'Event log', path: `/api/cli/optimization-runs/${encodeURIComponent(runId)}/events`, method: 'POST', body, reply: EventLogged,
|
|
91
|
+
mayAlreadyBeSaved: note('event', 'logged', `run the same command again with \`--event-id ${body.eventId}\` (a new id would be refused as a clash)`),
|
|
92
|
+
});
|
|
93
|
+
const Linked = Schema.Struct({ app: Schema.Struct({ id: Text, name: Text }), linkedDataset: Schema.Struct({ id: Text, name: Text }), versionNum: Count });
|
|
94
|
+
/**
|
|
95
|
+
* A plain overwrite, so a repeat is safe; without --version it links the
|
|
96
|
+
* app's current version at the time, which may have moved on.
|
|
97
|
+
*/
|
|
98
|
+
export const appLinkDataset = (appId, body) => ({
|
|
99
|
+
label: 'link dataset', name: 'Dataset link', path: `/api/cli/apps/${encodeURIComponent(appId)}/link-dataset`, method: 'POST', body, reply: Linked,
|
|
100
|
+
mayAlreadyBeSaved: note('link', 'saved', body.versionNum === undefined ? 'running it again with `--version <n>` for the version you meant is safe' : SAFE),
|
|
101
|
+
});
|
|
102
|
+
const Accepted = Schema.Struct({
|
|
103
|
+
scoreRun: Schema.Struct({ id: Text, provenance: Text, acceptedByUserId: Schema.NullOr(Text), acceptedAt: Schema.NullOr(Text), alreadyAccepted: Schema.Boolean }),
|
|
104
|
+
});
|
|
105
|
+
/** The first acceptance is kept and a repeat says "already accepted". */
|
|
106
|
+
export const scoreAccept = (project, scoreRunId) => ({
|
|
107
|
+
label: 'accept score run', name: 'Score run accept', path: `/api/cli/scores/accept?project=${encodeURIComponent(project)}`, method: 'POST', body: { scoreRunId }, reply: Accepted,
|
|
108
|
+
mayAlreadyBeSaved: note('acceptance', 'saved', SAFE),
|
|
109
|
+
});
|
|
110
|
+
const ManifestRejected = Schema.Struct({ manifest: Schema.Record(Text, Schema.Unknown) });
|
|
111
|
+
/** Once rejected, a repeat is refused, so the advice is to look first. */
|
|
112
|
+
export const manifestReject = (id) => ({
|
|
113
|
+
label: 'reject manifest', name: 'Manifest reject', path: `/api/cli/promotion-manifests/${encodeURIComponent(id)}`, method: 'POST', body: { action: 'reject' }, reply: ManifestRejected,
|
|
114
|
+
mayAlreadyBeSaved: note('manifest', 'rejected', `check \`orizu manifests show ${id}\``),
|
|
115
|
+
});
|
|
116
|
+
/** Sends a write with this command's `--json` setting and output. Ctrl-C sets the exit code and returns null. */
|
|
117
|
+
export async function sendCommandWrite(write, io) {
|
|
118
|
+
const outcome = await sendOneRequestWrite({ ...write, ...io });
|
|
119
|
+
if (outcome.kind === 'saved')
|
|
120
|
+
return outcome.reply;
|
|
121
|
+
process.exitCode = outcome.exitCode;
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
@@ -9,15 +9,42 @@
|
|
|
9
9
|
* The BASE allowlist (Orizu API + model provider + git host) is code-owned and
|
|
10
10
|
* NOT shown/managed here — this surface only widens a team's egress with domains
|
|
11
11
|
* a customer workflow needs. Human ADMIN only: the server rejects agent bearers
|
|
12
|
-
* and non-admins (the definer RPC gates on is_team_admin).
|
|
13
|
-
*
|
|
12
|
+
* and non-admins (the definer RPC gates on is_team_admin). The arguments and
|
|
13
|
+
* output live here; the requests run on Effect in egress-allowlist-workflow.ts
|
|
14
|
+
* (ORI-2764), loaded only when this command runs.
|
|
14
15
|
*/
|
|
15
16
|
export type CliFetcher = (path: string, init?: RequestInit) => Promise<Response>;
|
|
16
17
|
export interface EgressAllowlistCommandIo {
|
|
17
18
|
json: boolean;
|
|
18
19
|
print: (line: string) => void;
|
|
19
20
|
printErr?: (line: string) => void;
|
|
21
|
+
/** Stands in for `authedFetch` in tests. */
|
|
20
22
|
fetcher?: CliFetcher;
|
|
21
23
|
}
|
|
24
|
+
export declare function splitDomains(value: string): string[];
|
|
25
|
+
export interface CurrentAllowlist {
|
|
26
|
+
domains: string[];
|
|
27
|
+
/** ALI-1174: legacy entries the server flags as failing the tightened
|
|
28
|
+
* validator — stored, shown by GET, but silently dropped by the
|
|
29
|
+
* coordinator at policy compose. Surfaced so "configured" never silently
|
|
30
|
+
* means "inert". */
|
|
31
|
+
invalid: string[];
|
|
32
|
+
/** Valid entries beyond the 100-domain cap — equally inert at compose. */
|
|
33
|
+
capped: string[];
|
|
34
|
+
}
|
|
35
|
+
export declare function stringArray(value: unknown): string[];
|
|
36
|
+
/**
|
|
37
|
+
* Re-derive the "beyond the 100-domain cap" entries from a stored set the
|
|
38
|
+
* SAME way the GET route does (positional over UNIQUE VALID domains): the
|
|
39
|
+
* coordinator applies only the first MAX_ADDITIVE_EGRESS_DOMAINS valid
|
|
40
|
+
* domains, so every valid entry past that index is configured-but-inert.
|
|
41
|
+
* Stored entries are already canonical + deduped by the write RPC, and the
|
|
42
|
+
* invalid (grandfathered) ones — flagged by the server — are not "valid"
|
|
43
|
+
* and so never consume a cap slot. Used for the PUT response, where a
|
|
44
|
+
* shrink-by-one on an oversized legacy row leaves the returned set still
|
|
45
|
+
* over-cap and the server does not send cappedDomains back.
|
|
46
|
+
*/
|
|
47
|
+
export declare function deriveCapped(stored: readonly string[], invalid: readonly string[]): string[];
|
|
48
|
+
export declare function emit(io: EgressAllowlistCommandIo, teamSlug: string, current: CurrentAllowlist): void;
|
|
22
49
|
export declare function egressAllowlistCommand(args: string[], io: EgressAllowlistCommandIo): Promise<number>;
|
|
23
50
|
//# sourceMappingURL=egress-allowlist-cli.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"egress-allowlist-cli.d.ts","sourceRoot":"","sources":["../src/egress-allowlist-cli.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"egress-allowlist-cli.d.ts","sourceRoot":"","sources":["../src/egress-allowlist-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEhF,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,4CAA4C;IAC5C,OAAO,CAAC,EAAE,UAAU,CAAA;CACrB;AA0BD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAKpD;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB;;;yBAGqB;IACrB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAEpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAU5F;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CA6BpG;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAe1G"}
|