@duetso/agent 0.1.20

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 (148) hide show
  1. package/LICENSE +189 -0
  2. package/README.md +315 -0
  3. package/dist/package.json +84 -0
  4. package/dist/src/cli.d.ts +23 -0
  5. package/dist/src/cli.d.ts.map +1 -0
  6. package/dist/src/cli.js +754 -0
  7. package/dist/src/cli.js.map +1 -0
  8. package/dist/src/core/serializer.d.ts +3 -0
  9. package/dist/src/core/serializer.d.ts.map +1 -0
  10. package/dist/src/core/serializer.js +22 -0
  11. package/dist/src/core/serializer.js.map +1 -0
  12. package/dist/src/core/structured-output.d.ts +13 -0
  13. package/dist/src/core/structured-output.d.ts.map +1 -0
  14. package/dist/src/core/structured-output.js +41 -0
  15. package/dist/src/core/structured-output.js.map +1 -0
  16. package/dist/src/guardrails/firewall.d.ts +7 -0
  17. package/dist/src/guardrails/firewall.d.ts.map +1 -0
  18. package/dist/src/guardrails/firewall.js +31 -0
  19. package/dist/src/guardrails/firewall.js.map +1 -0
  20. package/dist/src/guardrails/pattern.d.ts +13 -0
  21. package/dist/src/guardrails/pattern.d.ts.map +1 -0
  22. package/dist/src/guardrails/pattern.js +70 -0
  23. package/dist/src/guardrails/pattern.js.map +1 -0
  24. package/dist/src/guardrails/semantic.d.ts +14 -0
  25. package/dist/src/guardrails/semantic.d.ts.map +1 -0
  26. package/dist/src/guardrails/semantic.js +47 -0
  27. package/dist/src/guardrails/semantic.js.map +1 -0
  28. package/dist/src/index.d.ts +20 -0
  29. package/dist/src/index.d.ts.map +1 -0
  30. package/dist/src/index.js +20 -0
  31. package/dist/src/index.js.map +1 -0
  32. package/dist/src/lib/compact-json.d.ts +11 -0
  33. package/dist/src/lib/compact-json.d.ts.map +1 -0
  34. package/dist/src/lib/compact-json.js +36 -0
  35. package/dist/src/lib/compact-json.js.map +1 -0
  36. package/dist/src/lib/xml.d.ts +3 -0
  37. package/dist/src/lib/xml.d.ts.map +1 -0
  38. package/dist/src/lib/xml.js +9 -0
  39. package/dist/src/lib/xml.js.map +1 -0
  40. package/dist/src/memory/observation-groups.d.ts +15 -0
  41. package/dist/src/memory/observation-groups.d.ts.map +1 -0
  42. package/dist/src/memory/observation-groups.js +159 -0
  43. package/dist/src/memory/observation-groups.js.map +1 -0
  44. package/dist/src/memory/observational-prompts.d.ts +27 -0
  45. package/dist/src/memory/observational-prompts.d.ts.map +1 -0
  46. package/dist/src/memory/observational-prompts.js +237 -0
  47. package/dist/src/memory/observational-prompts.js.map +1 -0
  48. package/dist/src/memory/observational.d.ts +63 -0
  49. package/dist/src/memory/observational.d.ts.map +1 -0
  50. package/dist/src/memory/observational.js +605 -0
  51. package/dist/src/memory/observational.js.map +1 -0
  52. package/dist/src/memory/storage.d.ts +3 -0
  53. package/dist/src/memory/storage.d.ts.map +1 -0
  54. package/dist/src/memory/storage.js +127 -0
  55. package/dist/src/memory/storage.js.map +1 -0
  56. package/dist/src/memory/store.d.ts +13 -0
  57. package/dist/src/memory/store.d.ts.map +1 -0
  58. package/dist/src/memory/store.js +106 -0
  59. package/dist/src/memory/store.js.map +1 -0
  60. package/dist/src/model-resolution/duet-gateway.d.ts +35 -0
  61. package/dist/src/model-resolution/duet-gateway.d.ts.map +1 -0
  62. package/dist/src/model-resolution/duet-gateway.js +56 -0
  63. package/dist/src/model-resolution/duet-gateway.js.map +1 -0
  64. package/dist/src/model-resolution/index.d.ts +31 -0
  65. package/dist/src/model-resolution/index.d.ts.map +1 -0
  66. package/dist/src/model-resolution/index.js +129 -0
  67. package/dist/src/model-resolution/index.js.map +1 -0
  68. package/dist/src/session/session-manager.d.ts +45 -0
  69. package/dist/src/session/session-manager.d.ts.map +1 -0
  70. package/dist/src/session/session-manager.js +94 -0
  71. package/dist/src/session/session-manager.js.map +1 -0
  72. package/dist/src/session/session.d.ts +113 -0
  73. package/dist/src/session/session.d.ts.map +1 -0
  74. package/dist/src/session/session.js +308 -0
  75. package/dist/src/session/session.js.map +1 -0
  76. package/dist/src/tui/app.d.ts +60 -0
  77. package/dist/src/tui/app.d.ts.map +1 -0
  78. package/dist/src/tui/app.js +742 -0
  79. package/dist/src/tui/app.js.map +1 -0
  80. package/dist/src/turn-runner/agent-events.d.ts +5 -0
  81. package/dist/src/turn-runner/agent-events.d.ts.map +1 -0
  82. package/dist/src/turn-runner/agent-events.js +59 -0
  83. package/dist/src/turn-runner/agent-events.js.map +1 -0
  84. package/dist/src/turn-runner/prompts.d.ts +13 -0
  85. package/dist/src/turn-runner/prompts.d.ts.map +1 -0
  86. package/dist/src/turn-runner/prompts.js +79 -0
  87. package/dist/src/turn-runner/prompts.js.map +1 -0
  88. package/dist/src/turn-runner/shell-state-handle.d.ts +32 -0
  89. package/dist/src/turn-runner/shell-state-handle.d.ts.map +1 -0
  90. package/dist/src/turn-runner/shell-state-handle.js +168 -0
  91. package/dist/src/turn-runner/shell-state-handle.js.map +1 -0
  92. package/dist/src/turn-runner/skill-context.d.ts +26 -0
  93. package/dist/src/turn-runner/skill-context.d.ts.map +1 -0
  94. package/dist/src/turn-runner/skill-context.js +110 -0
  95. package/dist/src/turn-runner/skill-context.js.map +1 -0
  96. package/dist/src/turn-runner/skills.d.ts +35 -0
  97. package/dist/src/turn-runner/skills.d.ts.map +1 -0
  98. package/dist/src/turn-runner/skills.js +130 -0
  99. package/dist/src/turn-runner/skills.js.map +1 -0
  100. package/dist/src/turn-runner/state-machine-controller.d.ts +90 -0
  101. package/dist/src/turn-runner/state-machine-controller.d.ts.map +1 -0
  102. package/dist/src/turn-runner/state-machine-controller.js +289 -0
  103. package/dist/src/turn-runner/state-machine-controller.js.map +1 -0
  104. package/dist/src/turn-runner/state-machine-session.d.ts +27 -0
  105. package/dist/src/turn-runner/state-machine-session.d.ts.map +1 -0
  106. package/dist/src/turn-runner/state-machine-session.js +189 -0
  107. package/dist/src/turn-runner/state-machine-session.js.map +1 -0
  108. package/dist/src/turn-runner/tools.d.ts +193 -0
  109. package/dist/src/turn-runner/tools.d.ts.map +1 -0
  110. package/dist/src/turn-runner/tools.js +509 -0
  111. package/dist/src/turn-runner/tools.js.map +1 -0
  112. package/dist/src/turn-runner/turn-runner.d.ts +160 -0
  113. package/dist/src/turn-runner/turn-runner.d.ts.map +1 -0
  114. package/dist/src/turn-runner/turn-runner.js +907 -0
  115. package/dist/src/turn-runner/turn-runner.js.map +1 -0
  116. package/dist/src/turn-runner/turn-state.d.ts +6 -0
  117. package/dist/src/turn-runner/turn-state.d.ts.map +1 -0
  118. package/dist/src/turn-runner/turn-state.js +32 -0
  119. package/dist/src/turn-runner/turn-state.js.map +1 -0
  120. package/dist/src/turn-runner/usage-accounting.d.ts +7 -0
  121. package/dist/src/turn-runner/usage-accounting.d.ts.map +1 -0
  122. package/dist/src/turn-runner/usage-accounting.js +49 -0
  123. package/dist/src/turn-runner/usage-accounting.js.map +1 -0
  124. package/dist/src/types/agent.d.ts +15 -0
  125. package/dist/src/types/agent.d.ts.map +1 -0
  126. package/dist/src/types/agent.js +2 -0
  127. package/dist/src/types/agent.js.map +1 -0
  128. package/dist/src/types/config.d.ts +37 -0
  129. package/dist/src/types/config.d.ts.map +1 -0
  130. package/dist/src/types/config.js +2 -0
  131. package/dist/src/types/config.js.map +1 -0
  132. package/dist/src/types/guardrails.d.ts +34 -0
  133. package/dist/src/types/guardrails.d.ts.map +1 -0
  134. package/dist/src/types/guardrails.js +2 -0
  135. package/dist/src/types/guardrails.js.map +1 -0
  136. package/dist/src/types/memory.d.ts +151 -0
  137. package/dist/src/types/memory.d.ts.map +1 -0
  138. package/dist/src/types/memory.js +2 -0
  139. package/dist/src/types/memory.js.map +1 -0
  140. package/dist/src/types/protocol.d.ts +426 -0
  141. package/dist/src/types/protocol.d.ts.map +1 -0
  142. package/dist/src/types/protocol.js +2 -0
  143. package/dist/src/types/protocol.js.map +1 -0
  144. package/dist/src/types/state-machine.d.ts +344 -0
  145. package/dist/src/types/state-machine.d.ts.map +1 -0
  146. package/dist/src/types/state-machine.js +2 -0
  147. package/dist/src/types/state-machine.js.map +1 -0
  148. package/package.json +84 -0
