@deepstrike/sdk 0.1.15 → 0.2.0
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/collaboration/harness.d.ts +4 -1
- package/dist/collaboration/harness.js +20 -6
- package/dist/collaboration/modes/creator-verifier.d.ts +8 -2
- package/dist/collaboration/modes/creator-verifier.js +9 -3
- package/dist/collaboration/pool.d.ts +24 -3
- package/dist/collaboration/pool.js +65 -5
- package/dist/harness/harness.d.ts +5 -1
- package/dist/harness/harness.js +23 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +5 -0
- package/dist/kernel.d.ts +12 -43
- package/dist/kernel.js +1 -1
- package/dist/providers/anthropic.js +7 -2
- package/dist/providers/base.d.ts +12 -0
- package/dist/providers/base.js +75 -0
- package/dist/providers/catalog.d.ts +3 -2
- package/dist/providers/catalog.js +61 -13
- package/dist/providers/deepseek.js +1 -1
- package/dist/providers/gemini.d.ts +3 -0
- package/dist/providers/gemini.js +26 -6
- package/dist/providers/glm.d.ts +9 -0
- package/dist/providers/glm.js +21 -0
- package/dist/providers/kimi.js +2 -0
- package/dist/providers/minimax.js +5 -0
- package/dist/providers/openai-responses.js +9 -0
- package/dist/providers/openai.js +52 -6
- package/dist/providers/profiles.d.ts +1304 -242
- package/dist/providers/profiles.js +429 -26
- package/dist/providers/qwen.d.ts +3 -1
- package/dist/providers/qwen.js +43 -13
- package/dist/runtime/archive.d.ts +15 -0
- package/dist/runtime/archive.js +35 -0
- package/dist/runtime/execution-plane.js +14 -4
- package/dist/runtime/filtered-plane.d.ts +14 -0
- package/dist/runtime/filtered-plane.js +45 -0
- package/dist/runtime/kernel-step.d.ts +88 -0
- package/dist/runtime/kernel-step.js +262 -0
- package/dist/runtime/process-sandbox-plane.d.ts +4 -4
- package/dist/runtime/process-sandbox-plane.js +5 -5
- package/dist/runtime/provider-replay.js +37 -3
- package/dist/runtime/replay-sanitize.d.ts +5 -0
- package/dist/runtime/replay-sanitize.js +25 -0
- package/dist/runtime/runner.d.ts +60 -4
- package/dist/runtime/runner.js +589 -86
- package/dist/runtime/session-log.d.ts +93 -1
- package/dist/runtime/session-repair.d.ts +37 -0
- package/dist/runtime/session-repair.js +77 -0
- package/dist/runtime/sub-agent-orchestrator.d.ts +19 -0
- package/dist/runtime/sub-agent-orchestrator.js +114 -0
- package/dist/skills/watcher.d.ts +19 -0
- package/dist/skills/watcher.js +38 -0
- package/dist/tools/index.d.ts +4 -1
- package/dist/tools/index.js +82 -11
- package/dist/types/agent.d.ts +68 -0
- package/dist/types/agent.js +78 -0
- package/dist/types.d.ts +27 -0
- package/package.json +2 -2
|
@@ -1,16 +1,50 @@
|
|
|
1
|
+
import { effectiveProviderReplay } from "./session-repair.js";
|
|
2
|
+
function sortObjectKeys(val) {
|
|
3
|
+
if (val === null || typeof val !== "object") {
|
|
4
|
+
return val;
|
|
5
|
+
}
|
|
6
|
+
if (Array.isArray(val)) {
|
|
7
|
+
return val.map(sortObjectKeys);
|
|
8
|
+
}
|
|
9
|
+
const sortedKeys = Object.keys(val).sort();
|
|
10
|
+
const result = {};
|
|
11
|
+
for (const key of sortedKeys) {
|
|
12
|
+
result[key] = sortObjectKeys(val[key]);
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
1
16
|
export function assistantReplayKey(message) {
|
|
17
|
+
const toolCalls = (message.toolCalls ?? []).map(tc => {
|
|
18
|
+
let normalizedArgs = tc.arguments;
|
|
19
|
+
try {
|
|
20
|
+
const parsed = typeof tc.arguments === "string" ? JSON.parse(tc.arguments) : tc.arguments;
|
|
21
|
+
normalizedArgs = JSON.stringify(sortObjectKeys(parsed));
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// fallback
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
id: tc.id,
|
|
28
|
+
name: tc.name,
|
|
29
|
+
arguments: normalizedArgs,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
2
32
|
return JSON.stringify({
|
|
3
33
|
content: message.content,
|
|
4
|
-
toolCalls
|
|
34
|
+
toolCalls,
|
|
5
35
|
});
|
|
6
36
|
}
|
|
7
37
|
export function seedProviderReplayFromEvents(provider, events) {
|
|
8
38
|
if (!provider.seedProviderReplay)
|
|
9
39
|
return;
|
|
10
40
|
for (const { event } of events) {
|
|
11
|
-
if (event.kind !== "llm_completed"
|
|
41
|
+
if (event.kind !== "llm_completed")
|
|
42
|
+
continue;
|
|
43
|
+
const toolCalls = event.tool_calls ?? [];
|
|
44
|
+
const replay = effectiveProviderReplay(event.content, toolCalls, event.provider_replay);
|
|
45
|
+
if (!replay)
|
|
12
46
|
continue;
|
|
13
|
-
provider.seedProviderReplay({ content: event.content, toolCalls
|
|
47
|
+
provider.seedProviderReplay({ content: event.content, toolCalls }, replay);
|
|
14
48
|
}
|
|
15
49
|
}
|
|
16
50
|
export function peekProviderReplay(provider, content, toolCalls) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** UTF-8-safe text helpers for session replay (defense in depth). */
|
|
2
|
+
/** Soft cap — only snip very large llm_completed bodies before preload. */
|
|
3
|
+
export declare const REPLAY_CONTENT_MAX_BYTES = 32768;
|
|
4
|
+
export declare function truncateBytesAtCharBoundary(text: string, maxBytes: number): string;
|
|
5
|
+
export declare function sanitizeReplayText(text: string, maxBytes?: number): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** UTF-8-safe text helpers for session replay (defense in depth). */
|
|
2
|
+
/** Soft cap — only snip very large llm_completed bodies before preload. */
|
|
3
|
+
export const REPLAY_CONTENT_MAX_BYTES = 32_768;
|
|
4
|
+
export function truncateBytesAtCharBoundary(text, maxBytes) {
|
|
5
|
+
const data = Buffer.from(text, "utf8");
|
|
6
|
+
if (data.length <= maxBytes)
|
|
7
|
+
return text;
|
|
8
|
+
let end = maxBytes;
|
|
9
|
+
while (end > 0) {
|
|
10
|
+
const slice = data.subarray(0, end).toString("utf8");
|
|
11
|
+
if (Buffer.byteLength(slice, "utf8") <= end)
|
|
12
|
+
return slice;
|
|
13
|
+
end -= 1;
|
|
14
|
+
}
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
export function sanitizeReplayText(text, maxBytes = REPLAY_CONTENT_MAX_BYTES) {
|
|
18
|
+
if (!text)
|
|
19
|
+
return text;
|
|
20
|
+
const safe = Buffer.from(text, "utf8").toString("utf8");
|
|
21
|
+
if (Buffer.byteLength(safe, "utf8") <= maxBytes)
|
|
22
|
+
return safe;
|
|
23
|
+
const prefix = truncateBytesAtCharBoundary(safe, maxBytes);
|
|
24
|
+
return `${prefix}… [replay truncated]`;
|
|
25
|
+
}
|
package/dist/runtime/runner.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { LLMProvider, StreamEvent, ToolSuspendEvent } from "../types.js";
|
|
2
|
-
import type { DreamStore
|
|
1
|
+
import type { LLMProvider, Message, ToolSchema, StreamEvent, ToolSuspendEvent } from "../types.js";
|
|
2
|
+
import type { DreamStore } from "../memory/protocols.js";
|
|
3
3
|
import type { KnowledgeSource } from "../knowledge/source.js";
|
|
4
4
|
import type { SignalSource } from "../signals/types.js";
|
|
5
|
-
import type { SessionLog } from "./session-log.js";
|
|
5
|
+
import type { SessionLog, SessionEvent } from "./session-log.js";
|
|
6
|
+
import type { ArchiveStore } from "./archive.js";
|
|
6
7
|
import type { ExecutionPlane } from "./execution-plane.js";
|
|
8
|
+
import type { AgentRunSpec, MilestoneCheckResult, MilestoneContract, MilestonePolicy } from "../types/agent.js";
|
|
9
|
+
import { type SubAgentOrchestrator } from "./sub-agent-orchestrator.js";
|
|
7
10
|
export interface RuntimeOptions {
|
|
8
11
|
provider: LLMProvider;
|
|
9
12
|
sessionLog: SessionLog;
|
|
@@ -27,23 +30,76 @@ export interface RuntimeOptions {
|
|
|
27
30
|
retryAfterMs?: number;
|
|
28
31
|
};
|
|
29
32
|
};
|
|
33
|
+
tokenizer?: string;
|
|
34
|
+
enablePlanTool?: boolean;
|
|
35
|
+
compressionStore?: ArchiveStore;
|
|
30
36
|
onToolSuspend?: (event: ToolSuspendEvent) => Promise<unknown> | unknown;
|
|
37
|
+
/** Default: terminate — stop with milestone_pending when a phase needs evaluation. */
|
|
38
|
+
milestonePolicy?: MilestonePolicy;
|
|
39
|
+
/** Optional external verifier when milestonePolicy is not auto_pass. */
|
|
40
|
+
onMilestoneEvaluate?: (ctx: {
|
|
41
|
+
phaseId: string;
|
|
42
|
+
criteria: string[];
|
|
43
|
+
requiredEvidence: string[];
|
|
44
|
+
}) => Promise<MilestoneCheckResult> | MilestoneCheckResult;
|
|
45
|
+
/** Passed to kernel start_run for role/isolation metadata. */
|
|
46
|
+
runSpec?: AgentRunSpec;
|
|
47
|
+
/** Loaded via load_milestone_contract before run start. */
|
|
48
|
+
milestoneContract?: MilestoneContract;
|
|
49
|
+
/** Custom sub-agent host driver; defaults to SubAgentOrchestrator. */
|
|
50
|
+
subAgentOrchestrator?: SubAgentOrchestrator;
|
|
51
|
+
/** Optional system prompt injected into the dream synthesis call. */
|
|
52
|
+
dreamSystemPrompt?: string;
|
|
31
53
|
}
|
|
32
54
|
export declare class RuntimeRunner {
|
|
33
55
|
private readonly opts;
|
|
34
56
|
private interrupted;
|
|
57
|
+
private activeKernel;
|
|
58
|
+
private pendingObservations;
|
|
59
|
+
private currentSessionId;
|
|
60
|
+
private nextArchiveStart;
|
|
35
61
|
constructor(opts: RuntimeOptions);
|
|
62
|
+
/** Host configuration (for coordinator / sub-agent spawn). */
|
|
63
|
+
get hostOptions(): RuntimeOptions;
|
|
64
|
+
/** Mount a tool capability on the currently-running kernel runtime. No-op if not running. */
|
|
65
|
+
mountTool(schema: ToolSchema): void;
|
|
66
|
+
/** Mount a skill capability on the currently-running kernel runtime. No-op if not running. */
|
|
67
|
+
mountSkill(name: string, description: string): void;
|
|
68
|
+
/** Mount a generic marker capability (e.g. MCP server, agent) on the active run. No-op if not running. */
|
|
69
|
+
mountMarker(kind: string, id: string, description: string): void;
|
|
70
|
+
/** Unmount a capability by kind + id from the active run. No-op if not running. */
|
|
71
|
+
unmountCapability(kind: string, id: string): void;
|
|
72
|
+
/** Push a large artifact into the kernel artifacts partition (not inlined in history). */
|
|
73
|
+
pushArtifact(message: Message, tokens?: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* Spawn an isolated sub-agent via the kernel, run it on the host, and feed the result back.
|
|
76
|
+
* Requires an active parent run (`run()` / `wake()` in progress or paused at milestone).
|
|
77
|
+
*/
|
|
78
|
+
spawnSubAgent(spec: AgentRunSpec): AsyncIterable<StreamEvent>;
|
|
36
79
|
interrupt(): void;
|
|
37
80
|
run(req: {
|
|
38
81
|
sessionId: string;
|
|
39
82
|
goal: string;
|
|
40
83
|
criteria?: string[];
|
|
41
84
|
extensions?: Record<string, unknown>;
|
|
85
|
+
/** Parent transcript to preload (e.g. sub-agent full context inheritance). */
|
|
86
|
+
inheritEvents?: Array<{
|
|
87
|
+
seq: number;
|
|
88
|
+
event: SessionEvent;
|
|
89
|
+
}>;
|
|
42
90
|
}): AsyncIterable<StreamEvent>;
|
|
43
91
|
wake(sessionId: string, extensions?: Record<string, unknown>): AsyncIterable<StreamEvent>;
|
|
44
|
-
dream(agentId: string, nowMs?: number):
|
|
92
|
+
dream(agentId: string, nowMs?: number): AsyncIterable<StreamEvent>;
|
|
45
93
|
private execute;
|
|
46
94
|
private appendObservations;
|
|
47
95
|
}
|
|
96
|
+
export declare function replayMessages(events: Array<{
|
|
97
|
+
seq: number;
|
|
98
|
+
event: SessionEvent;
|
|
99
|
+
}>, maxBytes?: number): Message[];
|
|
100
|
+
export declare function replayMessagesAsync(events: Array<{
|
|
101
|
+
seq: number;
|
|
102
|
+
event: SessionEvent;
|
|
103
|
+
}>, maxBytes?: number, loadArchive?: (archiveRef: string) => Promise<Message[]>): Promise<Message[]>;
|
|
48
104
|
/** Collect all text_delta events from a run into a single string. */
|
|
49
105
|
export declare function collectText(stream: AsyncIterable<StreamEvent>): Promise<string>;
|