@team-ai/teamai-cli 0.40.2 → 0.40.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.
- package/dist/cli.js +19 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -63237,21 +63237,22 @@ async function emitBindingHint(config, workspacePath, sessionId, tool) {
|
|
|
63237
63237
|
});
|
|
63238
63238
|
process.stdout.write(hookOutput + "\n");
|
|
63239
63239
|
}
|
|
63240
|
-
|
|
63241
|
-
const markerKey = event?.sessionId || `ppid-${process.ppid}`;
|
|
63240
|
+
function unenrolledNotice(context, workspacePath) {
|
|
63241
|
+
const markerKey = context.event?.sessionId || `ppid-${process.ppid}`;
|
|
63242
63242
|
const marker = path76.join(os9.tmpdir(), `teamai-unenrolled-${markerKey}`);
|
|
63243
63243
|
if (fs35.existsSync(marker)) return;
|
|
63244
63244
|
try {
|
|
63245
63245
|
fs35.writeFileSync(marker, "");
|
|
63246
63246
|
} catch {
|
|
63247
63247
|
}
|
|
63248
|
-
const
|
|
63249
|
-
|
|
63250
|
-
|
|
63248
|
+
const text2 = [
|
|
63249
|
+
`[teamai] This workspace is not enrolled, so teamai reports and syncs nothing here: ${workspacePath}`,
|
|
63250
|
+
"Run `teamai bind-project` once in it to enroll \u2014 bind a ClawPro project, or `--skip` to enroll without one."
|
|
63251
|
+
].join("\n");
|
|
63251
63252
|
const hookOutput = JSON.stringify({
|
|
63252
63253
|
hookSpecificOutput: {
|
|
63253
|
-
hookEventName: event
|
|
63254
|
-
additionalContext:
|
|
63254
|
+
hookEventName: context.event?.type === "prompt_submit" ? "UserPromptSubmit" : "SessionStart",
|
|
63255
|
+
additionalContext: text2
|
|
63255
63256
|
}
|
|
63256
63257
|
});
|
|
63257
63258
|
process.stdout.write(hookOutput + "\n");
|
|
@@ -65220,8 +65221,8 @@ async function syncLocalAgent(context) {
|
|
|
65220
65221
|
if (!config) return false;
|
|
65221
65222
|
const currentPath = await resolveWorkspacePath(context.cwd);
|
|
65222
65223
|
if (currentPath && !await enrollWorkspace(config, context.cwd, currentPath)) {
|
|
65223
|
-
if (isBindPromptEnabled()) await noticeUnenrolledWorkspace(currentPath, context.event);
|
|
65224
65224
|
log.debug(`[local-agent] workspace not enrolled, skipping: ${currentPath}`);
|
|
65225
|
+
if (isBindPromptEnabled()) unenrolledNotice(context, currentPath);
|
|
65225
65226
|
return false;
|
|
65226
65227
|
}
|
|
65227
65228
|
if (currentPath && isBindPromptEnabled() && isBindPromptTool(context.tool)) {
|
|
@@ -65435,8 +65436,11 @@ async function chooseAgentToken(existing2, agent, current, incoming) {
|
|
|
65435
65436
|
log.info(`Keeping the ${agent} access token already on this machine; the new one is not used.`);
|
|
65436
65437
|
return current;
|
|
65437
65438
|
}
|
|
65439
|
+
function isUserToken(token) {
|
|
65440
|
+
return token.startsWith("hk-");
|
|
65441
|
+
}
|
|
65438
65442
|
function legacyTokenAgent(config) {
|
|
65439
|
-
if (!config.token) return void 0;
|
|
65443
|
+
if (!config.token || isUserToken(config.token)) return void 0;
|
|
65440
65444
|
const agents = new Set(Object.values(config.workspaceBindings).map((binding) => binding.ideType).filter((t2) => Boolean(t2)).map(normalizeAgentType));
|
|
65441
65445
|
return agents.size === 1 ? [...agents][0] : void 0;
|
|
65442
65446
|
}
|
|
@@ -65448,14 +65452,15 @@ async function initLocalAgentHttp(options2) {
|
|
|
65448
65452
|
const existing2 = await loadLocalAgentConfig();
|
|
65449
65453
|
const token = options2.token?.trim() || void 0;
|
|
65450
65454
|
const sameEndpoint = existing2 !== null && normalizeEndpoint(existing2.endpoint) === endpoint;
|
|
65451
|
-
const
|
|
65455
|
+
const namedCount = options2.filterAgents?.length ?? 0;
|
|
65456
|
+
const namedAgent = namedCount === 1 ? normalizeAgentType(options2.filterAgents[0]) : void 0;
|
|
65452
65457
|
const held = sameEndpoint ? Object.keys(existing2?.agentTokens ?? {}) : [];
|
|
65453
|
-
const agent =
|
|
65454
|
-
const perAgent = Boolean(agent && token);
|
|
65458
|
+
const agent = namedAgent ?? (token && !isUserToken(token) && held.length === 1 ? held[0] : void 0);
|
|
65459
|
+
const perAgent = Boolean(agent && token && !isUserToken(token));
|
|
65455
65460
|
if (existing2 && !options2.force && !(perAgent && sameEndpoint)) {
|
|
65456
65461
|
throw new Error("HTTP local agent is already initialized. Re-run with --force to overwrite.");
|
|
65457
65462
|
}
|
|
65458
|
-
if (token && !agent && (
|
|
65463
|
+
if (token && !agent && !isUserToken(token) && (namedCount > 1 || held.length > 1)) {
|
|
65459
65464
|
throw new Error(
|
|
65460
65465
|
`An access token works for one agent only. Re-run with --agent <tool> naming the agent it is for${held.length > 1 ? `; this machine already holds credentials for ${held.join(", ")}` : ""}.`
|
|
65461
65466
|
);
|
|
@@ -108256,7 +108261,7 @@ async function sourceAddHttp(endpoint, options2) {
|
|
|
108256
108261
|
const agents = normalizeAgentList2(options2.agent);
|
|
108257
108262
|
await initLocalAgentHttp2({ endpoint: trimmed2, token: options2.token, force: true, filterAgents: agents.length > 0 ? agents : void 0 });
|
|
108258
108263
|
log.success(`HTTP source added (${trimmed2}).`);
|
|
108259
|
-
log.info("It will report/sync on the next AI session (via the hook-dispatch hook already installed).");
|
|
108264
|
+
log.info("It will report/sync on the next AI session in each workspace where `teamai bind-project` ran once (via the hook-dispatch hook already installed).");
|
|
108260
108265
|
}
|
|
108261
108266
|
async function sourceRemoveHttp(options2) {
|
|
108262
108267
|
if (options2.dryRun) {
|