Skip to content

Open-source, local-first AI agent for real work.

874 B
Raw Blame
import { createLsToolRegistration } from "../../../src/coding/index.js";
import type { LsBehaviorSubject, LsBehaviorSubjectOptions } from "./ls-behavior-contract.js";
import { defineLsBehaviorContract } from "./ls-behavior-contract.js";

function createRuntimeSubject(cwd: string, options?: LsBehaviorSubjectOptions): LsBehaviorSubject {
	const registration = createLsToolRegistration(cwd, options);
	return {
		definition: {
			name: registration.tool.name,
			label: registration.tool.label,
			description: registration.tool.description,
			schema: registration.tool.inputSchema,
		},
		execute(input, signal = new AbortController().signal) {
			return registration.tool.execute({
				sessionId: "session-1",
				turnId: "turn-1",
				toolCallId: "runtime-ls-contract",
				input,
				signal,
			});
		},
	};
}

defineLsBehaviorContract("runtime", createRuntimeSubject);