@@ -0,0 +1,344 @@
1
+ import type { TurnQuestion } from "./protocol.js";
2
+ export declare const INTERRUPTED_STATE_MACHINE_STATE = "interrupted";
3
+ /**
4
+ * Durable state-machine definitions and runtime state.
5
+ *
6
+ * A state machine models the high-level business process, not task execution.
7
+ * There is one current business state at a time. The state-machine runner agent
8
+ * sees the original prompt, current transition input, state history, and state
9
+ * definitions, then decides which state should run next, whether the session should
10
+ * wait, or whether a terminal state should finalize the state machine.
11
+ *
12
+ * If a state needs fan-out, parallelism, or task-level workflow execution, that
13
+ * belongs inside an agent or script state. The state machine only tracks the
14
+ * business-level state transition.
15
+ * Do not hardcode integrations such as email, GitHub, Slack, Calendly, or
16
+ * webhooks into the engine. Any external system with an API or CLI is a bash
17
+ * script away, and this engine can accept a few minutes of polling latency
18
+ * instead of requiring realtime responsiveness.
19
+ *
20
+ * Case 1: conference outreach state machine
21
+ *
22
+ * User provides an email address. Agent/script states can enrich the prospect,
23
+ * research the company, draft/send outreach, then a poll state can check whether
24
+ * the prospect has replied or whether the next follow-up date has arrived.
25
+ *
26
+ * The runner should:
27
+ *
28
+ * 1. Start a StateMachineSession from a StateMachineDefinition.
29
+ * 2. Enter an agent state for enrichment/research and record the output in the
30
+ * session history so the state machine can resume without repeating research.
31
+ * 3. Enter a send-email script state and record the sent message details.
32
+ * 4. The runner can choose a poll state. The runner runs one poll attempt,
33
+ * emits a sleep event if nothing changed, and relies on the outer layer to
34
+ * wake it later. A poll attempt can run a script or prompt an agent, and
35
+ * should return structured data only when there is something for the state
36
+ * machine to do next, such as:
37
+ * - prospect replied
38
+ * - follow-up due
39
+ * - meeting scheduled
40
+ * - outreach window expired
41
+ * 5. When polling returns a reply payload, resume the session and ask an
42
+ * agent to classify it: interested, negative, ad hoc question, neutral, or
43
+ * unclear.
44
+ * 6. The runner chooses the appropriate next state based on that classification:
45
+ * - interested -> send Calendly / schedule-meeting state
46
+ * - ad hoc question -> answer question, then return to waiting
47
+ * - negative -> terminal state: prospect_not_interested
48
+ * - unclear -> ask a follow-up or wait for more context
49
+ * 7. When polling returns follow-up_due, send a follow-up if the session
50
+ * has not exceeded the cadence limit. For example: every 4 days for one
51
+ * month.
52
+ * 8. End in one of the named terminal states:
53
+ * - meeting_scheduled
54
+ * - prospect_not_interested
55
+ * - negative_response
56
+ * - no_response_after_followups
57
+ *
58
+ * The state-machine types should support this by representing:
59
+ *
60
+ * - durable session history
61
+ * - agent/tool/script states whose outputs are available through state-machine history
62
+ * - poll states, plus explicit waits for human input
63
+ * - runner-agent decisions driven by full prompt, transition input, and history
64
+ * - named terminal states richer than generic "completed" or "failed"
65
+ *
66
+ * Case 2: development state machine
67
+ *
68
+ * User provides a prompt. Agent/script states can create an isolated worktree,
69
+ * run a dev agent, run a review agent, create a PR, poll until the PR is merged
70
+ * or closed, then clean up the worktree.
71
+ *
72
+ * The runner should:
73
+ *
74
+ * 1. Start a StateMachineSession from the user's prompt.
75
+ * 2. Execute a script/tool state that creates a worktree and records its path in
76
+ * state-machine history.
77
+ * 3. Execute an agent state that implements the requested code change inside the
78
+ * worktree.
79
+ * 4. Execute a review agent state. The review can either approve, request fixes,
80
+ * or block the state machine.
81
+ * 5. If fixes are requested, choose the dev-agent state again with the review
82
+ * feedback as input. The session history should preserve both attempts.
83
+ * 6. When approved, execute a PR creation state and record PR number/URL.
84
+ * 7. Enter a poll state. Each poll attempt can use gh, git, or any other
85
+ * CLI/API wrapper to inspect the PR state and return:
86
+ * - merged -> continue to cleanup and terminal state: merged
87
+ * - closed -> continue to cleanup and terminal state: closed
88
+ * 8. Execute cleanup using the recorded worktree path.
89
+ *
90
+ * The state-machine types should support this by representing:
91
+ *
92
+ * - a catalog of available business states
93
+ * - retry/review loops without losing prior state history
94
+ * - poll states that use sleep between attempts
95
+ * - cleanup/finalizer states that run after terminal external outcomes
96
+ * - terminal states such as merged, closed, failed_review, or cancelled
97
+ *
98
+ * In state-machine mode, the parent runner is still a normal pi agent with its
99
+ * normal tools. The difference is prompting and routing: it should do as much
100
+ * durable business-process work through the state machine as possible, while
101
+ * still answering simple unrelated requests directly when that is the right
102
+ * behavior. The parent runner dispatches the current state, records the
103
+ * selected state's result, asks the runner agent what state should come next,
104
+ * updates history, and emits protocol events.
105
+ *
106
+ * Agent states execute by running the runner in normal agent mode. The parent
107
+ * runner is not a separate worker pool; the selected state owns execution, and
108
+ * an agent state delegates that execution back to a turn-runner agent-mode turn.
109
+ * This lets the same state machine start in the middle when the user's prompt
110
+ * says prior work already happened, such as "I've already sent email, just wait
111
+ * for response." The runner injects the original prompt and relevant history
112
+ * automatically when constructing agent prompts; state definitions only describe
113
+ * their own behavior. Human input is not a separate state-machine state: if the
114
+ * current state is an agent state and the runner state is waiting_for_human, the
115
+ * state machine is waiting for that agent's user input. Polling remains explicit
116
+ * because the runner owns one poll attempt and emits sleep until the next attempt.
117
+ *
118
+ * Example of templated script commands:
119
+ *
120
+ * The parent runner can pass transition input when selecting a state:
121
+ *
122
+ * {
123
+ * kind: "script",
124
+ * inputSchema: {
125
+ * type: "object",
126
+ * properties: { branchName: { type: "string" } },
127
+ * required: ["branchName"]
128
+ * },
129
+ * command: "scripts/create-worktree.sh '{{ input.branchName }}'"
130
+ * }
131
+ *
132
+ * A later dev state or cleanup state can receive fresh input selected from
133
+ * prior completion output:
134
+ *
135
+ * {
136
+ * kind: "script",
137
+ * command: "rm -rf '{{ input.worktreePath }}'"
138
+ * }
139
+ *
140
+ * A PR poll state can check through any CLI/API wrapper without the state
141
+ * machine engine knowing about GitHub:
142
+ *
143
+ * {
144
+ * kind: "poll",
145
+ * command: "scripts/check-pr-finished.sh '{{ input.prUrl }}'",
146
+ * intervalMs: 300000
147
+ * }
148
+ */
149
+ /** User-authored state machine template. Runtime progress lives in StateMachineSession. */
150
+ export interface StateMachineDefinition {
151
+ /** Human-readable label for selection in CLIs/UIs. */
152
+ name: string;
153
+ /**
154
+ * Routing guidance for the runner agent. This explains when this definition's
155
+ * set of states applies; if the user's request does not match this prompt, the
156
+ * selected state can be undefined and the runner can answer normally in agent mode.
157
+ */
158
+ prompt: string;
159
+ /** Available states the runner agent can choose from, including terminal states. */
160
+ states: StateMachineState[];
161
+ }
162
+ /**
163
+ * Persisted execution state. The runner can stop after any state and later
164
+ * continue from this session without redoing completed work.
165
+ */
166
+ export interface StateMachineSession {
167
+ /** Current active definition. Required for resuming and dispatching currentState. */
168
+ definition: StateMachineDefinition;
169
+ /** Original user request that started the state machine. */
170
+ prompt: string;
171
+ /**
172
+ * Current business state, selected by the runner agent.
173
+ *
174
+ * The reserved value "interrupted" means runtime work was aborted before the
175
+ * state could finish. It is not a user-authored state name; the previous
176
+ * running state and its input remain available in history.
177
+ */
178
+ currentState?: string;
179
+ /**
180
+ * Input supplied by the parent runner when it selected the current state.
181
+ * Persisted so sleeping scheduled states can resume with the same template values.
182
+ */
183
+ currentInput?: Record<string, unknown>;
184
+ /**
185
+ * Compact progress counters for status questions. This stays separate from
186
+ * history so frequent poll sleeps do not spam the audit log.
187
+ */
188
+ progress?: StateMachineProgress;
189
+ /** Append-only audit log used for debugging, replay, and persistence. */
190
+ history: StateMachineSessionEvent[];
191
+ /** Present only after a session reaches a named terminal state. */
192
+ terminal?: StateMachineTerminalResult;
193
+ createdAt: number;
194
+ updatedAt: number;
195
+ }
196
+ export type StateMachineState = StateMachineAgentState | StateMachineScriptState | StateMachinePollState | StateMachineTimerState | StateMachineTerminalState;
197
+ export interface StateMachineProgress {
198
+ /** Per-state counters keyed by state name for compact status reporting. */
199
+ states: Record<string, StateMachineStateProgress>;
200
+ }
201
+ export interface StateMachineStateProgress {
202
+ /** State kind from the active definition when the progress entry was updated. */
203
+ kind?: StateMachineState["kind"];
204
+ /** Number of times the parent selected this state. */
205
+ runs: number;
206
+ /** Number of times this state emitted sleep while waiting for a later wake. */
207
+ sleeps: number;
208
+ /** Scheduled wake time from the latest sleep, cleared when the state runs again. */
209
+ nextWakeAt?: number;
210
+ }
211
+ export interface StateMachineBaseState {
212
+ /** Name shown in status output and used by the runner when choosing a state. */
213
+ name: string;
214
+ /** Helps the runner agent understand when this state is appropriate. */
215
+ when?: string;
216
+ /**
217
+ * Optional JSON Schema for the input the parent runner must provide when
218
+ * selecting this state. The runner validates transition input before executing
219
+ * the state and exposes it to prompt/script templates as `input`.
220
+ */
221
+ inputSchema?: Record<string, unknown>;
222
+ }
223
+ /** Runs an agent. The runner injects original prompt/history outside this state config. */
224
+ export interface StateMachineAgentState extends StateMachineBaseState {
225
+ kind: "agent";
226
+ /**
227
+ * User prompt sent to the sub-agent. The runner renders this as a template
228
+ * using the transition input provided when the parent runner selected this
229
+ * state.
230
+ */
231
+ prompt: string;
232
+ /**
233
+ * Optional system prompt appended to the runner's base system prompt for this
234
+ * sub-agent only. Use this for durable role or behavior instructions; dynamic
235
+ * state input belongs in `prompt`.
236
+ */
237
+ systemPrompt?: string;
238
+ /**
239
+ * Optional skill allowlist for this sub-agent. When set, only these discovered
240
+ * or explicitly configured skills are injected into the sub-agent system
241
+ * prompt.
242
+ */
243
+ allowedSkills?: string[];
244
+ }
245
+ /** Runs a shell command. This is the generic integration primitive. */
246
+ export interface StateMachineScriptState extends StateMachineBaseState {
247
+ kind: "script";
248
+ /**
249
+ * Shell command used for integrations, setup, cleanup, and deterministic
250
+ * checks. The runner renders this as a template using transition input; keep
251
+ * state-machine definitions serializable instead of storing executable
252
+ * functions here.
253
+ */
254
+ command: string;
255
+ /** Working directory for the command. Defaults to the state-machine session cwd. */
256
+ cwd?: string;
257
+ /** Kills the command if it exceeds this runtime. */
258
+ timeoutMs?: number;
259
+ /** Exit codes treated as success. Defaults to [0]. */
260
+ successCodes?: number[];
261
+ }
262
+ /** Performs one external check, then either records data or sleeps until the next attempt. */
263
+ export interface StateMachinePollState extends StateMachineBaseState {
264
+ kind: "poll";
265
+ /** Recurring delay between external check attempts. */
266
+ intervalMs: number;
267
+ /** Maximum time the state machine can remain in this poll state before failing the session. */
268
+ timeoutMs?: number;
269
+ /**
270
+ * Runs once per poll attempt. The command should return structured output
271
+ * only when something changed; otherwise the runner sleeps and tries again.
272
+ */
273
+ command: string;
274
+ /** Working directory for the command. Defaults to the state-machine session cwd. */
275
+ cwd?: string;
276
+ /** Exit codes that mean this poll found a result. Defaults to [0]. */
277
+ successCodes?: number[];
278
+ }
279
+ /** Sleeps until one absolute time, then lets the parent choose the next state. */
280
+ export interface StateMachineTimerState extends StateMachineBaseState {
281
+ kind: "timer";
282
+ /** Absolute Unix epoch millisecond time when this timer state should complete. */
283
+ wakeAt: number;
284
+ }
285
+ /** Finalizes the session when reached. Terminal outcomes are just state machine states. */
286
+ export interface StateMachineTerminalState extends StateMachineBaseState {
287
+ kind: "terminal";
288
+ /** Maps this named outcome to the session's lifecycle status. */
289
+ status: "completed" | "failed" | "cancelled";
290
+ /** Optional final explanation shown to users and recorded in history. */
291
+ reason?: string;
292
+ }
293
+ export interface StateMachineTerminalResult {
294
+ /** Names the terminal state that finalized the session. */
295
+ state: string;
296
+ /** Copied from the terminal state for easy querying. */
297
+ status: StateMachineTerminalState["status"];
298
+ /** Optional final explanation, often generated by the runner. */
299
+ reason?: string;
300
+ }
301
+ export type StateMachineSessionEvent = {
302
+ type: "state_machine_started";
303
+ timestamp: number;
304
+ } | {
305
+ type: "runner_decided";
306
+ timestamp: number;
307
+ decision: unknown;
308
+ } | {
309
+ type: "state_started";
310
+ timestamp: number;
311
+ state: string;
312
+ input?: Record<string, unknown>;
313
+ } | {
314
+ type: "state_completed";
315
+ timestamp: number;
316
+ state: string;
317
+ output?: unknown;
318
+ } | {
319
+ type: "state_failed";
320
+ timestamp: number;
321
+ state: string;
322
+ error: string;
323
+ } | {
324
+ type: "state_interrupted";
325
+ timestamp: number;
326
+ state: string;
327
+ reason?: string;
328
+ output?: {
329
+ assistantText?: string;
330
+ } | {
331
+ stdout: string;
332
+ stderr: string;
333
+ };
334
+ } | {
335
+ type: "state_asked_user";
336
+ timestamp: number;
337
+ state: string;
338
+ questions: TurnQuestion[];
339
+ } | {
340
+ type: "state_machine_completed";
341
+ timestamp: number;
342
+ terminal: StateMachineTerminalResult;
343
+ };
344
+ //# sourceMappingURL=state-machine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.d.ts","sourceRoot":"","sources":["../../../src/types/state-machine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,eAAO,MAAM,+BAA+B,gBAAgB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiJG;AAEH,2FAA2F;AAC3F,MAAM,WAAW,sBAAsB;IACrC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,qFAAqF;IACrF,UAAU,EAAE,sBAAsB,CAAC;IACnC,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,yEAAyE;IACzE,OAAO,EAAE,wBAAwB,EAAE,CAAC;IACpC,mEAAmE;IACnE,QAAQ,CAAC,EAAE,0BAA0B,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,iBAAiB,GACzB,sBAAsB,GACtB,uBAAuB,GACvB,qBAAqB,GACrB,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,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/E;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACzE;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1E,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,YAAY,EAAE,CAAC;CAC3B,GACD;IAAE,IAAI,EAAE,yBAAyB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,0BAA0B,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const INTERRUPTED_STATE_MACHINE_STATE = "interrupted";
2
+ //# sourceMappingURL=state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.js","sourceRoot":"","sources":["../../../src/types/state-machine.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,+BAA+B,GAAG,aAAa,CAAC"}
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@duetso/agent",
3
+ "version": "0.1.20",
4
+ "description": "An opinionated full-stack agent turn runner with native memories, interrupts, and multi-agent orchestration",
5
+ "keywords": [
6
+ "agent",
7
+ "ai",
8
+ "llm",
9
+ "memory",
10
+ "multi-agent",
11
+ "session-manager"
12
+ ],
13
+ "license": "Apache-2.0",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/dzhng/duet-agent"
17
+ },
18
+ "bin": {
19
+ "duet": "dist/src/cli.js"
20
+ },
21
+ "files": [
22
+ "dist/package.json",
23
+ "dist/src",
24
+ "LICENSE",
25
+ "README.md"
26
+ ],
27
+ "type": "module",
28
+ "main": "dist/src/index.js",
29
+ "types": "dist/src/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/src/index.d.ts",
33
+ "import": "./dist/src/index.js"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "scripts": {
41
+ "setup": "bash scripts/setup-docker.sh",
42
+ "build": "tsc",
43
+ "check-types": "tsc --noEmit",
44
+ "cli": "bun src/cli.ts",
45
+ "dev": "tsc --watch",
46
+ "eval": "docker run --rm -v \"$PWD:/src:ro\" -w /work -e HOME=/tmp/home -e DUET_TEST_IN_DOCKER=1 oven/bun:1.3.11 sh -lc 'cp -R /src/. /work && bun install --frozen-lockfile && bun test ./evals/*.eval.ts'",
47
+ "format": "oxfmt --write --no-error-on-unmatched-pattern",
48
+ "format:check": "oxfmt --check --no-error-on-unmatched-pattern",
49
+ "lint": "oxlint src/",
50
+ "prepack": "bun run build",
51
+ "test": "docker run --rm -v \"$PWD:/src:ro\" -w /work -e HOME=/tmp/home -e DUET_TEST_IN_DOCKER=1 oven/bun:1.3.11 sh -lc 'cp -R /src/. /work && bun install --frozen-lockfile && bun test ./test/*.test.ts'",
52
+ "example": "bun examples/basic.ts",
53
+ "example:state-machine": "bun examples/state-machine.ts",
54
+ "prepare": "husky",
55
+ "build:compile": "bun build src/cli.ts --compile --outfile dist/duet"
56
+ },
57
+ "dependencies": {
58
+ "@earendil-works/pi-agent-core": "^0.74.0",
59
+ "@earendil-works/pi-ai": "^0.74.0",
60
+ "@earendil-works/pi-coding-agent": "^0.74.0",
61
+ "@electric-sql/pglite": "^0.4.5",
62
+ "@opentui/core": "^0.2.2",
63
+ "ajv": "^8.20.0",
64
+ "dedent": "^1.7.2",
65
+ "dotenv": "^17.4.2",
66
+ "eventemitter3": "^5.0.0",
67
+ "jstoxml": "^7.1.0",
68
+ "nanoid": "^5.0.0",
69
+ "typebox": "^1.1.24"
70
+ },
71
+ "devDependencies": {
72
+ "@types/bun": "^1.3.13",
73
+ "@types/node": "^22.0.0",
74
+ "husky": "^9.1.7",
75
+ "oxfmt": "^0.47.0",
76
+ "oxlint": "^0.16.0",
77
+ "tsx": "^4.19.0",
78
+ "typescript": "^5.7.0"
79
+ },
80
+ "engines": {
81
+ "node": ">=20"
82
+ },
83
+ "packageManager": "bun@1.3.11"
84
+ }