talentos 1.4.22 → 1.6.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 +120 -17
- package/dist/agent/adapters.js +12 -2
- package/dist/agent/codex-policy.js +71 -0
- package/dist/agent/native/touch.js +18 -8
- package/dist/agent/provider-failure.js +9 -2
- package/dist/agent/serve.js +28 -5
- package/dist/agent/talentos-content.js +33 -0
- package/dist/agent-link.js +31 -3
- package/dist/args.js +14 -1
- package/dist/claude-plugin.js +82 -0
- package/dist/client.js +8 -4
- package/dist/commands/agent.js +1 -1
- package/dist/commands/approvals.js +145 -0
- package/dist/commands/doctor.js +427 -0
- package/dist/commands/init.js +78 -9
- package/dist/commands/login.js +10 -1
- package/dist/commands/mcp.js +17 -2
- package/dist/commands/publish.js +74 -0
- package/dist/commands/skills-sync.js +174 -0
- package/dist/commands/skills.js +24 -4
- package/dist/commands/task.js +77 -0
- package/dist/commands/tools.js +56 -0
- package/dist/config.js +34 -0
- package/dist/format.js +12 -0
- package/dist/hosting-skill.js +67 -0
- package/dist/index.js +129 -23
- package/dist/install.js +126 -38
- package/dist/memory-wire.js +22 -0
- package/dist/output.js +107 -0
- package/dist/publish-site.js +291 -0
- package/dist/published-pages.js +30 -0
- package/dist/setup.generated.js +180 -0
- package/dist/skill-files.js +1 -1
- package/dist/skill-sync-state.js +38 -0
- package/dist/upload-file.js +1 -1
- package/dist/watch.js +39 -0
- package/package.json +3 -2
- package/plugin/.claude-plugin/marketplace.json +12 -0
- package/plugin/plugins/talentos/.claude-plugin/plugin.json +9 -0
- package/plugin/plugins/talentos/.mcp.json +8 -0
- package/plugin/plugins/talentos/commands/ask-talent.md +21 -0
- package/plugin/plugins/talentos/commands/catch-up.md +16 -0
- package/plugin/plugins/talentos/commands/remember.md +15 -0
- package/plugin/plugins/talentos/hooks/hooks.json +17 -0
- package/plugin/plugins/talentos/scripts/session-start.mjs +177 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { withClient } from "../client.js";
|
|
3
|
+
import { emit, emitJson, emitLink } from "../format.js";
|
|
4
|
+
import { bundleSite } from "../publish-site.js";
|
|
5
|
+
import { publishedPage, rememberPublishedPage } from "../published-pages.js";
|
|
6
|
+
export const PUBLISH_TOOL = "publish_web_app";
|
|
7
|
+
const SAID = {
|
|
8
|
+
created: (title) => `Published ${title} to your Library. Only you can open it.`,
|
|
9
|
+
unchanged: (title) => `${title} is already up to date.`,
|
|
10
|
+
updated: (title) => `Updated ${title} in your Library.`,
|
|
11
|
+
};
|
|
12
|
+
/** Whether this sign-in may publish: the server shows the tool only where hosting is on. */
|
|
13
|
+
export async function hostingAvailable(client) {
|
|
14
|
+
let cursor;
|
|
15
|
+
do {
|
|
16
|
+
const page = await client.listTools(cursor);
|
|
17
|
+
if (page.tools.some((tool) => tool.name === PUBLISH_TOOL)) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
cursor = page.nextCursor;
|
|
21
|
+
} while (cursor);
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
export async function runPublish(parsed) {
|
|
25
|
+
if (parsed.args.length > 1) {
|
|
26
|
+
throw new Error("Usage: talentos publish [folder|page.html] [--title <title>] [--replace]");
|
|
27
|
+
}
|
|
28
|
+
const site = await bundleSite(parsed.args[0] ?? ".");
|
|
29
|
+
const named = parsed.options.title?.trim() || undefined;
|
|
30
|
+
const published = await withClient(parsed.options["api-url"], async (client) => {
|
|
31
|
+
if (!(await hostingAvailable(client))) {
|
|
32
|
+
throw new Error("Publishing to TalentOS isn't turned on for your workspace yet.");
|
|
33
|
+
}
|
|
34
|
+
const publish = async (args) => (await client.call(PUBLISH_TOOL, {
|
|
35
|
+
html: site.html,
|
|
36
|
+
requestId: randomUUID(),
|
|
37
|
+
...args,
|
|
38
|
+
})).data;
|
|
39
|
+
const create = () => publish({ title: named ?? site.title });
|
|
40
|
+
const before = await publishedPage(site.entry, client.apiUrl);
|
|
41
|
+
let result = before
|
|
42
|
+
? await publish({
|
|
43
|
+
artifactId: before.artifactId,
|
|
44
|
+
baseVersionId: before.versionId,
|
|
45
|
+
...(named ? { title: named } : {}),
|
|
46
|
+
...(parsed.options.replace ? { replace: true } : {}),
|
|
47
|
+
})
|
|
48
|
+
: await create();
|
|
49
|
+
if (result.status === "missing") {
|
|
50
|
+
// Deleted from the Library since: this page becomes a new app.
|
|
51
|
+
result = await create();
|
|
52
|
+
}
|
|
53
|
+
if (result.status === "missing") {
|
|
54
|
+
throw new Error("TalentOS did not save the page. Try again.");
|
|
55
|
+
}
|
|
56
|
+
if (result.status !== "changed_in_talentos") {
|
|
57
|
+
await rememberPublishedPage(site.entry, {
|
|
58
|
+
apiUrl: client.apiUrl,
|
|
59
|
+
artifactId: result.artifactId,
|
|
60
|
+
versionId: result.versionId,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
});
|
|
65
|
+
if (published.status === "changed_in_talentos") {
|
|
66
|
+
throw new Error(`Someone changed ${published.title} in TalentOS since it was last published from here, so nothing was replaced. To put this version over that change, run publish again with --replace.`);
|
|
67
|
+
}
|
|
68
|
+
if (parsed.options.json) {
|
|
69
|
+
emitJson(published);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
emit(SAID[published.status](published.title));
|
|
73
|
+
emitLink(published.url);
|
|
74
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { rm } from "node:fs/promises";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { withClient } from "../client.js";
|
|
4
|
+
import { emit, emitJson, renderTable, warn } from "../format.js";
|
|
5
|
+
import { homeDir, pullDirs } from "../install.js";
|
|
6
|
+
import { escapesRoot, SKILL_ENTRY, writeSkillPackage } from "../skill-files.js";
|
|
7
|
+
import { hashFiles, readManifest, readText, sha, writeManifest, } from "../skill-sync-state.js";
|
|
8
|
+
import { folderFor, mapConcurrent, PULL_LIMIT, scopeFrom, } from "./skills.js";
|
|
9
|
+
const FETCH_CONCURRENCY = 4;
|
|
10
|
+
/**
|
|
11
|
+
* `talentos skills sync`: bring the skill folders up to date, touching only
|
|
12
|
+
* what changed, and never overwrite work you did here.
|
|
13
|
+
*
|
|
14
|
+
* The rule, per skill folder:
|
|
15
|
+
* - Not here yet: written.
|
|
16
|
+
* - Written by an earlier sync and you have not touched it: updated when
|
|
17
|
+
* TalentOS has a newer version, otherwise not rewritten at all.
|
|
18
|
+
* - You edited, deleted or replaced a file the sync wrote, and TalentOS has
|
|
19
|
+
* since published a newer version: the whole skill is left exactly as it is
|
|
20
|
+
* ("kept") until you run `skills pull`. A skill you deleted stays deleted
|
|
21
|
+
* until then too.
|
|
22
|
+
* - A folder this sync did not write (yours, or from `skills pull`): left alone
|
|
23
|
+
* ("differs") unless every file already matches TalentOS.
|
|
24
|
+
* - Files you added, and skills TalentOS no longer lists: never deleted.
|
|
25
|
+
*/
|
|
26
|
+
export async function runSkillsSync(parsed) {
|
|
27
|
+
const dirs = pullDirs({
|
|
28
|
+
home: homeDir(),
|
|
29
|
+
target: parsed.options.for,
|
|
30
|
+
global: parsed.options.global,
|
|
31
|
+
to: parsed.options.to,
|
|
32
|
+
});
|
|
33
|
+
const results = await withClient(parsed.options["api-url"], (client) => syncInto(client, dirs, scopeFrom(parsed.options)));
|
|
34
|
+
if (parsed.options.json) {
|
|
35
|
+
emitJson(results);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const attention = results.filter((result) => result.status === "kept" || result.status === "differs");
|
|
39
|
+
for (const result of attention) {
|
|
40
|
+
warn(attentionLine(result));
|
|
41
|
+
}
|
|
42
|
+
if (parsed.options.quiet) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const changed = results.filter((result) => result.status === "added" || result.status === "updated");
|
|
46
|
+
if (changed.length === 0 && attention.length === 0) {
|
|
47
|
+
emit("Skills are up to date.");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
emit([
|
|
51
|
+
renderTable(["SKILL", "STATUS"], [...changed, ...attention].map((result) => [
|
|
52
|
+
result.slug,
|
|
53
|
+
STATUS_TEXT[result.status],
|
|
54
|
+
])),
|
|
55
|
+
`${changed.length} changed, ${attention.length} left alone in ${dirs.map((dir) => resolve(dir)).join(", ")}`,
|
|
56
|
+
].join("\n\n"));
|
|
57
|
+
}
|
|
58
|
+
const STATUS_TEXT = {
|
|
59
|
+
added: "added",
|
|
60
|
+
differs: "left alone (a different version is already here)",
|
|
61
|
+
kept: "kept your edits (TalentOS has a newer version)",
|
|
62
|
+
unchanged: "up to date",
|
|
63
|
+
updated: "updated",
|
|
64
|
+
};
|
|
65
|
+
function attentionLine(result) {
|
|
66
|
+
return `${result.slug}: ${STATUS_TEXT[result.status]}. \`talentos skills pull\` replaces it with TalentOS's version.`;
|
|
67
|
+
}
|
|
68
|
+
export async function syncInto(client, dirs, scope) {
|
|
69
|
+
const { data } = await client.call("list_skills", { scope, limit: PULL_LIMIT });
|
|
70
|
+
if (data.skills.length === PULL_LIMIT) {
|
|
71
|
+
warn(`Synced the first ${PULL_LIMIT} skills; there may be more. Narrow with --mine, --company or -q <query>.`);
|
|
72
|
+
}
|
|
73
|
+
const fetched = new Map();
|
|
74
|
+
const packageOf = (id) => {
|
|
75
|
+
let pending = fetched.get(id);
|
|
76
|
+
if (!pending) {
|
|
77
|
+
pending = client
|
|
78
|
+
.call("get_skill", { skillId: id })
|
|
79
|
+
.then((result) => result.data);
|
|
80
|
+
fetched.set(id, pending);
|
|
81
|
+
}
|
|
82
|
+
return pending;
|
|
83
|
+
};
|
|
84
|
+
const results = [];
|
|
85
|
+
for (const dir of dirs) {
|
|
86
|
+
results.push(...(await syncDir(dir, data.skills, packageOf)));
|
|
87
|
+
}
|
|
88
|
+
return results;
|
|
89
|
+
}
|
|
90
|
+
async function syncDir(dir, skills, packageOf) {
|
|
91
|
+
const manifest = await readManifest(dir);
|
|
92
|
+
const before = JSON.stringify(manifest);
|
|
93
|
+
const taken = new Set();
|
|
94
|
+
const planned = [...skills]
|
|
95
|
+
.sort((a, b) => a.slug.localeCompare(b.slug))
|
|
96
|
+
.map((skill) => ({ folder: folderFor(skill, taken), skill }));
|
|
97
|
+
// A skill whose id and version match the last sync is not fetched at all.
|
|
98
|
+
const stale = await mapConcurrent(planned, FETCH_CONCURRENCY, async (item) => {
|
|
99
|
+
const entry = manifest[item.folder];
|
|
100
|
+
const current = entry?.id === item.skill.id && entry.version === item.skill.version;
|
|
101
|
+
return current ? undefined : await packageOf(item.skill.id);
|
|
102
|
+
});
|
|
103
|
+
const results = [];
|
|
104
|
+
for (const [index, item] of planned.entries()) {
|
|
105
|
+
const pkg = stale[index];
|
|
106
|
+
results.push({
|
|
107
|
+
dir,
|
|
108
|
+
slug: item.folder,
|
|
109
|
+
status: pkg === undefined
|
|
110
|
+
? "unchanged"
|
|
111
|
+
: await syncOne(dir, item.folder, pkg, manifest),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (JSON.stringify(manifest) !== before) {
|
|
115
|
+
await writeManifest(dir, manifest);
|
|
116
|
+
}
|
|
117
|
+
return results;
|
|
118
|
+
}
|
|
119
|
+
async function syncOne(dir, folder, pkg, manifest) {
|
|
120
|
+
const root = resolve(dir, folder);
|
|
121
|
+
const remote = hashFiles(pkg.files);
|
|
122
|
+
const recorded = manifest[folder]?.id === pkg.id ? manifest[folder] : undefined;
|
|
123
|
+
const local = await localHashes(root, [
|
|
124
|
+
...Object.keys(remote),
|
|
125
|
+
...Object.keys(recorded?.files ?? {}),
|
|
126
|
+
]);
|
|
127
|
+
const record = () => {
|
|
128
|
+
manifest[folder] = { files: remote, id: pkg.id, version: pkg.version };
|
|
129
|
+
};
|
|
130
|
+
if (sameHashes(local, remote, Object.keys(remote))) {
|
|
131
|
+
// Already exactly TalentOS's version, however it got here.
|
|
132
|
+
record();
|
|
133
|
+
return "unchanged";
|
|
134
|
+
}
|
|
135
|
+
if (recorded === undefined) {
|
|
136
|
+
if (local[SKILL_ENTRY] !== undefined) {
|
|
137
|
+
return "differs";
|
|
138
|
+
}
|
|
139
|
+
await writeSkillPackage(dir, folder, pkg.files);
|
|
140
|
+
record();
|
|
141
|
+
return "added";
|
|
142
|
+
}
|
|
143
|
+
if (!sameHashes(local, recorded.files, Object.keys(recorded.files))) {
|
|
144
|
+
return "kept";
|
|
145
|
+
}
|
|
146
|
+
await writeSkillPackage(dir, folder, pkg.files);
|
|
147
|
+
for (const path of Object.keys(recorded.files)) {
|
|
148
|
+
if (!(path in remote)) {
|
|
149
|
+
await removeInside(root, path);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
record();
|
|
153
|
+
return "updated";
|
|
154
|
+
}
|
|
155
|
+
async function localHashes(root, paths) {
|
|
156
|
+
const hashes = {};
|
|
157
|
+
for (const path of new Set(paths)) {
|
|
158
|
+
if (escapesRoot(root, path)) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const text = await readText(resolve(root, path));
|
|
162
|
+
hashes[path] = text === undefined ? undefined : sha(text);
|
|
163
|
+
}
|
|
164
|
+
return hashes;
|
|
165
|
+
}
|
|
166
|
+
function sameHashes(local, expected, paths) {
|
|
167
|
+
return paths.every((path) => local[path] === expected[path]);
|
|
168
|
+
}
|
|
169
|
+
/** Never follows a manifest path out of the skill folder. */
|
|
170
|
+
async function removeInside(root, path) {
|
|
171
|
+
if (!escapesRoot(root, path)) {
|
|
172
|
+
await rm(resolve(root, path), { force: true });
|
|
173
|
+
}
|
|
174
|
+
}
|
package/dist/commands/skills.js
CHANGED
|
@@ -4,11 +4,12 @@ import { withClient } from "../client.js";
|
|
|
4
4
|
import { bold, emit, emitJson, emitLink, formatDate, renderTable, truncate, warn, } from "../format.js";
|
|
5
5
|
import { homeDir, pullDirs } from "../install.js";
|
|
6
6
|
import { readSkillPackage, SKILL_ENTRY, writeSkillPackage, } from "../skill-files.js";
|
|
7
|
+
import { hashFiles, readManifest, writeManifest } from "../skill-sync-state.js";
|
|
7
8
|
const SUMMARY_WIDTH = 60;
|
|
8
9
|
/** Enough to hide the round-trip latency of 100 skills without flooding. */
|
|
9
10
|
const PULL_CONCURRENCY = 4;
|
|
10
11
|
/** The server's ceiling: asking for less silently truncates at its default 50. */
|
|
11
|
-
const PULL_LIMIT = 100;
|
|
12
|
+
export const PULL_LIMIT = 100;
|
|
12
13
|
const ID_SUFFIX_LENGTH = 6;
|
|
13
14
|
export async function runSkills(parsed) {
|
|
14
15
|
switch (parsed.action) {
|
|
@@ -20,10 +21,13 @@ export async function runSkills(parsed) {
|
|
|
20
21
|
return await pushSkill(parsed);
|
|
21
22
|
case "pull":
|
|
22
23
|
return await pullSkills(parsed);
|
|
24
|
+
case "sync":
|
|
25
|
+
// Imported here, not at the top: skills-sync.ts imports this file.
|
|
26
|
+
return await (await import("./skills-sync.js")).runSkillsSync(parsed);
|
|
23
27
|
case "share":
|
|
24
28
|
return shareSkill();
|
|
25
29
|
default:
|
|
26
|
-
throw new Error("Usage: talentos skills <list|get|push|pull> — see `talentos skills --help`");
|
|
30
|
+
throw new Error("Usage: talentos skills <list|get|push|pull|sync> — see `talentos skills --help`");
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
export function scopeFrom(options) {
|
|
@@ -140,6 +144,9 @@ export async function pullInto(client, dirs, scope) {
|
|
|
140
144
|
const packages = await mapConcurrent(data.skills, PULL_CONCURRENCY, async (skill) => (await client.call("get_skill", { skillId: skill.id })).data);
|
|
141
145
|
const results = [];
|
|
142
146
|
const taken = new Set();
|
|
147
|
+
// A pull overwrites on purpose, so what it writes is what `skills sync`
|
|
148
|
+
// later keeps current: record it the way sync does.
|
|
149
|
+
const manifests = new Map(await Promise.all(dirs.map(async (dir) => [dir, await readManifest(dir)])));
|
|
143
150
|
// Fetched in parallel, written in slug order, so a run is reproducible.
|
|
144
151
|
for (const pkg of [...packages].sort((a, b) => a.slug.localeCompare(b.slug))) {
|
|
145
152
|
const slug = folderFor(pkg, taken);
|
|
@@ -147,13 +154,26 @@ export async function pullInto(client, dirs, scope) {
|
|
|
147
154
|
for (const dir of dirs) {
|
|
148
155
|
created = created || !(await exists(join(dir, slug, SKILL_ENTRY)));
|
|
149
156
|
await writeSkillPackage(dir, slug, pkg.files);
|
|
157
|
+
const manifest = manifests.get(dir);
|
|
158
|
+
if (manifest) {
|
|
159
|
+
manifest[slug] = {
|
|
160
|
+
files: hashFiles(pkg.files),
|
|
161
|
+
id: pkg.id,
|
|
162
|
+
version: pkg.version,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
150
165
|
}
|
|
151
166
|
results.push({ slug, created });
|
|
152
167
|
}
|
|
168
|
+
for (const [dir, manifest] of manifests) {
|
|
169
|
+
if (results.length > 0) {
|
|
170
|
+
await writeManifest(dir, manifest);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
153
173
|
return results;
|
|
154
174
|
}
|
|
155
175
|
/** Two skills may share a slug; the second keeps its own folder, not the first's. */
|
|
156
|
-
function folderFor(pkg, taken) {
|
|
176
|
+
export function folderFor(pkg, taken) {
|
|
157
177
|
if (!taken.has(pkg.slug)) {
|
|
158
178
|
taken.add(pkg.slug);
|
|
159
179
|
return pkg.slug;
|
|
@@ -164,7 +184,7 @@ function folderFor(pkg, taken) {
|
|
|
164
184
|
return unique;
|
|
165
185
|
}
|
|
166
186
|
/** Runs `work` over `items` with at most `limit` in flight, keeping order. */
|
|
167
|
-
async function mapConcurrent(items, limit, work) {
|
|
187
|
+
export async function mapConcurrent(items, limit, work) {
|
|
168
188
|
const results = [];
|
|
169
189
|
let next = 0;
|
|
170
190
|
const worker = async () => {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { withClient } from "../client.js";
|
|
2
|
+
import { emit, emitJson } from "../format.js";
|
|
3
|
+
import { CliError, cliContractEnabled, nextActions, withApiUrl, } from "../output.js";
|
|
4
|
+
import { watch } from "../watch.js";
|
|
5
|
+
const RUNNING = new Set(["queued", "working"]);
|
|
6
|
+
export async function runTask(parsed) {
|
|
7
|
+
if (!cliContractEnabled()) {
|
|
8
|
+
throw new CliError("FEATURE_DISABLED", "Task commands need HEADLESS_CLI_V1=true until release.");
|
|
9
|
+
}
|
|
10
|
+
const taskId = parsed.args[0];
|
|
11
|
+
if (!taskId ||
|
|
12
|
+
parsed.args.length !== 1 ||
|
|
13
|
+
!["status", "watch"].includes(parsed.action ?? "")) {
|
|
14
|
+
throw new CliError("INVALID_ARGUMENT", "Usage: talentos task <status|watch> <id> [--json]");
|
|
15
|
+
}
|
|
16
|
+
await withClient(parsed.options["api-url"], async (client) => {
|
|
17
|
+
const read = async (previous, waitSeconds, signal) => {
|
|
18
|
+
const { data } = await client.call("get_task", {
|
|
19
|
+
taskId,
|
|
20
|
+
waitSeconds,
|
|
21
|
+
...(previous ? { since: previous.version } : {}),
|
|
22
|
+
}, { signal });
|
|
23
|
+
return data;
|
|
24
|
+
};
|
|
25
|
+
const task = parsed.action === "watch"
|
|
26
|
+
? await watch({
|
|
27
|
+
read,
|
|
28
|
+
isRunning: (value) => RUNNING.has(value.state),
|
|
29
|
+
version: (value) => value.version,
|
|
30
|
+
onChange: (value) => {
|
|
31
|
+
if (RUNNING.has(value.state)) {
|
|
32
|
+
emit(renderTask(value));
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
: await read(undefined, 0);
|
|
37
|
+
nextActions(taskNext(task, parsed.options["api-url"]));
|
|
38
|
+
if (parsed.options.json) {
|
|
39
|
+
emitJson(task);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
emit(renderTask(task));
|
|
43
|
+
for (const action of taskNext(task, parsed.options["api-url"])) {
|
|
44
|
+
emit(`Next: ${action.command} — ${action.why}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function taskNext(task, apiUrl) {
|
|
50
|
+
if (["done", "failed", "cancelled"].includes(task.state)) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
let why = "Keep following the task without starting another run.";
|
|
54
|
+
if (task.state === "needs_input") {
|
|
55
|
+
why = `The member must ${task.question?.kind === "approval" ? "approve" : "answer"} in TalentOS${task.link ? ` (${task.link})` : ""}; follow again afterwards.`;
|
|
56
|
+
}
|
|
57
|
+
else if (task.state === "stale") {
|
|
58
|
+
why = "No recent progress; follow again to see whether the Talent resumes.";
|
|
59
|
+
}
|
|
60
|
+
return [
|
|
61
|
+
{ command: withApiUrl(`talentos task watch ${task.taskId}`, apiUrl), why },
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
function renderTask(task) {
|
|
65
|
+
return [
|
|
66
|
+
`Task ${task.taskId}: ${task.state}`,
|
|
67
|
+
...task.progress,
|
|
68
|
+
...(task.question ? [task.question.text] : []),
|
|
69
|
+
...(task.result
|
|
70
|
+
? [
|
|
71
|
+
task.result.text,
|
|
72
|
+
...task.result.files.map((file) => `${file.title}${file.url ? `: ${file.url}` : ""}`),
|
|
73
|
+
]
|
|
74
|
+
: []),
|
|
75
|
+
...(task.link ? [`Open: ${task.link}`] : []),
|
|
76
|
+
].join("\n");
|
|
77
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { withClient } from "../client.js";
|
|
2
|
+
import { emitJson } from "../format.js";
|
|
3
|
+
import { CliError, cliContractEnabled } from "../output.js";
|
|
4
|
+
export async function runTools(parsed) {
|
|
5
|
+
if (!cliContractEnabled()) {
|
|
6
|
+
throw new CliError("FEATURE_DISABLED", "Tool commands need HEADLESS_CLI_V1=true until release.");
|
|
7
|
+
}
|
|
8
|
+
if (parsed.group === "tools") {
|
|
9
|
+
if (parsed.args.length) {
|
|
10
|
+
throw new CliError("INVALID_ARGUMENT", "Usage: talentos tools [--json]");
|
|
11
|
+
}
|
|
12
|
+
await withClient(parsed.options["api-url"], async (client) => {
|
|
13
|
+
const tools = [];
|
|
14
|
+
let cursor;
|
|
15
|
+
do {
|
|
16
|
+
const page = await client.listTools(cursor);
|
|
17
|
+
tools.push(...page.tools);
|
|
18
|
+
cursor = page.nextCursor;
|
|
19
|
+
} while (cursor);
|
|
20
|
+
emitJson({ tools });
|
|
21
|
+
});
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const [name, raw] = parsed.args;
|
|
25
|
+
if (!name ||
|
|
26
|
+
parsed.args.length > 2 ||
|
|
27
|
+
(raw !== undefined && !parsed.options.json)) {
|
|
28
|
+
throw new CliError("INVALID_ARGUMENT", "Usage: talentos call <tool> [--json '<args>']");
|
|
29
|
+
}
|
|
30
|
+
let args = {};
|
|
31
|
+
if (raw !== undefined) {
|
|
32
|
+
try {
|
|
33
|
+
args = JSON.parse(raw);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw new CliError("INVALID_ARGUMENT", "Tool arguments must be a valid JSON object.");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (args === null || typeof args !== "object" || Array.isArray(args)) {
|
|
40
|
+
throw new CliError("INVALID_ARGUMENT", "Tool arguments must be a JSON object.");
|
|
41
|
+
}
|
|
42
|
+
await withClient(parsed.options["api-url"], async (client) => {
|
|
43
|
+
const result = await client.callTool({
|
|
44
|
+
name,
|
|
45
|
+
arguments: args,
|
|
46
|
+
});
|
|
47
|
+
if (result.isError) {
|
|
48
|
+
const message = result.content
|
|
49
|
+
.filter((block) => block.type === "text")
|
|
50
|
+
.map((block) => block.text)
|
|
51
|
+
.join("\n");
|
|
52
|
+
throw new CliError("TOOL_ERROR", message || `Tool ${name} failed.`, undefined, result);
|
|
53
|
+
}
|
|
54
|
+
emitJson(result);
|
|
55
|
+
});
|
|
56
|
+
}
|
package/dist/config.js
CHANGED
|
@@ -3,6 +3,13 @@ import { homedir } from "node:os";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
const TRAILING_SLASHES = /\/+$/;
|
|
5
5
|
export const DEFAULT_API_URL = "https://woozy-oyster-769.convex.site";
|
|
6
|
+
/**
|
|
7
|
+
* The remote MCP address clients are pointed at. The one place it is written:
|
|
8
|
+
* `plugin/plugins/talentos/.mcp.json` ships the same value (a test holds them
|
|
9
|
+
* equal) and `init` renders any other address into its staged copy. A branded
|
|
10
|
+
* MCP domain changes it here and in that file, nowhere else.
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_MCP_URL = `${DEFAULT_API_URL}/mcp`;
|
|
6
13
|
export function configDir(env = process.env) {
|
|
7
14
|
// An empty XDG_CONFIG_HOME is unset per the XDG spec; taking it literally
|
|
8
15
|
// would write the key into whatever directory the CLI was started from.
|
|
@@ -21,6 +28,33 @@ export function resolveApiUrl(override, fallback) {
|
|
|
21
28
|
const chosen = override === undefined || override.trim() === "" ? fallback : override;
|
|
22
29
|
return chosen.trim().replace(TRAILING_SLASHES, "");
|
|
23
30
|
}
|
|
31
|
+
/** Validate the optional origin before printing a bearer-bearing client config. */
|
|
32
|
+
export function resolveMcpOrigin(apiUrl, configured = process.env.MCP_PUBLIC_ORIGIN) {
|
|
33
|
+
if (!configured?.trim()) {
|
|
34
|
+
return apiUrl;
|
|
35
|
+
}
|
|
36
|
+
// The published CLI has no dependency on the app's source-only packages.
|
|
37
|
+
const url = new URL(configured.trim());
|
|
38
|
+
if (url.protocol !== "https:" ||
|
|
39
|
+
url.username ||
|
|
40
|
+
url.password ||
|
|
41
|
+
url.pathname !== "/" ||
|
|
42
|
+
url.search ||
|
|
43
|
+
url.hash) {
|
|
44
|
+
throw new Error("MCP_PUBLIC_ORIGIN must be an HTTPS origin without credentials, path, query or fragment.");
|
|
45
|
+
}
|
|
46
|
+
return url.origin;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The MCP url a client is given: `MCP_PUBLIC_ORIGIN` when it is set (the
|
|
50
|
+
* branded address), else the default API url gets `DEFAULT_MCP_URL` and any
|
|
51
|
+
* other (a staging key's) keeps its own `/mcp`, so a key never reaches the
|
|
52
|
+
* wrong deployment. Every client config and the staged plugin use this.
|
|
53
|
+
*/
|
|
54
|
+
export function mcpUrlFor(apiUrl, configured = process.env.MCP_PUBLIC_ORIGIN) {
|
|
55
|
+
const origin = resolveMcpOrigin(resolveApiUrl(apiUrl, DEFAULT_API_URL), configured);
|
|
56
|
+
return origin === DEFAULT_API_URL ? DEFAULT_MCP_URL : `${origin}/mcp`;
|
|
57
|
+
}
|
|
24
58
|
/**
|
|
25
59
|
* File values first, then env overrides. A machine with TALENTOS_API_KEY set
|
|
26
60
|
* (CI, a container, `codex` launching the stdio proxy) must never fall back to
|
package/dist/format.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { machineOutput } from "./output.js";
|
|
1
2
|
const WHITESPACE = /\s+/g;
|
|
2
3
|
const ANSI = {
|
|
3
4
|
bold: "[1m",
|
|
@@ -26,6 +27,12 @@ export function renderTable(headers, rows) {
|
|
|
26
27
|
return [dim(line(headers)), ...rows.map(line)].join("\n");
|
|
27
28
|
}
|
|
28
29
|
export function emit(text) {
|
|
30
|
+
const output = machineOutput();
|
|
31
|
+
if (output) {
|
|
32
|
+
output.message = text;
|
|
33
|
+
process.stderr.write(`${text}\n`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
29
36
|
process.stdout.write(`${text}\n`);
|
|
30
37
|
}
|
|
31
38
|
/** The app deep link a tool result carries; absent when the backend has no app url. */
|
|
@@ -39,6 +46,11 @@ export function warn(text) {
|
|
|
39
46
|
process.stderr.write(`${dim(text)}\n`);
|
|
40
47
|
}
|
|
41
48
|
export function emitJson(value) {
|
|
49
|
+
const output = machineOutput();
|
|
50
|
+
if (output) {
|
|
51
|
+
output.data = value;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
42
54
|
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
43
55
|
}
|
|
44
56
|
export function truncate(text, max) {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { pullDirs } from "./install.js";
|
|
2
|
+
import { writeSkillPackage } from "./skill-files.js";
|
|
3
|
+
export const HOSTING_SKILL_SLUG = "host-on-talentos";
|
|
4
|
+
// Written by `talentos init` at user level, so it works in every project. The
|
|
5
|
+
// person is often not technical: the agent asks nothing it can decide itself
|
|
6
|
+
// and says nothing about how hosting works.
|
|
7
|
+
export const HOSTING_SKILL_MD = `---
|
|
8
|
+
name: host-on-talentos
|
|
9
|
+
description: Publish a web page, site, app, game, dashboard or prototype you made to TalentOS and give the person a link. Use when they say host it, publish it, put it online, share it, deploy it or give me a link, or name TalentOS hosting.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Host on TalentOS
|
|
13
|
+
|
|
14
|
+
The person wants a link to what you made. Get it to them with no questions and
|
|
15
|
+
no technical talk.
|
|
16
|
+
|
|
17
|
+
## Do
|
|
18
|
+
|
|
19
|
+
1. Find what to publish yourself: the folder with the \`index.html\` you just
|
|
20
|
+
made or built, or one \`.html\` file. Build it first if it needs a build.
|
|
21
|
+
Ask only when there are several unrelated pages and nothing says which.
|
|
22
|
+
2. Run \`npx talentos@1 publish <folder or page.html>\`. Add \`--title "<name>"\`
|
|
23
|
+
when the page has no good \`<title>\`.
|
|
24
|
+
3. Reply with one short line and the link it printed, exactly as printed. For
|
|
25
|
+
example: "Here it is: <link>. Only you can open it for now."
|
|
26
|
+
|
|
27
|
+
To change it later, edit the files and run the same command again. It updates
|
|
28
|
+
the same page at the same link, and TalentOS keeps the earlier versions.
|
|
29
|
+
|
|
30
|
+
## When it refuses
|
|
31
|
+
|
|
32
|
+
Fix what you can and run it again without asking: copy a missing file into the
|
|
33
|
+
folder, move styles, scripts, images and fonts from other websites into the
|
|
34
|
+
folder, inline a module's imports with a single-file build, or put a second
|
|
35
|
+
page on \`index.html\`.
|
|
36
|
+
|
|
37
|
+
If it still can't be hosted (it needs a server, a database, an API key, or
|
|
38
|
+
calls another website), tell the person in one plain sentence what can't work
|
|
39
|
+
and what to change. Example: "TalentOS can't host the login part, because it
|
|
40
|
+
needs a server; I can publish the page without it."
|
|
41
|
+
|
|
42
|
+
If it says someone changed the page in TalentOS since, ask the person one
|
|
43
|
+
question: should this version replace that change? Run it again with
|
|
44
|
+
\`--replace\` only if they say yes.
|
|
45
|
+
|
|
46
|
+
If it says to sign in or that publishing is off, tell the person in one
|
|
47
|
+
sentence: sign in with \`npx talentos@1 init\`, or ask their TalentOS admin to
|
|
48
|
+
turn hosting on.
|
|
49
|
+
|
|
50
|
+
## Never
|
|
51
|
+
|
|
52
|
+
- Never ask about rooms, settings, versions or file formats.
|
|
53
|
+
- Never explain bundling, sandboxes, flags or how the link works.
|
|
54
|
+
- Never build or rewrite the link yourself.
|
|
55
|
+
`;
|
|
56
|
+
/** The user-level skill folders of these agents, under `home`. */
|
|
57
|
+
export function hostingSkillDirs(home, targets) {
|
|
58
|
+
const dirs = targets.flatMap((target) => pullDirs({ global: true, home, target }));
|
|
59
|
+
return [...new Set(dirs)];
|
|
60
|
+
}
|
|
61
|
+
export async function installHostingSkill(dirs) {
|
|
62
|
+
for (const dir of dirs) {
|
|
63
|
+
await writeSkillPackage(dir, HOSTING_SKILL_SLUG, [
|
|
64
|
+
{ path: "SKILL.md", text: HOSTING_SKILL_MD },
|
|
65
|
+
]);
|
|
66
|
+
}
|
|
67
|
+
}
|