@plico-ai/contracts 0.0.0-reserved.0 → 0.1.0

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/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Plico
2
+ Copyright 2026 Plico contributors
3
+
4
+ This product includes software developed by the Plico contributors.
package/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # @plico-ai/contracts
2
2
 
3
- Shared wire types for Plico.
3
+ Types-only contracts shared by every Plico package and surface: project/validation results, native events, run results, artifacts, eval results, readiness reports and composed instructions.
4
4
 
5
- This is a pre-release placeholder. The first developer preview is in progress at
6
- https://github.com/ITZSHOAIB/plico. Docs: https://plico.sohab.dev
5
+ Rules:
6
+
7
+ - No runtime code and no dependencies. Everything is `export type`.
8
+ - Packages import these types instead of redefining them (Studio, the server, the CLI and the future React kit all consume the same shapes).
9
+ - Changing a shape here is a public contract change; add versions explicitly.
@@ -0,0 +1,59 @@
1
+ export type ArtifactContent = string | {
2
+ encoding: "base64";
3
+ data: string;
4
+ };
5
+ export interface ArtifactFileMetadata {
6
+ path: string;
7
+ sizeBytes: number;
8
+ mimeType: string;
9
+ version: number;
10
+ contentHash: string;
11
+ }
12
+ export interface ArtifactFile {
13
+ path: string;
14
+ content: ArtifactContent;
15
+ mimeType: string;
16
+ /** Starts at 1 and increments each time the path is rewritten. */
17
+ version: number;
18
+ contentHash: string;
19
+ }
20
+ export interface ArtifactVersion {
21
+ path: string;
22
+ mimeType: string;
23
+ version: number;
24
+ contentHash: string;
25
+ runId: string;
26
+ createdAt: string;
27
+ }
28
+ export interface ArtifactDiff {
29
+ path: string;
30
+ fromVersion: number;
31
+ toVersion: number;
32
+ diff: string;
33
+ }
34
+ export interface ArtifactSnapshot {
35
+ snapshotId: string;
36
+ runId: string;
37
+ fileCount: number;
38
+ createdAt: string;
39
+ }
40
+ export interface ArtifactSnapshotDetail extends ArtifactSnapshot {
41
+ files: ArtifactFile[];
42
+ }
43
+ export interface ArtifactWorkspace {
44
+ workspaceId: string;
45
+ runId: string;
46
+ threadId?: string;
47
+ files: ArtifactFile[];
48
+ versions: ArtifactVersion[];
49
+ snapshots: ArtifactSnapshot[];
50
+ createdAt: string;
51
+ }
52
+ export interface ThreadArtifactWorkspace {
53
+ workspaceId: string;
54
+ threadId: string;
55
+ files: ArtifactFile[];
56
+ versions: ArtifactVersion[];
57
+ snapshots: ArtifactSnapshot[];
58
+ createdAt: string;
59
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { RunStatus } from "./runs.js";
2
+ export interface EvalCaseResult {
3
+ name: string;
4
+ description?: string;
5
+ status: "pass" | "fail";
6
+ runId: string;
7
+ runStatus: RunStatus;
8
+ output?: string;
9
+ diagnostics?: string[];
10
+ }
11
+ export interface EvalSummary {
12
+ total: number;
13
+ passed: number;
14
+ failed: number;
15
+ results: EvalCaseResult[];
16
+ }
17
+ export interface EvalReport extends EvalSummary {
18
+ schemaVersion: 1;
19
+ evaluatedAt: string;
20
+ /** Identifies the fixtures this report ran, so readers can detect stale results. */
21
+ fixturesDigest: string;
22
+ }
package/dist/evals.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,167 @@
1
+ import type { ArtifactContent } from "./artifacts.js";
2
+ import type { ValidationIssue } from "./project.js";
3
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
4
+ [key: string]: JsonValue;
5
+ };
6
+ export interface ModelToolCall {
7
+ id?: string;
8
+ name: string;
9
+ arguments: unknown;
10
+ providerMetadata?: JsonValue;
11
+ }
12
+ export interface PlicoEventPayloads {
13
+ "run.started": {
14
+ projectRoot: string;
15
+ projectName: string;
16
+ threadId?: string;
17
+ metadata?: Record<string, JsonValue>;
18
+ context?: Record<string, JsonValue>;
19
+ };
20
+ "instructions.composed": {
21
+ length: number;
22
+ sources: string[];
23
+ content: string;
24
+ /** The skills the run started with, so a resumed run keeps them. Absent on older runs. */
25
+ skills?: Array<{
26
+ name: string;
27
+ description: string;
28
+ source: string;
29
+ body: string;
30
+ }>;
31
+ };
32
+ "tools.discovered": {
33
+ tools: Array<{
34
+ source: string;
35
+ name: string;
36
+ description: string;
37
+ inputSchema: unknown;
38
+ capabilities: string[];
39
+ approval: {
40
+ required: boolean;
41
+ reason?: string;
42
+ };
43
+ }>;
44
+ /** Hash of the TypeScript files in `tools/`, so a resumed run can tell the tool code changed. */
45
+ fingerprint?: string;
46
+ };
47
+ "input.received": {
48
+ content: string;
49
+ };
50
+ "model.request": {
51
+ model?: {
52
+ provider: string;
53
+ name: string;
54
+ };
55
+ messages: Array<{
56
+ role: string;
57
+ content: string;
58
+ toolName?: string;
59
+ toolCallId?: string;
60
+ toolCalls?: ModelToolCall[];
61
+ providerMetadata?: JsonValue;
62
+ }>;
63
+ maxSteps: number;
64
+ tools: Array<{
65
+ name: string;
66
+ description: string;
67
+ inputSchema: unknown;
68
+ }>;
69
+ };
70
+ "model.attempt": {
71
+ turn: number;
72
+ attemptId: string;
73
+ };
74
+ "model.delta": {
75
+ turn: number;
76
+ attemptId: string;
77
+ text: string;
78
+ };
79
+ "model.response": {
80
+ attemptId?: string;
81
+ providerMetadata?: JsonValue;
82
+ content: string;
83
+ usage: {
84
+ inputTokens: number;
85
+ outputTokens: number;
86
+ };
87
+ toolCalls?: ModelToolCall[] | undefined;
88
+ };
89
+ "assistant.output": {
90
+ content: string;
91
+ };
92
+ "tool.call": {
93
+ toolName: string;
94
+ arguments: unknown;
95
+ };
96
+ "tool.result": {
97
+ toolName: string;
98
+ result: unknown;
99
+ };
100
+ "approval.requested": {
101
+ requestId: string;
102
+ toolName: string;
103
+ arguments: unknown;
104
+ approval: {
105
+ required: boolean;
106
+ reason?: string;
107
+ };
108
+ };
109
+ "approval.decided": {
110
+ requestId: string;
111
+ approved: boolean;
112
+ /** The context of whoever decided, as the host passed it. */
113
+ context?: Record<string, JsonValue>;
114
+ };
115
+ "artifact.workspace.created": {
116
+ workspaceId: string;
117
+ };
118
+ "artifact.file.written": {
119
+ path: string;
120
+ content: ArtifactContent;
121
+ mimeType: string;
122
+ contentHash?: string;
123
+ version?: number;
124
+ };
125
+ "artifact.snapshot.created": {
126
+ snapshotId: string;
127
+ fileCount: number;
128
+ };
129
+ "run.completed": {
130
+ output?: string;
131
+ };
132
+ "run.waiting": {
133
+ requestId: string;
134
+ toolName: string;
135
+ output?: string;
136
+ };
137
+ "run.failed": {
138
+ phase: string;
139
+ };
140
+ "run.cancelled": Record<string, never>;
141
+ "run.error": {
142
+ phase: string;
143
+ message?: string;
144
+ issues?: ValidationIssue[];
145
+ toolName?: string;
146
+ };
147
+ }
148
+ export type PlicoEventType = keyof PlicoEventPayloads;
149
+ export type EventStreamType = "run" | "thread";
150
+ interface EventEnvelope {
151
+ schemaVersion: 1;
152
+ streamType: "run";
153
+ /** Canonical location in the log. */
154
+ streamId: string;
155
+ /** Always equals `streamId` on run streams. */
156
+ runId: string;
157
+ id: string;
158
+ sequence: number;
159
+ timestamp: string;
160
+ }
161
+ export type PlicoEvent<T extends PlicoEventType = PlicoEventType> = {
162
+ [K in T]: EventEnvelope & {
163
+ type: K;
164
+ payload: PlicoEventPayloads[K];
165
+ };
166
+ }[T];
167
+ export {};
package/dist/events.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export type { ArtifactContent, ArtifactDiff, ArtifactFile, ArtifactFileMetadata, ArtifactSnapshot, ArtifactSnapshotDetail, ArtifactVersion, ArtifactWorkspace, ThreadArtifactWorkspace, } from "./artifacts.js";
2
+ export type { EvalCaseResult, EvalReport, EvalSummary } from "./evals.js";
3
+ export type { EventStreamType, JsonValue, ModelToolCall, PlicoEvent, PlicoEventPayloads, PlicoEventType, } from "./events.js";
4
+ export type { ComposedInstructions } from "./instructions.js";
5
+ export type { LoadedProject, ProjectConfig, ProviderInput, ValidationIssue, ValidationResult, ValidationSeverity, } from "./project.js";
6
+ export type { DiagnosticSeverity, ReadinessDiagnostic, ReadinessReport, } from "./readiness.js";
7
+ export type { RunResult, RunStatus, RunSummary } from "./runs.js";
8
+ export type { Thread, ThreadEvent, ThreadMessage } from "./threads.js";
9
+ export type { JsonSchema, JsonSchemaObject, ToolApprovalPolicy, ToolArtifactContext, ToolArtifactFile, ToolDefinition, ToolHandlerContext, ToolInputSchema, ZodInputParseResult, ZodInputSchema, } from "./tools.js";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface ComposedInstructions {
2
+ sources: string[];
3
+ content: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,57 @@
1
+ export type ValidationSeverity = "error" | "warning";
2
+ export interface ValidationIssue {
3
+ path: string;
4
+ message: string;
5
+ severity: ValidationSeverity;
6
+ }
7
+ export interface ProjectConfig {
8
+ schemaVersion: number;
9
+ name: string;
10
+ description?: string;
11
+ template?: string;
12
+ artifacts?: {
13
+ access: "read-write" | "read-only" | "off";
14
+ };
15
+ model?: {
16
+ provider: string;
17
+ name: string;
18
+ /** Endpoint for `openai-compatible` (and `openai`). */
19
+ baseURL?: string;
20
+ /** Environment variable holding the API key. Defaults to the provider's usual variable. */
21
+ apiKeyEnv?: string;
22
+ maxSteps?: number;
23
+ retries?: number;
24
+ retryDelayMs?: number;
25
+ };
26
+ execution?: {
27
+ leaseMs?: number;
28
+ };
29
+ /** Thread naming. `keywords` is the default; `model` asks the configured model to write titles. */
30
+ threads?: {
31
+ title?: "keywords" | "model";
32
+ };
33
+ approvals?: {
34
+ default?: "none" | "required";
35
+ timeoutMs?: number;
36
+ tools?: Record<string, "none" | "required">;
37
+ };
38
+ }
39
+ /** What the default export of `providers/<name>.ts` receives. It returns an AI SDK language model. */
40
+ export interface ProviderInput {
41
+ model: string;
42
+ /** The value of the variable named by `model.apiKeyEnv`, when the config names one. */
43
+ apiKey?: string;
44
+ baseURL?: string;
45
+ }
46
+ export interface LoadedProject {
47
+ root: string;
48
+ configPath: string;
49
+ config: ProjectConfig;
50
+ }
51
+ export interface ValidationResult {
52
+ ok: boolean;
53
+ issues: ValidationIssue[];
54
+ errors: ValidationIssue[];
55
+ warnings: ValidationIssue[];
56
+ project?: LoadedProject;
57
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ export type DiagnosticSeverity = "ok" | "warning" | "error";
2
+ export interface ReadinessDiagnostic {
3
+ severity: DiagnosticSeverity;
4
+ subsystem: string;
5
+ path?: string;
6
+ message: string;
7
+ }
8
+ export interface ReadinessReport {
9
+ projectRoot: string;
10
+ timestamp: string;
11
+ diagnostics: ReadinessDiagnostic[];
12
+ summary: {
13
+ ok: number;
14
+ warning: number;
15
+ error: number;
16
+ };
17
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/runs.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { JsonValue, PlicoEvent } from "./events.js";
2
+ import type { ValidationIssue } from "./project.js";
3
+ export type RunStatus = "running" | "completed" | "failed" | "waiting" | "cancelled";
4
+ export interface RunSummary {
5
+ runId: string;
6
+ projectRoot: string;
7
+ projectName: string;
8
+ status: RunStatus;
9
+ startedAt: string;
10
+ endedAt: string | null;
11
+ output?: string;
12
+ /** Host data set when the run started and never changed. */
13
+ metadata?: Record<string, JsonValue>;
14
+ }
15
+ export interface RunResult {
16
+ runId: string;
17
+ status: RunStatus;
18
+ output?: string;
19
+ events: PlicoEvent[];
20
+ errors?: ValidationIssue[];
21
+ }
package/dist/runs.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ import type { JsonValue } from "./events.js";
2
+ export interface Thread {
3
+ id: string;
4
+ createdAt: string;
5
+ /** Absent until the conversation has a topic or the user names it. */
6
+ title?: string;
7
+ /** Host data set at creation and never changed. */
8
+ metadata?: Record<string, JsonValue>;
9
+ }
10
+ export interface ThreadMessage {
11
+ id: string;
12
+ threadId: string;
13
+ role: "user" | "assistant";
14
+ runId?: string;
15
+ content: string;
16
+ createdAt: string;
17
+ }
18
+ interface ThreadEventEnvelope {
19
+ schemaVersion: 1;
20
+ streamType: "thread";
21
+ streamId: string;
22
+ sequence: number;
23
+ id: string;
24
+ timestamp: string;
25
+ }
26
+ export type ThreadEvent = (ThreadEventEnvelope & {
27
+ type: "thread.created";
28
+ payload: {
29
+ thread: Thread;
30
+ };
31
+ }) | (ThreadEventEnvelope & {
32
+ type: "message.created";
33
+ payload: {
34
+ message: ThreadMessage;
35
+ };
36
+ }) | (ThreadEventEnvelope & {
37
+ type: "thread.titled";
38
+ payload: {
39
+ title: string;
40
+ source: "generated" | "user";
41
+ };
42
+ });
43
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,66 @@
1
+ import type { ArtifactFileMetadata } from "./artifacts.js";
2
+ import type { JsonValue } from "./events.js";
3
+ export interface ToolArtifactFile {
4
+ path: string;
5
+ content: string | Uint8Array;
6
+ mimeType: string;
7
+ version: number;
8
+ contentHash: string;
9
+ }
10
+ export interface ToolArtifactContext {
11
+ read(path: string): Promise<ToolArtifactFile | undefined>;
12
+ write(path: string, content: string | Uint8Array, options?: {
13
+ mimeType?: string;
14
+ }): Promise<{
15
+ path: string;
16
+ version: number;
17
+ }>;
18
+ list(): Promise<ArtifactFileMetadata[]>;
19
+ }
20
+ export interface JsonSchemaObject {
21
+ [keyword: string]: JsonValue | undefined;
22
+ }
23
+ export type JsonSchema = JsonSchemaObject | boolean;
24
+ export interface ZodInputSchema {
25
+ safeParseAsync(input: unknown): Promise<ZodInputParseResult>;
26
+ }
27
+ export type ZodInputParseResult = {
28
+ success: true;
29
+ data: unknown;
30
+ } | {
31
+ success: false;
32
+ error: {
33
+ issues: Array<{
34
+ path: Array<string | number | symbol>;
35
+ message: string;
36
+ }>;
37
+ };
38
+ };
39
+ export type ToolInputSchema = JsonSchema | ZodInputSchema;
40
+ export interface ToolApprovalPolicy {
41
+ required: boolean;
42
+ reason?: string;
43
+ }
44
+ export interface ToolHandlerContext {
45
+ /** Aborts when the run is cancelled. Pass it to fetch or a child process to stop early. */
46
+ signal: AbortSignal;
47
+ /**
48
+ * Names this tool call and stays the same if the call runs again after a crash. Pass it to
49
+ * an API that accepts an idempotency key so a repeat does not act twice.
50
+ */
51
+ idempotencyKey: string;
52
+ artifacts: ToolArtifactContext;
53
+ /**
54
+ * Data the host passed when it started the run, such as the calling user. It is recorded in the
55
+ * run's event log, so it must not carry secrets.
56
+ */
57
+ context?: Record<string, JsonValue>;
58
+ }
59
+ export interface ToolDefinition {
60
+ name: string;
61
+ description: string;
62
+ inputSchema: ToolInputSchema;
63
+ capabilities: string[];
64
+ approval: ToolApprovalPolicy;
65
+ handler: (input: unknown, context: ToolHandlerContext) => unknown | Promise<unknown>;
66
+ }
package/dist/tools.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,21 +1,40 @@
1
1
  {
2
2
  "name": "@plico-ai/contracts",
3
- "version": "0.0.0-reserved.0",
4
- "description": "Shared wire types for Plico. Not released yet.",
3
+ "version": "0.1.0",
4
+ "description": "Types-only shared contracts (events, runs, artifacts, evals, readiness) for Plico packages",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://plico.sohab.dev",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/ITZSHOAIB/plico.git"
9
+ "url": "git+https://github.com/ITZSHOAIB/plico.git",
10
+ "directory": "packages/contracts"
10
11
  },
11
12
  "keywords": [
12
13
  "plico",
13
- "agent"
14
- ],
15
- "files": [
16
- "README.md"
14
+ "agent",
15
+ "types"
17
16
  ],
18
17
  "publishConfig": {
19
18
  "access": "public"
19
+ },
20
+ "type": "module",
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ }
28
+ },
29
+ "files": [
30
+ "NOTICE",
31
+ "dist"
32
+ ],
33
+ "engines": {
34
+ "node": ">=22.18.0"
35
+ },
36
+ "scripts": {
37
+ "typecheck": "tsc -p tsconfig.json --noEmit",
38
+ "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json"
20
39
  }
21
- }
40
+ }