@quadient/skillshare 1.20.2 → 1.21.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/README.md +23 -4
- package/dist/agents-codex.js +27 -4
- package/dist/agents-process.js +56 -3
- package/dist/agents-service.js +6 -253
- package/dist/agents-session.js +84 -9
- package/dist/agents.js +3 -2
- package/dist/help.js +10 -5
- package/dist/index.js +46 -10
- package/dist/output.js +8 -10
- package/dist/pages-comments.js +2 -2
- package/dist/pages-runtime.js +4 -12
- package/dist/pages-secrets.js +1 -1
- package/dist/service-manager.js +284 -0
- package/dist/teams-service.js +74 -0
- package/dist/teams-watch.js +7 -3
- package/dist/teams.js +8 -5
- package/package.json +2 -2
package/dist/agents-session.js
CHANGED
|
@@ -2,6 +2,7 @@ import { setTimeout as delay } from 'node:timers/promises';
|
|
|
2
2
|
import { isAbsolute } from 'node:path';
|
|
3
3
|
import { stat } from 'node:fs/promises';
|
|
4
4
|
import { responseFingerprint } from './agents-response-hash.js';
|
|
5
|
+
import { agentEnvironmentSecrets, sanitizeAgentDiagnostics } from './agents-process.js';
|
|
5
6
|
/** UI dimensions never change a native decision, scope or answer. Unencodable interactions stay visible and pending. */
|
|
6
7
|
export function boundedSessionRequest(request) {
|
|
7
8
|
const validKey = (key) => typeof key === 'string' && key.length > 0;
|
|
@@ -169,10 +170,12 @@ export class SessionRunner {
|
|
|
169
170
|
now;
|
|
170
171
|
opened = null;
|
|
171
172
|
openSucceeded = false;
|
|
173
|
+
stopStartup;
|
|
172
174
|
turnRunning = false;
|
|
173
175
|
interruptRequested = false;
|
|
174
176
|
idleTimer = null;
|
|
175
177
|
closing = null;
|
|
178
|
+
driverClosing = null;
|
|
176
179
|
closedReported = false;
|
|
177
180
|
requests = new Set();
|
|
178
181
|
responding = new Set();
|
|
@@ -200,16 +203,26 @@ export class SessionRunner {
|
|
|
200
203
|
workdir: options.workdir,
|
|
201
204
|
profile: options.profile,
|
|
202
205
|
sandbox: options.sandbox,
|
|
203
|
-
item: item =>
|
|
204
|
-
|
|
206
|
+
item: item => { if (!this.closing && !this.driverClosing)
|
|
207
|
+
this.events.push({ type: 'item', ...item, text: item.text === undefined ? undefined : clip(item.text) }); },
|
|
208
|
+
thread: threadId => { if (!this.closing && !this.driverClosing)
|
|
209
|
+
this.events.push({ type: 'thread', threadId }); },
|
|
205
210
|
suggestion: text => {
|
|
206
211
|
if (this.busy || this.closing || !text.trim())
|
|
207
212
|
return;
|
|
208
213
|
this.events.push({ type: 'suggestion', text: clip(text.trim(), MAX_SUGGESTION) });
|
|
209
214
|
},
|
|
210
|
-
exited: error =>
|
|
215
|
+
exited: error => {
|
|
216
|
+
if (this.driverClosing)
|
|
217
|
+
return;
|
|
218
|
+
const reason = error ?? 'The agent stopped unexpectedly.';
|
|
219
|
+
if (this.stopStartup)
|
|
220
|
+
this.stopStartup(reason);
|
|
221
|
+
else
|
|
222
|
+
void this.finish(reason);
|
|
223
|
+
},
|
|
211
224
|
request: request => {
|
|
212
|
-
if (this.closing || this.requests.has(request.id))
|
|
225
|
+
if (this.closing || this.driverClosing || this.requests.has(request.id))
|
|
213
226
|
return;
|
|
214
227
|
this.requests.add(request.id);
|
|
215
228
|
this.timeoutChanged?.();
|
|
@@ -338,6 +351,10 @@ export class SessionRunner {
|
|
|
338
351
|
if (!this.turnRunning || this.interruptRequested)
|
|
339
352
|
return;
|
|
340
353
|
this.interruptRequested = true;
|
|
354
|
+
if (this.stopStartup) {
|
|
355
|
+
this.stopStartup('The agent was stopped during startup.');
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
341
358
|
this.clearRequests();
|
|
342
359
|
await this.driver.interrupt().catch(() => { });
|
|
343
360
|
}
|
|
@@ -365,12 +382,15 @@ export class SessionRunner {
|
|
|
365
382
|
const started = this.now();
|
|
366
383
|
if (!this.openSucceeded) {
|
|
367
384
|
try {
|
|
368
|
-
|
|
369
|
-
|
|
385
|
+
await this.openWithTimeout();
|
|
386
|
+
if (this.closing)
|
|
387
|
+
return;
|
|
370
388
|
this.openSucceeded = true;
|
|
371
389
|
}
|
|
372
390
|
catch (error) {
|
|
373
|
-
|
|
391
|
+
if (this.closing)
|
|
392
|
+
return;
|
|
393
|
+
const reason = this.diagnosticError(errorMessage(error));
|
|
374
394
|
// A failed resume uses up the message as a failed turn, so the server does not ask for the same start again.
|
|
375
395
|
// A first start that fails has nothing to resume; the server fails the whole session.
|
|
376
396
|
if (this.options.start.resumeThreadId) {
|
|
@@ -397,12 +417,47 @@ export class SessionRunner {
|
|
|
397
417
|
this.clearRequests();
|
|
398
418
|
if (this.interruptRequested && outcome.status === 'failed' && !outcome.error)
|
|
399
419
|
outcome = { ...outcome, status: 'interrupted' };
|
|
400
|
-
this.events.push({ type: 'turnCompleted', status: outcome.status, error: outcome.error,
|
|
420
|
+
this.events.push({ type: 'turnCompleted', status: outcome.status, error: outcome.error === undefined ? undefined : this.diagnosticError(outcome.error),
|
|
401
421
|
stats: { ...outcome.stats, durationMs: this.now() - started } });
|
|
402
422
|
this.turnRunning = false;
|
|
403
423
|
void this.events.flush();
|
|
404
424
|
void this.pump();
|
|
405
425
|
}
|
|
426
|
+
/** Initialization can hang before a turn exists, so it needs its own deadline and cancellation. */
|
|
427
|
+
async openWithTimeout() {
|
|
428
|
+
const timeoutMs = this.options.startupTimeoutMs ?? 120_000;
|
|
429
|
+
let timer;
|
|
430
|
+
let expired = false;
|
|
431
|
+
const stopped = new Promise((resolve, reject) => {
|
|
432
|
+
this.stopStartup = error => {
|
|
433
|
+
if (expired && error)
|
|
434
|
+
return; // Killing the process must not replace the timeout with its exit error.
|
|
435
|
+
error ? reject(new Error(error)) : resolve();
|
|
436
|
+
};
|
|
437
|
+
// The backend can authorize native requests only after turnStarted, so startup must never pause for one.
|
|
438
|
+
timer = setTimeout(() => {
|
|
439
|
+
expired = true;
|
|
440
|
+
void this.closeDriver().then(() => {
|
|
441
|
+
const operation = this.options.start.resumeThreadId ? 'resume' : 'startup';
|
|
442
|
+
const diagnostics = this.driver.diagnostics?.();
|
|
443
|
+
reject(new Error(`The agent ${operation} did not finish within ${timeoutMs / 1000} seconds.`
|
|
444
|
+
+ (diagnostics ? `\n${diagnostics}` : '')));
|
|
445
|
+
}).catch(reject);
|
|
446
|
+
}, timeoutMs);
|
|
447
|
+
});
|
|
448
|
+
try {
|
|
449
|
+
this.opened ??= this.driver.open();
|
|
450
|
+
await Promise.race([this.opened.then(() => expired ? stopped : undefined, error => {
|
|
451
|
+
if (expired)
|
|
452
|
+
return stopped;
|
|
453
|
+
throw error;
|
|
454
|
+
}), stopped]);
|
|
455
|
+
}
|
|
456
|
+
finally {
|
|
457
|
+
clearTimeout(timer);
|
|
458
|
+
this.stopStartup = undefined;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
406
461
|
/** Interrupts a turn that runs past its timeout, and gives up on an agent that does not stop when asked. */
|
|
407
462
|
async withTimeout(turn) {
|
|
408
463
|
const timeoutMs = Math.max(1, this.options.start.turnTimeoutSeconds) * 1000;
|
|
@@ -456,14 +511,34 @@ export class SessionRunner {
|
|
|
456
511
|
clearTimeout(this.idleTimer);
|
|
457
512
|
this.idleTimer = null;
|
|
458
513
|
}
|
|
514
|
+
diagnosticError(error) {
|
|
515
|
+
return sanitizeAgentDiagnostics(error, [...agentEnvironmentSecrets(process.env), ...(this.options.start.mcpServers ?? []).map(server => server.bearerToken)]);
|
|
516
|
+
}
|
|
517
|
+
closeDriver() {
|
|
518
|
+
if (this.driverClosing)
|
|
519
|
+
return this.driverClosing;
|
|
520
|
+
let done;
|
|
521
|
+
this.driverClosing = new Promise(resolve => { done = resolve; });
|
|
522
|
+
try {
|
|
523
|
+
void this.driver.close().then(done, done);
|
|
524
|
+
}
|
|
525
|
+
catch {
|
|
526
|
+
done();
|
|
527
|
+
}
|
|
528
|
+
return this.driverClosing;
|
|
529
|
+
}
|
|
459
530
|
finish(error) {
|
|
460
531
|
this.closing ??= (async () => {
|
|
532
|
+
error = error === undefined ? undefined : this.diagnosticError(error);
|
|
533
|
+
if (error)
|
|
534
|
+
this.options.log?.(`Session ${this.sessionId} failed: ${oneLine(error, 2000)}`);
|
|
461
535
|
this.clearIdle();
|
|
536
|
+
this.stopStartup?.();
|
|
462
537
|
if (this.leaseTimer)
|
|
463
538
|
clearTimeout(this.leaseTimer);
|
|
464
539
|
this.leaseTimer = null;
|
|
465
540
|
this.clearRequests();
|
|
466
|
-
await this.
|
|
541
|
+
await this.closeDriver();
|
|
467
542
|
if (this.turnRunning && !this.closedReported) {
|
|
468
543
|
this.events.push({ type: 'turnCompleted', status: 'failed', error: error ?? 'The agent was stopped.' });
|
|
469
544
|
this.turnRunning = false;
|
package/dist/agents.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defaultServiceEnvironment, serviceLogs } from './service-manager.js';
|
|
1
2
|
import { createHash, randomBytes } from 'node:crypto';
|
|
2
3
|
import { mkdirSync } from 'node:fs';
|
|
3
4
|
import { mkdir, readFile, readdir, rm, stat, writeFile } from 'node:fs/promises';
|
|
@@ -5,7 +6,7 @@ import { hostname, homedir, platform, tmpdir } from 'node:os';
|
|
|
5
6
|
import { dirname, isAbsolute, join } from 'node:path';
|
|
6
7
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
7
8
|
import { createClaudeDriver } from './agents-claude.js';
|
|
8
|
-
import {
|
|
9
|
+
import { detectServiceAgents, installService, migrateServiceApprovalOptions, renderServiceStatus, serviceStatus, uninstallService, } from './agents-service.js';
|
|
9
10
|
import { createCodexDriver } from './agents-codex.js';
|
|
10
11
|
import { detectAgents, expandHome, profilesPath } from './agents-detect.js';
|
|
11
12
|
import { loadAgentSettings, withoutLegacySandboxArgs } from './agents-settings.js';
|
|
@@ -376,7 +377,7 @@ export async function listen(options) {
|
|
|
376
377
|
const runner = new SessionRunner({
|
|
377
378
|
sessionId: command.sessionId, leaseToken: command.leaseToken, start: command.start, workdir: options.workdir, profile, sandbox: false,
|
|
378
379
|
driver: driver(command.start), upload: uploader(command.sessionId, command.leaseToken), idleMs: options.idleMs, flushIntervalMs: options.flushIntervalMs,
|
|
379
|
-
now,
|
|
380
|
+
now, log,
|
|
380
381
|
leaseNow, leaseDeadline: polledAt + command.leaseRemainingMs,
|
|
381
382
|
authorizeResponse: async (response) => {
|
|
382
383
|
const result = await send(options.client, 'POST', `${root}/listeners/${options.listenerId}/sessions/${command.sessionId}/authorize-response`, {
|
package/dist/help.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
export const GLOBAL_FLAGS = ['token', 'server', 'help'];
|
|
3
|
-
export const BOOLEAN_FLAGS = new Set(['all', 'digest', 'disabled', 'dry-run', 'force', 'headless', 'help', 'json', 'keep-unread', 'no-teams-watch', 'no-update', 'notify-again', 'original', '
|
|
3
|
+
export const BOOLEAN_FLAGS = new Set(['all', 'digest', 'disabled', 'dry-run', 'force', 'headless', 'help', 'json', 'keep-unread', 'no-teams-watch', 'no-update', 'notify-again', 'original', 'always-on', 'owners-only', 'resolved', 'review', 'sandbox', 'unread']);
|
|
4
4
|
export const COMMANDS = [
|
|
5
5
|
{
|
|
6
6
|
name: 'login',
|
|
@@ -86,8 +86,9 @@ export const COMMANDS = [
|
|
|
86
86
|
'pages list [--json]',
|
|
87
87
|
'pages show <slug> [--json]',
|
|
88
88
|
'pages runtime <slug> [--json]',
|
|
89
|
-
'pages runtime set <slug> [--
|
|
89
|
+
'pages runtime set <slug> [--min <MiB>] [--max <MiB>] [--always-on true|false] [--json]',
|
|
90
90
|
'pages upload <directory> [--slug <slug>] [--json]',
|
|
91
|
+
'pages rename <slug> <new-slug> [--json]',
|
|
91
92
|
'pages secrets list <slug> [--json]',
|
|
92
93
|
'pages secrets set <slug> <name> [--json]',
|
|
93
94
|
'pages secrets delete <slug> <name> [--json]',
|
|
@@ -99,9 +100,9 @@ export const COMMANDS = [
|
|
|
99
100
|
'pages dev [directory] [--slug <slug>] [--port <port>] [--build <command> --watch-dir <sources>]',
|
|
100
101
|
' [--celld <executable>] [--user-id <id>] [--user-name <name>] [--user-email <email>]',
|
|
101
102
|
],
|
|
102
|
-
description: 'An upload replaces all content of the page. Without --slug the directory name is used; build output folders such as dist need an explicit --slug. Pages owned by someone else are refused unless you are an admin. pages secrets manages the write-only secrets an app reads through SKILLSHARE_SECRETS (owner or admin only, at most 32 per page, 16 KiB each); set reads the value from piped stdin or a masked prompt, never from the command line. pages runtime set
|
|
103
|
+
description: 'An upload replaces all content of the page. Without --slug the directory name is used; build output folders such as dist need an explicit --slug. Pages owned by someone else are refused unless you are their co-owner or an admin. pages rename moves a page to a new slug with its versions, comments, secrets and app data (owner or admin only); the old address redirects to the new one and stays reserved. pages secrets manages the write-only secrets an app reads through SKILLSHARE_SECRETS (owner or admin only, at most 32 per page, 16 KiB each); set reads the value from piped stdin or a masked prompt, never from the command line. pages runtime set: each app runs in its own pod and gets memory automatically between --min and --max MiB, which the page owners or an admin set; only admins use --always-on to keep an app running without traffic. pages comments reads and writes the annotations reviewers leave on a Page at /pa/<slug>/ (enable and disable decide whether the regular /p/<slug>/ address shows them too); add creates a page note, text without an argument (or -) is read from stdin, and list hides resolved threads unless --resolved is given.',
|
|
103
104
|
examples: ['skillshare pages upload ./site --slug release-notes', 'skillshare pages dev . --slug my-app', 'skillshare pages secrets set my-app API_TOKEN', 'printf %s "$TOKEN" | skillshare pages secrets set my-app API_TOKEN', 'skillshare pages comments list my-app --author mine', 'skillshare pages comments reply my-app 12 "Fixed in revision 4"'],
|
|
104
|
-
flags: ['slug', 'path', 'author', 'resolved', '
|
|
105
|
+
flags: ['slug', 'path', 'author', 'resolved', 'min', 'max', 'always-on', 'json'],
|
|
105
106
|
},
|
|
106
107
|
{
|
|
107
108
|
name: 'teams',
|
|
@@ -109,13 +110,17 @@ export const COMMANDS = [
|
|
|
109
110
|
usage: [
|
|
110
111
|
'teams login [local] [--browser chrome|msedge|chromium] [--headless] [--browser-profile <directory>]',
|
|
111
112
|
'teams watch [local] [--browser chrome|msedge|chromium]',
|
|
113
|
+
'teams service install [local] [--browser chrome|msedge|chromium] [--browser-profile <directory>] [--headless true|false]',
|
|
114
|
+
'teams service status | uninstall',
|
|
115
|
+
'teams service logs [--lines <count>]',
|
|
112
116
|
'teams status | test [--json]',
|
|
113
117
|
'teams logout',
|
|
114
118
|
'teams access readOnly|limitedAccess|fullAccess',
|
|
115
119
|
'teams upload <file>',
|
|
116
120
|
'teams download <url> --output <new-file>',
|
|
117
121
|
],
|
|
118
|
-
|
|
122
|
+
description: 'After teams login, teams service install runs teams watch at every login for Teams renewal only. Manage the service with status, logs and uninstall.',
|
|
123
|
+
flags: ['browser', 'headless', 'browser-profile', 'output', 'json', 'lines'],
|
|
119
124
|
},
|
|
120
125
|
{
|
|
121
126
|
name: 'salesforce',
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,9 @@ import { runSalesforceCommand } from './salesforce.js';
|
|
|
4
4
|
import { runNewsCommand } from './news.js';
|
|
5
5
|
import { assertCredentialDestination, resolveTeamsObjectId, runTeamsCommand, watchTeamsInBackground } from './teams.js';
|
|
6
6
|
import { runAgentsCommand, runServiceCommand } from './agents.js';
|
|
7
|
-
import {
|
|
7
|
+
import { runTeamsServiceCommand, TEAMS_SERVICE_ENV } from './teams-service.js';
|
|
8
|
+
import { defaultServiceEnvironment, servicePaths } from './service-manager.js';
|
|
9
|
+
import { fileLog, SERVICE_ENV } from './agents-update.js';
|
|
8
10
|
import { formatUnknownCommand, parseCliArgs } from './cli-args.js';
|
|
9
11
|
import { findCommand, readCliVersion, renderCommandHelp, renderUsage } from './help.js';
|
|
10
12
|
import { inspectInstallTarget, installFilesAtomically } from './install-files.js';
|
|
@@ -139,19 +141,36 @@ async function main() {
|
|
|
139
141
|
return;
|
|
140
142
|
}
|
|
141
143
|
case 'teams': {
|
|
142
|
-
const
|
|
144
|
+
const [action, serviceAction] = options.positionals;
|
|
145
|
+
if (action === 'service' && serviceAction !== 'install') {
|
|
146
|
+
await runTeamsServiceCommand(defaultServiceEnvironment(APP_DIR), serviceAction, options.flags);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const local = options.positionals[action === 'service' ? 2 : 1] === 'local';
|
|
150
|
+
const baseUrl = normalizeBaseUrl(options.flags.server ?? (local ? LOCAL_URL : await resolveActiveBaseUrl()));
|
|
143
151
|
assertCredentialDestination(baseUrl);
|
|
144
|
-
|
|
152
|
+
const background = process.env[TEAMS_SERVICE_ENV] === '1';
|
|
153
|
+
// A service uses the saved, renewable CLI session. Never copy an install-time token into its launcher.
|
|
154
|
+
if (action === 'service' && options.flags.token)
|
|
155
|
+
throw new Error('teams service install uses your saved Skillshare login. Run it without --token.');
|
|
156
|
+
const token = action === 'service' || background ? undefined : options.token;
|
|
157
|
+
if (!token && !await loadSession(baseUrl)) {
|
|
158
|
+
if (background)
|
|
159
|
+
throw new Error(`Run skillshare login --server ${baseUrl} to sign in for the Teams service.`);
|
|
145
160
|
await login(baseUrl);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
161
|
+
}
|
|
162
|
+
if (action === 'service') {
|
|
163
|
+
await runTeamsServiceCommand(defaultServiceEnvironment(APP_DIR), serviceAction, options.flags, baseUrl);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const teamsClient = await createClient(baseUrl, token);
|
|
167
|
+
if (!background && !token && (action === 'login' || action === 'watch')
|
|
149
168
|
&& !resolveTeamsObjectId(await teamsClient.get('/api/auth/me'))) {
|
|
150
169
|
// A browser sign-in lets the server record the Entra object id for this account.
|
|
151
170
|
console.log('Linking your Microsoft account to Skillshare. Sign in once more in the browser.');
|
|
152
171
|
await login(baseUrl);
|
|
153
172
|
}
|
|
154
|
-
await runTeamsCommand(teamsClient, options.positionals, options.flags, APP_DIR);
|
|
173
|
+
await runTeamsCommand(teamsClient, options.positionals, options.flags, APP_DIR, background ? fileLog(servicePaths(APP_DIR, 'teams').log) : undefined);
|
|
155
174
|
return;
|
|
156
175
|
}
|
|
157
176
|
case 'salesforce': {
|
|
@@ -402,6 +421,19 @@ async function main() {
|
|
|
402
421
|
}
|
|
403
422
|
return;
|
|
404
423
|
}
|
|
424
|
+
if (action === 'rename') {
|
|
425
|
+
const [slug, newSlug] = options.positionals.slice(1);
|
|
426
|
+
if (!slug || !newSlug)
|
|
427
|
+
throw new Error('pages rename requires <slug> <new-slug>');
|
|
428
|
+
const current = await client.get(`/api/pages/${encodeURIComponent(slug)}`);
|
|
429
|
+
const detail = await parseJson(await client.request(`/api/pages/${encodeURIComponent(current.slug)}/rename`, {
|
|
430
|
+
method: 'POST',
|
|
431
|
+
headers: { 'Content-Type': 'application/json' },
|
|
432
|
+
body: JSON.stringify({ slug: newSlug, revision: current.contentRevision }),
|
|
433
|
+
}));
|
|
434
|
+
print(detail, () => `Renamed /p/${current.slug}/ to /p/${detail.slug}/. The old address redirects to it.\nOpen ${pageUrl(client.baseUrl, detail.slug)}`);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
405
437
|
if (action === 'secrets') {
|
|
406
438
|
await runPageSecretsCommand(client, options.positionals.slice(1), print);
|
|
407
439
|
return;
|
|
@@ -410,7 +442,7 @@ async function main() {
|
|
|
410
442
|
await runPageCommentsCommand(client, options.positionals.slice(1), options.flags, print);
|
|
411
443
|
return;
|
|
412
444
|
}
|
|
413
|
-
throw new Error(`Unknown pages command '${action}'. Use list, show, runtime, upload, secrets, or comments.`);
|
|
445
|
+
throw new Error(`Unknown pages command '${action}'. Use list, show, runtime, upload, rename, secrets, or comments.`);
|
|
414
446
|
}
|
|
415
447
|
}
|
|
416
448
|
return;
|
|
@@ -1437,7 +1469,8 @@ async function describePageUploadTarget(client, slug) {
|
|
|
1437
1469
|
throw error;
|
|
1438
1470
|
}
|
|
1439
1471
|
const me = await client.get('/api/auth/me');
|
|
1440
|
-
const isOwner = me.storedUserId != null && me.storedUserId === page.ownerUserId
|
|
1472
|
+
const isOwner = me.storedUserId != null && (me.storedUserId === page.ownerUserId
|
|
1473
|
+
|| (page.coOwners ?? []).some((owner) => owner.userId === me.storedUserId));
|
|
1441
1474
|
if (!isOwner && !me.isAdmin) {
|
|
1442
1475
|
throw new Error(`Page /p/${slug}/ belongs to ${page.ownerDisplayName}. Choose another --slug.`);
|
|
1443
1476
|
}
|
|
@@ -2244,5 +2277,8 @@ main().catch((error) => {
|
|
|
2244
2277
|
const message = error instanceof Error
|
|
2245
2278
|
? error.message.trim() || 'Unexpected error.'
|
|
2246
2279
|
: String(error).trim() || 'Unexpected error.';
|
|
2247
|
-
process.
|
|
2280
|
+
if (process.env[TEAMS_SERVICE_ENV] === '1')
|
|
2281
|
+
fileLog(servicePaths(APP_DIR, 'teams').log)(message);
|
|
2282
|
+
else
|
|
2283
|
+
process.stderr.write(`${message}\n`);
|
|
2248
2284
|
});
|
package/dist/output.js
CHANGED
|
@@ -137,21 +137,19 @@ export function renderPageDetail(page, baseUrl, now = new Date()) {
|
|
|
137
137
|
export function renderPageRuntime(slug, runtime, logLimit = 20) {
|
|
138
138
|
const settings = runtime.settings;
|
|
139
139
|
const lines = [
|
|
140
|
-
`${slug}: ${runtime.state} · revision ${runtime.revision}${runtime.processId ? ` · pid ${runtime.processId}` : ''}
|
|
140
|
+
`${slug}: ${runtime.state} · revision ${runtime.revision}${runtime.processId ? ` · pid ${runtime.processId}` : ''}`,
|
|
141
141
|
];
|
|
142
142
|
if (runtime.error)
|
|
143
143
|
lines.push(`Error: ${runtime.error}`);
|
|
144
144
|
if (settings) {
|
|
145
145
|
lines.push(`Always on: ${settings.alwaysOn ? 'yes' : 'no'}`);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
lines.push(`Memory: ${settings.limitMiB} MiB, automatic within ${settings.minMiB}–${settings.maxMiB} MiB · CPU ${settings.cpuRequestMilli}m${usage.length ? ` · ${usage.join(' · ')}` : ''}`);
|
|
154
|
-
}
|
|
146
|
+
const memory = runtime.memory;
|
|
147
|
+
const usage = [
|
|
148
|
+
memory?.currentMiB != null ? `using ${memory.currentMiB} MiB` : null,
|
|
149
|
+
memory?.peakMiB != null ? `4-day peak ${memory.peakMiB} MiB` : null,
|
|
150
|
+
memory?.outOfMemoryCount ? `${memory.outOfMemoryCount} out of memory` : null,
|
|
151
|
+
].filter(Boolean);
|
|
152
|
+
lines.push(`Memory: ${settings.limitMiB} MiB, automatic within ${settings.minMiB}–${settings.maxMiB} MiB · CPU ${settings.cpuRequestMilli}m${usage.length ? ` · ${usage.join(' · ')}` : ''}`);
|
|
155
153
|
}
|
|
156
154
|
if (runtime.logsUrl)
|
|
157
155
|
lines.push(`Pod logs: ${runtime.logsUrl}`);
|
package/dist/pages-comments.js
CHANGED
|
@@ -131,8 +131,8 @@ async function expectJson(slug, response, id) {
|
|
|
131
131
|
return await response.json();
|
|
132
132
|
if (response.status === 403) {
|
|
133
133
|
throw new Error(id
|
|
134
|
-
? `Only the comment's author,
|
|
135
|
-
: `Only
|
|
134
|
+
? `Only the comment's author, an owner of /p/${slug}/ or an administrator can change #${id}.`
|
|
135
|
+
: `Only an owner of /p/${slug}/ or an administrator can change its annotation settings.`);
|
|
136
136
|
}
|
|
137
137
|
if (response.status === 404)
|
|
138
138
|
throw new Error(id ? `Comment #${id} on /p/${slug}/ was not found.` : `Page /p/${slug}/ was not found.`);
|
package/dist/pages-runtime.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { renderPageRuntime } from './output.js';
|
|
2
2
|
/**
|
|
3
3
|
* `pages runtime <slug>` shows the runtime to its owner or an administrator; `pages runtime set <slug>`
|
|
4
|
-
* lets
|
|
4
|
+
* lets its owners set the automatic memory range of its pod and an administrator also keep it always on.
|
|
5
5
|
*/
|
|
6
6
|
export async function runPageRuntimeCommand(client, positionals, flags, print) {
|
|
7
7
|
if (positionals[0] === 'set' && positionals[1]) {
|
|
8
8
|
const slug = positionals[1];
|
|
9
9
|
const body = settingsRequest(flags);
|
|
10
10
|
if (Object.keys(body).length === 0) {
|
|
11
|
-
throw new Error('pages runtime set needs --
|
|
11
|
+
throw new Error('pages runtime set needs --min <MiB>, --max <MiB> or --always-on true|false');
|
|
12
12
|
}
|
|
13
13
|
const settings = await expect(slug, await client.request(`/api/pages/${encodeURIComponent(slug)}/runtime-settings`, {
|
|
14
14
|
method: 'PUT',
|
|
15
15
|
headers: { 'Content-Type': 'application/json' },
|
|
16
16
|
body: JSON.stringify(body),
|
|
17
17
|
}));
|
|
18
|
-
print(settings, () => `Updated /p/${slug}/:
|
|
18
|
+
print(settings, () => `Updated /p/${slug}/: always on ${settings.alwaysOn ? 'yes' : 'no'}, memory ${settings.minMiB}–${settings.maxMiB} MiB (now ${settings.limitMiB} MiB).`);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
const slug = positionals[0];
|
|
@@ -26,14 +26,6 @@ export async function runPageRuntimeCommand(client, positionals, flags, print) {
|
|
|
26
26
|
}
|
|
27
27
|
export function settingsRequest(flags) {
|
|
28
28
|
const body = {};
|
|
29
|
-
const external = isTrue(flags.external);
|
|
30
|
-
const internal = isTrue(flags.internal);
|
|
31
|
-
if (external && internal)
|
|
32
|
-
throw new Error('Use either --external or --internal.');
|
|
33
|
-
if (external)
|
|
34
|
-
body.placement = 'external';
|
|
35
|
-
if (internal)
|
|
36
|
-
body.placement = 'internal';
|
|
37
29
|
if (flags.min !== undefined)
|
|
38
30
|
body.minMiB = mebibytes('--min', flags.min);
|
|
39
31
|
if (flags.max !== undefined)
|
|
@@ -54,7 +46,7 @@ async function expect(slug, response) {
|
|
|
54
46
|
if (response.ok)
|
|
55
47
|
return await response.json();
|
|
56
48
|
if (response.status === 403)
|
|
57
|
-
throw new Error(`Only an administrator can change
|
|
49
|
+
throw new Error(`Only an administrator can change Always on of /p/${slug}/; its owners can set --min and --max.`);
|
|
58
50
|
if (response.status === 404)
|
|
59
51
|
throw new Error(`Page /p/${slug}/ was not found.`);
|
|
60
52
|
let error = {};
|
package/dist/pages-secrets.js
CHANGED
|
@@ -50,7 +50,7 @@ async function expectSecrets(slug, response, name) {
|
|
|
50
50
|
if (response.ok)
|
|
51
51
|
return await response.json();
|
|
52
52
|
if (response.status === 403)
|
|
53
|
-
throw new Error(`Only the owner of /p/${slug}/ or an administrator can manage its secrets.`);
|
|
53
|
+
throw new Error(`Only the owner or a co-owner of /p/${slug}/ or an administrator can manage its secrets.`);
|
|
54
54
|
if (response.status === 404) {
|
|
55
55
|
throw new Error(name ? `Page /p/${slug}/ or its secret ${name} was not found.` : `Page /p/${slug}/ was not found.`);
|
|
56
56
|
}
|