@agentsmarket/cli 0.5.2 → 0.5.4

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.
@@ -1,7 +1,23 @@
1
1
  /**
2
- * `agentsmarket pipeline install <slug>` — STUB for B1.
2
+ * `agentsmarket pipeline install <slug>` — fetch the raw pipeline.yaml
3
+ * from the marketplace and save it to the local pipelines dir.
3
4
  *
4
- * Server route `/v1/pipelines/:id/yaml` is planned for R16. Until then,
5
- * this returns a clear error explaining the workflow gap.
5
+ * Writes to one of (in priority order):
6
+ * 1. $AGENTSMARKET_PIPELINES_DIR
7
+ * 2. ~/.config/agentsmarket/pipelines/<slug>/pipeline.yaml
8
+ *
9
+ * The file layout `<slug>/pipeline.yaml` (not flat `<slug>.yaml`) matches
10
+ * the directory convention `executePipeline` expects in
11
+ * @agentsmarket/pipeline-runtime — a pipeline is its own folder so that
12
+ * sibling files (e.g. example inputs, lockfiles, .gitignore) don't
13
+ * collide when installed alongside other pipelines.
14
+ *
15
+ * Lookup strategy (R23): try by display name first (`/by-slug/<slug>/yaml`),
16
+ * fall back to id (`/<slug>/yaml`). Users discover pipelines by name on
17
+ * the marketplace page and shouldn't need to know internal `pipe_<uuid>_vN`
18
+ * ids. The by-id path stays so scripts that pass the raw id still work.
19
+ *
20
+ * Requires authenticated agent — the server enforces auth on both routes
21
+ * and won't return private pipelines to callers outside `granted_to`.
6
22
  */
7
23
  export declare function pipelineInstallCommand(slug: string): Promise<void>;
@@ -1,16 +1,102 @@
1
1
  /**
2
- * `agentsmarket pipeline install <slug>` — STUB for B1.
2
+ * `agentsmarket pipeline install <slug>` — fetch the raw pipeline.yaml
3
+ * from the marketplace and save it to the local pipelines dir.
3
4
  *
4
- * Server route `/v1/pipelines/:id/yaml` is planned for R16. Until then,
5
- * this returns a clear error explaining the workflow gap.
5
+ * Writes to one of (in priority order):
6
+ * 1. $AGENTSMARKET_PIPELINES_DIR
7
+ * 2. ~/.config/agentsmarket/pipelines/<slug>/pipeline.yaml
8
+ *
9
+ * The file layout `<slug>/pipeline.yaml` (not flat `<slug>.yaml`) matches
10
+ * the directory convention `executePipeline` expects in
11
+ * @agentsmarket/pipeline-runtime — a pipeline is its own folder so that
12
+ * sibling files (e.g. example inputs, lockfiles, .gitignore) don't
13
+ * collide when installed alongside other pipelines.
14
+ *
15
+ * Lookup strategy (R23): try by display name first (`/by-slug/<slug>/yaml`),
16
+ * fall back to id (`/<slug>/yaml`). Users discover pipelines by name on
17
+ * the marketplace page and shouldn't need to know internal `pipe_<uuid>_vN`
18
+ * ids. The by-id path stays so scripts that pass the raw id still work.
19
+ *
20
+ * Requires authenticated agent — the server enforces auth on both routes
21
+ * and won't return private pipelines to callers outside `granted_to`.
6
22
  */
