@runappsai/agent 0.3.1 → 0.3.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/agent-core.umd.js +38 -38
- package/dist/agent.js +4 -0
- package/dist/agent.umd.js +52 -52
- package/dist/chat.js +7 -4
- package/dist/index.cjs +4 -1
- package/dist/llm.d.ts +4 -0
- package/dist/types.d.ts +2 -0
- package/dist/ui.cjs +8 -2
- package/package.json +1 -1
package/dist/chat.js
CHANGED
|
@@ -45,7 +45,7 @@ const STRINGS = {
|
|
|
45
45
|
runCode: "Run code", ingRead: "Reading", ingList: "Listing", ingSearch: "Searching", ingWrite: "Writing", ingEdit: "Editing", ingDelete: "Deleting", ingRun: "Running code", ingAsk: "Asking you", ingOther: "Running", current: "Current", jumpEnd: "Jump to the latest",
|
|
46
46
|
sTabModel: "Model", sTabContext: "Context", sCompact: "When the context is nearly full", sCompactSummary: "Summarise older turns (one extra model call)", sCompactTrim: "Only trim: drop old tool results, then the oldest turns", sCompactAt: "Start when fewer tokens than this are left", sKeepRecent: "Keep this many of the newest tokens word for word", sDefaultN: "Default ({n})", sCompactNote: "{model}: starts with {at} tokens left and keeps about {keep} word for word (capped at 20% / 40% of its {window} window)", sCompactNoteTrim: "{model}: trims with fewer than {at} tokens left (capped at 20% of its {window} window)", autoTrim: "Auto-trim", debug: "Debug", dCalls: "Calls", dRequests: "Requests", dEvents: "Events", dContext: "Context", dTools: "Tools", dClear: "Clear the record", dFilter: "Filter by type",
|
|
47
47
|
dNoCalls: "No tool calls yet.", dNoRequests: "No model requests yet. Each call to the model is listed here with what was sent and what came back.", dNoEvents: "No events yet.",
|
|
48
|
-
dSystem: "System prompt", dMessages: "Messages sent to the model", dPayload: "Request", dResponse: "Response", dRun: "Run", dTurn: "Turn {n}", sent: "sent", justNow: "Just now", minutesAgo: "{n} min ago", hoursAgo: "{n} h ago", context: "context", copy: "Copy", copied: "Copied", rewind: "Rewind to here", rewindTitle: "Rewind to this message", regen: "Answer again", regenTitle: "Answer this question again", regenMsg: "This answer and what follows are dropped and the question is sent again.", delTurn: "Delete", delTurnTitle: "Delete this question and its answer?", delTurnMsg: "They are removed from the conversation; files stay as they are.", replyCost: "Cost: {cost}", replyUsage: "{in} in · {out} out · {calls} calls",
|
|
48
|
+
dSystem: "System prompt", dMessages: "Messages sent to the model", dPayload: "Request", dResponse: "Response", dRun: "Run", dTurn: "Turn {n}", sent: "sent", justNow: "Just now", minutesAgo: "{n} min ago", hoursAgo: "{n} h ago", context: "context", copy: "Copy", copied: "Copied", rewind: "Rewind to here", rewindTitle: "Rewind to this message", regen: "Answer again", regenTitle: "Answer this question again", regenMsg: "This answer and what follows are dropped and the question is sent again.", delTurn: "Delete", delTurnTitle: "Delete this question and its answer?", delTurnMsg: "They are removed from the conversation; files stay as they are.", replyCost: "Cost: {cost}", replyUsage: "{in} in · {out} out · {calls} calls", replyCache: "cache hit {p}%", replyCached: " ({n} from cache)",
|
|
49
49
|
older: "Load earlier messages", olderBusy: "Wait for the reply to finish, then load earlier messages.",
|
|
50
50
|
rewindMsg: "The conversation after it is dropped and the message goes back into the composer.", rewindFiles: "Also restore the directory's files to that moment", rewindGone: "This message is no longer in the conversation.", rewindSnapshot: "{n} files ({size}) as they were at {time}", rewindPartial: "Files over 2 MB were not in the snapshot and stay as they are.", rewindGoneFile: "{path} is no longer in the directory.",
|
|
51
51
|
running: "running", waitingAnswer: "waiting for your answer", finished: "finished", bgLimit: "{n} conversations are already running in the background; stop one before switching away from this one.",
|
|
@@ -86,7 +86,7 @@ const STRINGS = {
|
|
|
86
86
|
runCode: "运行代码", ingRead: "正在读取", ingList: "正在查看", ingSearch: "正在搜索", ingWrite: "正在写入", ingEdit: "正在修改", ingDelete: "正在删除", ingRun: "正在运行代码", ingAsk: "正在询问你", ingOther: "正在执行", current: "当前", jumpEnd: "回到最新",
|
|
87
87
|
sTabModel: "模型", sTabContext: "上下文", sCompact: "上下文快满时", sCompactSummary: "把较早的对话写成摘要(多一次模型调用)", sCompactTrim: "只裁剪:先删旧的工具结果,再删最早的对话", sCompactAt: "剩余少于多少 tokens 时开始", sKeepRecent: "原样保留最近多少 tokens", sDefaultN: "默认({n})", sCompactNote: "{model}:剩余 {at} tokens 时开始,原样保留约 {keep} tokens(最多为上下文 {window} 的 20% / 40%)", sCompactNoteTrim: "{model}:剩余少于 {at} tokens 时裁剪(最多为上下文 {window} 的 20%)", autoTrim: "自动裁剪", debug: "调试", dCalls: "调用", dRequests: "请求", dEvents: "事件", dContext: "上下文", dTools: "工具", dClear: "清空记录", dFilter: "按类型过滤",
|
|
88
88
|
dNoCalls: "还没有工具调用。", dNoRequests: "还没有模型请求。每次调用模型都会记在这里,包括发了什么、收到什么。", dNoEvents: "还没有事件。",
|
|
89
|
-
dSystem: "系统提示词", dMessages: "发给模型的消息", dPayload: "请求内容", dResponse: "响应", dRun: "运行", dTurn: "第 {n} 轮", sent: "已发送", justNow: "刚刚", minutesAgo: "{n} 分钟前", hoursAgo: "{n} 小时前", context: "上下文", copy: "复制", copied: "已复制", rewind: "回退到这里", rewindTitle: "回退到这条消息", regen: "重新回答", regenTitle: "重新回答这个问题", regenMsg: "这个回答及之后的对话会被删除,问题重新发送。", delTurn: "删除", delTurnTitle: "删除这一轮问答?", delTurnMsg: "这条提问和它的回答会从对话中删除,文件不受影响。", replyCost: "费用:{cost}", replyUsage: "输入 {in} · 输出 {out} · {calls} 次调用",
|
|
89
|
+
dSystem: "系统提示词", dMessages: "发给模型的消息", dPayload: "请求内容", dResponse: "响应", dRun: "运行", dTurn: "第 {n} 轮", sent: "已发送", justNow: "刚刚", minutesAgo: "{n} 分钟前", hoursAgo: "{n} 小时前", context: "上下文", copy: "复制", copied: "已复制", rewind: "回退到这里", rewindTitle: "回退到这条消息", regen: "重新回答", regenTitle: "重新回答这个问题", regenMsg: "这个回答及之后的对话会被删除,问题重新发送。", delTurn: "删除", delTurnTitle: "删除这一轮问答?", delTurnMsg: "这条提问和它的回答会从对话中删除,文件不受影响。", replyCost: "费用:{cost}", replyUsage: "输入 {in} · 输出 {out} · {calls} 次调用", replyCache: "缓存命中 {p}%", replyCached: "(其中缓存 {n})",
|
|
90
90
|
older: "加载更早的消息", olderBusy: "等这次回复结束后再加载更早的消息。",
|
|
91
91
|
rewindMsg: "它之后的对话会被删除,消息内容放回输入框。", rewindFiles: "同时把目录里的文件恢复到那一刻", rewindGone: "这条消息已不在对话里(可能已被压缩)。", rewindSnapshot: "{time} 时的 {n} 个文件({size})", rewindPartial: "超过 2 MB 的文件没进快照,会保持原样。", rewindGoneFile: "{path} 已不在目录里。",
|
|
92
92
|
running: "运行中", waitingAnswer: "等待你回答", finished: "已完成", bgLimit: "后台已有 {n} 个会话在运行,先停掉一个再切换。",
|
|
@@ -2183,7 +2183,10 @@ export function renderChat(target, opts) {
|
|
|
2183
2183
|
foot.append(copy, ...(replyActions?.retry === false ? [] : [again]), ...(replyActions?.delete === false ? [] : [del]));
|
|
2184
2184
|
const u = last.runUsage;
|
|
2185
2185
|
if (u && u.calls) {
|
|
2186
|
-
|
|
2186
|
+
// The share of the input read from the provider's prompt cache, on the line itself: it is most of what decides the cost.
|
|
2187
|
+
const cached = u.cached_tokens ?? 0;
|
|
2188
|
+
const hit = cached > 0 && u.prompt_tokens > 0 ? " · " + t.replyCache.replace("{p}", String(Math.round((cached / u.prompt_tokens) * 100))) : "";
|
|
2189
|
+
const show = (currency) => { cost.textContent = t.replyCost.replace("{cost}", fmtCost(u.total_cost, currency)) + hit; };
|
|
2187
2190
|
const cost = h("span", "ra-cost");
|
|
2188
2191
|
show(costCurrency);
|
|
2189
2192
|
// In the model's currency: asked of its catalogue entry when not known yet.
|
|
@@ -2191,7 +2194,7 @@ export function renderChat(target, opts) {
|
|
|
2191
2194
|
if (costCurrency === undefined && a)
|
|
2192
2195
|
void a.modelInfo().then((info) => { if (info?.price?.currency)
|
|
2193
2196
|
show(info.price.currency); }).catch(() => undefined);
|
|
2194
|
-
cost.title = t.replyUsage.replace("{in}", fmtTokens(u.prompt_tokens)).replace("{out}", fmtTokens(u.completion_tokens)).replace("{calls}", String(u.calls));
|
|
2197
|
+
cost.title = t.replyUsage.replace("{in}", fmtTokens(u.prompt_tokens) + (cached > 0 ? t.replyCached.replace("{n}", fmtTokens(cached)) : "")).replace("{out}", fmtTokens(u.completion_tokens)).replace("{calls}", String(u.calls));
|
|
2195
2198
|
foot.append(cost);
|
|
2196
2199
|
}
|
|
2197
2200
|
return foot;
|
package/dist/index.cjs
CHANGED
|
@@ -4968,7 +4968,8 @@ Fix the call and try again.`);
|
|
|
4968
4968
|
total_cost: round(u.total_cost - before.total_cost),
|
|
4969
4969
|
prompt_tokens: u.prompt_tokens - before.prompt_tokens,
|
|
4970
4970
|
completion_tokens: u.completion_tokens - before.completion_tokens,
|
|
4971
|
-
calls: u.calls - before.calls
|
|
4971
|
+
calls: u.calls - before.calls,
|
|
4972
|
+
...(u.cached_tokens ?? 0) > (before.cached_tokens ?? 0) ? { cached_tokens: (u.cached_tokens ?? 0) - (before.cached_tokens ?? 0) } : {}
|
|
4972
4973
|
};
|
|
4973
4974
|
return;
|
|
4974
4975
|
}
|
|
@@ -4981,6 +4982,8 @@ Fix the call and try again.`);
|
|
|
4981
4982
|
this._usage.total_cost = round(this._usage.total_cost + (u.total_cost ?? 0));
|
|
4982
4983
|
this._usage.prompt_tokens += u.prompt_tokens ?? 0;
|
|
4983
4984
|
this._usage.completion_tokens += u.completion_tokens ?? 0;
|
|
4985
|
+
const cached = u.prompt_tokens_details?.cached_tokens ?? 0;
|
|
4986
|
+
if (cached > 0) this._usage.cached_tokens = (this._usage.cached_tokens ?? 0) + cached;
|
|
4984
4987
|
this._usage.calls++;
|
|
4985
4988
|
}
|
|
4986
4989
|
/** How full the model's context is: tokens the next call would send (estimated) against the window. */
|
package/dist/llm.d.ts
CHANGED
|
@@ -59,6 +59,10 @@ export interface Usage {
|
|
|
59
59
|
prompt_tokens?: number;
|
|
60
60
|
completion_tokens?: number;
|
|
61
61
|
total_tokens?: number;
|
|
62
|
+
/** cached_tokens: the part of prompt_tokens the provider read from its prompt cache. */
|
|
63
|
+
prompt_tokens_details?: {
|
|
64
|
+
cached_tokens?: number;
|
|
65
|
+
};
|
|
62
66
|
/** What the call cost in USD, when the provider says (RunApps does). */
|
|
63
67
|
total_cost?: number;
|
|
64
68
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -344,6 +344,8 @@ export interface AgentUsage {
|
|
|
344
344
|
completion_tokens: number;
|
|
345
345
|
/** Model calls made (turns), including retries that returned usage. */
|
|
346
346
|
calls: number;
|
|
347
|
+
/** Of prompt_tokens, those the provider read from its prompt cache (usage.prompt_tokens_details.cached_tokens), when it says. */
|
|
348
|
+
cached_tokens?: number;
|
|
347
349
|
}
|
|
348
350
|
export interface RunResult {
|
|
349
351
|
runId: string;
|
package/dist/ui.cjs
CHANGED
|
@@ -2709,6 +2709,8 @@ var STRINGS = {
|
|
|
2709
2709
|
delTurnMsg: "They are removed from the conversation; files stay as they are.",
|
|
2710
2710
|
replyCost: "Cost: {cost}",
|
|
2711
2711
|
replyUsage: "{in} in \xB7 {out} out \xB7 {calls} calls",
|
|
2712
|
+
replyCache: "cache hit {p}%",
|
|
2713
|
+
replyCached: " ({n} from cache)",
|
|
2712
2714
|
older: "Load earlier messages",
|
|
2713
2715
|
olderBusy: "Wait for the reply to finish, then load earlier messages.",
|
|
2714
2716
|
rewindMsg: "The conversation after it is dropped and the message goes back into the composer.",
|
|
@@ -3030,6 +3032,8 @@ var STRINGS = {
|
|
|
3030
3032
|
delTurnMsg: "\u8FD9\u6761\u63D0\u95EE\u548C\u5B83\u7684\u56DE\u7B54\u4F1A\u4ECE\u5BF9\u8BDD\u4E2D\u5220\u9664\uFF0C\u6587\u4EF6\u4E0D\u53D7\u5F71\u54CD\u3002",
|
|
3031
3033
|
replyCost: "\u8D39\u7528\uFF1A{cost}",
|
|
3032
3034
|
replyUsage: "\u8F93\u5165 {in} \xB7 \u8F93\u51FA {out} \xB7 {calls} \u6B21\u8C03\u7528",
|
|
3035
|
+
replyCache: "\u7F13\u5B58\u547D\u4E2D {p}%",
|
|
3036
|
+
replyCached: "\uFF08\u5176\u4E2D\u7F13\u5B58 {n}\uFF09",
|
|
3033
3037
|
older: "\u52A0\u8F7D\u66F4\u65E9\u7684\u6D88\u606F",
|
|
3034
3038
|
olderBusy: "\u7B49\u8FD9\u6B21\u56DE\u590D\u7ED3\u675F\u540E\u518D\u52A0\u8F7D\u66F4\u65E9\u7684\u6D88\u606F\u3002",
|
|
3035
3039
|
rewindMsg: "\u5B83\u4E4B\u540E\u7684\u5BF9\u8BDD\u4F1A\u88AB\u5220\u9664\uFF0C\u6D88\u606F\u5185\u5BB9\u653E\u56DE\u8F93\u5165\u6846\u3002",
|
|
@@ -5091,8 +5095,10 @@ ${t.webHint}`;
|
|
|
5091
5095
|
foot.append(copy, ...replyActions?.retry === false ? [] : [again], ...replyActions?.delete === false ? [] : [del]);
|
|
5092
5096
|
const u = last.runUsage;
|
|
5093
5097
|
if (u && u.calls) {
|
|
5098
|
+
const cached = u.cached_tokens ?? 0;
|
|
5099
|
+
const hit = cached > 0 && u.prompt_tokens > 0 ? " \xB7 " + t.replyCache.replace("{p}", String(Math.round(cached / u.prompt_tokens * 100))) : "";
|
|
5094
5100
|
const show = (currency) => {
|
|
5095
|
-
cost.textContent = t.replyCost.replace("{cost}", fmtCost(u.total_cost, currency));
|
|
5101
|
+
cost.textContent = t.replyCost.replace("{cost}", fmtCost(u.total_cost, currency)) + hit;
|
|
5096
5102
|
};
|
|
5097
5103
|
const cost = h("span", "ra-cost");
|
|
5098
5104
|
show(costCurrency);
|
|
@@ -5100,7 +5106,7 @@ ${t.webHint}`;
|
|
|
5100
5106
|
if (costCurrency === void 0 && a) void a.modelInfo().then((info) => {
|
|
5101
5107
|
if (info?.price?.currency) show(info.price.currency);
|
|
5102
5108
|
}).catch(() => void 0);
|
|
5103
|
-
cost.title = t.replyUsage.replace("{in}", fmtTokens(u.prompt_tokens)).replace("{out}", fmtTokens(u.completion_tokens)).replace("{calls}", String(u.calls));
|
|
5109
|
+
cost.title = t.replyUsage.replace("{in}", fmtTokens(u.prompt_tokens) + (cached > 0 ? t.replyCached.replace("{n}", fmtTokens(cached)) : "")).replace("{out}", fmtTokens(u.completion_tokens)).replace("{calls}", String(u.calls));
|
|
5104
5110
|
foot.append(cost);
|
|
5105
5111
|
}
|
|
5106
5112
|
return foot;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runappsai/agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Agent harness: the model ↔ tool loop with a workspace, skills, sessions, compaction, a sandbox and a chat UI. Bring any OpenAI-compatible model provider (RunApps included); no runtime dependencies.",
|
|
6
6
|
"license": "MIT",
|