pi-harness-runtime 1.1.336 → 1.1.337
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/index.ts +21 -12
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/dist/index.d.ts +11 -0
- package/packages/connection-runtime/dist/index.js +11 -0
- package/packages/connection-runtime/dist/registry.d.ts +69 -0
- package/packages/connection-runtime/dist/registry.js +117 -0
- package/packages/connection-runtime/dist/supervisor.d.ts +89 -0
- package/packages/connection-runtime/dist/supervisor.js +169 -0
- package/packages/connection-runtime/dist/types.d.ts +70 -0
- package/packages/connection-runtime/dist/types.js +16 -0
- package/packages/connection-runtime/package.json +24 -0
- package/packages/connection-runtime/src/index.ts +12 -0
- package/packages/connection-runtime/src/registry.ts +142 -0
- package/packages/connection-runtime/src/supervisor.ts +224 -0
- package/packages/connection-runtime/src/types.ts +88 -0
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/dist/approvals.d.ts +273 -0
- package/packages/contracts/dist/approvals.js +93 -0
- package/packages/contracts/dist/base.d.ts +78 -0
- package/packages/contracts/dist/base.js +82 -0
- package/packages/contracts/dist/events.d.ts +99 -0
- package/packages/contracts/dist/events.js +65 -0
- package/packages/contracts/dist/index.d.ts +20 -0
- package/packages/contracts/dist/index.js +20 -0
- package/packages/contracts/dist/jobs.d.ts +234 -0
- package/packages/contracts/dist/jobs.js +79 -0
- package/packages/contracts/dist/notifications.d.ts +317 -0
- package/packages/contracts/dist/notifications.js +85 -0
- package/packages/contracts/dist/projects.d.ts +171 -0
- package/packages/contracts/dist/projects.js +62 -0
- package/packages/contracts/dist/sessions.d.ts +226 -0
- package/packages/contracts/dist/sessions.js +82 -0
- package/packages/contracts/package.json +24 -0
- package/packages/contracts/src/approvals.ts +115 -0
- package/packages/contracts/src/base.ts +126 -0
- package/packages/contracts/src/events.ts +78 -0
- package/packages/contracts/src/index.ts +21 -0
- package/packages/contracts/src/jobs.ts +101 -0
- package/packages/contracts/src/notifications.ts +104 -0
- package/packages/contracts/src/projects.ts +81 -0
- package/packages/contracts/src/sessions.ts +104 -0
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/dist/index.d.ts +12 -0
- package/packages/event-sink/dist/index.js +12 -0
- package/packages/event-sink/dist/outbox.d.ts +51 -0
- package/packages/event-sink/dist/outbox.js +88 -0
- package/packages/event-sink/dist/projection.d.ts +41 -0
- package/packages/event-sink/dist/projection.js +62 -0
- package/packages/event-sink/dist/sink.d.ts +81 -0
- package/packages/event-sink/dist/sink.js +106 -0
- package/packages/event-sink/package.json +28 -0
- package/packages/event-sink/src/index.ts +15 -0
- package/packages/event-sink/src/outbox.ts +119 -0
- package/packages/event-sink/src/projection.ts +84 -0
- package/packages/event-sink/src/sink.ts +167 -0
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/dist/checker.d.ts +66 -0
- package/packages/permission-mode/dist/checker.js +64 -0
- package/packages/permission-mode/dist/index.d.ts +12 -0
- package/packages/permission-mode/dist/index.js +11 -0
- package/packages/permission-mode/dist/manager.d.ts +65 -0
- package/packages/permission-mode/dist/manager.js +91 -0
- package/packages/permission-mode/dist/mode.d.ts +31 -0
- package/packages/permission-mode/dist/mode.js +47 -0
- package/packages/permission-mode/package.json +24 -0
- package/packages/permission-mode/src/checker.ts +103 -0
- package/packages/permission-mode/src/index.ts +13 -0
- package/packages/permission-mode/src/manager.ts +154 -0
- package/packages/permission-mode/src/mode.ts +73 -0
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/dist/client.d.ts +53 -0
- package/packages/relay/dist/client.js +95 -0
- package/packages/relay/dist/index.d.ts +9 -0
- package/packages/relay/dist/index.js +8 -0
- package/packages/relay/dist/server.d.ts +58 -0
- package/packages/relay/dist/server.js +93 -0
- package/packages/relay/dist/types.d.ts +35 -0
- package/packages/relay/dist/types.js +4 -0
- package/packages/relay/package.json +24 -0
- package/packages/relay/src/client.ts +119 -0
- package/packages/relay/src/index.ts +10 -0
- package/packages/relay/src/server.ts +120 -0
- package/packages/relay/src/types.ts +38 -0
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session schemas for pi-harness
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/**
|
|
6
|
+
* Session status
|
|
7
|
+
*/
|
|
8
|
+
export declare const SessionStatus: z.ZodEnum<["active", "idle", "suspended", "ended"]>;
|
|
9
|
+
export type SessionStatus = z.infer<typeof SessionStatus>;
|
|
10
|
+
/**
|
|
11
|
+
* Session type
|
|
12
|
+
*/
|
|
13
|
+
export declare const SessionType: z.ZodEnum<["interactive", "batch", "background", "review"]>;
|
|
14
|
+
export type SessionType = z.infer<typeof SessionType>;
|
|
15
|
+
/**
|
|
16
|
+
* Session definition
|
|
17
|
+
*/
|
|
18
|
+
export declare const Session: z.ZodObject<{
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
type: z.ZodEnum<["interactive", "batch", "background", "review"]>;
|
|
21
|
+
status: z.ZodEnum<["active", "idle", "suspended", "ended"]>;
|
|
22
|
+
workspaceId: z.ZodString;
|
|
23
|
+
provider: z.ZodString;
|
|
24
|
+
model: z.ZodOptional<z.ZodString>;
|
|
25
|
+
startedAt: z.ZodString;
|
|
26
|
+
endedAt: z.ZodOptional<z.ZodString>;
|
|
27
|
+
lastActivityAt: z.ZodOptional<z.ZodString>;
|
|
28
|
+
promptTokens: z.ZodDefault<z.ZodNumber>;
|
|
29
|
+
completionTokens: z.ZodDefault<z.ZodNumber>;
|
|
30
|
+
cost: z.ZodDefault<z.ZodNumber>;
|
|
31
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
id: string;
|
|
34
|
+
type: "background" | "batch" | "interactive" | "review";
|
|
35
|
+
status: "active" | "ended" | "idle" | "suspended";
|
|
36
|
+
workspaceId: string;
|
|
37
|
+
provider: string;
|
|
38
|
+
model?: string | undefined;
|
|
39
|
+
startedAt: string;
|
|
40
|
+
endedAt?: string | undefined;
|
|
41
|
+
lastActivityAt?: string | undefined;
|
|
42
|
+
promptTokens: number;
|
|
43
|
+
completionTokens: number;
|
|
44
|
+
cost: number;
|
|
45
|
+
metadata?: Record<string, unknown> | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
id: string;
|
|
48
|
+
type: "background" | "batch" | "interactive" | "review";
|
|
49
|
+
status: "active" | "ended" | "idle" | "suspended";
|
|
50
|
+
workspaceId: string;
|
|
51
|
+
provider: string;
|
|
52
|
+
model?: string | undefined;
|
|
53
|
+
startedAt: string;
|
|
54
|
+
endedAt?: string | undefined;
|
|
55
|
+
lastActivityAt?: string | undefined;
|
|
56
|
+
promptTokens?: number | undefined;
|
|
57
|
+
completionTokens?: number | undefined;
|
|
58
|
+
cost?: number | undefined;
|
|
59
|
+
metadata?: Record<string, unknown> | undefined;
|
|
60
|
+
}>;
|
|
61
|
+
export type Session = z.infer<typeof Session>;
|
|
62
|
+
/**
|
|
63
|
+
* Session creation input
|
|
64
|
+
*/
|
|
65
|
+
export declare const SessionCreate: z.ZodObject<{
|
|
66
|
+
type: z.ZodDefault<z.ZodEnum<["interactive", "batch", "background", "review"]>>;
|
|
67
|
+
workspaceId: z.ZodString;
|
|
68
|
+
provider: z.ZodString;
|
|
69
|
+
model: z.ZodOptional<z.ZodString>;
|
|
70
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
type: "background" | "batch" | "interactive" | "review";
|
|
73
|
+
workspaceId: string;
|
|
74
|
+
provider: string;
|
|
75
|
+
model?: string | undefined;
|
|
76
|
+
metadata?: Record<string, unknown> | undefined;
|
|
77
|
+
}, {
|
|
78
|
+
type?: "background" | "batch" | "interactive" | "review" | undefined;
|
|
79
|
+
workspaceId: string;
|
|
80
|
+
provider: string;
|
|
81
|
+
model?: string | undefined;
|
|
82
|
+
metadata?: Record<string, unknown> | undefined;
|
|
83
|
+
}>;
|
|
84
|
+
export type SessionCreate = z.infer<typeof SessionCreate>;
|
|
85
|
+
/**
|
|
86
|
+
* Session update input
|
|
87
|
+
*/
|
|
88
|
+
export declare const SessionUpdate: z.ZodObject<{
|
|
89
|
+
status: z.ZodOptional<z.ZodEnum<["active", "idle", "suspended", "ended"]>>;
|
|
90
|
+
lastActivityAt: z.ZodOptional<z.ZodString>;
|
|
91
|
+
promptTokens: z.ZodOptional<z.ZodNumber>;
|
|
92
|
+
completionTokens: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
status?: "active" | "ended" | "idle" | "suspended" | undefined;
|
|
97
|
+
lastActivityAt?: string | undefined;
|
|
98
|
+
promptTokens?: number | undefined;
|
|
99
|
+
completionTokens?: number | undefined;
|
|
100
|
+
cost?: number | undefined;
|
|
101
|
+
metadata?: Record<string, unknown> | undefined;
|
|
102
|
+
}, {
|
|
103
|
+
status?: "active" | "ended" | "idle" | "suspended" | undefined;
|
|
104
|
+
lastActivityAt?: string | undefined;
|
|
105
|
+
promptTokens?: number | undefined;
|
|
106
|
+
completionTokens?: number | undefined;
|
|
107
|
+
cost?: number | undefined;
|
|
108
|
+
metadata?: Record<string, unknown> | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
export type SessionUpdate = z.infer<typeof SessionUpdate>;
|
|
111
|
+
/**
|
|
112
|
+
* Session filter
|
|
113
|
+
*/
|
|
114
|
+
export declare const SessionFilter: z.ZodObject<{
|
|
115
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
116
|
+
type: z.ZodOptional<z.ZodEnum<["interactive", "batch", "background", "review"]>>;
|
|
117
|
+
status: z.ZodOptional<z.ZodEnum<["active", "idle", "suspended", "ended"]>>;
|
|
118
|
+
since: z.ZodOptional<z.ZodString>;
|
|
119
|
+
until: z.ZodOptional<z.ZodString>;
|
|
120
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
121
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
workspaceId?: string | undefined;
|
|
124
|
+
type?: "background" | "batch" | "interactive" | "review" | undefined;
|
|
125
|
+
status?: "active" | "ended" | "idle" | "suspended" | undefined;
|
|
126
|
+
since?: string | undefined;
|
|
127
|
+
until?: string | undefined;
|
|
128
|
+
limit: number;
|
|
129
|
+
cursor?: string | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
workspaceId?: string | undefined;
|
|
132
|
+
type?: "background" | "batch" | "interactive" | "review" | undefined;
|
|
133
|
+
status?: "active" | "ended" | "idle" | "suspended" | undefined;
|
|
134
|
+
since?: string | undefined;
|
|
135
|
+
until?: string | undefined;
|
|
136
|
+
limit?: number | undefined;
|
|
137
|
+
cursor?: string | undefined;
|
|
138
|
+
}>;
|
|
139
|
+
export type SessionFilter = z.infer<typeof SessionFilter>;
|
|
140
|
+
/**
|
|
141
|
+
* Session list response
|
|
142
|
+
*/
|
|
143
|
+
export declare const SessionList: z.ZodObject<{
|
|
144
|
+
items: z.ZodArray<z.ZodObject<{
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
type: z.ZodEnum<["interactive", "batch", "background", "review"]>;
|
|
147
|
+
status: z.ZodEnum<["active", "idle", "suspended", "ended"]>;
|
|
148
|
+
workspaceId: z.ZodString;
|
|
149
|
+
provider: z.ZodString;
|
|
150
|
+
model: z.ZodOptional<z.ZodString>;
|
|
151
|
+
startedAt: z.ZodString;
|
|
152
|
+
endedAt: z.ZodOptional<z.ZodString>;
|
|
153
|
+
lastActivityAt: z.ZodOptional<z.ZodString>;
|
|
154
|
+
promptTokens: z.ZodDefault<z.ZodNumber>;
|
|
155
|
+
completionTokens: z.ZodDefault<z.ZodNumber>;
|
|
156
|
+
cost: z.ZodDefault<z.ZodNumber>;
|
|
157
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
id: string;
|
|
160
|
+
type: "background" | "batch" | "interactive" | "review";
|
|
161
|
+
status: "active" | "ended" | "idle" | "suspended";
|
|
162
|
+
workspaceId: string;
|
|
163
|
+
provider: string;
|
|
164
|
+
model?: string | undefined;
|
|
165
|
+
startedAt: string;
|
|
166
|
+
endedAt?: string | undefined;
|
|
167
|
+
lastActivityAt?: string | undefined;
|
|
168
|
+
promptTokens: number;
|
|
169
|
+
completionTokens: number;
|
|
170
|
+
cost: number;
|
|
171
|
+
metadata?: Record<string, unknown> | undefined;
|
|
172
|
+
}, {
|
|
173
|
+
id: string;
|
|
174
|
+
type: "background" | "batch" | "interactive" | "review";
|
|
175
|
+
status: "active" | "ended" | "idle" | "suspended";
|
|
176
|
+
workspaceId: string;
|
|
177
|
+
provider: string;
|
|
178
|
+
model?: string | undefined;
|
|
179
|
+
startedAt: string;
|
|
180
|
+
endedAt?: string | undefined;
|
|
181
|
+
lastActivityAt?: string | undefined;
|
|
182
|
+
promptTokens?: number | undefined;
|
|
183
|
+
completionTokens?: number | undefined;
|
|
184
|
+
cost?: number | undefined;
|
|
185
|
+
metadata?: Record<string, unknown> | undefined;
|
|
186
|
+
}>, "many">;
|
|
187
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
188
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
189
|
+
}, "strip", z.ZodTypeAny, {
|
|
190
|
+
items: {
|
|
191
|
+
id: string;
|
|
192
|
+
type: "background" | "batch" | "interactive" | "review";
|
|
193
|
+
status: "active" | "ended" | "idle" | "suspended";
|
|
194
|
+
workspaceId: string;
|
|
195
|
+
provider: string;
|
|
196
|
+
model?: string | undefined;
|
|
197
|
+
startedAt: string;
|
|
198
|
+
endedAt?: string | undefined;
|
|
199
|
+
lastActivityAt?: string | undefined;
|
|
200
|
+
promptTokens: number;
|
|
201
|
+
completionTokens: number;
|
|
202
|
+
cost: number;
|
|
203
|
+
metadata?: Record<string, unknown> | undefined;
|
|
204
|
+
}[];
|
|
205
|
+
nextCursor?: string | undefined;
|
|
206
|
+
total?: number | undefined;
|
|
207
|
+
}, {
|
|
208
|
+
items: {
|
|
209
|
+
id: string;
|
|
210
|
+
type: "background" | "batch" | "interactive" | "review";
|
|
211
|
+
status: "active" | "ended" | "idle" | "suspended";
|
|
212
|
+
workspaceId: string;
|
|
213
|
+
provider: string;
|
|
214
|
+
model?: string | undefined;
|
|
215
|
+
startedAt: string;
|
|
216
|
+
endedAt?: string | undefined;
|
|
217
|
+
lastActivityAt?: string | undefined;
|
|
218
|
+
promptTokens?: number | undefined;
|
|
219
|
+
completionTokens?: number | undefined;
|
|
220
|
+
cost?: number | undefined;
|
|
221
|
+
metadata?: Record<string, unknown> | undefined;
|
|
222
|
+
}[];
|
|
223
|
+
nextCursor?: string | undefined;
|
|
224
|
+
total?: number | undefined;
|
|
225
|
+
}>;
|
|
226
|
+
export type SessionList = z.infer<typeof SessionList>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session schemas for pi-harness
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { Timestamp, UUID, NonEmptyString } from './base.js';
|
|
6
|
+
/**
|
|
7
|
+
* Session status
|
|
8
|
+
*/
|
|
9
|
+
export const SessionStatus = z.enum([
|
|
10
|
+
'active',
|
|
11
|
+
'idle',
|
|
12
|
+
'suspended',
|
|
13
|
+
'ended',
|
|
14
|
+
]);
|
|
15
|
+
/**
|
|
16
|
+
* Session type
|
|
17
|
+
*/
|
|
18
|
+
export const SessionType = z.enum([
|
|
19
|
+
'interactive',
|
|
20
|
+
'batch',
|
|
21
|
+
'background',
|
|
22
|
+
'review',
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Session definition
|
|
26
|
+
*/
|
|
27
|
+
export const Session = z.object({
|
|
28
|
+
id: UUID,
|
|
29
|
+
type: SessionType,
|
|
30
|
+
status: SessionStatus,
|
|
31
|
+
workspaceId: z.string(),
|
|
32
|
+
provider: NonEmptyString,
|
|
33
|
+
model: z.string().optional(),
|
|
34
|
+
startedAt: Timestamp,
|
|
35
|
+
endedAt: Timestamp.optional(),
|
|
36
|
+
lastActivityAt: Timestamp.optional(),
|
|
37
|
+
promptTokens: z.number().int().nonnegative().default(0),
|
|
38
|
+
completionTokens: z.number().int().nonnegative().default(0),
|
|
39
|
+
cost: z.number().nonnegative().default(0),
|
|
40
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Session creation input
|
|
44
|
+
*/
|
|
45
|
+
export const SessionCreate = z.object({
|
|
46
|
+
type: SessionType.default('interactive'),
|
|
47
|
+
workspaceId: z.string(),
|
|
48
|
+
provider: NonEmptyString,
|
|
49
|
+
model: z.string().optional(),
|
|
50
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Session update input
|
|
54
|
+
*/
|
|
55
|
+
export const SessionUpdate = z.object({
|
|
56
|
+
status: SessionStatus.optional(),
|
|
57
|
+
lastActivityAt: Timestamp.optional(),
|
|
58
|
+
promptTokens: z.number().int().nonnegative().optional(),
|
|
59
|
+
completionTokens: z.number().int().nonnegative().optional(),
|
|
60
|
+
cost: z.number().nonnegative().optional(),
|
|
61
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Session filter
|
|
65
|
+
*/
|
|
66
|
+
export const SessionFilter = z.object({
|
|
67
|
+
workspaceId: z.string().optional(),
|
|
68
|
+
type: SessionType.optional(),
|
|
69
|
+
status: SessionStatus.optional(),
|
|
70
|
+
since: Timestamp.optional(),
|
|
71
|
+
until: Timestamp.optional(),
|
|
72
|
+
limit: z.number().int().positive().max(100).default(50),
|
|
73
|
+
cursor: z.string().optional(),
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Session list response
|
|
77
|
+
*/
|
|
78
|
+
export const SessionList = z.object({
|
|
79
|
+
items: z.array(Session),
|
|
80
|
+
nextCursor: z.string().optional(),
|
|
81
|
+
total: z.number().optional(),
|
|
82
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pi-harness/contracts",
|
|
3
|
+
"version": "1.1.337",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "RPC schema definitions for pi-harness runtime",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"test": "bun test"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"zod": "^3.23.8"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "^5.7.2"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approval schemas for pi-harness
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { Timestamp, UUID, NonEmptyString } from './base.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Approval status
|
|
10
|
+
*/
|
|
11
|
+
export const ApprovalStatus = z.enum([
|
|
12
|
+
'pending',
|
|
13
|
+
'approved',
|
|
14
|
+
'rejected',
|
|
15
|
+
'expired',
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
export type ApprovalStatus = z.infer<typeof ApprovalStatus>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Approval type
|
|
22
|
+
*/
|
|
23
|
+
export const ApprovalType = z.enum([
|
|
24
|
+
'tool_execution',
|
|
25
|
+
'file_write',
|
|
26
|
+
'file_delete',
|
|
27
|
+
'command_execution',
|
|
28
|
+
'network_request',
|
|
29
|
+
'external_action',
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
export type ApprovalType = z.infer<typeof ApprovalType>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Approval definition
|
|
36
|
+
*/
|
|
37
|
+
export const Approval = z.object({
|
|
38
|
+
id: UUID,
|
|
39
|
+
type: ApprovalType,
|
|
40
|
+
status: ApprovalStatus.default('pending'),
|
|
41
|
+
workspaceId: z.string(),
|
|
42
|
+
sessionId: z.string(),
|
|
43
|
+
jobId: z.string().optional(),
|
|
44
|
+
tool: NonEmptyString.optional(),
|
|
45
|
+
command: NonEmptyString.optional(),
|
|
46
|
+
file: NonEmptyString.optional(),
|
|
47
|
+
description: NonEmptyString,
|
|
48
|
+
reason: z.string().optional(),
|
|
49
|
+
requestedAt: Timestamp,
|
|
50
|
+
respondedAt: Timestamp.optional(),
|
|
51
|
+
expiresAt: Timestamp.optional(),
|
|
52
|
+
requestedBy: NonEmptyString,
|
|
53
|
+
approvedBy: NonEmptyString.optional(),
|
|
54
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export type Approval = z.infer<typeof Approval>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Approval request input
|
|
61
|
+
*/
|
|
62
|
+
export const ApprovalRequest = z.object({
|
|
63
|
+
type: ApprovalType,
|
|
64
|
+
workspaceId: z.string(),
|
|
65
|
+
sessionId: z.string(),
|
|
66
|
+
jobId: z.string().optional(),
|
|
67
|
+
tool: NonEmptyString.optional(),
|
|
68
|
+
command: NonEmptyString.optional(),
|
|
69
|
+
file: NonEmptyString.optional(),
|
|
70
|
+
description: NonEmptyString,
|
|
71
|
+
reason: z.string().optional(),
|
|
72
|
+
expiresIn: z.number().int().positive().optional(), // seconds, default 5 min
|
|
73
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export type ApprovalRequest = z.infer<typeof ApprovalRequest>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Approval response input
|
|
80
|
+
*/
|
|
81
|
+
export const ApprovalResponse = z.object({
|
|
82
|
+
id: UUID,
|
|
83
|
+
approved: z.boolean(),
|
|
84
|
+
reason: z.string().optional(),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export type ApprovalResponse = z.infer<typeof ApprovalResponse>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Approval filter
|
|
91
|
+
*/
|
|
92
|
+
export const ApprovalFilter = z.object({
|
|
93
|
+
workspaceId: z.string().optional(),
|
|
94
|
+
sessionId: z.string().optional(),
|
|
95
|
+
jobId: z.string().optional(),
|
|
96
|
+
status: ApprovalStatus.optional(),
|
|
97
|
+
type: ApprovalType.optional(),
|
|
98
|
+
since: Timestamp.optional(),
|
|
99
|
+
until: Timestamp.optional(),
|
|
100
|
+
limit: z.number().int().positive().max(100).default(50),
|
|
101
|
+
cursor: z.string().optional(),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export type ApprovalFilter = z.infer<typeof ApprovalFilter>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Approval list response
|
|
108
|
+
*/
|
|
109
|
+
export const ApprovalList = z.object({
|
|
110
|
+
items: z.array(Approval),
|
|
111
|
+
nextCursor: z.string().optional(),
|
|
112
|
+
total: z.number().optional(),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export type ApprovalList = z.infer<typeof ApprovalList>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base schemas for pi-harness contracts
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base64-encoded content
|
|
9
|
+
*/
|
|
10
|
+
export const Base64Content = z.string().regex(/^[A-Za-z0-9+/]*={0,2}$/);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ISO 8601 timestamp
|
|
14
|
+
*/
|
|
15
|
+
export const Timestamp = z.string().datetime();
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* UUID v4
|
|
19
|
+
*/
|
|
20
|
+
export const UUID = z.string().uuid();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Non-empty string
|
|
24
|
+
*/
|
|
25
|
+
export const NonEmptyString = z.string().min(1);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Positive integer
|
|
29
|
+
*/
|
|
30
|
+
export const PositiveInt = z.number().int().positive();
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Generic success result wrapper
|
|
34
|
+
*/
|
|
35
|
+
export function success<T>(data: T) {
|
|
36
|
+
return { ok: true, data } as const;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Generic error result wrapper
|
|
41
|
+
*/
|
|
42
|
+
export function error(message: string, code?: string) {
|
|
43
|
+
return { ok: false, error: { message, code } } as const;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Result type for operations that can fail
|
|
48
|
+
*/
|
|
49
|
+
export type Result<T, E = { message: string; code?: string }> =
|
|
50
|
+
| { ok: true; data: T }
|
|
51
|
+
| { ok: false; error: E };
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Pagination cursor
|
|
55
|
+
*/
|
|
56
|
+
export interface PageCursor {
|
|
57
|
+
after?: string;
|
|
58
|
+
before?: string;
|
|
59
|
+
limit?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Paginated response
|
|
64
|
+
*/
|
|
65
|
+
export interface Page<T> {
|
|
66
|
+
items: T[];
|
|
67
|
+
nextCursor?: string;
|
|
68
|
+
total?: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Base64 encode utility (pure TypeScript, no DOM dependencies)
|
|
73
|
+
*/
|
|
74
|
+
export function base64Encode(str: string): string {
|
|
75
|
+
// Use Node.js Buffer if available (most common in runtime)
|
|
76
|
+
// Otherwise use manual base64 encoding
|
|
77
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
78
|
+
let result = '';
|
|
79
|
+
let i = 0;
|
|
80
|
+
|
|
81
|
+
while (i < str.length) {
|
|
82
|
+
const a = str.charCodeAt(i++);
|
|
83
|
+
const b = i < str.length ? str.charCodeAt(i++) : 0;
|
|
84
|
+
const c = i < str.length ? str.charCodeAt(i++) : 0;
|
|
85
|
+
|
|
86
|
+
const triplet = (a << 16) | (b << 8) | c;
|
|
87
|
+
|
|
88
|
+
result += chars[(triplet >> 18) & 0x3f];
|
|
89
|
+
result += chars[(triplet >> 12) & 0x3f];
|
|
90
|
+
result += i - 2 < str.length ? chars[(triplet >> 6) & 0x3f] : '=';
|
|
91
|
+
result += i - 1 < str.length ? chars[triplet & 0x3f] : '=';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Base64 decode utility (pure TypeScript, no DOM dependencies)
|
|
99
|
+
*/
|
|
100
|
+
export function base64Decode(str: string): string {
|
|
101
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
102
|
+
let result = '';
|
|
103
|
+
let i = 0;
|
|
104
|
+
|
|
105
|
+
// Remove padding
|
|
106
|
+
const cleanStr = str.replace(/=/g, '');
|
|
107
|
+
|
|
108
|
+
while (i < cleanStr.length) {
|
|
109
|
+
const a = chars.indexOf(cleanStr[i++]);
|
|
110
|
+
const b = i < cleanStr.length ? chars.indexOf(cleanStr[i++]) : 0;
|
|
111
|
+
const c = i < cleanStr.length ? chars.indexOf(cleanStr[i++]) : 0;
|
|
112
|
+
const d = i < cleanStr.length ? chars.indexOf(cleanStr[i++]) : 0;
|
|
113
|
+
|
|
114
|
+
const triplet = (a << 18) | (b << 12) | (c << 6) | d;
|
|
115
|
+
|
|
116
|
+
result += String.fromCharCode((triplet >> 16) & 0xff);
|
|
117
|
+
if (cleanStr[i - 2] !== undefined) {
|
|
118
|
+
result += String.fromCharCode((triplet >> 8) & 0xff);
|
|
119
|
+
}
|
|
120
|
+
if (cleanStr[i - 1] !== undefined) {
|
|
121
|
+
result += String.fromCharCode(triplet & 0xff);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event schemas for pi-harness
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { Timestamp, UUID } from './base.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Event types
|
|
10
|
+
*/
|
|
11
|
+
export const EventType = z.enum([
|
|
12
|
+
'job.created',
|
|
13
|
+
'job.started',
|
|
14
|
+
'job.progress',
|
|
15
|
+
'job.completed',
|
|
16
|
+
'job.failed',
|
|
17
|
+
'job.cancelled',
|
|
18
|
+
'session.started',
|
|
19
|
+
'session.ended',
|
|
20
|
+
'approval.requested',
|
|
21
|
+
'approval.granted',
|
|
22
|
+
'approval.rejected',
|
|
23
|
+
'policy.acknowledged',
|
|
24
|
+
'policy.updated',
|
|
25
|
+
'tool.executed',
|
|
26
|
+
'tool.failed',
|
|
27
|
+
'checkpoint.created',
|
|
28
|
+
'checkpoint.restored',
|
|
29
|
+
'error.occurred',
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
export type EventType = z.infer<typeof EventType>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Base event schema
|
|
36
|
+
*/
|
|
37
|
+
export const Event = z.object({
|
|
38
|
+
id: UUID,
|
|
39
|
+
type: EventType,
|
|
40
|
+
timestamp: Timestamp,
|
|
41
|
+
workspaceId: z.string().optional(),
|
|
42
|
+
sessionId: z.string().optional(),
|
|
43
|
+
jobId: z.string().optional(),
|
|
44
|
+
payload: z.record(z.string(), z.unknown()).optional(),
|
|
45
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export type Event = z.infer<typeof Event>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Event creation input
|
|
52
|
+
*/
|
|
53
|
+
export const EventCreate = z.object({
|
|
54
|
+
type: EventType,
|
|
55
|
+
workspaceId: z.string().optional(),
|
|
56
|
+
sessionId: z.string().optional(),
|
|
57
|
+
jobId: z.string().optional(),
|
|
58
|
+
payload: z.record(z.string(), z.unknown()).optional(),
|
|
59
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export type EventCreate = z.infer<typeof EventCreate>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Event filter for queries
|
|
66
|
+
*/
|
|
67
|
+
export const EventFilter = z.object({
|
|
68
|
+
types: z.array(EventType).optional(),
|
|
69
|
+
workspaceId: z.string().optional(),
|
|
70
|
+
sessionId: z.string().optional(),
|
|
71
|
+
jobId: z.string().optional(),
|
|
72
|
+
since: Timestamp.optional(),
|
|
73
|
+
until: Timestamp.optional(),
|
|
74
|
+
limit: z.number().int().positive().max(1000).default(100),
|
|
75
|
+
cursor: z.string().optional(),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export type EventFilter = z.infer<typeof EventFilter>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pi-harness Contracts Package
|
|
3
|
+
*
|
|
4
|
+
* Type-safe RPC schema definitions for all pi-harness services.
|
|
5
|
+
* Uses Zod for runtime validation.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { schemas } from '@pi-harness/contracts';
|
|
10
|
+
*
|
|
11
|
+
* const result = schemas.JobCreate.parse(input);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export * from './base.js';
|
|
16
|
+
export * from './events.js';
|
|
17
|
+
export * from './jobs.js';
|
|
18
|
+
export * from './sessions.js';
|
|
19
|
+
export * from './projects.js';
|
|
20
|
+
export * from './notifications.js';
|
|
21
|
+
export * from './approvals.js';
|