thoth-agents 0.10.0 → 0.12.0

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 (101) hide show
  1. package/README.md +5 -3
  2. package/dist/agents/agent-config.d.ts +13 -0
  3. package/dist/agents/index.d.ts +1 -1
  4. package/dist/agents/orchestrator.d.ts +1 -1
  5. package/dist/{chunk-VHQMTZ5O.js → chunk-7F33WUSD.js} +1 -1
  6. package/dist/{chunk-RWQPMWEM.js → chunk-JLU3FSBT.js} +17 -2
  7. package/dist/chunk-MIDGZE34.js +107 -0
  8. package/dist/{chunk-RVQ6IIBR.js → chunk-NY2IPJ7V.js} +361 -118
  9. package/dist/{chunk-RN2ERZLZ.js → chunk-QOA2AETX.js} +2 -228
  10. package/dist/{chunk-6NZTNWI4.js → chunk-SEF6PFM6.js} +504 -211
  11. package/dist/cli/config-io.d.ts +2 -2
  12. package/dist/cli/index.js +92 -39
  13. package/dist/cli/install.d.ts +1 -0
  14. package/dist/cli/opencode-skill-consent.d.ts +5 -0
  15. package/dist/cli/operations/opencode.d.ts +2 -1
  16. package/dist/cli/operations/types.d.ts +1 -0
  17. package/dist/cli/owned-skills.d.ts +16 -0
  18. package/dist/cli/paths.d.ts +1 -1
  19. package/dist/cli/providers.d.ts +1 -1
  20. package/dist/cli/system.d.ts +3 -1
  21. package/dist/cli/thoth-mem-install.d.ts +10 -10
  22. package/dist/cli/tui/index.js +53 -5
  23. package/dist/cli/tui/operations.d.ts +2 -0
  24. package/dist/cli/types.d.ts +2 -4
  25. package/dist/config/loader.d.ts +1 -1
  26. package/dist/config/schema.d.ts +0 -31
  27. package/dist/harness/adapters/opencode.d.ts +1 -1
  28. package/dist/harness/core/agent-pack.d.ts +1 -0
  29. package/dist/harness/core/sdd.d.ts +6 -6
  30. package/dist/hooks/delegate-task-retry/hook.d.ts +8 -8
  31. package/dist/hooks/foreground-fallback/index.d.ts +14 -69
  32. package/dist/hooks/index.d.ts +0 -2
  33. package/dist/hooks/json-error-recovery/hook.d.ts +2 -15
  34. package/dist/hooks/oracle-gate-verdict/hook.d.ts +4 -11
  35. package/dist/index.d.ts +7 -4
  36. package/dist/index.js +822 -1421
  37. package/dist/opencode/agents.d.ts +3 -0
  38. package/dist/opencode/command.d.ts +3 -0
  39. package/dist/opencode/context.d.ts +20 -0
  40. package/dist/opencode/delegation-hooks.d.ts +3 -0
  41. package/dist/opencode/mcp.d.ts +3 -0
  42. package/dist/opencode/permission-rules.d.ts +9 -0
  43. package/dist/opencode/permissions.d.ts +3 -0
  44. package/dist/opencode/session-hooks.d.ts +3 -0
  45. package/dist/opencode/session-state.d.ts +39 -0
  46. package/dist/opencode/skills.d.ts +3 -0
  47. package/dist/opencode/tools.d.ts +3 -0
  48. package/dist/pi.js +3 -3
  49. package/dist/tools/ast-grep/cli.d.ts +1 -0
  50. package/dist/tools/ast-grep/index.d.ts +108 -2
  51. package/dist/tools/ast-grep/tools.d.ts +107 -3
  52. package/dist/tools/define-tool.d.ts +23 -0
  53. package/dist/tools/lsp/tools.d.ts +97 -5
  54. package/dist/utils/index.d.ts +0 -1
  55. package/package.json +14 -3
  56. package/pi/.thoth-agents-assets.json +2 -2
  57. package/pi/agents/thoth-designer.md +1 -1
  58. package/pi/agents/thoth-worker.md +1 -1
  59. package/plugin/.claude-plugin/.thoth-agents-plugin-assets.json +3 -3
  60. package/plugin/.claude-plugin/plugin.json +1 -1
  61. package/plugin/.codex-plugin/.thoth-agents-plugin-assets.json +3 -3
  62. package/plugin/.codex-plugin/plugin.json +1 -1
  63. package/plugin/agents/designer.md +1 -1
  64. package/plugin/agents/orchestrator.md +32 -32
  65. package/plugin/agents/worker.md +1 -1
  66. package/plugin/codex-hooks/payloads/designer.md +1 -1
  67. package/plugin/codex-hooks/payloads/root.md +32 -32
  68. package/plugin/codex-hooks/payloads/worker.md +1 -1
  69. package/plugin/skills/plan-reviewer/SKILL.md +5 -5
  70. package/plugin/skills/thoth-sdd/SKILL.md +33 -9
  71. package/plugin/skills/thoth-sdd/references/phases/checklist.md +1 -1
  72. package/plugin/skills/thoth-sdd/references/phases/clarify.md +1 -1
  73. package/plugin/skills/thoth-sdd/references/phases/converge.md +8 -1
  74. package/plugin/skills/thoth-sdd/references/phases/implement.md +5 -1
  75. package/plugin/skills/thoth-sdd/references/phases/plan.md +1 -1
  76. package/plugin/skills/thoth-sdd/references/phases/specify.md +1 -1
  77. package/plugin/skills/thoth-sdd/references/phases/tasks.md +1 -1
  78. package/plugin/skills/thoth-sdd/references/phases/verify.md +10 -3
  79. package/plugin/skills/thoth-sdd/scripts/validate-result.mjs +28 -2
  80. package/plugin/skills/thoth-sdd/templates/change.md +2 -1
  81. package/skills/plan-reviewer/SKILL.md +5 -5
  82. package/skills/thoth-sdd/SKILL.md +33 -9
  83. package/skills/thoth-sdd/references/phases/checklist.md +1 -1
  84. package/skills/thoth-sdd/references/phases/clarify.md +1 -1
  85. package/skills/thoth-sdd/references/phases/converge.md +8 -1
  86. package/skills/thoth-sdd/references/phases/implement.md +5 -1
  87. package/skills/thoth-sdd/references/phases/plan.md +1 -1
  88. package/skills/thoth-sdd/references/phases/specify.md +1 -1
  89. package/skills/thoth-sdd/references/phases/tasks.md +1 -1
  90. package/skills/thoth-sdd/references/phases/verify.md +10 -3
  91. package/skills/thoth-sdd/scripts/validate-result.mjs +28 -2
  92. package/skills/thoth-sdd/templates/change.md +2 -1
  93. package/thoth-agents.schema.json +0 -26
  94. package/dist/chunk-62L3ORXN.js +0 -30
  95. package/dist/delegation/project-id.d.ts +0 -10
  96. package/dist/hooks/auto-update-checker/checker.d.ts +0 -23
  97. package/dist/hooks/auto-update-checker/constants.d.ts +0 -11
  98. package/dist/hooks/auto-update-checker/index.d.ts +0 -17
  99. package/dist/hooks/auto-update-checker/types.d.ts +0 -22
  100. package/dist/utils/tmux-session-manager.d.ts +0 -63
  101. package/dist/utils/tmux.d.ts +0 -32
