acpx 0.11.1 → 0.11.2
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-D4XUKXcD.js → cli-CXlEcGWV.js} +4 -4
- package/dist/{cli-D4XUKXcD.js.map → cli-CXlEcGWV.js.map} +1 -1
- package/dist/cli.js +6 -6
- package/dist/{flags-Dvgmpq_l.js → flags-Dl_mhic3.js} +3 -3
- package/dist/{flags-Dvgmpq_l.js.map → flags-Dl_mhic3.js.map} +1 -1
- package/dist/{flows-Cvsc-_AW.js → flows-7OHjgEgq.js} +3 -3
- package/dist/{flows-Cvsc-_AW.js.map → flows-7OHjgEgq.js.map} +1 -1
- package/dist/flows.js +1 -1
- package/dist/{live-checkpoint-BWkYxMeS.js → live-checkpoint-mdAaF3qJ.js} +32 -17
- package/dist/{live-checkpoint-BWkYxMeS.js.map → live-checkpoint-mdAaF3qJ.js.map} +1 -1
- package/dist/{output-BEv_BB7T.js → output-Smw6kFL_.js} +2 -2
- package/dist/{output-BEv_BB7T.js.map → output-Smw6kFL_.js.map} +1 -1
- package/dist/runtime.d.ts +3 -4
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -1
- package/package.json +1 -1
package/dist/flows.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as parseStrictJsonObject, d as checkpoint, f as compute, i as parseJsonObject, l as acp, m as shell, n as decisionEdge, o as FlowRunner, p as defineFlow, r as extractJsonObject, s as flowRunsBaseDir, t as decision, u as action } from "./flows-
|
|
1
|
+
import { a as parseStrictJsonObject, d as checkpoint, f as compute, i as parseJsonObject, l as acp, m as shell, n as decisionEdge, o as FlowRunner, p as defineFlow, r as extractJsonObject, s as flowRunsBaseDir, t as decision, u as action } from "./flows-7OHjgEgq.js";
|
|
2
2
|
export { FlowRunner, acp, action, checkpoint, compute, decision, decisionEdge, defineFlow, extractJsonObject, flowRunsBaseDir, parseJsonObject, parseStrictJsonObject, shell };
|
|
@@ -5229,30 +5229,35 @@ function numberField(source, keys) {
|
|
|
5229
5229
|
if (typeof value === "number" && Number.isFinite(value) && value >= 0) return value;
|
|
5230
5230
|
}
|
|
5231
5231
|
}
|
|
5232
|
-
function
|
|
5233
|
-
const
|
|
5234
|
-
|
|
5235
|
-
const source = asRecord(usageMeta) ?? updateRecord;
|
|
5236
|
-
if (!source) return;
|
|
5232
|
+
function sourceToTokenUsage(source) {
|
|
5233
|
+
const usageRecord = asRecord(source);
|
|
5234
|
+
if (!usageRecord) return;
|
|
5237
5235
|
const normalized = {
|
|
5238
|
-
input_tokens: numberField(
|
|
5239
|
-
output_tokens: numberField(
|
|
5240
|
-
cache_creation_input_tokens: numberField(
|
|
5236
|
+
input_tokens: numberField(usageRecord, ["input_tokens", "inputTokens"]),
|
|
5237
|
+
output_tokens: numberField(usageRecord, ["output_tokens", "outputTokens"]),
|
|
5238
|
+
cache_creation_input_tokens: numberField(usageRecord, [
|
|
5241
5239
|
"cache_creation_input_tokens",
|
|
5242
5240
|
"cacheCreationInputTokens",
|
|
5243
5241
|
"cachedWriteTokens"
|
|
5244
5242
|
]),
|
|
5245
|
-
cache_read_input_tokens: numberField(
|
|
5243
|
+
cache_read_input_tokens: numberField(usageRecord, [
|
|
5246
5244
|
"cache_read_input_tokens",
|
|
5247
5245
|
"cacheReadInputTokens",
|
|
5248
5246
|
"cachedReadTokens"
|
|
5249
5247
|
]),
|
|
5250
|
-
thought_tokens: numberField(
|
|
5251
|
-
total_tokens: numberField(
|
|
5248
|
+
thought_tokens: numberField(usageRecord, ["thought_tokens", "thoughtTokens"]),
|
|
5249
|
+
total_tokens: numberField(usageRecord, ["total_tokens", "totalTokens"])
|
|
5252
5250
|
};
|
|
5253
5251
|
if (!hasTokenUsageValue(normalized)) return;
|
|
5254
5252
|
return normalized;
|
|
5255
5253
|
}
|
|
5254
|
+
function usageToTokenUsage(update) {
|
|
5255
|
+
const updateRecord = asRecord(update);
|
|
5256
|
+
const usageMeta = asRecord(updateRecord?._meta)?.usage;
|
|
5257
|
+
const source = asRecord(usageMeta) ?? updateRecord;
|
|
5258
|
+
if (!source) return;
|
|
5259
|
+
return sourceToTokenUsage(source);
|
|
5260
|
+
}
|
|
5256
5261
|
function hasTokenUsageValue(usage) {
|
|
5257
5262
|
return Object.values(usage).some((value) => value !== void 0);
|
|
5258
5263
|
}
|
|
@@ -5368,6 +5373,14 @@ function recordSessionUpdate(conversation, state, notification, timestamp = isoN
|
|
|
5368
5373
|
trimConversationForRuntime(conversation);
|
|
5369
5374
|
return acpx;
|
|
5370
5375
|
}
|
|
5376
|
+
function recordPromptResponseUsage(conversation, usage, promptMessageId, timestamp = isoNow()) {
|
|
5377
|
+
const tokenUsage = sourceToTokenUsage(usage);
|
|
5378
|
+
if (!tokenUsage) return false;
|
|
5379
|
+
applyTokenUsage(conversation, tokenUsage, promptMessageId);
|
|
5380
|
+
updateConversationTimestamp(conversation, timestamp);
|
|
5381
|
+
trimConversationForRuntime(conversation);
|
|
5382
|
+
return true;
|
|
5383
|
+
}
|
|
5371
5384
|
function applySessionUpdate(conversation, acpx, update) {
|
|
5372
5385
|
const handler = SESSION_UPDATE_HANDLERS[update.sessionUpdate];
|
|
5373
5386
|
handler?.(conversation, acpx, update);
|
|
@@ -5420,13 +5433,14 @@ function applyUsageUpdate(conversation, update) {
|
|
|
5420
5433
|
const usage = usageToTokenUsage(update);
|
|
5421
5434
|
const cost = usageCost(update);
|
|
5422
5435
|
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
|
-
}
|
|
5436
|
+
if (usage) applyTokenUsage(conversation, usage);
|
|
5428
5437
|
if (cost) conversation.cumulative_cost = cost;
|
|
5429
5438
|
}
|
|
5439
|
+
function applyTokenUsage(conversation, usage, promptMessageId) {
|
|
5440
|
+
conversation.cumulative_token_usage = usage;
|
|
5441
|
+
const userId = promptMessageId ?? lastUserMessageId(conversation);
|
|
5442
|
+
if (userId) conversation.request_token_usage[userId] = usage;
|
|
5443
|
+
}
|
|
5430
5444
|
function applySessionInfoUpdate(conversation, update) {
|
|
5431
5445
|
if (hasOwn(update, "title")) conversation.title = update.title ?? null;
|
|
5432
5446
|
if (hasOwn(update, "updatedAt")) conversation.updated_at = update.updatedAt ?? conversation.updated_at;
|
|
@@ -6038,6 +6052,7 @@ async function runPromptTurn(params) {
|
|
|
6038
6052
|
idleMs: SESSION_REPLY_IDLE_MS,
|
|
6039
6053
|
timeoutMs: SESSION_REPLY_DRAIN_TIMEOUT_MS
|
|
6040
6054
|
}).catch(() => {});
|
|
6055
|
+
recordPromptResponseUsage(params.conversation, response.usage, params.promptMessageId);
|
|
6041
6056
|
return {
|
|
6042
6057
|
stopReason: response.stopReason,
|
|
6043
6058
|
source: "rpc"
|
|
@@ -6111,4 +6126,4 @@ var LiveSessionCheckpoint = class {
|
|
|
6111
6126
|
//#endregion
|
|
6112
6127
|
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
6128
|
|
|
6114
|
-
//# sourceMappingURL=live-checkpoint-
|
|
6129
|
+
//# sourceMappingURL=live-checkpoint-mdAaF3qJ.js.map
|