teapot-coding-agent 0.37.185 → 0.37.187
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/agent.js +45 -12
- package/dist/agent/context-claim.js +19 -14
- package/dist/agent/mcp-registry.js +20 -0
- package/dist/agent/tools.js +41 -16
- package/dist/master.js +12 -6
- package/package.json +1 -1
- package/public/assets/index-CmSKwzH6.js +190 -0
- package/public/assets/index-CmSKwzH6.js.map +1 -0
- package/public/assets/{index-CjTazvlX.css → index-DtDAZT7V.css} +1 -1
- package/public/index.html +2 -2
- package/public/assets/index-BNc107Tr.js +0 -190
- package/public/assets/index-BNc107Tr.js.map +0 -1
package/dist/agent/agent.js
CHANGED
|
@@ -1125,23 +1125,56 @@ export class Agent {
|
|
|
1125
1125
|
this.bgExits = [];
|
|
1126
1126
|
}
|
|
1127
1127
|
}
|
|
1128
|
+
/**
|
|
1129
|
+
* goal.md is `body` + a metadata block, and the block is found by POSITION-INDEPENDENT parsing.
|
|
1130
|
+
*
|
|
1131
|
+
* The reader used to strip `status:`/`updated:` only when they sat at the very END. The writer appends `verify:` AFTER
|
|
1132
|
+
* them, so on any goal with a verification contract the strip loop could not remove anything and the metadata lines
|
|
1133
|
+
* became part of the goal TEXT — reported as "セッションリストアするとgoalが汚染される" with a goal that ended in
|
|
1134
|
+
* `status: paused / updated: …` (#253).
|
|
1135
|
+
*
|
|
1136
|
+
* The block is the LAST run of metadata lines in the file: find the last `status:` line and keep it only if everything
|
|
1137
|
+
* after it is metadata (`updated:`, `verify:` and the contract's own lines). A goal whose prose mentions "status:" stays
|
|
1138
|
+
* intact, because prose is not followed by an `updated:` line.
|
|
1139
|
+
*/
|
|
1128
1140
|
parseGoalFile(text) {
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1141
|
+
const lines = text.replace(/\r\n/g, "\n").split("\n");
|
|
1142
|
+
let blockAt = -1;
|
|
1143
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
1144
|
+
if (/^status:\s*\w+\s*$/i.test(lines[i])) {
|
|
1145
|
+
// everything below must be metadata, or this "status:" belongs to the prose
|
|
1146
|
+
let ok = true;
|
|
1147
|
+
let inVerify = false;
|
|
1148
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
1149
|
+
const l = lines[j];
|
|
1150
|
+
if (!l.trim())
|
|
1151
|
+
continue;
|
|
1152
|
+
if (/^verify:/i.test(l)) {
|
|
1153
|
+
inVerify = true; // the contract's own lines are arbitrary text
|
|
1154
|
+
continue;
|
|
1155
|
+
}
|
|
1156
|
+
if (inVerify)
|
|
1157
|
+
continue;
|
|
1158
|
+
if (/^(updated|status):/i.test(l))
|
|
1159
|
+
continue;
|
|
1160
|
+
ok = false;
|
|
1161
|
+
break;
|
|
1162
|
+
}
|
|
1163
|
+
if (ok)
|
|
1164
|
+
blockAt = i;
|
|
1136
1165
|
break;
|
|
1137
|
-
|
|
1166
|
+
}
|
|
1138
1167
|
}
|
|
1168
|
+
const bodyLines = blockAt === -1 ? lines : lines.slice(0, blockAt);
|
|
1169
|
+
const meta = blockAt === -1 ? [] : lines.slice(blockAt);
|
|
1170
|
+
const metaText = meta.join("\n");
|
|
1171
|
+
const statusWord = /status:\s*(\w+)/i.exec(metaText)?.[1]?.toLowerCase();
|
|
1172
|
+
const status = statusWord === "done" ? "done" : statusWord === "paused" ? "paused" : "active";
|
|
1173
|
+
let body = bodyLines.join("\n").trimEnd();
|
|
1139
1174
|
let verify = "";
|
|
1140
|
-
const vm =
|
|
1141
|
-
if (vm)
|
|
1175
|
+
const vm = /\nverify:\s*\n([\s\S]+)$/i.exec(metaText) ?? /^verify:\s*(.+)$/im.exec(metaText);
|
|
1176
|
+
if (vm)
|
|
1142
1177
|
verify = vm[1].trim();
|
|
1143
|
-
body = (body.slice(0, vm.index).trimEnd());
|
|
1144
|
-
}
|
|
1145
1178
|
const out = { text: body, status, updatedAt: new Date().toISOString() };
|
|
1146
1179
|
if (verify)
|
|
1147
1180
|
out.verify = verify;
|
|
@@ -116,27 +116,32 @@ export function claimsContextLimit(text) {
|
|
|
116
116
|
export function usageLine(used, budget, window) {
|
|
117
117
|
const fmt = (n) => (n >= 1_000 ? `${Math.round(n / 1_000)}k` : String(Math.max(0, Math.round(n))));
|
|
118
118
|
/**
|
|
119
|
-
*
|
|
119
|
+
* EVERY number, named once.
|
|
120
120
|
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* "
|
|
121
|
+
* The line used to mix two denominators without naming either: the percentage was of the WINDOW while "until
|
|
122
|
+
* auto-compaction" was measured from the BUDGET (the compaction threshold). A model reading
|
|
123
|
+
* "context 1% used (15k/1000k tokens, 735k until compaction)" had three different numbers in front of it and concluded it
|
|
124
|
+
* could not tell what they meant — "compact後のコンテキストウィンドウ残量報告が間違っている?" (#249). So the line states the
|
|
125
|
+
* percentage with its window, the threshold as its own figure, and the room left before that threshold:
|
|
124
126
|
*
|
|
125
|
-
* context
|
|
126
|
-
|
|
127
|
-
* When the window is unknown the budget is the only denominator
|
|
128
|
-
* window entirely rather than pretending they are the same thing.
|
|
127
|
+
* context 1% used (15k/1000k tokens) · auto-compacts at 750k · 735k until auto-compaction
|
|
128
|
+
*
|
|
129
|
+
* When the window is unknown the budget is the only denominator there is, and the line says so rather than pretending.
|
|
129
130
|
*/
|
|
130
131
|
const full = Number.isFinite(window) && (window ?? 0) > 0 ? window : 0;
|
|
131
|
-
const
|
|
132
|
+
const hasBudget = Number.isFinite(budget) && budget > 0;
|
|
133
|
+
const denom = full || (hasBudget ? budget : 0);
|
|
132
134
|
if (!denom)
|
|
133
135
|
return `context ${fmt(used)} tokens used`;
|
|
134
136
|
const pct = Math.max(0, Math.min(100, Math.round((used / denom) * 100)));
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
const size = full
|
|
138
|
+
? `${fmt(used)}/${fmt(full)} tokens`
|
|
139
|
+
: `${fmt(used)}/${fmt(budget)} tokens — the compaction threshold; full window unknown`;
|
|
140
|
+
if (!hasBudget)
|
|
141
|
+
return `context ${pct}% used (${size})`;
|
|
142
|
+
const until = Math.max(0, budget - used);
|
|
143
|
+
const threshold = full ? ` · auto-compacts at ${fmt(budget)}` : "";
|
|
144
|
+
return `context ${pct}% used (${size})${threshold} · ${fmt(until)} until auto-compaction`;
|
|
140
145
|
}
|
|
141
146
|
/**
|
|
142
147
|
* …and the OTHER thing that gets reported as "context is exhausted": the model has run out of its own ideas.
|
|
@@ -19,10 +19,27 @@ export class McpRegistry {
|
|
|
19
19
|
auths = new Map();
|
|
20
20
|
store = null;
|
|
21
21
|
flows = new Map();
|
|
22
|
+
/**
|
|
23
|
+
* A counter that changes whenever the tool set can have changed.
|
|
24
|
+
*
|
|
25
|
+
* The deferred catalogue (`search_tools`/`run_tool`) is cached per ToolContext, and a cache keyed only by that context
|
|
26
|
+
* cannot see the registry change underneath it: after re-authorising a server the tools were populated here but
|
|
27
|
+
* `search_tools` kept serving the catalogue built before the grant — "MCP再認証してもsearch_toolsで出てこない、叩けない"
|
|
28
|
+
* (#243). A version is the smallest thing the cache can compare.
|
|
29
|
+
*/
|
|
30
|
+
version = 0;
|
|
31
|
+
/** the current tool-set version; see `version` */
|
|
32
|
+
stateVersion() {
|
|
33
|
+
return this.version;
|
|
34
|
+
}
|
|
35
|
+
bump() {
|
|
36
|
+
this.version++;
|
|
37
|
+
}
|
|
22
38
|
init(dataDir) {
|
|
23
39
|
this.store = new McpAuthStore(dataDir);
|
|
24
40
|
}
|
|
25
41
|
apply(configs) {
|
|
42
|
+
this.bump();
|
|
26
43
|
const wanted = new Set(configs.map((c) => c.name));
|
|
27
44
|
for (const [name, st] of this.servers) {
|
|
28
45
|
if (!wanted.has(name)) {
|
|
@@ -59,6 +76,7 @@ export class McpRegistry {
|
|
|
59
76
|
return this.servers.get(name);
|
|
60
77
|
}
|
|
61
78
|
recordSuccess(name, tools) {
|
|
79
|
+
this.bump();
|
|
62
80
|
const st = this.servers.get(name);
|
|
63
81
|
if (!st)
|
|
64
82
|
return;
|
|
@@ -226,6 +244,7 @@ export class McpRegistry {
|
|
|
226
244
|
const conn = await connectMcp(st.config, { provider: auth });
|
|
227
245
|
st.connection = conn;
|
|
228
246
|
st.tools = await conn.tools();
|
|
247
|
+
this.bump();
|
|
229
248
|
st.status = "connected";
|
|
230
249
|
st.oauthRequired = false;
|
|
231
250
|
await this.finishFlow(name, pending);
|
|
@@ -251,6 +270,7 @@ export class McpRegistry {
|
|
|
251
270
|
await conn.close().catch(() => { });
|
|
252
271
|
st.connection = live;
|
|
253
272
|
st.tools = await live.tools();
|
|
273
|
+
this.bump();
|
|
254
274
|
st.status = "connected";
|
|
255
275
|
st.oauthRequired = false;
|
|
256
276
|
st.lastError = undefined;
|
package/dist/agent/tools.js
CHANGED
|
@@ -1502,10 +1502,34 @@ export const TOOLS = [
|
|
|
1502
1502
|
async run(args, ctx) {
|
|
1503
1503
|
if (args.background === true) {
|
|
1504
1504
|
const id = startBackgroundShell(str(args.command), ctx);
|
|
1505
|
+
/**
|
|
1506
|
+
* The result has to say two things the model kept getting wrong (#231, #235).
|
|
1507
|
+
*
|
|
1508
|
+
* - "you are woken when it exits" was already there, but models still polled or kept busy-working while a long
|
|
1509
|
+
* build ran ("モデルがバックエンドbashを待つために止まるってことを知らない / ポーリングしたり、余計な作業をし続けたり").
|
|
1510
|
+
* So the WAKE is stated as an instruction: stopping the round is how you wait, and you do not need to poll.
|
|
1511
|
+
* - and it lists the other jobs still running, because a model that starts three builds forgets the first two
|
|
1512
|
+
* ("そうじゃないと起動したこと忘れるモデルがある").
|
|
1513
|
+
*/
|
|
1514
|
+
const running = [...bgMapFor(ctx.cwd).values()].filter((j) => !j.exited);
|
|
1515
|
+
const others = running.filter((j) => j.id !== id);
|
|
1516
|
+
const list = running
|
|
1517
|
+
.map((j) => {
|
|
1518
|
+
const secs = Math.round((Date.now() - j.startedAt) / 1000);
|
|
1519
|
+
const when = secs >= 60 ? `${Math.round(secs / 60)}m` : `${secs}s`;
|
|
1520
|
+
const cmd = j.cmd.replace(/\s+/g, " ").slice(0, 90);
|
|
1521
|
+
return ` ${j.id}${j.id === id ? " (just started)" : ""} · ${when} · ${cmd}`;
|
|
1522
|
+
})
|
|
1523
|
+
.join("\n");
|
|
1505
1524
|
return {
|
|
1506
1525
|
ok: true,
|
|
1507
|
-
result: `started in background (job ${id})
|
|
1508
|
-
`
|
|
1526
|
+
result: `started in background (job ${id}). ` +
|
|
1527
|
+
`You are WOKEN when it exits (exit code + output tail), so waiting is not your job: do not poll it, do not ` +
|
|
1528
|
+
`sleep, and do not start another round just to check — end your turn (or do other work) and the harness will ` +
|
|
1529
|
+
`call you when it finishes.\n` +
|
|
1530
|
+
`Output mid-run: bash_output(job_id="${id}"). Stop: bash_output(job_id="${id}", action="kill").\n` +
|
|
1531
|
+
`running background jobs for this workspace (${running.length}):\n${list}` +
|
|
1532
|
+
(others.length ? `\nDo not start a duplicate of a job that is already here.` : ""),
|
|
1509
1533
|
};
|
|
1510
1534
|
}
|
|
1511
1535
|
const explicit = args.timeout_ms !== undefined && args.timeout_ms !== null;
|
|
@@ -2212,20 +2236,21 @@ export function repairToolInput(name, rawArgs) {
|
|
|
2212
2236
|
*/
|
|
2213
2237
|
const catalogs = new WeakMap();
|
|
2214
2238
|
function catalogFor(ctx) {
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
}
|
|
2239
|
+
const version = mcp.stateVersion();
|
|
2240
|
+
const hit = catalogs.get(ctx);
|
|
2241
|
+
if (hit && hit.version === version)
|
|
2242
|
+
return hit.catalog;
|
|
2243
|
+
const c = createCatalog(mcp.states().map((st) => ({
|
|
2244
|
+
id: st.config.name,
|
|
2245
|
+
name: st.config.name,
|
|
2246
|
+
description: st.config.description,
|
|
2247
|
+
enabled: st.status !== "disabled",
|
|
2248
|
+
status: st.status,
|
|
2249
|
+
tools: st.tools ?? [],
|
|
2250
|
+
})),
|
|
2251
|
+
// the built-ins are already in the request, so the catalog must know how much room is left
|
|
2252
|
+
{ builtInCount: TOOLS.length });
|
|
2253
|
+
catalogs.set(ctx, { version, catalog: c });
|
|
2229
2254
|
return c;
|
|
2230
2255
|
}
|
|
2231
2256
|
/** called at a turn boundary so each turn starts with nothing discovered */
|
package/dist/master.js
CHANGED
|
@@ -750,13 +750,19 @@ export class Master {
|
|
|
750
750
|
if (!parent)
|
|
751
751
|
return;
|
|
752
752
|
this.wakeAncestorWaiters(ac.parent);
|
|
753
|
-
|
|
753
|
+
/**
|
|
754
|
+
* An `error` child is NOT announced twice.
|
|
755
|
+
*
|
|
756
|
+
* The child's own `error` event already reaches the parent as "Sub-agent X hit an error: …" (see `onChildEvent`),
|
|
757
|
+
* so the generic "settled without having called finish()" note only repeated it with weaker wording — reported as
|
|
758
|
+
* "サブエージェントがエラー落ちしたときの親への通知がびみょい" (#245). The generic note exists for statuses that have
|
|
759
|
+
* no event of their own (`idle`, `stopped`, `waiting`).
|
|
760
|
+
*/
|
|
761
|
+
if (this.reportedRunning.has(agentId) && SETTLED.has(status) && status !== "error")
|
|
754
762
|
parent.enqueuePrompt(`[harness] Sub-agent @${agentId} is now ${status} without having called finish(), so it has not reported a result.` +
|
|
755
|
-
(status === "
|
|
756
|
-
? `
|
|
757
|
-
:
|
|
758
|
-
? ` It may have been stopped mid-task; message it to resume, or re-spawn it.`
|
|
759
|
-
: ` If you expected a result, message it or re-spawn it.`), "harness");
|
|
763
|
+
(status === "stopped"
|
|
764
|
+
? ` It may have been stopped mid-task; message it to resume, or re-spawn it.`
|
|
765
|
+
: ` If you expected a result, message it or re-spawn it.`), "harness");
|
|
760
766
|
if (status === "running")
|
|
761
767
|
this.reportedRunning.add(agentId);
|
|
762
768
|
else if (SETTLED.has(status))
|