@opencode/plugin 2.0.27 → 2.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { ExperimentalApi, GenerateApi, PluginApi } from "@opencode/client/effect/api";
1
+ import type { CredentialApi, ExperimentalApi, GenerateApi, PluginApi } from "@opencode/client/effect/api";
2
2
  import type { Location } from "@opencode/schema/location";
3
3
  import type { Effect, Scope } from "effect";
4
4
  import type { PluginOptions } from "../options.js";
@@ -29,6 +29,7 @@ export interface Context {
29
29
  readonly agent: AgentDomain;
30
30
  readonly aisdk: AISDKDomain;
31
31
  readonly command: CommandDomain;
32
+ readonly credential: Pick<CredentialApi<unknown>, "activate">;
32
33
  readonly event: EventDomain;
33
34
  readonly experimental: {
34
35
  readonly terminal: Pick<ExperimentalApi<unknown>["persistentPty"], "read">;
@@ -157,6 +157,7 @@ export function fromPromise(plugin) {
157
157
  const [{ ClientApi }, { OpenCodeEvent }] = yield* Effect.promise(() => Promise.all([import("@opencode/protocol/client"), import("@opencode/protocol/groups/event")]));
158
158
  const AgentEndpoints = ClientApi.groups["server.agent"].endpoints;
159
159
  const CommandEndpoints = ClientApi.groups["server.command"].endpoints;
160
+ const CredentialEndpoints = ClientApi.groups["server.credential"].endpoints;
160
161
  const ExperimentalEndpoints = ClientApi.groups["server.experimental"].endpoints;
161
162
  const GenerateEndpoints = ClientApi.groups["server.generate"].endpoints;
162
163
  const IntegrationEndpoints = ClientApi.groups["server.integration"].endpoints;
@@ -220,6 +221,9 @@ export function fromPromise(plugin) {
220
221
  }))),
221
222
  reload: () => run(host.command.reload()),
222
223
  },
224
+ credential: {
225
+ activate: adaptApiMethod(CredentialEndpoints["credential.activate"], host.credential.activate),
226
+ },
223
227
  event: {
224
228
  subscribe: (options) => streams(host.event.subscribe().pipe(Stream.mapEffect((event) => Schema.encodeUnknownEffect(OpenCodeEvent)(event)), Stream.map((event) => event)), options),
225
229
  },
@@ -447,8 +451,15 @@ export function fromPromise(plugin) {
447
451
  function attempt(evaluate) {
448
452
  return Effect.tryPromise({ try: evaluate, catch: (cause) => cause });
449
453
  }
450
- const executePromiseTool = (tool, input, context) => Effect.promise((signal) => tool.execute(input, {
451
- ...context,
452
- signal,
453
- progress: (update) => Effect.runPromise(context.progress(update), { signal }),
454
+ const executePromiseTool = (tool, input, context) => Effect.tryPromise({
455
+ try: (signal) => tool.execute(input, {
456
+ ...context,
457
+ signal,
458
+ progress: (update) => Effect.runPromise(context.progress(update), { signal }),
459
+ }),
460
+ catch: (error) => error,
461
+ }).pipe(Effect.catch((error) => {
462
+ if (error instanceof Tool.Error)
463
+ return Effect.fail(error);
464
+ return Effect.fail(new Tool.Error({ message: error instanceof Error ? error.message : String(error), error }));
454
465
  }));
@@ -1,5 +1,5 @@
1
1
  import type { OpenCodeClient } from "@opencode/client";
2
- import type { GenerateApi, PluginApi } from "@opencode/client/promise/api";
2
+ import type { CredentialApi, GenerateApi, PluginApi } from "@opencode/client/promise/api";
3
3
  import type { Location } from "@opencode/schema/location";
4
4
  import type { PluginOptions } from "../options.js";
5
5
  import type { App } from "../app.js";
@@ -29,6 +29,7 @@ export interface Context {
29
29
  readonly agent: AgentDomain;
30
30
  readonly aisdk: AISDKDomain;
31
31
  readonly command: CommandDomain;
32
+ readonly credential: Pick<CredentialApi, "activate">;
32
33
  readonly event: EventDomain;
33
34
  readonly experimental: {
34
35
  readonly terminal: Pick<OpenCodeClient["experimental"]["persistentPty"], "read">;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/plugin",
4
- "version": "2.0.27",
4
+ "version": "2.0.28",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -47,15 +47,15 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "@ai-sdk/provider": "3.0.8",
50
- "@opencode/ai": "2.0.27",
51
- "@opencode/client": "2.0.27",
52
- "@opencode/protocol": "2.0.27",
53
- "@opencode/schema": "2.0.27",
54
- "@opencode/util": "2.0.27",
50
+ "@opencode/ai": "2.0.28",
51
+ "@opencode/client": "2.0.28",
52
+ "@opencode/protocol": "2.0.28",
53
+ "@opencode/schema": "2.0.28",
54
+ "@opencode/util": "2.0.28",
55
55
  "effect": "4.0.1"
56
56
  },
57
57
  "peerDependencies": {
58
- "@opencode/theme": "2.0.27",
58
+ "@opencode/theme": "2.0.28",
59
59
  "@opentui/core": ">=0.5.17",
60
60
  "@opentui/solid": ">=0.5.17",
61
61
  "solid-js": ">=1.9.0"
@@ -75,7 +75,7 @@
75
75
  }
76
76
  },
77
77
  "devDependencies": {
78
- "@opencode/theme": "2.0.27",
78
+ "@opencode/theme": "2.0.28",
79
79
  "@opentui/core": "0.5.17",
80
80
  "@opentui/solid": "0.5.17",
81
81
  "@tsconfig/bun": "1.0.9",