@@ -59,26 +59,6 @@ export declare const AgentOverrideConfigSchema: z.ZodObject<{
59
59
  steps: z.ZodOptional<z.ZodNumber>;
60
60
  variant: z.ZodCatch<z.ZodOptional<z.ZodString>>;
61
61
  }, z.core.$strip>;
62
- export declare const TmuxLayoutSchema: z.ZodEnum<{
63
- "main-vertical": "main-vertical";
64
- "main-horizontal": "main-horizontal";
65
- tiled: "tiled";
66
- "even-horizontal": "even-horizontal";
67
- "even-vertical": "even-vertical";
68
- }>;
69
- export type TmuxLayout = z.infer<typeof TmuxLayoutSchema>;
70
- export declare const TmuxConfigSchema: z.ZodObject<{
71
- enabled: z.ZodDefault<z.ZodBoolean>;
72
- layout: z.ZodDefault<z.ZodEnum<{
73
- "main-vertical": "main-vertical";
74
- "main-horizontal": "main-horizontal";
75
- tiled: "tiled";
76
- "even-horizontal": "even-horizontal";
77
- "even-vertical": "even-vertical";
78
- }>>;
79
- main_pane_size: z.ZodDefault<z.ZodNumber>;
80
- }, z.core.$strip>;
81
- export type TmuxConfig = z.infer<typeof TmuxConfigSchema>;
82
62
  export type AgentOverrideConfig = z.infer<typeof AgentOverrideConfigSchema>;
