@11agents/cli 0.1.7 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@11agents/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "11agents local runtime and telemetry CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -272,6 +272,16 @@ async function projectSyncToken(project, flags = {}, deps = {}) {
272
272
  })
273
273
  }
274
274
 
275
+ function projectTokenCandidatesForTask(task, flags = {}) {
276
+ return [
277
+ task.workspace?.slug,
278
+ task.workspace?.name,
279
+ task.workspace_slug,
280
+ flag(flags, 'project'),
281
+ flag(flags, 'workspace'),
282
+ ].filter(Boolean)
283
+ }
284
+
275
285
  async function writeFileIfMissing(filePath, content) {
276
286
  try {
277
287
  await writeFile(filePath, content, { flag: 'wx' })
@@ -447,7 +457,7 @@ async function syncDatabaseIfNeeded({ task, workdir, config, flags, deps }) {
447
457
  if (!spec.syncRequired && localRevision === spec.cloudRevision) return { synced: false, cloud_revision: localRevision }
448
458
 
449
459
  const project = projectSlugForTask(task)
450
- const token = await projectSyncToken(project, flags, deps)
460
+ const token = await projectSyncToken(projectTokenCandidatesForTask(task, flags), flags, deps)
451
461
  const syncConfig = { ...config, token }
452
462
  const result = await deps.requestJson(`/api/projects/${project}/database/sync`, {
453
463
  method: 'POST',
@@ -678,7 +688,7 @@ async function claimAndRunRuntimeTasks(registration, flags, deps, handlerModule,
678
688
 
679
689
  deps.log(JSON.stringify({ claimed: runtimeTask.id, runtime_id: runtime.id }, null, 2))
680
690
  if (runtimeTask.workspace?.slug) {
681
- const token = await projectSyncToken(runtimeTask.workspace.slug, flags, deps)
691
+ const token = await projectSyncToken(projectTokenCandidatesForTask(runtimeTask, flags), flags, deps)
682
692
  const syncConfig = { ...config, token }
683
693
  await runWithDaemonRetry('sync knowledge base', () => (
684
694
  deps.syncKnowledge({
@@ -709,7 +719,7 @@ async function claimAndRunRuntimeTasks(registration, flags, deps, handlerModule,
709
719
 
710
720
  if (runtimeTask.workspace?.slug) {
711
721
  const syncBack = knowledgeDeepOrganizeSpec(runtimeTask) ? deps.mcpKnowledgeSync : deps.syncKnowledge
712
- const token = await projectSyncToken(runtimeTask.workspace.slug, flags, deps)
722
+ const token = await projectSyncToken(projectTokenCandidatesForTask(runtimeTask, flags), flags, deps)
713
723
  const syncConfig = { ...config, token }
714
724
  await runWithDaemonRetry('sync knowledge base back to cloud', () => (
715
725
  syncBack({
@@ -63,8 +63,11 @@ export async function resolveProjectToken(project, {
63
63
  if (token) return token
64
64
 
65
65
  const credentials = await readCredentials({ homeDir })
66
- const projectToken = credentials.tokens[slugify(project)]
67
- if (projectToken) return projectToken
66
+ const projects = Array.isArray(project) ? project : [project]
67
+ for (const candidate of projects) {
68
+ const projectToken = credentials.tokens[slugify(candidate)]
69
+ if (projectToken) return projectToken
70
+ }
68
71
 
69
72
  return env.GTM_SWARM_TOKEN || fallbackToken || ''
70
73
  }