@agentsky/sky 2.5.0 → 2.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.
Files changed (2) hide show
  1. package/dist/index.js +88 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -64,7 +64,7 @@ function currentUniverse() {
64
64
  }
65
65
 
66
66
  // src/version.ts
67
- var CLI_VERSION = "2.5.0";
67
+ var CLI_VERSION = "2.6.0";
68
68
  var USER_AGENT = `sky-cli/${CLI_VERSION} (${process.platform}; node/${process.versions.node})`;
69
69
 
70
70
  // src/api.ts
@@ -402,6 +402,62 @@ You are ${name}, a helpful long-lived agent.
402
402
  );
403
403
  }
404
404
 
405
+ // src/catalog.ts
406
+ var bare = (handle) => handle.replace(/^@/, "");
407
+ var optionalAuth = () => ({ auth: Boolean(apiToken()) });
408
+ function catalogQuery(filter) {
409
+ const params = new URLSearchParams();
410
+ if (filter.text?.trim()) params.set("q", filter.text.trim());
411
+ if (filter.category) params.set("category", filter.category);
412
+ const query = params.toString();
413
+ return query ? `?${query}` : "";
414
+ }
415
+ function listingBody(agentId, options) {
416
+ return {
417
+ agent_id: agentId,
418
+ handle: bare(options.handle),
419
+ tagline: options.tagline,
420
+ ...options.description ? { description: options.description } : {},
421
+ ...options.category?.length ? { categories: options.category } : {},
422
+ ...options.does?.length ? { does: options.does } : {},
423
+ ...options.doesNot?.length ? { does_not: options.doesNot } : {},
424
+ ...options.example?.length ? { examples: options.example } : {}
425
+ };
426
+ }
427
+ async function listCatalog(filter = {}) {
428
+ return (await api("GET", `/catalog/agents${catalogQuery(filter)}`, void 0, optionalAuth())).agents;
429
+ }
430
+ async function showCatalogAgent(handle) {
431
+ return (await api("GET", `/catalog/agents/${encodeURIComponent(bare(handle))}`, void 0, optionalAuth())).agent;
432
+ }
433
+ async function listCategories() {
434
+ return (await api("GET", "/catalog/categories", void 0, { auth: false })).categories;
435
+ }
436
+ async function publishListing(agentId, options) {
437
+ return (await api("POST", "/catalog/listings", listingBody(agentId, options))).agent;
438
+ }
439
+ async function removeListing(handle) {
440
+ await api("DELETE", `/catalog/listings/${encodeURIComponent(bare(handle))}`);
441
+ }
442
+ var uses = (agent2) => `${agent2.stats.uses} ${agent2.stats.uses === 1 ? "use" : "uses"}`;
443
+ var mine = (agent2) => agent2.visibility === "workspace" ? " (yours)" : "";
444
+ function renderCatalogAgent(agent2) {
445
+ const section = (title, lines) => lines.length ? [`${title}:`, ...lines.map((line) => ` - ${line}`)] : [];
446
+ return [
447
+ `@${agent2.handle} ${agent2.name}${mine(agent2)}`,
448
+ agent2.tagline,
449
+ ...agent2.description && agent2.description !== agent2.tagline ? ["", agent2.description] : [],
450
+ "",
451
+ `Categories: ${agent2.categories.join(", ") || "none"}`,
452
+ `Used: ${uses(agent2)}`,
453
+ ...section("Does", agent2.does),
454
+ ...section("Does not", agent2.does_not),
455
+ ...section("Examples", agent2.examples),
456
+ "",
457
+ `Hire it: sky session create @${agent2.handle} --message "\u2026"`
458
+ ].join("\n");
459
+ }
460
+
405
461
  // src/clone.ts
406
462
  import { spawn } from "child_process";
407
463
  import { existsSync as existsSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
@@ -1647,10 +1703,10 @@ session.command("create <agent>").description("create a session (starts provisio
1647
1703
  console.log(JSON.stringify(created));
1648
1704
  return;
1649
1705
  }
1650
- console.log(`Created ${created.id} (${created.agent} \xB7 ${created.status})${created.default ? " [default]" : ""}`);
1706
+ console.log(`Created ${created.id} (${created.agentId ?? "-"} \xB7 ${created.status})${created.default ? " [default]" : ""}`);
1651
1707
  printModelBilling(created);
1652
1708
  for (const r of created.resources ?? []) console.log(` ${renderResource(r)}`);
1653
- console.log(` sky agent message ${created.agent} "hello"`);
1709
+ console.log(` sky session message ${created.id} "hello"`);
1654
1710
  }
1655
1711
  )
1656
1712
  );
@@ -1664,7 +1720,7 @@ session.command("list [agent]").action(
1664
1720
  }
