pico-engine 1.8.0 → 1.9.1

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 (57) hide show
  1. package/README.md +5 -3
  2. package/dist/RulesetRegistryLoaderFs.js +46 -4
  3. package/dist/cli.js +3 -1
  4. package/dist/engineConfig.js +11 -0
  5. package/dist/index.js +2 -5
  6. package/dist/logging.js +148 -4
  7. package/dist/server.js +206 -1
  8. package/dist/stageKrl.js +26 -0
  9. package/dist/xmluiRuntime.js +68 -0
  10. package/krl/io.picolabs.pico-engine-ui.krl +14 -77
  11. package/krl/io.picolabs.wrangler.krl +28 -5
  12. package/krl/io.picolabs.xmlui.krl +305 -0
  13. package/mcp/devResources.js +17 -7
  14. package/mcp/docs/CLAUDE.md +85 -0
  15. package/{public → mcp}/docs/pico-engine.md +15 -11
  16. package/package.json +11 -7
  17. package/public/pico-engine-ui.css +1 -1
  18. package/public/pico-engine-ui.js +27 -25
  19. package/public/xmlui/0.12.7.js +419 -0
  20. package/public/xmlui/pico-view-boot.js +153 -0
  21. package/src/RulesetRegistryLoaderFs.ts +48 -4
  22. package/src/cli.ts +3 -1
  23. package/src/engineConfig.ts +18 -0
  24. package/src/index.ts +4 -6
  25. package/src/logging.ts +165 -4
  26. package/src/server.ts +250 -2
  27. package/src/stageKrl.ts +26 -0
  28. package/src/xmluiRuntime.ts +66 -0
  29. package/public/docs/README.md +0 -9
  30. package/public/docs/_media/logo.png +0 -0
  31. package/public/docs/_sidebar.md +0 -6
  32. package/public/docs/contributing.md +0 -64
  33. package/public/docs/favicon.ico +0 -0
  34. package/public/docs/index.html +0 -29
  35. package/public/docs/krl/README.md +0 -3
  36. package/public/docs/krl/_sidebar.md +0 -10
  37. package/public/docs/krl/discovery.md +0 -144
  38. package/public/docs/krl/modules/ctx.md +0 -151
  39. package/public/docs/krl/modules/event.md +0 -70
  40. package/public/docs/krl/modules/http.md +0 -42
  41. package/public/docs/krl/modules/math.md +0 -5
  42. package/public/docs/krl/modules/schedule.md +0 -5
  43. package/public/docs/krl/modules.md +0 -11
  44. package/public/docs/krl/rulesets.md +0 -81
  45. package/public/docs/krl/stdlib.md +0 -3
  46. package/public/docs/llms-full.txt +0 -479
  47. package/public/docs/llms.txt +0 -37
  48. package/public/docs/openapi.yaml +0 -78
  49. package/public/docs/pico.md +0 -5
  50. package/public/docs/rulesets/README.md +0 -25
  51. package/public/docs/rulesets/io.picolabs.oauth.md +0 -71
  52. package/public/docs/rulesets/io.picolabs.pds.md +0 -327
  53. package/public/docs/rulesets/io.picolabs.pico-engine-ui.md +0 -65
  54. package/public/docs/rulesets/io.picolabs.portable_subtree.md +0 -94
  55. package/public/docs/rulesets/io.picolabs.subscription.md +0 -398
  56. package/public/docs/rulesets/io.picolabs.wrangler.md +0 -471
  57. /package/{public → mcp}/docs/pico-overview.md +0 -0
