Skip to content

V2 /server plugin fails on stable hosts: TypeError: Schema.isStartsWith is not a function (host Effect 4.0.1 rename; beta @opencode-ai/* packages) #43

Open

Description

@Zburgers

Summary

The npm plugin (opencode-cursor-oauth, dist/v2.js) fails to load on current OpenCode V2 stable hosts (verified on @opencode/cli 2.1.3, Windows x64). The failure happens at import time, so setup() never runs and /plugins only ever shows it as failed:

level=WARN message="failed to load plugin" target=opencode-cursor-oauth role=server
cause="Cause([Die(TypeError: Schema.isStartsWith is not a function.
      (In 'Schema.isStartsWith("wrk")', 'Schema.isStartsWith' is undefined))])"

(~/.local/share/opencode/log/opencode.log; the host retries and records a second identical failure under a different ref — both attempts are fatal.)

Why (root cause)

  • v2.ts imports Credential, Integration, Model, Plugin from @opencode-ai/plugin@0.0.0-beta-17793 → @opencode-ai/schema@0.0.0-beta-17793 → which declares effect@4.0.0-rc.110.
  • const CURSOR_INTEGRATION_ID = Integration.ID.make(CURSOR_ID) runs at module import and evaluates @opencode-ai/schema/dist/workspace-id.js, whose first statement is Schema.String.check(Schema.isStartsWith("wrk")).
  • The plugin's own pinned dependency tree is internally consistent: importing @opencode-ai/schema under plain Node with the cached effect@4.0.0-rc.110 succeeds (that Effect still exports isStartsWith).
  • The OpenCode host, however, resolves plugin-side bare specifiers of effect (and @opencode/plugin) to its own bundled runtime copies (@opencode/plugin's runtime-modules.js; the host Effect 4.0.1 upgrade landed in chore: upgrade Effect to 4.0.1 anomalyco/opencode#54198, with plugin-modules-host-Effect behavior from fix(cli): give plugins the host's Effect anomalyco/opencode#53422). In effect@4.0.1, Schema.isStartsWith was renamed to Schema.isStartingWith; OpenCode's own schema source uses the new name, but the published @opencode-ai/* beta packages still call the old one.
  • Result: every host from the Effect-4.0.1 migration onward throws at the same import (see the maintainer reproduction in V2 plugin using @opencode-ai/plugin/rpc fails to load on 2.0.28 — TypeError: Schema.isStartsWith is not a function anomalyco/opencode#55154). The plugin's effect pin can never fix this, because the pinned effect is never the instance the schema modules are evaluated against.

Relation to #39

Same beta-API drift, one step upstream: #39 shows ctx.catalog.transform being undefined during setup on 2.0.4+ hosts — the stable plugin API removed the catalog domain entirely (it is now ctx.provider / ctx.model). This is the same underlying breakage of the @opencode-ai/* beta scope.

Proposed fix

Rebuild the V2 plugin against the stable @opencode/plugin API (versioned with the CLI, e.g. @opencode/plugin@2.1.4) as anomalyco/opencode#55154's triage recommends:

  • @opencode/plugin re-exports the host-matching @opencode/schema namespaces (Credential, Integration, Model, Provider, Plugin), so no host/dependency skew remains.
  • ctx.catalog.transform → ctx.provider.transform using Provider.Info.empty(id) + ProviderEditor.add({ info, models }) with Model.Info.default(providerID, id); ctx.catalog.reload() → ctx.provider.reload().
  • integration.connection.updated → watch credential.updated / credential.switched (filtered by data.integrationID).
  • Provider package reference @opencode-ai/ai/providers/openai-compatible → @opencode/ai/providers/openai-compatible.

A minimal migration was implemented and validated on OpenCode 2.1.3 (Windows x64): the plugin now loads cleanly (server logs loading plugin ... entrypoint=.../server.js, no failed to load plugin afterwards); the integration method and catalog register, and Cursor is exposed OAuth + model catalog after sign-in. The full patch is in #42 — happy to split/adjust however the maintainer prefers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions