gateproof 0.2.4 → 0.5.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/README.md +1447 -153
- package/dist/cloudflare/index.d.ts +4 -6
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/index.js +9 -43
- package/dist/cloudflare/index.js.map +1 -1
- package/dist/index.d.ts +263 -75
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1327 -212
- package/dist/index.js.map +1 -1
- package/package.json +18 -48
- package/dist/act.d.ts +0 -78
- package/dist/act.d.ts.map +0 -1
- package/dist/act.js +0 -47
- package/dist/act.js.map +0 -1
- package/dist/action-executors.d.ts +0 -39
- package/dist/action-executors.d.ts.map +0 -1
- package/dist/action-executors.js +0 -195
- package/dist/action-executors.js.map +0 -1
- package/dist/assert.d.ts +0 -59
- package/dist/assert.d.ts.map +0 -1
- package/dist/assert.js +0 -120
- package/dist/assert.js.map +0 -1
- package/dist/authority.d.ts +0 -34
- package/dist/authority.d.ts.map +0 -1
- package/dist/authority.js +0 -141
- package/dist/authority.js.map +0 -1
- package/dist/cli/gateproof.d.ts +0 -3
- package/dist/cli/gateproof.d.ts.map +0 -1
- package/dist/cli/gateproof.js +0 -548
- package/dist/cli/gateproof.js.map +0 -1
- package/dist/cloudflare/analytics.d.ts +0 -9
- package/dist/cloudflare/analytics.d.ts.map +0 -1
- package/dist/cloudflare/analytics.js +0 -98
- package/dist/cloudflare/analytics.js.map +0 -1
- package/dist/cloudflare/cli-stream.d.ts +0 -7
- package/dist/cloudflare/cli-stream.d.ts.map +0 -1
- package/dist/cloudflare/cli-stream.js +0 -85
- package/dist/cloudflare/cli-stream.js.map +0 -1
- package/dist/cloudflare/polling-backend.d.ts +0 -18
- package/dist/cloudflare/polling-backend.d.ts.map +0 -1
- package/dist/cloudflare/polling-backend.js +0 -53
- package/dist/cloudflare/polling-backend.js.map +0 -1
- package/dist/cloudflare/workers-logs.d.ts +0 -9
- package/dist/cloudflare/workers-logs.d.ts.map +0 -1
- package/dist/cloudflare/workers-logs.js +0 -51
- package/dist/cloudflare/workers-logs.js.map +0 -1
- package/dist/constants.d.ts +0 -11
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -11
- package/dist/constants.js.map +0 -1
- package/dist/filepath-backend.d.ts +0 -64
- package/dist/filepath-backend.d.ts.map +0 -1
- package/dist/filepath-backend.js +0 -126
- package/dist/filepath-backend.js.map +0 -1
- package/dist/filepath-protocol.d.ts +0 -214
- package/dist/filepath-protocol.d.ts.map +0 -1
- package/dist/filepath-protocol.js +0 -239
- package/dist/filepath-protocol.js.map +0 -1
- package/dist/filepath-runtime.d.ts +0 -100
- package/dist/filepath-runtime.d.ts.map +0 -1
- package/dist/filepath-runtime.js +0 -190
- package/dist/filepath-runtime.js.map +0 -1
- package/dist/http-backend.d.ts +0 -32
- package/dist/http-backend.d.ts.map +0 -1
- package/dist/http-backend.js +0 -166
- package/dist/http-backend.js.map +0 -1
- package/dist/observe.d.ts +0 -26
- package/dist/observe.d.ts.map +0 -1
- package/dist/observe.js +0 -84
- package/dist/observe.js.map +0 -1
- package/dist/prd/define-prd.d.ts +0 -7
- package/dist/prd/define-prd.d.ts.map +0 -1
- package/dist/prd/define-prd.js +0 -8
- package/dist/prd/define-prd.js.map +0 -1
- package/dist/prd/index.d.ts +0 -7
- package/dist/prd/index.d.ts.map +0 -1
- package/dist/prd/index.js +0 -8
- package/dist/prd/index.js.map +0 -1
- package/dist/prd/loop.d.ts +0 -160
- package/dist/prd/loop.d.ts.map +0 -1
- package/dist/prd/loop.js +0 -462
- package/dist/prd/loop.js.map +0 -1
- package/dist/prd/runner.d.ts +0 -19
- package/dist/prd/runner.d.ts.map +0 -1
- package/dist/prd/runner.js +0 -253
- package/dist/prd/runner.js.map +0 -1
- package/dist/prd/scope-check.d.ts +0 -28
- package/dist/prd/scope-check.d.ts.map +0 -1
- package/dist/prd/scope-check.js +0 -135
- package/dist/prd/scope-check.js.map +0 -1
- package/dist/prd/scope-defaults.d.ts +0 -75
- package/dist/prd/scope-defaults.d.ts.map +0 -1
- package/dist/prd/scope-defaults.js +0 -235
- package/dist/prd/scope-defaults.js.map +0 -1
- package/dist/prd/types.d.ts +0 -101
- package/dist/prd/types.d.ts.map +0 -1
- package/dist/prd/types.js +0 -2
- package/dist/prd/types.js.map +0 -1
- package/dist/provider.d.ts +0 -6
- package/dist/provider.d.ts.map +0 -1
- package/dist/provider.js +0 -2
- package/dist/provider.js.map +0 -1
- package/dist/report.d.ts +0 -137
- package/dist/report.d.ts.map +0 -1
- package/dist/report.js +0 -234
- package/dist/report.js.map +0 -1
- package/dist/test-helpers.d.ts +0 -12
- package/dist/test-helpers.d.ts.map +0 -1
- package/dist/test-helpers.js +0 -33
- package/dist/test-helpers.js.map +0 -1
- package/dist/types.d.ts +0 -41
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -22
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -49
- package/dist/utils.js.map +0 -1
- package/dist/validation.d.ts +0 -6
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -38
- package/dist/validation.js.map +0 -1
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Filepath Agent Protocol (FAP) — Gateproof integration
|
|
3
|
-
*
|
|
4
|
-
* Zod schemas for the NDJSON event stream between Filepath containers
|
|
5
|
-
* and the Gateproof observe layer. Each agent emits structured events
|
|
6
|
-
* on stdout; we parse and map them to Log entries for gate assertions.
|
|
7
|
-
*
|
|
8
|
-
* Protocol source: https://github.com/ACoyfellow/filepath
|
|
9
|
-
*/
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
import type { Log } from "./types";
|
|
12
|
-
export declare const AgentStatus: z.ZodEnum<{
|
|
13
|
-
error: "error";
|
|
14
|
-
idle: "idle";
|
|
15
|
-
thinking: "thinking";
|
|
16
|
-
running: "running";
|
|
17
|
-
done: "done";
|
|
18
|
-
}>;
|
|
19
|
-
export type AgentStatus = z.infer<typeof AgentStatus>;
|
|
20
|
-
export declare const TextEvent: z.ZodObject<{
|
|
21
|
-
type: z.ZodLiteral<"text">;
|
|
22
|
-
content: z.ZodString;
|
|
23
|
-
}, z.core.$strip>;
|
|
24
|
-
export type TextEvent = z.infer<typeof TextEvent>;
|
|
25
|
-
export declare const ToolEvent: z.ZodObject<{
|
|
26
|
-
type: z.ZodLiteral<"tool">;
|
|
27
|
-
name: z.ZodString;
|
|
28
|
-
path: z.ZodOptional<z.ZodString>;
|
|
29
|
-
status: z.ZodEnum<{
|
|
30
|
-
start: "start";
|
|
31
|
-
error: "error";
|
|
32
|
-
done: "done";
|
|
33
|
-
}>;
|
|
34
|
-
output: z.ZodOptional<z.ZodString>;
|
|
35
|
-
}, z.core.$strip>;
|
|
36
|
-
export type ToolEvent = z.infer<typeof ToolEvent>;
|
|
37
|
-
export declare const CommandEvent: z.ZodObject<{
|
|
38
|
-
type: z.ZodLiteral<"command">;
|
|
39
|
-
cmd: z.ZodString;
|
|
40
|
-
status: z.ZodEnum<{
|
|
41
|
-
start: "start";
|
|
42
|
-
error: "error";
|
|
43
|
-
done: "done";
|
|
44
|
-
}>;
|
|
45
|
-
exit: z.ZodOptional<z.ZodNumber>;
|
|
46
|
-
stdout: z.ZodOptional<z.ZodString>;
|
|
47
|
-
stderr: z.ZodOptional<z.ZodString>;
|
|
48
|
-
}, z.core.$strip>;
|
|
49
|
-
export type CommandEvent = z.infer<typeof CommandEvent>;
|
|
50
|
-
export declare const CommitEvent: z.ZodObject<{
|
|
51
|
-
type: z.ZodLiteral<"commit">;
|
|
52
|
-
hash: z.ZodString;
|
|
53
|
-
message: z.ZodString;
|
|
54
|
-
}, z.core.$strip>;
|
|
55
|
-
export type CommitEvent = z.infer<typeof CommitEvent>;
|
|
56
|
-
export declare const SpawnEvent: z.ZodObject<{
|
|
57
|
-
type: z.ZodLiteral<"spawn">;
|
|
58
|
-
name: z.ZodString;
|
|
59
|
-
agent: z.ZodString;
|
|
60
|
-
model: z.ZodString;
|
|
61
|
-
task: z.ZodOptional<z.ZodString>;
|
|
62
|
-
}, z.core.$strip>;
|
|
63
|
-
export type SpawnEvent = z.infer<typeof SpawnEvent>;
|
|
64
|
-
export declare const WorkersEvent: z.ZodObject<{
|
|
65
|
-
type: z.ZodLiteral<"workers">;
|
|
66
|
-
workers: z.ZodArray<z.ZodObject<{
|
|
67
|
-
name: z.ZodString;
|
|
68
|
-
status: z.ZodEnum<{
|
|
69
|
-
error: "error";
|
|
70
|
-
idle: "idle";
|
|
71
|
-
thinking: "thinking";
|
|
72
|
-
running: "running";
|
|
73
|
-
done: "done";
|
|
74
|
-
}>;
|
|
75
|
-
}, z.core.$strip>>;
|
|
76
|
-
}, z.core.$strip>;
|
|
77
|
-
export type WorkersEvent = z.infer<typeof WorkersEvent>;
|
|
78
|
-
export declare const StatusEvent: z.ZodObject<{
|
|
79
|
-
type: z.ZodLiteral<"status">;
|
|
80
|
-
state: z.ZodEnum<{
|
|
81
|
-
error: "error";
|
|
82
|
-
idle: "idle";
|
|
83
|
-
thinking: "thinking";
|
|
84
|
-
running: "running";
|
|
85
|
-
done: "done";
|
|
86
|
-
}>;
|
|
87
|
-
context_pct: z.ZodOptional<z.ZodNumber>;
|
|
88
|
-
}, z.core.$strip>;
|
|
89
|
-
export type StatusEvent = z.infer<typeof StatusEvent>;
|
|
90
|
-
export declare const HandoffEvent: z.ZodObject<{
|
|
91
|
-
type: z.ZodLiteral<"handoff">;
|
|
92
|
-
summary: z.ZodString;
|
|
93
|
-
}, z.core.$strip>;
|
|
94
|
-
export type HandoffEvent = z.infer<typeof HandoffEvent>;
|
|
95
|
-
export declare const DoneEvent: z.ZodObject<{
|
|
96
|
-
type: z.ZodLiteral<"done">;
|
|
97
|
-
summary: z.ZodOptional<z.ZodString>;
|
|
98
|
-
}, z.core.$strip>;
|
|
99
|
-
export type DoneEvent = z.infer<typeof DoneEvent>;
|
|
100
|
-
export declare const AgentEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
101
|
-
type: z.ZodLiteral<"text">;
|
|
102
|
-
content: z.ZodString;
|
|
103
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
104
|
-
type: z.ZodLiteral<"tool">;
|
|
105
|
-
name: z.ZodString;
|
|
106
|
-
path: z.ZodOptional<z.ZodString>;
|
|
107
|
-
status: z.ZodEnum<{
|
|
108
|
-
start: "start";
|
|
109
|
-
error: "error";
|
|
110
|
-
done: "done";
|
|
111
|
-
}>;
|
|
112
|
-
output: z.ZodOptional<z.ZodString>;
|
|
113
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
114
|
-
type: z.ZodLiteral<"command">;
|
|
115
|
-
cmd: z.ZodString;
|
|
116
|
-
status: z.ZodEnum<{
|
|
117
|
-
start: "start";
|
|
118
|
-
error: "error";
|
|
119
|
-
done: "done";
|
|
120
|
-
}>;
|
|
121
|
-
exit: z.ZodOptional<z.ZodNumber>;
|
|
122
|
-
stdout: z.ZodOptional<z.ZodString>;
|
|
123
|
-
stderr: z.ZodOptional<z.ZodString>;
|
|
124
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
125
|
-
type: z.ZodLiteral<"commit">;
|
|
126
|
-
hash: z.ZodString;
|
|
127
|
-
message: z.ZodString;
|
|
128
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
129
|
-
type: z.ZodLiteral<"spawn">;
|
|
130
|
-
name: z.ZodString;
|
|
131
|
-
agent: z.ZodString;
|
|
132
|
-
model: z.ZodString;
|
|
133
|
-
task: z.ZodOptional<z.ZodString>;
|
|
134
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
135
|
-
type: z.ZodLiteral<"workers">;
|
|
136
|
-
workers: z.ZodArray<z.ZodObject<{
|
|
137
|
-
name: z.ZodString;
|
|
138
|
-
status: z.ZodEnum<{
|
|
139
|
-
error: "error";
|
|
140
|
-
idle: "idle";
|
|
141
|
-
thinking: "thinking";
|
|
142
|
-
running: "running";
|
|
143
|
-
done: "done";
|
|
144
|
-
}>;
|
|
145
|
-
}, z.core.$strip>>;
|
|
146
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
147
|
-
type: z.ZodLiteral<"status">;
|
|
148
|
-
state: z.ZodEnum<{
|
|
149
|
-
error: "error";
|
|
150
|
-
idle: "idle";
|
|
151
|
-
thinking: "thinking";
|
|
152
|
-
running: "running";
|
|
153
|
-
done: "done";
|
|
154
|
-
}>;
|
|
155
|
-
context_pct: z.ZodOptional<z.ZodNumber>;
|
|
156
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
157
|
-
type: z.ZodLiteral<"handoff">;
|
|
158
|
-
summary: z.ZodString;
|
|
159
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
160
|
-
type: z.ZodLiteral<"done">;
|
|
161
|
-
summary: z.ZodOptional<z.ZodString>;
|
|
162
|
-
}, z.core.$strip>], "type">;
|
|
163
|
-
export type AgentEvent = z.infer<typeof AgentEvent>;
|
|
164
|
-
export declare const UserMessage: z.ZodObject<{
|
|
165
|
-
type: z.ZodLiteral<"message">;
|
|
166
|
-
from: z.ZodEnum<{
|
|
167
|
-
user: "user";
|
|
168
|
-
parent: "parent";
|
|
169
|
-
system: "system";
|
|
170
|
-
}>;
|
|
171
|
-
content: z.ZodString;
|
|
172
|
-
}, z.core.$strip>;
|
|
173
|
-
export type UserMessage = z.infer<typeof UserMessage>;
|
|
174
|
-
export declare const SignalMessage: z.ZodObject<{
|
|
175
|
-
type: z.ZodLiteral<"signal">;
|
|
176
|
-
action: z.ZodEnum<{
|
|
177
|
-
stop: "stop";
|
|
178
|
-
pause: "pause";
|
|
179
|
-
resume: "resume";
|
|
180
|
-
}>;
|
|
181
|
-
}, z.core.$strip>;
|
|
182
|
-
export type SignalMessage = z.infer<typeof SignalMessage>;
|
|
183
|
-
export declare const AgentInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
184
|
-
type: z.ZodLiteral<"message">;
|
|
185
|
-
from: z.ZodEnum<{
|
|
186
|
-
user: "user";
|
|
187
|
-
parent: "parent";
|
|
188
|
-
system: "system";
|
|
189
|
-
}>;
|
|
190
|
-
content: z.ZodString;
|
|
191
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
192
|
-
type: z.ZodLiteral<"signal">;
|
|
193
|
-
action: z.ZodEnum<{
|
|
194
|
-
stop: "stop";
|
|
195
|
-
pause: "pause";
|
|
196
|
-
resume: "resume";
|
|
197
|
-
}>;
|
|
198
|
-
}, z.core.$strip>], "type">;
|
|
199
|
-
export type AgentInput = z.infer<typeof AgentInput>;
|
|
200
|
-
export declare function parseAgentEvent(line: string): AgentEvent | null;
|
|
201
|
-
export declare function serializeInput(input: AgentInput): string;
|
|
202
|
-
/**
|
|
203
|
-
* Maps a Filepath AgentEvent to a Gateproof Log entry.
|
|
204
|
-
*
|
|
205
|
-
* This is the bridge between the two systems: Filepath's NDJSON protocol
|
|
206
|
-
* becomes observable evidence for gate assertions.
|
|
207
|
-
*/
|
|
208
|
-
export declare function agentEventToLog(event: AgentEvent, agentName?: string): Log;
|
|
209
|
-
/**
|
|
210
|
-
* Parses an NDJSON line and maps it to a Log entry.
|
|
211
|
-
* Returns null for unparseable lines (graceful degradation).
|
|
212
|
-
*/
|
|
213
|
-
export declare function ndjsonLineToLog(line: string, agentName?: string): Log | null;
|
|
214
|
-
//# sourceMappingURL=filepath-protocol.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filepath-protocol.d.ts","sourceRoot":"","sources":["../src/filepath-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAInC,eAAO,MAAM,WAAW;;;;;;EAMtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;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,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAIpD,eAAO,MAAM,WAAW;;;;;;;;iBAItB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,aAAa;;;;;;;iBAGxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;2BAGrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAIpD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAQ/D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAExD;AAsBD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,CAwG1E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAI5E"}
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Filepath Agent Protocol (FAP) — Gateproof integration
|
|
3
|
-
*
|
|
4
|
-
* Zod schemas for the NDJSON event stream between Filepath containers
|
|
5
|
-
* and the Gateproof observe layer. Each agent emits structured events
|
|
6
|
-
* on stdout; we parse and map them to Log entries for gate assertions.
|
|
7
|
-
*
|
|
8
|
-
* Protocol source: https://github.com/ACoyfellow/filepath
|
|
9
|
-
*/
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
// ─── Agent Status ───
|
|
12
|
-
export const AgentStatus = z.enum([
|
|
13
|
-
"idle",
|
|
14
|
-
"thinking",
|
|
15
|
-
"running",
|
|
16
|
-
"done",
|
|
17
|
-
"error",
|
|
18
|
-
]);
|
|
19
|
-
// ─── Output Events (agent stdout → gateproof) ───
|
|
20
|
-
export const TextEvent = z.object({
|
|
21
|
-
type: z.literal("text"),
|
|
22
|
-
content: z.string(),
|
|
23
|
-
});
|
|
24
|
-
export const ToolEvent = z.object({
|
|
25
|
-
type: z.literal("tool"),
|
|
26
|
-
name: z.string(),
|
|
27
|
-
path: z.string().optional(),
|
|
28
|
-
status: z.enum(["start", "done", "error"]),
|
|
29
|
-
output: z.string().optional(),
|
|
30
|
-
});
|
|
31
|
-
export const CommandEvent = z.object({
|
|
32
|
-
type: z.literal("command"),
|
|
33
|
-
cmd: z.string(),
|
|
34
|
-
status: z.enum(["start", "done", "error"]),
|
|
35
|
-
exit: z.number().optional(),
|
|
36
|
-
stdout: z.string().optional(),
|
|
37
|
-
stderr: z.string().optional(),
|
|
38
|
-
});
|
|
39
|
-
export const CommitEvent = z.object({
|
|
40
|
-
type: z.literal("commit"),
|
|
41
|
-
hash: z.string(),
|
|
42
|
-
message: z.string(),
|
|
43
|
-
});
|
|
44
|
-
export const SpawnEvent = z.object({
|
|
45
|
-
type: z.literal("spawn"),
|
|
46
|
-
name: z.string(),
|
|
47
|
-
agent: z.string(),
|
|
48
|
-
model: z.string(),
|
|
49
|
-
task: z.string().optional(),
|
|
50
|
-
});
|
|
51
|
-
export const WorkersEvent = z.object({
|
|
52
|
-
type: z.literal("workers"),
|
|
53
|
-
workers: z.array(z.object({
|
|
54
|
-
name: z.string(),
|
|
55
|
-
status: AgentStatus,
|
|
56
|
-
})),
|
|
57
|
-
});
|
|
58
|
-
export const StatusEvent = z.object({
|
|
59
|
-
type: z.literal("status"),
|
|
60
|
-
state: AgentStatus,
|
|
61
|
-
context_pct: z.number().min(0).max(1).optional(),
|
|
62
|
-
});
|
|
63
|
-
export const HandoffEvent = z.object({
|
|
64
|
-
type: z.literal("handoff"),
|
|
65
|
-
summary: z.string(),
|
|
66
|
-
});
|
|
67
|
-
export const DoneEvent = z.object({
|
|
68
|
-
type: z.literal("done"),
|
|
69
|
-
summary: z.string().optional(),
|
|
70
|
-
});
|
|
71
|
-
export const AgentEvent = z.discriminatedUnion("type", [
|
|
72
|
-
TextEvent,
|
|
73
|
-
ToolEvent,
|
|
74
|
-
CommandEvent,
|
|
75
|
-
CommitEvent,
|
|
76
|
-
SpawnEvent,
|
|
77
|
-
WorkersEvent,
|
|
78
|
-
StatusEvent,
|
|
79
|
-
HandoffEvent,
|
|
80
|
-
DoneEvent,
|
|
81
|
-
]);
|
|
82
|
-
// ─── Input Messages (gateproof → agent stdin) ───
|
|
83
|
-
export const UserMessage = z.object({
|
|
84
|
-
type: z.literal("message"),
|
|
85
|
-
from: z.enum(["user", "parent", "system"]),
|
|
86
|
-
content: z.string(),
|
|
87
|
-
});
|
|
88
|
-
export const SignalMessage = z.object({
|
|
89
|
-
type: z.literal("signal"),
|
|
90
|
-
action: z.enum(["stop", "pause", "resume"]),
|
|
91
|
-
});
|
|
92
|
-
export const AgentInput = z.discriminatedUnion("type", [
|
|
93
|
-
UserMessage,
|
|
94
|
-
SignalMessage,
|
|
95
|
-
]);
|
|
96
|
-
// ─── NDJSON Parsing ───
|
|
97
|
-
export function parseAgentEvent(line) {
|
|
98
|
-
try {
|
|
99
|
-
const json = JSON.parse(line);
|
|
100
|
-
const result = AgentEvent.safeParse(json);
|
|
101
|
-
return result.success ? result.data : null;
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
export function serializeInput(input) {
|
|
108
|
-
return JSON.stringify(input);
|
|
109
|
-
}
|
|
110
|
-
// ─── Event → Log Mapping ───
|
|
111
|
-
function statusToLogStatus(status) {
|
|
112
|
-
switch (status) {
|
|
113
|
-
case "start": return "start";
|
|
114
|
-
case "done": return "success";
|
|
115
|
-
case "error": return "error";
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function agentStateToLogStatus(state) {
|
|
119
|
-
switch (state) {
|
|
120
|
-
case "idle": return "info";
|
|
121
|
-
case "thinking": return "start";
|
|
122
|
-
case "running": return "start";
|
|
123
|
-
case "done": return "success";
|
|
124
|
-
case "error": return "error";
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Maps a Filepath AgentEvent to a Gateproof Log entry.
|
|
129
|
-
*
|
|
130
|
-
* This is the bridge between the two systems: Filepath's NDJSON protocol
|
|
131
|
-
* becomes observable evidence for gate assertions.
|
|
132
|
-
*/
|
|
133
|
-
export function agentEventToLog(event, agentName) {
|
|
134
|
-
const base = {
|
|
135
|
-
timestamp: new Date().toISOString(),
|
|
136
|
-
stage: agentName ?? "agent",
|
|
137
|
-
};
|
|
138
|
-
switch (event.type) {
|
|
139
|
-
case "text":
|
|
140
|
-
return {
|
|
141
|
-
...base,
|
|
142
|
-
action: "text",
|
|
143
|
-
status: "info",
|
|
144
|
-
data: { content: event.content },
|
|
145
|
-
};
|
|
146
|
-
case "tool":
|
|
147
|
-
return {
|
|
148
|
-
...base,
|
|
149
|
-
action: `tool:${event.name}`,
|
|
150
|
-
status: statusToLogStatus(event.status),
|
|
151
|
-
data: {
|
|
152
|
-
name: event.name,
|
|
153
|
-
...(event.path && { path: event.path }),
|
|
154
|
-
...(event.output && { output: event.output }),
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
case "command":
|
|
158
|
-
return {
|
|
159
|
-
...base,
|
|
160
|
-
action: `cmd:${event.cmd}`,
|
|
161
|
-
status: statusToLogStatus(event.status),
|
|
162
|
-
data: {
|
|
163
|
-
cmd: event.cmd,
|
|
164
|
-
...(event.exit !== undefined && { exit: event.exit }),
|
|
165
|
-
...(event.stdout && { stdout: event.stdout }),
|
|
166
|
-
...(event.stderr && { stderr: event.stderr }),
|
|
167
|
-
},
|
|
168
|
-
...(event.status === "error" && event.stderr && {
|
|
169
|
-
error: {
|
|
170
|
-
tag: "CommandError",
|
|
171
|
-
message: event.stderr,
|
|
172
|
-
},
|
|
173
|
-
}),
|
|
174
|
-
};
|
|
175
|
-
case "commit":
|
|
176
|
-
return {
|
|
177
|
-
...base,
|
|
178
|
-
action: "commit",
|
|
179
|
-
status: "success",
|
|
180
|
-
data: { hash: event.hash, message: event.message },
|
|
181
|
-
};
|
|
182
|
-
case "spawn":
|
|
183
|
-
return {
|
|
184
|
-
...base,
|
|
185
|
-
action: "spawn",
|
|
186
|
-
status: "start",
|
|
187
|
-
data: {
|
|
188
|
-
name: event.name,
|
|
189
|
-
agent: event.agent,
|
|
190
|
-
model: event.model,
|
|
191
|
-
...(event.task && { task: event.task }),
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
case "workers":
|
|
195
|
-
return {
|
|
196
|
-
...base,
|
|
197
|
-
action: "workers",
|
|
198
|
-
status: "info",
|
|
199
|
-
data: { workers: event.workers },
|
|
200
|
-
};
|
|
201
|
-
case "status":
|
|
202
|
-
return {
|
|
203
|
-
...base,
|
|
204
|
-
action: "status",
|
|
205
|
-
status: agentStateToLogStatus(event.state),
|
|
206
|
-
data: {
|
|
207
|
-
state: event.state,
|
|
208
|
-
...(event.context_pct !== undefined && { context_pct: event.context_pct }),
|
|
209
|
-
},
|
|
210
|
-
};
|
|
211
|
-
case "handoff":
|
|
212
|
-
return {
|
|
213
|
-
...base,
|
|
214
|
-
action: "handoff",
|
|
215
|
-
status: "info",
|
|
216
|
-
data: { summary: event.summary },
|
|
217
|
-
};
|
|
218
|
-
case "done":
|
|
219
|
-
return {
|
|
220
|
-
...base,
|
|
221
|
-
action: "done",
|
|
222
|
-
status: "success",
|
|
223
|
-
data: {
|
|
224
|
-
...(event.summary && { summary: event.summary }),
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Parses an NDJSON line and maps it to a Log entry.
|
|
231
|
-
* Returns null for unparseable lines (graceful degradation).
|
|
232
|
-
*/
|
|
233
|
-
export function ndjsonLineToLog(line, agentName) {
|
|
234
|
-
const event = parseAgentEvent(line);
|
|
235
|
-
if (!event)
|
|
236
|
-
return null;
|
|
237
|
-
return agentEventToLog(event, agentName);
|
|
238
|
-
}
|
|
239
|
-
//# sourceMappingURL=filepath-protocol.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filepath-protocol.js","sourceRoot":"","sources":["../src/filepath-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,uBAAuB;AAEvB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC;IAChC,MAAM;IACN,UAAU;IACV,SAAS;IACT,MAAM;IACN,OAAO;CACR,CAAC,CAAC;AAGH,mDAAmD;AAEnD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1B,GAAG,EAAE,CAAC,CAAC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K,CAAC,WAAW,EAAE,CAAC;iBAC3E;aACF,CAAC;QAEJ,KAAK,SAAS;YACZ,OAAO;gBACL,GAAG,IAAI;gBACP,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;aACjC,CAAC;QAEJ,KAAK,MAAM;YACT,OAAO;gBACL,GAAG,IAAI;gBACP,MAAM,EAAE,MAAM;gBACd,MAAM,EAAE,SAAS;gBACjB,IAAI,EAAE;oBACJ,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;iBACjD;aACF,CAAC;IACN,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,SAAkB;IAC9D,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cloudflare Sandbox Runtime — real FilepathRuntime for Cloudflare Workers
|
|
3
|
-
*
|
|
4
|
-
* Spawns agent processes inside Cloudflare Sandbox containers,
|
|
5
|
-
* wires NDJSON stdout to a broadcast AsyncIterable (solving the
|
|
6
|
-
* dual-reader problem), and maps stdin/stop to the sandbox process.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { getSandbox } from "@cloudflare/sandbox";
|
|
11
|
-
* import { CloudflareSandboxRuntime, setFilepathRuntime } from "gateproof";
|
|
12
|
-
*
|
|
13
|
-
* setFilepathRuntime(new CloudflareSandboxRuntime({
|
|
14
|
-
* getSandbox: (config) => getSandbox(env.Sandbox, `agent-${config.name}-${Date.now()}`),
|
|
15
|
-
* }));
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
import type { FilepathContainer, FilepathRuntime } from "./filepath-backend";
|
|
19
|
-
import type { AgentActConfig } from "./act";
|
|
20
|
-
/**
|
|
21
|
-
* Minimal interface for a Cloudflare Sandbox instance.
|
|
22
|
-
* Matches the shape returned by `getSandbox()` from `@cloudflare/sandbox`.
|
|
23
|
-
*/
|
|
24
|
-
export interface SandboxInstance {
|
|
25
|
-
startProcess(command: string[], options?: {
|
|
26
|
-
env?: Record<string, string>;
|
|
27
|
-
cwd?: string;
|
|
28
|
-
}): Promise<SandboxProcess>;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Minimal interface for a sandbox process.
|
|
32
|
-
* Matches the shape returned by `sandbox.startProcess()`.
|
|
33
|
-
*/
|
|
34
|
-
export interface SandboxProcess {
|
|
35
|
-
stdout: ReadableStream<Uint8Array>;
|
|
36
|
-
stdin?: WritableStream<Uint8Array>;
|
|
37
|
-
}
|
|
38
|
-
export interface CloudflareSandboxRuntimeOptions {
|
|
39
|
-
/**
|
|
40
|
-
* Factory that creates a sandbox for each agent spawn.
|
|
41
|
-
* Called once per `spawn()` invocation.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```ts
|
|
45
|
-
* import { getSandbox } from "@cloudflare/sandbox";
|
|
46
|
-
* getSandbox: (config) => getSandbox(env.Sandbox, `agent-${config.name}-${Date.now()}`)
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
getSandbox: (config: AgentActConfig) => SandboxInstance | Promise<SandboxInstance>;
|
|
50
|
-
/**
|
|
51
|
-
* Override the command run inside the container.
|
|
52
|
-
* Receives the agent config and returns an argv array.
|
|
53
|
-
*
|
|
54
|
-
* Default: `[config.agent]` (the agent field is used as the binary name).
|
|
55
|
-
*/
|
|
56
|
-
command?: (config: AgentActConfig) => string[];
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* A broadcast AsyncIterable that supports multiple concurrent readers.
|
|
60
|
-
*
|
|
61
|
-
* Each call to `[Symbol.asyncIterator]()` returns an independent iterator
|
|
62
|
-
* that starts from the beginning of the buffer and sees all items,
|
|
63
|
-
* including those pushed after the iterator was created.
|
|
64
|
-
*
|
|
65
|
-
* This solves the dual-reader problem: both the executor (lifecycle drain)
|
|
66
|
-
* and observe layer (log mapping) can read from the same `container.stdout`
|
|
67
|
-
* without interfering with each other.
|
|
68
|
-
*/
|
|
69
|
-
export declare class BroadcastIterable<T> implements AsyncIterable<T> {
|
|
70
|
-
private buffer;
|
|
71
|
-
private waiters;
|
|
72
|
-
private isDone;
|
|
73
|
-
push(item: T): void;
|
|
74
|
-
end(): void;
|
|
75
|
-
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Reads a `ReadableStream<Uint8Array>` and pushes complete NDJSON lines
|
|
79
|
-
* to a `BroadcastIterable<string>`.
|
|
80
|
-
*
|
|
81
|
-
* Handles:
|
|
82
|
-
* - Partial line buffering (chunks may split across line boundaries)
|
|
83
|
-
* - Stream completion (signals `end()` on the broadcast)
|
|
84
|
-
* - Stream errors (signals `end()` so readers don't hang)
|
|
85
|
-
*/
|
|
86
|
-
export declare function pipeReadableStreamToLines(stream: ReadableStream<Uint8Array>, broadcast: BroadcastIterable<string>): Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* Real FilepathRuntime backed by Cloudflare Sandbox.
|
|
89
|
-
*
|
|
90
|
-
* Spawns agent processes inside isolated Cloudflare Sandbox containers.
|
|
91
|
-
* Stdout is parsed as NDJSON lines and exposed as a broadcast
|
|
92
|
-
* `AsyncIterable<string>` so both the executor and observe layer
|
|
93
|
-
* can read concurrently.
|
|
94
|
-
*/
|
|
95
|
-
export declare class CloudflareSandboxRuntime implements FilepathRuntime {
|
|
96
|
-
private readonly options;
|
|
97
|
-
constructor(options: CloudflareSandboxRuntimeOptions);
|
|
98
|
-
spawn(config: AgentActConfig): Promise<FilepathContainer>;
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=filepath-runtime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filepath-runtime.d.ts","sourceRoot":"","sources":["../src/filepath-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,CACV,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GACvD,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,+BAA+B;IAC9C;;;;;;;;;OASG;IACH,UAAU,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEnF;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,MAAM,EAAE,CAAC;CAChD;AAED;;;;;;;;;;GAUG;AACH,qBAAa,iBAAiB,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAC3D,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,MAAM,CAAS;IAEvB,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAMnB,GAAG,IAAI,IAAI;IAMX,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