replicas-engine 0.1.64 → 0.1.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.js +55 -17
- package/package.json +2 -1
package/dist/src/index.js
CHANGED
|
@@ -102,7 +102,29 @@ var BaseRefreshManager = class {
|
|
|
102
102
|
}
|
|
103
103
|
console.log(`[${this.managerName}] Starting token refresh service`);
|
|
104
104
|
this.health.isRunning = true;
|
|
105
|
-
|
|
105
|
+
const config = this.getRuntimeConfig();
|
|
106
|
+
if (config) {
|
|
107
|
+
this.health.lastAttemptAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
108
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
109
|
+
try {
|
|
110
|
+
await this.doRefresh(config);
|
|
111
|
+
this.health.lastSuccessAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
112
|
+
this.health.lastErrorAt = null;
|
|
113
|
+
this.health.lastErrorMessage = null;
|
|
114
|
+
break;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
117
|
+
this.health.lastErrorAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
118
|
+
this.health.lastErrorMessage = message;
|
|
119
|
+
if (attempt < 3) {
|
|
120
|
+
console.warn(`[${this.managerName}] Initial refresh attempt ${attempt} failed, retrying in 2s...`);
|
|
121
|
+
await new Promise((resolve2) => setTimeout(resolve2, 2e3));
|
|
122
|
+
} else {
|
|
123
|
+
console.error(`[${this.managerName}] Initial refresh failed after 3 attempts:`, error);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
106
128
|
this.intervalHandle = setInterval(() => {
|
|
107
129
|
this.refreshOnce().catch((error) => {
|
|
108
130
|
console.error(`[${this.managerName}] Scheduled refresh failed:`, error);
|
|
@@ -330,7 +352,7 @@ import { execFileSync as execFileSync2 } from "child_process";
|
|
|
330
352
|
import { join as join3 } from "path";
|
|
331
353
|
|
|
332
354
|
// src/utils/state.ts
|
|
333
|
-
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
355
|
+
import { readFile, writeFile, mkdir, rename, unlink } from "fs/promises";
|
|
334
356
|
import { existsSync } from "fs";
|
|
335
357
|
import { join as join2 } from "path";
|
|
336
358
|
import { homedir as homedir2 } from "os";
|
|
@@ -357,7 +379,14 @@ async function updateEngineState(updater) {
|
|
|
357
379
|
await mkdir(STATE_DIR, { recursive: true });
|
|
358
380
|
const currentState = await loadEngineState();
|
|
359
381
|
const nextState = updater(currentState);
|
|
360
|
-
|
|
382
|
+
const tmpFile = `${STATE_FILE}.${process.pid}.tmp`;
|
|
383
|
+
try {
|
|
384
|
+
await writeFile(tmpFile, JSON.stringify(nextState, null, 2), "utf-8");
|
|
385
|
+
await rename(tmpFile, STATE_FILE);
|
|
386
|
+
} catch (err) {
|
|
387
|
+
await unlink(tmpFile).catch(() => void 0);
|
|
388
|
+
throw err;
|
|
389
|
+
}
|
|
361
390
|
});
|
|
362
391
|
}
|
|
363
392
|
function isEngineRepoDiff(value) {
|
|
@@ -674,11 +703,11 @@ var GitService = class {
|
|
|
674
703
|
try {
|
|
675
704
|
const currentBranch = currentBranchArg ?? getCurrentBranch(repoPath);
|
|
676
705
|
if (!currentBranch) {
|
|
677
|
-
return
|
|
706
|
+
return { status: "not_found" };
|
|
678
707
|
}
|
|
679
708
|
const cachedPr = this.cachedPrByRepo.get(repoName);
|
|
680
709
|
if (cachedPr && cachedPr.currentBranch === currentBranch) {
|
|
681
|
-
return cachedPr.prUrl;
|
|
710
|
+
return { status: "found", url: cachedPr.prUrl };
|
|
682
711
|
}
|
|
683
712
|
const persistedRepoState = persistedRepoStateArg ?? await loadRepoState(repoName);
|
|
684
713
|
if (persistedRepoState?.prUrl && persistedRepoState.currentBranch === currentBranch) {
|
|
@@ -686,7 +715,7 @@ var GitService = class {
|
|
|
686
715
|
prUrl: persistedRepoState.prUrl,
|
|
687
716
|
currentBranch
|
|
688
717
|
});
|
|
689
|
-
return persistedRepoState.prUrl;
|
|
718
|
+
return { status: "found", url: persistedRepoState.prUrl };
|
|
690
719
|
}
|
|
691
720
|
this.cachedPrByRepo.delete(repoName);
|
|
692
721
|
if (persistedRepoState?.prUrl && persistedRepoState.currentBranch !== currentBranch) {
|
|
@@ -699,10 +728,10 @@ var GitService = class {
|
|
|
699
728
|
stdio: ["pipe", "pipe", "pipe"]
|
|
700
729
|
}).trim();
|
|
701
730
|
if (!remoteRef) {
|
|
702
|
-
return
|
|
731
|
+
return { status: "not_found" };
|
|
703
732
|
}
|
|
704
733
|
} catch {
|
|
705
|
-
return
|
|
734
|
+
return { status: "error" };
|
|
706
735
|
}
|
|
707
736
|
try {
|
|
708
737
|
const prInfo = execFileSync2("gh", ["pr", "view", "--json", "url", "--jq", ".url"], {
|
|
@@ -718,17 +747,17 @@ var GitService = class {
|
|
|
718
747
|
if (persistedRepoState) {
|
|
719
748
|
await saveRepoState(repoName, { prUrl: prInfo }, persistedRepoState);
|
|
720
749
|
}
|
|
721
|
-
return prInfo;
|
|
750
|
+
return { status: "found", url: prInfo };
|
|
722
751
|
}
|
|
723
752
|
} catch (error) {
|
|
724
753
|
const message = error instanceof Error ? error.message : String(error);
|
|
725
754
|
console.warn(`[GitService] gh pr view failed for ${repoName}: ${message}`);
|
|
726
|
-
return
|
|
755
|
+
return { status: "error" };
|
|
727
756
|
}
|
|
728
|
-
return
|
|
757
|
+
return { status: "not_found" };
|
|
729
758
|
} catch (error) {
|
|
730
759
|
console.error("Error checking for pull request:", error);
|
|
731
|
-
return
|
|
760
|
+
return { status: "error" };
|
|
732
761
|
}
|
|
733
762
|
}
|
|
734
763
|
resolveDefaultBranch(repoPath) {
|
|
@@ -766,12 +795,21 @@ var GitService = class {
|
|
|
766
795
|
return normalized || "replicas";
|
|
767
796
|
}
|
|
768
797
|
async refreshRepoMetadata(repo, currentBranch, startHooksCompleted, persistedState) {
|
|
798
|
+
const prResult = await this.getPullRequestUrl(repo.name, repo.path, currentBranch, persistedState);
|
|
799
|
+
let prUrl;
|
|
800
|
+
if (prResult.status === "found") {
|
|
801
|
+
prUrl = prResult.url;
|
|
802
|
+
} else if (prResult.status === "not_found") {
|
|
803
|
+
prUrl = null;
|
|
804
|
+
} else {
|
|
805
|
+
prUrl = persistedState?.prUrl ?? null;
|
|
806
|
+
}
|
|
769
807
|
const state = {
|
|
770
808
|
name: repo.name,
|
|
771
809
|
path: repo.path,
|
|
772
810
|
defaultBranch: repo.defaultBranch,
|
|
773
811
|
currentBranch,
|
|
774
|
-
prUrl
|
|
812
|
+
prUrl,
|
|
775
813
|
gitDiff: this.getGitDiffStats(repo.path, repo.defaultBranch),
|
|
776
814
|
startHooksCompleted
|
|
777
815
|
};
|
|
@@ -1042,7 +1080,7 @@ function parseReplicasConfigString(content, filename) {
|
|
|
1042
1080
|
}
|
|
1043
1081
|
|
|
1044
1082
|
// ../shared/src/engine/environment.ts
|
|
1045
|
-
var
|
|
1083
|
+
var DAYTONA_SNAPSHOT_ID = "01-04-2026-kipling-v6";
|
|
1046
1084
|
|
|
1047
1085
|
// ../shared/src/engine/types.ts
|
|
1048
1086
|
var DEFAULT_CHAT_TITLES = {
|
|
@@ -1110,7 +1148,7 @@ function upsertRepositoryStatus(current, incoming) {
|
|
|
1110
1148
|
}
|
|
1111
1149
|
function createDefaultDetails() {
|
|
1112
1150
|
return {
|
|
1113
|
-
engineVersion:
|
|
1151
|
+
engineVersion: DAYTONA_SNAPSHOT_ID,
|
|
1114
1152
|
globalWarmHookCompleted: { status: "n/a", details: null },
|
|
1115
1153
|
repositories: [],
|
|
1116
1154
|
filesUploaded: [],
|
|
@@ -1150,7 +1188,7 @@ var EnvironmentDetailsService = class {
|
|
|
1150
1188
|
gitService.listRepositories(),
|
|
1151
1189
|
detectGitIdentityConfigured()
|
|
1152
1190
|
]);
|
|
1153
|
-
details.engineVersion =
|
|
1191
|
+
details.engineVersion = DAYTONA_SNAPSHOT_ID;
|
|
1154
1192
|
details.claudeAuthMethod = detectClaudeAuthMethod();
|
|
1155
1193
|
details.codexAuthMethod = detectCodexAuthMethod();
|
|
1156
1194
|
details.gitIdentityConfigured = gitIdentityConfigured;
|
|
@@ -3792,7 +3830,7 @@ function createV1Routes(deps) {
|
|
|
3792
3830
|
});
|
|
3793
3831
|
app2.get("/version", (c) => {
|
|
3794
3832
|
const response = {
|
|
3795
|
-
version:
|
|
3833
|
+
version: DAYTONA_SNAPSHOT_ID
|
|
3796
3834
|
};
|
|
3797
3835
|
return c.json(response);
|
|
3798
3836
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "replicas-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.66",
|
|
4
4
|
"description": "Lightweight API server for Replicas workspaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"author": "Replicas",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"@replicas/shared": "workspace:*",
|
|
30
31
|
"@anthropic-ai/claude-agent-sdk": "^0.2.41",
|
|
31
32
|
"@hono/node-server": "^1.19.5",
|
|
32
33
|
"@openai/codex-sdk": "^0.111.0",
|