polpo-ai 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -215,6 +215,43 @@ Use `type: "tool"` for deterministic sandbox/tool actions without an LLM turn, a
|
|
|
215
215
|
|
|
216
216
|
Loop guards use Polpo's safe expression evaluator instead of JavaScript `eval` or `new Function`. Step outputs are available in the shared context bag by step id or `saveAs` path, e.g. `classify.route`, `review.approved`, or `timing.start`. `saveAs` writes context data; it does not create shell variables inside later `bash` commands. The OSS surface validates and round-trips the contract through core types, API schemas, SDK types, `polpo deploy`, and `polpo pull`.
|
|
217
217
|
|
|
218
|
+
You can also keep loops as code and compile them to the same canonical contract:
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
// .polpo/loops/router-flow.ts
|
|
222
|
+
import { defineProjectLoop } from "@polpo-ai/core/loop-code";
|
|
223
|
+
|
|
224
|
+
export default defineProjectLoop({
|
|
225
|
+
version: "1",
|
|
226
|
+
kind: "graph",
|
|
227
|
+
name: "router-flow",
|
|
228
|
+
context: "shared",
|
|
229
|
+
start: "classify",
|
|
230
|
+
steps: {
|
|
231
|
+
classify: {
|
|
232
|
+
type: "agent",
|
|
233
|
+
systemPrompt: "Classify the incoming request.",
|
|
234
|
+
tools: ["read"],
|
|
235
|
+
next: "answer",
|
|
236
|
+
},
|
|
237
|
+
answer: {
|
|
238
|
+
type: "agent",
|
|
239
|
+
systemPrompt: "Answer using the selected route.",
|
|
240
|
+
tools: ["write"],
|
|
241
|
+
next: "end",
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
CLI support:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
polpo loops validate
|
|
251
|
+
polpo loops compile .polpo/loops/router-flow.ts --out .polpo/loops/router-flow.json
|
|
252
|
+
polpo deploy
|
|
253
|
+
```
|
|
254
|
+
|
|
218
255
|
Agent-direct chat can target a loop explicitly:
|
|
219
256
|
|
|
220
257
|
```json
|
|
@@ -227,6 +264,64 @@ Agent-direct chat can target a loop explicitly:
|
|
|
227
264
|
|
|
228
265
|
At runtime, the selected project loop can narrow the effective prompt, tools, skills, model, reasoning, tool choice, and max turns per agent step. If a step omits `skills`, it inherits the agent-level `skills`. Project loop execution in chat completions uses the shared context graph: deterministic tool steps run first, store outputs in the context bag, and later agent steps receive that context as runtime data in their system prompt. Core keeps a compatibility normalizer for legacy inline `loops` + `pipeline` configs and ships a pure `PipelineExecutor` for sequential, tool, switch, parallel, and human nodes; hosts wire `runLoop`, `runTool`, and `handleHuman` callbacks to their concrete runtime.
|
|
229
266
|
|
|
267
|
+
Project loops also support governance fields:
|
|
268
|
+
|
|
269
|
+
```jsonc
|
|
270
|
+
{
|
|
271
|
+
"version": "1",
|
|
272
|
+
"kind": "graph",
|
|
273
|
+
"name": "governed-build",
|
|
274
|
+
"context": "shared",
|
|
275
|
+
"hooks": {
|
|
276
|
+
"loop:start": [
|
|
277
|
+
{ "tool": "unix_time", "saveAs": "timing.start" }
|
|
278
|
+
],
|
|
279
|
+
"tool:after": [
|
|
280
|
+
{ "tool": "audit_step", "input": { "level": "info" }, "saveAs": "audit.last", "onError": "continue" }
|
|
281
|
+
],
|
|
282
|
+
"loop:end": [
|
|
283
|
+
{ "tool": "unix_time", "saveAs": "timing.end" }
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
"policies": [
|
|
287
|
+
{
|
|
288
|
+
"id": "only-safe-tools",
|
|
289
|
+
"hook": "tool:before",
|
|
290
|
+
"effect": "allow",
|
|
291
|
+
"when": "tool.name == 'read' || tool.name == 'grep' || tool.name == 'unix_time'"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"id": "deny-shell",
|
|
295
|
+
"hook": "tool:before",
|
|
296
|
+
"effect": "deny",
|
|
297
|
+
"when": "tool.name == 'bash'",
|
|
298
|
+
"message": "bash requires an explicit build loop"
|
|
299
|
+
}
|
|
300
|
+
],
|
|
301
|
+
"start": "capture_start",
|
|
302
|
+
"steps": {
|
|
303
|
+
"capture_start": {
|
|
304
|
+
"type": "tool",
|
|
305
|
+
"tool": "unix_time",
|
|
306
|
+
"saveAs": "timing.start",
|
|
307
|
+
"next": "plan"
|
|
308
|
+
},
|
|
309
|
+
"plan": {
|
|
310
|
+
"type": "agent",
|
|
311
|
+
"systemPrompt": "Plan the work. Do not edit files.",
|
|
312
|
+
"tools": ["read", "grep"],
|
|
313
|
+
"next": "end"
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Lifecycle hooks are deterministic tool actions run by the host runtime at `loop:start`, `step:before`, `model:before`, `tool:before`, `tool:after`, `step:after`, `loop:transition`, and `loop:end`. Hook `when` guards are evaluated against the shared context plus lifecycle payload such as `step.name`, `step.type`, `tool.name`, `tool.input`, and `transition.from/to`. Hook outputs are saved into the context bag with `saveAs`; `onError: "continue"` turns a failed hook into trace-only telemetry, while the default is fail-closed.
|
|
320
|
+
|
|
321
|
+
Policies are evaluated before hook actions at the same lifecycle point. `deny` fails the loop with `LoopPolicyDeniedError`, `approval` raises `LoopApprovalRequiredError`, and `allow` policies form an allow-list for that lifecycle point when at least one exists. If an allow-list is present and no allow rule matches, the loop is blocked.
|
|
322
|
+
|
|
323
|
+
When the host wires `LoopRunStore`, chat completions create durable loop runs, append every `loop_trace` event, and return `loop_run_id`. When the host also wires `ApprovalStore`, approval policies create a pending approval request and mark the loop run as `awaiting_approval` with `approvalRequestId`. The SDK exposes `getLoopRuns()` and `getLoopRun(id)` for audit/history surfaces. Streaming completions still emit each trace incrementally.
|
|
324
|
+
|
|
230
325
|
## SDK
|
|
231
326
|
|
|
232
327
|
### Client SDK
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polpo-ai",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "The open backend for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"nanoid": "^5.1.2",
|
|
67
67
|
"yaml": "^2.7.0",
|
|
68
68
|
"zod": "^4.3.6",
|
|
69
|
-
"@polpo-ai/
|
|
70
|
-
"@polpo-ai/
|
|
71
|
-
"@polpo-ai/
|
|
72
|
-
"@polpo-ai/
|
|
69
|
+
"@polpo-ai/core": "0.10.4",
|
|
70
|
+
"@polpo-ai/server": "0.10.4",
|
|
71
|
+
"@polpo-ai/llm": "0.10.4",
|
|
72
|
+
"@polpo-ai/vault-crypto": "0.10.4"
|
|
73
73
|
},
|
|
74
74
|
"optionalDependencies": {
|
|
75
75
|
"better-sqlite3": "^12.6.2",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"nodemailer": "^8.0.1",
|
|
78
78
|
"playwright-core": "^1.52.0",
|
|
79
79
|
"postgres": "^3.4.0",
|
|
80
|
-
"@polpo-ai/drizzle": "0.10.
|
|
80
|
+
"@polpo-ai/drizzle": "0.10.4"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@types/better-sqlite3": "^7.6.13",
|