@oyasmi/pipiclaw 0.8.10 → 0.8.11-beta.3
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 +3 -3
- package/dist/agent/channel-runner.d.ts +11 -0
- package/dist/agent/channel-runner.js +58 -27
- package/dist/agent/commands.js +2 -3
- package/dist/agent/effect-ledger.d.ts +1 -1
- package/dist/agent/effect-ledger.js +2 -2
- package/dist/agent/prompt/sections.js +3 -3
- package/dist/agent/runner-factory.d.ts +2 -0
- package/dist/agent/session-events.js +1 -1
- package/dist/main.js +6 -0
- package/dist/memory/commands.js +6 -1
- package/dist/memory/consolidation.d.ts +8 -1
- package/dist/memory/consolidation.js +34 -6
- package/dist/memory/extraction.d.ts +11 -3
- package/dist/memory/extraction.js +19 -6
- package/dist/memory/files.d.ts +2 -0
- package/dist/memory/files.js +14 -0
- package/dist/memory/maintenance-gates.d.ts +3 -0
- package/dist/memory/maintenance-gates.js +5 -2
- package/dist/memory/maintenance-jobs.js +19 -2
- package/dist/memory/maintenance-state.d.ts +29 -0
- package/dist/memory/maintenance-state.js +100 -8
- package/dist/memory/metadata.d.ts +9 -0
- package/dist/memory/metadata.js +5 -0
- package/dist/memory/probation.d.ts +21 -0
- package/dist/memory/probation.js +48 -0
- package/dist/memory/promotion.d.ts +26 -1
- package/dist/memory/promotion.js +34 -4
- package/dist/memory/recall.js +38 -19
- package/dist/memory/session-corpus.js +12 -11
- package/dist/memory/session-search.js +25 -6
- package/dist/memory/sidecar-worker.js +2 -0
- package/dist/memory/task-digest.d.ts +3 -2
- package/dist/memory/task-digest.js +22 -8
- package/dist/models/auth-cli.d.ts +25 -0
- package/dist/models/auth-cli.js +344 -0
- package/dist/models/login-ui.d.ts +35 -0
- package/dist/models/login-ui.js +145 -0
- package/dist/models/provider-login.d.ts +41 -0
- package/dist/models/provider-login.js +126 -0
- package/dist/models/utils.d.ts +6 -0
- package/dist/models/utils.js +10 -0
- package/dist/playbooks/memory-and-learning.md +7 -1
- package/dist/playbooks/outbound-media.md +7 -33
- package/dist/playbooks/runtime-orientation.md +2 -0
- package/dist/playbooks/task-closeout.md +22 -35
- package/dist/playbooks/task-delegation.md +13 -35
- package/dist/playbooks/task-driving.md +36 -56
- package/dist/playbooks/task-planning.md +26 -45
- package/dist/runtime/bootstrap.js +48 -14
- package/dist/runtime/delivery.js +8 -2
- package/dist/runtime/dingtalk.d.ts +6 -3
- package/dist/runtime/dingtalk.js +6 -39
- package/dist/runtime/events.js +4 -3
- package/dist/runtime/proxy.d.ts +36 -0
- package/dist/runtime/proxy.js +68 -0
- package/dist/runtime/store.d.ts +8 -2
- package/dist/runtime/store.js +12 -6
- package/dist/runtime/task-commands.d.ts +0 -2
- package/dist/runtime/task-commands.js +99 -112
- package/dist/runtime/task-driver.d.ts +5 -0
- package/dist/runtime/task-driver.js +155 -53
- package/dist/runtime/task-migration.d.ts +9 -0
- package/dist/runtime/task-migration.js +75 -2
- package/dist/security/command-guard.js +51 -17
- package/dist/security/path-guard.js +72 -14
- package/dist/shared/open-browser.d.ts +6 -0
- package/dist/shared/open-browser.js +22 -0
- package/dist/shared/recoverable-error.d.ts +1 -1
- package/dist/shared/recoverable-error.js +1 -1
- package/dist/subagents/tool.js +2 -0
- package/dist/tasks/control.d.ts +38 -67
- package/dist/tasks/control.js +90 -152
- package/dist/tasks/ledger.d.ts +104 -22
- package/dist/tasks/ledger.js +419 -56
- package/dist/tasks/store.d.ts +11 -10
- package/dist/tasks/store.js +58 -27
- package/dist/tasks/transitions.d.ts +8 -36
- package/dist/tasks/transitions.js +29 -54
- package/dist/tasks/verification.d.ts +2 -2
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +1 -0
- package/dist/tools/memory-manage.js +8 -1
- package/dist/tools/read.js +19 -5
- package/dist/tools/registry.d.ts +1 -0
- package/dist/tools/registry.js +1 -0
- package/dist/tools/task-manage/lifecycle.d.ts +1 -7
- package/dist/tools/task-manage/lifecycle.js +76 -77
- package/dist/tools/task-manage/schema.d.ts +10 -5
- package/dist/tools/task-manage/schema.js +35 -21
- package/dist/tools/task-manage/shared.d.ts +1 -1
- package/dist/tools/task-manage/shared.js +29 -30
- package/dist/tools/task-manage/types.d.ts +7 -1
- package/dist/tools/task-manage/verification.d.ts +4 -5
- package/dist/tools/task-manage/verification.js +43 -15
- package/dist/tools/task-manage.d.ts +1 -1
- package/dist/tools/task-manage.js +9 -9
- package/dist/tui/app.js +1 -2
- package/dist/tui/commands.d.ts +1 -1
- package/dist/tui/commands.js +1 -1
- package/dist/tui/turn-controller.d.ts +1 -1
- package/dist/usage/ledger.d.ts +1 -1
- package/dist/usage/ledger.js +47 -22
- package/dist/usage/render.d.ts +1 -1
- package/dist/usage/render.js +8 -6
- package/package.json +7 -6
|
@@ -96,6 +96,25 @@ function resolveExistingAncestor(path) {
|
|
|
96
96
|
current = parent;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* `resolveForGuard` for the two roots every call resolves: the workspace and the home directory.
|
|
101
|
+
*
|
|
102
|
+
* Unlike a guarded target, these are existing directories that do not move for the life of the
|
|
103
|
+
* process, so their realpath is stable — but resolving them cost two `realpathSync` calls on
|
|
104
|
+
* *every* guarded read and write. Cached on the literal input so a different workspace (tests,
|
|
105
|
+
* a second runtime in-process) still resolves correctly.
|
|
106
|
+
*/
|
|
107
|
+
const rootRealPathCache = new Map();
|
|
108
|
+
function resolveRootForGuard(path, ctx) {
|
|
109
|
+
const key = `${ctx.config.resolveSymlinks !== false}\0${path}`;
|
|
110
|
+
const cached = rootRealPathCache.get(key);
|
|
111
|
+
if (cached !== undefined) {
|
|
112
|
+
return cached;
|
|
113
|
+
}
|
|
114
|
+
const resolved = resolveForGuard(path, ctx);
|
|
115
|
+
rootRealPathCache.set(key, resolved);
|
|
116
|
+
return resolved;
|
|
117
|
+
}
|
|
99
118
|
function resolveForGuard(path, ctx) {
|
|
100
119
|
const normalized = normalize(path);
|
|
101
120
|
const resolveSymlinks = ctx.config.resolveSymlinks !== false;
|
|
@@ -112,15 +131,37 @@ function resolveForGuard(path, ctx) {
|
|
|
112
131
|
function matchesAnyPath(path, exactPaths, prefixes) {
|
|
113
132
|
return exactPaths.includes(path) || prefixes.some((prefix) => startsWithPathPrefix(path, prefix));
|
|
114
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* The sensitive-path lists are module constants; only `homeDir` varies, and in practice it is one
|
|
136
|
+
* value for the life of the process. Resolving all ~25 of them (null-strip, NFKC-normalize,
|
|
137
|
+
* expand, normalize) on every single guarded read/write was pure repeated work, so the resolved
|
|
138
|
+
* table is memoized per home directory.
|
|
139
|
+
*/
|
|
140
|
+
const sensitivePathTables = new Map();
|
|
141
|
+
function getSensitivePathTable(homeDir) {
|
|
142
|
+
const cached = sensitivePathTables.get(homeDir);
|
|
143
|
+
if (cached) {
|
|
144
|
+
return cached;
|
|
145
|
+
}
|
|
146
|
+
const table = {
|
|
147
|
+
homePrefixes: HOME_SENSITIVE_PREFIXES.map((item) => resolveHomeConfiguredPath(item, homeDir)),
|
|
148
|
+
homeFiles: HOME_SENSITIVE_FILES.map((item) => resolveHomeConfiguredPath(item, homeDir)),
|
|
149
|
+
writeDenyHomeFiles: WRITE_DENY_HOME_FILES.map((item) => resolveHomeConfiguredPath(item, homeDir)),
|
|
150
|
+
};
|
|
151
|
+
sensitivePathTables.set(homeDir, table);
|
|
152
|
+
return table;
|
|
153
|
+
}
|
|
154
|
+
/** Path-independent, so resolved once at module load. */
|
|
155
|
+
const SENSITIVE_SYSTEM_PREFIXES = SYSTEM_SENSITIVE_PREFIXES.map((item) => normalize(item));
|
|
156
|
+
const SENSITIVE_SYSTEM_FILES = SYSTEM_SENSITIVE_FILES.map((item) => normalize(item));
|
|
157
|
+
const NORMALIZED_SYSTEM_DENY_PREFIXES = SYSTEM_DENY_PREFIXES.map((prefix) => normalize(prefix));
|
|
158
|
+
const NORMALIZED_TEMP_PREFIXES = TEMP_PREFIXES.map((prefix) => normalize(prefix));
|
|
115
159
|
function matchesSensitiveReadPath(path, homeDir) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
const sensitiveSystemPrefixes = SYSTEM_SENSITIVE_PREFIXES.map((item) => normalize(item));
|
|
119
|
-
const sensitiveSystemFiles = SYSTEM_SENSITIVE_FILES.map((item) => normalize(item));
|
|
120
|
-
if (matchesAnyPath(path, sensitiveHomeFiles, sensitiveHomePrefixes)) {
|
|
160
|
+
const table = getSensitivePathTable(homeDir);
|
|
161
|
+
if (matchesAnyPath(path, table.homeFiles, table.homePrefixes)) {
|
|
121
162
|
return true;
|
|
122
163
|
}
|
|
123
|
-
if (matchesAnyPath(path,
|
|
164
|
+
if (matchesAnyPath(path, SENSITIVE_SYSTEM_FILES, SENSITIVE_SYSTEM_PREFIXES)) {
|
|
124
165
|
return true;
|
|
125
166
|
}
|
|
126
167
|
if (PROC_MEM_PATH.test(path)) {
|
|
@@ -137,16 +178,29 @@ function matchesSensitiveWritePath(path, homeDir) {
|
|
|
137
178
|
if (matchesSensitiveReadPath(path, homeDir)) {
|
|
138
179
|
return true;
|
|
139
180
|
}
|
|
140
|
-
|
|
141
|
-
return writeDenyHomeFiles.includes(path);
|
|
181
|
+
return getSensitivePathTable(homeDir).writeDenyHomeFiles.includes(path);
|
|
142
182
|
}
|
|
143
|
-
|
|
144
|
-
|
|
183
|
+
/**
|
|
184
|
+
* Resolving the runtime temp directory costs an `existsSync` plus a `realpathSync` walk, and
|
|
185
|
+
* `isWithinTemp` is consulted up to twice per guarded path. `tmpdir()` reads TMPDIR/TEMP each
|
|
186
|
+
* time, so the cache is keyed on it: an env change still takes effect, it just stops paying for
|
|
187
|
+
* the syscalls on every tool call.
|
|
188
|
+
*/
|
|
189
|
+
let tempPrefixCache = null;
|
|
190
|
+
function getTempPrefixes() {
|
|
145
191
|
const runtimeTmpDir = normalize(tmpdir());
|
|
192
|
+
if (tempPrefixCache?.tmpDir === runtimeTmpDir) {
|
|
193
|
+
return tempPrefixCache.prefixes;
|
|
194
|
+
}
|
|
146
195
|
const runtimePrefixes = existsSync(runtimeTmpDir)
|
|
147
196
|
? [runtimeTmpDir, resolveExistingAncestor(runtimeTmpDir)]
|
|
148
197
|
: [runtimeTmpDir];
|
|
149
|
-
|
|
198
|
+
const prefixes = [...NORMALIZED_TEMP_PREFIXES, ...runtimePrefixes];
|
|
199
|
+
tempPrefixCache = { tmpDir: runtimeTmpDir, prefixes };
|
|
200
|
+
return prefixes;
|
|
201
|
+
}
|
|
202
|
+
function isWithinTemp(path) {
|
|
203
|
+
return getTempPrefixes().some((prefix) => startsWithPathPrefix(path, prefix));
|
|
150
204
|
}
|
|
151
205
|
function isWithinHome(path, homeDir) {
|
|
152
206
|
return startsWithPathPrefix(path, normalize(homeDir));
|
|
@@ -158,8 +212,12 @@ function isDeniedSystemPath(path) {
|
|
|
158
212
|
if (isWithinTemp(path)) {
|
|
159
213
|
return false;
|
|
160
214
|
}
|
|
161
|
-
return
|
|
215
|
+
return NORMALIZED_SYSTEM_DENY_PREFIXES.some((prefix) => startsWithPathPrefix(path, prefix));
|
|
162
216
|
}
|
|
217
|
+
// Deliberately not cached: a configured allow/deny entry may not exist yet, and `resolveForGuard`
|
|
218
|
+
// resolves a missing path through its nearest existing ancestor. Caching that would freeze the
|
|
219
|
+
// pre-creation answer, so a path later created as a symlink would stop being resolved to its
|
|
220
|
+
// target. Both lists are empty by default, so this costs nothing unless the operator opts in.
|
|
163
221
|
function matchesConfiguredPath(path, entries, ctx) {
|
|
164
222
|
return entries
|
|
165
223
|
.map((entry) => resolveForGuard(resolveConfiguredPath(entry, ctx), ctx))
|
|
@@ -190,8 +248,8 @@ export function guardPath(rawPath, operation, ctx) {
|
|
|
190
248
|
const homeDir = ctx.homeDir ?? homedir();
|
|
191
249
|
const effectiveCtx = {
|
|
192
250
|
...ctx,
|
|
193
|
-
workspaceDir:
|
|
194
|
-
homeDir:
|
|
251
|
+
workspaceDir: resolveRootForGuard(ctx.workspaceDir, ctx),
|
|
252
|
+
homeDir: resolveRootForGuard(homeDir, ctx),
|
|
195
253
|
};
|
|
196
254
|
const resolvedTarget = resolveTargetPath(rawPath, ctx);
|
|
197
255
|
const guardedPath = resolveForGuard(resolvedTarget, ctx);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort attempt to open a URL in the user's default browser. Never
|
|
3
|
+
* throws or rejects — a login flow must keep working (via the printed URL)
|
|
4
|
+
* even on a headless server with no browser available.
|
|
5
|
+
*/
|
|
6
|
+
export declare function openBrowser(url: string): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* Best-effort attempt to open a URL in the user's default browser. Never
|
|
4
|
+
* throws or rejects — a login flow must keep working (via the printed URL)
|
|
5
|
+
* even on a headless server with no browser available.
|
|
6
|
+
*/
|
|
7
|
+
export function openBrowser(url) {
|
|
8
|
+
try {
|
|
9
|
+
const platform = process.platform;
|
|
10
|
+
const command = platform === "darwin" ? "open" : platform === "win32" ? "cmd" : "xdg-open";
|
|
11
|
+
const args = platform === "win32" ? ["/c", "start", '""', url] : [url];
|
|
12
|
+
const child = spawn(command, args, { stdio: "ignore", detached: true });
|
|
13
|
+
child.on("error", () => {
|
|
14
|
+
// No browser available (headless server, missing xdg-open, etc). The
|
|
15
|
+
// caller already printed the URL, so this is silently swallowed.
|
|
16
|
+
});
|
|
17
|
+
child.unref();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Never let a browser-launch failure interrupt the login flow.
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Throw a plain `Error` instead when the user genuinely has to act or know:
|
|
12
12
|
* - a security guard refused the call (the user may need to adjust security.json),
|
|
13
|
-
* - progress needs a human decision
|
|
13
|
+
* - progress needs a human decision outside the model's current task scope,
|
|
14
14
|
* - state is corrupt and needs manual repair,
|
|
15
15
|
* - the tool itself broke (I/O failure, a bug).
|
|
16
16
|
*
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Throw a plain `Error` instead when the user genuinely has to act or know:
|
|
12
12
|
* - a security guard refused the call (the user may need to adjust security.json),
|
|
13
|
-
* - progress needs a human decision
|
|
13
|
+
* - progress needs a human decision outside the model's current task scope,
|
|
14
14
|
* - state is corrupt and needs manual repair,
|
|
15
15
|
* - the tool itself broke (I/O failure, a bug).
|
|
16
16
|
*
|
package/dist/subagents/tool.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync, statSync } from "node:fs";
|
|
|
2
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
4
4
|
import { Agent } from "@earendil-works/pi-agent-core";
|
|
5
|
+
import { streamSimple } from "@earendil-works/pi-ai/compat";
|
|
5
6
|
import { convertToLlm } from "@earendil-works/pi-coding-agent";
|
|
6
7
|
import { Type } from "typebox";
|
|
7
8
|
import { getChannelHistoryPath, getChannelMemoryPath, getChannelSessionPath, readChannelSession, } from "../memory/files.js";
|
|
@@ -475,6 +476,7 @@ export function createSubAgentTool(options) {
|
|
|
475
476
|
},
|
|
476
477
|
convertToLlm,
|
|
477
478
|
getApiKey: async () => apiKey,
|
|
479
|
+
streamFn: streamSimple,
|
|
478
480
|
});
|
|
479
481
|
const childController = new AbortController();
|
|
480
482
|
const unlinkAbortSignals = linkAbortSignals(signal, childController);
|
package/dist/tasks/control.d.ts
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
export type TaskPriority = "low" | "normal" | "high" | "critical";
|
|
2
|
-
/**
|
|
3
|
-
* Whether the task may touch systems outside the workspace. Only `external` carries machine
|
|
4
|
-
* semantics (it gates the approval chain); the former `read-only`/`workspace` split had no
|
|
5
|
-
* enforcement anywhere and is read back as `workspace`.
|
|
6
|
-
*/
|
|
7
|
-
export type TaskSideEffects = "workspace" | "external";
|
|
8
2
|
export type TaskVerificationStatus = "pending" | "passed" | "failed";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* (attempt claim/finish and governor escalation) — never by a `task_manage` action or a
|
|
12
|
-
* `/tasks` command, so it cannot drift into a second state machine alongside `status`.
|
|
13
|
-
*/
|
|
3
|
+
export type TaskWaitingFor = "time" | "user" | "job" | "verification" | "external-signal";
|
|
4
|
+
/** How the last agent run ended. This is telemetry, not a lifecycle state. */
|
|
14
5
|
export type TaskOutcome = "pending" | "running" | "progress" | "blocked" | "failed";
|
|
15
|
-
/** Who paused a task: a user via /tasks pause, or the deterministic governor (ex-`escalated`). */
|
|
16
|
-
export type TaskPausedBy = "user" | "governor";
|
|
17
|
-
/**
|
|
18
|
-
* The single per-task stop-loss (spec 036, D1).
|
|
19
|
-
*
|
|
20
|
-
* Token / cost / wall-time budgets were removed: they are per-task per-cycle, while spend is
|
|
21
|
-
* global — fifty individually-compliant tasks still burn through a monthly budget. Cost control
|
|
22
|
-
* belongs in a global spend guard, not here. `usage` below still *measures* all four dimensions;
|
|
23
|
-
* only the enforcement was dropped.
|
|
24
|
-
*/
|
|
25
6
|
export interface TaskBudget {
|
|
26
7
|
maxAttempts: number;
|
|
27
8
|
}
|
|
@@ -33,88 +14,78 @@ export interface TaskUsage {
|
|
|
33
14
|
costKnown: boolean;
|
|
34
15
|
wallTimeMinutes: number;
|
|
35
16
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Independent acceptance state (spec 036, D5).
|
|
38
|
-
*
|
|
39
|
-
* There used to be two shapes here, `mode: "evidence" | "independent"`. The `evidence` half was
|
|
40
|
-
* the maker writing `status: "passed"` about its own work at `done` time, duplicating the
|
|
41
|
-
* Summary/Evidence already appended to the task body — a record, not a check. Only the
|
|
42
|
-
* independent form ever verified anything, so `mode` collapsed to a single boolean: does closing
|
|
43
|
-
* this task require a separate verifier's attestation?
|
|
44
|
-
*
|
|
45
|
-
* Dropping the second shape also removed five contradictory defaults for it (create said
|
|
46
|
-
* evidence, body rendering and the disk parser said independent).
|
|
47
|
-
*/
|
|
48
17
|
export interface TaskVerification {
|
|
49
|
-
/** True ⇒ `done` requires a matching attestation on disk from a `purpose=verify` sub-agent. */
|
|
50
18
|
required: boolean;
|
|
51
19
|
status: TaskVerificationStatus;
|
|
52
20
|
runId?: string;
|
|
53
21
|
evidence?: string;
|
|
54
|
-
/**
|
|
55
|
-
* Hash of the task's *contract* segment, not the whole body (see `taskBodyHash`). The key
|
|
56
|
-
* keeps its historical name: renaming it would make every stored task's recorded PASS
|
|
57
|
-
* unreadable and force a re-verify, which is not worth a naming fix.
|
|
58
|
-
*/
|
|
22
|
+
/** Hash of the task contract segment inspected by the verifier. */
|
|
59
23
|
bodyHash?: string;
|
|
60
24
|
checkedAt?: string;
|
|
61
|
-
/** Git view of the artifacts the verifier inspected
|
|
25
|
+
/** Git view of the artifacts the verifier inspected. */
|
|
62
26
|
subjectHash?: string;
|
|
63
27
|
}
|
|
28
|
+
export interface TaskStop {
|
|
29
|
+
by: "user" | "governor";
|
|
30
|
+
reason: string;
|
|
31
|
+
at: string;
|
|
32
|
+
}
|
|
33
|
+
export interface TaskProvenance {
|
|
34
|
+
createdBy?: string;
|
|
35
|
+
createdAt?: string;
|
|
36
|
+
sourceMessageId?: string;
|
|
37
|
+
}
|
|
38
|
+
/** The v2 persisted control block. Execution authority comes from capability and scope. */
|
|
64
39
|
export interface TaskControl {
|
|
65
|
-
version:
|
|
40
|
+
version: 2;
|
|
66
41
|
priority: TaskPriority;
|
|
67
42
|
deadline?: string;
|
|
68
43
|
nextAction?: string;
|
|
69
|
-
lastOutcome: TaskOutcome;
|
|
70
44
|
blockedReason?: string;
|
|
71
|
-
|
|
72
|
-
externalApproval: "not-required" | "required" | "granted";
|
|
73
|
-
approvalBy?: string;
|
|
74
|
-
approvedAt?: string;
|
|
75
|
-
approvalBodyHash?: string;
|
|
45
|
+
waitingFor?: TaskWaitingFor;
|
|
76
46
|
budget: TaskBudget;
|
|
77
|
-
/** Usage in the current recurring cycle (or the full one-shot task). */
|
|
78
47
|
usage: TaskUsage;
|
|
79
48
|
verification: TaskVerification;
|
|
80
|
-
/** Monotonic claim identity; prevents an older failed dispatch from releasing a newer claim. */
|
|
81
49
|
attemptGeneration: number;
|
|
50
|
+
lastOutcome: TaskOutcome;
|
|
82
51
|
lastStartedAt?: string;
|
|
83
52
|
lastFinishedAt?: string;
|
|
84
|
-
/**
|
|
53
|
+
/** Current or most recently closed recurring occurrence. */
|
|
85
54
|
cycleId?: string;
|
|
86
|
-
/** Present only while
|
|
87
|
-
|
|
55
|
+
/** Present only while the task is disabled. */
|
|
56
|
+
stop?: TaskStop;
|
|
57
|
+
provenance?: TaskProvenance;
|
|
88
58
|
}
|
|
89
59
|
export interface TaskControlPatch {
|
|
90
60
|
priority?: TaskPriority;
|
|
91
61
|
deadline?: string;
|
|
92
62
|
nextAction?: string;
|
|
93
63
|
blockedReason?: string;
|
|
94
|
-
|
|
95
|
-
externalApproval?: "not-required" | "required" | "granted";
|
|
64
|
+
waitingFor?: TaskWaitingFor;
|
|
96
65
|
maxAttempts?: number;
|
|
97
|
-
/** Whether closing this task requires an independent verifier attestation (spec 036, D5). */
|
|
98
66
|
verificationRequired?: boolean;
|
|
99
67
|
}
|
|
100
68
|
export declare const TASK_PRIORITIES: readonly TaskPriority[];
|
|
101
69
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* Ignoring them keeps stored tasks readable with no migration script, but silence would be
|
|
105
|
-
* wrong for `parent`/`dependsOn`: the task survives, the ordering constraint it expressed does
|
|
106
|
-
* not. `/tasks doctor` reports whatever a stored control block still carries so the loss is
|
|
107
|
-
* visible rather than silent.
|
|
70
|
+
* Keys from the v1 control block that this version deliberately retires. They remain visible to
|
|
71
|
+
* doctor until the next successful write, but they never enter the v2 control object.
|
|
108
72
|
*/
|
|
109
73
|
export declare const RETIRED_TASK_CONTROL_KEYS: readonly string[];
|
|
110
|
-
/** Retired keys actually present in a raw stored control block
|
|
74
|
+
/** Retired keys actually present in a raw stored control block. */
|
|
111
75
|
export declare function retiredTaskControlKeys(raw: unknown): string[];
|
|
112
|
-
export declare function createDefaultTaskControl(requiresVerification?: boolean): TaskControl;
|
|
76
|
+
export declare function createDefaultTaskControl(requiresVerification?: boolean, provenance?: TaskProvenance): TaskControl;
|
|
77
|
+
/**
|
|
78
|
+
* Read both v1 and v2 files. Retired v1 policy fields are intentionally ignored; the next
|
|
79
|
+
* write emits a v2 object without them. This is a reader migration, not command compatibility.
|
|
80
|
+
*/
|
|
113
81
|
export declare function parseTaskControl(raw: string): TaskControl;
|
|
114
|
-
/** Reset state
|
|
82
|
+
/** Reset state that is meaningful only within one recurring task cycle. */
|
|
115
83
|
export declare function resetTaskControlForCycle(control: TaskControl, cycleId: string): TaskControl;
|
|
116
84
|
export declare function applyTaskControlPatch(control: TaskControl, patch: TaskControlPatch): TaskControl;
|
|
117
85
|
export declare function taskPriorityRank(priority: TaskPriority): number;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Return a deterministic governance violation for a live task. Sleeping tasks have no current
|
|
88
|
+
* work, so neither a deadline nor an attempt budget may stop them. Waiting tasks are subject to
|
|
89
|
+
* their deadline but do not spend attempt budget while parked.
|
|
90
|
+
*/
|
|
91
|
+
export declare function taskBudgetViolation(control: TaskControl, nowMs: number, status?: "active" | "waiting" | "sleeping"): string | undefined;
|