stable-harness 0.0.36 → 0.0.38
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/node_modules/@stable-harness/adapter-deepagents/dist/src/adapter.d.ts +9 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/adapter.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/index.d.ts +4 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/index.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin-args.d.ts +5 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin-args.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin-call-repair.d.ts +9 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin-call-repair.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin-tool-policy.d.ts +39 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin-tool-policy.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/gateway/tool-evidence.d.ts +10 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/gateway/tool-evidence.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/gateway/tool-failure-events.d.ts +2 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/gateway/tool-failure-events.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/gateway-tools.d.ts +33 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/gateway-tools.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/messages.d.ts +9 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/messages.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/raw-tool-call-parser.d.ts +12 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/raw-tool-call-parser.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/skill-file-policy.d.ts +10 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/skill-file-policy.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/stream-events.d.ts +2 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/stream-events.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/tool-repeat-visibility.d.ts +4 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/tool-repeat-visibility.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/trace-projection.d.ts +16 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/trace-projection.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/memory.d.ts +5 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/memory.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/model-providers.d.ts +4 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/model-providers.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/retry-policy.d.ts +2 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/retry-policy.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/types.d.ts +12 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/types.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/package.json +26 -0
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/graph.d.ts +3 -0
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/graph.js +1 -0
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/index.d.ts +8 -0
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/index.js +1 -0
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/runtime.d.ts +3 -0
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/runtime.js +1 -0
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/skill-providers.d.ts +29 -0
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/skill-providers.js +1 -0
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/types.d.ts +60 -0
- package/node_modules/@stable-harness/adapter-langgraph/dist/src/types.js +1 -0
- package/node_modules/@stable-harness/adapter-langgraph/package.json +16 -0
- package/node_modules/@stable-harness/core/dist/boundary-scan.d.ts +38 -0
- package/node_modules/@stable-harness/core/dist/boundary-scan.js +1 -0
- package/node_modules/@stable-harness/core/dist/evaluations/index.d.ts +18 -0
- package/node_modules/@stable-harness/core/dist/evaluations/index.js +1 -0
- package/node_modules/@stable-harness/core/dist/execution-contract.d.ts +9 -0
- package/node_modules/@stable-harness/core/dist/execution-contract.js +1 -0
- package/node_modules/@stable-harness/core/dist/index.d.ts +20 -0
- package/node_modules/@stable-harness/core/dist/index.js +1 -0
- package/node_modules/@stable-harness/core/dist/memory-plugins/maintenance.d.ts +42 -0
- package/node_modules/@stable-harness/core/dist/memory-plugins/maintenance.js +1 -0
- package/node_modules/@stable-harness/core/dist/memory-plugins/shared.d.ts +8 -0
- package/node_modules/@stable-harness/core/dist/memory-plugins/shared.js +1 -0
- package/node_modules/@stable-harness/core/dist/memory-plugins.d.ts +25 -0
- package/node_modules/@stable-harness/core/dist/memory-plugins.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/event-evidence.d.ts +11 -0
- package/node_modules/@stable-harness/core/dist/quality/event-evidence.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/execution-review.d.ts +2 -0
- package/node_modules/@stable-harness/core/dist/quality/execution-review.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/index.d.ts +9 -0
- package/node_modules/@stable-harness/core/dist/quality/index.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/llm-review.d.ts +7 -0
- package/node_modules/@stable-harness/core/dist/quality/llm-review.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/planning-review.d.ts +2 -0
- package/node_modules/@stable-harness/core/dist/quality/planning-review.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/profile.d.ts +3 -0
- package/node_modules/@stable-harness/core/dist/quality/profile.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/recovery-policy.d.ts +11 -0
- package/node_modules/@stable-harness/core/dist/quality/recovery-policy.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/runtime.d.ts +13 -0
- package/node_modules/@stable-harness/core/dist/quality/runtime.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/synthesis/fields.d.ts +19 -0
- package/node_modules/@stable-harness/core/dist/quality/synthesis/fields.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/synthesis/language.d.ts +3 -0
- package/node_modules/@stable-harness/core/dist/quality/synthesis/language.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/synthesis/observed.d.ts +3 -0
- package/node_modules/@stable-harness/core/dist/quality/synthesis/observed.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/synthesis.d.ts +2 -0
- package/node_modules/@stable-harness/core/dist/quality/synthesis.js +1 -0
- package/node_modules/@stable-harness/core/dist/quality/types.d.ts +52 -0
- package/node_modules/@stable-harness/core/dist/quality/types.js +1 -0
- package/node_modules/@stable-harness/core/dist/recovery/tool-call.d.ts +28 -0
- package/node_modules/@stable-harness/core/dist/recovery/tool-call.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/capabilities.d.ts +47 -0
- package/node_modules/@stable-harness/core/dist/runtime/capabilities.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/completion.d.ts +18 -0
- package/node_modules/@stable-harness/core/dist/runtime/completion.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/direct-tool-call.d.ts +11 -0
- package/node_modules/@stable-harness/core/dist/runtime/direct-tool-call.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/events.d.ts +295 -0
- package/node_modules/@stable-harness/core/dist/runtime/events.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/governance/approval-gate.d.ts +8 -0
- package/node_modules/@stable-harness/core/dist/runtime/governance/approval-gate.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/governance/sandbox.d.ts +9 -0
- package/node_modules/@stable-harness/core/dist/runtime/governance/sandbox.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/inspection/artifacts.d.ts +15 -0
- package/node_modules/@stable-harness/core/dist/runtime/inspection/artifacts.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/inspection/methods.d.ts +11 -0
- package/node_modules/@stable-harness/core/dist/runtime/inspection/methods.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/inspection/replay.d.ts +6 -0
- package/node_modules/@stable-harness/core/dist/runtime/inspection/replay.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/memory.d.ts +29 -0
- package/node_modules/@stable-harness/core/dist/runtime/memory.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/artifacts.d.ts +8 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/artifacts.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/inspection.d.ts +4 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/inspection.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/queue.d.ts +2 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/queue.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/stores.d.ts +3 -0
- package/node_modules/@stable-harness/core/dist/runtime/persistence/stores.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/progress-narration.d.ts +38 -0
- package/node_modules/@stable-harness/core/dist/runtime/progress-narration.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/selection-repair.d.ts +24 -0
- package/node_modules/@stable-harness/core/dist/runtime/selection-repair.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/tool-failure.d.ts +41 -0
- package/node_modules/@stable-harness/core/dist/runtime/tool-failure.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/tool-gateway.d.ts +59 -0
- package/node_modules/@stable-harness/core/dist/runtime/tool-gateway.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/types.d.ts +191 -0
- package/node_modules/@stable-harness/core/dist/runtime/types.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime.d.ts +21 -0
- package/node_modules/@stable-harness/core/dist/runtime.js +1 -0
- package/node_modules/@stable-harness/core/dist/spec-driven/config.d.ts +4 -0
- package/node_modules/@stable-harness/core/dist/spec-driven/config.js +1 -0
- package/node_modules/@stable-harness/core/dist/spec-driven/events.d.ts +11 -0
- package/node_modules/@stable-harness/core/dist/spec-driven/events.js +1 -0
- package/node_modules/@stable-harness/core/dist/spec-driven/index.d.ts +4 -0
- package/node_modules/@stable-harness/core/dist/spec-driven/index.js +1 -0
- package/node_modules/@stable-harness/core/dist/spec-driven/lifecycle.d.ts +11 -0
- package/node_modules/@stable-harness/core/dist/spec-driven/lifecycle.js +1 -0
- package/node_modules/@stable-harness/core/dist/spec-driven/types.d.ts +38 -0
- package/node_modules/@stable-harness/core/dist/spec-driven/types.js +1 -0
- package/node_modules/@stable-harness/core/dist/trace.d.ts +15 -0
- package/node_modules/@stable-harness/core/dist/trace.js +1 -0
- package/node_modules/@stable-harness/core/dist/types.d.ts +144 -0
- package/node_modules/@stable-harness/core/dist/types.js +1 -0
- package/node_modules/@stable-harness/core/dist/workflows/index.d.ts +70 -0
- package/node_modules/@stable-harness/core/dist/workflows/index.js +1 -0
- package/node_modules/@stable-harness/core/dist/workflows/runtime.d.ts +12 -0
- package/node_modules/@stable-harness/core/dist/workflows/runtime.js +1 -0
- package/node_modules/@stable-harness/core/dist/workspace/tool-quality.d.ts +22 -0
- package/node_modules/@stable-harness/core/dist/workspace/tool-quality.js +1 -0
- package/node_modules/@stable-harness/core/dist/workspace/types.d.ts +134 -0
- package/node_modules/@stable-harness/core/dist/workspace/types.js +1 -0
- package/node_modules/@stable-harness/core/package.json +18 -0
- package/node_modules/@stable-harness/governance/dist/src/approval-queue.d.ts +2 -0
- package/node_modules/@stable-harness/governance/dist/src/approval-queue.js +1 -0
- package/node_modules/@stable-harness/governance/dist/src/index.d.ts +4 -0
- package/node_modules/@stable-harness/governance/dist/src/index.js +1 -0
- package/node_modules/@stable-harness/governance/dist/src/policy-engine.d.ts +2 -0
- package/node_modules/@stable-harness/governance/dist/src/policy-engine.js +1 -0
- package/node_modules/@stable-harness/governance/dist/src/skill-candidates.d.ts +2 -0
- package/node_modules/@stable-harness/governance/dist/src/skill-candidates.js +1 -0
- package/node_modules/@stable-harness/governance/dist/src/types.d.ts +101 -0
- package/node_modules/@stable-harness/governance/dist/src/types.js +1 -0
- package/node_modules/@stable-harness/governance/package.json +12 -0
- package/node_modules/@stable-harness/memory/dist/src/index.d.ts +9 -0
- package/node_modules/@stable-harness/memory/dist/src/index.js +1 -0
- package/node_modules/@stable-harness/memory/dist/src/langmem-service.d.ts +8 -0
- package/node_modules/@stable-harness/memory/dist/src/langmem-service.js +1 -0
- package/node_modules/@stable-harness/memory/dist/src/maintenance.d.ts +2 -0
- package/node_modules/@stable-harness/memory/dist/src/maintenance.js +1 -0
- package/node_modules/@stable-harness/memory/dist/src/persistence.d.ts +4 -0
- package/node_modules/@stable-harness/memory/dist/src/persistence.js +1 -0
- package/node_modules/@stable-harness/memory/dist/src/policy.d.ts +2 -0
- package/node_modules/@stable-harness/memory/dist/src/policy.js +1 -0
- package/node_modules/@stable-harness/memory/dist/src/provider.d.ts +50 -0
- package/node_modules/@stable-harness/memory/dist/src/provider.js +1 -0
- package/node_modules/@stable-harness/memory/dist/src/store.d.ts +5 -0
- package/node_modules/@stable-harness/memory/dist/src/store.js +1 -0
- package/node_modules/@stable-harness/memory/dist/src/types.d.ts +138 -0
- package/node_modules/@stable-harness/memory/dist/src/types.js +1 -0
- package/node_modules/@stable-harness/memory/package.json +12 -0
- package/node_modules/@stable-harness/protocols/dist/src/http-server.d.ts +3 -0
- package/node_modules/@stable-harness/protocols/dist/src/http-server.js +1 -0
- package/node_modules/@stable-harness/protocols/dist/src/in-process-client.d.ts +2 -0
- package/node_modules/@stable-harness/protocols/dist/src/in-process-client.js +1 -0
- package/node_modules/@stable-harness/protocols/dist/src/index.d.ts +4 -0
- package/node_modules/@stable-harness/protocols/dist/src/index.js +1 -0
- package/node_modules/@stable-harness/protocols/dist/src/openai-compatible.d.ts +9 -0
- package/node_modules/@stable-harness/protocols/dist/src/openai-compatible.js +1 -0
- package/node_modules/@stable-harness/protocols/dist/src/openai-payload.d.ts +74 -0
- package/node_modules/@stable-harness/protocols/dist/src/openai-payload.js +1 -0
- package/node_modules/@stable-harness/protocols/dist/src/openai-stream.d.ts +39 -0
- package/node_modules/@stable-harness/protocols/dist/src/openai-stream.js +1 -0
- package/node_modules/@stable-harness/protocols/package.json +15 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/argument-guard.d.ts +33 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/argument-guard.js +1 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/in-memory.d.ts +4 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/in-memory.js +1 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/index.d.ts +7 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/index.js +1 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/module-loader.d.ts +13 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/module-loader.js +1 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/schema-validation.d.ts +3 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/schema-validation.js +1 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/types.d.ts +79 -0
- package/node_modules/@stable-harness/tool-gateway/dist/src/types.js +1 -0
- package/node_modules/@stable-harness/tool-gateway/package.json +15 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/boundary-scan.d.ts +3 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/boundary-scan.js +1 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/discovery.d.ts +4 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/discovery.js +1 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/documents.d.ts +16 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/documents.js +1 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/evaluations.d.ts +9 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/evaluations.js +1 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/index.d.ts +1 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/index.js +1 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/loader.d.ts +2 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/loader.js +1 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/workflows.d.ts +16 -0
- package/node_modules/@stable-harness/workspace-yaml/dist/workflows.js +1 -0
- package/node_modules/@stable-harness/workspace-yaml/package.json +16 -0
- package/package.json +32 -10
- package/packages/adapter-deepagents/package.json +4 -6
- package/packages/adapter-langgraph/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/core/dist/quality/synthesis/fields.js +1 -1
- package/packages/core/dist/quality/synthesis.js +1 -1
- package/packages/core/package.json +1 -1
- package/packages/evaluation/package.json +1 -1
- package/packages/protocols/package.json +1 -1
- package/packages/tool-gateway/package.json +1 -1
- package/packages/workspace-yaml/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { CompiledWorkspace, RuntimeOutput, RuntimeToolGateway } from "../types.js";
|
|
2
|
+
export type WorkspaceWorkflow = {
|
|
3
|
+
id: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
sourcePath?: string;
|
|
6
|
+
adapter?: string;
|
|
7
|
+
entry?: string;
|
|
8
|
+
state?: WorkspaceWorkflowState;
|
|
9
|
+
nodes: WorkspaceWorkflowNode[];
|
|
10
|
+
edges: WorkspaceWorkflowEdge[];
|
|
11
|
+
policies?: Record<string, unknown>;
|
|
12
|
+
config?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
export type WorkspaceWorkflowState = {
|
|
15
|
+
schema?: string;
|
|
16
|
+
config?: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
export type WorkspaceWorkflowNode = {
|
|
19
|
+
id: string;
|
|
20
|
+
use: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
config?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
export type WorkspaceWorkflowEdge = {
|
|
25
|
+
from: string;
|
|
26
|
+
to: string;
|
|
27
|
+
condition?: string;
|
|
28
|
+
};
|
|
29
|
+
export type WorkspaceWorkflowRoutingPolicy = {
|
|
30
|
+
defaultWorkflowId?: string;
|
|
31
|
+
routes?: WorkspaceWorkflowRoute[];
|
|
32
|
+
};
|
|
33
|
+
export type WorkspaceWorkflowRoute = {
|
|
34
|
+
id: string;
|
|
35
|
+
workflowId: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
metadata?: Record<string, unknown>;
|
|
38
|
+
};
|
|
39
|
+
export type RuntimeWorkflowRequest = {
|
|
40
|
+
workflowId?: string;
|
|
41
|
+
routeId?: string;
|
|
42
|
+
input?: unknown;
|
|
43
|
+
metadata?: Record<string, unknown>;
|
|
44
|
+
};
|
|
45
|
+
export type RuntimeWorkflowAdapterInput = {
|
|
46
|
+
workspace: CompiledWorkspace;
|
|
47
|
+
workflow: WorkspaceWorkflow;
|
|
48
|
+
request: RuntimeWorkflowRequest;
|
|
49
|
+
requestId: string;
|
|
50
|
+
sessionId: string;
|
|
51
|
+
toolGateway?: RuntimeToolGateway;
|
|
52
|
+
emit: (event: unknown) => void;
|
|
53
|
+
};
|
|
54
|
+
export type RuntimeWorkflowAdapter = {
|
|
55
|
+
name: string;
|
|
56
|
+
run(input: RuntimeWorkflowAdapterInput): Promise<string | RuntimeOutput>;
|
|
57
|
+
};
|
|
58
|
+
export type WorkflowPlan = {
|
|
59
|
+
workflowId: string;
|
|
60
|
+
adapter?: string;
|
|
61
|
+
entry: string;
|
|
62
|
+
nodes: WorkspaceWorkflowNode[];
|
|
63
|
+
edges: WorkspaceWorkflowEdge[];
|
|
64
|
+
terminalNodes: string[];
|
|
65
|
+
unreachableNodes: string[];
|
|
66
|
+
cycles: string[][];
|
|
67
|
+
};
|
|
68
|
+
export declare function compileWorkflowPlan(workflow: WorkspaceWorkflow): WorkflowPlan;
|
|
69
|
+
export declare function renderWorkflowMermaid(workflow: WorkspaceWorkflow): string;
|
|
70
|
+
export declare function renderAgentMermaid(workspace: CompiledWorkspace, agentId: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function compileWorkflowPlan(e){const n=e.entry??e.nodes[0]?.id;if(!n)throw new Error(`Workflow ${e.id} has no entry node`);const t=function buildAdjacency(e){const n=new Map(e.nodes.map(e=>[e.id,[]]));for(const t of e.edges)n.get(t.from)?.push(t.to);return n}(e),o=function collectReachable(e,n){const t=new Set,o=[e];for(;o.length>0;){const e=o.pop();t.has(e)||(t.add(e),o.push(...n.get(e)??[]))}return t}(n,t),a=function findCycles(e,n){const t=[];for(const o of e)collectCycles(o,o,n,[],t);return function dedupeCycles(e){const n=new Set;return e.filter(e=>{const t=function canonicalCycleKey(e){const n=e.slice(0,-1);return n.map((e,t)=>[...n.slice(t),...n.slice(0,t)].join("|")).sort()[0]??""}(e);return!n.has(t)&&(n.add(t),!0)})}(t)}(e.nodes.map(e=>e.id),t);return{workflowId:e.id,...e.adapter?{adapter:e.adapter}:{},entry:n,nodes:e.nodes,edges:e.edges,terminalNodes:e.nodes.map(e=>e.id).filter(e=>0===(t.get(e)??[]).length),unreachableNodes:e.nodes.map(e=>e.id).filter(e=>!o.has(e)),cycles:a}}export function renderWorkflowMermaid(e){const n=["flowchart TD"];for(const t of e.nodes)n.push(` ${escapeId(t.id)}["${escapeLabel(`${t.id}\\n${t.use}`)}"]`);for(const t of e.edges){const e=t.condition?`|${escapeLabel(t.condition)}|`:"";n.push(` ${escapeId(t.from)} --\x3e${e} ${escapeId(t.to)}`)}return n.join("\n")}export function renderAgentMermaid(e,n){const t=e.agents.get(n);if(!t)throw new Error(`Agent is not defined: ${n}`);const o=function agentGraphNodes(e){return[...e.subagents.map(e=>agentGraphNode("agent",e)),...(e.skills??[]).map(e=>agentGraphNode("skill",e)),...e.tools.map(e=>agentGraphNode("tool",e))]}(t),a=["flowchart TD",` START_${escapeId(t.id)}([START])`,` END_${escapeId(t.id)}([END])`];for(const e of o)a.push(` ${e.diagramId}["${escapeLabel(`${e.id}\\n${e.label}`)}"]`);return 0===o.length?(a.push(` START_${escapeId(t.id)} --\x3e END_${escapeId(t.id)}`),a.join("\n")):[...a,...t.edges?.length?explicitAgentMermaidEdges(t,o):inventoryAgentMermaidEdges(t,o)].join("\n")}function agentGraphNode(e,n){return{id:n,diagramId:`${e}_${escapeId(n)}`,label:`${e}: ${n}`}}function explicitAgentMermaidEdges(e,n){const t=new Map(n.map(e=>[e.id,e.diagramId])),o=new Set((e.edges??[]).map(e=>e.to)),a=new Set((e.edges??[]).map(e=>e.from)),d=n.filter(e=>!o.has(e.id)).map(e=>e.diagramId),r=n.filter(e=>!a.has(e.id)).map(e=>e.diagramId);return[...d.map(n=>` START_${escapeId(e.id)} --\x3e ${escapeId(n)}`),...(e.edges??[]).flatMap(e=>function renderAgentEdge(e,n){const t=n.get(e.from),o=n.get(e.to);return t&&o?[` ${t} --\x3e${e.condition?`|${escapeLabel(e.condition)}|`:""} ${o}`]:[]}(e,t)),...r.map(n=>` ${escapeId(n)} --\x3e END_${escapeId(e.id)}`)]}function inventoryAgentMermaidEdges(e,n){return n.flatMap(n=>[` START_${escapeId(e.id)} -. available .-> ${n.diagramId}`,` ${n.diagramId} -.-> END_${escapeId(e.id)}`])}function collectCycles(e,n,t,o,a){const d=[...o,n];for(const r of t.get(n)??[])r===e?a.push([...d,e]):o.includes(r)||collectCycles(e,r,t,d,a)}function escapeId(e){return e.replace(/[^A-Za-z0-9_]/gu,"_")}function escapeLabel(e){return e.replace(/"/gu,'\\"')}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CompiledWorkspace, RuntimeEvent, RuntimeOutput } from "../types.js";
|
|
2
|
+
import type { RuntimeWorkflowAdapter, RuntimeWorkflowAdapterInput, RuntimeWorkflowRequest } from "./index.js";
|
|
3
|
+
export declare function runWorkflowRequest(input: {
|
|
4
|
+
workspace: CompiledWorkspace;
|
|
5
|
+
adapters: RuntimeWorkflowAdapter[];
|
|
6
|
+
toolGateway?: RuntimeWorkflowAdapterInput["toolGateway"];
|
|
7
|
+
request: RuntimeWorkflowRequest;
|
|
8
|
+
requestId: string;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
agentId: string;
|
|
11
|
+
emit: (event: RuntimeEvent) => void;
|
|
12
|
+
}): Promise<RuntimeOutput>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{repairRuntimeSelection as e}from"../runtime/selection-repair.js";export async function runWorkflowRequest(o){const r=await async function resolveWorkflow(o,r,t){const n=r.routeId?await async function resolveWorkflowRouteId(o,r,t){const n=o.runtime.workflowRouting?.routes??[];if(n.some(e=>e.id===r))return r;const i=await e({id:r,candidates:n.map(e=>({id:e.id,description:e.description,metadata:e.metadata})),trace:{...t,layer:"workflow_route",owner:"stable_runtime_policy"}});return i.ok?i.id:r}(o,r.routeId,t):void 0,i=n?o.runtime.workflowRouting?.routes?.find(e=>e.id===n):void 0;if(r.routeId&&!i)throw new Error(`Workflow route is not defined: ${r.routeId}`);const s=(r.workflowId?await async function resolveWorkflowId(o,r,t){if(o.workflows.has(r))return r;const n=await e({id:r,candidates:[...o.workflows.values()].map(e=>({id:e.id,description:e.description})),trace:{...t,layer:"workflow",owner:"stable_runtime_policy"}});return n.ok?n.id:r}(o,r.workflowId,t):void 0)??i?.workflowId??o.runtime.workflowRouting?.defaultWorkflowId;if(!s)throw new Error("Workflow request requires workflowId, routeId, or runtime.workflowRouting.defaultWorkflowId");const d=o.workflows.get(s);if(!d)throw new Error(`Workflow is not defined: ${s}`);return d}(o.workspace,o.request,o),t=function resolveWorkflowAdapter(e,o){const r=o?e.find(e=>e.name===o):e[0];if(!r)throw new Error("No workflow adapter is configured"+(o?` for ${o}`:""));return r}(o.adapters,r.adapter);o.emit({type:"runtime.workflow.started",requestId:o.requestId,sessionId:o.sessionId,agentId:o.agentId,adapter:t.name,workflowId:r.id});const n=await t.run({workspace:o.workspace,workflow:r,request:o.request,requestId:o.requestId,sessionId:o.sessionId,toolGateway:o.toolGateway,emit:e=>o.emit({type:"runtime.adapter.event",requestId:o.requestId,sessionId:o.sessionId,agentId:o.agentId,event:e})});return o.emit({type:"runtime.workflow.completed",requestId:o.requestId,sessionId:o.sessionId,agentId:o.agentId,adapter:t.name,workflowId:r.id}),"string"==typeof n?{text:n}:n}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CompiledWorkspace } from "./types.js";
|
|
2
|
+
export type WorkspaceToolQualityDiagnosticCode = "missing-description" | "weak-description" | "missing-schema" | "missing-output-contract" | "missing-permission-metadata" | "overlapping-description";
|
|
3
|
+
export type WorkspaceToolQualitySeverity = "error" | "warning";
|
|
4
|
+
export type WorkspaceToolQualityDiagnostic = {
|
|
5
|
+
code: WorkspaceToolQualityDiagnosticCode;
|
|
6
|
+
layer: "tool";
|
|
7
|
+
owner: "stable_runtime_policy" | "workspace_config";
|
|
8
|
+
resources: string[];
|
|
9
|
+
severity: WorkspaceToolQualitySeverity;
|
|
10
|
+
message: string;
|
|
11
|
+
locations: string[];
|
|
12
|
+
details?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
export type WorkspaceToolQualityPolicy = {
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
requireSchema?: boolean;
|
|
17
|
+
requireOutputContract?: boolean;
|
|
18
|
+
requirePermissionMetadata?: boolean;
|
|
19
|
+
failOn?: Partial<Record<WorkspaceToolQualityDiagnosticCode, boolean>>;
|
|
20
|
+
};
|
|
21
|
+
export declare function scanWorkspaceToolQuality(workspace: CompiledWorkspace, policy?: WorkspaceToolQualityPolicy): WorkspaceToolQualityDiagnostic[];
|
|
22
|
+
export declare function assertWorkspaceToolQualityDiagnostics(diagnostics: WorkspaceToolQualityDiagnostic[]): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function scanWorkspaceToolQuality(t,e={}){if(!1===e.enabled)return[];const o=[...t.tools.values()].flatMap(t=>function scanTool(t,e){const o=[],i=t.description?.trim()??"";return i?function isWeakDescription(t,e){const o=t.replace(/[_-]+/gu," ").toLowerCase(),i=e.replace(/[_-]+/gu," ").toLowerCase();return i.length<24||i===o}(t.id,i)&&o.push(diagnostic(t,"weak-description","Tool description is too short or repeats only the tool id.",e)):o.push(diagnostic(t,"missing-description","Tool is missing a description.",e)),!0===e.requireSchema&&void 0===t.schema&&o.push(diagnostic(t,"missing-schema","Tool is missing an input schema.",e)),!0!==e.requireOutputContract||void 0!==t.outputSchema||hasMetadata(t,"outputContract")||o.push(diagnostic(t,"missing-output-contract","Tool is missing output contract metadata.",e)),!0!==e.requirePermissionMetadata||hasMetadata(t,"permissions")||o.push(diagnostic(t,"missing-permission-metadata","Tool is missing permission metadata.",e)),o}(t,e));return[...o,...scanOverlaps([...t.tools.values()])]}export function assertWorkspaceToolQualityDiagnostics(t){const e=t.filter(t=>"error"===t.severity);if(0!==e.length)throw new Error(`Workspace tool quality gate failed:\n${e.map(formatDiagnostic).join("\n")}`)}function scanOverlaps(t){const e=[];for(let o=0;o<t.length;o+=1)for(let i=o+1;i<t.length;i+=1){const s=t[o],n=t[i],a=descriptionOverlap(s.description,n.description);a<.8||e.push({code:"overlapping-description",layer:"tool",owner:"workspace_config",resources:[s.id,n.id],severity:"warning",message:`Tools ${s.id} and ${n.id} have highly overlapping descriptions; add explicit selection boundaries.`,locations:[s.sourcePath,n.sourcePath].filter(isString),details:{score:a}})}return e}function diagnostic(t,e,o,i){return{code:e,layer:"tool",owner:"workspace_config",resources:[t.id],severity:!0===i.failOn?.[e]?"error":"warning",message:o,locations:t.sourcePath?[t.sourcePath]:[]}}function descriptionOverlap(t,e){const o=tokenSet(t),i=tokenSet(e);return o.size<4||i.size<4?0:[...o].filter(t=>i.has(t)).length/Math.min(o.size,i.size)}function tokenSet(t){return new Set((t??"").toLowerCase().split(/[^a-z0-9]+/u).filter(t=>t.length>2))}function hasMetadata(t,e){return"object"==typeof t.metadata&&null!==t.metadata&&!Array.isArray(t.metadata)&&void 0!==t.metadata[e]}function formatDiagnostic(t){return`- ${t.code}: ${t.message} (${t.resources.join(", ")})`}function isString(t){return"string"==typeof t&&t.length>0}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { WorkspaceEvaluation } from "../evaluations/index.js";
|
|
2
|
+
import type { WorkspaceSpecDrivenWorkflowPolicy } from "../spec-driven/index.js";
|
|
3
|
+
import type { WorkspaceWorkflow, WorkspaceWorkflowEdge, WorkspaceWorkflowRoutingPolicy } from "../workflows/index.js";
|
|
4
|
+
import type { WorkspaceToolQualityDiagnostic, WorkspaceToolQualityPolicy } from "./tool-quality.js";
|
|
5
|
+
export type WorkspaceModel = {
|
|
6
|
+
id: string;
|
|
7
|
+
provider: string;
|
|
8
|
+
model: string;
|
|
9
|
+
config?: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export type WorkspaceTool = {
|
|
12
|
+
id: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
schema?: unknown;
|
|
15
|
+
outputSchema?: unknown;
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
implementation?: string;
|
|
18
|
+
sourcePath?: string;
|
|
19
|
+
};
|
|
20
|
+
export type WorkspaceSkill = {
|
|
21
|
+
id: string;
|
|
22
|
+
path: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
allowedTools: string[];
|
|
25
|
+
};
|
|
26
|
+
export type WorkspaceMemory = {
|
|
27
|
+
id: string;
|
|
28
|
+
provider: string;
|
|
29
|
+
profile?: string;
|
|
30
|
+
mode?: string;
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
prompts?: {
|
|
33
|
+
semantic?: string;
|
|
34
|
+
episodic?: string;
|
|
35
|
+
procedural?: string;
|
|
36
|
+
};
|
|
37
|
+
config?: Record<string, unknown>;
|
|
38
|
+
};
|
|
39
|
+
export type WorkspaceAgent = {
|
|
40
|
+
id: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
sourcePath?: string;
|
|
43
|
+
backend: string;
|
|
44
|
+
modelRef?: string;
|
|
45
|
+
systemPrompt?: string;
|
|
46
|
+
tools: string[];
|
|
47
|
+
skills?: string[];
|
|
48
|
+
memory?: unknown[];
|
|
49
|
+
subagents: string[];
|
|
50
|
+
edges?: WorkspaceWorkflowEdge[];
|
|
51
|
+
config: Record<string, unknown>;
|
|
52
|
+
};
|
|
53
|
+
export type WorkspaceRuntimePolicy = {
|
|
54
|
+
defaultAgentId: string;
|
|
55
|
+
routes?: WorkspaceAgentRoute[];
|
|
56
|
+
workspaceId?: string;
|
|
57
|
+
profile?: string;
|
|
58
|
+
workspaceValidation?: WorkspaceValidationPolicy;
|
|
59
|
+
adapters?: WorkspaceAdapterPolicy[];
|
|
60
|
+
workflowRouting?: WorkspaceWorkflowRoutingPolicy;
|
|
61
|
+
specDrivenWorkflow?: WorkspaceSpecDrivenWorkflowPolicy;
|
|
62
|
+
approvals?: Record<string, unknown>;
|
|
63
|
+
recovery?: Record<string, unknown>;
|
|
64
|
+
retry?: WorkspaceRetryPolicy;
|
|
65
|
+
toolGateway?: Record<string, unknown>;
|
|
66
|
+
sandbox?: Record<string, unknown>;
|
|
67
|
+
memory?: Record<string, unknown>;
|
|
68
|
+
protocols?: Record<string, unknown>;
|
|
69
|
+
progress?: Record<string, unknown>;
|
|
70
|
+
cli?: Record<string, unknown>;
|
|
71
|
+
quality?: string | Record<string, unknown>;
|
|
72
|
+
responseLanguage?: Record<string, unknown>;
|
|
73
|
+
responsePresentation?: Record<string, unknown>;
|
|
74
|
+
};
|
|
75
|
+
export type WorkspaceAgentRoute = {
|
|
76
|
+
id: string;
|
|
77
|
+
agentId: string;
|
|
78
|
+
keywords?: string[];
|
|
79
|
+
pattern?: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
};
|
|
82
|
+
export type WorkspaceValidationPolicy = {
|
|
83
|
+
boundaryScan?: WorkspaceBoundaryScanPolicy;
|
|
84
|
+
toolQuality?: WorkspaceToolQualityPolicy;
|
|
85
|
+
};
|
|
86
|
+
export type WorkspaceBoundaryScanPolicy = {
|
|
87
|
+
enabled?: boolean;
|
|
88
|
+
failOn?: Partial<Record<WorkspaceBoundaryDiagnosticCode, boolean>>;
|
|
89
|
+
};
|
|
90
|
+
export type WorkspaceBoundaryDiagnosticCode = "duplicate-scope" | "hardcoded-sibling-routing" | "broad-fallback-scope" | "weak-positive-boundary" | "possible-sibling-overlap";
|
|
91
|
+
export type WorkspaceBoundaryDiagnostic = {
|
|
92
|
+
code: WorkspaceBoundaryDiagnosticCode;
|
|
93
|
+
layer: "subagent" | "skill" | "tool";
|
|
94
|
+
resources: string[];
|
|
95
|
+
severity: "error" | "warning";
|
|
96
|
+
message: string;
|
|
97
|
+
locations: string[];
|
|
98
|
+
details?: Record<string, unknown>;
|
|
99
|
+
};
|
|
100
|
+
export type WorkspaceAdapterPolicy = {
|
|
101
|
+
name: string;
|
|
102
|
+
enabled?: boolean;
|
|
103
|
+
config?: Record<string, unknown>;
|
|
104
|
+
};
|
|
105
|
+
export type WorkspaceRetryPolicy = {
|
|
106
|
+
model?: WorkspaceRetryTargetPolicy;
|
|
107
|
+
tools?: WorkspaceToolRetryPolicy;
|
|
108
|
+
};
|
|
109
|
+
export type WorkspaceRetryTargetPolicy = {
|
|
110
|
+
enabled?: boolean;
|
|
111
|
+
maxRetries?: number;
|
|
112
|
+
retryOn?: WorkspaceRetryReason[];
|
|
113
|
+
backoffFactor?: number;
|
|
114
|
+
initialDelayMs?: number;
|
|
115
|
+
maxDelayMs?: number;
|
|
116
|
+
jitter?: boolean;
|
|
117
|
+
onFailure?: "continue" | "error";
|
|
118
|
+
};
|
|
119
|
+
export type WorkspaceToolRetryPolicy = WorkspaceRetryTargetPolicy & {
|
|
120
|
+
tools?: string[];
|
|
121
|
+
};
|
|
122
|
+
export type WorkspaceRetryReason = "timeout" | "network" | "rateLimit" | "serverError";
|
|
123
|
+
export type CompiledWorkspace = {
|
|
124
|
+
root: string;
|
|
125
|
+
runtime: WorkspaceRuntimePolicy;
|
|
126
|
+
agents: Map<string, WorkspaceAgent>;
|
|
127
|
+
models: Map<string, WorkspaceModel>;
|
|
128
|
+
tools: Map<string, WorkspaceTool>;
|
|
129
|
+
skills: Map<string, WorkspaceSkill>;
|
|
130
|
+
memories: Map<string, WorkspaceMemory>;
|
|
131
|
+
workflows: Map<string, WorkspaceWorkflow>;
|
|
132
|
+
evaluations?: Map<string, WorkspaceEvaluation>;
|
|
133
|
+
diagnostics?: Array<WorkspaceBoundaryDiagnostic | WorkspaceToolQualityDiagnostic>;
|
|
134
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stable-harness/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist/**/*.js",
|
|
7
|
+
"dist/**/*.d.ts",
|
|
8
|
+
"package.json"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@botbotgo/better-call": "^0.1.58",
|
|
15
|
+
"@stable-harness/governance": "0.0.1",
|
|
16
|
+
"@stable-harness/memory": "0.0.1"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{randomUUID as e}from"node:crypto";export function createInMemoryApprovalQueue(){const t=[];return{async create(n){const s={id:e(),kind:n.kind,reason:n.reason,status:"pending",requestId:n.requestId,sessionId:n.sessionId,agentId:n.agentId,subject:n.subject,createdAt:(new Date).toISOString()};return t.push(s),s},get:async e=>t.find(t=>t.id===e),list:async e=>e?t.filter(t=>t.status===e):[...t],async resolve(e,n){const s=t.find(t=>t.id===e);if(s)return s.status=n,s.resolvedAt=(new Date).toISOString(),s}}}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createInMemoryApprovalQueue } from "./approval-queue.js";
|
|
2
|
+
export { createPolicyEngine } from "./policy-engine.js";
|
|
3
|
+
export { createSqliteSkillCandidateStore } from "./skill-candidates.js";
|
|
4
|
+
export type { ApprovalQueue, ApprovalRequest, ApprovalRequestKind, ApprovalRequestStatus, PolicyDecision, RuntimePolicyEngine, SkillCandidate, SkillCandidateEvidence, SkillCandidateInput, SkillCandidateStatus, SkillCandidateStore, ToolPolicy, } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{createInMemoryApprovalQueue}from"./approval-queue.js";export{createPolicyEngine}from"./policy-engine.js";export{createSqliteSkillCandidateStore}from"./skill-candidates.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function createPolicyEngine(o={}){const e=new Set(o.approvalRequiredToolIds??[]),l=o.sandboxByToolId??{};return{evaluateTool:o=>e.has(o.toolId)?{action:"require_approval",reason:`Tool '${o.toolId}' requires explicit approval.`}:{action:"allow",reason:`Tool '${o.toolId}' is allowed by configured policy.`},resolveSandbox:o=>l[o.toolId]??o.defaultSandbox??"default"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{randomUUID as e}from"node:crypto";import{mkdirSync as t}from"node:fs";import n from"node:path";import{DatabaseSync as a}from"node:sqlite";export function createSqliteSkillCandidateStore(d){t(n.dirname(d),{recursive:!0});const r=new a(d);return function init(e){e.exec("\n create table if not exists skill_candidates (\n id text primary key, workspace_id text not null, name text not null,\n status text not null, confidence real not null, evidence_count integer not null,\n proposed_path text, title text not null, summary text not null,\n draft_markdown text not null, created_at text not null, updated_at text not null,\n reviewed_at text, reviewed_by text, rejection_reason text,\n unique(workspace_id, name)\n );\n create table if not exists skill_candidate_evidence (\n id text primary key, candidate_id text not null, evidence_type text not null,\n evidence_ref text not null, summary text, weight real, created_at text not null,\n foreign key(candidate_id) references skill_candidates(id)\n );\n ")}(r),{async upsert(t){const n=(new Date).toISOString(),a=function findByName(e,t,n){const a=e.prepare("select * from skill_candidates where workspace_id = ? and name = ?").get(t,n);return a?rowToCandidate(a):void 0}(r,t.workspaceId,t.name),d=a?function updateCandidate(e,t,n,a){return e.prepare("\n update skill_candidates\n set status = ?, confidence = ?, evidence_count = ?, proposed_path = ?,\n title = ?, summary = ?, draft_markdown = ?, updated_at = ?\n where id = ?\n ").run(n.status??"review_required",n.confidence,n.evidence.length,n.proposedPath??null,n.title,n.summary,n.draftMarkdown,a,t),readCandidate(e,t)}(r,a.id,t,n):function insertCandidate(t,n,a){const d=String(e());return t.prepare("\n insert into skill_candidates\n (id, workspace_id, name, status, confidence, evidence_count, proposed_path,\n title, summary, draft_markdown, created_at, updated_at)\n values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ").run(d,n.workspaceId,n.name,n.status??"review_required",n.confidence,n.evidence.length,n.proposedPath??null,n.title,n.summary,n.draftMarkdown,a,a),readCandidate(t,d)}(r,t,n);return function replaceEvidence(t,n,a,d){t.prepare("delete from skill_candidate_evidence where candidate_id = ?").run(n);const r=t.prepare("\n insert into skill_candidate_evidence\n (id, candidate_id, evidence_type, evidence_ref, summary, weight, created_at)\n values (?, ?, ?, ?, ?, ?, ?)\n ");for(const t of a)r.run(String(e()),n,t.evidenceType,t.evidenceRef,t.summary??null,t.weight??null,d)}(r,d.id,t.evidence,n),d},list:async(e={})=>function listCandidates(e,t,n){return(t&&n?e.prepare("select * from skill_candidates where workspace_id = ? and status = ? order by updated_at desc").all(t,n):t?e.prepare("select * from skill_candidates where workspace_id = ? order by updated_at desc").all(t):e.prepare("select * from skill_candidates order by updated_at desc").all()).map(e=>rowToCandidate(e))}(r,e.workspaceId,e.status),get:async e=>readCandidate(r,e),listEvidence:async e=>function listEvidence(e,t){return e.prepare("select * from skill_candidate_evidence where candidate_id = ? order by created_at asc").all(t).map(e=>function rowToEvidence(e){return{id:String(e.id),candidateId:String(e.candidate_id),evidenceType:e.evidence_type,evidenceRef:String(e.evidence_ref),summary:readOptionalString(e.summary),weight:"number"==typeof e.weight?e.weight:void 0,createdAt:String(e.created_at)}}(e))}(r,e),async updateStatus(e){const t=(new Date).toISOString();return r.prepare("\n update skill_candidates\n set status = ?, reviewed_at = ?, reviewed_by = ?, rejection_reason = ?, updated_at = ?\n where id = ?\n ").run(e.status,t,e.reviewedBy??null,e.rejectionReason??null,t,e.id),readCandidate(r,e.id)}}}function readCandidate(e,t){const n=e.prepare("select * from skill_candidates where id = ?").get(t);return n?rowToCandidate(n):void 0}function rowToCandidate(e){return{id:String(e.id),workspaceId:String(e.workspace_id),name:String(e.name),status:e.status,confidence:Number(e.confidence),evidenceCount:Number(e.evidence_count),proposedPath:readOptionalString(e.proposed_path),title:String(e.title),summary:String(e.summary),draftMarkdown:String(e.draft_markdown),createdAt:String(e.created_at),updatedAt:String(e.updated_at),reviewedAt:readOptionalString(e.reviewed_at),reviewedBy:readOptionalString(e.reviewed_by),rejectionReason:readOptionalString(e.rejection_reason)}}function readOptionalString(e){return"string"==typeof e&&e?e:void 0}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export type PolicyDecision = {
|
|
2
|
+
action: "allow";
|
|
3
|
+
reason: string;
|
|
4
|
+
} | {
|
|
5
|
+
action: "require_approval";
|
|
6
|
+
reason: string;
|
|
7
|
+
};
|
|
8
|
+
export type ToolPolicy = {
|
|
9
|
+
approvalRequiredToolIds?: string[];
|
|
10
|
+
sandboxByToolId?: Record<string, string>;
|
|
11
|
+
};
|
|
12
|
+
export type RuntimePolicyEngine = {
|
|
13
|
+
evaluateTool(input: {
|
|
14
|
+
toolId: string;
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
}): PolicyDecision;
|
|
17
|
+
resolveSandbox(input: {
|
|
18
|
+
toolId: string;
|
|
19
|
+
defaultSandbox?: string;
|
|
20
|
+
}): string;
|
|
21
|
+
};
|
|
22
|
+
export type ApprovalRequestKind = "tool_invocation" | "memory_write" | "skill_candidate";
|
|
23
|
+
export type ApprovalRequestStatus = "pending" | "approved" | "rejected";
|
|
24
|
+
export type ApprovalRequest = {
|
|
25
|
+
id: string;
|
|
26
|
+
kind: ApprovalRequestKind;
|
|
27
|
+
reason: string;
|
|
28
|
+
status: ApprovalRequestStatus;
|
|
29
|
+
requestId?: string;
|
|
30
|
+
sessionId?: string;
|
|
31
|
+
agentId?: string;
|
|
32
|
+
subject: Record<string, unknown>;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
resolvedAt?: string;
|
|
35
|
+
};
|
|
36
|
+
export type ApprovalQueue = {
|
|
37
|
+
create(input: {
|
|
38
|
+
kind: ApprovalRequestKind;
|
|
39
|
+
reason: string;
|
|
40
|
+
requestId?: string;
|
|
41
|
+
sessionId?: string;
|
|
42
|
+
agentId?: string;
|
|
43
|
+
subject: Record<string, unknown>;
|
|
44
|
+
}): Promise<ApprovalRequest>;
|
|
45
|
+
get(id: string): Promise<ApprovalRequest | undefined>;
|
|
46
|
+
list(status?: ApprovalRequestStatus): Promise<ApprovalRequest[]>;
|
|
47
|
+
resolve(id: string, status: Exclude<ApprovalRequestStatus, "pending">): Promise<ApprovalRequest | undefined>;
|
|
48
|
+
};
|
|
49
|
+
export type SkillCandidateStatus = "observed" | "candidate" | "review_required" | "approved" | "rejected" | "drafted" | "enabled" | "deprecated";
|
|
50
|
+
export type SkillCandidate = {
|
|
51
|
+
id: string;
|
|
52
|
+
workspaceId: string;
|
|
53
|
+
name: string;
|
|
54
|
+
status: SkillCandidateStatus;
|
|
55
|
+
confidence: number;
|
|
56
|
+
evidenceCount: number;
|
|
57
|
+
proposedPath?: string;
|
|
58
|
+
title: string;
|
|
59
|
+
summary: string;
|
|
60
|
+
draftMarkdown: string;
|
|
61
|
+
createdAt: string;
|
|
62
|
+
updatedAt: string;
|
|
63
|
+
reviewedAt?: string;
|
|
64
|
+
reviewedBy?: string;
|
|
65
|
+
rejectionReason?: string;
|
|
66
|
+
};
|
|
67
|
+
export type SkillCandidateEvidence = {
|
|
68
|
+
id: string;
|
|
69
|
+
candidateId: string;
|
|
70
|
+
evidenceType: "memory_record" | "memory_file" | "run" | "tool_event" | "validation" | "user_correction";
|
|
71
|
+
evidenceRef: string;
|
|
72
|
+
summary?: string;
|
|
73
|
+
weight?: number;
|
|
74
|
+
createdAt: string;
|
|
75
|
+
};
|
|
76
|
+
export type SkillCandidateInput = {
|
|
77
|
+
workspaceId: string;
|
|
78
|
+
name: string;
|
|
79
|
+
status?: SkillCandidateStatus;
|
|
80
|
+
confidence: number;
|
|
81
|
+
proposedPath?: string;
|
|
82
|
+
title: string;
|
|
83
|
+
summary: string;
|
|
84
|
+
draftMarkdown: string;
|
|
85
|
+
evidence: Array<Omit<SkillCandidateEvidence, "id" | "candidateId" | "createdAt">>;
|
|
86
|
+
};
|
|
87
|
+
export type SkillCandidateStore = {
|
|
88
|
+
upsert(input: SkillCandidateInput): Promise<SkillCandidate>;
|
|
89
|
+
list(filter?: {
|
|
90
|
+
workspaceId?: string;
|
|
91
|
+
status?: SkillCandidateStatus;
|
|
92
|
+
}): Promise<SkillCandidate[]>;
|
|
93
|
+
get(id: string): Promise<SkillCandidate | undefined>;
|
|
94
|
+
listEvidence(candidateId: string): Promise<SkillCandidateEvidence[]>;
|
|
95
|
+
updateStatus(input: {
|
|
96
|
+
id: string;
|
|
97
|
+
status: SkillCandidateStatus;
|
|
98
|
+
reviewedBy?: string;
|
|
99
|
+
rejectionReason?: string;
|
|
100
|
+
}): Promise<SkillCandidate | undefined>;
|
|
101
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { applyMemoryMaintenance } from "./maintenance.js";
|
|
2
|
+
export { createEmbeddedMemoryProvider, } from "./provider.js";
|
|
3
|
+
export { createLangMemServiceProvider, } from "./langmem-service.js";
|
|
4
|
+
export type { LangMemServiceProviderOptions, } from "./langmem-service.js";
|
|
5
|
+
export type { MemoryProvider, MemoryProviderApprovalConfig, MemoryProviderConfig, MemoryProviderConsolidateInput, MemoryProviderDefaults, MemoryProviderMode, MemoryProviderProposeInput, MemoryProviderSearchInput, MemoryProviderTypeConfig, } from "./provider.js";
|
|
6
|
+
export { cloneRecords, createInMemoryMemoryPersistenceAdapter, createMemorySnapshot, } from "./persistence.js";
|
|
7
|
+
export { createDefaultMemoryPolicy } from "./policy.js";
|
|
8
|
+
export { createInMemoryRuntimeMemoryStore } from "./store.js";
|
|
9
|
+
export type { ListMemoriesInput, MemorizeInput, MemoryCandidate, MemoryDecision, MemoryDecisionAction, MemoryKind, MemoryMaintenanceAction, MemoryMaintenanceOperation, MemoryMaintenanceResult, MemoryPolicy, MemoryPersistenceAdapter, MemoryRecallResult, MemoryRecord, MemoryRecordStatus, MemoryScope, MemorySensitivity, MemoryStoreSnapshot, MemorySubmitResult, RecallInput, RuntimeMemoryStore, UpdateMemoryInput, } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{applyMemoryMaintenance}from"./maintenance.js";export{createEmbeddedMemoryProvider}from"./provider.js";export{createLangMemServiceProvider}from"./langmem-service.js";export{cloneRecords,createInMemoryMemoryPersistenceAdapter,createMemorySnapshot}from"./persistence.js";export{createDefaultMemoryPolicy}from"./policy.js";export{createInMemoryRuntimeMemoryStore}from"./store.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MemoryProvider, MemoryProviderConfig } from "./provider.js";
|
|
2
|
+
export type LangMemServiceProviderOptions = {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
config?: MemoryProviderConfig;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function createLangMemServiceProvider(options: LangMemServiceProviderOptions): MemoryProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function createLangMemServiceProvider(e){const n=function normalizeBaseUrl(e){return e.replace(/\/+$/u,"")}(e.baseUrl),t={...e.config,provider:"langmem-service"};return{name:"langmem-service",config:t,propose:async o=>(await postJson(n,"/memory/propose",{...o,config:t},e)).candidates??[],async search(o){const r=await(o.store?.list({namespace:o.namespace,kinds:o.kinds}))??[];return(await postJson(n,"/memory/search",{...withoutStore(o),records:r,config:t},e)).records??[]},consolidate:async o=>(await postJson(n,"/memory/consolidate",{...o,config:t},e)).operations??[]}}async function postJson(e,n,t,o){const r=new AbortController,a=setTimeout(()=>r.abort(),o.timeoutMs??3e4);try{const a=await fetch(`${e}${n}`,{method:"POST",headers:{"content-type":"application/json",...o.headers},body:JSON.stringify(t),signal:r.signal});return await async function readResponse(e,n){const t=await e.text();if(!e.ok)throw new Error(`LangMem service ${n} failed with ${e.status}: ${t}`);return t?JSON.parse(t):{}}(a,n)}finally{clearTimeout(a)}}function withoutStore(e){return{namespace:e.namespace,query:e.query,limit:e.limit,kinds:e.kinds,records:[]}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export async function applyMemoryMaintenance(a,e){const t=[];for(const n of e)t.push(await applyOperation(a,n));return t}async function applyOperation(a,e){return"archive"===e.action?result(e,await a.archive(e.recordId,e.reason)):"mark_stale"===e.action?result(e,await a.update({id:e.recordId,status:"stale",metadata:{maintenanceReason:e.reason}})):"refresh"===e.action?result(e,await a.update({id:e.recordId,status:"active",metadata:{maintenanceReason:e.reason}})):result(e,await a.update({id:e.recordId,status:"archived",metadata:{maintenanceReason:e.reason,supersededBy:e.replacementRecordId}}))}function result(a,e){return{operation:a,record:e,applied:Boolean(e),reason:e?a.reason:"record not found"}}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ListMemoriesInput, MemoryPersistenceAdapter, MemoryRecord, MemoryStoreSnapshot, RuntimeMemoryStore } from "./types.js";
|
|
2
|
+
export declare function createMemorySnapshot(store: RuntimeMemoryStore, input: ListMemoriesInput): Promise<MemoryStoreSnapshot>;
|
|
3
|
+
export declare function createInMemoryMemoryPersistenceAdapter(): MemoryPersistenceAdapter;
|
|
4
|
+
export declare function cloneRecords(records: MemoryRecord[]): MemoryRecord[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export async function createMemorySnapshot(e,t){return{namespace:t.namespace,records:await e.list(t),exportedAt:(new Date).toISOString()}}export function createInMemoryMemoryPersistenceAdapter(){const e=new Map;return{load:async t=>cloneRecords(e.get(t)??[]),async save(t){e.set(t.namespace,cloneRecords(t.records))}}}export function cloneRecords(e){return e.map(e=>({...e,sourceRefs:[...e.sourceRefs],tags:[...e.tags],metadata:{...e.metadata},provenance:{...e.provenance},supersedes:[...e.supersedes],conflictsWith:[...e.conflictsWith]}))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function createDefaultMemoryPolicy(){return{decide:e=>e.noStore?{action:"reject",reason:"candidate marked noStore",reviewRequired:!1}:e.content.trim()?"sensitive"===e.sensitivity||"restricted"===e.sensitivity?{action:"review",reason:"sensitive memory requires operator approval",kind:e.kindHint??"semantic",scope:e.scopeHint??"workspace",confidence:normalizeConfidence(e.confidenceHint),reviewRequired:!0}:{action:"store",reason:"candidate accepted by default runtime policy",kind:e.kindHint??"semantic",scope:e.scopeHint??"workspace",confidence:normalizeConfidence(e.confidenceHint),retrievalPriority:0,reviewRequired:!1}:{action:"reject",reason:"candidate content is empty",reviewRequired:!1}}}function normalizeConfidence(e){return void 0===e||Number.isNaN(e)?.6:Math.min(1,Math.max(0,e))}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { MemoryCandidate, MemoryKind, MemoryMaintenanceOperation, MemoryRecord, MemoryScope, MemorySensitivity, RuntimeMemoryStore } from "./types.js";
|
|
2
|
+
export type MemoryProviderMode = {
|
|
3
|
+
hotPathTools?: boolean;
|
|
4
|
+
backgroundManager?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type MemoryProviderTypeConfig = Partial<Record<MemoryKind, boolean>>;
|
|
7
|
+
export type MemoryProviderApprovalConfig = {
|
|
8
|
+
procedural?: boolean;
|
|
9
|
+
sensitive?: boolean;
|
|
10
|
+
restricted?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type MemoryProviderDefaults = {
|
|
13
|
+
scope?: MemoryScope;
|
|
14
|
+
sensitivity?: MemorySensitivity;
|
|
15
|
+
};
|
|
16
|
+
export type MemoryProviderConfig = {
|
|
17
|
+
provider?: "embedded" | "langmem-service" | "custom";
|
|
18
|
+
mode?: MemoryProviderMode;
|
|
19
|
+
types?: MemoryProviderTypeConfig;
|
|
20
|
+
approval?: MemoryProviderApprovalConfig;
|
|
21
|
+
defaults?: MemoryProviderDefaults;
|
|
22
|
+
};
|
|
23
|
+
export type MemoryProviderProposeInput = {
|
|
24
|
+
namespace: string;
|
|
25
|
+
content: string;
|
|
26
|
+
sourceType?: string;
|
|
27
|
+
sourceRef?: string;
|
|
28
|
+
kindHint?: MemoryKind;
|
|
29
|
+
scopeHint?: MemoryScope;
|
|
30
|
+
sensitivity?: MemorySensitivity;
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
export type MemoryProviderSearchInput = {
|
|
34
|
+
store?: RuntimeMemoryStore;
|
|
35
|
+
namespace: string;
|
|
36
|
+
query: string;
|
|
37
|
+
limit?: number;
|
|
38
|
+
kinds?: MemoryKind[];
|
|
39
|
+
};
|
|
40
|
+
export type MemoryProviderConsolidateInput = {
|
|
41
|
+
records: MemoryRecord[];
|
|
42
|
+
};
|
|
43
|
+
export type MemoryProvider = {
|
|
44
|
+
name: string;
|
|
45
|
+
config: MemoryProviderConfig;
|
|
46
|
+
propose(input: MemoryProviderProposeInput): Promise<MemoryCandidate[]>;
|
|
47
|
+
search(input: MemoryProviderSearchInput): Promise<MemoryRecord[]>;
|
|
48
|
+
consolidate(input: MemoryProviderConsolidateInput): Promise<MemoryMaintenanceOperation[]>;
|
|
49
|
+
};
|
|
50
|
+
export declare function createEmbeddedMemoryProvider(config?: MemoryProviderConfig): MemoryProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function createEmbeddedMemoryProvider(e={}){return{name:"embedded",config:e,async propose(n){const s=n.kindHint??function inferKind(e){const n=e.toLowerCase();return n.includes("must ")||n.includes("should ")?"procedural":n.includes("run ")||n.includes("failed ")?"episodic":"semantic"}(n.content);return function isKindEnabled(e,n){return!1!==e.types?.[n]}(e,s)?[{namespace:n.namespace,content:n.content,sourceType:n.sourceType,sourceRef:n.sourceRef,kindHint:s,scopeHint:n.scopeHint??e.defaults?.scope??"workspace",sensitivity:n.sensitivity??e.defaults?.sensitivity??"internal",confidenceHint:.6,metadata:n.metadata}]:[]},search:async e=>e.store?(await e.store.recall({namespace:e.namespace,query:e.query,limit:e.limit,kinds:e.kinds})).records:[],consolidate:async e=>e.records.filter(e=>"stale"===e.status).map(e=>({action:"archive",recordId:e.id,reason:"embedded provider archives stale records during consolidation"}))}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{randomUUID as e}from"node:crypto";import{createDefaultMemoryPolicy as t}from"./policy.js";import{cloneRecords as n}from"./persistence.js";export function createInMemoryRuntimeMemoryStore(e={}){const r=e.policy??t(),o=n(e.records??[]);return{async submitCandidate(e){const t=r.decide(e);if("store"!==t.action)return{candidate:e,decision:t};const n=createRecord({namespace:e.namespace,content:e.content,kind:t.kind,scope:t.scope,summary:e.summary,confidence:t.confidence,tags:e.tags,sensitivity:e.sensitivity,sourceType:e.sourceType,sourceRef:e.sourceRef,metadata:e.metadata,provenance:e.provenance,observedAt:e.observedAt,retrievalPriority:t.retrievalPriority});return o.push(n),{candidate:e,decision:{...t,recordId:n.id},record:cloneRecord(n)}},async memorize(e){const t=createRecord(e);return o.push(t),cloneRecord(t)},async recall(e){const t=e.query.toLowerCase(),n=filterRecords(o,e).filter(e=>function matchesQuery(e,t){return[e.canonicalKey,e.content,e.summary??"",...e.tags].join("\n").toLowerCase().includes(t)}(e,t)).sort(compareRecallPriority).slice(0,e.limit??10);return{records:n,context:buildMemoryContext(n)}},list:async e=>n(filterRecords(o,e)),async update(e){const t=o.find(t=>t.id===e.id);if(t)return function applyUpdate(e,t){e.content=t.content??e.content,e.summary=t.summary??e.summary,e.status=t.status??e.status,e.confidence=normalizeConfidence(t.confidence??e.confidence),e.tags=t.tags??e.tags,e.metadata=t.metadata?{...e.metadata,...t.metadata}:e.metadata,e.lastConfirmedAt=(new Date).toISOString(),e.revision+=1}(t,e),cloneRecord(t)},async archive(e,t){const n=o.find(t=>t.id===e);if(n)return n.status="archived",n.metadata={...n.metadata,archiveReason:t},n.revision+=1,cloneRecord(n)}}}function cloneRecord(e){return n([e])[0]}function createRecord(t){const n=(new Date).toISOString();return{id:e(),namespace:t.namespace,canonicalKey:(r=t.namespace,o=t.content,`${r}:${o.trim().toLowerCase().replace(/\s+/gu," ").slice(0,120)}`),kind:t.kind??"semantic",scope:t.scope??"workspace",status:"active",content:t.content,summary:t.summary,confidence:normalizeConfidence(t.confidence),sourceType:t.sourceType,sourceRefs:t.sourceRef?[t.sourceRef]:[],tags:t.tags??[],sensitivity:t.sensitivity??"internal",metadata:t.metadata??{},createdAt:n,observedAt:t.observedAt??n,lastConfirmedAt:n,provenance:t.provenance??{},revision:1,supersedes:[],conflictsWith:[],retrievalPriority:t.retrievalPriority??0};var r,o}function filterRecords(e,t){return e.filter(e=>e.namespace===t.namespace).filter(e=>!t.kinds||t.kinds.includes(e.kind)).filter(e=>!t.scopes||t.scopes.includes(e.scope)).filter(e=>(t.statuses??["active"]).includes(e.status))}function compareRecallPriority(e,t){return t.retrievalPriority-e.retrievalPriority||t.confidence-e.confidence||t.lastConfirmedAt.localeCompare(e.lastConfirmedAt)}function buildMemoryContext(e){return e.map(e=>`- [${e.kind}/${e.scope}] ${e.summary??e.content}`).join("\n")}function normalizeConfidence(e){return void 0===e||Number.isNaN(e)?.6:Math.min(1,Math.max(0,e))}
|