23
+ import * as fs from 'node:fs';
24
+ import * as os from 'node:os';
25
+ import * as path from 'node:path';
26
+ import { authedFetch } from '../../lib/http.js';
27
+ function detectPipelinesDir() {
28
+ const override = process.env.AGENTSMARKET_PIPELINES_DIR;
29
+ if (override) {
30
+ fs.mkdirSync(override, { recursive: true });
31
+ return override;
32
+ }
33
+ return path.join(os.homedir(), '.config', 'agentsmarket', 'pipelines');
34
+ }
35
+ async function fetchPipelineYaml(slug) {
36
+ const encoded = encodeURIComponent(slug);
37
+ const slugRes = await authedFetch('GET', `/v1/pipelines/by-slug/${encoded}/yaml`);
38
+ if (slugRes.status === 200)
39
+ return { res: slugRes, resolvedAs: 'slug' };
40
+ if (slugRes.status !== 404)
41
+ return { res: slugRes, resolvedAs: 'slug' };
42
+ // 404 from the by-slug route — fall back to id lookup. Releases auth
43
+ // (already signed) reuse the same identity for both calls.
44
+ const idRes = await authedFetch('GET', `/v1/pipelines/${encoded}/yaml`);
45
+ return { res: idRes, resolvedAs: 'id' };
46
+ }
7
47
  export async function pipelineInstallCommand(slug) {
8
- console.error('✗ `pipeline install` is not yet implemented.');
9
- console.error(' Pipeline YAML download is planned for R16 (server route /v1/pipelines/:id/yaml).');
10
- console.error(' Track progress: .omo/plans/v0-5-marketplace.md (todo 14)');
11
- console.error('');
12
- console.error(' Workaround: clone the pipeline YAML directly from your author\'s git repo,');
13
- console.error(' or copy from https://staging.agentsmarket.world/pipelines/');
14
- process.exit(1);
48
+ if (!slug || slug.trim() === '') {
49
+ console.error(' pipeline install requires a slug');
50
+ console.error(' Usage: agentsmarket pipeline install <slug>');
51
+ process.exit(2);
52
+ }
53
+ let fetched;
54
+ try {
55
+ fetched = await fetchPipelineYaml(slug);
56
+ }
57
+ catch (err) {
58
+ const msg = err instanceof Error ? err.message : String(err);
59
+ if (msg.includes('not initialized')) {
60
+ console.error('✗ Agent not initialized. Run `agentsmarket init` first.');
61
+ process.exit(1);
62
+ }
63
+ console.error(`✗ Network error fetching pipeline: ${msg}`);
64
+ console.error(' Try again, or check AGENTSMARKET_URL if using a non-default server.');
65
+ process.exit(1);
66
+ }
67
+ const { res, resolvedAs } = fetched;
68
+ if (res.status === 404) {
69
+ console.error(`✗ Pipeline "${slug}" not found (or not granted to you).`);
70
+ console.error(' Browse all public pipelines: agentsmarket pipeline search');
71
+ process.exit(1);
72
+ }
73
+ if (res.status === 401 || res.status === 403) {
74
+ console.error(`✗ Authentication failed (status ${res.status}).`);
75
+ console.error(' Run `agentsmarket init` to re-register your agent.');
76
+ process.exit(1);
77
+ }
78
+ if (!res.ok) {
79
+ const body = await res.text().catch(() => '');
80
+ console.error(`✗ Server error ${res.status} while fetching pipeline YAML.`);
81
+ if (body)
82
+ console.error(` ${body.slice(0, 200)}`);
83
+ process.exit(1);
84
+ }
85
+ const yaml = await res.text();
86
+ if (!yaml.trim()) {
87
+ console.error('✗ Server returned an empty YAML body.');
88
+ process.exit(1);
89
+ }
90
+ const dir = detectPipelinesDir();
91
+ const targetDir = path.join(dir, slug);
92
+ const targetFile = path.join(targetDir, 'pipeline.yaml');
93
+ fs.mkdirSync(targetDir, { recursive: true });
94
+ fs.writeFileSync(targetFile, yaml, 'utf-8');
95
+ const filename = res.headers.get('content-disposition')?.match(/filename="?([^";]+)"?/)?.[1];
96
+ const label = filename ?? `${slug}.yaml`;
97
+ console.log(`✓ Installed ${slug} → ${targetFile}`);
98
+ console.log(` Server returned: ${label} (${yaml.length} bytes)`);
99
+ console.log(` Resolved via: ${resolvedAs === 'slug' ? 'name' : 'id'}`);
100
+ console.log(` Run it: agentsmarket pipeline call ${slug} --local --mock`);
15
101
  }
16
102
  //# sourceMappingURL=install.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/pipeline/install.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,IAAY;IACvD,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAC9D,OAAO,CAAC,KAAK,CAAC,oFAAoF,CAAC,CAAC;IACpG,OAAO,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAC5E,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAC9F,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAC9E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/pipeline/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,SAAS,kBAAkB;IACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;IACxD,IAAI,QAAQ,EAAE,CAAC;QACb,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,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C,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACxE,OAAO,CAAC,GAAG,CAAC,wCAAwC,IAAI,iBAAiB,CAAC,CAAC;AAC7E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsmarket/cli",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "CLI for agentsmarket.world — agent identity, wallet, and skill invocations",
5
5
  "license": "MIT",
6
6
  "type": "module",