Skip to content

An open-source, faster Devin alternative

TypeScript

agent, cli, api-edge: drop linearAgent() and linearConnections (work 037 scope change)

Igor Zalutskibeacecce640c
diff --git a/agent/src/index.test.ts b/agent/src/index.test.ts
index 221f0bb3..90683502 100644
--- a/agent/src/index.test.ts
+++ b/agent/src/index.test.ts
@@ -9,7 +9,6 @@ import {
documentMemory,
githubApp,
httpMemory,
- linearAgent,
useConnection,
useInput,
useMemory,
@@ -602,17 +601,6 @@ test("defineTool refuses a result tool that waits for approval", () => {
);
});
-test("linearAgent defines a frozen connection to the agent's own Linear app", () => {
- const connection = defineConnection({ id: "linear", provider: linearAgent() });
- assert.deepEqual(JSON.parse(JSON.stringify(connection)), {
- kind: "connection",
- id: "linear",
- provider: { kind: "linear-agent" },
- });
- assert.ok(Object.isFrozen(connection));
- assert.ok(Object.isFrozen(connection.provider));
-});
-
test("defineTool reserves the question tool's id", () => {
assert.equal(ASK_TOOL, "ask");
assert.throws(
diff --git a/agent/src/index.ts b/agent/src/index.ts
index cf434942..12bf3af9 100644
--- a/agent/src/index.ts
+++ b/agent/src/index.ts
@@ -276,20 +276,6 @@ export interface GitHubConnectionDefinition extends ConnectionReference {
readonly provider: GitHubAppProvider;
}
-export interface LinearAgentProvider {
- readonly kind: "linear-agent";
-}
-
-/**
- * Linear's GraphQL API as this agent's own Linear app: `POST /graphql` on
- * `https://api.linear.app`, with the app's token attached on the way out.
- * The token is the environment's Linear connection for this agent; the
- * agent never sees it.
- */
-export interface LinearConnectionDefinition extends ConnectionReference {
- readonly provider: LinearAgentProvider;
-}
-
export interface McpServerDefinition extends ResourceReference {
readonly kind: "mcp";
readonly url: string;
@@ -841,16 +827,6 @@ export function githubApp(options: {
});
}
-/**
- * The agent's own Linear app as a connection provider. Requests go to
- * Linear's GraphQL API with the token of the Linear connection bound to this
- * agent in the session's environment; with it the agent writes documents,
- * sub-issues, comments and status changes as itself.
- */
-export function linearAgent(): LinearAgentProvider {
- return Object.freeze({ kind: "linear-agent" });
-}
-
/**
* A service the platform holds an OAuth credential for.
*
@@ -892,6 +868,8 @@ export interface ServiceRequest {
/**
* Call a service the platform is connected to on this session's behalf.
+ * In a session started from a Linear agent connection, `service: "linear"`
+ * acts as the agent's own Linear app.
*
* Returns the upstream response, so a caller reads status and body exactly as
* it would from `fetch` — a 404 from the service arrives as a 404, not as an
@@ -1071,11 +1049,6 @@ interface GitHubConnectionInput {
provider: GitHubAppProvider;
}
-interface LinearConnectionInput {
- id: string;
- provider: LinearAgentProvider;
-}
-
export function defineConnection(
input: HttpConnectionInput,
): HttpConnectionDefinition;
@@ -1083,25 +1056,14 @@ export function defineConnection(
input: GitHubConnectionInput,
): GitHubConnectionDefinition;
export function defineConnection(
- input: LinearConnectionInput,
-): LinearConnectionDefinition;
-export function defineConnection(
- input: HttpConnectionInput | GitHubConnectionInput | LinearConnectionInput,
-):
- | HttpConnectionDefinition
- | GitHubConnectionDefinition
- | LinearConnectionDefinition {
+ input: HttpConnectionInput | GitHubConnectionInput,
+): HttpConnectionDefinition | GitHubConnectionDefinition {
const id = identifier(input.id, "defineConnection");
if ("provider" in input) {
- const kind = input.provider?.kind;
- if (kind !== "github-app" && kind !== "linear-agent") {
+ if (input.provider?.kind !== "github-app") {
throw new Error("defineConnection() received an unsupported provider");
}
- return Object.freeze({
- kind: "connection",
- id,
- provider: input.provider,
- }) as GitHubConnectionDefinition | LinearConnectionDefinition;
+ return Object.freeze({ kind: "connection", id, provider: input.provider });
}
const origin = new URL(input.origin);
if (origin.protocol !== "https:" || origin.pathname !== "/") {
diff --git a/cli/src/api.ts b/cli/src/api.ts
index 2c64927f..f6f31b86 100644
--- a/cli/src/api.ts
+++ b/cli/src/api.ts
@@ -1349,10 +1349,6 @@ export class OpenComputerClient {
permissions: Record<string, "read" | "write">;
};
}>;
- linearConnections: Array<{
- id: string;
- provider: { kind: "linear-agent" };
- }>;
memory: MemoryDeclaration[];
models: Array<{ provider: string; model: string }>;
projectDeployment?: {
diff --git a/cli/src/dev.ts b/cli/src/dev.ts
index 4fa07133..b3f0a331 100644
--- a/cli/src/dev.ts
+++ b/cli/src/dev.ts
@@ -68,7 +68,6 @@ async function registerBuiltDeployment(
connections: built.connections,
httpConnections: built.httpConnections,
githubConnections: built.githubConnections,
- linearConnections: built.linearConnections,
memory: built.memory,
models: built.models,
...(projectDeployment ? { projectDeployment } : {}),
diff --git a/cli/src/project.test.ts b/cli/src/project.test.ts
index 40115bad..f252cc07 100644
--- a/cli/src/project.test.ts
+++ b/cli/src/project.test.ts
@@ -361,7 +361,6 @@ export default function Agent() {
connections: string[];
httpConnections: unknown[];
githubConnections: unknown[];
- linearConnections: unknown[];
mcpServers: string[];
mcpServerDefinitions: Array<{
id: string;
@@ -381,7 +380,6 @@ export default function Agent() {
connections: [],
httpConnections: [],
githubConnections: [],
- linearConnections: [],
mcpServers: ["docs"],
mcpServerDefinitions: [{ id: "docs", url: "https://mcp.example.com/" }],
memory: [],
@@ -1025,174 +1023,56 @@ export default defineConnection({
}
});
-test("the compiler records a Linear agent connection and the ask tool", async () => {
- const parent = await mkdtemp(resolve(tmpdir(), "opencomputer-linear-agent-"));
+test("useTool(\"ask\") selects the platform's question tool without a definition", async () => {
+ const parent = await mkdtemp(resolve(tmpdir(), "opencomputer-ask-select-"));
const root = resolve(parent, "app");
try {
const initialized = await initializeAgentProject(root);
- await mkdir(resolve(initialized.agentRoot, "connections"), {
- recursive: true,
- });
- await writeFile(
- resolve(initialized.agentRoot, "connections", "linear.ts"),
- `import { defineConnection, linearAgent } from "@opencomputer/agent";
-
-export const linear = defineConnection({
- id: "linear",
- provider: linearAgent(),
-});
-`,
- );
+ const tools = async () => {
+ await buildAgentArtifact(initialized.agentRoot);
+ return (
+ JSON.parse(
+ await readFile(
+ resolve(
+ await agentRuntimeDirectory(initialized.agentRoot),
+ ".opencomputer",
+ "reactive.json",
+ ),
+ "utf8",
+ ),
+ ) as { tools: string[] }
+ ).tools;
+ };
await writeFile(
resolve(initialized.agentRoot, "agent.ts"),
- `import { useConnection, useInput, useTool } from "@opencomputer/agent";
-import { linear } from "./connections/linear.js";
+ `import { useInput, useTool } from "@opencomputer/agent";
export default function Agent() {
- useConnection(linear);
useTool("ask");
return useInput().answer ? "Act on the answer." : "Ask before acting.";
}
`,
);
-
- const built = await buildAgentArtifact(initialized.agentRoot);
- // The id counts as a declared connection, as a GitHub one does: the
- // backend admits a provider connection only when `connections` names it.
- assert.deepEqual(built.connections, ["linear"]);
- assert.deepEqual(built.httpConnections, []);
- assert.deepEqual(built.githubConnections, []);
- assert.deepEqual(built.linearConnections, [
- { id: "linear", provider: { kind: "linear-agent" } },
- ]);
- const runtimeRoot = await agentRuntimeDirectory(initialized.agentRoot);
- const manifest = JSON.parse(
- await readFile(
- resolve(runtimeRoot, ".opencomputer", "reactive.json"),
- "utf8",
- ),
- ) as { linearConnections: unknown[]; tools: string[] };
- assert.deepEqual(manifest.linearConnections, built.linearConnections);
// `ask` has no defineTool(); the literal selection is what records it.
- assert.deepEqual(manifest.tools, ["ask"]);
+ assert.deepEqual(await tools(), ["ask"]);
- // The emitted shim is what the bundled agent imports at run time.
- const shim = (await import(
- `${pathToFileURL(resolve(runtimeRoot, "opencomputer-agent.js")).href}?test=${crypto.randomUUID()}`
- )) as {
- ASK_TOOL: string;
- linearAgent: () => { kind: string };
- defineConnection: (input: Record<string, unknown>) => {
- kind: string;
- id: string;
- provider: { kind: string };
- };
- };
- assert.equal(shim.ASK_TOOL, "ask");
- assert.deepEqual(
- shim.defineConnection({ id: "linear", provider: shim.linearAgent() }),
- { kind: "connection", id: "linear", provider: { kind: "linear-agent" } },
- );
- assert.throws(
- () => shim.defineConnection({ id: "x", provider: { kind: "jira" } }),
- /unsupported provider/,
- );
-
- // useTool(ASK_TOOL) selects the same tool as the literal.
+ // useTool(ASK_TOOL) selects the same tool as the literal, and the
+ // emitted shim exports the constant the bundled agent imports.
await writeFile(
resolve(initialized.agentRoot, "agent.ts"),
- `import { ASK_TOOL, useConnection, useTool } from "@opencomputer/agent";
-import { linear } from "./connections/linear.js";
+ `import { ASK_TOOL, useTool } from "@opencomputer/agent";
export default function Agent() {
- useConnection(linear);
useTool(ASK_TOOL);
return "Ask before acting.";
}
`,
);
- await buildAgentArtifact(initialized.agentRoot);
- assert.deepEqual(
- (
- JSON.parse(
- await readFile(
- resolve(
- await agentRuntimeDirectory(initialized.agentRoot),
- ".opencomputer",
- "reactive.json",
- ),
- "utf8",
- ),
- ) as { tools: string[] }
- ).tools,
- ["ask"],
- );
- } finally {
- await rm(parent, { recursive: true, force: true });
- }
-});
-
-test("the compiler rejects Linear connections it cannot record as written", async () => {
- const parent = await mkdtemp(
- resolve(tmpdir(), "opencomputer-linear-invalid-"),
- );
- const root = resolve(parent, "app");
- try {
- const initialized = await initializeAgentProject(root);
- await mkdir(resolve(initialized.agentRoot, "connections"), {
- recursive: true,
- });
- const connection = resolve(
- initialized.agentRoot,
- "connections",
- "linear.ts",
- );
- await writeFile(
- resolve(initialized.agentRoot, "agent.ts"),
- `import "./connections/linear.js";
-export default function Agent() { return "Use Linear."; }
-`,
- );
- const rejects = async (source: string, pattern: RegExp) => {
- await writeFile(connection, source);
- await assert.rejects(buildAgentArtifact(initialized.agentRoot), pattern);
- };
- await rejects(
- `import { defineConnection, linearAgent } from "@opencomputer/agent";
-export default defineConnection({
- id: "linear",
- provider: linearAgent({ workspace: "acme" }),
-});
-`,
- /Connection linear linearAgent\(\) takes no options/,
- );
- await rejects(
- `import { defineConnection, linearAgent } from "@opencomputer/agent";
-const provider = linearAgent();
-export default defineConnection({ id: "linear", provider: provider });
-`,
- /provider must be an inline githubApp\(\) or linearAgent\(\) call/,
- );
- await rejects(
- `import { defineConnection, linearAgent } from "@opencomputer/agent";
-export default defineConnection({
- id: "linear",
- provider: linearAgent(),
- origin: "https://api.linear.app",
-});
-`,
- /Linear connection linear does not support the origin option/,
- );
- await rejects(
- `import { defineConnection, githubApp, linearAgent } from "@opencomputer/agent";
-export const linear = defineConnection({ id: "work", provider: linearAgent() });
-export const github = defineConnection({
- id: "work",
- provider: githubApp({ permissions: { contents: "read" } }),
-});
-`,
- /Connection id "work" is defined more than once/,
- );
+ assert.deepEqual(await tools(), ["ask"]);
+ const shim = (await import(
+ `${pathToFileURL(resolve(await agentRuntimeDirectory(initialized.agentRoot), "opencomputer-agent.js")).href}?test=${crypto.randomUUID()}`
+ )) as { ASK_TOOL: string };
+ assert.equal(shim.ASK_TOOL, "ask");
} finally {
await rm(parent, { recursive: true, force: true });
}
diff --git a/cli/src/project.ts b/cli/src/project.ts
index 39ab2846..60b6be4c 100644
--- a/cli/src/project.ts
+++ b/cli/src/project.ts
@@ -41,7 +41,6 @@ export interface BuiltAgentArtifact {
connections: string[];
httpConnections: HttpConnectionManifest[];
githubConnections: GitHubConnectionManifest[];
- linearConnections: LinearConnectionManifest[];
memory: MemoryDeclaration[];
models: Array<{ provider: string; model: string }>;
body: Buffer;
@@ -94,16 +93,6 @@ export interface GitHubConnectionManifest {
};
}
-/**
- * `defineConnection({ id, provider: linearAgent() })`: Linear's GraphQL API as
- * the agent's own Linear app. The provider has no options; the token is the
- * environment's Linear connection bound to the agent, attached at egress.
- */
-export interface LinearConnectionManifest {
- id: string;
- provider: { kind: "linear-agent" };
-}
-
/** The platform's question tool. Selected with useTool("ask"); no defined tool may take the id. */
const ASK_TOOL = "ask";
@@ -2661,22 +2650,12 @@ const GITHUB_APP_PERMISSION_KEYS = new Set([
"pull_requests",
]);
-/**
- * Connections whose provider the platform holds the credential for:
- * `githubApp({ permissions })` and `linearAgent()`. Each must be written as
- * an inline call in the `defineConnection()` literal, so the deployment can
- * record the provider without running the module.
- */
-function definedProviderConnections(
+function definedGitHubConnections(
source: string,
path: string,
-): {
- github: GitHubConnectionManifest[];
- linear: LinearConnectionManifest[];
-} {
+): GitHubConnectionManifest[] {
const file = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true);
const definitions: GitHubConnectionManifest[] = [];
- const linear: LinearConnectionManifest[] = [];
const visit = (node: ts.Node): void => {
if (
ts.isCallExpression(node) &&
@@ -2696,23 +2675,6 @@ function definedProviderConnections(
objectProperty(input, "id"),
"connection id",
);
- const providerCall =
- ts.isCallExpression(providerExpression) &&
- ts.isIdentifier(providerExpression.expression)
- ? providerExpression
- : undefined;
- const providerName = providerCall
- ? (providerCall.expression as ts.Identifier).text
- : undefined;
- if (
- !providerCall ||
- (providerName !== "githubApp" && providerName !== "linearAgent")
- ) {
- throw new Error(
- `Connection ${id} provider must be an inline githubApp() or linearAgent() call`,
- );
- }
- const providerLabel = providerName === "githubApp" ? "GitHub" : "Linear";
for (const property of input.properties) {
if (!ts.isPropertyAssignment(property)) {
throw new Error(
@@ -2722,22 +2684,21 @@ function definedProviderConnections(
const name = staticPropertyName(property.name, `Connection ${id}`);
if (name !== "id" && name !== "provider") {
throw new Error(
- `${providerLabel} connection ${id} does not support the ${name} option`,
+ `GitHub connection ${id} does not support the ${name} option`,
);
}
}
- if (providerName === "linearAgent") {
- // The provider has no options: the Linear workspace and app are the
- // environment's connection bound to the agent, never the source.
- if (providerCall.arguments.length > 0) {
- throw new Error(`Connection ${id} linearAgent() takes no options`);
- }
- linear.push({ id, provider: { kind: "linear-agent" } });
- ts.forEachChild(node, visit);
- return;
+ if (
+ !ts.isCallExpression(providerExpression) ||
+ !ts.isIdentifier(providerExpression.expression) ||
+ providerExpression.expression.text !== "githubApp"
+ ) {
+ throw new Error(
+ `Connection ${id} provider must be an inline githubApp() call`,
+ );
}
const options = literalCallArgument(
- providerCall,
+ providerExpression,
`Connection ${id} githubApp()`,
);
if (!options) {
@@ -2819,7 +2780,7 @@ function definedProviderConnections(
ts.forEachChild(node, visit);
};
visit(file);
- return { github: definitions, linear };
+ return definitions;
}
interface DefinedTool {
@@ -3232,7 +3193,6 @@ export const githubApp = (options) => {
}
return Object.freeze({ kind: "github-app", permissions: Object.freeze(permissions) });
};
-export const linearAgent = () => Object.freeze({ kind: "linear-agent" });
export const ASK_TOOL = "ask";
export const callService = async (request) => {
const base = globalThis.process?.env?.OPENCOMPUTER_CONNECTIONS_URL;
@@ -3290,7 +3250,7 @@ export const listServices = async (options = {}) => {
export const defineConnection = (input) => {
const connectionId = id(input.id, "defineConnection");
if (input.provider) {
- if (input.provider.kind !== "github-app" && input.provider.kind !== "linear-agent") throw new Error("defineConnection() received an unsupported provider");
+ if (input.provider.kind !== "github-app") throw new Error("defineConnection() received an unsupported provider");
return Object.freeze({ kind: "connection", id: connectionId, provider: input.provider });
}
const origin = new URL(input.origin);
@@ -3773,20 +3733,10 @@ the product or support surface presented to users.
const httpConnections = sourceModules.flatMap((module) =>
definedHttpConnections(module.source, module.path),
);
- const providerConnections = sourceModules.map((module) =>
- definedProviderConnections(module.source, module.path),
+ const githubConnections = sourceModules.flatMap((module) =>
+ definedGitHubConnections(module.source, module.path),
);
- const githubConnections = providerConnections.flatMap(
- (connections) => connections.github,
- );
- const linearConnections = providerConnections.flatMap(
- (connections) => connections.linear,
- );
- const allConnections = [
- ...httpConnections,
- ...githubConnections,
- ...linearConnections,
- ];
+ const allConnections = [...httpConnections, ...githubConnections];
const duplicateConnection = allConnections.find(
(connection, index) =>
allConnections.findIndex(
@@ -3885,7 +3835,6 @@ the product or support surface presented to users.
].sort(),
httpConnections,
githubConnections,
- linearConnections,
mcpServers: [
...new Set([
...mcpServerDefinitions.map((server) => server.id),
@@ -3936,14 +3885,12 @@ export async function buildAgentArtifact(
connections?: string[];
httpConnections?: HttpConnectionManifest[];
githubConnections?: GitHubConnectionManifest[];
- linearConnections?: LinearConnectionManifest[];
memory?: MemoryDeclaration[];
models?: Array<{ provider: string; model: string }>;
};
const connections = [...new Set(reactive.connections ?? [])].sort();
const httpConnections = reactive.httpConnections ?? [];
const githubConnections = reactive.githubConnections ?? [];
- const linearConnections = reactive.linearConnections ?? [];
const memory = reactive.memory ?? [];
const models = reactive.models ?? [];
const body = Buffer.from(
@@ -3960,7 +3907,6 @@ export async function buildAgentArtifact(
connections,
httpConnections,
githubConnections,
- linearConnections,
memory,
models,
body,
diff --git a/cli/src/template.ts b/cli/src/template.ts
index 94a4ff44..063a7185 100644
--- a/cli/src/template.ts
+++ b/cli/src/template.ts
@@ -7,7 +7,6 @@ import {
readProjectResources,
type GitHubConnectionManifest,
type HttpConnectionManifest,
- type LinearConnectionManifest,
type MemoryDeclaration,
type ProjectResourceManifest,
} from "./project.js";
@@ -52,7 +51,6 @@ export interface TemplateBuildArtifact {
connections: string[];
httpConnections: HttpConnectionManifest[];
githubConnections: GitHubConnectionManifest[];
- linearConnections: LinearConnectionManifest[];
memory: MemoryDeclaration[];
models: Array<{ provider: string; model: string }>;
}
@@ -332,7 +330,6 @@ export async function buildTemplateProject(
connections: built.connections,
httpConnections: built.httpConnections,
githubConnections: built.githubConnections,
- linearConnections: built.linearConnections,
memory: built.memory,
models: built.models,
});
diff --git a/cloudflare-workers/api-edge/src/managed_agents.test.ts b/cloudflare-workers/api-edge/src/managed_agents.test.ts
index 4aa4a6ea..1ce419f9 100644
--- a/cloudflare-workers/api-edge/src/managed_agents.test.ts
+++ b/cloudflare-workers/api-edge/src/managed_agents.test.ts
@@ -3107,9 +3107,6 @@ describe("managed agents proxy", () => {
},
},
],
- linearConnections: [
- { id: "linear", provider: { kind: "linear-agent" } },
- ],
memory: [
{
id: "requirements",
@@ -3173,9 +3170,6 @@ describe("managed agents proxy", () => {
},
},
],
- linearConnections: [
- { id: "linear", provider: { kind: "linear-agent" } },
- ],
memory: [
{
id: "requirements",
diff --git a/cloudflare-workers/api-edge/src/managed_agents.ts b/cloudflare-workers/api-edge/src/managed_agents.ts
index e099ab66..71eb0b92 100644
--- a/cloudflare-workers/api-edge/src/managed_agents.ts
+++ b/cloudflare-workers/api-edge/src/managed_agents.ts
@@ -2389,9 +2389,6 @@ async function deploySourceAgent(
githubConnections: Array.isArray(body.githubConnections)
? body.githubConnections
: [],
- linearConnections: Array.isArray(body.linearConnections)
- ? body.linearConnections
- : [],
memory: Array.isArray(body.memory) ? body.memory : [],
models,
...(body.projectDeployment && typeof body.projectDeployment === "object"