83
63
  /** Normalized model entry with optional per-model variant. */
84
64
  export type ModelEntry = {
@@ -198,17 +178,6 @@ export declare const PluginConfigSchema: z.ZodObject<{
198
178
  variant: z.ZodCatch<z.ZodOptional<z.ZodString>>;
199
179
  }, z.core.$strip>>>;
200
180
  disabled_mcps: z.ZodOptional<z.ZodArray<z.ZodString>>;
201
- tmux: z.ZodOptional<z.ZodObject<{
202
- enabled: z.ZodDefault<z.ZodBoolean>;
203
- layout: z.ZodDefault<z.ZodEnum<{
204
- "main-vertical": "main-vertical";
205
- "main-horizontal": "main-horizontal";
206
- tiled: "tiled";
207
- "even-horizontal": "even-horizontal";
208
- "even-vertical": "even-vertical";
209
- }>>;
210
- main_pane_size: z.ZodDefault<z.ZodNumber>;
211
- }, z.core.$strip>>;
212
181
  fallback: z.ZodOptional<z.ZodObject<{
213
182
  enabled: z.ZodDefault<z.ZodBoolean>;
214
183
  timeoutMs: z.ZodDefault<z.ZodNumber>;
@@ -1,4 +1,4 @@
1
- import type { AgentConfig } from '@opencode-ai/sdk/v2';
1
+ import type { AgentConfig } from '../../agents/agent-config';
2
2
  import type { PluginConfig } from '../../config';
3
3
  import type { HarnessAdapter, HarnessCapabilities, HarnessRenderContext } from '../types';
4
4
  export type OpenCodeAgentConfigs = Record<string, AgentConfig>;
@@ -57,6 +57,7 @@ export interface ImplementationOwnershipPolicy {
57
57
  rootIdentity: string;
58
58
  defaultRule: string;
59
59
  rootResponsibilities: string[];
60
+ recordAuthorship: string;
60
61
  discovery: string[];
61
62
  directConsultation: string[];
62
63
  directException: string[];
@@ -179,7 +179,7 @@ export declare const SDD_PHASE_PROTOCOLS: readonly [{
179
179
  readonly id: "explore";
180
180
  readonly objective: "Understand current behavior and constraints in proportion to the request.";
181
181
  readonly requiredInputs: ["User intent and known repository context"];
182
- readonly instructions: ["Inspect repository evidence in proportion to the request to identify behavior, constraints, risks, and safe assumptions.", "Root owns completing understanding and acceptance; specific discovery ownership determines who gathers evidence, even when generic guidance permits direct exploration.", "Give each evidence assignment one precise question and result. Independent questions may run in parallel within native capacity; dependent questions wait until the upstream output is accepted by root. Do not duplicate discovery.", "Complete this phase before specifying. No document, agent, or interview is forced in this phase."];
182
+ readonly instructions: ["Inspect repository evidence in proportion to the request to identify behavior, constraints, risks, and safe assumptions.", "Root owns completing understanding and acceptance; specific discovery ownership determines who gathers evidence, even when generic guidance permits direct exploration.", "During planning, specialists supply only context within their full role scope; never assign them to create, modify or correct SDD files.", "Give each evidence assignment one precise question and result. Independent questions may run in parallel within native capacity; dependent questions wait until the upstream output is accepted by root. Do not duplicate discovery.", "Complete this phase before specifying. No document, agent, or interview is forced in this phase."];
183
183
  readonly outputSchema: ["confirmed facts", "constraints", "safe assumptions", "material uncertainty"];
184
184
  readonly doneWhen: ["The next step can state intended outcomes without repeating discovery."];
185
185
  readonly blockingConditions: ["A material human-owned decision cannot safely be inferred."];
@@ -203,7 +203,7 @@ export declare const SDD_PHASE_PROTOCOLS: readonly [{
203
203
  readonly id: "plan";
204
204
  readonly objective: "Plan substantial work in its one persistent record.";
205
205
  readonly requiredInputs: ["Settled understanding", "Substantial classification", "Accepted outcomes"];
206
- readonly instructions: ["Substantial classification only creates the `.thoth/changes/<id>/<id>.md` record.", "Capture interfaces, mutable surfaces, durable deltas, dependencies, risks, and verification seams.", "Plan each useful work unit with concrete inputs, outputs, and dependencies.", "Record each unit's owner, owned writes, interface boundaries, focused checks with PASS evidence, and return milestone and stop condition.", "Validate the plan before tasks exist; tasks are checked later for acceptance coverage."];
206
+ readonly instructions: ["Root alone creates, edits, validates and corrects the substantial change record: coordination outside specialist-default execution, direct-work allowances and consultation budget; no source discovery or substantive implementation permission.", "Substantial classification only creates the `.thoth/changes/<id>/<id>.md` record.", "Capture interfaces, mutable surfaces, durable deltas, dependencies, risks, and verification seams.", "Plan each useful work unit with concrete inputs, outputs, and dependencies.", "Record each unit's owner, owned writes, interface boundaries, focused checks with PASS evidence, and return milestone and stop condition.", "Validate the plan before tasks exist; tasks are checked later for acceptance coverage."];
207
207
  readonly outputSchema: ["technical approach", "affected interfaces", "risks", "verification seams"];
208
208
  readonly doneWhen: ["A competent implementer can proceed without guessing at critical constraints."];
209
209
  readonly blockingConditions: ["The approach contradicts accepted intent or unresolved material choices remain."];
@@ -227,7 +227,7 @@ export declare const SDD_PHASE_PROTOCOLS: readonly [{
227
227
  readonly id: "plan-review";
228
228
  readonly objective: "Offer optional independent blocker review after the ready plan.";
229
229
  readonly requiredInputs: ["Ready substantial record", "Selected review disposition"];
230
- readonly instructions: ["At ready, first show the user a concise plan summary (goal, acceptance, units, risks), then always offer “Review plan with Oracle (Recommended)” or “Proceed without review”; record the plan-review choice as EXPLICIT_REVIEW for an explicit review answer, EXPLICIT_SKIP for an explicit direct answer, or DEFAULT_REVIEW_AFTER_3 only when the third confirmed empty return selects review. Keep selection provenance separate from implementation authorization; silence never means EXPLICIT_SKIP.", "For every orchestrator choice with a meaningful safe recommendation, after its first and second confirmed empty native returns repeat the same question and do no dependent work; after the third confirmed empty native return choose the recommendation. Explicit answers and Stop win. Pending, unavailable, failed, interrupted or host-prohibited questions do not count. If higher-priority host or tool rules prevent asking or repeating, obey them and report the limitation rather than claiming three returns or an explicit selection.", "Never fabricate facts or secrets; recommend safe deferral when needed information or material intent is unresolved, and keep dependent work blocked.", "Review scope, approach, risks, and acceptance coverage without redesigning settled intent.", "Return actionable blockers and cautions; a pass is not implementation authorization or final verification.", "After [OKAY], preserve the separate Implement (Recommended) / Stop authorization decision; honor applicable prior explicit authorization, and let explicit Stop supersede it.", "A plan review does not substitute for fresh final verification."];
230
+ readonly instructions: ["At ready, first show the user a concise plan summary (goal, acceptance, units, risks), then always offer “Review plan with Oracle (Recommended)” or “Proceed without review”; record the plan-review choice as EXPLICIT_REVIEW for an explicit review answer, EXPLICIT_SKIP for an explicit direct answer, or DEFAULT_REVIEW_AFTER_3 only when the third confirmed empty return selects review. Keep selection provenance separate from implementation authorization; silence never means EXPLICIT_SKIP.", "For every orchestrator choice with a meaningful safe recommendation, after its first and second confirmed empty native returns repeat the same question and do no dependent work; after the third confirmed empty native return choose the recommendation. Explicit answers and Stop win. Pending, unavailable, failed, interrupted or host-prohibited questions do not count. If higher-priority host or tool rules prevent asking or repeating, obey them and report the limitation rather than claiming three returns or an explicit selection.", "Never fabricate facts or secrets; recommend safe deferral when needed information or material intent is unresolved, and keep dependent work blocked.", "Review scope, approach, risks, and acceptance coverage without redesigning settled intent.", "Return actionable blockers and cautions; a pass is not implementation authorization or final verification.", "After [OKAY], preserve the separate Implement (Recommended) / Stop authorization decision; honor applicable prior explicit authorization, and let explicit Stop supersede it.", "REJECT: root repairs the same record, reruns affected gates and sends it to a fresh Oracle; repeat until OKAY or a human-owned material blocker stops the round.", "A plan review does not substitute for fresh final verification."];
231
231
  readonly outputSchema: ["status", "blockers", "cautions"];
232
232
  readonly doneWhen: ["The selected review has a current, evidence-backed disposition."];
233
233
  readonly blockingConditions: ["A blocking finding remains unresolved."];
@@ -235,7 +235,7 @@ export declare const SDD_PHASE_PROTOCOLS: readonly [{
235
235
  readonly id: "implement";
236
236
  readonly objective: "Implement the accepted small request or authorized substantial slice.";
237
237
  readonly requiredInputs: ["Settled user intent or authorized record", "Exact mutable boundaries", "Focused checks"];
238
- readonly instructions: ["Use one writer per mutable surface and choose an owner from task shape.", "Work only from accepted inputs and named dependencies within the assigned outcome and interface boundaries.", "Return bounded progress for root acceptance before dependent work starts.", "Use test-first (TDD); observe red before green for behavior changes, then verify call sites, shared contracts, and edge cases.", "Stop on a missing interface, ownership conflict, or new independent outcome.", "Return completed bounded progress and the smallest blocker for root reassessment before expansion.", "Do not create process tooling, reports, evidence generators, or temporary artifacts."];
238
+ readonly instructions: ["For small work, root states a brief in-session plan (scope, owner, focused verification) before delegation or implementation; no record or planning phases.", "Implementation writers start only after authorization; never write .thoth/changes/ records.", "Use one writer per mutable surface and choose an owner from task shape.", "Work only from accepted inputs and named dependencies within the assigned outcome and interface boundaries.", "Return bounded progress for root acceptance before dependent work starts.", "Use test-first (TDD); observe red before green for behavior changes, then verify call sites, shared contracts, and edge cases.", "Stop on a missing interface, ownership conflict, or new independent outcome.", "Return completed bounded progress and the smallest blocker for root reassessment before expansion.", "Do not create process tooling, reports, evidence generators, or temporary artifacts."];
239
239
  readonly outputSchema: ["outcome", "changed files", "checks", "residual risks"];
240
240
  readonly doneWhen: ["The assigned outcome is implemented and focused checks have run."];
241
241
  readonly blockingConditions: ["Scope, risk, or material intent changes before safe completion."];
@@ -243,7 +243,7 @@ export declare const SDD_PHASE_PROTOCOLS: readonly [{
243
243
  readonly id: "verify";
244
244
  readonly objective: "Verify actual outcomes with independence proportional to risk.";
245
245
  readonly requiredInputs: ["Accepted outcomes", "Actual change and executed checks"];
246
- readonly instructions: ["Judge the actual diff, executed checks, and residual risks; verify completeness, correctness, coherence, and behavior.", "Substantial or materially risky work requires a fresh independent Oracle; no writer self-approves.", "For substantial work, record acceptance evidence, checks, source digests, and reviewed-record digest in the same record."];
246
+ readonly instructions: ["Judge the actual diff, executed checks, and residual risks; verify completeness, correctness, coherence, and behavior.", "Substantial or materially risky work requires a fresh independent Oracle; no writer self-approves.", "For substantial work, record acceptance evidence, checks, source digests, and reviewed-record digest in the same record.", "Plan review OKAY/REJECT judges the record; root repairs REJECT. Final verification PASS/FAIL judges the implementation.", "Root records remaining acceptance-linked work in the substantial record when one exists, otherwise in the brief in-session small plan; the owning Worker or Designer repairs each affected surface; root coordinates and does not repair implementation unless the user explicitly instructs direct work; even then, never self-approve and report unavailable independent review.", "Repeat independent verification as the change's verification level requires; substantial or materially risky work uses a fresh Oracle. Material changes in intent, scope or risk reopen understanding and planning before further implementation."];
247
247
  readonly outputSchema: ["verdict", "acceptance evidence", "checks", "residual risks"];
248
248
  readonly doneWhen: ["Every accepted outcome has evidence or an explicit residual risk."];
249
249
  readonly blockingConditions: ["A failed check, missing evidence, or critical issue remains."];
@@ -251,7 +251,7 @@ export declare const SDD_PHASE_PROTOCOLS: readonly [{
251
251
  readonly id: "converge";
252
252
  readonly objective: "Turn actionable verification gaps into bounded corrective work.";
253
253
  readonly requiredInputs: ["Failed verification", "Settled intent"];
254
- readonly instructions: ["Record acceptance-linked follow-up in the same record when one exists.", "If scope or risk changes materially, reopen understanding and classification.", "Do not create a separate convergence report."];
254
+ readonly instructions: ["Plan review OKAY/REJECT judges the record; root repairs REJECT. Final verification PASS/FAIL judges the implementation.", "Root records remaining acceptance-linked work in the substantial record when one exists, otherwise in the brief in-session small plan; the owning Worker or Designer repairs each affected surface; root coordinates and does not repair implementation unless the user explicitly instructs direct work; even then, never self-approve and report unavailable independent review.", "Repeat independent verification as the change's verification level requires; substantial or materially risky work uses a fresh Oracle. Material changes in intent, scope or risk reopen understanding and planning before further implementation.", "Do not create a separate convergence report."];
255
255
  readonly outputSchema: ["bounded follow-up", "verification seam"];
256
256
  readonly doneWhen: ["Each actionable gap has a safe next action or the work is confirmed converged."];
257
257
  readonly blockingConditions: ["Findings lack evidence or require material new intent."];
@@ -1,8 +1,8 @@
1
- import type { PluginInput } from '@opencode-ai/plugin';
2
- export declare function createDelegateTaskRetryHook(_ctx: PluginInput): {
3
- 'tool.execute.after': (input: {
4
- tool: string;
5
- }, output: {
6
- output: unknown;
7
- }) => Promise<void>;
8
- };
1
+ import type { Plugin } from '@opencode/plugin';
2
+ export type DelegationToolEvent = Extract<Parameters<Parameters<Plugin.Context['tool']['hook']>[1]>[0], {
3
+ status: 'completed' | 'error';
4
+ }>;
5
+ export declare function appendErrorGuidance(event: DelegationToolEvent & {
6
+ status: 'error';
7
+ }, guidance: string): void;
8
+ export declare function createDelegateTaskRetryHook(): (event: DelegationToolEvent) => Promise<void>;
@@ -1,73 +1,18 @@
1
- /**
2
- * Runtime model fallback for foreground (interactive) agent sessions.
3
- *
4
- * When OpenCode fires a session.error, message.updated, or session.status
5
- * event containing a rate-limit signal, this manager:
6
- * 1. Looks up the next untried model in the agent's configured chain
7
- * 2. Aborts the rate-limited prompt via client.session.abort()
8
- * 3. Re-queues the last user message via client.session.promptAsync()
9
- * with the new model — promptAsync returns immediately so we never
10
- * block the event handler waiting for a full LLM response.
11
- *
12
- * This mirrors the task fallback loop but operates
13
- * reactively through the event system instead of wrapping prompt() in a
14
- * try/catch, which is not possible for interactive (foreground) sessions.
15
- */
16
- import type { PluginInput } from '@opencode-ai/plugin';
17
- type OpencodeClient = PluginInput['client'];
1
+ import type { Plugin } from '@opencode/plugin';
2
+ import type { SessionRetry } from '@opencode/plugin/promise/session';
3
+ /** Retained public detection helper; v2 uses structured provider errors. */
18
4
  export declare function isRateLimitError(error: unknown): boolean;
19
- /**
20
- * Manages runtime model fallback for foreground agent sessions.
21
- *
22
- * Constructed at plugin init with the ordered fallback chains for each agent
23
- * (built from _modelArray entries merged with fallback.chains config).
24
- */
5
+ /** Retry state is isolated by session AND agent; no event replay or timers. */
25
6
  export declare class ForegroundFallbackManager {
26
- private readonly client;
27
- /**
28
- * Ordered fallback chains per agent.
29
- * e.g. { orchestrator: ['anthropic/claude-opus-4-5', 'openai/gpt-4o'] }
30
- * The first model that hasn't been tried yet is selected on each fallback.
31
- */
7
+ private readonly session;
32
8
  private readonly chains;
33
- private readonly enabled;
34
- /** sessionID → last observed model string ("providerID/modelID") */
35
- private readonly sessionModel;
36
- /** sessionID → agent name (populated from message.updated info.agent field) */
37
- private readonly sessionAgent;
38
- /** sessionID → set of models already attempted this session */
39
- private readonly sessionTried;
40
- /** Sessions with an active fallback switch in flight */
41
- private readonly inProgress;
42
- /** sessionID → timestamp of last trigger (for deduplication) */
43
- private readonly lastTrigger;
44
- constructor(client: OpencodeClient,
45
- /**
46
- * Ordered fallback chains per agent.
47
- * e.g. { orchestrator: ['anthropic/claude-opus-4-5', 'openai/gpt-4o'] }
48
- * The first model that hasn't been tried yet is selected on each fallback.
49
- */
50
- chains: Record<string, string[]>, enabled: boolean);
51
- /**
52
- * Process an OpenCode plugin event.
53
- * Call this from the plugin's `event` hook for every event received.
54
- */
55
- handleEvent(rawEvent: unknown): Promise<void>;
56
- getSessionModel(sessionId: string): string | undefined;
57
- private tryFallback;
58
- /**
59
- * Determine the fallback chain to use for a session.
60
- *
61
- * Priority:
62
- * 1. Agent name known AND has a configured chain → return it directly
63
- * 2. Agent name known but NO chain configured → return [] (no fallback;
64
- * do NOT bleed into other agents' chains which would re-prompt the
65
- * session with a model belonging to a completely different agent)
66
- * 3. Agent name unknown, current model known → search all chains for
67
- * the model to infer which chain to use
68
- * 4. Nothing matches → flatten all chains as a last resort (only
69
- * reached when both agent name and current model are unavailable)
70
- */
71
- private resolveChain;
9
+ private readonly models;
10
+ private readonly tried;
11
+ private readonly switching;
12
+ constructor(session: Pick<Plugin.Context['session'], 'switchModel'>, chains: Record<string, string[]>, models?: Record<string, {
13
+ id: string;
14
+ variant?: string;
15
+ }[]>);
16
+ forget(sessionID: string): void;
17
+ retry(input: SessionRetry): Promise<void>;
72
18
  }
73
- export {};
@@ -1,5 +1,3 @@
1
- export type { AutoUpdateCheckerOptions } from './auto-update-checker';
2
- export { createAutoUpdateCheckerHook } from './auto-update-checker';
3
1
  export { createDelegateTaskRetryHook } from './delegate-task-retry';
4
2
  export { ForegroundFallbackManager, isRateLimitError, } from './foreground-fallback';
5
3
  export { createJsonErrorRecoveryHook } from './json-error-recovery';
@@ -1,18 +1,5 @@
1
- import type { PluginInput } from '@opencode-ai/plugin';
1
+ import { type DelegationToolEvent } from '../delegate-task-retry/hook';
2
2
  export declare const JSON_ERROR_TOOL_EXCLUDE_LIST: readonly ["bash", "read", "glob", "webfetch", "grep_app_searchgithub", "exa_web_search_exa"];
3
3
  export declare const JSON_ERROR_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
4
4
  export declare const JSON_ERROR_REMINDER = "\n[JSON PARSE ERROR - IMMEDIATE ACTION REQUIRED]\n\nYou sent invalid JSON arguments. The system could not parse your tool call.\nSTOP and do this NOW:\n\n1. LOOK at the error message above to see what was expected vs what you sent.\n2. CORRECT your JSON syntax (missing braces, unescaped quotes, trailing commas, etc).\n3. RETRY the tool call with valid JSON.\n\nDO NOT repeat the exact same invalid call.\n";
5
- interface ToolExecuteAfterInput {
6
- tool: string;
7
- sessionID: string;
8
- callID: string;
9
- }
10
- interface ToolExecuteAfterOutput {
11
- title: string;
12
- output: unknown;
13
- metadata: unknown;
14
- }
15
- export declare function createJsonErrorRecoveryHook(_ctx: PluginInput): {
16
- 'tool.execute.after': (input: ToolExecuteAfterInput, output: ToolExecuteAfterOutput) => Promise<void>;
17
- };
18
- export {};
5
+ export declare function createJsonErrorRecoveryHook(): (event: DelegationToolEvent) => Promise<void>;
@@ -1,11 +1,4 @@
1
- import type { PluginInput } from '@opencode-ai/plugin';
2
- export declare function createOracleGateVerdictHook(ctx: PluginInput): {
3
- 'tool.execute.after': (input: {
4
- tool: string;
5
- args?: {
6
- subagent_type?: unknown;
7
- };
8
- }, output: {
9
- output: unknown;
10
- }) => Promise<void>;
11
- };
1
+ import type { DelegationToolEvent } from '../delegate-task-retry/hook';
2
+ export declare function createOracleGateVerdictHook(ctx: {
3
+ directory: string;
4
+ }): (event: DelegationToolEvent) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- import type { Plugin } from '@opencode-ai/plugin';
2
- declare const ThothAgents: Plugin;
3
- export default ThothAgents;
4
- export type { AgentName, AgentOverrideConfig, McpName, PluginConfig, TmuxConfig, TmuxLayout, } from './config';
1
+ import type { Plugin } from '@opencode/plugin';
2
+ declare const plugin: {
3
+ id: string;
4
+ setup(ctx: Plugin.Context): Promise<void>;
5
+ };
6
+ export default plugin;
7
+ export type { AgentName, AgentOverrideConfig, McpName, PluginConfig, } from './config';
5
8
  export type { RemoteMcpConfig } from './mcp';