@quadient/skillshare 1.18.1 → 1.19.1
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 +9 -1
- package/dist/agents-claude.js +61 -7
- package/dist/agents-codex.js +24 -4
- package/dist/agents-detect.js +208 -71
- package/dist/agents-executable.js +76 -0
- package/dist/agents-process.js +117 -28
- package/dist/agents-service.js +4 -2
- package/dist/agents-session.js +8 -0
- package/dist/agents.js +50 -13
- package/dist/help.js +39 -2
- package/dist/index.js +9 -0
- package/dist/news.js +409 -0
- package/dist/teams.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import filesystem from 'node:fs/promises';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { isAbsolute, join } from 'node:path';
|
|
4
|
+
function environmentValue(env, name) {
|
|
5
|
+
// Node's Windows spawn keeps the first case-insensitive key in lexicographic order.
|
|
6
|
+
const key = Object.keys(env).sort().find(key => key.toLowerCase() === name.toLowerCase());
|
|
7
|
+
return key === undefined ? undefined : env[key];
|
|
8
|
+
}
|
|
9
|
+
async function file(path, signal) {
|
|
10
|
+
signal?.throwIfAborted();
|
|
11
|
+
try {
|
|
12
|
+
const info = await filesystem.stat(path);
|
|
13
|
+
signal?.throwIfAborted();
|
|
14
|
+
return info.isFile();
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
signal?.throwIfAborted();
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Resolve afresh for every launch: the desktop app replaces its copied runtime directories during updates. */
|
|
22
|
+
export async function resolveAgentCommand(command, env = process.env, options = {}) {
|
|
23
|
+
const { signal } = options;
|
|
24
|
+
signal?.throwIfAborted();
|
|
25
|
+
if ((options.platform ?? process.platform) !== 'win32' || /[\\/:]/.test(command))
|
|
26
|
+
return command;
|
|
27
|
+
const configuredExtensions = (environmentValue(env, 'PATHEXT') ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(part => /^\.[a-z0-9]+$/i.test(part));
|
|
28
|
+
const extensions = command.includes('.') ? ['', ...configuredExtensions] : configuredExtensions;
|
|
29
|
+
const directories = (environmentValue(env, 'PATH') ?? '').split(';').map(part => part.trim().replace(/^"(.*)"$/, '$1'))
|
|
30
|
+
// Do not discover commands in the listener's working directory or in relative PATH entries.
|
|
31
|
+
.filter(part => part.length > 0 && isAbsolute(part));
|
|
32
|
+
// Match cross-spawn's extension lookup first, then its extensionless/shebang-wrapper fallback.
|
|
33
|
+
const paths = directories.flatMap(directory => extensions.map(extension => join(directory, command + extension)));
|
|
34
|
+
if (!extensions.includes(''))
|
|
35
|
+
paths.push(...directories.map(directory => join(directory, command)));
|
|
36
|
+
for (const path of paths) {
|
|
37
|
+
if (await file(path, signal)) {
|
|
38
|
+
signal?.throwIfAborted();
|
|
39
|
+
return path;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (/^codex(?:\.exe)?$/i.test(command)) {
|
|
43
|
+
const local = environmentValue(env, 'LOCALAPPDATA') ?? join(options.home ?? homedir(), 'AppData', 'Local');
|
|
44
|
+
const root = join(local, 'OpenAI', 'Codex', 'bin');
|
|
45
|
+
try {
|
|
46
|
+
const entries = await filesystem.readdir(root, { withFileTypes: true });
|
|
47
|
+
signal?.throwIfAborted();
|
|
48
|
+
const candidates = [];
|
|
49
|
+
for (const entry of entries.filter(entry => entry.isDirectory() && /^[0-9a-f]{16}$/i.test(entry.name))) {
|
|
50
|
+
const directory = join(root, entry.name);
|
|
51
|
+
const executable = join(directory, 'codex.exe');
|
|
52
|
+
try {
|
|
53
|
+
const binary = await filesystem.lstat(executable);
|
|
54
|
+
signal?.throwIfAborted();
|
|
55
|
+
if (!binary.isFile())
|
|
56
|
+
continue;
|
|
57
|
+
const folder = await filesystem.stat(directory);
|
|
58
|
+
signal?.throwIfAborted();
|
|
59
|
+
candidates.push({ executable, modified: folder.mtimeMs });
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
signal?.throwIfAborted();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
candidates.sort((a, b) => b.modified - a.modified || a.executable.localeCompare(b.executable));
|
|
66
|
+
signal?.throwIfAborted();
|
|
67
|
+
if (candidates[0])
|
|
68
|
+
return candidates[0].executable;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
signal?.throwIfAborted();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
signal?.throwIfAborted();
|
|
75
|
+
throw Object.assign(new Error('Agent executable was not found.'), { code: 'ENOENT' });
|
|
76
|
+
}
|
package/dist/agents-process.js
CHANGED
|
@@ -1,32 +1,76 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { open } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
2
4
|
import { createInterface } from 'node:readline';
|
|
3
|
-
import
|
|
5
|
+
import { resolveAgentCommand } from './agents-executable.js';
|
|
4
6
|
/**
|
|
5
7
|
* Starts an agent that speaks newline-delimited JSON on stdio. Tokens go through the environment only. A separate
|
|
6
8
|
* process group lets stopping the agent also stop the shell commands it runs.
|
|
7
9
|
*/
|
|
8
|
-
export function startAgentProcess(options) {
|
|
10
|
+
export async function startAgentProcess(options) {
|
|
9
11
|
const posix = process.platform !== 'win32';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const env = { ...process.env, ...options.env };
|
|
13
|
+
options.signal?.throwIfAborted();
|
|
14
|
+
// Resolve for every new process: desktop updates can replace Codex's directory while the listener stays running.
|
|
15
|
+
const resolveCommand = options.resolveCommand ?? (options.spawnAgent ? undefined : resolveAgentCommand);
|
|
16
|
+
let command = resolveCommand ? await resolveCommand(options.command, env, { signal: options.signal }) : options.command;
|
|
17
|
+
let args = options.args;
|
|
18
|
+
// Extensionless wrappers use an interpreter; resolve it asynchronously instead of cross-spawn's synchronous PATH walk.
|
|
19
|
+
if (!posix && !options.spawnAgent) {
|
|
20
|
+
for (let depth = 0; !/\.(?:exe|com|cmd|bat)$/i.test(command); depth++) {
|
|
21
|
+
if (depth === 4)
|
|
22
|
+
throw Object.assign(new Error('The agent interpreter could not be resolved.'), { code: 'ENOEXEC' });
|
|
23
|
+
const file = await open(command, 'r');
|
|
24
|
+
let firstLine;
|
|
25
|
+
try {
|
|
26
|
+
const buffer = Buffer.alloc(150);
|
|
27
|
+
const { bytesRead } = await file.read(buffer, 0, buffer.length, 0);
|
|
28
|
+
firstLine = buffer.subarray(0, bytesRead).toString().split(/\r?\n/, 1)[0] ?? '';
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
await file.close();
|
|
32
|
+
}
|
|
33
|
+
const parts = /^#!\s*(.+)$/.exec(firstLine)?.[1]?.trim().split(/\s+/);
|
|
34
|
+
let interpreter = parts?.shift()?.split(/[\\/]/).at(-1);
|
|
35
|
+
if (interpreter === 'env')
|
|
36
|
+
interpreter = parts?.shift();
|
|
37
|
+
if (!interpreter)
|
|
38
|
+
throw Object.assign(new Error('The agent executable has no supported interpreter.'), { code: 'ENOEXEC' });
|
|
39
|
+
args = [...parts ?? [], command, ...args];
|
|
40
|
+
command = await resolveAgentCommand(interpreter, env, { signal: options.signal });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
options.signal?.throwIfAborted();
|
|
44
|
+
// Batch shims need cmd, but no synchronous filesystem lookup or interpreter discovery belongs on the listener thread.
|
|
45
|
+
const batch = !posix && !options.spawnAgent && /\.(?:cmd|bat)$/i.test(command);
|
|
46
|
+
if (batch) {
|
|
47
|
+
const doubleEscape = /node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i.test(command);
|
|
48
|
+
const shellCommand = [command.replace(BATCH_META, '^$1'), ...args.map(arg => batchArgument(arg, doubleEscape))].join(' ');
|
|
49
|
+
args = ['/d', '/s', '/v:off', '/c', `"${shellCommand}"`];
|
|
50
|
+
command = join(env.SystemRoot ?? env.SYSTEMROOT ?? 'C:\\Windows', 'System32', 'cmd.exe');
|
|
51
|
+
}
|
|
52
|
+
const child = (options.spawnAgent ?? spawn)(command, args, {
|
|
53
|
+
cwd: options.cwd, env, stdio: ['pipe', 'pipe', 'pipe'],
|
|
14
54
|
detached: posix, windowsHide: true,
|
|
55
|
+
...(batch ? { windowsVerbatimArguments: true } : {}),
|
|
15
56
|
});
|
|
16
57
|
let stderr = '';
|
|
17
58
|
child.stderr?.on('data', chunk => { stderr = (stderr + chunk).slice(-4000); });
|
|
18
59
|
child.stdin?.on('error', () => { });
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
60
|
+
const lines = child.stdout ? createInterface({ input: child.stdout, crlfDelay: Infinity }) : undefined;
|
|
61
|
+
lines?.on('line', line => { if (line.trim())
|
|
62
|
+
options.onLine(line); });
|
|
63
|
+
let running = true;
|
|
22
64
|
const exited = new Promise(resolve => {
|
|
23
|
-
child.once('error', error => { stderr = (stderr + '\n' + error.message).slice(-4000); resolve(null); });
|
|
24
|
-
child.once('exit', code => resolve(code));
|
|
65
|
+
child.once('error', error => { running = false; stderr = (stderr + '\n' + error.message).slice(-4000); resolve(null); });
|
|
66
|
+
child.once('exit', code => { running = false; resolve(code); });
|
|
25
67
|
});
|
|
68
|
+
const closed = new Promise(resolve => child.once('close', () => resolve()));
|
|
26
69
|
let killing = null;
|
|
27
70
|
return {
|
|
28
71
|
child,
|
|
29
72
|
exited,
|
|
73
|
+
closed,
|
|
30
74
|
stderrTail: () => stderr.trim().split(/\r?\n/).filter(line => line.trim()).slice(-3).join(' ').slice(-300),
|
|
31
75
|
// write(false) signals backpressure, not rejection: the frame is already buffered and must not be resent.
|
|
32
76
|
write: line => {
|
|
@@ -42,26 +86,71 @@ export function startAgentProcess(options) {
|
|
|
42
86
|
},
|
|
43
87
|
kill() {
|
|
44
88
|
killing ??= (async () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
89
|
+
try {
|
|
90
|
+
if (posix) {
|
|
91
|
+
const signal = (sig) => {
|
|
92
|
+
try {
|
|
93
|
+
child.pid ? process.kill(-child.pid, sig) : child.kill(sig);
|
|
94
|
+
}
|
|
95
|
+
catch { }
|
|
96
|
+
};
|
|
97
|
+
child.stdin?.end();
|
|
98
|
+
signal('SIGTERM');
|
|
99
|
+
await bounded(exited, 5000);
|
|
100
|
+
// A shell may exit before its descendants. End the remaining process group too.
|
|
101
|
+
signal('SIGKILL');
|
|
102
|
+
}
|
|
103
|
+
else if (running && child.pid) {
|
|
104
|
+
// Kill the complete tree in one operation. Gracefully ending cmd first loses the descendant PIDs.
|
|
105
|
+
const killer = spawn(join(env.SystemRoot ?? env.SYSTEMROOT ?? 'C:\\Windows', 'System32', 'taskkill.exe'), ['/pid', String(child.pid), '/T', '/F'], { windowsHide: true, stdio: 'ignore' });
|
|
106
|
+
const killed = new Promise(resolve => { killer.once('error', () => resolve()); killer.once('close', () => resolve()); });
|
|
107
|
+
if (!await bounded(killed, 5000))
|
|
108
|
+
killer.kill();
|
|
54
109
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
110
|
+
if (running) {
|
|
111
|
+
try {
|
|
112
|
+
child.kill('SIGKILL');
|
|
113
|
+
}
|
|
114
|
+
catch { }
|
|
115
|
+
}
|
|
116
|
+
await bounded(exited, 1000);
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
lines?.close();
|
|
120
|
+
child.stdin?.destroy();
|
|
121
|
+
child.stdout?.destroy();
|
|
122
|
+
child.stderr?.destroy();
|
|
123
|
+
}
|
|
63
124
|
})();
|
|
64
125
|
return killing;
|
|
65
126
|
},
|
|
66
127
|
};
|
|
67
128
|
}
|
|
129
|
+
async function bounded(promise, milliseconds) {
|
|
130
|
+
let timer;
|
|
131
|
+
try {
|
|
132
|
+
return await Promise.race([promise.then(() => true), new Promise(resolve => { timer = setTimeout(() => resolve(false), milliseconds); })]);
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
clearTimeout(timer);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/* Batch escaping adapted from cross-spawn 7.0.6, MIT License.
|
|
139
|
+
* Copyright (c) 2018 Made With MOXY Lda <hello@moxy.studio>
|
|
140
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
141
|
+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
|
|
142
|
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
|
|
143
|
+
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
144
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
|
|
145
|
+
* the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
146
|
+
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
147
|
+
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
148
|
+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
149
|
+
* OTHER DEALINGS IN THE SOFTWARE.
|
|
150
|
+
*/
|
|
151
|
+
const BATCH_META = /([()\][%!^"`<>&|;, *?])/g;
|
|
152
|
+
function batchArgument(argument, doubleEscape) {
|
|
153
|
+
const quoted = `"${argument.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"').replace(/(?=(\\+?)?)\1$/, '$1$1')}"`;
|
|
154
|
+
const escaped = quoted.replace(BATCH_META, '^$1');
|
|
155
|
+
return doubleEscape ? escaped.replace(BATCH_META, '^$1') : escaped;
|
|
156
|
+
}
|
package/dist/agents-service.js
CHANGED
|
@@ -317,9 +317,11 @@ export async function uninstallService(environment) {
|
|
|
317
317
|
await environment.run('systemctl', ['--user', 'daemon-reload']);
|
|
318
318
|
return existed || wasRunning;
|
|
319
319
|
}
|
|
320
|
-
export async function detectServiceAgents(appDir) {
|
|
320
|
+
export async function detectServiceAgents(appDir, signal) {
|
|
321
|
+
signal?.throwIfAborted();
|
|
321
322
|
const warnings = await refreshServicePath();
|
|
322
|
-
const detected = await detectAgents();
|
|
323
|
+
const detected = await detectAgents({ signal });
|
|
324
|
+
signal?.throwIfAborted();
|
|
323
325
|
detected.problems.unshift(...warnings);
|
|
324
326
|
const report = {
|
|
325
327
|
checkedAt: new Date().toISOString(), path: process.env.PATH ?? '',
|
package/dist/agents-session.js
CHANGED
|
@@ -33,9 +33,17 @@ export async function validateSessionWorkdir(context) {
|
|
|
33
33
|
export const CLAUDE_SANDBOX_TOOLS = ['Read', 'Grep', 'Glob', 'WebSearch', 'WebFetch'];
|
|
34
34
|
export const SANDBOX_NOTE = 'This session is sandboxed: you can read files, search and use the provided MCP tools, but you cannot change files or ' +
|
|
35
35
|
'run commands that modify anything.';
|
|
36
|
+
export const LOCKDOWN_NOTE = 'This session is locked down: you have no files, shell, web access or other tools, only the tools of the ' +
|
|
37
|
+
'provided MCP servers. Everything you need is in the instructions and the message.';
|
|
38
|
+
/** Claude Code built-in tools a locked-down session must never use; dontAsk already denies them, this states it explicitly. */
|
|
39
|
+
export const CLAUDE_LOCKDOWN_DENIED_TOOLS = ['Bash', 'BashOutput', 'KillShell', 'Edit', 'MultiEdit', 'Write', 'NotebookEdit', 'Read', 'Grep', 'Glob',
|
|
40
|
+
'LS', 'WebFetch', 'WebSearch', 'Task', 'TodoWrite', 'SlashCommand', 'Skill', 'ExitPlanMode'];
|
|
36
41
|
export const DEFAULT = 'default';
|
|
37
42
|
const MAX_TEXT = 50_000;
|
|
38
43
|
const MAX_SUGGESTION = 2_000;
|
|
44
|
+
export function isLockedDown(start) {
|
|
45
|
+
return start.lockdown === true;
|
|
46
|
+
}
|
|
39
47
|
/** Only frozen permissions of an already-created session may enforce the legacy read-only restriction. */
|
|
40
48
|
export function isSandboxed(configuration) {
|
|
41
49
|
return configuration.sandbox === true;
|
package/dist/agents.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash, randomBytes } from 'node:crypto';
|
|
2
|
+
import { mkdirSync } from 'node:fs';
|
|
2
3
|
import { mkdir, readFile, readdir, rm, stat, writeFile } from 'node:fs/promises';
|
|
3
4
|
import { hostname, homedir, platform, tmpdir } from 'node:os';
|
|
4
5
|
import { dirname, isAbsolute, join } from 'node:path';
|
|
@@ -142,7 +143,7 @@ export async function runAgentsCommand(client, args, flags, appDirectory, teamsW
|
|
|
142
143
|
try {
|
|
143
144
|
result = await listen({
|
|
144
145
|
client, listenerId, name: flags.name, workdir, maxConcurrency: max, signal: abort.signal, onProgress: console.log, service,
|
|
145
|
-
detect: service ?
|
|
146
|
+
detect: service ? signal => detectServiceAgents(appDirectory, signal) : undefined,
|
|
146
147
|
updater: worker ? { currentVersion: readCliVersion(), prepare: version => installVersion(appDirectory, version) } : undefined,
|
|
147
148
|
});
|
|
148
149
|
}
|
|
@@ -241,7 +242,9 @@ export function renderDetected(listenerId, server, detected) {
|
|
|
241
242
|
return lines.join('\n');
|
|
242
243
|
}
|
|
243
244
|
export async function listen(options) {
|
|
244
|
-
const
|
|
245
|
+
const detectionAbort = new AbortController();
|
|
246
|
+
const detectionSignal = AbortSignal.any([options.signal, detectionAbort.signal]);
|
|
247
|
+
const detect = () => options.detect ? options.detect(detectionSignal) : detectAgents({ signal: detectionSignal });
|
|
245
248
|
const codex = createCodexDriver({ clientVersion: readCliVersion() });
|
|
246
249
|
const claude = createClaudeDriver();
|
|
247
250
|
const driver = options.driver ?? (start => start.configuration.agent === 'codex' ? codex : claude);
|
|
@@ -256,7 +259,11 @@ export async function listen(options) {
|
|
|
256
259
|
const imageRoot = options.imageDirectory ?? join(tmpdir(), 'skillshare-agents');
|
|
257
260
|
let detected = await detect();
|
|
258
261
|
let registeredFingerprint = '';
|
|
259
|
-
|
|
262
|
+
const redetectMs = options.redetectMs ?? 5 * 60_000;
|
|
263
|
+
let nextDetectionAt = now() + redetectMs;
|
|
264
|
+
let detecting;
|
|
265
|
+
let pendingDetection;
|
|
266
|
+
let detectionActive = true;
|
|
260
267
|
let failures = 0;
|
|
261
268
|
// A downloaded update waits until no turn runs; a failed download is tried again later.
|
|
262
269
|
let updateReady = null;
|
|
@@ -264,6 +271,22 @@ export async function listen(options) {
|
|
|
264
271
|
let updateRetryAt = 0;
|
|
265
272
|
let updateMentioned = '';
|
|
266
273
|
let result = 'stopped';
|
|
274
|
+
function refreshDetection() {
|
|
275
|
+
if (detecting || now() < nextDetectionAt)
|
|
276
|
+
return;
|
|
277
|
+
// Detection can outlast the server's presence/lease timeout. Poll using the last complete snapshot meanwhile.
|
|
278
|
+
detecting = Promise.resolve().then(detect).then(next => {
|
|
279
|
+
if (!detectionActive || options.signal.aborted)
|
|
280
|
+
return;
|
|
281
|
+
pendingDetection = next;
|
|
282
|
+
nextDetectionAt = now() + redetectMs;
|
|
283
|
+
}).catch(() => {
|
|
284
|
+
if (!detectionActive || options.signal.aborted)
|
|
285
|
+
return;
|
|
286
|
+
nextDetectionAt = now() + Math.max(1000, Math.min(redetectMs, 5000));
|
|
287
|
+
log('! Agent detection failed. Keeping the last known capabilities and trying again shortly.');
|
|
288
|
+
}).finally(() => { detecting = undefined; });
|
|
289
|
+
}
|
|
267
290
|
function considerUpdate(version) {
|
|
268
291
|
const current = options.updater?.currentVersion ?? readCliVersion();
|
|
269
292
|
// Only a plain release number; npm would read anything else as a git, URL or file package spec.
|
|
@@ -287,15 +310,17 @@ export async function listen(options) {
|
|
|
287
310
|
log(`! Could not download Skillshare CLI ${version} (${error instanceof Error ? error.message : String(error)}). Trying again in 30 minutes.`);
|
|
288
311
|
}).finally(() => { updating = null; });
|
|
289
312
|
}
|
|
290
|
-
const capabilities = () => ({ ...detected.capabilities, sessionApprovals: true });
|
|
313
|
+
const capabilities = () => ({ ...detected.capabilities, sessionApprovals: true, lockdown: true });
|
|
291
314
|
async function register() {
|
|
292
|
-
const
|
|
293
|
-
const
|
|
315
|
+
const snapshot = detected;
|
|
316
|
+
const registeredCapabilities = capabilities();
|
|
317
|
+
const fingerprint = JSON.stringify(registeredCapabilities);
|
|
318
|
+
const requiresApprovalDefaults = Boolean(registeredCapabilities.defaultApprovalMode || registeredCapabilities.profiles.some(profile => profile.defaultApprovalMode));
|
|
294
319
|
// A dedicated route rejects an older server before it can overwrite restrictions or dispatch queued work.
|
|
295
320
|
const path = `${root}/listeners/${options.listenerId}${requiresApprovalDefaults ? '/register' : ''}`;
|
|
296
321
|
const registered = await send(options.client, 'PUT', path, {
|
|
297
322
|
name: options.name ?? hostname(), host: hostname(), os: platform(), cliVersion: readCliVersion(), maxConcurrency: options.maxConcurrency,
|
|
298
|
-
capabilities:
|
|
323
|
+
capabilities: registeredCapabilities, service: options.service === true, autoUpdate: options.updater !== undefined,
|
|
299
324
|
}, options.signal).catch(error => {
|
|
300
325
|
if (requiresApprovalDefaults && error instanceof AgentsHttpError && error.status === 404)
|
|
301
326
|
throw new Error('Update Skillshare before connecting this listener; this server does not support safe approval-default registration.');
|
|
@@ -304,9 +329,9 @@ export async function listen(options) {
|
|
|
304
329
|
if (requiresApprovalDefaults && (registered?.approvalDefaultsVersion ?? 0) < 1)
|
|
305
330
|
throw new Error('Update Skillshare before using migrated approval defaults; this server cannot acknowledge them safely.');
|
|
306
331
|
registeredFingerprint = fingerprint;
|
|
307
|
-
for (const problem of
|
|
332
|
+
for (const problem of snapshot.problems)
|
|
308
333
|
log(`! ${problem}`);
|
|
309
|
-
log(`Listening as "${registered.name}" with ${registered.effectiveConcurrency} slot(s): ${describe(
|
|
334
|
+
log(`Listening as "${registered.name}" with ${registered.effectiveConcurrency} slot(s): ${describe(snapshot)}. Start sessions and choose routes under Connected agents on ${options.client.baseUrl}.`);
|
|
310
335
|
}
|
|
311
336
|
/** Posts a batch of session events: a rejected lease means the server moved on and the agent must stop. */
|
|
312
337
|
function uploader(sessionId, leaseToken) {
|
|
@@ -334,13 +359,20 @@ export async function listen(options) {
|
|
|
334
359
|
const previous = sessions.get(command.sessionId);
|
|
335
360
|
if (previous)
|
|
336
361
|
void previous.stop();
|
|
337
|
-
|
|
362
|
+
// A locked-down session gets an empty folder of its own and none of the local profile's arguments or approval settings.
|
|
363
|
+
const lockdown = command.start.lockdown === true;
|
|
364
|
+
const lockdownDir = lockdown ? join(tmpdir(), `skillshare-lockdown-${command.sessionId}-${randomBytes(6).toString('hex')}`) : undefined;
|
|
365
|
+
if (lockdown)
|
|
366
|
+
command.start = { ...command.start, configuration: { ...command.start.configuration, profile: undefined, approvalMode: undefined, sandbox: false, workdir: lockdownDir } };
|
|
367
|
+
const profile = !lockdown && command.start.configuration.profile ? detected.profiles.find(p => p.name === command.start.configuration.profile) : undefined;
|
|
338
368
|
const mode = command.start.configuration.approvalMode;
|
|
339
369
|
const supported = detected.capabilities.agents.find(agent => agent.kind === command.start.configuration.agent)?.approvalModes;
|
|
340
370
|
if (mode && !supported?.includes(mode)) {
|
|
341
371
|
void uploader(command.sessionId, command.leaseToken)([{ type: 'closed', error: `The installed ${command.start.configuration.agent} does not advertise support for approval mode ${mode}. Update the agent and let the listener refresh its capabilities.` }]);
|
|
342
372
|
return;
|
|
343
373
|
}
|
|
374
|
+
if (lockdownDir)
|
|
375
|
+
mkdirSync(lockdownDir, { recursive: true, mode: 0o700 });
|
|
344
376
|
const runner = new SessionRunner({
|
|
345
377
|
sessionId: command.sessionId, leaseToken: command.leaseToken, start: command.start, workdir: options.workdir, profile, sandbox: false,
|
|
346
378
|
driver: driver(command.start), upload: uploader(command.sessionId, command.leaseToken), idleMs: options.idleMs, flushIntervalMs: options.flushIntervalMs,
|
|
@@ -361,6 +393,8 @@ export async function listen(options) {
|
|
|
361
393
|
deliveries.delete(command.sessionId);
|
|
362
394
|
await rm(join(imageRoot, command.sessionId), { recursive: true, force: true }).catch(() => { });
|
|
363
395
|
}
|
|
396
|
+
if (lockdownDir)
|
|
397
|
+
await rm(lockdownDir, { recursive: true, force: true }).catch(() => { });
|
|
364
398
|
log(`Closed session ${command.sessionId}.`);
|
|
365
399
|
});
|
|
366
400
|
deliver(runner, command.messages ?? []);
|
|
@@ -406,10 +440,11 @@ export async function listen(options) {
|
|
|
406
440
|
break;
|
|
407
441
|
}
|
|
408
442
|
try {
|
|
409
|
-
if (
|
|
410
|
-
detected =
|
|
411
|
-
|
|
443
|
+
if (pendingDetection) {
|
|
444
|
+
detected = pendingDetection;
|
|
445
|
+
pendingDetection = undefined;
|
|
412
446
|
}
|
|
447
|
+
refreshDetection();
|
|
413
448
|
if (registeredFingerprint !== JSON.stringify(capabilities()))
|
|
414
449
|
await register();
|
|
415
450
|
const polledAt = now();
|
|
@@ -451,6 +486,8 @@ export async function listen(options) {
|
|
|
451
486
|
}
|
|
452
487
|
}
|
|
453
488
|
finally {
|
|
489
|
+
detectionActive = false;
|
|
490
|
+
detectionAbort.abort();
|
|
454
491
|
// Closing reports each session as closed, so the server knows at once that the next message must resume it.
|
|
455
492
|
await Promise.all([...sessions.values()].map(runner => runner.close()));
|
|
456
493
|
}
|
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(['dry-run', 'force', 'headless', 'help', 'json', 'no-teams-watch', 'no-update', 'resolved', 'sandbox']);
|
|
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', 'owners-only', 'resolved', 'review', 'sandbox', 'unread']);
|
|
4
4
|
export const COMMANDS = [
|
|
5
5
|
{
|
|
6
6
|
name: 'login',
|
|
@@ -110,7 +110,7 @@ export const COMMANDS = [
|
|
|
110
110
|
'teams watch [local] [--browser chrome|msedge|chromium]',
|
|
111
111
|
'teams status | test [--json]',
|
|
112
112
|
'teams logout',
|
|
113
|
-
'teams access readOnly|fullAccess',
|
|
113
|
+
'teams access readOnly|limitedAccess|fullAccess',
|
|
114
114
|
'teams upload <file>',
|
|
115
115
|
'teams download <url> --output <new-file>',
|
|
116
116
|
],
|
|
@@ -141,6 +141,43 @@ export const COMMANDS = [
|
|
|
141
141
|
examples: ['skillshare agents status', 'skillshare agents listen --workdir ~/Research', 'skillshare agents service install --workdir ~/Research'],
|
|
142
142
|
flags: ['name', 'workdir', 'max-concurrency', 'no-teams-watch', 'no-update', 'log-file', 'lines', 'browser', 'headless', 'browser-profile', 'json'],
|
|
143
143
|
},
|
|
144
|
+
{
|
|
145
|
+
name: 'news',
|
|
146
|
+
summary: 'Read, write and follow news',
|
|
147
|
+
usage: [
|
|
148
|
+
'news [list] [--tag <slug>] [--importance <level>] [--unread] [--all] [--search <text>] [--limit <n>] [--before <cursor>] [--json]',
|
|
149
|
+
'news show <id> [--keep-unread] [--json]',
|
|
150
|
+
'news read <id>... | news read --all [--tag <slug>] [--importance <level>]',
|
|
151
|
+
'news unread <id>...',
|
|
152
|
+
'news post --title <title> --tags <slug>[,<slug>...] [--importance <level>] [--date <date>] [--lang <locale>] [--file <path> | <text> | -]',
|
|
153
|
+
'news edit <id> [--title <title>] [--tags <slugs>] [--importance <level>] [--date <date>] [--file <path> | <text> | -] [--notify-again]',
|
|
154
|
+
'news delete <id>',
|
|
155
|
+
'news tags [<search>] [--json]',
|
|
156
|
+
'news tag show <slug> | news tag create <slug> [--name <name>] [--description <text>] [--owners-only] [--lang <locale>]',
|
|
157
|
+
'news tag edit <slug> [--name <name>] [--description <text>] [--owners-only true|false] [--owners <userId>,...]',
|
|
158
|
+
'news subscribe <slug> [--importance important|normal|cosmetic]',
|
|
159
|
+
'news unsubscribe <slug> | news subscriptions',
|
|
160
|
+
'news show <id> [--lang <locale>] [--original]',
|
|
161
|
+
'news notify on|off',
|
|
162
|
+
'news review <tag> | news publish <draft id>',
|
|
163
|
+
'news repos | news branches <repository> [--branches <regex>]',
|
|
164
|
+
'news feeds <tag>',
|
|
165
|
+
'news feed create <tag> --repo <alias> --branches <regex> [--digest] [--review] [--agent <listener>[:claude|codex[/<model>]]] [--backfill <days>]',
|
|
166
|
+
'news feed edit <feed id> --tag <tag> [--repo …] [--branches …] [--digest true|false] [--review true|false] [--agent …|auto] [--disabled true|false]',
|
|
167
|
+
'news feed run|preview|delete <feed id>',
|
|
168
|
+
],
|
|
169
|
+
description: 'Without --all, list shows your feed: news from the tags you follow, at or above the importance you chose for each. --all lists everything (with --tag, one tag whether or not you follow it). Levels are important, normal and cosmetic; following with cosmetic shows everything. show marks the item read like opening it in the browser. read --all marks the whole feed (or one tag / importance) read and prints the command to undo it. post reads the Markdown text from --file, the arguments or stdin, and is written in your language: --lang, otherwise the language you last chose in the web app. A future --date schedules the item. Creating a tag makes you its owner and follower. News is shown in your language (--lang, else the one you chose in the web app); a missing translation is made by the agent of the author or a tag owner, locked down, and the original is shown meanwhile (--original always shows it). Repo feeds turn merged pull requests and commits of branches matching a regex into news of a tag: the connected agent of the feed owner, locked down, classifies each change as important, normal or cosmetic and writes it in all four languages. --review keeps that news as drafts for news review/publish; --digest writes one item a day; feed preview lets the agent write from recent changes without publishing. news branches shows which branches a regex follows. notify on sends browser notifications for important news in your feed.',
|
|
170
|
+
examples: [
|
|
171
|
+
'skillshare news --unread',
|
|
172
|
+
'skillshare news show 42',
|
|
173
|
+
'skillshare news read --all --tag platform',
|
|
174
|
+
'skillshare news post --title "Release 2.0" --tags platform,web --importance important --file notes.md',
|
|
175
|
+
'skillshare news subscribe platform --importance important',
|
|
176
|
+
],
|
|
177
|
+
flags: ['tag', 'importance', 'unread', 'all', 'search', 'limit', 'before', 'keep-unread', 'title', 'tags', 'date', 'lang', 'file',
|
|
178
|
+
'notify-again', 'name', 'description', 'owners-only', 'owners', 'original', 'repo', 'branches', 'digest', 'review', 'agent', 'backfill',
|
|
179
|
+
'disabled', 'json'],
|
|
180
|
+
},
|
|
144
181
|
{
|
|
145
182
|
name: 'git',
|
|
146
183
|
summary: 'Register Skillshare in Git Credential Manager',
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { refreshSession, withSessionLock, writeSessionAtomically } from './session-auth.js';
|
|
2
2
|
import { configurePageLinks } from './page-links.js';
|
|
3
3
|
import { runSalesforceCommand } from './salesforce.js';
|
|
4
|
+
import { runNewsCommand } from './news.js';
|
|
4
5
|
import { assertCredentialDestination, resolveTeamsObjectId, runTeamsCommand, watchTeamsInBackground } from './teams.js';
|
|
5
6
|
import { runAgentsCommand, runServiceCommand } from './agents.js';
|
|
6
7
|
import { SERVICE_ENV } from './agents-update.js';
|
|
@@ -159,6 +160,14 @@ async function main() {
|
|
|
159
160
|
await runSalesforceCommand(await createClient(baseUrl, options.token), options.positionals, options.flags, openBrowser);
|
|
160
161
|
return;
|
|
161
162
|
}
|
|
163
|
+
case 'news': {
|
|
164
|
+
const baseUrl = options.flags.server ?? await resolveActiveBaseUrl();
|
|
165
|
+
assertCredentialDestination(baseUrl);
|
|
166
|
+
if (!options.token && !await loadSession(baseUrl))
|
|
167
|
+
await login(baseUrl);
|
|
168
|
+
await runNewsCommand(await createClient(baseUrl, options.token), options.positionals, options.flags, print);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
162
171
|
case 'agents': {
|
|
163
172
|
// Managing the background service needs no server, except to install it.
|
|
164
173
|
if (options.positionals[0] === 'service' && options.positionals[1] !== 'install') {
|