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 changes: 2 additions & 1 deletion .github/workflows/publish_typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ jobs:
adapters/typescript/opencode \
adapters/typescript/qwen \
adapters/typescript/kilo \
adapters/typescript/kiro; do
adapters/typescript/kiro \
adapters/typescript/strands; do
python3 scripts/ci/publish_typescript_package.py \
--action publish \
--package-directory "$package_directory" \
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ NeMo Fabric includes adapters for the following harnesses and execution targets.
| [Factory Droid](adapters/typescript/droid/README.md) | ✅ | ✅ | ✅ | — |
| [Hermes Agent](adapters/python/hermes/README.md) | ✅ | ✅ | ✅ | ✅ |
| [Kilo Code](adapters/typescript/kilo/README.md) | ✅ | ✅ | ✅ | — |
| [Kiro](adapters/typescript/kiro/README.md) | — | ✅ | — | — |
| [AWS Kiro](adapters/typescript/kiro/README.md) | — | ✅ | — | — |
| [AWS Strands](adapters/typescript/strands/README.md) | — | ✅ | — | — |
| [LangChain Deep Agents](adapters/python/deepagents/README.md) | ✅ | ✅ | ✅ | ✅ |
| [mini-SWE-agent](adapters/python/mini-swe-agent/README.md) | — | — | — | ✅ |
| [NOOA](adapters/python/nooa/README.md) | — | ✅ | ✅ | ✅ |
Expand Down
8 changes: 5 additions & 3 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ package-specific tag pushes:
| Ecosystem | Published Surface |
|---|---|
| crates.io | `nemo-fabric-core`, `nemo-fabric-cli` |
| npm | `nemo-fabric-adapter-contract`, `nemo-fabric-adapters-common`, `nemo-fabric-adapters-droid`, `nemo-fabric-adapters-pi`, `nemo-fabric-adapters-opencode`, `nemo-fabric-adapters-qwen`, `nemo-fabric-adapters-kiro` |
| npm | `nemo-fabric-adapter-contract`, `nemo-fabric-adapters-common`, `nemo-fabric-adapters-droid`, `nemo-fabric-adapters-pi`, `nemo-fabric-adapters-opencode`, `nemo-fabric-adapters-qwen`, `nemo-fabric-adapters-kiro`, `nemo-fabric-adapters-strands` |
| GitHub Actions | `nemo-fabric`, `nemo-fabric-runtime`, `nemo-fabric-collector`, `nemo-fabric-adapter-catalog`, `nemo-fabric-adapters-common`, `nemo-fabric-adapters-claude`, `nemo-fabric-adapters-codex`, `nemo-fabric-adapters-deepagents`, `nemo-fabric-adapters-hermes`, and `nemo-fabric-adapters-nooa` wheel artifacts |
| Fern | The documentation site |

Expand Down Expand Up @@ -544,7 +544,8 @@ After the release is live, verify:
nemo-fabric-adapters-pi \
nemo-fabric-adapters-opencode \
nemo-fabric-adapters-qwen \
nemo-fabric-adapters-kiro; do
nemo-fabric-adapters-kiro \
nemo-fabric-adapters-strands; do
npm view "${package}@<release-version>" version \
--registry="$npmjs_registry"
npm view "$package" dist-tags --registry="$npmjs_registry"
Expand All @@ -561,7 +562,8 @@ After the release is live, verify:
"nemo-fabric-adapters-pi@<release-version>" \
"nemo-fabric-adapters-opencode@<release-version>" \
"nemo-fabric-adapters-qwen@<release-version>" \
"nemo-fabric-adapters-kiro@<release-version>"
"nemo-fabric-adapters-kiro@<release-version>" \
"nemo-fabric-adapters-strands@<release-version>"
npm audit signatures --registry="$npmjs_registry"
)
```
Expand Down
71 changes: 37 additions & 34 deletions adapters/README.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion adapters/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0
# NVIDIA NeMo Fabric TypeScript Adapter Workspace

This private npm workspace coordinates the independently published common,
Cline, Pi, OpenCode, Qwen Code, Kilo Code, and Kiro adapter packages. It
Cline, Pi, OpenCode, Qwen Code, Kilo Code, AWS Kiro, and AWS Strands adapter packages. It
provides shared build, test, package-content, and consumer-install checks
without becoming a published package itself.

Expand Down Expand Up @@ -76,3 +76,5 @@ npm dependency.
The OpenCode adapter runs with Bun 1.4.2 or later. Source and package checks
run its process lifecycle under Bun while using Node.js for TypeScript builds
and the shared workspace tooling.

The [AWS Strands adapter](strands/README.md) runs the standard Strands harness through the shared ACP runner. Install the CLI separately, then use `just install-typescript-strands` to install the adapter workspace dependencies.
Comment thread
AnuradhaKaruppiah marked this conversation as resolved.
4 changes: 3 additions & 1 deletion adapters/typescript/common/acp-runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ When an agent invocation exceeds its deadline, the runner attempts to send `sess

