@cognisphere-sh/cognisphere-harness 0.13.0 → 0.15.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 (33) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/dist-web/assets/{file-editor-CqGYKmT3.js → file-editor-DJydzVQK.js} +1 -1
  3. package/dist-web/assets/{index-CDE-jsH8.js → index-C2uTXv8R.js} +2 -2
  4. package/dist-web/index.html +1 -1
  5. package/home-template/docs/base-harness/README.md +25 -7
  6. package/home-template/docs/base-harness/skills.md +1 -1
  7. package/package.json +5 -4
  8. package/skills/create-plugin/CHANGELOG.md +7 -0
  9. package/skills/create-plugin/SKILL.md +10 -6
  10. package/src/agents/base-agent/system_prompts/0-base_prompt.md +2 -0
  11. package/src/agents/base-agent/workspace/router.ts +47 -0
  12. package/src/agents/base-agent/workspace/workflows/README.md +71 -0
  13. package/src/api/admin.ts +1 -1
  14. package/src/cli/agent.ts +1 -2
  15. package/src/core/agent-manager.ts +17 -9
  16. package/src/core/queue.ts +19 -6
  17. package/src/core/router.ts +258 -0
  18. package/src/core/runner.ts +273 -66
  19. package/src/core/types.ts +2 -14
  20. package/src/plugins/admin/index.ts +2 -2
  21. package/src/plugins/agent-messaging/index.ts +4 -3
  22. package/src/plugins/gws/index.ts +8 -120
  23. package/src/plugins/gws/seed/system_prompts/plugin-gws.md +8 -4
  24. package/src/plugins/scheduler/index.ts +4 -4
  25. package/src/plugins/scheduler/seed/system_prompts/plugin-scheduler.md +1 -1
  26. package/src/plugins/telegram/index.ts +4 -98
  27. package/src/plugins/telegram/seed/system_prompts/plugin-telegram.md +4 -6
  28. package/src/plugins/gws/seed/scripts/gws/routes +0 -117
  29. package/src/plugins/gws/seed/skills/gws/route-email/CHANGELOG.md +0 -14
  30. package/src/plugins/gws/seed/skills/gws/route-email/SKILL.md +0 -84
  31. package/src/plugins/telegram/seed/scripts/telegram/routes +0 -95
  32. package/src/plugins/telegram/seed/skills/telegram/route-chats/CHANGELOG.md +0 -7
  33. package/src/plugins/telegram/seed/skills/telegram/route-chats/SKILL.md +0 -63
