@oyasmi/pipiclaw 0.9.1-beta.1 → 0.9.1-beta.2

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.
Files changed (49) hide show
  1. package/dist/agent/channel-runner.d.ts +0 -1
  2. package/dist/agent/channel-runner.js +0 -2
  3. package/dist/agent/runner-factory.d.ts +0 -2
  4. package/dist/memory/task-digest.js +0 -2
  5. package/dist/playbooks/agent-delegation.md +3 -2
  6. package/dist/playbooks/task-driving.md +11 -13
  7. package/dist/playbooks/task-planning.md +3 -5
  8. package/dist/runtime/bootstrap.d.ts +1 -1
  9. package/dist/runtime/bootstrap.js +13 -49
  10. package/dist/runtime/channel-event.d.ts +0 -6
  11. package/dist/runtime/task-commands.d.ts +1 -1
  12. package/dist/runtime/task-commands.js +33 -174
  13. package/dist/runtime/task-driver.d.ts +1 -3
  14. package/dist/runtime/task-driver.js +34 -40
  15. package/dist/runtime/task-migration.d.ts +7 -6
  16. package/dist/runtime/task-migration.js +85 -19
  17. package/dist/runtime/task-wake.d.ts +3 -5
  18. package/dist/runtime/task-wake.js +7 -15
  19. package/dist/subagents/external/run.js +18 -1
  20. package/dist/subagents/runs.js +22 -3
  21. package/dist/subagents/tool.d.ts +10 -0
  22. package/dist/subagents/tool.js +32 -7
  23. package/dist/subagents/verification-outcome.js +17 -10
  24. package/dist/tasks/control.d.ts +18 -67
  25. package/dist/tasks/control.js +44 -176
  26. package/dist/tasks/ledger.d.ts +7 -13
  27. package/dist/tasks/ledger.js +13 -49
  28. package/dist/tasks/store.d.ts +15 -48
  29. package/dist/tasks/store.js +22 -154
  30. package/dist/tasks/transitions.d.ts +3 -4
  31. package/dist/tasks/transitions.js +8 -27
  32. package/dist/tools/index.d.ts +0 -2
  33. package/dist/tools/index.js +2 -1
  34. package/dist/tools/registry.d.ts +0 -1
  35. package/dist/tools/registry.js +0 -1
  36. package/dist/tools/subagent-manage.d.ts +8 -1
  37. package/dist/tools/subagent-manage.js +77 -7
  38. package/dist/tools/task-manage/lifecycle.js +19 -17
  39. package/dist/tools/task-manage/schema.d.ts +2 -6
  40. package/dist/tools/task-manage/schema.js +4 -17
  41. package/dist/tools/task-manage/shared.js +1 -6
  42. package/dist/tools/task-manage/types.d.ts +0 -3
  43. package/dist/tools/task-manage/verification.d.ts +9 -6
  44. package/dist/tools/task-manage/verification.js +19 -71
  45. package/dist/tools/task-manage.d.ts +1 -1
  46. package/dist/tools/task-manage.js +2 -4
  47. package/dist/usage/ledger.d.ts +4 -0
  48. package/dist/usage/ledger.js +3 -0
  49. package/package.json +1 -1
@@ -3,22 +3,12 @@ import { SETTABLE_TASK_STATUSES } from "../../tasks/transitions.js";
3
3
  import { RecoverableToolError } from "../tool-details.js";
4
4
  export const SETTABLE_STATUSES = SETTABLE_TASK_STATUSES;
