@agentic-ops/engine-sdk 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/README.md +3 -0
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/worker.cjs +68 -0
- package/dist/worker.d.cts +12 -0
- package/dist/worker.d.ts +12 -0
- package/dist/worker.js +37 -0
- package/dist/workflow.cjs +663 -0
- package/dist/workflow.d.cts +16 -0
- package/dist/workflow.d.ts +16 -0
- package/dist/workflow.js +634 -0
- package/package.json +46 -0
package/dist/workflow.js
ADDED
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
import "./chunk-3RG5ZIWI.js";
|
|
2
|
+
|
|
3
|
+
// src/workflow.ts
|
|
4
|
+
import { proxyActivities, executeChild, workflowInfo } from "@temporalio/workflow";
|
|
5
|
+
import { defaultPayloadConverter } from "@temporalio/common";
|
|
6
|
+
|
|
7
|
+
// ../contracts/src/stage.ts
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
var StageSchema = z.enum([
|
|
10
|
+
"context",
|
|
11
|
+
"assess",
|
|
12
|
+
"design",
|
|
13
|
+
"plan",
|
|
14
|
+
"implement",
|
|
15
|
+
"full_verify",
|
|
16
|
+
"review",
|
|
17
|
+
"pr",
|
|
18
|
+
"pr_babysit",
|
|
19
|
+
"done",
|
|
20
|
+
"failed",
|
|
21
|
+
"platform",
|
|
22
|
+
"bughunt",
|
|
23
|
+
"agent"
|
|
24
|
+
]);
|
|
25
|
+
var TaskStatusSchema = z.enum(["pending", "running", "blocked", "done", "failed"]);
|
|
26
|
+
var BlockReasonSchema = z.enum([
|
|
27
|
+
"needs-clarification",
|
|
28
|
+
"iteration-brake",
|
|
29
|
+
"token-brake",
|
|
30
|
+
"babysit-brake",
|
|
31
|
+
"max-attempts",
|
|
32
|
+
"hook-required-failed",
|
|
33
|
+
// A LiteLLM virtual key's hard spend cap, not a token-count brake -- kept
|
|
34
|
+
// distinct from 'token-brake' since the two are independent enforcement
|
|
35
|
+
// layers (ARCHITECTURE.md §7) that can trip for unrelated reasons.
|
|
36
|
+
"budget-exceeded",
|
|
37
|
+
// A prompt-started devCycle (no pre-resolved config) whose repo isn't in
|
|
38
|
+
// the worker's merged static+managed registry -- set together with
|
|
39
|
+
// status 'failed' as a fail-fast, not a resumable block (prompt-devcycle
|
|
40
|
+
// design §5/§7).
|
|
41
|
+
"unregistered-repo"
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
// ../contracts/src/model.ts
|
|
45
|
+
import { z as z2 } from "zod";
|
|
46
|
+
var ModelRefSchema = z2.object({
|
|
47
|
+
// 'litellm' is a transport kind (an HTTP call through the LiteLLM gateway),
|
|
48
|
+
// not a provider -- `model` is the LiteLLM-side model_list alias (e.g.
|
|
49
|
+
// "zai-glm-4.6"), never a raw provider string. See agentops-platform's
|
|
50
|
+
// litellm-deploy-design.md for why that indirection matters.
|
|
51
|
+
backend: z2.enum(["claude", "cursor", "pi", "codex", "stub", "litellm"]),
|
|
52
|
+
model: z2.string().min(1),
|
|
53
|
+
effort: z2.enum(["low", "medium", "high", "xhigh", "max"]).optional()
|
|
54
|
+
});
|
|
55
|
+
var BrakesSchema = z2.object({
|
|
56
|
+
maxImplementAttempts: z2.number().int().positive().default(3),
|
|
57
|
+
maxIterations: z2.number().int().positive(),
|
|
58
|
+
maxTokens: z2.number().int().positive(),
|
|
59
|
+
maxBabysitRounds: z2.number().int().positive()
|
|
60
|
+
});
|
|
61
|
+
var RoutingSchema = z2.object({
|
|
62
|
+
context: ModelRefSchema.optional(),
|
|
63
|
+
assess: ModelRefSchema.optional(),
|
|
64
|
+
design: ModelRefSchema.optional(),
|
|
65
|
+
plan: ModelRefSchema.optional(),
|
|
66
|
+
implement: ModelRefSchema.optional(),
|
|
67
|
+
full_verify: ModelRefSchema.optional(),
|
|
68
|
+
review: ModelRefSchema.optional(),
|
|
69
|
+
pr: ModelRefSchema.optional(),
|
|
70
|
+
pr_babysit: ModelRefSchema.optional(),
|
|
71
|
+
bughunt: ModelRefSchema.optional(),
|
|
72
|
+
agent: ModelRefSchema.optional()
|
|
73
|
+
});
|
|
74
|
+
var StageTimeoutSchema = z2.object({
|
|
75
|
+
idleTimeoutMs: z2.number().int().positive().optional(),
|
|
76
|
+
timeoutMs: z2.number().int().positive().optional()
|
|
77
|
+
});
|
|
78
|
+
var TimeoutsSchema = z2.object({
|
|
79
|
+
context: StageTimeoutSchema.optional(),
|
|
80
|
+
assess: StageTimeoutSchema.optional(),
|
|
81
|
+
design: StageTimeoutSchema.optional(),
|
|
82
|
+
plan: StageTimeoutSchema.optional(),
|
|
83
|
+
implement: StageTimeoutSchema.optional(),
|
|
84
|
+
full_verify: StageTimeoutSchema.optional(),
|
|
85
|
+
review: StageTimeoutSchema.optional(),
|
|
86
|
+
pr: StageTimeoutSchema.optional(),
|
|
87
|
+
pr_babysit: StageTimeoutSchema.optional(),
|
|
88
|
+
bughunt: StageTimeoutSchema.optional(),
|
|
89
|
+
agent: StageTimeoutSchema.optional()
|
|
90
|
+
});
|
|
91
|
+
var StageToggleSchema = z2.object({
|
|
92
|
+
assess: z2.boolean().optional(),
|
|
93
|
+
triage: z2.boolean().optional()
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// ../contracts/src/project-config.ts
|
|
97
|
+
import { z as z3, ZodError } from "zod";
|
|
98
|
+
var VerifyServiceReadinessSchema = z3.discriminatedUnion("type", [
|
|
99
|
+
z3.object({ type: z3.literal("exec"), command: z3.array(z3.string()).min(1) }),
|
|
100
|
+
z3.object({ type: z3.literal("tcpSocket"), port: z3.number().int().positive() })
|
|
101
|
+
]);
|
|
102
|
+
var VerifyServiceSchema = z3.object({
|
|
103
|
+
name: z3.string().min(1),
|
|
104
|
+
image: z3.string().min(1),
|
|
105
|
+
env: z3.record(z3.string(), z3.string()).optional(),
|
|
106
|
+
readiness: VerifyServiceReadinessSchema
|
|
107
|
+
});
|
|
108
|
+
var ProjectConfigSchema = z3.object({
|
|
109
|
+
image: z3.string().min(1).optional(),
|
|
110
|
+
services: z3.array(VerifyServiceSchema).optional(),
|
|
111
|
+
initCommands: z3.array(z3.string()).optional(),
|
|
112
|
+
fastVerifyCommands: z3.array(z3.string()).optional(),
|
|
113
|
+
fullVerifyCommands: z3.array(z3.string()).optional(),
|
|
114
|
+
stages: StageToggleSchema,
|
|
115
|
+
routing: RoutingSchema,
|
|
116
|
+
escalation: ModelRefSchema.optional(),
|
|
117
|
+
brakes: BrakesSchema,
|
|
118
|
+
timeouts: TimeoutsSchema.optional()
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// ../contracts/src/task-input.ts
|
|
122
|
+
import { z as z4 } from "zod";
|
|
123
|
+
var TaskInputSchema = z4.object({
|
|
124
|
+
taskId: z4.string().min(1),
|
|
125
|
+
project: z4.string().min(1),
|
|
126
|
+
repo: z4.string().min(1),
|
|
127
|
+
issueRef: z4.string().optional(),
|
|
128
|
+
goal: z4.string().min(1),
|
|
129
|
+
// Optional since the prompt-devcycle design (2026-07-09): when absent, the
|
|
130
|
+
// devCycle workflow resolves it on the worker via resolveRepoConfig.
|
|
131
|
+
// Gateway/CLI/platform-children keep pre-resolving and passing it.
|
|
132
|
+
config: ProjectConfigSchema.optional()
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// ../contracts/src/dev-cycle-state.ts
|
|
136
|
+
import { z as z5 } from "zod";
|
|
137
|
+
var DevCycleStateSchema = z5.object({
|
|
138
|
+
taskId: z5.string().min(1),
|
|
139
|
+
stage: StageSchema,
|
|
140
|
+
status: TaskStatusSchema,
|
|
141
|
+
blockReason: BlockReasonSchema.nullable(),
|
|
142
|
+
implementAttempts: z5.number().int().nonnegative(),
|
|
143
|
+
iterations: z5.number().int().nonnegative(),
|
|
144
|
+
cumulativeTokens: z5.number().int().nonnegative(),
|
|
145
|
+
babysitRounds: z5.number().int().nonnegative(),
|
|
146
|
+
prRef: z5.string().nullable(),
|
|
147
|
+
workspaceRef: z5.string(),
|
|
148
|
+
branch: z5.string()
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// ../contracts/src/stage-result.ts
|
|
152
|
+
import { z as z6 } from "zod";
|
|
153
|
+
var StageSourceSchema = z6.enum(["agent", "human", "triage"]);
|
|
154
|
+
var StageOutcomeSchema = z6.enum(["pass", "fail", "unparseable", "skipped"]);
|
|
155
|
+
var StageResultSchema = z6.object({
|
|
156
|
+
stage: StageSchema,
|
|
157
|
+
source: StageSourceSchema,
|
|
158
|
+
contentHash: z6.string().min(1),
|
|
159
|
+
tokens: z6.number().int().nonnegative(),
|
|
160
|
+
outcome: StageOutcomeSchema
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// ../contracts/src/verdict.ts
|
|
164
|
+
import { z as z7 } from "zod";
|
|
165
|
+
var VerdictKindSchema = z7.enum(["pass", "fail", "unparseable"]);
|
|
166
|
+
var VerdictSchema = z7.object({
|
|
167
|
+
kind: VerdictKindSchema,
|
|
168
|
+
findings: z7.array(z7.string()).optional()
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// ../contracts/src/agent-run.ts
|
|
172
|
+
import { z as z8 } from "zod";
|
|
173
|
+
var AgentRunLimitsSchema = z8.object({
|
|
174
|
+
maxTokens: z8.number().int().positive(),
|
|
175
|
+
idleTimeoutMs: z8.number().int().positive().optional(),
|
|
176
|
+
timeoutMs: z8.number().int().positive()
|
|
177
|
+
});
|
|
178
|
+
var EffortSchema = z8.enum(["low", "medium", "high", "xhigh", "max"]);
|
|
179
|
+
var AgentRunRequestSchema = z8.object({
|
|
180
|
+
taskId: z8.string().min(1),
|
|
181
|
+
stage: StageSchema,
|
|
182
|
+
attempt: z8.number().int().positive(),
|
|
183
|
+
callIndex: z8.number().int().positive().default(1),
|
|
184
|
+
backend: z8.string().min(1),
|
|
185
|
+
model: z8.string().min(1),
|
|
186
|
+
effort: EffortSchema.optional(),
|
|
187
|
+
image: z8.string().min(1).optional(),
|
|
188
|
+
services: z8.array(VerifyServiceSchema).optional(),
|
|
189
|
+
promptRef: z8.string().min(1),
|
|
190
|
+
promptContext: z8.record(z8.string(), z8.unknown()).default({}),
|
|
191
|
+
promptSource: z8.object({ repo: z8.string().min(1), commit: z8.string().min(1), path: z8.string().min(1) }).optional(),
|
|
192
|
+
workspaceRef: z8.string().min(1),
|
|
193
|
+
limits: AgentRunLimitsSchema
|
|
194
|
+
});
|
|
195
|
+
var BackendRunRequestSchema = AgentRunRequestSchema.omit({ promptRef: true, promptContext: true }).extend({
|
|
196
|
+
prompt: z8.string().min(1)
|
|
197
|
+
});
|
|
198
|
+
var AgentRunResultSchema = z8.object({
|
|
199
|
+
output: z8.string(),
|
|
200
|
+
tokensIn: z8.number().int().nonnegative(),
|
|
201
|
+
tokensOut: z8.number().int().nonnegative(),
|
|
202
|
+
wallMs: z8.number().int().nonnegative()
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// ../contracts/src/run-stats.ts
|
|
206
|
+
import { z as z9 } from "zod";
|
|
207
|
+
var RunStatsSchema = z9.object({
|
|
208
|
+
taskId: z9.string().min(1),
|
|
209
|
+
stage: StageSchema,
|
|
210
|
+
backend: z9.string().min(1),
|
|
211
|
+
model: z9.string().min(1),
|
|
212
|
+
tokensIn: z9.number().int().nonnegative(),
|
|
213
|
+
tokensOut: z9.number().int().nonnegative(),
|
|
214
|
+
wallMs: z9.number().int().nonnegative(),
|
|
215
|
+
outcome: StageOutcomeSchema,
|
|
216
|
+
// provenance + attribution (design §7) — optional so existing call sites compile
|
|
217
|
+
promptHash: z9.string().optional(),
|
|
218
|
+
promptSource: z9.string().optional(),
|
|
219
|
+
project: z9.string().optional(),
|
|
220
|
+
workflowType: z9.string().optional()
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// ../contracts/src/pr-feedback.ts
|
|
224
|
+
import { z as z10 } from "zod";
|
|
225
|
+
|
|
226
|
+
// ../contracts/src/sha256.ts
|
|
227
|
+
var K = new Uint32Array([
|
|
228
|
+
1116352408,
|
|
229
|
+
1899447441,
|
|
230
|
+
3049323471,
|
|
231
|
+
3921009573,
|
|
232
|
+
961987163,
|
|
233
|
+
1508970993,
|
|
234
|
+
2453635748,
|
|
235
|
+
2870763221,
|
|
236
|
+
3624381080,
|
|
237
|
+
310598401,
|
|
238
|
+
607225278,
|
|
239
|
+
1426881987,
|
|
240
|
+
1925078388,
|
|
241
|
+
2162078206,
|
|
242
|
+
2614888103,
|
|
243
|
+
3248222580,
|
|
244
|
+
3835390401,
|
|
245
|
+
4022224774,
|
|
246
|
+
264347078,
|
|
247
|
+
604807628,
|
|
248
|
+
770255983,
|
|
249
|
+
1249150122,
|
|
250
|
+
1555081692,
|
|
251
|
+
1996064986,
|
|
252
|
+
2554220882,
|
|
253
|
+
2821834349,
|
|
254
|
+
2952996808,
|
|
255
|
+
3210313671,
|
|
256
|
+
3336571891,
|
|
257
|
+
3584528711,
|
|
258
|
+
113926993,
|
|
259
|
+
338241895,
|
|
260
|
+
666307205,
|
|
261
|
+
773529912,
|
|
262
|
+
1294757372,
|
|
263
|
+
1396182291,
|
|
264
|
+
1695183700,
|
|
265
|
+
1986661051,
|
|
266
|
+
2177026350,
|
|
267
|
+
2456956037,
|
|
268
|
+
2730485921,
|
|
269
|
+
2820302411,
|
|
270
|
+
3259730800,
|
|
271
|
+
3345764771,
|
|
272
|
+
3516065817,
|
|
273
|
+
3600352804,
|
|
274
|
+
4094571909,
|
|
275
|
+
275423344,
|
|
276
|
+
430227734,
|
|
277
|
+
506948616,
|
|
278
|
+
659060556,
|
|
279
|
+
883997877,
|
|
280
|
+
958139571,
|
|
281
|
+
1322822218,
|
|
282
|
+
1537002063,
|
|
283
|
+
1747873779,
|
|
284
|
+
1955562222,
|
|
285
|
+
2024104815,
|
|
286
|
+
2227730452,
|
|
287
|
+
2361852424,
|
|
288
|
+
2428436474,
|
|
289
|
+
2756734187,
|
|
290
|
+
3204031479,
|
|
291
|
+
3329325298
|
|
292
|
+
]);
|
|
293
|
+
|
|
294
|
+
// ../contracts/src/pr-feedback.ts
|
|
295
|
+
var CiStatusSchema = z10.enum(["pending", "green", "failed"]);
|
|
296
|
+
var PrCommentSchema = z10.object({
|
|
297
|
+
id: z10.string().min(1),
|
|
298
|
+
body: z10.string(),
|
|
299
|
+
resolved: z10.boolean()
|
|
300
|
+
});
|
|
301
|
+
var PrFeedbackSchema = z10.object({
|
|
302
|
+
ciStatus: CiStatusSchema,
|
|
303
|
+
unresolvedThreads: z10.number().int().nonnegative(),
|
|
304
|
+
comments: z10.array(PrCommentSchema)
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// ../contracts/src/managed-project.ts
|
|
308
|
+
import { z as z11 } from "zod";
|
|
309
|
+
var BaseManagedProjectFields = {
|
|
310
|
+
id: z11.string().uuid(),
|
|
311
|
+
project: z11.string().min(1),
|
|
312
|
+
repo: z11.string().min(1),
|
|
313
|
+
credentialSet: z11.boolean(),
|
|
314
|
+
// GitHub token set? never the token itself
|
|
315
|
+
config: ProjectConfigSchema.nullable(),
|
|
316
|
+
createdAt: z11.string(),
|
|
317
|
+
updatedAt: z11.string()
|
|
318
|
+
};
|
|
319
|
+
var ManagedProjectSchema = z11.discriminatedUnion("trackerType", [
|
|
320
|
+
z11.object({ ...BaseManagedProjectFields, trackerType: z11.literal("github") }),
|
|
321
|
+
z11.object({
|
|
322
|
+
...BaseManagedProjectFields,
|
|
323
|
+
trackerType: z11.literal("linear"),
|
|
324
|
+
linearTeamKey: z11.string().min(1),
|
|
325
|
+
linearTriggerLabelId: z11.string().min(1),
|
|
326
|
+
linearCredentialSet: z11.boolean()
|
|
327
|
+
// Linear token set? never the token itself
|
|
328
|
+
})
|
|
329
|
+
]);
|
|
330
|
+
var UpsertManagedProjectRequestSchema = z11.object({
|
|
331
|
+
project: z11.string().min(1),
|
|
332
|
+
repo: z11.string().min(1),
|
|
333
|
+
token: z11.string().min(1).optional(),
|
|
334
|
+
config: ProjectConfigSchema.nullable().optional(),
|
|
335
|
+
trackerType: z11.enum(["github", "linear"]).default("github"),
|
|
336
|
+
linearTeamKey: z11.string().min(1).optional(),
|
|
337
|
+
linearTriggerLabelId: z11.string().min(1).optional(),
|
|
338
|
+
linearToken: z11.string().min(1).optional()
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// ../contracts/src/platform-agent.ts
|
|
342
|
+
import { z as z12 } from "zod";
|
|
343
|
+
var ProposedFixSchema = z12.object({
|
|
344
|
+
repo: z12.string().min(1),
|
|
345
|
+
goal: z12.string().min(1)
|
|
346
|
+
});
|
|
347
|
+
var SkippedFixSchema = ProposedFixSchema.extend({
|
|
348
|
+
reason: z12.string().min(1)
|
|
349
|
+
});
|
|
350
|
+
var PlatformActionSchema = z12.object({
|
|
351
|
+
type: z12.enum(["terminate", "signal"]),
|
|
352
|
+
workflowId: z12.string().min(1),
|
|
353
|
+
reason: z12.string().min(1)
|
|
354
|
+
});
|
|
355
|
+
var PlatformSentinelSchema = z12.object({
|
|
356
|
+
summary: z12.string().min(1),
|
|
357
|
+
actionsTaken: z12.array(PlatformActionSchema).default([]),
|
|
358
|
+
proposedFixes: z12.array(ProposedFixSchema).default([])
|
|
359
|
+
});
|
|
360
|
+
var PlatformAgentInputSchema = z12.object({
|
|
361
|
+
prompt: z12.string().min(1),
|
|
362
|
+
hintRepos: z12.array(z12.string()).optional()
|
|
363
|
+
});
|
|
364
|
+
var PlatformAgentResultSchema = z12.object({
|
|
365
|
+
summary: z12.string(),
|
|
366
|
+
actionsTaken: z12.array(PlatformActionSchema).default([]),
|
|
367
|
+
childWorkflows: z12.array(
|
|
368
|
+
z12.object({
|
|
369
|
+
workflowId: z12.string().min(1),
|
|
370
|
+
repo: z12.string().min(1),
|
|
371
|
+
goal: z12.string().min(1)
|
|
372
|
+
})
|
|
373
|
+
).default([]),
|
|
374
|
+
skippedFixes: z12.array(SkippedFixSchema).default([])
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// ../contracts/src/control-api.ts
|
|
378
|
+
import { z as z13 } from "zod";
|
|
379
|
+
var StartRunRequestSchema = z13.object({
|
|
380
|
+
prompt: z13.string().min(1),
|
|
381
|
+
hintRepos: z13.array(z13.string()).optional(),
|
|
382
|
+
workflowId: z13.string().min(1).optional()
|
|
383
|
+
});
|
|
384
|
+
var StartRunResponseSchema = z13.object({
|
|
385
|
+
workflowId: z13.string().min(1),
|
|
386
|
+
runId: z13.string().min(1)
|
|
387
|
+
});
|
|
388
|
+
var RunStatusSchema = z13.enum([
|
|
389
|
+
"RUNNING",
|
|
390
|
+
"COMPLETED",
|
|
391
|
+
"FAILED",
|
|
392
|
+
"CANCELLED",
|
|
393
|
+
"TERMINATED",
|
|
394
|
+
"TIMED_OUT",
|
|
395
|
+
"CONTINUED_AS_NEW"
|
|
396
|
+
]);
|
|
397
|
+
var RunListItemSchema = z13.object({
|
|
398
|
+
workflowId: z13.string().min(1),
|
|
399
|
+
runId: z13.string().min(1),
|
|
400
|
+
status: RunStatusSchema,
|
|
401
|
+
startTime: z13.string().min(1),
|
|
402
|
+
closeTime: z13.string().min(1).optional(),
|
|
403
|
+
// Truncated prompt text from the Temporal memo set at start -- NOT
|
|
404
|
+
// PlatformAgentResult.summary, which only exists once a run completes.
|
|
405
|
+
promptSnippet: z13.string().min(1).optional()
|
|
406
|
+
});
|
|
407
|
+
var RunDetailSchema = z13.object({
|
|
408
|
+
workflowId: z13.string().min(1),
|
|
409
|
+
runId: z13.string().min(1),
|
|
410
|
+
status: RunStatusSchema,
|
|
411
|
+
prompt: z13.string().min(1).optional(),
|
|
412
|
+
result: PlatformAgentResultSchema.optional(),
|
|
413
|
+
error: z13.string().min(1).optional(),
|
|
414
|
+
temporalUrl: z13.string().min(1)
|
|
415
|
+
});
|
|
416
|
+
var RepoListResponseSchema = z13.object({
|
|
417
|
+
repos: z13.array(z13.string())
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
// ../contracts/src/control-devcycle-api.ts
|
|
421
|
+
import { z as z14 } from "zod";
|
|
422
|
+
var StartDevCycleRequestSchema = z14.object({
|
|
423
|
+
repo: z14.string().min(1),
|
|
424
|
+
// owner/repo -- must resolve to a registered project (422 otherwise)
|
|
425
|
+
prompt: z14.string().min(1),
|
|
426
|
+
// becomes TaskInput.goal verbatim
|
|
427
|
+
taskId: z14.string().min(1).optional()
|
|
428
|
+
// default: randomUUID() in control
|
|
429
|
+
});
|
|
430
|
+
var StartDevCycleResponseSchema = z14.object({
|
|
431
|
+
workflowId: z14.string().min(1),
|
|
432
|
+
runId: z14.string().min(1),
|
|
433
|
+
taskId: z14.string().min(1)
|
|
434
|
+
});
|
|
435
|
+
var DevCycleRunDetailSchema = z14.object({
|
|
436
|
+
workflowId: z14.string().min(1),
|
|
437
|
+
runId: z14.string().min(1),
|
|
438
|
+
status: RunStatusSchema,
|
|
439
|
+
prompt: z14.string().min(1).optional(),
|
|
440
|
+
// from the Temporal memo; absent for gateway/CLI-started runs
|
|
441
|
+
state: DevCycleStateSchema.optional(),
|
|
442
|
+
// live 'state' query while RUNNING, workflow result once COMPLETED
|
|
443
|
+
error: z14.string().min(1).optional(),
|
|
444
|
+
temporalUrl: z14.string().min(1)
|
|
445
|
+
});
|
|
446
|
+
var DevCycleTargetSchema = z14.object({
|
|
447
|
+
repo: z14.string().min(1),
|
|
448
|
+
project: z14.string().min(1)
|
|
449
|
+
});
|
|
450
|
+
var DevCycleTargetsResponseSchema = z14.object({
|
|
451
|
+
targets: z14.array(DevCycleTargetSchema)
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
// ../contracts/src/control-projects-api.ts
|
|
455
|
+
import { z as z15 } from "zod";
|
|
456
|
+
var CreateManagedProjectRequestSchema = z15.object({
|
|
457
|
+
project: z15.string().min(1),
|
|
458
|
+
repo: z15.string().min(1),
|
|
459
|
+
token: z15.string().min(1),
|
|
460
|
+
config: ProjectConfigSchema.nullable().optional(),
|
|
461
|
+
trackerType: z15.enum(["github", "linear"]).default("github"),
|
|
462
|
+
linearTeamKey: z15.string().min(1).optional(),
|
|
463
|
+
linearTriggerLabelId: z15.string().min(1).optional(),
|
|
464
|
+
linearToken: z15.string().min(1).optional()
|
|
465
|
+
}).superRefine((data, ctx) => {
|
|
466
|
+
if (data.trackerType !== "linear") {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (!data.linearTeamKey) {
|
|
470
|
+
ctx.addIssue({ code: "custom", path: ["linearTeamKey"], message: 'linearTeamKey is required when trackerType is "linear"' });
|
|
471
|
+
}
|
|
472
|
+
if (!data.linearTriggerLabelId) {
|
|
473
|
+
ctx.addIssue({ code: "custom", path: ["linearTriggerLabelId"], message: 'linearTriggerLabelId is required when trackerType is "linear"' });
|
|
474
|
+
}
|
|
475
|
+
if (!data.linearToken) {
|
|
476
|
+
ctx.addIssue({ code: "custom", path: ["linearToken"], message: 'linearToken is required when trackerType is "linear"' });
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
var UpdateManagedProjectRequestSchema = z15.object({
|
|
480
|
+
token: z15.string().min(1).optional(),
|
|
481
|
+
config: ProjectConfigSchema.nullable().optional(),
|
|
482
|
+
linearTeamKey: z15.string().min(1).optional(),
|
|
483
|
+
linearTriggerLabelId: z15.string().min(1).optional(),
|
|
484
|
+
linearToken: z15.string().min(1).optional()
|
|
485
|
+
});
|
|
486
|
+
var ManagedProjectListResponseSchema = z15.array(ManagedProjectSchema);
|
|
487
|
+
|
|
488
|
+
// ../contracts/src/control-agents-api.ts
|
|
489
|
+
import { z as z16 } from "zod";
|
|
490
|
+
var AgentScheduleSummarySchema = z16.object({
|
|
491
|
+
scheduleId: z16.string().min(1),
|
|
492
|
+
project: z16.string().min(1),
|
|
493
|
+
agentName: z16.string().min(1),
|
|
494
|
+
workflow: z16.string().min(1),
|
|
495
|
+
cron: z16.string().min(1),
|
|
496
|
+
paused: z16.boolean(),
|
|
497
|
+
nextRun: z16.string().optional()
|
|
498
|
+
});
|
|
499
|
+
var ListAgentSchedulesResponseSchema = z16.object({
|
|
500
|
+
agents: z16.array(AgentScheduleSummarySchema)
|
|
501
|
+
});
|
|
502
|
+
var TriggerAgentResponseSchema = z16.object({
|
|
503
|
+
scheduleId: z16.string().min(1),
|
|
504
|
+
triggered: z16.boolean()
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
// ../contracts/src/agents-manifest.ts
|
|
508
|
+
import { z as z17, ZodError as ZodError2 } from "zod";
|
|
509
|
+
var CRON_FIELD = String.raw`[\d*/,\-A-Za-z?]+`;
|
|
510
|
+
var CRON_RE = new RegExp(`^${CRON_FIELD}(\\s+${CRON_FIELD}){4}$`);
|
|
511
|
+
var scheduleSchema = z17.union([z17.literal("continuous"), z17.string().regex(CRON_RE, 'must be a 5-field cron or "continuous"')]);
|
|
512
|
+
var AgentSpecSchema = z17.object({
|
|
513
|
+
name: z17.string().regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/, "name must be kebab-case DNS-safe"),
|
|
514
|
+
workflow: z17.string().min(1),
|
|
515
|
+
schedule: scheduleSchema,
|
|
516
|
+
input: z17.record(z17.string(), z17.unknown()).default({}),
|
|
517
|
+
enabled: z17.boolean().default(true),
|
|
518
|
+
timezone: z17.string().default("UTC"),
|
|
519
|
+
overlap: z17.enum(["skip", "bufferOne", "allow"]).default("skip"),
|
|
520
|
+
// Task queue the reconciler starts this agent on. Built-in workflows omit
|
|
521
|
+
// it (they run on ENGINE_QUEUE); a continuous Tier-2 agent sets it to its
|
|
522
|
+
// project worker's queue so the reconciler can start it by name there.
|
|
523
|
+
taskQueue: z17.string().min(1).optional()
|
|
524
|
+
}).strict();
|
|
525
|
+
var AgentsManifestSchema = z17.object({ agents: z17.array(AgentSpecSchema) }).strict();
|
|
526
|
+
var WhiteboxBugHuntManifestInputSchema = z17.object({ focus: z17.string().optional() }).strict();
|
|
527
|
+
|
|
528
|
+
// ../contracts/src/whitebox-finding.ts
|
|
529
|
+
import { z as z18 } from "zod";
|
|
530
|
+
var WhiteboxFindingSchema = z18.object({
|
|
531
|
+
title: z18.string().min(1),
|
|
532
|
+
detail: z18.string().min(1),
|
|
533
|
+
severity: z18.enum(["low", "medium", "high", "critical"]),
|
|
534
|
+
location: z18.string().min(1)
|
|
535
|
+
// e.g. "src/db.ts:42"
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
// ../contracts/src/engine-queue.ts
|
|
539
|
+
var ENGINE_QUEUE = "agentops-engine";
|
|
540
|
+
|
|
541
|
+
// ../contracts/src/project-identity.ts
|
|
542
|
+
var PROJECT_HEADER_KEY = "x-agentops-project";
|
|
543
|
+
function readProjectFromMemo(memo) {
|
|
544
|
+
const p = memo?.project;
|
|
545
|
+
return typeof p === "string" && p.length > 0 ? p : void 0;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// ../contracts/src/index.ts
|
|
549
|
+
import { z as z19 } from "zod";
|
|
550
|
+
|
|
551
|
+
// ../policies/src/parse-verdict.ts
|
|
552
|
+
function escapeRegExp(value) {
|
|
553
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
554
|
+
}
|
|
555
|
+
var SENTINEL_PREFIX = "[\\s>#*_-]{0,6}";
|
|
556
|
+
function parseVerdict(text, sentinel) {
|
|
557
|
+
const pattern = new RegExp(`^${SENTINEL_PREFIX}${escapeRegExp(sentinel)}\\s*(PASS|FAIL)\\b(.*)$`, "gm");
|
|
558
|
+
let lastMatch = null;
|
|
559
|
+
let match;
|
|
560
|
+
while ((match = pattern.exec(text)) !== null) {
|
|
561
|
+
lastMatch = match;
|
|
562
|
+
}
|
|
563
|
+
if (!lastMatch) {
|
|
564
|
+
return { kind: "unparseable" };
|
|
565
|
+
}
|
|
566
|
+
const [, verdictWord, rest] = lastMatch;
|
|
567
|
+
const kind = verdictWord === "PASS" ? "pass" : "fail";
|
|
568
|
+
const findingsText = rest.trim().replace(/[\s*_]+$/, "");
|
|
569
|
+
return findingsText.length > 0 ? { kind, findings: [findingsText] } : { kind };
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// ../policies/src/parse-findings.ts
|
|
573
|
+
function parseFindings(output) {
|
|
574
|
+
const re = /^FINDINGS:\s*(.+)$/gm;
|
|
575
|
+
let last = null;
|
|
576
|
+
for (let m = re.exec(output); m !== null; m = re.exec(output)) last = m;
|
|
577
|
+
if (!last) return [];
|
|
578
|
+
let json;
|
|
579
|
+
try {
|
|
580
|
+
json = JSON.parse(last[1]);
|
|
581
|
+
} catch {
|
|
582
|
+
return [];
|
|
583
|
+
}
|
|
584
|
+
if (!Array.isArray(json)) return [];
|
|
585
|
+
const out = [];
|
|
586
|
+
for (const item of json) {
|
|
587
|
+
const res = WhiteboxFindingSchema.safeParse(item);
|
|
588
|
+
if (res.success) out.push(res.data);
|
|
589
|
+
}
|
|
590
|
+
return out;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// src/workflow.ts
|
|
594
|
+
function engineActivities(opts = {}) {
|
|
595
|
+
return proxyActivities({ taskQueue: ENGINE_QUEUE, startToCloseTimeout: opts.startToCloseTimeout ?? "10m" });
|
|
596
|
+
}
|
|
597
|
+
function engineAgent(opts = {}) {
|
|
598
|
+
return proxyActivities({ taskQueue: ENGINE_QUEUE, startToCloseTimeout: opts.startToCloseTimeout ?? "1h" });
|
|
599
|
+
}
|
|
600
|
+
function childDevCycle(input) {
|
|
601
|
+
return executeChild("devCycle", { taskQueue: ENGINE_QUEUE, args: [input] });
|
|
602
|
+
}
|
|
603
|
+
var ProjectOutbound = class {
|
|
604
|
+
project() {
|
|
605
|
+
return readProjectFromMemo(workflowInfo().memo);
|
|
606
|
+
}
|
|
607
|
+
async scheduleActivity(input, next) {
|
|
608
|
+
const p = this.project();
|
|
609
|
+
if (p) input.headers = { ...input.headers, [PROJECT_HEADER_KEY]: defaultPayloadConverter.toPayload(p) };
|
|
610
|
+
return next(input);
|
|
611
|
+
}
|
|
612
|
+
async startChildWorkflowExecution(input, next) {
|
|
613
|
+
const p = this.project();
|
|
614
|
+
if (p) {
|
|
615
|
+
input.headers = { ...input.headers, [PROJECT_HEADER_KEY]: defaultPayloadConverter.toPayload(p) };
|
|
616
|
+
input.options = {
|
|
617
|
+
...input.options,
|
|
618
|
+
memo: { ...input.options?.memo ?? {}, project: p },
|
|
619
|
+
searchAttributes: { ...input.options?.searchAttributes ?? {}, project: [p] }
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
return next(input);
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
var interceptors = () => ({ outbound: [new ProjectOutbound()] });
|
|
626
|
+
export {
|
|
627
|
+
ENGINE_QUEUE,
|
|
628
|
+
childDevCycle,
|
|
629
|
+
engineActivities,
|
|
630
|
+
engineAgent,
|
|
631
|
+
interceptors,
|
|
632
|
+
parseFindings,
|
|
633
|
+
parseVerdict
|
|
634
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentic-ops/engine-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Thin, secret-free facade for authoring Tier-2 agentops project workflows.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
"./workflow": {
|
|
12
|
+
"types": "./dist/workflow.d.ts",
|
|
13
|
+
"import": "./dist/workflow.js",
|
|
14
|
+
"require": "./dist/workflow.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./worker": {
|
|
17
|
+
"types": "./dist/worker.d.ts",
|
|
18
|
+
"import": "./dist/worker.js",
|
|
19
|
+
"require": "./dist/worker.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@temporalio/workflow": "*",
|
|
24
|
+
"@temporalio/worker": "*",
|
|
25
|
+
"@temporalio/common": "*",
|
|
26
|
+
"@temporalio/client": "*"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"zod": "^3.23.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"tsup": "^8.0.0",
|
|
33
|
+
"typescript": "^6.0.3",
|
|
34
|
+
"vitest": "^4.1.9",
|
|
35
|
+
"@agentops/contracts": "0.0.0",
|
|
36
|
+
"@agentops/policies": "0.0.0"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsup",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"test": "vitest run"
|
|
45
|
+
}
|
|
46
|
+
}
|