@kynver-app/runtime 0.1.118 → 0.1.119
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.
- package/dist/chat/anthropic-credentials.d.ts +9 -0
- package/dist/chat/anthropic-stream.d.ts +43 -0
- package/dist/chat/chat-claim-loop.d.ts +25 -0
- package/dist/chat/delta-batcher.d.ts +13 -0
- package/dist/cli.js +8143 -6989
- package/dist/cli.js.map +4 -4
- package/dist/config.d.ts +2 -0
- package/dist/cron/cron-env-file.d.ts +15 -0
- package/dist/cron/cron-id.d.ts +3 -0
- package/dist/cron/cron-install-api.d.ts +27 -0
- package/dist/cron/cron-install-cli.d.ts +2 -0
- package/dist/cron/cron-install-plan.d.ts +32 -0
- package/dist/cron/cron-install-secrets.d.ts +6 -0
- package/dist/cron/cron-install-systemd.d.ts +18 -0
- package/dist/cron/cron-install-verify.d.ts +15 -0
- package/dist/cron/cron-install.d.ts +51 -0
- package/dist/cron/cron-store.d.ts +5 -0
- package/dist/index.js +1349 -197
- package/dist/index.js.map +4 -4
- package/dist/server/cleanup.js.map +2 -2
- package/dist/server/default-repo.js.map +2 -2
- package/dist/server/memory-cost-enforce.js.map +1 -1
- package/dist/server/monitor.js.map +2 -2
- package/dist/server/worker-policy.js.map +2 -2
- package/dist/start.d.ts +7 -0
- package/dist/worktree.d.ts +8 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type LocalAnthropicCredentials = {
|
|
2
|
+
kind: "api_key";
|
|
3
|
+
key: string;
|
|
4
|
+
} | {
|
|
5
|
+
kind: "oauth";
|
|
6
|
+
token: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function parseClaudeCredentials(raw: string, now?: number): string | null;
|
|
9
|
+
export declare function resolveLocalAnthropicCredentials(env?: Record<string, string | undefined>): LocalAnthropicCredentials | null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { LocalAnthropicCredentials } from "./anthropic-credentials.js";
|
|
2
|
+
export interface ChatTurnPayload {
|
|
3
|
+
system: string;
|
|
4
|
+
tools?: unknown[];
|
|
5
|
+
messages: unknown[];
|
|
6
|
+
maxTokens: number;
|
|
7
|
+
temperature?: number;
|
|
8
|
+
}
|
|
9
|
+
/** Anthropic-shaped final message — the relay's `final` event body. */
|
|
10
|
+
export interface LocalTurnMessage {
|
|
11
|
+
content: unknown[];
|
|
12
|
+
stop_reason: string;
|
|
13
|
+
usage: {
|
|
14
|
+
input_tokens: number;
|
|
15
|
+
output_tokens: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
interface ContentBlockAccumulator {
|
|
19
|
+
type: "text" | "tool_use";
|
|
20
|
+
text: string;
|
|
21
|
+
id?: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
inputJson: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AnthropicStreamAccumulator {
|
|
26
|
+
blocks: ContentBlockAccumulator[];
|
|
27
|
+
stopReason: string | null;
|
|
28
|
+
inputTokens: number;
|
|
29
|
+
outputTokens: number;
|
|
30
|
+
}
|
|
31
|
+
export declare function createAnthropicAccumulator(): AnthropicStreamAccumulator;
|
|
32
|
+
/** Fold one parsed SSE event; returns the text delta it carried (if any). */
|
|
33
|
+
export declare function foldAnthropicEvent(acc: AnthropicStreamAccumulator, event: unknown): string;
|
|
34
|
+
export declare function toLocalTurnMessage(acc: AnthropicStreamAccumulator): LocalTurnMessage;
|
|
35
|
+
export declare function getAnthropicBaseUrl(env?: Record<string, string | undefined>): string;
|
|
36
|
+
export declare function streamLocalAnthropicTurn(input: {
|
|
37
|
+
creds: LocalAnthropicCredentials;
|
|
38
|
+
model: string;
|
|
39
|
+
payload: ChatTurnPayload;
|
|
40
|
+
onDelta: (text: string) => void;
|
|
41
|
+
signal?: AbortSignal;
|
|
42
|
+
}): Promise<LocalTurnMessage>;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ChatTurnPayload } from "./anthropic-stream.js";
|
|
2
|
+
export interface ChatBridgeTarget {
|
|
3
|
+
bridgeUrl: string;
|
|
4
|
+
agentOsId: string;
|
|
5
|
+
apiKey: string;
|
|
6
|
+
boxId: string;
|
|
7
|
+
model: string;
|
|
8
|
+
}
|
|
9
|
+
/** Resolve the chat-bridge target; null when the feature is off/unconfigured. */
|
|
10
|
+
export declare function resolveChatBridgeTarget(env?: Record<string, string | undefined>): ChatBridgeTarget | null;
|
|
11
|
+
interface ClaimedTurn {
|
|
12
|
+
turnId: string;
|
|
13
|
+
agentOsId: string;
|
|
14
|
+
payload: ChatTurnPayload;
|
|
15
|
+
}
|
|
16
|
+
/** Execute one claimed turn and stream its events back. Never throws. */
|
|
17
|
+
export declare function executeChatTurn(target: ChatBridgeTarget, turn: ClaimedTurn): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* The forever loop the daemon runs alongside its pipeline ticks. Serial by
|
|
20
|
+
* design (one turn at a time per box). Exits when `shouldStop()` flips.
|
|
21
|
+
*/
|
|
22
|
+
export declare function runChatClaimLoop(opts: {
|
|
23
|
+
shouldStop: () => boolean;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const DELTA_FLUSH_FLOOR_MS = 150;
|
|
2
|
+
export declare class DeltaBatcher {
|
|
3
|
+
private readonly flushFn;
|
|
4
|
+
private readonly floorMs;
|
|
5
|
+
private buffer;
|
|
6
|
+
private timer;
|
|
7
|
+
private closed;
|
|
8
|
+
constructor(flushFn: (text: string) => void, floorMs?: number);
|
|
9
|
+
push(text: string): void;
|
|
10
|
+
private flushNow;
|
|
11
|
+
/** Flush any remainder and stop the timer. Idempotent. */
|
|
12
|
+
close(): void;
|
|
13
|
+
}
|