stable-harness 0.0.140 → 0.0.144
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/README.md +30 -17
- package/dist/index.js +1 -1
- package/dist/runtime/skills/skill-metadata.js +1 -1
- package/dist/workspace/compile.js +1 -1
- package/docs/0.1.0-tool-guard-benchmark.zh.md +5 -5
- package/docs/architecture/system-architecture.zh.md +3 -3
- package/docs/evaluation/0.1.0-bfcl-targeted-model-matrix.zh.md +306 -306
- package/docs/evaluation/0.1.0-bfcl-targeted-review-matrix.zh.md +1 -1
- package/docs/evaluation/0.1.0-bfcl-tool-guard.zh.md +1 -1
- package/docs/granite-tool-calling-comparison.zh.md +8 -8
- package/docs/guides/getting-started.md +14 -6
- package/docs/guides/index.md +5 -3
- package/docs/guides/integration-guide.md +44 -43
- package/docs/guides/operator-runbook.md +51 -3
- package/docs/guides/runtime-governance-proof.md +4 -4
- package/docs/guides/workspace-authoring.md +2 -2
- package/docs/guides/workspace-docker-build.md +3 -3
- package/docs/memory/0.1.0-memory-design.zh.md +20 -0
- package/docs/memory/0.1.0-step-09-deepagents-native-memory.zh.md +1 -1
- package/docs/memory/0.1.0-step-09-langmem-shaped-provider.zh.md +1 -1
- package/docs/memory/0.1.0-step-09-memory-adapter-projection.zh.md +3 -3
- package/docs/memory/0.1.0-step-09-memory-contract.zh.md +1 -1
- package/docs/memory/0.1.0-step-09-memory-governance-approval.zh.md +1 -1
- package/docs/memory/0.1.0-step-09-memory-lifecycle-hooks.zh.md +1 -1
- package/docs/memory/0.1.0-step-09-memory-maintenance-boundary.zh.md +1 -1
- package/docs/memory/0.1.0-step-09-memory-persistence-boundary.zh.md +1 -1
- package/docs/protocols/coverage-matrix.md +114 -0
- package/docs/protocols/http-runtime.md +31 -8
- package/docs/protocols/langgraph-compatible.md +75 -17
- package/docs/protocols/openai-compatible.md +25 -7
- package/docs/protocols/{agent-protocols.md → protocol-facades.md} +76 -18
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/adapter.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin/task-inventory.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin-call-repair.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin-tool-policy.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/gateway/tool-failure-events.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/raw-tool-call-parser.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/stream-events.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/substrate/checkpoint.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/tool-repeat-visibility.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/trace-projection.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/vfs-backend.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/package.json +2 -2
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/graph.js +1 -1
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/index.js +1 -1
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/runtime.js +1 -1
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/skill-providers.js +1 -1
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/types.d.ts +1 -0
- package/node_modules/@stable-harness/adapter-langgraph/package.json +2 -2
- package/node_modules/@stable-harness/core/dist/boundary-scan.js +1 -1
- package/node_modules/@stable-harness/core/dist/index.d.ts +1 -0
- package/node_modules/@stable-harness/core/dist/index.js +1 -1
- package/node_modules/@stable-harness/core/dist/memory-plugins/shared.js +1 -1
- package/node_modules/@stable-harness/core/dist/memory-plugins.js +1 -1
- package/node_modules/@stable-harness/core/dist/quality/event-evidence.js +1 -1
- package/node_modules/@stable-harness/core/dist/quality/execution-review.js +1 -1
- package/node_modules/@stable-harness/core/dist/quality/synthesis/fields.js +1 -1
- package/node_modules/@stable-harness/core/dist/recovery/execution-contract.js +1 -1
- package/node_modules/@stable-harness/core/dist/recovery/tool-call-structure.js +1 -1
- package/node_modules/@stable-harness/core/dist/recovery/tool-call.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/direct-tool-call.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/inspection/methods.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/inspection/replay.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/persistence/artifacts.d.ts +4 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/artifacts.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/persistence/queue.d.ts +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/queue.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/persistence/stores.d.ts +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/stores.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/persistence/system-data.d.ts +34 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/system-data.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/recovery/adapter-result.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/recovery/non-focused-recovery.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime.js +1 -1
- package/node_modules/@stable-harness/core/dist/workflows/index.d.ts +20 -0
- package/node_modules/@stable-harness/core/dist/workflows/index.js +1 -1
- package/node_modules/@stable-harness/core/package.json +3 -3
- package/node_modules/@stable-harness/governance/dist/src/approval-queue.d.ts +1 -0
- package/node_modules/@stable-harness/governance/dist/src/approval-queue.js +1 -1
- package/node_modules/@stable-harness/governance/dist/src/index.d.ts +1 -1
- package/node_modules/@stable-harness/governance/dist/src/index.js +1 -1
- package/node_modules/@stable-harness/governance/package.json +1 -1
- package/node_modules/@stable-harness/memory/package.json +1 -1
- package/node_modules/@stable-harness/protocols/dist/src/http-events.d.ts +2 -0
- package/node_modules/@stable-harness/protocols/dist/src/http-events.js +1 -1
- package/node_modules/@stable-harness/protocols/dist/src/http-server.d.ts +5 -1
- package/node_modules/@stable-harness/protocols/dist/src/http-server.js +1 -1
- package/node_modules/@stable-harness/protocols/dist/src/index.d.ts +3 -3
- package/node_modules/@stable-harness/protocols/dist/src/index.js +1 -1
- package/node_modules/@stable-harness/protocols/dist/src/openai-compatible.js +1 -1
- package/node_modules/@stable-harness/protocols/dist/src/openai-payload.d.ts +89 -0
- package/node_modules/@stable-harness/protocols/dist/src/openai-payload.js +1 -1
- package/node_modules/@stable-harness/protocols/dist/src/{agent-protocols.d.ts → protocol-facades.d.ts} +4 -10
- package/node_modules/@stable-harness/protocols/dist/src/protocol-facades.js +1 -0
- package/node_modules/@stable-harness/protocols/dist/src/protocol-utils.d.ts +505 -0
- package/node_modules/@stable-harness/protocols/dist/src/protocol-utils.js +1 -0
- package/node_modules/@stable-harness/protocols/package.json +2 -2
- package/node_modules/@stable-harness/tool-gateway/dist/src/argument-guard.js +1 -1
- package/node_modules/@stable-harness/tool-gateway/dist/src/schema-validation.js +1 -1
- package/node_modules/@stable-harness/tool-gateway/package.json +1 -1
- package/node_modules/@stable-harness/workspace-yaml/dist/boundary-scan.js +1 -1
- package/node_modules/@stable-harness/workspace-yaml/dist/discovery.js +1 -1
- package/node_modules/@stable-harness/workspace-yaml/dist/documents.js +1 -1
- package/node_modules/@stable-harness/workspace-yaml/dist/loader.js +1 -1
- package/node_modules/@stable-harness/workspace-yaml/dist/workflows.js +1 -1
- package/node_modules/@stable-harness/workspace-yaml/package.json +2 -2
- package/package.json +12 -11
- package/packages/adapter-deepagents/dist/src/adapter.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/builtin/task-inventory.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/builtin-call-repair.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/builtin-tool-policy.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/gateway/tool-failure-events.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/raw-tool-call-parser.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/stream-events.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/substrate/checkpoint.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/tool-repeat-visibility.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/trace-projection.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/vfs-backend.js +1 -1
- package/packages/adapter-deepagents/package.json +2 -2
- package/packages/adapter-langgraph/dist/src/graph.js +1 -1
- package/packages/adapter-langgraph/dist/src/index.js +1 -1
- package/packages/adapter-langgraph/dist/src/runtime.js +1 -1
- package/packages/adapter-langgraph/dist/src/skill-providers.js +1 -1
- package/packages/adapter-langgraph/dist/src/types.d.ts +1 -0
- package/packages/adapter-langgraph/package.json +2 -2
- package/packages/cli/dist/src/args.d.ts +3 -2
- package/packages/cli/dist/src/args.js +1 -1
- package/packages/cli/dist/src/build.js +1 -1
- package/packages/cli/dist/src/cli.js +1 -1
- package/packages/cli/dist/src/console/session.js +1 -1
- package/packages/cli/dist/src/daemon/client.d.ts +4 -3
- package/packages/cli/dist/src/daemon/client.js +1 -1
- package/packages/cli/dist/src/init.js +1 -1
- package/packages/cli/dist/src/langgraph/agent-server-compat.d.ts +8 -0
- package/packages/cli/dist/src/langgraph/agent-server-compat.js +1 -0
- package/packages/cli/dist/src/langgraph/store-projection.d.ts +1 -0
- package/packages/cli/dist/src/langgraph/store-projection.js +1 -0
- package/packages/cli/dist/src/langgraph-official.js +1 -1
- package/packages/cli/dist/src/memory/providers.js +1 -1
- package/packages/cli/dist/src/server/gateway.d.ts +12 -0
- package/packages/cli/dist/src/server/gateway.js +1 -0
- package/packages/cli/dist/src/server/protocol-defaults.d.ts +7 -0
- package/packages/cli/dist/src/server/protocol-defaults.js +1 -0
- package/packages/cli/dist/src/server/studio.d.ts +1 -0
- package/packages/cli/dist/src/server/studio.js +1 -0
- package/packages/cli/dist/src/server.js +1 -1
- package/packages/cli/package.json +8 -8
- package/packages/core/dist/boundary-scan.js +1 -1
- package/packages/core/dist/index.d.ts +1 -0
- package/packages/core/dist/index.js +1 -1
- package/packages/core/dist/memory-plugins/shared.js +1 -1
- package/packages/core/dist/memory-plugins.js +1 -1
- package/packages/core/dist/quality/event-evidence.js +1 -1
- package/packages/core/dist/quality/execution-review.js +1 -1
- package/packages/core/dist/quality/synthesis/fields.js +1 -1
- package/packages/core/dist/recovery/execution-contract.js +1 -1
- package/packages/core/dist/recovery/tool-call-structure.js +1 -1
- package/packages/core/dist/recovery/tool-call.js +1 -1
- package/packages/core/dist/runtime/direct-tool-call.js +1 -1
- package/packages/core/dist/runtime/inspection/methods.js +1 -1
- package/packages/core/dist/runtime/inspection/replay.js +1 -1
- package/packages/core/dist/runtime/persistence/artifacts.d.ts +4 -0
- package/packages/core/dist/runtime/persistence/artifacts.js +1 -1
- package/packages/core/dist/runtime/persistence/queue.d.ts +1 -0
- package/packages/core/dist/runtime/persistence/queue.js +1 -1
- package/packages/core/dist/runtime/persistence/stores.d.ts +1 -0
- package/packages/core/dist/runtime/persistence/stores.js +1 -1
- package/packages/core/dist/runtime/persistence/system-data.d.ts +34 -0
- package/packages/core/dist/runtime/persistence/system-data.js +1 -0
- package/packages/core/dist/runtime/recovery/adapter-result.js +1 -1
- package/packages/core/dist/runtime/recovery/non-focused-recovery.js +1 -1
- package/packages/core/dist/runtime.js +1 -1
- package/packages/core/dist/workflows/index.d.ts +20 -0
- package/packages/core/dist/workflows/index.js +1 -1
- package/packages/core/package.json +3 -3
- package/packages/evaluation/dist/src/benchmark.js +1 -1
- package/packages/evaluation/dist/src/run-record.js +1 -1
- package/packages/evaluation/dist/src/tool-call-metrics.js +1 -1
- package/packages/evaluation/package.json +2 -2
- package/packages/governance/dist/src/approval-queue.d.ts +1 -0
- package/packages/governance/dist/src/approval-queue.js +1 -1
- package/packages/governance/dist/src/index.d.ts +1 -1
- package/packages/governance/dist/src/index.js +1 -1
- package/packages/governance/package.json +1 -1
- package/packages/memory/package.json +1 -1
- package/packages/protocols/dist/src/http-events.d.ts +2 -0
- package/packages/protocols/dist/src/http-events.js +1 -1
- package/packages/protocols/dist/src/http-server.d.ts +5 -1
- package/packages/protocols/dist/src/http-server.js +1 -1
- package/packages/protocols/dist/src/index.d.ts +3 -3
- package/packages/protocols/dist/src/index.js +1 -1
- package/packages/protocols/dist/src/openai-compatible.js +1 -1
- package/packages/protocols/dist/src/openai-payload.d.ts +89 -0
- package/packages/protocols/dist/src/openai-payload.js +1 -1
- package/packages/protocols/dist/src/{agent-protocols.d.ts → protocol-facades.d.ts} +4 -10
- package/packages/protocols/dist/src/protocol-facades.js +1 -0
- package/packages/protocols/dist/src/protocol-utils.d.ts +505 -0
- package/packages/protocols/dist/src/protocol-utils.js +1 -0
- package/packages/protocols/package.json +2 -2
- package/packages/tool-gateway/dist/src/argument-guard.js +1 -1
- package/packages/tool-gateway/dist/src/schema-validation.js +1 -1
- package/packages/tool-gateway/package.json +1 -1
- package/packages/workspace-yaml/dist/boundary-scan.js +1 -1
- package/packages/workspace-yaml/dist/discovery.js +1 -1
- package/packages/workspace-yaml/dist/documents.js +1 -1
- package/packages/workspace-yaml/dist/loader.js +1 -1
- package/packages/workspace-yaml/dist/workflows.js +1 -1
- package/packages/workspace-yaml/package.json +2 -2
- package/node_modules/@stable-harness/protocols/dist/src/agent-protocols.js +0 -1
- package/packages/protocols/dist/src/agent-protocols.js +0 -1
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { type RuntimeArtifact, type RuntimeEvent, type RuntimeRequest, type StableHarnessRuntime } from "@stable-harness/core";
|
|
3
|
+
export type A2aPushConfig = {
|
|
4
|
+
url: string;
|
|
5
|
+
token?: string;
|
|
6
|
+
};
|
|
7
|
+
export type RunInspection = {
|
|
8
|
+
requestId: string;
|
|
9
|
+
kind: "trace" | "spans" | "replay";
|
|
10
|
+
};
|
|
11
|
+
export type JsonRpcMessage = {
|
|
12
|
+
jsonrpc?: string;
|
|
13
|
+
id?: string | number | null;
|
|
14
|
+
method?: string;
|
|
15
|
+
params?: unknown;
|
|
16
|
+
};
|
|
17
|
+
export declare function readRecord(value: unknown): Record<string, unknown> | undefined;
|
|
18
|
+
export declare function readString(value: unknown): string | undefined;
|
|
19
|
+
export declare function readPromptText(value: Record<string, unknown>): string;
|
|
20
|
+
export declare function matchPath(url: string | undefined, pattern: RegExp): string | undefined;
|
|
21
|
+
export declare function readRunInspectionPath(url: string | undefined, pattern: RegExp): RunInspection | undefined;
|
|
22
|
+
export declare function jsonRpcResult(id: JsonRpcMessage["id"], result: unknown): {
|
|
23
|
+
jsonrpc: string;
|
|
24
|
+
id: string | number | null | undefined;
|
|
25
|
+
result: unknown;
|
|
26
|
+
};
|
|
27
|
+
export declare function jsonRpcError(id: JsonRpcMessage["id"], code: number, message: string): {
|
|
28
|
+
jsonrpc: string;
|
|
29
|
+
id: string | number | null | undefined;
|
|
30
|
+
error: {
|
|
31
|
+
code: number;
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare function sendJson(response: ServerResponse, statusCode: number, body: unknown): void;
|
|
36
|
+
export declare function handleAgentControlRoute(runtime: StableHarnessRuntime, request: IncomingMessage, response: ServerResponse): Promise<boolean>;
|
|
37
|
+
export declare function sendRunInspection(runtime: StableHarnessRuntime, response: ServerResponse, inspection: RunInspection, missingError?: string): void;
|
|
38
|
+
export declare function handleAcpRunInspection(runtime: StableHarnessRuntime, message: JsonRpcMessage): {
|
|
39
|
+
jsonrpc: string;
|
|
40
|
+
id: string | number | null | undefined;
|
|
41
|
+
result: unknown;
|
|
42
|
+
} | {
|
|
43
|
+
jsonrpc: string;
|
|
44
|
+
id: string | number | null | undefined;
|
|
45
|
+
error: {
|
|
46
|
+
code: number;
|
|
47
|
+
message: string;
|
|
48
|
+
};
|
|
49
|
+
} | undefined;
|
|
50
|
+
export declare function validateA2aVersion(request: IncomingMessage, response: ServerResponse): boolean;
|
|
51
|
+
export declare function writeSseHeaders(response: ServerResponse): void;
|
|
52
|
+
export declare function writeSse(response: ServerResponse, event: unknown, id?: string): void;
|
|
53
|
+
export declare function readJson(request: IncomingMessage): Promise<Record<string, unknown>>;
|
|
54
|
+
export declare function errorMessage(error: unknown): string;
|
|
55
|
+
export declare function storeA2aPushConfig(configs: Map<string, A2aPushConfig>, request: RuntimeRequest, body: Record<string, unknown>): void;
|
|
56
|
+
export declare function readA2aPushConfig(body: Record<string, unknown>): A2aPushConfig | undefined;
|
|
57
|
+
export declare function notifyA2aPush(configs: Map<string, A2aPushConfig>, taskId: string | undefined, event: unknown): void;
|
|
58
|
+
export declare function streamRuntimeEventReplay(runtime: StableHarnessRuntime, requestId: string, response: ServerResponse, project: (event: RuntimeEvent) => unknown, options?: {
|
|
59
|
+
afterEventId?: string;
|
|
60
|
+
}): void;
|
|
61
|
+
export declare function readSseReplayCursor(request: IncomingMessage): string | undefined;
|
|
62
|
+
export declare function isTerminalState(state: string): boolean;
|
|
63
|
+
export declare function toA2aHistoryMessage(index: number, event: RuntimeEvent): {
|
|
64
|
+
role: string;
|
|
65
|
+
messageId: string;
|
|
66
|
+
parts: {
|
|
67
|
+
kind: string;
|
|
68
|
+
text: string;
|
|
69
|
+
}[];
|
|
70
|
+
metadata: {
|
|
71
|
+
stableHarnessEvent: RuntimeEvent;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export declare function toA2aArtifact(artifact: RuntimeArtifact): {
|
|
75
|
+
artifactId: string;
|
|
76
|
+
name: string;
|
|
77
|
+
parts: {
|
|
78
|
+
kind: string;
|
|
79
|
+
data: {
|
|
80
|
+
id: string;
|
|
81
|
+
kind: string;
|
|
82
|
+
uri: string | undefined;
|
|
83
|
+
metadata: Record<string, unknown> | undefined;
|
|
84
|
+
};
|
|
85
|
+
}[];
|
|
86
|
+
metadata: {
|
|
87
|
+
stableHarnessArtifact: RuntimeArtifact;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export declare function toAguiEvent(event: RuntimeEvent): {
|
|
91
|
+
type: string;
|
|
92
|
+
timestamp: number;
|
|
93
|
+
name: string;
|
|
94
|
+
value: import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
95
|
+
type: "runtime.progress.narration";
|
|
96
|
+
requestId: string;
|
|
97
|
+
sessionId: string;
|
|
98
|
+
agentId: string;
|
|
99
|
+
message: string;
|
|
100
|
+
provider: string;
|
|
101
|
+
sourceEventTypes: string[];
|
|
102
|
+
sourceEventIds?: string[];
|
|
103
|
+
model?: string;
|
|
104
|
+
style?: string;
|
|
105
|
+
};
|
|
106
|
+
toolCallId?: undefined;
|
|
107
|
+
toolCallName?: undefined;
|
|
108
|
+
messageId?: undefined;
|
|
109
|
+
content?: undefined;
|
|
110
|
+
role?: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
type: string;
|
|
113
|
+
timestamp: number;
|
|
114
|
+
toolCallId: string;
|
|
115
|
+
toolCallName: string;
|
|
116
|
+
name?: undefined;
|
|
117
|
+
value?: undefined;
|
|
118
|
+
messageId?: undefined;
|
|
119
|
+
content?: undefined;
|
|
120
|
+
role?: undefined;
|
|
121
|
+
} | {
|
|
122
|
+
type: string;
|
|
123
|
+
timestamp: number;
|
|
124
|
+
messageId: string;
|
|
125
|
+
toolCallId: string;
|
|
126
|
+
content: string;
|
|
127
|
+
role: string;
|
|
128
|
+
name?: undefined;
|
|
129
|
+
value?: undefined;
|
|
130
|
+
toolCallName?: undefined;
|
|
131
|
+
} | {
|
|
132
|
+
type: string;
|
|
133
|
+
timestamp: number;
|
|
134
|
+
name: string;
|
|
135
|
+
value: (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
136
|
+
type: "runtime.request.started";
|
|
137
|
+
requestId: string;
|
|
138
|
+
sessionId: string;
|
|
139
|
+
agentId: string;
|
|
140
|
+
input?: string;
|
|
141
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
142
|
+
type: "runtime.request.completed";
|
|
143
|
+
requestId: string;
|
|
144
|
+
sessionId: string;
|
|
145
|
+
agentId: string;
|
|
146
|
+
output: string;
|
|
147
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
148
|
+
type: "runtime.request.failed";
|
|
149
|
+
requestId: string;
|
|
150
|
+
sessionId: string;
|
|
151
|
+
agentId: string;
|
|
152
|
+
error: string;
|
|
153
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
154
|
+
type: "runtime.failure.classified";
|
|
155
|
+
requestId: string;
|
|
156
|
+
sessionId: string;
|
|
157
|
+
agentId: string;
|
|
158
|
+
classification: import("@stable-harness/core").RuntimeFailureClassification;
|
|
159
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
160
|
+
type: "runtime.improvement.proposed";
|
|
161
|
+
requestId: string;
|
|
162
|
+
sessionId: string;
|
|
163
|
+
agentId: string;
|
|
164
|
+
proposal: import("@stable-harness/core").RuntimeImprovementProposal;
|
|
165
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
166
|
+
type: "runtime.improvement.reviewed";
|
|
167
|
+
requestId: string;
|
|
168
|
+
sessionId: string;
|
|
169
|
+
agentId: string;
|
|
170
|
+
proposal: import("@stable-harness/core").RuntimeImprovementProposal;
|
|
171
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
172
|
+
type: "runtime.improvement.applied";
|
|
173
|
+
requestId: string;
|
|
174
|
+
sessionId: string;
|
|
175
|
+
agentId: string;
|
|
176
|
+
proposal: import("@stable-harness/core").RuntimeImprovementProposal;
|
|
177
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
178
|
+
type: "runtime.verification.hook.completed";
|
|
179
|
+
requestId: string;
|
|
180
|
+
sessionId: string;
|
|
181
|
+
agentId: string;
|
|
182
|
+
hookId: string;
|
|
183
|
+
status: "passed" | "failed" | "blocked";
|
|
184
|
+
evidence?: import("@stable-harness/core").RuntimeFailureEvidenceReference[];
|
|
185
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
186
|
+
type: "runtime.context.offloaded";
|
|
187
|
+
requestId: string;
|
|
188
|
+
sessionId: string;
|
|
189
|
+
agentId: string;
|
|
190
|
+
artifact: RuntimeArtifact;
|
|
191
|
+
retainedPreview?: string;
|
|
192
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
193
|
+
type: "runtime.context.compacted";
|
|
194
|
+
requestId: string;
|
|
195
|
+
sessionId: string;
|
|
196
|
+
agentId: string;
|
|
197
|
+
artifact?: RuntimeArtifact;
|
|
198
|
+
summary: string;
|
|
199
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
200
|
+
type: "runtime.request.cancelled";
|
|
201
|
+
requestId: string;
|
|
202
|
+
sessionId: string;
|
|
203
|
+
agentId: string;
|
|
204
|
+
reason?: string;
|
|
205
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
206
|
+
type: "runtime.request.deleted";
|
|
207
|
+
requestId: string;
|
|
208
|
+
sessionId: string;
|
|
209
|
+
agentId: string;
|
|
210
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
211
|
+
type: "runtime.session.deleted";
|
|
212
|
+
requestId: string;
|
|
213
|
+
sessionId: string;
|
|
214
|
+
agentId: string;
|
|
215
|
+
deletedRequestIds: string[];
|
|
216
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
217
|
+
type: "runtime.artifact.created";
|
|
218
|
+
requestId: string;
|
|
219
|
+
sessionId: string;
|
|
220
|
+
agentId: string;
|
|
221
|
+
artifact: RuntimeArtifact;
|
|
222
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
223
|
+
type: "runtime.deliverable.created";
|
|
224
|
+
requestId: string;
|
|
225
|
+
sessionId: string;
|
|
226
|
+
agentId: string;
|
|
227
|
+
deliverable: import("packages/core/src/runtime/events.js").RuntimeDeliverable;
|
|
228
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
229
|
+
type: "runtime.execution.contract.failed";
|
|
230
|
+
requestId: string;
|
|
231
|
+
sessionId: string;
|
|
232
|
+
agentId: string;
|
|
233
|
+
reason: string;
|
|
234
|
+
missingEvidenceTools?: string[];
|
|
235
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
236
|
+
type: "runtime.repair.started";
|
|
237
|
+
requestId: string;
|
|
238
|
+
sessionId: string;
|
|
239
|
+
agentId: string;
|
|
240
|
+
layer: import("packages/core/src/runtime/events.js").RuntimeRepairLayer;
|
|
241
|
+
attempt?: number;
|
|
242
|
+
reason?: string;
|
|
243
|
+
diagnostics?: import("packages/core/src/runtime/events.js").RuntimeRepairDiagnostics;
|
|
244
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
245
|
+
type: "runtime.repair.completed";
|
|
246
|
+
requestId: string;
|
|
247
|
+
sessionId: string;
|
|
248
|
+
agentId: string;
|
|
249
|
+
layer: import("packages/core/src/runtime/events.js").RuntimeRepairLayer;
|
|
250
|
+
outcome: import("packages/core/src/runtime/events.js").RuntimeRepairOutcome;
|
|
251
|
+
attempt?: number;
|
|
252
|
+
reason?: string;
|
|
253
|
+
diagnostics?: import("packages/core/src/runtime/events.js").RuntimeRepairDiagnostics;
|
|
254
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
255
|
+
type: "runtime.inventory.repair";
|
|
256
|
+
requestId: string;
|
|
257
|
+
sessionId: string;
|
|
258
|
+
agentId: string;
|
|
259
|
+
status: import("packages/core/src/runtime/events.js").RuntimeInventoryRepairStatus;
|
|
260
|
+
diagnostic: import("packages/core/src/runtime/events.js").RuntimeInventoryRepairDiagnostic;
|
|
261
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
262
|
+
type: "runtime.sandbox.decision";
|
|
263
|
+
requestId: string;
|
|
264
|
+
sessionId: string;
|
|
265
|
+
agentId: string;
|
|
266
|
+
toolId: string;
|
|
267
|
+
decision: import("@stable-harness/core").RuntimeSandboxDecision;
|
|
268
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
269
|
+
type: "runtime.approval.requested";
|
|
270
|
+
requestId: string;
|
|
271
|
+
sessionId: string;
|
|
272
|
+
agentId: string;
|
|
273
|
+
approval: import("@stable-harness/core").ApprovalRequest;
|
|
274
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
275
|
+
type: "runtime.approval.resolved";
|
|
276
|
+
requestId: string;
|
|
277
|
+
sessionId: string;
|
|
278
|
+
agentId: string;
|
|
279
|
+
approval: import("@stable-harness/core").ApprovalRequest;
|
|
280
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
281
|
+
type: "runtime.tool.failure";
|
|
282
|
+
requestId: string;
|
|
283
|
+
sessionId: string;
|
|
284
|
+
agentId: string;
|
|
285
|
+
toolId: string;
|
|
286
|
+
error: unknown;
|
|
287
|
+
failure: import("@stable-harness/core").RuntimeToolFailureClassification;
|
|
288
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
289
|
+
type: "runtime.tool.circuit.opened";
|
|
290
|
+
requestId: string;
|
|
291
|
+
sessionId: string;
|
|
292
|
+
agentId: string;
|
|
293
|
+
toolId: string;
|
|
294
|
+
reason: import("@stable-harness/core").RuntimeToolFailureReason;
|
|
295
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
296
|
+
type: "runtime.workflow.started";
|
|
297
|
+
requestId: string;
|
|
298
|
+
sessionId: string;
|
|
299
|
+
agentId: string;
|
|
300
|
+
workflowId: string;
|
|
301
|
+
adapter: string;
|
|
302
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
303
|
+
type: "runtime.workflow.completed";
|
|
304
|
+
requestId: string;
|
|
305
|
+
sessionId: string;
|
|
306
|
+
agentId: string;
|
|
307
|
+
workflowId: string;
|
|
308
|
+
adapter: string;
|
|
309
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
310
|
+
type: "runtime.specDriven.phase.started";
|
|
311
|
+
requestId: string;
|
|
312
|
+
sessionId: string;
|
|
313
|
+
agentId: string;
|
|
314
|
+
phaseId: string;
|
|
315
|
+
workflowId?: string;
|
|
316
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
317
|
+
type: "runtime.specDriven.phase.blocked";
|
|
318
|
+
requestId: string;
|
|
319
|
+
sessionId: string;
|
|
320
|
+
agentId: string;
|
|
321
|
+
phaseId: string;
|
|
322
|
+
workflowId?: string;
|
|
323
|
+
reason: string;
|
|
324
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
325
|
+
type: "runtime.specDriven.phase.completed";
|
|
326
|
+
requestId: string;
|
|
327
|
+
sessionId: string;
|
|
328
|
+
agentId: string;
|
|
329
|
+
phaseId: string;
|
|
330
|
+
workflowId?: string;
|
|
331
|
+
artifact?: RuntimeArtifact;
|
|
332
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
333
|
+
type: "runtime.specDriven.phase.verified";
|
|
334
|
+
requestId: string;
|
|
335
|
+
sessionId: string;
|
|
336
|
+
agentId: string;
|
|
337
|
+
phaseId: string;
|
|
338
|
+
workflowId?: string;
|
|
339
|
+
artifact?: RuntimeArtifact;
|
|
340
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
341
|
+
type: "runtime.memory.lifecycle";
|
|
342
|
+
requestId: string;
|
|
343
|
+
sessionId: string;
|
|
344
|
+
agentId: string;
|
|
345
|
+
hook: import("@stable-harness/core").RuntimeMemoryHook;
|
|
346
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
347
|
+
type: "runtime.memory.recall.completed";
|
|
348
|
+
requestId: string;
|
|
349
|
+
sessionId: string;
|
|
350
|
+
agentId: string;
|
|
351
|
+
namespace: string;
|
|
352
|
+
recordIds: string[];
|
|
353
|
+
context: string;
|
|
354
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
355
|
+
type: "runtime.memory.candidate.submitted";
|
|
356
|
+
requestId: string;
|
|
357
|
+
sessionId: string;
|
|
358
|
+
agentId: string;
|
|
359
|
+
candidate: import("@stable-harness/memory").MemoryCandidate;
|
|
360
|
+
decision: import("@stable-harness/memory").MemoryDecision;
|
|
361
|
+
record?: import("@stable-harness/memory").MemoryRecord;
|
|
362
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
363
|
+
type: "runtime.memory.approval.requested";
|
|
364
|
+
requestId: string;
|
|
365
|
+
sessionId: string;
|
|
366
|
+
agentId: string;
|
|
367
|
+
approval: import("@stable-harness/core").ApprovalRequest;
|
|
368
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
369
|
+
type: "runtime.memory.plugin.started";
|
|
370
|
+
requestId: string;
|
|
371
|
+
sessionId: string;
|
|
372
|
+
agentId: string;
|
|
373
|
+
memoryId: string;
|
|
374
|
+
provider: string;
|
|
375
|
+
namespace: string;
|
|
376
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
377
|
+
type: "runtime.memory.plugin.completed";
|
|
378
|
+
requestId: string;
|
|
379
|
+
sessionId: string;
|
|
380
|
+
agentId: string;
|
|
381
|
+
memoryId: string;
|
|
382
|
+
provider: string;
|
|
383
|
+
namespace: string;
|
|
384
|
+
candidateCount: number;
|
|
385
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
386
|
+
type: "runtime.memory.plugin.failed";
|
|
387
|
+
requestId: string;
|
|
388
|
+
sessionId: string;
|
|
389
|
+
agentId: string;
|
|
390
|
+
memoryId: string;
|
|
391
|
+
provider: string;
|
|
392
|
+
namespace: string;
|
|
393
|
+
error: string;
|
|
394
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
395
|
+
type: "runtime.memory.maintenance.started";
|
|
396
|
+
requestId: string;
|
|
397
|
+
sessionId: string;
|
|
398
|
+
agentId: string;
|
|
399
|
+
target: string;
|
|
400
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
401
|
+
type: "runtime.memory.maintenance.completed";
|
|
402
|
+
requestId: string;
|
|
403
|
+
sessionId: string;
|
|
404
|
+
agentId: string;
|
|
405
|
+
target: string;
|
|
406
|
+
operationCount: number;
|
|
407
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
408
|
+
type: "runtime.memory.maintenance.failed";
|
|
409
|
+
requestId: string;
|
|
410
|
+
sessionId: string;
|
|
411
|
+
agentId: string;
|
|
412
|
+
target: string;
|
|
413
|
+
error: string;
|
|
414
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
415
|
+
type: "runtime.skill.candidate.created";
|
|
416
|
+
requestId: string;
|
|
417
|
+
sessionId: string;
|
|
418
|
+
agentId: string;
|
|
419
|
+
candidateId: string;
|
|
420
|
+
name: string;
|
|
421
|
+
confidence: number;
|
|
422
|
+
evidenceCount: number;
|
|
423
|
+
status: string;
|
|
424
|
+
proposedPath?: string;
|
|
425
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
426
|
+
type: "runtime.quality.planning.reviewed";
|
|
427
|
+
requestId: string;
|
|
428
|
+
sessionId: string;
|
|
429
|
+
agentId: string;
|
|
430
|
+
verdict: string;
|
|
431
|
+
issues: Array<{
|
|
432
|
+
code: string;
|
|
433
|
+
message: string;
|
|
434
|
+
recoverable: boolean;
|
|
435
|
+
}>;
|
|
436
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
437
|
+
type: "runtime.quality.execution.reviewed";
|
|
438
|
+
requestId: string;
|
|
439
|
+
sessionId: string;
|
|
440
|
+
agentId: string;
|
|
441
|
+
verdict: string;
|
|
442
|
+
issues: Array<{
|
|
443
|
+
code: string;
|
|
444
|
+
message: string;
|
|
445
|
+
recoverable: boolean;
|
|
446
|
+
}>;
|
|
447
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
448
|
+
type: "runtime.quality.recovery.started";
|
|
449
|
+
requestId: string;
|
|
450
|
+
sessionId: string;
|
|
451
|
+
agentId: string;
|
|
452
|
+
phase: "planning" | "execution";
|
|
453
|
+
attempt: number;
|
|
454
|
+
verdict: string;
|
|
455
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
456
|
+
type: "runtime.quality.synthesis.created";
|
|
457
|
+
requestId: string;
|
|
458
|
+
sessionId: string;
|
|
459
|
+
agentId: string;
|
|
460
|
+
mode: "evidence_only";
|
|
461
|
+
}) | (import("packages/core/src/runtime/events.js").RuntimeEventMetadata & {
|
|
462
|
+
type: "runtime.adapter.event";
|
|
463
|
+
requestId: string;
|
|
464
|
+
sessionId: string;
|
|
465
|
+
agentId: string;
|
|
466
|
+
event: unknown;
|
|
467
|
+
});
|
|
468
|
+
toolCallId?: undefined;
|
|
469
|
+
toolCallName?: undefined;
|
|
470
|
+
messageId?: undefined;
|
|
471
|
+
content?: undefined;
|
|
472
|
+
role?: undefined;
|
|
473
|
+
};
|
|
474
|
+
export declare function createAcpInitializeResult(runtime: StableHarnessRuntime, params?: Record<string, unknown>): {
|
|
475
|
+
protocolVersion: number;
|
|
476
|
+
agentCapabilities: {
|
|
477
|
+
loadSession: boolean;
|
|
478
|
+
promptCapabilities: {
|
|
479
|
+
embeddedContext: boolean;
|
|
480
|
+
};
|
|
481
|
+
mcpCapabilities: {
|
|
482
|
+
http: boolean;
|
|
483
|
+
sse: boolean;
|
|
484
|
+
};
|
|
485
|
+
session: {
|
|
486
|
+
update: boolean;
|
|
487
|
+
cancel: boolean;
|
|
488
|
+
list: boolean;
|
|
489
|
+
close: boolean;
|
|
490
|
+
};
|
|
491
|
+
sessionCapabilities: {
|
|
492
|
+
close: boolean;
|
|
493
|
+
};
|
|
494
|
+
_meta: {
|
|
495
|
+
transport: string;
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
agentInfo: {
|
|
499
|
+
name: string;
|
|
500
|
+
title: string;
|
|
501
|
+
version: string;
|
|
502
|
+
};
|
|
503
|
+
authMethods: never[];
|
|
504
|
+
};
|
|
505
|
+
export declare function readRuntimeRequestExtension(body: Record<string, unknown>): RuntimeRequest | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{projectRuntimeTrace as e,projectRuntimeTraceSpans as t,renderStableHarnessPrometheusMetrics as r}from"@stable-harness/core";export function readRecord(e){return"object"!=typeof e||null===e||Array.isArray(e)?void 0:e}export function readString(e){return"string"==typeof e&&e.trim()?e:void 0}export function readPromptText(e){return"string"==typeof e.input?e.input:"string"==typeof e.text?e.text:"string"==typeof e.prompt?e.prompt:Array.isArray(e.parts)?e.parts.map(readPartText).filter(Boolean).join("\n"):Array.isArray(e.messages)?readPromptText(readRecord(e.messages.at(-1))??{}):Array.isArray(e.content)?e.content.map(readPartText).filter(Boolean).join("\n"):"string"==typeof e.content?e.content:""}export function matchPath(e,t){const r=(e??"").match(t);return r?.[1]?decodeURIComponent(r[1]):void 0}export function readRunInspectionPath(e,t){const r=(e??"").match(t);return r?.[1]&&r[2]?{requestId:decodeURIComponent(r[1]),kind:r[2]}:void 0}export function jsonRpcResult(e,t){return{jsonrpc:"2.0",id:e,result:t}}export function jsonRpcError(e,t,r){return{jsonrpc:"2.0",id:e,error:{code:t,message:r}}}export function sendJson(e,t,r){e.writeHead(t,{"content-type":"application/json"}),e.end(JSON.stringify(r))}export async function handleAgentControlRoute(e,t,n){if("GET"===t.method&&"/metrics"===t.url)return n.writeHead(200,{"content-type":"text/plain; version=0.0.4; charset=utf-8"}).end(r({runtime:e})),!0;const o=function readApprovalList(e){if(!e?.startsWith("/approvals"))return;const t=new URL(e,"http://stable-harness.local");if("/approvals"!==t.pathname)return;const r=t.searchParams.get("status");return{status:"pending"===r||"approved"===r||"rejected"===r?r:void 0}}(t.url);if("GET"===t.method&&o)return sendJson(n,200,await e.listApprovals(o.status)),!0;const a=function readApprovalDecision(e){const t=(e??"").match(/^\/approvals\/([^/]+)\/(approve|reject)$/u);return t?.[1]&&t[2]?{id:decodeURIComponent(t[1]),status:"approve"===t[2]?"approved":"rejected"}:void 0}(t.url);if("POST"===t.method&&a){const t=await e.resolveApproval(a.id,a.status);return sendJson(n,t?200:404,t??{error:"approval_not_found"}),!0}return!1}export function sendRunInspection(r,n,o,a="run_not_found"){const s=r.getRun(o.requestId),i="replay"===o.kind?r.exportReplayBundle(o.requestId):void 0;sendJson(n,s||i?200:404,("trace"===o.kind&&s?e(s):"spans"===o.kind&&s?t(s):i)??{error:a})}export function handleAcpRunInspection(r,n){const o="runtime/trace"===n.method?"trace":"runtime/spans"===n.method?"spans":"runtime/replay"===n.method?"replay":void 0;if(!o)return;const a=readString(readRecord(n.params)?.requestId);if(!a)return jsonRpcError(n.id,-32602,"request_id_required");const s=r.getRun(a),i="replay"===o?r.exportReplayBundle(a):void 0;return s||i?jsonRpcResult(n.id,"trace"===o&&s?e(s):"spans"===o&&s?t(s):i):jsonRpcError(n.id,-32004,"run_not_found")}export function validateA2aVersion(e,t){const r=e.headers["a2a-version"],n=Array.isArray(r)?r[0]:r;return!n||"0.3"===n||"1.0"===n||(sendJson(t,400,jsonRpcError(null,-32006,"version_not_supported")),!1)}export function writeSseHeaders(e){e.writeHead(200,{"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive"})}export function writeSse(e,t,r){r&&e.write(`id: ${r}\n`),e.write(`data: ${JSON.stringify(t)}\n\n`)}export async function readJson(e){const t=[];for await(const r of e)t.push(Buffer.isBuffer(r)?r:Buffer.from(r));return t.length>0?JSON.parse(Buffer.concat(t).toString("utf8")):{}}export function errorMessage(e){return e instanceof Error?e.message:String(e)}export function storeA2aPushConfig(e,t,r){const n=readA2aPushConfig(r),o=t.requestId;n&&o&&e.set(o,n)}export function readA2aPushConfig(e){const t=readRecord(e.pushNotificationConfig)??readRecord(readRecord(e.configuration)?.pushNotificationConfig)??readRecord(readRecord(e.message)?.pushNotificationConfig),r=readString(t?.url);return r?{url:r,...readString(t?.token)?{token:readString(t?.token)}:{}}:void 0}export function notifyA2aPush(e,t,r){const n=t?e.get(t):void 0;n&&fetch(n.url,{method:"POST",headers:{"content-type":"application/json",...n.token?{authorization:`Bearer ${n.token}`}:{}},body:JSON.stringify({taskId:t,event:r})}).catch(()=>{})}export function streamRuntimeEventReplay(e,t,r,n,o={}){const a=e.inspectRequest(t);if(!a)return void sendJson(r,404,{error:"run_not_found"});if(writeSseHeaders(r),function replayTimeline(e,t,r,n){const o=n?e.findIndex(e=>e.event.eventId===n)+1:0;(o>0?e.slice(o):e).forEach(e=>writeSse(t,r(e.event),e.event.eventId))}(a.timeline,r,n,o.afterEventId),["completed","failed","cancelled","canceled","rejected"].includes(a.summary.state))return void r.end();const s=e.subscribe(e=>{e.requestId===t&&writeSse(r,n(e),e.eventId)});r.on("close",s)}export function readSseReplayCursor(e){const t=e.headers["last-event-id"],r=readString(Array.isArray(t)?t[0]:t);if(r)return r;const n=new URL(e.url??"/","http://127.0.0.1");return readString(n.searchParams.get("afterEventId"))??readString(n.searchParams.get("after"))}function readPartText(e){const t=readRecord(e);return t?readString(t.text)??readString(t.content)??"":"string"==typeof e?e:""}export function isTerminalState(e){return"completed"===e||"failed"===e||"cancelled"===e||"canceled"===e||"rejected"===e}export function toA2aHistoryMessage(e,t){const r="runtime.request.started"===t.type?t.input:"runtime.request.completed"===t.type?t.output:"runtime.request.failed"===t.type?t.error:"runtime.request.cancelled"===t.type?t.reason:"runtime.progress.narration"===t.type?t.message:void 0;return{role:"runtime.request.started"===t.type?"user":"agent",messageId:`${t.requestId}-history-${e}`,parts:r?[{kind:"text",text:r}]:[],metadata:{stableHarnessEvent:t}}}export function toA2aArtifact(e){return{artifactId:e.id,name:e.kind,parts:[{kind:"data",data:{id:e.id,kind:e.kind,uri:e.uri,metadata:e.metadata}}],metadata:{stableHarnessArtifact:e}}}export function toAguiEvent(e){if("runtime.progress.narration"===e.type)return{type:"CUSTOM",timestamp:Date.now(),name:"stable-harness.progress",value:e};if("runtime.tool.direct.started"===e.type)return{type:"TOOL_CALL_START",timestamp:Date.now(),toolCallId:`${e.requestId}:${e.toolId}`,toolCallName:e.toolId};if("runtime.tool.direct.completed"===e.type)return{type:"TOOL_CALL_RESULT",timestamp:Date.now(),messageId:`${e.requestId}-message`,toolCallId:`${e.requestId}:${e.toolId}`,content:JSON.stringify(e.output),role:"tool"};const t=function readAdapterToolEvent(e){if("runtime.adapter.event"!==e.type||"object"!=typeof e.event||null===e.event)return;const t=e.event,r=readString(t.toolId);return r?"deepagents.tool_execution.start"===t.eventType||"agent.tool.start"===t.phase?{kind:"start",toolId:r}:"deepagents.tool_execution.result"===t.eventType||"agent.tool.result"===t.phase?{kind:"result",toolId:r,output:t.output??t.error??t}:void 0:void 0}(e);return"start"===t?.kind?{type:"TOOL_CALL_START",timestamp:Date.now(),toolCallId:`${e.requestId}:${t.toolId}`,toolCallName:t.toolId}:"result"===t?.kind?{type:"TOOL_CALL_RESULT",timestamp:Date.now(),messageId:`${e.requestId}-message`,toolCallId:`${e.requestId}:${t.toolId}`,content:JSON.stringify(t.output),role:"tool"}:{type:"CUSTOM",timestamp:Date.now(),name:`stable-harness.${e.type}`,value:e}}export function createAcpInitializeResult(e,t){return"number"==typeof t?.protocolVersion&&t.protocolVersion,{protocolVersion:1,agentCapabilities:{loadSession:!0,promptCapabilities:{embeddedContext:!0},mcpCapabilities:{http:!1,sse:!1},session:{update:!0,cancel:!0,list:!0,close:!0},sessionCapabilities:{close:!0},_meta:{transport:"http-jsonrpc"}},agentInfo:{name:"stable-harness",title:"Stable Harness",version:"0.0.0"},authMethods:[]}}export function readRuntimeRequestExtension(e){const t=readRecord(e.runtimeRequest)??readRecord(readRecord(e.metadata)?.runtimeRequest);if(t)return{input:readString(t.input)??"",...readString(t.requestId)?{requestId:readString(t.requestId)}:{},...readString(t.sessionId)?{sessionId:readString(t.sessionId)}:{},...readString(t.agentId)?{agentId:readString(t.agentId)}:{},...readToolCall(t.toolCall)?{toolCall:readToolCall(t.toolCall)}:{},...readWorkflow(t.workflow)?{workflow:readWorkflow(t.workflow)}:{},...readRecord(t.metadata)?{metadata:readRecord(t.metadata)}:{}}}function readToolCall(e){const t=readRecord(e),r=readString(t?.toolId);return r?{toolId:r,args:t?.args}:void 0}function readWorkflow(e){const t=readRecord(e);if(t)return{...readString(t.workflowId)?{workflowId:readString(t.workflowId)}:{},...readString(t.routeId)?{routeId:readString(t.routeId)}:{},...void 0!==t.input?{input:t.input}:{},...readRecord(t.metadata)?{metadata:readRecord(t.metadata)}:{}}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stable-harness/protocols",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.144",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"main": "dist/src/index.js",
|
|
12
12
|
"types": "dist/src/index.d.ts",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@stable-harness/core": "0.0.
|
|
14
|
+
"@stable-harness/core": "0.0.144"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BetterToolValidationError as o,betterTools as t,defaultRepair as
|
|
1
|
+
import{BetterToolValidationError as o,betterTools as t,defaultRepair as r,reliableToolCalls as e,repairCallSelection as a}from"@easynet/better-call";import{isRecord as i,validateWithZodSchema as l}from"./schema-validation.js";export class ToolArgumentValidationError extends Error{toolId;issues;constructor(o,t){super(`Tool argument validation failed for ${o}: ${t.map(o=>`${o.path} ${o.message}`).join("; ")}`),this.toolId=o,this.issues=t,this.name="ToolArgumentValidationError"}}export function createDefaultArgumentGuard(t={}){return{async validate(r){const e=r.tool.validateArgs?await r.tool.validateArgs({args:r.args,context:r.context}):{action:"allow",args:r.args};if("reject"===e.action)return e;const a=await async function validateWithBetterCall(t,r,e){const a=l(t.schema,r);if(void 0===t.schema)return a??{action:"allow",args:r};if("allow"===a?.action&&function serializedLength(o){try{return JSON.stringify(o).length}catch{return 0}}(a.args)>1e4)return a;const i=await async function invokeBetterCallValidation(t,r,e){try{return{action:"allow",args:await createBetterCallValidationTool(t,e).invoke(r)}}catch(t){if(t instanceof o)return{action:"reject",reason:"BetterCall validation failed",issues:t.issues.map(toToolArgumentIssue)};throw t}}(t,"allow"===a?.action?a.args:r,e);if(!a)return i;if("allow"===a.action)return i;if("reject"===i.action)return a;const n=l(t.schema,i.args);return n||i}(r.tool,e.args,t.betterCall);return"reject"===a.action?a:"repair"===e.action?{...e,args:a.args}:a}}}export function assertToolArguments(o,t,r,e){return Promise.resolve(e.validate({tool:o,args:t,context:r})).then(t=>{if("reject"===t.action)throw new ToolArgumentValidationError(o.id,t.issues);return t.args})}export function prepareBetterCallTools(o,r){const e=t(o.map(toBetterCallTool),toBetterToolsOptions(r));return o.map((o,t)=>({...o,validationTool:e[t]}))}export async function repairBetterCallToolSelection(o){if(0===o.tools.length)return;const t=function resolveRepair(o){return o?.repair??(o?.repairModel?r(o.repairModel):void 0)}(o.options);if(t){const r=await e({userInput:JSON.stringify({tool:o.toolId,args:o.args}),tools:o.tools.map(toToolDefinition),calls:[{tool:o.toolId,args:toToolCallArgs(o.args)}],repair:t,repairPolicy:o.options?.repairPolicy??{allowCoercion:!0,allowClamp:!0,allowArrayStringSplit:!0,allowModelRepair:!0},mode:o.options?.mode??"repair"}),a=r.ok?r.calls.find(t=>o.tools.some(o=>o.id===t.tool)):void 0;return a?{toolId:a.tool,args:a.args}:void 0}const i=await a({userInput:JSON.stringify({tool:o.toolId,args:o.args}),call:{name:o.toolId,args:toToolCallArgs(o.args)},candidates:o.tools.map(toCallCandidate),repair:o.options?.repair,repairModel:o.options?.repairModel,repairPolicy:o.options?.repairPolicy??{allowCoercion:!0,allowClamp:!0,allowArrayStringSplit:!0,allowModelRepair:!0},mode:o.options?.mode??"repair"});return i.ok?{toolId:i.candidateId,args:i.args}:void 0}function createBetterCallValidationTool(o,r){return o.validationTool??t([toBetterCallTool(o)],toBetterToolsOptions(r))[0]}function toBetterCallTool(o){return{name:o.id,description:o.description,schema:o.schema,invoke:o=>o}}function toToolDefinition(o){return{name:o.id,description:o.description,schema:o.schema}}function toCallCandidate(o){return{id:o.id,description:o.description,schema:o.schema}}function toToolArgumentIssue(o){return{path:o.path.replace(/^\$\.calls\[\d+\]\.args/u,"$"),message:o.message,expected:void 0===o.expected?void 0:String(o.expected),actual:o.actual}}function toBetterToolsOptions(o){const t=Boolean(o?.repair||o?.repairModel);return{mode:o?.mode??(t?"repair":"guard"),repair:o?.repair,repairModel:o?.repairModel,repairPolicy:o?.repairPolicy??(t?{allowCoercion:!0,allowClamp:!0,allowArrayStringSplit:!0,allowModelRepair:!0}:{allowCoercion:!1,allowClamp:!1,allowArrayStringSplit:!1,allowModelRepair:!1})}}function toToolCallArgs(o){return i(o)?o:{input:o}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeArgsBySchema as e}from"@easynet/better-call";export function validateWithZodSchema(t,r){return isZodLike(t)?toZodGuardResult(t.safeParse(r??{})):function isZodShape(e){return isRecord(e)&&Object.values(e).length>0&&Object.values(e).every(isZodLike)}(t)?function validateWithZodShape(t,r){const s=function normalizeZodShapeArgs(t,r){const s=isRecord(r)?r:{};return e(t,s,{allowCoercion:!0,allowClamp:!0,allowArrayStringSplit:!0}).args}(t,r),
|
|
1
|
+
import{normalizeArgsBySchema as e}from"@easynet/better-call";export function validateWithZodSchema(t,r){return isZodLike(t)?toZodGuardResult(t.safeParse(r??{})):function isZodShape(e){return isRecord(e)&&Object.values(e).length>0&&Object.values(e).every(isZodLike)}(t)?function validateWithZodShape(t,r){const s=function normalizeZodShapeArgs(t,r){const s=isRecord(r)?r:{};return e(t,s,{allowCoercion:!0,allowClamp:!0,allowArrayStringSplit:!0}).args}(t,r),o={},a=[];for(const[e,r]of Object.entries(t)){const t=r.safeParse(s[e]);t.success?void 0!==t.data&&(o[e]=t.data):a.push(...t.error.issues.map(t=>({...t,path:[e,...t.path]})))}return a.length>0?toZodGuardResult({success:!1,error:{issues:a}}):{action:"allow",args:o}}(t,r):function isJsonObjectSchema(e){return isRecord(e)&&"object"===e.type}(t)?function validateWithJsonObjectSchema(e,t){const r=isRecord(t)?t:{},s=[];for(const t of e.required??[])t in r||s.push({path:`$.${t}`,message:"Required property is missing",expected:"required"});for(const[t,o]of Object.entries(e.properties??{}))t in r&&void 0!==o.type&&jsonType(r[t])!==o.type&&s.push({path:`$.${t}`,message:`Expected ${o.type}`,expected:o.type,actual:r[t]});return s.length>0?{action:"reject",reason:"JSON schema validation failed",issues:s}:{action:"allow",args:r}}(t,r):void 0}export function isRecord(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function toZodGuardResult(e){return e.success?{action:"allow",args:e.data}:{action:"reject",reason:"Zod schema validation failed",issues:e.error.issues.map(e=>{return{path:(t=e.path,t.length>0?`$.${t.map(String).join(".")}`:"$"),message:e.message,expected:"schema"};var t})}}function isZodLike(e){return isRecord(e)&&"function"==typeof e.safeParse}function jsonType(e){return Array.isArray(e)?"array":null===e?"null":typeof e}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertBoundaryPolicyDiagnostics as s,checkBoundaryScanPolicy as
|
|
1
|
+
import{assertBoundaryPolicyDiagnostics as s,checkBoundaryScanPolicy as t,scanAgentBoundary as o}from"@stable-harness/core";export function scanWorkspaceBoundaries(s){const e=s.runtime.workspaceValidation?.boundaryScan;if(!0!==e?.enabled)return[];const n=o({subagents:readSubagents(s),skills:readSkills(s),tools:readTools(s)});return t(n,e)}export function assertWorkspaceBoundaryDiagnostics(t){s(t)}function readSubagents(s){const t=s.agents.get(s.runtime.defaultAgentId);return(t?.subagents??[]).map(t=>s.agents.get(t)).filter(s=>Boolean(s)).map(s=>({id:s.id,description:s.description,text:s.systemPrompt,tools:s.tools,skills:s.skills,subagents:s.subagents,locations:s.sourcePath?[s.sourcePath]:[]}))}function readSkills(s){return[...s.skills.values()].map(s=>({id:s.id,description:s.description,tools:s.allowedTools,locations:[s.path]}))}function readTools(s){return[...s.tools.values()].map(s=>({id:s.id,description:s.description,text:s.id,locations:s.sourcePath?[s.sourcePath]:[]}))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdir as t,readFile as e}from"node:fs/promises";import
|
|
1
|
+
import{readdir as t,readFile as e}from"node:fs/promises";import o from"node:path";import{parseAllDocuments as r}from"yaml";export async function listYamlFiles(e){const r=await t(e,{withFileTypes:!0});return(await Promise.all(r.map(async t=>{const r=o.join(e,t.name);return t.isDirectory()?listYamlFiles(r):t.isFile()&&/\.ya?ml$/iu.test(t.name)?[r]:[]}))).flat().sort()}export async function discoverModuleTools(t){const r=o.join(t,"resources","tools");let i;try{i=await listModuleToolFiles(r)}catch{return[]}return(await Promise.all(i.map(t=>async function discoverModuleToolFile(t){const r=await e(t,"utf8"),i=[...r.matchAll(/export\s+const\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*tool\s*\(/gu)].map(t=>t[1]).filter(t=>"default"!==t);return(i.length>0?i:[o.basename(t,".mjs")]).map(e=>({id:e,sourcePath:t,...readModuleToolDescription(r,e)}))}(t)))).flat()}async function listModuleToolFiles(e){const r=await t(e,{withFileTypes:!0});return(await Promise.all(r.map(async t=>{const r=o.join(e,t.name);return t.isDirectory()&&!t.name.startsWith("_")?listModuleToolFiles(r):t.isFile()&&t.name.endsWith(".mjs")&&!t.name.startsWith("_")?[r]:[]}))).flat().sort()}export async function discoverSkills(i){const n=o.join(i,"resources","skills");let s;try{s=await t(n,{withFileTypes:!0})}catch{return[]}return(await Promise.all(s.filter(t=>t.isDirectory()).map(t=>async function readSkill(t,i){const n=o.join(t,"SKILL.md");let s;try{s=await e(n,"utf8")}catch{return}const a=function readFrontMatter(t){const e=t.match(/^---\n([\s\S]*?)\n---/u);if(!e)return{};const o=r(e[1]).at(0)?.toJSON();return"object"!=typeof o||null===o||Array.isArray(o)?{}:o}(s);return{id:readOptionalString(a.name)??i,path:n,...readOptionalString(a.description)?{description:readOptionalString(a.description)}:{},allowedTools:(l=a["allowed-tools"],Array.isArray(l)?l.filter(t=>"string"==typeof t&&t.trim().length>0):[])};var l}(o.join(n,t.name),t.name)))).filter(t=>Boolean(t))}function readModuleToolDescription(t,e){const o=t.match(new RegExp(`export\\s+const\\s+${function escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}(e)}\\s*=\\s*tool\\s*\\(\\s*\\{[\\s\\S]{0,4000}?description\\s*:\\s*(["'\`])([\\s\\S]*?)\\1`,"u")),r=t.match(/description\s*:\s*(["'`])([\s\S]*?)\1/u),i=function normalizeDescription(t){const e=t?.replace(/\\n/gu," ").replace(/\s+/gu," ").trim();return e||void 0}(o?.[2]??r?.[2]);return i?{description:i}:{}}function readOptionalString(t){return"string"==typeof t&&t.trim()?t.trim():void 0}
|