replicas-engine 0.1.1657 → 0.1.1659
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/src/{asp-host-FQPUDYMI.js → asp-host-IZ7MK34S.js} +5 -5
- package/dist/src/{chunk-2VDQA473.js → chunk-DJ65VX3O.js} +2 -2
- package/dist/src/{chunk-PMQVLR64.js → chunk-HVQJJ3DD.js} +2 -2
- package/dist/src/{chunk-UKEZJE34.js → chunk-LZEHZPZC.js} +1 -1
- package/dist/src/{chunk-YLKNOKME.js → chunk-M3TLTCVX.js} +7 -6
- package/dist/src/{chunk-7UBUKFDR.js → chunk-MWWCGFYT.js} +1 -1
- package/dist/src/{chunk-6CYVRLIO.js → chunk-SN5ADKDL.js} +3 -3
- package/dist/src/{chunk-43SFZW43.js → chunk-WGGB32TH.js} +2 -2
- package/dist/src/{chunk-MGHRWQZQ.js → chunk-X3W2J7N3.js} +6 -6
- package/dist/src/command-protection-hook.js +4 -4
- package/dist/src/headless-agent.js +4 -4
- package/dist/src/index.js +41 -10
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/subagent-mcp.js +1 -1
- package/package.json +1 -1
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
listCodexModelsForDetails,
|
|
9
9
|
restartCodexAspHost,
|
|
10
10
|
restartCodexAspHostIfRunning
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-X3W2J7N3.js";
|
|
12
|
+
import "./chunk-HVQJJ3DD.js";
|
|
13
|
+
import "./chunk-SN5ADKDL.js";
|
|
14
|
+
import "./chunk-LZEHZPZC.js";
|
|
15
15
|
import "./chunk-UZSNFLDQ.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-M3TLTCVX.js";
|
|
17
17
|
import "./chunk-VEQXQN22.js";
|
|
18
18
|
export {
|
|
19
19
|
CODEX_ULTRAFAST_SERVICE_TIER,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ENGINE_ENV,
|
|
6
6
|
monolithRequest,
|
|
7
7
|
runGitCommand
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-HVQJJ3DD.js";
|
|
9
9
|
import {
|
|
10
10
|
COMMAND_PROTECTION_MAX_MESSAGE_FILE_BYTES,
|
|
11
11
|
COMMAND_PROTECTION_REPO_GIT_ARGS,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
parseCommandProtectionRequest,
|
|
19
19
|
toCommandProtectionRepoState,
|
|
20
20
|
withRetry
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-M3TLTCVX.js";
|
|
22
22
|
|
|
23
23
|
// src/services/command-protection-service.ts
|
|
24
24
|
import { readFile, stat } from "fs/promises";
|
|
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
SUBPROCESS_MAX_BUFFER,
|
|
6
6
|
execFileAsync
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LZEHZPZC.js";
|
|
8
8
|
import {
|
|
9
9
|
isRecord as isRecord2
|
|
10
10
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
provisionedDeviceSchema,
|
|
22
22
|
readReplicasRuntimeEnv,
|
|
23
23
|
serializePosixEnvFile
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-M3TLTCVX.js";
|
|
25
25
|
|
|
26
26
|
// src/runtime-env-loader.ts
|
|
27
27
|
import { readFileSync } from "fs";
|
|
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
HOOK_EXEC_MAX_BUFFER_BYTES
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-M3TLTCVX.js";
|
|
7
7
|
|
|
8
8
|
// src/utils/exec.ts
|
|
9
9
|
import { exec, execFile } from "child_process";
|
|
@@ -16060,14 +16060,13 @@ function stripAgentInstructionBlocks(text4) {
|
|
|
16060
16060
|
}
|
|
16061
16061
|
var MANAGER_EVENT_CHAT_NOTE = `If a message the user typed in this turn is still unanswered, your final reply answers it and they see it. Otherwise they don't see text you write in this turn: if it brings something they asked for, or a blocker that needs them, send it with ${REPLICAS_MCP_TOOLS.sendToChat}; then update the board if its order, notes or overview changed, and end with a one-line note.`;
|
|
16062
16062
|
var BOARD_ANSWER_NOTE = "The user answered on the board.";
|
|
16063
|
-
var BOARD_RULES = `- The board in the Ships pane beside this chat is the user's one view of the work
|
|
16064
|
-
-
|
|
16065
|
-
- You keep the board organized with \`${REPLICAS_MCP_TOOLS.updateBoard}\`: the order of tickets, most important first; one short note per ticket when it adds something the ticket doesn't say, such as "Merge after #12" or "Waiting on REP-40"; and one overview line at the top on where the work as a whole stands. Archive tickets the user no longer needs. When a ship continues another ship's task, pass that ticket's id as \`ticket\` to \`${REPLICAS_MCP_TOOLS.spawnSubagent}\` instead of making a new one.
|
|
16063
|
+
var BOARD_RULES = `- The board in the Ships pane beside this chat is the user's one view of the work: one ticket per task they ask for, holding only that task's pull requests. Replicas fills in each ticket's title, summaries, section and pull requests from the task, the ship's reports and its pull requests, so never restate what a ticket shows, and correct one with \`${REPLICAS_MCP_TOOLS.updateBoard}\` only when it's wrong.
|
|
16064
|
+
- Keep the board organized with \`${REPLICAS_MCP_TOOLS.updateBoard}\`: tickets in order, most important first; one short note per ticket only when it adds something, such as "Merge after #12"; and one overview line on where the work as a whole stands. Archive tickets the user no longer needs.
|
|
16066
16065
|
- Ask the user only for decisions you truly can't make. Make routine calls yourself, such as retries, small scope choices or test cleanup. For a question of your own, create a ticket with it; the user's answer comes to you here, marked "${BOARD_ANSWER_NOTE}". Answers to a ship's questions go straight to that ship.
|
|
16067
16066
|
- A ship with open pull requests is not done when it sends \`finished\`: Replicas fixes their CI failures and review comments automatically, then sends \`ready\` or \`needs_attention\`. On \`needs_attention\`, direct the ship, or ask the user only if you can't decide.
|
|
16068
16067
|
- When a pull request should merge once it's approved and CI passes, call \`${REPLICAS_MCP_TOOLS.mergeWhenReady}\`: Replicas merges it and sends \`merged\`, or \`needs_attention\` saying why it can't. Never watch CI or pull requests with \`gh\`, sleep loops or wait scripts, and merge one yourself only when the user wants it merged right away.
|
|
16069
|
-
- On every ship event and
|
|
16070
|
-
- The chat is like texting an assistant. In a turn the user typed, they see the text you write between tool calls as it streams, your final reply, what you send with \`${REPLICAS_MCP_TOOLS.sendToChat}\`, and your \`${REPLICAS_MCP_TOOLS.setStatus}\` line, never your tool calls. Unless you can answer right away, open with one line on what you'll do first and roughly how long it takes. Then call \`${REPLICAS_MCP_TOOLS.setStatus}\` with a few words on your current step, such as "Reading the billing webhook"
|
|
16068
|
+
- On every ship event and board answer, act with tools on whatever it unblocks, such as starting the next task once a pull request merges, and update the board if it changed. The user sees nothing you write in these turns unless a message they typed is still unanswered; otherwise reach them only with \`${REPLICAS_MCP_TOOLS.sendToChat}\`, and only for what they'd want right now: a deliverable they asked for, with its media, links or answer; a blocker that needs them, also on the board; or a request of theirs being done. Never for status, such as "PR #12 merged" or "I asked the ship to\u2026". End the turn with a one-line note of what you did.
|
|
16069
|
+
- The chat is like texting an assistant. In a turn the user typed, they see the text you write between tool calls as it streams, your final reply, what you send with \`${REPLICAS_MCP_TOOLS.sendToChat}\`, and your \`${REPLICAS_MCP_TOOLS.setStatus}\` line, never your tool calls. Unless you can answer right away, open with one line on what you'll do first and roughly how long it takes. Then call \`${REPLICAS_MCP_TOOLS.setStatus}\` with a few words on your current step, such as "Reading the billing webhook", and again each time you move to a new step. Before your final reply, write only what they'd want to know now: a finding that changes the answer, a ship you started, or a decision you need. Never narrate tool calls or say you're still working. When they message you mid-turn, reply in one line before anything else, then fold it into your work. Write in a line or two with links and any media inline, and never restate the board in chat.
|
|
16071
16070
|
`;
|
|
16072
16071
|
function splitTaggedBlock(text4, tag) {
|
|
16073
16072
|
const match = text4?.match(new RegExp(`\\s*<${tag}>\\n([\\s\\S]*?)\\n</${tag}>`));
|
|
@@ -21194,7 +21193,7 @@ async function withRetry(label, fn, options) {
|
|
|
21194
21193
|
}
|
|
21195
21194
|
|
|
21196
21195
|
// ../shared/src/tensorlake.ts
|
|
21197
|
-
var TENSORLAKE_IMAGE_NAME = "replicas-sandbox-2026-11-
|
|
21196
|
+
var TENSORLAKE_IMAGE_NAME = "replicas-sandbox-2026-11-20-v4";
|
|
21198
21197
|
var TENSORLAKE_DISK_MB = 100 * 1024;
|
|
21199
21198
|
|
|
21200
21199
|
// ../shared/src/egress.ts
|
|
@@ -22589,6 +22588,7 @@ var MAX_CLIENT_STATE_BYTES_PER_USER = 10 * 1024 * 1024;
|
|
|
22589
22588
|
var WORKSPACE_LAST_VIEWED_AT_CLIENT_STATE_KEY_PREFIX = "replicas-workspace-last-viewed-at-";
|
|
22590
22589
|
var WORKSPACE_ATTENTION_DONE_CLIENT_STATE_KEY_PREFIX = "replicas-workspace-attention-done-";
|
|
22591
22590
|
var WORKSPACE_SECTION_ORDER_CLIENT_STATE_KEY_PREFIX = "replicas-workspace-section-order-";
|
|
22591
|
+
var WORKSPACE_SHIP_ORDER_CLIENT_STATE_KEY_PREFIX = "replicas-workspace-ship-order-";
|
|
22592
22592
|
var WORKSPACE_STAGES_CLIENT_STATE_KEY_PREFIX = "replicas-workspace-stages-";
|
|
22593
22593
|
var WORKSPACE_MARKED_UNREAD_CLIENT_STATE_KEY_PREFIX = "replicas-workspace-marked-unread-";
|
|
22594
22594
|
var WORKSPACE_PINNED_CLIENT_STATE_KEY_PREFIX = "replicas-pinned-workspaces-";
|
|
@@ -22599,6 +22599,7 @@ var workspaceLastViewedAtClientStateKey = orgUserClientStateKey(WORKSPACE_LAST_V
|
|
|
22599
22599
|
var workspaceAttentionDoneClientStateKey = orgUserClientStateKey(WORKSPACE_ATTENTION_DONE_CLIENT_STATE_KEY_PREFIX);
|
|
22600
22600
|
var workspaceStagesClientStateKey = orgUserClientStateKey(WORKSPACE_STAGES_CLIENT_STATE_KEY_PREFIX);
|
|
22601
22601
|
var workspaceSectionOrderClientStateKey = orgUserClientStateKey(WORKSPACE_SECTION_ORDER_CLIENT_STATE_KEY_PREFIX);
|
|
22602
|
+
var workspaceShipOrderClientStateKey = orgUserClientStateKey(WORKSPACE_SHIP_ORDER_CLIENT_STATE_KEY_PREFIX);
|
|
22602
22603
|
var workspaceMarkedUnreadClientStateKey = orgUserClientStateKey(WORKSPACE_MARKED_UNREAD_CLIENT_STATE_KEY_PREFIX);
|
|
22603
22604
|
var workspacePinnedClientStateKey = orgUserClientStateKey(WORKSPACE_PINNED_CLIENT_STATE_KEY_PREFIX);
|
|
22604
22605
|
var promptHistoryClientStateKey = orgUserClientStateKey(PROMPT_HISTORY_CLIENT_STATE_KEY_PREFIX);
|
|
@@ -3,10 +3,10 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
execFileAsync
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LZEHZPZC.js";
|
|
7
7
|
import {
|
|
8
8
|
isVersionBelow
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-M3TLTCVX.js";
|
|
10
10
|
|
|
11
11
|
// src/utils/codex-agent-env.ts
|
|
12
12
|
function buildCodexAgentEnv(source = process.env) {
|
|
@@ -240,7 +240,7 @@ function getCodexModelProvider(method) {
|
|
|
240
240
|
if (method === "foundry") return "azure";
|
|
241
241
|
return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
|
|
242
242
|
}
|
|
243
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
243
|
+
var ENGINE_PACKAGE_VERSION = "0.1.1659";
|
|
244
244
|
var INITIALIZE_METHOD = "initialize";
|
|
245
245
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
246
246
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
AspClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SN5ADKDL.js";
|
|
7
7
|
import {
|
|
8
8
|
ASTER_BASE_URL,
|
|
9
9
|
ASTER_PROVIDER,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
isRecord,
|
|
16
16
|
readOllamaAuthEnv,
|
|
17
17
|
readOpenAICompatibleAuthEnv
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-M3TLTCVX.js";
|
|
19
19
|
|
|
20
20
|
// src/managers/codex-asp/notification-dispatch.ts
|
|
21
21
|
var TURN_STARTED_METHOD = "turn/started";
|
|
@@ -12,15 +12,15 @@ import {
|
|
|
12
12
|
resolveDiffBase,
|
|
13
13
|
runGitCommand,
|
|
14
14
|
setAgentCredentialSnapshot
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-HVQJJ3DD.js";
|
|
16
16
|
import {
|
|
17
17
|
AppServerProcess,
|
|
18
18
|
buildCodexAgentEnv
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-SN5ADKDL.js";
|
|
20
20
|
import {
|
|
21
21
|
SUBPROCESS_MAX_BUFFER,
|
|
22
22
|
execFileAsync
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-LZEHZPZC.js";
|
|
24
24
|
import {
|
|
25
25
|
isRecord
|
|
26
26
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
shrunkImageSize,
|
|
62
62
|
splitManagerInstructions,
|
|
63
63
|
withTimeout
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-M3TLTCVX.js";
|
|
65
65
|
|
|
66
66
|
// src/managers/codex-token-manager.ts
|
|
67
67
|
import { promises as fs } from "fs";
|
|
@@ -461,7 +461,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
461
461
|
await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
|
|
462
462
|
await this.applyCredentialsResponse(data);
|
|
463
463
|
setAgentCredentialSnapshot("codex", data);
|
|
464
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
464
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-IZ7MK34S.js");
|
|
465
465
|
await restartCodexAspHostIfRunning2();
|
|
466
466
|
});
|
|
467
467
|
await this.start(true);
|
|
@@ -483,7 +483,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
483
483
|
const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
|
|
484
484
|
await this.applyCredentialsResponse(data);
|
|
485
485
|
if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
|
|
486
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
486
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-IZ7MK34S.js");
|
|
487
487
|
await restartCodexAspHostIfRunning2();
|
|
488
488
|
}
|
|
489
489
|
setAgentCredentialSnapshot("codex", data);
|
|
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
evaluateCommandProtection
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-DJ65VX3O.js";
|
|
7
|
+
import "./chunk-HVQJJ3DD.js";
|
|
8
|
+
import "./chunk-LZEHZPZC.js";
|
|
9
9
|
import {
|
|
10
10
|
isRecord
|
|
11
11
|
} from "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-M3TLTCVX.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
|
|
15
15
|
// src/command-protection-hook.ts
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
recoverCompletedTurn,
|
|
15
15
|
spawnMuseMsp,
|
|
16
16
|
startMuseSession
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-WGGB32TH.js";
|
|
18
18
|
import {
|
|
19
19
|
AppServerProcess,
|
|
20
20
|
buildCodexAgentEnv
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
21
|
+
} from "./chunk-SN5ADKDL.js";
|
|
22
|
+
import "./chunk-LZEHZPZC.js";
|
|
23
23
|
import {
|
|
24
24
|
AGENT,
|
|
25
25
|
OPENCODE_GO_PROVIDER,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
headlessAgentUsagePath,
|
|
30
30
|
isRecord,
|
|
31
31
|
withTimeout
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-M3TLTCVX.js";
|
|
33
33
|
import "./chunk-VEQXQN22.js";
|
|
34
34
|
|
|
35
35
|
// src/headless-agent.ts
|
package/dist/src/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
evaluateCommandProtection,
|
|
92
92
|
extractToolCommand,
|
|
93
93
|
reportCommandProtectionBlock
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-DJ65VX3O.js";
|
|
95
95
|
import {
|
|
96
96
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
97
97
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -129,10 +129,10 @@ import {
|
|
|
129
129
|
spawnMuseMsp,
|
|
130
130
|
startMuseSession,
|
|
131
131
|
uuidV7
|
|
132
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-WGGB32TH.js";
|
|
133
133
|
import {
|
|
134
134
|
publishedPullRequestUrls
|
|
135
|
-
} from "./chunk-
|
|
135
|
+
} from "./chunk-MWWCGFYT.js";
|
|
136
136
|
import {
|
|
137
137
|
ACCOUNT_RATE_LIMITS_READ_METHOD,
|
|
138
138
|
AsyncLock,
|
|
@@ -212,7 +212,7 @@ import {
|
|
|
212
212
|
transcriptSecrets,
|
|
213
213
|
upsertCredentialFileLines,
|
|
214
214
|
writeSecureCredentialFile
|
|
215
|
-
} from "./chunk-
|
|
215
|
+
} from "./chunk-X3W2J7N3.js";
|
|
216
216
|
import {
|
|
217
217
|
ENGINE_ENV,
|
|
218
218
|
UNQUOTED_PATHS_CONFIG,
|
|
@@ -223,16 +223,16 @@ import {
|
|
|
223
223
|
resolveDiffBase,
|
|
224
224
|
setAgentCredentialSnapshot,
|
|
225
225
|
setLinearSessionId
|
|
226
|
-
} from "./chunk-
|
|
226
|
+
} from "./chunk-HVQJJ3DD.js";
|
|
227
227
|
import {
|
|
228
228
|
buildCodexAgentEnv,
|
|
229
229
|
getCodexModelProvider
|
|
230
|
-
} from "./chunk-
|
|
230
|
+
} from "./chunk-SN5ADKDL.js";
|
|
231
231
|
import {
|
|
232
232
|
SUBPROCESS_MAX_BUFFER,
|
|
233
233
|
execAsync,
|
|
234
234
|
execFileAsync
|
|
235
|
-
} from "./chunk-
|
|
235
|
+
} from "./chunk-LZEHZPZC.js";
|
|
236
236
|
import {
|
|
237
237
|
isRecord as isRecord2
|
|
238
238
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -531,7 +531,7 @@ import {
|
|
|
531
531
|
workspaceTokenRequestSchema,
|
|
532
532
|
workspaceTokenResponseSchema,
|
|
533
533
|
wrapInTag
|
|
534
|
-
} from "./chunk-
|
|
534
|
+
} from "./chunk-M3TLTCVX.js";
|
|
535
535
|
import {
|
|
536
536
|
__commonJS,
|
|
537
537
|
__export,
|
|
@@ -13500,6 +13500,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13500
13500
|
pendingBackgroundCompletion = false;
|
|
13501
13501
|
backgroundCompletionsInFlight = 0;
|
|
13502
13502
|
partialMessageStreams = /* @__PURE__ */ new Map();
|
|
13503
|
+
requestsInFlight = /* @__PURE__ */ new Map();
|
|
13503
13504
|
partialMessageFlushTimers = /* @__PURE__ */ new Map();
|
|
13504
13505
|
/** Active tool-input requests keyed by requestId; resolved when the user selects an option. */
|
|
13505
13506
|
pendingToolInputs = /* @__PURE__ */ new Map();
|
|
@@ -13545,6 +13546,11 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13545
13546
|
if (this.stopping === stopping) this.stopping = null;
|
|
13546
13547
|
});
|
|
13547
13548
|
}
|
|
13549
|
+
// A request cut before its stop reason never reaches Claude Code's totals, so it is counted from what it started with.
|
|
13550
|
+
countCutRequests() {
|
|
13551
|
+
for (const started of this.requestsInFlight.values()) this.onUsageUpdate(started, (/* @__PURE__ */ new Date()).toISOString());
|
|
13552
|
+
this.requestsInFlight.clear();
|
|
13553
|
+
}
|
|
13548
13554
|
// Stop can tear a session down before its command_lifecycle event is read, so the transcript decides.
|
|
13549
13555
|
async dropRecordedUnreadPrompt() {
|
|
13550
13556
|
const unread = this.unreadPrompt;
|
|
@@ -14483,6 +14489,12 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14483
14489
|
if (name && this.pendingInterrupt && block.is_error && extractToolResultText(block.content, "").startsWith(CLAUDE_STOPPED_TOOL_RESULT)) this.cutOffTools.set(block.tool_use_id, name);
|
|
14484
14490
|
}
|
|
14485
14491
|
}
|
|
14492
|
+
if (msg.type === "stream_event") {
|
|
14493
|
+
const key = this.partialMessageStreamKey(msg);
|
|
14494
|
+
if (msg.event.type === "message_start") this.requestsInFlight.set(key, msg.event.message);
|
|
14495
|
+
else if (msg.event.type === "message_delta" && msg.event.delta.stop_reason) this.requestsInFlight.delete(key);
|
|
14496
|
+
}
|
|
14497
|
+
if (msg.type === "result" && (msg.terminal_reason === "aborted_streaming" || msg.terminal_reason === "aborted_tools")) this.countCutRequests();
|
|
14486
14498
|
if (msg.type === "result" && msg.user_message_uuid) for (const uuid of msg.user_message_uuids ?? [msg.user_message_uuid]) this.endedReplies.add(uuid);
|
|
14487
14499
|
if (msg.type === "system" && msg.subtype === "status") this.compacting = msg.status === "compacting";
|
|
14488
14500
|
if (this.pendingInterrupt) {
|
|
@@ -14497,7 +14509,10 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14497
14509
|
return { ...block, text };
|
|
14498
14510
|
}).filter((block) => block.type !== "text" || block.text);
|
|
14499
14511
|
await this.recordEvent({ ...msg, message: { ...msg.message, content } });
|
|
14500
|
-
} else if (msg.type === "result")
|
|
14512
|
+
} else if (msg.type === "result") {
|
|
14513
|
+
this.onUsageUpdate(msg, (/* @__PURE__ */ new Date()).toISOString());
|
|
14514
|
+
this.stoppedTurnEnded?.resolve();
|
|
14515
|
+
}
|
|
14501
14516
|
continue;
|
|
14502
14517
|
}
|
|
14503
14518
|
if (this.cutSentAt && (msg.type === "result" ? msg.terminal_reason === "aborted_streaming" || msg.terminal_reason === "aborted_tools" : msg.type === "user" && msg.parent_tool_use_id === null && Array.isArray(msg.message.content) && msg.message.content.some((block) => block.type === "text" && INTERRUPTED_MESSAGE_REGEX.test(block.text)))) {
|
|
@@ -14647,6 +14662,7 @@ ${msg.result}` } : { ...msg, errors: [loginFailure, ...msg.errors] } : msg);
|
|
|
14647
14662
|
}
|
|
14648
14663
|
this.partialMessageFlushTimers.clear();
|
|
14649
14664
|
this.partialMessageStreams.clear();
|
|
14665
|
+
this.countCutRequests();
|
|
14650
14666
|
this.runningTools.clear();
|
|
14651
14667
|
this.pendingCut = null;
|
|
14652
14668
|
this.compacting = false;
|
|
@@ -60100,6 +60116,17 @@ function isClaudeModelUsage(value) {
|
|
|
60100
60116
|
if (!isRecord(value) || !isTokenUsageCounts(value)) return false;
|
|
60101
60117
|
return (value.costUsd === void 0 || typeof value.costUsd === "number" && Number.isFinite(value.costUsd) && value.costUsd >= 0) && (value.pricingProvider === void 0 || isNonEmptyString(value.pricingProvider));
|
|
60102
60118
|
}
|
|
60119
|
+
var withoutDate = (model) => model.replace(/-\d{8}$/, "");
|
|
60120
|
+
function parseClaudeRequestStart(payload) {
|
|
60121
|
+
if (!isRecord(payload) || payload.type !== "message" || !isNonEmptyString(payload.model) || !isRecord(payload.usage)) return null;
|
|
60122
|
+
const usage = {
|
|
60123
|
+
inputTokens: payload.usage.input_tokens,
|
|
60124
|
+
outputTokens: payload.usage.output_tokens,
|
|
60125
|
+
cacheReadInputTokens: payload.usage.cache_read_input_tokens ?? 0,
|
|
60126
|
+
cacheWriteInputTokens: payload.usage.cache_creation_input_tokens ?? 0
|
|
60127
|
+
};
|
|
60128
|
+
return isTokenUsageCounts(usage) ? { model: withoutDate(payload.model), usage } : null;
|
|
60129
|
+
}
|
|
60103
60130
|
function parseClaudeResult(payload) {
|
|
60104
60131
|
if (!isRecord(payload) || payload.type !== "result") return null;
|
|
60105
60132
|
if (!isNonEmptyString(payload.session_id) || !isRecord(payload.modelUsage)) return null;
|
|
@@ -60115,7 +60142,7 @@ function parseClaudeResult(payload) {
|
|
|
60115
60142
|
...isNonEmptyString(rawUsage.provider) ? { pricingProvider: rawUsage.provider } : {}
|
|
60116
60143
|
};
|
|
60117
60144
|
if (!isClaudeModelUsage(usage)) continue;
|
|
60118
|
-
const model = isNonEmptyString(rawUsage.canonicalModel) ? rawUsage.canonicalModel : rawModel
|
|
60145
|
+
const model = isNonEmptyString(rawUsage.canonicalModel) ? rawUsage.canonicalModel : withoutDate(rawModel);
|
|
60119
60146
|
const previous = snapshot[model];
|
|
60120
60147
|
snapshot[model] = previous ? {
|
|
60121
60148
|
inputTokens: previous.inputTokens + usage.inputTokens,
|
|
@@ -60158,6 +60185,10 @@ var ClaudeTokenUsageService = class {
|
|
|
60158
60185
|
snapshots = /* @__PURE__ */ new Map();
|
|
60159
60186
|
record(event) {
|
|
60160
60187
|
if (event.type !== "usage-updated") return void 0;
|
|
60188
|
+
const cut = parseClaudeRequestStart(event.payload);
|
|
60189
|
+
if (cut) {
|
|
60190
|
+
return { records: [{ ...event.context, model: cut.model, ...cut.usage, harness: AGENT.CLAUDE, occurredAt: event.occurredAt }] };
|
|
60191
|
+
}
|
|
60161
60192
|
const result = parseClaudeResult(event.payload);
|
|
60162
60193
|
if (!result) return void 0;
|
|
60163
60194
|
const snapshotsBySession = this.snapshots.get(event.chatId) ?? /* @__PURE__ */ new Map();
|
|
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
publishedPullRequestUrls
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MWWCGFYT.js";
|
|
7
7
|
import {
|
|
8
8
|
isRecord
|
|
9
9
|
} from "./chunk-UZSNFLDQ.js";
|
|
10
10
|
import {
|
|
11
11
|
shouldRefreshPullRequests
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-M3TLTCVX.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
|
|
15
15
|
// src/services/post-tool-pr-notifier.ts
|
package/dist/src/subagent-mcp.js
CHANGED