@zihanw/pi-forge 0.5.4 → 0.5.6
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 +83 -0
- package/README.md +67 -103
- package/README.zh-CN.md +67 -95
- package/assets/pi-forge-header-concept-1.png +0 -0
- package/assets/readme/PROVENANCE.md +95 -0
- package/assets/readme/en/capability-tools.gif +0 -0
- package/assets/readme/en/context-composition.gif +0 -0
- package/assets/readme/en/context-toggle.gif +0 -0
- package/assets/readme/en/draft-diff.png +0 -0
- package/assets/readme/en/edit-draft-diff.gif +0 -0
- package/assets/readme/en/editor-overview-v3.png +0 -0
- package/assets/readme/en/editor-overview.png +0 -0
- package/assets/readme/en/mode-tools.gif +0 -0
- package/assets/readme/en/regex-transforms.gif +0 -0
- package/assets/readme/en/tool-selection.gif +0 -0
- package/assets/readme/tui-quickstart.gif +0 -0
- package/assets/readme/zh-CN/capability-tools.gif +0 -0
- package/assets/readme/zh-CN/context-composition.gif +0 -0
- package/assets/readme/zh-CN/context-toggle.gif +0 -0
- package/assets/readme/zh-CN/draft-diff.png +0 -0
- package/assets/readme/zh-CN/edit-draft-diff.gif +0 -0
- package/assets/readme/zh-CN/editor-overview-v3.png +0 -0
- package/assets/readme/zh-CN/editor-overview.png +0 -0
- package/assets/readme/zh-CN/mode-tools.gif +0 -0
- package/assets/readme/zh-CN/regex-transforms.gif +0 -0
- package/assets/readme/zh-CN/tool-selection.gif +0 -0
- package/dist/active-state.d.ts +148 -0
- package/dist/active-state.d.ts.map +1 -0
- package/dist/active-state.js +374 -0
- package/dist/active-state.js.map +1 -0
- package/dist/agent-profile.d.ts +1 -0
- package/dist/agent-profile.d.ts.map +1 -1
- package/dist/agent-profile.js +20 -14
- package/dist/agent-profile.js.map +1 -1
- package/dist/capabilities.d.ts +39 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +160 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/capability-anchors.d.ts +45 -0
- package/dist/capability-anchors.d.ts.map +1 -0
- package/dist/capability-anchors.js +263 -0
- package/dist/capability-anchors.js.map +1 -0
- package/dist/capability-command.d.ts +4 -0
- package/dist/capability-command.d.ts.map +1 -0
- package/dist/capability-command.js +164 -0
- package/dist/capability-command.js.map +1 -0
- package/dist/capability-events.d.ts +79 -0
- package/dist/capability-events.d.ts.map +1 -0
- package/dist/capability-events.js +478 -0
- package/dist/capability-events.js.map +1 -0
- package/dist/capability-projection.d.ts +22 -0
- package/dist/capability-projection.d.ts.map +1 -0
- package/dist/capability-projection.js +273 -0
- package/dist/capability-projection.js.map +1 -0
- package/dist/capability-protocol.d.ts +21 -0
- package/dist/capability-protocol.d.ts.map +1 -0
- package/dist/capability-protocol.js +15 -0
- package/dist/capability-protocol.js.map +1 -0
- package/dist/capability-state.d.ts +74 -0
- package/dist/capability-state.d.ts.map +1 -0
- package/dist/capability-state.js +43 -0
- package/dist/capability-state.js.map +1 -0
- package/dist/capability-tool.d.ts +11 -0
- package/dist/capability-tool.d.ts.map +1 -0
- package/dist/capability-tool.js +25 -0
- package/dist/capability-tool.js.map +1 -0
- package/dist/capability-web-host.d.ts +11 -0
- package/dist/capability-web-host.d.ts.map +1 -0
- package/dist/capability-web-host.js +105 -0
- package/dist/capability-web-host.js.map +1 -0
- package/dist/codecs/capability.d.ts +71 -0
- package/dist/codecs/capability.d.ts.map +1 -0
- package/dist/codecs/capability.js +363 -0
- package/dist/codecs/capability.js.map +1 -0
- package/dist/codecs/prompt-stack.d.ts +1 -1
- package/dist/codecs/prompt-stack.d.ts.map +1 -1
- package/dist/codecs/prompt-stack.js +140 -13
- package/dist/codecs/prompt-stack.js.map +1 -1
- package/dist/command-contribution/index.d.ts +21 -0
- package/dist/command-contribution/index.d.ts.map +1 -0
- package/dist/command-contribution/index.js +14 -0
- package/dist/command-contribution/index.js.map +1 -0
- package/dist/compile-cycle.d.ts +1 -0
- package/dist/compile-cycle.d.ts.map +1 -1
- package/dist/compile-cycle.js.map +1 -1
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +81 -17
- package/dist/compiler.js.map +1 -1
- package/dist/forge-command.d.ts +10 -0
- package/dist/forge-command.d.ts.map +1 -0
- package/dist/forge-command.js +106 -0
- package/dist/forge-command.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -5
- package/dist/index.js.map +1 -1
- package/dist/json-fingerprint.d.ts +11 -0
- package/dist/json-fingerprint.d.ts.map +1 -0
- package/dist/json-fingerprint.js +66 -0
- package/dist/json-fingerprint.js.map +1 -0
- package/dist/lifecycle.d.ts +14 -0
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +167 -67
- package/dist/lifecycle.js.map +1 -1
- package/dist/payload-command.d.ts +2 -2
- package/dist/payload-command.d.ts.map +1 -1
- package/dist/payload-command.js +80 -26
- package/dist/payload-command.js.map +1 -1
- package/dist/payload-state.d.ts +1 -0
- package/dist/payload-state.d.ts.map +1 -1
- package/dist/payload-state.js +1 -0
- package/dist/payload-state.js.map +1 -1
- package/dist/policy.d.ts +2 -1
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +3 -0
- package/dist/policy.js.map +1 -1
- package/dist/preset-command.d.ts +1 -0
- package/dist/preset-command.d.ts.map +1 -1
- package/dist/preset-command.js +94 -36
- package/dist/preset-command.js.map +1 -1
- package/dist/preview-text.d.ts +5 -0
- package/dist/preview-text.d.ts.map +1 -0
- package/dist/preview-text.js +27 -0
- package/dist/preview-text.js.map +1 -0
- package/dist/preview.d.ts +18 -1
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +132 -97
- package/dist/preview.js.map +1 -1
- package/dist/profile-command.js +68 -9
- package/dist/profile-command.js.map +1 -1
- package/dist/regex.d.ts.map +1 -1
- package/dist/regex.js +5 -0
- package/dist/regex.js.map +1 -1
- package/dist/render-helpers.d.ts.map +1 -1
- package/dist/render-helpers.js +2 -0
- package/dist/render-helpers.js.map +1 -1
- package/dist/repositories/capability.d.ts +53 -0
- package/dist/repositories/capability.d.ts.map +1 -0
- package/dist/repositories/capability.js +294 -0
- package/dist/repositories/capability.js.map +1 -0
- package/dist/runtime/capability-runtime.d.ts +93 -0
- package/dist/runtime/capability-runtime.d.ts.map +1 -0
- package/dist/runtime/capability-runtime.js +987 -0
- package/dist/runtime/capability-runtime.js.map +1 -0
- package/dist/runtime/profile-runtime.d.ts.map +1 -1
- package/dist/runtime/profile-runtime.js +10 -9
- package/dist/runtime/profile-runtime.js.map +1 -1
- package/dist/runtime/prompt-stack-runtime.d.ts +7 -4
- package/dist/runtime/prompt-stack-runtime.d.ts.map +1 -1
- package/dist/runtime/prompt-stack-runtime.js +47 -11
- package/dist/runtime/prompt-stack-runtime.js.map +1 -1
- package/dist/runtime/tool-policy-runtime.d.ts +10 -0
- package/dist/runtime/tool-policy-runtime.d.ts.map +1 -1
- package/dist/runtime/tool-policy-runtime.js +171 -30
- package/dist/runtime/tool-policy-runtime.js.map +1 -1
- package/dist/session-adapter.d.ts +13 -0
- package/dist/session-adapter.d.ts.map +1 -1
- package/dist/session-adapter.js +110 -0
- package/dist/session-adapter.js.map +1 -1
- package/dist/session-usage.d.ts +65 -0
- package/dist/session-usage.d.ts.map +1 -0
- package/dist/session-usage.js +134 -0
- package/dist/session-usage.js.map +1 -0
- package/dist/subagent/fingerprints.d.ts +3 -15
- package/dist/subagent/fingerprints.d.ts.map +1 -1
- package/dist/subagent/fingerprints.js +5 -69
- package/dist/subagent/fingerprints.js.map +1 -1
- package/dist/subagent/index.d.ts +2 -0
- package/dist/subagent/index.d.ts.map +1 -1
- package/dist/subagent/index.js +2 -0
- package/dist/subagent/index.js.map +1 -1
- package/dist/subagent-host.d.ts +2 -2
- package/dist/subagent-host.d.ts.map +1 -1
- package/dist/subagent-host.js +13 -1
- package/dist/subagent-host.js.map +1 -1
- package/dist/types.d.ts +6 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/web-editor/client-script.generated.d.ts.map +1 -1
- package/dist/web-editor/client-script.generated.js +1 -1
- package/dist/web-editor/client-script.generated.js.map +1 -1
- package/dist/web-editor/client-styles.generated.d.ts.map +1 -1
- package/dist/web-editor/client-styles.generated.js +1 -1
- package/dist/web-editor/client-styles.generated.js.map +1 -1
- package/dist/web-editor/server.d.ts.map +1 -1
- package/dist/web-editor/server.js +152 -4
- package/dist/web-editor/server.js.map +1 -1
- package/dist/web-editor/styles.d.ts.map +1 -1
- package/dist/web-editor/styles.js +573 -165
- package/dist/web-editor/styles.js.map +1 -1
- package/dist/web-editor/types.d.ts +81 -1
- package/dist/web-editor/types.d.ts.map +1 -1
- package/dist/web-host.d.ts +9 -0
- package/dist/web-host.d.ts.map +1 -1
- package/dist/web-host.js +210 -11
- package/dist/web-host.js.map +1 -1
- package/dist/workspace.d.ts +11 -0
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +63 -5
- package/dist/workspace.js.map +1 -1
- package/docs/README.md +4 -0
- package/docs/design/README.md +3 -1
- package/docs/design/architecture-0.5.md +22 -0
- package/docs/design/archive/2026-09-12-system-update-design.md +229 -0
- package/docs/design/pi-forge-system-update-design-notes.md +157 -229
- package/docs/development/release.md +20 -20
- package/docs/development/roadmap.md +21 -2
- package/docs/development/scoped-global-profiles-stacks.md +1 -1
- package/docs/development/setup.md +1 -1
- package/docs/getting-started.md +1 -1
- package/docs/guides/delegation.md +22 -20
- package/docs/guides/migrating-to-0.5.md +29 -0
- package/docs/guides/use-cases.md +6 -2
- package/docs/guides/web-editor.md +74 -5
- package/docs/reference/active-state.md +77 -0
- package/docs/reference/capabilities.md +259 -0
- package/docs/reference/commands.md +52 -24
- package/docs/reference/configuration.md +4 -2
- package/docs/reference/features.md +70 -4
- package/docs/reference/provider-support.md +67 -0
- package/docs/reference/public-api.md +49 -3
- package/docs/reference/session-cache.md +112 -0
- package/docs/reference/stack-schema.md +18 -4
- package/docs/reference/subagent-host-port.md +8 -0
- package/docs/zh-CN/README.md +3 -0
- package/docs/zh-CN/getting-started.md +1 -1
- package/docs/zh-CN/guides/delegation.md +22 -10
- package/docs/zh-CN/guides/migrating-to-0.5.md +29 -0
- package/docs/zh-CN/guides/web-editor.md +75 -7
- package/docs/zh-CN/reference/capabilities.md +259 -0
- package/docs/zh-CN/reference/commands.md +61 -33
- package/docs/zh-CN/reference/provider-support.md +67 -0
- package/docs/zh-CN/reference/session-cache.md +112 -0
- package/examples/capabilities/review.json +12 -0
- package/examples/capabilities/write-tools.json +15 -0
- package/examples/read-first-worker-prompt-stack.json +49 -0
- package/package.json +16 -9
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# README media
|
|
2
|
+
|
|
3
|
+
## September 26 Capabilities rename
|
|
4
|
+
|
|
5
|
+
All ten currently embedded WebUI GIFs (five scenes in each language) were re-recorded from the renamed development source based on `9f3bbb4`. They now show Capabilities and Enable/Disable; `capability-tools.gif` replaces the README reference to `mode-tools.gif`. Historical files, including the old mode and TUI clips, are retained rather than silently relabelled.
|
|
6
|
+
|
|
7
|
+
Context, Draft diff and Capability recordings use the continuous recorder (1440×900, 15fps exports); Tools and Regex use their dedicated recorder (1200×750, 15fps exports). Both use native pointer actions and continuous X11 capture, with only the disclosed pointer halo. The Capability scene checks actual SDK tool selection `read → read,grep,find → read` and locates both the update and removal in projected context. All projects and sessions are disposable fixtures; no real provider inference, personal history, or cache-hit claim is involved. English/Chinese final keyframes were reviewed against the current UI. The legacy TUI clip was not re-recorded and remains unembedded.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run build
|
|
11
|
+
PI_FORGE_MEDIA_OUT_DIR=/tmp/forge-capability-media LOCALES=en,zh-CN SCENES=context,diff,capability node scripts/record-readme-continuous.ts
|
|
12
|
+
python3 scripts/export-readme-continuous.py /tmp/forge-capability-media
|
|
13
|
+
PI_FORGE_MEDIA_OUT_DIR=/tmp/forge-tools-regex node scripts/record-readme-tools-regex.ts
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Current output scene names are `context`, `diff`, and `capability`; copy reviewed outputs to `context-composition.gif`, `edit-draft-diff.gif`, and `capability-tools.gif` respectively. The sections below document earlier captures, not the current embedded footage.
|
|
17
|
+
|
|
18
|
+
## September 26 README refresh
|
|
19
|
+
|
|
20
|
+
The concept header `../pi-forge-header-concept-1.png` is restored unchanged. The duplicate overview screenshot is no longer embedded; old image files remain available. Installation precedes all demo GIFs.
|
|
21
|
+
|
|
22
|
+
Follow-up review: the TUI clip was removed from both READMEs because its command/status flow did not clearly communicate the benefit. The file and recorder are retained as historical material; the five WebUI feature GIFs remain in use. The personal motivation is now a short opening note, with a prominent optional-subagents link before installation.
|
|
23
|
+
|
|
24
|
+
Recordings produced for this refresh, based on source `6a197e6` plus the local unpublished-alias removal:
|
|
25
|
+
|
|
26
|
+
- `tui-quickstart.gif` (retained, not embedded in README): real Pi 0.87.1 TUI, 1000×540, about 12.75s. `/preset use project:read-first` → `/instruction use project:write-tools` → `/instruction status`. This uses synthetic read-first resources, not a verbatim copy of the checked-in example. Real Forge operations change selected tools from read/ls/control to also bash/edit. No model response is shown or implied.
|
|
27
|
+
- `<locale>/tool-selection.gif`: real Policy picker, defaults read/ls → read/ls/grep, Save/Activate, compiled Preview tool list. Permission ceiling already includes grep; this is a default-selection edit, not an authorization bypass. About 12.94s.
|
|
28
|
+
- `<locale>/regex-transforms.gif`: enable a preconfigured outgoing system-text rule, then inspect `SAMPLE_TOKEN` → `[REDACTED]` in Preview. About 8.07s. Only synthetic text is used; no general secret-detection guarantee.
|
|
29
|
+
|
|
30
|
+
Browser captures use the built product editor and production loopback host/compiler, with an inert command harness and synthetic tools (not a live model session). Native X11 pointer interactions are continuous; the blue halo is a recording aid. 1440×900 masters export to 1200×750/15fps GIFs. Semantic before/after assertions check Preview and tool selection; the browser is restricted to its own editor origin. Parent review confirmed no page errors or external browser requests in either locale, and decoded all five GIFs.
|
|
31
|
+
|
|
32
|
+
The TUI uses a separate temporary home/agent directory, isolated dark colors with brighter dim text, no session persistence, and a local `offline-demo` model definition with an inert placeholder key. That model is not a real provider. Pi runs offline; a Node preload blocks fetch/socket connections and asserts an empty network-attempt log. Keyframes were manually reviewed for actual command results and tool state; capture action logs are not automated OCR assertions. The terminal has no custom Forge UI or replaced output. Earlier captures showing missing-model warnings were discarded from the published asset and retained only in the local evidence report.
|
|
33
|
+
|
|
34
|
+
### Reproduce the new recordings
|
|
35
|
+
|
|
36
|
+
Requires the repository dev dependencies, Pi CLI, Google Chrome, Xvfb, xdotool, ffmpeg, ImageMagick `import`, GNOME Terminal and `dbus-run-session`. Private displays `:192` (browser) and `:196` (terminal) must be free. Recorders create disposable resources and clean up only their own processes. Outputs default to the review directory, not the checked-in images.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm run build
|
|
40
|
+
PI_FORGE_MEDIA_OUT_DIR=/tmp/forge-tools-regex node scripts/record-readme-tools-regex.ts
|
|
41
|
+
PI_FORGE_MEDIA_OUT_DIR=/tmp/forge-tui node scripts/record-readme-tui.ts
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Review `/tmp/forge-tools-regex/assets/{en,zh-CN}/` and `/tmp/forge-tui/assets/tui-quickstart.gif` before copying to `assets/readme/`. Masters, keyframes and evidence stay in each output directory. Fixture IDs, timing and hashes vary between runs. These clips prove local editing/management behavior, not provider delivery, model compliance, cache reuse, sandbox isolation or autonomous agent decisions.
|
|
45
|
+
|
|
46
|
+
## September 24 continuous v3
|
|
47
|
+
|
|
48
|
+
Captured 2026-09-24 EDT from accepted UI commit `89c6ba2` (development package metadata 0.5.4), using isolated synthetic projects, the built production loopback editor/compiler and, for Mode, a real SDK AgentSession with no remote model requests.
|
|
49
|
+
|
|
50
|
+
The September 24 capture produced these per-locale files:
|
|
51
|
+
- `editor-overview-v3.png` (retained, no longer in README): editor and compiled Preview (1439×899 browser viewport; the continuous videos/GIFs include the 1px X11 border at 1440×900).
|
|
52
|
+
- `context-composition.gif`: native drag reordering plus project-context toggle, about 14.6s.
|
|
53
|
+
- `mode-tools.gif`: Current session Use → locate → Off → locate removal, about 18.3s. Actual SDK tools `read → read,grep,find → read`; projected instructions/stop notices remain distinct from delivery or cache evidence.
|
|
54
|
+
- `edit-draft-diff.gif`: real keyboard edit followed by Draft diff without resizing, about 13–14s.
|
|
55
|
+
|
|
56
|
+
GIFs are 1440×900/15fps exports of continuous 30fps x11grab MP4, without time acceleration or stitched state screenshots. The native pointer drives the UI; the blue halo/click pulse is a disclosed recording aid, not a Forge feature. Native dragging's light drag image and actual compile loading states are retained. GIF palette conversion is lossy. Complete MP4/GIF decoding and real browser playback/seek were checked for both languages. No personal resources/credentials/history, model inference, provider/cache claims or user-host restart were involved.
|
|
57
|
+
|
|
58
|
+
## Reproduce September 24 recordings
|
|
59
|
+
|
|
60
|
+
Requires the checkout's development dependencies, Xvfb, xdotool, ffmpeg, Google Chrome and Python Pillow. Private display `:192` must be unused. The recorder refuses to use an occupied display, creates disposable fixtures and cleans its own processes/resources. Do not copy output over formal assets without reviewing it.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm run build
|
|
64
|
+
PI_FORGE_MEDIA_OUT_DIR=/tmp/forge-readme-v3 LOCALES=en,zh-CN SCENES=context,diff,capability node scripts/record-readme-continuous.ts
|
|
65
|
+
python3 scripts/export-readme-continuous.py /tmp/forge-readme-v3
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Output is `media/<locale>/{context,capability,diff}.{mp4,gif}`, proof images and semantic evidence; `manifest.json` records dimensions/durations/hashes. Copy approved GIFs to the corresponding names above and `context-poster.png` to `editor-overview-v3.png`. New recordings have fresh synthetic session IDs; pixel-identical reproduction is not promised.
|
|
69
|
+
|
|
70
|
+
## Retained legacy media (not referenced by current README)
|
|
71
|
+
|
|
72
|
+
Captured on 2026-09-23 from the built 0.5.5-development WebUI (package version still 0.5.4), using the production loopback editor server and compiler with an isolated, synthetic code-review project.
|
|
73
|
+
|
|
74
|
+
Each locale (`en`, `zh-CN`) has:
|
|
75
|
+
|
|
76
|
+
- `editor-overview.png`: 1440 × 900, selected instructions beside compiled Preview.
|
|
77
|
+
- `context-toggle.gif`: 1440 × 900, two real, settled UI states in a five-second loop. Clicking the project-context toggle removes/restores the owned example `AGENTS.md` paragraph. This is a sampled-state demonstration, not real-time footage or a latency measurement. No zoom, captions, or drawn/replaced UI.
|
|
78
|
+
- `draft-diff.png`: 1440 × 620, one instruction edit compared with the saved Preset. Token deltas are estimates, not provider usage.
|
|
79
|
+
|
|
80
|
+
No model requests, credentials, personal presets, real conversation history, or user-host restart were needed. `demo-session` and the project contents are examples; `/tmp/pi-forge-readme-*` is a disposable project. Runtime context-file input is supplied through the harness's public prompt-options boundary; no private SDK state is patched. Browser traffic is restricted to that editor origin. These images demonstrate editing/compilation, not provider delivery, model compliance or cache reuse.
|
|
81
|
+
|
|
82
|
+
## Reproduce from a repository checkout
|
|
83
|
+
|
|
84
|
+
Requires the repository's Node development dependencies, system Chrome (or `CHROME_PATH`) and Python with Pillow for GIF encoding. Outputs are local; this does not publish them.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm run build
|
|
88
|
+
PI_FORGE_MEDIA_OUT_DIR=/tmp/forge-readme-capture node scripts/record-readme-media.ts
|
|
89
|
+
# Inspect the captured PNGs before replacing the checked-in media.
|
|
90
|
+
python3 scripts/render-readme-media.py /tmp/forge-readme-capture assets/readme
|
|
91
|
+
npm run check:docs
|
|
92
|
+
npm run check:package
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The recorder owns its temporary project/global configuration directories and removes them after use. It never copies user auth files. GIFs use one shared palette and two 2.5-second holds; the encoder validates frame count, loop and dimensions.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neutral active-state snapshot/change bus for optional appearance/session
|
|
3
|
+
* consumers.
|
|
4
|
+
*
|
|
5
|
+
* This module is deliberately Pi Pet-agnostic: it publishes only the small,
|
|
6
|
+
* privacy-preserving scalar contract in the parent implementation contract
|
|
7
|
+
* (`@zihanw/pi-forge/active-state/v1`). It never carries prompt text, file
|
|
8
|
+
* paths, tokens, credentials, model configuration, tool policy, or character
|
|
9
|
+
* data. Consumers are optional and must not affect Forge compilation, tool
|
|
10
|
+
* policy, or provider behavior.
|
|
11
|
+
*/
|
|
12
|
+
export declare const FORGE_ACTIVE_STATE_SCHEMA_VERSION: "1";
|
|
13
|
+
export declare const FORGE_ACTIVE_STATE_CHANNEL = "@zihanw/pi-forge/active-state/v1";
|
|
14
|
+
export declare const FORGE_ACTIVE_STATE_REQUEST_CHANNEL = "@zihanw/pi-forge/active-state/request/v1";
|
|
15
|
+
/** Hash domain separator from the parent contract. Do not change without a new version. */
|
|
16
|
+
export declare const FORGE_ACTIVE_STATE_PROJECT_KEY_PREFIX = "pi-forge-project-v1\0";
|
|
17
|
+
/**
|
|
18
|
+
* Scoped resource key grammar from the parent contract. Stricter than the
|
|
19
|
+
* internal resource grammar (length-bounded, exactly one colon).
|
|
20
|
+
*/
|
|
21
|
+
export declare const FORGE_ACTIVE_STATE_SCOPED_KEY_PATTERN: RegExp;
|
|
22
|
+
/** Opaque lower-hex SHA-256 project key. */
|
|
23
|
+
export declare const FORGE_ACTIVE_STATE_PROJECT_KEY_PATTERN: RegExp;
|
|
24
|
+
/**
|
|
25
|
+
* Bounded publisher-instance grammar shared with the downstream Pi Pet/Clawd
|
|
26
|
+
* appearance consumer. UUIDs pass; control characters, path separators, and
|
|
27
|
+
* other punctuation are rejected so an instance id can never look like a path
|
|
28
|
+
* or smuggle control bytes across the bus.
|
|
29
|
+
*/
|
|
30
|
+
export declare const FORGE_ACTIVE_STATE_INSTANCE_ID_PATTERN: RegExp;
|
|
31
|
+
export declare const FORGE_ACTIVE_STATE_MAX_SESSION_ID_LENGTH = 1024;
|
|
32
|
+
export declare const FORGE_ACTIVE_STATE_MAX_INSTANCE_ID_LENGTH = 128;
|
|
33
|
+
export interface ForgeActiveStateEvent {
|
|
34
|
+
schemaVersion: typeof FORGE_ACTIVE_STATE_SCHEMA_VERSION;
|
|
35
|
+
/** Raw Pi session-manager ID for the session this snapshot belongs to. */
|
|
36
|
+
sessionId: string;
|
|
37
|
+
/** UUID refreshed per publisher attach/epoch; retired instances must be ignored. */
|
|
38
|
+
instanceId: string;
|
|
39
|
+
/** Monotonic safe integer within one instance. */
|
|
40
|
+
revision: number;
|
|
41
|
+
/** Effective scoped prompt-stack key, or null when no stack is active. */
|
|
42
|
+
stackKey: string | null;
|
|
43
|
+
/** Compatible applied-profile provenance key, or null (see profile rule). */
|
|
44
|
+
profileKey: string | null;
|
|
45
|
+
/** Opaque project key, or null. Never a raw path. */
|
|
46
|
+
projectKey: string | null;
|
|
47
|
+
}
|
|
48
|
+
export interface ForgeActiveStateRequest {
|
|
49
|
+
schemaVersion: typeof FORGE_ACTIVE_STATE_SCHEMA_VERSION;
|
|
50
|
+
/** When present, the publisher only answers for this exact session. */
|
|
51
|
+
sessionId?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface ActiveStateTransport {
|
|
54
|
+
emit(channel: string, data: unknown): void;
|
|
55
|
+
on(channel: string, handler: (data: unknown) => void): () => void;
|
|
56
|
+
}
|
|
57
|
+
export type ActiveStateValidationResult<T> = {
|
|
58
|
+
ok: true;
|
|
59
|
+
data: T;
|
|
60
|
+
} | {
|
|
61
|
+
ok: false;
|
|
62
|
+
error: string;
|
|
63
|
+
};
|
|
64
|
+
export interface ForgeActiveStateWorkspaceProfile {
|
|
65
|
+
profileId: string;
|
|
66
|
+
scope?: "global" | "project";
|
|
67
|
+
/** Prompt-stack reference recorded when the profile was applied. */
|
|
68
|
+
promptStack: string | null;
|
|
69
|
+
}
|
|
70
|
+
export interface ForgeActiveStateWorkspaceView {
|
|
71
|
+
/** Canonical scoped key of the effective stack, or null when disabled. */
|
|
72
|
+
stackKey?: string | null;
|
|
73
|
+
profile?: ForgeActiveStateWorkspaceProfile | undefined;
|
|
74
|
+
}
|
|
75
|
+
export interface ForgeActiveStateSession {
|
|
76
|
+
sessionId: string;
|
|
77
|
+
cwd: string;
|
|
78
|
+
}
|
|
79
|
+
export interface ForgeActiveStatePublisherOptions {
|
|
80
|
+
transport: ActiveStateTransport;
|
|
81
|
+
/** Pure read of the current effective workspace view. Must never throw. */
|
|
82
|
+
readWorkspace(): ForgeActiveStateWorkspaceView;
|
|
83
|
+
/** Test seam; defaults to the OS hostname. */
|
|
84
|
+
hostname?: string;
|
|
85
|
+
/** Test seam; defaults to a fresh UUID per attach. */
|
|
86
|
+
createInstanceId?: () => string;
|
|
87
|
+
}
|
|
88
|
+
export declare function isValidActiveStateSessionId(value: unknown): value is string;
|
|
89
|
+
export declare function isValidActiveStateScopedKey(value: unknown): value is string;
|
|
90
|
+
export declare function isValidActiveStateProjectKey(value: unknown): value is string;
|
|
91
|
+
export declare function isValidActiveStateInstanceId(value: unknown): value is string;
|
|
92
|
+
/**
|
|
93
|
+
* Opaque project identity from the session working directory. The raw path and
|
|
94
|
+
* hostname never leave this function; only the 64-char digest crosses the bus.
|
|
95
|
+
*/
|
|
96
|
+
export declare function activeStateProjectKey(cwd: string, hostnameValue?: string): string | null;
|
|
97
|
+
export declare function validateActiveStateRequest(value: unknown): ActiveStateValidationResult<ForgeActiveStateRequest>;
|
|
98
|
+
export declare function validateActiveStateEvent(value: unknown): ActiveStateValidationResult<ForgeActiveStateEvent>;
|
|
99
|
+
/**
|
|
100
|
+
* Publishes active-state snapshots on the neutral channel and answers
|
|
101
|
+
* late-subscriber snapshot requests. One publisher instance corresponds to one
|
|
102
|
+
* attached Pi session identity; a session-id change retires the old instance
|
|
103
|
+
* (after a final cleared snapshot) and attaches a new instance.
|
|
104
|
+
*/
|
|
105
|
+
export declare class ForgeActiveStatePublisher {
|
|
106
|
+
private readonly transport;
|
|
107
|
+
private readonly read;
|
|
108
|
+
private readonly hostnameValue;
|
|
109
|
+
private readonly createInstanceId;
|
|
110
|
+
private sessionValue?;
|
|
111
|
+
private instanceIdValue?;
|
|
112
|
+
private revisionValue;
|
|
113
|
+
private requestUnsubscribe?;
|
|
114
|
+
private requestListenerAttached;
|
|
115
|
+
private suspended;
|
|
116
|
+
constructor(options: ForgeActiveStatePublisherOptions);
|
|
117
|
+
get attached(): boolean;
|
|
118
|
+
get sessionId(): string | undefined;
|
|
119
|
+
get instanceId(): string | undefined;
|
|
120
|
+
get revision(): number;
|
|
121
|
+
/**
|
|
122
|
+
* Pause publication and request replies while a lifecycle restore is in
|
|
123
|
+
* flight. The workspace publishes several intermediate snapshots during
|
|
124
|
+
* `restoreBranchScopedRuntime`; emitting those would leak the new workspace
|
|
125
|
+
* under the old session id before the publisher is rebound. Call
|
|
126
|
+
* `bindSession` once the restore is complete to resume with the latest
|
|
127
|
+
* coherent snapshot.
|
|
128
|
+
*/
|
|
129
|
+
suspend(): void;
|
|
130
|
+
/** Bind or rebind the Pi session, resume publication, and publish the current snapshot. */
|
|
131
|
+
bindSession(session: ForgeActiveStateSession): void;
|
|
132
|
+
/** Publish the current workspace view with a fresh revision. */
|
|
133
|
+
publish(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Emit one final cleared snapshot for the bound session, unregister the
|
|
136
|
+
* request listener, and detach. Safe to call more than once.
|
|
137
|
+
*/
|
|
138
|
+
dispose(): void;
|
|
139
|
+
private ensureRequestListener;
|
|
140
|
+
private unsubscribeRequest;
|
|
141
|
+
private onRequest;
|
|
142
|
+
private buildEvent;
|
|
143
|
+
private buildClearEvent;
|
|
144
|
+
private emitEvent;
|
|
145
|
+
private readSafely;
|
|
146
|
+
private advanceEpoch;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=active-state.d.ts.map
|
|
@@ -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