@polpo-ai/core 0.11.1 → 0.12.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.
Files changed (109) hide show
  1. package/dist/__tests__/mission-store.test.js +9 -13
  2. package/dist/__tests__/mission-store.test.js.map +1 -1
  3. package/dist/adapter.d.ts +10 -19
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/adapter.js +0 -7
  6. package/dist/adapter.js.map +1 -1
  7. package/dist/approval-manager.js +11 -11
  8. package/dist/approval-manager.js.map +1 -1
  9. package/dist/assessment-orchestrator.d.ts +1 -1
  10. package/dist/assessment-orchestrator.js +46 -46
  11. package/dist/assessment-orchestrator.js.map +1 -1
  12. package/dist/context-compactor.d.ts +1 -0
  13. package/dist/context-compactor.d.ts.map +1 -1
  14. package/dist/context-compactor.js.map +1 -1
  15. package/dist/escalation-manager.js +8 -8
  16. package/dist/escalation-manager.js.map +1 -1
  17. package/dist/events.d.ts +1 -25
  18. package/dist/events.d.ts.map +1 -1
  19. package/dist/hooks.d.ts +15 -9
  20. package/dist/hooks.d.ts.map +1 -1
  21. package/dist/hooks.js.map +1 -1
  22. package/dist/in-memory-stores.d.ts +21 -0
  23. package/dist/in-memory-stores.d.ts.map +1 -0
  24. package/dist/in-memory-stores.js +43 -0
  25. package/dist/in-memory-stores.js.map +1 -0
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +1 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/loop/hooks.d.ts +10 -28
  31. package/dist/loop/hooks.d.ts.map +1 -1
  32. package/dist/loop/hooks.js +2 -83
  33. package/dist/loop/hooks.js.map +1 -1
  34. package/dist/loop/step-helpers.d.ts +20 -0
  35. package/dist/loop/step-helpers.d.ts.map +1 -0
  36. package/dist/loop/step-helpers.js +69 -0
  37. package/dist/loop/step-helpers.js.map +1 -0
  38. package/dist/mission-executor.d.ts +16 -22
  39. package/dist/mission-executor.d.ts.map +1 -1
  40. package/dist/mission-executor.js +204 -459
  41. package/dist/mission-executor.js.map +1 -1
  42. package/dist/mission-gating.d.ts +89 -0
  43. package/dist/mission-gating.d.ts.map +1 -0
  44. package/dist/mission-gating.js +281 -0
  45. package/dist/mission-gating.js.map +1 -0
  46. package/dist/mission-store.d.ts +14 -8
  47. package/dist/mission-store.d.ts.map +1 -1
  48. package/dist/mission-store.js +19 -8
  49. package/dist/mission-store.js.map +1 -1
  50. package/dist/orchestrator-context.d.ts +1 -1
  51. package/dist/orchestrator-context.d.ts.map +1 -1
  52. package/dist/orchestrator-engine.d.ts +6 -6
  53. package/dist/orchestrator-engine.d.ts.map +1 -1
  54. package/dist/orchestrator-engine.js +10 -10
  55. package/dist/orchestrator-engine.js.map +1 -1
  56. package/dist/playbook-logic.d.ts +1 -1
  57. package/dist/playbook-logic.js +1 -1
  58. package/dist/scheduler.js +1 -1
  59. package/dist/scheduler.js.map +1 -1
  60. package/dist/schemas.d.ts +2 -2
  61. package/dist/session-store.d.ts +0 -2
  62. package/dist/session-store.d.ts.map +1 -1
  63. package/dist/session-store.js.map +1 -1
  64. package/dist/sla-monitor.js +3 -3
  65. package/dist/sla-monitor.js.map +1 -1
  66. package/dist/task-manager.d.ts +1 -1
  67. package/dist/task-manager.d.ts.map +1 -1
  68. package/dist/task-manager.js +37 -37
  69. package/dist/task-manager.js.map +1 -1
  70. package/dist/task-runner.d.ts.map +1 -1
  71. package/dist/task-runner.js +19 -36
  72. package/dist/task-runner.js.map +1 -1
  73. package/dist/task-store.d.ts +5 -19
  74. package/dist/task-store.d.ts.map +1 -1
  75. package/dist/tool-types.d.ts +0 -2
  76. package/dist/tool-types.d.ts.map +1 -1
  77. package/dist/types/agent.d.ts +186 -0
  78. package/dist/types/agent.d.ts.map +1 -0
  79. package/dist/types/agent.js +23 -0
  80. package/dist/types/agent.js.map +1 -0
  81. package/dist/types/assessment.d.ts +134 -0
  82. package/dist/types/assessment.d.ts.map +1 -0
  83. package/dist/types/assessment.js +18 -0
  84. package/dist/types/assessment.js.map +1 -0
  85. package/dist/types/config.d.ts +193 -0
  86. package/dist/types/config.d.ts.map +1 -0
  87. package/dist/types/config.js +8 -0
  88. package/dist/types/config.js.map +1 -0
  89. package/dist/types/mission.d.ts +226 -0
  90. package/dist/types/mission.d.ts.map +1 -0
  91. package/dist/types/mission.js +6 -0
  92. package/dist/types/mission.js.map +1 -0
  93. package/dist/types/notifications.d.ts +162 -0
  94. package/dist/types/notifications.d.ts.map +1 -0
  95. package/dist/types/notifications.js +6 -0
  96. package/dist/types/notifications.js.map +1 -0
  97. package/dist/types/task.d.ts +191 -0
  98. package/dist/types/task.d.ts.map +1 -0
  99. package/dist/types/task.js +5 -0
  100. package/dist/types/task.js.map +1 -0
  101. package/dist/types.d.ts +17 -1150
  102. package/dist/types.d.ts.map +1 -1
  103. package/dist/types.js +18 -31
  104. package/dist/types.js.map +1 -1
  105. package/package.json +1 -1
  106. package/dist/attachment-store.d.ts +0 -42
  107. package/dist/attachment-store.d.ts.map +0 -1
  108. package/dist/attachment-store.js +0 -13
  109. package/dist/attachment-store.js.map +0 -1
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Mission domain — mission lifecycle, reports, flow control (quality gates,
3
+ * checkpoints, delays, approval gates), SLA, quality metrics, and scheduling.
4
+ */
5
+ import type { TaskOutcome } from "./task.js";
6
+ import type { ScopedNotificationRules } from "./notifications.js";
7
+ export type MissionStatus = "draft" | "scheduled" | "recurring" | "active" | "paused" | "completed" | "failed" | "cancelled";
8
+ export interface Mission {
9
+ id: string;
10
+ name: string;
11
+ data: string;
12
+ prompt?: string;
13
+ status: MissionStatus;
14
+ /** Absolute deadline for the entire mission (ISO timestamp). */
15
+ deadline?: string;
16
+ /** Cron expression or ISO timestamp for scheduled execution. */
17
+ schedule?: string;
18
+ /** End date for recurring schedules (ISO timestamp). After this date the schedule stops firing and the mission transitions to completed. */
19
+ endDate?: string;
20
+ /** Minimum average score for the mission to be considered successful. */
21
+ qualityThreshold?: number;
22
+ /** Scoped notification rules — override or extend global rules for tasks in this mission. */
23
+ notifications?: ScopedNotificationRules;
24
+ /** How many times this mission has been executed. Incremented on each run (useful for recurring missions). */
25
+ executionCount?: number;
26
+ /**
27
+ * Opaque end-user identifier (OpenAI-compat `user`). Tasks generated by this
28
+ * mission inherit this value unless explicitly overridden at task level.
29
+ */
30
+ user?: string;
31
+ createdAt: string;
32
+ updatedAt: string;
33
+ }
34
+ /** Completion report for a mission — aggregated results across all tasks. */
35
+ export interface MissionReport {
36
+ missionId: string;
37
+ group: string;
38
+ allPassed: boolean;
39
+ totalDuration: number;
40
+ tasks: {
41
+ title: string;
42
+ status: "done" | "failed";
43
+ duration: number;
44
+ score?: number;
45
+ filesCreated: string[];
46
+ filesEdited: string[];
47
+ outcomes?: TaskOutcome[];
48
+ }[];
49
+ filesCreated: string[];
50
+ filesEdited: string[];
51
+ outcomes?: TaskOutcome[];
52
+ avgScore?: number;
53
+ }
54
+ export type ApprovalGateHandler = "auto" | "human";
55
+ export interface ApprovalGateCondition {
56
+ /** JS-like expression evaluated against the hook payload.
57
+ * For "auto" gates — if condition passes, task proceeds. If it fails, task is blocked.
58
+ * For "human" gates — condition determines WHEN to trigger the gate. */
59
+ expression: string;
60
+ }
61
+ export interface ApprovalGate {
62
+ /** Unique gate ID. */
63
+ id: string;
64
+ /** Human-readable name. */
65
+ name: string;
66
+ /** "auto" = system evaluates condition. "human" = blocks for human approval. */
67
+ handler: ApprovalGateHandler;
68
+ /** Which lifecycle hook triggers this gate. */
69
+ hook: string;
70
+ /** Optional condition — when to activate the gate. */
71
+ condition?: ApprovalGateCondition;
72
+ /** Notification channels to alert on gate activation (for "human" gates). */
73
+ notifyChannels?: string[];
74
+ /** Timeout in ms (for "human" gates). 0 = no timeout. */
75
+ timeoutMs?: number;
76
+ /** Action when timeout expires. Default: "reject". */
77
+ timeoutAction?: "approve" | "reject";
78
+ /** Priority within the same hook point. Lower = first. Default: 100. */
79
+ priority?: number;
80
+ /** Max revision rounds before only approve/reject is allowed. Default: 3. */
81
+ maxRevisions?: number;
82
+ /** Include task outcomes as attachments in the approval notification. */
83
+ includeOutcomes?: boolean;
84
+ }
85
+ export type ApprovalStatus = "pending" | "approved" | "rejected" | "timeout";
86
+ export interface ApprovalRequest {
87
+ /** Unique request ID. */
88
+ id: string;
89
+ /** Gate that triggered this request. */
90
+ gateId: string;
91
+ /** Gate name (denormalized for display). */
92
+ gateName: string;
93
+ /** Related task ID, if applicable. */
94
+ taskId?: string;
95
+ /** Related mission ID, if applicable. */
96
+ missionId?: string;
97
+ /** Current status. */
98
+ status: ApprovalStatus;
99
+ /** Hook payload snapshot at time of request. */
100
+ payload: unknown;
101
+ /** When the request was created. */
102
+ requestedAt: string;
103
+ /** When the request was resolved (approved/rejected/timeout). */
104
+ resolvedAt?: string;
105
+ /** Who resolved it (user ID, "system", "timeout"). */
106
+ resolvedBy?: string;
107
+ /** Optional resolution note. */
108
+ note?: string;
109
+ }
110
+ /** Quality gate defined within a mission — checkpoint between task phases. */
111
+ export interface MissionQualityGate {
112
+ /** Gate name. */
113
+ name: string;
114
+ /** Tasks that must be completed before this gate is evaluated. */
115
+ afterTasks: string[];
116
+ /** Tasks that are blocked until this gate passes. */
117
+ blocksTasks: string[];
118
+ /** Minimum average score of `afterTasks` to pass. */
119
+ minScore?: number;
120
+ /** All `afterTasks` must have status "done" (not just completed — they must pass). */
121
+ requireAllPassed?: boolean;
122
+ /** Custom condition expression evaluated against gate context. */
123
+ condition?: string;
124
+ /** Notification channels to alert on gate pass/fail. */
125
+ notifyChannels?: string[];
126
+ }
127
+ /** Checkpoint defined within a mission — planned stopping point for human review.
128
+ *
129
+ * Unlike approval gates (which ask yes/no and auto-resume on approval),
130
+ * checkpoints unconditionally pause the mission until explicitly resumed.
131
+ * Use checkpoints for human-in-the-loop review at defined milestones. */
132
+ export interface MissionCheckpoint {
133
+ /** Checkpoint name (used in events and notifications). */
134
+ name: string;
135
+ /** Tasks that must be completed before this checkpoint triggers. */
136
+ afterTasks: string[];
137
+ /** Tasks that are blocked until the checkpoint is resumed. */
138
+ blocksTasks: string[];
139
+ /** Notification channels to alert when the checkpoint is reached. */
140
+ notifyChannels?: string[];
141
+ /** Optional message included in the notification when the checkpoint triggers. */
142
+ message?: string;
143
+ }
144
+ /** Delay defined within a mission — timed wait between task groups.
145
+ *
146
+ * Unlike checkpoints (which pause until a human resumes), delays
147
+ * automatically resume after a specified duration elapses.
148
+ * The timer starts when ALL afterTasks reach a terminal state (done/failed).
149
+ * Use delays for cooldown periods, staggered rollouts, rate-limiting, etc. */
150
+ export interface MissionDelay {
151
+ /** Delay name (used in events and notifications). */
152
+ name: string;
153
+ /** Tasks that must be completed before this delay timer starts. */
154
+ afterTasks: string[];
155
+ /** Tasks that are blocked until the delay timer expires. */
156
+ blocksTasks: string[];
157
+ /** ISO 8601 duration (e.g. "PT2H" = 2 hours, "PT30M" = 30 minutes, "P1D" = 1 day). */
158
+ duration: string;
159
+ /** Notification channels to alert when the delay starts / expires. */
160
+ notifyChannels?: string[];
161
+ /** Optional message included in the notification when the delay starts. */
162
+ message?: string;
163
+ }
164
+ /** SLA configuration for deadline monitoring. */
165
+ export interface SLAConfig {
166
+ /** Percentage of deadline elapsed before emitting a warning (0-1). Default: 0.8 */
167
+ warningThreshold?: number;
168
+ /** Check interval in ms. Default: 30000 (30s). */
169
+ checkIntervalMs?: number;
170
+ /** Notification channels for SLA warnings. */
171
+ warningChannels?: string[];
172
+ /** Notification channels for SLA violations. */
173
+ violationChannels?: string[];
174
+ /** Action on SLA violation: "notify" (default) or "fail" (force-fail the task). */
175
+ violationAction?: "notify" | "fail";
176
+ }
177
+ /** Quality metrics snapshot for a single entity (task, agent, mission). */
178
+ export interface QualityMetrics {
179
+ /** Entity identifier. */
180
+ entityId: string;
181
+ /** Entity type. */
182
+ entityType: "task" | "agent" | "mission";
183
+ /** Total assessments run. */
184
+ totalAssessments: number;
185
+ /** Assessments that passed. */
186
+ passedAssessments: number;
187
+ /** Average global score (1-5). */
188
+ avgScore?: number;
189
+ /** Minimum score observed. */
190
+ minScore?: number;
191
+ /** Maximum score observed. */
192
+ maxScore?: number;
193
+ /** Per-dimension average scores. */
194
+ dimensionScores: Record<string, number>;
195
+ /** Total retries consumed. */
196
+ totalRetries: number;
197
+ /** Total fix attempts consumed. */
198
+ totalFixes: number;
199
+ /** Deadlines met vs missed. */
200
+ deadlinesMet: number;
201
+ deadlinesMissed: number;
202
+ /** Last updated. */
203
+ updatedAt: string;
204
+ }
205
+ /** Scheduled mission entry — runtime artifact derived from Mission fields. */
206
+ export interface ScheduleEntry {
207
+ /** Unique schedule ID. */
208
+ id: string;
209
+ /** Mission ID to execute. */
210
+ missionId: string;
211
+ /** Cron expression (e.g. "0 2 * * *") or ISO timestamp for one-shot. */
212
+ expression: string;
213
+ /** Whether this schedule recurs (derived from mission status === "recurring"). */
214
+ recurring: boolean;
215
+ /** Whether this schedule is active. */
216
+ enabled: boolean;
217
+ /** Last execution time (ISO). */
218
+ lastRunAt?: string;
219
+ /** Next scheduled execution time (ISO). */
220
+ nextRunAt?: string;
221
+ /** Deadline offset — auto-set task/mission deadline to N ms after execution start. */
222
+ deadlineOffsetMs?: number;
223
+ /** Created at. */
224
+ createdAt: string;
225
+ }
226
+ //# sourceMappingURL=mission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission.d.ts","sourceRoot":"","sources":["../../src/types/mission.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAIlE,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE7H,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC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EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Mission domain — mission lifecycle, reports, flow control (quality gates,
3
+ * checkpoints, delays, approval gates), SLA, quality metrics, and scheduling.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=mission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission.js","sourceRoot":"","sources":["../../src/types/mission.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Notifications domain — channels, rules, conditions, action triggers,
3
+ * scoped rules, and escalation policies.
4
+ */
5
+ import type { TaskExpectation, OutcomeType } from "./task.js";
6
+ export type NotificationChannelType = "slack" | "email" | "telegram" | "webhook";
7
+ export interface NotificationChannelConfig {
8
+ type: NotificationChannelType;
9
+ /** Slack: webhook URL. */
10
+ webhookUrl?: string;
11
+ /** Email: recipient addresses. */
12
+ to?: string[];
13
+ /** Email: provider ("smtp" | "resend" | "sendgrid"). */
14
+ provider?: string;
15
+ /** API key (direct value or "${ENV_VAR}" reference). */
16
+ apiKey?: string;
17
+ /** Telegram: bot token. */
18
+ botToken?: string;
19
+ /** Telegram: chat ID. */
20
+ chatId?: string;
21
+ /** Webhook: target URL. */
22
+ url?: string;
23
+ /** Webhook: custom headers. */
24
+ headers?: Record<string, string>;
25
+ /** SMTP host. */
26
+ host?: string;
27
+ /** SMTP port. */
28
+ port?: number;
29
+ /** SMTP from address. */
30
+ from?: string;
31
+ }
32
+ export type NotificationSeverity = "info" | "warning" | "critical";
33
+ /**
34
+ * JSON-based condition for notification rule filtering.
35
+ *
36
+ * Supports:
37
+ * - Single comparison: { "field": "status", "op": "==", "value": "failed" }
38
+ * - Logical AND: { "and": [ ...conditions ] }
39
+ * - Logical OR: { "or": [ ...conditions ] }
40
+ * - Logical NOT: { "not": condition }
41
+ * - Inclusion: { "field": "tags", "op": "includes", "value": "urgent" }
42
+ * - Existence: { "field": "error", "op": "exists" }
43
+ *
44
+ * Fields are dot-paths resolved on the event data (e.g. "task.status", "score").
45
+ */
46
+ export type ConditionOp = "==" | "!=" | ">" | ">=" | "<" | "<=" | "includes" | "not_includes" | "exists" | "not_exists";
47
+ export interface ConditionExpr {
48
+ field: string;
49
+ op: ConditionOp;
50
+ value?: string | number | boolean | null;
51
+ }
52
+ export interface ConditionAnd {
53
+ and: NotificationCondition[];
54
+ }
55
+ export interface ConditionOr {
56
+ or: NotificationCondition[];
57
+ }
58
+ export interface ConditionNot {
59
+ not: NotificationCondition;
60
+ }
61
+ export type NotificationCondition = ConditionExpr | ConditionAnd | ConditionOr | ConditionNot;
62
+ export interface NotificationRule {
63
+ /** Unique rule ID. */
64
+ id: string;
65
+ /** Human-readable name. */
66
+ name: string;
67
+ /** Event patterns to match (glob-style: "task:*", "mission:completed"). */
68
+ events: string[];
69
+ /** Optional JSON condition on the event payload. No eval — pure data. */
70
+ condition?: NotificationCondition;
71
+ /** Channels to notify (references to channel IDs in config). */
72
+ channels: string[];
73
+ /** Severity level. Default: "info". */
74
+ severity?: NotificationSeverity;
75
+ /** Mustache-style template for the notification body. */
76
+ template?: string;
77
+ /** Minimum interval between notifications for the same rule (ms). */
78
+ cooldownMs?: number;
79
+ /** Attach task outcomes to the notification (files sent as attachments). Default: false. */
80
+ includeOutcomes?: boolean;
81
+ /** Only include outcomes of these types. When omitted, all types are included. */
82
+ outcomeFilter?: OutcomeType[];
83
+ /** Max file size per attachment in bytes. Files larger than this are skipped. Default: 10MB. */
84
+ maxAttachmentSize?: number;
85
+ /** Action triggers — executed when the rule fires, in addition to sending notifications. */
86
+ actions?: NotificationAction[];
87
+ }
88
+ /** Action types that can be triggered by notification rules. */
89
+ export type NotificationActionType = "create_task" | "execute_mission" | "run_script" | "send_notification";
90
+ /** Base action interface. */
91
+ interface NotificationActionBase {
92
+ type: NotificationActionType;
93
+ }
94
+ /** Create a task when the rule fires. */
95
+ export interface CreateTaskAction extends NotificationActionBase {
96
+ type: "create_task";
97
+ title: string;
98
+ description: string;
99
+ assignTo: string;
100
+ expectations?: TaskExpectation[];
101
+ }
102
+ /** Execute an existing mission when the rule fires. */
103
+ export interface ExecuteMissionAction extends NotificationActionBase {
104
+ type: "execute_mission";
105
+ missionId: string;
106
+ }
107
+ /** Run a shell script when the rule fires. */
108
+ export interface RunScriptAction extends NotificationActionBase {
109
+ type: "run_script";
110
+ command: string;
111
+ /** Max execution time in ms. Default: 30000. */
112
+ timeoutMs?: number;
113
+ }
114
+ /** Send an additional notification to different channels. */
115
+ export interface SendNotificationAction extends NotificationActionBase {
116
+ type: "send_notification";
117
+ channel: string;
118
+ title: string;
119
+ body: string;
120
+ severity?: NotificationSeverity;
121
+ }
122
+ export type NotificationAction = CreateTaskAction | ExecuteMissionAction | RunScriptAction | SendNotificationAction;
123
+ export interface NotificationsConfig {
124
+ channels: Record<string, NotificationChannelConfig>;
125
+ rules: NotificationRule[];
126
+ }
127
+ /**
128
+ * Scoped notification rules — can be attached to a Task or Mission to override
129
+ * or extend the global notification rules.
130
+ *
131
+ * Precedence: task > mission > global.
132
+ * - Default: more-specific scope **replaces** global rules for matching events.
133
+ * - With `inherit: true`: scoped rules are **added** on top of the parent scope.
134
+ */
135
+ export interface ScopedNotificationRules {
136
+ /** Notification rules for this scope. */
137
+ rules: NotificationRule[];
138
+ /** If true, these rules are added on top of the parent scope (plan or global).
139
+ * If false (default), they replace parent rules for matching events. */
140
+ inherit?: boolean;
141
+ }
142
+ export type EscalationHandlerType = "agent" | "orchestrator" | "human";
143
+ export interface EscalationLevel {
144
+ /** Level number (0 = first). */
145
+ level: number;
146
+ /** Who handles at this level. */
147
+ handler: EscalationHandlerType;
148
+ /** Target agent name (for "agent"), notification channel (for "human"). */
149
+ target?: string;
150
+ /** Timeout before escalating to next level (ms). */
151
+ timeoutMs?: number;
152
+ /** Notification channels to alert at this level. */
153
+ notifyChannels?: string[];
154
+ }
155
+ export interface EscalationPolicy {
156
+ /** Policy name. */
157
+ name: string;
158
+ /** Ordered escalation levels. */
159
+ levels: EscalationLevel[];
160
+ }
161
+ export {};
162
+ //# sourceMappingURL=notifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/types/notifications.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI9D,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAEjF,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,0BAA0B;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,iBAAiB;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;AAEnE;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,G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E,OAAO,CAAC;CACnB;AAID,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,cAAc,GAAG,OAAO,CAAC;AAEvE,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,OAAO,EAAE,qBAAqB,CAAC;IAC/B,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Notifications domain — channels, rules, conditions, action triggers,
3
+ * scoped rules, and escalation policies.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/types/notifications.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Task domain — task lifecycle, expectations, outcomes, watchers.
3
+ */
4
+ import type { EvalDimension, AssessmentResult } from "./assessment.js";
5
+ import type { ScopedNotificationRules, NotificationAction } from "./notifications.js";
6
+ export type TaskStatus = "draft" | "pending" | "awaiting_approval" | "assigned" | "in_progress" | "review" | "done" | "failed";
7
+ export interface TaskExpectation {
8
+ type: "test" | "file_exists" | "script" | "llm_review";
9
+ command?: string;
10
+ paths?: string[];
11
+ criteria?: string;
12
+ /** For llm_review: evaluation dimensions with weights and rubrics */
13
+ dimensions?: EvalDimension[];
14
+ /** For llm_review: minimum weighted score (1-5) to pass. Default 3.0 */
15
+ threshold?: number;
16
+ /** Whether this expectation is a firm requirement or an estimate that can be auto-corrected.
17
+ * Default: "estimated" for file_exists, "firm" for test/script/llm_review. */
18
+ confidence?: "firm" | "estimated";
19
+ }
20
+ export interface TaskMetric {
21
+ name: string;
22
+ command: string;
23
+ threshold: number;
24
+ }
25
+ export interface RetryPolicy {
26
+ /** After this many failures, escalate to fallbackAgent */
27
+ escalateAfter?: number;
28
+ /** Agent to use for escalation retries */
29
+ fallbackAgent?: string;
30
+ /** Model override for escalation (e.g. switch from haiku to sonnet) */
31
+ escalateModel?: string;
32
+ }
33
+ export type TaskPhase = "execution" | "review" | "fix" | "clarification";
34
+ /** What type of artifact a task can produce. */
35
+ export type OutcomeType = "file" | "text" | "url" | "json" | "media";
36
+ /**
37
+ * A concrete artifact produced by a task at runtime.
38
+ * Populated automatically by tool interception and/or explicitly by agent output.
39
+ */
40
+ export interface TaskOutcome {
41
+ /** Unique outcome ID (nanoid). */
42
+ id: string;
43
+ /** Outcome category. */
44
+ type: OutcomeType;
45
+ /** Human-readable label (e.g. "Sales Report", "Transcription", "Generated Audio"). */
46
+ label: string;
47
+ /** file/media: relative or absolute path to the produced file. */
48
+ path?: string;
49
+ /** file/media: MIME type (auto-detected from extension or explicit). */
50
+ mimeType?: string;
51
+ /** file/media: file size in bytes. */
52
+ size?: number;
53
+ /** text: the content itself (transcription, summary, analysis, etc.). */
54
+ text?: string;
55
+ /** url: link to external resource (deploy URL, PR, page, etc.). */
56
+ url?: string;
57
+ /** json: structured data payload (query results, metrics, report, etc.). */
58
+ data?: unknown;
59
+ /** Tool name that generated this outcome (auto-collected). */
60
+ producedBy?: string;
61
+ /** ISO timestamp when the outcome was created. */
62
+ producedAt: string;
63
+ /** User-defined tags for filtering and categorization. */
64
+ tags?: string[];
65
+ }
66
+ /**
67
+ * Declared in task/mission definitions — tells the agent what it should produce.
68
+ * Used for validation: the orchestrator checks that expected outcomes are fulfilled.
69
+ */
70
+ export interface ExpectedOutcome {
71
+ /** Expected outcome type. */
72
+ type: OutcomeType;
73
+ /** Human-readable label — also used to match against produced TaskOutcome.label. */
74
+ label: string;
75
+ /** Hints for the agent about what to produce. */
76
+ description?: string;
77
+ /** Expected file path (optional — agent can choose). */
78
+ path?: string;
79
+ /** Expected MIME type (e.g. "audio/mpeg", "application/pdf"). */
80
+ mimeType?: string;
81
+ /** Whether this outcome is required for the task to pass. Default: true. */
82
+ required?: boolean;
83
+ /** Tags to auto-apply to the produced outcome. */
84
+ tags?: string[];
85
+ }
86
+ export interface Task {
87
+ id: string;
88
+ title: string;
89
+ description: string;
90
+ assignTo: string;
91
+ group?: string;
92
+ /** ID of the mission this task belongs to (set when created via executeMission). */
93
+ missionId?: string;
94
+ dependsOn: string[];
95
+ status: TaskStatus;
96
+ expectations: TaskExpectation[];
97
+ metrics: TaskMetric[];
98
+ retries: number;
99
+ maxRetries: number;
100
+ maxDuration?: number;
101
+ retryPolicy?: RetryPolicy;
102
+ result?: TaskResult;
103
+ phase?: TaskPhase;
104
+ fixAttempts?: number;
105
+ questionRounds?: number;
106
+ resolutionAttempts?: number;
107
+ originalDescription?: string;
108
+ sessionId?: string;
109
+ /** Absolute deadline (ISO timestamp). Task is SLA-violated if not done by this time. */
110
+ deadline?: string;
111
+ /** Priority weight for quality scoring (higher = more important). Default: 1.0 */
112
+ priority?: number;
113
+ /** Declared expected outcomes — what this task should produce. */
114
+ expectedOutcomes?: ExpectedOutcome[];
115
+ /** Actual outcomes produced at runtime (auto-collected + explicit). */
116
+ outcomes?: TaskOutcome[];
117
+ /** Number of approval revision rounds this task has gone through. */
118
+ revisionCount?: number;
119
+ /** Scoped notification rules — override or extend global/mission rules for this task. */
120
+ notifications?: ScopedNotificationRules;
121
+ /**
122
+ * Whether this task produces irreversible side effects (email sends, API calls,
123
+ * WhatsApp messages, etc.). When true, automatic retry/fix is blocked and the
124
+ * task transitions to `awaiting_approval` so a human can approve re-execution.
125
+ * Set by the orchestrator LLM when creating/planning tasks.
126
+ */
127
+ sideEffects?: boolean;
128
+ /**
129
+ * Opaque end-user identifier (OpenAI-compat `user`). Set by integrators to
130
+ * scope this task to their authenticated end-user. Polpo never verifies it.
131
+ * Propagates from Task → Run for per-user attribution and metering.
132
+ */
133
+ user?: string;
134
+ createdAt: string;
135
+ updatedAt: string;
136
+ }
137
+ export interface TaskResult {
138
+ exitCode: number;
139
+ stdout: string;
140
+ stderr: string;
141
+ duration: number;
142
+ assessment?: AssessmentResult;
143
+ /** All previous assessments (oldest first). Current assessment is always in `assessment`. */
144
+ assessmentHistory?: AssessmentResult[];
145
+ }
146
+ export interface AskUserOption {
147
+ label: string;
148
+ description?: string;
149
+ }
150
+ export interface AskUserQuestion {
151
+ /** Unique question key for matching answers (e.g. "auth-method") */
152
+ id: string;
153
+ /** The question text */
154
+ question: string;
155
+ /** Short label for compact display (max 30 chars) */
156
+ header?: string;
157
+ /** Pre-populated selectable options */
158
+ options: AskUserOption[];
159
+ /** Allow selecting multiple options (default: false) */
160
+ multiple?: boolean;
161
+ /** Whether to add a "Type your own answer" custom input (default: true) */
162
+ custom?: boolean;
163
+ }
164
+ export interface AskUserAnswer {
165
+ questionId: string;
166
+ /** Labels of selected options */
167
+ selected: string[];
168
+ /** Custom text typed by user (if custom input was used) */
169
+ customText?: string;
170
+ }
171
+ export interface AskUserRequest {
172
+ questions: AskUserQuestion[];
173
+ }
174
+ /** A watcher that fires an action when a task reaches a target status. */
175
+ export interface TaskWatcher {
176
+ /** Unique watcher ID. */
177
+ id: string;
178
+ /** Task ID to watch. */
179
+ taskId: string;
180
+ /** Target status to trigger on. */
181
+ targetStatus: TaskStatus;
182
+ /** Action to execute when triggered. */
183
+ action: NotificationAction;
184
+ /** Whether the watcher has already fired. */
185
+ fired: boolean;
186
+ /** Created at (ISO). */
187
+ createdAt: string;
188
+ /** Fired at (ISO). */
189
+ firedAt?: string;
190
+ }
191
+ //# sourceMappingURL=task.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../src/types/task.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAA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,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B;AAID,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,YAAY,EAAE,UAAU,CAAC;IACzB,wCAAwC;IACxC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,6CAA6C;IAC7C,KAAK,EAAE,OAAO,CAAC;IACf,wBAAwB;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Task domain — task lifecycle, expectations, outcomes, watchers.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/types/task.ts"],"names":[],"mappings":"AAAA;;GAEG"}