@orchagent/cli 0.3.69 → 0.3.70

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.
@@ -15,7 +15,12 @@ const errors_1 = require("../lib/errors");
15
15
  async function resolveAgentId(config, ref) {
16
16
  const parts = ref.split('/');
17
17
  const agentName = parts.length >= 2 ? parts[1] : parts[0];
18
- const agents = await (0, api_1.listMyAgents)(config);
18
+ const orgSlug = parts.length >= 2 ? parts[0] : undefined;
19
+ // Resolve workspace context from org slug or config
20
+ const configFile = await (0, config_1.loadConfig)();
21
+ const resolvedOrg = orgSlug ?? configFile.workspace ?? config.defaultOrg;
22
+ const workspaceId = resolvedOrg ? await (0, api_1.resolveWorkspaceIdForOrg)(config, resolvedOrg) : undefined;
23
+ const agents = await (0, api_1.listMyAgents)(config, workspaceId);
19
24
  const matching = agents.filter(a => a.name === agentName);
20
25
  if (matching.length === 0) {
21
26
  throw new errors_1.CliError(`Agent '${ref}' not found. Run 'orchagent agents' to list your agents.`);
@@ -49,7 +49,11 @@ function registerAgentsCommand(program) {
49
49
  .option('--json', 'Output raw JSON')
50
50
  .action(async (options) => {
51
51
  const config = await (0, config_1.getResolvedConfig)();
52
- const agents = await (0, api_1.listMyAgents)(config);
52
+ // Resolve workspace context
53
+ const configFile = await (0, config_1.loadConfig)();
54
+ const orgSlug = configFile.workspace ?? config.defaultOrg;
55
+ const workspaceId = orgSlug ? await (0, api_1.resolveWorkspaceIdForOrg)(config, orgSlug) : undefined;
56
+ const agents = await (0, api_1.listMyAgents)(config, workspaceId);
53
57
  // Apply filter if provided
54
58
  const filteredAgents = options.filter
55
59
  ? agents.filter(a => a.name.toLowerCase().includes(options.filter.toLowerCase()))
@@ -42,9 +42,11 @@ Examples:
42
42
  if (!config.apiKey) {
43
43
  throw new errors_1.CliError('Not logged in. Run `orchagent login` first.');
44
44
  }
45
+ // Resolve workspace context for the target org
46
+ const workspaceId = await (0, api_1.resolveWorkspaceIdForOrg)(config, ref.org);
45
47
  process.stdout.write('Finding agent...\n');
46
48
  // Find the agent by name, filtering by org if provided
47
- const agents = await (0, api_1.listMyAgents)(config);
49
+ const agents = await (0, api_1.listMyAgents)(config, workspaceId);
48
50
  const matching = agents.filter(a => a.name === ref.agent && (!a.org_slug || a.org_slug === ref.org));
49
51
  if (matching.length === 0) {
50
52
  throw new errors_1.CliError(`Agent '${ref.org}/${ref.agent}' not found`);
@@ -49,7 +49,7 @@ async function fetchReadme(url) {
49
49
  return null;
50
50
  }
51
51
  }
52
- async function getAgentInfo(config, org, agent, version) {
52
+ async function getAgentInfo(config, org, agent, version, workspaceId) {
53
53
  // Use public metadata endpoint as primary source — never blocked by download restrictions
54
54
  try {
55
55
  const publicMeta = await (0, api_1.getPublicAgent)(config, org, agent, version);
@@ -78,11 +78,11 @@ async function getAgentInfo(config, org, agent, version) {
78
78
  if (!config.apiKey) {
79
79
  throw new api_1.ApiError(`Agent '${org}/${agent}@${version}' not found`, 404);
80
80
  }
81
- const userOrg = await (0, api_1.getOrg)(config);
81
+ const userOrg = await (0, api_1.getOrg)(config, workspaceId);
82
82
  if (userOrg.slug !== org) {
83
83
  throw new api_1.ApiError(`Agent '${org}/${agent}@${version}' not found`, 404);
84
84
  }
85
- const agents = await (0, api_1.listMyAgents)(config);
85
+ const agents = await (0, api_1.listMyAgents)(config, workspaceId);
86
86
  const matching = agents.filter(a => a.name === agent);
87
87
  if (matching.length === 0) {
88
88
  throw new api_1.ApiError(`Agent '${org}/${agent}@${version}' not found`, 404);
@@ -123,8 +123,10 @@ function registerInfoCommand(program) {
123
123
  .action(async (agentArg, options) => {
124
124
  const config = await (0, config_1.getResolvedConfig)();
125
125
  const { org, agent, version } = (0, agent_ref_1.parseAgentRef)(agentArg);
126
+ // Resolve workspace context for the target org
127
+ const workspaceId = await (0, api_1.resolveWorkspaceIdForOrg)(config, org);
126
128
  // Fetch agent metadata
127
- const agentData = await getAgentInfo(config, org, agent, version);
129
+ const agentData = await getAgentInfo(config, org, agent, version, workspaceId);
128
130
  if (options.json) {
129
131
  // Don't expose internal routing URLs in JSON output
130
132
  const output = { ...agentData };
@@ -29,7 +29,7 @@ function parseAgentRef(value) {
29
29
  }
30
30
  throw new errors_1.CliError('Invalid agent reference. Use org/agent or agent format.');
31
31
  }
32
- async function downloadAgentWithFallback(config, org, name, version) {
32
+ async function downloadAgentWithFallback(config, org, name, version, workspaceId) {
33
33
  // Fetch public metadata first to check if paid
34
34
  let publicMeta;
35
35
  try {
@@ -48,12 +48,12 @@ async function downloadAgentWithFallback(config, org, name, version) {
48
48
  if (publicMeta && (0, pricing_1.isPaidAgent)(publicMeta)) {
49
49
  // Paid agent - check if owner
50
50
  if (config.apiKey) {
51
- const callerOrg = await (0, api_1.getOrg)(config);
51
+ const callerOrg = await (0, api_1.getOrg)(config, workspaceId);
52
52
  const isOwner = (publicMeta.org_id && callerOrg.id === publicMeta.org_id) ||
53
53
  (publicMeta.org_slug && callerOrg.slug === publicMeta.org_slug);
54
54
  if (isOwner) {
55
55
  // Owner - fetch from authenticated endpoint with full prompt
56
- const myAgents = await (0, api_1.listMyAgents)(config);
56
+ const myAgents = await (0, api_1.listMyAgents)(config, workspaceId);
57
57
  const matching = myAgents.filter(a => a.name === name);
58
58
  if (matching.length > 0) {
59
59
  let targetAgent;
@@ -90,12 +90,12 @@ async function downloadAgentWithFallback(config, org, name, version) {
90
90
  if (publicMeta && publicMeta.allow_local_download === false) {
91
91
  // Check if owner (can bypass)
92
92
  if (config.apiKey) {
93
- const callerOrg = await (0, api_1.getOrg)(config);
93
+ const callerOrg = await (0, api_1.getOrg)(config, workspaceId);
94
94
  const isOwner = (publicMeta.org_id && callerOrg.id === publicMeta.org_id) ||
95
95
  (publicMeta.org_slug && callerOrg.slug === publicMeta.org_slug);
96
96
  if (isOwner) {
97
97
  // Owner - fetch from authenticated endpoint
98
- const myAgents = await (0, api_1.listMyAgents)(config);
98
+ const myAgents = await (0, api_1.listMyAgents)(config, workspaceId);
99
99
  const matching = myAgents.filter(a => a.name === name);
100
100
  if (matching.length > 0) {
101
101
  let targetAgent;
@@ -128,11 +128,11 @@ async function downloadAgentWithFallback(config, org, name, version) {
128
128
  if (!config.apiKey) {
129
129
  throw new api_1.ApiError(`Agent '${org}/${name}@${version}' not found`, 404);
130
130
  }
131
- const userOrg = await (0, api_1.getOrg)(config);
131
+ const userOrg = await (0, api_1.getOrg)(config, workspaceId);
132
132
  if (userOrg.slug !== org) {
133
133
  throw new api_1.ApiError(`Agent '${org}/${name}@${version}' not found`, 404);
134
134
  }
135
- const agents = await (0, api_1.listMyAgents)(config);
135
+ const agents = await (0, api_1.listMyAgents)(config, workspaceId);
136
136
  const matching = agents.filter(a => a.name === name);
137
137
  if (matching.length === 0) {
138
138
  throw new api_1.ApiError(`Agent '${org}/${name}@${version}' not found`, 404);
@@ -232,11 +232,13 @@ Note: Paid agents cannot be installed locally - they run on server only.
232
232
  throw new errors_1.CliError(errMsg);
233
233
  }
234
234
  result.scope = scope;
235
+ // Resolve workspace context for the target org
236
+ const workspaceId = await (0, api_1.resolveWorkspaceIdForOrg)(resolved, org);
235
237
  // Download agent
236
238
  log(`Fetching ${org}/${parsed.name}@${parsed.version}...\n`);
237
239
  let agent;
238
240
  try {
239
- agent = await downloadAgentWithFallback(resolved, org, parsed.name, parsed.version);
241
+ agent = await downloadAgentWithFallback(resolved, org, parsed.name, parsed.version, workspaceId);
240
242
  }
241
243
  catch (err) {
242
244
  if (jsonMode) {
@@ -58,7 +58,7 @@ function commandForEntrypoint(entrypoint) {
58
58
  return `python ${entrypoint}`;
59
59
  }
60
60
  // ─── Agent Resolution ───────────────────────────────────────────────────────
61
- async function resolveAgent(config, org, agent, version) {
61
+ async function resolveAgent(config, org, agent, version, workspaceId) {
62
62
  // 1. Try public download endpoint
63
63
  try {
64
64
  const data = await (0, api_1.publicRequest)(config, `/public/agents/${org}/${agent}/${version}/download`);
@@ -96,7 +96,7 @@ async function resolveAgent(config, org, agent, version) {
96
96
  if (errorCode === 'PAID_AGENT_SERVER_ONLY' || errorCode === 'DOWNLOAD_DISABLED') {
97
97
  // Try authenticated owner path
98
98
  if (config.apiKey) {
99
- const ownerData = await tryOwnerFallback(config, org, agent, version);
99
+ const ownerData = await tryOwnerFallback(config, org, agent, version, workspaceId);
100
100
  if (ownerData)
101
101
  return { ...ownerData, source: 'owner_authenticated' };
102
102
  }
@@ -117,19 +117,19 @@ async function resolveAgent(config, org, agent, version) {
117
117
  if (!config.apiKey) {
118
118
  throw new api_1.ApiError(`Agent '${org}/${agent}@${version}' not found`, 404);
119
119
  }
120
- const userOrg = await (0, api_1.getOrg)(config);
120
+ const userOrg = await (0, api_1.getOrg)(config, workspaceId);
121
121
  if (userOrg.slug !== org) {
122
122
  throw new api_1.ApiError(`Agent '${org}/${agent}@${version}' not found`, 404);
123
123
  }
124
- const data = await resolveFromMyAgents(config, agent, version, org);
124
+ const data = await resolveFromMyAgents(config, agent, version, org, workspaceId);
125
125
  if (!data) {
126
126
  throw new api_1.ApiError(`Agent '${org}/${agent}@${version}' not found`, 404);
127
127
  }
128
128
  return { ...data, source: 'private_authenticated' };
129
129
  }
130
- async function tryOwnerFallback(config, org, agent, version) {
130
+ async function tryOwnerFallback(config, org, agent, version, workspaceId) {
131
131
  try {
132
- const myAgents = await (0, api_1.listMyAgents)(config);
132
+ const myAgents = await (0, api_1.listMyAgents)(config, workspaceId);
133
133
  let match;
134
134
  if (version === 'latest') {
135
135
  match = myAgents
@@ -148,8 +148,8 @@ async function tryOwnerFallback(config, org, agent, version) {
148
148
  return null;
149
149
  }
150
150
  }
151
- async function resolveFromMyAgents(config, agent, version, org) {
152
- const agents = await (0, api_1.listMyAgents)(config);
151
+ async function resolveFromMyAgents(config, agent, version, org, workspaceId) {
152
+ const agents = await (0, api_1.listMyAgents)(config, workspaceId);
153
153
  const matching = agents.filter(a => a.name === agent && a.org_slug === org);
154
154
  if (matching.length === 0)
155
155
  return null;
@@ -361,9 +361,11 @@ Examples:
361
361
  throw new errors_1.CliError('Missing org. Use org/agent[@version] format, or set a default org with:\n' +
362
362
  ' orch config set default-org <org>');
363
363
  }
364
+ // Resolve workspace context for the target org
365
+ const workspaceId = await (0, api_1.resolveWorkspaceIdForOrg)(config, org);
364
366
  write(`Resolving ${org}/${parsed.agent}@${parsed.version}...\n`);
365
367
  // Resolve agent data
366
- const data = await resolveAgent(config, org, parsed.agent, parsed.version);
368
+ const data = await resolveAgent(config, org, parsed.agent, parsed.version, workspaceId);
367
369
  // Reject skills
368
370
  if (canonicalType(data.type) === 'skill') {
369
371
  throw new errors_1.CliError("This is a skill. Use 'orch skill install <ref>' instead.");
@@ -88,7 +88,7 @@ function parseSkillRef(value) {
88
88
  }
89
89
  throw new errors_1.CliError('Invalid skill reference. Use org/skill or skill format.');
90
90
  }
91
- async function downloadSkillWithFallback(config, org, skill, version) {
91
+ async function downloadSkillWithFallback(config, org, skill, version, workspaceId) {
92
92
  // Fetch metadata first to check if paid
93
93
  let skillMeta;
94
94
  try {
@@ -114,12 +114,12 @@ async function downloadSkillWithFallback(config, org, skill, version) {
114
114
  if (skillMeta && (0, pricing_1.isPaidAgent)(skillMeta)) {
115
115
  // Paid skill - check ownership
116
116
  if (config.apiKey) {
117
- const callerOrg = await (0, api_1.getOrg)(config);
117
+ const callerOrg = await (0, api_1.getOrg)(config, workspaceId);
118
118
  const isOwner = (skillMeta.org_id && callerOrg.id === skillMeta.org_id) ||
119
119
  (skillMeta.org_slug && callerOrg.slug === skillMeta.org_slug);
120
120
  if (isOwner) {
121
121
  // Owner - fetch from authenticated endpoint with full content
122
- const myAgents = await (0, api_1.listMyAgents)(config);
122
+ const myAgents = await (0, api_1.listMyAgents)(config, workspaceId);
123
123
  const matching = myAgents.filter(a => a.name === skill && a.type === 'skill');
124
124
  if (matching.length > 0) {
125
125
  let targetAgent;
@@ -162,12 +162,12 @@ async function downloadSkillWithFallback(config, org, skill, version) {
162
162
  // Check if download is disabled (server-only skill)
163
163
  if (skillMeta && skillMeta.allow_local_download === false) {
164
164
  if (config.apiKey) {
165
- const callerOrg = await (0, api_1.getOrg)(config);
165
+ const callerOrg = await (0, api_1.getOrg)(config, workspaceId);
166
166
  const isOwner = (skillMeta.org_id && callerOrg.id === skillMeta.org_id) ||
167
167
  (skillMeta.org_slug && callerOrg.slug === skillMeta.org_slug);
168
168
  if (isOwner) {
169
169
  // Owner - fetch from authenticated endpoint
170
- const myAgents = await (0, api_1.listMyAgents)(config);
170
+ const myAgents = await (0, api_1.listMyAgents)(config, workspaceId);
171
171
  const matching = myAgents.filter(a => a.name === skill && a.type === 'skill');
172
172
  if (matching.length > 0) {
173
173
  let targetAgent;
@@ -221,12 +221,12 @@ async function downloadSkillWithFallback(config, org, skill, version) {
221
221
  if (!config.apiKey) {
222
222
  throw new api_1.ApiError(`Skill '${org}/${skill}@${version}' not found`, 404);
223
223
  }
224
- const userOrg = await (0, api_1.getOrg)(config);
224
+ const userOrg = await (0, api_1.getOrg)(config, workspaceId);
225
225
  if (userOrg.slug !== org) {
226
226
  throw new api_1.ApiError(`Skill '${org}/${skill}@${version}' not found`, 404);
227
227
  }
228
228
  // Find skill in user's list
229
- const agents = await (0, api_1.listMyAgents)(config);
229
+ const agents = await (0, api_1.listMyAgents)(config, workspaceId);
230
230
  const matching = agents.filter(a => a.name === skill && a.type === 'skill');
231
231
  if (matching.length === 0) {
232
232
  throw new api_1.ApiError(`Skill '${org}/${skill}@${version}' not found`, 404);
@@ -420,10 +420,12 @@ Instructions and guidance for AI agents...
420
420
  }
421
421
  result.skill = `${org}/${parsed.skill}`;
422
422
  result.version = parsed.version;
423
+ // Resolve workspace context for the target org
424
+ const workspaceId = await (0, api_1.resolveWorkspaceIdForOrg)(resolved, org);
423
425
  // Download skill (tries public first, falls back to authenticated for private)
424
426
  let skillData;
425
427
  try {
426
- skillData = await downloadSkillWithFallback(resolved, org, parsed.skill, parsed.version);
428
+ skillData = await downloadSkillWithFallback(resolved, org, parsed.skill, parsed.version, workspaceId);
427
429
  }
428
430
  catch (err) {
429
431
  if (jsonMode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orchagent/cli",
3
- "version": "0.3.69",
3
+ "version": "0.3.70",
4
4
  "description": "Command-line interface for orchagent — deploy and run AI agents for your team",
5
5
  "license": "MIT",
6
6
  "author": "orchagent <hello@orchagent.io>",