@cursor/july 0.1.26 → 0.1.27
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/ab.d.ts +6 -0
- package/dist/ab.d.ts.map +1 -1
- package/dist/ab.js +1 -0
- package/dist/artifacts.d.ts +34 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +57 -0
- package/dist/bin/agent-serve.js +31 -9
- package/dist/channels/github/github-channel.d.ts +1 -1
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +14 -1
- package/dist/channels/github/types.d.ts +6 -1
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/slack/api.d.ts +2 -1
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +1 -0
- package/dist/channels/slack/cursor-account.d.ts +2 -1
- package/dist/channels/slack/cursor-account.d.ts.map +1 -1
- package/dist/channels/slack/cursor-account.js +1 -1
- package/dist/channels/slack/dispatch.d.ts +4 -1
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +3 -3
- package/dist/channels/slack/interactive.d.ts +2 -1
- package/dist/channels/slack/interactive.d.ts.map +1 -1
- package/dist/channels/slack/interactive.js +1 -0
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +4 -3
- package/dist/channels/slack/types.d.ts +6 -1
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/docs/404.html +1 -1
- package/dist/docs/ab.html +2 -2
- package/dist/docs/assets/{app.DYcC9FY-.js → app.BICLoJYF.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.CQJytDwU.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.o4N_knTV.js → VPLocalSearchBox.wN4Ko9dT.js} +1 -1
- package/dist/docs/assets/chunks/{theme.DQ-njyo0.js → theme.dnnTE-Co.js} +2 -2
- package/dist/docs/building-with-agents.html +2 -2
- package/dist/docs/concepts.html +2 -2
- package/dist/docs/deployment.html +2 -2
- package/dist/docs/evals.html +2 -2
- package/dist/docs/example-agents/approval-buddy.html +2 -2
- package/dist/docs/example-agents/benny.html +2 -2
- package/dist/docs/example-agents/bugbot.html +2 -2
- package/dist/docs/example-agents/codebase-wiki.html +2 -2
- package/dist/docs/example-agents/codeowners-review.html +2 -2
- package/dist/docs/example-agents/concierge.html +2 -2
- package/dist/docs/example-agents/fsd.html +2 -2
- package/dist/docs/example-agents/index.html +2 -2
- package/dist/docs/example-agents/knowledge-base.html +2 -2
- package/dist/docs/example-agents/oncall.html +2 -2
- package/dist/docs/example-agents/security-reviewer.html +2 -2
- package/dist/docs/example-agents/slack-agent.html +2 -2
- package/dist/docs/example-agents/weather-agent.html +2 -2
- package/dist/docs/guides/agent-to-agent.html +2 -2
- package/dist/docs/guides/cloud-runtime.html +2 -2
- package/dist/docs/guides/github.html +2 -2
- package/dist/docs/guides/human-in-the-loop.html +2 -2
- package/dist/docs/guides/mcp-oauth.html +2 -2
- package/dist/docs/guides/slack.html +2 -2
- package/dist/docs/guides/webhooks.html +2 -2
- package/dist/docs/hillclimbing.html +2 -2
- package/dist/docs/index.html +2 -2
- package/dist/docs/quickstart.html +2 -2
- package/dist/docs/reference/agent-config.html +2 -2
- package/dist/docs/reference/channels.html +2 -2
- package/dist/docs/reference/cli.html +2 -2
- package/dist/docs/reference/connections.html +2 -2
- package/dist/docs/reference/hooks.html +2 -2
- package/dist/docs/reference/http-api.html +2 -2
- package/dist/docs/reference/instructions.html +2 -2
- package/dist/docs/reference/playground.html +2 -2
- package/dist/docs/reference/project-layout.html +2 -2
- package/dist/docs/reference/prompt.html +2 -2
- package/dist/docs/reference/schedules.html +2 -2
- package/dist/docs/reference/sessions.html +2 -2
- package/dist/docs/reference/skills.html +2 -2
- package/dist/docs/reference/subagents.html +2 -2
- package/dist/docs/reference/tools.html +2 -2
- package/dist/docs/scaffolding-agents.html +2 -2
- package/dist/docs/storage.html +2 -2
- package/dist/docs/troubleshooting.html +2 -2
- package/dist/evals/assertions.d.ts +10 -1
- package/dist/evals/assertions.d.ts.map +1 -1
- package/dist/evals/assertions.js +12 -0
- package/dist/evals.d.ts +1 -1
- package/dist/evals.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/ab-fold.d.ts.map +1 -1
- package/dist/internal/ab-fold.js +4 -0
- package/dist/internal/ab-snapshot.d.ts.map +1 -1
- package/dist/internal/ab-snapshot.js +1 -0
- package/dist/internal/artifacts-store.d.ts +45 -0
- package/dist/internal/artifacts-store.d.ts.map +1 -0
- package/dist/internal/artifacts-store.js +250 -0
- package/dist/internal/builtin-tools/artifacts.d.ts +10 -0
- package/dist/internal/builtin-tools/artifacts.d.ts.map +1 -0
- package/dist/internal/builtin-tools/artifacts.js +73 -0
- package/dist/internal/builtin-tools/index.d.ts +8 -1
- package/dist/internal/builtin-tools/index.d.ts.map +1 -1
- package/dist/internal/builtin-tools/index.js +15 -0
- package/dist/internal/cli-ax.d.ts +11 -0
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +80 -0
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +14 -6
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +83 -2
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +1 -0
- package/dist/internal/model-pricing.d.ts +49 -0
- package/dist/internal/model-pricing.d.ts.map +1 -0
- package/dist/internal/model-pricing.js +377 -0
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +1 -0
- package/dist/internal/schedule-runner.d.ts.map +1 -1
- package/dist/internal/schedule-runner.js +1 -0
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +9 -1
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +39 -0
- package/dist/internal/session-cost.d.ts +49 -0
- package/dist/internal/session-cost.d.ts.map +1 -0
- package/dist/internal/session-cost.js +175 -0
- package/dist/internal/session-engine.d.ts +35 -1
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +128 -7
- package/dist/internal/storage-coordinator.d.ts +15 -0
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +52 -0
- package/dist/internal/trajectory.d.ts +9 -1
- package/dist/internal/trajectory.d.ts.map +1 -1
- package/dist/internal/trajectory.js +32 -5
- package/dist/playground/assets/index-BDCeW4uc.js +86 -0
- package/dist/playground/assets/index-Bul1WfrB.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage.d.ts +4 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +4 -0
- package/dist/types.d.ts +164 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +26 -26
- package/src/ab.ts +7 -0
- package/src/bin/agent-serve.ts +30 -2
- package/src/internal/ab-fold.ts +4 -0
- package/src/internal/ab-snapshot.ts +1 -0
- package/src/internal/cli-ax.ts +95 -0
- package/src/internal/model-pricing.ts +426 -0
- package/src/internal/sdk-runner.ts +10 -2
- package/src/internal/session-cost.ts +231 -0
- package/src/internal/session-engine.ts +28 -0
- package/src/internal/trajectory.ts +45 -3
- package/src/types.ts +24 -1
- package/dist/channels/github/instrument.d.ts +0 -20
- package/dist/channels/github/instrument.d.ts.map +0 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BQTzJjR_.js +0 -1
- package/dist/internal/json-dir-store.d.ts +0 -32
- package/dist/internal/json-dir-store.d.ts.map +0 -1
- package/dist/internal/json-dir-store.js +0 -100
- package/dist/playground/assets/index-CjOQ4hN9.css +0 -1
- package/dist/playground/assets/index-DqXdAFGa.js +0 -85
- package/src/bin/agent-serve.version.test.ts +0 -64
- package/src/channels/github/api.test.ts +0 -64
- package/src/channels/github/auth.test.ts +0 -105
- package/src/channels/github/cursor-account.test.ts +0 -204
- package/src/channels/github/forward.test.ts +0 -457
- package/src/channels/github/github.test.ts +0 -985
- package/src/channels/github/replay.test.ts +0 -179
- package/src/channels/slack/api.post-message.test.ts +0 -148
- package/src/channels/slack/approvals.test.ts +0 -328
- package/src/channels/slack/block-actions.test.ts +0 -469
- package/src/channels/slack/bot-mentions.test.ts +0 -267
- package/src/channels/slack/channel-watch.test.ts +0 -363
- package/src/channels/slack/cursor-account.test.ts +0 -301
- package/src/channels/slack/defaults.final-post.test.ts +0 -182
- package/src/channels/slack/dispatch.test.ts +0 -875
- package/src/channels/slack/eval-directive.test.ts +0 -273
- package/src/channels/slack/message-body.test.ts +0 -54
- package/src/channels/slack/nudge-store.test.ts +0 -143
- package/src/channels/slack/slack.test.ts +0 -391
- package/src/channels/slack/stop.test.ts +0 -23
- package/src/channels/slack/thread-context.test.ts +0 -202
- package/src/evals/assertions.test.ts +0 -617
- package/src/evals/expect.test.ts +0 -144
- package/src/evals/judge.test.ts +0 -181
- package/src/evals/loaders.test.ts +0 -132
- package/src/evals/matchers.test.ts +0 -95
- package/src/evals/reporters.test.ts +0 -303
- package/src/evals/run-facts.test.ts +0 -259
- package/src/internal/ab-snapshot.test.ts +0 -325
- package/src/internal/approval-gate.test.ts +0 -49
- package/src/internal/approvals.integration.test.ts +0 -383
- package/src/internal/artifacts-store.test.ts +0 -283
- package/src/internal/authored-loaders.test.ts +0 -31
- package/src/internal/builtin-tools/artifacts.test.ts +0 -247
- package/src/internal/builtin-tools/reminders.test.ts +0 -201
- package/src/internal/channel-route-schema.test.ts +0 -294
- package/src/internal/chat-attach.test.ts +0 -262
- package/src/internal/cli-deploy.test.ts +0 -1991
- package/src/internal/cli-docs.test.ts +0 -161
- package/src/internal/cli-mcp.test.ts +0 -789
- package/src/internal/cli-skills.test.ts +0 -133
- package/src/internal/cli-slack.test.ts +0 -1654
- package/src/internal/cloud-merge.test.ts +0 -74
- package/src/internal/cron.test.ts +0 -22
- package/src/internal/cursor/account-mcp.test.ts +0 -807
- package/src/internal/cursor/backend-client.test.ts +0 -591
- package/src/internal/cursor/credentials.test.ts +0 -351
- package/src/internal/cursor/github-credentials.test.ts +0 -136
- package/src/internal/cursor-account-mcp-auth.test.ts +0 -310
- package/src/internal/cursor-account.integration.test.ts +0 -441
- package/src/internal/cursor-event-relay.test.ts +0 -746
- package/src/internal/cursor-github-credentials.integration.test.ts +0 -271
- package/src/internal/cursor-slack-relay.test.ts +0 -525
- package/src/internal/deploy-source.test.ts +0 -111
- package/src/internal/discovery.artifact-tool.test.ts +0 -136
- package/src/internal/discovery.artifacts.test.ts +0 -119
- package/src/internal/discovery.builtin-tools.test.ts +0 -94
- package/src/internal/discovery.concurrency.test.ts +0 -60
- package/src/internal/discovery.cursor-account.test.ts +0 -133
- package/src/internal/discovery.cwd.test.ts +0 -83
- package/src/internal/discovery.hosting.test.ts +0 -80
- package/src/internal/discovery.identity.test.ts +0 -44
- package/src/internal/docs-site.test.ts +0 -66
- package/src/internal/duration.test.ts +0 -29
- package/src/internal/eval-judge-model.test.ts +0 -187
- package/src/internal/eval-run-store.cancel.test.ts +0 -142
- package/src/internal/eval-run-store.storage.test.ts +0 -211
- package/src/internal/eval-runner.http.test.ts +0 -403
- package/src/internal/eval-runner.run.test.ts +0 -928
- package/src/internal/evals-client.test.ts +0 -307
- package/src/internal/event-mapper.test.ts +0 -243
- package/src/internal/github-fanout.test.ts +0 -213
- package/src/internal/handleAgentServeTrigger.test.ts +0 -185
- package/src/internal/host-kv.test.ts +0 -82
- package/src/internal/host-platforms.test.ts +0 -126
- package/src/internal/http-channel.test.ts +0 -402
- package/src/internal/init-project.test.ts +0 -270
- package/src/internal/install-cursor-skills.test.ts +0 -262
- package/src/internal/local-env.test.ts +0 -120
- package/src/internal/log-ring.test.ts +0 -31
- package/src/internal/logs-client.test.ts +0 -350
- package/src/internal/mcp-endpoint.test.ts +0 -436
- package/src/internal/mcp-host.test.ts +0 -298
- package/src/internal/mcp-oauth.test.ts +0 -148
- package/src/internal/net.test.ts +0 -17
- package/src/internal/peer-connections.test.ts +0 -128
- package/src/internal/peer-mcp.integration.test.ts +0 -289
- package/src/internal/playground/toolchain.test.ts +0 -53
- package/src/internal/playground-cli.test.ts +0 -187
- package/src/internal/playground-proxy.test.ts +0 -376
- package/src/internal/prompt-context.integration.test.ts +0 -232
- package/src/internal/prompt-context.test.ts +0 -127
- package/src/internal/reminder-runner.test.ts +0 -432
- package/src/internal/reminder-store.test.ts +0 -53
- package/src/internal/request-headers.test.ts +0 -27
- package/src/internal/resolve-prod-target.test.ts +0 -787
- package/src/internal/resolved-connections.test.ts +0 -295
- package/src/internal/router.test.ts +0 -57
- package/src/internal/sdk-runner.test.ts +0 -290
- package/src/internal/server.artifacts.test.ts +0 -334
- package/src/internal/session-engine.artifacts.test.ts +0 -293
- package/src/internal/session-engine.coalesce.test.ts +0 -169
- package/src/internal/session-engine.concurrency.test.ts +0 -250
- package/src/internal/session-engine.host-oauth-mcp.test.ts +0 -110
- package/src/internal/session-engine.interrupt.test.ts +0 -577
- package/src/internal/session-engine.storage.test.ts +0 -547
- package/src/internal/session-urls.test.ts +0 -28
- package/src/internal/sessions-client.test.ts +0 -518
- package/src/internal/storage-coordinator.test.ts +0 -517
- package/src/internal/tool-call.test.ts +0 -458
- package/src/internal/tool-result.test.ts +0 -52
- package/src/internal/trajectory.approvals.test.ts +0 -83
- package/src/internal/trajectory.subagents.test.ts +0 -198
- package/src/internal/turn-governor.test.ts +0 -137
- package/src/internal/update-check.test.ts +0 -485
- package/src/internal/workspace.test.ts +0 -207
- package/src/storage-backends/cursor-hosted.test.ts +0 -121
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import type { SessionEvent } from "../types.js";
|
|
3
|
-
import { buildTrajectory, formatTrajectoryText } from "./trajectory.js";
|
|
4
|
-
|
|
5
|
-
function ev(
|
|
6
|
-
partial: Omit<SessionEvent, "index" | "sessionId" | "at"> & {
|
|
7
|
-
index?: number;
|
|
8
|
-
}
|
|
9
|
-
): SessionEvent {
|
|
10
|
-
return {
|
|
11
|
-
index: partial.index ?? 0,
|
|
12
|
-
sessionId: "sess_1",
|
|
13
|
-
at: "2026-01-01T00:00:00.000Z",
|
|
14
|
-
...partial,
|
|
15
|
-
} as SessionEvent;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe("buildTrajectory subagent progress", () => {
|
|
19
|
-
it("keeps bare top-level task in toolCalls for calledTool evals", () => {
|
|
20
|
-
const traj = buildTrajectory([
|
|
21
|
-
ev({ type: "session.started", data: { channelId: "http" } }),
|
|
22
|
-
ev({
|
|
23
|
-
type: "message.received",
|
|
24
|
-
turnId: "turn_1",
|
|
25
|
-
data: { text: "review this" },
|
|
26
|
-
}),
|
|
27
|
-
ev({
|
|
28
|
-
type: "actions.requested",
|
|
29
|
-
turnId: "turn_1",
|
|
30
|
-
data: {
|
|
31
|
-
calls: [
|
|
32
|
-
{
|
|
33
|
-
callId: "task-1",
|
|
34
|
-
toolName: "task",
|
|
35
|
-
args: { description: "deep review" },
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
ev({
|
|
41
|
-
type: "subagent.called",
|
|
42
|
-
turnId: "turn_1",
|
|
43
|
-
data: {
|
|
44
|
-
callId: "task-1",
|
|
45
|
-
name: "reviewer",
|
|
46
|
-
description: "deep review",
|
|
47
|
-
},
|
|
48
|
-
}),
|
|
49
|
-
ev({
|
|
50
|
-
type: "actions.requested",
|
|
51
|
-
turnId: "turn_1",
|
|
52
|
-
data: {
|
|
53
|
-
parentCallId: "task-1",
|
|
54
|
-
calls: [
|
|
55
|
-
{
|
|
56
|
-
callId: "shell-1",
|
|
57
|
-
toolName: "shell",
|
|
58
|
-
args: { command: "ls" },
|
|
59
|
-
parentCallId: "task-1",
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
}),
|
|
64
|
-
ev({
|
|
65
|
-
type: "action.result",
|
|
66
|
-
turnId: "turn_1",
|
|
67
|
-
data: {
|
|
68
|
-
callId: "shell-1",
|
|
69
|
-
toolName: "shell",
|
|
70
|
-
output: "ok",
|
|
71
|
-
isError: false,
|
|
72
|
-
parentCallId: "task-1",
|
|
73
|
-
},
|
|
74
|
-
}),
|
|
75
|
-
ev({
|
|
76
|
-
type: "subagent.completed",
|
|
77
|
-
turnId: "turn_1",
|
|
78
|
-
data: { callId: "task-1", name: "reviewer" },
|
|
79
|
-
}),
|
|
80
|
-
ev({
|
|
81
|
-
type: "action.result",
|
|
82
|
-
turnId: "turn_1",
|
|
83
|
-
data: {
|
|
84
|
-
callId: "task-1",
|
|
85
|
-
toolName: "task",
|
|
86
|
-
output: { done: true },
|
|
87
|
-
isError: false,
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
ev({
|
|
91
|
-
type: "message.completed",
|
|
92
|
-
turnId: "turn_1",
|
|
93
|
-
data: { text: "Parent reply.", finishReason: "stop" },
|
|
94
|
-
}),
|
|
95
|
-
ev({ type: "turn.completed", turnId: "turn_1", data: {} }),
|
|
96
|
-
]);
|
|
97
|
-
|
|
98
|
-
const turn = traj.turns[0]!;
|
|
99
|
-
expect(turn.toolCalls.map((c) => c.toolName)).toContain("task");
|
|
100
|
-
expect(turn.toolCalls.find((c) => c.toolName === "task")).toMatchObject({
|
|
101
|
-
callId: "task-1",
|
|
102
|
-
output: { done: true },
|
|
103
|
-
});
|
|
104
|
-
expect(turn.subagents).toHaveLength(1);
|
|
105
|
-
expect(turn.subagents[0]?.toolCalls.map((c) => c.toolName)).toEqual([
|
|
106
|
-
"shell",
|
|
107
|
-
]);
|
|
108
|
-
expect(turn.assistantText).toBe("Parent reply.");
|
|
109
|
-
expect(traj.finalText).toBe("Parent reply.");
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("does not let nested message.completed overwrite parent assistantText", () => {
|
|
113
|
-
const traj = buildTrajectory([
|
|
114
|
-
ev({
|
|
115
|
-
type: "message.received",
|
|
116
|
-
turnId: "turn_1",
|
|
117
|
-
data: { text: "hi" },
|
|
118
|
-
}),
|
|
119
|
-
ev({
|
|
120
|
-
type: "subagent.called",
|
|
121
|
-
turnId: "turn_1",
|
|
122
|
-
data: { callId: "task-1", name: "worker" },
|
|
123
|
-
}),
|
|
124
|
-
ev({
|
|
125
|
-
type: "message.completed",
|
|
126
|
-
turnId: "turn_1",
|
|
127
|
-
data: {
|
|
128
|
-
text: "Nested says hi.",
|
|
129
|
-
finishReason: "stop",
|
|
130
|
-
parentCallId: "task-1",
|
|
131
|
-
},
|
|
132
|
-
}),
|
|
133
|
-
ev({
|
|
134
|
-
type: "message.completed",
|
|
135
|
-
turnId: "turn_1",
|
|
136
|
-
data: { text: "Parent final.", finishReason: "stop" },
|
|
137
|
-
}),
|
|
138
|
-
ev({ type: "turn.completed", turnId: "turn_1", data: {} }),
|
|
139
|
-
]);
|
|
140
|
-
|
|
141
|
-
expect(traj.turns[0]?.assistantText).toBe("Parent final.");
|
|
142
|
-
expect(traj.finalText).toBe("Parent final.");
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("does not let nested reasoning.appended overwrite parent reasoningText", () => {
|
|
146
|
-
const traj = buildTrajectory([
|
|
147
|
-
ev({
|
|
148
|
-
type: "reasoning.appended",
|
|
149
|
-
turnId: "turn_1",
|
|
150
|
-
data: {
|
|
151
|
-
delta: "parent think",
|
|
152
|
-
text: "parent think",
|
|
153
|
-
},
|
|
154
|
-
}),
|
|
155
|
-
ev({
|
|
156
|
-
type: "reasoning.appended",
|
|
157
|
-
turnId: "turn_1",
|
|
158
|
-
data: {
|
|
159
|
-
delta: "nested think",
|
|
160
|
-
text: "nested think",
|
|
161
|
-
parentCallId: "task-1",
|
|
162
|
-
},
|
|
163
|
-
}),
|
|
164
|
-
ev({ type: "turn.completed", turnId: "turn_1", data: {} }),
|
|
165
|
-
]);
|
|
166
|
-
|
|
167
|
-
expect(traj.turns[0]?.reasoningText).toBe("parent think");
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it("formatTrajectoryText includes nested subagent tools", () => {
|
|
171
|
-
const traj = buildTrajectory([
|
|
172
|
-
ev({
|
|
173
|
-
type: "subagent.called",
|
|
174
|
-
turnId: "turn_1",
|
|
175
|
-
data: { callId: "task-1", name: "worker", description: "do work" },
|
|
176
|
-
}),
|
|
177
|
-
ev({
|
|
178
|
-
type: "actions.requested",
|
|
179
|
-
turnId: "turn_1",
|
|
180
|
-
data: {
|
|
181
|
-
calls: [
|
|
182
|
-
{
|
|
183
|
-
callId: "read-1",
|
|
184
|
-
toolName: "read",
|
|
185
|
-
args: { path: "a.ts" },
|
|
186
|
-
parentCallId: "task-1",
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
}),
|
|
191
|
-
ev({ type: "turn.completed", turnId: "turn_1", data: {} }),
|
|
192
|
-
]);
|
|
193
|
-
|
|
194
|
-
const text = formatTrajectoryText(traj);
|
|
195
|
-
expect(text).toContain("task worker");
|
|
196
|
-
expect(text).toContain("read");
|
|
197
|
-
});
|
|
198
|
-
});
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { TurnGovernor, type TurnPermit } from "./turn-governor.js";
|
|
3
|
-
|
|
4
|
-
describe("TurnGovernor", () => {
|
|
5
|
-
it("grants immediately with no limit configured", async () => {
|
|
6
|
-
const governor = new TurnGovernor(undefined);
|
|
7
|
-
expect(governor.limited).toBe(false);
|
|
8
|
-
const permit = await governor.acquire({ sessionId: "s1" });
|
|
9
|
-
expect(permit).toBeDefined();
|
|
10
|
-
expect(governor.queuedCount).toBe(0);
|
|
11
|
-
permit?.release();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("queues FIFO beyond the limit and wakes waiters in order", async () => {
|
|
15
|
-
const governor = new TurnGovernor({ maxRunningTurns: 2 });
|
|
16
|
-
const first = await governor.acquire({ sessionId: "s1" });
|
|
17
|
-
const second = await governor.acquire({ sessionId: "s2" });
|
|
18
|
-
expect(governor.runningCount).toBe(2);
|
|
19
|
-
|
|
20
|
-
const positions: Array<{ sessionId: string; position: number }> = [];
|
|
21
|
-
const grants: string[] = [];
|
|
22
|
-
const third = governor
|
|
23
|
-
.acquire({
|
|
24
|
-
sessionId: "s3",
|
|
25
|
-
onQueued: (position) => positions.push({ sessionId: "s3", position }),
|
|
26
|
-
})
|
|
27
|
-
.then((permit) => {
|
|
28
|
-
grants.push("s3");
|
|
29
|
-
return permit;
|
|
30
|
-
});
|
|
31
|
-
const fourth = governor
|
|
32
|
-
.acquire({
|
|
33
|
-
sessionId: "s4",
|
|
34
|
-
onQueued: (position) => positions.push({ sessionId: "s4", position }),
|
|
35
|
-
})
|
|
36
|
-
.then((permit) => {
|
|
37
|
-
grants.push("s4");
|
|
38
|
-
return permit;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
expect(positions).toEqual([
|
|
42
|
-
{ sessionId: "s3", position: 1 },
|
|
43
|
-
{ sessionId: "s4", position: 2 },
|
|
44
|
-
]);
|
|
45
|
-
expect(governor.queuedCount).toBe(2);
|
|
46
|
-
expect(governor.isQueued("s3")).toBe(true);
|
|
47
|
-
expect(governor.isQueued("s4")).toBe(true);
|
|
48
|
-
|
|
49
|
-
first?.release();
|
|
50
|
-
const thirdPermit = await third;
|
|
51
|
-
expect(grants).toEqual(["s3"]);
|
|
52
|
-
expect(governor.isQueued("s3")).toBe(false);
|
|
53
|
-
expect(governor.runningCount).toBe(2);
|
|
54
|
-
|
|
55
|
-
second?.release();
|
|
56
|
-
const fourthPermit = await fourth;
|
|
57
|
-
expect(grants).toEqual(["s3", "s4"]);
|
|
58
|
-
expect(governor.queuedCount).toBe(0);
|
|
59
|
-
|
|
60
|
-
thirdPermit?.release();
|
|
61
|
-
fourthPermit?.release();
|
|
62
|
-
expect(governor.runningCount).toBe(0);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("resolves undefined when the signal aborts while waiting", async () => {
|
|
66
|
-
const governor = new TurnGovernor({ maxRunningTurns: 1 });
|
|
67
|
-
const holder = await governor.acquire({ sessionId: "s1" });
|
|
68
|
-
|
|
69
|
-
const abort = new AbortController();
|
|
70
|
-
const waiting = governor.acquire({
|
|
71
|
-
sessionId: "s2",
|
|
72
|
-
signal: abort.signal,
|
|
73
|
-
});
|
|
74
|
-
expect(governor.isQueued("s2")).toBe(true);
|
|
75
|
-
|
|
76
|
-
abort.abort();
|
|
77
|
-
expect(await waiting).toBeUndefined();
|
|
78
|
-
expect(governor.isQueued("s2")).toBe(false);
|
|
79
|
-
expect(governor.queuedCount).toBe(0);
|
|
80
|
-
|
|
81
|
-
// The abandoned wait must not consume the slot when it frees.
|
|
82
|
-
holder?.release();
|
|
83
|
-
const next = await governor.acquire({ sessionId: "s3" });
|
|
84
|
-
expect(next).toBeDefined();
|
|
85
|
-
next?.release();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("resolves undefined without enqueuing when already aborted", async () => {
|
|
89
|
-
const governor = new TurnGovernor({ maxRunningTurns: 1 });
|
|
90
|
-
const holder = await governor.acquire({ sessionId: "s1" });
|
|
91
|
-
const abort = new AbortController();
|
|
92
|
-
abort.abort();
|
|
93
|
-
let queued = false;
|
|
94
|
-
const permit = await governor.acquire({
|
|
95
|
-
sessionId: "s2",
|
|
96
|
-
signal: abort.signal,
|
|
97
|
-
onQueued: () => {
|
|
98
|
-
queued = true;
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
expect(permit).toBeUndefined();
|
|
102
|
-
expect(queued).toBe(false);
|
|
103
|
-
holder?.release();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("release is idempotent", async () => {
|
|
107
|
-
const governor = new TurnGovernor({ maxRunningTurns: 1 });
|
|
108
|
-
const first = (await governor.acquire({ sessionId: "s1" })) as TurnPermit;
|
|
109
|
-
first.release();
|
|
110
|
-
first.release();
|
|
111
|
-
expect(governor.runningCount).toBe(0);
|
|
112
|
-
const second = await governor.acquire({ sessionId: "s2" });
|
|
113
|
-
expect(second).toBeDefined();
|
|
114
|
-
expect(governor.runningCount).toBe(1);
|
|
115
|
-
second?.release();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("keeps FIFO order over grants freed by aborted waiters", async () => {
|
|
119
|
-
const governor = new TurnGovernor({ maxRunningTurns: 1 });
|
|
120
|
-
const holder = await governor.acquire({ sessionId: "s1" });
|
|
121
|
-
const abortSecond = new AbortController();
|
|
122
|
-
const second = governor.acquire({
|
|
123
|
-
sessionId: "s2",
|
|
124
|
-
signal: abortSecond.signal,
|
|
125
|
-
});
|
|
126
|
-
const third = governor.acquire({ sessionId: "s3" });
|
|
127
|
-
|
|
128
|
-
abortSecond.abort();
|
|
129
|
-
expect(await second).toBeUndefined();
|
|
130
|
-
|
|
131
|
-
holder?.release();
|
|
132
|
-
const thirdPermit = await third;
|
|
133
|
-
expect(thirdPermit).toBeDefined();
|
|
134
|
-
expect(governor.queuedCount).toBe(0);
|
|
135
|
-
thirdPermit?.release();
|
|
136
|
-
});
|
|
137
|
-
});
|