agent-contracts-runtime 0.0.1
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/LICENSE +21 -0
- package/README.md +266 -0
- package/cli-contract.yaml +532 -0
- package/dist/adapters/claude-agent-sdk.d.ts +20 -0
- package/dist/adapters/claude-agent-sdk.js +31 -0
- package/dist/adapters/claude-agent-sdk.js.map +1 -0
- package/dist/adapters/cursor-sdk.d.ts +21 -0
- package/dist/adapters/cursor-sdk.js +35 -0
- package/dist/adapters/cursor-sdk.js.map +1 -0
- package/dist/adapters/mock.d.ts +20 -0
- package/dist/adapters/mock.js +27 -0
- package/dist/adapters/mock.js.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +32 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +378 -0
- package/dist/index.js.map +1 -0
- package/dist/task-runner-B5SV4eCS.d.ts +66 -0
- package/package.json +110 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Task Runner — runs a single DSL task via an SDK agent
|
|
5
|
+
*
|
|
6
|
+
* Responsibilities:
|
|
7
|
+
* 1. Resolve task contract → target agent contract
|
|
8
|
+
* 2. Build the agent prompt from contract + context
|
|
9
|
+
* 3. Apply plugin prompt enhancers and beforeTask hooks
|
|
10
|
+
* 4. Send to SDK agent (via abstract SdkAdapter) and stream result
|
|
11
|
+
* 5. Parse + validate result against handoff schema
|
|
12
|
+
* 6. Apply plugin afterTask hooks
|
|
13
|
+
* 7. Return typed result or escalation signal
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
interface AgentContractLike {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly role_name: string;
|
|
19
|
+
readonly purpose: string;
|
|
20
|
+
readonly mode: "read-write" | "read-only";
|
|
21
|
+
readonly responsibilities: readonly string[];
|
|
22
|
+
readonly constraints: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
interface TaskContractLike {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly description: string;
|
|
27
|
+
readonly target_agent: string;
|
|
28
|
+
readonly result_handoff: string;
|
|
29
|
+
readonly completion_criteria: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
interface SdkAdapter {
|
|
32
|
+
send(prompt: string, options: {
|
|
33
|
+
readonly: boolean;
|
|
34
|
+
}): Promise<string>;
|
|
35
|
+
}
|
|
36
|
+
interface TaskContext {
|
|
37
|
+
user_request: string;
|
|
38
|
+
prior_context?: string;
|
|
39
|
+
relevant_paths?: string[];
|
|
40
|
+
acceptance_criteria?: string[];
|
|
41
|
+
}
|
|
42
|
+
type TaskOutcome = {
|
|
43
|
+
status: "success";
|
|
44
|
+
data: unknown;
|
|
45
|
+
raw: string;
|
|
46
|
+
} | {
|
|
47
|
+
status: "validation_error";
|
|
48
|
+
errors: z.ZodError;
|
|
49
|
+
raw: string;
|
|
50
|
+
} | {
|
|
51
|
+
status: "escalation";
|
|
52
|
+
reason: string;
|
|
53
|
+
raw: string;
|
|
54
|
+
} | {
|
|
55
|
+
status: "error";
|
|
56
|
+
message: string;
|
|
57
|
+
};
|
|
58
|
+
declare function buildTaskPrompt(agent: AgentContractLike, task: TaskContractLike, context: TaskContext): string;
|
|
59
|
+
declare function extractStructuredResult(raw: string): unknown | null;
|
|
60
|
+
declare function runTask(adapter: SdkAdapter, taskId: string, context: TaskContext, options?: {
|
|
61
|
+
agentRegistry?: Record<string, AgentContractLike>;
|
|
62
|
+
taskRegistry?: Record<string, TaskContractLike>;
|
|
63
|
+
handoffSchemas?: Record<string, z.ZodTypeAny>;
|
|
64
|
+
}): Promise<TaskOutcome>;
|
|
65
|
+
|
|
66
|
+
export { type AgentContractLike as A, type SdkAdapter as S, type TaskOutcome as T, type TaskContext as a, type TaskContractLike as b, buildTaskPrompt as c, extractStructuredResult as e, runTask as r };
|
package/package.json
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-contracts-runtime",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Runtime bridge for executing agent-contracts workflows on Agent SDKs",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"agent-runtime": "dist/cli/index.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./adapters/cursor-sdk": {
|
|
17
|
+
"types": "./dist/adapters/cursor-sdk.d.ts",
|
|
18
|
+
"import": "./dist/adapters/cursor-sdk.js"
|
|
19
|
+
},
|
|
20
|
+
"./adapters/claude-agent-sdk": {
|
|
21
|
+
"types": "./dist/adapters/claude-agent-sdk.d.ts",
|
|
22
|
+
"import": "./dist/adapters/claude-agent-sdk.js"
|
|
23
|
+
},
|
|
24
|
+
"./adapters/openai-agents-sdk": {
|
|
25
|
+
"types": "./dist/adapters/openai-agents-sdk.d.ts",
|
|
26
|
+
"import": "./dist/adapters/openai-agents-sdk.js"
|
|
27
|
+
},
|
|
28
|
+
"./adapters/mock": {
|
|
29
|
+
"types": "./dist/adapters/mock.d.ts",
|
|
30
|
+
"import": "./dist/adapters/mock.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"templates",
|
|
36
|
+
"cli-contract.yaml",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:watch": "vitest",
|
|
45
|
+
"test:coverage": "vitest run --coverage",
|
|
46
|
+
"lint": "eslint src/",
|
|
47
|
+
"cli:docs": "cli-contracts docs -f cli-contract.yaml -o docs/cli-reference.md",
|
|
48
|
+
"cli:validate": "cli-contracts validate -f cli-contract.yaml",
|
|
49
|
+
"prepublishOnly": "npm run build"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"agent-contracts",
|
|
53
|
+
"agent",
|
|
54
|
+
"workflow",
|
|
55
|
+
"orchestration",
|
|
56
|
+
"sdk",
|
|
57
|
+
"runtime",
|
|
58
|
+
"guardrails",
|
|
59
|
+
"handoff",
|
|
60
|
+
"contract-first",
|
|
61
|
+
"multi-agent",
|
|
62
|
+
"ai-agent",
|
|
63
|
+
"cursor",
|
|
64
|
+
"claude",
|
|
65
|
+
"openai"
|
|
66
|
+
],
|
|
67
|
+
"author": "foo-ogawa <ogawa@foo-log.co.jp>",
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"repository": {
|
|
70
|
+
"type": "git",
|
|
71
|
+
"url": "git+https://github.com/foo-ogawa/agent-contracts-runtime.git"
|
|
72
|
+
},
|
|
73
|
+
"bugs": {
|
|
74
|
+
"url": "https://github.com/foo-ogawa/agent-contracts-runtime/issues"
|
|
75
|
+
},
|
|
76
|
+
"homepage": "https://github.com/foo-ogawa/agent-contracts-runtime#readme",
|
|
77
|
+
"engines": {
|
|
78
|
+
"node": ">=20.0.0"
|
|
79
|
+
},
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"commander": "^12.1.0",
|
|
82
|
+
"dotenv": "^17.4.2",
|
|
83
|
+
"yaml": "^2.8.3",
|
|
84
|
+
"zod": "^3.24.4"
|
|
85
|
+
},
|
|
86
|
+
"devDependencies": {
|
|
87
|
+
"@types/node": "^25.6.0",
|
|
88
|
+
"cli-contracts": "^0.2.1",
|
|
89
|
+
"tsup": "^8.5.0",
|
|
90
|
+
"tsx": "^4.21.0",
|
|
91
|
+
"typescript": "^5.8.3",
|
|
92
|
+
"vitest": "^3.1.3"
|
|
93
|
+
},
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"@anthropic-ai/claude-agent-sdk": ">=0.2.0",
|
|
96
|
+
"@cursor/sdk": ">=1.0.0",
|
|
97
|
+
"agent-contracts": ">=0.1.0"
|
|
98
|
+
},
|
|
99
|
+
"peerDependenciesMeta": {
|
|
100
|
+
"agent-contracts": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"@cursor/sdk": {
|
|
104
|
+
"optional": true
|
|
105
|
+
},
|
|
106
|
+
"@anthropic-ai/claude-agent-sdk": {
|
|
107
|
+
"optional": true
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|