stable-harness 0.0.2 → 0.0.4
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/cli.js +1 -1
- package/dist/compat/agent-harness.js +1 -1
- package/dist/index.d.ts +29 -6
- package/dist/index.js +1 -1
- package/dist/runtime/compat/agent-harness-compat-runner.js +1 -1
- package/dist/runtime/compat/json.js +1 -1
- package/dist/runtime/compat/presentation.js +1 -1
- package/dist/runtime/compat/prompts.js +1 -1
- package/dist/runtime/model/ollama.js +1 -1
- package/dist/runtime/skills/skill-metadata.js +1 -1
- package/dist/workspace/compile.js +1 -1
- package/package.json +14 -10
- package/packages/adapter-deepagents/dist/src/adapter.d.ts +1 -0
- package/packages/adapter-deepagents/dist/src/adapter.js +1 -1
- package/packages/adapter-deepagents/dist/src/index.d.ts +1 -0
- package/packages/adapter-deepagents/dist/src/index.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/builtin-args.d.ts +4 -0
- package/packages/adapter-deepagents/dist/src/internal/builtin-args.js +1 -0
- package/packages/adapter-deepagents/dist/src/internal/builtin-tool-policy.d.ts +39 -0
- package/packages/adapter-deepagents/dist/src/internal/builtin-tool-policy.js +1 -0
- package/packages/adapter-deepagents/dist/src/internal/gateway-tools.d.ts +32 -0
- package/packages/adapter-deepagents/dist/src/internal/gateway-tools.js +1 -0
- package/packages/adapter-deepagents/dist/src/internal/messages.js +1 -0
- package/packages/adapter-deepagents/dist/src/internal/raw-tool-call-parser.d.ts +12 -0
- package/packages/adapter-deepagents/dist/src/internal/raw-tool-call-parser.js +1 -0
- package/packages/adapter-deepagents/dist/src/internal/skill-file-policy.d.ts +10 -0
- package/packages/adapter-deepagents/dist/src/internal/skill-file-policy.js +1 -0
- package/packages/adapter-deepagents/dist/src/internal/stream-events.js +1 -0
- package/packages/adapter-deepagents/dist/src/internal/tool-repeat-visibility.d.ts +4 -0
- package/packages/adapter-deepagents/dist/src/internal/tool-repeat-visibility.js +1 -0
- package/packages/adapter-deepagents/dist/src/internal/trace-projection.d.ts +16 -0
- package/packages/adapter-deepagents/dist/src/internal/trace-projection.js +1 -0
- package/packages/adapter-deepagents/dist/src/memory.d.ts +5 -0
- package/packages/adapter-deepagents/dist/src/memory.js +1 -0
- package/packages/adapter-deepagents/dist/src/model-providers.d.ts +4 -0
- package/packages/adapter-deepagents/dist/src/model-providers.js +1 -0
- package/packages/adapter-deepagents/dist/src/retry-policy.js +1 -1
- package/packages/adapter-deepagents/dist/src/types.d.ts +7 -1
- package/packages/adapter-deepagents/package.json +1 -0
- package/packages/adapter-langgraph/dist/src/graph.d.ts +3 -0
- package/packages/adapter-langgraph/dist/src/graph.js +1 -0
- package/packages/adapter-langgraph/dist/src/index.d.ts +8 -0
- package/packages/adapter-langgraph/dist/src/index.js +1 -0
- package/packages/adapter-langgraph/dist/src/runtime.d.ts +3 -0
- package/packages/adapter-langgraph/dist/src/runtime.js +1 -0
- package/packages/adapter-langgraph/dist/src/skill-providers.d.ts +29 -0
- package/packages/adapter-langgraph/dist/src/skill-providers.js +1 -0
- package/packages/adapter-langgraph/dist/src/types.d.ts +60 -0
- package/packages/adapter-langgraph/dist/src/types.js +1 -0
- package/packages/adapter-langgraph/package.json +16 -0
- package/packages/cli/dist/src/args.d.ts +25 -0
- package/packages/cli/dist/src/args.js +1 -0
- package/packages/cli/dist/src/cli.js +1 -1
- package/packages/cli/dist/src/event-view.d.ts +9 -0
- package/packages/cli/dist/src/event-view.js +1 -0
- package/packages/cli/dist/src/index.d.ts +3 -0
- package/packages/cli/dist/src/index.js +1 -1
- package/packages/cli/dist/src/langgraph-env.d.ts +5 -0
- package/packages/cli/dist/src/langgraph-env.js +1 -0
- package/packages/cli/dist/src/langgraph-official.d.ts +13 -0
- package/packages/cli/dist/src/langgraph-official.js +1 -0
- package/packages/cli/dist/src/memory/lifecycle.d.ts +2 -0
- package/packages/cli/dist/src/memory/lifecycle.js +1 -0
- package/packages/cli/dist/src/memory/providers.d.ts +3 -0
- package/packages/cli/dist/src/memory/providers.js +1 -0
- package/packages/cli/dist/src/output.d.ts +8 -0
- package/packages/cli/dist/src/output.js +1 -0
- package/packages/cli/dist/src/server.d.ts +5 -0
- package/packages/cli/dist/src/server.js +1 -0
- package/packages/cli/package.json +3 -0
- package/packages/core/dist/evaluations/index.d.ts +18 -0
- package/packages/core/dist/evaluations/index.js +1 -0
- package/packages/core/dist/execution-contract.d.ts +1 -0
- package/packages/core/dist/execution-contract.js +1 -1
- package/packages/core/dist/index.d.ts +8 -4
- package/packages/core/dist/index.js +1 -1
- package/packages/core/dist/memory-plugins/maintenance.d.ts +42 -0
- package/packages/core/dist/memory-plugins/maintenance.js +1 -0
- package/packages/core/dist/memory-plugins/shared.d.ts +8 -0
- package/packages/core/dist/memory-plugins/shared.js +1 -0
- package/packages/core/dist/memory-plugins.d.ts +5 -48
- package/packages/core/dist/memory-plugins.js +1 -1
- package/packages/core/dist/recovery/tool-call.d.ts +28 -0
- package/packages/core/dist/recovery/tool-call.js +1 -0
- package/packages/core/dist/runtime/completion.d.ts +17 -0
- package/packages/core/dist/runtime/completion.js +1 -0
- package/packages/core/dist/runtime/direct-tool-call.d.ts +10 -0
- package/packages/core/dist/runtime/direct-tool-call.js +1 -0
- package/packages/core/dist/runtime/events.d.ts +204 -0
- package/packages/core/dist/runtime/events.js +1 -0
- package/packages/core/dist/runtime/memory.d.ts +23 -0
- package/packages/core/dist/runtime/memory.js +1 -0
- package/packages/core/dist/{artifacts.d.ts → runtime/persistence/artifacts.d.ts} +1 -1
- package/packages/core/dist/runtime/persistence/artifacts.js +1 -0
- package/packages/core/dist/{inspection.d.ts → runtime/persistence/inspection.d.ts} +1 -1
- package/packages/core/dist/runtime/persistence/inspection.js +1 -0
- package/packages/core/dist/{queue.d.ts → runtime/persistence/queue.d.ts} +1 -1
- package/packages/core/dist/runtime/persistence/queue.js +1 -0
- package/packages/core/dist/{stores.d.ts → runtime/persistence/stores.d.ts} +1 -1
- package/packages/core/dist/runtime/persistence/stores.js +1 -0
- package/packages/core/dist/runtime/progress-narration.d.ts +33 -0
- package/packages/core/dist/runtime/progress-narration.js +1 -0
- package/packages/core/dist/runtime/tool-gateway.d.ts +40 -0
- package/packages/core/dist/runtime/tool-gateway.js +1 -0
- package/packages/core/dist/runtime/types.d.ts +168 -0
- package/packages/core/dist/runtime/types.js +1 -0
- package/packages/core/dist/runtime.d.ts +7 -3
- package/packages/core/dist/runtime.js +1 -1
- package/packages/core/dist/spec-driven/config.d.ts +4 -0
- package/packages/core/dist/spec-driven/config.js +1 -0
- package/packages/core/dist/spec-driven/events.d.ts +11 -0
- package/packages/core/dist/spec-driven/events.js +1 -0
- package/packages/core/dist/spec-driven/index.d.ts +4 -0
- package/packages/core/dist/spec-driven/index.js +1 -0
- package/packages/core/dist/spec-driven/lifecycle.d.ts +11 -0
- package/packages/core/dist/spec-driven/lifecycle.js +1 -0
- package/packages/core/dist/spec-driven/types.d.ts +38 -0
- package/packages/core/dist/spec-driven/types.js +1 -0
- package/packages/core/dist/trace.d.ts +1 -1
- package/packages/core/dist/trace.js +1 -1
- package/packages/core/dist/types.d.ts +31 -426
- package/packages/core/dist/workflows/index.d.ts +70 -0
- package/packages/core/dist/workflows/index.js +1 -0
- package/packages/core/dist/workflows/runtime.d.ts +12 -0
- package/packages/core/dist/workflows/runtime.js +1 -0
- package/packages/core/dist/workspace/types.d.ts +101 -0
- package/packages/core/dist/workspace/types.js +1 -0
- package/packages/governance/dist/src/skill-candidates.js +1 -1
- package/packages/governance/dist/src/types.d.ts +1 -1
- package/packages/memory/dist/src/langmem-service.js +1 -1
- package/packages/memory/dist/src/maintenance.js +1 -1
- package/packages/memory/dist/src/policy.js +1 -1
- package/packages/memory/dist/src/provider.js +1 -1
- package/packages/memory/dist/src/store.js +1 -1
- package/packages/protocols/dist/src/http-server.js +1 -1
- package/packages/protocols/dist/src/in-process-client.js +1 -1
- package/packages/protocols/dist/src/openai-compatible.js +1 -1
- package/packages/protocols/dist/src/openai-payload.d.ts +74 -0
- package/packages/protocols/dist/src/openai-payload.js +1 -0
- package/packages/protocols/dist/src/openai-stream.d.ts +39 -0
- package/packages/protocols/dist/src/openai-stream.js +1 -0
- package/packages/tool-gateway/dist/src/argument-guard.d.ts +2 -1
- package/packages/tool-gateway/dist/src/argument-guard.js +1 -1
- package/packages/tool-gateway/dist/src/in-memory.js +1 -1
- package/packages/tool-gateway/dist/src/module-loader.js +1 -1
- package/packages/tool-gateway/dist/src/schema-validation.d.ts +3 -0
- package/packages/tool-gateway/dist/src/schema-validation.js +1 -0
- package/packages/tool-gateway/dist/src/types.d.ts +3 -0
- package/packages/tool-gateway/package.json +1 -1
- package/packages/workspace-yaml/dist/discovery.d.ts +4 -0
- package/packages/workspace-yaml/dist/discovery.js +1 -0
- package/packages/workspace-yaml/dist/documents.d.ts +16 -0
- package/packages/workspace-yaml/dist/documents.js +1 -0
- package/packages/workspace-yaml/dist/evaluations.d.ts +9 -0
- package/packages/workspace-yaml/dist/evaluations.js +1 -0
- package/packages/workspace-yaml/dist/loader.js +1 -1
- package/packages/workspace-yaml/dist/workflows.d.ts +16 -0
- package/packages/workspace-yaml/dist/workflows.js +1 -0
- package/packages/adapter-deepagents/dist/src/builtin-tool-policy.d.ts +0 -18
- package/packages/adapter-deepagents/dist/src/builtin-tool-policy.js +0 -1
- package/packages/adapter-deepagents/dist/src/messages.js +0 -1
- package/packages/adapter-deepagents/dist/src/stream-events.js +0 -1
- package/packages/core/dist/artifacts.js +0 -1
- package/packages/core/dist/inspection.js +0 -1
- package/packages/core/dist/queue.js +0 -1
- package/packages/core/dist/stores.js +0 -1
- /package/packages/adapter-deepagents/dist/src/{messages.d.ts → internal/messages.d.ts} +0 -0
- /package/packages/adapter-deepagents/dist/src/{stream-events.d.ts → internal/stream-events.d.ts} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type RuntimeToolCallRequest = {
|
|
2
|
+
toolId: string;
|
|
3
|
+
args?: unknown;
|
|
4
|
+
};
|
|
5
|
+
export type RuntimeToolGatewayContext = {
|
|
6
|
+
workspaceRoot: string;
|
|
7
|
+
requestId: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
agentId: string;
|
|
10
|
+
};
|
|
11
|
+
export type RuntimeToolGatewayTool = {
|
|
12
|
+
id: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
schema?: unknown;
|
|
15
|
+
};
|
|
16
|
+
export type RuntimeToolRepairModel = {
|
|
17
|
+
invoke(input: unknown): Promise<unknown> | unknown;
|
|
18
|
+
};
|
|
19
|
+
export type RuntimeToolGateway = {
|
|
20
|
+
get(toolId: string): RuntimeToolGatewayTool | undefined;
|
|
21
|
+
repairToolCall?(request: {
|
|
22
|
+
toolId: string;
|
|
23
|
+
args?: unknown;
|
|
24
|
+
allowedToolIds?: string[];
|
|
25
|
+
repairModel?: RuntimeToolRepairModel;
|
|
26
|
+
context: RuntimeToolGatewayContext;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
toolId: string;
|
|
29
|
+
args: unknown;
|
|
30
|
+
} | undefined>;
|
|
31
|
+
invoke(request: {
|
|
32
|
+
toolId: string;
|
|
33
|
+
args?: unknown;
|
|
34
|
+
repairModel?: RuntimeToolRepairModel;
|
|
35
|
+
context: RuntimeToolGatewayContext;
|
|
36
|
+
}): Promise<{
|
|
37
|
+
toolId: string;
|
|
38
|
+
output: unknown;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { MemoryCandidate } from "@stable-harness/memory";
|
|
2
|
+
import type { RuntimeWorkflowRequest } from "../workflows/index.js";
|
|
3
|
+
import type { RuntimeEvent } from "./events.js";
|
|
4
|
+
import type { RuntimeToolCallRequest } from "./tool-gateway.js";
|
|
5
|
+
export type RuntimeRecordState = "queued" | "running" | "completed" | "failed" | "cancelled";
|
|
6
|
+
export type RuntimeOutput = {
|
|
7
|
+
text: string;
|
|
8
|
+
metadata?: Record<string, unknown>;
|
|
9
|
+
artifacts?: RuntimeArtifact[];
|
|
10
|
+
};
|
|
11
|
+
export type RuntimeArtifact = {
|
|
12
|
+
id: string;
|
|
13
|
+
kind: string;
|
|
14
|
+
uri?: string;
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
export type RuntimeArtifactRecord = RuntimeArtifact & {
|
|
18
|
+
requestId: string;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
agentId: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
contentType?: string;
|
|
23
|
+
size?: number;
|
|
24
|
+
};
|
|
25
|
+
export type RuntimeArtifactInput = RuntimeArtifact & {
|
|
26
|
+
requestId: string;
|
|
27
|
+
sessionId: string;
|
|
28
|
+
agentId: string;
|
|
29
|
+
content?: unknown;
|
|
30
|
+
contentType?: string;
|
|
31
|
+
createdAt?: string;
|
|
32
|
+
};
|
|
33
|
+
export type RuntimeArtifactStore = {
|
|
34
|
+
createArtifact(input: RuntimeArtifactInput): RuntimeArtifactRecord;
|
|
35
|
+
listArtifacts(filter?: RuntimeArtifactFilter): RuntimeArtifactRecord[];
|
|
36
|
+
readArtifact(id: string): unknown;
|
|
37
|
+
};
|
|
38
|
+
export type RuntimeArtifactFilter = {
|
|
39
|
+
requestId?: string;
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
agentId?: string;
|
|
42
|
+
};
|
|
43
|
+
export type RuntimeRequest = {
|
|
44
|
+
input: string;
|
|
45
|
+
agentId?: string;
|
|
46
|
+
sessionId?: string;
|
|
47
|
+
requestId?: string;
|
|
48
|
+
parentRunId?: string;
|
|
49
|
+
toolCall?: RuntimeToolCallRequest;
|
|
50
|
+
workflow?: RuntimeWorkflowRequest;
|
|
51
|
+
memory?: RuntimeRequestMemory;
|
|
52
|
+
metadata?: Record<string, unknown>;
|
|
53
|
+
};
|
|
54
|
+
export type RuntimeRequestMemory = {
|
|
55
|
+
namespace?: string;
|
|
56
|
+
recall?: false | {
|
|
57
|
+
query?: string;
|
|
58
|
+
limit?: number;
|
|
59
|
+
};
|
|
60
|
+
candidates?: RuntimeMemoryCandidateInput[];
|
|
61
|
+
};
|
|
62
|
+
export type RuntimeMemoryCandidateInput = Omit<MemoryCandidate, "namespace"> & {
|
|
63
|
+
namespace?: string;
|
|
64
|
+
};
|
|
65
|
+
export type RuntimeResponse = {
|
|
66
|
+
requestId: string;
|
|
67
|
+
sessionId: string;
|
|
68
|
+
agentId: string;
|
|
69
|
+
state: RuntimeRecordState;
|
|
70
|
+
output: string;
|
|
71
|
+
metadata?: Record<string, unknown>;
|
|
72
|
+
artifacts?: RuntimeArtifact[];
|
|
73
|
+
};
|
|
74
|
+
export type RuntimeRunRecord = {
|
|
75
|
+
requestId: string;
|
|
76
|
+
sessionId: string;
|
|
77
|
+
agentId: string;
|
|
78
|
+
input: string;
|
|
79
|
+
state: RuntimeRecordState;
|
|
80
|
+
output?: string;
|
|
81
|
+
error?: string;
|
|
82
|
+
parentRunId?: string;
|
|
83
|
+
metadata?: Record<string, unknown>;
|
|
84
|
+
artifacts: RuntimeArtifact[];
|
|
85
|
+
startedAt: string;
|
|
86
|
+
completedAt?: string;
|
|
87
|
+
events: RuntimeEvent[];
|
|
88
|
+
};
|
|
89
|
+
export type RuntimeStoreRunPatch = Partial<Pick<RuntimeRunRecord, "state" | "output" | "error" | "metadata" | "artifacts" | "completedAt">>;
|
|
90
|
+
export type RuntimeRunFilter = {
|
|
91
|
+
agentId?: string;
|
|
92
|
+
sessionId?: string;
|
|
93
|
+
state?: RuntimeRecordState;
|
|
94
|
+
};
|
|
95
|
+
export type RuntimeStore = {
|
|
96
|
+
createRun(record: RuntimeRunRecord): void;
|
|
97
|
+
updateRun(requestId: string, patch: RuntimeStoreRunPatch): RuntimeRunRecord | undefined;
|
|
98
|
+
appendEvent(event: RuntimeEvent): RuntimeRunRecord | undefined;
|
|
99
|
+
getRun(requestId: string): RuntimeRunRecord | undefined;
|
|
100
|
+
listRuns(filter?: RuntimeRunFilter): RuntimeRunRecord[];
|
|
101
|
+
};
|
|
102
|
+
export type RuntimeQueueRecord = {
|
|
103
|
+
requestId: string;
|
|
104
|
+
sessionId: string;
|
|
105
|
+
priority: number;
|
|
106
|
+
queueKey?: string;
|
|
107
|
+
enqueuedAt: string;
|
|
108
|
+
availableAt: string;
|
|
109
|
+
claimedBy?: string;
|
|
110
|
+
claimedAt?: string;
|
|
111
|
+
leaseExpiresAt?: string;
|
|
112
|
+
attemptCount: number;
|
|
113
|
+
lastError?: string;
|
|
114
|
+
};
|
|
115
|
+
export type RuntimeRequestControlRecord = {
|
|
116
|
+
requestId: string;
|
|
117
|
+
cancelRequested: boolean;
|
|
118
|
+
cancelReason?: string;
|
|
119
|
+
cancelRequestedAt?: string;
|
|
120
|
+
heartbeatAt?: string;
|
|
121
|
+
workerId?: string;
|
|
122
|
+
workerStartedAt?: string;
|
|
123
|
+
};
|
|
124
|
+
export type RuntimeRecoveryIntent = {
|
|
125
|
+
requestId: string;
|
|
126
|
+
sessionId: string;
|
|
127
|
+
kind: "approval-decision" | "restart-request";
|
|
128
|
+
savedAt: string;
|
|
129
|
+
checkpointRef?: string;
|
|
130
|
+
resumePayload?: unknown;
|
|
131
|
+
attempts: number;
|
|
132
|
+
};
|
|
133
|
+
export type RuntimeQueueStore = {
|
|
134
|
+
enqueue(record: Omit<RuntimeQueueRecord, "attemptCount" | "enqueuedAt"> & {
|
|
135
|
+
attemptCount?: number;
|
|
136
|
+
enqueuedAt?: string;
|
|
137
|
+
}): RuntimeQueueRecord;
|
|
138
|
+
listQueue(): RuntimeQueueRecord[];
|
|
139
|
+
getQueuedRequest(requestId: string): RuntimeQueueRecord | undefined;
|
|
140
|
+
claimNext(input: RuntimeQueueClaimInput): RuntimeQueueRecord | undefined;
|
|
141
|
+
heartbeat(input: RuntimeHeartbeatInput): RuntimeRequestControlRecord | undefined;
|
|
142
|
+
requestCancel(input: RuntimeCancelIntentInput): RuntimeRequestControlRecord;
|
|
143
|
+
getControl(requestId: string): RuntimeRequestControlRecord | undefined;
|
|
144
|
+
listStuck(input: RuntimeStuckRequestInput): RuntimeQueueRecord[];
|
|
145
|
+
saveRecoveryIntent(intent: RuntimeRecoveryIntent): RuntimeRecoveryIntent;
|
|
146
|
+
getRecoveryIntent(requestId: string): RuntimeRecoveryIntent | undefined;
|
|
147
|
+
clearRecoveryIntent(requestId: string): boolean;
|
|
148
|
+
};
|
|
149
|
+
export type RuntimeQueueClaimInput = {
|
|
150
|
+
workerId: string;
|
|
151
|
+
now?: string;
|
|
152
|
+
leaseMs: number;
|
|
153
|
+
queueKey?: string;
|
|
154
|
+
};
|
|
155
|
+
export type RuntimeHeartbeatInput = {
|
|
156
|
+
requestId: string;
|
|
157
|
+
workerId: string;
|
|
158
|
+
now?: string;
|
|
159
|
+
};
|
|
160
|
+
export type RuntimeCancelIntentInput = {
|
|
161
|
+
requestId: string;
|
|
162
|
+
reason?: string;
|
|
163
|
+
now?: string;
|
|
164
|
+
};
|
|
165
|
+
export type RuntimeStuckRequestInput = {
|
|
166
|
+
now?: string;
|
|
167
|
+
staleAfterMs: number;
|
|
168
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { ApprovalQueue } from "@stable-harness/governance";
|
|
2
2
|
import type { MemoryProvider, RuntimeMemoryStore } from "@stable-harness/memory";
|
|
3
|
-
import type { CompiledWorkspace, RuntimeToolGateway, RuntimeAdapter, RuntimeStore, StableHarnessRuntime } from "./types.js";
|
|
4
|
-
|
|
3
|
+
import type { CompiledWorkspace, RuntimeToolGateway, RuntimeAdapter, RuntimeStore, RuntimeProgressNarrationOptions, RuntimeWorkflowAdapter, StableHarnessRuntime } from "./types.js";
|
|
4
|
+
type RuntimeFactoryInput = {
|
|
5
5
|
workspace: CompiledWorkspace;
|
|
6
6
|
adapters: RuntimeAdapter[];
|
|
7
|
+
workflowAdapters?: RuntimeWorkflowAdapter[];
|
|
7
8
|
memory?: RuntimeMemoryStore;
|
|
8
9
|
memoryProviders?: MemoryProvider[];
|
|
9
10
|
approvals?: ApprovalQueue;
|
|
10
11
|
toolGateway?: RuntimeToolGateway;
|
|
11
12
|
store?: RuntimeStore;
|
|
12
|
-
|
|
13
|
+
progressNarration?: RuntimeProgressNarrationOptions | false;
|
|
14
|
+
};
|
|
15
|
+
export declare function createStableHarnessRuntime(input: RuntimeFactoryInput): StableHarnessRuntime;
|
|
16
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomUUID as e}from"node:crypto";import{assertExecutionContract as t}from"./execution-contract.js";import{projectRequestInspection as
|
|
1
|
+
import{randomUUID as e}from"node:crypto";import{assertExecutionContract as t}from"./execution-contract.js";import{projectRequestInspection as r,projectRequestSummary as s,projectSessionSummaries as o}from"./runtime/persistence/inspection.js";import{recallMemoryPlugins as a,runMemoryPlugins as n}from"./memory-plugins.js";import{assertNoRawToolCallOutput as i,assertNoToolExecutionErrorOutput as u,buildAdapterErrorRecoveryPrompt as c,buildEvidenceSynthesisOutput as l,buildExecutionContractRecoveryRequest as p,buildResultRecoveryRequest as d,containsRawToolCallOutput as m,isRecoverableAdapterError as w,rawToolCallFailureMessage as f,toolCallRecoveryEnabled as y}from"./recovery/tool-call.js";import{completeRun as g,failRun as q}from"./runtime/completion.js";import{runDirectToolCall as I}from"./runtime/direct-tool-call.js";import{emitMemoryLifecycle as k,runMemoryRecall as R,submitMemoryCandidates as v}from"./runtime/memory.js";import{createInMemoryRuntimeStore as A}from"./runtime/persistence/stores.js";import{createProgressNarrationEvent as b,resolveProgressNarrator as C}from"./runtime/progress-narration.js";import{runWorkflowRequest as h}from"./workflows/runtime.js";export function createStableHarnessRuntime(t){const i=new Set,u=t.store??A(),l=C({options:t.progressNarration,policy:t.workspace.runtime}),emit=e=>{u.appendEvent(e);for(const t of i)t(e);!function tryEmitProgressNarration(e){try{const t=b({source:e.event,narrator:e.narrator,options:e.options,policy:e.policy});!function isPromiseLike(e){return"object"==typeof e&&null!==e&&"then"in e&&"function"==typeof e.then}(t)?t&&e.emitNarration(t):t.then(t=>{t&&e.emitNarration(t)}).catch(()=>{})}catch{return}}({event:e,narrator:l,options:t.progressNarration,policy:t.workspace.runtime,emitNarration:e=>{u.appendEvent(e);for(const t of i)t(e)}})};return{request:async r=>async function runRuntimeRequest(t){const{agent:r,adapter:s}=function resolveExecution(e,t){const r=t.agentId??e.workspace.runtime.defaultAgentId,s=e.workspace.agents.get(r);if(!s)throw new Error(`Agent ${r} is not defined in the workspace`);if(t.toolCall||t.workflow)return{agent:s,adapter:void 0};const o=e.adapters.find(e=>e.canRun(s));if(!o)throw new Error(`No runtime adapter can run backend ${s.backend} for agent ${s.id}`);return{agent:s,adapter:o}}(t.input,t.request),o=t.request.requestId??e(),i=t.request.sessionId??e();t.store.createRun(function createRunRecord(e,t,r,s){return{requestId:t,sessionId:r,agentId:s.id,input:e.input,state:"running",parentRunId:e.parentRunId,metadata:e.metadata,artifacts:[],startedAt:(new Date).toISOString(),events:[]}}(t.request,o,i,r)),t.emit({type:"runtime.request.started",requestId:o,sessionId:i,agentId:r.id,input:t.request.input});try{if(t.request.workflow){const e=await h({workspace:t.input.workspace,adapters:t.input.workflowAdapters??[],toolGateway:t.input.toolGateway,request:{input:t.request.input,...t.request.workflow},requestId:o,sessionId:i,agentId:r.id,emit:t.emit});return g({store:t.store,emit:t.emit,requestId:o,sessionId:i,agent:r,result:e})}if(t.request.toolCall){const e=await I({gateway:t.input.toolGateway,workspace:t.input.workspace,emit:t.emit,request:t.request,requestId:o,sessionId:i,agent:r});return g({store:t.store,emit:t.emit,requestId:o,sessionId:i,agent:r,result:e})}return await async function runAdapterRequest(e){if(!e.adapter)throw new Error(`No runtime adapter can run backend ${e.agent.backend} for agent ${e.agent.id}`);const t=e.adapter,r=await R({memory:e.input.memory,emit:e.emit,request:e.request,requestId:e.requestId,sessionId:e.sessionId,agent:e.agent,workspace:e.input.workspace}),s=await a({providers:e.input.memoryProviders,request:e.request,agent:e.agent,workspace:e.input.workspace}),o=e.input.workspace.runtime,i=new Map;let u;try{u=await runAdapterOnce(e,t,e.request,r,s,i)}catch(a){if(!w(a,o))throw a;u=await runAdapterOnce(e,t,c(e.request,a,o),r,s,i)}u=await recoverAdapterResultOutput(e,t,e.request,u,r,s,o,i),k(e.input.memory,e.emit,e.requestId,e.sessionId,e.agent.id,"read-before-finalize"),await v({memory:e.input.memory,approvals:e.input.approvals,emit:e.emit,request:e.request,requestId:e.requestId,sessionId:e.sessionId,agent:e.agent,workspace:e.input.workspace});try{assertRequestExecutionContract(e)}catch(a){const n=p({request:e.request,events:e.store.getRun(e.requestId)?.events??[],policy:o});if(!n)throw a;u=await runAdapterOnce(e,t,n,r,s,i),u=await recoverAdapterResultOutput(e,t,n,u,r,s,o,i),assertRequestExecutionContract(e)}const l=g({store:e.store,emit:e.emit,requestId:e.requestId,sessionId:e.sessionId,agent:e.agent,result:u});return await n({providers:e.input.memoryProviders,emit:e.emit,request:e.request,requestId:e.requestId,sessionId:e.sessionId,agent:e.agent,workspace:e.input.workspace,result:u}),l}({...t,adapter:s,requestId:o,sessionId:i,agent:r})}catch(e){return q({store:t.store,emit:t.emit,requestId:o,sessionId:i,agent:r,error:e})}}({input:t,store:u,emit:emit,request:r}),subscribe:e=>(i.add(e),()=>i.delete(e)),inspect(){return{workspaceRoot:t.workspace.root,agents:[...t.workspace.agents.keys()].sort(),workflows:[...t.workspace.workflows.keys()].sort(),...t.workspace.runtime.specDrivenWorkflow?{specDrivenWorkflow:(e=t.workspace.runtime.specDrivenWorkflow,{enabled:e.enabled,artifactsDir:e.artifactsDir,...e.constitution?{constitution:e.constitution}:{},phases:e.phases.map(e=>e.id)})}:{},evaluations:[...t.workspace.evaluations?.keys()??[]].sort(),...t.workspace.runtime.workflowRouting?.defaultWorkflowId?{defaultWorkflowId:t.workspace.runtime.workflowRouting.defaultWorkflowId}:{},workflowRoutes:(t.workspace.runtime.workflowRouting?.routes??[]).map(e=>e.id).sort(),models:[...t.workspace.models.keys()].sort(),tools:[...t.workspace.tools.keys()].sort(),runs:u.listRuns()};var e},getRuntimePolicy:()=>t.workspace.runtime,getWorkflow:e=>t.workspace.workflows.get(e),getRun:e=>u.getRun(e),listRequests:e=>u.listRuns(e).map(s),listSessions:()=>o(u.listRuns()),inspectRequest(e){const s=u.getRun(e);return s?r(t.workspace,s):void 0},cancel(e,t){const r=u.getRun(e);r&&"running"===r.state&&(u.updateRun(e,{state:"cancelled",completedAt:(new Date).toISOString()}),emit({type:"runtime.request.cancelled",requestId:e,sessionId:r.sessionId,agentId:r.agentId,reason:t}))},async stop(){i.clear()}}}async function recoverAdapterResultOutput(e,t,r,s,o,a,n,c){let p=r;const w=function resultRecoveryAttempts(e){const t="object"!=typeof e||null===e||Array.isArray(e)?void 0:e.recovery,r="object"!=typeof t||null===t||Array.isArray(t)?void 0:t.toolCall,s="object"!=typeof r||null===r||Array.isArray(r)?void 0:r.maxResultRecoveryAttempts;return"number"==typeof s&&Number.isInteger(s)&&s>0?s:3}(n);let g=0;for(let r=0;r<w;r+=1){const r=e.store.getRun(e.requestId)?.events??[],i=d({request:p,output:s.text,events:r.slice(g),availableToolIds:e.agent.tools,policy:n});if(!i)break;p=i,g=e.store.getRun(e.requestId)?.events.length??0,s=await runAdapterOnce(e,t,i,o,a,c)}if(y(n)){let t=!1;m(s.text,n)&&function rawToolCallFailureReturnsMessage(e){return"message"===("object"!=typeof e?.toolCallRecovery||null===e.toolCallRecovery||Array.isArray(e.toolCallRecovery)?{}:e.toolCallRecovery).onFailure}(r.metadata)&&(s={...s,text:f(),metadata:{...s.metadata,toolCallRecovery:{failed:!0,reason:"raw_tool_call_output"}}});const o=l({request:r,output:s.text,events:e.store.getRun(e.requestId)?.events??[],policy:n});o&&(t=!0,s={...s,text:o,metadata:{...s.metadata,toolCallRecovery:{synthesized:!0,reason:"raw_tool_call_output_with_evidence"}}}),t||(i(s.text,n),u(s.text,n))}return s}function assertRequestExecutionContract(e){t({store:e.store,emit:e.emit,requestId:e.requestId,sessionId:e.sessionId,agent:e.agent,metadata:e.request.metadata})}async function runAdapterOnce(e,t,r,s,o,a){return function normalizeAdapterResult(e){return"string"==typeof e?{text:e}:e}(await t.run({workspace:e.input.workspace,agent:e.agent,request:r,requestId:e.requestId,sessionId:e.sessionId,memory:s,pluginMemories:o,toolGateway:e.input.toolGateway,requestState:a,emit:e.emit}))}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkspaceSpecDrivenPhase, WorkspaceSpecDrivenWorkflowPolicy } from "./types.js";
|
|
2
|
+
export declare const DEFAULT_SPEC_DRIVEN_PHASES: WorkspaceSpecDrivenPhase[];
|
|
3
|
+
export declare function createSpecDrivenWorkflowPolicy(input?: Partial<WorkspaceSpecDrivenWorkflowPolicy>): WorkspaceSpecDrivenWorkflowPolicy;
|
|
4
|
+
export declare function assertSpecDrivenWorkflowPolicy(policy: WorkspaceSpecDrivenWorkflowPolicy): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_SPEC_DRIVEN_PHASES=[{id:"constitution",artifactKind:"constitution",required:!0},{id:"specify",artifactKind:"spec",required:!0},{id:"plan",artifactKind:"plan",required:!0},{id:"contracts",artifactKind:"contract"},{id:"research",artifactKind:"research"},{id:"tasks",artifactKind:"tasks",required:!0},{id:"implement",artifactKind:"execution"},{id:"verify",artifactKind:"evidence",required:!0}];export function createSpecDrivenWorkflowPolicy(i){return{enabled:i?.enabled??!1,...i?.constitution?{constitution:i.constitution}:{},artifactsDir:i?.artifactsDir??"specs",phases:(t=i?.phases,(t&&t.length>0?t:DEFAULT_SPEC_DRIVEN_PHASES).map(i=>({id:i.id,...i.artifactKind?{artifactKind:i.artifactKind}:{},...void 0!==i.required?{required:i.required}:{},...i.gate?{gate:i.gate}:{},...i.config?{config:i.config}:{}}))),...i?.gates?{gates:i.gates}:{},...i?.config?{config:i.config}:{}};var t}export function assertSpecDrivenWorkflowPolicy(i){const t=new Set;for(const e of i.phases){if(!e.id.trim())throw new Error("specDrivenWorkflow phases require non-empty id");if(t.has(e.id))throw new Error(`specDrivenWorkflow phase is duplicated: ${e.id}`);t.add(e.id)}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RuntimeEvent } from "../runtime/events.js";
|
|
2
|
+
import type { RuntimeArtifact } from "../runtime/types.js";
|
|
3
|
+
import type { SpecDrivenPhaseTransition } from "./types.js";
|
|
4
|
+
export type SpecDrivenEventContext = {
|
|
5
|
+
requestId: string;
|
|
6
|
+
sessionId: string;
|
|
7
|
+
agentId: string;
|
|
8
|
+
workflowId?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function createSpecDrivenPhaseEvent(context: SpecDrivenEventContext, transition: SpecDrivenPhaseTransition): RuntimeEvent;
|
|
11
|
+
export declare function createSpecDrivenArtifactEvent(context: SpecDrivenEventContext, phaseId: string, artifact: RuntimeArtifact): RuntimeEvent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function createSpecDrivenPhaseEvent(e,t){const r={requestId:e.requestId,sessionId:e.sessionId,agentId:e.agentId,phaseId:t.phaseId,...e.workflowId?{workflowId:e.workflowId}:{}};return"started"===t.status?{type:"runtime.specDriven.phase.started",...r}:"completed"===t.status?{type:"runtime.specDriven.phase.completed",...r,artifact:t.artifact}:"verified"===t.status?{type:"runtime.specDriven.phase.verified",...r,artifact:t.artifact}:{type:"runtime.specDriven.phase.blocked",...r,reason:t.reason??"unspecified"}}export function createSpecDrivenArtifactEvent(e,t,r){return{type:"runtime.artifact.created",requestId:e.requestId,sessionId:e.sessionId,agentId:e.agentId,artifact:{...r,metadata:{...r.metadata,phaseId:t,workflowKind:"spec-driven"}}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./config.js";export*from"./events.js";export*from"./lifecycle.js";export*from"./types.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RuntimeArtifact } from "../runtime/types.js";
|
|
2
|
+
import type { SpecDrivenPhaseTransition, SpecDrivenWorkflowState, WorkspaceSpecDrivenWorkflowPolicy } from "./types.js";
|
|
3
|
+
export declare function createSpecDrivenWorkflowState(policy: WorkspaceSpecDrivenWorkflowPolicy): SpecDrivenWorkflowState;
|
|
4
|
+
export declare function applySpecDrivenPhaseTransition(state: SpecDrivenWorkflowState, transition: SpecDrivenPhaseTransition): SpecDrivenWorkflowState;
|
|
5
|
+
export declare function createSpecDrivenArtifact(input: {
|
|
6
|
+
id: string;
|
|
7
|
+
phaseId: string;
|
|
8
|
+
artifactKind: string;
|
|
9
|
+
uri?: string;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
}): RuntimeArtifact;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function createSpecDrivenWorkflowState(t){return{enabled:t.enabled,artifactsDir:t.artifactsDir,...t.constitution?{constitution:t.constitution}:{},phases:t.phases.map(t=>({id:t.id,status:"pending",updatedAt:new Date(0).toISOString()}))}}export function applySpecDrivenPhaseTransition(t,a){if(!new Set(t.phases.map(t=>t.id)).has(a.phaseId))throw new Error(`Spec-driven workflow phase is not configured: ${a.phaseId}`);return{...t,phases:t.phases.map(t=>function updatePhase(t,a){return t.id!==a.phaseId?t:{id:t.id,status:a.status,...a.artifact?{artifact:a.artifact}:t.artifact?{artifact:t.artifact}:{},...a.reason?{reason:a.reason}:{},updatedAt:a.timestamp??(new Date).toISOString()}}(t,a))}}export function createSpecDrivenArtifact(t){return{id:t.id,kind:`spec-driven.${t.artifactKind}`,...t.uri?{uri:t.uri}:{},metadata:{phaseId:t.phaseId,...t.metadata}}}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RuntimeArtifact } from "../runtime/types.js";
|
|
2
|
+
export type SpecDrivenPhaseId = string;
|
|
3
|
+
export type SpecDrivenPhaseStatus = "pending" | "started" | "blocked" | "completed" | "verified";
|
|
4
|
+
export type WorkspaceSpecDrivenPhase = {
|
|
5
|
+
id: string;
|
|
6
|
+
artifactKind?: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
gate?: string;
|
|
9
|
+
config?: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export type WorkspaceSpecDrivenWorkflowPolicy = {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
constitution?: string;
|
|
14
|
+
artifactsDir: string;
|
|
15
|
+
phases: WorkspaceSpecDrivenPhase[];
|
|
16
|
+
gates?: Record<string, unknown>;
|
|
17
|
+
config?: Record<string, unknown>;
|
|
18
|
+
};
|
|
19
|
+
export type SpecDrivenPhaseRecord = {
|
|
20
|
+
id: string;
|
|
21
|
+
status: SpecDrivenPhaseStatus;
|
|
22
|
+
artifact?: RuntimeArtifact;
|
|
23
|
+
reason?: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
};
|
|
26
|
+
export type SpecDrivenWorkflowState = {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
artifactsDir: string;
|
|
29
|
+
constitution?: string;
|
|
30
|
+
phases: SpecDrivenPhaseRecord[];
|
|
31
|
+
};
|
|
32
|
+
export type SpecDrivenPhaseTransition = {
|
|
33
|
+
phaseId: string;
|
|
34
|
+
status: Exclude<SpecDrivenPhaseStatus, "pending">;
|
|
35
|
+
artifact?: RuntimeArtifact;
|
|
36
|
+
reason?: string;
|
|
37
|
+
timestamp?: string;
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -4,7 +4,7 @@ export type PlanTodoItem = {
|
|
|
4
4
|
status: string;
|
|
5
5
|
};
|
|
6
6
|
export type RuntimeTraceEntry = {
|
|
7
|
-
type: "request" | "tool" | "adapter" | "memory" | "artifact" | "plan" | "delegation";
|
|
7
|
+
type: "request" | "tool" | "workflow" | "spec" | "adapter" | "memory" | "artifact" | "progress" | "plan" | "delegation";
|
|
8
8
|
label: string;
|
|
9
9
|
agentId: string;
|
|
10
10
|
requestId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function projectRuntimeTrace(
|
|
1
|
+
export function projectRuntimeTrace(e){return e.events.map(projectEvent).filter(isTraceEntry)}export function projectEvent(e){return"runtime.request.started"===e.type||"runtime.request.completed"===e.type||"runtime.request.failed"===e.type?base(e,"request",e.type):"runtime.request.cancelled"===e.type?base(e,"request",e.type,{reason:e.reason}):"runtime.execution.contract.failed"===e.type?base(e,"request",e.type,{reason:e.reason,missingEvidenceTools:e.missingEvidenceTools}):"runtime.tool.direct.started"===e.type?base(e,"tool","runtime.tool.direct.started",{toolId:e.toolId}):"runtime.tool.direct.completed"===e.type?base(e,"tool","runtime.tool.direct.completed",{toolId:e.toolId}):"runtime.workflow.started"===e.type||"runtime.workflow.completed"===e.type?base(e,"workflow",e.type,{workflowId:e.workflowId,adapter:e.adapter}):function isSpecDrivenPhaseEvent(e){return e.type.startsWith("runtime.specDriven.phase.")}(e)?base(e,"spec",e.type,{phaseId:e.phaseId,..."workflowId"in e&&e.workflowId?{workflowId:e.workflowId}:{},..."reason"in e?{reason:e.reason}:{},..."artifact"in e&&e.artifact?{artifact:e.artifact}:{}}):"runtime.adapter.event"===e.type?function adapterTrace(e){const t=e.event;if(isRecord(t)&&"string"==typeof t.phase){const r=function semanticAdapterTrace(e,t){const r=function readTraceType(e){const t=readString(e);return"request"===t||"tool"===t||"workflow"===t||"spec"===t||"adapter"===t||"memory"===t||"artifact"===t||"progress"===t||"plan"===t||"delegation"===t?t:void 0}(t.traceType),o=readString(t.traceLabel);if(r&&o)return base(e,r,o,t)}(e,t);return r||base(e,"adapter",t.phase.startsWith("agent.")?t.phase:`adapter.${t.phase}`,t)}return base(e,"adapter","runtime.adapter.event",{event:t})}(e):"runtime.artifact.created"===e.type?base(e,"artifact","runtime.artifact.created",{artifact:e.artifact}):e.type.startsWith("runtime.memory.")?base(e,"memory",e.type):"runtime.progress.narration"===e.type?base(e,"progress",e.type,{message:e.message,provider:e.provider,sourceEventTypes:e.sourceEventTypes}):void 0}export function readPlanTodos(e){const t=function readPlanRecord(e){if(isRecord(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);return isRecord(t)?t:void 0}catch{return}}(e),r=function readTodosArray(e){const t=isRecord(e?.args)?e.args:void 0;return Array.isArray(e?.todos)?e.todos:Array.isArray(t?.todos)?t.todos:[]}(t);return r.map(readTodo).filter(isPlanTodoItem)}function readTodo(e){if(isRecord(e)&&"string"==typeof e.content)return{content:e.content,status:"string"==typeof e.status?e.status:"pending"}}function isPlanTodoItem(e){return void 0!==e}function base(e,t,r,o){return{type:t,label:r,agentId:e.agentId,requestId:e.requestId,detail:o}}function isTraceEntry(e){return void 0!==e}function isRecord(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function readString(e){return"string"==typeof e&&e.trim()?e:void 0}
|