pantheon-opencode 1.5.0-beta.2 → 1.5.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pantheon/code-mode/manifest.json +21 -0
- package/AGENTS.md +14 -63
- package/CHANGELOG.md +1260 -0
- package/README.md +162 -23
- package/README.pt-BR.md +104 -19
- package/bin/pantheon-init.mjs +178 -21
- package/commands/pantheon.md +1 -35
- package/package.json +23 -15
- package/plugin.json +1 -1
- package/pyproject.toml +62 -0
- package/scripts/code_mode_server.py +431 -55
- package/scripts/doctor.mjs +207 -9
- package/scripts/install/cli-ui.mjs +17 -11
- package/scripts/install/config-migration.mjs +4 -6
- package/scripts/install/opencode.mjs +137 -35
- package/scripts/install/plugin.mjs +12 -45
- package/scripts/install/shared.mjs +43 -2
- package/scripts/install/strings.mjs +129 -0
- package/scripts/install-mcp.mjs +1 -0
- package/scripts/manifest-inventory.mjs +410 -0
- package/scripts/mcp_persistence_server.py +536 -164
- package/scripts/package-evidence.mjs +242 -0
- package/scripts/probe-pantheon-cost.mjs +10 -1
- package/scripts/release-beta-version.mjs +56 -60
- package/scripts/sync-artifacts.mjs +169 -0
- package/scripts/sync-tui.mjs +129 -64
- package/scripts/test-opencode-v1-v2-sandbox.sh +79 -161
- package/scripts/validation-policy.mjs +7 -7
- package/scripts/version-check.mjs +113 -108
- package/scripts/versioning.mjs +230 -86
- package/src/agents/apollo.md +1 -0
- package/src/agents/gaia.md +1 -0
- package/src/agents/mnemosyne.md +1 -1
- package/src/agents/zeus.md +11 -54
- package/src/instructions/memory-protocol.instructions.md +6 -3
- package/src/instructions/zeus-anti-stall.instructions.md +2 -4
- package/src/instructions/zeus-council-synthesis.instructions.md +3 -28
- package/src/instructions/zeus-timeout-retry.instructions.md +3 -28
- package/src/mcp/code_mode_server.py +431 -55
- package/src/mcp/mcp_persistence_server.py +536 -164
- package/src/mcp/toon_codec.py +2 -4
- package/src/pantheon/background-job-board.ts +47 -5
- package/src/pantheon/{delegation-compaction.ts → compaction-context.ts} +10 -100
- package/src/pantheon/cost-command.ts +309 -44
- package/src/pantheon/delegation-enforce.ts +59 -14
- package/src/pantheon/file-persistence-salvage.ts +64 -0
- package/src/pantheon/file-persistence.ts +194 -45
- package/src/pantheon/goal-loop.ts +1 -1
- package/src/pantheon/goal-store.ts +1 -1
- package/src/pantheon/idle-continuation.ts +4 -6
- package/src/pantheon/model-command.ts +1 -2
- package/src/pantheon/native-task-status.ts +139 -0
- package/src/pantheon/presets.d.mts +0 -20
- package/src/pantheon/presets.mjs +0 -64
- package/src/pantheon/session-guard.ts +2 -2
- package/src/pantheon/session-id.ts +30 -0
- package/src/pantheon/shared-board.ts +37 -0
- package/src/pantheon/task-result-guard.ts +106 -0
- package/src/pantheon/todo-enforcer.ts +3 -3
- package/src/pantheon/tool-ceiling.ts +159 -0
- package/src/pantheon/tool-context.ts +23 -0
- package/src/pantheon/v2-bridge.ts +1 -4
- package/src/plugin-v2.ts +8 -21
- package/src/plugin.ts +83 -251
- package/src/plugins/pantheon-hooks.ts +51 -0
- package/src/plugins/tui/dist/server.d.ts +1 -1
- package/src/plugins/tui/dist/server.d.ts.map +1 -1
- package/src/plugins/tui/dist/server.js +1 -1
- package/src/plugins/tui/dist/server.js.map +1 -1
- package/src/plugins/tui/dist/tui.d.ts +261 -77
- package/src/plugins/tui/dist/tui.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui.js +640 -234
- package/src/plugins/tui/dist/tui.js.map +1 -1
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +2 -2
- package/src/plugins/tui/src/index.tsx +872 -226
- package/src/routing.yml +0 -16
- package/src/skills/context-compression/SKILL.md +1 -1
- package/scripts/generate-preset-docs.mjs +0 -300
- package/scripts/generate-prompts.sh +0 -222
- package/scripts/hash_verify.py +0 -192
- package/scripts/install/component.mjs +0 -24
- package/scripts/install/migrate-config.mjs +0 -302
- package/scripts/test-context-compression.sh +0 -169
- package/src/pantheon/auto-wake.ts +0 -89
- package/src/pantheon/chat-reminders.ts +0 -9
- package/src/pantheon/comment-checker.ts +0 -48
- package/src/pantheon/compaction-assert.ts +0 -160
- package/src/pantheon/cost-tracker.ts +0 -108
- package/src/pantheon/delegate-manager.ts +0 -669
- package/src/pantheon/delegation-classifier.ts +0 -307
- package/src/pantheon/delegation-finalize.ts +0 -374
- package/src/pantheon/delegation-notify.ts +0 -212
- package/src/pantheon/delegation-toast.ts +0 -73
- package/src/pantheon/delegation.ts +0 -1120
- package/src/pantheon/dispatch-guard.ts +0 -109
- package/src/pantheon/permission-eval.ts +0 -284
- package/src/pantheon/preemptive-compact.ts +0 -76
- package/src/pantheon/retry-policy.ts +0 -212
- package/src/pantheon/step-cap.ts +0 -110
- package/src/pantheon/token-opt.ts +0 -781
- package/src/pantheon/toon-codec.ts +0 -481
- package/src/pantheon/v2-events.ts +0 -131
- package/src/pantheon/v2-hooks.ts +0 -287
- package/src/pantheon/v2-tool-definitions.ts +0 -331
- package/src/pantheon/zeus-delegate-with-retry.ts +0 -406
- package/src/plugins/tui/dist/tui.tsx +0 -2605
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-wide BackgroundJobBoard singleton shared by every Pantheon plugin
|
|
3
|
+
* surface (src/plugin.ts V1, src/plugins/pantheon-hooks.ts).
|
|
4
|
+
*
|
|
5
|
+
* WHY globalThis and not a module-level `const`: opencode loads each plugin
|
|
6
|
+
* TWICE from two different filesystem paths (the installed npm package AND
|
|
7
|
+
* the repo source — see src/pantheon/plugin-once.ts). Each load is a separate
|
|
8
|
+
* module instance, so a plain ESM singleton would yield TWO boards: the
|
|
9
|
+
* native-task mirror in pantheon-hooks would register jobs on one instance
|
|
10
|
+
* while the finalize path (session.idle + idle scan in plugin.ts) listens on
|
|
11
|
+
* the other, and the job would never finalize. A globalThis-anchored value is
|
|
12
|
+
* process-global by construction, deduping both module copies.
|
|
13
|
+
*
|
|
14
|
+
* The persistence file and signal dir are RELATIVE paths — the board operates
|
|
15
|
+
* against the opencode project root (the cwd of the plugin process), matching
|
|
16
|
+
* the pre-existing plugin.ts wiring exactly.
|
|
17
|
+
*/
|
|
18
|
+
import { BackgroundJobBoard } from './background-job-board.ts'
|
|
19
|
+
import { FilePersistenceAdapter } from './file-persistence.ts'
|
|
20
|
+
|
|
21
|
+
const BOARD_KEY = '__pantheonSharedBoard'
|
|
22
|
+
|
|
23
|
+
/** Construction inputs mirror the original plugin.ts module-scope board. */
|
|
24
|
+
const BOARD_OPTIONS = {
|
|
25
|
+
maxConcurrentPerAgent: 3,
|
|
26
|
+
signalDir: '.pantheon/deepwork/board-signals',
|
|
27
|
+
} as const
|
|
28
|
+
|
|
29
|
+
export function getSharedBoard(): BackgroundJobBoard {
|
|
30
|
+
const host = globalThis as { [BOARD_KEY]?: BackgroundJobBoard }
|
|
31
|
+
const existing = host[BOARD_KEY]
|
|
32
|
+
if (existing instanceof BackgroundJobBoard) return existing
|
|
33
|
+
const board = new BackgroundJobBoard(BOARD_OPTIONS)
|
|
34
|
+
board.setPersistence(new FilePersistenceAdapter('.pantheon/board/state.json'))
|
|
35
|
+
host[BOARD_KEY] = board
|
|
36
|
+
return board
|
|
37
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Result Guard — detects empty task() results from native opencode
|
|
3
|
+
* subagent calls and converts them to explicit errors.
|
|
4
|
+
*
|
|
5
|
+
* Bug context (reproduced 2026-09-10): task() native creates a child session
|
|
6
|
+
* that inherits the parent transcript. When the payload exceeds the provider's
|
|
7
|
+
* admission limit (e.g. free-tier max_outstanding_uncached_prefill_tokens=1000
|
|
8
|
+
* vs 57k incoming tokens), the stream errors with BackendAdmissionRejected.
|
|
9
|
+
* The error is NOT propagated — the child loop exits normally, the child
|
|
10
|
+
* session goes idle with zero assistant/tool output, and opencode marks the
|
|
11
|
+
* task as `completed` with empty content. The parent LLM receives an empty
|
|
12
|
+
* result and proceeds as if the task succeeded.
|
|
13
|
+
*
|
|
14
|
+
* The guard intercepts this in the `tool.execute.after` hook: when the tool
|
|
15
|
+
* is `task` and the output is empty/whitespace-only, it replaces the output
|
|
16
|
+
* with an explicit error message so the parent sees a failure, not silence.
|
|
17
|
+
*
|
|
18
|
+
* Pure TypeScript — zero runtime dependencies. Meant to be wired into the
|
|
19
|
+
* `combinedAfter` hook chain in plugin.ts alongside the sandbox and read
|
|
20
|
+
* enhancer handlers.
|
|
21
|
+
*
|
|
22
|
+
* @module task-result-guard
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { createPantheonLogger } from './logger.ts'
|
|
26
|
+
|
|
27
|
+
const log = createPantheonLogger({ module: 'pantheon-task-result-guard' })
|
|
28
|
+
|
|
29
|
+
// ─── Types ─────────────────────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
/** Input shape of the opencode `tool.execute.after` hook. */
|
|
32
|
+
export interface TaskGuardInput {
|
|
33
|
+
tool: string
|
|
34
|
+
sessionID: string
|
|
35
|
+
callID: string
|
|
36
|
+
args: unknown
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Output shape of the opencode `tool.execute.after` hook (mutable). */
|
|
40
|
+
export interface TaskGuardOutput {
|
|
41
|
+
title?: string
|
|
42
|
+
output: string
|
|
43
|
+
metadata?: Record<string, unknown>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The `tool.execute.after` handler shape. */
|
|
47
|
+
export type TaskResultGuardHandler = (
|
|
48
|
+
input: TaskGuardInput,
|
|
49
|
+
output: TaskGuardOutput,
|
|
50
|
+
) => Promise<void>
|
|
51
|
+
|
|
52
|
+
export interface TaskResultGuardOptions {
|
|
53
|
+
/** Injectable logger (defaults to the Pantheon file log). */
|
|
54
|
+
logger?: { warn: (message: string) => void }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ─── Constants ─────────────────────────────────────────────────────────
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The error message injected when a task() result is empty.
|
|
61
|
+
* Keeps the historical "no assistant or tool output" contract text.
|
|
62
|
+
*/
|
|
63
|
+
export const EMPTY_TASK_ERROR =
|
|
64
|
+
'ERROR: task() returned empty output — child session produced no assistant or tool output. ' +
|
|
65
|
+
'This typically means the provider rejected the request (admission control / rate limit) ' +
|
|
66
|
+
'or the child session crashed before producing any response. ' +
|
|
67
|
+
'Consider splitting the work into a smaller task() or retrying the child session.'
|
|
68
|
+
|
|
69
|
+
// ─── Implementation ────────────────────────────────────────────────────
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Whether a result carries any text content (whitespace-only counts as empty).
|
|
73
|
+
*/
|
|
74
|
+
function isEmptyOutput(output: unknown): boolean {
|
|
75
|
+
if (output == null) return true
|
|
76
|
+
if (typeof output !== 'string') return true
|
|
77
|
+
return output.trim() === ''
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Create a task result guard handler for the `tool.execute.after` hook.
|
|
82
|
+
*
|
|
83
|
+
* When the tool is `task` and the output is empty/whitespace-only, replaces
|
|
84
|
+
* the output with an explicit error message. All other tools pass through
|
|
85
|
+
* untouched.
|
|
86
|
+
*
|
|
87
|
+
* @returns A `ToolExecuteAfterHandler`-compatible async function.
|
|
88
|
+
*/
|
|
89
|
+
export function createTaskResultGuard(options?: TaskResultGuardOptions): TaskResultGuardHandler {
|
|
90
|
+
const warn = options?.logger?.warn ?? ((message: string) => log.warn(message))
|
|
91
|
+
|
|
92
|
+
return async (input: TaskGuardInput, output: TaskGuardOutput): Promise<void> => {
|
|
93
|
+
// Only intercept the `task` tool — all others pass through untouched.
|
|
94
|
+
if (input.tool !== 'task') return
|
|
95
|
+
|
|
96
|
+
// Only flag truly empty results — non-empty content is the happy path.
|
|
97
|
+
if (!isEmptyOutput(output.output)) return
|
|
98
|
+
|
|
99
|
+
warn(
|
|
100
|
+
`[task-result-guard] Empty task() result detected on session ${input.sessionID} ` +
|
|
101
|
+
`(callID=${input.callID}). Replacing with explicit error.`,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
output.output = EMPTY_TASK_ERROR
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* TODO Enforcer (Wave 1) — keeps root/non-board sessions working on their
|
|
3
3
|
* todo list when the session goes idle.
|
|
4
4
|
*
|
|
5
|
-
* The plugin's `event` hook dispatches `session.idle`: board-child sessions
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The plugin's `event` hook dispatches `session.idle`: board-child sessions
|
|
6
|
+
* are owned by the board transition path, everything else (roots, non-board
|
|
7
|
+
* sessions) goes to `TodoEnforcer.onIdle`. The enforcer
|
|
8
8
|
* re-injects a continuation prompt when the session went idle with incomplete
|
|
9
9
|
* todos, so the agent keeps working on its task list instead of stopping.
|
|
10
10
|
*
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/** Host-real context ceiling probe for C9/tool filtering. */
|
|
2
|
+
|
|
3
|
+
import type { PluginInput } from '@opencode-ai/plugin'
|
|
4
|
+
import { createPantheonLogger, type PantheonLogger } from './logger.ts'
|
|
5
|
+
import type { NativeTaskStatus } from './native-task-status.ts'
|
|
6
|
+
|
|
7
|
+
export interface ToolCeilingSnapshot {
|
|
8
|
+
usage: { inputTokens: number; outputTokens: number }
|
|
9
|
+
limit: { contextTokens: number }
|
|
10
|
+
supportsToolFiltering: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ToolCeilingResult =
|
|
14
|
+
| {
|
|
15
|
+
status: 'OK'
|
|
16
|
+
ceiling: number
|
|
17
|
+
usage: ToolCeilingSnapshot['usage']
|
|
18
|
+
limit: ToolCeilingSnapshot['limit']
|
|
19
|
+
}
|
|
20
|
+
| { status: Exclude<NativeTaskStatus, 'OK'>; detail: string }
|
|
21
|
+
|
|
22
|
+
export type HostToolCeilingSource = () => unknown | Promise<unknown>
|
|
23
|
+
|
|
24
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
25
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isFiniteNonNegative(value: unknown): value is number {
|
|
29
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isSnapshot(value: unknown): value is ToolCeilingSnapshot {
|
|
33
|
+
if (!isRecord(value) || !isRecord(value.usage) || !isRecord(value.limit)) return false
|
|
34
|
+
return (
|
|
35
|
+
isFiniteNonNegative(value.usage.inputTokens) &&
|
|
36
|
+
isFiniteNonNegative(value.usage.outputTokens) &&
|
|
37
|
+
isFiniteNonNegative(value.limit.contextTokens) &&
|
|
38
|
+
typeof value.supportsToolFiltering === 'boolean'
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Probe exact host usage/limit without estimation, fallback, or retry. */
|
|
43
|
+
export async function probeToolCeiling(source?: HostToolCeilingSource): Promise<ToolCeilingResult> {
|
|
44
|
+
if (source === undefined)
|
|
45
|
+
return { status: 'UNSUPPORTED', detail: 'host SDK exposes no context probe' }
|
|
46
|
+
|
|
47
|
+
let raw: unknown
|
|
48
|
+
try {
|
|
49
|
+
raw = await source()
|
|
50
|
+
} catch (error: unknown) {
|
|
51
|
+
return { status: 'UNAVAILABLE', detail: error instanceof Error ? error.message : String(error) }
|
|
52
|
+
}
|
|
53
|
+
if (!isSnapshot(raw))
|
|
54
|
+
return { status: 'CORRUPT_DATA', detail: 'host context probe returned malformed data' }
|
|
55
|
+
if (raw.supportsToolFiltering === false) {
|
|
56
|
+
return { status: 'UNSUPPORTED', detail: 'host SDK does not filter tools' }
|
|
57
|
+
}
|
|
58
|
+
const used = raw.usage.inputTokens + raw.usage.outputTokens
|
|
59
|
+
if (used > raw.limit.contextTokens) {
|
|
60
|
+
return { status: 'CORRUPT_DATA', detail: 'host usage exceeds context limit' }
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
status: 'OK',
|
|
64
|
+
ceiling: raw.limit.contextTokens - used,
|
|
65
|
+
usage: raw.usage,
|
|
66
|
+
limit: raw.limit,
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Read a ceiling from the actual OpenCode SDK event and provider catalogue.
|
|
72
|
+
*
|
|
73
|
+
* `message.updated` is the SDK's runtime usage source (`info.tokens`). The
|
|
74
|
+
* provider catalogue supplies the selected model's context limit and its
|
|
75
|
+
* `capabilities.toolcall` flag. This adapter intentionally does not accept a
|
|
76
|
+
* caller-provided snapshot/callback, so tests cannot accidentally turn a
|
|
77
|
+
* fixture into a claimed host probe.
|
|
78
|
+
*/
|
|
79
|
+
export async function probeToolCeilingFromHost(
|
|
80
|
+
client: PluginInput['client'],
|
|
81
|
+
event: unknown,
|
|
82
|
+
): Promise<ToolCeilingResult> {
|
|
83
|
+
if (!isRecord(event) || event.type !== 'message.updated' || !isRecord(event.properties)) {
|
|
84
|
+
return { status: 'UNSUPPORTED', detail: 'host SDK event has no message usage' }
|
|
85
|
+
}
|
|
86
|
+
const info = event.properties.info
|
|
87
|
+
if (
|
|
88
|
+
!isRecord(info) ||
|
|
89
|
+
typeof info.providerID !== 'string' ||
|
|
90
|
+
typeof info.modelID !== 'string' ||
|
|
91
|
+
!isRecord(info.tokens)
|
|
92
|
+
) {
|
|
93
|
+
return { status: 'UNSUPPORTED', detail: 'host SDK message has no token usage' }
|
|
94
|
+
}
|
|
95
|
+
const providerID = info.providerID as string
|
|
96
|
+
const modelID = info.modelID as string
|
|
97
|
+
const tokens = info.tokens as Record<string, unknown>
|
|
98
|
+
|
|
99
|
+
let providersResult: unknown
|
|
100
|
+
try {
|
|
101
|
+
providersResult = await client.config.providers()
|
|
102
|
+
} catch (error: unknown) {
|
|
103
|
+
return { status: 'UNAVAILABLE', detail: error instanceof Error ? error.message : String(error) }
|
|
104
|
+
}
|
|
105
|
+
if (!isRecord(providersResult) || providersResult.error !== undefined) {
|
|
106
|
+
return { status: 'UNAVAILABLE', detail: 'host SDK provider catalogue unavailable' }
|
|
107
|
+
}
|
|
108
|
+
const data = providersResult.data
|
|
109
|
+
if (!isRecord(data) || !Array.isArray(data.providers)) {
|
|
110
|
+
return { status: 'CORRUPT_DATA', detail: 'host SDK provider catalogue malformed' }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const provider = data.providers.find(
|
|
114
|
+
(candidate) =>
|
|
115
|
+
isRecord(candidate) &&
|
|
116
|
+
candidate.id === providerID &&
|
|
117
|
+
isRecord(candidate.models) &&
|
|
118
|
+
isRecord(candidate.models[modelID]),
|
|
119
|
+
)
|
|
120
|
+
if (!isRecord(provider) || !isRecord(provider.models)) {
|
|
121
|
+
return { status: 'UNSUPPORTED', detail: 'host SDK model metadata unavailable' }
|
|
122
|
+
}
|
|
123
|
+
const model = provider.models[modelID]
|
|
124
|
+
if (!isRecord(model) || !isRecord(model.limit) || !isRecord(model.capabilities)) {
|
|
125
|
+
return { status: 'UNSUPPORTED', detail: 'host SDK model ceiling capability unavailable' }
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return probeToolCeiling(() => ({
|
|
129
|
+
usage: { inputTokens: tokens.input, outputTokens: tokens.output },
|
|
130
|
+
limit: { contextTokens: (model.limit as Record<string, unknown>).context },
|
|
131
|
+
supportsToolFiltering: (model.capabilities as Record<string, unknown>).toolcall,
|
|
132
|
+
}))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const log = createPantheonLogger({ module: 'pantheon-tool-ceiling' })
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Handle the host usage event and retain the result for the compaction hook.
|
|
139
|
+
* Malformed SDK events are diagnostic-only: they must never break the event
|
|
140
|
+
* pipeline or create an entry under an invalid session identifier.
|
|
141
|
+
*/
|
|
142
|
+
export async function handleToolCeilingEvent(
|
|
143
|
+
client: PluginInput['client'],
|
|
144
|
+
event: unknown,
|
|
145
|
+
ceilings: Map<string, ToolCeilingResult>,
|
|
146
|
+
logger: Pick<PantheonLogger, 'warn'> = log,
|
|
147
|
+
): Promise<ToolCeilingResult> {
|
|
148
|
+
const sessionID = (
|
|
149
|
+
event as { properties?: { info?: { sessionID?: unknown } } } | null | undefined
|
|
150
|
+
)?.properties?.info?.sessionID
|
|
151
|
+
if (typeof sessionID !== 'string' || sessionID.trim() === '') {
|
|
152
|
+
logger.warn('[Pantheon Plugin] message.updated event has no valid sessionID')
|
|
153
|
+
return { status: 'UNSUPPORTED', detail: 'host SDK event has no valid sessionID' }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const result = await probeToolCeilingFromHost(client, event)
|
|
157
|
+
ceilings.set(sessionID, result)
|
|
158
|
+
return result
|
|
159
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Context — the structural view of the context opencode passes to a
|
|
3
|
+
* tool's `execute()`.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from `delegation.ts` (Fase 2 of the delegate removal) so the
|
|
6
|
+
* surviving structural tools (cost-command, model-command, goal-loop) no
|
|
7
|
+
* longer depend on the delegation module. Pure type — zero runtime code.
|
|
8
|
+
*
|
|
9
|
+
* @module tool-context
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Structural view of the tool context opencode passes to execute(). */
|
|
13
|
+
export interface ToolContextLike {
|
|
14
|
+
sessionID: string
|
|
15
|
+
directory?: string
|
|
16
|
+
worktree?: string
|
|
17
|
+
/**
|
|
18
|
+
* The OpenCode SDK's ToolContext declares this as required. It remains
|
|
19
|
+
* optional here because the structural test/embedding surface can be
|
|
20
|
+
* supplied by older hosts; enforcement must skip when it is absent.
|
|
21
|
+
*/
|
|
22
|
+
agent?: string
|
|
23
|
+
}
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import type { BackgroundJobBoard } from './background-job-board.ts'
|
|
20
|
-
import type { DelegationClient } from './delegation-finalize.ts'
|
|
21
20
|
import type { GoalStore } from './goal-store.ts'
|
|
22
21
|
import type { TodoEnforcer } from './todo-enforcer.ts'
|
|
23
22
|
|
|
@@ -57,8 +56,6 @@ export interface VisionHandler {
|
|
|
57
56
|
export interface PantheonV2Bridge {
|
|
58
57
|
/** Background job board — tracks running/completed/cancelled delegated jobs. */
|
|
59
58
|
board?: BackgroundJobBoard
|
|
60
|
-
/** Structural delegation client — creates child sessions and sends prompts. */
|
|
61
|
-
delegationClient?: DelegationClient
|
|
62
59
|
/** Goal store — file-based persistence for full-auto goal loop. */
|
|
63
60
|
goalStore?: GoalStore
|
|
64
61
|
/** Todo enforcer — idle continuation when todos are incomplete. */
|
|
@@ -85,7 +82,7 @@ export const BRIDGE_OPTIONS_KEY = '__pantheonV1Bridge' as const
|
|
|
85
82
|
* @example
|
|
86
83
|
* ```ts
|
|
87
84
|
* // In V1 plugin setup (plugin.ts):
|
|
88
|
-
* const bridge = createV2Bridge({ board,
|
|
85
|
+
* const bridge = createV2Bridge({ board, goalStore, ... })
|
|
89
86
|
* // Then pass bridge to V2 context via options
|
|
90
87
|
* ```
|
|
91
88
|
*/
|
package/src/plugin-v2.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Pantheon V2 Plugin — full orchestration plugin for OpenCode V2.
|
|
3
3
|
*
|
|
4
4
|
* Registers:
|
|
5
|
-
* -
|
|
5
|
+
* - 6 orchestration tools via V2 tool.transform (with V1 bridge fallback)
|
|
6
6
|
* - 4 event subscriptions (session.created, idle, error, compacted)
|
|
7
7
|
* - Session hooks (prompt, context) and tool hooks (execute.before/after)
|
|
8
8
|
* - Permission hooks for custom authorization
|
|
@@ -408,11 +408,11 @@ async function onSessionIdle(_event: V2SessionEvent): Promise<void> {
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
async function onSessionError(_event: V2SessionEvent): Promise<void> {
|
|
411
|
-
// Error handling —
|
|
411
|
+
// Error handling — board transition to error.
|
|
412
412
|
const bridge = resolveBridge()
|
|
413
413
|
if (bridge?.board != null) {
|
|
414
|
-
// Bridge available:
|
|
415
|
-
// V2 only logs — V1
|
|
414
|
+
// Bridge available: error handling is done by the V1 event hook.
|
|
415
|
+
// V2 only logs — V1 owns the board transition.
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
|
|
@@ -640,9 +640,6 @@ function createV2ToolDefinitionsFromContext(_context: PluginContext): V2ToolDef[
|
|
|
640
640
|
'infrastructure through the V2 bridge (src/pantheon/v2-bridge.ts).'
|
|
641
641
|
|
|
642
642
|
const toolNames = [
|
|
643
|
-
'pantheon_delegate',
|
|
644
|
-
'pantheon_delegation_read',
|
|
645
|
-
'pantheon_delegation_list',
|
|
646
643
|
'hashline_edit',
|
|
647
644
|
'pantheon_goal_create',
|
|
648
645
|
'pantheon_goal_get',
|
|
@@ -652,14 +649,6 @@ function createV2ToolDefinitionsFromContext(_context: PluginContext): V2ToolDef[
|
|
|
652
649
|
]
|
|
653
650
|
|
|
654
651
|
const toolDescriptions: Record<string, string> = {
|
|
655
|
-
pantheon_delegate:
|
|
656
|
-
'Dispatch a background agent as a child session and register it on the job board. ' +
|
|
657
|
-
'Returns the readable alias (e.g. "apo-1"); read the result with pantheon_delegation_read.',
|
|
658
|
-
pantheon_delegation_read:
|
|
659
|
-
'Block until a background delegation finishes (completed/error/cancelled), then return ' +
|
|
660
|
-
'its report markdown (with a trailing agent-activity section) and mark the job reconciled.',
|
|
661
|
-
pantheon_delegation_list:
|
|
662
|
-
'List background delegations for the current session, with [unread] for finished jobs.',
|
|
663
652
|
hashline_edit:
|
|
664
653
|
'Edit a file anchored by hashline refs (LINE#TAG) instead of raw line numbers. ' +
|
|
665
654
|
'Ops: replace, append, prepend, delete. ALL refs validated against ORIGINAL file first.',
|
|
@@ -681,12 +670,10 @@ function createV2ToolDefinitionsFromContext(_context: PluginContext): V2ToolDef[
|
|
|
681
670
|
name,
|
|
682
671
|
description: toolDescriptions[name] ?? `Pantheon tool: ${name}`,
|
|
683
672
|
input: { type: 'object' as const, properties: {} },
|
|
684
|
-
// FOLLOW-UP:
|
|
685
|
-
//
|
|
686
|
-
//
|
|
687
|
-
//
|
|
688
|
-
// are likewise unwired. Until then, placeholders resolve to the object
|
|
689
|
-
// shape so the beta host never sees a bare string.
|
|
673
|
+
// FOLLOW-UP: wire the real tool wrappers (costCommand/goalTools) once V1
|
|
674
|
+
// infrastructure is resolvable in the V2 standalone context. Until then,
|
|
675
|
+
// placeholders resolve to the object shape so the beta host never sees a
|
|
676
|
+
// bare string.
|
|
690
677
|
execute: async (_input: Record<string, unknown>, _context: unknown): Promise<V2ToolResult> => {
|
|
691
678
|
return { output: `${name}: ${v2UnavailableMessage}` }
|
|
692
679
|
},
|