@oyasmi/pipiclaw 0.8.3 → 0.8.4

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.
@@ -2,6 +2,7 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync
2
2
  import { join } from "path";
3
3
  import { formatUnknownCommandMessage, isRunnerBuiltInCommand, parseBuiltInCommand, slashCommandName, } from "../agent/commands.js";
4
4
  import { getOrCreateRunner } from "../agent/index.js";
5
+ import { loadDetachedMaintenanceContext } from "../agent/maintenance-context.js";
5
6
  import { resetRunner } from "../agent/runner-factory.js";
6
7
  import { renderStatus } from "../agent/status-render.js";
7
8
  import { createExecutor } from "../executor.js";
@@ -15,7 +16,7 @@ import { formatConfigDiagnostic } from "../shared/config-diagnostics.js";
15
16
  import { readActiveTasks } from "../shared/task-ledger.js";
16
17
  import { errorMessage } from "../shared/text-utils.js";
17
18
  import { finishTaskAttempt } from "../tasks/store.js";
18
- import { loadToolsConfigWithDiagnostics } from "../tools/config.js";
19
+ import { loadToolsConfig, loadToolsConfigWithDiagnostics } from "../tools/config.js";
19
20
  import { getUsageLedger } from "../usage/ledger.js";
20
21
  import { parseUsageMode, renderUsageReport } from "../usage/render.js";
21
22
  import { ensureChannelDir, getChannelDir } from "./channel-paths.js";
@@ -128,6 +129,9 @@ const TOOLS_CONFIG_TEMPLATE = {
128
129
  maxResults: 5,
129
130
  },
130
131
  },
132
+ tasks: {
133
+ enabled: true,
134
+ },
131
135
  },
132
136
  _examples: {
133
137
  proxy: "http://127.0.0.1:7890",
@@ -137,6 +141,7 @@ const TOOLS_CONFIG_TEMPLATE = {
137
141
  "Set tools.web.enable to true to register web_search and web_fetch.",
138
142
  "Replace tools.web.search.apiKey with your Brave API key before enabling web tools.",
139
143
  "If needed, copy _examples.proxy to tools.web.proxy.",
144
+ "tools.tasks.enabled is the master switch for autonomous long-running tasks (task_manage tool + task driver + task digest).",
140
145
  ],
141
146
  };
142
147
  const SECURITY_CONFIG_TEMPLATE = {
@@ -380,13 +385,13 @@ function waitForTasks(tasks, timeoutMs) {
380
385
  }),
381
386
  ]);
382
387
  }
