@studio-foundation/contracts 0.3.0-beta.1 → 0.3.0-beta.6

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.
Files changed (73) hide show
  1. package/dist/agent.d.ts +28 -0
  2. package/dist/agent.d.ts.map +1 -0
  3. package/dist/agent.js +3 -0
  4. package/dist/agent.js.map +1 -0
  5. package/dist/context-pack.d.ts +21 -0
  6. package/dist/context-pack.d.ts.map +1 -0
  7. package/dist/context-pack.js +3 -0
  8. package/dist/context-pack.js.map +1 -0
  9. package/dist/errors.d.ts +16 -0
  10. package/dist/errors.d.ts.map +1 -0
  11. package/dist/errors.js +23 -0
  12. package/dist/errors.js.map +1 -0
  13. package/dist/index.d.ts +14 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/{src/index.ts → dist/index.js} +1 -3
  16. package/dist/index.js.map +1 -0
  17. package/dist/integration-plugin.d.ts +35 -0
  18. package/dist/integration-plugin.d.ts.map +1 -0
  19. package/dist/integration-plugin.js +3 -0
  20. package/dist/integration-plugin.js.map +1 -0
  21. package/dist/pipeline.d.ts +79 -0
  22. package/dist/pipeline.d.ts.map +1 -0
  23. package/dist/pipeline.js +5 -0
  24. package/dist/pipeline.js.map +1 -0
  25. package/dist/provider.d.ts +35 -0
  26. package/dist/provider.d.ts.map +1 -0
  27. package/dist/provider.js +3 -0
  28. package/dist/provider.js.map +1 -0
  29. package/dist/run.d.ts +43 -0
  30. package/dist/run.d.ts.map +1 -0
  31. package/dist/run.js +3 -0
  32. package/dist/run.js.map +1 -0
  33. package/dist/runner-events.d.ts +67 -0
  34. package/dist/runner-events.d.ts.map +1 -0
  35. package/dist/runner-events.js +7 -0
  36. package/dist/runner-events.js.map +1 -0
  37. package/dist/spawner.d.ts +15 -0
  38. package/dist/spawner.d.ts.map +1 -0
  39. package/dist/spawner.js +4 -0
  40. package/dist/spawner.js.map +1 -0
  41. package/{src/stage.ts → dist/stage.d.ts} +6 -9
  42. package/dist/stage.d.ts.map +1 -0
  43. package/dist/stage.js +3 -0
  44. package/dist/stage.js.map +1 -0
  45. package/{src/task.ts → dist/task.d.ts} +1 -2
  46. package/dist/task.d.ts.map +1 -0
  47. package/dist/task.js +3 -0
  48. package/dist/task.js.map +1 -0
  49. package/dist/tool-plugin.d.ts +42 -0
  50. package/dist/tool-plugin.d.ts.map +1 -0
  51. package/dist/tool-plugin.js +3 -0
  52. package/dist/tool-plugin.js.map +1 -0
  53. package/dist/validation.d.ts +38 -0
  54. package/dist/validation.d.ts.map +1 -0
  55. package/dist/validation.js +3 -0
  56. package/dist/validation.js.map +1 -0
  57. package/package.json +4 -1
  58. package/.claude/settings.json +0 -5
  59. package/ARCHITECTURE.md +0 -33
  60. package/src/agent.ts +0 -33
  61. package/src/context-pack.ts +0 -15
  62. package/src/errors.ts +0 -23
  63. package/src/integration-plugin.ts +0 -34
  64. package/src/pipeline.ts +0 -97
  65. package/src/provider.ts +0 -39
  66. package/src/run.ts +0 -49
  67. package/src/runner-events.ts +0 -69
  68. package/src/spawner.ts +0 -19
  69. package/src/tool-plugin.ts +0 -47
  70. package/src/validation.ts +0 -42
  71. package/tests/types.test.ts +0 -101
  72. package/tsconfig.json +0 -24
  73. package/tsconfig.test.json +0 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-plugin.js","sourceRoot":"","sources":["../src/tool-plugin.ts"],"names":[],"mappings":"AAAA,+BAA+B"}
