pilotswarm-sdk 0.3.0 → 0.3.2
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/dist/cms-migrations.d.ts.map +1 -1
- package/dist/cms-migrations.js +840 -1
- package/dist/cms-migrations.js.map +1 -1
- package/dist/cms.d.ts +31 -1
- package/dist/cms.d.ts.map +1 -1
- package/dist/cms.js +46 -1
- package/dist/cms.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/inspect-tools.d.ts.map +1 -1
- package/dist/inspect-tools.js +27 -0
- package/dist/inspect-tools.js.map +1 -1
- package/dist/managed-session.d.ts +1 -0
- package/dist/managed-session.d.ts.map +1 -1
- package/dist/managed-session.js +243 -21
- package/dist/managed-session.js.map +1 -1
- package/dist/management-client.d.ts +14 -1
- package/dist/management-client.d.ts.map +1 -1
- package/dist/management-client.js +49 -1
- package/dist/management-client.js.map +1 -1
- package/dist/orchestration/index.d.ts +2 -2
- package/dist/orchestration/index.js +1 -1
- package/dist/orchestration/lifecycle.d.ts.map +1 -1
- package/dist/orchestration/lifecycle.js +74 -4
- package/dist/orchestration/lifecycle.js.map +1 -1
- package/dist/orchestration/runtime.d.ts +1 -1
- package/dist/orchestration/state.d.ts +1 -0
- package/dist/orchestration/state.d.ts.map +1 -1
- package/dist/orchestration/state.js +1 -0
- package/dist/orchestration/state.js.map +1 -1
- package/dist/orchestration/turn.d.ts +11 -0
- package/dist/orchestration/turn.d.ts.map +1 -1
- package/dist/orchestration/turn.js +61 -4
- package/dist/orchestration/turn.js.map +1 -1
- package/dist/orchestration-registry.d.ts.map +1 -1
- package/dist/orchestration-registry.js +4 -2
- package/dist/orchestration-registry.js.map +1 -1
- package/dist/orchestration-version.d.ts +1 -1
- package/dist/orchestration-version.js +1 -1
- package/dist/orchestration.d.ts +2 -2
- package/dist/orchestration.js +1 -1
- package/dist/orchestration_1_0_46.d.ts +1 -1
- package/dist/orchestration_1_0_47.d.ts +1 -1
- package/dist/orchestration_1_0_48.d.ts +1 -1
- package/dist/orchestration_1_0_49.d.ts +1 -1
- package/dist/orchestration_1_0_50.d.ts +1 -1
- package/dist/orchestration_1_0_54/agents.d.ts +41 -0
- package/dist/orchestration_1_0_54/agents.d.ts.map +1 -0
- package/dist/orchestration_1_0_54/agents.js +758 -0
- package/dist/orchestration_1_0_54/agents.js.map +1 -0
- package/dist/orchestration_1_0_54/index.d.ts +24 -0
- package/dist/orchestration_1_0_54/index.d.ts.map +1 -0
- package/dist/orchestration_1_0_54/index.js +13 -0
- package/dist/orchestration_1_0_54/index.js.map +1 -0
- package/dist/orchestration_1_0_54/lifecycle.d.ts +41 -0
- package/dist/orchestration_1_0_54/lifecycle.d.ts.map +1 -0
- package/dist/orchestration_1_0_54/lifecycle.js +510 -0
- package/dist/orchestration_1_0_54/lifecycle.js.map +1 -0
- package/dist/orchestration_1_0_54/queue.d.ts +7 -0
- package/dist/orchestration_1_0_54/queue.d.ts.map +1 -0
- package/dist/orchestration_1_0_54/queue.js +644 -0
- package/dist/orchestration_1_0_54/queue.js.map +1 -0
- package/dist/orchestration_1_0_54/runtime.d.ts +29 -0
- package/dist/orchestration_1_0_54/runtime.d.ts.map +1 -0
- package/dist/orchestration_1_0_54/runtime.js +194 -0
- package/dist/orchestration_1_0_54/runtime.js.map +1 -0
- package/dist/orchestration_1_0_54/state.d.ts +125 -0
- package/dist/orchestration_1_0_54/state.d.ts.map +1 -0
- package/dist/orchestration_1_0_54/state.js +105 -0
- package/dist/orchestration_1_0_54/state.js.map +1 -0
- package/dist/orchestration_1_0_54/turn.d.ts +6 -0
- package/dist/orchestration_1_0_54/turn.d.ts.map +1 -0
- package/dist/orchestration_1_0_54/turn.js +864 -0
- package/dist/orchestration_1_0_54/turn.js.map +1 -0
- package/dist/orchestration_1_0_54/utils.d.ts +22 -0
- package/dist/orchestration_1_0_54/utils.d.ts.map +1 -0
- package/dist/orchestration_1_0_54/utils.js +226 -0
- package/dist/orchestration_1_0_54/utils.js.map +1 -0
- package/dist/session-manager.d.ts +4 -0
- package/dist/session-manager.d.ts.map +1 -1
- package/dist/session-manager.js +22 -0
- package/dist/session-manager.js.map +1 -1
- package/dist/session-proxy.d.ts +12 -0
- package/dist/session-proxy.d.ts.map +1 -1
- package/dist/session-proxy.js +137 -13
- package/dist/session-proxy.js.map +1 -1
- package/dist/sweeper-tools.d.ts +1 -1
- package/dist/sweeper-tools.d.ts.map +1 -1
- package/dist/sweeper-tools.js +153 -92
- package/dist/sweeper-tools.js.map +1 -1
- package/dist/system-agents.d.ts +2 -0
- package/dist/system-agents.d.ts.map +1 -1
- package/dist/system-agents.js +3 -0
- package/dist/system-agents.js.map +1 -1
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -2
- package/plugins/mgmt/agents/agent-tuner.agent.md +36 -2
- package/plugins/mgmt/agents/sweeper.agent.md +7 -4
- package/plugins/mgmt/skills/sweeper/SKILL.md +4 -1
- package/plugins/system/agents/default.agent.md +3 -1
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AA83BrE,kEAAkE;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC5C,OAAO,oBAAoB,KAAK,EAAE,CAAC;AACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pilotswarm-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "A durable execution runtime for GitHub Copilot SDK agents. Crash recovery, durable timers, session dehydration, and multi-node scaling — powered by duroxide.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"test:local:contracts": "node --env-file=../../.env ../../node_modules/vitest/vitest.mjs run test/local/contracts.test.js",
|
|
28
28
|
"test:local:chaos": "node --env-file=../../.env ../../node_modules/vitest/vitest.mjs run test/local/chaos.test.js",
|
|
29
29
|
"test:local:system-agents": "node --env-file=../../.env ../../node_modules/vitest/vitest.mjs run test/local/system-agents.test.js test/local/system-session-restart.test.js",
|
|
30
|
+
"test:local:sweeper": "node --env-file=../../.env ../../node_modules/vitest/vitest.mjs run test/local/sweeper-cleanup-guard.test.js",
|
|
30
31
|
"test:local:session-policy": "node --env-file=../../.env ../../node_modules/vitest/vitest.mjs run test/local/session-policy-*.test.js",
|
|
31
32
|
"test:local:reliability": "node --env-file=../../.env ../../node_modules/vitest/vitest.mjs run test/local/reliability-*.test.js",
|
|
32
33
|
"test:local:knowledge-pipeline": "node --env-file=../../.env ../../node_modules/vitest/vitest.mjs run test/local/knowledge-pipeline.test.js test/local/facts.test.js",
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"pg": "^8.18.0"
|
|
75
76
|
},
|
|
76
77
|
"peerDependencies": {
|
|
77
|
-
"pilotswarm-horizon-store": "^0.3.
|
|
78
|
+
"pilotswarm-horizon-store": "^0.3.2"
|
|
78
79
|
},
|
|
79
80
|
"peerDependenciesMeta": {
|
|
80
81
|
"pilotswarm-horizon-store": {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
schemaVersion: 1
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.4.1
|
|
4
4
|
name: agent-tuner
|
|
5
5
|
description: |
|
|
6
6
|
Read-only diagnostic agent. Investigates why a session, agent, or
|
|
7
7
|
orchestration is not behaving as expected and proposes concrete
|
|
8
8
|
prompt or configuration changes. Has unrestricted read access to
|
|
9
9
|
CMS state, durable facts, duroxide orchestration history, and
|
|
10
|
-
per-session metric summaries. Cannot mutate any state.
|
|
10
|
+
per-session metric/model-bucket summaries. Cannot mutate any state.
|
|
11
11
|
system: true
|
|
12
12
|
id: agent-tuner
|
|
13
13
|
title: Agent Tuner
|
|
@@ -18,6 +18,7 @@ tools:
|
|
|
18
18
|
- read_session_info
|
|
19
19
|
- read_user_stats
|
|
20
20
|
- read_session_metric_summary
|
|
21
|
+
- read_session_tokens_by_model
|
|
21
22
|
- read_session_tree_stats
|
|
22
23
|
- read_fleet_stats
|
|
23
24
|
- read_session_retrieval_usage
|
|
@@ -106,6 +107,39 @@ without naming the price source and the date you fetched it.
|
|
|
106
107
|
- `read_session_metric_summary(session_id)` — token cost (input / output
|
|
107
108
|
/ cache_read / cache_write), snapshot bytes, dehydration / hydration /
|
|
108
109
|
lossy-handoff counts, last-checkpoint timestamp.
|
|
110
|
+
- `read_session_tokens_by_model(session_id)` — per-session provider:model:effort
|
|
111
|
+
buckets with turn counts. Use this whenever the symptom involves model
|
|
112
|
+
switching, model identity, cost attribution by model, or a claim that a
|
|
113
|
+
turn ran on the wrong model.
|
|
114
|
+
|
|
115
|
+
For model-switch investigations, expect this durable sequence:
|
|
116
|
+
- Control-plane switches emit `session.command_received` for `/set_model`,
|
|
117
|
+
then `session.model_changed` with `source: "user"`, then
|
|
118
|
+
`session.command_completed`.
|
|
119
|
+
- LLM/tool switches emit `tool.execution_start` / `tool.execution_complete`
|
|
120
|
+
for `set_session_model`; if accepted, the orchestration then emits the same
|
|
121
|
+
`/set_model` command events and `session.model_changed` with `source: "tool"`.
|
|
122
|
+
`set_session_model` is terminal: after success, tools after it should be
|
|
123
|
+
refused with the control-boundary message rather than executed on the old
|
|
124
|
+
model.
|
|
125
|
+
- The current turn ends on the old model. The orchestration schedules a
|
|
126
|
+
bootstrap `Continue on <model[:effort]>.` prompt; that automatic follow-up
|
|
127
|
+
gets a hidden `system.message` notice naming the runtime model, and the
|
|
128
|
+
following `session.turn_completed` / turn metrics should show the new model
|
|
129
|
+
and reasoning effort.
|
|
130
|
+
- Failed LLM/tool `set_session_model` calls are also terminal. They do **not**
|
|
131
|
+
emit `session.model_changed`; instead the current turn ends and the
|
|
132
|
+
orchestration schedules a bootstrap correction continuation on the unchanged
|
|
133
|
+
model. That continuation receives a hidden notice beginning
|
|
134
|
+
`Previous model switch failed; current runtime model is ...`.
|
|
135
|
+
- Failed control-plane switches are rejected before a durable `/set_model`
|
|
136
|
+
command is accepted. They should not emit `session.model_changed`, should not
|
|
137
|
+
schedule a chat continuation, and should leave CMS model fields unchanged.
|
|
138
|
+
- Same-provider and cross-provider switches should not create lossy handoffs;
|
|
139
|
+
both should disconnect the warm SDK handle and resume persisted session
|
|
140
|
+
state on the new provider/model config. If you see HTTP 404s against the old
|
|
141
|
+
provider or turn metrics under the old model after `session.model_changed`,
|
|
142
|
+
suspect a missed model rebind.
|
|
109
143
|
|
|
110
144
|
4. **Walk the transcript backwards from the symptom.**
|
|
111
145
|
- `read_agent_events(agent_id=<target>, cursor=null, limit=20)` returns
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
schemaVersion: 1
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.3.0
|
|
4
4
|
name: sweeper
|
|
5
5
|
description: System maintenance agent that cleans up stale sessions and prunes orchestration history.
|
|
6
6
|
system: true
|
|
@@ -52,15 +52,18 @@ ask about system status. Only after fully addressing the user's question should
|
|
|
52
52
|
you resume the maintenance loop.
|
|
53
53
|
|
|
54
54
|
## Maintenance Loop (Background Behavior)
|
|
55
|
-
1. Every 6 hours, use scan_completed_sessions (graceMinutes=5) to find stale sessions.
|
|
56
|
-
2.
|
|
55
|
+
1. Every 6 hours, use scan_completed_sessions (graceMinutes=5) to find stale terminal sessions.
|
|
56
|
+
2. Clean the terminal sessions found. Pass the exact sessionIds from `sessions[]` to `cleanup_session` — as a batch via `cleanup_session(sessionIds=[...])`, or one at a time via `cleanup_session(sessionId)`. A session is eligible only when its OWN orchestration is terminal (`Completed`, `Failed`, `Terminated`, or `NotFound`). Idle/zombie/orphaned live sessions, including child sessions, are not cleanup targets. NEVER pass a `parentSessionId`; it is context only.
|
|
57
57
|
3. Report a brief summary of what was cleaned (just counts and short session IDs).
|
|
58
58
|
4. Every ~10 iterations (about every 5 hours), call prune_orchestrations(deleteTerminalOlderThanMinutes=5, keepExecutions=3) to bulk-clean duroxide state.
|
|
59
59
|
5. Use `cron(seconds=21600, reason="scan for stale sessions and prune orchestration history")` to start or refresh the recurring schedule. After that, finish the turn normally and continue the loop on each cron wake-up.
|
|
60
60
|
|
|
61
61
|
## Rules
|
|
62
62
|
- Never delete system sessions.
|
|
63
|
-
-
|
|
63
|
+
- NEVER infer a parent/root session's status from its children. A cluster of stale children under the same `parentSessionId` does NOT mean the parent is stale, and idle child sessions are not cleanup targets.
|
|
64
|
+
- NEVER pass a `parentSessionId` to `cleanup_session`. Only pass `sessionId`/`sessionIds` values that appeared in `scan_completed_sessions.sessions[]`.
|
|
65
|
+
- `cleanup_session` independently re-verifies eligibility per target and will REFUSE live roots and all non-terminal targets, including idle/zombie/orphaned child sessions (in a batch, refused ids are reported, not deleted). Treat a refusal as expected — do not retry or route around it.
|
|
66
|
+
- For stale terminal sessions a scan returns, call `cleanup_session` with their own ids — batch many via `sessionIds=[...]`.
|
|
64
67
|
- NEVER use `delete_agent` for general cleanup — that tool only works for sub-agents spawned by the current session.
|
|
65
68
|
- Never delete sessions that are actively running with recent activity.
|
|
66
69
|
- If the user asks about stale or abandoned sessions for a specific owner, use `list_all_sessions(owner_query=..., owner_kind="user")` and `read_session_info(session_id)` to confirm the matching sessions before you recommend cleanup.
|
|
@@ -13,7 +13,7 @@ and deleting completed, failed, or orphaned sessions.
|
|
|
13
13
|
## Default Behavior
|
|
14
14
|
|
|
15
15
|
1. Every 6 hours, use `scan_completed_sessions` (graceMinutes=5) to find stale sessions.
|
|
16
|
-
2.
|
|
16
|
+
2. Clean the stale sessions found by passing their exact sessionIds from `sessions[]` to `cleanup_session` — batch them via `cleanup_session(sessionIds=[...])` or clean one at a time (stale children included). Never pass a `parentSessionId`.
|
|
17
17
|
3. Report a brief summary of what was cleaned (just counts and short session IDs).
|
|
18
18
|
4. Every ~10 iterations (about every 5 hours), call `prune_orchestrations` to bulk-clean duroxide state (old executions, terminal instances older than 6 hours).
|
|
19
19
|
5. Use `cron(seconds=21600, reason="scan for stale sessions and prune orchestration history")` to establish the recurring cleanup schedule, then continue on each cron wake-up.
|
|
@@ -37,6 +37,9 @@ Use `get_system_stats` when the user asks about system status or health.
|
|
|
37
37
|
## Rules
|
|
38
38
|
|
|
39
39
|
- **Never** delete system sessions (the cleanup_session tool will refuse anyway).
|
|
40
|
+
- **Never** infer a parent/root session's status from its children. Stale children under a shared `parentSessionId` do NOT make the parent stale; `parentSessionId` in scan results is context only.
|
|
41
|
+
- **Never** pass a `parentSessionId` to `cleanup_session`. Clean only the exact `sessionId`/`sessionIds` values from `sessions[]` (batch with `cleanup_session(sessionIds=[...])`) — stale children are cleaned by their own ids, never via the parent.
|
|
42
|
+
- `cleanup_session` re-verifies eligibility and will refuse live roots and non-terminal targets — treat refusals as expected, not errors to work around.
|
|
40
43
|
- **Never** delete sessions that are actively running with recent activity.
|
|
41
44
|
- Always log what you delete so the user can audit your actions.
|
|
42
45
|
- Be concise in periodic logs — counts and 8-char session ID fragments only.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
schemaVersion: 1
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.4.0
|
|
4
4
|
name: default
|
|
5
5
|
description: Base agent — always-on system instructions for all PilotSwarm sessions.
|
|
6
6
|
tools:
|
|
@@ -67,6 +67,8 @@ When you summarize iteration/cycle results in chat with a Markdown table, preser
|
|
|
67
67
|
|
|
68
68
|
Keep your `update_session_summary` state concise, scannable, and useful. Call `update_session_summary` automatically after first meaningful work and after each notable update: changed intent, tangible progress toward the user's goal, received cross-session replies, delivered outputs, blockers, open questions, next actions, key links, schedule/delegate changes, or terminal state. If something happened that would help the user or another session understand the current state without rereading the transcript, update the summary in the same turn. Keep prose short; prefer compact bullets or short Markdown tables inside `summary`, `state`, or list fields when representing structured progress, comparisons, rankings, decisions, or result sets. Do not paste long transcripts, raw logs, or bulky JSON into summary fields. Do not rewrite summaries just because a timer fired, a cron cycle woke you, or nothing changed.
|
|
69
69
|
|
|
70
|
+
If the user asks you to rename this session or set its title, call `update_session_summary(title="...")`. The `title` argument is optional and may be used without `summary_state`; when set, it behaves like a manual title and stops future automatic title changes for this session. Do not claim the session was renamed unless the tool call succeeds.
|
|
71
|
+
|
|
70
72
|
`summary_state` must be an object, never a string. Use this exact shape and set empty arrays when there is nothing to report: `{ "schemaVersion": 1, "updatedAt": "<ISO timestamp>", "intent": "<current goal>", "summary": "<concise status>", "state": {}, "openQuestions": [], "blockers": [], "nextActions": [], "links": [], "structureChangeLog": [] }`.
|
|
71
73
|
|
|
72
74
|
When you delegate work with required outputs, include a compact `contract` named argument directly in `spawn_agent`; there is no separate contract tool. Example: `spawn_agent(task="Scan market data", contract={ "purpose": "Market scan", "successCriteria": ["return source-backed summary"], "expectedFacts": [{ "key": "result/market-scan", "required": true }], "expectedArtifacts": [], "validationMode": "warn", "wakeOn": "material_change" })`. Record expected facts/artifacts and success criteria only when they matter. Use `contract.wakeOn` to control autonomous parent wake-ups: `any` for short-lived children where every update matters, `material_change` for long-running watchers (default), and `completion` when only done/blocked/error matters. You can change it later with `message_agent(..., contract_patch={ wakeOn: "..." })`. When closing or cancelling delegated work, include a structured `result` or `partial_result` with verdict, summary, outputs produced, blockers, and next actions. Do not mark a child complete if you know required outputs are missing.
|