@h-rig/product-entrypoint-plugin 0.0.6-alpha.157 → 0.0.6-alpha.159
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/metadata.d.ts +2 -0
- package/dist/src/metadata.js +3 -1
- package/dist/src/plugin.js +270 -5
- package/dist/src/product-entrypoint.js +57 -16
- package/dist/src/reconcile.d.ts +0 -1
- package/dist/src/reconcile.js +41 -8
- package/package.json +3 -4
package/dist/src/metadata.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export type StandardProductCommandDescriptor = {
|
|
|
7
7
|
export declare const STANDARD_PRODUCT_COMMANDS: readonly StandardProductCommandDescriptor[];
|
|
8
8
|
export declare function standardProductCliCommandId(command: RigProductCommandName): string;
|
|
9
9
|
export declare function standardProductCliCommandMetadata(descriptor: StandardProductCommandDescriptor): {
|
|
10
|
+
productRoot: boolean;
|
|
11
|
+
rootDefault?: boolean | undefined;
|
|
10
12
|
id: string;
|
|
11
13
|
family: RigProductCommandName;
|
|
12
14
|
description: string;
|
package/dist/src/metadata.js
CHANGED
|
@@ -17,7 +17,9 @@ function standardProductCliCommandMetadata(descriptor) {
|
|
|
17
17
|
family: descriptor.command,
|
|
18
18
|
description: descriptor.description,
|
|
19
19
|
usage: descriptor.usage,
|
|
20
|
-
projectRequired: false
|
|
20
|
+
projectRequired: false,
|
|
21
|
+
...descriptor.command === "launch" ? { rootDefault: true } : {},
|
|
22
|
+
productRoot: true
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
25
|
export {
|
package/dist/src/plugin.js
CHANGED
|
@@ -1,4 +1,268 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
+
var __require = import.meta.require;
|
|
18
|
+
|
|
19
|
+
// packages/product-entrypoint-plugin/src/reconcile.ts
|
|
20
|
+
import { CUSTOM_TYPE_FOR } from "@rig/contracts";
|
|
21
|
+
async function loadCollabApi() {
|
|
22
|
+
return await import("@oh-my-pi/pi-coding-agent/collab/api");
|
|
23
|
+
}
|
|
24
|
+
async function loadSessionManager() {
|
|
25
|
+
return await import("@oh-my-pi/pi-coding-agent/session/session-manager");
|
|
26
|
+
}
|
|
27
|
+
function isRunStatus(value) {
|
|
28
|
+
return typeof value === "string" && RUN_STATUS_VALUES.has(value);
|
|
29
|
+
}
|
|
30
|
+
function isTerminalRunStatus(status) {
|
|
31
|
+
return TERMINAL_RUN_STATUSES.has(status);
|
|
32
|
+
}
|
|
33
|
+
function statusFromSessionEntry(entry) {
|
|
34
|
+
if (entry.type !== "custom" || entry.customType !== CUSTOM_TYPE_FOR["status-changed"])
|
|
35
|
+
return null;
|
|
36
|
+
const data = entry.data !== null && typeof entry.data === "object" ? entry.data : null;
|
|
37
|
+
if (!data)
|
|
38
|
+
return null;
|
|
39
|
+
return isRunStatus(data.to) ? data.to : null;
|
|
40
|
+
}
|
|
41
|
+
function projectRunFromEntries(source, runId) {
|
|
42
|
+
const entries = typeof source === "object" && source !== null && "getEntries" in source ? source.getEntries() : source;
|
|
43
|
+
let status = null;
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
status = statusFromSessionEntry(entry) ?? status;
|
|
46
|
+
}
|
|
47
|
+
return { status };
|
|
48
|
+
}
|
|
49
|
+
function pidExists(pid) {
|
|
50
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
51
|
+
return false;
|
|
52
|
+
try {
|
|
53
|
+
process.kill(pid, 0);
|
|
54
|
+
return true;
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function defaultOpenSession(sessionPath) {
|
|
60
|
+
const { SessionManager } = await loadSessionManager();
|
|
61
|
+
return await SessionManager.open(sessionPath, undefined, undefined, { suppressBreadcrumb: true });
|
|
62
|
+
}
|
|
63
|
+
function projectionRunId(item) {
|
|
64
|
+
if (item.runId?.trim())
|
|
65
|
+
return item.runId.trim();
|
|
66
|
+
if (item.collab?.sessionId?.trim())
|
|
67
|
+
return item.collab.sessionId.trim();
|
|
68
|
+
if (item.session.id?.trim())
|
|
69
|
+
return item.session.id.trim();
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function isLocallyDiscovered(item) {
|
|
73
|
+
return item.source === "session-list";
|
|
74
|
+
}
|
|
75
|
+
function isActiveStatus(status) {
|
|
76
|
+
if (status === null)
|
|
77
|
+
return false;
|
|
78
|
+
return !isTerminalRunStatus(status);
|
|
79
|
+
}
|
|
80
|
+
function shouldFlip(item, status, exists) {
|
|
81
|
+
if (!isActiveStatus(status))
|
|
82
|
+
return false;
|
|
83
|
+
if (item.collab?.stale === true)
|
|
84
|
+
return true;
|
|
85
|
+
const pid = item.collab?.pid;
|
|
86
|
+
return isLocallyDiscovered(item) && pid !== undefined && ACTIVE_LOCAL_RUN_STATUSES.has(status) && !exists(pid);
|
|
87
|
+
}
|
|
88
|
+
function failedStatusData(status, at) {
|
|
89
|
+
return {
|
|
90
|
+
type: "status-changed",
|
|
91
|
+
from: status,
|
|
92
|
+
to: "failed",
|
|
93
|
+
reason: "lazy-reconcile:dead-pid",
|
|
94
|
+
actor: { kind: "agent" },
|
|
95
|
+
at
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function reconcileRuns(input, deps = {}) {
|
|
99
|
+
const listProjections = deps.listCollabSessionProjections ?? (await loadCollabApi()).listCollabSessionProjections;
|
|
100
|
+
const projectRun = deps.projectRunFromSession ?? projectRunFromEntries;
|
|
101
|
+
const exists = deps.processExists ?? pidExists;
|
|
102
|
+
const openSession = deps.openSession ?? defaultOpenSession;
|
|
103
|
+
const nowIso = deps.nowIso ?? (() => new Date().toISOString());
|
|
104
|
+
const projections = await listProjections(input.identityFilter);
|
|
105
|
+
const flipped = [];
|
|
106
|
+
for (const item of projections) {
|
|
107
|
+
const runId = projectionRunId(item);
|
|
108
|
+
const sessionPath = item.session.path || item.collab?.sessionPath || "";
|
|
109
|
+
if (!runId || !sessionPath)
|
|
110
|
+
continue;
|
|
111
|
+
const projection = await projectRun(item.customEntries, runId);
|
|
112
|
+
const status = projection.status;
|
|
113
|
+
if (status === null || !shouldFlip(item, status, exists))
|
|
114
|
+
continue;
|
|
115
|
+
const session = await openSession(sessionPath);
|
|
116
|
+
session.appendCustomEntry(CUSTOM_TYPE_FOR["status-changed"], failedStatusData(status, nowIso()));
|
|
117
|
+
flipped.push({ runId, sessionPath, reason: "lazy-reconcile:dead-pid" });
|
|
118
|
+
}
|
|
119
|
+
return { flipped, resumable: flipped };
|
|
120
|
+
}
|
|
121
|
+
var RUN_STATUS_VALUES, TERMINAL_RUN_STATUSES, ACTIVE_LOCAL_RUN_STATUSES;
|
|
122
|
+
var init_reconcile = __esm(() => {
|
|
123
|
+
RUN_STATUS_VALUES = new Set([
|
|
124
|
+
"created",
|
|
125
|
+
"queued",
|
|
126
|
+
"preparing",
|
|
127
|
+
"running",
|
|
128
|
+
"waiting-approval",
|
|
129
|
+
"waiting-user-input",
|
|
130
|
+
"paused",
|
|
131
|
+
"validating",
|
|
132
|
+
"reviewing",
|
|
133
|
+
"closing-out",
|
|
134
|
+
"needs-attention",
|
|
135
|
+
"completed",
|
|
136
|
+
"failed",
|
|
137
|
+
"stopped"
|
|
138
|
+
]);
|
|
139
|
+
TERMINAL_RUN_STATUSES = new Set([
|
|
140
|
+
"completed",
|
|
141
|
+
"failed",
|
|
142
|
+
"stopped"
|
|
143
|
+
]);
|
|
144
|
+
ACTIVE_LOCAL_RUN_STATUSES = new Set([
|
|
145
|
+
"created",
|
|
146
|
+
"preparing",
|
|
147
|
+
"running",
|
|
148
|
+
"validating",
|
|
149
|
+
"reviewing",
|
|
150
|
+
"closing-out"
|
|
151
|
+
]);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// packages/product-entrypoint-plugin/src/product-entrypoint.ts
|
|
155
|
+
var exports_product_entrypoint = {};
|
|
156
|
+
__export(exports_product_entrypoint, {
|
|
157
|
+
runRigOmpProductCommand: () => runRigOmpProductCommand
|
|
158
|
+
});
|
|
159
|
+
import { resolve } from "path";
|
|
160
|
+
import { runCli } from "@oh-my-pi/pi-coding-agent/cli";
|
|
161
|
+
import { parseArgs } from "@oh-my-pi/pi-coding-agent/cli/args";
|
|
162
|
+
import { resolveCliArgv } from "@oh-my-pi/pi-coding-agent/cli-commands";
|
|
163
|
+
import { prepareAcpTerminalAuthArgs } from "@oh-my-pi/pi-coding-agent/modes/acp/terminal-auth";
|
|
164
|
+
import { runRootCommand } from "@oh-my-pi/pi-coding-agent/main";
|
|
165
|
+
import { createAgentSession } from "@oh-my-pi/pi-coding-agent/sdk";
|
|
166
|
+
import { defineCapability } from "@rig/core/capability";
|
|
167
|
+
import { loadCapabilityForRoot } from "@rig/core/capability-loaders";
|
|
168
|
+
import { resolveRigOmpConfigOverlayPath } from "@rig/core/remote-config";
|
|
169
|
+
import { resolvePluginHost } from "@rig/core/project-plugins";
|
|
170
|
+
import { RUN_IDENTITY_ENV } from "@rig/contracts";
|
|
171
|
+
function withRigDefaultConfig(projectRoot, argv) {
|
|
172
|
+
return ["--config", resolveRigOmpConfigOverlayPath(projectRoot), ...argv];
|
|
173
|
+
}
|
|
174
|
+
async function createRigAgentSession(projectRoot, options = {}) {
|
|
175
|
+
const { host } = await resolvePluginHost(projectRoot);
|
|
176
|
+
const sessionExtensions = host.listSessionExtensions();
|
|
177
|
+
return createAgentSession({
|
|
178
|
+
...options,
|
|
179
|
+
extensions: [...sessionExtensions.map((entry) => (api) => entry.install(api)), ...options.extensions ?? []]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function productArgv(input) {
|
|
183
|
+
if (input.command === "launch" && input.args.length === 0)
|
|
184
|
+
return [];
|
|
185
|
+
if (input.command === "launch" && input.args[0]?.startsWith("-"))
|
|
186
|
+
return [...input.args];
|
|
187
|
+
return [input.command, ...input.args];
|
|
188
|
+
}
|
|
189
|
+
async function runRigOmpProductCommand(input) {
|
|
190
|
+
const projectRoot = resolve(input.projectRoot);
|
|
191
|
+
const previousProjectRoot = process.env.RIG_PROJECT_ROOT;
|
|
192
|
+
const previousCwd = process.cwd();
|
|
193
|
+
const identityEnv = await loadCapabilityForRoot(projectRoot, RunIdentityEnvCap);
|
|
194
|
+
const restorePublicIdentityEnv = identityEnv?.applyIdentityEnv(projectRoot) ?? (() => {});
|
|
195
|
+
process.env.RIG_PROJECT_ROOT = projectRoot;
|
|
196
|
+
process.chdir(projectRoot);
|
|
197
|
+
try {
|
|
198
|
+
const argv = productArgv(input);
|
|
199
|
+
if (argv[0]?.startsWith("__omp_worker_") || argv[0] === "--smoke-test") {
|
|
200
|
+
await runCli(argv);
|
|
201
|
+
return { ok: true, group: "product", command: input.command };
|
|
202
|
+
}
|
|
203
|
+
if (process.stdin.isTTY) {
|
|
204
|
+
const reconcile = await reconcileRuns({
|
|
205
|
+
workspaceRoot: projectRoot,
|
|
206
|
+
identityFilter: identityEnv?.identityFilterFromEnv() ?? {}
|
|
207
|
+
}).catch(() => ({ flipped: [], resumable: [] }));
|
|
208
|
+
globalThis.__RIG_RESUMABLE__ = reconcile.resumable;
|
|
209
|
+
}
|
|
210
|
+
const resolved = resolveCliArgv(argv);
|
|
211
|
+
if ("error" in resolved) {
|
|
212
|
+
process.stderr.write(`error: ${resolved.error}
|
|
213
|
+
`);
|
|
214
|
+
process.exitCode = 1;
|
|
215
|
+
return { ok: true, group: "product", command: input.command };
|
|
216
|
+
}
|
|
217
|
+
const [ompCommand, ...ompCommandArgs] = resolved.argv;
|
|
218
|
+
if (ompCommand === "launch") {
|
|
219
|
+
const args = withRigDefaultConfig(projectRoot, ompCommandArgs);
|
|
220
|
+
await runRootCommand(parseArgs(args), args, { createAgentSession: (options) => createRigAgentSession(projectRoot, options) });
|
|
221
|
+
} else if (ompCommand === "acp") {
|
|
222
|
+
const { args: preparedArgs, terminalAuth } = prepareAcpTerminalAuthArgs(ompCommandArgs);
|
|
223
|
+
const args = withRigDefaultConfig(projectRoot, preparedArgs);
|
|
224
|
+
const parsed = parseArgs(args);
|
|
225
|
+
if (!terminalAuth)
|
|
226
|
+
parsed.mode = "acp";
|
|
227
|
+
await runRootCommand(parsed, args, { createAgentSession: (options) => createRigAgentSession(projectRoot, options) });
|
|
228
|
+
} else if (ompCommand === "join") {
|
|
229
|
+
const link = ompCommandArgs[0]?.trim();
|
|
230
|
+
if (!link) {
|
|
231
|
+
process.stderr.write(`Usage: rig join <link>
|
|
232
|
+
`);
|
|
233
|
+
process.exitCode = 1;
|
|
234
|
+
return { ok: true, group: "product", command: input.command };
|
|
235
|
+
}
|
|
236
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
237
|
+
process.stderr.write(`rig join requires an interactive terminal
|
|
238
|
+
`);
|
|
239
|
+
process.exitCode = 1;
|
|
240
|
+
return { ok: true, group: "product", command: input.command };
|
|
241
|
+
}
|
|
242
|
+
const args = withRigDefaultConfig(projectRoot, []);
|
|
243
|
+
const parsed = parseArgs(args);
|
|
244
|
+
parsed.join = link;
|
|
245
|
+
await runRootCommand(parsed, args, { createAgentSession: (options) => createRigAgentSession(projectRoot, options) });
|
|
246
|
+
} else {
|
|
247
|
+
await runCli(resolved.argv);
|
|
248
|
+
}
|
|
249
|
+
return { ok: true, group: "product", command: input.command };
|
|
250
|
+
} finally {
|
|
251
|
+
restorePublicIdentityEnv();
|
|
252
|
+
process.chdir(previousCwd);
|
|
253
|
+
if (previousProjectRoot === undefined) {
|
|
254
|
+
delete process.env.RIG_PROJECT_ROOT;
|
|
255
|
+
} else {
|
|
256
|
+
process.env.RIG_PROJECT_ROOT = previousProjectRoot;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
var RunIdentityEnvCap;
|
|
261
|
+
var init_product_entrypoint = __esm(() => {
|
|
262
|
+
init_reconcile();
|
|
263
|
+
RunIdentityEnvCap = defineCapability(RUN_IDENTITY_ENV);
|
|
264
|
+
});
|
|
265
|
+
|
|
2
266
|
// packages/product-entrypoint-plugin/src/plugin.ts
|
|
3
267
|
import { definePlugin } from "@rig/core/config";
|
|
4
268
|
|
|
@@ -20,21 +284,22 @@ function standardProductCliCommandMetadata(descriptor) {
|
|
|
20
284
|
family: descriptor.command,
|
|
21
285
|
description: descriptor.description,
|
|
22
286
|
usage: descriptor.usage,
|
|
23
|
-
projectRequired: false
|
|
287
|
+
projectRequired: false,
|
|
288
|
+
...descriptor.command === "launch" ? { rootDefault: true } : {},
|
|
289
|
+
productRoot: true
|
|
24
290
|
};
|
|
25
291
|
}
|
|
26
292
|
|
|
27
293
|
// packages/product-entrypoint-plugin/src/plugin.ts
|
|
28
294
|
async function importProductEntrypoint() {
|
|
29
|
-
|
|
30
|
-
return await import(specifier);
|
|
295
|
+
return await Promise.resolve().then(() => (init_product_entrypoint(), exports_product_entrypoint));
|
|
31
296
|
}
|
|
32
297
|
function createStandardProductCliCommand(descriptor) {
|
|
33
298
|
return {
|
|
34
299
|
...standardProductCliCommandMetadata(descriptor),
|
|
35
300
|
run: async (context, args) => {
|
|
36
|
-
const { runRigOmpProductCommand } = await importProductEntrypoint();
|
|
37
|
-
return
|
|
301
|
+
const { runRigOmpProductCommand: runRigOmpProductCommand2 } = await importProductEntrypoint();
|
|
302
|
+
return runRigOmpProductCommand2({
|
|
38
303
|
projectRoot: context.projectRoot,
|
|
39
304
|
command: descriptor.command,
|
|
40
305
|
args
|
|
@@ -9,23 +9,62 @@ import { resolveCliArgv } from "@oh-my-pi/pi-coding-agent/cli-commands";
|
|
|
9
9
|
import { prepareAcpTerminalAuthArgs } from "@oh-my-pi/pi-coding-agent/modes/acp/terminal-auth";
|
|
10
10
|
import { runRootCommand } from "@oh-my-pi/pi-coding-agent/main";
|
|
11
11
|
import { createAgentSession } from "@oh-my-pi/pi-coding-agent/sdk";
|
|
12
|
-
import {
|
|
12
|
+
import { defineCapability } from "@rig/core/capability";
|
|
13
|
+
import { loadCapabilityForRoot } from "@rig/core/capability-loaders";
|
|
14
|
+
import { resolveRigOmpConfigOverlayPath } from "@rig/core/remote-config";
|
|
15
|
+
import { resolvePluginHost } from "@rig/core/project-plugins";
|
|
16
|
+
import { RUN_IDENTITY_ENV } from "@rig/contracts";
|
|
13
17
|
|
|
14
18
|
// packages/product-entrypoint-plugin/src/reconcile.ts
|
|
15
|
-
import {
|
|
16
|
-
CUSTOM_TYPE_FOR,
|
|
17
|
-
foldRunSessionEntries,
|
|
18
|
-
isTerminalRunStatus
|
|
19
|
-
} from "@rig/contracts";
|
|
19
|
+
import { CUSTOM_TYPE_FOR } from "@rig/contracts";
|
|
20
20
|
async function loadCollabApi() {
|
|
21
21
|
return await import("@oh-my-pi/pi-coding-agent/collab/api");
|
|
22
22
|
}
|
|
23
23
|
async function loadSessionManager() {
|
|
24
24
|
return await import("@oh-my-pi/pi-coding-agent/session/session-manager");
|
|
25
25
|
}
|
|
26
|
+
var RUN_STATUS_VALUES = new Set([
|
|
27
|
+
"created",
|
|
28
|
+
"queued",
|
|
29
|
+
"preparing",
|
|
30
|
+
"running",
|
|
31
|
+
"waiting-approval",
|
|
32
|
+
"waiting-user-input",
|
|
33
|
+
"paused",
|
|
34
|
+
"validating",
|
|
35
|
+
"reviewing",
|
|
36
|
+
"closing-out",
|
|
37
|
+
"needs-attention",
|
|
38
|
+
"completed",
|
|
39
|
+
"failed",
|
|
40
|
+
"stopped"
|
|
41
|
+
]);
|
|
42
|
+
var TERMINAL_RUN_STATUSES = new Set([
|
|
43
|
+
"completed",
|
|
44
|
+
"failed",
|
|
45
|
+
"stopped"
|
|
46
|
+
]);
|
|
47
|
+
function isRunStatus(value) {
|
|
48
|
+
return typeof value === "string" && RUN_STATUS_VALUES.has(value);
|
|
49
|
+
}
|
|
50
|
+
function isTerminalRunStatus(status) {
|
|
51
|
+
return TERMINAL_RUN_STATUSES.has(status);
|
|
52
|
+
}
|
|
53
|
+
function statusFromSessionEntry(entry) {
|
|
54
|
+
if (entry.type !== "custom" || entry.customType !== CUSTOM_TYPE_FOR["status-changed"])
|
|
55
|
+
return null;
|
|
56
|
+
const data = entry.data !== null && typeof entry.data === "object" ? entry.data : null;
|
|
57
|
+
if (!data)
|
|
58
|
+
return null;
|
|
59
|
+
return isRunStatus(data.to) ? data.to : null;
|
|
60
|
+
}
|
|
26
61
|
function projectRunFromEntries(source, runId) {
|
|
27
62
|
const entries = typeof source === "object" && source !== null && "getEntries" in source ? source.getEntries() : source;
|
|
28
|
-
|
|
63
|
+
let status = null;
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
status = statusFromSessionEntry(entry) ?? status;
|
|
66
|
+
}
|
|
67
|
+
return { status };
|
|
29
68
|
}
|
|
30
69
|
var ACTIVE_LOCAL_RUN_STATUSES = new Set([
|
|
31
70
|
"created",
|
|
@@ -109,15 +148,16 @@ async function reconcileRuns(input, deps = {}) {
|
|
|
109
148
|
}
|
|
110
149
|
|
|
111
150
|
// packages/product-entrypoint-plugin/src/product-entrypoint.ts
|
|
112
|
-
|
|
113
|
-
import { resolveRigOmpConfigOverlayPath } from "@rig/runtime/control-plane/remote-config";
|
|
151
|
+
var RunIdentityEnvCap = defineCapability(RUN_IDENTITY_ENV);
|
|
114
152
|
function withRigDefaultConfig(projectRoot, argv) {
|
|
115
153
|
return ["--config", resolveRigOmpConfigOverlayPath(projectRoot), ...argv];
|
|
116
154
|
}
|
|
117
|
-
function createRigAgentSession(options = {}) {
|
|
155
|
+
async function createRigAgentSession(projectRoot, options = {}) {
|
|
156
|
+
const { host } = await resolvePluginHost(projectRoot);
|
|
157
|
+
const sessionExtensions = host.listSessionExtensions();
|
|
118
158
|
return createAgentSession({
|
|
119
159
|
...options,
|
|
120
|
-
extensions: [(api) =>
|
|
160
|
+
extensions: [...sessionExtensions.map((entry) => (api) => entry.install(api)), ...options.extensions ?? []]
|
|
121
161
|
});
|
|
122
162
|
}
|
|
123
163
|
function productArgv(input) {
|
|
@@ -131,7 +171,8 @@ async function runRigOmpProductCommand(input) {
|
|
|
131
171
|
const projectRoot = resolve(input.projectRoot);
|
|
132
172
|
const previousProjectRoot = process.env.RIG_PROJECT_ROOT;
|
|
133
173
|
const previousCwd = process.cwd();
|
|
134
|
-
const
|
|
174
|
+
const identityEnv = await loadCapabilityForRoot(projectRoot, RunIdentityEnvCap);
|
|
175
|
+
const restorePublicIdentityEnv = identityEnv?.applyIdentityEnv(projectRoot) ?? (() => {});
|
|
135
176
|
process.env.RIG_PROJECT_ROOT = projectRoot;
|
|
136
177
|
process.chdir(projectRoot);
|
|
137
178
|
try {
|
|
@@ -143,7 +184,7 @@ async function runRigOmpProductCommand(input) {
|
|
|
143
184
|
if (process.stdin.isTTY) {
|
|
144
185
|
const reconcile = await reconcileRuns({
|
|
145
186
|
workspaceRoot: projectRoot,
|
|
146
|
-
identityFilter: identityFilterFromEnv()
|
|
187
|
+
identityFilter: identityEnv?.identityFilterFromEnv() ?? {}
|
|
147
188
|
}).catch(() => ({ flipped: [], resumable: [] }));
|
|
148
189
|
globalThis.__RIG_RESUMABLE__ = reconcile.resumable;
|
|
149
190
|
}
|
|
@@ -157,14 +198,14 @@ async function runRigOmpProductCommand(input) {
|
|
|
157
198
|
const [ompCommand, ...ompCommandArgs] = resolved.argv;
|
|
158
199
|
if (ompCommand === "launch") {
|
|
159
200
|
const args = withRigDefaultConfig(projectRoot, ompCommandArgs);
|
|
160
|
-
await runRootCommand(parseArgs(args), args, { createAgentSession: createRigAgentSession });
|
|
201
|
+
await runRootCommand(parseArgs(args), args, { createAgentSession: (options) => createRigAgentSession(projectRoot, options) });
|
|
161
202
|
} else if (ompCommand === "acp") {
|
|
162
203
|
const { args: preparedArgs, terminalAuth } = prepareAcpTerminalAuthArgs(ompCommandArgs);
|
|
163
204
|
const args = withRigDefaultConfig(projectRoot, preparedArgs);
|
|
164
205
|
const parsed = parseArgs(args);
|
|
165
206
|
if (!terminalAuth)
|
|
166
207
|
parsed.mode = "acp";
|
|
167
|
-
await runRootCommand(parsed, args, { createAgentSession: createRigAgentSession });
|
|
208
|
+
await runRootCommand(parsed, args, { createAgentSession: (options) => createRigAgentSession(projectRoot, options) });
|
|
168
209
|
} else if (ompCommand === "join") {
|
|
169
210
|
const link = ompCommandArgs[0]?.trim();
|
|
170
211
|
if (!link) {
|
|
@@ -182,7 +223,7 @@ async function runRigOmpProductCommand(input) {
|
|
|
182
223
|
const args = withRigDefaultConfig(projectRoot, []);
|
|
183
224
|
const parsed = parseArgs(args);
|
|
184
225
|
parsed.join = link;
|
|
185
|
-
await runRootCommand(parsed, args, { createAgentSession: createRigAgentSession });
|
|
226
|
+
await runRootCommand(parsed, args, { createAgentSession: (options) => createRigAgentSession(projectRoot, options) });
|
|
186
227
|
} else {
|
|
187
228
|
await runCli(resolved.argv);
|
|
188
229
|
}
|
package/dist/src/reconcile.d.ts
CHANGED
|
@@ -31,5 +31,4 @@ export type LazyReconcileInput = {
|
|
|
31
31
|
readonly identityFilter: CollabRegistryFilter;
|
|
32
32
|
};
|
|
33
33
|
export declare function reconcileRuns(input: LazyReconcileInput, deps?: LazyReconcileDeps): Promise<LazyReconcileResult>;
|
|
34
|
-
export declare const runLazyReconcile: typeof reconcileRuns;
|
|
35
34
|
export {};
|
package/dist/src/reconcile.js
CHANGED
|
@@ -2,20 +2,55 @@
|
|
|
2
2
|
var __require = import.meta.require;
|
|
3
3
|
|
|
4
4
|
// packages/product-entrypoint-plugin/src/reconcile.ts
|
|
5
|
-
import {
|
|
6
|
-
CUSTOM_TYPE_FOR,
|
|
7
|
-
foldRunSessionEntries,
|
|
8
|
-
isTerminalRunStatus
|
|
9
|
-
} from "@rig/contracts";
|
|
5
|
+
import { CUSTOM_TYPE_FOR } from "@rig/contracts";
|
|
10
6
|
async function loadCollabApi() {
|
|
11
7
|
return await import("@oh-my-pi/pi-coding-agent/collab/api");
|
|
12
8
|
}
|
|
13
9
|
async function loadSessionManager() {
|
|
14
10
|
return await import("@oh-my-pi/pi-coding-agent/session/session-manager");
|
|
15
11
|
}
|
|
12
|
+
var RUN_STATUS_VALUES = new Set([
|
|
13
|
+
"created",
|
|
14
|
+
"queued",
|
|
15
|
+
"preparing",
|
|
16
|
+
"running",
|
|
17
|
+
"waiting-approval",
|
|
18
|
+
"waiting-user-input",
|
|
19
|
+
"paused",
|
|
20
|
+
"validating",
|
|
21
|
+
"reviewing",
|
|
22
|
+
"closing-out",
|
|
23
|
+
"needs-attention",
|
|
24
|
+
"completed",
|
|
25
|
+
"failed",
|
|
26
|
+
"stopped"
|
|
27
|
+
]);
|
|
28
|
+
var TERMINAL_RUN_STATUSES = new Set([
|
|
29
|
+
"completed",
|
|
30
|
+
"failed",
|
|
31
|
+
"stopped"
|
|
32
|
+
]);
|
|
33
|
+
function isRunStatus(value) {
|
|
34
|
+
return typeof value === "string" && RUN_STATUS_VALUES.has(value);
|
|
35
|
+
}
|
|
36
|
+
function isTerminalRunStatus(status) {
|
|
37
|
+
return TERMINAL_RUN_STATUSES.has(status);
|
|
38
|
+
}
|
|
39
|
+
function statusFromSessionEntry(entry) {
|
|
40
|
+
if (entry.type !== "custom" || entry.customType !== CUSTOM_TYPE_FOR["status-changed"])
|
|
41
|
+
return null;
|
|
42
|
+
const data = entry.data !== null && typeof entry.data === "object" ? entry.data : null;
|
|
43
|
+
if (!data)
|
|
44
|
+
return null;
|
|
45
|
+
return isRunStatus(data.to) ? data.to : null;
|
|
46
|
+
}
|
|
16
47
|
function projectRunFromEntries(source, runId) {
|
|
17
48
|
const entries = typeof source === "object" && source !== null && "getEntries" in source ? source.getEntries() : source;
|
|
18
|
-
|
|
49
|
+
let status = null;
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
status = statusFromSessionEntry(entry) ?? status;
|
|
52
|
+
}
|
|
53
|
+
return { status };
|
|
19
54
|
}
|
|
20
55
|
var ACTIVE_LOCAL_RUN_STATUSES = new Set([
|
|
21
56
|
"created",
|
|
@@ -97,8 +132,6 @@ async function reconcileRuns(input, deps = {}) {
|
|
|
97
132
|
}
|
|
98
133
|
return { flipped, resumable: flipped };
|
|
99
134
|
}
|
|
100
|
-
var runLazyReconcile = reconcileRuns;
|
|
101
135
|
export {
|
|
102
|
-
runLazyReconcile,
|
|
103
136
|
reconcileRuns
|
|
104
137
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/product-entrypoint-plugin",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.159",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Standard Rig product entrypoint plugin boundary for OMP-backed product commands.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@oh-my-pi/pi-coding-agent": "16.0.4",
|
|
34
|
-
"@rig/
|
|
35
|
-
"@rig/
|
|
36
|
-
"@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.157"
|
|
34
|
+
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.159",
|
|
35
|
+
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.159"
|
|
37
36
|
}
|
|
38
37
|
}
|