@11agents/cli 0.1.6 → 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 +1 -1
- package/src/commands/runtime.js +17 -5
- package/src/credentials.js +5 -2
package/package.json
CHANGED
package/src/commands/runtime.js
CHANGED
|
@@ -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' })
|
|
@@ -438,7 +448,7 @@ function databaseSyncSpec(task) {
|
|
|
438
448
|
return { cloudRevision, syncRequired }
|
|
439
449
|
}
|
|
440
450
|
|
|
441
|
-
async function syncDatabaseIfNeeded({ task, workdir, config, deps }) {
|
|
451
|
+
async function syncDatabaseIfNeeded({ task, workdir, config, flags, deps }) {
|
|
442
452
|
const spec = databaseSyncSpec(task)
|
|
443
453
|
if (!spec) return { synced: false }
|
|
444
454
|
const statePath = path.join(workdir, 'database', 'sync-state.json')
|
|
@@ -447,6 +457,8 @@ async function syncDatabaseIfNeeded({ task, workdir, config, deps }) {
|
|
|
447
457
|
if (!spec.syncRequired && localRevision === spec.cloudRevision) return { synced: false, cloud_revision: localRevision }
|
|
448
458
|
|
|
449
459
|
const project = projectSlugForTask(task)
|
|
460
|
+
const token = await projectSyncToken(projectTokenCandidatesForTask(task, flags), flags, deps)
|
|
461
|
+
const syncConfig = { ...config, token }
|
|
450
462
|
const result = await deps.requestJson(`/api/projects/${project}/database/sync`, {
|
|
451
463
|
method: 'POST',
|
|
452
464
|
body: {
|
|
@@ -454,7 +466,7 @@ async function syncDatabaseIfNeeded({ task, workdir, config, deps }) {
|
|
|
454
466
|
local_revision: localRevision,
|
|
455
467
|
cloud_revision: spec.cloudRevision,
|
|
456
468
|
},
|
|
457
|
-
config,
|
|
469
|
+
config: syncConfig,
|
|
458
470
|
})
|
|
459
471
|
await mkdir(path.dirname(statePath), { recursive: true })
|
|
460
472
|
if (result?.snapshot !== undefined) {
|
|
@@ -491,7 +503,7 @@ async function prepareRuntimeTask(task, flags, deps, config) {
|
|
|
491
503
|
const tmpDir = path.join(workdir, 'tmp', sanitizeTaskId(task.id))
|
|
492
504
|
await mkdir(tmpDir, { recursive: true })
|
|
493
505
|
|
|
494
|
-
const database = await syncDatabaseIfNeeded({ task, workdir, config, deps })
|
|
506
|
+
const database = await syncDatabaseIfNeeded({ task, workdir, config, flags, deps })
|
|
495
507
|
const skills = await materializeSkillsIfChanged({ task, workdir, flags, deps })
|
|
496
508
|
const env = {
|
|
497
509
|
...process.env,
|
|
@@ -676,7 +688,7 @@ async function claimAndRunRuntimeTasks(registration, flags, deps, handlerModule,
|
|
|
676
688
|
|
|
677
689
|
deps.log(JSON.stringify({ claimed: runtimeTask.id, runtime_id: runtime.id }, null, 2))
|
|
678
690
|
if (runtimeTask.workspace?.slug) {
|
|
679
|
-
const token = await projectSyncToken(runtimeTask
|
|
691
|
+
const token = await projectSyncToken(projectTokenCandidatesForTask(runtimeTask, flags), flags, deps)
|
|
680
692
|
const syncConfig = { ...config, token }
|
|
681
693
|
await runWithDaemonRetry('sync knowledge base', () => (
|
|
682
694
|
deps.syncKnowledge({
|
|
@@ -707,7 +719,7 @@ async function claimAndRunRuntimeTasks(registration, flags, deps, handlerModule,
|
|
|
707
719
|
|
|
708
720
|
if (runtimeTask.workspace?.slug) {
|
|
709
721
|
const syncBack = knowledgeDeepOrganizeSpec(runtimeTask) ? deps.mcpKnowledgeSync : deps.syncKnowledge
|
|
710
|
-
const token = await projectSyncToken(runtimeTask
|
|
722
|
+
const token = await projectSyncToken(projectTokenCandidatesForTask(runtimeTask, flags), flags, deps)
|
|
711
723
|
const syncConfig = { ...config, token }
|
|
712
724
|
await runWithDaemonRetry('sync knowledge base back to cloud', () => (
|
|
713
725
|
syncBack({
|
package/src/credentials.js
CHANGED
|
@@ -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
|
|
67
|
-
|
|
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
|
}
|