@grackle-ai/runtime-sdk 0.108.3 → 0.110.1

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.
Files changed (2) hide show
  1. package/README.md +76 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @grackle-ai/runtime-sdk
2
+
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/@grackle-ai/runtime-sdk"><img src="https://img.shields.io/npm/v/@grackle-ai/runtime-sdk.svg" alt="npm version" /></a>
5
+ <a href="https://github.com/nick-pape/grackle/actions/workflows/ci.yml"><img src="https://github.com/nick-pape/grackle/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a>
6
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT" /></a>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <img src="https://raw.githubusercontent.com/nick-pape/grackle/main/apps/docs-site/static/img/grackle-logo.png" alt="Grackle" width="200" />
11
+ </p>
12
+
13
+ SDK for building [Grackle](https://github.com/nick-pape/grackle) agent runtimes.
14
+
15
+ Grackle runs AI coding agents inside environments. Each kind of agent is driven by a **runtime**: a module that knows how to spawn that particular agent SDK, stream its events, feed it follow-up input, and tear it down. A runtime is to an agent (Claude Code, Codex, Copilot, GenAIScript, ACP) what an [adapter](https://www.npmjs.com/package/@grackle-ai/adapter-sdk) is to an environment.
16
+
17
+ This package provides the interfaces, base classes, and shared utilities you need to write a custom runtime. If you want to drive an agent that isn't covered by the built-in runtimes, implement the `AgentRuntime` interface (or extend `BaseAgentRuntime` / `BaseAgentSession`) and plug it into the Grackle PowerLine.
18
+
19
+ ### Built-in Runtime Packages
20
+
21
+ - [`@grackle-ai/runtime-claude-code`](https://www.npmjs.com/package/@grackle-ai/runtime-claude-code) — Anthropic Claude Code (Claude Agent SDK)
22
+ - [`@grackle-ai/runtime-copilot`](https://www.npmjs.com/package/@grackle-ai/runtime-copilot) — GitHub Copilot
23
+ - [`@grackle-ai/runtime-codex`](https://www.npmjs.com/package/@grackle-ai/runtime-codex) — OpenAI Codex
24
+ - [`@grackle-ai/runtime-genaiscript`](https://www.npmjs.com/package/@grackle-ai/runtime-genaiscript) — GenAIScript
25
+ - [`@grackle-ai/runtime-acp`](https://www.npmjs.com/package/@grackle-ai/runtime-acp) — Agent Client Protocol (ACP) agents
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ npm install @grackle-ai/runtime-sdk
31
+ ```
32
+
33
+ ## Key Concepts
34
+
35
+ ### Runtimes
36
+
37
+ A runtime is a class that implements the `AgentRuntime` interface. It tells Grackle how to:
38
+
39
+ - **Spawn** — create and start a new agent session from a set of `SpawnOptions` (prompt, model, max turns, branch, MCP servers, and more).
40
+ - **Resume** — reattach to a previously suspended session using its runtime session ID.
41
+
42
+ Both `spawn()` and `resume()` return an `AgentSession`.
43
+
44
+ ### Sessions
45
+
46
+ An `AgentSession` is a handle to an in-progress agent run. It exposes:
47
+
48
+ - **`stream()`** — an async iterable of `AgentEvent`s emitted as the agent works.
49
+ - **`sendInput(text)`** — send follow-up user input to a session that is waiting for it.
50
+ - **`kill(reason?)`** — forcefully terminate the session.
51
+ - **`drainBufferedEvents()`** — collect any events that were buffered but not yet consumed by the stream.
52
+
53
+ Each `AgentEvent` carries a `type`, `timestamp`, `content`, and optional `raw` payload.
54
+
55
+ ### Base Classes
56
+
57
+ Most runtimes don't implement these interfaces from scratch. The SDK ships two abstract base classes that encode the shared lifecycle so a new runtime only needs to fill in the SDK-specific pieces:
58
+
59
+ - **`BaseAgentRuntime`** — implements `spawn()` and `resume()` by delegating to a single `createSession()` method you supply.
60
+ - **`BaseAgentSession`** — implements the full event-queue and `waiting_input` lifecycle: streaming, sequential follow-up processing, status transitions, and teardown. Subclasses implement abstract hooks such as `setupSdk()`, `runInitialQuery()`, `executeFollowUp()`, and `abortActive()`.
61
+
62
+ ### Shared Utilities
63
+
64
+ - **Working directory & worktrees** — `resolveWorkingDirectory()` and `findGitRepoPath()` locate the right git repository (honoring Docker `/workspace` and Codespaces `/workspaces/*` conventions) and prepare it for the session. The lower-level `ensureWorktree()` / `removeWorktree()` helpers create and clean up per-branch git worktrees for isolation.
65
+ - **MCP configuration** — `resolveMcpServers()` merges MCP server configs from the shared `GRACKLE_MCP_CONFIG` file and spawn options, applies `disallowedTools` filtering, and injects the Grackle MCP broker entry. `convertMcpServers()` translates Grackle's keyed config into the named-array format expected by ACP agents.
66
+ - **Runtime installer** — `ensureRuntimeInstalled()` lazily installs a runtime's npm packages into an isolated `~/.grackle/runtimes/<name>/` directory, `importFromRuntime()` dynamically imports modules from it, and `getRuntimeBinDirectory()` exposes the runtime's `.bin` path for spawning agent CLIs.
67
+ - **`AsyncQueue`** — a small `AsyncIterable` queue used to bridge pushed events into `for await` consumers, with `push`, `shift`, `drain`, and `close`.
68
+ - **`logger`** — a shared [pino](https://github.com/pinojs/pino) structured logger.
69
+
70
+ ## Requirements
71
+
72
+ - Node.js >= 22
73
+
74
+ ## License
75
+
76
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grackle-ai/runtime-sdk",
3
- "version": "0.108.3",
3
+ "version": "0.110.1",
4
4
  "description": "Grackle runtime SDK — interfaces, base classes, shared utilities, and runtime installer",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@modelcontextprotocol/sdk": "^1.27.0",
32
32
  "pino": "^10.3.1",
33
- "@grackle-ai/common": "0.108.3"
33
+ "@grackle-ai/common": "0.110.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@rushstack/heft": "1.2.7",