acpx 0.11.1 → 0.12.0
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 +3 -2
- package/dist/{cli-D4XUKXcD.js → cli-CxsS1XQp.js} +4 -4
- package/dist/{cli-D4XUKXcD.js.map → cli-CxsS1XQp.js.map} +1 -1
- package/dist/cli.js +25 -10
- package/dist/cli.js.map +1 -1
- package/dist/{client-DIlpCkHw.d.ts → client-DwNyFauq.d.ts} +4 -1
- package/dist/{client-DIlpCkHw.d.ts.map → client-DwNyFauq.d.ts.map} +1 -1
- package/dist/{flags-Dvgmpq_l.js → flags-Bjq_XQ4-.js} +4 -4
- package/dist/{flags-Dvgmpq_l.js.map → flags-Bjq_XQ4-.js.map} +1 -1
- package/dist/{flows-Cvsc-_AW.js → flows-Db_LZKu9.js} +3 -3
- package/dist/flows-Db_LZKu9.js.map +1 -0
- package/dist/flows.js +1 -1
- package/dist/{live-checkpoint-BWkYxMeS.js → live-checkpoint-ClPCSdrW.js} +59 -17
- package/dist/live-checkpoint-ClPCSdrW.js.map +1 -0
- package/dist/{output-BEv_BB7T.js → output-CjdF5rHk.js} +303 -74
- package/dist/output-CjdF5rHk.js.map +1 -0
- package/dist/runtime.d.ts +4 -5
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/package.json +9 -9
- package/skills/acpx/SKILL.md +2 -1
- package/dist/flows-Cvsc-_AW.js.map +0 -1
- package/dist/live-checkpoint-BWkYxMeS.js.map +0 -1
- package/dist/output-BEv_BB7T.js.map +0 -1
|
@@ -445,6 +445,7 @@ const AGENT_REGISTRY = {
|
|
|
445
445
|
copilot: "copilot --acp --stdio",
|
|
446
446
|
droid: "droid exec --output-format acp",
|
|
447
447
|
"fast-agent": "uvx fast-agent-mcp acp",
|
|
448
|
+
"grok-build": "grok agent stdio",
|
|
448
449
|
iflow: "iflow --experimental-acp",
|
|
449
450
|
kilocode: "npx -y @kilocode/cli acp",
|
|
450
451
|
kimi: "kimi acp",
|
|
@@ -4561,7 +4562,33 @@ var AcpClient = class {
|
|
|
4561
4562
|
credential: configCredential,
|
|
4562
4563
|
source: "config"
|
|
4563
4564
|
};
|
|
4565
|
+
const agentSpecificEnvCredential = this.readAgentSpecificEnvCredential(method.id);
|
|
4566
|
+
if (agentSpecificEnvCredential) return {
|
|
4567
|
+
methodId: method.id,
|
|
4568
|
+
credential: agentSpecificEnvCredential,
|
|
4569
|
+
source: "env"
|
|
4570
|
+
};
|
|
4564
4571
|
}
|
|
4572
|
+
for (const method of methods) {
|
|
4573
|
+
const agentManagedSelection = this.selectAgentManagedAuthMethod(method.id);
|
|
4574
|
+
if (agentManagedSelection) return agentManagedSelection;
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
readAgentSpecificEnvCredential(methodId) {
|
|
4578
|
+
if (!this.isGrokBuildAcpCommand() || methodId !== "xai.api_key") return;
|
|
4579
|
+
const value = process.env.XAI_API_KEY;
|
|
4580
|
+
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
4581
|
+
}
|
|
4582
|
+
selectAgentManagedAuthMethod(methodId) {
|
|
4583
|
+
if (!this.isGrokBuildAcpCommand() || methodId !== "cached_token") return;
|
|
4584
|
+
return {
|
|
4585
|
+
methodId,
|
|
4586
|
+
source: "agent"
|
|
4587
|
+
};
|
|
4588
|
+
}
|
|
4589
|
+
isGrokBuildAcpCommand() {
|
|
4590
|
+
const { command, args } = splitCommandLine(this.options.agentCommand);
|
|
4591
|
+
return command.replace(/\\/g, "/").split("/").pop()?.replace(/\.(cmd|exe|ps1)$/iu, "").toLowerCase() === "grok" && args[0] === "agent" && args[1] === "stdio";
|
|
4565
4592
|
}
|
|
4566
4593
|
async authenticateIfRequired(connection, methods) {
|
|
4567
4594
|
if (methods.length === 0) return;
|
|
@@ -5229,30 +5256,35 @@ function numberField(source, keys) {
|
|
|
5229
5256
|
if (typeof value === "number" && Number.isFinite(value) && value >= 0) return value;
|
|
5230
5257
|
}
|
|
5231
5258
|
}
|
|
5232
|
-
function
|
|
5233
|
-
const
|
|
5234
|
-
|
|
5235
|
-
const source = asRecord(usageMeta) ?? updateRecord;
|
|
5236
|
-
if (!source) return;
|
|
5259
|
+
function sourceToTokenUsage(source) {
|
|
5260
|
+
const usageRecord = asRecord(source);
|
|
5261
|
+
if (!usageRecord) return;
|
|
5237
5262
|
const normalized = {
|
|
5238
|
-
input_tokens: numberField(
|
|
5239
|
-
output_tokens: numberField(
|
|
5240
|
-
cache_creation_input_tokens: numberField(
|
|
5263
|
+
input_tokens: numberField(usageRecord, ["input_tokens", "inputTokens"]),
|
|
5264
|
+
output_tokens: numberField(usageRecord, ["output_tokens", "outputTokens"]),
|
|
5265
|
+
cache_creation_input_tokens: numberField(usageRecord, [
|
|
5241
5266
|
"cache_creation_input_tokens",
|
|
5242
5267
|
"cacheCreationInputTokens",
|
|
5243
5268
|
"cachedWriteTokens"
|
|
5244
5269
|
]),
|
|
5245
|
-
cache_read_input_tokens: numberField(
|
|
5270
|
+
cache_read_input_tokens: numberField(usageRecord, [
|
|
5246
5271
|
"cache_read_input_tokens",
|
|
5247
5272
|
"cacheReadInputTokens",
|
|
5248
5273
|
"cachedReadTokens"
|
|
5249
5274
|
]),
|
|
5250
|
-
thought_tokens: numberField(
|
|
5251
|
-
total_tokens: numberField(
|
|
5275
|
+
thought_tokens: numberField(usageRecord, ["thought_tokens", "thoughtTokens"]),
|
|
5276
|
+
total_tokens: numberField(usageRecord, ["total_tokens", "totalTokens"])
|
|
5252
5277
|
};
|
|
5253
5278
|
if (!hasTokenUsageValue(normalized)) return;
|
|
5254
5279
|
return normalized;
|
|
5255
5280
|
}
|
|
5281
|
+
function usageToTokenUsage(update) {
|
|
5282
|
+
const updateRecord = asRecord(update);
|
|
5283
|
+
const usageMeta = asRecord(updateRecord?._meta)?.usage;
|
|
5284
|
+
const source = asRecord(usageMeta) ?? updateRecord;
|
|
5285
|
+
if (!source) return;
|
|
5286
|
+
return sourceToTokenUsage(source);
|
|
5287
|
+
}
|
|
5256
5288
|
function hasTokenUsageValue(usage) {
|
|
5257
5289
|
return Object.values(usage).some((value) => value !== void 0);
|
|
5258
5290
|
}
|
|
@@ -5368,6 +5400,14 @@ function recordSessionUpdate(conversation, state, notification, timestamp = isoN
|
|
|
5368
5400
|
trimConversationForRuntime(conversation);
|
|
5369
5401
|
return acpx;
|
|
5370
5402
|
}
|
|
5403
|
+
function recordPromptResponseUsage(conversation, usage, promptMessageId, timestamp = isoNow()) {
|
|
5404
|
+
const tokenUsage = sourceToTokenUsage(usage);
|
|
5405
|
+
if (!tokenUsage) return false;
|
|
5406
|
+
applyTokenUsage(conversation, tokenUsage, promptMessageId);
|
|
5407
|
+
updateConversationTimestamp(conversation, timestamp);
|
|
5408
|
+
trimConversationForRuntime(conversation);
|
|
5409
|
+
return true;
|
|
5410
|
+
}
|
|
5371
5411
|
function applySessionUpdate(conversation, acpx, update) {
|
|
5372
5412
|
const handler = SESSION_UPDATE_HANDLERS[update.sessionUpdate];
|
|
5373
5413
|
handler?.(conversation, acpx, update);
|
|
@@ -5420,13 +5460,14 @@ function applyUsageUpdate(conversation, update) {
|
|
|
5420
5460
|
const usage = usageToTokenUsage(update);
|
|
5421
5461
|
const cost = usageCost(update);
|
|
5422
5462
|
if (!usage && !cost) return;
|
|
5423
|
-
if (usage)
|
|
5424
|
-
conversation.cumulative_token_usage = usage;
|
|
5425
|
-
const userId = lastUserMessageId(conversation);
|
|
5426
|
-
if (userId) conversation.request_token_usage[userId] = usage;
|
|
5427
|
-
}
|
|
5463
|
+
if (usage) applyTokenUsage(conversation, usage);
|
|
5428
5464
|
if (cost) conversation.cumulative_cost = cost;
|
|
5429
5465
|
}
|
|
5466
|
+
function applyTokenUsage(conversation, usage, promptMessageId) {
|
|
5467
|
+
conversation.cumulative_token_usage = usage;
|
|
5468
|
+
const userId = promptMessageId ?? lastUserMessageId(conversation);
|
|
5469
|
+
if (userId) conversation.request_token_usage[userId] = usage;
|
|
5470
|
+
}
|
|
5430
5471
|
function applySessionInfoUpdate(conversation, update) {
|
|
5431
5472
|
if (hasOwn(update, "title")) conversation.title = update.title ?? null;
|
|
5432
5473
|
if (hasOwn(update, "updatedAt")) conversation.updated_at = update.updatedAt ?? conversation.updated_at;
|
|
@@ -6038,6 +6079,7 @@ async function runPromptTurn(params) {
|
|
|
6038
6079
|
idleMs: SESSION_REPLY_IDLE_MS,
|
|
6039
6080
|
timeoutMs: SESSION_REPLY_DRAIN_TIMEOUT_MS
|
|
6040
6081
|
}).catch(() => {});
|
|
6082
|
+
recordPromptResponseUsage(params.conversation, response.usage, params.promptMessageId);
|
|
6041
6083
|
return {
|
|
6042
6084
|
stopReason: response.stopReason,
|
|
6043
6085
|
source: "rpc"
|
|
@@ -6111,4 +6153,4 @@ var LiveSessionCheckpoint = class {
|
|
|
6111
6153
|
//#endregion
|
|
6112
6154
|
export { getPerfMetricsSnapshot as $, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE as A, listBuiltInAgents as At, absolutePath as B, AUTH_POLICIES as Bt, mergeSessionOptions as C, promptToDisplayText as Ct, applyLifecycleSnapshotToRecord as D, withInterrupt as Dt, applyConversation as E, TimeoutError as Et, modelStateFromConfigOptions as F, isRetryablePromptError as Ft, listSessions as G, OUTPUT_FORMATS as Gt, findSession as H, NON_INTERACTIVE_PERMISSION_POLICIES as Ht, splitCommandLine as I, normalizeOutputError as It, pruneSessions as J, SESSION_RECORD_SCHEMA as Jt, listSessionsForAgent as K, PERMISSION_MODES as Kt, getAcpxVersion as L, extractAcpError as Lt, RequestedModelUnsupportedError as M, resolveAgentCommand as Mt, assertRequestedModelSupported as N, exitCodeForOutputErrorCode as Nt, reconcileAgentSessionId as O, withTimeout as Ot, isRequestedModelUnsupportedError as P, formatErrorMessage as Pt, formatPerfMetric as Q, QueueProtocolError as Qt, permissionModeSatisfies as R, isAcpResourceNotFoundError as Rt, advertisedModelState as S, parsePromptSource as St, sessionOptionsFromRecord as T, InterruptedError as Tt, findSessionByDirectoryWalk as U, OUTPUT_ERROR_CODES as Ut, findGitRepositoryRoot as V, EXIT_CODES as Vt, isoNow$2 as W, OUTPUT_ERROR_ORIGINS as Wt, writeSessionRecord as X, AgentSpawnError as Xt, resolveSessionRecord as Y, AcpxOperationalError as Yt, assertPersistedKeyPolicy as Z, QueueConnectionError as Zt, createSessionConversation as _, parseJsonRpcErrorMessage as _t, applyRequestedModelIfAdvertised as a, startPerfTimer as at, recordSessionUpdate as b, isPromptInput as bt, setCurrentModelId as c, normalizeRuntimeSessionId as ct, setDesiredModelId as d, sessionBaseDir$1 as dt, incrementPerfCounter as et, syncAdvertisedModelState as f, sessionEventActivePath as ft, cloneSessionConversation as g, isAcpJsonRpcMessage as gt, cloneSessionAcpxState as h, extractSessionUpdateNotification as ht, connectAndLoadSession as i, setPerfGauge as it, REQUESTED_MODEL_UNSUPPORTED_REASONS as j, normalizeAgentName$1 as jt, AcpClient as k, DEFAULT_AGENT_NAME as kt, setDesiredConfigOption as l, DEFAULT_EVENT_SEGMENT_MAX_BYTES as lt, applyConfigOptionsToState as m, sessionEventSegmentPath as mt, runPromptTurn as n, recordPerfDuration as nt, currentModelIdFromSetModelResponse as o, parseSessionRecord as ot, applyConfigOptionsToRecord as p, sessionEventLockPath as pt, normalizeName as q, PERMISSION_POLICY_ACTIONS as qt, withConnectedSession as r, resetPerfMetrics as rt, clearDesiredConfigOption as s, serializeSessionRecordForDisk as st, LiveSessionCheckpoint as t, measurePerf as tt, setDesiredModeId as u, defaultSessionEventLog as ut, recordClientOperation as v, parsePromptStopReason as vt, persistSessionOptions as w, textPrompt as wt, trimConversationForRuntime as x, mergePromptSourceWithText as xt, recordPromptSubmission as y, PromptInputValidationError as yt, DEFAULT_HISTORY_LIMIT as z, toAcpErrorPayload as zt };
|
|
6113
6155
|
|
|
6114
|
-
//# sourceMappingURL=live-checkpoint-
|
|
6156
|
+
//# sourceMappingURL=live-checkpoint-ClPCSdrW.js.map
|