Dashboard › opencode › Session 1eNlLkjIwbrt
1eNlLkjIwbrtrSrVyRead-only investigation in /home/byk/Code/opencode. Trace how the web/desktop client loads provider/model lists and creates a new session for a selected project directory. Identify: (1) which HTTP endpoints are called and how directory is passed; (2) every path that can yield HTTP 499 or client-aborted responses; (3) project bootstrap work shared by provider discovery and session creation; (4) likely project-specific failure modes when no .opencode config exists; (5) exact log messages/errors expected. Inspect current source only and cite exact file:line references. Do not edit files or run tests. Return concise findings and a ranked diagnostic checklist.
/home/byk/Code/opencode/packages/client/test/promise.test.ts /home/byk/Code/opencode/packages/client/test/import-boundaries.test.ts /home/byk/Code/opencode/packages/client/test/effect.test.ts /home/byk/Code/opencode/packages/client/test/contract-identity.test.ts /home/byk/Code/opencode/packages/client/sst-env.d.ts /home/byk/Code/opencode/packages/opencode/parsers-config.ts /home/byk/Code/opencode/packages/opencode/specs/v2/api.ts /home/byk/Code/opencode/packages/opencode/sst-env.d.ts /home/byk/Code/opencode/packages/opencode/test/permission-task.test.ts /home/byk/Code/opencode/packages/opencode/test/event-manifest.test.ts /home/byk/Code/opencode/packages/opencode/test/preload.ts /home/byk/Code/opencode/packages/opencode/test/acp/usage.test.ts /home/byk/Code/opencode/packages/opencode/test/acp/service-session.test.ts /home/byk/Code/opencode/packages/opencode/test/acp/session.test.ts /home/byk/Code/opencode/packages/opencode/test/acp/permission.test.ts /home/byk/Code/opencode/packages/op...
<path>/home/byk/Code/opencode/packages/app/src</path> <type>directory</type> <entries> addons/ app.tsx assets/ components/ constants/ context/ custom-elements.d.ts desktop-menu.test.ts desktop-menu.ts entry.tsx env.d.ts hooks/ i18n/ index.css index.ts pages/ sst-env.d.ts theme-preload.test.ts updater.ts utils/ wsl/ (21 entries) </entries>
<path>/home/byk/Code/opencode/packages/desktop/src</path> <type>directory</type> <entries> main/ preload/ renderer/ (3 entries) </entries>
Found 100 matches (more matches available)
/home/byk/Code/opencode/packages/app/src/app.tsx:
Line 66: import { createSessionLineage } from "@/pages/session/session-lineage"
Line 120: // subtree (SessionRouteErrorBoundary resets and createSessionLineage
Line 151: const current = createSessionLineage(
/home/byk/Code/opencode/packages/app/src/utils/server-compat.ts:
Line 164: const result = await legacy(value?.location ?? undefined).session.create({
Line 381: const methods = ((await legacy(value.location).provider.auth()).data?.[value.integrationID] ?? []).map(
Line 412: const result = await legacy(value.location).provider.oauth.authorize(
Line 430: await legacy(value.location).provider.oauth.callback(
Line 439: await legacy(value.location).provider.oauth.callback(
/home/byk/Code/opencode/packages/app/src/pages/session.tsx:
Line 70: createSessionComposerController,
Line 71: ...
Found 5 matches
/home/byk/Code/opencode/packages/app/src/utils/server-compat.ts:
Line 164: const result = await legacy(value?.location ?? undefined).session.create({
Line 381: const methods = ((await legacy(value.location).provider.auth()).data?.[value.integrationID] ?? []).map(
/home/byk/Code/opencode/packages/app/src/context/global-sync/bootstrap.ts:
Line 233: const result = await legacy.provider.list()
Line 238: sdk.provider.list(location),
/home/byk/Code/opencode/packages/app/src/components/prompt-input/submit.ts:
Line 404: .api.session.create({
<path>/home/byk/Code/opencode/packages/app/src/context/global-sync/bootstrap.ts</path>
<type>file</type>
<content>
1: import type {
2: Config,
3: OpencodeClient,
4: Path,
5: PermissionRequest,
6: Project,
7: ProviderAuthResponse,
8: QuestionRequest,
9: ReferenceInfo,
10: Session,
11: } from "@opencode-ai/sdk/v2/client"
12: import type {
13: AgentListInput,
14: AgentListOutput,
15: CatalogApi,
16: CommandInfo,
17: CommandListInput,
18: CommandListOutput,
19: ProjectCurrentInput,
20: ProjectCurrentOutput,
21: ProjectListOutput,
22: ReferenceListInput,
23: ReferenceListOutput,
24: SessionApi,
25: } from "@opencode-ai/client/promise"
26: import { showToast } from "@/utils/toast"
27: import { getFilename } from "@opencode-ai/core/util/path"
28: import { retry } from "@opencode-ai/core/util/retry"
29: import { batch } from "solid-js"
30: import { produce, reconcile, type SetStoreFunction, type Store } from "solid-js/store"
31: import type { State, ...
<path>/home/byk/Code/opencode/packages/app/src/context/global-sync/bootstrap.ts</path>
<type>file</type>
<content>
330: export async function bootstrapDirectory(input: {
331: directory: string
332: scope: ServerScope
333: mcp: boolean
334: sdk: OpencodeClient
335: api: CatalogApi & {
336: readonly agent: AgentListApi
337: readonly command: CommandListApi
338: readonly mcp: McpApi
339: readonly permission: PermissionApi
340: readonly project: ProjectApi
341: readonly question: QuestionApi
342: readonly reference: ReferenceListApi
343: readonly session: SessionApi
344: readonly vcs: VcsApi
345: }
346: store: Store<State>
347: setStore: SetStoreFunction<State>
348: vcsCache: VcsCache
349: loadSessions: (directory: string) => Promise<void> | void
350: translate: (key: string, vars?: Record<string, string | number>) => string
351: global: {
352: config: Config
353: path: Path
354: project: Project[]
355: provider: ...
<path>/home/byk/Code/opencode/packages/app/src/components/prompt-input/submit.ts</path>
<type>file</type>
<content>
330: const images = input.imageAttachments().slice()
331: const mode = input.mode()
332:
333: if (text.trim().length === 0 && images.length === 0 && input.commentCount() === 0) {
334: if (input.working()) void abort()
335: return
336: }
337:
338: const modelSelection = input.model ?? local.model
339: const currentModel = modelSelection.current()
340: const currentAgent = local.agent.current()
341: const variant = modelSelection.variant.current()
342: if (!currentModel || !currentAgent) {
343: showToast({
344: title: language.t("prompt.toast.modelAgentRequired.title"),
345: description: language.t("prompt.toast.modelAgentRequired.description"),
346: })
347: return
348: }
349:
350: input.addToHistory(currentPrompt, mode)
351: input.resetHistoryNavigation()
352:
353: const ...
/home/byk/Code/opencode/packages/client/src/index.ts /home/byk/Code/opencode/packages/client/src/generated/types.ts /home/byk/Code/opencode/packages/client/src/generated/index.ts /home/byk/Code/opencode/packages/client/src/generated/client.ts /home/byk/Code/opencode/packages/client/src/generated/client-error.ts /home/byk/Code/opencode/packages/client/src/generated-effect/index.ts /home/byk/Code/opencode/packages/client/src/generated-effect/client.ts /home/byk/Code/opencode/packages/client/src/generated-effect/client-error.ts /home/byk/Code/opencode/packages/client/src/effect.ts /home/byk/Code/opencode/packages/client/src/contract.ts
No files found
Found 7 matches
/home/byk/Code/opencode/packages/app/src/context/global-sync/bootstrap.ts:
Line 15: CatalogApi,
Line 145: serverAPI: CatalogApi & { readonly project: ProjectApi }
Line 224: sdk: CatalogApi,
Line 335: api: CatalogApi & {
/home/byk/Code/opencode/packages/app/src/context/global-sync/bootstrap.test.ts:
Line 5: import type { AgentApi, CatalogApi, CommandApi, ReferenceApi } from "@opencode-ai/client/promise"
Line 231: const api = {} as CatalogApi
Line 258: } as unknown as CatalogApi
<path>/home/byk/Code/opencode/packages/client/package.json</path>
<type>file</type>
<content>
1: {
2: "$schema": "https://json.schemastore.org/package.json",
3: "name": "@opencode-ai/client",
4: "private": true,
5: "type": "module",
6: "license": "MIT",
7: "exports": {
8: ".": "./src/index.ts",
9: "./effect": "./src/effect.ts"
10: },
11: "scripts": {
12: "generate": "bun run script/build.ts",
13: "check:generated": "bun run generate && git diff --exit-code -- src/generated src/generated-effect",
14: "test": "bun test --timeout 5000",
15: "typecheck": "tsgo --noEmit"
16: },
17: "dependencies": {
18: "@opencode-ai/schema": "workspace:*",
19: "@opencode-ai/protocol": "workspace:*"
20: },
21: "peerDependencies": {
22: "effect": "4.0.0-beta.83"
23: },
24: "peerDependenciesMeta": {
25: "effect": {
26: "optional": true
27: }
28: },
29: "devDependencies": {
30: "@effect/platform-node": "catalog:",
31: ...
Found 1 matches /home/byk/Code/opencode/packages/client/package.json: Line 3: "name": "@opencode-ai/client",
/home/byk/Code/opencode/packages/codemode/test/promise.test.ts /home/byk/Code/opencode/packages/codemode/src/stdlib/promise.ts /home/byk/Code/opencode/packages/client/test/promise.test.ts /home/byk/Code/opencode/packages/core/test/plugin/promise.test.ts /home/byk/Code/opencode/packages/core/src/plugin/promise.ts /home/byk/Code/opencode/packages/opencode/src/effect/promise.ts
<path>/home/byk/Code/opencode/packages/client/src/index.ts</path>
<type>file</type>
<content>
1: export * from "./generated/index"
2: export type { EventsSubscribeOutput as OpenCodeEvent } from "./generated/types"
(End of file - total 2 lines)
</content>
No files found
<path>/home/byk/Code/opencode/packages/app/package.json</path>
<type>file</type>
<content>
1: {
2: "name": "@opencode-ai/app",
3: "version": "1.18.16",
4: "description": "",
5: "type": "module",
6: "exports": {
7: ".": "./src/index.ts",
8: "./desktop-menu": "./src/desktop-menu.ts",
9: "./i18n/desktop-native": "./src/i18n/desktop-native.ts",
10: "./updater": "./src/updater.ts",
11: "./wsl/types": "./src/wsl/types.ts",
12: "./vite": "./vite.js",
13: "./index.css": "./src/index.css"
14: },
15: "scripts": {
16: "typecheck": "tsgo -b",
17: "typecheck:e2e": "tsgo -p e2e/tsconfig.json",
18: "start": "vite",
19: "dev": "vite",
20: "build": "vite build",
21: "serve": "vite preview",
22: "test": "bun run test:unit && bun run test:browser",
23: "test:unit": "bun test --conditions=solid --only-failures --preload ./happydom.ts ./src",
24: "test:browser": "bun test --conditions=browser --preload ./happydom.ts ...
<path>/home/byk/Code/opencode/packages/app/vendor</path> <type>directory</type> <entries> opencode-ai-client-1.17.13-v2.tgz (1 entries) </entries>
No files found
No files found
<path>/home/byk/Code/opencode/node_modules/@opencode-ai</path> <type>directory</type> <entries> plugin/ script/ sdk/ (3 entries) </entries>
<path>/home/byk/Code/opencode/packages/app/node_modules</path> <type>directory</type> <entries> .bin/ .ts-dist/ .vite-temp/ @corvu/ @dnd-kit/ @happy-dom/ @kobalte/ @opencode-ai/ @pierre/ @playwright/ @sentry/ @shikijs/ @solid-primitives/ @solidjs/ @tailwindcss/ @tanstack/ @thisbeyond/ @tsconfig/ @types/ @typescript/ diff/ effect/ fuzzysort/ ghostty-web/ luxon/ marked-shiki/ marked/ remeda/ shiki/ solid-js/ solid-list/ solid-presence/ tailwindcss/ tw-animate-css/ typescript/ virtua/ vite-plugin-icons-spritesheet/ vite-plugin-solid/ vite/ (39 entries) </entries>
<path>/home/byk/Code/opencode/packages/app/node_modules/@opencode-ai</path> <type>directory</type> <entries> client/ core/ schema/ sdk/ session-ui/ ui/ (6 entries) </entries>
<path>/home/byk/Code/opencode/packages/app/node_modules/@opencode-ai/client</path> <type>directory</type> <entries> dist/ package.json README.md (3 entries) </entries>
Found 2 matches
/home/byk/Code/opencode/packages/server/src/api.ts:
Line 3: import { SessionLocationMiddleware } from "./middleware/session-location"
Line 7: sessionLocationMiddleware: SessionLocationMiddleware,
<path>/home/byk/Code/opencode/packages/server/src</path> <type>directory</type> <entries> api.ts auth.ts cors.ts handlers.ts handlers/ location.ts middleware/ pty-environment.ts routes.ts (9 entries) </entries>
Found 100 matches (more matches available)
/home/byk/Code/opencode/packages/cli/src/tui.ts:
Line 23: "/provider": { all: [], default: {}, connected: [] },
/home/byk/Code/opencode/packages/httpapi-codegen/test/generated/session.ts:
Line 28: .add(HttpApiEndpoint.make("GET")("health", "/session/health", { success: Endpoint0Success }))
Line 29: .add(HttpApiEndpoint.make("GET")("list", "/session", { query: Endpoint1Query, success: Endpoint1Success }))
Line 31: HttpApiEndpoint.make("GET")("get", "/session/:sessionID", {
Line 38: HttpApiEndpoint.make("POST")("interrupt", "/session/:sessionID/interrupt", {
/home/byk/Code/opencode/packages/cli/src/commands/handlers/api.test.ts:
Line 11: get: { operationId: "v2.session.get" },
Line 24: { paths: { "/api/session/{sessionID}": { get: { operationId: "v2.session.get" } } } },
/home/byk/Code/opencode/packages/llm/test/executor.test.ts:
Line 187: remaining: { requests: "499", ...
<path>/home/byk/Code/opencode/packages/protocol/src</path> <type>directory</type> <entries> api.ts errors.ts groups/ middleware/ (4 entries) </entries>
<path>/home/byk/Code/opencode/packages/protocol/src/groups</path> <type>directory</type> <entries> agent.ts command.ts credential.ts event.ts fs.ts health.ts integration.ts location.ts message.ts model.ts permission.ts project-copy.ts provider.ts pty.ts question.ts reference.ts session.ts skill.ts (18 entries) </entries>
<path>/home/byk/Code/opencode/packages/protocol/src/groups/provider.ts</path>
<type>file</type>
<content>
1: import { Provider } from "@opencode-ai/schema/provider"
2: import { Location } from "@opencode-ai/schema/location"
3: import { Schema } from "effect"
4: import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
5: import { ProviderNotFoundError, ServiceUnavailableError } from "../errors"
6: import { LocationQuery, locationQueryOpenApi } from "./location"
7:
8: export const ProviderGroup = HttpApiGroup.make("server.provider")
9: .add(
10: HttpApiEndpoint.get("provider.list", "/api/provider", {
11: query: LocationQuery,
12: success: Location.response(Schema.Array(Provider.Info)),
13: error: ServiceUnavailableError,
14: })
15: .annotateMerge(locationQueryOpenApi)
16: .annotateMerge(
17: OpenApi.annotations({
18: identifier: "v2.provider.list",
19: summary: "List providers",
20: ...
<path>/home/byk/Code/opencode/packages/protocol/src/groups/model.ts</path>
<type>file</type>
<content>
1: import { Model } from "@opencode-ai/schema/model"
2: import { Location } from "@opencode-ai/schema/location"
3: import { Schema } from "effect"
4: import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
5: import { ServiceUnavailableError } from "../errors"
6: import { LocationQuery, locationQueryOpenApi } from "./location"
7:
8: export const ModelGroup = HttpApiGroup.make("server.model")
9: .add(
10: HttpApiEndpoint.get("model.list", "/api/model", {
11: query: LocationQuery,
12: success: Location.response(Schema.Array(Model.Info)),
13: error: ServiceUnavailableError,
14: })
15: .annotateMerge(locationQueryOpenApi)
16: .annotateMerge(
17: OpenApi.annotations({
18: identifier: "v2.model.list",
19: summary: "List models",
20: description: "Retrieve available models ordered by ...
<path>/home/byk/Code/opencode/packages/protocol/src/groups/session.ts</path>
<type>file</type>
<content>
1: import { SessionMessage } from "@opencode-ai/schema/session-message"
2: import { SessionInput } from "@opencode-ai/schema/session-input"
3: import { PromptInput } from "@opencode-ai/schema/prompt-input"
4: import { Session } from "@opencode-ai/schema/session"
5: import { Project } from "@opencode-ai/schema/project"
6: import { AbsolutePath, NonNegativeInt, PositiveInt, RelativePath, statics } from "@opencode-ai/schema/schema"
7: import { Workspace } from "@opencode-ai/schema/workspace"
8: import { Context, Effect, Encoding, Result, Schema, Struct } from "effect"
9: import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi"
10: import {
11: ConflictError,
12: InvalidCursorError,
13: InvalidRequestError,
14: MessageNotFoundError,
15: ServiceUnavailableError,
16: SessionNotFoundError,
17: UnknownError,
18: } from ...
Found 74 matches
/home/byk/Code/opencode/packages/llm/test/prepare.test.ts:
Line 47: it.effect("prepares bodies with route defaults, model defaults, and call options in order", () =>
/home/byk/Code/opencode/packages/llm/test/llm.test.ts:
Line 111: test("carries model defaults and compatibility through route model selection", () => {
Line 124: expect(request.model.defaults?.limits).toEqual({ context: 128_000, output: 8_192 })
Line 125: expect(request.model.defaults?.generation).toEqual({ maxTokens: 1_024, stop: ["END"] })
Line 126: expect(request.model.defaults?.providerOptions).toEqual({ openai: { parallelToolCalls: false } })
Line 127: expect(request.model.defaults?.http).toEqual({ body: { extra_body: true } })
/home/byk/Code/opencode/packages/llm/src/schema/options.ts:
Line 210: defaults: model.defaults,
/home/byk/Code/opencode/packages/llm/src/route/client.ts:
Line 169: const modelDefaults = ...
Found 100 matches (more matches available)
/home/byk/Code/opencode/packages/codemode/test/openapi.test.ts:
Line 424: expect(new URL(requests[0]!.url).pathname).toBe("/api/session/ses_123")
/home/byk/Code/opencode/packages/cli/src/commands/handlers/api.test.ts:
Line 10: "/api/session/{sessionID}": {
Line 18: ).toEqual({ method: "GET", path: "/api/session/ses%2Fa?workspace=work" })
Line 24: { paths: { "/api/session/{sessionID}": { get: { operationId: "v2.session.get" } } } },
/home/byk/Code/opencode/packages/sdk/js/test/session-history.test.ts:
Line 8: url: "/api/session/{sessionID}/history",
/home/byk/Code/opencode/packages/protocol/src/groups/session.ts:
Line 109: HttpApiEndpoint.get("session.list", "/api/session", {
Line 129: HttpApiEndpoint.post("session.create", "/api/session", {
Line 146: HttpApiEndpoint.get("session.active", "/api/session/active", {
Line 158: HttpApiEndpoint.get("session.get", ...
<path>/home/byk/Code/opencode/packages/app/node_modules/@opencode-ai/client/dist</path> <type>directory</type> <entries> contract.d.ts contract.js effect/ promise/ service.d.ts service.js (6 entries) </entries>
<path>/home/byk/Code/opencode/packages/app/node_modules/@opencode-ai/client/dist/promise</path> <type>directory</type> <entries> api.d.ts api.js generated/ index.d.ts index.js service.d.ts service.js (7 entries) </entries>
Found 100 matches (more matches available)
/home/byk/Code/opencode/packages/app/node_modules/@opencode-ai/client/dist/promise/generated/client.js:
Line 144: location: {
Line 147: path: `/api/location`,
Line 148: query: { location: input?.["location"] },
Line 158: query: { location: input?.["location"] },
Line 168: query: { location: input?.["location"] },
Line 177: path: `/api/session`,
Line 184: directory: input?.["directory"],
Line 195: path: `/api/session`,
Line 200: location: input?.["location"],
Line 208: path: `/api/session/active`,
Line 215: path: `/api/session/${encodeURIComponent(input.sessionID)}`,
Line 222: path: `/api/session/${encodeURIComponent(input.sessionID)}`,
Line 229: path: ...
<path>/home/byk/Code/opencode/packages/server/src/handlers.ts</path>
<type>file</type>
<content>
1: import { Layer } from "effect"
2: import { MessageHandler } from "./handlers/message"
3: import { ModelHandler } from "./handlers/model"
4: import { ProviderHandler } from "./handlers/provider"
5: import { SessionHandler } from "./handlers/session"
6: import { PermissionHandler } from "./handlers/permission"
7: import { FileSystemHandler } from "./handlers/fs"
8: import { CommandHandler } from "./handlers/command"
9: import { SkillHandler } from "./handlers/skill"
10: import { EventHandler } from "./handlers/event"
11: import { AgentHandler } from "./handlers/agent"
12: import { HealthHandler } from "./handlers/health"
13: import { PtyHandler } from "./handlers/pty"
14: import { QuestionHandler } from "./handlers/question"
15: import { ReferenceHandler } from "./handlers/reference"
16: import { LocationHandler } from "./handlers/location"
17: import { IntegrationHandler } from ...
<path>/home/byk/Code/opencode/packages/server/src/handlers/provider.ts</path>
<type>file</type>
<content>
1: import { Catalog } from "@opencode-ai/core/catalog"
2: import { Effect } from "effect"
3: import { HttpApiBuilder } from "effect/unstable/httpapi"
4: import { Api } from "../api"
5: import { ProviderNotFoundError } from "@opencode-ai/protocol/errors"
6: import { response } from "../location"
7:
8: export const ProviderHandler = HttpApiBuilder.group(Api, "server.provider", (handlers) =>
9: Effect.gen(function* () {
10: return handlers
11: .handle(
12: "provider.list",
13: Effect.fn(function* () {
14: const catalog = yield* Catalog.Service
15: return yield* response(catalog.provider.available())
16: }),
17: )
18: .handle(
19: "provider.get",
20: Effect.fn(function* (ctx) {
21: const catalog = yield* Catalog.Service
22: const provider = yield* ...
<path>/home/byk/Code/opencode/packages/server/src/handlers/model.ts</path>
<type>file</type>
<content>
1: import { Catalog } from "@opencode-ai/core/catalog"
2: import { Effect } from "effect"
3: import { HttpApiBuilder } from "effect/unstable/httpapi"
4: import { Api } from "../api"
5: import { response } from "../location"
6:
7: export const ModelHandler = HttpApiBuilder.group(Api, "server.model", (handlers) =>
8: Effect.gen(function* () {
9: return handlers.handle(
10: "model.list",
11: Effect.fn(function* () {
12: const catalog = yield* Catalog.Service
13: return yield* response(catalog.model.available())
14: }),
15: )
16: }),
17: )
(End of file - total 17 lines)
</content>
<path>/home/byk/Code/opencode/packages/server/src/handlers/session.ts</path>
<type>file</type>
<content>
1: import { SessionV2 } from "@opencode-ai/core/session"
2: import { DateTime, Effect, Stream } from "effect"
3: import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi"
4: import { Api } from "../api"
5: import { SessionsCursor } from "@opencode-ai/protocol/groups/session"
6: import {
7: ConflictError,
8: InvalidCursorError,
9: MessageNotFoundError,
10: ServiceUnavailableError,
11: SessionNotFoundError,
12: UnknownError,
13: } from "@opencode-ai/protocol/errors"
14: import { AbsolutePath } from "@opencode-ai/core/schema"
15:
16: const DefaultSessionsLimit = 50
17: const DefaultSessionHistoryLimit = 50
18:
19: export const SessionHandler = HttpApiBuilder.group(Api, "server.session", (handlers) =>
20: Effect.gen(function* () {
21: const session = yield* SessionV2.Service
22:
23: return handlers
24: .handle(
25: ...
Found 100 matches (more matches available)
/home/byk/Code/opencode/packages/app/src/context/server-sdk.test.ts:
Line 3: import type { OpenCodeEvent } from "@opencode-ai/client/promise"
/home/byk/Code/opencode/packages/app/src/context/permission.tsx:
Line 215: if (input.sdk.protocolKind() !== "v1") return
Line 261: if ((await input.sdk.protocol) === "v1") {
/home/byk/Code/opencode/packages/app/src/context/global-sync/bootstrap.ts:
Line 25: } from "@opencode-ai/client/promise"
Line 46: import type { ServerProtocol } from "@/utils/server-protocol"
Line 108: export const loadGlobalConfigQuery = (scope: ServerScope, sdk: OpencodeClient, protocol?: Promise<ServerProtocol>) =>
Line 112: if ((await protocol) !== "v1") return {}
Line 127: export const loadProjectsQuery = (scope: ServerScope, api: ProjectApi) =>
Line 145: serverAPI: CatalogApi & { readonly project: ProjectApi }
Line 146: protocol?: Promise<ServerProtocol>
Line 155: () => ...
<path>/home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx</path>
<type>file</type>
<content>
1: import type { OpenCodeEvent } from "@opencode-ai/client/promise"
2: import type { Event } from "@opencode-ai/sdk/v2/client"
3: import { createSimpleContext } from "@opencode-ai/ui/context"
4: import { createGlobalEmitter } from "@solid-primitives/event-bus"
5: import { makeEventListener } from "@solid-primitives/event-listener"
6: import { type Accessor, batch, createMemo, createResource, createSignal, onCleanup, onMount } from "solid-js"
7: import { createApiForServer, createSdkForServer, type ServerApi } from "@/utils/server"
8: import { useLanguage } from "./language"
9: import { usePlatform } from "./platform"
10: import { ServerConnection, useServer } from "./server"
11: import { createRefCountMap } from "@/utils/refcount"
12: import { useGlobal } from "./global"
13: import { ServerScope } from "@/utils/server-scope"
14: import { detectServerProtocol, type ServerProtocol } ...
<path>/home/byk/Code/opencode/packages/app/src/utils/server.ts</path>
<type>file</type>
<content>
1: import { createOpencodeClient } from "@opencode-ai/sdk/v2/client"
2: import { OpenCode, type OpenCodeClient } from "@opencode-ai/client/promise"
3: import type { ServerConnection } from "@/context/server"
4: import { decode64 } from "@/utils/base64"
5:
6: export function authTokenFromCredentials(input: { username?: string; password: string }) {
7: return btoa(`${input.username ?? "opencode"}:${input.password}`)
8: }
9:
10: export function authFromToken(token: string | null) {
11: const decoded = decode64(token ?? undefined)
12: if (!decoded) return
13: const separator = decoded.indexOf(":")
14: if (separator === -1) return
15: return {
16: username: decoded.slice(0, separator) || "opencode",
17: password: decoded.slice(separator + 1),
18: }
19: }
20:
21: export function createSdkForServer({
22: server,
23: ...config
24: }: Omit<NonNullable<Parameters<typeof ...
<path>/home/byk/Code/opencode/packages/app/node_modules/@opencode-ai/client/dist/promise/generated/client.js</path>
<type>file</type>
<content>
1: import { ClientError } from "./client-error";
2: const maxSseEventBytes = 16 * 1024 * 1024;
3: export function make(options) {
4: const fetch = options.fetch ?? globalThis.fetch;
5: const prepare = (descriptor, requestOptions) => {
6: const url = new URL(descriptor.path, options.baseUrl);
7: for (const [key, value] of Object.entries(descriptor.query ?? {}))
8: appendQuery(url.searchParams, key, value);
9: const headers = new Headers(options.headers);
10: for (const [key, value] of Object.entries(descriptor.headers ?? {})) {
11: if (value !== undefined && value !== null)
12: headers.set(key, String(value));
13: }
14: for (const [key, value] of new Headers(requestOptions?.headers))
15: headers.set(key, value);
16: if ...
<path>/home/byk/Code/opencode/packages/app/node_modules/@opencode-ai/client/dist/promise/generated/client.js</path>
<type>file</type>
<content>
1090: },
1091: };
1092: }
1093: function encodePath(value) {
1094: return value.split("/").map(encodeURIComponent).join("/");
1095: }
1096: function appendQuery(params, key, value) {
1097: if (value === undefined)
1098: return;
1099: if (value === null) {
1100: params.append(key, "null");
1101: return;
1102: }
1103: if (Array.isArray(value)) {
1104: for (const item of value)
1105: appendQuery(params, key, item);
1106: return;
1107: }
1108: if (typeof value === "object") {
1109: for (const [child, item] of Object.entries(value))
1110: appendQuery(params, `${key}[${child}]`, item);
1111: return;
1112: }
1113: params.append(key, String(value));
1114: }
1115: async function json(response) {
1116: if ...
Found 28 matches
/home/byk/Code/opencode/packages/llm/test/llm.test.ts:
Line 124: expect(request.model.defaults?.limits).toEqual({ context: 128_000, output: 8_192 })
Line 125: expect(request.model.defaults?.generation).toEqual({ maxTokens: 1_024, stop: ["END"] })
Line 126: expect(request.model.defaults?.providerOptions).toEqual({ openai: { parallelToolCalls: false } })
Line 127: expect(request.model.defaults?.http).toEqual({ body: { extra_body: true } })
/home/byk/Code/opencode/packages/llm/src/schema/options.ts:
Line 210: defaults: model.defaults,
/home/byk/Code/opencode/packages/llm/src/route/client.ts:
Line 169: const modelDefaults = request.model.defaults
/home/byk/Code/opencode/packages/llm/src/protocols/anthropic-messages.ts:
Line 510: const outputLimit = request.model.defaults?.limits?.output ?? request.model.route.defaults.limits?.output ?? 4096
/home/byk/Code/opencode/packages/core/test/catalog.test.ts:
Line 256: ...
Found 62 matches
/home/byk/Code/opencode/packages/opencode/src/control-plane/workspace.ts:
Line 837: signal?.aborted
Line 840: message: signal.reason instanceof Error ? signal.reason.message : "Request aborted",
/home/byk/Code/opencode/packages/opencode/src/control-plane/util.ts:
Line 5: if (input.signal?.aborted) return Effect.fail(input.signal.reason ?? new Error("Request aborted"))
Line 10: resume(Effect.fail(input.signal?.reason ?? new Error("Request aborted")))
/home/byk/Code/opencode/packages/opencode/src/acp/event.ts:
Line 63: if (this.abort.signal.aborted) return
Line 145: while (!this.abort.signal.aborted) {
Line 148: if (!this.abort.signal.aborted) await new Promise((resolve) => setTimeout(resolve, 1000))
Line 161: if (this.abort.signal.aborted) return
Line 169: if (this.abort.signal.aborted) throw new Error("ACP event subscription ...
Found 6 matches
/home/byk/Code/opencode/packages/llm/test/executor.test.ts:
Line 187: remaining: { requests: "499", tokens: "29900" },
Line 202: "x-ratelimit-remaining-requests": "499",
Line 398: yield* TestClock.adjust(499)
/home/byk/Code/opencode/packages/opencode/test/provider/digitalocean.test.ts:
Line 69: { name: "my-router", uuid: "11f1499a-aaaa-bbbb-cccc-4e013e2ddde4" },
Line 70: { name: "other-router", uuid: "22f1499a-aaaa-bbbb-cccc-4e013e2ddde4" },
/home/byk/Code/opencode/packages/console/app/src/routes/zen/util/handler.ts:
Line 464: return new Response(null, { status: 499 })
Ripgrep JSON record exceeded 65536 bytes
/home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/platform-node-shared/src/NodeStream.ts /home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/platform-node-shared/src/NodeChildProcessSpawner.ts /home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/platform-node-shared/src/NodeFileSystem.ts /home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/platform-node-shared/src/internal/utils.ts /home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/platform-node-shared/src/index.ts /home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/platform-node-shared/src/NodeTerminal.ts /home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/platform-node-shared/src/NodeStdio.ts /home/byk/.local/share/opencode/repos/github.com/Effect-TS/effect-smol/packages/platform-node-shared/src/NodeSocketServer.ts /home/byk/.local/share/op...
No files found
<path>/home/byk/Code/opencode/packages/opencode/src/server</path> <type>directory</type> <entries> auth.ts event.ts global-lifecycle.ts init-projectors.ts mdns.ts projectors.ts proxy-util.ts routes/ server.ts shared/ tui-event.ts (11 entries) </entries>
<path>/home/byk/Code/opencode/packages/opencode/src/server/server.ts</path>
<type>file</type>
<content>
1: import "./init-projectors"
2:
3: import { NodeHttpServer } from "@effect/platform-node"
4: import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
5: import { ConfigProvider, Context, Effect, Exit, Layer, Scope } from "effect"
6: import { HttpRouter, HttpServer } from "effect/unstable/http"
7: import { OpenApi } from "effect/unstable/httpapi"
8: import { createServer } from "node:http"
9: import { MDNS } from "./mdns"
10: import { HttpApiApp } from "./routes/instance/httpapi/server"
11: import { disposeMiddleware } from "./routes/instance/httpapi/lifecycle"
12: import { WebSocketTracker } from "./routes/instance/httpapi/websocket-tracker"
13: import { PublicApi } from "./routes/instance/httpapi/public"
14: import type { CorsOptions } from "@opencode-ai/server/cors"
15: import { lazy } from "@/util/lazy"
16:
17: // @ts-ignore This global is needed to prevent ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi</path> <type>directory</type> <entries> AGENTS.md api.ts errors.ts groups/ handlers/ lifecycle.ts middleware/ public.ts server.ts websocket-tracker.ts (10 entries) </entries>
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/AGENTS.md</path>
<type>file</type>
<content>
1: # HttpApi Route Patterns
2:
3: Use `HttpApiBuilder.group(...)` for normal HTTP endpoints, including streaming HTTP responses such as server-sent events. Handlers should yield stable services once while building the handler layer, then close over those services in endpoint implementations.
4:
5: ```ts
6: export const sessionHandlers = HttpApiBuilder.group(InstanceHttpApi, "session", (handlers) =>
7: Effect.gen(function* () {
8: const session = yield* Session.Service
9:
10: return handlers.handle("list", () => session.list())
11: }),
12: )
13: ```
14:
15: For SSE endpoints, stay in `HttpApiBuilder.group(...)` and return `HttpServerResponse.stream(...)` from the handler. Annotate the endpoint success schema with `HttpApiSchema.asText({ contentType: "text/event-stream" })` so OpenAPI documents the stream content type. ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/groups</path> <type>directory</type> <entries> config.ts control-plane.ts control.ts event.ts experimental.ts file.ts global.ts instance.ts mcp.ts metadata.ts permission.ts project-copy.ts project.ts provider.ts pty.ts query.ts question.ts session.ts sync.ts tui.ts workspace.ts (21 entries) </entries>
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/groups/provider.ts</path>
<type>file</type>
<content>
1: import { ProviderAuth } from "@/provider/auth"
2: import { Provider } from "@/provider/provider"
3:
4: import { Schema } from "effect"
5: import { HttpApi, HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"
6: import { Authorization } from "../middleware/authorization"
7: import { InstanceContextMiddleware } from "../middleware/instance-context"
8: import { WorkspaceRoutingMiddleware, WorkspaceRoutingQuery } from "../middleware/workspace-routing"
9: import { described } from "./metadata"
10: import { ProviderV2 } from "@opencode-ai/core/provider"
11:
12: const root = "/provider"
13:
14: const ProviderAuthErrorName = Schema.Union([
15: Schema.Literal("BadRequest"),
16: Schema.Literal("ProviderAuthOauthMissing"),
17: Schema.Literal("ProviderAuthOauthCodeMissing"),
18: ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/api.ts</path>
<type>file</type>
<content>
1: import { Schema } from "effect"
2: import { HttpApi } from "effect/unstable/httpapi"
3: import { EventV2 } from "@opencode-ai/core/event"
4: import { EventManifest } from "@/event-manifest"
5: import { Credential } from "@opencode-ai/core/credential"
6: import { Integration } from "@opencode-ai/core/integration"
7: import { SkillV2 } from "@opencode-ai/core/skill"
8: import { InstanceDisposed } from "@/server/event"
9: import { Question } from "@/question"
10: import { ConfigApi } from "./groups/config"
11: import { ControlApi } from "./groups/control"
12: import { ControlPlaneApi } from "./groups/control-plane"
13: import { EventApi } from "./groups/event"
14: import { ExperimentalApi } from "./groups/experimental"
15: import { FileApi } from "./groups/file"
16: import { InstanceApi } from "./groups/instance"
17: import { McpApi } from "./groups/mcp"
18: ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/middleware/instance-context.ts</path>
<type>file</type>
<content>
1: import { InstanceRef, WorkspaceRef } from "@/effect/instance-ref"
2: import { InstanceStore } from "@/project/instance-store"
3: import { Effect, Layer } from "effect"
4: import { HttpServerResponse } from "effect/unstable/http"
5: import { HttpApiMiddleware } from "effect/unstable/httpapi"
6: import { WorkspaceRouteContext } from "./workspace-routing"
7:
8: export class InstanceContextMiddleware extends HttpApiMiddleware.Service<
9: InstanceContextMiddleware,
10: {
11: requires: WorkspaceRouteContext
12: }
13: >()("@opencode/ExperimentalHttpApiInstanceContext") {}
14:
15: function decode(input: string): string {
16: try {
17: return decodeURIComponent(input)
18: } catch {
19: return input
20: }
21: }
22:
23: function provideInstanceContext<E>(
24: effect: ...
<path>/home/byk/Code/opencode/packages/server/src/location.ts</path>
<type>file</type>
<content>
1: import { Location } from "@opencode-ai/core/location"
2: import { LocationServiceMap } from "@opencode-ai/core/location-services"
3: import { AbsolutePath } from "@opencode-ai/core/schema"
4: import { WorkspaceV2 } from "@opencode-ai/core/workspace"
5: import { Effect, Layer } from "effect"
6: import { HttpServerRequest } from "effect/unstable/http"
7: import { HttpApiMiddleware } from "effect/unstable/httpapi"
8:
9: export type LocationServices = Layer.Success<ReturnType<(typeof LocationServiceMap.Service)["get"]>>
10:
11: export class LocationMiddleware extends HttpApiMiddleware.Service<LocationMiddleware, { provides: LocationServices }>()(
12: "@opencode/HttpApiLocation",
13: ) {}
14:
15: export function response<A, E, R>(data: Effect.Effect<A, E, R>) {
16: return Effect.gen(function* () {
17: const location = yield* Location.Service
18: return {
19: location: ...
<path>/home/byk/Code/opencode/packages/app/src/utils/server-compat.ts</path>
<type>file</type>
<content>
1: import type { ServerApi } from "./server"
2: import type { ServerProtocol } from "./server-protocol"
3: import type { AgentPartInput, FilePartInput, OpencodeClient, Session, TextPartInput } from "@opencode-ai/sdk/v2/client"
4: import type {
5: Project,
6: ProjectCurrent,
7: SessionApi,
8: SessionCommandInput,
9: SessionCommandOutput,
10: SessionCompactInput,
11: SessionCompactOutput,
12: SessionInfo,
13: SessionPromptInput,
14: SessionPromptOutput,
15: SessionShellInput,
16: SessionShellOutput,
17: } from "@opencode-ai/client/promise"
18:
19: type LegacyClient = OpencodeClient
20: type LegacyFor = (directory?: string) => LegacyClient
21: type CompatibleSessionApi = Omit<
22: SessionApi,
23: "prompt" | "command" | "shell" | "compact" | "rename" | "archive" | "remove"
24: > & {
25: prompt: (input: SessionPromptInput & LegacyPrompt) => ...
<path>/home/byk/Code/opencode/packages/app/src/utils/server-protocol.ts</path>
<type>file</type>
<content>
1: import type { ServerConnection } from "@/context/server"
2: import { authTokenFromCredentials } from "./server"
3:
4: export type ServerProtocol = "v1" | "v2"
5:
6: function headers(server: ServerConnection.HttpBase) {
7: if (!server.password) return
8: return {
9: Authorization: `Basic ${authTokenFromCredentials({ username: server.username, password: server.password })}`,
10: }
11: }
12:
13: async function probe(server: ServerConnection.HttpBase, fetch: typeof globalThis.fetch, path: string) {
14: const response = await fetch(new URL(path, server.url), {
15: headers: headers(server),
16: signal: AbortSignal.timeout(5_000),
17: })
18: if (!response.ok || !response.headers.get("content-type")?.includes("application/json")) return
19: const value: unknown = await response.json()
20: if (!value || typeof value !== "object") return
21: return ...
<path>/home/byk/Code/opencode/packages/opencode/node_modules/@effect/platform-node</path> <type>directory</type> <entries> dist/ LICENSE package.json README.md src/ (5 entries) </entries>
No files found
Ripgrep JSON record exceeded 65536 bytes
<path>/home/byk/Code/opencode/packages/opencode/node_modules/effect/src/unstable/http</path> <type>directory</type> <entries> Cookies.ts Etag.ts FetchHttpClient.ts FindMyWay.ts Headers.ts HttpBody.ts HttpClient.ts HttpClientError.ts HttpClientRequest.ts HttpClientResponse.ts HttpEffect.ts HttpIncomingMessage.ts HttpMethod.ts HttpMiddleware.ts HttpPlatform.ts HttpRouter.ts HttpServer.ts HttpServerError.ts HttpServerRequest.ts HttpServerRespondable.ts HttpServerResponse.ts HttpStaticServer.ts HttpTraceContext.ts index.ts internal/ Multipart.ts Multipasta.ts Multipasta/ Template.ts Url.ts UrlParams.ts (31 entries) </entries>
Found 3 matches
/home/byk/Code/opencode/packages/opencode/node_modules/effect/src/unstable/http/HttpServerError.ts:
Line 249: * `causeResponse` uses this annotation to map a pure client abort to a `499`
Line 278: * produce either `499` for client aborts or `503` for server aborts.
Line 359: const clientAbortError = Effect.succeed(Response.empty({ status: 499 }))
<path>/home/byk/Code/opencode/packages/opencode/node_modules/effect/src/unstable/http/HttpServerError.ts</path>
<type>file</type>
<content>
210:
211: override get message() {
212: const info = `${this._tag} (${this.response.status} ${this.methodAndUrl})`
213: return this.description ? `${info}: ${this.description}` : info
214: }
215: }
216:
217: /**
218: * Union of errors that are tied directly to an incoming server request.
219: *
220: * @category errors
221: * @since 4.0.0
222: */
223: export type RequestError = RequestParseError | RouteNotFound | InternalError
224:
225: /**
226: * Reason carried by an `HttpServerError`, either a request-level error or a response-level error.
227: *
228: * @category errors
229: * @since 4.0.0
230: */
231: export type HttpServerErrorReason = RequestError | ResponseError
232:
233: /**
234: * Error wrapping a low-level failure from the HTTP server implementation.
235: *
236: * @category errors
237: * @since 4.0.0
238: ...
Found 46 matches
/home/byk/Code/opencode/packages/desktop/src/renderer/index.tsx:
Line 270: fetch: (input, init) => {
/home/byk/Code/opencode/packages/desktop/src/main/wsl/startup.ts:
Line 21: while (!signal.aborted) {
Line 23: await abortableDelay(interval, signal)
Line 27: function abortableDelay(duration: number, signal: AbortSignal) {
Line 31: signal.removeEventListener("abort", done)
Line 35: signal.addEventListener("abort", done, { once: true })
/home/byk/Code/opencode/packages/desktop/src/main/wsl/sidecar.ts:
Line 61: const startup = new AbortController()
Line 80: startup.abort()
/home/byk/Code/opencode/packages/desktop/src/main/wsl/servers.ts:
Line 71: let jobAbort: AbortController | undefined
Line 95: const beginJob = (job: WslJob): AbortController => {
Line 96: jobAbort?.abort()
Line 97: const abort = new AbortController()
Line 98: jobAbort = abort
Line 100: return abort
Line 103: ...
<path>/home/byk/Code/opencode/packages/desktop/src/renderer/index.tsx</path>
<type>file</type>
<content>
220: return window.api.openPath(path, resolvedApp ?? undefined)
221: }
222: return window.api.openPath(path, app)
223: },
224: async revealPath(path: string) {
225: return window.api.revealPath(path)
226: },
227:
228: storage,
229: draftStore: createDraftStore({
230: get: window.api.draftGet,
231: set: window.api.draftSet,
232: remove: window.api.draftDelete,
233: putBlob: (blob) => blob.arrayBuffer().then(window.api.draftBlobPut),
234: getBlob: (id) => window.api.draftBlobGet(id).then((data) => data && new Blob([data])),
235: }),
236:
237: updater: {
238: state: updaterState,
239: check: () => window.api.updater.check(),
240: install: () => window.api.updater.install(),
241: },
242:
243: exportDebugLogs: () => window.api.exportDebugLogs(),
244:
245: setForceFocus: ...
Found 26 matches /home/byk/Code/opencode/packages/opencode/node_modules/@effect/platform-node/src/Undici.ts: Line 12: * dispatcher lifetimes, mocking, aborts, and request options follow Undici's /home/byk/Code/opencode/packages/opencode/node_modules/@effect/platform-node/src/NodeWorkerRunner.ts: Line 8: * `WorkerRunner`, sends replies over the same channel, and closes when the Line 9: * parent sends the close message. Line 50: const closeLatch = Deferred.makeUnsafe<void, WorkerError>() Line 69: WorkerThreads.parentPort.close() Line 73: Deferred.doneUnsafe(closeLatch, Exit.void) Line 80: closeLatch, Line 91: closeLatch, Line 104: return yield* Deferred.await(closeLatch) /home/byk/Code/opencode/packages/opencode/node_modules/@effect/platform-node/src/NodeWorker.ts: Line 8: * workers to close on scope finalization before forcefully terminating them ...
<path>/home/byk/Code/opencode/packages/opencode/node_modules/@effect/platform-node/src/NodeHttpServer.ts</path>
<type>file</type>
<content>
145: scope
146: }) as Effect.Effect<(nodeRequest: Http.IncomingMessage, nodeResponse: Http.ServerResponse) => void>)
147: const upgradeHandler = yield* makeUpgradeHandler(wss, httpApp, {
148: middleware: middleware as any,
149: scope
150: })
151: yield* Scope.addFinalizerExit(serveScope, () => {
152: server.off("request", handler)
153: server.off("upgrade", upgradeHandler)
154: return preemptiveShutdown
155: })
156: server.on("request", handler)
157: server.on("upgrade", upgradeHandler)
158: })
159: })
160: })
161:
162: /**
163: * Creates a Node `request` event handler for an Effect HTTP application,
164: * injecting a `HttpServerRequest` and interrupting the request fiber if the
165: * client closes the response before it finishes. ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/server.ts</path>
<type>file</type>
<content>
1: import { Config as EffectConfig, Context, Effect, Layer } from "effect"
2: import { HttpApiBuilder, OpenApi } from "effect/unstable/httpapi"
3: import { HttpClient, HttpMiddleware, HttpRouter, HttpServer, HttpServerResponse } from "effect/unstable/http"
4: import * as Socket from "effect/unstable/socket/Socket"
5: import { FSUtil } from "@opencode-ai/core/fs-util"
6: import * as Observability from "@opencode-ai/core/observability"
7: import { Account } from "@/account/account"
8: import { Agent } from "@/agent/agent"
9: import { Auth } from "@/auth"
10: import { BackgroundJob } from "@/background/job"
11: import { Command } from "@/command"
12: import { Config } from "@/config/config"
13: import { Workspace } from "@/control-plane/workspace"
14: import { Env } from "@/env"
15: import { EventV2Bridge } from "@/event-v2-bridge"
16: import { Format } from ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/lifecycle.ts</path>
<type>file</type>
<content>
1: import { EffectBridge } from "@/effect/bridge"
2: import type { InstanceContext } from "@/project/instance-context"
3: import { InstanceStore } from "@/project/instance-store"
4: import { Effect } from "effect"
5: import { HttpEffect, HttpMiddleware, HttpServerRequest } from "effect/unstable/http"
6:
7: type MarkedInstance = {
8: ctx: InstanceContext
9: store: InstanceStore.Interface
10: bridge: EffectBridge.Shape
11: }
12:
13: // Disposal is requested by an endpoint handler, but must run from the outer
14: // server middleware after the response has been produced. The original Request
15: // object is the stable handoff key between those two phases.
16: const disposeAfterResponse = new WeakMap<object, MarkedInstance>()
17:
18: const mark = (ctx: InstanceContext) =>
19: Effect.gen(function* () {
20: return { ctx, store: yield* ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/middleware/fence.ts</path>
<type>file</type>
<content>
1: import { Flag } from "@opencode-ai/core/flag/flag"
2: import { Database } from "@opencode-ai/core/database/database"
3: import { Effect } from "effect"
4: import { HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/unstable/http"
5: import * as Fence from "@/server/shared/fence"
6:
7: const ignoredMethods = new Set(["GET", "HEAD", "OPTIONS"])
8:
9: export const fenceLayer = HttpRouter.middleware<{ requires: Database.Service; handles: unknown }>()(
10: Effect.gen(function* () {
11: const { db } = yield* Database.Service
12: return (effect) =>
13: Effect.gen(function* () {
14: const request = yield* HttpServerRequest.HttpServerRequest
15: if (!Flag.OPENCODE_WORKSPACE_ID || ignoredMethods.has(request.method)) return yield* effect
16:
17: const previous = yield* Fence.load(db)
18: const ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/middleware/error.ts</path>
<type>file</type>
<content>
1: import { NamedError } from "@opencode-ai/core/util/error"
2: import { ConfigErrorV1 } from "@opencode-ai/core/v1/config/error"
3: import { Cause, Effect } from "effect"
4: import { HttpRouter, HttpServerError, HttpServerRespondable, HttpServerResponse } from "effect/unstable/http"
5:
6: // Keep typed HttpApi failures on their declared error path; this boundary only replaces defect-only empty 500s.
7: export const errorLayer = HttpRouter.middleware<{ handles: unknown }>()((effect) =>
8: effect.pipe(
9: Effect.catchCause((cause) => {
10: const defect = cause.reasons.filter(Cause.isDieReason).find((reason) => {
11: if (HttpServerResponse.isHttpServerResponse(reason.defect)) return false
12: if (HttpServerError.isHttpServerError(reason.defect)) return false
13: if ...
Found 5 matches
/home/byk/Code/opencode/packages/opencode/node_modules/effect/src/unstable/http/HttpServerError.ts:
Line 255: export class ClientAbort extends Context.Service<ClientAbort, true>()("effect/http/HttpServerError/ClientAbort") {
Line 258: name: "ClientAbort",
Line 309: isClientInterrupt = reason.annotations.has(ClientAbort.key)
/home/byk/Code/opencode/packages/opencode/node_modules/effect/src/unstable/http/HttpEffect.ts:
Line 23: import { causeResponse, ClientAbort, HttpServerError, InternalError } from "./HttpServerError.ts"
Line 284: fiber.interruptUnsafe(undefined, ClientAbort.annotation)
<path>/home/byk/Code/opencode/packages/opencode/node_modules/effect/src/unstable/http/HttpEffect.ts</path>
<type>file</type>
<content>
245: }))
246:
247: /**
248: * Converts an HTTP server effect into a Web `Request` handler using the supplied base context and optional middleware.
249: *
250: * @category converting
251: * @since 4.0.0
252: */
253: export const toWebHandlerWith = <Provided, R = never, ReqR = Exclude<R, Provided | Scope.Scope | HttpServerRequest>>(
254: context: Context.Context<Provided>
255: ) =>
256: <E>(
257: self: Effect.Effect<HttpServerResponse, E, R>,
258: middleware?: HttpMiddleware | undefined
259: ): [ReqR] extends [never] ?
260: (request: Request, context?: Context.Context<never> | undefined) => Promise<globalThis.Response>
261: : (request: Request, context: Context.Context<ReqR>) => Promise<globalThis.Response> =>
262: {
263: const resolveSymbol = Symbol.for("@effect/platform/HttpApp/resolve")
264: const httpApp = toHandled(self, ...
<path>/home/byk/Code/opencode/packages/core/src/util/retry.ts</path>
<type>file</type>
<content>
1: export interface RetryOptions {
2: attempts?: number
3: delay?: number
4: factor?: number
5: maxDelay?: number
6: retryIf?: (error: unknown) => boolean
7: }
8:
9: const TRANSIENT_MESSAGES = [
10: "load failed",
11: "network connection was lost",
12: "network request failed",
13: "failed to fetch",
14: "econnreset",
15: "econnrefused",
16: "etimedout",
17: "socket hang up",
18: ]
19:
20: function isTransientError(error: unknown): boolean {
21: if (!error) return false
22: // oxlint-disable-next-line no-base-to-string -- error is unknown, intentional coercion for message matching
23: const message = String(error instanceof Error ? error.message : error).toLowerCase()
24: return TRANSIENT_MESSAGES.some((m) => message.includes(m))
25: }
26:
27: export async function retry<T>(fn: () => Promise<T>, options: RetryOptions = {}): Promise<T> {
28: const { ...
<path>/home/byk/Code/opencode/packages/core/src/location-services.ts</path>
<type>file</type>
<content>
1: import { Effect, Layer, LayerMap } from "effect"
2: import { AgentV2 } from "./agent"
3: import { AISDK } from "./aisdk"
4: import { Catalog } from "./catalog"
5: import { CommandV2 } from "./command"
6: import { Config } from "./config"
7: import { LayerNode } from "./effect/layer-node"
8: import { Node } from "./effect/app-node"
9: import { FileMutation } from "./file-mutation"
10: import { FileSystem } from "./filesystem"
11: import { FileSystemSearch } from "./filesystem/search"
12: import { Watcher } from "./filesystem/watcher"
13: import { Image } from "./image"
14: import { Integration } from "./integration"
15: import { Location } from "./location"
16: import { LocationMutation } from "./location-mutation"
17: import { LocationServiceMap } from "./location-service-map"
18: import { PermissionV2 } from "./permission"
19: import { PluginV2 } from "./plugin"
20: import { ...
<path>/home/byk/Code/opencode/packages/core/src/location.ts</path>
<type>file</type>
<content>
1: import { Context, Effect, Layer } from "effect"
2: import { Info, Ref, response } from "@opencode-ai/schema/location"
3: import { Project } from "./project"
4: import { LayerNode } from "./effect/layer-node"
5: import { makeLocationNode, tags } from "./effect/app-node"
6:
7: export * as Location from "./location"
8:
9: export { Info, Ref, response }
10:
11: export interface Interface extends Info {
12: readonly vcs?: Project.Vcs
13: }
14:
15: export class Service extends Context.Service<Service, Interface>()("@opencode/Location") {}
16:
17: export const node = LayerNode.unbound(Service, tags.values.location)
18:
19: const layer = (ref: Ref) =>
20: Layer.effect(
21: Service,
22: Effect.gen(function* () {
23: const project = yield* Project.Service
24: const resolved = yield* project.resolve(ref.directory)
25: return Service.of({
26: directory: ...
<path>/home/byk/Code/opencode/packages/core/src/project.ts</path>
<type>file</type>
<content>
1: export * as ProjectV2 from "./project"
2: export * as Project from "./project"
3:
4: import { Context, Effect, Layer, Schema } from "effect"
5: import path from "path"
6: import { AbsolutePath } from "./schema"
7: import { FSUtil } from "./fs-util"
8: import { Git } from "./git"
9: import { makeGlobalNode } from "./effect/app-node"
10: import { Hash } from "./util/hash"
11: import { ProjectDirectories } from "./project/directories"
12: import { ProjectSchema } from "./project/schema"
13:
14: export const ID = ProjectSchema.ID
15: export type ID = ProjectSchema.ID
16:
17: export const Vcs = ProjectSchema.Vcs
18: export type Vcs = ProjectSchema.Vcs
19:
20: export class Info extends Schema.Class<Info>("Project.Info")({
21: id: ID,
22: }) {}
23:
24: export const DirectoriesInput = ProjectDirectories.ListInput
25: export type DirectoriesInput = typeof DirectoriesInput.Type
26:
27: ...
<path>/home/byk/Code/opencode/packages/opencode/src/project/bootstrap.ts</path>
<type>file</type>
<content>
1: import { makeGlobalNode } from "@opencode-ai/core/effect/app-node"
2: import { Plugin } from "../plugin"
3: import { Format } from "../format"
4: import { LSP } from "@/lsp/lsp"
5: import { Snapshot } from "../snapshot"
6: import * as Project from "./project"
7: import * as Vcs from "./vcs"
8: import { InstanceState } from "@/effect/instance-state"
9: import { ShareNext } from "@/share/share-next"
10: import { Effect, Layer } from "effect"
11: import { Config } from "@/config/config"
12: import { Service } from "./bootstrap-service"
13:
14: export { Service } from "./bootstrap-service"
15: export type { Interface } from "./bootstrap-service"
16:
17: const layer = Layer.effect(
18: Service,
19: Effect.gen(function* () {
20: // Yield each bootstrap dep at layer init so `run` itself has R = never. ...
File not found: /home/byk/Code/opencode/packages/core/src/session/index.ts
<path>/home/byk/Code/opencode/packages/core/src/session</path> <type>directory</type> <entries> compaction.ts context-epoch.ts error.ts event.ts execution.ts execution/ history.ts info.ts input.ts message-updater.ts message.ts projector.ts prompt.ts revert.ts run-coordinator.ts runner/ schema.ts sql.ts store.ts todo.ts (20 entries) </entries>
<path>/home/byk/Code/opencode/packages/core/src/session.ts</path>
<type>file</type>
<content>
1: export * as SessionV2 from "./session"
2: export * from "./session/schema"
3:
4: import { DateTime, Effect, Layer, Schema, Context, Stream } from "effect"
5: import { ListAnchor } from "@opencode-ai/schema/session"
6: import { and, asc, desc, eq, gt, like, lt, or, type SQL } from "drizzle-orm"
7: import { ProjectV2 } from "./project"
8: import { WorkspaceV2 } from "./workspace"
9: import { ModelV2 } from "./model"
10: import { Location } from "./location"
11: import { SessionMessage } from "./session/message"
12: import { Prompt } from "./session/prompt"
13: import { PromptInput } from "@opencode-ai/schema/prompt-input"
14: import { EventV2 } from "./event"
15: import { Database } from "./database/database"
16: import { SessionProjector } from "./session/projector"
17: import { SessionMessageTable, SessionTable } from "./session/sql"
18: import { SessionSchema } from ...
Found 19 matches
/home/byk/Code/opencode/packages/sdk/js/src/client.ts:
Line 20: const value = pick(request.headers.get("x-opencode-directory"), directory)
Line 29: next.headers.delete("x-opencode-directory")
Line 49: "x-opencode-directory": encodeURIComponent(config.directory),
/home/byk/Code/opencode/packages/sdk/js/src/v2/client.ts:
Line 25: ["x-opencode-directory", "directory"],
Line 45: next.headers.delete("x-opencode-directory")
Line 66: "x-opencode-directory": encodeURIComponent(config.directory),
/home/byk/Code/opencode/packages/sdk/js/src/v2/gen/types.gen.ts:
Line 9308: url: "/provider"
/home/byk/Code/opencode/packages/sdk/js/src/v2/gen/sdk.gen.ts:
Line 805: export class Session extends HeyApiClient {
Line 3295: export class Provider extends HeyApiClient {
Line 3320: url: "/provider",
Line 3362: export class Session2 extends HeyApiClient {
Line 5426: export class Session3 extends HeyApiClient {
Line 5900: ...
<path>/home/byk/Code/opencode/packages/sdk/js/src/v2/client.ts</path>
<type>file</type>
<content>
1: export * from "./gen/types.gen.js"
2: export type { FileSystemEntry as LocationFileSystemEntry } from "./gen/types.gen.js"
3:
4: import { createClient } from "./gen/client/client.gen.js"
5: import { type Config } from "./gen/client/types.gen.js"
6: import { OpencodeClient } from "./gen/sdk.gen.js"
7: import { wrapClientError } from "../error-interceptor.js"
8: export { type Config as OpencodeClientConfig, OpencodeClient }
9:
10: function pick(value: string | null, fallback?: string, encode?: (value: string) => string) {
11: if (!value) return
12: if (!fallback) return value
13: if (value === fallback) return fallback
14: if (encode && value === encode(fallback)) return fallback
15: return value
16: }
17:
18: function rewrite(request: Request, values: { directory?: string; workspace?: string }) {
19: if (request.method !== "GET" && request.method !== "HEAD") return ...
<path>/home/byk/Code/opencode/packages/protocol/src/api.ts</path>
<type>file</type>
<content>
1: import { Context } from "effect"
2: import { HttpApi, HttpApiGroup, HttpApiMiddleware, OpenApi } from "effect/unstable/httpapi"
3: import { SchemaErrorMiddleware } from "./middleware/schema-error"
4: import { MessageGroup } from "./groups/message"
5: import { ModelGroup } from "./groups/model"
6: import { ProviderGroup } from "./groups/provider"
7: import { makeSessionGroup } from "./groups/session"
8: import { makePermissionGroup } from "./groups/permission"
9: import { FileSystemGroup } from "./groups/fs"
10: import { CommandGroup } from "./groups/command"
11: import { SkillGroup } from "./groups/skill"
12: import { EventGroup, makeEventGroup } from "./groups/event"
13: import type { Definition } from "@opencode-ai/schema/event"
14: import { AgentGroup } from "./groups/agent"
15: import { HealthGroup } from "./groups/health"
16: import { PtyGroup } from "./groups/pty"
17: import { ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/groups/session.ts</path>
<type>file</type>
<content>
1: import { PermissionV1 } from "@opencode-ai/core/v1/permission"
2: import { Permission } from "@/permission"
3: import { SessionV1 } from "@opencode-ai/core/v1/session"
4:
5: import { Session } from "@/session/session"
6: import { MessageV2 } from "@/session/message-v2"
7: import { SessionPrompt } from "@/session/prompt"
8: import { SessionRevert } from "@/session/revert"
9: import { SessionStatus } from "@/session/status"
10: import { SessionSummary } from "@/session/summary"
11: import { Todo } from "@/session/todo"
12: import { MessageID, PartID, SessionID } from "@/session/schema"
13: import { Snapshot } from "@/snapshot"
14: import { Schema, Struct } from "effect"
15: import { HttpApi, HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi"
16: import { Authorization } from ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/groups/session.ts</path>
<type>file</type>
<content>
420: }),
421: ),
422: HttpApiEndpoint.delete("deletePart", SessionPaths.deletePart, {
423: params: { sessionID: SessionID, messageID: MessageID, partID: PartID },
424: query: WorkspaceRoutingQuery,
425: success: described(Schema.Boolean, "Successfully deleted part"),
426: error: [HttpApiError.BadRequest, ApiNotFoundError],
427: }).annotateMerge(
428: OpenApi.annotations({
429: identifier: "part.delete",
430: description: "Delete a part from a message.",
431: }),
432: ),
433: HttpApiEndpoint.patch("updatePart", SessionPaths.updatePart, {
434: params: { sessionID: SessionID, messageID: MessageID, partID: PartID },
435: query: WorkspaceRoutingQuery,
436: payload: SessionV1.Part,
437: ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/handlers/provider.ts</path>
<type>file</type>
<content>
1: import { ProviderAuth } from "@/provider/auth"
2: import { Config } from "@/config/config"
3: import { ModelsDev } from "@opencode-ai/core/models-dev"
4: import { Provider } from "@/provider/provider"
5:
6: import { mapValues } from "remeda"
7: import { Effect, Schema } from "effect"
8: import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http"
9: import { HttpApiBuilder } from "effect/unstable/httpapi"
10: import { InstanceHttpApi } from "../api"
11: import { ProviderAuthApiError } from "../groups/provider"
12: import { ProviderV2 } from "@opencode-ai/core/provider"
13:
14: function mapProviderAuthError<A, R>(self: Effect.Effect<A, ProviderAuth.Error, R>) {
15: return self.pipe(
16: Effect.mapError((error) => {
17: if (error instanceof ProviderAuth.OauthMissing) {
18: return new ProviderAuthApiError({ ...
Found 5 matches
/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/handlers/session.ts:
Line 155: const create = Effect.fn("SessionHttpApi.create")(function* (ctx: { payload?: Session.CreateInput }) {
Line 159: const createRaw = Effect.fn("SessionHttpApi.createRaw")(function* (ctx: {
Line 422: .handleRaw("create", createRaw)
/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/handlers/workspace.ts:
Line 96: .handle("create", create)
/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/handlers/pty.ts:
Line 155: .handle("create", create)
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/handlers/session.ts</path>
<type>file</type>
<content>
120: return yield* SessionError.mapStorageNotFound(session.messages({ sessionID: ctx.params.sessionID }))
121: }
122:
123: const page = yield* SessionError.mapStorageNotFound(
124: MessageV2.page({
125: sessionID: ctx.params.sessionID,
126: limit: ctx.query.limit,
127: before: ctx.query.before,
128: }),
129: )
130: if (!page.cursor) return page.items
131:
132: const request = yield* HttpServerRequest.HttpServerRequest
133: // toURL() honors the Host + x-forwarded-proto headers, so the Link
134: // header echoes the real origin instead of a hard-coded localhost.
135: const url = Option.getOrElse(HttpServerRequest.toURL(request), () => new URL(request.url, "http://localhost"))
136: url.searchParams.set("limit", ctx.query.limit.toString())
137: ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/handlers/session.ts</path>
<type>file</type>
<content>
1: import { PermissionV1 } from "@opencode-ai/core/v1/permission"
2: import { Agent } from "@/agent/agent"
3: import { SessionV1 } from "@opencode-ai/core/v1/session"
4: import { EventV2Bridge } from "@/event-v2-bridge"
5: import { Command } from "@/command"
6: import { Permission } from "@/permission"
7: import { SessionShare } from "@/share/session"
8: import { Session } from "@/session/session"
9: import { SessionCompaction } from "@/session/compaction"
10: import { MessageV2 } from "@/session/message-v2"
11: import { SessionPrompt } from "@/session/prompt"
12: import { SessionRevert } from "@/session/revert"
13: import { SessionRunState } from "@/session/run-state"
14: import { SessionStatus } from "@/session/status"
15: import { SessionSummary } from "@/session/summary"
16: import { Todo } from "@/session/todo"
17: import { MessageID, PartID, ...
<path>/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/middleware/workspace-routing.ts</path>
<type>file</type>
<content>
1: import { WorkspaceV2 } from "@opencode-ai/core/workspace"
2: import type { Target } from "@/control-plane/types"
3: import { Workspace } from "@/control-plane/workspace"
4: import { WorkspaceAdapterRuntime } from "@/control-plane/workspace-adapter-runtime"
5: import { Session } from "@/session/session"
6: import { HttpApiProxy } from "./proxy"
7: import * as Fence from "@/server/shared/fence"
8: import { getWorkspaceRouteSessionID, isLocalWorkspaceRoute, workspaceProxyURL } from "@/server/shared/workspace-routing"
9: import { NotFoundError } from "@/storage/storage"
10: import { Flag } from "@opencode-ai/core/flag/flag"
11: import { Context, Data, Effect, Layer, Option, Schema } from "effect"
12: import { HttpClient, HttpServerRequest, HttpServerResponse } from "effect/unstable/http"
13: import { HttpApiMiddleware } from ...
<path>/home/byk/Code/opencode/packages/core/src/config.ts</path>
<type>file</type>
<content>
1: export * as Config from "./config"
2:
3: import { makeLocationNode } from "./effect/app-node"
4: import path from "path"
5: import { type ParseError, parse } from "jsonc-parser"
6: import { Context, Effect, Layer, Option, Schema } from "effect"
7: import { Permission } from "@opencode-ai/schema/permission"
8: import { FSUtil } from "./fs-util"
9: import { Global } from "./global"
10: import { Location } from "./location"
11: import { Policy } from "./policy"
12: import { AbsolutePath } from "./schema"
13: import { ConfigAgent } from "./config/agent"
14: import { ConfigAttachments } from "./config/attachments"
15: import { ConfigCompaction } from "./config/compaction"
16: import { ConfigCommand } from "./config/command"
17: import { ConfigExperimental } from "./config/experimental"
18: import { ConfigFormatter } from "./config/formatter"
19: import { ConfigLSP } from "./config/lsp"
20: ...
<path>/home/byk/Code/opencode/packages/core/src/catalog.ts</path>
<type>file</type>
<content>
1: export * as Catalog from "./catalog"
2:
3: import { makeLocationNode } from "./effect/app-node"
4: import { Array, Context, Effect, Layer, Option, Order, pipe, Schema } from "effect"
5: import { Catalog } from "@opencode-ai/schema/catalog"
6: import { ModelV2 } from "./model"
7: import { ProviderV2 } from "./provider"
8: import { EventV2 } from "./event"
9: import { Policy } from "./policy"
10: import { State } from "./state"
11: import { Integration } from "./integration"
12:
13: export type ProviderRecord = {
14: provider: ProviderV2.MutableInfo
15: models: Map<ModelV2.ID, ModelV2.MutableInfo>
16: }
17:
18: export type DefaultModel = { providerID: ProviderV2.ID; modelID: ModelV2.ID }
19:
20: export const PolicyActions = Schema.Literals(["provider.use"])
21:
22: export const Event = Catalog.Event
23:
24: type Data = {
25: providers: Map<ProviderV2.ID, ProviderRecord>
26: ...
<path>/home/byk/Code/opencode/packages/core/src/config/provider.ts</path>
<type>file</type>
<content>
1: export * as ConfigProvider from "./provider"
2:
3: import { Schema } from "effect"
4: import { ProviderV2 } from "../provider"
5: import { ModelV2 } from "../model"
6:
7: export class Request extends Schema.Class<Request>("ConfigV2.Provider.Request")({
8: headers: Schema.Record(Schema.String, Schema.String).pipe(Schema.optional),
9: body: Schema.Record(Schema.String, Schema.Unknown).pipe(Schema.optional),
10: }) {}
11:
12: class Cache extends Schema.Class<Cache>("ConfigV2.Model.Cost.Cache")({
13: read: Schema.Finite.pipe(Schema.optional),
14: write: Schema.Finite.pipe(Schema.optional),
15: }) {}
16:
17: class Cost extends Schema.Class<Cost>("ConfigV2.Model.Cost")({
18: tier: Schema.Struct({
19: type: Schema.Literal("context"),
20: size: Schema.Int,
21: }).pipe(Schema.optional),
22: input: Schema.Finite,
23: output: Schema.Finite,
24: cache: ...
Found 8 matches
/home/byk/Code/opencode/packages/core/src/config/plugin/agent.ts:
Line 54: const documents = yield* Effect.forEach(yield* config.entries(), (entry) => {
/home/byk/Code/opencode/packages/core/src/config/plugin/skill.ts:
Line 20: const entries = yield* config.entries()
/home/byk/Code/opencode/packages/core/src/config/plugin/reference.ts:
Line 22: for (const doc of (yield* config.entries()).filter(
/home/byk/Code/opencode/packages/core/src/config/plugin/provider.ts:
Line 15: const files = (yield* config.entries()).filter((entry): entry is Config.Document => entry.type === "document")
Line 41: yield* ctx.catalog.transform(
Line 43: const entries = yield* config.entries()
/home/byk/Code/opencode/packages/core/src/config/plugin/external.ts:
Line 42: for (const entry of yield* config.entries()) {
/home/byk/Code/opencode/packages/core/src/config/plugin/command.ts:
Line 22: const documents = ...
<path>/home/byk/Code/opencode/packages/core/src/config/plugin/provider.ts</path>
<type>file</type>
<content>
1: export * as ConfigProviderPlugin from "./provider"
2:
3: import { define } from "../../plugin/internal"
4: import { Effect } from "effect"
5: import { Config } from "../../config"
6: import { ModelV2 } from "../../model"
7: import { ProviderV2 } from "../../provider"
8:
9: export const Plugin = define({
10: id: "config-provider",
11: effect: Effect.fn(function* (ctx) {
12: const config = yield* Config.Service
13: yield* ctx.integration.transform(
14: Effect.fn(function* (integrations) {
15: const files = (yield* config.entries()).filter((entry): entry is Config.Document => entry.type === "document")
16: const configuredIntegrations = new Set(
17: files.flatMap((file) =>
18: Object.entries(file.info.providers ?? {}).flatMap(([id, provider]) =>
19: provider.env === undefined ? ...
<path>/home/byk/Code/opencode/packages/core/src/plugin/internal.ts</path>
<type>file</type>
<content>
1: export * as PluginInternal from "./internal"
2:
3: import { makeLocationNode } from "../effect/app-node"
4: import { httpClient } from "../effect/app-node-platform"
5: import type { PluginContext } from "@opencode-ai/plugin/v2/effect"
6: import { Effect, Layer, Scope } from "effect"
7: import { AgentV2 } from "../agent"
8: import { Catalog } from "../catalog"
9: import { CommandV2 } from "../command"
10: import { Config } from "../config"
11: import { ConfigAgentPlugin } from "../config/plugin/agent"
12: import { ConfigCommandPlugin } from "../config/plugin/command"
13: import { ConfigExternalPlugin } from "../config/plugin/external"
14: import { ConfigProviderPlugin } from "../config/plugin/provider"
15: import { ConfigReferencePlugin } from "../config/plugin/reference"
16: import { ConfigSkillPlugin } from "../config/plugin/skill"
17: import { EventV2 } from "../event"
18: ...
<path>/home/byk/Code/opencode/packages/core/src/config/plugin/external.ts</path>
<type>file</type>
<content>
1: export * as ConfigExternalPlugin from "./external"
2:
3: import type { Plugin as EffectPlugin } from "@opencode-ai/plugin/v2/effect"
4: import type { Plugin as PromisePlugin } from "@opencode-ai/plugin/v2/promise"
5: import { Effect, Schema } from "effect"
6: import path from "path"
7: import { fileURLToPath, pathToFileURL } from "url"
8: import { Config } from "../../config"
9: import { FSUtil } from "../../fs-util"
10: import { Location } from "../../location"
11: import { Npm } from "../../npm"
12: import { define } from "../../plugin/internal"
13: import { PluginPromise } from "../../plugin/promise"
14:
15: const PluginModule = Schema.Struct({
16: default: Schema.Union([
17: Schema.Struct({
18: id: Schema.String,
19: effect: Schema.declare<EffectPlugin["effect"]>(
20: (input): input is EffectPlugin["effect"] => typeof input === "function",
21: ...
Found 49 matches
/home/byk/Code/opencode/packages/opencode/src/config/tui.ts:
Line 107: // (mirroring the old opencode.json shape) still get their settings applied.
Line 124: Effect.logWarning("skipping invalid tui config", {
Line 138: Effect.logWarning("failed to read tui config", {
Line 145: yield* Effect.logInfo("loading tui config", { path: filepath })
Line 154: yield* Effect.logInfo("applying tui config", { path: file, order: appliedOrder })
Line 171: // Every config dir we may read from: global config dir, any `.opencode`
Line 172: // folders between cwd and home, and OPENCODE_CONFIG_DIR.
Line 200: // 4. `.opencode` directories (and OPENCODE_CONFIG_DIR) discovered while
Line 203: const dirs = unique(directories).filter((dir) => dir.endsWith(".opencode") || dir === Flag.OPENCODE_CONFIG_DIR)
Line 206: if (!dir.endsWith(".opencode") && dir !== Flag.OPENCODE_CONFIG_DIR) ...
<path>/home/byk/Code/opencode/packages/opencode/src/project/instance-store.ts</path>
<type>file</type>
<content>
1: import { LayerNode } from "@opencode-ai/core/effect/layer-node"
2: import { makeGlobalNode, Node } from "@opencode-ai/core/effect/app-node"
3: import { GlobalBus } from "@/bus/global"
4: import { serviceUse } from "@opencode-ai/core/effect/service-use"
5: import { WorkspaceContext } from "@/control-plane/workspace-context"
6: import { InstanceRef } from "@/effect/instance-ref"
7: import { disposeInstance as runDisposers } from "@/effect/instance-registry"
8: import { FSUtil } from "@opencode-ai/core/fs-util"
9: import { Context, Deferred, Duration, Effect, Exit, Layer, Scope } from "effect"
10: import { type InstanceContext } from "./instance-context"
11: import { InstanceBootstrap } from "./bootstrap-service"
12: import * as Project from "./project"
13:
14: export interface LoadInput {
15: directory: string
16: worktree?: string
17: project?: Project.Info
18: ...
Found 85 matches
/home/byk/Code/opencode/packages/opencode/src/project/vcs.ts:
Line 6: import { Git } from "@/git"
Line 84: const header = /^diff --git (.+)$/m.exec(chunk)?.[1]
Line 89: const starts = [...patch.text.matchAll(/(?:^|\n)diff --git /g)].map((match) =>
Line 98: git: Git.Interface,
Line 106: const result = yield* git.patchAll(cwd, ref, {
Line 123: git: Git.Interface,
Line 131: ? yield* git.patchUntracked(cwd, item.file, {
Line 135: : yield* git.patch(cwd, ref, item.file, {
Line 150: git: Git.Interface,
Line 163: return yield* nativePatch(git, cwd, ref, item, options)
Line 167: git: Git.Interface,
Line 180: const stat = map.get(item.file) ?? (item.status === "added" ? yield* git.statUntracked(cwd, item.file) : undefined)
Line 181: const patch = yield* patchForItem(git, cwd, ref, item, batch, capped, options)
Line 203: git: Git.Interface,
Line 208: const [list, stats, extra] = yield* ...
<path>/home/byk/Code/opencode/packages/opencode/src/project/project.ts</path>
<type>file</type>
<content>
100: }
101:
102: export class Service extends Context.Service<Service, Interface>()("@opencode/Project") {}
103:
104: type GitResult = { code: number; text: string; stderr: string }
105:
106: const layer = Layer.effect(
107: Service,
108: Effect.gen(function* () {
109: const fs = yield* FSUtil.Service
110: const spawner = yield* ChildProcessSpawner.ChildProcessSpawner
111: const projectV2 = yield* ProjectV2.Service
112: const projectDirectories = yield* ProjectDirectories.Service
113: const events = yield* EventV2Bridge.Service
114: const flags = yield* RuntimeFlags.Service
115: const { db } = yield* Database.Service
116:
117: const git = Effect.fnUntraced(
118: function* (args: string[], opts?: { cwd?: string }) {
119: const handle = yield* spawner.spawn(
120: ChildProcess.make("git", args, { cwd: opts?.cwd, ...
Found 100 matches (more matches available)
/home/byk/Code/opencode/packages/core/src/repository.ts:
Line 10: readonly repo: string
Line 11: readonly remote: string
Line 66: if (scp) return buildRemote({ host: scp[1], segments: parts(scp[2]), remote: cleaned })
Line 75: if (url.protocol === "file:") return buildFile({ url, remote: cleaned })
Line 80: remote: url.host === "github.com" ? githubRemote(segments.join("/")) : cleaned,
Line 190: repo: segments[segments.length - 1],
Line 191: remote:
Line 198: function buildFile(input: { url: URL; remote: string }) {
Line 207: repo: trimGitSuffix(segments[segments.length - 1]),
Line 208: remote: input.remote,
/home/byk/Code/opencode/packages/core/src/repository-cache.ts:
Line 21: readonly remote: string
Line 153: const existing = yield* git.repo.discover(AbsolutePath.make(localPath))
Line 179: remote: input.reference.remote,
Line ...
<path>/home/byk/Code/opencode/packages/core/src/git.ts</path>
<type>file</type>
<content>
160: repository: Repository
161: current: TreeID
162: files: ReadonlyMap<RelativePath, TreeID>
163: context?: number
164: }) => Effect.Effect<readonly File.Diff[], OperationError>
165: readonly restore: (input: {
166: repository: Repository
167: files: ReadonlyMap<RelativePath, TreeID>
168: }) => Effect.Effect<void, OperationError>
169: readonly checkout: (input: { repository: Repository; tree: TreeID }) => Effect.Effect<void, OperationError>
170: }
171: }
172:
173: export class Service extends Context.Service<Service, Interface>()("@opencode/GitV2") {}
174:
175: const layer = Layer.effect(
176: Service,
177: Effect.gen(function* () {
178: const fs = yield* FSUtil.Service
179: const proc = yield* AppProcess.Service
180: const locks = KeyedMutex.makeUnsafe<string>()
181: const locked = <A, E, R>(repository: Repository, ...
* 🟡 (19:28) `/home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/groups/provider.ts` defines `ProviderAuthApiError` as `Schema.ErrorClass("ProviderAuthError")` with HTTP status `400`; allowed `name` values are `"BadRequest"`, `"ProviderAuthOauthMissing"`, `"ProviderAuthOauthCodeMissing"`, `"ProviderAuthOauthCallbackFailed"`, and `"ProviderAuthValidationFailed"`, while op…
Date: Sep 8, 2026 * 🟡 (19:24) An abort-handling search returned exactly `Found 62 matches`. Hits included `/home/byk/Code/opencode/packages/opencode/src/control-plane/workspace.ts`, `src/control-plane/util.ts`, `src/acp/event.ts`, `src/plugin/openai/ws-pool.ts`, `src/plugin/openai/ws.ts`, `src/util/process.ts`, `src/tool/code-mode.ts`, `src/tool/shell.ts`, `src/session/prompt.ts`, `src/session/m…
* 🔴 (19:23) [enforced-event-behavior] User directed: “always fire visibilitychange,” establishing that `visibilitychange` should always be fired. * 🟡 (19:22) A protocol-usage search returned exactly `Found 100 matches (more matches available)` and was truncated. It showed extensive v1/v2 branching in `/home/byk/Code/opencode/packages/app/src/context/`, including `global-sync/bootstrap.ts`, `per…
* 🟡 (19:18) `/home/byk/Code/opencode/packages/protocol/src` contains exactly 4 entries: `api.ts`, `errors.ts`, `groups/`, and `middleware/`. * 🟡 (19:18) `/home/byk/Code/opencode/packages/protocol/src/groups` contains exactly 18 files: `agent.ts`, `command.ts`, `credential.ts`, `event.ts`, `fs.ts`, `health.ts`, `integration.ts`, `location.ts`, `message.ts`, `model.ts`, `permission.ts`, `project-…
* 🟡 (19:17) A repository-wide provider/session/499-related search returned exactly `Found 100 matches (more matches available)` and was truncated to the first 100 results. * 🟡 (19:17) Relevant search hits included `/home/byk/Code/opencode/packages/cli/src/tui.ts:23`, which initializes `"/provider"` as `{ all: [], default: {}, connected: [] }`. * 🟡 (19:17) `/home/byk/Code/opencode/packages/http…
Date: Sep 8, 2026 * 🟡 (19:03) User requested a read-only investigation of `/home/byk/Code/opencode` tracing how the web/desktop client loads provider/model lists and creates a new session for a selected project directory. * 🟡 (19:03) User asked the investigation to identify: 1. HTTP endpoints called and how directory is passed; 2. every path yielding HTTP 499 or client-aborted responses; 3. pro…