package/CHANGELOG.md CHANGED
@@ -18,6 +18,110 @@ the harness directory, and applies it after user approval. See
18
18
  The format is based on [Keep a Changelog](https://keepachangelog.com/) and this
19
19
  project adheres to [Semantic Versioning](https://semver.org/).
20
20
 
21
+ ## [0.15.0]
22
+
23
+ ### Breaking changes
24
+
25
+ - **The agent's router is the only routing authority.** `agent.json`'s
26
+ `threadIdStrategy`, plugins' `threadIdOverride` and the Telegram/GWS
27
+ `routes.json` rules are gone. Every event goes through
28
+ `workspace/router.ts`, which returns thread id(s); without a rule an event
29
+ goes to its `metadata.threadId` (agent-messaging, scheduler, console) or to
30
+ `main`. To keep each existing agent's conversations on the threads they
31
+ use today, write its `workspace/router.ts` **before restarting the server**
32
+ (a first start seeds the starter router; replace it if it is still the
33
+ unmodified starter). The router must reproduce, in this order:
34
+ 1. `msg.metadata.threadId` if it is a non-empty string → return it.
35
+ 2. Telegram (`msg.pluginId === "telegram"`): each rule of
36
+ `agents/<a>/plugins/telegram/state/routes.json` (`{threadId, chat}`, first
37
+ match wins; `chat` is matched as `new RegExp("^(?:" + chat + ")$", "i")`
38
+ against `msg.channelId`) → return `clean(rule.threadId, "default")`.
39
+ Unmatched messages fall through to step 4.
40
+ 3. GWS email (`msg.pluginId === "gws"` and `msg.notification` is
41
+ `email_received` or `email_silent`): each rule of
42
+ `agents/<a>/plugins/gws/state/routes.json` (`{threadId, from?, subject?,
43
+ gmailThreadId?}`, first match wins, every present pattern must match;
44
+ `from` and `subject` are `new RegExp(p, "i")` against `msg.metadata.From`
45
+ and `msg.metadata.Subject`, `gmailThreadId` is
46
+ `new RegExp("^(?:" + p + ")$", "i")` against `msg.channelId`) → return
47
+ `clean(rule.threadId, "(no subject)")`. Otherwise return the old default
48
+ `` `${clean(String(msg.metadata.Subject), "(no subject)")}[${msg.channelId}]` ``.
49
+ (`from` used to match the Gmail thread's latest sender; it now matches
50
+ each message's own `From`, which differs only in backlog mode.)
51
+ Both use the plugins' old sanitizer:
52
+ `const clean = (s, empty) => s.replace(/[/\\\0]+/g, "_").slice(0, 120).trim() || empty;`.
53
+ 4. The agent's old `threadIdStrategy`: `single` → `"default"`, `plugin` →
54
+ `msg.pluginId`, `plugin_channel` → `` `${msg.pluginId}:${msg.channelId}` ``.
55
+ Then delete `threadIdStrategy` from `agent.json`, the two `routes.json`
56
+ files, and the stale seeded copies `scripts/telegram/routes`,
57
+ `skills/telegram/route-chats/`, `scripts/gws/routes` and
58
+ `skills/gws/route-email/` (seeds are copied on start but never removed).
59
+ An old thread id that starts with `.` or is longer than 256 characters is
60
+ now rejected (the event goes to `main`); rename such a thread in the
61
+ router. Until an agent's router is migrated, every Telegram chat and email
62
+ shares `main`.
63
+ [affects: agents/*/workspace/router.ts, agents/*/workspace/workflows/, agents/*/agent.json, agents/*/plugins/telegram/state/routes.json, agents/*/plugins/gws/state/routes.json, agents/*/scripts/telegram/routes, agents/*/skills/telegram/route-chats/, agents/*/scripts/gws/routes, agents/*/skills/gws/route-email/]
64
+
65
+ - **Plugin contract: no `threadIdOverride`, no `ctx.resetThread`.** A
66
+ deployment plugin that still passes `threadIdOverride` is silently ignored
67
+ (its events go to `main`); pass the thread as `metadata.threadId` instead,
68
+ or leave routing to the agent's router. A call to `ctx.resetThread` now
69
+ throws; remove it (delete the thread from the console or the
70
+ `DELETE /api/agents/<agent>/sessions/<threadId>` route).
71
+ [affects: plugins/*/index.ts]
72
+
73
+ - **Telegram, GWS and scheduler plugin prompts** now point at the router
74
+ instead of `routes.json` / `/reset`. Plugin-owned prompts are reseeded on
75
+ every agent start, so no edit is needed; listed so the change is visible.
76
+ [affects: agents/*/system_prompts/plugin-telegram.md, agents/*/system_prompts/plugin-gws.md, agents/*/system_prompts/plugin-scheduler.md]
77
+
78
+ - **Base prompt gains a Routing paragraph** (the router and workflows).
79
+ [affects: agents/*/system_prompts/0-base_prompt.md]
80
+
81
+ ### Added
82
+
83
+ - **Workflows.** A folder `workspace/workflows/<name>/` (`workflow.json` with
84
+ a required `description` and `script`, plus the executable script) is the
85
+ thread `workflow:<name>`: the router sends events there, they are queued
86
+ like any thread's, and a worker runs the script once per event (message
87
+ JSON on stdin; exit 0 = done; any failure, a 10-minute timeout or an
88
+ interruption marks the event failed with **no retry**). A script invokes
89
+ the agent with `scripts/agent-msg/send`, and the agent's reply to
90
+ `workflow:<name>` runs it again. Scripts should catch their errors and send
91
+ them to the agent's `main` thread so it can babysit the workflow; the
92
+ harness itself reports only runs it killed (timeout, stop, crash) with a
93
+ `workflow_killed` notice on `main`. Router and workflow edits apply within a few seconds,
94
+ without a restart. New and existing agents get the starter router and
95
+ `workspace/workflows/README.md` (written only if missing).
96
+
97
+ ### Changed
98
+
99
+ - Telegram no longer handles `/reset`; reset a conversation by deleting its
100
+ thread in the console.
101
+ - GWS notifications add `Subject` (the Gmail thread's first subject) to their
102
+ metadata.
103
+ - Thread ids are checked before a row is saved (no `/`, `\`, NUL or leading
104
+ `.`, at most 256 characters). An invalid id from the router is logged and
105
+ the event goes to its `metadata.threadId` or `main`; an invalid
106
+ `metadata.threadId` is replaced by `main`.
107
+ - The `create-plugin` skill (1.4.0) describes the router contract
108
+ (`.claude/skills/`, refreshed on upgrade).
109
+ - `docs/base-harness/` (README, skills) documents the router and workflows
110
+ and drops `threadIdStrategy`, `routes.json` and `/reset` (refreshed on
111
+ upgrade).
112
+ - The console's agent settings no longer show `threadIdStrategy`.
113
+
114
+ ## [0.14.0]
115
+
116
+ ### Changed
117
+
118
+ - **Pi upgraded to 1.0.0** (`@earendil-works/pi-ai` and
119
+ `@earendil-works/pi-coding-agent`, pinned exactly; from 0.99.2). RPC mode,
120
+ the extension API and the session format are unchanged, and every curated
121
+ model ID still resolves. The Models page's Anthropic sign-in now asks for
122
+ browser or copy-code login; copy-code works when the browser is on another
123
+ machine.
124
+
21
125
  ## [0.13.0]
22
126
 
23
127
  ### Breaking changes
@@ -1,4 +1,4 @@
1
- import{j as h}from"./radix-DHW5y7jr.js";import{r as G}from"./react-BIlrhC09.js";import{c as mt,L as kO,E as y,a as BO,C as ie,s as F,t as l,b as M,i as ft,d as ht,e as St,f as yO,g as QO,h as La,j as uO,k as $O,l as J,m as ne,n as T,o as se,p as q,q as U,r as gt,N as le,I as oe,P as Aa,u as xO,v as I,T as Ma,w as Pt,x as L,y as Xt,z as Ia,A as Na,B as Ba,D as Da,F as rO,G as Fa,H as Ja,J as Ha,K as Ka,M as Or,O as Ze,Q as er,R as tr,S as ar,U as rr,V as ir,W as nr,X as sr,Y as lr,Z as or,_ as Te,$ as Qr,a0 as ke,a1 as dr,a2 as cr,a3 as pr,a4 as ur,a5 as $r,a6 as ye,a7 as xe,a8 as mr,a9 as fr,aa as hr,ab as Sr}from"./index-CDE-jsH8.js";import"./markdown-sumxz7Eq.js";/**
1
+ import{j as h}from"./radix-DHW5y7jr.js";import{r as G}from"./react-BIlrhC09.js";import{c as mt,L as kO,E as y,a as BO,C as ie,s as F,t as l,b as M,i as ft,d as ht,e as St,f as yO,g as QO,h as La,j as uO,k as $O,l as J,m as ne,n as T,o as se,p as q,q as U,r as gt,N as le,I as oe,P as Aa,u as xO,v as I,T as Ma,w as Pt,x as L,y as Xt,z as Ia,A as Na,B as Ba,D as Da,F as rO,G as Fa,H as Ja,J as Ha,K as Ka,M as Or,O as Ze,Q as er,R as tr,S as ar,U as rr,V as ir,W as nr,X as sr,Y as lr,Z as or,_ as Te,$ as Qr,a0 as ke,a1 as dr,a2 as cr,a3 as pr,a4 as ur,a5 as $r,a6 as ye,a7 as xe,a8 as mr,a9 as fr,aa as hr,ab as Sr}from"./index-C2uTXv8R.js";import"./markdown-sumxz7Eq.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.