@@ -0,0 +1,38 @@
1
+ export interface ToolCallRequirements {
2
+ minimum?: number;
3
+ maximum?: number;
4
+ required_tools?: string[];
5
+ required_tool_groups?: string[][];
6
+ counted_tools?: string[];
7
+ }
8
+ export interface OutputContract {
9
+ name: string;
10
+ version: number;
11
+ schema?: {
12
+ required_fields?: string[];
13
+ [key: string]: unknown;
14
+ };
15
+ tool_calls?: ToolCallRequirements;
16
+ custom_rules?: ValidationRule[];
17
+ post_validation?: {
18
+ rejection_detection: {
19
+ field: string;
20
+ rejected_values?: string[];
21
+ approved_values?: string[];
22
+ details_field?: string;
23
+ summary_field?: string;
24
+ reject_if_non_empty?: string;
25
+ };
26
+ };
27
+ }
28
+ export interface ValidationRule {
29
+ name: string;
30
+ description: string;
31
+ check: string;
32
+ }
33
+ export interface ValidationResult {
34
+ valid: boolean;
35
+ errors: string[];
36
+ warnings: string[];
37
+ }
38
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE;QACP,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE;QAChB,mBAAmB,EAAE;YACnB,KAAK,EAAE,MAAM,CAAC;YACd,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;YAC3B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;YAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;YACvB,aAAa,CAAC,EAAE,MAAM,CAAC;YACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;SAC9B,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
@@ -0,0 +1,3 @@
1
+ // Validation contracts and results
2
+ export {};
3
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,mCAAmC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studio-foundation/contracts",
3
- "version": "0.3.0-beta.1",
3
+ "version": "0.3.0-beta.6",
4
4
  "description": "Shared TypeScript types and interfaces for Studio v7",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,6 +11,9 @@
11
11
  "types": "./dist/index.d.ts"
12
12
  }
13
13
  },
