opencode-matrixx 2.6.5 → 2.6.7

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 (54) hide show
  1. package/dist/agents/oracle/behavioral-summary.d.ts +1 -1
  2. package/dist/agents/oracle/high-accuracy-mode.d.ts +1 -1
  3. package/dist/agents/oracle/interview-mode.d.ts +1 -1
  4. package/dist/agents/oracle/plan-generation.d.ts +1 -1
  5. package/dist/agents/oracle/plan-template.d.ts +1 -1
  6. package/dist/agents/oracle/system-prompt.d.ts +1 -1
  7. package/dist/cli.js +65 -10
  8. package/dist/config/schema/background-task.d.ts +37 -0
  9. package/dist/config/schema/dcp.d.ts +46 -0
  10. package/dist/config/schema/hooks.d.ts +1 -0
  11. package/dist/config/schema/matrixx-config.d.ts +33 -0
  12. package/dist/create-hooks.d.ts +1 -0
  13. package/dist/features/background-agent/admission.d.ts +24 -0
  14. package/dist/features/background-agent/concurrency.d.ts +9 -0
  15. package/dist/features/background-agent/constants.d.ts +13 -0
  16. package/dist/features/background-agent/handle-index.d.ts +75 -0
  17. package/dist/features/background-agent/handle-index.test.d.ts +1 -0
  18. package/dist/features/background-agent/index.d.ts +1 -0
  19. package/dist/features/background-agent/manager-handles.test.d.ts +1 -0
  20. package/dist/features/background-agent/manager.d.ts +69 -2
  21. package/dist/features/background-agent/notification-builder.d.ts +1 -0
  22. package/dist/features/background-agent/reconcile.d.ts +33 -0
  23. package/dist/features/background-agent/revive.d.ts +39 -0
  24. package/dist/features/background-agent/session-output.d.ts +40 -0
  25. package/dist/features/background-agent/task-history.d.ts +20 -0
  26. package/dist/features/background-agent/types.d.ts +21 -1
  27. package/dist/features/background-agent/wake-scheduler.d.ts +47 -0
  28. package/dist/features/background-agent/wallclock.d.ts +37 -0
  29. package/dist/features/bdd/schema.d.ts +5 -5
  30. package/dist/hooks/background-task-blocker/hook.d.ts +10 -0
  31. package/dist/hooks/background-task-blocker/index.d.ts +1 -0
  32. package/dist/hooks/context-mode-enforcer/constants.d.ts +1 -1
  33. package/dist/hooks/index.d.ts +1 -0
  34. package/dist/index.js +2037 -620
  35. package/dist/matrixx.schema.json +166 -3
  36. package/dist/plugin/hooks/create-core-hooks.d.ts +1 -0
  37. package/dist/plugin/hooks/create-tool-guard-hooks.d.ts +2 -1
  38. package/dist/plugin-handlers/agent-config-handler.d.ts +2 -1
  39. package/dist/shared/context-mode-enforcement.d.ts +35 -0
  40. package/dist/shared/index.d.ts +1 -0
  41. package/dist/shared/revive-outcome.d.ts +15 -0
  42. package/dist/shared/saturated-outcome.d.ts +18 -0
  43. package/dist/shared/wallclock-outcome.d.ts +18 -0
  44. package/dist/tools/background-task/constants.d.ts +1 -1
  45. package/dist/tools/background-task/create-background-revive.d.ts +3 -0
  46. package/dist/tools/background-task/index.d.ts +1 -1
  47. package/dist/tools/background-task/tools.d.ts +1 -1
  48. package/dist/tools/background-task/types.d.ts +9 -5
  49. package/dist/tools/dcp-switch-profile/tools.d.ts +1 -0
  50. package/dist/tools/delegate-task/sync-task.test.d.ts +1 -0
  51. package/dist/tools/delegate-task/timing.test.d.ts +1 -0
  52. package/dist/tools/index.d.ts +1 -1
  53. package/package.json +1 -1
  54. package/dist/tools/background-task/create-background-task.d.ts +0 -3
package/dist/cli.js CHANGED
@@ -15787,6 +15787,20 @@ var CircuitBreakerConfigSchema = exports_external.object({
15787
15787
  maxToolCalls: exports_external.number().int().min(10).optional(),
15788
15788
  consecutiveThreshold: exports_external.number().int().min(5).optional()
15789
15789
  });
