@liy/mote-pi-runtime 0.3.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 - 2026-09-16
4
+
5
+ Split from `@liy/mote-sandbox-runtime` by process lifetime (ADR-084).
6
+
7
+ - Carries everything an agent loads per run: the Pi RPC bridge, the extensions,
8
+ the universal skills, and the agent-facing `orchestrator` CLI. Updating this
9
+ package restarts nothing; a new version reaches the next agent launch.
10
+ - Pins Pi, `pi-mcp-adapter`, `pi-web-access` and the component catalog CLI as
11
+ ordinary exact dependencies rather than peers, because this package is the
12
+ host that starts Pi.
13
+ - Compiles all five Pi extensions at publish time, so no compiler reaches a
14
+ Sprite and Pi's loader does not transpile them.
15
+ - Installs into a version-stamped directory published through an atomically
16
+ renamed `current` symlink, with stable `extensions` and `skills` names.
17
+
18
+ ## Unreleased
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # @liy/mote-pi-runtime
2
+
3
+ Everything a Mote agent loads inside its own process: the Pi RPC bridge, the
4
+ precompiled Pi extensions, the universal Agent Skills, and the agent-facing
5
+ `orchestrator` CLI.
6
+
7
+ | Binary | Role |
8
+ | --- | --- |
9
+ | `mote-pi-rpc` | Per-run Pi process the orchestrator spawns for each launch |
10
+ | `orchestrator` | CLI agents invoke to call back into the orchestrator |
11
+
12
+ ## Why this package exists on its own
13
+
14
+ ADR-084 tiers the sandbox by what loads an artifact. Nothing resident loads this
15
+ package: Pi runs as a spawned, detached child. **A new version therefore takes
16
+ effect at the next agent launch and needs no service restart.** Publishing a
17
+ skill, a persona, an extension fix, or a new Pi release costs no downtime.
18
+
19
+ ## Dependencies
20
+
21
+ Pi, its MCP adapter, `pi-web-access` and the component catalog CLI are ordinary
22
+ dependencies pinned to exact versions. They are not peers: this package is the
23
+ host that starts Pi, so nothing above it supplies an instance. Conflict
24
+ detection is unaffected, because the adapter still declares its own peer range
25
+ and npm still fails on an incompatible pair.
26
+
27
+ ## Precompiled extensions
28
+
29
+ `scripts/compile-extensions.mjs` bundles all five extensions at publish time
30
+ into `dist/extensions`, so no compiler reaches a Sprite and Pi's loader never
31
+ transpiles them. Pi's SDK and installed JavaScript dependencies stay external,
32
+ preserving SDK identity and native assets.
33
+
34
+ The two third-party extensions locate their own worker, keyring helper and UI
35
+ assets relative to their installed package. A banner resolves that directory on
36
+ load rather than baking it in, because the install path is not known at publish
37
+ time. It resolves the **real** path first: agent profiles reach this tree
38
+ through a symlinked `extensions` directory and Pi's loader keeps that symlinked
39
+ path, so walking up from `import.meta.url` alone would escape the package.
40
+
41
+ ## Installed layout
42
+
43
+ ```
44
+ /opt/mote/pi-runtime/<version>/ complete npm install root
45
+ /opt/mote/pi-runtime/<version>/extensions -> the compiled extension tree
46
+ /opt/mote/pi-runtime/<version>/skills -> the shipped Agent Skills
47
+ /opt/mote/pi-runtime/current -> <version>
48
+ ```
49
+
50
+ Agent profiles link to the stable `current` names, so a version swap needs no
51
+ profile rewrite. The orchestrator resolves `current` when it spawns, not at
52
+ boot, which is what lets an update land without restarting anything.
53
+
54
+ ## Contract
55
+
56
+ `mote.contract` in the manifest pairs this package with the services that drive
57
+ it. The orchestrator refuses to spawn against a contract it does not support,
58
+ which is the only guard against a version pairing nobody tested.
59
+
60
+ ## Release
61
+
62
+ `pnpm release:pi-runtime:check` packs a dry run. Publication is manual dispatch
63
+ only, through npm trusted publishing.
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: agent-browser
3
+ description: Use the installed agent-browser CLI for browser interaction and validation.
4
+ ---
5
+
6
+ # Agent Browser
7
+
8
+ Load the version-matched workflow before using the browser CLI:
9
+
10
+ ```bash
11
+ agent-browser skills get core
12
+ ```
13
+
14
+ Use `agent-browser skills get core --full` when the task needs its complete
15
+ command reference and templates.
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: gen-app
3
+ description: Build, modify, validate, and integrate static React SPAs in Mote. Discover supported components with component-catalog; use inline-widget for timeline visualizations.
4
+ ---
5
+
6
+ # Gen App
7
+
8
+ Write explanations and user-facing labels in the user’s language; preserve component names, prop keys, and CLI syntax.
9
+
10
+ ## Discover components
11
+
12
+ ```bash
13
+ component-catalog list
14
+ component-catalog describe Table
15
+ ```
16
+
17
+ Describe each selected component before authoring. The command returns its props,
18
+ constraints, example, and guide path for this release. Read the referenced guide.
19
+ Use the available components; report missing capabilities rather than adding
20
+ local component definitions.
21
+
22
+ ## Build the app
23
+
24
+ Read the ticket and inspect the app repository. Require
25
+ `MOTE_AGENTIC_COMPONENT_CATALOG_PACKAGE`; if absent, report the missing requirement
26
+ and finish without changing application files. Install the selected package:
27
+
28
+ ```bash
29
+ npm install --save-exact "$MOTE_AGENTIC_COMPONENT_CATALOG_PACKAGE" \
30
+ react@19.2.7 react-dom@19.2.7 scheduler@0.27.0
31
+ ```
32
+
33
+ Use a Vite React TypeScript SPA with `base: "./"` and output in `dist/`. Keep browser
34
+ dependencies bundled. Compose a json-render `Spec`, validate with
35
+ `assertComponentSpec`, and render with `ComponentRenderer`. Import the catalog
36
+ stylesheet, supply prepared datasets, and set `visible: true` on unconditional
37
+ elements. The installed app dependency must match the catalog release used for
38
+ discovery.
39
+
40
+ ## Registered queries
41
+
42
+ Every app declares `mote.queries.json` at the repository root, outside `dist/`;
43
+ use `{ "queries": [] }` when no data is needed. Each query declares `key`, `sql`,
44
+ positional `parameters` (`name`, `type`, `nullable`), and `maxRows` (at most 2000).
45
+ Use Analytics Datasets and `$1`, `$2`, etc.; test with `query_analytics_sql`.
46
+ Never import SQL or the manifest into browser code.
47
+
48
+ Wrap the app in `GenAppQueryProvider`, call `useGenAppQuery(key, parameters)`,
49
+ and keep `GenAppQueryStatus` beside each data view. Adapt ready rows into prepared
50
+ datasets; retain denial, empty, scope, and truncation feedback. Registration
51
+ supplies output column contracts. The host supplies bundle/mode bootstrap;
52
+ app code must not select another bundle or widen public scope.
53
+
54
+ ## Validate and integrate
55
+
56
+ Authors typecheck and build their ticket worktree, verify `dist/index.html`,
57
+ commit the complete app, and run `orchestrator workspace check <ticket-id>`.
58
+ Include validation results and evidence references in the required
59
+ `orchestrator ticket handoff`; raw tool evidence is retained automatically.
60
+
61
+ Gatekeepers merge canonical `main` into their ticket worktree, review the result
62
+ against the ticket, and use the browser when it materially validates requirements.
63
+ Then run `orchestrator integration <ticket-id>`. It builds the clean committed
64
+ head, verifies artifacts, uploads and registers an immutable bundle, fast-forwards
65
+ `main`, and conditionally advances preview. Do not run another build in the
66
+ canonical repository.
67
+
68
+ Report the integrated commit and returned `bundleVersionId`, and open the preview
69
+ handoff. Publication is a separate administrator review under selected datasets
70
+ and Farms. Retry failed integration with the same command; the orchestrator
71
+ reconciles the retained upload. Do not rebuild or copy artifacts into the
72
+ canonical repository.
73
+
74
+ Artifacts are limited to 8 MiB and 512 regular files. Symlinks, hidden or escaping
75
+ paths, and source query manifests are rejected. Sandbox serving is for active
76
+ local development only.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: inline-widget
3
+ description: Compose or revise inline charts, tables, and cards in Mote timelines. Discover supported components with component-catalog; use gen-app for application source and deployment work.
4
+ ---
5
+
6
+ # Inline widget
7
+
8
+ Write explanations and user-facing labels in the user’s language; preserve component names, prop keys, and CLI syntax.
9
+
10
+ ## Discover components
11
+
12
+ ```bash
13
+ component-catalog list
14
+ component-catalog describe Table
15
+ ```
16
+
17
+ Describe each selected component before authoring. The command returns its props,
18
+ constraints, example, and guide path for this release. Read the referenced guide
19
+ and `submissionGuide` for the widget envelope and limits. Use the available
20
+ components; report missing capabilities rather than inventing a renderer.
21
+
22
+ ## Compose and submit
23
+
24
+ Acquire data through authorized MCP reads. Normalize decimal strings to numbers,
25
+ preserve nulls, and share prepared datasets across components. Use a tree with concrete props and `visible: true` for unconditional elements.
26
+ Local state, conditional visibility, and event bindings follow the shared catalog. Filter or aggregate upstream to fit
27
+ submission limits; disclose scope, truncation, and missing data in `summary`.
28
+
29
+ Call `mote_render_inline_widget` directly, or use one MCP proxy call that retains
30
+ the original result. Do not wrap submission in `mcpScript`, which can omit its
31
+ result. Correct validation errors using the returned details.
32
+
33
+ For an update, reuse `widget_id` and submit the complete replacement spec and
34
+ datasets. Local controls do not fetch more records; new data requires another
35
+ authorized read. Domain writes use the proposal workflow.
36
+
37
+ After success, explain the takeaway without repeating JSON or all rows.
38
+ No ticket, app scaffold, or deployment is needed.
@@ -0,0 +1,160 @@
1
+ ---
2
+ name: orchestrator
3
+ description: Use the sandbox-local orchestrator CLI to work the ticket board and app workspaces; create apps and maintain shared briefs, integrate and clean worktrees, transition tickets, read native timelines, and read the agent roster.
4
+ ---
5
+
6
+ # Orchestrator CLI
7
+
8
+ The `orchestrator` command is the only way to read or change the work board.
9
+ Never invent ticket IDs, statuses, or results; the CLI response is the source
10
+ of truth. Treat output as JSON: continue only when `ok` is `true`, otherwise
11
+ report `error.message`.
12
+
13
+ The sandbox derives your authoritative identity from the operating-system
14
+ process connected to the orchestrator Unix socket. `AGENT_ID` and, for Drone
15
+ work, `MOTE_TICKET_ID` describe runtime context only; they are not credentials.
16
+ The agent receives no Mote access token. Never add identity, Org, delegation,
17
+ authorization, destination URL, upstream-origin, or credential fields to a
18
+ request: the command channel rejects those claims and selects authority from
19
+ kernel identity.
20
+
21
+ ## Current task context
22
+
23
+ Start with `ticket brief` for the ticket named by `MOTE_TICKET_ID`, including in a
24
+ conversation attached to that ticket. It includes ticket state and worklog context.
25
+ Use `ticket get` for general ticket information; it does not return timeline records.
26
+ For `MOTE_APP_ID`, read the shared brief with `app get`. Infer the assignment
27
+ from the current ticket and handoff, never from the agent's persona or role.
28
+ Use the `gen-app` skill for app changes or integration, and `agent-browser`
29
+ when browser interaction materially validates the requirements.
30
+
31
+ Track executable work in tickets. Direct answers, brief edits, inline widgets
32
+ and immediate action proposals need no ticket. After initiating work in a
33
+ conversation, finish the turn; the scheduler handles subsequent assessment.
34
+
35
+ ## Protected MCP
36
+
37
+ Use the Pi `mcp` or `mcpScript` tool for the Mote MCP tools. The installed
38
+ `pi-mcp-adapter` runs `orchestrator mcp mote` internally as its configured stdio
39
+ transport. Do not invoke that command through Bash or construct JSON-RPC
40
+ payloads yourself.
41
+
42
+ ## Commands
43
+
44
+ ```bash
45
+ orchestrator app create <app-code> "<name>" "<shared brief>"
46
+ orchestrator app get <app-id>
47
+ orchestrator app update <app-id> "<shared brief>" # Overmind only; code is immutable
48
+ orchestrator ticket list --status <waiting|ongoing|intervention|done> [--unassigned]
49
+ orchestrator ticket get <ticket-id> # general ticket information
50
+ orchestrator ticket create '{"title":"...","summary":"...","description":"...","scope":["code"],"appId":"..."}' # appId optional; omit for standalone work
51
+ orchestrator ticket assign '{"ticketId":"...","assigneeAgentId":"..."}' # Overmind only; optional summary adds context
52
+ orchestrator ticket park '{"ticketId":"...","summary":"<required human action or blocker>"}' # Overmind only; waiting tickets only
53
+ orchestrator ticket unpark '{"ticketId":"...","summary":"<why it can proceed>"}' # Overmind only
54
+ orchestrator ticket done '{"ticketId":"...","summary":"<acceptance>"}' # Overmind only
55
+ orchestrator ticket archive <ticket-id> # Overmind only; aborts its active Drone and waits for termination
56
+ orchestrator ticket unarchive <ticket-id> # Overmind only; restores its prior board state
57
+ orchestrator ticket brief <ticket-id> [--after <cursor>] [--through <highWaterMark>]
58
+ orchestrator ticket worklog <ticket-id> [--after <cursor>] [--through <highWaterMark>]
59
+ orchestrator ticket decision <ticket-id> '{"choice":"...","rationale":"..."}'
60
+ orchestrator ticket handoff <ticket-id> '{"results":"...","validation":"...","remainingWork":"...","references":["<event ID, commit or durable artifact>"]}'
61
+ orchestrator ticket guide <ticket-id> '{"message":"..."}' # Overmind only; passive advice
62
+ orchestrator ticket timeline <ticket-id> [--after <cursor>] [--through <highWaterMark>]
63
+ orchestrator workspace check <ticket-id>
64
+ orchestrator integration <ticket-id> # assigned gatekeeper drone only
65
+ orchestrator workspace cleanup <ticket-id> # Overmind only; ticket must be done
66
+ orchestrator agent list | agent get <name> | agent prompt <name>
67
+ ```
68
+
69
+ Ticket status is lifecycle-derived: the orchestrator moves an assigned
70
+ ticket to `ongoing` when its Drone run starts and back to `waiting` when the
71
+ run ends. Agents never start, accept, yield, or release tickets. Before ending
72
+ each assignment, write one `ticket handoff`, including unfinished work and any
73
+ failed or unperformed checks. A normal final response does not replace it.
74
+ The orchestrator gives at most one handoff-only reminder, bounded to 60 seconds;
75
+ if still absent, the terminal outcome records it explicitly. A handoff does not
76
+ mark the ticket complete. Pi already records routine messages and tool results.
77
+
78
+ Read `ticket brief` first: it returns current ticket state, the latest handoff
79
+ (or null), and a bounded `notes` page of decisions and guides. Inspect the
80
+ handoff's execution ID: it may describe an earlier assignment. `ticket worklog`
81
+ returns only decisions, handoffs and guides, preserving canonical IDs, sequences,
82
+ authors and execution IDs. To continue a notes/worklog page, pass its `cursor`
83
+ as `--after` and retain its `highWaterMark` as `--through`. Use `ticket timeline`
84
+ sparingly: it returns raw timeline records, including messages and tool results.
85
+ Read targeted pages only when ticket information and worklogs leave an evidence
86
+ gap; event sequence N is after cursor N-1. Do not scan the full timeline by default.
87
+
88
+ Use `ticket decision` optionally for a consequential choice and its rationale.
89
+ Use `ticket guide` for passive Overmind advice: it records context without waking
90
+ or steering Pi, changing the assignment, or requiring immediate agreement.
91
+ Only the assigned Drone writes its handoff; an Overmind may write decisions
92
+ and guides. Keep records concise. Maximum field lengths: choice/validation/
93
+ remainingWork 1024 characters, rationale/results/message 2048. References are
94
+ optional (up to 8, 512 characters each); use durable pointers, not copied logs.
95
+ For a transport retry, preserve the command ID with `--command-id <uuid>`. An accepted
96
+ handoff is immutable for that execution; additional corrections can be decisions.
97
+
98
+ Transition verbs still require a short `summary` explaining the decision.
99
+ Assignment changes retain the old and new assignee as host-authoritative facts.
100
+ Do not pass channel or identity fields; the orchestrator supplies provenance.
101
+
102
+ Tickets are independent work items, with no typed links or parent chain.
103
+ In an assessment session, `ticket create` requires `contextTicketId` naming a
104
+ ticket in your authorized set. This is used once to copy its source conversation
105
+ and is not stored as a relationship. Drone creation uses its current ticket;
106
+ conversation creation uses the current channel. Newly created tickets enter the
107
+ launch's authorized set so they can be read and assigned in the same turn.
108
+
109
+ ## App workspace flow
110
+
111
+ App association is optional and fixed at ticket creation. For generated-app
112
+ work, create or reuse the app first and pass `appId` to `ticket create`.
113
+ Use `app get` to read its shared brief, and `app update` to maintain the goal,
114
+ constraints and acceptance criteria. Do not create a coordination-only ticket.
115
+ Standalone work runs in the assigned agent's ticket session directory and
116
+ requires no app, repository or integration. Its timeline preserves handoffs
117
+ between agents; their scratch directories are separate.
118
+
119
+ The orchestrator derives all Git mechanics; agents do not invent paths or
120
+ branches:
121
+
122
+ ```text
123
+ repository: /workspace/<appId>
124
+ worktree: /worktree/<appId>/<ticketId>
125
+ branch: ticket/<ticketId>
126
+ ```
127
+
128
+ Every app ticket runs in its worktree. The author commits, writes its ticket
129
+ handoff, and finishes without integrating; the orchestrator returns
130
+ the ticket to the queue. Overmind assigns a different Drone as gatekeeper.
131
+ The gatekeeper merges the latest `main` into the ticket branch, reviews and
132
+ tests that combined state, then runs `orchestrator integration <ticket-id>`.
133
+ Authors can run `orchestrator workspace check <ticket-id>` before handoff.
134
+ The command updates canonical `main` with `git merge --ff-only`; a concurrent
135
+ integration makes it fail stale and the gatekeeper must repeat the merge and
136
+ checks. Overmind marks the ticket done only after integration evidence is
137
+ present. Cleanup removes only clean, merged worktrees and branches and never
138
+ forces deletion.
139
+
140
+ ## Board model
141
+
142
+ - `waiting` is the judgment queue: every finished Drone run lands its ticket
143
+ back here, unassigned, for Overmind to resolve — assign (re-assigning the
144
+ same agent resumes its session), park, or done. Overmind must resolve
145
+ every unassigned `waiting` ticket; the native timeline records
146
+ how the last run ended and the Gen App build result. Dispatch is
147
+ automatic: the orchestrator spawns the ticket owner's Overmind for a
148
+ board assessment shortly after judgment work appears. Do not poll.
149
+ - `waiting` + assigned = the orchestrator will spawn that drone and move the
150
+ ticket to `ongoing` itself. Do not poll.
151
+ - `ongoing` mirrors a live Drone run exactly; it always drains back to
152
+ `waiting` when the run ends, whatever the outcome.
153
+ - `intervention` = parked for a human or a blocker; nothing runs. Only
154
+ `waiting` tickets park (Overmind judgment, or the scheduler at a
155
+ repeated-failure cap).
156
+ - `done` is terminal and only Overmind sets it.
157
+ - Archived tickets retain their workflow state but are absent from all four
158
+ board queues. Archiving first aborts any active Drone for that ticket and
159
+ waits for terminal execution state; unarchiving restores the ticket to the
160
+ queue for its retained state.