@oxagen/cli 3.0.1-792 → 3.0.1-802
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/README.md +6 -6
- package/oxagen.mjs +737 -1007
- package/package.json +1 -1
package/oxagen.mjs
CHANGED
|
@@ -9814,8 +9814,8 @@ function candidatePaths(path2, context) {
|
|
|
9814
9814
|
const base2 = fold(lib.normalize(root)).replace(/\/+$/, "");
|
|
9815
9815
|
return resolved.startsWith(`${base2}/`) ? resolved.slice(base2.length + 1) : void 0;
|
|
9816
9816
|
};
|
|
9817
|
-
const
|
|
9818
|
-
if (
|
|
9817
|
+
const relative11 = cwd !== void 0 ? under2(cwd) : void 0;
|
|
9818
|
+
if (relative11 !== void 0) out.push(relative11);
|
|
9819
9819
|
const fromHome = home !== void 0 ? under2(home) : void 0;
|
|
9820
9820
|
if (fromHome !== void 0) out.push(`~/${fromHome}`);
|
|
9821
9821
|
return out;
|
|
@@ -29915,7 +29915,7 @@ import { readFileSync as readFileSync10 } from "node:fs";
|
|
|
29915
29915
|
import { dirname as dirname9, resolve as resolve3 } from "node:path";
|
|
29916
29916
|
import { fileURLToPath } from "node:url";
|
|
29917
29917
|
function readVersion() {
|
|
29918
|
-
if (true) return "3.0.1-
|
|
29918
|
+
if (true) return "3.0.1-802";
|
|
29919
29919
|
try {
|
|
29920
29920
|
const here = dirname9(fileURLToPath(import.meta.url));
|
|
29921
29921
|
const pkg = JSON.parse(
|
|
@@ -30184,11 +30184,11 @@ function harnessFacts(exec4, name2, platform = process.platform, env = process.e
|
|
|
30184
30184
|
path2 ??= shellExecutable(exec4("sh", ["-lc", `command -v ${name2}`]));
|
|
30185
30185
|
}
|
|
30186
30186
|
if (path2 === void 0) {
|
|
30187
|
-
const
|
|
30187
|
+
const sep14 = platform === "win32" ? "\\" : "/";
|
|
30188
30188
|
const names2 = platform === "win32" ? [`${name2}.exe`, `${name2}.cmd`] : [name2];
|
|
30189
30189
|
outer: for (const dir of wellKnownBinDirs(home, platform, env)) {
|
|
30190
30190
|
for (const file of names2) {
|
|
30191
|
-
const candidate = `${dir}${
|
|
30191
|
+
const candidate = `${dir}${sep14}${file}`;
|
|
30192
30192
|
if (exists(candidate)) {
|
|
30193
30193
|
path2 = candidate;
|
|
30194
30194
|
break outer;
|
|
@@ -36873,8 +36873,8 @@ function harnessFileProblems(harnesses, deps) {
|
|
|
36873
36873
|
if (harnesses.includes("codex"))
|
|
36874
36874
|
check3(deps.paths.codexHooks, deps.readCodexHooks, hooksShapeProblem);
|
|
36875
36875
|
if (harnesses.includes("cursor")) {
|
|
36876
|
-
const
|
|
36877
|
-
if (
|
|
36876
|
+
const relative11 = absoluteHookCommandProblem(deps.runtime.hookCommand);
|
|
36877
|
+
if (relative11 !== void 0) problems.push(relative11);
|
|
36878
36878
|
for (const path2 of deps.paths.cursorHooks)
|
|
36879
36879
|
check3(path2, () => deps.readCursorHooks(path2), cursorHooksShapeProblem);
|
|
36880
36880
|
}
|
|
@@ -39830,6 +39830,9 @@ var init_github2 = __esm({
|
|
|
39830
39830
|
});
|
|
39831
39831
|
|
|
39832
39832
|
// ../../packages/tacho/src/contained/sandbox/profile.ts
|
|
39833
|
+
function sandboxCheckoutPath(repository) {
|
|
39834
|
+
return `${SANDBOX_WORKSPACE}/${repository}`;
|
|
39835
|
+
}
|
|
39833
39836
|
function sandboxMeasurement(placement, guest) {
|
|
39834
39837
|
const digests = [
|
|
39835
39838
|
placement.templateDigest,
|
|
@@ -39878,7 +39881,7 @@ function modalSandboxMeasurement(placement, guest) {
|
|
|
39878
39881
|
function sandboxLaunchMeasurement(placement, guest) {
|
|
39879
39882
|
return placement.profile === MODAL_SANDBOX_PROFILE ? modalSandboxMeasurement(placement, guest) : sandboxMeasurement(placement, guest);
|
|
39880
39883
|
}
|
|
39881
|
-
var SANDBOX_PROFILE, MODAL_SANDBOX_PROFILE, SANDBOX_HARNESSES, SANDBOX_AGENT_USER, SANDBOX_AGENT_UID, SANDBOX_AGENT_GID, SANDBOX_WORKSPACE, SANDBOX_AGENT_HOME, SANDBOX_GATEWAY_PORT, DIGEST, HOST_ID, VM_ID, MODAL_ENVIRONMENT, MODAL_ID;
|
|
39884
|
+
var SANDBOX_PROFILE, MODAL_SANDBOX_PROFILE, SANDBOX_HARNESSES, SANDBOX_AGENT_USER, SANDBOX_AGENT_UID, SANDBOX_AGENT_GID, SANDBOX_WORKSPACE, SANDBOX_AGENT_HOME, SANDBOX_INCLUDED_REPOSITORIES_MAX, SANDBOX_CHECKOUT_HELP_MARKER, SANDBOX_GATEWAY_PORT, DIGEST, HOST_ID, VM_ID, MODAL_ENVIRONMENT, MODAL_ID;
|
|
39882
39885
|
var init_profile = __esm({
|
|
39883
39886
|
"../../packages/tacho/src/contained/sandbox/profile.ts"() {
|
|
39884
39887
|
"use strict";
|
|
@@ -39890,6 +39893,8 @@ var init_profile = __esm({
|
|
|
39890
39893
|
SANDBOX_AGENT_GID = 1e3;
|
|
39891
39894
|
SANDBOX_WORKSPACE = "/workspace";
|
|
39892
39895
|
SANDBOX_AGENT_HOME = "/home/agent";
|
|
39896
|
+
SANDBOX_INCLUDED_REPOSITORIES_MAX = 50;
|
|
39897
|
+
SANDBOX_CHECKOUT_HELP_MARKER = "/workspace/<owner>/<name>";
|
|
39893
39898
|
SANDBOX_GATEWAY_PORT = 43801;
|
|
39894
39899
|
DIGEST = /^sha256:[a-f0-9]{64}$/;
|
|
39895
39900
|
HOST_ID = /^shs_[0-9a-z]+$/;
|
|
@@ -39900,7 +39905,7 @@ var init_profile = __esm({
|
|
|
39900
39905
|
});
|
|
39901
39906
|
|
|
39902
39907
|
// ../../packages/tacho/src/contained/sandbox/request.ts
|
|
39903
|
-
var digest2, hostPlacementSchema, modalPlacementSchema, sandboxPlacementSchema, sandboxRunRequestSchema;
|
|
39908
|
+
var digest2, hostPlacementSchema, modalPlacementSchema, sandboxPlacementSchema, sandboxIncludedRepositorySchema, sandboxRunRequestSchema;
|
|
39904
39909
|
var init_request = __esm({
|
|
39905
39910
|
"../../packages/tacho/src/contained/sandbox/request.ts"() {
|
|
39906
39911
|
"use strict";
|
|
@@ -39927,6 +39932,20 @@ var init_request = __esm({
|
|
|
39927
39932
|
modalPlacementSchema,
|
|
39928
39933
|
hostPlacementSchema
|
|
39929
39934
|
]);
|
|
39935
|
+
sandboxIncludedRepositorySchema = external_exports.object({
|
|
39936
|
+
/** `owner/name` on GitHub, or the project's full path on GitLab. */
|
|
39937
|
+
repository: external_exports.string().min(3).max(1024),
|
|
39938
|
+
/** Present when the repository is a GitLab project. */
|
|
39939
|
+
gitlab: containedGitLabSchema.optional()
|
|
39940
|
+
}).strict().superRefine((included, ctx2) => {
|
|
39941
|
+
const valid = included.gitlab === void 0 ? containedGitHubSchema.shape.repository.safeParse(included.repository).success : isGitLabProjectPath(included.repository);
|
|
39942
|
+
if (!valid)
|
|
39943
|
+
ctx2.addIssue({
|
|
39944
|
+
code: external_exports.ZodIssueCode.custom,
|
|
39945
|
+
path: ["repository"],
|
|
39946
|
+
message: "The repository is not owner/name or a GitLab project path"
|
|
39947
|
+
});
|
|
39948
|
+
});
|
|
39930
39949
|
sandboxRunRequestSchema = external_exports.object({
|
|
39931
39950
|
/** `sbx_…`, the sandbox the control plane placed. */
|
|
39932
39951
|
sandboxId: external_exports.string().regex(/^sbx_[0-9a-z]+$/),
|
|
@@ -39948,8 +39967,28 @@ var init_request = __esm({
|
|
|
39948
39967
|
* launcher resumes the harness's session from disk and sends no prompt.
|
|
39949
39968
|
*/
|
|
39950
39969
|
resume: external_exports.boolean().default(false),
|
|
39970
|
+
/**
|
|
39971
|
+
* The other repositories the run checks out, in the workspace's order
|
|
39972
|
+
* (ADR-8604). Present, every repository sits at its own path under the
|
|
39973
|
+
* workspace folder and the harness starts in the target's. Absent, the
|
|
39974
|
+
* run keeps its one clone at the workspace folder, as before.
|
|
39975
|
+
*/
|
|
39976
|
+
repositories: external_exports.array(sandboxIncludedRepositorySchema).max(SANDBOX_INCLUDED_REPOSITORIES_MAX).optional(),
|
|
39951
39977
|
placement: sandboxPlacementSchema
|
|
39952
39978
|
}).strict().superRefine((request3, ctx2) => {
|
|
39979
|
+
if (request3.repositories !== void 0) {
|
|
39980
|
+
const paths = /* @__PURE__ */ new Set([sandboxCheckoutPath(request3.repository)]);
|
|
39981
|
+
for (const included of request3.repositories) {
|
|
39982
|
+
const path2 = sandboxCheckoutPath(included.repository);
|
|
39983
|
+
if (paths.has(path2))
|
|
39984
|
+
ctx2.addIssue({
|
|
39985
|
+
code: external_exports.ZodIssueCode.custom,
|
|
39986
|
+
path: ["repositories"],
|
|
39987
|
+
message: `Two repositories of the run would share ${path2}`
|
|
39988
|
+
});
|
|
39989
|
+
paths.add(path2);
|
|
39990
|
+
}
|
|
39991
|
+
}
|
|
39953
39992
|
const valid = request3.gitlab === void 0 ? containedGitHubSchema.shape.repository.safeParse(request3.repository).success : isGitLabProjectPath(request3.repository);
|
|
39954
39993
|
if (!valid)
|
|
39955
39994
|
ctx2.addIssue({
|
|
@@ -40246,6 +40285,17 @@ var init_provider_launch = __esm({
|
|
|
40246
40285
|
*/
|
|
40247
40286
|
gitlab: external_exports.object({ host: hostName }).strict().optional(),
|
|
40248
40287
|
branch: external_exports.string().min(1).max(255),
|
|
40288
|
+
/**
|
|
40289
|
+
* The other repositories the run checks out, in the workspace's order
|
|
40290
|
+
* (ADR-8604), each on its default branch. Absent for a template built
|
|
40291
|
+
* before this field, whose launcher would refuse it.
|
|
40292
|
+
*/
|
|
40293
|
+
repositories: external_exports.array(
|
|
40294
|
+
external_exports.object({
|
|
40295
|
+
repositoryFullName: external_exports.string().min(3).max(1024),
|
|
40296
|
+
gitlab: external_exports.object({ host: hostName }).strict().optional()
|
|
40297
|
+
}).strict()
|
|
40298
|
+
).max(SANDBOX_INCLUDED_REPOSITORIES_MAX).optional(),
|
|
40249
40299
|
/** `wo_…`, the work order the run holds, or null. */
|
|
40250
40300
|
workOrderId: external_exports.string().nullable(),
|
|
40251
40301
|
modalEnvironment: external_exports.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/),
|
|
@@ -42263,13 +42313,27 @@ var init_gateway = __esm({
|
|
|
42263
42313
|
// ../../packages/tacho/src/contained/sandbox/harness/claude-code.ts
|
|
42264
42314
|
function claudeCodeEnvironment(options) {
|
|
42265
42315
|
const port = options.gatewayPort ?? SANDBOX_GATEWAY_PORT;
|
|
42266
|
-
const
|
|
42316
|
+
const forgeOf = (gitlabHost) => gitlabHost === void 0 ? {
|
|
42267
42317
|
prefix: `http://127.0.0.1:${port}/github/git/`,
|
|
42268
42318
|
origin: "https://github.com/"
|
|
42269
42319
|
} : {
|
|
42270
|
-
prefix: `http://127.0.0.1:${port}/gitlab/git/${
|
|
42271
|
-
origin: `https://${
|
|
42272
|
-
};
|
|
42320
|
+
prefix: `http://127.0.0.1:${port}/gitlab/git/${gitlabHost}/`,
|
|
42321
|
+
origin: `https://${gitlabHost}/`
|
|
42322
|
+
};
|
|
42323
|
+
const forges = [
|
|
42324
|
+
options.gitlabHost,
|
|
42325
|
+
...(options.included ?? []).map((r) => r.gitlabHost)
|
|
42326
|
+
].map(forgeOf).filter(
|
|
42327
|
+
(forge, at2, all) => all.findIndex((other) => other.origin === forge.origin) === at2
|
|
42328
|
+
);
|
|
42329
|
+
const trusted = options.checkouts ?? [SANDBOX_WORKSPACE];
|
|
42330
|
+
const gitConfig = [
|
|
42331
|
+
...forges.map((forge) => [
|
|
42332
|
+
`url.${forge.prefix}.insteadOf`,
|
|
42333
|
+
forge.origin
|
|
42334
|
+
]),
|
|
42335
|
+
...trusted.map((folder) => ["safe.directory", folder])
|
|
42336
|
+
];
|
|
42273
42337
|
return {
|
|
42274
42338
|
PATH: "/usr/local/bin:/usr/bin:/bin",
|
|
42275
42339
|
HOME: SANDBOX_AGENT_HOME,
|
|
@@ -42284,20 +42348,23 @@ function claudeCodeEnvironment(options) {
|
|
|
42284
42348
|
ENABLE_TOOL_SEARCH: "true",
|
|
42285
42349
|
DISABLE_AUTOUPDATER: "1",
|
|
42286
42350
|
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
|
|
42287
|
-
GIT_CONFIG_COUNT:
|
|
42288
|
-
|
|
42289
|
-
|
|
42290
|
-
|
|
42291
|
-
|
|
42351
|
+
GIT_CONFIG_COUNT: String(gitConfig.length),
|
|
42352
|
+
...Object.fromEntries(
|
|
42353
|
+
gitConfig.flatMap(([key, value], at2) => [
|
|
42354
|
+
[`GIT_CONFIG_KEY_${at2}`, key],
|
|
42355
|
+
[`GIT_CONFIG_VALUE_${at2}`, value]
|
|
42356
|
+
])
|
|
42357
|
+
),
|
|
42292
42358
|
GIT_TERMINAL_PROMPT: "0",
|
|
42293
42359
|
...options.gitlabHost === void 0 ? { GITHUB_REPOSITORY: options.repository } : {},
|
|
42294
42360
|
...options.workOrderId !== null ? { OXAGEN_WORK_ORDER_ID: options.workOrderId } : {}
|
|
42295
42361
|
};
|
|
42296
42362
|
}
|
|
42297
|
-
function claudeCodeArguments(prompt, resume = false) {
|
|
42363
|
+
function claudeCodeArguments(prompt, resume = false, addDirs = []) {
|
|
42364
|
+
const dirs = addDirs.flatMap((dir) => ["--add-dir", dir]);
|
|
42298
42365
|
if (resume)
|
|
42299
|
-
return prompt === null ? ["--continue"] : ["--continue", "--print"];
|
|
42300
|
-
return prompt === null ?
|
|
42366
|
+
return prompt === null ? ["--continue", ...dirs] : ["--continue", ...dirs, "--print"];
|
|
42367
|
+
return prompt === null ? dirs : [...dirs, "--print", "--", prompt];
|
|
42301
42368
|
}
|
|
42302
42369
|
function claudeCodeManagedSettings(hookCommand) {
|
|
42303
42370
|
const hooks = Object.fromEntries(
|
|
@@ -42322,13 +42389,13 @@ function claudeCodeManagedSettings(hookCommand) {
|
|
|
42322
42389
|
2
|
|
42323
42390
|
) + "\n";
|
|
42324
42391
|
}
|
|
42325
|
-
function claudeCodeUserState(gatewayPort = SANDBOX_GATEWAY_PORT) {
|
|
42392
|
+
function claudeCodeUserState(gatewayPort = SANDBOX_GATEWAY_PORT, project2 = SANDBOX_WORKSPACE) {
|
|
42326
42393
|
return {
|
|
42327
42394
|
".claude.json": JSON.stringify({
|
|
42328
42395
|
hasCompletedOnboarding: true,
|
|
42329
42396
|
autoUpdates: false,
|
|
42330
42397
|
projects: {
|
|
42331
|
-
[
|
|
42398
|
+
[project2]: {
|
|
42332
42399
|
hasTrustDialogAccepted: true,
|
|
42333
42400
|
hasCompletedProjectOnboarding: true,
|
|
42334
42401
|
mcpServers: {
|
|
@@ -42518,6 +42585,30 @@ var init_privilege = __esm({
|
|
|
42518
42585
|
// ../../packages/tacho/src/contained/sandbox/launcher.ts
|
|
42519
42586
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
42520
42587
|
import { join as join31 } from "node:path";
|
|
42588
|
+
function sandboxCheckouts(request3) {
|
|
42589
|
+
const target = {
|
|
42590
|
+
repository: request3.repository,
|
|
42591
|
+
...request3.gitlabHost !== void 0 ? { gitlabHost: request3.gitlabHost } : {},
|
|
42592
|
+
path: request3.repositories === void 0 ? SANDBOX_WORKSPACE : sandboxCheckoutPath(request3.repository)
|
|
42593
|
+
};
|
|
42594
|
+
const included = (request3.repositories ?? []).map((other) => ({
|
|
42595
|
+
...other,
|
|
42596
|
+
path: sandboxCheckoutPath(other.repository)
|
|
42597
|
+
}));
|
|
42598
|
+
return { target, included };
|
|
42599
|
+
}
|
|
42600
|
+
function cloneUrl(checkout) {
|
|
42601
|
+
return `https://${checkout.gitlabHost ?? "github.com"}/${checkout.repository}.git`;
|
|
42602
|
+
}
|
|
42603
|
+
function assertRepository(checkout) {
|
|
42604
|
+
if (checkout.gitlabHost !== void 0) {
|
|
42605
|
+
if (!containedGitLabSchema.shape.host.safeParse(checkout.gitlabHost).success || !isGitLabProjectPath(checkout.repository))
|
|
42606
|
+
throw new Error(
|
|
42607
|
+
"The GitLab project must be its full path on a GitLab host name"
|
|
42608
|
+
);
|
|
42609
|
+
} else if (!REPOSITORY.test(checkout.repository) || /\/\.\.?$/.test(checkout.repository))
|
|
42610
|
+
throw new Error("The repository must be owner/name");
|
|
42611
|
+
}
|
|
42521
42612
|
function shellQuote4(value) {
|
|
42522
42613
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
42523
42614
|
}
|
|
@@ -42527,13 +42618,19 @@ function sandboxHarnessEnvironment(request3, gatewayPort) {
|
|
|
42527
42618
|
([name2]) => !isReservedSandboxEnvName(name2)
|
|
42528
42619
|
)
|
|
42529
42620
|
);
|
|
42621
|
+
const checkouts = sandboxCheckouts(request3);
|
|
42530
42622
|
return {
|
|
42531
42623
|
...runtime,
|
|
42532
42624
|
...claudeCodeEnvironment({
|
|
42533
42625
|
...gatewayPort !== void 0 ? { gatewayPort } : {},
|
|
42534
42626
|
repository: request3.repository,
|
|
42535
42627
|
...request3.gitlabHost !== void 0 ? { gitlabHost: request3.gitlabHost } : {},
|
|
42536
|
-
workOrderId: request3.workOrderId
|
|
42628
|
+
workOrderId: request3.workOrderId,
|
|
42629
|
+
included: checkouts.included,
|
|
42630
|
+
checkouts: [
|
|
42631
|
+
checkouts.target.path,
|
|
42632
|
+
...checkouts.included.map((other) => other.path)
|
|
42633
|
+
]
|
|
42537
42634
|
})
|
|
42538
42635
|
};
|
|
42539
42636
|
}
|
|
@@ -42560,13 +42657,19 @@ async function launchSandboxAgent(options) {
|
|
|
42560
42657
|
);
|
|
42561
42658
|
if (!SANDBOX_HARNESSES.includes(request3.harness))
|
|
42562
42659
|
throw new Error(`This sandbox cannot start ${String(request3.harness)}`);
|
|
42563
|
-
|
|
42564
|
-
|
|
42565
|
-
|
|
42566
|
-
|
|
42567
|
-
|
|
42568
|
-
|
|
42569
|
-
|
|
42660
|
+
const checkouts = sandboxCheckouts(request3);
|
|
42661
|
+
assertRepository(checkouts.target);
|
|
42662
|
+
if (checkouts.included.length > SANDBOX_INCLUDED_REPOSITORIES_MAX)
|
|
42663
|
+
throw new Error(
|
|
42664
|
+
`A run checks out at most ${SANDBOX_INCLUDED_REPOSITORIES_MAX} repositories beside its own`
|
|
42665
|
+
);
|
|
42666
|
+
const taken = /* @__PURE__ */ new Set([checkouts.target.path]);
|
|
42667
|
+
for (const other of checkouts.included) {
|
|
42668
|
+
assertRepository(other);
|
|
42669
|
+
if (taken.has(other.path))
|
|
42670
|
+
throw new Error(`Two repositories of the run would share ${other.path}`);
|
|
42671
|
+
taken.add(other.path);
|
|
42672
|
+
}
|
|
42570
42673
|
if (!BRANCH.test(request3.branch) || request3.branch.startsWith("-") || request3.branch.includes(".."))
|
|
42571
42674
|
throw new Error("The branch name is not one Git accepts");
|
|
42572
42675
|
const hooks = pinSandboxHooks(system, {
|
|
@@ -42595,7 +42698,7 @@ async function launchSandboxAgent(options) {
|
|
|
42595
42698
|
try {
|
|
42596
42699
|
prepared = await options.prepare({
|
|
42597
42700
|
sessionId,
|
|
42598
|
-
workspace:
|
|
42701
|
+
workspace: checkouts.target.path
|
|
42599
42702
|
});
|
|
42600
42703
|
for (const directory of [SANDBOX_WORKSPACE, SANDBOX_AGENT_HOME]) {
|
|
42601
42704
|
system.mkdir(directory, 493, AGENT_OWNER);
|
|
@@ -42609,14 +42712,21 @@ async function launchSandboxAgent(options) {
|
|
|
42609
42712
|
request3.branch,
|
|
42610
42713
|
"--single-branch",
|
|
42611
42714
|
"--",
|
|
42612
|
-
|
|
42613
|
-
|
|
42715
|
+
cloneUrl(checkouts.target),
|
|
42716
|
+
checkouts.target.path
|
|
42614
42717
|
],
|
|
42615
42718
|
{ ...asAgent, cwd: SANDBOX_AGENT_HOME, timeoutMs: 15 * 6e4 }
|
|
42616
42719
|
);
|
|
42720
|
+
for (const other of checkouts.included) {
|
|
42721
|
+
await system.exec(
|
|
42722
|
+
"git",
|
|
42723
|
+
["clone", "--single-branch", "--", cloneUrl(other), other.path],
|
|
42724
|
+
{ ...asAgent, cwd: SANDBOX_AGENT_HOME, timeoutMs: 15 * 6e4 }
|
|
42725
|
+
);
|
|
42726
|
+
}
|
|
42617
42727
|
}
|
|
42618
42728
|
for (const [name2, contents] of Object.entries(
|
|
42619
|
-
claudeCodeUserState(options.gatewayPort)
|
|
42729
|
+
claudeCodeUserState(options.gatewayPort, checkouts.target.path)
|
|
42620
42730
|
)) {
|
|
42621
42731
|
system.writeFile(
|
|
42622
42732
|
join31(SANDBOX_AGENT_HOME, name2),
|
|
@@ -42627,7 +42737,7 @@ async function launchSandboxAgent(options) {
|
|
|
42627
42737
|
}
|
|
42628
42738
|
const harnessVersion = (await system.exec("claude", ["--version"], {
|
|
42629
42739
|
...asAgent,
|
|
42630
|
-
cwd:
|
|
42740
|
+
cwd: checkouts.target.path,
|
|
42631
42741
|
timeoutMs: 3e4
|
|
42632
42742
|
})).stdout.trim().split(/\s+/)[0]?.slice(0, 64);
|
|
42633
42743
|
if (!harnessVersion)
|
|
@@ -42645,12 +42755,19 @@ async function launchSandboxAgent(options) {
|
|
|
42645
42755
|
);
|
|
42646
42756
|
const prompt = request3.prompt ?? registered?.prompt ?? null;
|
|
42647
42757
|
const pty = ptyCommand(
|
|
42648
|
-
[
|
|
42758
|
+
[
|
|
42759
|
+
"claude",
|
|
42760
|
+
...claudeCodeArguments(
|
|
42761
|
+
prompt,
|
|
42762
|
+
request3.resume,
|
|
42763
|
+
checkouts.included.map((other) => other.path)
|
|
42764
|
+
)
|
|
42765
|
+
],
|
|
42649
42766
|
options.harnessSession
|
|
42650
42767
|
);
|
|
42651
42768
|
const child = system.spawn(pty.file, pty.args, {
|
|
42652
42769
|
...asAgent,
|
|
42653
|
-
cwd:
|
|
42770
|
+
cwd: checkouts.target.path
|
|
42654
42771
|
});
|
|
42655
42772
|
started = true;
|
|
42656
42773
|
const stop = () => child.kill("SIGTERM");
|
|
@@ -43244,6 +43361,12 @@ function createContainedRunner(options) {
|
|
|
43244
43361
|
repository: input.repository,
|
|
43245
43362
|
...input.gitlab !== void 0 ? { gitlabHost: input.gitlab.host } : {},
|
|
43246
43363
|
branch: input.branch,
|
|
43364
|
+
...input.repositories !== void 0 ? {
|
|
43365
|
+
repositories: input.repositories.map((included) => ({
|
|
43366
|
+
repository: included.repository,
|
|
43367
|
+
...included.gitlab !== void 0 ? { gitlabHost: included.gitlab.host } : {}
|
|
43368
|
+
}))
|
|
43369
|
+
} : {},
|
|
43247
43370
|
workOrderId: input.workOrderId,
|
|
43248
43371
|
environment: input.environment,
|
|
43249
43372
|
resume: input.resume
|
|
@@ -60509,10 +60632,10 @@ function toolContext(body2) {
|
|
|
60509
60632
|
continue;
|
|
60510
60633
|
if (path2.startsWith("/") || /^[A-Za-z]:/.test(path2) || path2.includes("\\"))
|
|
60511
60634
|
continue;
|
|
60512
|
-
const
|
|
60513
|
-
if (
|
|
60514
|
-
files2.delete(
|
|
60515
|
-
files2.add(
|
|
60635
|
+
const relative11 = path2.replace(/^\.\//, "");
|
|
60636
|
+
if (relative11.length === 0 || relative11.split("/").includes("..")) continue;
|
|
60637
|
+
files2.delete(relative11);
|
|
60638
|
+
files2.add(relative11);
|
|
60516
60639
|
if (files2.size > 64) files2.delete(files2.values().next().value ?? "");
|
|
60517
60640
|
}
|
|
60518
60641
|
if (name2 === "Skill" && typeof args["skill"] === "string" && args["skill"].length <= 256)
|
|
@@ -66608,6 +66731,12 @@ async function launchSandboxFromEnv(deps) {
|
|
|
66608
66731
|
repository: launch.repositoryFullName,
|
|
66609
66732
|
...launch.gitlab !== void 0 ? { gitlab: launch.gitlab } : {},
|
|
66610
66733
|
branch: launch.branch,
|
|
66734
|
+
...launch.repositories !== void 0 ? {
|
|
66735
|
+
repositories: launch.repositories.map((included) => ({
|
|
66736
|
+
repository: included.repositoryFullName,
|
|
66737
|
+
...included.gitlab !== void 0 ? { gitlab: included.gitlab } : {}
|
|
66738
|
+
}))
|
|
66739
|
+
} : {},
|
|
66611
66740
|
workOrderId: launch.workOrderId,
|
|
66612
66741
|
environment,
|
|
66613
66742
|
resume: launch.resume,
|
|
@@ -67052,16 +67181,16 @@ function gitHeadIn(cwd) {
|
|
|
67052
67181
|
}
|
|
67053
67182
|
function claimRefusalMessage(error2, criterionId, head3) {
|
|
67054
67183
|
const said = controlErrorMessage(error2);
|
|
67055
|
-
const
|
|
67184
|
+
const short4 = head3.slice(0, 7);
|
|
67056
67185
|
if (controlErrorReason(error2) === "stale_head")
|
|
67057
|
-
return `Oxagen refused the claim on ${criterionId} at commit ${
|
|
67186
|
+
return `Oxagen refused the claim on ${criterionId} at commit ${short4}, so nothing was recorded. ${said} Push commit ${short4} to the pull request first, then claim again.`;
|
|
67058
67187
|
if (error2.status === 400)
|
|
67059
67188
|
return `Oxagen refused the claim on ${criterionId}, so nothing was recorded. ${said} Name an item of the Done Checklist in your first prompt, such as c1.`;
|
|
67060
67189
|
return `Oxagen refused the claim on ${criterionId}, so nothing was recorded. ${said}`;
|
|
67061
67190
|
}
|
|
67062
67191
|
function claimAnswerMessage(answer, criterionId, workOrderId, head3) {
|
|
67063
|
-
const
|
|
67064
|
-
return answer.repeat ? `Oxagen already had this claim on ${criterionId} at commit ${
|
|
67192
|
+
const short4 = head3.slice(0, 7);
|
|
67193
|
+
return answer.repeat ? `Oxagen already had this claim on ${criterionId} at commit ${short4}, so nothing new was recorded. The first text stands.` : `Claimed ${criterionId} at commit ${short4} for ${workOrderId}. A person still checks each item and decides.`;
|
|
67065
67194
|
}
|
|
67066
67195
|
async function workClaim(criterionId, options, deps) {
|
|
67067
67196
|
if (!WORK_CRITERION_ID_PATTERN.test(criterionId)) {
|
|
@@ -71180,7 +71309,7 @@ import {
|
|
|
71180
71309
|
writeFileSync as writeFileSync7
|
|
71181
71310
|
} from "node:fs";
|
|
71182
71311
|
import { dirname as dirname32, join as join57, resolve as resolve22 } from "node:path";
|
|
71183
|
-
function bundlePath(root,
|
|
71312
|
+
function bundlePath(root, relative11, create2 = false) {
|
|
71184
71313
|
const absolute = resolve22(root);
|
|
71185
71314
|
if (create2) mkdirSync10(absolute, { recursive: true, mode: 448 });
|
|
71186
71315
|
if (lstatSync11(absolute).isSymbolicLink() || !lstatSync11(absolute).isDirectory()) {
|
|
@@ -71188,14 +71317,14 @@ function bundlePath(root, relative12, create2 = false) {
|
|
|
71188
71317
|
}
|
|
71189
71318
|
const base2 = realpathSync8(absolute);
|
|
71190
71319
|
let current = base2;
|
|
71191
|
-
const parts =
|
|
71320
|
+
const parts = relative11.split("/");
|
|
71192
71321
|
for (let i2 = 0; i2 < parts.length; i2++) {
|
|
71193
71322
|
current = join57(current, parts[i2]);
|
|
71194
71323
|
try {
|
|
71195
71324
|
const stat7 = lstatSync11(current);
|
|
71196
71325
|
if (stat7.isSymbolicLink() || i2 < parts.length - 1 && !stat7.isDirectory()) {
|
|
71197
71326
|
arpFail(
|
|
71198
|
-
`The bundle path ${
|
|
71327
|
+
`The bundle path ${relative11} passes through a symlink or a file where a directory belongs.`
|
|
71199
71328
|
);
|
|
71200
71329
|
}
|
|
71201
71330
|
} catch (error2) {
|
|
@@ -71205,36 +71334,36 @@ function bundlePath(root, relative12, create2 = false) {
|
|
|
71205
71334
|
}
|
|
71206
71335
|
}
|
|
71207
71336
|
if (realpathSync8(dirname32(current)) !== dirname32(current)) {
|
|
71208
|
-
arpFail(`The bundle directory changed while ${
|
|
71337
|
+
arpFail(`The bundle directory changed while ${relative11} was read.`);
|
|
71209
71338
|
}
|
|
71210
71339
|
return current;
|
|
71211
71340
|
}
|
|
71212
|
-
function readBounded(root,
|
|
71213
|
-
const path2 = bundlePath(root,
|
|
71341
|
+
function readBounded(root, relative11, limit = ARP_MAX_BLOB_BYTES) {
|
|
71342
|
+
const path2 = bundlePath(root, relative11);
|
|
71214
71343
|
const fd2 = openSync9(path2, constants7.O_RDONLY | constants7.O_NOFOLLOW);
|
|
71215
71344
|
try {
|
|
71216
71345
|
const stat7 = fstatSync2(fd2);
|
|
71217
71346
|
if (!stat7.isFile() || stat7.size > limit)
|
|
71218
71347
|
arpFail(
|
|
71219
|
-
`The bundle file ${
|
|
71348
|
+
`The bundle file ${relative11} is not a regular file of at most ${limit} bytes.`
|
|
71220
71349
|
);
|
|
71221
71350
|
const bytes = Buffer.alloc(stat7.size);
|
|
71222
71351
|
let offset = 0;
|
|
71223
71352
|
while (offset < bytes.length) {
|
|
71224
71353
|
const count13 = readSync5(fd2, bytes, offset, bytes.length - offset, offset);
|
|
71225
71354
|
if (!count13)
|
|
71226
|
-
arpFail(`The bundle file ${
|
|
71355
|
+
arpFail(`The bundle file ${relative11} changed while it was read.`);
|
|
71227
71356
|
offset += count13;
|
|
71228
71357
|
}
|
|
71229
71358
|
if (readSync5(fd2, Buffer.alloc(1), 0, 1, offset) !== 0)
|
|
71230
|
-
arpFail(`The bundle file ${
|
|
71359
|
+
arpFail(`The bundle file ${relative11} changed while it was read.`);
|
|
71231
71360
|
return bytes;
|
|
71232
71361
|
} finally {
|
|
71233
71362
|
closeSync9(fd2);
|
|
71234
71363
|
}
|
|
71235
71364
|
}
|
|
71236
|
-
function writeNew2(root,
|
|
71237
|
-
const path2 = bundlePath(root,
|
|
71365
|
+
function writeNew2(root, relative11, bytes) {
|
|
71366
|
+
const path2 = bundlePath(root, relative11, true);
|
|
71238
71367
|
const fd2 = openSync9(
|
|
71239
71368
|
path2,
|
|
71240
71369
|
constants7.O_WRONLY | constants7.O_CREAT | constants7.O_EXCL | constants7.O_NOFOLLOW,
|
|
@@ -73211,7 +73340,7 @@ function buildTachoProgram(options = {}) {
|
|
|
73211
73340
|
"The launcher inside a sandbox the control plane started (not meant to be run by hand)"
|
|
73212
73341
|
);
|
|
73213
73342
|
sandbox.command("launch").description(
|
|
73214
|
-
|
|
73343
|
+
`Start the run this sandbox was created for: enroll the daemon with the run token, clone each repository at ${SANDBOX_CHECKOUT_HELP_MARKER}, register the launch, start the harness`
|
|
73215
73344
|
).requiredOption(
|
|
73216
73345
|
"--from-env",
|
|
73217
73346
|
"Read the launch and the run token from OXAGEN_SANDBOX_LAUNCH and OXAGEN_SANDBOX_RUN_TOKEN"
|
|
@@ -73272,6 +73401,7 @@ var init_main = __esm({
|
|
|
73272
73401
|
init_enroll();
|
|
73273
73402
|
init_export();
|
|
73274
73403
|
init_legacy_name();
|
|
73404
|
+
init_profile();
|
|
73275
73405
|
init_mcp_stdio();
|
|
73276
73406
|
init_reassign();
|
|
73277
73407
|
init_run();
|
|
@@ -73315,7 +73445,7 @@ var init_package = __esm({
|
|
|
73315
73445
|
"package.json"() {
|
|
73316
73446
|
package_default = {
|
|
73317
73447
|
name: "@oxagen/cli",
|
|
73318
|
-
version: "3.0.1-
|
|
73448
|
+
version: "3.0.1-802",
|
|
73319
73449
|
description: "Oxagen governance CLI: spend, source tracking, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
|
|
73320
73450
|
type: "module",
|
|
73321
73451
|
main: "./dist/index.js",
|
|
@@ -82102,10 +82232,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
82102
82232
|
let offset = bm.offset;
|
|
82103
82233
|
let commentEnd = null;
|
|
82104
82234
|
for (const collItem of bm.items) {
|
|
82105
|
-
const { start, key, sep:
|
|
82235
|
+
const { start, key, sep: sep14, value } = collItem;
|
|
82106
82236
|
const keyProps = resolveProps.resolveProps(start, {
|
|
82107
82237
|
indicator: "explicit-key-ind",
|
|
82108
|
-
next: key ??
|
|
82238
|
+
next: key ?? sep14?.[0],
|
|
82109
82239
|
offset,
|
|
82110
82240
|
onError,
|
|
82111
82241
|
parentIndent: bm.indent,
|
|
@@ -82119,7 +82249,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
82119
82249
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
82120
82250
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
82121
82251
|
}
|
|
82122
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
82252
|
+
if (!keyProps.anchor && !keyProps.tag && !sep14) {
|
|
82123
82253
|
commentEnd = keyProps.end;
|
|
82124
82254
|
if (keyProps.comment) {
|
|
82125
82255
|
if (map.comment)
|
|
@@ -82143,7 +82273,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
82143
82273
|
ctx2.atKey = false;
|
|
82144
82274
|
if (utilMapIncludes.mapIncludes(ctx2, map.items, keyNode))
|
|
82145
82275
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
82146
|
-
const valueProps = resolveProps.resolveProps(
|
|
82276
|
+
const valueProps = resolveProps.resolveProps(sep14 ?? [], {
|
|
82147
82277
|
indicator: "map-value-ind",
|
|
82148
82278
|
next: value,
|
|
82149
82279
|
offset: keyNode.range[2],
|
|
@@ -82159,7 +82289,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
82159
82289
|
if (ctx2.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
82160
82290
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
82161
82291
|
}
|
|
82162
|
-
const valueNode = value ? composeNode(ctx2, value, valueProps, onError) : composeEmptyNode(ctx2, offset,
|
|
82292
|
+
const valueNode = value ? composeNode(ctx2, value, valueProps, onError) : composeEmptyNode(ctx2, offset, sep14, null, valueProps, onError);
|
|
82163
82293
|
if (ctx2.schema.compat)
|
|
82164
82294
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
82165
82295
|
offset = valueNode.range[2];
|
|
@@ -82250,7 +82380,7 @@ var require_resolve_end = __commonJS({
|
|
|
82250
82380
|
let comment = "";
|
|
82251
82381
|
if (end) {
|
|
82252
82382
|
let hasSpace = false;
|
|
82253
|
-
let
|
|
82383
|
+
let sep14 = "";
|
|
82254
82384
|
for (const token of end) {
|
|
82255
82385
|
const { source, type } = token;
|
|
82256
82386
|
switch (type) {
|
|
@@ -82264,13 +82394,13 @@ var require_resolve_end = __commonJS({
|
|
|
82264
82394
|
if (!comment)
|
|
82265
82395
|
comment = cb;
|
|
82266
82396
|
else
|
|
82267
|
-
comment +=
|
|
82268
|
-
|
|
82397
|
+
comment += sep14 + cb;
|
|
82398
|
+
sep14 = "";
|
|
82269
82399
|
break;
|
|
82270
82400
|
}
|
|
82271
82401
|
case "newline":
|
|
82272
82402
|
if (comment)
|
|
82273
|
-
|
|
82403
|
+
sep14 += source;
|
|
82274
82404
|
hasSpace = true;
|
|
82275
82405
|
break;
|
|
82276
82406
|
default:
|
|
@@ -82313,18 +82443,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
82313
82443
|
let offset = fc.offset + fc.start.source.length;
|
|
82314
82444
|
for (let i2 = 0; i2 < fc.items.length; ++i2) {
|
|
82315
82445
|
const collItem = fc.items[i2];
|
|
82316
|
-
const { start, key, sep:
|
|
82446
|
+
const { start, key, sep: sep14, value } = collItem;
|
|
82317
82447
|
const props = resolveProps.resolveProps(start, {
|
|
82318
82448
|
flow: fcName,
|
|
82319
82449
|
indicator: "explicit-key-ind",
|
|
82320
|
-
next: key ??
|
|
82450
|
+
next: key ?? sep14?.[0],
|
|
82321
82451
|
offset,
|
|
82322
82452
|
onError,
|
|
82323
82453
|
parentIndent: fc.indent,
|
|
82324
82454
|
startOnNewline: false
|
|
82325
82455
|
});
|
|
82326
82456
|
if (!props.found) {
|
|
82327
|
-
if (!props.anchor && !props.tag && !
|
|
82457
|
+
if (!props.anchor && !props.tag && !sep14 && !value) {
|
|
82328
82458
|
if (i2 === 0 && props.comma)
|
|
82329
82459
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
82330
82460
|
else if (i2 < fc.items.length - 1)
|
|
@@ -82378,8 +82508,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
82378
82508
|
}
|
|
82379
82509
|
}
|
|
82380
82510
|
}
|
|
82381
|
-
if (!isMap3 && !
|
|
82382
|
-
const valueNode = value ? composeNode(ctx2, value, props, onError) : composeEmptyNode(ctx2, props.end,
|
|
82511
|
+
if (!isMap3 && !sep14 && !props.found) {
|
|
82512
|
+
const valueNode = value ? composeNode(ctx2, value, props, onError) : composeEmptyNode(ctx2, props.end, sep14, null, props, onError);
|
|
82383
82513
|
coll.items.push(valueNode);
|
|
82384
82514
|
offset = valueNode.range[2];
|
|
82385
82515
|
if (isBlock(value))
|
|
@@ -82391,7 +82521,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
82391
82521
|
if (isBlock(key))
|
|
82392
82522
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
82393
82523
|
ctx2.atKey = false;
|
|
82394
|
-
const valueProps = resolveProps.resolveProps(
|
|
82524
|
+
const valueProps = resolveProps.resolveProps(sep14 ?? [], {
|
|
82395
82525
|
flow: fcName,
|
|
82396
82526
|
indicator: "map-value-ind",
|
|
82397
82527
|
next: value,
|
|
@@ -82402,8 +82532,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
82402
82532
|
});
|
|
82403
82533
|
if (valueProps.found) {
|
|
82404
82534
|
if (!isMap3 && !props.found && ctx2.options.strict) {
|
|
82405
|
-
if (
|
|
82406
|
-
for (const st of
|
|
82535
|
+
if (sep14)
|
|
82536
|
+
for (const st of sep14) {
|
|
82407
82537
|
if (st === valueProps.found)
|
|
82408
82538
|
break;
|
|
82409
82539
|
if (st.type === "newline") {
|
|
@@ -82420,7 +82550,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
82420
82550
|
else
|
|
82421
82551
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
82422
82552
|
}
|
|
82423
|
-
const valueNode = value ? composeNode(ctx2, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx2, valueProps.end,
|
|
82553
|
+
const valueNode = value ? composeNode(ctx2, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx2, valueProps.end, sep14, null, valueProps, onError) : null;
|
|
82424
82554
|
if (valueNode) {
|
|
82425
82555
|
if (isBlock(value))
|
|
82426
82556
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -82600,7 +82730,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
82600
82730
|
chompStart = i2 + 1;
|
|
82601
82731
|
}
|
|
82602
82732
|
let value = "";
|
|
82603
|
-
let
|
|
82733
|
+
let sep14 = "";
|
|
82604
82734
|
let prevMoreIndented = false;
|
|
82605
82735
|
for (let i2 = 0; i2 < contentStart; ++i2)
|
|
82606
82736
|
value += lines[i2][0].slice(trimIndent) + "\n";
|
|
@@ -82617,24 +82747,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
82617
82747
|
indent = "";
|
|
82618
82748
|
}
|
|
82619
82749
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
82620
|
-
value +=
|
|
82621
|
-
|
|
82750
|
+
value += sep14 + indent.slice(trimIndent) + content;
|
|
82751
|
+
sep14 = "\n";
|
|
82622
82752
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
82623
|
-
if (
|
|
82624
|
-
|
|
82625
|
-
else if (!prevMoreIndented &&
|
|
82626
|
-
|
|
82627
|
-
value +=
|
|
82628
|
-
|
|
82753
|
+
if (sep14 === " ")
|
|
82754
|
+
sep14 = "\n";
|
|
82755
|
+
else if (!prevMoreIndented && sep14 === "\n")
|
|
82756
|
+
sep14 = "\n\n";
|
|
82757
|
+
value += sep14 + indent.slice(trimIndent) + content;
|
|
82758
|
+
sep14 = "\n";
|
|
82629
82759
|
prevMoreIndented = true;
|
|
82630
82760
|
} else if (content === "") {
|
|
82631
|
-
if (
|
|
82761
|
+
if (sep14 === "\n")
|
|
82632
82762
|
value += "\n";
|
|
82633
82763
|
else
|
|
82634
|
-
|
|
82764
|
+
sep14 = "\n";
|
|
82635
82765
|
} else {
|
|
82636
|
-
value +=
|
|
82637
|
-
|
|
82766
|
+
value += sep14 + content;
|
|
82767
|
+
sep14 = " ";
|
|
82638
82768
|
prevMoreIndented = false;
|
|
82639
82769
|
}
|
|
82640
82770
|
}
|
|
@@ -82817,25 +82947,25 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
82817
82947
|
trimBoth = /^[ \t]+|[ \t]+$/g;
|
|
82818
82948
|
}
|
|
82819
82949
|
let res = match[1].replace(trimEnd, "");
|
|
82820
|
-
let
|
|
82950
|
+
let sep14 = " ";
|
|
82821
82951
|
let pos = line.lastIndex;
|
|
82822
82952
|
while (match = line.exec(source)) {
|
|
82823
82953
|
const lm = match[1].replace(trimBoth, "");
|
|
82824
82954
|
if (lm === "") {
|
|
82825
|
-
if (
|
|
82826
|
-
res +=
|
|
82955
|
+
if (sep14 === "\n")
|
|
82956
|
+
res += sep14;
|
|
82827
82957
|
else
|
|
82828
|
-
|
|
82958
|
+
sep14 = "\n";
|
|
82829
82959
|
} else {
|
|
82830
|
-
res +=
|
|
82831
|
-
|
|
82960
|
+
res += sep14 + lm;
|
|
82961
|
+
sep14 = " ";
|
|
82832
82962
|
}
|
|
82833
82963
|
pos = line.lastIndex;
|
|
82834
82964
|
}
|
|
82835
82965
|
const last = /[ \t]*(.*)/sy;
|
|
82836
82966
|
last.lastIndex = pos;
|
|
82837
82967
|
match = last.exec(source);
|
|
82838
|
-
return res +
|
|
82968
|
+
return res + sep14 + (match?.[1] ?? "");
|
|
82839
82969
|
}
|
|
82840
82970
|
function doubleQuotedValue(source, onError) {
|
|
82841
82971
|
let res = "";
|
|
@@ -83645,14 +83775,14 @@ var require_cst_stringify = __commonJS({
|
|
|
83645
83775
|
}
|
|
83646
83776
|
}
|
|
83647
83777
|
}
|
|
83648
|
-
function stringifyItem({ start, key, sep:
|
|
83778
|
+
function stringifyItem({ start, key, sep: sep14, value }) {
|
|
83649
83779
|
let res = "";
|
|
83650
83780
|
for (const st of start)
|
|
83651
83781
|
res += st.source;
|
|
83652
83782
|
if (key)
|
|
83653
83783
|
res += stringifyToken(key);
|
|
83654
|
-
if (
|
|
83655
|
-
for (const st of
|
|
83784
|
+
if (sep14)
|
|
83785
|
+
for (const st of sep14)
|
|
83656
83786
|
res += st.source;
|
|
83657
83787
|
if (value)
|
|
83658
83788
|
res += stringifyToken(value);
|
|
@@ -84819,18 +84949,18 @@ var require_parser = __commonJS({
|
|
|
84819
84949
|
if (this.type === "map-value-ind") {
|
|
84820
84950
|
const prev = getPrevProps(this.peek(2));
|
|
84821
84951
|
const start = getFirstKeyStartProps(prev);
|
|
84822
|
-
let
|
|
84952
|
+
let sep14;
|
|
84823
84953
|
if (scalar2.end) {
|
|
84824
|
-
|
|
84825
|
-
|
|
84954
|
+
sep14 = scalar2.end;
|
|
84955
|
+
sep14.push(this.sourceToken);
|
|
84826
84956
|
delete scalar2.end;
|
|
84827
84957
|
} else
|
|
84828
|
-
|
|
84958
|
+
sep14 = [this.sourceToken];
|
|
84829
84959
|
const map = {
|
|
84830
84960
|
type: "block-map",
|
|
84831
84961
|
offset: scalar2.offset,
|
|
84832
84962
|
indent: scalar2.indent,
|
|
84833
|
-
items: [{ start, key: scalar2, sep:
|
|
84963
|
+
items: [{ start, key: scalar2, sep: sep14 }]
|
|
84834
84964
|
};
|
|
84835
84965
|
this.onKeyLine = true;
|
|
84836
84966
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -84983,15 +85113,15 @@ var require_parser = __commonJS({
|
|
|
84983
85113
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
84984
85114
|
const start2 = getFirstKeyStartProps(it.start);
|
|
84985
85115
|
const key = it.key;
|
|
84986
|
-
const
|
|
84987
|
-
|
|
85116
|
+
const sep14 = it.sep;
|
|
85117
|
+
sep14.push(this.sourceToken);
|
|
84988
85118
|
delete it.key;
|
|
84989
85119
|
delete it.sep;
|
|
84990
85120
|
this.stack.push({
|
|
84991
85121
|
type: "block-map",
|
|
84992
85122
|
offset: this.offset,
|
|
84993
85123
|
indent: this.indent,
|
|
84994
|
-
items: [{ start: start2, key, sep:
|
|
85124
|
+
items: [{ start: start2, key, sep: sep14 }]
|
|
84995
85125
|
});
|
|
84996
85126
|
} else if (start.length > 0) {
|
|
84997
85127
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -85185,13 +85315,13 @@ var require_parser = __commonJS({
|
|
|
85185
85315
|
const prev = getPrevProps(parent);
|
|
85186
85316
|
const start = getFirstKeyStartProps(prev);
|
|
85187
85317
|
fixFlowSeqItems(fc);
|
|
85188
|
-
const
|
|
85189
|
-
|
|
85318
|
+
const sep14 = fc.end.splice(1, fc.end.length);
|
|
85319
|
+
sep14.push(this.sourceToken);
|
|
85190
85320
|
const map = {
|
|
85191
85321
|
type: "block-map",
|
|
85192
85322
|
offset: fc.offset,
|
|
85193
85323
|
indent: fc.indent,
|
|
85194
|
-
items: [{ start, key: fc, sep:
|
|
85324
|
+
items: [{ start, key: fc, sep: sep14 }]
|
|
85195
85325
|
};
|
|
85196
85326
|
this.onKeyLine = true;
|
|
85197
85327
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -86486,6 +86616,7 @@ __export(sandbox_attach_exports, {
|
|
|
86486
86616
|
DETACH_KEY: () => DETACH_KEY,
|
|
86487
86617
|
MAX_RECONNECTS: () => MAX_RECONNECTS,
|
|
86488
86618
|
MAX_START_WAITS: () => MAX_START_WAITS,
|
|
86619
|
+
TAKE_CONTROL_REASON: () => TAKE_CONTROL_REASON,
|
|
86489
86620
|
attachToRun: () => attachToRun,
|
|
86490
86621
|
parseRunTarget: () => parseRunTarget,
|
|
86491
86622
|
processIo: () => processIo,
|
|
@@ -86523,8 +86654,9 @@ function encodeInput(bytes) {
|
|
|
86523
86654
|
data: Buffer.from(bytes).toString("base64")
|
|
86524
86655
|
});
|
|
86525
86656
|
}
|
|
86526
|
-
async function terminalSession(relay, mode, runName, io, writer) {
|
|
86657
|
+
async function terminalSession(relay, mode, runName, io, writer, opts = {}) {
|
|
86527
86658
|
let token = relay.token;
|
|
86659
|
+
let granted = opts.paused !== true;
|
|
86528
86660
|
let lastSeq = null;
|
|
86529
86661
|
let current = null;
|
|
86530
86662
|
let detaching = false;
|
|
@@ -86551,14 +86683,14 @@ async function terminalSession(relay, mode, runName, io, writer) {
|
|
|
86551
86683
|
if (control) {
|
|
86552
86684
|
const at2 = chunk.indexOf(DETACH_KEY);
|
|
86553
86685
|
const head3 = at2 === -1 ? chunk : chunk.subarray(0, at2);
|
|
86554
|
-
if (head3.length > 0) send5(encodeInput(head3));
|
|
86686
|
+
if (head3.length > 0 && granted) send5(encodeInput(head3));
|
|
86555
86687
|
if (at2 !== -1) detach();
|
|
86556
86688
|
return;
|
|
86557
86689
|
}
|
|
86558
86690
|
if (chunk.includes(DETACH_KEY) || chunk.includes(CTRL_C)) detach();
|
|
86559
86691
|
};
|
|
86560
86692
|
const onResize = () => {
|
|
86561
|
-
if (!control) return;
|
|
86693
|
+
if (!control || !granted) return;
|
|
86562
86694
|
const { columns, rows } = io.stdout;
|
|
86563
86695
|
if (columns && rows) send5({ type: "resize", cols: columns, rows });
|
|
86564
86696
|
};
|
|
@@ -86596,6 +86728,16 @@ async function terminalSession(relay, mode, runName, io, writer) {
|
|
|
86596
86728
|
case "token":
|
|
86597
86729
|
token = message2.token;
|
|
86598
86730
|
break;
|
|
86731
|
+
case "control": {
|
|
86732
|
+
const next = message2.state === "granted";
|
|
86733
|
+
if (next === granted) break;
|
|
86734
|
+
granted = next;
|
|
86735
|
+
writer.writeErr(
|
|
86736
|
+
granted ? "The run is paused. Your keystrokes reach it now." : "The run resumed, so your keystrokes no longer reach it."
|
|
86737
|
+
);
|
|
86738
|
+
onResize();
|
|
86739
|
+
break;
|
|
86740
|
+
}
|
|
86599
86741
|
case "closed": {
|
|
86600
86742
|
const text6 = CLOSED_MESSAGE[message2.reason];
|
|
86601
86743
|
state.final = {
|
|
@@ -86662,7 +86804,12 @@ async function terminalSession(relay, mode, runName, io, writer) {
|
|
|
86662
86804
|
}
|
|
86663
86805
|
}
|
|
86664
86806
|
const result2 = state.final;
|
|
86665
|
-
if (detaching) {
|
|
86807
|
+
if (detaching && opts.paused === true) {
|
|
86808
|
+
writer.writeErr(
|
|
86809
|
+
`
|
|
86810
|
+
You left the terminal. The run stays paused until someone resumes it from its page in the app. Open its terminal again with \`oxagen sandbox attach ${runName}\`.`
|
|
86811
|
+
);
|
|
86812
|
+
} else if (detaching) {
|
|
86666
86813
|
writer.writeErr(
|
|
86667
86814
|
`
|
|
86668
86815
|
You left the terminal. The run keeps going. Open its terminal again with \`oxagen sandbox attach ${runName}\`.`
|
|
@@ -86725,12 +86872,35 @@ async function attachToRun(run3, opts, writer = stdoutWriter, io = processIo())
|
|
|
86725
86872
|
);
|
|
86726
86873
|
return 1;
|
|
86727
86874
|
}
|
|
86875
|
+
const scope = { org, ws: workspace };
|
|
86728
86876
|
let relay;
|
|
86729
|
-
|
|
86877
|
+
let pauses = null;
|
|
86878
|
+
try {
|
|
86879
|
+
if (mode === "control") {
|
|
86880
|
+
const { run: detail } = await apiPostOrThrow("sandbox-runs/get", target, scope);
|
|
86881
|
+
if (!detail.interactive) {
|
|
86882
|
+
if (detail.runId === null) {
|
|
86883
|
+
writer.writeErr(
|
|
86884
|
+
"\u2717 This run has not recorded its first step, so it cannot pause yet. Pass --watch to read the screen."
|
|
86885
|
+
);
|
|
86886
|
+
return 1;
|
|
86887
|
+
}
|
|
86888
|
+
pauses = detail.runId;
|
|
86889
|
+
await apiPostOrThrow(
|
|
86890
|
+
"commands",
|
|
86891
|
+
{
|
|
86892
|
+
target: { kind: "run", id: pauses },
|
|
86893
|
+
command: "pause",
|
|
86894
|
+
reason: TAKE_CONTROL_REASON
|
|
86895
|
+
},
|
|
86896
|
+
scope
|
|
86897
|
+
);
|
|
86898
|
+
}
|
|
86899
|
+
}
|
|
86730
86900
|
relay = await openRelay(
|
|
86731
86901
|
target,
|
|
86732
86902
|
mode,
|
|
86733
|
-
|
|
86903
|
+
scope,
|
|
86734
86904
|
io,
|
|
86735
86905
|
writer,
|
|
86736
86906
|
opts.waitForStart === true
|
|
@@ -86740,15 +86910,17 @@ async function attachToRun(run3, opts, writer = stdoutWriter, io = processIo())
|
|
|
86740
86910
|
return 1;
|
|
86741
86911
|
}
|
|
86742
86912
|
writer.writeErr(
|
|
86743
|
-
mode === "
|
|
86913
|
+
mode === "watch" ? "Watching. Press Ctrl-] to stop watching." : pauses !== null ? "Pausing the run. Your keystrokes reach it once it reports the pause. Press Ctrl-] to detach." : "Connected. Press Ctrl-] to detach and leave the run going."
|
|
86744
86914
|
);
|
|
86745
|
-
return terminalSession(relay, mode, run3, io, writer
|
|
86915
|
+
return terminalSession(relay, mode, run3, io, writer, {
|
|
86916
|
+
paused: pauses !== null
|
|
86917
|
+
});
|
|
86746
86918
|
}
|
|
86747
86919
|
async function runAttach(run3, opts, writer = stdoutWriter) {
|
|
86748
86920
|
const code = await attachToRun(run3, opts, writer);
|
|
86749
86921
|
if (code !== 0) process.exitCode = code;
|
|
86750
86922
|
}
|
|
86751
|
-
var DETACH_KEY, CTRL_C, MAX_RECONNECTS, MAX_START_WAITS, START_WAIT_MS, SOCKET_OPEN, FINAL_CLOSE, CLOSED_MESSAGE;
|
|
86923
|
+
var DETACH_KEY, CTRL_C, TAKE_CONTROL_REASON, MAX_RECONNECTS, MAX_START_WAITS, START_WAIT_MS, SOCKET_OPEN, FINAL_CLOSE, CLOSED_MESSAGE;
|
|
86752
86924
|
var init_sandbox_attach = __esm({
|
|
86753
86925
|
"src/commands/sandbox-attach.ts"() {
|
|
86754
86926
|
init_api();
|
|
@@ -86757,6 +86929,7 @@ var init_sandbox_attach = __esm({
|
|
|
86757
86929
|
init_sandbox_run();
|
|
86758
86930
|
DETACH_KEY = 29;
|
|
86759
86931
|
CTRL_C = 3;
|
|
86932
|
+
TAKE_CONTROL_REASON = "The operator took control of the run's terminal.";
|
|
86760
86933
|
MAX_RECONNECTS = 5;
|
|
86761
86934
|
MAX_START_WAITS = 60;
|
|
86762
86935
|
START_WAIT_MS = 2e3;
|
|
@@ -86767,6 +86940,7 @@ var init_sandbox_attach = __esm({
|
|
|
86767
86940
|
4401: "The terminal session expired. Run `oxagen sandbox attach` again.",
|
|
86768
86941
|
4403: "Only the operator who launched this run can stop it or open its terminal.",
|
|
86769
86942
|
4408: "The relay got no hello in time. Run `oxagen sandbox attach` again.",
|
|
86943
|
+
4409: "Another session has control of this run's terminal. Pass --watch to read the screen, or try again once that session hands control back.",
|
|
86770
86944
|
4410: "This terminal session has ended. Run `oxagen sandbox attach` to open a new one.",
|
|
86771
86945
|
4502: "The relay could not open the run's terminal. Try again in a moment."
|
|
86772
86946
|
};
|
|
@@ -86846,6 +87020,18 @@ async function sandboxRun(opts, writer = stdoutWriter, deps = {}) {
|
|
|
86846
87020
|
if (!workspace) return fail3(NO_WORKSPACE, "usage");
|
|
86847
87021
|
const org = getOrgId();
|
|
86848
87022
|
if (!org) return fail3(NO_ORG, "not_logged_in");
|
|
87023
|
+
if (opts.accountSource !== void 0 && !ACCOUNT_SOURCES.includes(opts.accountSource)) {
|
|
87024
|
+
return fail3(
|
|
87025
|
+
`Pass --account-source with one of: ${ACCOUNT_SOURCES.join(", ")}.`,
|
|
87026
|
+
"usage"
|
|
87027
|
+
);
|
|
87028
|
+
}
|
|
87029
|
+
if (opts.workOrder && (opts.accountSource || opts.confirmWorkspaceBilling)) {
|
|
87030
|
+
return fail3(
|
|
87031
|
+
"A work order runs on the account source its send recorded. Leave out --account-source and --confirm-workspace-billing.",
|
|
87032
|
+
"usage"
|
|
87033
|
+
);
|
|
87034
|
+
}
|
|
86849
87035
|
if (opts.workOrder) {
|
|
86850
87036
|
if (opts.repo || opts.repoProvider || opts.branch || opts.prompt || opts.promptFile) {
|
|
86851
87037
|
return fail3(
|
|
@@ -86896,6 +87082,8 @@ async function sandboxRun(opts, writer = stdoutWriter, deps = {}) {
|
|
|
86896
87082
|
...opts.runtime ? { runtime: opts.runtime } : {},
|
|
86897
87083
|
...prompt !== void 0 ? { prompt } : {},
|
|
86898
87084
|
...opts.workOrder ? { workOrderId: opts.workOrder } : {},
|
|
87085
|
+
...opts.accountSource ? { accountSource: opts.accountSource } : {},
|
|
87086
|
+
...opts.confirmWorkspaceBilling ? { confirmWorkspaceBilling: true } : {},
|
|
86899
87087
|
launchedVia: "cli"
|
|
86900
87088
|
};
|
|
86901
87089
|
let run3;
|
|
@@ -87110,13 +87298,18 @@ async function sandboxShow(run3, opts, writer = stdoutWriter) {
|
|
|
87110
87298
|
}
|
|
87111
87299
|
}
|
|
87112
87300
|
}
|
|
87113
|
-
var NO_WORKSPACE, NO_ORG, NO_RUNTIME_HINT, REPO_SLUG, REPO_PROVIDERS, SANDBOX_STATES;
|
|
87301
|
+
var ACCOUNT_SOURCES, NO_WORKSPACE, NO_ORG, NO_RUNTIME_HINT, REPO_SLUG, REPO_PROVIDERS, SANDBOX_STATES;
|
|
87114
87302
|
var init_sandbox_run = __esm({
|
|
87115
87303
|
"src/commands/sandbox-run.ts"() {
|
|
87116
87304
|
init_api();
|
|
87117
87305
|
init_config();
|
|
87118
87306
|
init_capture_writer();
|
|
87119
87307
|
init_output();
|
|
87308
|
+
ACCOUNT_SOURCES = [
|
|
87309
|
+
"operator",
|
|
87310
|
+
"workspace",
|
|
87311
|
+
"operator_then_workspace"
|
|
87312
|
+
];
|
|
87120
87313
|
NO_WORKSPACE = "Name a workspace with --workspace-slug <slug> or OXAGEN_WORKSPACE. The CLI does not pick one for you.";
|
|
87121
87314
|
NO_ORG = "No organization is selected. Run `oxagen login`, or set OXAGEN_ORG_ID.";
|
|
87122
87315
|
NO_RUNTIME_HINT = "A sandbox run starts on a sandbox runtime. An org Owner adds one on the Runtimes page, with the workspace's Modal account connected.";
|
|
@@ -87304,6 +87497,7 @@ var sandbox_template_exports = {};
|
|
|
87304
87497
|
__export(sandbox_template_exports, {
|
|
87305
87498
|
STARTER_IDS: () => STARTER_IDS,
|
|
87306
87499
|
sandboxTemplateGenerate: () => sandboxTemplateGenerate,
|
|
87500
|
+
sandboxTemplateLog: () => sandboxTemplateLog,
|
|
87307
87501
|
sandboxTemplateTest: () => sandboxTemplateTest
|
|
87308
87502
|
});
|
|
87309
87503
|
async function sandboxTemplateGenerate(opts, writer = stdoutWriter) {
|
|
@@ -87519,7 +87713,51 @@ function testLines(test) {
|
|
|
87519
87713
|
}
|
|
87520
87714
|
return lines;
|
|
87521
87715
|
}
|
|
87522
|
-
|
|
87716
|
+
async function sandboxTemplateLog(runtime, build, opts, writer = stdoutWriter) {
|
|
87717
|
+
const out = createOutput({ json: opts.json }, writer);
|
|
87718
|
+
if (!RUNTIME_ID2.test(runtime)) {
|
|
87719
|
+
return out.error(
|
|
87720
|
+
`Name the sandbox runtime by its id, which starts with rtm_. "${runtime}" is not a runtime id.`,
|
|
87721
|
+
"usage"
|
|
87722
|
+
);
|
|
87723
|
+
}
|
|
87724
|
+
if (!TEMPLATE_ID.test(build)) {
|
|
87725
|
+
return out.error(
|
|
87726
|
+
`Name the build by its id, which starts with rtp_. "${build}" is not a build id. \`oxagen sandbox runtime list --json\` lists each runtime's builds.`,
|
|
87727
|
+
"usage"
|
|
87728
|
+
);
|
|
87729
|
+
}
|
|
87730
|
+
const workspace = namedWorkspace(opts.workspaceSlug);
|
|
87731
|
+
if (!workspace) return out.error(NO_WORKSPACE, "usage");
|
|
87732
|
+
const org = getOrgId();
|
|
87733
|
+
if (!org) return out.error(NO_ORG, "not_logged_in");
|
|
87734
|
+
let answer;
|
|
87735
|
+
try {
|
|
87736
|
+
answer = await apiPostOrThrow(
|
|
87737
|
+
"sandbox-templates/build-log",
|
|
87738
|
+
{ runtimeId: runtime, templateId: build },
|
|
87739
|
+
{ org, ws: workspace }
|
|
87740
|
+
);
|
|
87741
|
+
} catch (err2) {
|
|
87742
|
+
const refusal = refusalOf3(err2);
|
|
87743
|
+
return out.error(refusal.message, refusal.reason ?? "api");
|
|
87744
|
+
}
|
|
87745
|
+
if (out.isJson) {
|
|
87746
|
+
out.data(answer);
|
|
87747
|
+
return;
|
|
87748
|
+
}
|
|
87749
|
+
if (answer.log === null) {
|
|
87750
|
+
writer.writeErr(
|
|
87751
|
+
`Build ${build} stored no log. \`oxagen sandbox runtime list --json\` shows its failure reason.`
|
|
87752
|
+
);
|
|
87753
|
+
return;
|
|
87754
|
+
}
|
|
87755
|
+
if (answer.log.truncated) {
|
|
87756
|
+
writer.writeErr("The log is long, so this shows its last 256 KiB.");
|
|
87757
|
+
}
|
|
87758
|
+
writer.write(answer.log.text);
|
|
87759
|
+
}
|
|
87760
|
+
var STARTERS, STARTER_IDS, ROUTE_TEXT, POLL_MS, MAX_WAIT_MS, RUNTIME_ID2, TEMPLATE_ID;
|
|
87523
87761
|
var init_sandbox_template = __esm({
|
|
87524
87762
|
"src/commands/sandbox-template.ts"() {
|
|
87525
87763
|
init_api();
|
|
@@ -87543,6 +87781,7 @@ var init_sandbox_template = __esm({
|
|
|
87543
87781
|
POLL_MS = 5e3;
|
|
87544
87782
|
MAX_WAIT_MS = 12 * 6e4;
|
|
87545
87783
|
RUNTIME_ID2 = /^rtm_[0-9a-z]+$/;
|
|
87784
|
+
TEMPLATE_ID = /^rtp_[0-9a-z]+$/;
|
|
87546
87785
|
}
|
|
87547
87786
|
});
|
|
87548
87787
|
|
|
@@ -87563,6 +87802,15 @@ function templateFromFlags(flags) {
|
|
|
87563
87802
|
if (flags.dockerfile !== void 0)
|
|
87564
87803
|
named.push(["dockerfile", flags.dockerfile]);
|
|
87565
87804
|
const services = flags.service ?? [];
|
|
87805
|
+
const setup = flags.setupCommand === void 0 ? void 0 : {
|
|
87806
|
+
command: flags.setupCommand,
|
|
87807
|
+
workingDirectory: flags.setupDir ?? "/"
|
|
87808
|
+
};
|
|
87809
|
+
if (flags.setupDir !== void 0 && setup === void 0) {
|
|
87810
|
+
return {
|
|
87811
|
+
error: "--setup-dir names the folder the setup command runs in. Pass --setup-command with it."
|
|
87812
|
+
};
|
|
87813
|
+
}
|
|
87566
87814
|
if (named.length > 1) {
|
|
87567
87815
|
return {
|
|
87568
87816
|
error: "Pass one of --image, --pinned-image, or --dockerfile. Each names a whole template."
|
|
@@ -87570,16 +87818,21 @@ function templateFromFlags(flags) {
|
|
|
87570
87818
|
}
|
|
87571
87819
|
const [first] = named;
|
|
87572
87820
|
if (first === void 0) {
|
|
87573
|
-
|
|
87574
|
-
|
|
87575
|
-
|
|
87821
|
+
if (services.length > 0)
|
|
87822
|
+
return {
|
|
87823
|
+
error: "--service adds a service to a template. Pass --image, --pinned-image, or --dockerfile with it."
|
|
87824
|
+
};
|
|
87825
|
+
return setup === void 0 ? {} : {
|
|
87826
|
+
error: "--setup-command is part of a template. Pass --image, --pinned-image, or --dockerfile with it."
|
|
87827
|
+
};
|
|
87576
87828
|
}
|
|
87577
87829
|
const [sourceKind, sourceRef] = first;
|
|
87578
87830
|
return {
|
|
87579
87831
|
template: {
|
|
87580
87832
|
sourceKind,
|
|
87581
87833
|
sourceRef,
|
|
87582
|
-
...services.length > 0 ? { services } : {}
|
|
87834
|
+
...services.length > 0 ? { services } : {},
|
|
87835
|
+
...setup === void 0 ? {} : { setup }
|
|
87583
87836
|
}
|
|
87584
87837
|
};
|
|
87585
87838
|
}
|
|
@@ -93411,7 +93664,7 @@ function compareModels(usage3) {
|
|
|
93411
93664
|
function listRateCard() {
|
|
93412
93665
|
return RATE_CARD.filter((e) => !e.alias);
|
|
93413
93666
|
}
|
|
93414
|
-
var HAIKU_5_5_LONG_CONTEXT, RATE_CARD, FALLBACK_RATE;
|
|
93667
|
+
var HAIKU_5_5_LONG_CONTEXT, QWEN_3_7_FLASH_LONG_CONTEXT, RATE_CARD, FALLBACK_RATE;
|
|
93415
93668
|
var init_rate_card = __esm({
|
|
93416
93669
|
"../../packages/billing/src/rate-card.ts"() {
|
|
93417
93670
|
"use strict";
|
|
@@ -93422,6 +93675,13 @@ var init_rate_card = __esm({
|
|
|
93422
93675
|
cachedInputPer1M: 0.05,
|
|
93423
93676
|
cacheWritePer1M: 0.625
|
|
93424
93677
|
};
|
|
93678
|
+
QWEN_3_7_FLASH_LONG_CONTEXT = {
|
|
93679
|
+
abovePromptTokens: 32e3,
|
|
93680
|
+
inputPer1M: 0.1,
|
|
93681
|
+
outputPer1M: 0.4,
|
|
93682
|
+
cachedInputPer1M: 0.02,
|
|
93683
|
+
cacheWritePer1M: 0.125
|
|
93684
|
+
};
|
|
93425
93685
|
RATE_CARD = [
|
|
93426
93686
|
// Fable 5.1 and Opus 5.5 break from their family's price, so each gets a row
|
|
93427
93687
|
// for both the hyphenated and the dotted gateway spelling, the dotted one
|
|
@@ -93870,7 +94130,20 @@ var init_rate_card = __esm({
|
|
|
93870
94130
|
},
|
|
93871
94131
|
// Zhipu GLM rows from the AI Gateway's /v1/models pricing (2026-07-10).
|
|
93872
94132
|
// Specific families MUST sort before the generic "glm" prefix row (same
|
|
93873
|
-
// first-match rule as the gpt-5.5 rows above).
|
|
94133
|
+
// first-match rule as the gpt-5.5 rows above). GLM 5.3 Flash is from
|
|
94134
|
+
// OpenRouter's model list (2026-10-28), which prices a cache read at the
|
|
94135
|
+
// fresh input rate.
|
|
94136
|
+
{
|
|
94137
|
+
family: "glm-5.3-flash",
|
|
94138
|
+
label: "GLM 5.3 Flash",
|
|
94139
|
+
vendor: "zai",
|
|
94140
|
+
rate: {
|
|
94141
|
+
inputPer1M: 0.0259,
|
|
94142
|
+
outputPer1M: 0.1042,
|
|
94143
|
+
cachedInputPer1M: 0.0259,
|
|
94144
|
+
cacheWritePer1M: 0.0259
|
|
94145
|
+
}
|
|
94146
|
+
},
|
|
93874
94147
|
{
|
|
93875
94148
|
family: "glm-5.2-fast",
|
|
93876
94149
|
label: "GLM 5.2 Fast",
|
|
@@ -94002,6 +94275,22 @@ var init_rate_card = __esm({
|
|
|
94002
94275
|
cacheWritePer1M: 0.28
|
|
94003
94276
|
}
|
|
94004
94277
|
},
|
|
94278
|
+
// Qwen3.7 Flash at OpenRouter's price (2026-10-28). Unlike the other
|
|
94279
|
+
// vendors here, OpenRouter lists a cache write above fresh input for it:
|
|
94280
|
+
// $0.038 against $0.03. There is no generic "qwen" row, so another Qwen
|
|
94281
|
+
// model still falls back.
|
|
94282
|
+
{
|
|
94283
|
+
family: "qwen3.7-flash",
|
|
94284
|
+
label: "Qwen3.7 Flash",
|
|
94285
|
+
vendor: "qwen",
|
|
94286
|
+
rate: {
|
|
94287
|
+
inputPer1M: 0.03,
|
|
94288
|
+
outputPer1M: 0.13,
|
|
94289
|
+
cachedInputPer1M: 6e-3,
|
|
94290
|
+
cacheWritePer1M: 0.038,
|
|
94291
|
+
longContext: QWEN_3_7_FLASH_LONG_CONTEXT
|
|
94292
|
+
}
|
|
94293
|
+
},
|
|
94005
94294
|
// Gateway /v1/models 2026-07-07 (base tier ≤200k): gemini-3-pro* $2/$12.
|
|
94006
94295
|
{
|
|
94007
94296
|
family: "gemini-3-pro",
|
|
@@ -94041,6 +94330,19 @@ var init_rate_card = __esm({
|
|
|
94041
94330
|
cacheWritePer1M: 0.5
|
|
94042
94331
|
}
|
|
94043
94332
|
},
|
|
94333
|
+
// Gemini 3.8 Flash at OpenRouter's price (2026-10-28), the batch triage
|
|
94334
|
+
// model. It MUST sort before the generic "gemini" row.
|
|
94335
|
+
{
|
|
94336
|
+
family: "gemini-3.8-flash",
|
|
94337
|
+
label: "Gemini 3.8 Flash",
|
|
94338
|
+
vendor: "google",
|
|
94339
|
+
rate: {
|
|
94340
|
+
inputPer1M: 0.825,
|
|
94341
|
+
outputPer1M: 4.125,
|
|
94342
|
+
cachedInputPer1M: 0.0825,
|
|
94343
|
+
cacheWritePer1M: 0.825
|
|
94344
|
+
}
|
|
94345
|
+
},
|
|
94044
94346
|
{
|
|
94045
94347
|
family: "gemini",
|
|
94046
94348
|
label: "Gemini",
|
|
@@ -98194,26 +98496,14 @@ var init_steering_findings = __esm({
|
|
|
98194
98496
|
// src/commands/repo.ts
|
|
98195
98497
|
var repo_exports = {};
|
|
98196
98498
|
__export(repo_exports, {
|
|
98197
|
-
draftGovernanceToml: () => draftGovernanceToml,
|
|
98198
98499
|
parseRepositoryRef: () => parseRepositoryRef,
|
|
98199
98500
|
repoBranch: () => repoBranch,
|
|
98200
98501
|
repoGovernance: () => repoGovernance,
|
|
98201
|
-
repoInit: () => repoInit,
|
|
98202
98502
|
repoLink: () => repoLink,
|
|
98203
98503
|
repoList: () => repoList,
|
|
98204
98504
|
repoTree: () => repoTree,
|
|
98205
98505
|
repoUnlink: () => repoUnlink
|
|
98206
98506
|
});
|
|
98207
|
-
import { readFile as readFile6 } from "node:fs/promises";
|
|
98208
|
-
function draftGovernanceToml(mode) {
|
|
98209
|
-
return [
|
|
98210
|
-
"# Read on the production branch when a pull request is opened and again",
|
|
98211
|
-
"# when it is merged. A missing file means team.",
|
|
98212
|
-
`mode = "${mode}"`,
|
|
98213
|
-
`separation_of_duties = ${mode === "regulated" ? "true" : "false"}`,
|
|
98214
|
-
""
|
|
98215
|
-
].join("\n");
|
|
98216
|
-
}
|
|
98217
98507
|
function parseRepositoryRef(ref) {
|
|
98218
98508
|
const parts = ref.trim().split("/");
|
|
98219
98509
|
if (parts.length !== 2) return null;
|
|
@@ -98336,20 +98626,21 @@ async function repoUnlink(bindingId, opts = {}, writer = stdoutWriter) {
|
|
|
98336
98626
|
"Its binding versions stay as evidence for the runs that cited them. Link it again to write the next version."
|
|
98337
98627
|
);
|
|
98338
98628
|
}
|
|
98339
|
-
async function repoTree(
|
|
98340
|
-
const id2 = bindingId.trim();
|
|
98341
|
-
if (id2.length === 0) {
|
|
98342
|
-
return usageError(
|
|
98343
|
-
writer,
|
|
98344
|
-
"a binding id is required",
|
|
98345
|
-
"oxagen repo tree <bindingId> [--json]"
|
|
98346
|
-
);
|
|
98347
|
-
}
|
|
98629
|
+
async function repoTree(opts = {}, writer = stdoutWriter) {
|
|
98348
98630
|
const out = createOutput({ json: opts.json }, writer);
|
|
98349
98631
|
let result2;
|
|
98350
98632
|
try {
|
|
98633
|
+
const { repositories } = await apiGetOrThrow("repositories");
|
|
98634
|
+
const steeringRepo = repositories.find((repo) => repo.role === "main");
|
|
98635
|
+
if (steeringRepo === void 0) {
|
|
98636
|
+
out.error(
|
|
98637
|
+
"This workspace has no steering repository yet.",
|
|
98638
|
+
"main_repo_unbound"
|
|
98639
|
+
);
|
|
98640
|
+
return;
|
|
98641
|
+
}
|
|
98351
98642
|
result2 = await apiPostOrThrow("repository/tree", {
|
|
98352
|
-
bindingId:
|
|
98643
|
+
bindingId: steeringRepo.bindingId
|
|
98353
98644
|
});
|
|
98354
98645
|
} catch (err2) {
|
|
98355
98646
|
out.error(err2, "api");
|
|
@@ -98369,9 +98660,7 @@ async function repoTree(bindingId, opts = {}, writer = stdoutWriter) {
|
|
|
98369
98660
|
}
|
|
98370
98661
|
const steering = result2.steering?.present === true;
|
|
98371
98662
|
if (!steering && !result2.oxagen.present) {
|
|
98372
|
-
writer.write(
|
|
98373
|
-
result2.initPullRequest === null ? "No .oxagen/ on the production branch. Add it with `oxagen repo init`." : `No .oxagen/ yet. The init pull request is open: ${result2.initPullRequest.htmlUrl}`
|
|
98374
|
-
);
|
|
98663
|
+
writer.write("No steering files on the production branch.");
|
|
98375
98664
|
return;
|
|
98376
98665
|
}
|
|
98377
98666
|
writer.write(`governance mode: ${result2.governanceMode}`);
|
|
@@ -98407,59 +98696,6 @@ async function repoBranch(bindingId, branch, opts = {}, writer = stdoutWriter) {
|
|
|
98407
98696
|
result2.changed ? `${result2.fullName}: production branch ${result2.previousBranch} \u2192 ${result2.productionBranch} \xB7 ${result2.bindingId}` : `${result2.fullName}: production branch is already ${result2.productionBranch}; nothing was written`
|
|
98408
98697
|
);
|
|
98409
98698
|
}
|
|
98410
|
-
async function repoInit(bindingId, opts = {}, writer = stdoutWriter) {
|
|
98411
|
-
const line = "oxagen repo init <bindingId> --workspace-toml <file> [--mode solo|team|regulated] [--governance-toml <file>] [--json]";
|
|
98412
|
-
const id2 = bindingId.trim();
|
|
98413
|
-
if (id2.length === 0) {
|
|
98414
|
-
return usageError(writer, "a binding id is required", line);
|
|
98415
|
-
}
|
|
98416
|
-
const mode = opts.mode ?? "team";
|
|
98417
|
-
if (!GOVERNANCE_MODES.includes(mode)) {
|
|
98418
|
-
return usageError(
|
|
98419
|
-
writer,
|
|
98420
|
-
`expected a mode of solo, team or regulated, got ${JSON.stringify(opts.mode)}`,
|
|
98421
|
-
line
|
|
98422
|
-
);
|
|
98423
|
-
}
|
|
98424
|
-
if (opts.workspaceToml === void 0) {
|
|
98425
|
-
return usageError(writer, "--workspace-toml is required", line);
|
|
98426
|
-
}
|
|
98427
|
-
let workspaceToml;
|
|
98428
|
-
let governanceToml;
|
|
98429
|
-
try {
|
|
98430
|
-
workspaceToml = await readFile6(opts.workspaceToml, "utf8");
|
|
98431
|
-
governanceToml = opts.governanceToml === void 0 ? draftGovernanceToml(mode) : await readFile6(opts.governanceToml, "utf8");
|
|
98432
|
-
} catch (err2) {
|
|
98433
|
-
return usageError(
|
|
98434
|
-
writer,
|
|
98435
|
-
`could not read a file: ${err2 instanceof Error ? err2.message : String(err2)}`,
|
|
98436
|
-
line
|
|
98437
|
-
);
|
|
98438
|
-
}
|
|
98439
|
-
const out = createOutput({ json: opts.json }, writer);
|
|
98440
|
-
let result2;
|
|
98441
|
-
try {
|
|
98442
|
-
result2 = await apiPostOrThrow("repository/init-pr", {
|
|
98443
|
-
bindingId: id2,
|
|
98444
|
-
governanceMode: mode,
|
|
98445
|
-
workspaceToml,
|
|
98446
|
-
governanceToml
|
|
98447
|
-
});
|
|
98448
|
-
} catch (err2) {
|
|
98449
|
-
out.error(err2, "api");
|
|
98450
|
-
return;
|
|
98451
|
-
}
|
|
98452
|
-
if (out.isJson) {
|
|
98453
|
-
out.data(result2);
|
|
98454
|
-
return;
|
|
98455
|
-
}
|
|
98456
|
-
writer.write(
|
|
98457
|
-
result2.reused ? `An init pull request is already open on ${result2.fullName}: ${result2.pullRequest.htmlUrl}` : `Opened ${result2.pullRequest.htmlUrl} on ${result2.fullName}: ${result2.branch} \u2192 ${result2.base}, ${result2.files.length} files`
|
|
98458
|
-
);
|
|
98459
|
-
writer.write(
|
|
98460
|
-
"Nothing reaches the production branch until a person merges it."
|
|
98461
|
-
);
|
|
98462
|
-
}
|
|
98463
98699
|
async function repoGovernance(opts = {}, writer = stdoutWriter) {
|
|
98464
98700
|
const line = "oxagen repo governance --mode solo|team|regulated [--workspace <wrk_\u2026>] [--apply-now] [--json]";
|
|
98465
98701
|
const mode = opts.mode;
|
|
@@ -99164,7 +99400,7 @@ function recordLineageFromPath(path2) {
|
|
|
99164
99400
|
return parts[parts.length - 1].slice(0, -3);
|
|
99165
99401
|
return null;
|
|
99166
99402
|
}
|
|
99167
|
-
var AGENTS_MD_PATH, CLAUDE_MD_PATH, README_PATH, GITATTRIBUTES_PATH, WORKSPACE_TOML_PATH, AGENTS_DIR, STEERING_DIR, PEOPLE_DIR, PERSON_FOLDER, GOVERNANCE_TOML_PATH, SKILLS_DIR, TOOLS_DIR, TOOL_SERVERS_DIR, POLICY_DIR, CEDAR_SCHEMA_PATH, CODEGRAPH_SETTINGS_DIR, SANDBOX_TEMPLATE_DIR, SKILL_FILE_NAME, SERVER_TOML_NAME, TOOLS_TOML_NAME, TOOLS_LOCK_NAME, LEDGER_ROTATIONS, LEDGER_FILE, ROOT_FILES, SERVER_FILES, SANDBOX_SERVICE_NAME
|
|
99403
|
+
var AGENTS_MD_PATH, CLAUDE_MD_PATH, README_PATH, GITATTRIBUTES_PATH, WORKSPACE_TOML_PATH, AGENTS_DIR, STEERING_DIR, PEOPLE_DIR, PERSON_FOLDER, GOVERNANCE_TOML_PATH, SKILLS_DIR, TOOLS_DIR, TOOL_SERVERS_DIR, POLICY_DIR, CEDAR_SCHEMA_PATH, CODEGRAPH_SETTINGS_DIR, SANDBOX_TEMPLATE_DIR, SKILL_FILE_NAME, SERVER_TOML_NAME, TOOLS_TOML_NAME, TOOLS_LOCK_NAME, LEDGER_ROTATIONS, LEDGER_FILE, ROOT_FILES, SERVER_FILES, SANDBOX_SERVICE_NAME;
|
|
99168
99404
|
var init_paths2 = __esm({
|
|
99169
99405
|
"../../packages/oxagen/src/steering-repo/paths.ts"() {
|
|
99170
99406
|
"use strict";
|
|
@@ -99216,7 +99452,6 @@ var init_paths2 = __esm({
|
|
|
99216
99452
|
"schema.graphql": "server-definition"
|
|
99217
99453
|
};
|
|
99218
99454
|
SANDBOX_SERVICE_NAME = /^[a-z0-9][a-z0-9@._-]{0,127}$/;
|
|
99219
|
-
WORKSPACE_LINK_PATH = ".oxagen/workspace.json";
|
|
99220
99455
|
}
|
|
99221
99456
|
});
|
|
99222
99457
|
|
|
@@ -104205,15 +104440,35 @@ var init_schemas2 = __esm({
|
|
|
104205
104440
|
});
|
|
104206
104441
|
|
|
104207
104442
|
// ../../packages/oxagen/src/steering-repo/settings-baseline.ts
|
|
104208
|
-
var OXAGEN_STEERING_APP, GITLAB_SETTINGS_BASELINE;
|
|
104443
|
+
var OXAGEN_STEERING_APP, GITHUB_MAIN_PROTECTION, GITLAB_SETTINGS_BASELINE;
|
|
104209
104444
|
var init_settings_baseline = __esm({
|
|
104210
104445
|
"../../packages/oxagen/src/steering-repo/settings-baseline.ts"() {
|
|
104211
104446
|
"use strict";
|
|
104212
104447
|
init_names();
|
|
104213
104448
|
OXAGEN_STEERING_APP = "oxagen-steering";
|
|
104449
|
+
GITHUB_MAIN_PROTECTION = {
|
|
104450
|
+
name: "Oxagen steering",
|
|
104451
|
+
target: "branch",
|
|
104452
|
+
enforcement: "active",
|
|
104453
|
+
include: [`refs/heads/${STEERING_DEFAULT_BRANCH}`],
|
|
104454
|
+
bypass_actors: [],
|
|
104455
|
+
rules: [
|
|
104456
|
+
{
|
|
104457
|
+
type: "pull_request",
|
|
104458
|
+
parameters: {
|
|
104459
|
+
required_approving_review_count: 0,
|
|
104460
|
+
dismiss_stale_reviews_on_push: false,
|
|
104461
|
+
require_code_owner_review: false,
|
|
104462
|
+
require_last_push_approval: false,
|
|
104463
|
+
required_review_thread_resolution: false
|
|
104464
|
+
}
|
|
104465
|
+
}
|
|
104466
|
+
]
|
|
104467
|
+
};
|
|
104214
104468
|
GITLAB_SETTINGS_BASELINE = {
|
|
104215
104469
|
visibility: "private",
|
|
104216
104470
|
default_branch: STEERING_DEFAULT_BRANCH,
|
|
104471
|
+
// Creation protects main so no one pushes and only the Oxagen bot merges.
|
|
104217
104472
|
protected_branches: {
|
|
104218
104473
|
[STEERING_DEFAULT_BRANCH]: {
|
|
104219
104474
|
push_access: "no_one",
|
|
@@ -106634,32 +106889,19 @@ function shown2(value) {
|
|
|
106634
106889
|
return text6.length > 120 ? `${text6.slice(0, 117)}...` : text6;
|
|
106635
106890
|
}
|
|
106636
106891
|
function describe7(difference) {
|
|
106637
|
-
const { setting: setting2, actual } = difference;
|
|
106638
|
-
|
|
106639
|
-
if (setting2 === "actions.enabled" && actual === true) {
|
|
106892
|
+
const { setting: setting2, expected, actual } = difference;
|
|
106893
|
+
if (SQUASH_SETTINGS.has(setting2) && actual === false) {
|
|
106640
106894
|
return {
|
|
106641
|
-
rule: "
|
|
106642
|
-
message: "
|
|
106643
|
-
|
|
106644
|
-
|
|
106645
|
-
}
|
|
106646
|
-
if (setting2 === "ci_cd.builds_access_level" && actual !== "disabled") {
|
|
106647
|
-
return {
|
|
106648
|
-
rule: "ci-enabled",
|
|
106649
|
-
message: "CI/CD is on",
|
|
106650
|
-
fix: `${REPAIR} Or turn CI/CD off by hand. Oxagen runs every check itself.`
|
|
106651
|
-
};
|
|
106652
|
-
}
|
|
106653
|
-
if (parts[0] === "protected_branches" && parts[2] === "allow_force_push" && actual === true) {
|
|
106654
|
-
return {
|
|
106655
|
-
rule: "force-push-allowed",
|
|
106656
|
-
message: `The protected branch ${parts[1]} allows force pushes`,
|
|
106657
|
-
fix: `${REPAIR} Or turn force pushes off by hand.`
|
|
106895
|
+
rule: "squash-merge-off",
|
|
106896
|
+
message: "Squash merging is off",
|
|
106897
|
+
expected: "Squash merging is on.",
|
|
106898
|
+
fix: `${REPAIR} Or turn squash merging back on by hand. Oxagen merges every steering pull request with a squash.`
|
|
106658
106899
|
};
|
|
106659
106900
|
}
|
|
106660
106901
|
return {
|
|
106661
106902
|
rule: "setting-differs",
|
|
106662
106903
|
message: `${setting2} is ${shown2(actual)}`,
|
|
106904
|
+
expected: `${setting2} is ${shown2(expected)}.`,
|
|
106663
106905
|
fix: `${REPAIR} Or set it back by hand.`
|
|
106664
106906
|
};
|
|
106665
106907
|
}
|
|
@@ -106671,13 +106913,17 @@ function changedBy(difference) {
|
|
|
106671
106913
|
if (by) return ` (by ${by})`;
|
|
106672
106914
|
return "";
|
|
106673
106915
|
}
|
|
106674
|
-
var find11, REPAIR, settingsCheck;
|
|
106916
|
+
var find11, REPAIR, SQUASH_SETTINGS, settingsCheck;
|
|
106675
106917
|
var init_settings = __esm({
|
|
106676
106918
|
"../../packages/steering-check/src/checks/settings.ts"() {
|
|
106677
106919
|
"use strict";
|
|
106678
106920
|
init_finding();
|
|
106679
106921
|
find11 = finder("settings");
|
|
106680
106922
|
REPAIR = "A workspace admin opens Workspace settings, then Steering repo, and selects Repair settings.";
|
|
106923
|
+
SQUASH_SETTINGS = /* @__PURE__ */ new Set([
|
|
106924
|
+
"merge.allow_squash_merge",
|
|
106925
|
+
"merge_requests.squash_allowed"
|
|
106926
|
+
]);
|
|
106681
106927
|
settingsCheck = (env) => {
|
|
106682
106928
|
if (env.health === null) {
|
|
106683
106929
|
return {
|
|
@@ -106685,20 +106931,20 @@ var init_settings = __esm({
|
|
|
106685
106931
|
};
|
|
106686
106932
|
}
|
|
106687
106933
|
const findings = env.health.differences.map((difference) => {
|
|
106688
|
-
const { rule, message: message2, fix } = describe7(difference);
|
|
106934
|
+
const { rule, message: message2, expected, fix } = describe7(difference);
|
|
106689
106935
|
return find11({
|
|
106690
106936
|
rule,
|
|
106691
106937
|
path: difference.setting,
|
|
106692
106938
|
line: null,
|
|
106693
106939
|
field: null,
|
|
106694
106940
|
message: `${message2}${changedBy(difference)}.`,
|
|
106695
|
-
expected
|
|
106941
|
+
expected,
|
|
106696
106942
|
fix
|
|
106697
106943
|
});
|
|
106698
106944
|
});
|
|
106699
106945
|
return findings.length === 0 ? { findings } : {
|
|
106700
106946
|
findings,
|
|
106701
|
-
note: "
|
|
106947
|
+
note: "Oxagen merges no steering pull request while these settings differ."
|
|
106702
106948
|
};
|
|
106703
106949
|
};
|
|
106704
106950
|
}
|
|
@@ -107176,7 +107422,7 @@ var init_memory_client = __esm({
|
|
|
107176
107422
|
});
|
|
107177
107423
|
|
|
107178
107424
|
// src/lib/markdown-import.ts
|
|
107179
|
-
import { readFile as
|
|
107425
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
107180
107426
|
import {
|
|
107181
107427
|
basename as basename10,
|
|
107182
107428
|
dirname as dirname35,
|
|
@@ -107205,7 +107451,7 @@ async function readImportDocuments(sources, target, writer) {
|
|
|
107205
107451
|
for (const source of sources) {
|
|
107206
107452
|
let content;
|
|
107207
107453
|
try {
|
|
107208
|
-
content = await
|
|
107454
|
+
content = await readFile6(source.path, "utf8");
|
|
107209
107455
|
} catch {
|
|
107210
107456
|
unreadable.push(source.path);
|
|
107211
107457
|
continue;
|
|
@@ -107228,7 +107474,7 @@ async function readImportDocuments(sources, target, writer) {
|
|
|
107228
107474
|
for (const file of source.files) {
|
|
107229
107475
|
let text6;
|
|
107230
107476
|
try {
|
|
107231
|
-
text6 = await
|
|
107477
|
+
text6 = await readFile6(file.file, "utf8");
|
|
107232
107478
|
} catch {
|
|
107233
107479
|
unreadable.push(file.file);
|
|
107234
107480
|
continue;
|
|
@@ -108110,9 +108356,9 @@ function formatDismissResult(result2, restore) {
|
|
|
108110
108356
|
}
|
|
108111
108357
|
function formatDropResult(result2) {
|
|
108112
108358
|
const pr = result2.pull_request;
|
|
108113
|
-
const
|
|
108359
|
+
const short4 = result2.commit_sha.slice(0, 7);
|
|
108114
108360
|
return [
|
|
108115
|
-
result2.already_dropped ? `${result2.path} was already dropped from memory PR #${pr.number} in commit ${
|
|
108361
|
+
result2.already_dropped ? `${result2.path} was already dropped from memory PR #${pr.number} in commit ${short4}.` : `Dropped ${result2.path} from memory PR #${pr.number} in commit ${short4} on ${pr.branch}.`,
|
|
108116
108362
|
"When the PR merges, the record's statements are rejected and its memories wait again.",
|
|
108117
108363
|
pr.url
|
|
108118
108364
|
].join("\n");
|
|
@@ -109678,6 +109924,12 @@ __export(credentials_exports, {
|
|
|
109678
109924
|
credentialsUpdate: () => credentialsUpdate,
|
|
109679
109925
|
readSecret: () => readSecret
|
|
109680
109926
|
});
|
|
109927
|
+
function sharedBody(opts) {
|
|
109928
|
+
return opts.shared ? { scope: "workspace" } : {};
|
|
109929
|
+
}
|
|
109930
|
+
function sharedQuery(opts) {
|
|
109931
|
+
return opts.shared ? "?scope=workspace" : "";
|
|
109932
|
+
}
|
|
109681
109933
|
async function readSecret(label, io = {
|
|
109682
109934
|
stdin: process.stdin,
|
|
109683
109935
|
prompt: (text6) => process.stderr.write(text6)
|
|
@@ -109832,13 +110084,17 @@ async function credentialsAdd(opts, writer = stdoutWriter, deps = {}) {
|
|
|
109832
110084
|
);
|
|
109833
110085
|
}
|
|
109834
110086
|
try {
|
|
109835
|
-
const { credential } = await apiPostOrThrow(
|
|
110087
|
+
const { credential } = await apiPostOrThrow(
|
|
110088
|
+
"user/model-credentials",
|
|
110089
|
+
{ ...body2, ...sharedBody(opts), secret },
|
|
110090
|
+
scope
|
|
110091
|
+
);
|
|
109836
110092
|
if (out.isJson) {
|
|
109837
110093
|
out.data({ credential });
|
|
109838
110094
|
return;
|
|
109839
110095
|
}
|
|
109840
110096
|
writer.write(
|
|
109841
|
-
credential.baseUrl ? `Stored the key ending ${credential.hint} for ${credential.baseUrl} as ${credential.id}. Sandbox runs don't use your own endpoint yet. Oxagen keeps the key until they do.` : `Stored the ${credential.provider} credential ending ${credential.hint} as ${credential.id}. Only your own runs use it.`
|
|
110097
|
+
credential.baseUrl ? `Stored the key ending ${credential.hint} for ${credential.baseUrl} as ${credential.id}. Sandbox runs don't use your own endpoint yet. Oxagen keeps the key until they do.` : opts.shared ? `Stored the ${credential.provider} account ending ${credential.hint} as ${credential.id}. Runs whose account source names this workspace can use it.` : `Stored the ${credential.provider} credential ending ${credential.hint} as ${credential.id}. Only your own runs use it.`
|
|
109842
110098
|
);
|
|
109843
110099
|
} catch (err2) {
|
|
109844
110100
|
const refusal = refusalOf3(err2);
|
|
@@ -109852,7 +110108,7 @@ async function credentialsList(opts, writer = stdoutWriter) {
|
|
|
109852
110108
|
try {
|
|
109853
110109
|
const { items } = await apiGetOrThrow(
|
|
109854
110110
|
"user/model-credentials",
|
|
109855
|
-
void 0,
|
|
110111
|
+
opts.shared ? { scope: "workspace" } : void 0,
|
|
109856
110112
|
scope
|
|
109857
110113
|
);
|
|
109858
110114
|
if (out.isJson) {
|
|
@@ -109920,7 +110176,8 @@ async function credentialsUpdate(credentialId, opts, writer = stdoutWriter) {
|
|
|
109920
110176
|
{
|
|
109921
110177
|
...opts.label !== void 0 ? { label: opts.label } : {},
|
|
109922
110178
|
...opts.pause ? { paused: true } : {},
|
|
109923
|
-
...opts.resume ? { paused: false } : {}
|
|
110179
|
+
...opts.resume ? { paused: false } : {},
|
|
110180
|
+
...sharedBody(opts)
|
|
109924
110181
|
},
|
|
109925
110182
|
scope
|
|
109926
110183
|
);
|
|
@@ -109966,7 +110223,7 @@ async function credentialsRotate(credentialId, opts, writer = stdoutWriter, deps
|
|
|
109966
110223
|
try {
|
|
109967
110224
|
const { items } = await apiGetOrThrow(
|
|
109968
110225
|
"user/model-credentials",
|
|
109969
|
-
void 0,
|
|
110226
|
+
opts.shared ? { scope: "workspace" } : void 0,
|
|
109970
110227
|
scope
|
|
109971
110228
|
);
|
|
109972
110229
|
current = items.find((c) => c.id === credentialId);
|
|
@@ -110015,7 +110272,7 @@ async function credentialsRotate(credentialId, opts, writer = stdoutWriter, deps
|
|
|
110015
110272
|
try {
|
|
110016
110273
|
const { credential } = await apiPostOrThrow(
|
|
110017
110274
|
`user/model-credentials/${encodeURIComponent(credentialId)}/rotate`,
|
|
110018
|
-
{ secret },
|
|
110275
|
+
{ secret, ...sharedBody(opts) },
|
|
110019
110276
|
scope
|
|
110020
110277
|
);
|
|
110021
110278
|
if (out.isJson) {
|
|
@@ -110036,7 +110293,10 @@ async function credentialsRemove(credentialId, opts, writer = stdoutWriter) {
|
|
|
110036
110293
|
const scope = scopeFor(opts);
|
|
110037
110294
|
if ("error" in scope) return out.error(scope.error, "usage");
|
|
110038
110295
|
try {
|
|
110039
|
-
const { credential } = await apiDeleteOrThrow(
|
|
110296
|
+
const { credential } = await apiDeleteOrThrow(
|
|
110297
|
+
`user/model-credentials/${encodeURIComponent(credentialId)}${sharedQuery(opts)}`,
|
|
110298
|
+
scope
|
|
110299
|
+
);
|
|
110040
110300
|
if (out.isJson) {
|
|
110041
110301
|
out.data({ credential });
|
|
110042
110302
|
return;
|
|
@@ -124682,49 +124942,49 @@ var require_fast_uri = __commonJS({
|
|
|
124682
124942
|
schemelessOptions.skipEscape = true;
|
|
124683
124943
|
return serialize2(resolved, schemelessOptions);
|
|
124684
124944
|
}
|
|
124685
|
-
function resolveComponent(base2,
|
|
124945
|
+
function resolveComponent(base2, relative11, options, skipNormalization) {
|
|
124686
124946
|
const target = {};
|
|
124687
124947
|
if (!skipNormalization) {
|
|
124688
124948
|
base2 = parse4(serialize2(base2, options), options);
|
|
124689
|
-
|
|
124949
|
+
relative11 = parse4(serialize2(relative11, options), options);
|
|
124690
124950
|
}
|
|
124691
124951
|
options = options || {};
|
|
124692
|
-
if (!options.tolerant &&
|
|
124693
|
-
target.scheme =
|
|
124694
|
-
target.userinfo =
|
|
124695
|
-
target.host =
|
|
124696
|
-
target.port =
|
|
124697
|
-
target.path = removeDotSegments(
|
|
124698
|
-
target.query =
|
|
124952
|
+
if (!options.tolerant && relative11.scheme) {
|
|
124953
|
+
target.scheme = relative11.scheme;
|
|
124954
|
+
target.userinfo = relative11.userinfo;
|
|
124955
|
+
target.host = relative11.host;
|
|
124956
|
+
target.port = relative11.port;
|
|
124957
|
+
target.path = removeDotSegments(relative11.path || "");
|
|
124958
|
+
target.query = relative11.query;
|
|
124699
124959
|
} else {
|
|
124700
|
-
if (
|
|
124701
|
-
target.userinfo =
|
|
124702
|
-
target.host =
|
|
124703
|
-
target.port =
|
|
124704
|
-
target.path = removeDotSegments(
|
|
124705
|
-
target.query =
|
|
124960
|
+
if (relative11.userinfo !== void 0 || relative11.host !== void 0 || relative11.port !== void 0) {
|
|
124961
|
+
target.userinfo = relative11.userinfo;
|
|
124962
|
+
target.host = relative11.host;
|
|
124963
|
+
target.port = relative11.port;
|
|
124964
|
+
target.path = removeDotSegments(relative11.path || "");
|
|
124965
|
+
target.query = relative11.query;
|
|
124706
124966
|
} else {
|
|
124707
|
-
if (!
|
|
124967
|
+
if (!relative11.path) {
|
|
124708
124968
|
target.path = base2.path;
|
|
124709
|
-
if (
|
|
124710
|
-
target.query =
|
|
124969
|
+
if (relative11.query !== void 0) {
|
|
124970
|
+
target.query = relative11.query;
|
|
124711
124971
|
} else {
|
|
124712
124972
|
target.query = base2.query;
|
|
124713
124973
|
}
|
|
124714
124974
|
} else {
|
|
124715
|
-
if (
|
|
124716
|
-
target.path = removeDotSegments(
|
|
124975
|
+
if (relative11.path[0] === "/") {
|
|
124976
|
+
target.path = removeDotSegments(relative11.path);
|
|
124717
124977
|
} else {
|
|
124718
124978
|
if ((base2.userinfo !== void 0 || base2.host !== void 0 || base2.port !== void 0) && !base2.path) {
|
|
124719
|
-
target.path = "/" +
|
|
124979
|
+
target.path = "/" + relative11.path;
|
|
124720
124980
|
} else if (!base2.path) {
|
|
124721
|
-
target.path =
|
|
124981
|
+
target.path = relative11.path;
|
|
124722
124982
|
} else {
|
|
124723
|
-
target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) +
|
|
124983
|
+
target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) + relative11.path;
|
|
124724
124984
|
}
|
|
124725
124985
|
target.path = removeDotSegments(target.path);
|
|
124726
124986
|
}
|
|
124727
|
-
target.query =
|
|
124987
|
+
target.query = relative11.query;
|
|
124728
124988
|
}
|
|
124729
124989
|
target.userinfo = base2.userinfo;
|
|
124730
124990
|
target.host = base2.host;
|
|
@@ -124732,7 +124992,7 @@ var require_fast_uri = __commonJS({
|
|
|
124732
124992
|
}
|
|
124733
124993
|
target.scheme = base2.scheme;
|
|
124734
124994
|
}
|
|
124735
|
-
target.fragment =
|
|
124995
|
+
target.fragment = relative11.fragment;
|
|
124736
124996
|
return target;
|
|
124737
124997
|
}
|
|
124738
124998
|
function equal(uriA, uriB, options) {
|
|
@@ -128902,7 +129162,7 @@ __export(mcp_exports, {
|
|
|
128902
129162
|
mcpDescribe: () => mcpDescribe,
|
|
128903
129163
|
mcpList: () => mcpList
|
|
128904
129164
|
});
|
|
128905
|
-
import { readFile as
|
|
129165
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
128906
129166
|
function errorDetails(error2) {
|
|
128907
129167
|
return {
|
|
128908
129168
|
message: error2 instanceof Error ? error2.message : "The MCP request failed.",
|
|
@@ -128962,7 +129222,7 @@ async function readInput(options) {
|
|
|
128962
129222
|
}
|
|
128963
129223
|
text6 = Buffer.concat(chunks).toString("utf8");
|
|
128964
129224
|
} else {
|
|
128965
|
-
text6 = await
|
|
129225
|
+
text6 = await readFile7(options.inputFile, "utf8");
|
|
128966
129226
|
}
|
|
128967
129227
|
}
|
|
128968
129228
|
let value;
|
|
@@ -129466,7 +129726,6 @@ var init_open_browser = __esm({
|
|
|
129466
129726
|
import { execFile as execFile6 } from "node:child_process";
|
|
129467
129727
|
import { createHash as createHash29, randomBytes as randomBytes14 } from "node:crypto";
|
|
129468
129728
|
import {
|
|
129469
|
-
appendFileSync as appendFileSync5,
|
|
129470
129729
|
existsSync as existsSync30,
|
|
129471
129730
|
lstatSync as lstatSync13,
|
|
129472
129731
|
mkdirSync as mkdirSync14,
|
|
@@ -129476,7 +129735,7 @@ import {
|
|
|
129476
129735
|
writeFileSync as writeFileSync11
|
|
129477
129736
|
} from "node:fs";
|
|
129478
129737
|
import { homedir as homedir13, hostname as osHostname3 } from "node:os";
|
|
129479
|
-
import { join as join68,
|
|
129738
|
+
import { join as join68, resolve as resolve26, sep as sep12 } from "node:path";
|
|
129480
129739
|
function git3(cwd, args) {
|
|
129481
129740
|
return new Promise((done) => {
|
|
129482
129741
|
try {
|
|
@@ -129593,7 +129852,6 @@ async function probeWorkingCopy(opts) {
|
|
|
129593
129852
|
return "";
|
|
129594
129853
|
}
|
|
129595
129854
|
})();
|
|
129596
|
-
const pulled = opts.pulledCommit ?? null;
|
|
129597
129855
|
return {
|
|
129598
129856
|
machineId: machineId(opts.configDir),
|
|
129599
129857
|
hostname: host.length > 0 ? host : "unknown",
|
|
@@ -129604,8 +129862,8 @@ async function probeWorkingCopy(opts) {
|
|
|
129604
129862
|
headCommit: head3 && COMMIT_SHA.test(head3) ? head3 : null,
|
|
129605
129863
|
oxagenPresent: oxagenPresent(root),
|
|
129606
129864
|
symlinks: symlinkState(root),
|
|
129607
|
-
pulledCommit:
|
|
129608
|
-
event:
|
|
129865
|
+
pulledCommit: null,
|
|
129866
|
+
event: "init",
|
|
129609
129867
|
cliVersion: cliVersion()
|
|
129610
129868
|
};
|
|
129611
129869
|
}
|
|
@@ -129626,35 +129884,6 @@ async function reportWorkingCopy(opts) {
|
|
|
129626
129884
|
return { error: err2 instanceof Error ? err2.message : String(err2) };
|
|
129627
129885
|
}
|
|
129628
129886
|
}
|
|
129629
|
-
function realpathOr(path2) {
|
|
129630
|
-
try {
|
|
129631
|
-
return realpathSync10(path2);
|
|
129632
|
-
} catch {
|
|
129633
|
-
return resolve26(path2);
|
|
129634
|
-
}
|
|
129635
|
-
}
|
|
129636
|
-
async function ensureWorkspaceLinkIgnored(root) {
|
|
129637
|
-
const top = await git3(root, ["rev-parse", "--show-toplevel"]);
|
|
129638
|
-
if (!top) return null;
|
|
129639
|
-
const topDir = resolve26(top);
|
|
129640
|
-
const entry2 = relative10(
|
|
129641
|
-
topDir,
|
|
129642
|
-
join68(realpathOr(root), ".oxagen", "workspace.json")
|
|
129643
|
-
).split(sep12).join("/");
|
|
129644
|
-
if (entry2.startsWith("../")) return null;
|
|
129645
|
-
const rule = await git3(topDir, ["check-ignore", "--no-index", "-v", entry2]);
|
|
129646
|
-
if (rule !== null) return null;
|
|
129647
|
-
const gitignore = join68(resolve26(top), ".gitignore");
|
|
129648
|
-
let existing = "";
|
|
129649
|
-
try {
|
|
129650
|
-
existing = readFileSync31(gitignore, "utf8");
|
|
129651
|
-
} catch {
|
|
129652
|
-
}
|
|
129653
|
-
const prefix = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
|
|
129654
|
-
appendFileSync5(gitignore, `${prefix}${entry2}
|
|
129655
|
-
`, "utf8");
|
|
129656
|
-
return gitignore;
|
|
129657
|
-
}
|
|
129658
129887
|
var GIT_TIMEOUT_MS2, REPORT_TIMEOUT_MS, MACHINE_ID_FILE, STELLA_LINKS, COMMIT_SHA;
|
|
129659
129888
|
var init_working_copy = __esm({
|
|
129660
129889
|
"src/lib/working-copy.ts"() {
|
|
@@ -129673,84 +129902,6 @@ var init_working_copy = __esm({
|
|
|
129673
129902
|
}
|
|
129674
129903
|
});
|
|
129675
129904
|
|
|
129676
|
-
// src/commands/workspace-link.ts
|
|
129677
|
-
import { existsSync as existsSync31, mkdirSync as mkdirSync15, readFileSync as readFileSync32 } from "node:fs";
|
|
129678
|
-
import { dirname as dirname37, join as join69 } from "node:path";
|
|
129679
|
-
function workspaceLinkPath(cwd) {
|
|
129680
|
-
return join69(cwd, WORKSPACE_LINK_PATH);
|
|
129681
|
-
}
|
|
129682
|
-
function isRecord10(value) {
|
|
129683
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
129684
|
-
}
|
|
129685
|
-
function stringsWherePresent(value, keys) {
|
|
129686
|
-
return keys.every(
|
|
129687
|
-
(key) => value[key] === void 0 || typeof value[key] === "string"
|
|
129688
|
-
);
|
|
129689
|
-
}
|
|
129690
|
-
function linkProblem(value) {
|
|
129691
|
-
if (!isRecord10(value)) return "it is not a JSON object";
|
|
129692
|
-
if (!stringsWherePresent(value, LINK_STRING_FIELDS))
|
|
129693
|
-
return "an org or workspace field is not a string";
|
|
129694
|
-
if (value.repos !== void 0) {
|
|
129695
|
-
const repos = value.repos;
|
|
129696
|
-
if (!Array.isArray(repos) || !repos.every((r) => isRecord10(r) && typeof r.fullName === "string"))
|
|
129697
|
-
return "`repos` is not a list of repositories";
|
|
129698
|
-
}
|
|
129699
|
-
if (value.pull !== void 0) {
|
|
129700
|
-
const pull2 = value.pull;
|
|
129701
|
-
if (!isRecord10(pull2) || !["commit", "bindingId", "fullName", "pulledAt"].every(
|
|
129702
|
-
(key) => typeof pull2[key] === "string"
|
|
129703
|
-
) || !isRecord10(pull2.files) || !Object.values(pull2.files).every((hash4) => typeof hash4 === "string"))
|
|
129704
|
-
return "`pull` is not the record of a pull";
|
|
129705
|
-
}
|
|
129706
|
-
return null;
|
|
129707
|
-
}
|
|
129708
|
-
function readWorkspaceLink(cwd) {
|
|
129709
|
-
const filePath = workspaceLinkPath(cwd);
|
|
129710
|
-
if (!existsSync31(filePath)) return null;
|
|
129711
|
-
let parsed2;
|
|
129712
|
-
try {
|
|
129713
|
-
parsed2 = JSON.parse(readFileSync32(filePath, "utf8"));
|
|
129714
|
-
} catch (err2) {
|
|
129715
|
-
const detail = err2 instanceof Error ? err2.message : String(err2);
|
|
129716
|
-
process.stderr.write(
|
|
129717
|
-
`Warning: corrupt workspace link at ${filePath}: ${detail}
|
|
129718
|
-
`
|
|
129719
|
-
);
|
|
129720
|
-
return null;
|
|
129721
|
-
}
|
|
129722
|
-
const problem = linkProblem(parsed2);
|
|
129723
|
-
if (problem !== null) {
|
|
129724
|
-
process.stderr.write(
|
|
129725
|
-
`Warning: corrupt workspace link at ${filePath}: ${problem}
|
|
129726
|
-
`
|
|
129727
|
-
);
|
|
129728
|
-
return null;
|
|
129729
|
-
}
|
|
129730
|
-
return parsed2;
|
|
129731
|
-
}
|
|
129732
|
-
function writeWorkspaceLink(cwd, link) {
|
|
129733
|
-
const filePath = workspaceLinkPath(cwd);
|
|
129734
|
-
mkdirSync15(dirname37(filePath), { recursive: true });
|
|
129735
|
-
atomicWriteFileSync(filePath, JSON.stringify(link, null, 2));
|
|
129736
|
-
}
|
|
129737
|
-
var LINK_STRING_FIELDS;
|
|
129738
|
-
var init_workspace_link = __esm({
|
|
129739
|
-
"src/commands/workspace-link.ts"() {
|
|
129740
|
-
init_paths2();
|
|
129741
|
-
init_atomic_write();
|
|
129742
|
-
LINK_STRING_FIELDS = [
|
|
129743
|
-
"orgSlug",
|
|
129744
|
-
"orgId",
|
|
129745
|
-
"orgName",
|
|
129746
|
-
"workspaceSlug",
|
|
129747
|
-
"workspaceId",
|
|
129748
|
-
"workspaceName",
|
|
129749
|
-
"linkedAt"
|
|
129750
|
-
];
|
|
129751
|
-
}
|
|
129752
|
-
});
|
|
129753
|
-
|
|
129754
129905
|
// src/commands/init.ts
|
|
129755
129906
|
var init_exports = {};
|
|
129756
129907
|
__export(init_exports, {
|
|
@@ -129893,7 +130044,7 @@ GitHub connected. Fetching repositories...
|
|
|
129893
130044
|
} catch (err2) {
|
|
129894
130045
|
process.stdout.write(
|
|
129895
130046
|
` Could not list the GitHub App's installations: ${errorMessage3(err2)}
|
|
129896
|
-
|
|
130047
|
+
Re-run \`oxagen init\` to list the repositories again.
|
|
129897
130048
|
`
|
|
129898
130049
|
);
|
|
129899
130050
|
return null;
|
|
@@ -129924,7 +130075,7 @@ GitHub connected. Fetching repositories...
|
|
|
129924
130075
|
});
|
|
129925
130076
|
if (failed5 > 0) {
|
|
129926
130077
|
process.stdout.write(
|
|
129927
|
-
`
|
|
130078
|
+
` Re-run \`oxagen init\` to list the repositories again.
|
|
129928
130079
|
`
|
|
129929
130080
|
);
|
|
129930
130081
|
return null;
|
|
@@ -129948,7 +130099,7 @@ GitHub connected. Fetching repositories...
|
|
|
129948
130099
|
}
|
|
129949
130100
|
return repos;
|
|
129950
130101
|
}
|
|
129951
|
-
async function runWorkspaceLinker(
|
|
130102
|
+
async function runWorkspaceLinker(flags) {
|
|
129952
130103
|
const token = getToken();
|
|
129953
130104
|
if (!token) {
|
|
129954
130105
|
return {
|
|
@@ -129961,25 +130112,20 @@ async function runWorkspaceLinker(root, flags) {
|
|
|
129961
130112
|
Linking workspace...
|
|
129962
130113
|
`);
|
|
129963
130114
|
let account;
|
|
129964
|
-
const
|
|
129965
|
-
const
|
|
130115
|
+
const savedOrg = getOrgId();
|
|
130116
|
+
const savedWorkspace = getWorkspaceId();
|
|
130117
|
+
const saved = savedOrg && savedWorkspace ? { orgSlug: savedOrg, workspaceSlug: savedWorkspace } : null;
|
|
130118
|
+
const namesOtherPair = saved !== null && (flags.org !== void 0 && flags.org !== saved.orgSlug || flags.workspace !== void 0 && flags.workspace !== saved.workspaceSlug);
|
|
129966
130119
|
let relinkedFrom;
|
|
129967
|
-
if (
|
|
130120
|
+
if (saved && !namesOtherPair) {
|
|
129968
130121
|
process.stdout.write(
|
|
129969
|
-
` Already linked: ${
|
|
130122
|
+
` Already linked: ${saved.orgSlug} / ${saved.workspaceSlug}
|
|
129970
130123
|
`
|
|
129971
130124
|
);
|
|
129972
|
-
account =
|
|
129973
|
-
orgId: existing.orgId,
|
|
129974
|
-
orgSlug: existing.orgSlug,
|
|
129975
|
-
orgName: existing.orgName,
|
|
129976
|
-
workspaceId: existing.workspaceId,
|
|
129977
|
-
workspaceSlug: existing.workspaceSlug,
|
|
129978
|
-
workspaceName: existing.workspaceName
|
|
129979
|
-
};
|
|
130125
|
+
account = saved;
|
|
129980
130126
|
} else {
|
|
129981
|
-
const orgSlug = flags.org ??
|
|
129982
|
-
const workspaceSlug3 = flags.workspace ?? (
|
|
130127
|
+
const orgSlug = flags.org ?? saved?.orgSlug;
|
|
130128
|
+
const workspaceSlug3 = flags.workspace ?? (saved && orgSlug === saved.orgSlug ? saved.workspaceSlug : void 0);
|
|
129983
130129
|
try {
|
|
129984
130130
|
account = await resolveLinkedAccount({ orgSlug, workspaceSlug: workspaceSlug3, isTTY });
|
|
129985
130131
|
} catch (err2) {
|
|
@@ -129988,23 +130134,14 @@ Linking workspace...
|
|
|
129988
130134
|
skippedReason: `Workspace picker failed: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
129989
130135
|
};
|
|
129990
130136
|
}
|
|
129991
|
-
|
|
130137
|
+
writeConfig({
|
|
129992
130138
|
orgSlug: account.orgSlug,
|
|
129993
|
-
|
|
129994
|
-
|
|
129995
|
-
|
|
129996
|
-
|
|
129997
|
-
workspaceName: account.workspaceName,
|
|
129998
|
-
linkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
129999
|
-
};
|
|
130000
|
-
writeWorkspaceLink(root, link);
|
|
130001
|
-
if (existing) {
|
|
130002
|
-
relinkedFrom = {
|
|
130003
|
-
orgSlug: existing.orgSlug,
|
|
130004
|
-
workspaceSlug: existing.workspaceSlug
|
|
130005
|
-
};
|
|
130139
|
+
workspaceSlug: account.workspaceSlug
|
|
130140
|
+
});
|
|
130141
|
+
if (saved) {
|
|
130142
|
+
relinkedFrom = saved;
|
|
130006
130143
|
process.stdout.write(
|
|
130007
|
-
` Relinked: ${account.orgName} / ${account.workspaceName} (was ${
|
|
130144
|
+
` Relinked: ${account.orgName} / ${account.workspaceName} (was ${saved.orgSlug} / ${saved.workspaceSlug})
|
|
130008
130145
|
`
|
|
130009
130146
|
);
|
|
130010
130147
|
} else {
|
|
@@ -130064,23 +130201,19 @@ No GitHub connection found in this workspace.
|
|
|
130064
130201
|
`
|
|
130065
130202
|
);
|
|
130066
130203
|
}
|
|
130067
|
-
const currentLink = readWorkspaceLink(root);
|
|
130068
|
-
if (currentLink && repos) {
|
|
130069
|
-
writeWorkspaceLink(root, { ...currentLink, repos });
|
|
130070
|
-
}
|
|
130071
130204
|
return {
|
|
130072
130205
|
linked: true,
|
|
130073
130206
|
orgSlug: account.orgSlug,
|
|
130074
|
-
orgName: account.orgName,
|
|
130207
|
+
...account.orgName !== void 0 ? { orgName: account.orgName } : {},
|
|
130075
130208
|
workspaceSlug: account.workspaceSlug,
|
|
130076
|
-
workspaceName: account.workspaceName,
|
|
130077
|
-
repos
|
|
130209
|
+
...account.workspaceName !== void 0 ? { workspaceName: account.workspaceName } : {},
|
|
130210
|
+
...repos ? { repos } : {},
|
|
130078
130211
|
...relinkedFrom ? { relinkedFrom } : {}
|
|
130079
130212
|
};
|
|
130080
130213
|
}
|
|
130081
130214
|
function formatInitSummary(result2) {
|
|
130082
130215
|
const lines = [];
|
|
130083
|
-
lines.push(`
|
|
130216
|
+
lines.push(`Directory: ${result2.projectRoot}`);
|
|
130084
130217
|
if (result2.workspaceLink === null) {
|
|
130085
130218
|
lines.push(" Skipped (--no-link).");
|
|
130086
130219
|
return lines.join("\n");
|
|
@@ -130092,7 +130225,7 @@ function formatInitSummary(result2) {
|
|
|
130092
130225
|
);
|
|
130093
130226
|
if (wl.relinkedFrom) {
|
|
130094
130227
|
lines.push(
|
|
130095
|
-
` Replaced
|
|
130228
|
+
` Replaced ${wl.relinkedFrom.orgSlug} / ${wl.relinkedFrom.workspaceSlug}.`
|
|
130096
130229
|
);
|
|
130097
130230
|
}
|
|
130098
130231
|
if (wl.repos && wl.repos.length > 0) {
|
|
@@ -130103,9 +130236,6 @@ function formatInitSummary(result2) {
|
|
|
130103
130236
|
} else if (result2.workspaceLink.skippedReason) {
|
|
130104
130237
|
lines.push(` ${result2.workspaceLink.skippedReason}`);
|
|
130105
130238
|
}
|
|
130106
|
-
if (result2.gitignoreUpdated) {
|
|
130107
|
-
lines.push(` Added .oxagen/workspace.json to ${result2.gitignoreUpdated}.`);
|
|
130108
|
-
}
|
|
130109
130239
|
if (result2.workingCopy && "workingCopyId" in result2.workingCopy) {
|
|
130110
130240
|
lines.push(
|
|
130111
130241
|
` Reported this directory to Oxagen (${result2.workingCopy.workingCopyId}).`
|
|
@@ -130119,48 +130249,28 @@ async function runInit(opts) {
|
|
|
130119
130249
|
await opts.onProgress?.(event);
|
|
130120
130250
|
};
|
|
130121
130251
|
let workspaceLink = null;
|
|
130122
|
-
let gitignoreUpdated = null;
|
|
130123
130252
|
let workingCopy = null;
|
|
130124
130253
|
if (!opts.noLink) {
|
|
130125
130254
|
await emit({ phase: "link", status: "start" });
|
|
130126
|
-
workspaceLink = await runWorkspaceLinker(
|
|
130255
|
+
workspaceLink = await runWorkspaceLinker({
|
|
130127
130256
|
org: opts.org,
|
|
130128
130257
|
workspace: opts.workspace
|
|
130129
130258
|
});
|
|
130130
130259
|
await emit({ phase: "link", status: "done" });
|
|
130131
130260
|
}
|
|
130132
|
-
if (workspaceLink?.linked) {
|
|
130133
|
-
|
|
130134
|
-
|
|
130135
|
-
|
|
130261
|
+
if (workspaceLink?.linked && workspaceLink.orgSlug !== void 0 && workspaceLink.workspaceSlug !== void 0) {
|
|
130262
|
+
workingCopy = await reportWorkingCopy({
|
|
130263
|
+
root,
|
|
130264
|
+
scope: { org: workspaceLink.orgSlug, ws: workspaceLink.workspaceSlug }
|
|
130265
|
+
});
|
|
130266
|
+
if ("error" in workingCopy) {
|
|
130136
130267
|
process.stderr.write(
|
|
130137
|
-
`Warning: could not
|
|
130268
|
+
`Warning: could not report this directory to Oxagen: ${workingCopy.error}
|
|
130138
130269
|
`
|
|
130139
130270
|
);
|
|
130140
130271
|
}
|
|
130141
|
-
const link = readWorkspaceLink(root);
|
|
130142
|
-
if (link) {
|
|
130143
|
-
workingCopy = await reportWorkingCopy({
|
|
130144
|
-
root,
|
|
130145
|
-
scope: { org: link.orgSlug, ws: link.workspaceSlug },
|
|
130146
|
-
event: "init",
|
|
130147
|
-
pulledCommit: link.pull?.commit ?? null
|
|
130148
|
-
});
|
|
130149
|
-
if ("error" in workingCopy) {
|
|
130150
|
-
process.stderr.write(
|
|
130151
|
-
`Warning: could not report this directory to Oxagen: ${workingCopy.error}
|
|
130152
|
-
`
|
|
130153
|
-
);
|
|
130154
|
-
}
|
|
130155
|
-
}
|
|
130156
130272
|
}
|
|
130157
|
-
return {
|
|
130158
|
-
projectRoot: root,
|
|
130159
|
-
workspaceLinkPath: workspaceLinkPath(root),
|
|
130160
|
-
workspaceLink,
|
|
130161
|
-
gitignoreUpdated,
|
|
130162
|
-
workingCopy
|
|
130163
|
-
};
|
|
130273
|
+
return { projectRoot: root, workspaceLink, workingCopy };
|
|
130164
130274
|
}
|
|
130165
130275
|
function divertStdoutToStderr() {
|
|
130166
130276
|
const original = process.stdout.write;
|
|
@@ -130214,7 +130324,6 @@ var init_init = __esm({
|
|
|
130214
130324
|
init_config();
|
|
130215
130325
|
init_linker();
|
|
130216
130326
|
init_working_copy();
|
|
130217
|
-
init_workspace_link();
|
|
130218
130327
|
init_api();
|
|
130219
130328
|
init_output();
|
|
130220
130329
|
GITHUB_POLL = {
|
|
@@ -130224,430 +130333,6 @@ var init_init = __esm({
|
|
|
130224
130333
|
}
|
|
130225
130334
|
});
|
|
130226
130335
|
|
|
130227
|
-
// src/commands/pull.ts
|
|
130228
|
-
var pull_exports = {};
|
|
130229
|
-
__export(pull_exports, {
|
|
130230
|
-
applyPlan: () => applyPlan,
|
|
130231
|
-
checkSteeringPath: () => checkSteeringPath,
|
|
130232
|
-
findLinkedRoot: () => findLinkedRoot,
|
|
130233
|
-
fsReader: () => fsReader,
|
|
130234
|
-
isPublishedSteering: () => isPublishedSteering,
|
|
130235
|
-
planPull: () => planPull,
|
|
130236
|
-
pull: () => pull,
|
|
130237
|
-
recordPull: () => recordPull,
|
|
130238
|
-
sha256: () => sha2563
|
|
130239
|
-
});
|
|
130240
|
-
import { createHash as createHash30 } from "node:crypto";
|
|
130241
|
-
import {
|
|
130242
|
-
existsSync as existsSync32,
|
|
130243
|
-
lstatSync as lstatSync14,
|
|
130244
|
-
mkdirSync as mkdirSync16,
|
|
130245
|
-
readFileSync as readFileSync33,
|
|
130246
|
-
readdirSync as readdirSync19,
|
|
130247
|
-
realpathSync as realpathSync11,
|
|
130248
|
-
rmSync as rmSync14,
|
|
130249
|
-
rmdirSync as rmdirSync7
|
|
130250
|
-
} from "node:fs";
|
|
130251
|
-
import {
|
|
130252
|
-
dirname as dirname38,
|
|
130253
|
-
isAbsolute as isAbsolute19,
|
|
130254
|
-
join as join70,
|
|
130255
|
-
parse as parsePath,
|
|
130256
|
-
posix as posix8,
|
|
130257
|
-
sep as sep13
|
|
130258
|
-
} from "node:path";
|
|
130259
|
-
function isPublishedSteering(value) {
|
|
130260
|
-
if (typeof value !== "object" || value === null) return false;
|
|
130261
|
-
const answer = value;
|
|
130262
|
-
return typeof answer.bindingId === "string" && answer.bindingId.length > 0 && typeof answer.fullName === "string" && typeof answer.productionBranch === "string" && (answer.head === null || typeof answer.head === "string") && Array.isArray(answer.files) && answer.files.every(
|
|
130263
|
-
(file) => typeof file === "object" && file !== null && typeof file.path === "string" && typeof file.content === "string"
|
|
130264
|
-
);
|
|
130265
|
-
}
|
|
130266
|
-
function checkSteeringPath(path2) {
|
|
130267
|
-
if (typeof path2 !== "string" || path2.length === 0) {
|
|
130268
|
-
return { ok: false, reason: "empty path" };
|
|
130269
|
-
}
|
|
130270
|
-
if (path2.includes("\0")) return { ok: false, reason: "contains a NUL byte" };
|
|
130271
|
-
if (path2.includes("\\")) {
|
|
130272
|
-
return { ok: false, reason: "contains a backslash" };
|
|
130273
|
-
}
|
|
130274
|
-
if (posix8.isAbsolute(path2) || isAbsolute19(path2) || /^[A-Za-z]:/.test(path2)) {
|
|
130275
|
-
return { ok: false, reason: "absolute path" };
|
|
130276
|
-
}
|
|
130277
|
-
const normalized = posix8.normalize(path2);
|
|
130278
|
-
if (normalized !== path2 || normalized.split("/").some((s2) => s2 === ".." || s2 === ".")) {
|
|
130279
|
-
return { ok: false, reason: "has a . or .. part or a double slash" };
|
|
130280
|
-
}
|
|
130281
|
-
if (!normalized.startsWith(`${OXAGEN_DIR}/`)) {
|
|
130282
|
-
return { ok: false, reason: "outside .oxagen/" };
|
|
130283
|
-
}
|
|
130284
|
-
if (normalized === LINK_PATH) {
|
|
130285
|
-
return { ok: false, reason: "the machine's own workspace link" };
|
|
130286
|
-
}
|
|
130287
|
-
return { ok: true, path: normalized };
|
|
130288
|
-
}
|
|
130289
|
-
function sha2563(content) {
|
|
130290
|
-
return createHash30("sha256").update(content).digest("hex");
|
|
130291
|
-
}
|
|
130292
|
-
function planPull(input) {
|
|
130293
|
-
const base2 = input.base ?? {};
|
|
130294
|
-
const force = input.force === true;
|
|
130295
|
-
const entries2 = [];
|
|
130296
|
-
const conflicts = [];
|
|
130297
|
-
const rejected2 = [];
|
|
130298
|
-
const writes = [];
|
|
130299
|
-
const deletes = [];
|
|
130300
|
-
const manifest = {};
|
|
130301
|
-
const published = /* @__PURE__ */ new Map();
|
|
130302
|
-
for (const file of input.published) {
|
|
130303
|
-
const checked2 = checkSteeringPath(file.path);
|
|
130304
|
-
if (!checked2.ok) {
|
|
130305
|
-
rejected2.push({ path: String(file.path), reason: checked2.reason });
|
|
130306
|
-
continue;
|
|
130307
|
-
}
|
|
130308
|
-
if (published.has(checked2.path)) {
|
|
130309
|
-
rejected2.push({ path: checked2.path, reason: "published twice" });
|
|
130310
|
-
continue;
|
|
130311
|
-
}
|
|
130312
|
-
published.set(checked2.path, file.content);
|
|
130313
|
-
}
|
|
130314
|
-
for (const [path2, content] of [...published].sort(
|
|
130315
|
-
([a], [b3]) => a < b3 ? -1 : a > b3 ? 1 : 0
|
|
130316
|
-
)) {
|
|
130317
|
-
const want = sha2563(content);
|
|
130318
|
-
manifest[path2] = want;
|
|
130319
|
-
const local = input.readLocal(path2);
|
|
130320
|
-
if (local === null) {
|
|
130321
|
-
entries2.push({ path: path2, action: "create" });
|
|
130322
|
-
writes.push({ path: path2, content });
|
|
130323
|
-
continue;
|
|
130324
|
-
}
|
|
130325
|
-
const have = sha2563(local);
|
|
130326
|
-
if (have === want) {
|
|
130327
|
-
entries2.push({ path: path2, action: "unchanged" });
|
|
130328
|
-
} else if (base2[path2] === have || force) {
|
|
130329
|
-
entries2.push({ path: path2, action: "update" });
|
|
130330
|
-
writes.push({ path: path2, content });
|
|
130331
|
-
} else {
|
|
130332
|
-
entries2.push({ path: path2, action: "conflict", wants: "update" });
|
|
130333
|
-
conflicts.push(path2);
|
|
130334
|
-
}
|
|
130335
|
-
}
|
|
130336
|
-
const gone = Object.keys(base2).filter((p) => !published.has(p)).sort();
|
|
130337
|
-
for (const path2 of gone) {
|
|
130338
|
-
if (!checkSteeringPath(path2).ok) continue;
|
|
130339
|
-
const local = input.readLocal(path2);
|
|
130340
|
-
if (local === null) continue;
|
|
130341
|
-
if (sha2563(local) === base2[path2] || force) {
|
|
130342
|
-
entries2.push({ path: path2, action: "delete" });
|
|
130343
|
-
deletes.push(path2);
|
|
130344
|
-
} else {
|
|
130345
|
-
entries2.push({ path: path2, action: "conflict", wants: "delete" });
|
|
130346
|
-
conflicts.push(path2);
|
|
130347
|
-
}
|
|
130348
|
-
}
|
|
130349
|
-
return {
|
|
130350
|
-
entries: entries2,
|
|
130351
|
-
conflicts: force ? [] : conflicts,
|
|
130352
|
-
rejected: rejected2,
|
|
130353
|
-
writes,
|
|
130354
|
-
deletes,
|
|
130355
|
-
manifest
|
|
130356
|
-
};
|
|
130357
|
-
}
|
|
130358
|
-
function findLinkedRoot(start) {
|
|
130359
|
-
let dir = start;
|
|
130360
|
-
const { root } = parsePath(start);
|
|
130361
|
-
for (; ; ) {
|
|
130362
|
-
try {
|
|
130363
|
-
if (lstatSync14(workspaceLinkPath(dir)).isFile()) return dir;
|
|
130364
|
-
} catch {
|
|
130365
|
-
}
|
|
130366
|
-
if (dir === root) return null;
|
|
130367
|
-
const parent = dirname38(dir);
|
|
130368
|
-
if (parent === dir) return null;
|
|
130369
|
-
dir = parent;
|
|
130370
|
-
}
|
|
130371
|
-
}
|
|
130372
|
-
function fsReader(root, strict = false) {
|
|
130373
|
-
return (path2) => {
|
|
130374
|
-
if (strict) assertInsideOxagen(root, path2);
|
|
130375
|
-
const abs = join70(root, ...path2.split("/"));
|
|
130376
|
-
try {
|
|
130377
|
-
const st = lstatSync14(abs);
|
|
130378
|
-
if (!st.isFile()) return Buffer.from(`\0not-a-file:${abs}`);
|
|
130379
|
-
return readFileSync33(abs);
|
|
130380
|
-
} catch (error2) {
|
|
130381
|
-
if (!strict || error2 instanceof Error && "code" in error2 && error2.code === "ENOENT")
|
|
130382
|
-
return null;
|
|
130383
|
-
throw error2;
|
|
130384
|
-
}
|
|
130385
|
-
};
|
|
130386
|
-
}
|
|
130387
|
-
function assertInsideOxagen(root, path2) {
|
|
130388
|
-
const oxagenAbs = join70(root, OXAGEN_DIR);
|
|
130389
|
-
if (existsSync32(oxagenAbs) && lstatSync14(oxagenAbs).isSymbolicLink()) {
|
|
130390
|
-
throw new Error(
|
|
130391
|
-
".oxagen is a symlink. Use a local directory for pulled steering."
|
|
130392
|
-
);
|
|
130393
|
-
}
|
|
130394
|
-
let oxagenReal;
|
|
130395
|
-
try {
|
|
130396
|
-
oxagenReal = realpathSync11(oxagenAbs);
|
|
130397
|
-
} catch {
|
|
130398
|
-
return;
|
|
130399
|
-
}
|
|
130400
|
-
const abs = join70(root, ...path2.split("/"));
|
|
130401
|
-
try {
|
|
130402
|
-
if (lstatSync14(abs).isSymbolicLink()) {
|
|
130403
|
-
throw new Error(
|
|
130404
|
-
`${path2} is a symlink, and pull does not write through one`
|
|
130405
|
-
);
|
|
130406
|
-
}
|
|
130407
|
-
} catch (err2) {
|
|
130408
|
-
if (err2.code !== "ENOENT") throw err2;
|
|
130409
|
-
}
|
|
130410
|
-
let dir = dirname38(abs);
|
|
130411
|
-
for (; ; ) {
|
|
130412
|
-
let real = null;
|
|
130413
|
-
try {
|
|
130414
|
-
real = realpathSync11(dir);
|
|
130415
|
-
} catch {
|
|
130416
|
-
real = null;
|
|
130417
|
-
}
|
|
130418
|
-
if (real !== null) {
|
|
130419
|
-
if (real !== oxagenReal && !real.startsWith(oxagenReal + sep13)) {
|
|
130420
|
-
throw new Error(`${path2} resolves outside .oxagen/`);
|
|
130421
|
-
}
|
|
130422
|
-
return;
|
|
130423
|
-
}
|
|
130424
|
-
const parent = dirname38(dir);
|
|
130425
|
-
if (parent === dir) return;
|
|
130426
|
-
dir = parent;
|
|
130427
|
-
}
|
|
130428
|
-
}
|
|
130429
|
-
function pruneEmptyDirs(root, path2) {
|
|
130430
|
-
const stop = join70(root, OXAGEN_DIR);
|
|
130431
|
-
let dir = dirname38(join70(root, ...path2.split("/")));
|
|
130432
|
-
while (dir.startsWith(stop + sep13)) {
|
|
130433
|
-
try {
|
|
130434
|
-
if (readdirSync19(dir).length > 0) return;
|
|
130435
|
-
rmdirSync7(dir);
|
|
130436
|
-
} catch {
|
|
130437
|
-
return;
|
|
130438
|
-
}
|
|
130439
|
-
dir = dirname38(dir);
|
|
130440
|
-
}
|
|
130441
|
-
}
|
|
130442
|
-
function applyPlan(root, plan, deadline) {
|
|
130443
|
-
const checkDeadline = () => {
|
|
130444
|
-
if (deadline !== void 0 && Date.now() >= deadline) {
|
|
130445
|
-
throw new Error(
|
|
130446
|
-
"The steering pull ran out of time. Run `oxagen pull` again."
|
|
130447
|
-
);
|
|
130448
|
-
}
|
|
130449
|
-
};
|
|
130450
|
-
checkDeadline();
|
|
130451
|
-
for (const w of plan.writes) assertInsideOxagen(root, w.path);
|
|
130452
|
-
for (const d of plan.deletes) assertInsideOxagen(root, d);
|
|
130453
|
-
for (const w of plan.writes) {
|
|
130454
|
-
checkDeadline();
|
|
130455
|
-
const abs = join70(root, ...w.path.split("/"));
|
|
130456
|
-
mkdirSync16(dirname38(abs), { recursive: true });
|
|
130457
|
-
atomicWriteFileSync(abs, w.content);
|
|
130458
|
-
}
|
|
130459
|
-
for (const d of plan.deletes) {
|
|
130460
|
-
checkDeadline();
|
|
130461
|
-
rmSync14(join70(root, ...d.split("/")), { force: true });
|
|
130462
|
-
pruneEmptyDirs(root, d);
|
|
130463
|
-
}
|
|
130464
|
-
}
|
|
130465
|
-
function recordPull(root, link, published, plan) {
|
|
130466
|
-
if (published.head === null)
|
|
130467
|
-
throw new Error("The steering publication has no commit.");
|
|
130468
|
-
const current = readWorkspaceLink(root);
|
|
130469
|
-
if (!current || current.orgSlug !== link.orgSlug || current.workspaceSlug !== link.workspaceSlug) {
|
|
130470
|
-
throw new Error("The workspace link changed. Run `oxagen pull` again.");
|
|
130471
|
-
}
|
|
130472
|
-
writeWorkspaceLink(root, {
|
|
130473
|
-
...current,
|
|
130474
|
-
pull: {
|
|
130475
|
-
commit: published.head,
|
|
130476
|
-
bindingId: published.bindingId,
|
|
130477
|
-
fullName: published.fullName,
|
|
130478
|
-
pulledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
130479
|
-
files: plan.manifest
|
|
130480
|
-
}
|
|
130481
|
-
});
|
|
130482
|
-
}
|
|
130483
|
-
function short3(sha2) {
|
|
130484
|
-
return sha2.slice(0, 7);
|
|
130485
|
-
}
|
|
130486
|
-
async function pull(opts = {}, writer = stdoutWriter, cwd = process.cwd()) {
|
|
130487
|
-
const out = createOutput({ json: opts.json }, writer);
|
|
130488
|
-
if (opts.binding !== void 0 && !BINDING_ID.test(opts.binding)) {
|
|
130489
|
-
out.error(
|
|
130490
|
-
`--binding takes a repository binding id (rpb_\u2026), not "${opts.binding}".`,
|
|
130491
|
-
"bad_argument"
|
|
130492
|
-
);
|
|
130493
|
-
process.exitCode = 2;
|
|
130494
|
-
return;
|
|
130495
|
-
}
|
|
130496
|
-
const root = findLinkedRoot(cwd);
|
|
130497
|
-
const link = root ? readWorkspaceLink(root) : null;
|
|
130498
|
-
if (!root || !link?.orgSlug || !link.workspaceSlug) {
|
|
130499
|
-
out.error(NOT_LINKED, "not_linked");
|
|
130500
|
-
return;
|
|
130501
|
-
}
|
|
130502
|
-
const scope = { org: link.orgSlug, ws: link.workspaceSlug };
|
|
130503
|
-
let answer;
|
|
130504
|
-
try {
|
|
130505
|
-
answer = await apiPostOrThrow(
|
|
130506
|
-
"context/steering/published",
|
|
130507
|
-
opts.binding ? { bindingId: opts.binding } : {},
|
|
130508
|
-
scope
|
|
130509
|
-
);
|
|
130510
|
-
} catch (err2) {
|
|
130511
|
-
out.error(err2, "api_error");
|
|
130512
|
-
return;
|
|
130513
|
-
}
|
|
130514
|
-
if (!isPublishedSteering(answer)) {
|
|
130515
|
-
out.error(
|
|
130516
|
-
"Oxagen's answer for the published steering is not in the shape this CLI reads. Nothing was written. Update the CLI and pull again.",
|
|
130517
|
-
"bad_answer"
|
|
130518
|
-
);
|
|
130519
|
-
return;
|
|
130520
|
-
}
|
|
130521
|
-
const published = answer;
|
|
130522
|
-
const source = published.fullName;
|
|
130523
|
-
if (published.head === null) {
|
|
130524
|
-
out.error(
|
|
130525
|
-
`The production branch ${published.productionBranch} of ${source} is gone, so nothing is published to pull. Set the production branch on the Repositories page.`,
|
|
130526
|
-
"branch_gone"
|
|
130527
|
-
);
|
|
130528
|
-
return;
|
|
130529
|
-
}
|
|
130530
|
-
const head3 = published.head;
|
|
130531
|
-
const at2 = `${source}@${short3(head3)} (${published.productionBranch})`;
|
|
130532
|
-
const plan = planPull({
|
|
130533
|
-
published: published.files,
|
|
130534
|
-
readLocal: fsReader(root),
|
|
130535
|
-
base: link.pull?.files,
|
|
130536
|
-
force: opts.force
|
|
130537
|
-
});
|
|
130538
|
-
const created = plan.entries.filter((e) => e.action === "create").map((e) => e.path);
|
|
130539
|
-
const updated = plan.entries.filter((e) => e.action === "update").map((e) => e.path);
|
|
130540
|
-
const deleted = plan.entries.filter((e) => e.action === "delete").map((e) => e.path);
|
|
130541
|
-
const unchanged = plan.entries.filter((e) => e.action === "unchanged").length;
|
|
130542
|
-
const summary = {
|
|
130543
|
-
projectRoot: root,
|
|
130544
|
-
repository: published.fullName,
|
|
130545
|
-
bindingId: published.bindingId,
|
|
130546
|
-
productionBranch: published.productionBranch,
|
|
130547
|
-
head: head3,
|
|
130548
|
-
created,
|
|
130549
|
-
updated,
|
|
130550
|
-
deleted,
|
|
130551
|
-
unchanged,
|
|
130552
|
-
conflicts: plan.conflicts,
|
|
130553
|
-
rejected: plan.rejected
|
|
130554
|
-
};
|
|
130555
|
-
if (plan.rejected.length > 0) {
|
|
130556
|
-
const list2 = plan.rejected.map((r) => `${r.path} (${r.reason})`).join(", ");
|
|
130557
|
-
if (out.isJson) {
|
|
130558
|
-
out.data({ status: "refused", refusal: "unsafe_paths", ...summary });
|
|
130559
|
-
}
|
|
130560
|
-
out.error(
|
|
130561
|
-
`Refused: ${source} publishes paths pull will not write: ${list2}. Nothing was written.`,
|
|
130562
|
-
"unsafe_paths"
|
|
130563
|
-
);
|
|
130564
|
-
return;
|
|
130565
|
-
}
|
|
130566
|
-
if (plan.conflicts.length > 0) {
|
|
130567
|
-
if (out.isJson) {
|
|
130568
|
-
out.data({ status: "refused", refusal: "conflicts", ...summary });
|
|
130569
|
-
} else {
|
|
130570
|
-
for (const path2 of plan.conflicts) writer.write(`conflict ${path2}`);
|
|
130571
|
-
}
|
|
130572
|
-
out.error(
|
|
130573
|
-
`Refused: ${plan.conflicts.length} file${plan.conflicts.length === 1 ? " was" : "s were"} edited here and differ from ${at2}. Nothing was written. Move your edits aside, or run \`oxagen pull --force\` to overwrite them.`,
|
|
130574
|
-
"conflicts"
|
|
130575
|
-
);
|
|
130576
|
-
return;
|
|
130577
|
-
}
|
|
130578
|
-
const changes = created.length + updated.length + deleted.length;
|
|
130579
|
-
if (opts.dryRun) {
|
|
130580
|
-
if (out.isJson) {
|
|
130581
|
-
out.data({ status: "dry_run", ...summary });
|
|
130582
|
-
return;
|
|
130583
|
-
}
|
|
130584
|
-
for (const p of created) writer.write(`would create ${p}`);
|
|
130585
|
-
for (const p of updated) writer.write(`would update ${p}`);
|
|
130586
|
-
for (const p of deleted) writer.write(`would delete ${p}`);
|
|
130587
|
-
writer.write(
|
|
130588
|
-
changes === 0 ? `Dry run: already up to date with ${at2}.` : `Dry run: would pull ${plural3(created.length + updated.length, "file", "files")} and delete ${deleted.length} from ${at2}. Nothing was written.`
|
|
130589
|
-
);
|
|
130590
|
-
return;
|
|
130591
|
-
}
|
|
130592
|
-
try {
|
|
130593
|
-
applyPlan(root, plan);
|
|
130594
|
-
} catch (err2) {
|
|
130595
|
-
out.error(
|
|
130596
|
-
`Pull stopped: ${err2 instanceof Error ? err2.message : String(err2)}`,
|
|
130597
|
-
"write_failed"
|
|
130598
|
-
);
|
|
130599
|
-
return;
|
|
130600
|
-
}
|
|
130601
|
-
recordPull(root, link, published, plan);
|
|
130602
|
-
const workingCopy = await reportWorkingCopy({
|
|
130603
|
-
root,
|
|
130604
|
-
scope,
|
|
130605
|
-
event: "pull",
|
|
130606
|
-
pulledCommit: head3
|
|
130607
|
-
});
|
|
130608
|
-
if ("error" in workingCopy) {
|
|
130609
|
-
out.warn(
|
|
130610
|
-
`Warning: could not report this directory to Oxagen: ${workingCopy.error}`
|
|
130611
|
-
);
|
|
130612
|
-
}
|
|
130613
|
-
if (out.isJson) {
|
|
130614
|
-
out.data({
|
|
130615
|
-
status: changes === 0 ? "up_to_date" : "pulled",
|
|
130616
|
-
...summary,
|
|
130617
|
-
workingCopy
|
|
130618
|
-
});
|
|
130619
|
-
return;
|
|
130620
|
-
}
|
|
130621
|
-
for (const p of created) writer.write(`created ${p}`);
|
|
130622
|
-
for (const p of updated) writer.write(`updated ${p}`);
|
|
130623
|
-
for (const p of deleted) writer.write(`deleted ${p}`);
|
|
130624
|
-
if (changes === 0) {
|
|
130625
|
-
writer.write(`Already up to date with ${at2}.`);
|
|
130626
|
-
return;
|
|
130627
|
-
}
|
|
130628
|
-
const deletedNote = deleted.length > 0 ? `, deleted ${deleted.length}` : "";
|
|
130629
|
-
writer.write(
|
|
130630
|
-
`Pulled ${plural3(created.length + updated.length, "file", "files")} from ${at2}${deletedNote}.`
|
|
130631
|
-
);
|
|
130632
|
-
}
|
|
130633
|
-
var OXAGEN_DIR, LINK_PATH, NOT_LINKED, BINDING_ID;
|
|
130634
|
-
var init_pull = __esm({
|
|
130635
|
-
"src/commands/pull.ts"() {
|
|
130636
|
-
init_paths2();
|
|
130637
|
-
init_api();
|
|
130638
|
-
init_atomic_write();
|
|
130639
|
-
init_capture_writer();
|
|
130640
|
-
init_output();
|
|
130641
|
-
init_working_copy();
|
|
130642
|
-
init_workspace_link();
|
|
130643
|
-
init_steering_findings();
|
|
130644
|
-
OXAGEN_DIR = ".oxagen";
|
|
130645
|
-
LINK_PATH = WORKSPACE_LINK_PATH;
|
|
130646
|
-
NOT_LINKED = "This directory is not linked to a workspace. Run `oxagen init --org <org> --workspace <workspace>` first.";
|
|
130647
|
-
BINDING_ID = /^rpb_[0-9A-Za-z]+$/;
|
|
130648
|
-
}
|
|
130649
|
-
});
|
|
130650
|
-
|
|
130651
130336
|
// ../../packages/mcp-studio/src/not-built.ts
|
|
130652
130337
|
var NotBuiltError;
|
|
130653
130338
|
var init_not_built = __esm({
|
|
@@ -133068,7 +132753,7 @@ var init_local_discovery_envelope = __esm({
|
|
|
133068
132753
|
function messageOf5(error2) {
|
|
133069
132754
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
133070
132755
|
}
|
|
133071
|
-
function
|
|
132756
|
+
function isRecord10(value) {
|
|
133072
132757
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
133073
132758
|
}
|
|
133074
132759
|
function isList(value) {
|
|
@@ -133082,7 +132767,7 @@ function jsonEqual(a, b3) {
|
|
|
133082
132767
|
if (Array.isArray(a)) {
|
|
133083
132768
|
return Array.isArray(b3) && a.length === b3.length && a.every((item, index) => jsonEqual(item, b3[index]));
|
|
133084
132769
|
}
|
|
133085
|
-
if (
|
|
132770
|
+
if (isRecord10(a) && isRecord10(b3)) {
|
|
133086
132771
|
const keys = definedKeys(a);
|
|
133087
132772
|
return keys.length === definedKeys(b3).length && keys.every((key) => Object.hasOwn(b3, key) && jsonEqual(a[key], b3[key]));
|
|
133088
132773
|
}
|
|
@@ -133094,7 +132779,7 @@ function utf8Length(text6) {
|
|
|
133094
132779
|
function valueAt2(value, path2) {
|
|
133095
132780
|
let current = value;
|
|
133096
132781
|
for (const step of path2.split(".")) {
|
|
133097
|
-
if (step.endsWith("[]") || !
|
|
132782
|
+
if (step.endsWith("[]") || !isRecord10(current) || !Object.hasOwn(current, step))
|
|
133098
132783
|
return void 0;
|
|
133099
132784
|
current = current[step];
|
|
133100
132785
|
}
|
|
@@ -133102,9 +132787,9 @@ function valueAt2(value, path2) {
|
|
|
133102
132787
|
}
|
|
133103
132788
|
function withValueAt(value, path2, replacement) {
|
|
133104
132789
|
const [step, ...rest] = path2.split(".");
|
|
133105
|
-
if (step === void 0 || !
|
|
132790
|
+
if (step === void 0 || !isRecord10(value)) return value;
|
|
133106
132791
|
const inner = Object.hasOwn(value, step) ? value[step] : void 0;
|
|
133107
|
-
if (rest.length > 0 && !
|
|
132792
|
+
if (rest.length > 0 && !isRecord10(inner)) return value;
|
|
133108
132793
|
const next = rest.length === 0 ? replacement : withValueAt(inner, rest.join("."), replacement);
|
|
133109
132794
|
return { ...value, [step]: next };
|
|
133110
132795
|
}
|
|
@@ -142136,13 +141821,13 @@ var require_path = __commonJS({
|
|
|
142136
141821
|
"../../node_modules/.pnpm/@protobufjs+path@1.1.2/node_modules/@protobufjs/path/index.js"(exports) {
|
|
142137
141822
|
"use strict";
|
|
142138
141823
|
var path2 = exports;
|
|
142139
|
-
var
|
|
141824
|
+
var isAbsolute20 = (
|
|
142140
141825
|
/**
|
|
142141
141826
|
* Tests if the specified path is absolute.
|
|
142142
141827
|
* @param {string} path Path to test
|
|
142143
141828
|
* @returns {boolean} `true` if path is absolute
|
|
142144
141829
|
*/
|
|
142145
|
-
path2.isAbsolute = function
|
|
141830
|
+
path2.isAbsolute = function isAbsolute21(path3) {
|
|
142146
141831
|
return /^(?:\/|\w+:)/.test(path3);
|
|
142147
141832
|
}
|
|
142148
141833
|
);
|
|
@@ -142154,7 +141839,7 @@ var require_path = __commonJS({
|
|
|
142154
141839
|
*/
|
|
142155
141840
|
path2.normalize = function normalize5(path3) {
|
|
142156
141841
|
path3 = path3.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
142157
|
-
var parts = path3.split("/"), absolute =
|
|
141842
|
+
var parts = path3.split("/"), absolute = isAbsolute20(path3), prefix = "";
|
|
142158
141843
|
if (absolute)
|
|
142159
141844
|
prefix = parts.shift() + "/";
|
|
142160
141845
|
for (var i2 = 0; i2 < parts.length; ) {
|
|
@@ -142176,7 +141861,7 @@ var require_path = __commonJS({
|
|
|
142176
141861
|
path2.resolve = function resolve29(originPath, includePath, alreadyNormalized) {
|
|
142177
141862
|
if (!alreadyNormalized)
|
|
142178
141863
|
includePath = normalize4(includePath);
|
|
142179
|
-
if (
|
|
141864
|
+
if (isAbsolute20(includePath))
|
|
142180
141865
|
return includePath;
|
|
142181
141866
|
if (!alreadyNormalized)
|
|
142182
141867
|
originPath = normalize4(originPath);
|
|
@@ -146504,8 +146189,8 @@ function doubleText(value) {
|
|
|
146504
146189
|
if (value === Infinity) return "inf";
|
|
146505
146190
|
if (value === -Infinity) return "-inf";
|
|
146506
146191
|
if (Object.is(value, -0)) return "-0";
|
|
146507
|
-
const
|
|
146508
|
-
return Number(
|
|
146192
|
+
const short4 = formatG(value, 15);
|
|
146193
|
+
return Number(short4) === value ? short4 : formatG(value, 17);
|
|
146509
146194
|
}
|
|
146510
146195
|
function floatText(value) {
|
|
146511
146196
|
const float = toFloat32(value);
|
|
@@ -146513,8 +146198,8 @@ function floatText(value) {
|
|
|
146513
146198
|
if (float === Infinity) return "inf";
|
|
146514
146199
|
if (float === -Infinity) return "-inf";
|
|
146515
146200
|
if (Object.is(float, -0)) return "-0";
|
|
146516
|
-
const
|
|
146517
|
-
return Math.fround(Number(
|
|
146201
|
+
const short4 = formatG(float, 6);
|
|
146202
|
+
return Math.fround(Number(short4)) === float ? short4 : formatG(float, 9);
|
|
146518
146203
|
}
|
|
146519
146204
|
function toFloat32(value) {
|
|
146520
146205
|
if (value > FLOAT_MAX) {
|
|
@@ -148979,7 +148664,7 @@ var init_lock2 = __esm({
|
|
|
148979
148664
|
|
|
148980
148665
|
// ../../packages/mcp-studio/src/compile/json-schema.ts
|
|
148981
148666
|
function propertiesOf(schema) {
|
|
148982
|
-
return
|
|
148667
|
+
return isRecord10(schema.properties) ? schema.properties : {};
|
|
148983
148668
|
}
|
|
148984
148669
|
function requiredOf(schema) {
|
|
148985
148670
|
if (!Array.isArray(schema.required)) return [];
|
|
@@ -149140,7 +148825,7 @@ function shapeInput(key, entry2, upstream, supplied, issues) {
|
|
|
149140
148825
|
for (const [name2, value] of defaults) {
|
|
149141
148826
|
if (!usable("defaults", name2)) continue;
|
|
149142
148827
|
const property = shaped[name2];
|
|
149143
|
-
shaped[name2] = { ...
|
|
148828
|
+
shaped[name2] = { ...isRecord10(property) ? property : {}, default: value };
|
|
149144
148829
|
required2 = required2.filter((other) => other !== name2);
|
|
149145
148830
|
}
|
|
149146
148831
|
const renamed = /* @__PURE__ */ new Map();
|
|
@@ -149193,7 +148878,7 @@ function selectTree(paths) {
|
|
|
149193
148878
|
return root;
|
|
149194
148879
|
}
|
|
149195
148880
|
function trimObject(schema, children) {
|
|
149196
|
-
if (!
|
|
148881
|
+
if (!isRecord10(schema.properties)) return schema;
|
|
149197
148882
|
const properties = schema.properties;
|
|
149198
148883
|
const kept = {};
|
|
149199
148884
|
for (const [name2, node2] of children) {
|
|
@@ -149208,9 +148893,9 @@ function trimObject(schema, children) {
|
|
|
149208
148893
|
return out;
|
|
149209
148894
|
}
|
|
149210
148895
|
function trimNode(schema, node2) {
|
|
149211
|
-
if (node2.whole || !
|
|
148896
|
+
if (node2.whole || !isRecord10(schema)) return schema;
|
|
149212
148897
|
if (!node2.array) return trimObject(schema, node2.children);
|
|
149213
|
-
return
|
|
148898
|
+
return isRecord10(schema.items) ? { ...schema, items: trimObject(schema.items, node2.children) } : schema;
|
|
149214
148899
|
}
|
|
149215
148900
|
function selectOutput(outputSchema, select) {
|
|
149216
148901
|
if (select.length === 0) return outputSchema;
|
|
@@ -150024,12 +149709,12 @@ function walkSchemas(root, at2, visit2) {
|
|
|
150024
149709
|
node2.forEach((item, index) => walk2(item, `${path2}[${index}]`, depth + 1));
|
|
150025
149710
|
return;
|
|
150026
149711
|
}
|
|
150027
|
-
if (!
|
|
149712
|
+
if (!isRecord10(node2) || above.has(node2)) return;
|
|
150028
149713
|
visit2(node2, path2);
|
|
150029
149714
|
above.add(node2);
|
|
150030
149715
|
for (const [key, value] of Object.entries(node2)) {
|
|
150031
149716
|
if (DATA.has(key)) continue;
|
|
150032
|
-
if (SCHEMA_MAPS.has(key) &&
|
|
149717
|
+
if (SCHEMA_MAPS.has(key) && isRecord10(value)) {
|
|
150033
149718
|
for (const [name2, child] of Object.entries(value))
|
|
150034
149719
|
walk2(child, `${path2}.${key}.${name2}`, depth + 1);
|
|
150035
149720
|
} else {
|
|
@@ -150041,7 +149726,7 @@ function walkSchemas(root, at2, visit2) {
|
|
|
150041
149726
|
walk2(root, at2, 0);
|
|
150042
149727
|
}
|
|
150043
149728
|
function tagOf(schema) {
|
|
150044
|
-
if (!
|
|
149729
|
+
if (!isRecord10(schema)) return void 0;
|
|
150045
149730
|
if (Object.hasOwn(schema, "const")) return JSON.stringify(schema.const);
|
|
150046
149731
|
if (Array.isArray(schema.enum) && schema.enum.length === 1)
|
|
150047
149732
|
return JSON.stringify(schema.enum[0]);
|
|
@@ -150049,7 +149734,7 @@ function tagOf(schema) {
|
|
|
150049
149734
|
}
|
|
150050
149735
|
function distinguishable(branches) {
|
|
150051
149736
|
if (branches.length < 2) return true;
|
|
150052
|
-
const records = branches.filter(
|
|
149737
|
+
const records = branches.filter(isRecord10);
|
|
150053
149738
|
const [first] = records;
|
|
150054
149739
|
if (first === void 0 || records.length < branches.length) return false;
|
|
150055
149740
|
const types = records.map((branch) => branch.type);
|
|
@@ -150159,11 +149844,11 @@ function quoted2(values) {
|
|
|
150159
149844
|
return orList2(values.map((value) => JSON.stringify(value)));
|
|
150160
149845
|
}
|
|
150161
149846
|
function isArraySchema(schema) {
|
|
150162
|
-
if (!
|
|
149847
|
+
if (!isRecord10(schema)) return false;
|
|
150163
149848
|
return schema.type === "array" || Array.isArray(schema.type) && schema.type.includes("array");
|
|
150164
149849
|
}
|
|
150165
149850
|
function hasDescription(schema) {
|
|
150166
|
-
return
|
|
149851
|
+
return isRecord10(schema) && typeof schema.description === "string" && schema.description.trim() !== "";
|
|
150167
149852
|
}
|
|
150168
149853
|
function refTarget(root, ref) {
|
|
150169
149854
|
if (ref === "#") return root;
|
|
@@ -150176,7 +149861,7 @@ function refTarget(root, ref) {
|
|
|
150176
149861
|
} catch {
|
|
150177
149862
|
return void 0;
|
|
150178
149863
|
}
|
|
150179
|
-
if (!
|
|
149864
|
+
if (!isRecord10(node2) || !Object.hasOwn(node2, name2)) return void 0;
|
|
150180
149865
|
node2 = node2[name2];
|
|
150181
149866
|
}
|
|
150182
149867
|
return node2;
|
|
@@ -150185,7 +149870,7 @@ function isDescribed(schema, root) {
|
|
|
150185
149870
|
const seen = /* @__PURE__ */ new Set();
|
|
150186
149871
|
let node2 = schema;
|
|
150187
149872
|
while (!hasDescription(node2)) {
|
|
150188
|
-
const ref =
|
|
149873
|
+
const ref = isRecord10(node2) ? node2.$ref : void 0;
|
|
150189
149874
|
if (typeof ref !== "string") return false;
|
|
150190
149875
|
if (seen.has(ref)) return true;
|
|
150191
149876
|
seen.add(ref);
|
|
@@ -150451,7 +150136,7 @@ function lintUpstream(folder, context, key, entry2, upstream, apply, report) {
|
|
|
150451
150136
|
});
|
|
150452
150137
|
}
|
|
150453
150138
|
const oneOf4 = (node2, at2) => {
|
|
150454
|
-
if (!Array.isArray(node2.oneOf) ||
|
|
150139
|
+
if (!Array.isArray(node2.oneOf) || isRecord10(node2.discriminator) || distinguishable(node2.oneOf))
|
|
150455
150140
|
return;
|
|
150456
150141
|
report("undiscriminated_one_of", {
|
|
150457
150142
|
tool: key,
|
|
@@ -151298,7 +150983,7 @@ function upstreamError(response, bytes) {
|
|
|
151298
150983
|
let problem;
|
|
151299
150984
|
if (text6 !== "" && isJsonMediaType(headerValue(response.headers, "content-type"))) {
|
|
151300
150985
|
const parsed2 = parseJson4(text6);
|
|
151301
|
-
if (parsed2.ok &&
|
|
150986
|
+
if (parsed2.ok && isRecord10(parsed2.value)) problem = parsed2.value;
|
|
151302
150987
|
}
|
|
151303
150988
|
const title = problem === void 0 ? void 0 : firstText(problem, ["title"]);
|
|
151304
150989
|
const detail = problem === void 0 ? text6.trim() === "" ? void 0 : text6 : firstText(problem, ["detail", "message", "error_description", "error"]);
|
|
@@ -151433,13 +151118,13 @@ var init_http_call = __esm({
|
|
|
151433
151118
|
|
|
151434
151119
|
// ../../packages/mcp-studio/src/execute/mcp.ts
|
|
151435
151120
|
function toolResult(value) {
|
|
151436
|
-
if (!
|
|
151121
|
+
if (!isRecord10(value))
|
|
151437
151122
|
return { ok: false, detail: "The tools/call result is not an object." };
|
|
151438
151123
|
if (!isList(value.content))
|
|
151439
151124
|
return { ok: false, detail: "The tools/call result has no content list." };
|
|
151440
151125
|
const content = [];
|
|
151441
151126
|
for (const [index, item] of value.content.entries()) {
|
|
151442
|
-
if (!
|
|
151127
|
+
if (!isRecord10(item) || typeof item.type !== "string") {
|
|
151443
151128
|
return {
|
|
151444
151129
|
ok: false,
|
|
151445
151130
|
detail: `Content item ${index} is not an object with a string type.`
|
|
@@ -151450,7 +151135,7 @@ function toolResult(value) {
|
|
|
151450
151135
|
const result2 = { content };
|
|
151451
151136
|
const structured = value.structuredContent;
|
|
151452
151137
|
if (structured !== void 0 && structured !== null) {
|
|
151453
|
-
if (!
|
|
151138
|
+
if (!isRecord10(structured))
|
|
151454
151139
|
return {
|
|
151455
151140
|
ok: false,
|
|
151456
151141
|
detail: "The tools/call result's structuredContent is not an object."
|
|
@@ -151595,7 +151280,7 @@ function rejectedAttempt(response, failure4) {
|
|
|
151595
151280
|
function findResponse(value, id2) {
|
|
151596
151281
|
const messages = isList(value) ? value : [value];
|
|
151597
151282
|
for (const message2 of messages) {
|
|
151598
|
-
if (
|
|
151283
|
+
if (isRecord10(message2) && message2.id === id2 && !Object.hasOwn(message2, "method"))
|
|
151599
151284
|
return message2;
|
|
151600
151285
|
}
|
|
151601
151286
|
return void 0;
|
|
@@ -151668,8 +151353,8 @@ async function readReply(session, response, id2, what) {
|
|
|
151668
151353
|
return { ok: true, value: message2 };
|
|
151669
151354
|
}
|
|
151670
151355
|
function rpcError2(error2) {
|
|
151671
|
-
const message2 =
|
|
151672
|
-
const code =
|
|
151356
|
+
const message2 = isRecord10(error2) && typeof error2.message === "string" ? error2.message : JSON.stringify(error2);
|
|
151357
|
+
const code = isRecord10(error2) && typeof error2.code === "number" ? ` (code ${error2.code})` : "";
|
|
151673
151358
|
return {
|
|
151674
151359
|
title: "MCP error",
|
|
151675
151360
|
detail: cutDetail(`${message2}${code}`),
|
|
@@ -151708,7 +151393,7 @@ async function initialize(session) {
|
|
|
151708
151393
|
if (Object.hasOwn(reply3.value, "error"))
|
|
151709
151394
|
return { ok: false, error: rpcError2(reply3.value.error) };
|
|
151710
151395
|
const result2 = reply3.value.result;
|
|
151711
|
-
if (!
|
|
151396
|
+
if (!isRecord10(result2))
|
|
151712
151397
|
return invalidResponse(
|
|
151713
151398
|
"The MCP server's initialize result is not an object.",
|
|
151714
151399
|
response.status
|
|
@@ -151966,8 +151651,8 @@ function firstPosition(paging, args, options) {
|
|
|
151966
151651
|
if (paging.style === "offset") return 0;
|
|
151967
151652
|
const properties = options.inputSchema.properties;
|
|
151968
151653
|
const name2 = options.agentName(paging.input);
|
|
151969
|
-
const property =
|
|
151970
|
-
if (
|
|
151654
|
+
const property = isRecord10(properties) && Object.hasOwn(properties, name2) ? properties[name2] : void 0;
|
|
151655
|
+
if (isRecord10(property)) {
|
|
151971
151656
|
const fallback = wholeNumber(property.default) ?? wholeNumber(property.minimum);
|
|
151972
151657
|
if (fallback !== void 0) return fallback;
|
|
151973
151658
|
}
|
|
@@ -152150,7 +151835,7 @@ function graphqlDocument(template, args) {
|
|
|
152150
151835
|
}
|
|
152151
151836
|
function errorMessages(errors) {
|
|
152152
151837
|
return errors.map(
|
|
152153
|
-
(entry2) =>
|
|
151838
|
+
(entry2) => isRecord10(entry2) && typeof entry2.message === "string" ? entry2.message : JSON.stringify(entry2)
|
|
152154
151839
|
).join("; ");
|
|
152155
151840
|
}
|
|
152156
151841
|
function invalidResponse2(detail, status2) {
|
|
@@ -152162,7 +151847,7 @@ function interpret(template) {
|
|
|
152162
151847
|
const status2 = response.status;
|
|
152163
151848
|
const parsed2 = bytes.byteLength === 0 ? void 0 : parseJson4(decodeText2(bytes));
|
|
152164
151849
|
const body2 = parsed2?.ok === true ? parsed2.value : void 0;
|
|
152165
|
-
if (
|
|
151850
|
+
if (isRecord10(body2) && isList(body2.errors) && body2.errors.length > 0) {
|
|
152166
151851
|
return {
|
|
152167
151852
|
ok: false,
|
|
152168
151853
|
error: {
|
|
@@ -152184,8 +151869,8 @@ function interpret(template) {
|
|
|
152184
151869
|
`The upstream answered ${status2} with JSON that does not parse: ${parsed2.message}`,
|
|
152185
151870
|
status2
|
|
152186
151871
|
);
|
|
152187
|
-
const data =
|
|
152188
|
-
if (!
|
|
151872
|
+
const data = isRecord10(body2) ? body2.data : void 0;
|
|
151873
|
+
if (!isRecord10(data))
|
|
152189
151874
|
return invalidResponse2(
|
|
152190
151875
|
`The upstream answered ${status2} with no data object.`,
|
|
152191
151876
|
status2
|
|
@@ -152858,7 +152543,7 @@ function exchangesFor(call2, ending) {
|
|
|
152858
152543
|
];
|
|
152859
152544
|
}
|
|
152860
152545
|
function isJsonObject(value) {
|
|
152861
|
-
return
|
|
152546
|
+
return isRecord10(value);
|
|
152862
152547
|
}
|
|
152863
152548
|
var DEFAULT_MAX_STREAM_BYTES, RETRIED_LEVELS, CANCELLED2, grpcSender, TRANSPORT_TITLES2;
|
|
152864
152549
|
var init_sender = __esm({
|
|
@@ -152922,7 +152607,7 @@ function scalarText(value, name2) {
|
|
|
152922
152607
|
function shapeOf(value, name2) {
|
|
152923
152608
|
if (isList(value))
|
|
152924
152609
|
return { kind: "list", items: value.map((item) => scalarText(item, name2)) };
|
|
152925
|
-
if (
|
|
152610
|
+
if (isRecord10(value)) {
|
|
152926
152611
|
return {
|
|
152927
152612
|
kind: "object",
|
|
152928
152613
|
entries: Object.entries(value).filter(([, item]) => item !== void 0).map(([key, item]) => [key, scalarText(item, name2)])
|
|
@@ -153115,7 +152800,7 @@ function formText(value) {
|
|
|
153115
152800
|
throw invalidArguments(`A form body cannot carry a ${typeof value} value.`);
|
|
153116
152801
|
}
|
|
153117
152802
|
function formBody(value) {
|
|
153118
|
-
if (!
|
|
152803
|
+
if (!isRecord10(value)) throw invalidArguments("A form body takes an object.");
|
|
153119
152804
|
const form = new URLSearchParams();
|
|
153120
152805
|
for (const [key, item] of Object.entries(value)) {
|
|
153121
152806
|
const items = (isList(item) ? item : [item]).filter(
|
|
@@ -153383,7 +153068,7 @@ function project(value, at2) {
|
|
|
153383
153068
|
const each = at2.each;
|
|
153384
153069
|
return value.map((item) => project(item, each)).filter((item) => item !== ABSENT);
|
|
153385
153070
|
}
|
|
153386
|
-
if (
|
|
153071
|
+
if (isRecord10(value) && at2.fields.size > 0) {
|
|
153387
153072
|
const kept = [];
|
|
153388
153073
|
for (const [name2, child] of at2.fields) {
|
|
153389
153074
|
if (!Object.hasOwn(value, name2)) continue;
|
|
@@ -153400,7 +153085,7 @@ function remove(value, at2) {
|
|
|
153400
153085
|
const each = at2.each;
|
|
153401
153086
|
return value.map((item) => remove(item, each)).filter((item) => item !== ABSENT);
|
|
153402
153087
|
}
|
|
153403
|
-
if (
|
|
153088
|
+
if (isRecord10(value) && at2.fields.size > 0) {
|
|
153404
153089
|
const kept = [];
|
|
153405
153090
|
for (const [name2, item] of Object.entries(value)) {
|
|
153406
153091
|
const child = at2.fields.get(name2);
|
|
@@ -153436,14 +153121,14 @@ function shapeRecord(value, rules, isError) {
|
|
|
153436
153121
|
let out = value;
|
|
153437
153122
|
if (rules.select !== void 0 && !isError) out = project(out, rules.select);
|
|
153438
153123
|
if (rules.redact !== void 0) out = remove(out, rules.redact);
|
|
153439
|
-
return
|
|
153124
|
+
return isRecord10(out) ? out : {};
|
|
153440
153125
|
}
|
|
153441
153126
|
function redactReachesList(redact) {
|
|
153442
153127
|
const items = redact.fields.get(LIST_FIELD);
|
|
153443
153128
|
return items !== void 0 && (items.end || items.each !== void 0);
|
|
153444
153129
|
}
|
|
153445
153130
|
function shapeAny(value, rules) {
|
|
153446
|
-
if (
|
|
153131
|
+
if (isRecord10(value)) return shapeRecord(value, rules, false);
|
|
153447
153132
|
if (!isList(value)) return value;
|
|
153448
153133
|
if (rules.redact !== void 0 && !redactReachesList(rules.redact))
|
|
153449
153134
|
return WITHHELD;
|
|
@@ -153476,12 +153161,12 @@ function resultBytes(content, structured) {
|
|
|
153476
153161
|
}
|
|
153477
153162
|
function jsonResult(value, text6) {
|
|
153478
153163
|
const result2 = { content: [textItem(text6)] };
|
|
153479
|
-
if (
|
|
153164
|
+
if (isRecord10(value)) result2.structuredContent = value;
|
|
153480
153165
|
return result2;
|
|
153481
153166
|
}
|
|
153482
153167
|
function jsonResultBytes(value, text6) {
|
|
153483
153168
|
const bytes = utf8Length(text6);
|
|
153484
|
-
return
|
|
153169
|
+
return isRecord10(value) ? 2 * bytes : bytes;
|
|
153485
153170
|
}
|
|
153486
153171
|
function cutList(value, rules) {
|
|
153487
153172
|
const list2 = valueAt2(value, rules.list);
|
|
@@ -153546,7 +153231,7 @@ function shapeText(text6, rules, isError, structured) {
|
|
|
153546
153231
|
if (typeof text6 !== "string") return void 0;
|
|
153547
153232
|
const parsed2 = parseJson4(text6);
|
|
153548
153233
|
if (!parsed2.ok) return void 0;
|
|
153549
|
-
if (
|
|
153234
|
+
if (isRecord10(parsed2.value))
|
|
153550
153235
|
return JSON.stringify(shapeRecord(parsed2.value, rules, isError));
|
|
153551
153236
|
if (!isList(parsed2.value) || rules.redact === void 0) return void 0;
|
|
153552
153237
|
if (redactReachesList(rules.redact)) {
|
|
@@ -153560,7 +153245,7 @@ function shapeItem(item, rules, isError, structured) {
|
|
|
153560
153245
|
const text6 = shapeText(item.text, rules, isError, structured);
|
|
153561
153246
|
return text6 === void 0 ? item : { ...item, text: text6 };
|
|
153562
153247
|
}
|
|
153563
|
-
if (item.type === "resource" &&
|
|
153248
|
+
if (item.type === "resource" && isRecord10(item.resource)) {
|
|
153564
153249
|
const text6 = shapeText(item.resource.text, rules, isError, structured);
|
|
153565
153250
|
return text6 === void 0 ? item : { ...item, resource: { ...item.resource, text: text6 } };
|
|
153566
153251
|
}
|
|
@@ -153648,7 +153333,7 @@ function hasType(type, value) {
|
|
|
153648
153333
|
case "boolean":
|
|
153649
153334
|
return typeof value === "boolean";
|
|
153650
153335
|
case "object":
|
|
153651
|
-
return
|
|
153336
|
+
return isRecord10(value);
|
|
153652
153337
|
case "array":
|
|
153653
153338
|
return isList(value);
|
|
153654
153339
|
default:
|
|
@@ -153712,7 +153397,7 @@ function resolveRef(root, ref) {
|
|
|
153712
153397
|
if (!Number.isInteger(index) || index < 0 || index >= current.length)
|
|
153713
153398
|
return void 0;
|
|
153714
153399
|
current = current[index];
|
|
153715
|
-
} else if (
|
|
153400
|
+
} else if (isRecord10(current) && Object.hasOwn(current, token)) {
|
|
153716
153401
|
current = current[token];
|
|
153717
153402
|
} else {
|
|
153718
153403
|
return void 0;
|
|
@@ -153722,7 +153407,7 @@ function resolveRef(root, ref) {
|
|
|
153722
153407
|
}
|
|
153723
153408
|
function canonical2(value) {
|
|
153724
153409
|
if (isList(value)) return `[${value.map(canonical2).join(",")}]`;
|
|
153725
|
-
if (
|
|
153410
|
+
if (isRecord10(value)) {
|
|
153726
153411
|
const keys = Object.keys(value).sort();
|
|
153727
153412
|
return `{${keys.map((key) => `${JSON.stringify(key)}:${canonical2(value[key])}`).join(",")}}`;
|
|
153728
153413
|
}
|
|
@@ -153775,7 +153460,7 @@ var init_validate = __esm({
|
|
|
153775
153460
|
return [];
|
|
153776
153461
|
}
|
|
153777
153462
|
if (schema === false) return [`${path2} is not allowed.`];
|
|
153778
|
-
if (!
|
|
153463
|
+
if (!isRecord10(schema)) return [];
|
|
153779
153464
|
if (value === null && schema.nullable === true) return [];
|
|
153780
153465
|
const issues = [];
|
|
153781
153466
|
if (typeof schema.$ref === "string") {
|
|
@@ -153797,7 +153482,7 @@ var init_validate = __esm({
|
|
|
153797
153482
|
issues.push(...checkNumber2(schema, value, path2));
|
|
153798
153483
|
else if (isList(value))
|
|
153799
153484
|
issues.push(...this.checkArray(schema, value, path2, depth));
|
|
153800
|
-
else if (
|
|
153485
|
+
else if (isRecord10(value))
|
|
153801
153486
|
issues.push(...this.checkObject(schema, value, path2, depth));
|
|
153802
153487
|
issues.push(...this.checkCombinators(schema, value, path2, depth));
|
|
153803
153488
|
return issues;
|
|
@@ -153909,8 +153594,8 @@ var init_validate = __esm({
|
|
|
153909
153594
|
`${path2} must have at most ${schema.maxProperties} ${plural8(schema.maxProperties, "property", "properties")}.`
|
|
153910
153595
|
);
|
|
153911
153596
|
}
|
|
153912
|
-
const properties =
|
|
153913
|
-
const patterns =
|
|
153597
|
+
const properties = isRecord10(schema.properties) ? schema.properties : {};
|
|
153598
|
+
const patterns = isRecord10(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];
|
|
153914
153599
|
for (const key of present) {
|
|
153915
153600
|
const at2 = propertyPath(path2, key);
|
|
153916
153601
|
let known = false;
|
|
@@ -172193,7 +171878,7 @@ function differenceAt(path2, expected, actual) {
|
|
|
172193
171878
|
actual: actual[shared]
|
|
172194
171879
|
};
|
|
172195
171880
|
}
|
|
172196
|
-
if (
|
|
171881
|
+
if (isRecord10(expected) && isRecord10(actual)) {
|
|
172197
171882
|
for (const key of Object.keys(expected)) {
|
|
172198
171883
|
const found = differenceAt(
|
|
172199
171884
|
keyPath(path2, key),
|
|
@@ -172288,7 +171973,7 @@ function rpcMessage(request3) {
|
|
|
172288
171973
|
const parsed2 = parseJson4(decodeText2(request3.body));
|
|
172289
171974
|
if (!parsed2.ok) return void 0;
|
|
172290
171975
|
const value = isList(parsed2.value) ? parsed2.value[0] : parsed2.value;
|
|
172291
|
-
return
|
|
171976
|
+
return isRecord10(value) ? value : void 0;
|
|
172292
171977
|
}
|
|
172293
171978
|
function replayTransport(exchanges, route) {
|
|
172294
171979
|
let next = 0;
|
|
@@ -174543,10 +174228,12 @@ var init_src8 = __esm({
|
|
|
174543
174228
|
});
|
|
174544
174229
|
|
|
174545
174230
|
// ../../packages/steering-bundle/src/tree.ts
|
|
174546
|
-
import { createHash as
|
|
174231
|
+
import { createHash as createHash30 } from "node:crypto";
|
|
174547
174232
|
function gitBlobId(text6) {
|
|
174548
|
-
|
|
174549
|
-
|
|
174233
|
+
return gitBlobIdOfBytes(Buffer.from(text6, "utf8"));
|
|
174234
|
+
}
|
|
174235
|
+
function gitBlobIdOfBytes(bytes) {
|
|
174236
|
+
return createHash30("sha1").update(`blob ${bytes.length}\0`).update(bytes).digest("hex");
|
|
174550
174237
|
}
|
|
174551
174238
|
function treeFromFiles(files2) {
|
|
174552
174239
|
return {
|
|
@@ -174606,6 +174293,10 @@ var init_tree = __esm({
|
|
|
174606
174293
|
texts = /* @__PURE__ */ new Map();
|
|
174607
174294
|
/** Reads in flight, so two callers of one path share one fetch. */
|
|
174608
174295
|
pending = /* @__PURE__ */ new Map();
|
|
174296
|
+
/** Texts decoded from the tree's bytes, by blob id, or by path for a file listed without one. */
|
|
174297
|
+
decoded = /* @__PURE__ */ new Map();
|
|
174298
|
+
/** Byte reads in flight, keyed as `decoded` is. */
|
|
174299
|
+
decoding = /* @__PURE__ */ new Map();
|
|
174609
174300
|
blobs = /* @__PURE__ */ new Map();
|
|
174610
174301
|
listed;
|
|
174611
174302
|
/** How many files this reader fetched from the host. */
|
|
@@ -174632,6 +174323,35 @@ var init_tree = __esm({
|
|
|
174632
174323
|
const text6 = await this.read(path2);
|
|
174633
174324
|
return this.blobs.get(path2) ?? gitBlobId(text6);
|
|
174634
174325
|
}
|
|
174326
|
+
/**
|
|
174327
|
+
* The file's text as `read_steering` serves it, for any file, an image
|
|
174328
|
+
* included. With the tree's bytes, they are decoded as UTF-8: a byte that
|
|
174329
|
+
* is not UTF-8 becomes U+FFFD, and a NUL byte stays as U+0000. Without
|
|
174330
|
+
* them, the text `read` returns. Paths that share a listed blob share one
|
|
174331
|
+
* fetch, and a fetch that fails is not kept.
|
|
174332
|
+
*/
|
|
174333
|
+
async text(path2) {
|
|
174334
|
+
if (this.tree.readBytes === void 0) return this.read(path2);
|
|
174335
|
+
const listed = this.blobs.get(path2);
|
|
174336
|
+
const key = listed === void 0 ? `path:${path2}` : `blob:${listed}`;
|
|
174337
|
+
const held = this.decoded.get(key);
|
|
174338
|
+
if (held !== void 0) return held;
|
|
174339
|
+
const inFlight = this.decoding.get(key);
|
|
174340
|
+
if (inFlight !== void 0) return inFlight;
|
|
174341
|
+
const reading = this.decode(path2, key).finally(
|
|
174342
|
+
() => this.decoding.delete(key)
|
|
174343
|
+
);
|
|
174344
|
+
this.decoding.set(key, reading);
|
|
174345
|
+
return reading;
|
|
174346
|
+
}
|
|
174347
|
+
async decode(path2, key) {
|
|
174348
|
+
if (this.tree.readBytes === void 0) return this.read(path2);
|
|
174349
|
+
const bytes = await this.tree.readBytes(path2);
|
|
174350
|
+
this.reads += 1;
|
|
174351
|
+
const text6 = new TextDecoder("utf-8").decode(bytes);
|
|
174352
|
+
this.decoded.set(key, text6);
|
|
174353
|
+
return text6;
|
|
174354
|
+
}
|
|
174635
174355
|
/** The file's text, from this reader, the cache, or the host. */
|
|
174636
174356
|
async read(path2) {
|
|
174637
174357
|
const held = this.texts.get(path2);
|
|
@@ -175032,15 +174752,15 @@ __export(check_exports, {
|
|
|
175032
174752
|
readHead: () => readHead2
|
|
175033
174753
|
});
|
|
175034
174754
|
import { execFileSync } from "node:child_process";
|
|
175035
|
-
import { createHash as
|
|
174755
|
+
import { createHash as createHash31 } from "node:crypto";
|
|
175036
174756
|
import {
|
|
175037
|
-
lstatSync as
|
|
175038
|
-
mkdirSync as
|
|
175039
|
-
readFileSync as
|
|
174757
|
+
lstatSync as lstatSync14,
|
|
174758
|
+
mkdirSync as mkdirSync15,
|
|
174759
|
+
readFileSync as readFileSync32,
|
|
175040
174760
|
readlinkSync as readlinkSync4,
|
|
175041
174761
|
statSync as statSync21
|
|
175042
174762
|
} from "node:fs";
|
|
175043
|
-
import { dirname as
|
|
174763
|
+
import { dirname as dirname37, isAbsolute as isAbsolute19, join as join69, relative as relative10, resolve as resolve28, sep as sep13 } from "node:path";
|
|
175044
174764
|
function cloneRepoKind(root) {
|
|
175045
174765
|
const out = git4(root, ["remote", "get-url", "origin"]);
|
|
175046
174766
|
const url2 = out?.toString("utf8").trim() ?? "";
|
|
@@ -175080,11 +174800,11 @@ function commitOf(root, ref) {
|
|
|
175080
174800
|
return sha2.length > 0 ? sha2 : null;
|
|
175081
174801
|
}
|
|
175082
174802
|
function readWorkingFile(root, path2) {
|
|
175083
|
-
const abs =
|
|
174803
|
+
const abs = join69(root, ...path2.split("/"));
|
|
175084
174804
|
try {
|
|
175085
|
-
const stat7 =
|
|
174805
|
+
const stat7 = lstatSync14(abs);
|
|
175086
174806
|
if (stat7.isSymbolicLink()) return readlinkSync4(abs, "utf8");
|
|
175087
|
-
return stat7.isFile() ?
|
|
174807
|
+
return stat7.isFile() ? readFileSync32(abs, "utf8") : null;
|
|
175088
174808
|
} catch {
|
|
175089
174809
|
return null;
|
|
175090
174810
|
}
|
|
@@ -175174,10 +174894,10 @@ function isDir(path2) {
|
|
|
175174
174894
|
function findSteeringRoot(start) {
|
|
175175
174895
|
let dir = resolve28(start);
|
|
175176
174896
|
for (; ; ) {
|
|
175177
|
-
if (isFile(
|
|
174897
|
+
if (isFile(join69(dir, WORKSPACE_TOML_PATH)) || isFile(join69(dir, AGENTS_MD_PATH)) && isDir(join69(dir, STEERING_DIR))) {
|
|
175178
174898
|
return dir;
|
|
175179
174899
|
}
|
|
175180
|
-
const parent =
|
|
174900
|
+
const parent = dirname37(dir);
|
|
175181
174901
|
if (parent === dir) return null;
|
|
175182
174902
|
dir = parent;
|
|
175183
174903
|
}
|
|
@@ -175188,11 +174908,11 @@ function within3(path2, scope) {
|
|
|
175188
174908
|
function scopesFor(root, cwd, paths, trees) {
|
|
175189
174909
|
const scopes = [];
|
|
175190
174910
|
for (const path2 of paths) {
|
|
175191
|
-
const rel =
|
|
175192
|
-
if (rel === ".." || rel.startsWith(`..${
|
|
174911
|
+
const rel = relative10(root, resolve28(cwd, path2));
|
|
174912
|
+
if (rel === ".." || rel.startsWith(`..${sep13}`) || isAbsolute19(rel)) {
|
|
175193
174913
|
return { error: `${path2} is outside the steering repo at ${root}.` };
|
|
175194
174914
|
}
|
|
175195
|
-
const scope = rel.split(
|
|
174915
|
+
const scope = rel.split(sep13).join("/");
|
|
175196
174916
|
const known = trees.some(
|
|
175197
174917
|
(tree) => tree !== null && [...tree.keys()].some((file) => within3(file, scope))
|
|
175198
174918
|
);
|
|
@@ -175251,15 +174971,15 @@ function cacheFile(cacheDir, root) {
|
|
|
175251
174971
|
const identity = {
|
|
175252
174972
|
api: getApiUrl(),
|
|
175253
174973
|
...targetOf(root),
|
|
175254
|
-
key: token === void 0 ? null :
|
|
174974
|
+
key: token === void 0 ? null : createHash31("sha256").update(token).digest("hex").slice(0, 16)
|
|
175255
174975
|
};
|
|
175256
|
-
const key =
|
|
175257
|
-
return
|
|
174976
|
+
const key = createHash31("sha256").update(JSON.stringify([root, identity])).digest("hex").slice(0, 32);
|
|
174977
|
+
return join69(cacheDir, `${key}.json`);
|
|
175258
174978
|
}
|
|
175259
174979
|
function readCache(file, now) {
|
|
175260
174980
|
let entry2;
|
|
175261
174981
|
try {
|
|
175262
|
-
entry2 = JSON.parse(
|
|
174982
|
+
entry2 = JSON.parse(readFileSync32(file, "utf8"));
|
|
175263
174983
|
} catch {
|
|
175264
174984
|
return null;
|
|
175265
174985
|
}
|
|
@@ -175282,7 +175002,7 @@ async function publishedInputs(root, deps, refresh, out) {
|
|
|
175282
175002
|
}
|
|
175283
175003
|
if (file !== null) {
|
|
175284
175004
|
try {
|
|
175285
|
-
|
|
175005
|
+
mkdirSync15(dirname37(file), { recursive: true });
|
|
175286
175006
|
atomicWriteFileSync(
|
|
175287
175007
|
file,
|
|
175288
175008
|
JSON.stringify({
|
|
@@ -175368,7 +175088,7 @@ function defaultDeps2() {
|
|
|
175368
175088
|
return {
|
|
175369
175089
|
fetchPublished: fetchSteeringIndex,
|
|
175370
175090
|
cedar: cedarHooks,
|
|
175371
|
-
cacheDir:
|
|
175091
|
+
cacheDir: join69(getConfigDir(), "cache", "steering-check"),
|
|
175372
175092
|
now: () => Date.now()
|
|
175373
175093
|
};
|
|
175374
175094
|
}
|
|
@@ -175943,12 +175663,12 @@ var init_telemetry = __esm({
|
|
|
175943
175663
|
});
|
|
175944
175664
|
|
|
175945
175665
|
// src/auth/pkce.ts
|
|
175946
|
-
import { createHash as
|
|
175666
|
+
import { createHash as createHash32, randomBytes as randomBytes15 } from "node:crypto";
|
|
175947
175667
|
function generateCodeVerifier() {
|
|
175948
175668
|
return randomBytes15(32).toString("base64url");
|
|
175949
175669
|
}
|
|
175950
175670
|
function codeChallengeS256(codeVerifier) {
|
|
175951
|
-
return
|
|
175671
|
+
return createHash32("sha256").update(codeVerifier, "ascii").digest("base64url");
|
|
175952
175672
|
}
|
|
175953
175673
|
function generateState() {
|
|
175954
175674
|
return randomBytes15(16).toString("base64url");
|
|
@@ -176565,10 +176285,6 @@ async function handleLogout() {
|
|
|
176565
176285
|
`
|
|
176566
176286
|
);
|
|
176567
176287
|
}
|
|
176568
|
-
process.stdout.write(
|
|
176569
|
-
`Note: per-project links (.oxagen/workspace.json) are left intact.
|
|
176570
|
-
`
|
|
176571
|
-
);
|
|
176572
176288
|
}
|
|
176573
176289
|
var WHOAMI_TIMEOUT_MS, LOGOUT_TIMEOUT_MS;
|
|
176574
176290
|
var init_auth4 = __esm({
|
|
@@ -176830,7 +176546,7 @@ async function routerPreview(prompt, opts = {}, writer = stdoutWriter) {
|
|
|
176830
176546
|
writer.write(
|
|
176831
176547
|
`Task class: ${result2.taskClass} \xB7 decision: ${result2.source}`
|
|
176832
176548
|
);
|
|
176833
|
-
writer.write(`\u2192 ${
|
|
176549
|
+
writer.write(`\u2192 ${short3(result2.model)} (${result2.tier})`);
|
|
176834
176550
|
writer.write(` ${result2.rationale}`);
|
|
176835
176551
|
writer.write("");
|
|
176836
176552
|
if (result2.candidates.length === 0) {
|
|
@@ -176842,7 +176558,7 @@ async function routerPreview(prompt, opts = {}, writer = stdoutWriter) {
|
|
|
176842
176558
|
printTable(
|
|
176843
176559
|
["MODEL", "VERIFIED", "N", "AVG COST", "ELIGIBLE", "WHY"],
|
|
176844
176560
|
result2.candidates.map((c) => [
|
|
176845
|
-
|
|
176561
|
+
short3(c.model),
|
|
176846
176562
|
pct2(c.verifiedRate),
|
|
176847
176563
|
String(c.samples),
|
|
176848
176564
|
usd(c.avgCostUsdMicros),
|
|
@@ -176930,7 +176646,7 @@ async function routerPolicySet(opts = {}, writer = stdoutWriter) {
|
|
|
176930
176646
|
renderPolicy(result2, writer);
|
|
176931
176647
|
renderKindRules(result2.kindRules, { withSource: false }, writer);
|
|
176932
176648
|
}
|
|
176933
|
-
var pct2, usd,
|
|
176649
|
+
var pct2, usd, short3;
|
|
176934
176650
|
var init_router = __esm({
|
|
176935
176651
|
"src/commands/router.ts"() {
|
|
176936
176652
|
init_api();
|
|
@@ -176939,7 +176655,7 @@ var init_router = __esm({
|
|
|
176939
176655
|
init_capture_writer();
|
|
176940
176656
|
pct2 = (r) => `${(r * 100).toFixed(1)}%`;
|
|
176941
176657
|
usd = (micros2) => formatUsd(micros2 / 1e6);
|
|
176942
|
-
|
|
176658
|
+
short3 = (model) => model.split("/").pop() ?? model;
|
|
176943
176659
|
}
|
|
176944
176660
|
});
|
|
176945
176661
|
|
|
@@ -177004,7 +176720,7 @@ __export(secret_exports, {
|
|
|
177004
176720
|
handleSecretReveal: () => handleSecretReveal,
|
|
177005
176721
|
handleSecretSet: () => handleSecretSet
|
|
177006
176722
|
});
|
|
177007
|
-
import { readFileSync as
|
|
176723
|
+
import { readFileSync as readFileSync33, writeFileSync as writeFileSync12 } from "fs";
|
|
177008
176724
|
async function readStdin2() {
|
|
177009
176725
|
const chunks = [];
|
|
177010
176726
|
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
@@ -177117,7 +176833,7 @@ async function handleSecretReveal(key, opts, writer = stdoutWriter) {
|
|
|
177117
176833
|
async function handleSecretImport(opts, writer = stdoutWriter) {
|
|
177118
176834
|
const out = createOutput({}, writer);
|
|
177119
176835
|
try {
|
|
177120
|
-
const text6 = opts.file ?
|
|
176836
|
+
const text6 = opts.file ? readFileSync33(opts.file, "utf8") : await readStdin2();
|
|
177121
176837
|
const environmentId = opts.env ? await resolveEnvironmentId(opts.env) : null;
|
|
177122
176838
|
const { rows, committed } = await apiPostOrThrow("secret/import-env", { text: text6, environmentId, commit: !!opts.yes });
|
|
177123
176839
|
const newCount = rows.filter((r) => r.isNewKey).length;
|
|
@@ -177494,6 +177210,12 @@ function withTemplateFlags(command2) {
|
|
|
177494
177210
|
"--service <name>",
|
|
177495
177211
|
"A service the template starts before the harness, such as postgres. Repeat for each one",
|
|
177496
177212
|
collectLines
|
|
177213
|
+
).option(
|
|
177214
|
+
"--setup-command <command>",
|
|
177215
|
+
"A command the image build runs once as root, such as 'apt-get install -y libpq-dev'"
|
|
177216
|
+
).option(
|
|
177217
|
+
"--setup-dir <folder>",
|
|
177218
|
+
"The folder the setup command runs in, such as /opt/setup (default: /)"
|
|
177497
177219
|
);
|
|
177498
177220
|
}
|
|
177499
177221
|
function addSandboxRunsAndRuntimes(sandbox) {
|
|
@@ -178034,10 +177756,10 @@ function buildProgram() {
|
|
|
178034
177756
|
await repoUnlink2(bindingId, opts);
|
|
178035
177757
|
});
|
|
178036
177758
|
repoCmd.command("tree").description(
|
|
178037
|
-
"What
|
|
178038
|
-
).
|
|
177759
|
+
"What the workspace's steering repository holds on its production branch, read from GitHub now"
|
|
177760
|
+
).option("--json", "Output JSON").action(async (opts) => {
|
|
178039
177761
|
const { repoTree: repoTree2 } = await Promise.resolve().then(() => (init_repo(), repo_exports));
|
|
178040
|
-
await repoTree2(
|
|
177762
|
+
await repoTree2(opts);
|
|
178041
177763
|
});
|
|
178042
177764
|
repoCmd.command("branch").description(
|
|
178043
177765
|
"Confirm or change a repository's production branch; the branch must exist on GitHub"
|
|
@@ -178047,20 +177769,6 @@ function buildProgram() {
|
|
|
178047
177769
|
await repoBranch2(bindingId, branch, opts);
|
|
178048
177770
|
}
|
|
178049
177771
|
);
|
|
178050
|
-
repoCmd.command("init").description(
|
|
178051
|
-
"Open the pull request that adds .oxagen/ to a repository; it never writes to the production branch"
|
|
178052
|
-
).argument("<bindingId>", "The rpb_\u2026 binding id `oxagen repo list` shows").requiredOption(
|
|
178053
|
-
"--workspace-toml <file>",
|
|
178054
|
-
"The .oxagen/workspace.toml to propose"
|
|
178055
|
-
).option("--mode <mode>", "solo | team | regulated", "team").option(
|
|
178056
|
-
"--governance-toml <file>",
|
|
178057
|
-
"The .oxagen/rules/governance.toml to propose; drafted from --mode when omitted"
|
|
178058
|
-
).option("--json", "Output JSON").action(
|
|
178059
|
-
async (bindingId, opts) => {
|
|
178060
|
-
const { repoInit: repoInit2 } = await Promise.resolve().then(() => (init_repo(), repo_exports));
|
|
178061
|
-
await repoInit2(bindingId, opts);
|
|
178062
|
-
}
|
|
178063
|
-
);
|
|
178064
177772
|
repoCmd.command("governance").description(
|
|
178065
177773
|
"Set the steering governance mode: who may merge a steering PR in this workspace"
|
|
178066
177774
|
).requiredOption("--mode <mode>", "solo | team | regulated").option(
|
|
@@ -178370,6 +178078,12 @@ function buildProgram() {
|
|
|
178370
178078
|
).option("--prompt <text>", "The task for the agent").option("--prompt-file <path>", "Read the task for the agent from a file").option(
|
|
178371
178079
|
"--work-order <id>",
|
|
178372
178080
|
"Run this work order (wo_\u2026) instead of naming a repo"
|
|
178081
|
+
).option(
|
|
178082
|
+
"--account-source <source>",
|
|
178083
|
+
"Whose model accounts the run bills: operator, workspace, or operator_then_workspace (default: the agent's)"
|
|
178084
|
+
).option(
|
|
178085
|
+
"--confirm-workspace-billing",
|
|
178086
|
+
"Confirm that the run may bill the workspace's model accounts"
|
|
178373
178087
|
).option("--json", "Output the run as JSON and do not attach").action(
|
|
178374
178088
|
async (opts) => (await Promise.resolve().then(() => (init_sandbox_run(), sandbox_run_exports))).sandboxRun(opts)
|
|
178375
178089
|
);
|
|
@@ -178417,6 +178131,18 @@ function buildProgram() {
|
|
|
178417
178131
|
opts
|
|
178418
178132
|
)
|
|
178419
178133
|
);
|
|
178134
|
+
sandboxTemplateCmd.command("log").description(
|
|
178135
|
+
"Print the stored log of one template build of a sandbox runtime, with credentials redacted. Org Owner, or workspace Admin"
|
|
178136
|
+
).argument("<runtime>", "The sandbox runtime's id (rtm_\u2026)").argument("<build>", "The template build's id (rtp_\u2026)").option(
|
|
178137
|
+
"--workspace-slug <slug>",
|
|
178138
|
+
"The workspace the runtime belongs to (or OXAGEN_WORKSPACE)"
|
|
178139
|
+
).option("--json", "Output the log as JSON").action(
|
|
178140
|
+
async (runtime, build, opts) => (await Promise.resolve().then(() => (init_sandbox_template(), sandbox_template_exports))).sandboxTemplateLog(
|
|
178141
|
+
runtime,
|
|
178142
|
+
build,
|
|
178143
|
+
opts
|
|
178144
|
+
)
|
|
178145
|
+
);
|
|
178420
178146
|
sandboxCmd.command("pin-hooks", { hidden: true }).description(
|
|
178421
178147
|
"Write the sandbox's hook files as the launcher does, and print their hash"
|
|
178422
178148
|
).helpOption(false).allowUnknownOption().allowExcessArguments().action(async () => {
|
|
@@ -178444,18 +178170,27 @@ function buildProgram() {
|
|
|
178444
178170
|
).option(
|
|
178445
178171
|
"--workspace-slug <slug>",
|
|
178446
178172
|
"The workspace to address (or OXAGEN_WORKSPACE)"
|
|
178173
|
+
).option(
|
|
178174
|
+
"--shared",
|
|
178175
|
+
"Act on this workspace's accounts instead of your own. Changing one needs a workspace Admin or an organization Owner"
|
|
178447
178176
|
).option("--json", "Output JSON").action(
|
|
178448
178177
|
async (opts) => (await Promise.resolve().then(() => (init_credentials(), credentials_exports))).credentialsAdd(opts)
|
|
178449
178178
|
);
|
|
178450
178179
|
credentialsCmd.command("list").description("List your credentials in the order the gateway uses them").option(
|
|
178451
178180
|
"--workspace-slug <slug>",
|
|
178452
178181
|
"The workspace to address (or OXAGEN_WORKSPACE)"
|
|
178182
|
+
).option(
|
|
178183
|
+
"--shared",
|
|
178184
|
+
"Act on this workspace's accounts instead of your own. Changing one needs a workspace Admin or an organization Owner"
|
|
178453
178185
|
).option("--json", "Output JSON").action(
|
|
178454
178186
|
async (opts) => (await Promise.resolve().then(() => (init_credentials(), credentials_exports))).credentialsList(opts)
|
|
178455
178187
|
);
|
|
178456
178188
|
credentialsCmd.command("update").description("Rename, pause, or resume one of your credentials").argument("<credential>", "The credential's id (vlt_\u2026)").option("--label <name>", "A new name").option("--pause", "Make the gateway skip it").option("--resume", "Make the gateway use it again").option(
|
|
178457
178189
|
"--workspace-slug <slug>",
|
|
178458
178190
|
"The workspace to address (or OXAGEN_WORKSPACE)"
|
|
178191
|
+
).option(
|
|
178192
|
+
"--shared",
|
|
178193
|
+
"Act on this workspace's accounts instead of your own. Changing one needs a workspace Admin or an organization Owner"
|
|
178459
178194
|
).option("--json", "Output JSON").action(
|
|
178460
178195
|
async (credential, opts) => (await Promise.resolve().then(() => (init_credentials(), credentials_exports))).credentialsUpdate(
|
|
178461
178196
|
credential,
|
|
@@ -178470,6 +178205,9 @@ function buildProgram() {
|
|
|
178470
178205
|
).option(
|
|
178471
178206
|
"--workspace-slug <slug>",
|
|
178472
178207
|
"The workspace to address (or OXAGEN_WORKSPACE)"
|
|
178208
|
+
).option(
|
|
178209
|
+
"--shared",
|
|
178210
|
+
"Act on this workspace's accounts instead of your own. Changing one needs a workspace Admin or an organization Owner"
|
|
178473
178211
|
).option("--json", "Output JSON").action(
|
|
178474
178212
|
async (credential, opts) => (await Promise.resolve().then(() => (init_credentials(), credentials_exports))).credentialsRotate(
|
|
178475
178213
|
credential,
|
|
@@ -178479,6 +178217,9 @@ function buildProgram() {
|
|
|
178479
178217
|
credentialsCmd.command("remove").description("Remove one of your credentials").argument("<credential>", "The credential's id (vlt_\u2026)").option(
|
|
178480
178218
|
"--workspace-slug <slug>",
|
|
178481
178219
|
"The workspace to address (or OXAGEN_WORKSPACE)"
|
|
178220
|
+
).option(
|
|
178221
|
+
"--shared",
|
|
178222
|
+
"Act on this workspace's accounts instead of your own. Changing one needs a workspace Admin or an organization Owner"
|
|
178482
178223
|
).option("--json", "Output JSON").action(
|
|
178483
178224
|
async (credential, opts) => (await Promise.resolve().then(() => (init_credentials(), credentials_exports))).credentialsRemove(
|
|
178484
178225
|
credential,
|
|
@@ -178761,13 +178502,13 @@ function buildProgram() {
|
|
|
178761
178502
|
}
|
|
178762
178503
|
);
|
|
178763
178504
|
program2.command("init").description(
|
|
178764
|
-
"
|
|
178505
|
+
"Pick the Oxagen org + workspace the CLI works in, and report this directory to it. Writes no file here"
|
|
178765
178506
|
).option(
|
|
178766
178507
|
"--org <slug>",
|
|
178767
178508
|
"Link this organization instead of choosing one; works without a terminal"
|
|
178768
178509
|
).option(
|
|
178769
178510
|
"--workspace <slug>",
|
|
178770
|
-
"Link this workspace instead of choosing one; relinks when
|
|
178511
|
+
"Link this workspace instead of choosing one; relinks when another one is saved"
|
|
178771
178512
|
).option("--json", "Output JSON instead of human-readable text").option("--no-link", "Skip the workspace linker step entirely").action(
|
|
178772
178513
|
async (opts) => {
|
|
178773
178514
|
const { handleInit: handleInit2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
@@ -178779,17 +178520,6 @@ function buildProgram() {
|
|
|
178779
178520
|
});
|
|
178780
178521
|
}
|
|
178781
178522
|
);
|
|
178782
|
-
program2.command("pull").description(
|
|
178783
|
-
"Write the steering published in this workspace into this directory's .oxagen/"
|
|
178784
|
-
).option(
|
|
178785
|
-
"--binding <rpb_id>",
|
|
178786
|
-
"Pull from this repository binding instead of the workspace's main repository"
|
|
178787
|
-
).option("--force", "Overwrite files edited here").option("--dry-run", "Show what would change, and write nothing").option("--json", "Output JSON").action(
|
|
178788
|
-
async (opts) => {
|
|
178789
|
-
const { pull: pull2 } = await Promise.resolve().then(() => (init_pull(), pull_exports));
|
|
178790
|
-
await pull2(opts);
|
|
178791
|
-
}
|
|
178792
|
-
);
|
|
178793
178523
|
program2.command("check").argument(
|
|
178794
178524
|
"[paths...]",
|
|
178795
178525
|
"Report only the findings in these files and folders"
|