## Stop a Session

Shutdown is idempotent. The runner disposes its active-session observer, requests `session/close` when the agent advertises that capability, and closes the ACP connection. On POSIX systems, the agent runs in a dedicated process group: cleanup sends `SIGTERM` to the group, waits for the agent to exit within the shutdown timeout, then sends `SIGKILL` to any remaining group members. On Windows, cleanup uses `taskkill /T /F` to terminate the agent and its descendants. The runner waits for the agent process to exit before returning.
Shutdown is idempotent. The runner disposes its active-session observer, requests `session/close` when the agent advertises that capability, and closes the ACP connection. On POSIX systems, the agent runs in a dedicated process group: cleanup sends `SIGTERM` to the group, waits for the agent to exit within the shutdown timeout, then sends `SIGKILL` to any remaining group members. On Windows, cleanup uses `taskkill /T /F` to terminate the agent and its descendants. The runner waits for the agent process to exit before returning. If process termination fails, a later `stop()` retries termination while prompts remain disabled. Concurrent stop calls share the same cleanup attempt; calls after successful termination do nothing.

Refer to the [Kiro adapter](../kiro/README.md) for the first integration that uses the shared ACP runner.

The [Strands adapter](../strands/README.md) also uses this runner. It configures the standard Strands CLI before session creation, relies on the new-session response for MCP readiness, and normalizes invocation-local usage. These target-specific choices remain in the adapter.
43 changes: 29 additions & 14 deletions adapters/typescript/common/src/acp-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ class SpawnedAcpSession implements AcpSession {
readonly initializeResponse: InitializeResponse;

private stopped = false;
private processTerminated = false;
private stopPromise: Promise<void> | undefined;
private readonly child: ChildProcessWithoutNullStreams;
private readonly connection: ClientConnection;
private readonly activeSession: ActiveSession;
Expand Down Expand Up @@ -267,23 +269,36 @@ class SpawnedAcpSession implements AcpSession {
}

async stop(): Promise<void> {
if (this.stopped) return;
this.stopped = true;
this.activeSession.dispose();

if (this.initializeResponse.agentCapabilities?.sessionCapabilities?.close != null) {
try {
await timeout(
this.connection.agent.request(methods.agent.session.close, { sessionId: this.sessionId }),
this.shutdownTimeoutMs,
new AcpRunnerError("acp_shutdown_timeout", "The ACP agent did not close the session before the deadline"),
);
} catch {
// Process termination below is the final cleanup boundary.
if (this.processTerminated) return;
if (this.stopPromise !== undefined) return this.stopPromise;
this.stopPromise = this.stopAttempt();
try {
await this.stopPromise;
} finally {
this.stopPromise = undefined;
}
}

private async stopAttempt(): Promise<void> {
if (!this.stopped) {
this.stopped = true;
this.activeSession.dispose();

if (this.initializeResponse.agentCapabilities?.sessionCapabilities?.close != null) {
try {
await timeout(
this.connection.agent.request(methods.agent.session.close, { sessionId: this.sessionId }),
this.shutdownTimeoutMs,
new AcpRunnerError("acp_shutdown_timeout", "The ACP agent did not close the session before the deadline"),
);
} catch {
// Process termination below is the final cleanup boundary.
}
}
this.connection.close();
}
this.connection.close();
await terminateProcessTree(this.child, this.shutdownTimeoutMs);
this.processTerminated = true;
}
}

Expand Down
52 changes: 52 additions & 0 deletions adapters/typescript/common/test/acp-runner.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,55 @@ for (const scenario of ["parent exits", "forced shutdown", "partial startup"]) {
}
});
}