1665
1721
  for (const s of sessions) {
1666
1722
  console.log(
1667
- `${s.id.padEnd(24)} ${(s.agent ?? "-").padEnd(20)} ${(s.title ?? "").padEnd(16)} ${s.status}${s.default ? " *" : ""}`
1723
+ `${s.id.padEnd(24)} ${(s.agentId ?? "-").padEnd(20)} ${(s.title ?? "").padEnd(16)} ${s.status}${s.default ? " *" : ""}`
1668
1724
  );
1669
1725
  }
1670
1726
  })
@@ -1676,7 +1732,7 @@ session.command("show <id>").action(
1676
1732
  `/sessions/${encodeURIComponent(id)}`
1677
1733
  );
1678
1734
  console.log(`${s.id}${s.default ? " [default]" : ""}`);
1679
- console.log(` agent ${s.agent ?? "-"}`);
1735
+ console.log(` agent ${s.agentId ?? "-"}`);
1680
1736
  console.log(` title ${s.title ?? "-"}`);
1681
1737
  console.log(` status ${s.status}`);
1682
1738
  console.log(` model ${s.agentType} \xB7 ${s.llm}`);
@@ -1892,12 +1948,10 @@ async function chatLoop(sessionId, opts = {}) {
1892
1948
  await new Promise(() => {
1893
1949
  });
1894
1950
  }
1895
- program.command("catalog").description("the agents that can be started by handle").command("search [words...]").description("find an agent for a piece of work; no words lists every agent").option("--category <category>", "only this category").option("--json", "print the full listings as JSON").action(
1951
+ var catalog = program.command("catalog").description("the agents that can be started by handle");
1952
+ catalog.command("search [words...]").description("find an agent for a piece of work; no words lists every agent; works without logging in").option("--category <category>", "only this category (see `sky catalog categories`)").option("--json", "print the full listings as JSON").action(
1896
1953
  run(async (words, opts) => {
1897
- const query = new URLSearchParams();
1898
- if (words.length) query.set("q", words.join(" "));
1899
- if (opts.category) query.set("category", opts.category);
1900
- const { agents } = await api("GET", `/catalog/agents${query.size ? `?${query}` : ""}`);
1954
+ const agents = await listCatalog({ text: words.join(" "), category: opts.category });
1901
1955
  if (opts.json) {
1902
1956
  console.log(JSON.stringify(agents));
1903
1957
  return;
@@ -2302,6 +2356,30 @@ for (const [verb, method, suffix, blurb] of [
2302
2356
  })
2303
2357
  );
2304
2358
  }
2359
+ catalog.command("show <handle>").description("what one agent does, and how to hire it").option("--json", "print the raw listing").action(
2360
+ run(async (handle, opts) => {
2361
+ const agent2 = await showCatalogAgent(handle);
2362
+ console.log(opts.json ? JSON.stringify(agent2, null, 2) : renderCatalogAgent(agent2));
2363
+ })
2364
+ );
2365
+ catalog.command("categories").description("the categories a listing can carry").action(
2366
+ run(async () => {
2367
+ for (const category of await listCategories()) console.log(`${category.id.padEnd(10)} ${category.label}`);
2368
+ })
2369
+ );
2370
+ catalog.command("publish <agent>").description("list one of your agents under a handle, visible to your workspace; publishing again replaces the listing").requiredOption("--handle <handle>", "the @handle people hire it by: 2 to 40 lower-case letters, digits or underscores").requiredOption("--tagline <text>", "one line on what it is for").option("--description <text>", "a longer description").option("--category <id>", "a category; repeat for several", collect).option("--does <text>", "something it does; repeat for several", collect).option("--does-not <text>", "something it does not do; repeat for several", collect).option("--example <text>", "an example request; repeat for several", collect).action(
2371
+ run(async (agentId, opts) => {
2372
+ const agent2 = await publishListing(agentId, opts);
2373
+ console.log(`Listed @${agent2.handle} (${agent2.name})`);
2374
+ console.log(` sky session create @${agent2.handle} --message "\u2026"`);
2375
+ })
2376
+ );
2377
+ catalog.command("unpublish <handle>").description("take down one of your workspace's listings; the agent itself is untouched").action(
2378
+ run(async (handle) => {
2379
+ await removeListing(handle);
2380
+ console.log(`Removed @${handle.replace(/^@/, "")} from the catalog`);
2381
+ })
2382
+ );
2305
2383
  program.command("config").description("show the CLI config location and current values").action(() => {
2306
2384
  const config = loadConfig();
2307
2385
  console.log(`config: ${configPath()}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsky/sky",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "sky — the AgentSky developer CLI: launch and talk to long-lived agents from your terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",