@team-ai/teamai-cli 0.40.3 → 0.40.4
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 +54 -25
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -63072,6 +63072,14 @@ async function askViaTty(prompt) {
|
|
|
63072
63072
|
}
|
|
63073
63073
|
async function promptForProjectBinding(workspacePath, projects) {
|
|
63074
63074
|
if (projects.length === 0) return null;
|
|
63075
|
+
if (!isInteractive2()) {
|
|
63076
|
+
log.info("\u53EF\u7528\u9879\u76EE:");
|
|
63077
|
+
projects.forEach((project, index2) => {
|
|
63078
|
+
const desc = project.description ? ` - ${project.description}` : "";
|
|
63079
|
+
log.info(` ${index2 + 1}. ${project.name}${desc} [id=${project.id}]`);
|
|
63080
|
+
});
|
|
63081
|
+
return null;
|
|
63082
|
+
}
|
|
63075
63083
|
log.debug(`local-agent: workspace not bound: ${workspacePath}`);
|
|
63076
63084
|
const answer = await askViaTty("\u662F\u5426\u7ED1\u5B9A\u5230\u4E00\u4E2A\u9879\u76EE\uFF1F[y/N] ");
|
|
63077
63085
|
if (!answer || answer.toLowerCase() !== "y") return null;
|
|
@@ -63149,15 +63157,22 @@ async function bindWorkspaceToProject(workspacePath, projectId) {
|
|
|
63149
63157
|
log.success(`\u5DF2\u5C06\u5DE5\u4F5C\u533A\u7ED1\u5B9A\u5230\u9879\u76EE\uFF1A${project.name} [id=${project.id}]`);
|
|
63150
63158
|
return binding;
|
|
63151
63159
|
}
|
|
63152
|
-
|
|
63153
|
-
|
|
63154
|
-
|
|
63155
|
-
|
|
63156
|
-
|
|
63160
|
+
function hintMarkerPath(prefix, key) {
|
|
63161
|
+
const flat = key.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
63162
|
+
return path76.join(os9.tmpdir(), `${prefix}-${flat}`);
|
|
63163
|
+
}
|
|
63164
|
+
function bindingHintMarkerFresh(marker) {
|
|
63157
63165
|
try {
|
|
63158
|
-
fs35.
|
|
63166
|
+
const stamp = Number(fs35.readFileSync(marker, "utf8"));
|
|
63167
|
+
return Number.isFinite(stamp) && Date.now() - stamp < BINDING_MARKER_TTL_MS;
|
|
63159
63168
|
} catch {
|
|
63169
|
+
return false;
|
|
63160
63170
|
}
|
|
63171
|
+
}
|
|
63172
|
+
async function ensureWorkspaceBinding(config, workspacePath, sessionId, cwd, tool) {
|
|
63173
|
+
if (config.workspaceBindings[workspacePath]?.projectName !== PENDING_BINDING_NAME) return;
|
|
63174
|
+
const hintMarker = hintMarkerPath("teamai-bind-session", sessionId || `ppid-${process.ppid}`);
|
|
63175
|
+
if (bindingHintMarkerFresh(hintMarker)) return;
|
|
63161
63176
|
let projects;
|
|
63162
63177
|
try {
|
|
63163
63178
|
projects = await fetchUserProjects(config, tool);
|
|
@@ -63184,6 +63199,10 @@ async function ensureWorkspaceBinding(config, workspacePath, sessionId, cwd, too
|
|
|
63184
63199
|
additionalContext: context
|
|
63185
63200
|
}
|
|
63186
63201
|
});
|
|
63202
|
+
try {
|
|
63203
|
+
fs35.writeFileSync(hintMarker, String(Date.now()));
|
|
63204
|
+
} catch {
|
|
63205
|
+
}
|
|
63187
63206
|
process.stdout.write(hookOutput + "\n");
|
|
63188
63207
|
}
|
|
63189
63208
|
function isBindPromptEnabled() {
|
|
@@ -63198,13 +63217,8 @@ function isBindPromptTool(tool) {
|
|
|
63198
63217
|
}
|
|
63199
63218
|
async function emitBindingHint(config, workspacePath, sessionId, tool) {
|
|
63200
63219
|
if (config.workspaceBindings[workspacePath]?.projectName !== PENDING_BINDING_NAME) return;
|
|
63201
|
-
const
|
|
63202
|
-
|
|
63203
|
-
if (fs35.existsSync(hintMarker)) return;
|
|
63204
|
-
try {
|
|
63205
|
-
fs35.writeFileSync(hintMarker, "");
|
|
63206
|
-
} catch {
|
|
63207
|
-
}
|
|
63220
|
+
const hintMarker = hintMarkerPath("teamai-bind-hint", sessionId || `ppid-${process.ppid}`);
|
|
63221
|
+
if (bindingHintMarkerFresh(hintMarker)) return;
|
|
63208
63222
|
let projects;
|
|
63209
63223
|
try {
|
|
63210
63224
|
projects = await fetchUserProjects(config, tool);
|
|
@@ -63235,16 +63249,15 @@ async function emitBindingHint(config, workspacePath, sessionId, tool) {
|
|
|
63235
63249
|
additionalContext: context
|
|
63236
63250
|
}
|
|
63237
63251
|
});
|
|
63238
|
-
process.stdout.write(hookOutput + "\n");
|
|
63239
|
-
}
|
|
63240
|
-
function unenrolledNotice(context, workspacePath) {
|
|
63241
|
-
const markerKey = context.event?.sessionId || `ppid-${process.ppid}`;
|
|
63242
|
-
const marker = path76.join(os9.tmpdir(), `teamai-unenrolled-${markerKey}`);
|
|
63243
|
-
if (fs35.existsSync(marker)) return;
|
|
63244
63252
|
try {
|
|
63245
|
-
fs35.writeFileSync(
|
|
63253
|
+
fs35.writeFileSync(hintMarker, String(Date.now()));
|
|
63246
63254
|
} catch {
|
|
63247
63255
|
}
|
|
63256
|
+
process.stdout.write(hookOutput + "\n");
|
|
63257
|
+
}
|
|
63258
|
+
function unenrolledNotice(context, workspacePath) {
|
|
63259
|
+
const marker = hintMarkerPath("teamai-unenrolled", context.event?.sessionId || `ppid-${process.ppid}`);
|
|
63260
|
+
if (bindingHintMarkerFresh(marker)) return;
|
|
63248
63261
|
const text2 = [
|
|
63249
63262
|
`[teamai] This workspace is not enrolled, so teamai reports and syncs nothing here: ${workspacePath}`,
|
|
63250
63263
|
"Run `teamai bind-project` once in it to enroll \u2014 bind a ClawPro project, or `--skip` to enroll without one."
|
|
@@ -63255,6 +63268,10 @@ function unenrolledNotice(context, workspacePath) {
|
|
|
63255
63268
|
additionalContext: text2
|
|
63256
63269
|
}
|
|
63257
63270
|
});
|
|
63271
|
+
try {
|
|
63272
|
+
fs35.writeFileSync(marker, String(Date.now()));
|
|
63273
|
+
} catch {
|
|
63274
|
+
}
|
|
63258
63275
|
process.stdout.write(hookOutput + "\n");
|
|
63259
63276
|
}
|
|
63260
63277
|
function isEphemeralTaskDir(dir) {
|
|
@@ -65455,7 +65472,7 @@ async function initLocalAgentHttp(options2) {
|
|
|
65455
65472
|
const namedCount = options2.filterAgents?.length ?? 0;
|
|
65456
65473
|
const namedAgent = namedCount === 1 ? normalizeAgentType(options2.filterAgents[0]) : void 0;
|
|
65457
65474
|
const held = sameEndpoint ? Object.keys(existing2?.agentTokens ?? {}) : [];
|
|
65458
|
-
const agent = namedAgent ?? (token && !isUserToken(token) && held.length === 1 ? held[0] : void 0);
|
|
65475
|
+
const agent = namedAgent ?? (namedCount === 0 && token && !isUserToken(token) && held.length === 1 ? held[0] : void 0);
|
|
65459
65476
|
const perAgent = Boolean(agent && token && !isUserToken(token));
|
|
65460
65477
|
if (existing2 && !options2.force && !(perAgent && sameEndpoint)) {
|
|
65461
65478
|
throw new Error("HTTP local agent is already initialized. Re-run with --force to overwrite.");
|
|
@@ -65475,6 +65492,10 @@ async function initLocalAgentHttp(options2) {
|
|
|
65475
65492
|
}
|
|
65476
65493
|
agentTokens[agent] = sameEndpoint ? await chooseAgentToken(existing2, agent, current, token) : token;
|
|
65477
65494
|
}
|
|
65495
|
+
if (perAgent && sharedToken && sameEndpoint && sharedToken !== token && await tokenStillWorks(existing2, sharedToken) === false) {
|
|
65496
|
+
log.warn("The shared access token on this machine no longer works, so the agents without a token of their own have none now. Re-run with `--agent <tool>` for each of them to install a new one.");
|
|
65497
|
+
sharedToken = void 0;
|
|
65498
|
+
}
|
|
65478
65499
|
const config = {
|
|
65479
65500
|
endpoint,
|
|
65480
65501
|
token: sharedToken,
|
|
@@ -65744,7 +65765,7 @@ async function bindCurrentProject(options2) {
|
|
|
65744
65765
|
log.info("\u672A\u7ED1\u5B9A\u9879\u76EE\u3002");
|
|
65745
65766
|
}
|
|
65746
65767
|
}
|
|
65747
|
-
var import_fs_extra9, execFileAsync2, LOCAL_AGENT_DIR, CONFIG_FILE, MANIFEST_FILE, MODEL_MANIFEST_FILE, REPORTER_ERROR_LOG, LOCAL_AGENT_FETCH_TIMEOUT_MS, LOCAL_AGENT_HOOK_FETCH_TIMEOUT_MS, activeFetchTimeoutMs, UNIMPLEMENTED_COMMAND_TYPES, IMPLEMENTED_HOOK_COMMAND_TYPES, PENDING_BINDING_NAME, DEFAULT_ROUTES, LOCK_HOLDER_ENV, WORKSPACE_CACHE_GITIGNORE, PLUGIN_PULL_INTERVAL_MS, PLUGIN_FAIL_BACKOFF_MS, ZIP_MAGIC, DEFAULT_MAX_TOKENS, MODEL_KEY_RERUN, TEAMAI_MODEL_GITIGNORE, VALID_MCP_TRANSPORTS;
|
|
65768
|
+
var import_fs_extra9, execFileAsync2, LOCAL_AGENT_DIR, CONFIG_FILE, MANIFEST_FILE, MODEL_MANIFEST_FILE, REPORTER_ERROR_LOG, LOCAL_AGENT_FETCH_TIMEOUT_MS, LOCAL_AGENT_HOOK_FETCH_TIMEOUT_MS, activeFetchTimeoutMs, UNIMPLEMENTED_COMMAND_TYPES, IMPLEMENTED_HOOK_COMMAND_TYPES, PENDING_BINDING_NAME, DEFAULT_ROUTES, LOCK_HOLDER_ENV, WORKSPACE_CACHE_GITIGNORE, PLUGIN_PULL_INTERVAL_MS, PLUGIN_FAIL_BACKOFF_MS, BINDING_MARKER_TTL_MS, ZIP_MAGIC, DEFAULT_MAX_TOKENS, MODEL_KEY_RERUN, TEAMAI_MODEL_GITIGNORE, VALID_MCP_TRANSPORTS;
|
|
65748
65769
|
var init_local_agent = __esm({
|
|
65749
65770
|
"src/local-agent.ts"() {
|
|
65750
65771
|
"use strict";
|
|
@@ -65804,6 +65825,7 @@ var init_local_agent = __esm({
|
|
|
65804
65825
|
WORKSPACE_CACHE_GITIGNORE = ["# teamai local state", "local-agent/", ""].join("\n");
|
|
65805
65826
|
PLUGIN_PULL_INTERVAL_MS = 12 * 60 * 60 * 1e3;
|
|
65806
65827
|
PLUGIN_FAIL_BACKOFF_MS = 60 * 60 * 1e3;
|
|
65828
|
+
BINDING_MARKER_TTL_MS = 10 * 60 * 1e3;
|
|
65807
65829
|
ZIP_MAGIC = Buffer.from([80, 75, 3, 4]);
|
|
65808
65830
|
DEFAULT_MAX_TOKENS = 4096;
|
|
65809
65831
|
MODEL_KEY_RERUN = "apply the model config again";
|
|
@@ -66951,14 +66973,21 @@ async function initHttp(url, options2) {
|
|
|
66951
66973
|
await runInitScript(localConfig2, "preInit", options2.dryRun);
|
|
66952
66974
|
await reconcileHooksForInit(teamConfig, localConfig2, filterAgents2);
|
|
66953
66975
|
const { initLocalAgentHttp: initLocalAgentHttp2 } = await Promise.resolve().then(() => (init_local_agent(), local_agent_exports));
|
|
66976
|
+
let localAgentFailed = false;
|
|
66954
66977
|
try {
|
|
66955
66978
|
await initLocalAgentHttp2({ endpoint: url, token: options2.token, force: options2.force, filterAgents: filterAgents2 });
|
|
66956
66979
|
} catch (e) {
|
|
66957
|
-
|
|
66980
|
+
localAgentFailed = true;
|
|
66981
|
+
process.exitCode = 1;
|
|
66982
|
+
log.error(`Local agent init: ${e.message}`);
|
|
66958
66983
|
}
|
|
66959
66984
|
await runInitScript(localConfig2, "postInit", options2.dryRun, true);
|
|
66960
|
-
|
|
66961
|
-
|
|
66985
|
+
if (localAgentFailed) {
|
|
66986
|
+
log.warn("teamai initialized (HTTP read-only) without the local agent: report/sync keeps the credentials this machine already had.");
|
|
66987
|
+
} else {
|
|
66988
|
+
log.success("teamai initialized (HTTP read-only)!");
|
|
66989
|
+
log.info("Skills/rules will auto-sync on each session start in an enrolled workspace via report/sync. This team is read-only (no push).");
|
|
66990
|
+
}
|
|
66962
66991
|
closePrompt();
|
|
66963
66992
|
}
|
|
66964
66993
|
async function reconcileHooksForInit(teamConfig, localConfig2, filterAgents2) {
|