15790
+ var NestedAdmissionConfigSchema = exports_external.object({
15791
+ enabled: exports_external.boolean().optional(),
15792
+ mode: exports_external.enum(["bypass", "reserve"]).optional(),
15793
+ maxDepth: exports_external.number().int().min(1).max(5).optional()
15794
+ });
15795
+ var WakeSchedulerConfigSchema = exports_external.object({
15796
+ enabled: exports_external.boolean().optional(),
15797
+ intervalMs: exports_external.number().min(60000).optional()
15798
+ });
15799
+ var JobBoardConfigSchema = exports_external.object({
15800
+ enabled: exports_external.boolean().optional(),
15801
+ strategy: exports_external.enum(["latest", "checkpoint-compatible"]).optional(),
15802
+ maxRetainedSnapshots: exports_external.number().int().min(1).max(100).optional()
15803
+ });
15790
15804
  var BackgroundTaskConfigSchema = exports_external.object({
15791
15805
  defaultConcurrency: exports_external.number().min(1).optional(),
15792
15806
  providerConcurrency: exports_external.record(exports_external.string(), exports_external.number().min(0)).optional(),
@@ -15794,7 +15808,13 @@ var BackgroundTaskConfigSchema = exports_external.object({
15794
15808
  staleTimeoutMs: exports_external.number().min(60000).optional(),
15795
15809
  messageStalenessTimeoutMs: exports_external.number().min(60000).optional(),
15796
15810
  maxToolCalls: exports_external.number().int().min(10).optional(),
15797
- circuitBreaker: CircuitBreakerConfigSchema.optional()
15811
+ circuitBreaker: CircuitBreakerConfigSchema.optional(),
15812
+ admissionTimeoutMs: exports_external.union([exports_external.literal(0), exports_external.number().min(60000)]).optional(),
15813
+ nestedAdmission: NestedAdmissionConfigSchema.optional(),
15814
+ wakeScheduler: WakeSchedulerConfigSchema.optional(),
15815
+ jobBoard: JobBoardConfigSchema.optional(),
15816
+ wallClockTimeoutMs: exports_external.union([exports_external.literal(0), exports_external.number().int().min(60000).max(2147483647)]).optional(),
15817
+ wallClockAbortGraceMs: exports_external.number().int().min(1000).max(60000).optional()
15798
15818
  });
15799
15819
 
15800
15820
  // src/config/schema/browser-automation.ts
@@ -15873,7 +15893,7 @@ var CommentCheckerConfigSchema = exports_external.object({
15873
15893
  var ContextModeConfigSchema = exports_external.object({
15874
15894
  enabled: exports_external.boolean().default(true),
15875
15895
  enforce: exports_external.boolean().default(false),
15876
- blocked_tools: exports_external.array(exports_external.string()).default(["read", "grep", "glob"])
15896
+ blocked_tools: exports_external.array(exports_external.string()).default(["grep", "glob"])
15877
15897
  });
15878
15898
 
15879
15899
  // src/config/schema/dcp.ts
@@ -15959,12 +15979,37 @@ var BUILTIN_DCP_PROFILES = {
15959
15979
  turnProtection: { enabled: true, turns: 5 },
15960
15980
  experimental: { allowSubAgents: true },
15961
15981
  strategies: { purgeErrors: { turns: 4 } }
15982
+ },
15983
+ brutal: {
15984
+ pruneNotification: "off",
15985
+ compress: {
15986
+ maxContextLimit: "15%",
15987
+ minContextLimit: "10%",
15988
+ nudgeFrequency: 1,
15989
+ nudgeForce: "strong",
15990
+ iterationNudgeThreshold: 1
15991
+ },
15992
+ turnProtection: { enabled: false },
15993
+ experimental: { allowSubAgents: false },
15994
+ strategies: { purgeErrors: { turns: 1 } }
15962
15995
  }
15963
15996
  };
15997
+ var DcpHandoffCompressionSchema = exports_external.object({
15998
+ enabled: exports_external.boolean().default(true),
15999
+ maxMessages: exports_external.number().int().min(1).default(6),
16000
+ keepFirst: exports_external.number().int().min(0).default(2),
16001
+ keepLast: exports_external.number().int().min(0).default(3)
16002
+ });
15964
16003
  var DcpConfigSchema = exports_external.object({
15965
16004
  enabled: exports_external.boolean().default(true),
15966
16005
  profiles: exports_external.record(exports_external.string(), DcpProfileDefinitionSchema).default(BUILTIN_DCP_PROFILES),
15967
16006
  default_profile: exports_external.string().optional(),
16007
+ handoffCompression: DcpHandoffCompressionSchema.default({
16008
+ enabled: true,
16009
+ maxMessages: 6,
16010
+ keepFirst: 2,
16011
+ keepLast: 3
16012
+ }),
15968
16013
  base: exports_external.object({
15969
16014
  autoUpdate: exports_external.boolean().default(false),
15970
16015
  debug: exports_external.boolean().default(false),
@@ -16021,7 +16066,8 @@ var DcpConfigSchema = exports_external.object({
16021
16066
  enabled: false,
16022
16067
  automaticStrategies: true
16023
16068
  }),
16024
- protectedFilePatterns: exports_external.array(exports_external.string()).default([])
16069
+ protectedFilePatterns: exports_external.array(exports_external.string()).default([]),
16070
+ experimental: DcpExperimentalSchema.default({ allowSubAgents: true })
16025
16071
  }).default({
16026
16072
  autoUpdate: false,
16027
16073
  debug: false,
@@ -16042,7 +16088,8 @@ var DcpConfigSchema = exports_external.object({
16042
16088
  },
16043
16089
  commands: { enabled: true, protectedTools: [] },
16044
16090
  manualMode: { enabled: false, automaticStrategies: true },
16045
- protectedFilePatterns: []
16091
+ protectedFilePatterns: [],
16092
+ experimental: { allowSubAgents: true }
16046
16093
  })
16047
16094
  });
16048
16095
 
@@ -16159,6 +16206,7 @@ var HookNameEnum = exports_external.enum([
16159
16206
  "preemptive-compaction",
16160
16207
  "rules-injector",
16161
16208
  "background-notification",
16209
+ "background-task-blocker",
16162
16210
  "auto-update-checker",
16163
16211
  "startup-toast",
16164
16212
  "keyword-detector",
@@ -16233,11 +16281,14 @@ var ModelFallbackEntrySchema = exports_external.object({
16233
16281
  variant: exports_external.string().optional()
16234
16282
  });
16235
16283
  var complexityDowngradeValueSchema = exports_external.string().refine((s) => {
16236
- if (s.includes("/")) {
16237
- const parts = s.split("/");
16238
- return parts.length === 2 && parts[0].length > 0 && parts[1].length > 0;
16239
- }
16240
- return false;
16284
+ if (!s.includes("/"))
16285
+ return false;
16286
+ if (s.startsWith("/") || s.endsWith("/"))
16287
+ return false;
16288
+ if (s.includes("//"))
16289
+ return false;
16290
+ const parts = s.split("/");
16291
+ return parts.length >= 2 && parts.every((p) => p.length > 0);
16241
16292
  }, { message: "Must be <provider>/<model>" });
16242
16293
  var ComplexityDowngradesSchema = exports_external.record(exports_external.string(), exports_external.record(exports_external.string(), complexityDowngradeValueSchema));
16243
16294
  var AgentModelRequirementsSchema = exports_external.object({
@@ -16263,8 +16314,12 @@ var ModelRequirementsSchema = exports_external.object({
16263
16314
  var providerModelSchema = exports_external.string().refine((s) => {
16264
16315
  if (!s.includes("/"))
16265
16316
  return false;
16317
+ if (s.startsWith("/") || s.endsWith("/"))
16318
+ return false;
16319
+ if (s.includes("//"))
16320
+ return false;
16266
16321
  const parts = s.split("/");
16267
- return parts.length === 2 && parts[0].length > 0 && parts[1].length > 0;
16322
+ return parts.length >= 2 && parts.every((p) => p.length > 0);
16268
16323
  }, { message: "Must be <provider>/<model>" });
16269
16324
  var ModelPresetEntrySchema = exports_external.object({
16270
16325
  model: providerModelSchema,
@@ -1,4 +1,18 @@
1
1
  import { z } from "zod";
2
+ /** Idle-parent wake scheduler settings (default ON, default interval 300000ms, minimum 60000ms) */
3
+ export declare const WakeSchedulerConfigSchema: z.ZodObject<{
4
+ enabled: z.ZodOptional<z.ZodBoolean>;
5
+ intervalMs: z.ZodOptional<z.ZodNumber>;
6
+ }, z.core.$strip>;
7
+ /** Job-board snapshot settings (defaults: enabled true, strategy "latest", maxRetainedSnapshots 20) */
8
+ export declare const JobBoardConfigSchema: z.ZodObject<{
9
+ enabled: z.ZodOptional<z.ZodBoolean>;
10
+ strategy: z.ZodOptional<z.ZodEnum<{
11
+ latest: "latest";
12
+ "checkpoint-compatible": "checkpoint-compatible";
13
+ }>>;
14
+ maxRetainedSnapshots: z.ZodOptional<z.ZodNumber>;
15
+ }, z.core.$strip>;
2
16
  export declare const BackgroundTaskConfigSchema: z.ZodObject<{
3
17
  defaultConcurrency: z.ZodOptional<z.ZodNumber>;
4
18
  providerConcurrency: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
@@ -11,5 +25,28 @@ export declare const BackgroundTaskConfigSchema: z.ZodObject<{
11
25
  maxToolCalls: z.ZodOptional<z.ZodNumber>;
12
26
  consecutiveThreshold: z.ZodOptional<z.ZodNumber>;
13
27
  }, z.core.$strip>>;
28
+ admissionTimeoutMs: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodNumber]>>;
29
+ nestedAdmission: z.ZodOptional<z.ZodObject<{
30
+ enabled: z.ZodOptional<z.ZodBoolean>;
31
+ mode: z.ZodOptional<z.ZodEnum<{
32
+ bypass: "bypass";
33
+ reserve: "reserve";
34
+ }>>;
35
+ maxDepth: z.ZodOptional<z.ZodNumber>;
36
+ }, z.core.$strip>>;
37
+ wakeScheduler: z.ZodOptional<z.ZodObject<{
38
+ enabled: z.ZodOptional<z.ZodBoolean>;
39
+ intervalMs: z.ZodOptional<z.ZodNumber>;
40
+ }, z.core.$strip>>;
41
+ jobBoard: z.ZodOptional<z.ZodObject<{
42
+ enabled: z.ZodOptional<z.ZodBoolean>;
43
+ strategy: z.ZodOptional<z.ZodEnum<{
44
+ latest: "latest";
45
+ "checkpoint-compatible": "checkpoint-compatible";
46
+ }>>;
47
+ maxRetainedSnapshots: z.ZodOptional<z.ZodNumber>;
48
+ }, z.core.$strip>>;
49
+ wallClockTimeoutMs: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodNumber]>>;
50
+ wallClockAbortGraceMs: z.ZodOptional<z.ZodNumber>;
14
51
  }, z.core.$strip>;
15
52
  export type BackgroundTaskConfig = z.infer<typeof BackgroundTaskConfigSchema>;
@@ -158,7 +158,44 @@ export declare const BUILTIN_DCP_PROFILES: {
158
158
  };
159
159
  };
160
160
  };
161
+ readonly brutal: {
162
+ readonly pruneNotification: "off";
163
+ readonly compress: {
164
+ readonly maxContextLimit: "15%";
165
+ readonly minContextLimit: "10%";
166
+ readonly nudgeFrequency: 1;
167
+ readonly nudgeForce: "strong";
168
+ readonly iterationNudgeThreshold: 1;
169
+ };
170
+ readonly turnProtection: {
171
+ readonly enabled: false;
172
+ };
173
+ readonly experimental: {
174
+ readonly allowSubAgents: false;
175
+ };
176
+ readonly strategies: {
177
+ readonly purgeErrors: {
178
+ readonly turns: 1;
179
+ };
180
+ };
181
+ };
161
182
  };
183
+ /**
184
+ * Configuration for compressing background task results when sending
185
+ * completion notifications to the parent session (handoff boundary).
186
+ *
187
+ * When enabled, assistant messages beyond `maxMessages` are truncated:
188
+ * the first `keepFirst` and last `keepLast` messages are preserved,
189
+ * with a "[... N messages truncated]" marker inserted between them.
190
+ * This reduces the context cost of notifying the parent session.
191
+ */
192
+ export declare const DcpHandoffCompressionSchema: z.ZodObject<{
193
+ enabled: z.ZodDefault<z.ZodBoolean>;
194
+ maxMessages: z.ZodDefault<z.ZodNumber>;
195
+ keepFirst: z.ZodDefault<z.ZodNumber>;
196
+ keepLast: z.ZodDefault<z.ZodNumber>;
197
+ }, z.core.$strip>;
198
+ export type DcpHandoffCompression = z.infer<typeof DcpHandoffCompressionSchema>;
162
199
  export declare const DcpConfigSchema: z.ZodObject<{
163
200
  enabled: z.ZodDefault<z.ZodBoolean>;
164
201
  profiles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -194,6 +231,12 @@ export declare const DcpConfigSchema: z.ZodObject<{
194
231
  }, z.core.$strip>>;
195
232
  }, z.core.$strip>>>;
196
233
  default_profile: z.ZodOptional<z.ZodString>;
234
+ handoffCompression: z.ZodDefault<z.ZodObject<{
235
+ enabled: z.ZodDefault<z.ZodBoolean>;
236
+ maxMessages: z.ZodDefault<z.ZodNumber>;
237
+ keepFirst: z.ZodDefault<z.ZodNumber>;
238
+ keepLast: z.ZodDefault<z.ZodNumber>;
239
+ }, z.core.$strip>>;
197
240
  base: z.ZodDefault<z.ZodObject<{
198
241
  autoUpdate: z.ZodDefault<z.ZodBoolean>;
199
242
  debug: z.ZodDefault<z.ZodBoolean>;
@@ -240,6 +283,9 @@ export declare const DcpConfigSchema: z.ZodObject<{
240
283
  automaticStrategies: z.ZodDefault<z.ZodBoolean>;
241
284
  }, z.core.$strip>>;
242
285
  protectedFilePatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
286
+ experimental: z.ZodDefault<z.ZodObject<{
287
+ allowSubAgents: z.ZodOptional<z.ZodBoolean>;
288
+ }, z.core.$strip>>;
243
289
  }, z.core.$strip>>;
244
290
  }, z.core.$strip>;
245
291
  export type DcpConfig = z.infer<typeof DcpConfigSchema>;
@@ -20,6 +20,7 @@ export declare const HookNameSchema: z.ZodUnion<readonly [z.ZodEnum<{
20
20
  "preemptive-compaction": "preemptive-compaction";
21
21
  "rules-injector": "rules-injector";
22
22
  "background-notification": "background-notification";
23
+ "background-task-blocker": "background-task-blocker";
23
24
  "auto-update-checker": "auto-update-checker";
24
25
  "startup-toast": "startup-toast";
25
26
  "keyword-detector": "keyword-detector";
@@ -93,6 +93,7 @@ export declare const MatrixxConfigSchema: z.ZodObject<{
93
93
  "preemptive-compaction": "preemptive-compaction";
94
94
  "rules-injector": "rules-injector";
95
95
  "background-notification": "background-notification";
96
+ "background-task-blocker": "background-task-blocker";
96
97
  "auto-update-checker": "auto-update-checker";
97
98
  "startup-toast": "startup-toast";
98
99
  "keyword-detector": "keyword-detector";
@@ -1607,6 +1608,12 @@ export declare const MatrixxConfigSchema: z.ZodObject<{
1607
1608
  }, z.core.$strip>>;
1608
1609
  }, z.core.$strip>>>;
1609
1610
  default_profile: z.ZodOptional<z.ZodString>;
1611
+ handoffCompression: z.ZodDefault<z.ZodObject<{
1612
+ enabled: z.ZodDefault<z.ZodBoolean>;
1613
+ maxMessages: z.ZodDefault<z.ZodNumber>;
1614
+ keepFirst: z.ZodDefault<z.ZodNumber>;
1615
+ keepLast: z.ZodDefault<z.ZodNumber>;
1616
+ }, z.core.$strip>>;
1610
1617
  base: z.ZodDefault<z.ZodObject<{
1611
1618
  autoUpdate: z.ZodDefault<z.ZodBoolean>;
1612
1619
  debug: z.ZodDefault<z.ZodBoolean>;
@@ -1653,6 +1660,9 @@ export declare const MatrixxConfigSchema: z.ZodObject<{
1653
1660
  automaticStrategies: z.ZodDefault<z.ZodBoolean>;
1654
1661
  }, z.core.$strip>>;
1655
1662
  protectedFilePatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
1663
+ experimental: z.ZodDefault<z.ZodObject<{
1664
+ allowSubAgents: z.ZodOptional<z.ZodBoolean>;
1665
+ }, z.core.$strip>>;
1656
1666
  }, z.core.$strip>>;
1657
1667
  }, z.core.$strip>>;
1658
1668
  auto_update: z.ZodOptional<z.ZodBoolean>;
@@ -1700,6 +1710,29 @@ export declare const MatrixxConfigSchema: z.ZodObject<{
1700
1710
  maxToolCalls: z.ZodOptional<z.ZodNumber>;
1701
1711
  consecutiveThreshold: z.ZodOptional<z.ZodNumber>;
1702
1712
  }, z.core.$strip>>;
1713
+ admissionTimeoutMs: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodNumber]>>;
1714
+ nestedAdmission: z.ZodOptional<z.ZodObject<{
1715
+ enabled: z.ZodOptional<z.ZodBoolean>;
1716
+ mode: z.ZodOptional<z.ZodEnum<{
1717
+ bypass: "bypass";
1718
+ reserve: "reserve";
1719
+ }>>;
1720
+ maxDepth: z.ZodOptional<z.ZodNumber>;
1721
+ }, z.core.$strip>>;
1722
+ wakeScheduler: z.ZodOptional<z.ZodObject<{
1723
+ enabled: z.ZodOptional<z.ZodBoolean>;
1724
+ intervalMs: z.ZodOptional<z.ZodNumber>;
1725
+ }, z.core.$strip>>;
1726
+ jobBoard: z.ZodOptional<z.ZodObject<{
1727
+ enabled: z.ZodOptional<z.ZodBoolean>;
1728
+ strategy: z.ZodOptional<z.ZodEnum<{
1729
+ latest: "latest";
1730
+ "checkpoint-compatible": "checkpoint-compatible";
1731
+ }>>;
1732
+ maxRetainedSnapshots: z.ZodOptional<z.ZodNumber>;
1733
+ }, z.core.$strip>>;
1734
+ wallClockTimeoutMs: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodNumber]>>;
1735
+ wallClockAbortGraceMs: z.ZodOptional<z.ZodNumber>;
1703
1736
  }, z.core.$strip>>;
1704
1737
  notification: z.ZodOptional<z.ZodObject<{
1705
1738
  force_enable: z.ZodOptional<z.ZodBoolean>;
@@ -33,6 +33,7 @@ export declare function createHooks(args: {
33
33
  thinkingBlockValidator: ReturnType<typeof import("./hooks").createThinkingBlockValidatorHook> | null;
34
34
  toolPairValidator: ReturnType<typeof import("./hooks").createToolPairValidatorHook> | null;
35
35
  designIntentPreserver: ReturnType<typeof import("./hooks").createDesignIntentPreserverHook> | null;
36
+ backgroundTaskBlocker: ReturnType<typeof import("./hooks").createBackgroundTaskBlockerHook> | null;
36
37
  commentChecker: ReturnType<typeof import("./hooks").createCommentCheckerHooks> | null;
37
38
  toolOutputTruncator: ReturnType<typeof import("./hooks").createToolOutputTruncatorHook> | null;
38
39
  directoryAgentsInjector: ReturnType<typeof import("./hooks").createDirectoryAgentsInjectorHook> | null;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Whether a background launch originates from the root session or from a
3
+ * managed (subagent) session descended from it. Nested launches are exempt
4
+ * from the concurrency semaphore so a saturated managed child cannot deadlock
5
+ * by waiting on its own background work.
6
+ */
7
+ export type AdmissionClass = {
8
+ kind: "root";
9
+ } | {
10
+ kind: "nested";
11
+ depth: number;
12
+ };
13
+ /**
14
+ * Classify a launch whose requesting session is `parentSessionID`.
15
+ *
16
+ * Walks the child→parent session registry using `getParentSessionID`, treating
17
+ * each registered ancestor hop as one level of nesting. Depth is capped at
18
+ * `maxDepth` and reported as actually reached.
19
+ *
20
+ * Fails open to `root` when the requester is absent from the process-local
21
+ * registry (undefined, empty, or unregistered), so a cold start can never
22
+ * misclassify a root launch as nested.
23
+ */
24
+ export declare function classifyAdmission(parentSessionID: string | undefined, maxDepth: number): AdmissionClass;
@@ -1,11 +1,20 @@
1
1
  import type { BackgroundTaskConfig } from "../../config/schema";
2
+ export type AcquireOutcome = {
3
+ granted: true;
4
+ } | {
5
+ granted: false;
6
+ reason: "timeout" | "cancelled";
7
+ waitedMs: number;
8
+ };
2
9
  export declare class ConcurrencyManager {
3
10
  private config?;
4
11
  private counts;
5
12
  private queues;
6
13
  constructor(config?: BackgroundTaskConfig);
7
14
  getConcurrencyLimit(model: string): number;
15
+ private tryAcquireSlot;
8
16
  acquire(model: string): Promise<void>;
17
+ acquireWithDeadline(model: string, timeoutMs?: number): Promise<AcquireOutcome>;
9
18
  release(model: string): void;
10
19
  /**
11
20
  * Cancel all waiting acquires for a model. Used during cleanup.
@@ -12,6 +12,19 @@ export declare const MIN_IDLE_TIME_MS = 5000;
12
12
  export declare const POLLING_INTERVAL_MS = 3000;
13
13
  export declare const PRUNE_THROTTLE_MS = 30000;
14
14
  export declare const TASK_CLEANUP_DELAY_MS: number;
15
+ export declare const DEFAULT_ADMISSION_TIMEOUT_MS = 0;
16
+ export declare const DEFAULT_WALL_CLOCK_TIMEOUT_MS = 0;
17
+ export declare const DEFAULT_WALL_CLOCK_ABORT_GRACE_MS = 5000;
18
+ export declare const DEFAULT_NESTED_ADMISSION_ENABLED = true;
19
+ export declare const DEFAULT_NESTED_ADMISSION_MODE: "bypass";
20
+ export declare const DEFAULT_NESTED_MAX_DEPTH = 2;
21
+ export declare const DEFAULT_WAKE_SCHEDULER_ENABLED = true;
22
+ export declare const DEFAULT_WAKE_INTERVAL_MS = 300000;
23
+ export declare const MIN_WAKE_INTERVAL_MS = 60000;
24
+ export declare const DEFAULT_JOB_BOARD_ENABLED = true;
25
+ export declare const DEFAULT_JOB_BOARD_STRATEGY: "latest";
26
+ export declare const DEFAULT_MAX_RETAINED_SNAPSHOTS = 20;
27
+ export declare const RECONCILE_CONFIRMATION_GRACE_MS = 5000;
15
28
  export type ProcessCleanupEvent = NodeJS.Signals | "beforeExit" | "exit";
16
29
  export type OpencodeClient = PluginInput["client"];
17
30
  export interface MessagePartInfo {
@@ -0,0 +1,75 @@
1
+ import { z } from "zod";
2
+ import type { BackgroundTask } from "./types";
3
+ /**
4
+ * File-backed handle index for background tasks.
5
+ *
6
+ * Mirrors the `task-storage` pattern: one file per handle under a
7
+ * project-scoped `.matrixx/bg-handles/` directory, written atomically via
8
+ * `tmp + renameSync`. Only a lightweight index is persisted — prompts,
9
+ * progress, results, errors and tool-call windows stay ephemeral.
10
+ *
11
+ * This lets a freshly-created `BackgroundManager` recover previously-created
12
+ * `bg_*` handles after a plugin/process restart.
13
+ */
14
+ export declare const BG_HANDLE_DIR_NAME = "bg-handles";
15
+ export declare const BG_HANDLE_FILE_PREFIX = "bg_";
16
+ export declare const BgHandleSchema: z.ZodObject<{
17
+ taskId: z.ZodString;
18
+ parentSessionID: z.ZodString;
19
+ parentMessageID: z.ZodString;
20
+ description: z.ZodString;
21
+ agent: z.ZodString;
22
+ status: z.ZodEnum<{
23
+ error: "error";
24
+ cancelled: "cancelled";
25
+ interrupt: "interrupt";
26
+ pending: "pending";
27
+ running: "running";
28
+ completed: "completed";
29
+ stopped: "stopped";
30
+ statusUncertain: "statusUncertain";
31
+ }>;
32
+ sessionID: z.ZodOptional<z.ZodString>;
33
+ terminalReason: z.ZodOptional<z.ZodEnum<{
34
+ aborted: "aborted";
35
+ "queue-saturated": "queue-saturated";
36
+ "no-output": "no-output";
37
+ uncertain: "uncertain";
38
+ stale: "stale";
39
+ "nested-depth-exceeded": "nested-depth-exceeded";
40
+ "wall-clock-timeout": "wall-clock-timeout";
41
+ }>>;
42
+ model: z.ZodOptional<z.ZodObject<{
43
+ providerID: z.ZodString;
44
+ modelID: z.ZodString;
45
+ variant: z.ZodOptional<z.ZodString>;
46
+ temperature: z.ZodOptional<z.ZodNumber>;
47
+ }, z.core.$strip>>;
48
+ category: z.ZodOptional<z.ZodString>;
49
+ concurrencyGroup: z.ZodOptional<z.ZodString>;
50
+ queuedAt: z.ZodOptional<z.ZodNumber>;
51
+ startedAt: z.ZodOptional<z.ZodNumber>;
52
+ completedAt: z.ZodOptional<z.ZodNumber>;
53
+ }, z.core.$strict>;
54
+ export type BgHandle = z.infer<typeof BgHandleSchema>;
55
+ /** Project-scoped handle directory: `<project>/.matrixx/bg-handles`. */
56
+ export declare function getBgHandleDir(directory: string): string;
57
+ /** One file per handle id: `<project>/.matrixx/bg-handles/<taskId>.json`. */
58
+ export declare function getHandlePath(directory: string, taskId: string): string;
59
+ /** Project a full task onto the lightweight, persistable handle index. */
60
+ export declare function toHandle(task: BackgroundTask): BgHandle;
61
+ /**
62
+ * Atomically persist a handle: write to a temp file then rename into place.
63
+ * Throws on write failure; callers decide how to surface it.
64
+ */
65
+ export declare function writeHandle(directory: string, task: BackgroundTask): void;
66
+ /** Read and validate every persisted handle. Invalid/corrupt files are skipped. */
67
+ export declare function readHandles(directory: string): BgHandle[];
68
+ /** Remove the handle file for a task id. Returns true when a file was deleted. */
69
+ export declare function deleteHandleFile(directory: string, taskId: string): boolean;
70
+ /**
71
+ * Bounded TTL sweep: delete handle files whose most recent timestamp is older
72
+ * than `ttlMs` (default 30 min). Corrupt/unreadable files are swept too so the
73
+ * directory cannot grow without bound. Returns the number of files removed.
74
+ */
75
+ export declare function sweepStaleHandles(directory: string, ttlMs?: number, now?: number): number;
@@ -1,4 +1,5 @@
1
1
  export { ConcurrencyManager } from "./concurrency";
2
+ export { BG_HANDLE_FILE_PREFIX, type BgHandle, BgHandleSchema, deleteHandleFile, getBgHandleDir, getHandlePath, readHandles, sweepStaleHandles, toHandle, writeHandle, } from "./handle-index";
2
3
  export { BackgroundManager, type OnSubagentSessionCreated, type SubagentSessionCreatedEvent } from "./manager";
3
4
  export { TaskStateManager } from "./state";
4
5
  export { TaskHistory, type TaskHistoryEntry } from "./task-history";
@@ -1,7 +1,7 @@
1
1
  import type { PluginInput } from "@opencode-ai/plugin";
2
- import type { BackgroundTaskConfig, TmuxConfig } from "../../config/schema";
2
+ import type { BackgroundTaskConfig, DcpHandoffCompression, TmuxConfig } from "../../config/schema";
3
3
  import { TaskHistory } from "./task-history";
4
- import type { BackgroundTask, LaunchInput, ResumeInput } from "./types";
4
+ import type { BackgroundTask, LaunchInput, ResumeInput, ReviveInput } from "./types";
5
5
  export interface EventProperties {
6
6
  sessionID?: string;
7
7
  info?: {
@@ -41,18 +41,72 @@ export declare class BackgroundManager {
41
41
  private processingKeys;
42
42
  private completionTimers;
43
43
  private idleDeferralTimers;
44
+ private wakeScheduler;
44
45
  private notificationQueueByParent;
45
46
  private enableParentSessionNotifications;
46
47
  private cachedCircuitBreakerSettings?;
48
+ private handoffCompression?;
49
+ /** Active nested bypass admits per concurrency key (maxDepth cap). */
50
+ private nestedActive;
51
+ /** Task IDs admitted via nested bypass — used to decrement `nestedActive` exactly once. */
52
+ private nestedBypassTaskIds;
53
+ /** Elapsed-time bound supervisor (U7 wall-clock). OFF by default — arms nothing when disabled. */
54
+ private wallclock;
55
+ /** Grace timers pending a terminal wall-clock mark, keyed by task id. */
56
+ private wallclockGraceTimers;
47
57
  readonly taskHistory: TaskHistory;
48
58
  constructor(ctx: PluginInput, config?: BackgroundTaskConfig, options?: {
49
59
  tmuxConfig?: TmuxConfig;
50
60
  onSubagentSessionCreated?: OnSubagentSessionCreated;
51
61
  onShutdown?: () => void;
52
62
  enableParentSessionNotifications?: boolean;
63
+ handoffCompression?: DcpHandoffCompression;
53
64
  });
65
+ /**
66
+ * Persist a lightweight handle for the given task. Called on running and
67
+ * terminal transitions only — never on intermediate progress updates (C8).
68
+ * Best-effort: write failures are logged and never break task lifecycle.
69
+ */
70
+ private persistHandle;
71
+ private armWallclock;
72
+ private disarmWallclock;
73
+ private onWallclockFire;
74
+ private completeWallclockTimeout;
75
+ /**
76
+ * Recover handles persisted by a previous manager/process. Sweeps stale
77
+ * handles first, then loads the remainder into memory. Persisted
78
+ * `running|pending` handles are reconciled against the live host instead of
79
+ * being flattened to a false `"interrupt"` (C6). No concurrency is
80
+ * re-acquired for restored running handles (C7).
81
+ */
82
+ restoreHandles(): Promise<void>;
83
+ /**
84
+ * Probe the live host for a persisted in-flight handle and apply the
85
+ * reconciled outcome. Never throws: any unexpected failure degrades to
86
+ * `statusUncertain`, never a false completion. `restoreHandles()`'s caller
87
+ * is fire-and-forget (`create-managers.ts`), so rejection is not an option.
88
+ */
89
+ private reconcileRestoredTask;
54
90
  launch(input: LaunchInput): Promise<BackgroundTask>;
55
91
  private processKey;
92
+ /**
93
+ * Admit a nested launch. Bypass mode grants immediately without touching the
94
+ * semaphore; reserve mode first tries the reserved slot with a bounded wait
95
+ * and falls back to bypass overflow. Both modes enforce the maxDepth cap.
96
+ * Returns "skip" when the item was terminated (depth exceeded / cancelled).
97
+ */
98
+ private admitNested;
99
+ /**
100
+ * Terminal `stopped` outcome for a queued task that was never admitted.
101
+ * Mirrors the cancelTask terminal+notify sequence but never releases a slot
102
+ * (none was taken) and routes through the same parent-notification pipeline.
103
+ */
104
+ private terminateQueuedTask;
105
+ /**
106
+ * Decrement the nested bypass count for a task exactly once. Idempotent:
107
+ * repeated calls after the first are no-ops and can never underflow.
108
+ */
109
+ private decrementNestedActive;
56
110
  private startTask;
57
111
  getTask(id: string): BackgroundTask | undefined;
58
112
  getTasksByParentSession(sessionID: string): BackgroundTask[];
@@ -73,6 +127,17 @@ export declare class BackgroundManager {
73
127
  concurrencyKey?: string;
74
128
  }): Promise<BackgroundTask>;
75
129
  resume(input: ResumeInput): Promise<BackgroundTask>;
130
+ /** Revive a terminal task with a new prompt, from memory or disk. Bounded admission; saturated queue fails truthfully. */
131
+ revive(input: ReviveInput): Promise<BackgroundTask>;
132
+ /** Revivable terminal tasks: in-memory first (wins on taskId), then disk; newest-first. */
133
+ listRevivable(parentSessionID?: string): Array<{
134
+ taskId: string;
135
+ description: string;
136
+ agent: string;
137
+ status: string;
138
+ sessionID: string;
139
+ terminalReason?: string;
140
+ }>;
76
141
  private checkSessionTodos;
77
142
  handleEvent(event: Event): void;
78
143
  markForNotification(task: BackgroundTask): void;
@@ -88,6 +153,7 @@ export declare class BackgroundManager {
88
153
  /**
89
154
  * Validates that a session has actual assistant/tool output before marking complete.
90
155
  * Prevents premature completion when session.idle fires before agent responds.
156
+ * Delegates to the shared `session-output` helper (also used by reconciliation).
91
157
  */
92
158
  private validateSessionHasOutput;
93
159
  private clearNotificationsForTask;
@@ -96,6 +162,7 @@ export declare class BackgroundManager {
96
162
  * Cleans up the parent entry if no pending tasks remain.
97
163
  */
98
164
  private cleanupPendingByParent;
165
+ private refreshParentWake;
99
166
  /**
100
167
  * Fire-and-forget session abort. Logs failures at debug level instead of
101
168
  * swallowing errors silently — useful for diagnosing zombie sessions.
@@ -15,3 +15,4 @@ export declare function resolveAgentAndModel(client: {
15
15
  modelID: string;
16
16
  } | undefined;
17
17
  }>;
18
+ export declare function buildJobBoardNotification(snapshot: import("./task-history").JobBoardSnapshot): string;
@@ -0,0 +1,33 @@
1
+ import type { BgHandle } from "./handle-index";
2
+ import type { BackgroundTerminalReason } from "./types";
3
+ export type ReconcileOutcome = {
4
+ status: "completed" | "error" | "running" | "stopped" | "statusUncertain";
5
+ terminalReason?: BackgroundTerminalReason;
6
+ };
7
+ export interface ReconcileProbeClient {
8
+ session: {
9
+ status: () => Promise<unknown>;
10
+ messages: (args: {
11
+ path: {
12
+ id: string;
13
+ };
14
+ }) => Promise<unknown>;
15
+ todo: (args: {
16
+ path: {
17
+ id: string;
18
+ };
19
+ }) => Promise<unknown>;
20
+ };
21
+ }
22
+ export interface ReconcileDeps {
23
+ validateOutput?: (sessionID: string) => Promise<boolean>;
24
+ sleep?: (ms: number) => Promise<void>;
25
+ }
26
+ /**
27
+ * Classify a persisted `running|pending` handle against the live host.
28
+ *
29
+ * Deterministic order: unprobeable → uncertain; non-idle → running; recorded
30
+ * error → error; awaiting-user → running; no output → stopped; output with
31
+ * incomplete todos → running; otherwise completed. Never throws.
32
+ */
33
+ export declare function reconcileHandle(client: ReconcileProbeClient, handle: BgHandle, deps?: ReconcileDeps): Promise<ReconcileOutcome>;