5
5
  const taskControlSchema = Type.Object({
6
- priority: Type.Optional(Type.Union([Type.Literal("low"), Type.Literal("normal"), Type.Literal("high"), Type.Literal("critical")])),
7
6
  deadline: Type.Optional(Type.String({
8
7
  description: "Local time deadline, e.g. 2026-07-27T18:00:00+08:00 (host timezone if no offset given); empty string clears it.",
9
8
  })),
10
9
  nextAction: Type.Optional(Type.String({ description: "Concrete next executable step; empty string clears it." })),
11
- blockedReason: Type.Optional(Type.String({ description: "Why work cannot currently proceed; empty clears it." })),
12
- waitingFor: Type.Optional(Type.Union([
13
- Type.Literal("time"),
14
- Type.Literal("user"),
15
- Type.Literal("job"),
16
- Type.Literal("verification"),
17
- Type.Literal("external-signal"),
18
- ], { description: "Diagnostic recovery source; it does not create a new lifecycle status." })),
19
- maxAttempts: Type.Optional(Type.Integer({
20
- minimum: 1,
21
- description: "Attempt stop-loss; the only per-task budget. Default 12, spent over the whole task (recurring: per cycle) — raise it on create for long multi-step work.",
10
+ waitingFor: Type.Optional(Type.Union([Type.Literal("time"), Type.Literal("user"), Type.Literal("job"), Type.Literal("external-signal")], {
11
+ description: "Diagnostic recovery source; it does not create a new lifecycle status.",
22
12
  })),
23
13
  verificationRequired: Type.Optional(Type.Boolean({
24
14
  description: "Whether complete requires an independent verifier attestation. Default false; set true only when the task produces a checkable artifact (code, config, a runnable command) a read-only verifier sub-agent can inspect.",
@@ -30,14 +20,13 @@ export const taskManageSchema = Type.Object({
30
20
  Type.Literal("create"),
31
21
  Type.Literal("progress"),
32
22
  Type.Literal("set"),
33
- Type.Literal("request-verification"),
34
23
  Type.Literal("verify"),
35
24
  Type.Literal("complete"),
36
25
  Type.Literal("skip"),
37
26
  Type.Literal("cancel"),
38
27
  Type.Literal("list"),
39
28
  ], {
40
- description: '"create" writes a persistent task; "progress" checkpoints work; "request-verification" parks active work and schedules an independent checker; "set" repairs metadata; "verify" imports an attestation; "complete" closes a task; "skip" closes one recurring occurrence without claiming completion; "cancel" archives abandoned work; "list" returns tasks. Recurring tasks sleep between occurrences.',
29
+ description: '"create" writes a persistent task; "progress" checkpoints work — to wait on an independent verifier, dispatch a purpose=verify sub-agent with taskId and park like any other delegation (status=waiting, waitingFor=external-signal); "set" repairs metadata; "verify" imports the verifier\'s attestation by run id; "complete" closes a task; "skip" closes one recurring occurrence without claiming completion; "cancel" archives abandoned work; "list" returns tasks. Recurring tasks sleep between occurrences.',
41
30
  }),
42
31
  id: Type.Optional(Type.String({ description: "Task id (filename without .md). Required for create/progress/set/complete." })),
43
32
  title: Type.Optional(Type.String({ description: "Required for create: task title used as the H1 heading." })),
@@ -74,7 +63,6 @@ export const taskManageSchema = Type.Object({
74
63
  "Changing this on an existing task recomputes wake to the new cadence's next occurrence unless this " +
75
64
  "same call also sets wake explicitly. Recurring creation starts in sleeping and opens cycles at occurrences. Min every 30 minutes.",
76
65
  })),
77
- recurrence: Type.Optional(Type.String({ description: "Human annotation only (e.g. 每周一); empty string clears it." })),
78
66
  note: Type.Optional(Type.String({
79
67
  description: "Required for progress: concise Current Cycle entry covering what changed, evidence observed, and the next step.",
80
68
  })),
@@ -89,7 +77,6 @@ export const taskManageSchema = Type.Object({
89
77
  export function parseAction(action) {
90
78
  if (action === "create" ||
91
79
  action === "progress" ||
92
- action === "request-verification" ||
93
80
  action === "set" ||
94
81
  action === "verify" ||
95
82
  action === "complete" ||
@@ -98,5 +85,5 @@ export function parseAction(action) {
98
85
  action === "list") {
99
86
  return action;
100
87
  }
101
- throw new RecoverableToolError("Unsupported task action. Next step: use create, progress, request-verification, set, verify, complete, skip, cancel, or list.");
88
+ throw new RecoverableToolError("Unsupported task action. Next step: use create, progress, set, verify, complete, skip, cancel, or list.");
102
89
  }
@@ -59,7 +59,7 @@ export function renderTaskSkeleton(request) {
59
59
  const goal = requiredField(request.goal, "goal", "create");
60
60
  const dod = requiredField(request.dod, "dod", "create");
61
61
  // Independent verification is opt-in: it is a quality fact, not an external-action policy.
62
- const control = applyTaskControlPatch(createDefaultTaskControl(request.control?.verificationRequired ?? false, { createdAt: formatLocalTime() }), request.control ?? {});
62
+ const control = applyTaskControlPatch(createDefaultTaskControl(request.control?.verificationRequired ?? false), request.control ?? {});
63
63
  const fields = applySet({ status: normalizeCreateStatus(request.status), enabled: true, control }, request);
64
64
  if (!fields.schedule && fields.status === "sleeping") {
65
65
  throw new RecoverableToolError('A one-shot task cannot use status "sleeping"; create it as active or waiting.');
@@ -108,7 +108,6 @@ export async function readTaskDocument(taskPath, id, allowControlRepair = false)
108
108
  enabled: frontmatter.enabled,
109
109
  wake: frontmatter.wake,
110
110
  schedule: frontmatter.schedule,
111
- recurrence: frontmatter.recurrence,
112
111
  // A successful task_manage write upgrades a hand-written/v0 task to the v2
113
112
  // control contract instead of preserving an ungoverned task indefinitely.
114
113
  control: frontmatter.control ?? createDefaultTaskControl(),
@@ -177,10 +176,6 @@ export function applySet(fields, request) {
177
176
  }
178
177
  }
179
178
  }
180
- if (request.recurrence !== undefined) {
181
- const trimmed = request.recurrence.trim();
182
- next.recurrence = trimmed === "" ? undefined : trimmed;
183
- }
184
179
  if (request.control !== undefined) {
185
180
  next.control = applyTaskControlPatch(next.control ?? createDefaultTaskControl(), request.control);
186
181
  }
@@ -43,15 +43,12 @@ export interface TaskManageToolOptions {
43
43
  channelId: string;
44
44
  /** Project checkout whose artifact state an independent verifier binds to. */
45
45
  workingDirectory?: string;
46
- /** Durable checker dispatch supplied by the long-lived runtime. */
47
- dispatchVerification?: (taskId: string) => Promise<boolean>;
48
46
  }
49
47
  export interface TaskFields {
50
48
  status: string;
51
49
  enabled?: boolean;
52
50
  wake?: string;
53
51
  schedule?: string;
54
- recurrence?: string;
55
52
  control?: TaskControl;
56
53
  outcome?: "completed" | "cancelled";
57
54
  closedAt?: string;
@@ -1,16 +1,19 @@
1
- import { type TaskVerification } from "../../tasks/control.js";
2
1
  import { type VerificationAttestation } from "../../tasks/verification.js";
3
2
  import type { TaskManageRequest, TaskManageResult, TaskManageToolOptions } from "./types.js";
4
3
  /**
5
- * Park an active task for an independent checker. The runtime callback creates the durable
6
- * checker dispatch; the task is never placed in a special lifecycle status.
4
+ * Import a verifier's attestation. The task's own lifecycle status is not the authorization
5
+ * check — a real, matching, on-disk attestation for this task id is (spec 040's threat model:
6
+ * the task Markdown is agent-writable and proves nothing). `verify` works whether the task is
7
+ * still `waiting` (e.g. called right after its completion wake reactivated it) or already
8
+ * `active`.
7
9
  */
8
- export declare function requestVerificationTask(options: TaskManageToolOptions, request: TaskManageRequest): Promise<TaskManageResult>;
9
10
  export declare function verifyTask(options: TaskManageToolOptions, request: TaskManageRequest): Promise<TaskManageResult>;
10
11
  /**
11
12
  * `verify` writes control.verification from a real attestation file, but the task Markdown
12
13
  * itself is writable by the agent's own write/edit tools — nothing stops it from hand-crafting
13
14
  * a "passed" verification block that was never backed by a real verifier run. Re-check the
14
- * attestation file on the consuming side (complete/doctor) too, not just at import time.
15
+ * attestation file on the consuming side (complete/doctor) too, not just at import time, and
16
+ * against the task's *current* body hash directly — not a mirrored value the task file could
17
+ * itself have drifted.
15
18
  */
16
- export declare function assertVerificationAttestationMatches(channelDir: string, id: string, verification: TaskVerification): Promise<VerificationAttestation>;
19
+ export declare function assertVerificationAttestationMatches(channelDir: string, id: string, runId: string | undefined, currentBodyHash: string): Promise<VerificationAttestation>;
@@ -1,64 +1,19 @@
1
- import { join } from "node:path";
2
1
  import { writeFileAtomically } from "../../shared/atomic-file.js";
3
- import { errorMessage } from "../../shared/text-utils.js";
4
2
  import { workspaceSubjectHash } from "../../tasks/artifact-subject.js";
5
3
  import { createDefaultTaskControl } from "../../tasks/control.js";
6
- import { appendCurrentCycleNote, normalizeTaskId, uncheckedTaskAcceptanceItems } from "../../tasks/ledger.js";
4
+ import { normalizeTaskId } from "../../tasks/ledger.js";
7
5
  import { readStoredTask, taskBodyHash } from "../../tasks/store.js";
8
6
  import { normalizeStoredStatus, resolveTaskTransition } from "../../tasks/transitions.js";
9
7
  import { readVerificationAttestation } from "../../tasks/verification.js";
10
8
  import { RecoverableToolError } from "../tool-details.js";
11
- import { readTaskDocument, renderTaskFile, requiredField, tasksDir } from "./shared.js";
9
+ import { renderTaskFile, requiredField } from "./shared.js";
12
10
  /**
13
- * Park an active task for an independent checker. The runtime callback creates the durable
14
- * checker dispatch; the task is never placed in a special lifecycle status.
11
+ * Import a verifier's attestation. The task's own lifecycle status is not the authorization
12
+ * check — a real, matching, on-disk attestation for this task id is (spec 040's threat model:
13
+ * the task Markdown is agent-writable and proves nothing). `verify` works whether the task is
14
+ * still `waiting` (e.g. called right after its completion wake reactivated it) or already
15
+ * `active`.
15
16
  */
16
- export async function requestVerificationTask(options, request) {
17
- if (!request.id)
18
- throw new RecoverableToolError('action "request-verification" requires an id.');
19
- const id = normalizeTaskId(request.id);
20
- const note = requiredField(request.note, "note", "request-verification");
21
- const taskPath = join(tasksDir(options), `${id}.md`);
22
- const { fields, body } = await readTaskDocument(taskPath, id);
23
- resolveTaskTransition("request-verification", id, normalizeStoredStatus(fields.status, Boolean(fields.schedule)));
24
- const uncheckedAcceptance = uncheckedTaskAcceptanceItems(body);
25
- if (uncheckedAcceptance.length > 0) {
26
- throw new RecoverableToolError(`Task "${id}" still has unchecked acceptance items: ${uncheckedAcceptance.join("; ")}. Check them with evidence before requesting verification.`);
27
- }
28
- if (!options.dispatchVerification) {
29
- throw new RecoverableToolError(`Task "${id}" cannot enter verification wait because the durable checker is unavailable. Retry request-verification when the runtime can enqueue a checker.`);
30
- }
31
- const originalFields = structuredClone(fields);
32
- const control = fields.control ?? createDefaultTaskControl(true);
33
- control.verification = { required: true, status: "pending" };
34
- control.blockedReason = undefined;
35
- control.waitingFor = "verification";
36
- control.nextAction = "Wait for the durable checker, then import its attestation.";
37
- const waitingFields = { ...fields, status: "waiting", wake: undefined, control };
38
- const nextBody = appendCurrentCycleNote(body, note);
39
- await writeFileAtomically(taskPath, renderTaskFile(waitingFields, nextBody));
40
- let accepted;
41
- try {
42
- accepted = await options.dispatchVerification(id);
43
- }
44
- catch (error) {
45
- await writeFileAtomically(taskPath, renderTaskFile(originalFields, nextBody));
46
- throw new RecoverableToolError(`Could not enqueue the verification checker for task "${id}": ${errorMessage(error)}. The task was restored to active; retry request-verification.`);
47
- }
48
- if (!accepted) {
49
- // Do not leave a signal-waiting task with no signal source. Roll back atomically to active;
50
- // the caller can retry once durable dispatch is available.
51
- await writeFileAtomically(taskPath, renderTaskFile(originalFields, nextBody));
52
- throw new RecoverableToolError(`Could not enqueue the verification checker for task "${id}". The task was restored to active; retry request-verification.`);
53
- }
54
- return {
55
- action: "request-verification",
56
- id,
57
- path: taskPath,
58
- status: "waiting",
59
- notice: `任务 \`${id}\` 已进入独立验收等待;checker 完成后 runtime 会恢复任务。`,
60
- };
61
- }
62
17
  export async function verifyTask(options, request) {
63
18
  if (!request.id)
64
19
  throw new RecoverableToolError('action "verify" requires an id.');
@@ -67,10 +22,7 @@ export async function verifyTask(options, request) {
67
22
  const task = await readStoredTask(options.channelDir, id);
68
23
  if (!task)
69
24
  throw new RecoverableToolError(`Task "${id}" does not exist; create it before verification.`);
70
- resolveTaskTransition("verify", id, normalizeStoredStatus(task.fields.status, Boolean(task.fields.schedule)));
71
- if (task.fields.control?.waitingFor !== "verification") {
72
- throw new RecoverableToolError(`Task "${id}" is not waiting for verification. Request verification first so the checker signal is tied to this task.`);
73
- }
25
+ resolveTaskTransition("verify", id, normalizeStoredStatus(task.fields.status));
74
26
  const attestation = await readVerificationAttestation(options.channelDir, runId);
75
27
  if (attestation.taskId !== id) {
76
28
  throw new RecoverableToolError(`Verification run "${runId}" belongs to task "${attestation.taskId}", not "${id}".`);
@@ -95,13 +47,7 @@ export async function verifyTask(options, request) {
95
47
  required: true,
96
48
  status: attestation.verdict === "pass" ? "passed" : "failed",
97
49
  runId,
98
- evidence: attestation.evidence,
99
- bodyHash: attestation.bodyHash,
100
- subjectHash: attestation.subjectHash,
101
- checkedAt: attestation.checkedAt,
102
50
  };
103
- // The verdict lives in `control.verification`; `lastOutcome` stays runtime-owned telemetry.
104
- control.blockedReason = attestation.verdict === "fail" ? attestation.evidence : undefined;
105
51
  control.waitingFor = undefined;
106
52
  control.nextAction = undefined;
107
53
  task.fields.control = control;
@@ -113,28 +59,30 @@ export async function verifyTask(options, request) {
113
59
  id,
114
60
  path: task.path,
115
61
  status: "active",
116
- notice: `任务 \`${id}\` 独立验收结果:${attestation.verdict.toUpperCase()}(run: ${runId})。`,
62
+ notice: `任务 \`${id}\` 独立验收结果:${attestation.verdict.toUpperCase()}${attestation.verificationStrength === "advisory" ? "(advisory)" : ""}(run: ${runId})。`,
117
63
  };
118
64
  }
119
65
  /**
120
66
  * `verify` writes control.verification from a real attestation file, but the task Markdown
121
67
  * itself is writable by the agent's own write/edit tools — nothing stops it from hand-crafting
122
68
  * a "passed" verification block that was never backed by a real verifier run. Re-check the
123
- * attestation file on the consuming side (complete/doctor) too, not just at import time.
69
+ * attestation file on the consuming side (complete/doctor) too, not just at import time, and
70
+ * against the task's *current* body hash directly — not a mirrored value the task file could
71
+ * itself have drifted.
124
72
  */
125
- export async function assertVerificationAttestationMatches(channelDir, id, verification) {
126
- if (!verification.runId) {
73
+ export async function assertVerificationAttestationMatches(channelDir, id, runId, currentBodyHash) {
74
+ if (!runId) {
127
75
  throw new RecoverableToolError(`Task "${id}" has no verification run id; rerun task_manage verify before complete.`);
128
76
  }
129
- const attestation = await readVerificationAttestation(channelDir, verification.runId);
77
+ const attestation = await readVerificationAttestation(channelDir, runId);
130
78
  if (attestation.taskId !== id) {
131
- throw new RecoverableToolError(`Verification run "${verification.runId}" belongs to task "${attestation.taskId}", not "${id}"; rerun verification.`);
79
+ throw new RecoverableToolError(`Verification run "${runId}" belongs to task "${attestation.taskId}", not "${id}"; rerun verification.`);
132
80
  }
133
81
  if (attestation.verdict !== "pass") {
134
- throw new RecoverableToolError(`Verification run "${verification.runId}" recorded a FAIL, not a PASS; rerun verification.`);
82
+ throw new RecoverableToolError(`Verification run "${runId}" recorded a FAIL, not a PASS; rerun verification.`);
135
83
  }
136
- if (attestation.bodyHash !== verification.bodyHash) {
137
- throw new RecoverableToolError(`Task "${id}" control.verification.bodyHash does not match the attestation for run "${verification.runId}"; rerun task_manage verify.`);
84
+ if (attestation.bodyHash !== currentBodyHash) {
85
+ throw new RecoverableToolError(`Task "${id}" changed since verification run "${runId}"; rerun task_manage verify.`);
138
86
  }
139
87
  return attestation;
140
88
  }
@@ -4,7 +4,7 @@ import type { TaskManageRequest, TaskManageResult, TaskManageToolOptions } from
4
4
  export type { TaskManageAction, TaskManageRequest, TaskManageResult, TaskManageToolOptions, } from "./task-manage/types.js";
5
5
  /**
6
6
  * The `task_manage` dispatcher. Each action lives in a focused module — `create`,
7
- * `lifecycle` (progress/set/complete/skip/cancel/list) and `verification` (request-verification/verify) — over a
7
+ * `lifecycle` (progress/set/complete/skip/cancel/list) and `verification` (verify) — over a
8
8
  * shared helper layer, with the status transition table in `src/tasks/transitions.ts` (spec
9
9
  * 029, D7). This entry only routes and wraps the tool.
10
10
  */
@@ -3,10 +3,10 @@ import { withTaskMutation } from "../tasks/mutation-lock.js";
3
3
  import { createTask } from "./task-manage/create.js";
4
4
  import { cancelTask, completeTask, listTasks, progressTask, setTask, skipTask } from "./task-manage/lifecycle.js";
5
5
  import { parseAction, taskManageSchema } from "./task-manage/schema.js";
6
- import { requestVerificationTask, verifyTask } from "./task-manage/verification.js";
6
+ import { verifyTask } from "./task-manage/verification.js";
7
7
  /**
8
8
  * The `task_manage` dispatcher. Each action lives in a focused module — `create`,
9
- * `lifecycle` (progress/set/complete/skip/cancel/list) and `verification` (request-verification/verify) — over a
9
+ * `lifecycle` (progress/set/complete/skip/cancel/list) and `verification` (verify) — over a
10
10
  * shared helper layer, with the status transition table in `src/tasks/transitions.ts` (spec
11
11
  * 029, D7). This entry only routes and wraps the tool.
12
12
  */
@@ -24,8 +24,6 @@ function dispatchTaskMutation(options, request) {
24
24
  return createTask(options, request);
25
25
  case "progress":
26
26
  return progressTask(options, request);
27
- case "request-verification":
28
- return requestVerificationTask(options, request);
29
27
  case "set":
30
28
  return setTask(options, request);
31
29
  case "verify":
@@ -23,6 +23,8 @@ export interface UsageLedgerEntry {
23
23
  correlationId?: string;
24
24
  /** Idempotency key for a delegation run's usage entry (spec 040, D7); absent for turn/sidecar kinds. */
25
25
  runId?: string;
26
+ /** Task this spend is attributable to, when known. Lets `/usage` answer "what did this task cost". */
27
+ taskId?: string;
26
28
  usage: UsageTokens;
27
29
  cost: UsageCost;
28
30
  /** False only when the harness cannot report tokens at all (external `exec`). Display as "unknown", not 0. */
@@ -38,6 +40,8 @@ export interface UsageSummary {
38
40
  byKind: Record<string, number>;
39
41
  byModel: Record<string, number>;
40
42
  byChannel: Record<string, number>;
43
+ /** Only populated for entries carrying a `taskId`; unattributed spend is absent, not bucketed. */
44
+ byTask: Record<string, number>;
41
45
  /** Entries with `usageKnown === false` (e.g. the `exec` harness never reports tokens at all).
42
46
  * Their `usage.total` is always 0 and never contributes to `totalTokens` — display this count
43
47
  * rather than let those runs silently read as "0 tokens used". */
@@ -102,6 +102,7 @@ export function createUsageLedger(options = {}) {
102
102
  byKind: {},
103
103
  byModel: {},
104
104
  byChannel: {},
105
+ byTask: {},
105
106
  unknownUsageCount: 0,
106
107
  unknownCostCount: 0,
107
108
  };
@@ -119,6 +120,8 @@ export function createUsageLedger(options = {}) {
119
120
  summary.byKind[entry.kind] = (summary.byKind[entry.kind] ?? 0) + cost;
120
121
  summary.byModel[entry.model] = (summary.byModel[entry.model] ?? 0) + cost;
121
122
  summary.byChannel[entry.channelId] = (summary.byChannel[entry.channelId] ?? 0) + cost;
123
+ if (entry.taskId)
124
+ summary.byTask[entry.taskId] = (summary.byTask[entry.taskId] ?? 0) + cost;
122
125
  // `undefined` (every entry recorded before this field existed) counts as known —
123
126
  // backward compatibility for a ledger that predates this distinction.
124
127
  if (entry.usageKnown === false)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oyasmi/pipiclaw",
3
- "version": "0.9.1-beta.1",
3
+ "version": "0.9.1-beta.2",
4
4
  "description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
5
5
  "type": "module",
6
6
  "bin": {