383
- function flushInactiveChannelMemory(channelStates) {
388
+ function flushInactiveChannelMemory(channelRunners) {
384
389
  const flushes = [];
385
- for (const [channelId, state] of channelStates) {
386
- if (state.running) {
390
+ for (const [channelId, runner] of channelRunners) {
391
+ if (runner.isBusy()) {
387
392
  continue;
388
393
  }
389
- flushes.push(state.runner.flushMemoryForShutdown().catch((err) => {
394
+ flushes.push(runner.flushMemoryForShutdown().catch((err) => {
390
395
  log.logWarning(`[${channelId}] Failed to flush memory during shutdown`, errorMessage(err));
391
396
  }));
392
397
  }
@@ -403,7 +408,7 @@ export function createRuntimeContext(options) {
403
408
  log.configureLogging(runtimeSettingsManager.getLoggingSettings());
404
409
  const startedAt = Date.now();
405
410
  const cliVersion = readCliVersion();
406
- const channelStates = new Map();
411
+ const channelRunners = new Map();
407
412
  const activeTasks = new Set();
408
413
  let durableDispatch;
409
414
  let shuttingDown = false;
@@ -416,34 +421,29 @@ export function createRuntimeContext(options) {
416
421
  log.logWarning(`[${channelId}] Failed to archive ${contextLabel}`, errorMessage(err));
417
422
  }
418
423
  };
419
- const getState = (channelId) => {
420
- let state = channelStates.get(channelId);
421
- if (!state) {
424
+ const getRunner = (channelId) => {
425
+ let runner = channelRunners.get(channelId);
426
+ if (!runner) {
422
427
  const channelDir = ensureChannelDir(options.paths.workspaceDir, channelId);
423
428
  ensureChannelMemoryFilesSync(channelDir);
424
- state = {
425
- running: false,
426
- runner: getOrCreateRunner(channelId, channelDir, {
427
- appHomeDir: options.paths.appHomeDir,
428
- authConfigPath: options.paths.authConfigPath,
429
- modelsConfigPath: options.paths.modelsConfigPath,
430
- }),
431
- stopRequested: false,
432
- };
433
- channelStates.set(channelId, state);
429
+ runner = getOrCreateRunner(channelId, channelDir, {
430
+ appHomeDir: options.paths.appHomeDir,
431
+ authConfigPath: options.paths.authConfigPath,
432
+ modelsConfigPath: options.paths.modelsConfigPath,
433
+ });
434
+ channelRunners.set(channelId, runner);
434
435
  }
435
- return state;
436
+ return runner;
436
437
  };
437
438
  const handler = {
438
439
  isRunning(channelId) {
439
- const state = channelStates.get(channelId);
440
- return state?.running ?? false;
440
+ return channelRunners.get(channelId)?.isBusy() ?? false;
441
441
  },
442
442
  async handleStop(channelId, _bot) {
443
- const state = channelStates.get(channelId);
444
- if (state?.running) {
445
- state.stopRequested = true;
446
- const taskId = /^\[TASK_DRIVER:([A-Za-z0-9._-]+)\]/.exec(state.currentTaskText ?? "")?.[1];
443
+ const runner = channelRunners.get(channelId);
444
+ if (runner?.isBusy()) {
445
+ runner.requestStop();
446
+ const taskId = /^\[TASK_DRIVER:([A-Za-z0-9._-]+)\]/.exec(runner.getTurnStatus().taskText ?? "")?.[1];
447
447
  if (taskId) {
448
448
  const pauseResult = await pauseTask({
449
449
  args: "",
@@ -463,7 +463,7 @@ export function createRuntimeContext(options) {
463
463
  if (canceled) {
464
464
  log.logInfo(`[${channelId}] Reset ${canceled} durable-dispatch lease(s) on stop`);
465
465
  }
466
- void state.runner.abort().catch((err) => {
466
+ void runner.abort().catch((err) => {
467
467
  log.logWarning(`[${channelId}] Failed to abort run`, errorMessage(err));
468
468
  });
469
469
  log.logInfo(`[${channelId}] Stop requested`);
@@ -496,7 +496,7 @@ export function createRuntimeContext(options) {
496
496
  },
497
497
  async handleStatusCommand(event, bot) {
498
498
  const response = renderStatus({
499
- state: channelStates.get(event.channelId),
499
+ runner: channelRunners.get(event.channelId),
500
500
  version: cliVersion,
501
501
  uptimeMs: Date.now() - startedAt,
502
502
  });
@@ -510,7 +510,7 @@ export function createRuntimeContext(options) {
510
510
  if (shuttingDown) {
511
511
  return { kind: "handled" };
512
512
  }
513
- const state = getState(event.channelId);
513
+ const runner = getRunner(event.channelId);
514
514
  const trimmedQueueText = queueText.trim();
515
515
  if (!trimmedQueueText) {
516
516
  const commandName = mode === "followUp" ? "followup" : "steer";
@@ -522,7 +522,7 @@ export function createRuntimeContext(options) {
522
522
  return { kind: "requeue", text: trimmedQueueText };
523
523
  }
524
524
  try {
525
- await state.runner.queueSteer(trimmedQueueText, event.userName);
525
+ await runner.queueSteer(trimmedQueueText, event.userName);
526
526
  await archiveIncomingMessage(event.channelId, {
527
527
  date: new Date().toISOString(),
528
528
  ts: event.ts,
@@ -556,14 +556,13 @@ export function createRuntimeContext(options) {
556
556
  log.logInfo(`[${event.channelId}] Ignoring event during shutdown`);
557
557
  return;
558
558
  }
559
- const state = getState(event.channelId);
560
- // Mark running synchronously, before yielding to the async task body.
559
+ const runner = getRunner(event.channelId);
560
+ // Reserve the turn synchronously, before yielding to the async task body.
561
561
  // The channel queue invokes this handler's synchronous prefix within the
562
- // same tick as dispatch, so setting it here closes the window where a
563
- // second message arriving in the same tick saw running=false and was
564
- // routed as a fresh run instead of a steer/follow-up.
565
- state.running = true;
566
- state.stopRequested = false;
562
+ // same tick as dispatch, so beginning the turn here closes the window
563
+ // where a second message arriving in the same tick saw an idle runner and
564
+ // was routed as a fresh run instead of a steer/follow-up.
565
+ runner.beginTurn(event.text);
567
566
  await durableDispatch?.markStarted(event.dispatchId);
568
567
  const task = (async () => {
569
568
  try {
@@ -596,24 +595,23 @@ export function createRuntimeContext(options) {
596
595
  return;
597
596
  }
598
597
  if (isRunnerBuiltInCommand(builtInCommand)) {
599
- await state.runner.handleBuiltinCommand(ctx, builtInCommand);
598
+ await runner.handleBuiltinCommand(ctx, builtInCommand);
600
599
  }
601
600
  return;
602
601
  }
603
602
  // Reject an unknown slash command instead of spending a full LLM turn
604
603
  // letting the model guess what `/modle` meant. Session commands,
605
604
  // skills, and prompt templates are recognized by isKnownSlashCommand.
606
- if (event.text.trim().startsWith("/") && !state.runner.isKnownSlashCommand(event.text)) {
605
+ if (event.text.trim().startsWith("/") && !runner.isKnownSlashCommand(event.text)) {
607
606
  const name = slashCommandName(event.text) ?? "";
608
607
  await bot.sendPlain(event.channelId, formatUnknownCommandMessage(name));
609
608
  return;
610
609
  }
611
610
  log.logInfo(`[${event.channelId}] Starting run: ${event.text.substring(0, 50)}`);
612
- state.currentTaskText = event.text;
613
611
  if (!_isEvent) {
614
612
  ctx.primeCard(350);
615
613
  }
616
- const result = await state.runner.run(ctx, store);
614
+ const result = await runner.run(ctx, store);
617
615
  const taskDriverMatch = /^\[TASK_DRIVER:([A-Za-z0-9._-]+)\]/.exec(event.text);
618
616
  if (taskDriverMatch?.[1] && result.usage && result.durationMs !== undefined) {
619
617
  await finishTaskAttempt(getChannelDir(options.paths.workspaceDir, event.channelId), taskDriverMatch[1], {
@@ -624,7 +622,7 @@ export function createRuntimeContext(options) {
624
622
  finishedAt: new Date(),
625
623
  });
626
624
  }
627
- if (result.stopReason === "aborted" && state.stopRequested) {
625
+ if (result.stopReason === "aborted" && runner.getTurnStatus().stopRequested) {
628
626
  log.logInfo(`[${event.channelId}] Stopped`);
629
627
  }
630
628
  }
@@ -633,8 +631,7 @@ export function createRuntimeContext(options) {
633
631
  }
634
632
  finally {
635
633
  await durableDispatch?.markCompleted(event.dispatchId);
636
- state.running = false;
637
- state.currentTaskText = undefined;
634
+ runner.endTurn();
638
635
  }
639
636
  })();
640
637
  activeTasks.add(task);
@@ -662,9 +659,26 @@ export function createRuntimeContext(options) {
662
659
  : new MemoryMaintenanceScheduler({
663
660
  appHomeDir: options.paths.appHomeDir,
664
661
  workspaceDir: options.paths.workspaceDir,
665
- getKnownChannelIds: () => channelStates.keys(),
666
- getRuntimeContext: async (channelId) => getState(channelId).runner.getMemoryMaintenanceContext(),
667
- isChannelActive: (channelId) => channelStates.get(channelId)?.running ?? false,
662
+ getKnownChannelIds: () => channelRunners.keys(),
663
+ // Channels active this boot reuse their runner's in-memory context; every
664
+ // other discovered channel gets a lightweight disk-backed context instead
665
+ // of resurrecting a full ChannelRunner (session, tools, sub-agents) that
666
+ // would then sit in the runner cache forever.
667
+ getRuntimeContext: async (channelId) => {
668
+ const runner = channelRunners.get(channelId);
669
+ if (runner) {
670
+ return runner.getMemoryMaintenanceContext();
671
+ }
672
+ return loadDetachedMaintenanceContext({
673
+ channelId,
674
+ channelDir: getChannelDir(options.paths.workspaceDir, channelId),
675
+ workspaceDir: options.paths.workspaceDir,
676
+ authConfigPath: options.paths.authConfigPath,
677
+ modelsConfigPath: options.paths.modelsConfigPath,
678
+ settingsManager: runtimeSettingsManager,
679
+ });
680
+ },
681
+ isChannelActive: (channelId) => channelRunners.get(channelId)?.isBusy() ?? false,
668
682
  getSettings: () => {
669
683
  runtimeSettingsManager.reload();
670
684
  return {
@@ -680,13 +694,14 @@ export function createRuntimeContext(options) {
680
694
  ? options.createTaskDriver()
681
695
  : new TaskDriver({
682
696
  workspaceDir: options.paths.workspaceDir,
683
- getKnownChannelIds: () => channelStates.keys(),
684
- isChannelActive: (channelId) => channelStates.get(channelId)?.running ?? false,
697
+ getKnownChannelIds: () => channelRunners.keys(),
698
+ isChannelActive: (channelId) => channelRunners.get(channelId)?.isBusy() ?? false,
685
699
  dispatch: (event) => durableDispatch?.dispatch(event) ?? false,
686
700
  getSettings: () => {
687
701
  runtimeSettingsManager.reload();
688
702
  return runtimeSettingsManager.getTaskDriverSettings();
689
703
  },
704
+ isEnabled: () => loadToolsConfig(options.paths.appHomeDir).tools.tasks.enabled,
690
705
  intervalMs: options.taskDriverIntervalMs,
691
706
  });
692
707
  const shutdownWithReason = async (reason = "manual") => {
@@ -708,12 +723,12 @@ export function createRuntimeContext(options) {
708
723
  if (!completed) {
709
724
  log.logWarning(`Shutdown grace period exceeded ${SHUTDOWN_WAIT_MS}ms, aborting active runs`);
710
725
  const aborts = [];
711
- for (const [channelId, state] of channelStates) {
712
- if (!state.running)
726
+ for (const [channelId, runner] of channelRunners) {
727
+ if (!runner.isBusy())
713
728
  continue;
714
- state.stopRequested = true;
729
+ runner.requestStop();
715
730
  log.logInfo(`[${channelId}] Aborting active run for shutdown`);
716
- aborts.push(state.runner.abort().catch((err) => {
731
+ aborts.push(runner.abort().catch((err) => {
717
732
  log.logWarning(`[${channelId}] Failed to abort run during shutdown`, errorMessage(err));
718
733
  }));
719
734
  }
@@ -727,7 +742,7 @@ export function createRuntimeContext(options) {
727
742
  }
728
743
  }
729
744
  }
730
- const flushes = flushInactiveChannelMemory(channelStates);
745
+ const flushes = flushInactiveChannelMemory(channelRunners);
731
746
  if (flushes.length > 0) {
732
747
  log.logInfo(`Flushing memory for ${flushes.length} inactive channel(s) before shutdown`);
733
748
  const flushed = await waitForTasks(flushes, SHUTDOWN_FLUSH_WAIT_MS);
@@ -735,7 +750,7 @@ export function createRuntimeContext(options) {
735
750
  log.logWarning(`Shutdown memory flush exceeded ${SHUTDOWN_FLUSH_WAIT_MS}ms`);
736
751
  }
737
752
  }
738
- for (const channelId of channelStates.keys()) {
753
+ for (const channelId of channelRunners.keys()) {
739
754
  const channelDir = ensureChannelDir(options.paths.workspaceDir, channelId);
740
755
  resetRunner(channelId, {
741
756
  appHomeDir: options.paths.appHomeDir,
@@ -0,0 +1,17 @@
1
+ export type QueuedWork = () => Promise<void>;
2
+ /**
3
+ * The per-channel turn serialization point: a channel processes one inbound
4
+ * message at a time; later arrivals wait here. This is runtime policy, not a
5
+ * transport detail — DingTalk consumes it via `DingTalkBot`; busy-state itself
6
+ * is owned by the runner's turn state machine (`AgentRunner.beginTurn`).
7
+ */
8
+ export declare class ChannelQueue {
9
+ private queue;
10
+ private processing;
11
+ private stopped;
12
+ enqueue(work: QueuedWork): void;
13
+ size(): number;
14
+ private processNext;
15
+ stop(): void;
16
+ clearPending(): number;
17
+ }
@@ -0,0 +1,50 @@
1
+ import * as log from "../log.js";
2
+ import { errorMessage } from "../shared/text-utils.js";
3
+ /**
4
+ * The per-channel turn serialization point: a channel processes one inbound
5
+ * message at a time; later arrivals wait here. This is runtime policy, not a
6
+ * transport detail — DingTalk consumes it via `DingTalkBot`; busy-state itself
7
+ * is owned by the runner's turn state machine (`AgentRunner.beginTurn`).
8
+ */
9
+ export class ChannelQueue {
10
+ constructor() {
11
+ this.queue = [];
12
+ this.processing = false;
13
+ this.stopped = false;
14
+ }
15
+ enqueue(work) {
16
+ if (this.stopped)
17
+ return;
18
+ this.queue.push(work);
19
+ this.processNext();
20
+ }
21
+ size() {
22
+ return this.queue.length;
23
+ }
24
+ async processNext() {
25
+ if (this.processing || this.stopped || this.queue.length === 0)
26
+ return;
27
+ this.processing = true;
28
+ const work = this.queue.shift();
29
+ try {
30
+ await work();
31
+ }
32
+ catch (err) {
33
+ log.logWarning("Queue error", errorMessage(err));
34
+ }
35
+ this.processing = false;
36
+ this.processNext();
37
+ }
38
+ stop() {
39
+ this.stopped = true;
40
+ this.queue = [];
41
+ }
42
+ // Drop not-yet-started work without disabling the queue. Used by /stop so a
43
+ // burst of queued messages does not keep running after the user asked to halt.
44
+ // The in-flight item (already shifted) is unaffected; the caller aborts it.
45
+ clearPending() {
46
+ const dropped = this.queue.length;
47
+ this.queue = [];
48
+ return dropped;
49
+ }
50
+ }
@@ -16,6 +16,9 @@ import * as log from "../log.js";
16
16
  import { errorMessage } from "../shared/text-utils.js";
17
17
  import { isRecord } from "../shared/type-guards.js";
18
18
  import { getChannelDir } from "./channel-paths.js";
19
+ // Turn serialization is runtime policy; the queue lives in its own module and
20
+ // this transport only consumes it.
21
+ import { ChannelQueue } from "./channel-queue.js";
19
22
  const RESPONSE_MODE_VALUES = [
20
23
  "full_progress_then_plain_final",
21
24
  "rolling_progress_then_plain_final",
@@ -58,48 +61,6 @@ export function normalizeResponseMode(value) {
58
61
  }
59
62
  throw new Error('Invalid `responseMode`: expected "full_progress_then_plain_final", "rolling_progress_then_plain_final", or "final_card_only".');
60
63
  }
61
- class ChannelQueue {
62
- constructor() {
63
- this.queue = [];
64
- this.processing = false;
65
- this.stopped = false;
66
- }
67
- enqueue(work) {
68
- if (this.stopped)
69
- return;
70
- this.queue.push(work);
71
- this.processNext();
72
- }
73
- size() {
74
- return this.queue.length;
75
- }
76
- async processNext() {
77
- if (this.processing || this.stopped || this.queue.length === 0)
78
- return;
79
- this.processing = true;
80
- const work = this.queue.shift();
81
- try {
82
- await work();
83
- }
84
- catch (err) {
85
- log.logWarning("Queue error", errorMessage(err));
86
- }
87
- this.processing = false;
88
- this.processNext();
89
- }
90
- stop() {
91
- this.stopped = true;
92
- this.queue = [];
93
- }
94
- // Drop not-yet-started work without disabling the queue. Used by /stop so a
95
- // burst of queued messages does not keep running after the user asked to halt.
96
- // The in-flight item (already shifted) is unaffected; the caller aborts it.
97
- clearPending() {
98
- const dropped = this.queue.length;
99
- this.queue = [];
100
- return dropped;
101
- }
102
- }
103
64
  // ============================================================================
104
65
  // Constants
105
66
  // ============================================================================
@@ -7,6 +7,8 @@ export interface TaskDriverOptions {
7
7
  isChannelActive: (channelId: string) => boolean;
8
8
  dispatch: (event: DingTalkEvent) => boolean | Promise<boolean>;
9
9
  getSettings: () => PipiclawTaskDriverSettings;
10
+ /** Master autonomy switch (`tools.tasks.enabled`); re-read every tick. Defaults to on. */
11
+ isEnabled?: () => boolean;
10
12
  intervalMs?: number;
11
13
  }
12
14
  export declare function discoverTaskChannels(workspaceDir: string, knownChannelIds?: Iterable<string>): Promise<string[]>;
@@ -1,15 +1,12 @@
1
- import { readdir, readFile } from "node:fs/promises";
1
+ import { readdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import * as log from "../log.js";
4
4
  import { PLAYBOOKS_DIR } from "../paths.js";
5
- import { taskEventName } from "../shared/task-events.js";
6
5
  import { readActiveTasks } from "../shared/task-ledger.js";
7
6
  import { errorMessage } from "../shared/text-utils.js";
8
7
  import { taskBudgetViolation } from "../tasks/control.js";
9
8
  import { claimTaskAttempt, dependencyState, escalateTask, releaseTaskAttemptClaim } from "../tasks/store.js";
10
- import { parseScheduledEventContent } from "./events.js";
11
9
  const DEFAULT_SCAN_INTERVAL_MS = 60_000;
12
- const LEGACY_CHECKIN_HANDOFF_GRACE_MS = 2 * 60_000;
13
10
  const CHANNEL_ID_PATTERN = /^(dm|group)_[A-Za-z0-9._:-]+$/;
14
11
  function isChannelId(value) {
15
12
  return CHANNEL_ID_PATTERN.test(value);
@@ -59,20 +56,6 @@ function isEligible(attempt, fingerprint, nowMs, settings) {
59
56
  const delayMinutes = changed || !attempt.accepted ? settings.continuationDelayMinutes : settings.stalledRetryMinutes;
60
57
  return nowMs - attempt.atMs >= delayMinutes * 60_000;
61
58
  }
62
- async function hasLiveLegacyCheckin(workspaceDir, channelId, taskId, nowMs) {
63
- const name = taskEventName(channelId, taskId, "checkin");
64
- const path = join(workspaceDir, "events", `${name}.json`);
65
- try {
66
- const event = parseScheduledEventContent(await readFile(path, "utf-8"), `${name}.json`);
67
- if (event.type !== "one-shot")
68
- return false;
69
- const atMs = new Date(event.at).getTime();
70
- return Number.isFinite(atMs) && atMs >= nowMs - LEGACY_CHECKIN_HANDOFF_GRACE_MS;
71
- }
72
- catch {
73
- return false;
74
- }
75
- }
76
59
  export function createTaskDriverEvent(channelId, entry, nowMs) {
77
60
  const verification = entry.frontmatter.control?.verification;
78
61
  const verificationInstruction = entry.frontmatter.status === "verifying"
@@ -161,9 +144,9 @@ export class TaskDriver {
161
144
  this.timer = null;
162
145
  }
163
146
  async runOnce(now = new Date()) {
164
- const settings = this.options.getSettings();
165
- if (!settings.enabled || this.running)
147
+ if (this.options.isEnabled?.() === false || this.running)
166
148
  return;
149
+ const settings = this.options.getSettings();
167
150
  this.running = true;
168
151
  try {
169
152
  const channels = await discoverTaskChannels(this.options.workspaceDir, this.options.getKnownChannelIds?.());
@@ -228,12 +211,6 @@ export class TaskDriver {
228
211
  }
229
212
  if (!entry || dispatched >= settings.maxDispatchesPerTick)
230
213
  continue;
231
- // Upgrade compatibility: while a legacy task-owned one-shot is still
232
- // about to deliver this same wake, let it own the handoff. Once it is
233
- // consumed (or stale for >2m), the native driver becomes the recovery path.
234
- if (await hasLiveLegacyCheckin(this.options.workspaceDir, channelId, entry.id, now.getTime())) {
235
- continue;
236
- }
237
214
  const key = attemptKey(channelId, entry.id);
238
215
  let fingerprint = await taskFingerprint(channelDir, entry);
239
216
  if (!isEligible(this.attempts.get(key), fingerprint, now.getTime(), settings))
@@ -61,13 +61,10 @@ export interface PipiclawMemoryRecallSettings {
61
61
  rerankWithModel: boolean | "auto";
62
62
  }
63
63
  export interface PipiclawTaskDigestSettings {
64
- enabled: boolean;
65
64
  maxTasks: number;
66
65
  maxChars: number;
67
66
  }
68
67
  export interface PipiclawTaskDriverSettings {
69
- /** Native runtime wake-up for actionable task-ledger entries. */
70
- enabled: boolean;
71
68
  /** Earliest continuation after a task changed during its previous run. */
72
69
  continuationDelayMinutes: number;
73
70
  /** Retry delay when a dispatched task made no observable ledger progress. */
package/dist/settings.js CHANGED
@@ -32,7 +32,6 @@ const DEFAULT_MEMORY_RECALL = {
32
32
  // Cheap and high-value: reading a handful of task frontmatters and always surfacing
33
33
  // the in-flight agenda is worth more than the tokens it costs, so it defaults on.
34
34
  const DEFAULT_TASK_DIGEST = {
35
- enabled: true,
36
35
  maxTasks: 8,
37
36
  maxChars: 1000,
38
37
  };
@@ -40,7 +39,6 @@ const DEFAULT_TASK_DIGEST = {
40
39
  // that requires users to install a heartbeat event and sensor script. A changed
41
40
  // task can continue promptly; an unchanged task backs off to avoid token loops.
42
41
  const DEFAULT_TASK_DRIVER = {
43
- enabled: true,
44
42
  continuationDelayMinutes: 5,
45
43
  stalledRetryMinutes: 60,
46
44
  maxDispatchesPerTick: 4,
@@ -204,7 +202,6 @@ export class PipiclawSettingsManager {
204
202
  ? Math.min(20, Math.max(1, Math.floor(configured.maxDispatchesPerTick)))
205
203
  : DEFAULT_TASK_DRIVER.maxDispatchesPerTick;
206
204
  return {
207
- enabled: configured.enabled !== false,
208
205
  continuationDelayMinutes,
209
206
  stalledRetryMinutes,
210
207
  maxDispatchesPerTick,
@@ -25,31 +25,15 @@ export interface PipiclawWebToolsConfig {
25
25
  export interface PipiclawToolsConfig {
26
26
  tools: {
27
27
  web: PipiclawWebToolsConfig;
28
- memory: {
29
- sessionSearch: {
30
- enabled: boolean;
31
- };
32
- save: {
33
- enabled: boolean;
34
- };
35
- };
36
- skills: {
37
- manage: {
38
- enabled: boolean;
39
- };
40
- };
41
- events: {
42
- enabled: boolean;
43
- };
28
+ /**
29
+ * Master switch for the autonomous long-running task mechanism: gates the
30
+ * `task_manage` tool, the native TaskDriver, and the per-turn task digest
31
+ * together. Core capabilities (read/bash/edit/write/grep, memory, skills,
32
+ * events, background jobs) are always on and have no switches.
33
+ */
44
34
  tasks: {
45
35
  enabled: boolean;
46
36
  };
47
- grep: {
48
- enabled: boolean;
49
- };
50
- jobs: {
51
- enabled: boolean;
52
- };
53
37
  bashInterceptor: {
54
38
  enabled: boolean;
55
39
  };
@@ -26,31 +26,9 @@ export const DEFAULT_TOOLS_CONFIG = {
26
26
  defaultExtractMode: "markdown",
27
27
  },
28
28
  },
29
- memory: {
30
- sessionSearch: {
31
- enabled: true,
32
- },
33
- save: {
34
- enabled: true,
35
- },
36
- },
37
- skills: {
38
- manage: {
39
- enabled: true,
40
- },
41
- },
42
- events: {
43
- enabled: true,
44
- },
45
29
  tasks: {
46
30
  enabled: true,
47
31
  },
48
- grep: {
49
- enabled: true,
50
- },
51
- jobs: {
52
- enabled: true,
53
- },
54
32
  bashInterceptor: {
55
33
  enabled: true,
56
34
  },
@@ -100,15 +78,7 @@ function mergeToolsConfig(source, configPath, diagnostics) {
100
78
  }
101
79
  const tools = isRecord(source.tools) ? source.tools : {};
102
80
  const web = isRecord(tools.web) ? tools.web : {};
103
- const memory = isRecord(tools.memory) ? tools.memory : {};
104
- const sessionSearch = isRecord(memory.sessionSearch) ? memory.sessionSearch : {};
105
- const memorySave = isRecord(memory.save) ? memory.save : {};
106
- const skills = isRecord(tools.skills) ? tools.skills : {};
107
- const manage = isRecord(skills.manage) ? skills.manage : {};
108
- const events = isRecord(tools.events) ? tools.events : {};
109
81
  const tasks = isRecord(tools.tasks) ? tools.tasks : {};
110
- const grep = isRecord(tools.grep) ? tools.grep : {};
111
- const jobs = isRecord(tools.jobs) ? tools.jobs : {};
112
82
  const bashInterceptor = isRecord(tools.bashInterceptor) ? tools.bashInterceptor : {};
113
83
  const rtk = isRecord(tools.rtk) ? tools.rtk : {};
114
84
  const search = isRecord(web.search) ? web.search : {};
@@ -175,37 +145,9 @@ function mergeToolsConfig(source, configPath, diagnostics) {
175
145
  : DEFAULT_TOOLS_CONFIG.tools.web.fetch.defaultExtractMode,
176
146
  },
177
147
  },
178
- memory: {
179
- sessionSearch: {
180
- enabled: typeof sessionSearch.enabled === "boolean"
181
- ? sessionSearch.enabled
182
- : DEFAULT_TOOLS_CONFIG.tools.memory.sessionSearch.enabled,
183
- },
184
- save: {
185
- enabled: typeof memorySave.enabled === "boolean"
186
- ? memorySave.enabled
187
- : DEFAULT_TOOLS_CONFIG.tools.memory.save.enabled,
188
- },
189
- },
190
- skills: {
191
- manage: {
192
- enabled: typeof manage.enabled === "boolean"
193
- ? manage.enabled
194
- : DEFAULT_TOOLS_CONFIG.tools.skills.manage.enabled,
195
- },
196
- },
197
- events: {
198
- enabled: typeof events.enabled === "boolean" ? events.enabled : DEFAULT_TOOLS_CONFIG.tools.events.enabled,
199
- },
200
148
  tasks: {
201
149
  enabled: typeof tasks.enabled === "boolean" ? tasks.enabled : DEFAULT_TOOLS_CONFIG.tools.tasks.enabled,
202
150
  },
203
- grep: {
204
- enabled: typeof grep.enabled === "boolean" ? grep.enabled : DEFAULT_TOOLS_CONFIG.tools.grep.enabled,
205
- },
206
- jobs: {
207
- enabled: typeof jobs.enabled === "boolean" ? jobs.enabled : DEFAULT_TOOLS_CONFIG.tools.jobs.enabled,
208
- },
209
151
  bashInterceptor: {
210
152
  enabled: typeof bashInterceptor.enabled === "boolean"
211
153
  ? bashInterceptor.enabled