@@ -1,151 +0,0 @@
1
- # ctx
2
-
3
- The `ctx` module provides context information and actions for running code. Context includes the pico, ruleset, and engine the code is running for and on.
4
-
5
- ## ctx:picoId
6
-
7
- Get the identifier for the pico assigned by the engine.
8
-
9
- ## ctx:rid
10
-
11
- Get the ruleset id (rid) string.
12
-
13
- ## ctx:rid_version
14
-
15
- The ruleset version string.
16
-
17
- ## ctx:rid_url
18
-
19
- The ruleset url string.
20
-
21
- ## ctx:rid_config
22
-
23
- The configuration Map when the ruleset was installed onto the pico.
24
-
25
- ## ctx:parent
26
-
27
- The eci string of the parent or null if there is no parent.
28
-
29
- ## ctx:children
30
-
31
- A list of the eci strings of the pico's children.
32
-
33
- ## ctx:channels
34
-
35
- A list of all channels this pico owns.
36
-
37
- TODO channel schema
38
-
39
- ## ctx:rulesets
40
-
41
- A list of all the rulesets the pico has installed
42
-
43
- ## ctx:raiseEvent(domain, name, attrs)
44
-
45
- Raise an event to yourself. This event does not use a channel, only runs on the current pico, and happens in the same event schedule.
46
-
47
- - `domain` - String - The event domain.
48
- - `name` - String - The event name.
49
- - `attrs` - Map - The event attributes.
50
-
51
- ## ctx:allowsEvent(eci, domain, name)
52
-
53
- Return `true` when the given channel's event policy would allow an event with this domain and name. Returns `false` for unknown channels or denied events (never throws).
54
-
55
- ## ctx:allowsQuery(eci, rid, name)
56
-
57
- Return `true` when the given channel's query policy would allow this query. Returns `false` for unknown channels or denied queries (never throws).
58
-
59
- ## ctx:query(eci, rid, name, args = {})
60
-
61
- Query a local pico.
62
-
63
- - `eci` - String - Which channel to send the query over.
64
- - `rid` - String - The rid you wish to query.
65
- - `name` - String - The name of the function you wish to query.
66
- - `args` - Map - Any query function arguments where the map keys match the argument name.
67
-
68
- ## ctx:event(eci, domain, name, attrs = {})
69
-
70
- Send an event to a local pico.
71
-
72
- - `eci` - String - Which channel to signal the event to.
73
- - `domain` - String - The event domain.
74
- - `name` - String - The event name.
75
- - `attrs` - Map - The event attributes.
76
-
77
- ## ctx:eventWait(eci, domain, name, attrs = {})
78
-
79
- - `eci` - String - Which channel to signal the event to.
80
- - `domain` - String - The event domain.
81
- - `name` - String - The event name.
82
- - `attrs` - Map - The event attributes.
83
-
84
- ## ctx:eventQuery(eci, domain, name, attrs, rid, qname, args = {})
85
-
86
- Signal an event then query immediately after the event finished processing.
87
-
88
- - `eci` - String - Which channel to signal the event to and query over.
89
- - `domain` - String - The event domain.
90
- - `name` - String - The event name.
91
- - `attrs` - Map - The event attributes.
92
- - `rid` - String - The rid you wish to query.
93
- - `qname` - String - The name from the ruleset you wish to query.
94
- - `args` - Map - Any query function arguments where the map keys match the argument name.
95
-
96
- ## ctx:newPico(rulesets = [])
97
-
98
- Create a new child pico. This returns the channel you can use to talk the child pico.
99
-
100
- - `rulesets` - Array - List of the rulesets you wish installed on this pico when it's created.
101
-
102
- Example:
103
-
104
- ```krl
105
- ctx:newPico([
106
- {"url": "http://.../ruleset.krl", "config": {"some": "config"}}
107
- ])
108
- ```
109
-
110
- ## ctx:delPico(eci)
111
-
112
- Delete a child pico.
113
-
114
- - `eci` - String - The parent's eci for talking to the child. No other eci will work.
115
-
116
- ## ctx:newChannel(tags, eventPolicy, queryPolicy)
117
-
118
- - `tags` - String[] - An array of tags to organize your channels
119
- - `eventPolicy` - EventPolicy - Your event allow/deny rules
120
- - `queryPolicy` - QueryPolicy - Your query allow/deny rules
121
-
122
- ## ctx:putChannel(eci, tags, eventPolicy, queryPolicy)
123
-
124
- Same as newChannel except you provide the eci you whish to modify. Channels can only be modified by their owners.
125
-
126
- ## ctx:upsertChannel(tags, eventPolicy, queryPolicy)
127
-
128
- If there is a channel with the same tags it will update it. Otherwise it will create a new channel.
129
-
130
- ## ctx:delChannel(eci)
131
-
132
- Delete a channel. Only the owner pico can delete their channel.
133
-
134
- ## ctx:install(url, config = {})
135
-
136
- Install a ruleset.
137
-
138
- - `url` - String - The url to the ruleset you wish to install.
139
- - `config` - Map - Any configuration data the ruleset may want.
140
-
141
- ## ctx:uninstall(rid)
142
-
143
- Uninstall a ruleset.
144
-
145
- - `rid` - String - The id of the ruleset you wish to uninstall.
146
-
147
- ## ctx:flush(url)
148
-
149
- Flush a ruleset by fetching the url and reloading it.
150
-
151
- - `url` - String - The url to the ruleset you wish to flush.
@@ -1,70 +0,0 @@
1
- # event
2
-
3
- The `event` module provides access to the current executing event. These return `null` if the code is running when there is no event i.e. query.
4
-
5
- ## event:eci
6
-
7
- Get the event channel id. `String` or `null`
8
-
9
- ## event:domain
10
-
11
- Get the event domain. `String` or `null`
12
-
13
- ## event:name
14
-
15
- Get the event name. `String` or `null`
16
-
17
- ## event:attrs
18
-
19
- Get the event attributes. `Map` or `null`
20
-
21
- ## event:eid
22
-
23
- Get the event transaction id. `String` or `null`
24
-
25
- ## event:time
26
-
27
- Get the event timestamp as number of milliseconds since epoch. `Number` or `null`
28
-
29
- ## event:send
30
-
31
- Send an event to another pico. Action.
32
-
33
- ```krl
34
- event:send({
35
- "eci": "<channel id>", // local or remote ECI
36
- "domain": "wrangler",
37
- "type": "ping", // alias: "name"
38
- "attrs": { "key": "value" }
39
- }, host) // optional host for remote ECI
40
- ```
41
-
42
- **DID-based (1.6+) — send by DID** (requires an established DID-based relationship):
43
-
44
- ```krl
45
- event:send({
46
- "did": "did:peer:2....", // or did:webvh:...
47
- "domain": "wrangler",
48
- "type": "ping",
49
- "attrs": {}
50
- })
51
- ```
52
-
53
- **DID-based — send via established relationship map** (from `relationship:established()` etc.; legacy module name `subscription:established()`):
54
-
55
- ```krl
56
- use module io.picolabs.subscription alias relationship
57
-
58
- event:send({
59
- "sub": bus, // established relationship (bus) map
60
- "domain": "wrangler",
61
- "type": "ping",
62
- "attrs": {}
63
- })
64
- ```
65
-
66
- When `bus.layer2` is true (DID-based relationship), routing uses `Tx_did` and DIDComm (or verified local dispatch on the same engine). ECI-based relationships use `bus.Tx` and optional `bus.Tx_host` as before.
67
-
68
- ## event:attr
69
-
70
- Get a single attribute by name. `Function(name)` → value or `null`
@@ -1,42 +0,0 @@
1
- # http
2
-
3
- This module allows you to make http requests.
4
-
5
- ## http:do(method, url, qs, headers, body, auth, json, form, parseJSON, autoraise, autosignal)
6
-
7
- - `method` - String -
8
- - `url` - String - the http(s) base url
9
- - `qs` - Map - query string values
10
- - `headers` - Map - http headers
11
- - `body` - String - the payload of the data
12
- - TODO rest
13
-
14
- Example:
15
-
16
- ```krl
17
- TODO example
18
- ```
19
-
20
- ## http:get(...)
21
-
22
- Same as `http:do('GET', ...)`
23
-
24
- ## http:post(...)
25
-
26
- Same as `http:do('POST', ...)`
27
-
28
- ## http:put(...)
29
-
30
- Same as `http:do('PUT', ...)`
31
-
32
- ## http:patch(...)
33
-
34
- Same as `http:do('PATCH', ...)`
35
-
36
- ## http:delete(...)
37
-
38
- Same as `http:do('DELETE', ...)`
39
-
40
- ## http:head(...)
41
-
42
- Same as `http:do('HEAD', ...)`
@@ -1,5 +0,0 @@
1
- # math
2
-
3
- The math library provides a number of useful math functions.
4
-
5
- TODO
@@ -1,5 +0,0 @@
1
- # schedule
2
-
3
- Scheduled events allow you to raise an event at a point in time or on a recurring basis.
4
-
5
- TODO
@@ -1,11 +0,0 @@
1
- # KRL Modules
2
-
3
- TODO explain how modules work
4
-
5
- ## Create a KRL module
6
-
7
- TODO explain how
8
-
9
- ## Create a Node.js module for KRL
10
-
11
- TODO explain how
@@ -1,81 +0,0 @@
1
- # KRL Rulesets
2
-
3
- A ruleset is the primary means of program organization in KRL. A ruleset is a collection of rules. Each rule is designed to respond to a specific event.
4
-
5
- Each ruleset can have the following sections.
6
-
7
- - `meta`
8
- - `global`
9
- - `rule`(s)
10
-
11
- ```
12
- ruleset <rid> {
13
- version <string>
14
- meta {
15
- <configuration>
16
- }
17
- global {
18
- <global declarations>
19
- }
20
- rule one {
21
- ...
22
- }
23
- rule two {
24
- ...
25
- }
26
- ...
27
- }
28
- ```
29
-
30
-
31
- ## meta
32
-
33
- The meta section stores information about a ruleset. Meta sections are optional and may be empty.
34
-
35
- The following are allowed in a meta section:
36
-
37
- ### version
38
-
39
- Rulesets are versioned. Version strings follow [Semantic Versioning](https://semver.org/). i.e `1.2.3` where `<major>.<minor>.<patch>`.
40
-
41
- During development you can set the version to `"draft"` or omit it completely. This way you can make frequent changes and see them reflected immediately on the picos that use the "draft" version.
42
-
43
-
44
- TODO
45
-
46
- ## global
47
-
48
- TODO
49
-
50
- ## rule
51
-
52
- TODO
53
-
54
- ### select
55
-
56
- Select statements are the initial condition on whether or not to run a rule.
57
-
58
- There are 2 variants of select
59
-
60
- - `select when <event-expression>`
61
- - `select where <expression>`
62
-
63
- #### select when
64
-
65
- TODO
66
-
67
- #### select where
68
-
69
- The rule will select when the `<expression>` evaluates truthy.
70
-
71
- ### prelude
72
-
73
- TODO
74
-
75
- ### action
76
-
77
- TODO
78
-
79
- ### postlude
80
-
81
- TODO
@@ -1,3 +0,0 @@
1
- # KRL Standard Library
2
-
3
- TODO