teamai-cli 0.17.5 → 0.17.6
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/dist/index.js +79 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4852,6 +4852,7 @@ __export(local_agent_exports, {
|
|
|
4852
4852
|
bindCurrentProject: () => bindCurrentProject,
|
|
4853
4853
|
bindWorkspaceToProject: () => bindWorkspaceToProject,
|
|
4854
4854
|
buildReportPayload: () => buildReportPayload,
|
|
4855
|
+
buildSyncPayload: () => buildSyncPayload,
|
|
4855
4856
|
describeLocalAgent: () => describeLocalAgent,
|
|
4856
4857
|
fetchUserProjects: () => fetchUserProjects,
|
|
4857
4858
|
initLocalAgentHttp: () => initLocalAgentHttp,
|
|
@@ -4863,6 +4864,7 @@ __export(local_agent_exports, {
|
|
|
4863
4864
|
reportAndSyncLocalAgent: () => reportAndSyncLocalAgent,
|
|
4864
4865
|
resolveRoute: () => resolveRoute,
|
|
4865
4866
|
runPluginReconcileWorker: () => runPluginReconcileWorker,
|
|
4867
|
+
stampWorkspaceTool: () => stampWorkspaceTool,
|
|
4866
4868
|
teardownLocalAgentPlugins: () => teardownLocalAgentPlugins,
|
|
4867
4869
|
writeTokenFile: () => writeTokenFile
|
|
4868
4870
|
});
|
|
@@ -4925,6 +4927,14 @@ function resolveLocalAgentId(context) {
|
|
|
4925
4927
|
const agentType = context.tool ?? "workbuddy";
|
|
4926
4928
|
return deriveLocalAgentId(agentType, getMachineId(), resolveAgentInstallPath(agentType));
|
|
4927
4929
|
}
|
|
4930
|
+
function isCloudStudioSandbox() {
|
|
4931
|
+
if (process.env.X_IDE_IS_CLOUDSTUDIO === "TRUE") return true;
|
|
4932
|
+
try {
|
|
4933
|
+
return fs10.existsSync("/var/run/cloudstudio");
|
|
4934
|
+
} catch {
|
|
4935
|
+
return false;
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
4928
4938
|
function localAgentTag(context) {
|
|
4929
4939
|
const tool = context.tool ?? "workbuddy";
|
|
4930
4940
|
return `[${resolveLocalAgentId(context).slice(-6)}] [${tool}]`;
|
|
@@ -5493,6 +5503,24 @@ async function pruneDeadWorkspaceBindings(config) {
|
|
|
5493
5503
|
}
|
|
5494
5504
|
return changed;
|
|
5495
5505
|
}
|
|
5506
|
+
function stampWorkspaceTool(config, currentPath, tool) {
|
|
5507
|
+
if (!currentPath) return false;
|
|
5508
|
+
const binding = config.workspaceBindings[currentPath];
|
|
5509
|
+
if (!binding) return false;
|
|
5510
|
+
const normalized = normalizeAgentType(tool);
|
|
5511
|
+
if (binding.ideType === normalized) return false;
|
|
5512
|
+
binding.ideType = normalized;
|
|
5513
|
+
return true;
|
|
5514
|
+
}
|
|
5515
|
+
function selectToolWorkspaces(config, currentPath, currentTool) {
|
|
5516
|
+
const paths = new Set(Object.keys(config.workspaceBindings));
|
|
5517
|
+
if (currentPath) paths.add(currentPath);
|
|
5518
|
+
return Array.from(paths).filter((wsPath) => {
|
|
5519
|
+
const b = config.workspaceBindings[wsPath];
|
|
5520
|
+
const wsTool = (b?.ideType || void 0) ?? (wsPath === currentPath ? currentTool : void 0);
|
|
5521
|
+
return wsTool === currentTool;
|
|
5522
|
+
});
|
|
5523
|
+
}
|
|
5496
5524
|
async function buildReportPayload(config, context) {
|
|
5497
5525
|
const manifest = await loadManifest();
|
|
5498
5526
|
const tool = context.tool ?? "workbuddy";
|
|
@@ -5524,19 +5552,17 @@ async function buildReportPayload(config, context) {
|
|
|
5524
5552
|
user_level: userLevel
|
|
5525
5553
|
};
|
|
5526
5554
|
const currentPath = await resolveWorkspacePath(context.cwd);
|
|
5527
|
-
const
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
payload.workspaces = await Promise.all(
|
|
5533
|
-
Array.from(workspacePaths).map(async (wsPath) => {
|
|
5555
|
+
const currentTool = normalizeAgentType(tool);
|
|
5556
|
+
const targetPaths = selectToolWorkspaces(config, currentPath, currentTool);
|
|
5557
|
+
if (targetPaths.length > 0) {
|
|
5558
|
+
const workspaceResults = await Promise.all(
|
|
5559
|
+
targetPaths.map(async (wsPath) => {
|
|
5534
5560
|
const wsScope = await scanScope(wsPath);
|
|
5535
5561
|
const wsBinding = config.workspaceBindings[wsPath];
|
|
5536
5562
|
const workspace = {
|
|
5537
5563
|
path: wsPath,
|
|
5538
5564
|
name: path18.basename(wsPath),
|
|
5539
|
-
ide_type:
|
|
5565
|
+
ide_type: currentTool,
|
|
5540
5566
|
project_id: wsBinding?.projectId
|
|
5541
5567
|
};
|
|
5542
5568
|
if (wsScope.skills.length > 0) workspace.skills = wsScope.skills;
|
|
@@ -5544,6 +5570,7 @@ async function buildReportPayload(config, context) {
|
|
|
5544
5570
|
return workspace;
|
|
5545
5571
|
})
|
|
5546
5572
|
);
|
|
5573
|
+
payload.workspaces = workspaceResults;
|
|
5547
5574
|
}
|
|
5548
5575
|
return payload;
|
|
5549
5576
|
}
|
|
@@ -5554,17 +5581,15 @@ async function buildSyncPayload(config, context) {
|
|
|
5554
5581
|
status: context.status ?? "running"
|
|
5555
5582
|
};
|
|
5556
5583
|
const currentPath = await resolveWorkspacePath(context.cwd);
|
|
5557
|
-
const
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
if (workspacePaths.size > 0) {
|
|
5562
|
-
payload.workspaces = Array.from(workspacePaths).map((wsPath) => {
|
|
5584
|
+
const currentTool = normalizeAgentType(context.tool ?? "workbuddy");
|
|
5585
|
+
const targetPaths = selectToolWorkspaces(config, currentPath, currentTool);
|
|
5586
|
+
if (targetPaths.length > 0) {
|
|
5587
|
+
payload.workspaces = targetPaths.map((wsPath) => {
|
|
5563
5588
|
const wsBinding = config.workspaceBindings[wsPath];
|
|
5564
5589
|
return {
|
|
5565
5590
|
path: wsPath,
|
|
5566
5591
|
name: path18.basename(wsPath),
|
|
5567
|
-
ide_type:
|
|
5592
|
+
ide_type: currentTool,
|
|
5568
5593
|
project_id: wsBinding?.projectId
|
|
5569
5594
|
};
|
|
5570
5595
|
});
|
|
@@ -5746,6 +5771,27 @@ async function installDownloadedResource(input) {
|
|
|
5746
5771
|
}
|
|
5747
5772
|
const teamConfig = { ...fullTeamConfig, toolPaths: { [tool]: toolPath } };
|
|
5748
5773
|
const localConfig = createResourceLocalConfig(input.config, input.scope, repoPath, input.workspacePath);
|
|
5774
|
+
if (localConfig.scope === "project") {
|
|
5775
|
+
try {
|
|
5776
|
+
const baseDir = resolveBaseDir(localConfig);
|
|
5777
|
+
const resourceToolPath = input.kind === "skill" ? toolPath.skills : input.kind === "rule" ? toolPath.rules : (
|
|
5778
|
+
// Default branch covers the 'claudemd' kind; if a new CommandResourceKind
|
|
5779
|
+
// is added, revisit this mapping so it doesn't silently fall through to claudemd.
|
|
5780
|
+
toolPath.claudemd
|
|
5781
|
+
);
|
|
5782
|
+
if (resourceToolPath && resourceToolPath.includes("/")) {
|
|
5783
|
+
const rootSegment = resourceToolPath.split("/")[0];
|
|
5784
|
+
await ensureDir(path18.join(baseDir, rootSegment));
|
|
5785
|
+
}
|
|
5786
|
+
} catch (err) {
|
|
5787
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
5788
|
+
if (msg.includes("resolveBaseDir")) {
|
|
5789
|
+
log.warn(`Cannot resolve base dir to pre-create tool root: ${msg}`);
|
|
5790
|
+
} else {
|
|
5791
|
+
log.debug(`Failed to pre-create tool root directory: ${msg}`);
|
|
5792
|
+
}
|
|
5793
|
+
}
|
|
5794
|
+
}
|
|
5749
5795
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5750
5796
|
let displayName = input.command.display_name ?? input.slug;
|
|
5751
5797
|
let skillDirName = input.slug;
|
|
@@ -5908,22 +5954,32 @@ async function processCommands(config, commands, context) {
|
|
|
5908
5954
|
async function reportAndSyncLocalAgent(context) {
|
|
5909
5955
|
const config = await loadLocalAgentConfig();
|
|
5910
5956
|
if (!config) return false;
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
if (
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5957
|
+
if (isBindPromptEnabled()) {
|
|
5958
|
+
const workspacePath = await resolveWorkspacePath(context.cwd);
|
|
5959
|
+
if (workspacePath) {
|
|
5960
|
+
if (context.event?.type === "session_start") {
|
|
5961
|
+
await ensureWorkspaceBinding(config, workspacePath);
|
|
5962
|
+
}
|
|
5963
|
+
if (context.event?.type === "prompt_submit") {
|
|
5964
|
+
await emitBindingHint(config, workspacePath);
|
|
5965
|
+
}
|
|
5918
5966
|
}
|
|
5919
5967
|
}
|
|
5968
|
+
if (isCloudStudioSandbox() && process.env.TEAMAI_ALLOW_SANDBOX_REPORT !== "1") {
|
|
5969
|
+
log.debug(
|
|
5970
|
+
"[local-agent] CloudStudio sandbox detected; skipping HTTP report/sync (binding prompt still runs; set TEAMAI_ALLOW_SANDBOX_REPORT=1 to override)"
|
|
5971
|
+
);
|
|
5972
|
+
return false;
|
|
5973
|
+
}
|
|
5920
5974
|
const tag = localAgentTag(context);
|
|
5921
5975
|
log.debug(`${tag} run: endpoint=${config.endpoint}`);
|
|
5922
5976
|
if (context.event?.type === "session_start") {
|
|
5923
5977
|
await maybeReconcilePlugins(context);
|
|
5924
5978
|
}
|
|
5925
5979
|
const pruned = await pruneDeadWorkspaceBindings(config);
|
|
5926
|
-
|
|
5980
|
+
const currentPath = await resolveWorkspacePath(context.cwd);
|
|
5981
|
+
const stamped = stampWorkspaceTool(config, currentPath, context.tool ?? "workbuddy");
|
|
5982
|
+
if (pruned || stamped) {
|
|
5927
5983
|
await saveLocalAgentConfig(config);
|
|
5928
5984
|
}
|
|
5929
5985
|
try {
|