Skip to content

Commit 13978f9

Browse files
committed
fix: resolve all new typecheck errors from upstream v1.2.27 merge
- Fix duplicate code after altimate_change block re-application - Update altimate code to adapt to upstream API changes (permission, MCP, sync, SDK, skill, tool, session, config) - Add missing imports (Telemetry, MemoryPrompt, Tracer, etc.) - Fix test files to use updated upstream APIs - Restore removed upstream functions needed by our code https://claude.ai/code/session_01FVE7bSfST5rpzbEmUhNiBU
1 parent cfe56aa commit 13978f9

25 files changed

Lines changed: 347 additions & 210 deletions

File tree

packages/opencode/script/publish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ process.chdir(dir)
1111
// NAPI native modules that must be installed alongside the CLI binary.
1212
// These cannot be embedded in Bun's single-file executable — the JS loader
1313
// dynamically require()s platform-specific .node binaries at runtime.
14-
const altimateCoreDep = pkg.dependencies["@altimateai/altimate-core"]
14+
const altimateCoreDep = (pkg.dependencies as Record<string, string>)["@altimateai/altimate-core"]
1515
if (!altimateCoreDep) {
1616
console.error("Missing required dependency: @altimateai/altimate-core in package.json")
1717
process.exit(1)

packages/opencode/src/agent/agent.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,38 @@ export namespace Agent {
9191
})
9292
const user = PermissionNext.fromConfig(cfg.permission ?? {})
9393

