@rallycry/conveyor-agent 10.13.71 → 10.13.72
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/{boot-PKHZUDAC.js → boot-ZNL7X5LQ.js} +8 -4
- package/dist/chunk-2L5THOWD.js +697 -0
- package/dist/{chunk-7MMECTTJ.js → chunk-2SN32LM6.js} +134 -2598
- package/dist/chunk-3F4ZZKCA.js +291 -0
- package/dist/chunk-LSZ2KLJY.js +2527 -0
- package/dist/{chunk-DOB2XE2I.js → chunk-UBDSLM44.js} +4 -2
- package/dist/{chunk-GJXAAPJ6.js → chunk-W4LZ7R6Z.js} +117 -400
- package/dist/{chunk-QU53HND5.js → chunk-WMMBAKPE.js} +4 -48
- package/dist/chunk-XORJ6SII.js +46 -0
- package/dist/cli.js +55 -712
- package/dist/index.js +9 -5
- package/dist/serve-boot-4N3FRXVQ.js +225 -0
- package/dist/{server-CC7KUJOK.js → server-7XH7RYUX.js} +3 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SessionRunner,
|
|
3
|
+
unshallowRepo
|
|
4
|
+
} from "./chunk-2SN32LM6.js";
|
|
5
|
+
import "./chunk-XORJ6SII.js";
|
|
1
6
|
import {
|
|
2
7
|
AgentConnection,
|
|
3
8
|
GIT_TIMEOUT_MS,
|
|
4
|
-
SessionRunner,
|
|
5
9
|
flushPendingChanges,
|
|
6
10
|
getCurrentBranch,
|
|
7
11
|
hasUncommittedChanges,
|
|
@@ -10,11 +14,10 @@ import {
|
|
|
10
14
|
loadForwardPorts,
|
|
11
15
|
pushToOrigin,
|
|
12
16
|
stageAndCommit,
|
|
13
|
-
unshallowRepo,
|
|
14
17
|
updateRemoteToken,
|
|
15
18
|
workspacePathExists
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-LSZ2KLJY.js";
|
|
20
|
+
import "./chunk-WMMBAKPE.js";
|
|
18
21
|
import "./chunk-IA45XHOA.js";
|
|
19
22
|
import {
|
|
20
23
|
getWorkbenchClient
|
|
@@ -22,11 +25,12 @@ import {
|
|
|
22
25
|
import {
|
|
23
26
|
workbenchEnabled
|
|
24
27
|
} from "./chunk-KMB3BU4S.js";
|
|
28
|
+
import "./chunk-3F4ZZKCA.js";
|
|
25
29
|
import {
|
|
26
30
|
runAuthTokenCommand,
|
|
27
31
|
runSetupCommand,
|
|
28
32
|
runStartCommand
|
|
29
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-W4LZ7R6Z.js";
|
|
30
34
|
import "./chunk-6Q6LQBWO.js";
|
|
31
35
|
|
|
32
36
|
// src/runner/worktree.ts
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WorkspaceCommandSupervisor
|
|
3
|
+
} from "./chunk-2L5THOWD.js";
|
|
4
|
+
import {
|
|
5
|
+
AgentConnection,
|
|
6
|
+
CodespacePortVisibility,
|
|
7
|
+
DEFAULT_LIFECYCLE_CONFIG,
|
|
8
|
+
Lifecycle,
|
|
9
|
+
PortDiscovery,
|
|
10
|
+
awaitGitReady,
|
|
11
|
+
createServiceLogger,
|
|
12
|
+
ensureOnTaskBranch,
|
|
13
|
+
loadConveyorConfig
|
|
14
|
+
} from "./chunk-LSZ2KLJY.js";
|
|
15
|
+
import "./chunk-WMMBAKPE.js";
|
|
16
|
+
import "./chunk-IA45XHOA.js";
|
|
17
|
+
import "./chunk-EXQ6AHOY.js";
|
|
18
|
+
import "./chunk-KMB3BU4S.js";
|
|
19
|
+
import "./chunk-W4LZ7R6Z.js";
|
|
20
|
+
import "./chunk-6Q6LQBWO.js";
|
|
21
|
+
|
|
22
|
+
// src/runner/serve-session-runner.ts
|
|
23
|
+
var ServeSessionRunner = class {
|
|
24
|
+
connection;
|
|
25
|
+
lifecycle;
|
|
26
|
+
config;
|
|
27
|
+
callbacks;
|
|
28
|
+
portDiscovery;
|
|
29
|
+
commandSupervisor;
|
|
30
|
+
git;
|
|
31
|
+
stopped = false;
|
|
32
|
+
stopResolver = null;
|
|
33
|
+
_finalState = null;
|
|
34
|
+
constructor(config, callbacks = {}, deps) {
|
|
35
|
+
this.config = config;
|
|
36
|
+
this.callbacks = callbacks;
|
|
37
|
+
this.connection = deps?.connection ?? new AgentConnection(config.connection);
|
|
38
|
+
const portVisibility = new CodespacePortVisibility();
|
|
39
|
+
this.portDiscovery = deps?.portDiscovery ?? new PortDiscovery({
|
|
40
|
+
report: (ports) => this.connection.reportDiscoveredPorts(ports),
|
|
41
|
+
onReported: (ports) => portVisibility.ensureVisible(ports.map(({ port }) => port))
|
|
42
|
+
});
|
|
43
|
+
this.commandSupervisor = deps?.commandSupervisor ?? new WorkspaceCommandSupervisor({
|
|
44
|
+
config: loadConveyorConfig(),
|
|
45
|
+
workspaceDir: config.workspaceDir,
|
|
46
|
+
connection: this.connection
|
|
47
|
+
});
|
|
48
|
+
this.git = deps?.git ?? {
|
|
49
|
+
awaitGitReady: (opts) => awaitGitReady(opts),
|
|
50
|
+
checkoutBranch: (cwd, branch) => ensureOnTaskBranch(cwd, branch)
|
|
51
|
+
};
|
|
52
|
+
this.lifecycle = new Lifecycle(
|
|
53
|
+
// No git flush and no usage sample: nothing here writes to the checkout,
|
|
54
|
+
// and the serving bundle selects no coding-agent key to measure.
|
|
55
|
+
{
|
|
56
|
+
...DEFAULT_LIFECYCLE_CONFIG,
|
|
57
|
+
gitFlushIntervalMs: 0,
|
|
58
|
+
usageSampleIntervalMs: 0,
|
|
59
|
+
...config.lifecycle
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
onHeartbeat: () => this.connection.sendHeartbeat(),
|
|
63
|
+
// Never armed (see the file header) — supplied because Lifecycle
|
|
64
|
+
// requires the full callback set.
|
|
65
|
+
onIdleTimeout: () => this.requestStop(),
|
|
66
|
+
onDormantTimeout: () => this.requestStop(),
|
|
67
|
+
onTokenRefresh: () => void this.connection.refreshTaskTokenFromBootstrap().catch(() => {
|
|
68
|
+
}),
|
|
69
|
+
onGitFlush: () => {
|
|
70
|
+
},
|
|
71
|
+
onUsageSample: () => {
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
get finalState() {
|
|
77
|
+
return this._finalState;
|
|
78
|
+
}
|
|
79
|
+
get isStopped() {
|
|
80
|
+
return this.stopped;
|
|
81
|
+
}
|
|
82
|
+
/** Connect, register the session, launch the start command, then hold open. */
|
|
83
|
+
async run() {
|
|
84
|
+
try {
|
|
85
|
+
await this.connection.connect();
|
|
86
|
+
this.connection.sendEvent({
|
|
87
|
+
type: "connected",
|
|
88
|
+
sessionId: this.config.connection.sessionId
|
|
89
|
+
});
|
|
90
|
+
this.connection.onStop(() => this.requestStop());
|
|
91
|
+
this.lifecycle.startHeartbeat();
|
|
92
|
+
this.lifecycle.startTokenRefresh();
|
|
93
|
+
await this.connection.call("connectAgent", {
|
|
94
|
+
sessionId: this.config.connection.sessionId
|
|
95
|
+
});
|
|
96
|
+
await this.portDiscovery.start().catch(() => {
|
|
97
|
+
});
|
|
98
|
+
if (this.stopped) {
|
|
99
|
+
this._finalState = "finished";
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const gitState = await this.git.awaitGitReady({
|
|
103
|
+
onLog: (m) => process.stderr.write(`[conveyor-agent] ${m}
|
|
104
|
+
`)
|
|
105
|
+
});
|
|
106
|
+
if (this.stopped) {
|
|
107
|
+
this._finalState = "finished";
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (gitState === "failed" || gitState === "timeout") {
|
|
111
|
+
throw new Error(
|
|
112
|
+
gitState === "failed" ? "Workspace git preparation failed (see pod logs)" : "Workspace git preparation timed out (see pod logs)"
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
const onBranch = await this.git.checkoutBranch(this.config.workspaceDir, this.config.branch);
|
|
116
|
+
if (this.stopped) {
|
|
117
|
+
this._finalState = "finished";
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!onBranch) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
`Task-branch checkout failed for "${this.config.branch}"; refusing to serve base-branch code`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
this.commandSupervisor.start();
|
|
126
|
+
this.commandSupervisor.notifyLoopReady?.();
|
|
127
|
+
await this.connection.emitStatus("idle");
|
|
128
|
+
this.callbacks.onEvent?.({ type: "serve_runner_started", taskId: this.config.taskId });
|
|
129
|
+
await this.waitUntilStopped();
|
|
130
|
+
this._finalState = "finished";
|
|
131
|
+
} catch (error) {
|
|
132
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
133
|
+
process.stderr.write(`[conveyor-agent] Serve runner failed: ${message}
|
|
134
|
+
`);
|
|
135
|
+
this.connection.sendEvent({ type: "error", message });
|
|
136
|
+
this._finalState = "error";
|
|
137
|
+
} finally {
|
|
138
|
+
await this.shutdown();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** External stop (SIGTERM/SIGINT or server session:stop). */
|
|
142
|
+
stop() {
|
|
143
|
+
this.requestStop();
|
|
144
|
+
}
|
|
145
|
+
requestStop() {
|
|
146
|
+
if (this.stopped) return;
|
|
147
|
+
this.stopped = true;
|
|
148
|
+
this.portDiscovery.stop();
|
|
149
|
+
if (this.stopResolver) {
|
|
150
|
+
const resolve = this.stopResolver;
|
|
151
|
+
this.stopResolver = null;
|
|
152
|
+
resolve();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
waitUntilStopped() {
|
|
156
|
+
if (this.stopped) return Promise.resolve();
|
|
157
|
+
return new Promise((resolve) => {
|
|
158
|
+
this.stopResolver = resolve;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
async shutdown() {
|
|
162
|
+
this.stopped = true;
|
|
163
|
+
this.portDiscovery.stop();
|
|
164
|
+
this.lifecycle.destroy();
|
|
165
|
+
await this.commandSupervisor.stop().catch(() => {
|
|
166
|
+
});
|
|
167
|
+
this.connection.sendEvent({ type: "shutdown", reason: this._finalState ?? "finished" });
|
|
168
|
+
this.connection.disconnect();
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// src/runner/serve-boot.ts
|
|
173
|
+
var logger = createServiceLogger("ServeBoot");
|
|
174
|
+
function outcomeFor(runner) {
|
|
175
|
+
const errored = runner.finalState === "error";
|
|
176
|
+
return {
|
|
177
|
+
exitCode: errored ? 1 : 0,
|
|
178
|
+
reason: errored ? "error" : "clean",
|
|
179
|
+
finalState: runner.finalState ?? void 0
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async function runServingSession(params) {
|
|
183
|
+
if (!params.sessionId) {
|
|
184
|
+
logger.error("Serving mode requires CONVEYOR_SESSION_ID");
|
|
185
|
+
return { exitCode: 1, reason: "error", finalState: "error" };
|
|
186
|
+
}
|
|
187
|
+
if (!params.branch) {
|
|
188
|
+
logger.error("Serving mode requires BRANCH (the card's branch to serve)");
|
|
189
|
+
return { exitCode: 1, reason: "error", finalState: "error" };
|
|
190
|
+
}
|
|
191
|
+
logger.info("Starting preview-only serving runner", {
|
|
192
|
+
taskId: params.taskId,
|
|
193
|
+
sessionId: params.sessionId,
|
|
194
|
+
branch: params.branch
|
|
195
|
+
});
|
|
196
|
+
const runner = new ServeSessionRunner(
|
|
197
|
+
{
|
|
198
|
+
connection: {
|
|
199
|
+
apiUrl: params.apiUrl,
|
|
200
|
+
taskToken: params.taskToken,
|
|
201
|
+
sessionId: params.sessionId,
|
|
202
|
+
runnerMode: "serving"
|
|
203
|
+
},
|
|
204
|
+
taskId: params.taskId,
|
|
205
|
+
workspaceDir: params.workspaceDir,
|
|
206
|
+
branch: params.branch
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
onEvent: (event) => {
|
|
210
|
+
logger.info("Serve runner event", { eventType: event.type });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
const stop = () => {
|
|
215
|
+
params.onSignal?.();
|
|
216
|
+
runner.stop();
|
|
217
|
+
};
|
|
218
|
+
process.on("SIGTERM", stop);
|
|
219
|
+
process.on("SIGINT", stop);
|
|
220
|
+
await runner.run();
|
|
221
|
+
return outcomeFor(runner);
|
|
222
|
+
}
|
|
223
|
+
export {
|
|
224
|
+
runServingSession
|
|
225
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
startWorkbenchServer
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-UBDSLM44.js";
|
|
4
|
+
import "./chunk-3F4ZZKCA.js";
|
|
5
|
+
import "./chunk-W4LZ7R6Z.js";
|
|
5
6
|
import "./chunk-6Q6LQBWO.js";
|
|
6
7
|
import "./chunk-6W6UZ4SJ.js";
|
|
7
8
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rallycry/conveyor-agent",
|
|
3
|
-
"version": "10.13.
|
|
3
|
+
"version": "10.13.72",
|
|
4
4
|
"description": "Conveyor Agent Runner v10 - PTY harness for the task chat (SDK harness for audit/project-chat). Agent-as-User architecture with BaseService patterns. Works locally too.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|