14
+ "files": [
15
+ "dist"
16
+ ],
14
17
  "keywords": [
15
18
  "studio",
16
19
  "types",
@@ -1,5 +0,0 @@
1
- {
2
- "enabledPlugins": {
3
- "linear@claude-plugins-official": true
4
- }
5
- }
package/ARCHITECTURE.md DELETED
@@ -1,33 +0,0 @@
1
- # @studio-foundation/contracts
2
-
3
- Types et interfaces partagés par tous les packages Studio. ZERO dépendances. ZERO logique.
4
-
5
- ## Règles
6
-
7
- - Ce package n'a AUCUNE dépendance (pas de `@studio/*`, pas de libs externes)
8
- - JAMAIS de logique — uniquement des types, interfaces, enums TypeScript
9
- - Exception unique : `isStageGroup()` dans `pipeline.ts` (type guard pur, sans état)
10
- - Tout changement ici impacte TOUS les autres packages — être conservateur
11
- - Exporter tout depuis `index.ts`
12
-
13
- ## Fichiers clés
14
-
15
- - `pipeline.ts` — `PipelineDefinition`, `StageDefinition`, `StageGroup`, `StageHooks`, `ToolHookDef`, `StageHookDef`, `StartupCommand`, `isStageGroup()`
16
- - `stage.ts` — `StageStatus`, `StageKind` (= string), `StageResult`
17
- - `task.ts` — `TaskStatus`
18
- - `agent.ts` — `AgentConfig`, `AgentProfile`, `ToolCall`
19
- - `run.ts` — `PipelineRun`, `StageRun`, `TaskRun`, `AgentRun`, `AgentStatus`
20
- - `validation.ts` — `OutputContract`, `ToolCallRequirements`, `ValidationResult`, `ValidationRule`
21
- - `provider.ts` — `LLMRequest`, `LLMResponse`, `Message`, `ToolDefinition`
22
- - `errors.ts` — `ErrorCode` (enum), `StudioError`
23
- - `context-pack.ts` — `ContextPackDefinition`, `ResolvedContextPack`
24
- - `tool-plugin.ts` — `ToolPluginDef`, `ToolCommandDef`, `ShellExecute`, `BuiltinExecute`, `ParameterDef`
25
- - `runner-events.ts` — `RunnerCallbacks`, événements de streaming tool calls et tokens
26
- - `spawner.ts` — `RunSpawner`, `SpawnConfig`, `SpawnResult`
27
- - `integration-plugin.ts` — `IntegrationPluginDef`
28
-
29
- ## Test
30
-
31
- ```bash
32
- pnpm test
33
- ```
package/src/agent.ts DELETED
@@ -1,33 +0,0 @@
1
- // Agent configuration and profiles
2
-
3
- export interface AgentConfig {
4
- name: string;
5
- description?: string;
6
- provider?: string;
7
- model?: string;
8
- system_prompt?: string;
9
- tools?: string[];
10
- plugins?: string[];
11
- skills?: string[];
12
- temperature?: number;
13
- max_tokens?: number;
14
- anonymize?: boolean; // Enable PII anonymization for this agent
15
- }
16
-
17
- /** AgentConfig after defaults have been applied — provider and model are guaranteed. */
18
- export interface ResolvedAgentConfig extends AgentConfig {
19
- provider: string;
20
- model: string;
21
- }
22
-
23
- export interface AgentProfile extends AgentConfig {
24
- // Additional profile-specific fields
25
- }
26
-
27
- export interface ToolCall {
28
- id: string;
29
- name: string;
30
- arguments: Record<string, unknown>;
31
- result?: unknown;
32
- error?: string;
33
- }
@@ -1,15 +0,0 @@
1
- // Shared types for the context packs feature (STU-13)
2
-
3
- export interface ContextPackDefinition {
4
- name: string;
5
- description?: string;
6
- version: number;
7
- files?: Array<{ path: string }>;
8
- inline?: Array<{ title: string; content: string }>;
9
- }
10
-
11
- export interface ResolvedContextPack {
12
- name: string;
13
- description?: string;
14
- sections: Array<{ title: string; content: string }>;
15
- }
package/src/errors.ts DELETED
@@ -1,23 +0,0 @@
1
- // Error types and codes
2
-
3
- export enum ErrorCode {
4
- VALIDATION_FAILED = 'VALIDATION_FAILED',
5
- AGENT_EXECUTION_FAILED = 'AGENT_EXECUTION_FAILED',
6
- STAGE_FAILED = 'STAGE_FAILED',
7
- PIPELINE_FAILED = 'PIPELINE_FAILED',
8
- RALPH_EXHAUSTED = 'RALPH_EXHAUSTED',
9
- TOOL_EXECUTION_FAILED = 'TOOL_EXECUTION_FAILED',
10
- PROVIDER_ERROR = 'PROVIDER_ERROR',
11
- CONFIGURATION_ERROR = 'CONFIGURATION_ERROR',
12
- }
13
-
14
- export class StudioError extends Error {
15
- constructor(
16
- public code: ErrorCode,
17
- message: string,
18
- public details?: Record<string, unknown>
19
- ) {
20
- super(message);
21
- this.name = 'StudioError';
22
- }
23
- }
@@ -1,34 +0,0 @@
1
- // contracts/src/integration-plugin.ts
2
-
3
- export interface IntegrationPluginDef {
4
- name: string;
5
- version: number;
6
- description?: string;
7
- config?: {
8
- required?: string[];
9
- optional?: Record<string, unknown>;
10
- };
11
- events?: {
12
- consumes?: string[];
13
- emits?: string[];
14
- };
15
- test?: {
16
- type: 'http';
17
- endpoint: string;
18
- method?: 'GET' | 'POST';
19
- /** e.g. "bearer:${LINEAR_API_KEY}" — resolved before use */
20
- auth?: string;
21
- body?: string;
22
- expect?: { status?: number };
23
- };
24
- webhook?: {
25
- hmac?: {
26
- header: string; // e.g. 'linear-signature'
27
- secret_env: string; // e.g. 'LINEAR_WEBHOOK_SECRET' — resolved from integration config
28
- };
29
- handler: string; // e.g. 'linear-webhook' — key in WEBHOOK_HANDLERS registry
30
- };
31
- on_failure?: {
32
- handler: string; // e.g. 'linear-failure' — key in FAILURE_HANDLERS registry
33
- };
34
- }
package/src/pipeline.ts DELETED
@@ -1,97 +0,0 @@
1
- // Pipeline and Stage definitions
2
-
3
- import type { StageKind } from './stage';
4
-
5
- export interface InputField {
6
- name: string;
7
- type: 'text' | 'array';
8
- prompt: string;
9
- required: boolean;
10
- default?: string;
11
- items?: 'text';
12
- }
13
-
14
- export interface InputSchema {
15
- type: 'structured';
16
- fields: InputField[];
17
- }
18
-
19
- export interface StartupCommand {
20
- command: string;
21
- inject_as: string;
22
- }
23
-
24
- export interface PipelineDefinition {
25
- name: string;
26
- description: string;
27
- version: number;
28
- on_pipeline_start?: StartupCommand[];
29
- input_schema?: InputSchema;
30
- repo?: {
31
- url: string;
32
- branch?: string;
33
- };
34
- stages: PipelineEntry[];
35
- }
36
-
37
- // Lifecycle hooks — configurable shell commands at stage/tool lifecycle points
38
-
39
- export type HookOnFailure = 'warn' | 'reject' | 'fail';
40
-
41
- export interface StageHookDef {
42
- command: string;
43
- on_failure?: HookOnFailure; // default: 'warn'
44
- }
45
-
46
- export interface ToolHookDef {
47
- matcher: string; // exact tool name to match (e.g. "repo_manager-write_file")
48
- command: string;
49
- on_failure?: 'warn' | 'reject'; // default: 'warn' — 'fail' not supported at tool boundary
50
- }
51
-
52
- export interface StageHooks {
53
- on_stage_start?: StageHookDef[];
54
- on_stage_complete?: StageHookDef[];
55
- pre_tool_use?: ToolHookDef[];
56
- post_tool_use?: ToolHookDef[];
57
- }
58
-
59
- export interface StageDefinition {
60
- name: string;
61
- condition?: string; // e.g. "input.meals_count >= 6" or "stages.foo.output.count > 0"
62
- kind?: StageKind;
63
- agent?: string; // optional — not needed for script executor
64
- executor?: 'script'; // 'script' or absent (defaults to LLM)
65
- script?: string; // path to script file (required when executor: 'script')
66
- runtime?: 'python' | 'node' | 'shell'; // runtime for script executor
67
- timeout_ms?: number; // script timeout in ms (default: 30000)
68
- contract?: string;
69
- ralph?: {
70
- max_attempts: number;
71
- retry_strategy: string;
72
- max_tool_calls?: number;
73
- };
74
- context?: {
75
- include: string[];
76
- packs?: string[];
77
- };
78
- tools?: {
79
- required?: string[];
80
- };
81
- hooks?: StageHooks;
82
- }
83
-
84
- // A pipeline entry is either a stage or a group of stages
85
- export type PipelineEntry = StageDefinition | StageGroup;
86
-
87
- export interface StageGroup {
88
- group: string;
89
- max_iterations: number;
90
- mode?: 'sequential' | 'parallel'; // default: 'sequential'
91
- on_failure?: 'fail-fast' | 'collect-all'; // parallel only, default: 'fail-fast'
92
- stages: StageDefinition[];
93
- }
94
-
95
- export function isStageGroup(entry: PipelineEntry): entry is StageGroup {
96
- return 'group' in entry && 'stages' in entry;
97
- }
package/src/provider.ts DELETED
@@ -1,39 +0,0 @@
1
- // LLM provider interfaces
2
-
3
- export interface LLMRequest {
4
- model: string;
5
- messages: Message[];
6
- tools?: ToolDefinition[];
7
- temperature?: number;
8
- max_tokens?: number;
9
- stage_name?: string;
10
- json_mode?: boolean;
11
- }
12
-
13
- export interface Message {
14
- role: 'system' | 'user' | 'assistant';
15
- content: string;
16
- }
17
-
18
- export interface LLMResponse {
19
- content: string;
20
- tool_calls?: Array<{
21
- id: string;
22
- name: string;
23
- arguments: Record<string, unknown>;
24
- }>;
25
- finish_reason: string;
26
- usage?: {
27
- prompt_tokens: number;
28
- completion_tokens: number;
29
- total_tokens: number;
30
- cached_input_tokens?: number;
31
- cache_creation_tokens?: number;
32
- };
33
- }
34
-
35
- export interface ToolDefinition {
36
- name: string;
37
- description: string;
38
- parameters: Record<string, unknown>;
39
- }
package/src/run.ts DELETED
@@ -1,49 +0,0 @@
1
- // Runtime execution tracking
2
-
3
- import type { StageStatus } from './stage';
4
- import type { TaskStatus } from './task';
5
-
6
- export type AgentStatus = 'pending' | 'running' | 'success' | 'failed';
7
-
8
- export interface PipelineRun {
9
- id: string;
10
- pipeline_name: string;
11
- status: StageStatus;
12
- started_at: string;
13
- completed_at?: string;
14
- stages: StageRun[];
15
- input?: Record<string, unknown>;
16
- parent_run_id?: string;
17
- }
18
-
19
- export interface StageRun {
20
- id: string;
21
- stage_name: string;
22
- status: StageStatus;
23
- started_at: string;
24
- completed_at?: string;
25
- tasks: TaskRun[];
26
- output?: unknown; // final output of the stage (populated by engine for observability)
27
- skipped_reason?: string; // reason why stage was skipped (populated by resume loop)
28
- }
29
-
30
- export interface TaskRun {
31
- id: string;
32
- task_name: string;
33
- status: TaskStatus;
34
- started_at: string;
35
- completed_at?: string;
36
- agent_runs: AgentRun[];
37
- }
38
-
39
- export interface AgentRun {
40
- id: string;
41
- agent_name: string;
42
- attempt: number;
43
- status: AgentStatus;
44
- tool_calls: number;
45
- started_at: string;
46
- completed_at?: string;
47
- output?: unknown;
48
- error?: string;
49
- }
@@ -1,69 +0,0 @@
1
- /**
2
- * Event types for real-time tool call streaming.
3
- * Defined in contracts (leaf package) so runner can import them
4
- * without creating an inverse dependency on engine.
5
- */
6
-
7
- export interface ToolCallStartEvent {
8
- tool: string;
9
- params: Record<string, unknown>;
10
- timestamp: number; // ms since epoch (Date.now())
11
- }
12
-
13
- export interface ToolCallCompleteEvent {
14
- tool: string;
15
- result: unknown; // tool-plugin-specific; typed by each tool plugin
16
- error?: string;
17
- duration_ms: number;
18
- timestamp: number; // ms since epoch (Date.now())
19
- }
20
-
21
- export interface AgentThinkingEvent {
22
- thought: string; // LLM text content emitted before the first round of tool calls
23
- timestamp: number; // ms since epoch (Date.now())
24
- }
25
-
26
- export interface AgentProgressEvent {
27
- message: string; // LLM text content emitted between subsequent rounds of tool calls
28
- timestamp: number; // ms since epoch (Date.now())
29
- }
30
-
31
- export interface AgentTokenEvent {
32
- token: string;
33
- timestamp: number; // ms since epoch (Date.now())
34
- }
35
-
36
- /**
37
- * Subset of callbacks the runner accepts for real-time event emission.
38
- * Engine populates these from EngineEvents and passes them to runAgent().
39
- */
40
- export interface RunnerCallbacks {
41
- onToolCallStart?: (event: ToolCallStartEvent) => void;
42
- onToolCallComplete?: (event: ToolCallCompleteEvent) => void;
43
- onAgentThinking?: (event: AgentThinkingEvent) => void;
44
- onAgentProgress?: (event: AgentProgressEvent) => void;
45
- onAgentToken?: (event: AgentTokenEvent) => void;
46
-
47
- /**
48
- * Called before tool execution. Return { blocked: true, error } to prevent the tool from running.
49
- * The error is surfaced as the tool result so the LLM can react and RALPH loop continues.
50
- */
51
- onPreToolUse?: (event: {
52
- tool: string;
53
- params: Record<string, unknown>;
54
- timestamp: number;
55
- }) => Promise<{ blocked: boolean; error?: string }>;
56
-
57
- /**
58
- * Called after tool execution (only if the tool was not blocked).
59
- * Return { append_message } to inject a note into the conversation after the tool result.
60
- * Only effective in the standard (Chat Completions) provider path.
61
- */
62
- onPostToolUse?: (event: {
63
- tool: string;
64
- params: Record<string, unknown>;
65
- result: unknown;
66
- error?: string;
67
- timestamp: number;
68
- }) => Promise<{ append_message?: string }>;
69
- }
package/src/spawner.ts DELETED
@@ -1,19 +0,0 @@
1
- // The abstraction that studio-run tool uses to launch child runs.
2
- // Implementations: DirectEngineSpawner (engine) and HttpApiSpawner (api).
3
-
4
- export interface SpawnConfig {
5
- pipeline: string;
6
- input: Record<string, unknown>;
7
- parentRunId: string;
8
- depth: number;
9
- }
10
-
11
- export interface SpawnResult {
12
- run_id: string;
13
- status: string;
14
- output: unknown;
15
- }
16
-
17
- export interface RunSpawner {
18
- spawnAndWait(config: SpawnConfig): Promise<SpawnResult>;
19
- }
@@ -1,47 +0,0 @@
1
- // contracts/src/tool-plugin.ts
2
-
3
- export type ParseOutputFormat = 'text' | 'json';
4
-
5
- export interface ParameterDef {
6
- type: 'string' | 'number' | 'boolean' | 'array';
7
- description?: string;
8
- required?: boolean;
9
- default?: unknown;
10
- items?: { type: string };
11
- }
12
-
13
- export interface ShellExecute {
14
- type: 'shell';
15
- command: string;
16
- parse_output?: ParseOutputFormat;
17
- timeout_ms?: number;
18
- }
19
-
20
- export interface BuiltinExecute {
21
- type: 'builtin';
22
- handler?: string; // informational only — we look up by cmd.name
23
- parse_output?: ParseOutputFormat;
24
- }
25
-
26
- export type CommandExecute = ShellExecute | BuiltinExecute;
27
-
28
- export interface ToolCommandDef {
29
- name: string;
30
- description: string;
31
- parameters: Record<string, ParameterDef>;
32
- execute: CommandExecute;
33
- constraints?: Record<string, unknown>;
34
- }
35
-
36
- export interface ToolPluginDef {
37
- name: string;
38
- description?: string;
39
- version: number;
40
- commands: ToolCommandDef[];
41
- config?: Record<string, unknown>;
42
- prompt_snippet?: string;
43
- constraints?: {
44
- requires_initialized_repo?: boolean;
45
- requires_binaries?: string[];
46
- };
47
- }
package/src/validation.ts DELETED
@@ -1,42 +0,0 @@
1
- // Validation contracts and results
2
-
3
- export interface ToolCallRequirements {
4
- minimum?: number;
5
- maximum?: number;
6
- required_tools?: string[];
7
- required_tool_groups?: string[][];
8
- counted_tools?: string[];
9
- }
10
-
11
- export interface OutputContract {
12
- name: string;
13
- version: number;
14
- schema?: {
15
- required_fields?: string[];
16
- [key: string]: unknown;
17
- };
18
- tool_calls?: ToolCallRequirements;
19
- custom_rules?: ValidationRule[];
20
- post_validation?: {
21
- rejection_detection: {
22
- field: string;
23
- rejected_values?: string[];
24
- approved_values?: string[];
25
- details_field?: string;
26
- summary_field?: string;
27
- reject_if_non_empty?: string;
28
- };
29
- };
30
- }
31
-
32
- export interface ValidationRule {
33
- name: string;
34
- description: string;
35
- check: string;
36
- }
37
-
38
- export interface ValidationResult {
39
- valid: boolean;
40
- errors: string[];
41
- warnings: string[];
42
- }
@@ -1,101 +0,0 @@
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
- });