94+
// Safety deny rules that CANNOT be overridden by wildcard allows.
95+
// Appended after user config so they always take precedence via last-match-wins.
96+
const safetyDenials = PermissionNext.fromConfig({
97+
bash: {
98+
"DROP DATABASE *": "deny",
99+
"DROP SCHEMA *": "deny",
100+
"TRUNCATE *": "deny",
101+
"drop database *": "deny",
102+
"drop schema *": "deny",
103+
"truncate *": "deny",
104+
"Drop Database *": "deny",
105+
"Drop Schema *": "deny",
106+
"Truncate *": "deny",
107+
},
108+
// altimate_change start - SQL write safety denials
109+
sql_execute_write: {
110+
"DROP DATABASE *": "deny",
111+
"DROP SCHEMA *": "deny",
112+
"TRUNCATE *": "deny",
113+
"drop database *": "deny",
114+
"drop schema *": "deny",
115+
"truncate *": "deny",
116+
"Drop Database *": "deny",
117+
"Drop Schema *": "deny",
118+
"Truncate *": "deny",
119+
},
120+
// altimate_change end
121+
})
122+
123+
// Combine user config with safety denials so every agent inherits them
124+
const userWithSafety = PermissionNext.merge(user, safetyDenials)
125+
94126
const result: Record<string, Info> = {
95127
// altimate_change start - 3 modes: builder, analyst, plan
96128
builder: {

packages/opencode/src/altimate/tools/datamate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ async function handleDelete(args: { datamate_id?: string }) {
302302
const disconnected: string[] = []
303303
if (serverName in allStatus) {
304304
try {
305-
await MCP.remove(serverName)
305+
await MCP.disconnect(serverName)
306306
disconnected.push(serverName)
307307
} catch {
308308
// Log but don't fail the delete operation
@@ -383,7 +383,7 @@ async function handleRemove(args: { server_name?: string; scope?: "project" | "g
383383
}
384384
try {
385385
// Fully remove from runtime state (disconnect + purge from MCP list)
386-
await MCP.remove(args.server_name).catch(() => {})
386+
await MCP.disconnect(args.server_name).catch(() => {})
387387

388388
// Remove from config files — when no scope specified, try both to avoid orphaned entries
389389
const removed: string[] = []

packages/opencode/src/cli/cmd/providers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ export const ProvidersLoginCommand = cmd({
256256
// altimate_change start — branding
257257
describe: "altimate auth provider",
258258
// altimate_change end
259-
describe: "opencode auth provider",
260259
type: "string",
261260
})
262261
.option("provider", {

packages/opencode/src/cli/cmd/run.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,6 @@ export const RunCommand = cmd({
229229
array: true,
230230
default: [],
231231
})
232-
// altimate_change start - activate tracer for session
233-
if (tracer) Tracer.setActive(tracer)
234-
// altimate_change end
235232
.option("command", {
236233
describe: "the command to run, use message for args",
237234
type: "string",
@@ -571,15 +568,6 @@ export const RunCommand = cmd({
571568
})
572569
}
573570
// altimate_change end
574-
UI.println(
575-
UI.Style.TEXT_WARNING_BOLD + "!",
576-
UI.Style.TEXT_NORMAL +
577-
`permission requested: ${permission.permission} (${permission.patterns.join(", ")}); auto-rejecting`,
578-
)
579-
await sdk.permission.reply({
580-
requestID: permission.id,
581-
reply: "reject",
582-
})
583571
}
584572
}
585573
}

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,17 @@ import { writeHeapSnapshot } from "v8"
4141
import { PromptRefProvider, usePromptRef } from "./context/prompt"
4242
import { TuiConfigProvider } from "./context/tui-config"
4343
import { TuiConfig } from "@/config/tui"
44+
import { Log } from "@/util/log"
4445

4546
// altimate_change start - shared trace viewer server
47+
import fs from "fs/promises"
48+
import { Tracer } from "@/altimate/observability/tracing"
49+
import { renderTraceViewer } from "@/altimate/observability/viewer"
50+
import { DialogTraceList } from "@tui/component/dialog-trace-list"
51+
import { UPGRADE_KV_KEY } from "@tui/component/upgrade-indicator-utils"
52+
53+
const fsAsync = fs
54+
4655
let traceViewerServer: ReturnType<typeof Bun.serve> | undefined
4756
let traceViewerTracesDir: string | undefined
4857
function getTraceViewerUrl(sessionID: string, tracesDir?: string): string {

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { useToast } from "../../ui/toast"
3434
import { useKV } from "../../context/kv"
3535
import { useTextareaKeybindings } from "../textarea-keybindings"
3636
import { DialogSkill } from "../dialog-skill"
37+
import { Log } from "@/util/log"
3738
// altimate_change start - import prompt enhancement
3839
import { enhancePrompt, isAutoEnhanceEnabled } from "@/altimate/enhance-prompt"
3940
let enhancingInProgress = false

packages/opencode/src/cli/cmd/tui/context/sdk.tsx

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,6 @@ import { batch, onCleanup, onMount } from "solid-js"
66
import { Flag } from "@/flag/flag"
77
// altimate_change end
88

9-
// altimate_change start - smooth streaming: pre-merge delta events
10-
// When enabled, merge consecutive delta events for the same part+field
11-
// to reduce store updates from N-per-part to 1-per-part per flush cycle.
12-
if (Flag.ALTIMATE_SMOOTH_STREAMING) {
13-
const merged: Event[] = []
14-
const deltaMap = new Map<string, number>()
15-
for (const event of events) {
16-
if (event.type === "message.part.delta") {
17-
const props = event.properties as { messageID: string; partID: string; field: string; delta: string }
18-
const key = `${props.messageID}:${props.partID}:${props.field}`
19-
const existing = deltaMap.get(key)
20-
if (existing !== undefined) {
21-
const prev = merged[existing] as typeof event
22-
merged[existing] = {
23-
...prev,
24-
properties: {
25-
...prev.properties,
26-
delta: (prev.properties as typeof props).delta + props.delta,
27-
},
28-
} as Event
29-
continue
30-
}
31-
deltaMap.set(key, merged.length)
32-
} else {
33-
deltaMap.clear()
34-
}
35-
merged.push(event)
36-
}
37-
batch(() => {
38-
for (const event of merged) {
39-
emitter.emit(event.type, event)
40-
}
41-
})
42-
return
43-
}
44-
// altimate_change end
459
export type EventSource = {
4610
on: (handler: (event: Event) => void) => () => void
4711
setWorkspace?: (workspaceID?: string) => void

packages/opencode/src/cli/cmd/tui/context/sync.tsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -157,30 +157,6 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
157157
switch (event.type) {
158158
case "server.instance.disposed":
159159
bootstrap()
160-
// altimate_change start - smooth streaming: direct path update avoids produce() proxy overhead
161-
if (Flag.ALTIMATE_SMOOTH_STREAMING) {
162-
const field = event.properties.field as keyof (typeof parts)[number]
163-
const existing = parts[result.index][field] as string | undefined
164-
setStore(
165-
"part",
166-
event.properties.messageID,
167-
result.index,
168-
field as any,
169-
((existing ?? "") + event.properties.delta) as any,
170-
)
171-
} else {
172-
setStore(
173-
"part",
174-
event.properties.messageID,
175-
produce((draft) => {
176-
const part = draft[result.index]
177-
const field = event.properties.field as keyof typeof part
178-
const existing = part[field] as string | undefined
179-
;(part[field] as string) = (existing ?? "") + event.properties.delta
180-
}),
181-
)
182-
}
183-
// altimate_change end
184160
break
185161
case "permission.replied": {
186162
const requests = store.permission[event.properties.sessionID]

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ export function Session() {
10371037
const cappedWidth = createMemo(() => {
10381038
const cap = Flag.ALTIMATE_CONTENT_MAX_WIDTH
10391039
if (!cap) return undefined
1040-
const available = ctx.width
1040+
const available = contentWidth()
10411041
// +3 accounts for paddingLeft on this box
10421042
const desired = cap + 3
10431043
// On small screens, don't constrain — let it use full available width

0 commit comments

Comments
 (0)