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