Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 357f035418 | |||
| f340ce52ee | |||
| ecc477d0be | |||
| f9ba77527a | |||
| f304c70899 |
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "paperclip-adapter-claude-k8s",
|
"name": "paperclip-adapter-claude-k8s",
|
||||||
"version": "0.1.40",
|
"version": "0.1.42",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "paperclip-adapter-claude-k8s",
|
"name": "paperclip-adapter-claude-k8s",
|
||||||
"version": "0.1.40",
|
"version": "0.1.42",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kubernetes/client-node": "^1.0.0",
|
"@kubernetes/client-node": "^1.0.0",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "paperclip-adapter-claude-k8s",
|
"name": "paperclip-adapter-claude-k8s",
|
||||||
"version": "0.1.40",
|
"version": "0.1.43",
|
||||||
"description": "Paperclip adapter plugin that runs Claude Code agents as Kubernetes Jobs",
|
"description": "Paperclip adapter plugin that runs Claude Code agents as Kubernetes Jobs",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
export { printClaudeStreamEvent, formatClaudeStreamLine } from "./format-event.js";
|
export { printClaudeStreamEvent } from "./format-event.js";
|
||||||
|
|||||||
+1
-1
@@ -52,4 +52,4 @@ Notes:
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export { createServerAdapter } from "./server/index.js";
|
export { createServerAdapter } from "./server/index.js";
|
||||||
export { printClaudeStreamEvent, formatClaudeStreamLine } from "./cli/index.js";
|
export { printClaudeStreamEvent } from "./cli/index.js";
|
||||||
|
|||||||
+8
-11
@@ -19,7 +19,6 @@ import {
|
|||||||
import { getSelfPodInfo, getBatchApi, getCoreApi, getLogApi } from "./k8s-client.js";
|
import { getSelfPodInfo, getBatchApi, getCoreApi, getLogApi } from "./k8s-client.js";
|
||||||
import { buildJobManifest, sanitizeLabelValue } from "./job-manifest.js";
|
import { buildJobManifest, sanitizeLabelValue } from "./job-manifest.js";
|
||||||
import { LogLineDedupFilter } from "./log-dedup.js";
|
import { LogLineDedupFilter } from "./log-dedup.js";
|
||||||
import { formatClaudeStreamLine } from "../cli/format-event.js";
|
|
||||||
import type * as k8s from "@kubernetes/client-node";
|
import type * as k8s from "@kubernetes/client-node";
|
||||||
import { Writable } from "node:stream";
|
import { Writable } from "node:stream";
|
||||||
|
|
||||||
@@ -354,21 +353,17 @@ export async function streamPodLogsOnce(
|
|||||||
const writable = new Writable({
|
const writable = new Writable({
|
||||||
write(chunk: Buffer, _encoding, callback) {
|
write(chunk: Buffer, _encoding, callback) {
|
||||||
const text = chunk.toString("utf-8");
|
const text = chunk.toString("utf-8");
|
||||||
// Always store raw text — parseClaudeStreamJson needs the original
|
|
||||||
// stream-json lines to extract session IDs, usage, and result events.
|
|
||||||
chunks.push(text);
|
chunks.push(text);
|
||||||
const emitted = dedup ? dedup.filter(text) : text;
|
const emitted = dedup ? dedup.filter(text) : text;
|
||||||
if (!emitted) {
|
if (!emitted) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Format each stream-json event into human-readable text before the
|
// Forward raw stream-json lines unchanged. The Paperclip UI uses the
|
||||||
// Paperclip server sees it, matching claude_local output style.
|
// adapter's ui-parser export (src/ui-parser.ts) to render structured
|
||||||
// Non-JSON lines (adapter status messages, plain errors) pass through.
|
// transcript entries — pre-formatting here would strip that structure
|
||||||
const formatted = emitted.split("\n")
|
// and produce flat plain text that looks nothing like claude_local.
|
||||||
.map((line) => formatClaudeStreamLine(line) ?? "")
|
void onLog("stdout", emitted).then(() => callback(), callback);
|
||||||
.join("\n");
|
|
||||||
void onLog("stdout", formatted).then(() => callback(), callback);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -654,7 +649,9 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
|
|||||||
labelSelector: `paperclip.io/agent-id=${sanitizedAgentId},paperclip.io/adapter-type=claude_k8s`,
|
labelSelector: `paperclip.io/agent-id=${sanitizedAgentId},paperclip.io/adapter-type=claude_k8s`,
|
||||||
});
|
});
|
||||||
const running = existing.items.filter(
|
const running = existing.items.filter(
|
||||||
(j) => !j.status?.conditions?.some((c) => (c.type === "Complete" || c.type === "Failed") && c.status === "True"),
|
(j) =>
|
||||||
|
!j.metadata?.deletionTimestamp &&
|
||||||
|
!j.status?.conditions?.some((c) => (c.type === "Complete" || c.type === "Failed") && c.status === "True"),
|
||||||
);
|
);
|
||||||
if (running.length > 0) {
|
if (running.length > 0) {
|
||||||
// Separate orphaned jobs (from a previous server-side run) from truly
|
// Separate orphaned jobs (from a previous server-side run) from truly
|
||||||
|
|||||||
Reference in New Issue
Block a user