Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,697 changes: 3,697 additions & 0 deletions dist/index.mjs

Large diffs are not rendered by default.

700 changes: 8 additions & 692 deletions dist/plugin.mjs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions opencode/plugin-contract.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import assert from "node:assert/strict";
import test from "node:test";

test("configured server-plugin bundle exposes only its default factory", async () => {
const plugin = await import(new URL("../dist/plugin.mjs", import.meta.url).href);
assert.deepEqual(Object.keys(plugin), ["default"]);
assert.equal(typeof plugin.default, "function");
});

test("package library bundle retains the public adapter contract", async () => {
const library = await import(new URL("../dist/index.mjs", import.meta.url).href);
assert.deepEqual(Object.keys(library).sort(), [
"DurableOpenCodeNoticeIngressStore",
"OPENCODE_NOTICE_AUTHORITY_UNAVAILABLE",
"OPENCODE_NOTICE_CURRENT_CLAIM_EVIDENCE_VERSION",
"OPENCODE_NOTICE_CURRENT_CLAIM_UNAVAILABLE",
"OpenCodeIntercomPlugin",
"OpenCodeNoticeAuthorityUnavailableError",
"OpenCodeNoticeCurrentClaimUnavailableError",
"OpenCodeNoticeRecipientIngress",
"createProductionOpenCodeNoticeRecipientIngress",
"default",
"getOpenCodeNoticeIngressStatePath",
]);
assert.equal(typeof library.default, "function");
assert.equal(typeof library.OpenCodeIntercomPlugin, "function");
assert.equal(typeof library.createProductionOpenCodeNoticeRecipientIngress, "function");
});
18 changes: 4 additions & 14 deletions opencode/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,9 @@ import { invokeAgentFleet, isFleetManagementEnabled } from "./fleet.ts";
import { startOpenCodeControlServer } from "./control.ts";
import { validateAskTimeoutMs } from "../config.ts";

// Public, bundled contract surface. Production creation intentionally fails
// closed until the protected authority client and typed notice ingress exist.
export {
createProductionOpenCodeNoticeRecipientIngress,
DurableOpenCodeNoticeIngressStore,
getOpenCodeNoticeIngressStatePath,
OpenCodeNoticeAuthorityUnavailableError,
OpenCodeNoticeCurrentClaimUnavailableError,
OpenCodeNoticeRecipientIngress,
OPENCODE_NOTICE_AUTHORITY_UNAVAILABLE,
OPENCODE_NOTICE_CURRENT_CLAIM_EVIDENCE_VERSION,
OPENCODE_NOTICE_CURRENT_CLAIM_UNAVAILABLE,
} from "./notice-ingress.ts";
// OpenCode v1 treats every export from a configured server-plugin module as
// a plugin factory. Keep this module default-only; package consumers import
// the public contract from dist/index.mjs instead.

const INJECT_LOG_PATH = "/tmp/intercom-inject.log";

Expand All @@ -40,7 +30,7 @@ function listScope(value: string | undefined): "machine" | "directory" | "repo"
throw new Error('scope must be one of "machine", "directory", or "repo"');
}

export const OpenCodeIntercomPlugin: Plugin = async ({ client, directory, serverUrl }) => {
const OpenCodeIntercomPlugin: Plugin = async ({ client, directory, serverUrl }) => {
let activeSessionID = process.env.OPENCODE_INTERCOM_TARGET_SESSION?.trim() || process.env.OPENCODE_SESSION_ID?.trim() || undefined;
let activeSessionStatus = "idle";
const knownSessionIDs = new Set<string>();
Expand Down
18 changes: 18 additions & 0 deletions opencode/public.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Library entry point. Keep public values out of plugin.ts: OpenCode's v1
// server-plugin loader treats every export from that configured module as a
// plugin factory.
import OpenCodeIntercomPlugin from "./plugin.ts";

export default OpenCodeIntercomPlugin;
export { OpenCodeIntercomPlugin };
export {
createProductionOpenCodeNoticeRecipientIngress,
DurableOpenCodeNoticeIngressStore,
getOpenCodeNoticeIngressStatePath,
OpenCodeNoticeAuthorityUnavailableError,
OpenCodeNoticeCurrentClaimUnavailableError,
OpenCodeNoticeRecipientIngress,
OPENCODE_NOTICE_AUTHORITY_UNAVAILABLE,
OPENCODE_NOTICE_CURRENT_CLAIM_EVIDENCE_VERSION,
OPENCODE_NOTICE_CURRENT_CLAIM_UNAVAILABLE,
} from "./notice-ingress.ts";
Loading
Loading