@agimon-ai/po-git 0.0.0-alpha.3 → 0.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/server.cjs +13 -13
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +1 -1
- package/dist/extensions/server.mjs +14 -14
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +112 -112
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{worktreeOperations-2PaaLPTF.mjs → worktreeOperations-BSeyxUai.mjs} +39 -39
- package/dist/worktreeOperations-BSeyxUai.mjs.map +1 -0
- package/dist/{worktreeOperations-C6_xikos.cjs → worktreeOperations-DGUbUnYU.cjs} +50 -50
- package/dist/worktreeOperations-DGUbUnYU.cjs.map +1 -0
- package/package.json +14 -14
- package/dist/worktreeOperations-2PaaLPTF.mjs.map +0 -1
- package/dist/worktreeOperations-C6_xikos.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region generated/server.d.ts
|
|
2
|
-
export declare const facet: import("@agimon-ai/po-core/serverFacet").
|
|
2
|
+
export declare const facet: import("@agimon-ai/po-core/serverFacet").PoServerFacet;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { facet as default };
|
|
5
5
|
//# sourceMappingURL=server.d.mts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { _ as NETWORK_TIMEOUT_MS, a as GIT_WORKTREE_LIFECYCLE_EVENT, b as createWorktreeGit, c as isWorktreeLifecycleEvent, d as registryFile, f as readJson, g as invalidRequest, h as
|
|
1
|
+
import { _ as NETWORK_TIMEOUT_MS, a as GIT_WORKTREE_LIFECYCLE_EVENT, b as createWorktreeGit, c as isWorktreeLifecycleEvent, d as registryFile, f as readJson, g as invalidRequest, h as PoGitExpectedError, i as GIT_SESSION_CHANGED_EVENT, l as credentialsFile, m as HubUnavailableError, n as createWorktreeRegistry, o as createWorktreeMessageInbox, p as writeJsonAtomic, r as validRefName, s as isSessionChangedEvent, t as createWorktreeOperations, u as poGitRoot, v as READ_TIMEOUT_MS, x as runGit, y as REBASE_TIMEOUT_MS } from "../worktreeOperations-BSeyxUai.mjs";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { composeServerProviderOverrides, defineServerPlugin, readPackageResource } from "@agimon-ai/po-core/serverFacet";
|
|
6
6
|
import { composeRootHooks, defineChannel, defineHook, defineResource, defineRoot, defineRoute, defineServerTool } from "@agimon-ai/po-core/extensionFile";
|
|
7
|
-
import {
|
|
7
|
+
import { readPoSessionDelivery } from "@agimon-ai/po-session";
|
|
8
8
|
import { Type } from "typebox";
|
|
9
9
|
//#region src/schemas/runWorktreeTool.ts
|
|
10
10
|
/**
|
|
@@ -312,7 +312,7 @@ function createGitSession({ context, host: serverHost }) {
|
|
|
312
312
|
git: createWorktreeGit(),
|
|
313
313
|
sessionService: serverHost.context.sessionService,
|
|
314
314
|
messageInbox,
|
|
315
|
-
sessionDelivery: () =>
|
|
315
|
+
sessionDelivery: () => readPoSessionDelivery(context)
|
|
316
316
|
});
|
|
317
317
|
const resources = [{
|
|
318
318
|
when: {
|
|
@@ -928,7 +928,7 @@ function createGitAuthStore(homeDir = os.homedir()) {
|
|
|
928
928
|
const key = workspaceKey(workspaceRoot);
|
|
929
929
|
const current = readFile();
|
|
930
930
|
const next = parseGitAuthSave(request, current.workspaces[key] ?? { method: "none" }, homeDir);
|
|
931
|
-
const root =
|
|
931
|
+
const root = poGitRoot(homeDir);
|
|
932
932
|
fs.mkdirSync(root, {
|
|
933
933
|
recursive: true,
|
|
934
934
|
mode: OWNER_ONLY_DIRECTORY
|
|
@@ -1100,7 +1100,7 @@ function badRequest(message) {
|
|
|
1100
1100
|
return Response.json({ error: message }, { status: 400 });
|
|
1101
1101
|
}
|
|
1102
1102
|
function failed(error) {
|
|
1103
|
-
if (error instanceof
|
|
1103
|
+
if (error instanceof PoGitExpectedError) return Response.json({
|
|
1104
1104
|
error: error.message,
|
|
1105
1105
|
code: error.code
|
|
1106
1106
|
}, { status: error.retryable ? 503 : 409 });
|
|
@@ -1191,7 +1191,7 @@ var route_server_default = defineRoute({
|
|
|
1191
1191
|
try {
|
|
1192
1192
|
return Response.json(gitAuth.save(root, await request.json().catch(() => void 0)));
|
|
1193
1193
|
} catch (error) {
|
|
1194
|
-
if (error instanceof
|
|
1194
|
+
if (error instanceof PoGitExpectedError && error.code === "invalid_request") {
|
|
1195
1195
|
const text = error.message.replace(/^\[[a-z_]+\] /u, "").replace("\nRecovery: ", " ");
|
|
1196
1196
|
return Response.json({
|
|
1197
1197
|
error: text,
|
|
@@ -1366,12 +1366,12 @@ const RULES = [
|
|
|
1366
1366
|
}
|
|
1367
1367
|
];
|
|
1368
1368
|
function classifyGitFailure(operation, result, mismatch) {
|
|
1369
|
-
if (result.timedOut) return new
|
|
1369
|
+
if (result.timedOut) return new PoGitExpectedError("git_timeout", `git ${operation} took too long and was stopped.`, true, "Check the network, then try again.");
|
|
1370
1370
|
const text = `${result.stderr}\n${result.stdout}`.toLowerCase();
|
|
1371
1371
|
const rule = RULES.find((candidate) => candidate.phrases.some((phrase) => text.includes(phrase)));
|
|
1372
|
-
if (rule === void 0) return new
|
|
1372
|
+
if (rule === void 0) return new PoGitExpectedError("git_failed", `git ${operation} failed (exit ${String(result.code)}).`, false, "Run the same command in a terminal in this checkout to see what git says.");
|
|
1373
1373
|
const recovery = rule.code === "auth_failed" && mismatch !== void 0 ? `${mismatch} ${rule.recovery}` : rule.recovery;
|
|
1374
|
-
return new
|
|
1374
|
+
return new PoGitExpectedError(rule.code, rule.message, rule.retryable, recovery);
|
|
1375
1375
|
}
|
|
1376
1376
|
//#endregion
|
|
1377
1377
|
//#region src/services/gitSync/index.ts
|
|
@@ -1394,7 +1394,7 @@ function classifyGitFailure(operation, result, mismatch) {
|
|
|
1394
1394
|
*/
|
|
1395
1395
|
const DONE = { outcome: "done" };
|
|
1396
1396
|
function expected(code, message, recovery) {
|
|
1397
|
-
return new
|
|
1397
|
+
return new PoGitExpectedError(code, message, false, recovery);
|
|
1398
1398
|
}
|
|
1399
1399
|
async function readLine(cwd, args) {
|
|
1400
1400
|
const result = await runGit(cwd, args, { timeout: READ_TIMEOUT_MS });
|
|
@@ -1621,13 +1621,13 @@ const PENDING = {
|
|
|
1621
1621
|
/** The error target a failure maps to: a rejected plain push asks for a confirmed lease force. */
|
|
1622
1622
|
function errorTargetFor$1(command, error) {
|
|
1623
1623
|
if (command.action !== "push") return { action: command.action };
|
|
1624
|
-
return error instanceof
|
|
1624
|
+
return error instanceof PoGitExpectedError && error.code === "push_needs_force" && command.force !== true ? {
|
|
1625
1625
|
action: "push",
|
|
1626
1626
|
forceRequired: true
|
|
1627
1627
|
} : { action: "push" };
|
|
1628
1628
|
}
|
|
1629
1629
|
function failureText$1(error) {
|
|
1630
|
-
if (error instanceof
|
|
1630
|
+
if (error instanceof PoGitExpectedError) return error.message.replace(/^\[[a-z_]+\] /u, "").replace("\nRecovery: ", " ");
|
|
1631
1631
|
return "The git command failed.";
|
|
1632
1632
|
}
|
|
1633
1633
|
function createGitChangesChannel(options = {}) {
|
|
@@ -1745,7 +1745,7 @@ function createGitChangesChannel(options = {}) {
|
|
|
1745
1745
|
errorTarget: void 0
|
|
1746
1746
|
});
|
|
1747
1747
|
run(scope, command).then(() => update(scope.sessionId, { pending: void 0 })).catch((error) => {
|
|
1748
|
-
host.onNotice(`git ${command.action} failed for ${scope.sessionId} (${error instanceof
|
|
1748
|
+
host.onNotice(`git ${command.action} failed for ${scope.sessionId} (${error instanceof PoGitExpectedError ? error.code : "unexpected"})`);
|
|
1749
1749
|
update(scope.sessionId, {
|
|
1750
1750
|
pending: void 0,
|
|
1751
1751
|
error: failureText$1(error),
|
|
@@ -1857,7 +1857,7 @@ function parseCommand(payload) {
|
|
|
1857
1857
|
* echoed: a git error can carry a remote URL with a token in it.
|
|
1858
1858
|
*/
|
|
1859
1859
|
function failureText(error) {
|
|
1860
|
-
return error instanceof
|
|
1860
|
+
return error instanceof PoGitExpectedError ? error.message : "The worktree operation failed.";
|
|
1861
1861
|
}
|
|
1862
1862
|
/** Starts one direct-event subscription per managed session. */
|
|
1863
1863
|
function createWorktreesChannel(options = {}) {
|