@triclaps/cli 0.0.2 → 0.0.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/README.md +17 -5
- package/index.js +136 -40
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -43,20 +43,32 @@ claps-cli register \
|
|
|
43
43
|
--runtime codex \
|
|
44
44
|
--external-key your-agent-key \
|
|
45
45
|
--name "Your Agent Name" \
|
|
46
|
-
--save-token
|
|
47
|
-
--start-daemon
|
|
46
|
+
--save-token
|
|
48
47
|
```
|
|
49
48
|
|
|
50
|
-
`register` handles the first-time onboarding flow
|
|
49
|
+
`register` handles the first-time onboarding flow end to end:
|
|
50
|
+
|
|
51
|
+
- it registers the agent
|
|
52
|
+
- saves the returned token into the default local agent home at `$HOME/.triclaps-agents/<agent-key>`
|
|
53
|
+
- starts the detached worker by default
|
|
54
|
+
- injects the managed CLAPS skills into `$HOME/.triclaps-agents/<agent-key>/skills`
|
|
55
|
+
|
|
56
|
+
If you need to restart that same agent later, run:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
claps-cli daemon start --api-base-url http://127.0.0.1:3001 --external-key your-agent-key
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`daemon start` replaces any existing process for the same agent key by default, so one key stays mapped to one local worker instance.
|
|
51
63
|
|
|
52
64
|
## Common Commands
|
|
53
65
|
|
|
54
66
|
```bash
|
|
55
67
|
claps-cli daemon status
|
|
56
|
-
claps-cli run
|
|
68
|
+
claps-cli run --external-key your-agent-key
|
|
57
69
|
claps-cli sync-runtime --runtime codex
|
|
58
70
|
```
|
|
59
71
|
|
|
60
72
|
- Use `claps-cli daemon status` to inspect the detached worker.
|
|
61
|
-
- Use `claps-cli run
|
|
73
|
+
- Use `claps-cli run --external-key ...` when you want foreground output for debugging.
|
|
62
74
|
- Use `claps-cli sync-runtime` when you need to refresh managed runtime assets for a runtime.
|
package/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
|
+
import os6 from "node:os";
|
|
9
10
|
import { mkdir as mkdir6, readFile as readFile7, writeFile as writeFile7 } from "node:fs/promises";
|
|
10
11
|
import { dirname as dirname3, resolve as resolve2 } from "node:path";
|
|
11
12
|
|
|
@@ -4359,6 +4360,7 @@ var agentSummarySchema = external_exports.object({
|
|
|
4359
4360
|
lastSeenAt: external_exports.string().min(1),
|
|
4360
4361
|
heartbeatStatus: agentHeartbeatStatusSchema.nullable().optional(),
|
|
4361
4362
|
heartbeatNote: nullableTextSchema.optional(),
|
|
4363
|
+
protocolVersion: nullableTextSchema.optional(),
|
|
4362
4364
|
notificationEndpoint: external_exports.object({
|
|
4363
4365
|
endpointType: external_exports.enum(notificationEndpointTypes),
|
|
4364
4366
|
address: external_exports.string().min(1)
|
|
@@ -4392,6 +4394,7 @@ var importedAgentSchema = external_exports.object({
|
|
|
4392
4394
|
token: nullableTextSchema,
|
|
4393
4395
|
heartbeatStatus: agentHeartbeatStatusSchema.nullable().optional(),
|
|
4394
4396
|
heartbeatNote: nullableTextSchema.optional(),
|
|
4397
|
+
protocolVersion: nullableTextSchema.optional(),
|
|
4395
4398
|
lastSeenAt: external_exports.string().min(1).nullable().optional(),
|
|
4396
4399
|
importedAt: external_exports.string().min(1),
|
|
4397
4400
|
deletedAt: external_exports.string().min(1).nullable().optional()
|
|
@@ -7009,13 +7012,16 @@ async function ensureAgentHome(input) {
|
|
|
7009
7012
|
}
|
|
7010
7013
|
async function ensureAgentRuntimeHome(input) {
|
|
7011
7014
|
const env = input.env ?? process.env;
|
|
7012
|
-
const
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7015
|
+
const explicitAgentHomePath = env.CLAPS_AGENT_HOME_PATH?.trim();
|
|
7016
|
+
const runtimeHomePath = explicitAgentHomePath ? path4.resolve(explicitAgentHomePath) : path4.join(
|
|
7017
|
+
(await ensureAgentHome({
|
|
7018
|
+
agentId: input.agentId,
|
|
7019
|
+
agentName: input.agentName ?? null,
|
|
7020
|
+
runtime: input.runtime,
|
|
7021
|
+
env
|
|
7022
|
+
})).runtimePath,
|
|
7023
|
+
input.runtime
|
|
7024
|
+
);
|
|
7019
7025
|
await mkdir(runtimeHomePath, { recursive: true });
|
|
7020
7026
|
const sharedRuntimeHomePath = getAgentDriver(input.runtime).resolveHome(env);
|
|
7021
7027
|
if (path4.resolve(sharedRuntimeHomePath) !== path4.resolve(runtimeHomePath)) {
|
|
@@ -7320,7 +7326,8 @@ async function readDiscoveredAgentHomes(env) {
|
|
|
7320
7326
|
const homeDir = resolveHomeDirectory(env);
|
|
7321
7327
|
const candidateRoots = /* @__PURE__ */ new Set([
|
|
7322
7328
|
path5.join(stateHome, "agents"),
|
|
7323
|
-
path5.join(homeDir, ".claps-agents")
|
|
7329
|
+
path5.join(homeDir, ".claps-agents"),
|
|
7330
|
+
path5.join(homeDir, ".triclaps-agents")
|
|
7324
7331
|
]);
|
|
7325
7332
|
const candidateHomePaths = /* @__PURE__ */ new Set();
|
|
7326
7333
|
for (const rootPath of candidateRoots) {
|
|
@@ -8144,6 +8151,10 @@ function resolveRuntimeHome(runtime, env) {
|
|
|
8144
8151
|
if (genericHome) {
|
|
8145
8152
|
return path6.resolve(genericHome);
|
|
8146
8153
|
}
|
|
8154
|
+
const agentHomePath = env.CLAPS_AGENT_HOME_PATH?.trim();
|
|
8155
|
+
if (agentHomePath) {
|
|
8156
|
+
return path6.resolve(agentHomePath);
|
|
8157
|
+
}
|
|
8147
8158
|
return getAgentDriver(runtime).resolveHome(env);
|
|
8148
8159
|
}
|
|
8149
8160
|
async function inspectManagedSkillPath(targetPath, expectedSource) {
|
|
@@ -12182,6 +12193,10 @@ async function resolveEffectiveWorkspacePath(me, env = process.env) {
|
|
|
12182
12193
|
if (configuredWorkspacePath) {
|
|
12183
12194
|
return configuredWorkspacePath;
|
|
12184
12195
|
}
|
|
12196
|
+
const configuredAgentHomePath = me.agentHomePath?.trim() || env.CLAPS_AGENT_HOME_PATH?.trim();
|
|
12197
|
+
if (configuredAgentHomePath) {
|
|
12198
|
+
return path10.join(path10.resolve(configuredAgentHomePath), "workspace");
|
|
12199
|
+
}
|
|
12185
12200
|
return ensureAgentWorkspaceRoot({
|
|
12186
12201
|
agentId: me.id,
|
|
12187
12202
|
env
|
|
@@ -14822,7 +14837,7 @@ async function processConversationTurnItem(client, me, item, logger = defaultLog
|
|
|
14822
14837
|
logger.info(
|
|
14823
14838
|
`[claps-cli] processing conversation turn: ticketId=${ticketId}, conversationId=${context.conversation.id}, message=${context.requestMessage.content.slice(0, 200)}`
|
|
14824
14839
|
);
|
|
14825
|
-
const runtimeCwd = me.agent
|
|
14840
|
+
const runtimeCwd = await resolveEffectiveWorkspacePath(me.agent);
|
|
14826
14841
|
const driver = getAgentDriver(me.agent.runtime);
|
|
14827
14842
|
const preparedSession = await conversationSessionManager.prepareTurn({
|
|
14828
14843
|
agentId: me.agent.id,
|
|
@@ -15380,9 +15395,15 @@ async function runCli(argv, options = {}) {
|
|
|
15380
15395
|
return 0;
|
|
15381
15396
|
}
|
|
15382
15397
|
if (parsed.command === "run") {
|
|
15398
|
+
const agentHomeOverride2 = validateNoAgentHomeOverride(parsed.flags);
|
|
15399
|
+
if (!agentHomeOverride2.ok) {
|
|
15400
|
+
stderr.write(`${agentHomeOverride2.message}
|
|
15401
|
+
`);
|
|
15402
|
+
return 1;
|
|
15403
|
+
}
|
|
15383
15404
|
const runEnv = mergeEnvWithDaemonFlags(env, parsed.flags);
|
|
15384
15405
|
const requestedExternalKey = readStringFlag(parsed.flags, "external-key");
|
|
15385
|
-
const configuredAgentKey = normalizeOptional3(env.CLAPS_AGENT_KEY);
|
|
15406
|
+
const configuredAgentKey = normalizeOptional3((options.env ?? process.env).CLAPS_AGENT_KEY) ?? normalizeOptional3(env.CLAPS_AGENT_KEY);
|
|
15386
15407
|
if (requestedExternalKey) {
|
|
15387
15408
|
logger.warn(
|
|
15388
15409
|
configuredAgentKey && configuredAgentKey !== requestedExternalKey ? `[claps-cli] run still identifies via CLAPS_AGENT_TOKEN from .env.local/env. The current local binding is ${configuredAgentKey}, so --external-key ${requestedExternalKey} does not switch the worker to a different agent by itself.` : `[claps-cli] run uses CLAPS_AGENT_TOKEN to select the agent. --external-key ${requestedExternalKey} does not switch identity by itself.`
|
|
@@ -16076,6 +16097,12 @@ ${await buildHelpText(cwd)}
|
|
|
16076
16097
|
return 0;
|
|
16077
16098
|
}
|
|
16078
16099
|
if (parsed.command === "daemon-start") {
|
|
16100
|
+
const agentHomeOverride2 = validateNoAgentHomeOverride(parsed.flags);
|
|
16101
|
+
if (!agentHomeOverride2.ok) {
|
|
16102
|
+
stderr.write(`${agentHomeOverride2.message}
|
|
16103
|
+
`);
|
|
16104
|
+
return 1;
|
|
16105
|
+
}
|
|
16079
16106
|
const daemonEnv = mergeEnvWithDaemonFlags(env, parsed.flags);
|
|
16080
16107
|
const daemonLaunchCheck = validateDaemonLaunchEnv(daemonEnv);
|
|
16081
16108
|
if (!daemonLaunchCheck.ok) {
|
|
@@ -16086,7 +16113,7 @@ ${await buildHelpText(cwd)}
|
|
|
16086
16113
|
const result = await startBackgroundDaemon({
|
|
16087
16114
|
cwd,
|
|
16088
16115
|
env: daemonEnv,
|
|
16089
|
-
replaceExisting: readBooleanFlag(parsed.flags, "replace")
|
|
16116
|
+
replaceExisting: readBooleanFlag(parsed.flags, "replace") !== false,
|
|
16090
16117
|
...options.spawnImpl ? { spawnImpl: options.spawnImpl } : {},
|
|
16091
16118
|
...options.killImpl ? { killImpl: options.killImpl } : {}
|
|
16092
16119
|
});
|
|
@@ -16095,6 +16122,12 @@ ${await buildHelpText(cwd)}
|
|
|
16095
16122
|
return 0;
|
|
16096
16123
|
}
|
|
16097
16124
|
if (parsed.command === "daemon-stop") {
|
|
16125
|
+
const agentHomeOverride2 = validateNoAgentHomeOverride(parsed.flags);
|
|
16126
|
+
if (!agentHomeOverride2.ok) {
|
|
16127
|
+
stderr.write(`${agentHomeOverride2.message}
|
|
16128
|
+
`);
|
|
16129
|
+
return 1;
|
|
16130
|
+
}
|
|
16098
16131
|
const daemonEnv = mergeEnvWithDaemonFlags(env, parsed.flags);
|
|
16099
16132
|
const result = await stopBackgroundDaemon(
|
|
16100
16133
|
daemonEnv,
|
|
@@ -16105,6 +16138,12 @@ ${await buildHelpText(cwd)}
|
|
|
16105
16138
|
return 0;
|
|
16106
16139
|
}
|
|
16107
16140
|
if (parsed.command === "daemon-status") {
|
|
16141
|
+
const agentHomeOverride2 = validateNoAgentHomeOverride(parsed.flags);
|
|
16142
|
+
if (!agentHomeOverride2.ok) {
|
|
16143
|
+
stderr.write(`${agentHomeOverride2.message}
|
|
16144
|
+
`);
|
|
16145
|
+
return 1;
|
|
16146
|
+
}
|
|
16108
16147
|
const daemonEnv = mergeEnvWithDaemonFlags(env, parsed.flags);
|
|
16109
16148
|
const result = await readDaemonStatus(daemonEnv, options.killImpl ?? process.kill);
|
|
16110
16149
|
stdout.write(`${formatDaemonStatus(result)}
|
|
@@ -16112,6 +16151,12 @@ ${await buildHelpText(cwd)}
|
|
|
16112
16151
|
return result.status === "running" ? 0 : 1;
|
|
16113
16152
|
}
|
|
16114
16153
|
if (parsed.command === "daemon-logs") {
|
|
16154
|
+
const agentHomeOverride2 = validateNoAgentHomeOverride(parsed.flags);
|
|
16155
|
+
if (!agentHomeOverride2.ok) {
|
|
16156
|
+
stderr.write(`${agentHomeOverride2.message}
|
|
16157
|
+
`);
|
|
16158
|
+
return 1;
|
|
16159
|
+
}
|
|
16115
16160
|
const daemonEnv = mergeEnvWithDaemonFlags(env, parsed.flags);
|
|
16116
16161
|
const lineCount = readNumberFlag(parsed.flags, "lines");
|
|
16117
16162
|
const result = await readDaemonLog(daemonEnv, lineCount ? { lines: lineCount } : {});
|
|
@@ -16150,6 +16195,12 @@ ${await buildHelpText(cwd)}
|
|
|
16150
16195
|
return 1;
|
|
16151
16196
|
}
|
|
16152
16197
|
}
|
|
16198
|
+
const agentHomeOverride = validateNoAgentHomeOverride(parsed.flags);
|
|
16199
|
+
if (!agentHomeOverride.ok) {
|
|
16200
|
+
stderr.write(`${agentHomeOverride.message}
|
|
16201
|
+
`);
|
|
16202
|
+
return 1;
|
|
16203
|
+
}
|
|
16153
16204
|
const registration = buildRegisterCommandConfig(parsed.flags, env, cwd);
|
|
16154
16205
|
if (!registration.ok) {
|
|
16155
16206
|
stderr.write(`${registration.message}
|
|
@@ -16163,7 +16214,10 @@ ${await buildHelpText(cwd)}
|
|
|
16163
16214
|
const syncResult = await syncRuntimeAssets({
|
|
16164
16215
|
runtime: registration.config.request.runtime,
|
|
16165
16216
|
cwd,
|
|
16166
|
-
env
|
|
16217
|
+
env: {
|
|
16218
|
+
...env,
|
|
16219
|
+
...registration.config.request.agentHomePath ? { CLAPS_AGENT_HOME_PATH: registration.config.request.agentHomePath } : {}
|
|
16220
|
+
}
|
|
16167
16221
|
});
|
|
16168
16222
|
if (syncResult.status === "check_failed") {
|
|
16169
16223
|
stderr.write(`${formatRuntimeAssetSyncResult(syncResult)}
|
|
@@ -16177,11 +16231,14 @@ ${await buildHelpText(cwd)}
|
|
|
16177
16231
|
const response = await registerAgentWithApi(registration.config, options.fetchImpl ?? fetch);
|
|
16178
16232
|
if (registration.config.saveToken) {
|
|
16179
16233
|
await saveRuntimeEnv(registration.config.envFilePath, {
|
|
16234
|
+
...registration.config.request.capabilitySummary ? { CLAPS_AGENT_CAPABILITY_SUMMARY: registration.config.request.capabilitySummary } : {},
|
|
16180
16235
|
CLAPS_AGENT_KEY: registration.config.request.externalKey,
|
|
16181
16236
|
CLAPS_AGENT_NAME: registration.config.request.name,
|
|
16182
16237
|
CLAPS_AGENT_RUNTIME: registration.config.request.runtime,
|
|
16183
16238
|
CLAPS_AGENT_HOME_PATH: registration.config.request.agentHomePath ?? dirname3(registration.config.envFilePath),
|
|
16239
|
+
CLAPS_AGENT_DANGEROUSLY_BYPASS_SANDBOX: registration.config.request.dangerouslyBypassSandbox ? "1" : "0",
|
|
16184
16240
|
...registration.config.request.workspacePath ? { CLAPS_AGENT_WORKSPACE_PATH: registration.config.request.workspacePath } : {},
|
|
16241
|
+
...registration.config.request.protocolVersion ? { CLAPS_AGENT_PROTOCOL_VERSION: registration.config.request.protocolVersion } : {},
|
|
16185
16242
|
CLAPS_AGENT_AUTH_MODE: response.outcome === "registered" ? response.session.authMode : response.bootstrapSession.authMode,
|
|
16186
16243
|
...registration.config.request.orgSlug ? { CLAPS_ORG_SLUG: registration.config.request.orgSlug } : {},
|
|
16187
16244
|
CLAPS_AGENT_TOKEN: response.outcome === "registered" ? response.session.token : response.bootstrapSession.token,
|
|
@@ -16200,7 +16257,9 @@ ${await buildHelpText(cwd)}
|
|
|
16200
16257
|
CLAPS_AGENT_NAME: registration.config.request.name,
|
|
16201
16258
|
CLAPS_AGENT_RUNTIME: registration.config.request.runtime,
|
|
16202
16259
|
CLAPS_AGENT_HOME_PATH: registration.config.request.agentHomePath ?? dirname3(registration.config.envFilePath),
|
|
16260
|
+
CLAPS_AGENT_DANGEROUSLY_BYPASS_SANDBOX: registration.config.request.dangerouslyBypassSandbox ? "1" : "0",
|
|
16203
16261
|
...registration.config.request.workspacePath ? { CLAPS_AGENT_WORKSPACE_PATH: registration.config.request.workspacePath } : {},
|
|
16262
|
+
...registration.config.request.protocolVersion ? { CLAPS_AGENT_PROTOCOL_VERSION: registration.config.request.protocolVersion } : {},
|
|
16204
16263
|
...registration.config.request.orgSlug ? { CLAPS_ORG_SLUG: registration.config.request.orgSlug } : {}
|
|
16205
16264
|
};
|
|
16206
16265
|
daemonResult = await startBackgroundDaemon({
|
|
@@ -16498,10 +16557,8 @@ function buildRegisterCommandConfig(flags, env, cwd) {
|
|
|
16498
16557
|
capabilitySummary: readStringFlag(flags, "capability-summary") ?? normalizeNullable(env.CLAPS_AGENT_CAPABILITY_SUMMARY),
|
|
16499
16558
|
channelRef: readStringFlag(flags, "channel-ref") ?? normalizeNullable(env.CLAPS_AGENT_CHANNEL_REF),
|
|
16500
16559
|
workspacePath: readStringFlag(flags, "workspace-path") ?? normalizeNullable(env.CLAPS_AGENT_WORKSPACE_PATH),
|
|
16501
|
-
agentHomePath:
|
|
16502
|
-
|
|
16503
|
-
cwd
|
|
16504
|
-
) ?? resolve2(cwd),
|
|
16560
|
+
agentHomePath: null,
|
|
16561
|
+
dangerouslyBypassSandbox: readBooleanFlag(flags, "dangerously-bypass-sandbox") ?? normalizeOptional3(env.CLAPS_AGENT_DANGEROUSLY_BYPASS_SANDBOX) === "1",
|
|
16505
16562
|
protocolVersion: readStringFlag(flags, "protocol-version") ?? normalizeNullable(env.CLAPS_AGENT_PROTOCOL_VERSION)
|
|
16506
16563
|
};
|
|
16507
16564
|
const parsedRequest = registerAgentRequestSchema.safeParse(requestCandidate);
|
|
@@ -16513,13 +16570,19 @@ function buildRegisterCommandConfig(flags, env, cwd) {
|
|
|
16513
16570
|
}
|
|
16514
16571
|
const apiBaseUrl = readStringFlag(flags, "api-base-url") ?? normalizeOptional3(env.CLAPS_API_URL) ?? normalizeOptional3(env.CLAPS_API_BASE_URL) ?? "http://127.0.0.1:3001";
|
|
16515
16572
|
const envFileArg = readStringFlag(flags, "env-file");
|
|
16516
|
-
const saveToken =
|
|
16573
|
+
const saveToken = shouldSaveToken(flags, env);
|
|
16517
16574
|
return {
|
|
16518
16575
|
ok: true,
|
|
16519
16576
|
config: {
|
|
16520
16577
|
apiBaseUrl: apiBaseUrl.replace(/\/+$/g, ""),
|
|
16521
|
-
envFilePath: envFileArg ? resolve2(cwd, envFileArg) : resolve2(
|
|
16522
|
-
|
|
16578
|
+
envFilePath: envFileArg ? resolve2(cwd, envFileArg) : resolve2(
|
|
16579
|
+
resolveDefaultAgentHomePath(parsedRequest.data.externalKey, env) ?? cwd,
|
|
16580
|
+
defaultEnvFileName
|
|
16581
|
+
),
|
|
16582
|
+
request: {
|
|
16583
|
+
...parsedRequest.data,
|
|
16584
|
+
agentHomePath: resolveDefaultAgentHomePath(parsedRequest.data.externalKey, env)
|
|
16585
|
+
},
|
|
16523
16586
|
saveToken
|
|
16524
16587
|
}
|
|
16525
16588
|
};
|
|
@@ -16577,6 +16640,17 @@ function buildAgentHomeMigrationConfig(flags, cwd) {
|
|
|
16577
16640
|
}
|
|
16578
16641
|
};
|
|
16579
16642
|
}
|
|
16643
|
+
function validateNoAgentHomeOverride(flags) {
|
|
16644
|
+
if (!readStringFlag(flags, "agent-home-path")) {
|
|
16645
|
+
return {
|
|
16646
|
+
ok: true
|
|
16647
|
+
};
|
|
16648
|
+
}
|
|
16649
|
+
return {
|
|
16650
|
+
ok: false,
|
|
16651
|
+
message: "Agent home path is no longer configurable for register/run/daemon commands. CLAPS now uses $HOME/.triclaps-agents/<agent-key> automatically."
|
|
16652
|
+
};
|
|
16653
|
+
}
|
|
16580
16654
|
function buildSessionLoginCommandConfig(flags, env) {
|
|
16581
16655
|
const requestCandidate = {
|
|
16582
16656
|
email: readStringFlag(flags, "email") ?? void 0,
|
|
@@ -17438,13 +17512,13 @@ function createCliLogger(stdout, stderr) {
|
|
|
17438
17512
|
};
|
|
17439
17513
|
}
|
|
17440
17514
|
function mergeEnvWithDaemonFlags(env, flags) {
|
|
17515
|
+
const requestedAgentKey = readStringFlag(flags, "external-key") ?? env.CLAPS_AGENT_KEY;
|
|
17516
|
+
const resolvedAgentHomePath = normalizeOptional3(env.CLAPS_AGENT_HOME_PATH) ?? resolveDefaultAgentHomePath(requestedAgentKey, env);
|
|
17441
17517
|
return {
|
|
17442
17518
|
...env,
|
|
17443
17519
|
...readStringFlag(flags, "api-base-url") ? { CLAPS_API_BASE_URL: readStringFlag(flags, "api-base-url") ?? env.CLAPS_API_BASE_URL } : {},
|
|
17444
|
-
...
|
|
17445
|
-
...
|
|
17446
|
-
CLAPS_AGENT_HOME_PATH: readStringFlag(flags, "agent-home-path") ?? env.CLAPS_AGENT_HOME_PATH
|
|
17447
|
-
} : {}
|
|
17520
|
+
...requestedAgentKey ? { CLAPS_AGENT_KEY: requestedAgentKey } : {},
|
|
17521
|
+
...resolvedAgentHomePath ? { CLAPS_AGENT_HOME_PATH: resolvedAgentHomePath } : {}
|
|
17448
17522
|
};
|
|
17449
17523
|
}
|
|
17450
17524
|
function validateDaemonLaunchEnv(env) {
|
|
@@ -17573,6 +17647,16 @@ async function getBootstrapStatus(config, fetchImpl) {
|
|
|
17573
17647
|
return { kind: "unavailable" };
|
|
17574
17648
|
}
|
|
17575
17649
|
}
|
|
17650
|
+
function shouldSaveToken(flags, env) {
|
|
17651
|
+
const explicit = readBooleanFlag(flags, "save-token");
|
|
17652
|
+
if (explicit !== null) {
|
|
17653
|
+
return explicit;
|
|
17654
|
+
}
|
|
17655
|
+
if (normalizeOptional3(env.CLAPS_SAVE_TOKEN) === "0") {
|
|
17656
|
+
return false;
|
|
17657
|
+
}
|
|
17658
|
+
return true;
|
|
17659
|
+
}
|
|
17576
17660
|
function shouldStartDaemonByDefault(flags) {
|
|
17577
17661
|
return readBooleanFlag(flags, "start-daemon") !== false;
|
|
17578
17662
|
}
|
|
@@ -17657,8 +17741,9 @@ Unsupported runtime value: ${runtime}` : ""}`
|
|
|
17657
17741
|
};
|
|
17658
17742
|
}
|
|
17659
17743
|
async function runApiReachabilityCheck(apiBaseUrl, fetchImpl) {
|
|
17744
|
+
const healthUrl = `${apiBaseUrl}/api/health`;
|
|
17660
17745
|
try {
|
|
17661
|
-
const response = await fetchImpl(
|
|
17746
|
+
const response = await fetchImpl(healthUrl, {
|
|
17662
17747
|
method: "GET",
|
|
17663
17748
|
headers: {
|
|
17664
17749
|
accept: "application/json"
|
|
@@ -17669,14 +17754,14 @@ async function runApiReachabilityCheck(apiBaseUrl, fetchImpl) {
|
|
|
17669
17754
|
return {
|
|
17670
17755
|
name: "API reachability",
|
|
17671
17756
|
status: "issues",
|
|
17672
|
-
lines: [`GET ${
|
|
17757
|
+
lines: [`GET ${healthUrl} returned HTTP ${response.status}.`]
|
|
17673
17758
|
};
|
|
17674
17759
|
}
|
|
17675
17760
|
return {
|
|
17676
17761
|
name: "API reachability",
|
|
17677
17762
|
status: payload.status === "ok" ? "ok" : "warning",
|
|
17678
17763
|
lines: [
|
|
17679
|
-
`GET ${
|
|
17764
|
+
`GET ${healthUrl} returned HTTP ${response.status}.`,
|
|
17680
17765
|
`service: ${payload.service ?? "unknown"}`,
|
|
17681
17766
|
`status: ${payload.status ?? "unknown"}`
|
|
17682
17767
|
]
|
|
@@ -17686,7 +17771,7 @@ async function runApiReachabilityCheck(apiBaseUrl, fetchImpl) {
|
|
|
17686
17771
|
name: "API reachability",
|
|
17687
17772
|
status: "issues",
|
|
17688
17773
|
lines: [
|
|
17689
|
-
`GET ${
|
|
17774
|
+
`GET ${healthUrl} failed: ${error instanceof Error ? error.message : "unknown fetch error"}`
|
|
17690
17775
|
]
|
|
17691
17776
|
};
|
|
17692
17777
|
}
|
|
@@ -18792,6 +18877,13 @@ function normalizePathLike(value, cwd) {
|
|
|
18792
18877
|
}
|
|
18793
18878
|
return resolve2(cwd, normalized);
|
|
18794
18879
|
}
|
|
18880
|
+
function resolveDefaultAgentHomePath(agentKey, env) {
|
|
18881
|
+
const normalizedAgentKey = normalizeOptional3(agentKey ?? void 0);
|
|
18882
|
+
if (!normalizedAgentKey) {
|
|
18883
|
+
return null;
|
|
18884
|
+
}
|
|
18885
|
+
return resolve2(env.HOME?.trim() || os6.homedir(), ".triclaps-agents", normalizedAgentKey);
|
|
18886
|
+
}
|
|
18795
18887
|
async function loadCliEnvironment(cwd, env, flags) {
|
|
18796
18888
|
const explicitEnvFile = flags ? readStringFlag(flags, "env-file") : null;
|
|
18797
18889
|
if (explicitEnvFile) {
|
|
@@ -18803,17 +18895,21 @@ async function loadCliEnvironment(cwd, env, flags) {
|
|
|
18803
18895
|
...env
|
|
18804
18896
|
};
|
|
18805
18897
|
}
|
|
18806
|
-
const
|
|
18807
|
-
(flags ? readStringFlag(flags, "
|
|
18808
|
-
cwd
|
|
18898
|
+
const requestedAgentKey = normalizeOptional3(
|
|
18899
|
+
(flags ? readStringFlag(flags, "external-key") : null) ?? normalizeOptional3(env.CLAPS_AGENT_KEY)
|
|
18809
18900
|
);
|
|
18810
|
-
|
|
18901
|
+
const explicitAgentHomePath = normalizePathLike(env.CLAPS_AGENT_HOME_PATH, cwd);
|
|
18902
|
+
const defaultAgentHomePath = resolveDefaultAgentHomePath(requestedAgentKey, env);
|
|
18903
|
+
const resolvedAgentHomePath = explicitAgentHomePath ?? defaultAgentHomePath;
|
|
18904
|
+
if (resolvedAgentHomePath) {
|
|
18811
18905
|
const fileValues = parseEnvFile(
|
|
18812
|
-
await readTextFileIfExists2(resolve2(
|
|
18906
|
+
await readTextFileIfExists2(resolve2(resolvedAgentHomePath, defaultEnvFileName))
|
|
18813
18907
|
);
|
|
18814
18908
|
return {
|
|
18815
18909
|
...fileValues,
|
|
18816
|
-
...env
|
|
18910
|
+
...env,
|
|
18911
|
+
CLAPS_AGENT_HOME_PATH: resolvedAgentHomePath,
|
|
18912
|
+
...requestedAgentKey ? { CLAPS_AGENT_KEY: requestedAgentKey } : {}
|
|
18817
18913
|
};
|
|
18818
18914
|
}
|
|
18819
18915
|
const primaryEnvFilePath = resolve2(cwd, defaultEnvFileName);
|
|
@@ -19167,11 +19263,11 @@ async function buildHelpText(cwd) {
|
|
|
19167
19263
|
" claps-cli project archive --project-id <project-id> [--json] [--session-token <token>] [--api-base-url <url>]",
|
|
19168
19264
|
" claps-cli project repo-binding get --project-id <project-id> [--json] [--session-token <token>] [--api-base-url <url>]",
|
|
19169
19265
|
" claps-cli project repo-binding set --project-id <project-id> --repo-owner <owner> --repo-name <name> --repo-url <url> [--provider <github|github_enterprise|gitlab|gitlab_selfhost>] [--default-branch <branch>] [--root-path <path>] [--is-monorepo <true|false>] [--auth-type <none|token|oauth|app>] [--json] [--session-token <token>] [--api-base-url <url>]",
|
|
19170
|
-
" claps-cli run [--api-base-url <url>] [--external-key <key>] [--
|
|
19171
|
-
" claps-cli daemon start [--replace] [--api-base-url <url>] [--external-key <key>] [--
|
|
19172
|
-
" claps-cli daemon stop [--api-base-url <url>] [--external-key <key>] [--
|
|
19173
|
-
" claps-cli daemon status [--api-base-url <url>] [--external-key <key>] [--
|
|
19174
|
-
" claps-cli daemon logs [--lines <count>] [--api-base-url <url>] [--external-key <key>] [--
|
|
19266
|
+
" claps-cli run [--api-base-url <url>] [--external-key <key>] [--env-file <path>]",
|
|
19267
|
+
" claps-cli daemon start [--replace] [--api-base-url <url>] [--external-key <key>] [--env-file <path>]",
|
|
19268
|
+
" claps-cli daemon stop [--api-base-url <url>] [--external-key <key>] [--env-file <path>]",
|
|
19269
|
+
" claps-cli daemon status [--api-base-url <url>] [--external-key <key>] [--env-file <path>]",
|
|
19270
|
+
" claps-cli daemon logs [--lines <count>] [--api-base-url <url>] [--external-key <key>] [--env-file <path>]",
|
|
19175
19271
|
" claps-cli agent-home migrate --agent-home-path <path> [--env-file <legacy-env-file>] [--sync-profile <true|false>]",
|
|
19176
19272
|
" claps-cli version",
|
|
19177
19273
|
" claps-cli doctor [--runtime <runtime>] [--api-base-url <url>]",
|
|
@@ -19198,7 +19294,7 @@ async function buildHelpText(cwd) {
|
|
|
19198
19294
|
" claps-cli skills audit [--check-todo]",
|
|
19199
19295
|
" claps-cli skills todo [--write|--check]",
|
|
19200
19296
|
" claps-cli skill <name>",
|
|
19201
|
-
" claps-cli register --api-base-url <url> --org-slug <slug> --runtime <runtime> --external-key <key> --name <name> [--
|
|
19297
|
+
" claps-cli register --api-base-url <url> --org-slug <slug> --runtime <runtime> --external-key <key> --name <name> [--workspace-path <path>] [--capability-summary <text>] [--save-token <true|false>] [--start-daemon <true|false>]",
|
|
19202
19298
|
" claps-cli sync-runtime --runtime <runtime> [--check]",
|
|
19203
19299
|
" claps-cli preview expose --app-slug <slug> --port <port> [--name <name>] [--local-host <host>] [--api-base-url <url>]",
|
|
19204
19300
|
"",
|
|
@@ -19243,7 +19339,7 @@ async function buildHelpText(cwd) {
|
|
|
19243
19339
|
"Agent home stores CLAPS-local env, session history, and runtime state; workspace path is the file tree the agent edits.",
|
|
19244
19340
|
"Use `claps-cli agent-home migrate` to move a legacy workspace-root .env.local into a dedicated agent home and leave behind a pointer env.",
|
|
19245
19341
|
"claps-cli run re-checks managed runtime assets on an interval and repairs drift automatically.",
|
|
19246
|
-
"Register now saves agent env defaults
|
|
19342
|
+
"Register now saves agent env defaults by default. Start the detached worker separately with `claps-cli daemon start`, or opt in during registration with `--start-daemon`.",
|
|
19247
19343
|
"Use `claps-cli daemon start` for manual detached startup; `claps-cli daemon logs` reads recent worker output without opening the metadata directory.",
|
|
19248
19344
|
"`claps-cli run` stays in the foreground for debugging."
|
|
19249
19345
|
].join("\n");
|