@studio-foundation/contracts 0.3.0-beta.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.
@@ -0,0 +1,101 @@
1
+ // Type-level tests for @studio/contracts
2
+ // These tests verify that types compile correctly
3
+
4
+ import { describe, it, expect } from 'vitest';
5
+ import type {
6
+ PipelineDefinition,
7
+ StageDefinition,
8
+ StageStatus,
9
+ AgentConfig,
10
+ ValidationResult,
11
+ ToolCallRequirements,
12
+ OutputContract,
13
+ } from '../src/index.js';
14
+
15
+ describe('contracts types', () => {
16
+ it('can create valid pipeline definition', () => {
17
+ const pipeline: PipelineDefinition = {
18
+ name: 'test-pipeline',
19
+ description: 'Test pipeline',
20
+ version: 1,
21
+ stages: [],
22
+ };
23
+ expect(pipeline.name).toBe('test-pipeline');
24
+ });
25
+
26
+ it('can create valid stage definition', () => {
27
+ const stage: StageDefinition = {
28
+ name: 'test-stage',
29
+ kind: 'analysis',
30
+ agent: 'test-agent',
31
+ };
32
+ expect(stage.kind).toBe('analysis');
33
+ });
34
+
35
+ it('status types are correct', () => {
36
+ const status: StageStatus = 'success';
37
+ expect(status).toBe('success');
38
+ });
39
+
40
+ it('can create agent config', () => {
41
+ const agent: AgentConfig = {
42
+ name: 'test-agent',
43
+ provider: 'openai',
44
+ model: 'gpt-4',
45
+ };
46
+ expect(agent.provider).toBe('openai');
47
+ });
48
+
49
+ it('can create pipeline with repo config', () => {
50
+ const pipeline: PipelineDefinition = {
51
+ name: 'test',
52
+ description: 'Test',
53
+ version: 1,
54
+ repo: {
55
+ url: 'https://github.com/test/repo',
56
+ branch: 'main',
57
+ },
58
+ stages: [],
59
+ };
60
+ expect(pipeline.repo?.url).toBe('https://github.com/test/repo');
61
+ });
62
+
63
+ it('validation result structure', () => {
64
+ const validation: ValidationResult = {
65
+ valid: true,
66
+ errors: [],
67
+ warnings: [],
68
+ };
69
+ expect(validation.valid).toBe(true);
70
+ expect(validation.errors).toEqual([]);
71
+ });
72
+
73
+ it('ToolCallRequirements supports required_tool_groups for OR semantics', () => {
74
+ const req: ToolCallRequirements = {
75
+ minimum: 1,
76
+ required_tools: ['repo_manager-read_file'],
77
+ required_tool_groups: [
78
+ ['repo_manager-write_file', 'repo_manager-apply_patch'],
79
+ ],
80
+ };
81
+ expect(req.required_tool_groups).toHaveLength(1);
82
+ expect(req.required_tool_groups![0]).toEqual([
83
+ 'repo_manager-write_file',
84
+ 'repo_manager-apply_patch',
85
+ ]);
86
+ });
87
+
88
+ it('OutputContract.tool_calls accepts required_tool_groups', () => {
89
+ const contract: OutputContract = {
90
+ name: 'code-generation',
91
+ version: 1,
92
+ tool_calls: {
93
+ minimum: 1,
94
+ required_tool_groups: [
95
+ ['repo_manager-write_file', 'repo_manager-apply_patch'],
96
+ ],
97
+ },
98
+ };
99
+ expect(contract.tool_calls?.required_tool_groups).toBeDefined();
100
+ });
101
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "moduleResolution": "bundler",
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "sourceMap": true,
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "noImplicitReturns": true,
20
+ "noFallthroughCasesInSwitch": true
21
+ },
22
+ "include": ["src/**/*"],
23
+ "exclude": ["node_modules", "dist", "tests"]
24
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "rootDir": "."
6
+ },
7
+ "include": ["src/**/*", "tests/**/*"]
8
+ }