test("retries process-group termination after a failed stop", { skip: process.platform === "win32" }, async (t) => {
const directory = await mkdtemp(join(tmpdir(), "fabric-acp-retry-"));
const marker = join(directory, "pids.json");
const session = await startAcpSession({
command: process.execPath,
args: [fixture],
cwd: process.cwd(),
env: { ...process.env, TEST_DESCENDANT_MARKER: marker, TEST_IGNORE_SIGTERM: "1" },
shutdownTimeoutMs: 100,
});
const pids = JSON.parse(await readFile(marker, "utf8"));
const originalKill = process.kill.bind(process);
let failTermination = true;
const kill = t.mock.method(process, "kill", (pid, signal) => {
if (pid === -pids.parent && signal === "SIGTERM" && failTermination) {
failTermination = false;
throw Object.assign(new Error("termination denied"), { code: "EPERM" });
}
return originalKill(pid, signal);
});
let cleanupError;
try {
await assert.rejects(session.stop(), { code: "EPERM" });
originalKill(pids.child, 0);
await assert.rejects(session.prompt("after failed stop"), { code: "acp_session_stopped" });
await Promise.all([session.stop(), session.stop()]);
await waitForProcessToStop(pids.parent);
await waitForProcessToStop(pids.child);
assert.equal(kill.mock.calls.filter(({ arguments: [pid, signal] }) => pid === -pids.parent && signal === "SIGTERM").length, 2);
const signalCount = kill.mock.callCount();
await session.stop();
assert.equal(kill.mock.callCount(), signalCount);
} finally {
try {
kill.mock.restore();
} catch (error) {
cleanupError ??= error;
}
for (const pid of [pids.parent, pids.child]) {
try { originalKill(pid, "SIGKILL"); } catch (error) {
if (error.code !== "ESRCH") cleanupError ??= error;
}
Comment thread
AnuradhaKaruppiah marked this conversation as resolved.
}
try {
await session.stop();
} catch (error) {
cleanupError ??= error;
}
}
if (cleanupError !== undefined) throw cleanupError;
});
57 changes: 56 additions & 1 deletion adapters/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions adapters/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
"opencode",
"qwen",
"kilo",
"kiro"
"kiro",
"strands"
],
"scripts": {
"build": "npm run build --workspace nemo-fabric-adapters-common && npm run build --workspace nemo-fabric-adapters-cline && npm run build --workspace nemo-fabric-adapters-droid && npm run build --workspace nemo-fabric-adapters-pi && npm run build --workspace nemo-fabric-adapters-opencode && npm run build --workspace nemo-fabric-adapters-qwen && npm run build --workspace nemo-fabric-adapters-kilo && npm run build --workspace nemo-fabric-adapters-kiro",
"build": "npm run build --workspace nemo-fabric-adapters-common && npm run build --workspace nemo-fabric-adapters-cline && npm run build --workspace nemo-fabric-adapters-droid && npm run build --workspace nemo-fabric-adapters-pi && npm run build --workspace nemo-fabric-adapters-opencode && npm run build --workspace nemo-fabric-adapters-qwen && npm run build --workspace nemo-fabric-adapters-kilo && npm run build --workspace nemo-fabric-adapters-kiro && npm run build --workspace nemo-fabric-adapters-strands",
"pack:check": "npm run pack:contents && npm run pack:install-check",
"pack:contents": "npm run pack:check --workspace nemo-fabric-adapters-common && npm run pack:check --workspace nemo-fabric-adapters-cline && npm run pack:check --workspace nemo-fabric-adapters-droid && npm run pack:check --workspace nemo-fabric-adapters-pi && npm run pack:check --workspace nemo-fabric-adapters-opencode && npm run pack:check --workspace nemo-fabric-adapters-qwen && npm run pack:check --workspace nemo-fabric-adapters-kilo && npm run pack:check --workspace nemo-fabric-adapters-kiro",
"pack:contents": "npm run pack:check --workspace nemo-fabric-adapters-common && npm run pack:check --workspace nemo-fabric-adapters-cline && npm run pack:check --workspace nemo-fabric-adapters-droid && npm run pack:check --workspace nemo-fabric-adapters-pi && npm run pack:check --workspace nemo-fabric-adapters-opencode && npm run pack:check --workspace nemo-fabric-adapters-qwen && npm run pack:check --workspace nemo-fabric-adapters-kilo && npm run pack:check --workspace nemo-fabric-adapters-kiro && npm run pack:check --workspace nemo-fabric-adapters-strands",
"pack:install-check": "node scripts/check-install.mjs",
"test": "npm run test:units && npm run test:dependencies && npm run pack:check",
"test:dependencies": "npm ls --all && node scripts/audit-dependencies.mjs",
"test:units": "node --test scripts/audit-dependencies.test.mjs && npm test --workspace nemo-fabric-adapters-common && npm test --workspace nemo-fabric-adapters-cline && npm test --workspace nemo-fabric-adapters-droid && npm test --workspace nemo-fabric-adapters-pi && npm test --workspace nemo-fabric-adapters-opencode && npm test --workspace nemo-fabric-adapters-qwen && npm test --workspace nemo-fabric-adapters-kilo && npm test --workspace nemo-fabric-adapters-kiro"
"test:units": "node --test scripts/audit-dependencies.test.mjs && npm test --workspace nemo-fabric-adapters-common && npm test --workspace nemo-fabric-adapters-cline && npm test --workspace nemo-fabric-adapters-droid && npm test --workspace nemo-fabric-adapters-pi && npm test --workspace nemo-fabric-adapters-opencode && npm test --workspace nemo-fabric-adapters-qwen && npm test --workspace nemo-fabric-adapters-kilo && npm test --workspace nemo-fabric-adapters-kiro && npm run test --workspace nemo-fabric-adapters-strands"
},
"devDependencies": {
"nemo-fabric-adapter-contract": "file:../../adapter-contract/typescript"
Expand Down
Loading
Loading