@agentsmarket/cli 0.5.2 → 0.5.3

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,19 @@
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
+ * Requires authenticated agent — the server enforces auth on
16
+ * `GET /v1/pipelines/:id/yaml` and won't return private pipelines to
17
+ * callers outside `granted_to`.
6
18
  */
7
19
  export declare function pipelineInstallCommand(slug: string): Promise<void>;
@@ -1,16 +1,84 @@
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
+ * Requires authenticated agent — the server enforces auth on
16
+ * `GET /v1/pipelines/:id/yaml` and won't return private pipelines to
17
+ * callers outside `granted_to`.
6
18
  */
19
+ import * as fs from 'node:fs';
20
+ import * as os from 'node:os';
21
+ import * as path from 'node:path';
22
+ import { authedFetch } from '../../lib/http.js';
23
+ function detectPipelinesDir() {
24
+ const override = process.env.AGENTSMARKET_PIPELINES_DIR;
25
+ if (override) {
26
+ fs.mkdirSync(override, { recursive: true });
27
+ return override;
28
+ }
29
+ return path.join(os.homedir(), '.config', 'agentsmarket', 'pipelines');
30
+ }
7
31
  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);
32
+ if (!slug || slug.trim() === '') {
33
+ console.error(' pipeline install requires a slug');
34
+ console.error(' Usage: agentsmarket pipeline install <slug>');
35
+ process.exit(2);
36
+ }
37
+ let res;
38
+ try {
39
+ res = await authedFetch('GET', `/v1/pipelines/${encodeURIComponent(slug)}/yaml`);
40
+ }
41
+ catch (err) {
42
+ const msg = err instanceof Error ? err.message : String(err);
43
+ if (msg.includes('not initialized')) {
44
+ console.error('✗ Agent not initialized. Run `agentsmarket init` first.');
45
+ process.exit(1);
46
+ }
47
+ console.error(`✗ Network error fetching pipeline: ${msg}`);
48
+ console.error(' Try again, or check AGENTSMARKET_URL if using a non-default server.');
49
+ process.exit(1);
50
+ }
51
+ if (res.status === 404) {
52
+ console.error(`✗ Pipeline "${slug}" not found (or not granted to you).`);
53
+ console.error(' Browse all public pipelines: agentsmarket pipeline search');
54
+ process.exit(1);
55
+ }
56
+ if (res.status === 401 || res.status === 403) {
57
+ console.error(`✗ Authentication failed (status ${res.status}).`);
58
+ console.error(' Run `agentsmarket init` to re-register your agent.');
59
+ process.exit(1);
60
+ }
61
+ if (!res.ok) {
62
+ const body = await res.text().catch(() => '');
63
+ console.error(`✗ Server error ${res.status} while fetching pipeline YAML.`);
64
+ if (body)
65
+ console.error(` ${body.slice(0, 200)}`);
66
+ process.exit(1);
67
+ }
68
+ const yaml = await res.text();
69
+ if (!yaml.trim()) {
70
+ console.error('✗ Server returned an empty YAML body.');
71
+ process.exit(1);
72
+ }
73
+ const dir = detectPipelinesDir();
74
+ const targetDir = path.join(dir, slug);
75
+ const targetFile = path.join(targetDir, 'pipeline.yaml');
76
+ fs.mkdirSync(targetDir, { recursive: true });
77
+ fs.writeFileSync(targetFile, yaml, 'utf-8');
78
+ const filename = res.headers.get('content-disposition')?.match(/filename="?([^";]+)"?/)?.[1];
79
+ const label = filename ?? `${slug}.yaml`;
80
+ console.log(`✓ Installed ${slug} → ${targetFile}`);
81
+ console.log(` Server returned: ${label} (${yaml.length} bytes)`);
82
+ console.log(` Run it: agentsmarket pipeline call ${slug} --local --mock`);
15
83
  }
16
84
  //# 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,OAA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"CLI for agentsmarket.world — agent identity, wallet, and skill invocations",
5
5
  "license": "MIT",
6
6
  "type": "module",