@agentconnect.md/daemon 1.0.0-rc.69 → 1.0.0-rc.70
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/index.js +48 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13341,6 +13341,13 @@ const WorkspaceGitFile = object({
|
|
|
13341
13341
|
index: string(),
|
|
13342
13342
|
workingDir: string()
|
|
13343
13343
|
});
|
|
13344
|
+
/** The HEAD commit of the checkout. */
|
|
13345
|
+
const WorkspaceGitCommit = object({
|
|
13346
|
+
sha: string(),
|
|
13347
|
+
shortSha: string(),
|
|
13348
|
+
subject: string(),
|
|
13349
|
+
committedAt: string()
|
|
13350
|
+
});
|
|
13344
13351
|
/** D→C REP (corr = the req id): the working-tree status. */
|
|
13345
13352
|
const WorkspaceGitStatus = object({
|
|
13346
13353
|
agentId: string(),
|
|
@@ -13351,7 +13358,9 @@ const WorkspaceGitStatus = object({
|
|
|
13351
13358
|
ahead: number().int().nonnegative().optional(),
|
|
13352
13359
|
behind: number().int().nonnegative().optional(),
|
|
13353
13360
|
files: array(WorkspaceGitFile).optional(),
|
|
13354
|
-
truncated: boolean().optional()
|
|
13361
|
+
truncated: boolean().optional(),
|
|
13362
|
+
lastCommit: WorkspaceGitCommit.optional(),
|
|
13363
|
+
lastFetchAt: string().optional()
|
|
13355
13364
|
});
|
|
13356
13365
|
/** C→D REQ: force a fast-forward-only `git pull` in the agent's workspace now. */
|
|
13357
13366
|
const WorkspaceGitPullReq = object({ agentId: string().min(1) });
|
|
@@ -82961,12 +82970,14 @@ function createWorkspaceGit(workspaceRootByAgent) {
|
|
|
82961
82970
|
isRepo: false,
|
|
82962
82971
|
clean: true
|
|
82963
82972
|
};
|
|
82964
|
-
const
|
|
82973
|
+
const git = simpleGit(root);
|
|
82974
|
+
const s = await git.status();
|
|
82965
82975
|
const files = s.files.slice(0, MAX_STATUS_FILES).map((f) => ({
|
|
82966
82976
|
path: f.path,
|
|
82967
82977
|
index: f.index,
|
|
82968
82978
|
workingDir: f.working_dir
|
|
82969
82979
|
}));
|
|
82980
|
+
const [lastCommit, lastFetchAt] = await Promise.all([headCommit(git), fetchHeadMtime(root)]);
|
|
82970
82981
|
return {
|
|
82971
82982
|
agentId,
|
|
82972
82983
|
isRepo: true,
|
|
@@ -82976,7 +82987,9 @@ function createWorkspaceGit(workspaceRootByAgent) {
|
|
|
82976
82987
|
ahead: s.ahead,
|
|
82977
82988
|
behind: s.behind,
|
|
82978
82989
|
...files.length ? { files } : {},
|
|
82979
|
-
...s.files.length > files.length ? { truncated: true } : {}
|
|
82990
|
+
...s.files.length > files.length ? { truncated: true } : {},
|
|
82991
|
+
...lastCommit ? { lastCommit } : {},
|
|
82992
|
+
...lastFetchAt ? { lastFetchAt } : {}
|
|
82980
82993
|
};
|
|
82981
82994
|
},
|
|
82982
82995
|
async pull(agentId) {
|
|
@@ -83015,6 +83028,38 @@ function createWorkspaceGit(workspaceRootByAgent) {
|
|
|
83015
83028
|
}
|
|
83016
83029
|
};
|
|
83017
83030
|
}
|
|
83031
|
+
/** The HEAD commit (sha / short sha / subject / committer date), or null for an
|
|
83032
|
+
* empty repo with no commits yet. `%cI` is git's strict-ISO committer date. */
|
|
83033
|
+
async function headCommit(git) {
|
|
83034
|
+
try {
|
|
83035
|
+
const c = (await git.log({
|
|
83036
|
+
maxCount: 1,
|
|
83037
|
+
format: {
|
|
83038
|
+
hash: "%H",
|
|
83039
|
+
date: "%cI",
|
|
83040
|
+
subject: "%s"
|
|
83041
|
+
}
|
|
83042
|
+
})).latest;
|
|
83043
|
+
if (!c?.hash) return null;
|
|
83044
|
+
return {
|
|
83045
|
+
sha: c.hash,
|
|
83046
|
+
shortSha: c.hash.slice(0, 7),
|
|
83047
|
+
subject: c.subject ?? "",
|
|
83048
|
+
committedAt: c.date
|
|
83049
|
+
};
|
|
83050
|
+
} catch {
|
|
83051
|
+
return null;
|
|
83052
|
+
}
|
|
83053
|
+
}
|
|
83054
|
+
/** When the checkout last fetched/pulled, from `.git/FETCH_HEAD`'s mtime (git
|
|
83055
|
+
* rewrites it on every fetch/pull). Null if it has never fetched. */
|
|
83056
|
+
async function fetchHeadMtime(root) {
|
|
83057
|
+
try {
|
|
83058
|
+
return (await promises.stat(join(root, ".git", "FETCH_HEAD"))).mtime.toISOString();
|
|
83059
|
+
} catch {
|
|
83060
|
+
return null;
|
|
83061
|
+
}
|
|
83062
|
+
}
|
|
83018
83063
|
//#endregion
|
|
83019
83064
|
//#region src/cp/cp-cron.ts
|
|
83020
83065
|
/**
|