attestari 2.9.4 → 2.9.6
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/hook.js +14 -10
- package/package.json +1 -1
package/dist/hook.js
CHANGED
|
@@ -657,7 +657,7 @@ function install(home2, hookFile = __filename) {
|
|
|
657
657
|
...groups,
|
|
658
658
|
[GROUP]: {
|
|
659
659
|
PreToolUse: [{ matcher: "*", hooks: [{ type: "command", command: commands.preToolUse, timeout: TIMEOUT_S }] }],
|
|
660
|
-
SessionStart: [{
|
|
660
|
+
SessionStart: [{ type: "command", command: commands.sessionStart, timeout: TIMEOUT_S }]
|
|
661
661
|
}
|
|
662
662
|
};
|
|
663
663
|
const after = formatLike(text, next);
|
|
@@ -1068,13 +1068,14 @@ function usableFolder(folder) {
|
|
|
1068
1068
|
return void 0;
|
|
1069
1069
|
}
|
|
1070
1070
|
}
|
|
1071
|
-
function spawnRefresh(agent, cwd) {
|
|
1071
|
+
function spawnRefresh(agent, cwd, reason) {
|
|
1072
1072
|
const at = /* @__PURE__ */ new Date();
|
|
1073
1073
|
attempt("refresh_started_at was not written", () => writeStamp(agent, "refresh_started_at", at));
|
|
1074
1074
|
const folder = usableFolder(cwd);
|
|
1075
1075
|
let pid;
|
|
1076
1076
|
try {
|
|
1077
|
-
const
|
|
1077
|
+
const args = [__filename, agent, "refresh", ...cwd !== void 0 && cwd !== "" ? ["--cwd", cwd] : [], ...reason !== void 0 ? ["--reason", reason] : []];
|
|
1078
|
+
const child = (0, import_node_child_process.spawn)(process.execPath, args, {
|
|
1078
1079
|
cwd: folder,
|
|
1079
1080
|
detached: true,
|
|
1080
1081
|
stdio: "ignore",
|
|
@@ -2003,7 +2004,7 @@ var import_node_http = require("node:http");
|
|
|
2003
2004
|
var import_node_https = require("node:https");
|
|
2004
2005
|
|
|
2005
2006
|
// src/version.ts
|
|
2006
|
-
var HOOK_VERSION = "2.9.
|
|
2007
|
+
var HOOK_VERSION = "2.9.6";
|
|
2007
2008
|
|
|
2008
2009
|
// src/api.ts
|
|
2009
2010
|
var timeoutMs = 1e4;
|
|
@@ -2178,14 +2179,14 @@ function sessionStart(stdinText, adapter) {
|
|
|
2178
2179
|
attempt("the session was not bound to its folder", () => writeSession(agent, sessionId, cwd));
|
|
2179
2180
|
}
|
|
2180
2181
|
attempt("the refresh was not started", () => {
|
|
2181
|
-
if (!heldBack(agent, Date.now(), true)) spawnRefresh(agent, cwd);
|
|
2182
|
+
if (!heldBack(agent, Date.now(), true)) spawnRefresh(agent, cwd, "session_start");
|
|
2182
2183
|
});
|
|
2183
2184
|
return { stdout: "", exitCode: 0 };
|
|
2184
2185
|
}
|
|
2185
2186
|
function nextAt(agent, ms, word) {
|
|
2186
2187
|
attempt("next_refresh_at was not written", () => writeStamp(agent, "next_refresh_at", new Date(Date.now() + ms), word));
|
|
2187
2188
|
}
|
|
2188
|
-
async function refresh(adapter, cwd) {
|
|
2189
|
+
async function refresh(adapter, cwd, reason = "refresh") {
|
|
2189
2190
|
const agent = adapter.name;
|
|
2190
2191
|
const token = readToken(agent);
|
|
2191
2192
|
if (token === null) return null;
|
|
@@ -2217,7 +2218,7 @@ async function refresh(adapter, cwd) {
|
|
|
2217
2218
|
answer = await checkin(
|
|
2218
2219
|
accountsBase(),
|
|
2219
2220
|
token,
|
|
2220
|
-
{ hook_version: HOOK_VERSION, agent_client: adapter.client, policy_version: held?.policy.policy.version ?? 0, servers, events },
|
|
2221
|
+
{ hook_version: HOOK_VERSION, agent_client: adapter.client, policy_version: held?.policy.policy.version ?? 0, servers, events, reason },
|
|
2221
2222
|
held !== null && etag === held.policy.etag ? etag : null
|
|
2222
2223
|
);
|
|
2223
2224
|
} catch (error) {
|
|
@@ -2350,7 +2351,7 @@ ${PAIR_USAGE}
|
|
|
2350
2351
|
let refreshed = null;
|
|
2351
2352
|
try {
|
|
2352
2353
|
resolveAndKeep(adapter, cwd);
|
|
2353
|
-
refreshed = await refresh(adapter, cwd);
|
|
2354
|
+
refreshed = await refresh(adapter, cwd, "pairing");
|
|
2354
2355
|
} catch (error) {
|
|
2355
2356
|
say2(`the first check-in failed: ${message(error)}`);
|
|
2356
2357
|
}
|
|
@@ -2508,10 +2509,13 @@ function hook(agent, event, args) {
|
|
|
2508
2509
|
return outcome.exitCode;
|
|
2509
2510
|
}
|
|
2510
2511
|
// Detached, its output ignored: whatever happens it exits 0 and the next session or hour tries again.
|
|
2511
|
-
// `--cwd <folder>`: the session's working folder, resolved first when it has no resolution.
|
|
2512
|
+
// `--cwd <folder>`: the session's working folder, resolved first when it has no resolution. `--reason <why>`: why
|
|
2513
|
+
// the check-in is made (session_start from a session's start; the hourly refresh otherwise).
|
|
2512
2514
|
case "refresh": {
|
|
2513
2515
|
const at = args.indexOf("--cwd");
|
|
2514
|
-
|
|
2516
|
+
const why = args.indexOf("--reason");
|
|
2517
|
+
const reason = why >= 0 && args[why + 1] === "session_start" ? "session_start" : "refresh";
|
|
2518
|
+
return refresh(adapter, at >= 0 ? args[at + 1] : void 0, reason).then(() => 0);
|
|
2515
2519
|
}
|
|
2516
2520
|
default:
|
|
2517
2521
|
return notBuilt(`${agent} ${event}`);
|