pico-engine 1.6.4 → 1.9.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 (108) hide show
  1. package/README.md +16 -9
  2. package/dist/RulesetRegistryLoaderFs.js +60 -6
  3. package/dist/auth/cookies.js +32 -0
  4. package/dist/auth/index.js +6 -1
  5. package/dist/channelIdentityPolicy.js +22 -0
  6. package/dist/cli.js +106 -69
  7. package/dist/engineConfig.js +291 -0
  8. package/dist/identity/IdentityService.js +90 -0
  9. package/dist/identity/crossPico.js +24 -8
  10. package/dist/identity/didoModule.js +80 -18
  11. package/dist/identity/establishSubscription.js +2 -2
  12. package/dist/identity/identityPortable.js +92 -0
  13. package/dist/identity/index.js +10 -1
  14. package/dist/identity/localPeerReconcile.js +65 -0
  15. package/dist/identity/peerDid4.js +175 -0
  16. package/dist/identity/peerDid4Create.js +90 -0
  17. package/dist/identity/portableExportPrepare.js +196 -0
  18. package/dist/identity/portableMove.js +87 -0
  19. package/dist/identity/skyIntro.js +6 -3
  20. package/dist/identity/skyProtocol.js +26 -1
  21. package/dist/identity/skyRotation.js +121 -0
  22. package/dist/identity/store.js +5 -1
  23. package/dist/identity/subscriptionEntSync.js +72 -0
  24. package/dist/identity/veramoDidComm.js +41 -2
  25. package/dist/identity/webvh.js +4 -2
  26. package/dist/identity/webvhRelocation.js +115 -0
  27. package/dist/index.js +84 -27
  28. package/dist/logging.js +156 -16
  29. package/dist/oauth/OAuthService.js +6 -2
  30. package/dist/policyConfigFromJson.js +112 -0
  31. package/dist/runMcp.js +27 -0
  32. package/dist/server.js +261 -24
  33. package/dist/stageKrl.js +26 -0
  34. package/dist/subtreeWrangler.js +180 -0
  35. package/dist/uiChannelPolicies.js +15 -0
  36. package/dist/xmluiRuntime.js +68 -0
  37. package/krl/io.picolabs.oauth.krl +41 -2
  38. package/krl/io.picolabs.pds.krl +131 -10
  39. package/krl/io.picolabs.pico-engine-ui.krl +217 -94
  40. package/krl/io.picolabs.portable_subtree.krl +97 -0
  41. package/krl/io.picolabs.subscription.krl +180 -72
  42. package/krl/io.picolabs.wrangler.krl +313 -57
  43. package/krl/io.picolabs.xmlui.krl +295 -0
  44. package/mcp/devResources.js +118 -0
  45. package/mcp/devTools.js +351 -0
  46. package/mcp/engineClient.js +133 -0
  47. package/mcp/meshHttp.js +137 -0
  48. package/mcp/meshTools.js +189 -0
  49. package/mcp/runStdio.js +34 -0
  50. package/mcp/schemaToZod.js +56 -0
  51. package/package.json +24 -9
  52. package/public/.DS_Store +0 -0
  53. package/public/docs/_sidebar.md +3 -1
  54. package/public/docs/llms-full.txt +630 -0
  55. package/public/docs/llms.txt +38 -0
  56. package/public/docs/openapi.yaml +78 -0
  57. package/public/docs/pico-engine.md +239 -4
  58. package/public/docs/pico-overview.md +117 -0
  59. package/public/docs/pico-views-xmlui.md +5 -0
  60. package/public/docs/pico-views.md +140 -0
  61. package/public/docs/pico.md +3 -1
  62. package/public/docs/rulesets/README.md +26 -0
  63. package/public/docs/rulesets/io.picolabs.oauth.md +71 -0
  64. package/public/docs/rulesets/io.picolabs.pds.md +327 -0
  65. package/public/docs/rulesets/io.picolabs.pico-engine-ui.md +65 -0
  66. package/public/docs/rulesets/io.picolabs.portable_subtree.md +94 -0
  67. package/public/docs/rulesets/io.picolabs.subscription.md +398 -0
  68. package/public/docs/rulesets/io.picolabs.wrangler.md +471 -0
  69. package/public/pico-engine-ui.css +1 -1
  70. package/public/pico-engine-ui.js +27 -23
  71. package/public/xmlui/0.12.7.js +419 -0
  72. package/public/xmlui/pico-view-boot.js +153 -0
  73. package/src/RulesetRegistryLoaderFs.ts +66 -7
  74. package/src/auth/cookies.ts +34 -0
  75. package/src/auth/index.ts +7 -0
  76. package/src/channelIdentityPolicy.ts +29 -0
  77. package/src/cli.ts +70 -37
  78. package/src/engineConfig.ts +363 -0
  79. package/src/identity/IdentityService.ts +189 -1
  80. package/src/identity/crossPico.ts +57 -8
  81. package/src/identity/didoModule.ts +140 -23
  82. package/src/identity/establishSubscription.ts +2 -2
  83. package/src/identity/identityPortable.ts +153 -0
  84. package/src/identity/index.ts +14 -0
  85. package/src/identity/localPeerReconcile.ts +97 -0
  86. package/src/identity/peerDid4.ts +197 -0
  87. package/src/identity/peerDid4Create.ts +121 -0
  88. package/src/identity/portableExportPrepare.ts +302 -0
  89. package/src/identity/portableMove.ts +193 -0
  90. package/src/identity/skyIntro.ts +11 -11
  91. package/src/identity/skyProtocol.ts +46 -0
  92. package/src/identity/skyRotation.ts +211 -0
  93. package/src/identity/store.ts +5 -1
  94. package/src/identity/subscriptionEntSync.ts +97 -0
  95. package/src/identity/veramoDidComm.ts +52 -2
  96. package/src/identity/webvh.ts +4 -4
  97. package/src/identity/webvhRelocation.ts +167 -0
  98. package/src/index.ts +123 -31
  99. package/src/logging.ts +173 -18
  100. package/src/oauth/OAuthService.ts +11 -3
  101. package/src/policyConfigFromJson.ts +131 -0
  102. package/src/runMcp.ts +30 -0
  103. package/src/server.ts +328 -27
  104. package/src/stageKrl.ts +26 -0
  105. package/src/subtreeWrangler.ts +278 -0
  106. package/src/uiChannelPolicies.ts +15 -0
  107. package/src/xmluiRuntime.ts +66 -0
  108. package/krl/io.picolabs.did-o.krl +0 -349
@@ -1,349 +0,0 @@
1
- /*
2
- DID-O V 1.0.0
3
- ⠀⠀⠀⢠⡜⠛⠛⠿⣤⠀⠀⣤⡼⠿⠿⢧⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
4
- ⠀⣀⡶⠎⠁⠀⠀⠀⠉⠶⠶⠉⠁⠀⠀⠈⠹⢆⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
5
- ⣀⡿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠶⠶⠶⠶⣆⡀⠀⠀⠀⠀
6
- ⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢣⡄⠀⠀⠀
7
- ⠛⣧⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀
8
- ⠀⠛⣧⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⠀⠀⠀⠀⢠⡼⠃⠀⠀
9
- ⠀⠀⠿⢇⡀⠀⠀⠀⠀⠀⠀⠀⠰⠶⠶⢆⣀⣀⣀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀
10
- ⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀
11
- ⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀
12
- ⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢣⣤
13
- ⠀⣶⡏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿
14
- ⠀⠿⣇⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⠀⠀⠀⠀⢀⣀⣸⠿
15
- ⠀⠀⠙⢳⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⡞⠛⠛⠛⠛⠛⠛⣶⣶⣶⣶⡞⠛⠃⠀
16
- */
17
-
18
- ruleset io.picolabs.did-o {
19
- meta {
20
- name "did-o"
21
- description
22
- <<
23
- DEPRECATED (pico-engine 1.6+): Layer 2 identity folds DIDComm routing into the
24
- engine dido module and wrangler core. Do not install on new picos. Use
25
- wrangler:myDid(), event:send({did: ...}), and wrangler:picoQuery with DID targets instead.
26
-
27
- Legacy ruleset for DIDComm v2 communication using picos (did:peer:2 era).
28
- >>
29
- author "Rembrand Paul Pardo, Kekoapoaono Montalbo, Josh Mann"
30
-
31
- provides addRoute, routes, send, sendEvent, sendQuery, didMap, clearDidMap, didDocs, clearDidDocs, pendingRotations, clearPendingRotations, generate_invitation, generate_message
32
-
33
- shares routes, addRoute, didDocs, clearDidDocs, didMap, clearDidMap, pendingRotations, clearPendingRotations, generate_invitation, generate_message
34
-
35
- use module io.picolabs.wrangler alias wrangler
36
- }
37
-
38
-
39
- global {
40
- ///////////////////////////////////////////// ROUTING //////////////////////////////////////////////
41
-
42
- /**
43
- * Adds a route to the routes stored in the dido.ts library. The type should be a valid Protocol URI.
44
- * The domain and name are the domain and name of the event that will be raised when a message of the specified type is received.
45
- */
46
- addRoute = function(type, _domain, name) {
47
- dido:addRoute(type, _domain, name)
48
- }
49
-
50
- /**
51
- * Queries the existing routes.
52
- */
53
- routes = function() {
54
- ent:routes
55
- }
56
-
57
- /**
58
- * Send a message to the specified DID. did is the recipient DID and message is a valid DIDComm v2 message.
59
- */
60
- send = function(did, message) {
61
- dido:send(did, message)
62
- }
63
-
64
- /**
65
- * Send an event to the specified DID. did is the recipient DID and the event is formatted as follows:
66
- * event = {
67
- * "domain": domain: string,
68
- * "name": name: string,
69
- * "attrs": attrs: {[name: string]: any}
70
- * }
71
- */
72
- sendEvent = function(did, event) {
73
- message = dido:generateMessage({
74
- "type": "https://picolabs.io/event/1.0/event",
75
- "from": ent:didMap{did},
76
- "to": [did],
77
- "body": event
78
- })
79
- dido:send(did, message)
80
- }
81
-
82
- /**
83
- * Send a query to the specified DID. did is the recipient DID and the query is formatted as follows:
84
- * query = {
85
- * "rid": rid: string,
86
- * "name": name: string,
87
- * "args": args: {[name: string]: any}
88
- * }
89
- */
90
- sendQuery = function(did, _query) {
91
- message = dido:generateMessage({
92
- "type": "https://picolabs.io/query/1.0/query",
93
- "from": ent:didMap{did},
94
- "to": [did],
95
- "body": _query
96
- })
97
- dido:sendQuery(did, message)
98
- }
99
-
100
- ///////////////////////////////////////////// DID MANAGEMENT //////////////////////////////////////////////
101
-
102
- /**
103
- * Return the map of DID relationships stored in the pattern [ thier_did : your_did ].
104
- */
105
- didMap = function() {
106
- ent:didMap
107
- }
108
-
109
- /**
110
- * Clear the map of DID relationships.
111
- */
112
- clearDidMap = function() {
113
- dido:clearDidMap()
114
- }
115
-
116
- /**
117
- * Return all the DIDs and DIDDocs stored in the pattern [ did : diddoc ].
118
- */
119
- didDocs = function() {
120
- ent:didDocs
121
- }
122
-
123
- /**
124
- * Clear all the DIDs and DIDDocs.
125
- */
126
- clearDidDocs = function() {
127
- dido:clearDidDocs()
128
- }
129
-
130
- /**
131
- * Return all the pending rotations stored in the pattern [ new_did : from_prior ].
132
- */
133
- pendingRotations = function() {
134
- ent:pendingRotations
135
- }
136
-
137
- /**
138
- * Clear all the pending rotations.
139
- */
140
- clearPendingRotations = function() {
141
- dido:clearPendingRotations()
142
- }
143
-
144
- ///////////////////////////////////////////// MESSAGE CREATORS //////////////////////////////////////////////
145
-
146
- /**
147
- * Generates and returns a DIDComm v2 message with the given message.
148
- * message is formatted as follows:
149
- * {
150
- * type: string,
151
- * body: any,
152
- * from?: string,
153
- * to?: [string],
154
- * thid?: string,
155
- * pthid?: string,
156
- * expires_time?: number,
157
- * attachments?: [Attachment]
158
- * }
159
- *
160
- * Refer to didcomm-node package for Attachment object specifics.
161
- */
162
- generate_message = function(message) {
163
- dido:generateMessage(message)
164
- }
165
-
166
- /**
167
- * Creates an invitation OOB URL that can be used to establish DID based relationships.
168
- * This automates the DID, channel, and message creation and encodes it into a base64 Out-of-Band URL.
169
- */
170
- generate_invitation = function(label) {
171
- DIDdoc = dido:generateDID(true)
172
- new_did = DIDdoc{"id"}
173
- invitation = dido:generateMessage({
174
- "type": "https://didcomm.org/out-of-band/2.0/invitation",
175
- "from": new_did,
176
- "body": {
177
- "goal_code": "exchange-did",
178
- "goal": "ExchangeDid",
179
- "label": label || "PicoInvite",
180
- "accept": [
181
- "didcomm/v2"
182
- ]
183
- }
184
- })
185
- base64 = math:base64encode(invitation.encode())
186
- dido:createInviteUrl(base64)
187
- }
188
-
189
- /**
190
- * Creates a trust ping message according to the DIDComm v2 protocol and returns it. The to parameter is the DID of the recipient.
191
- */
192
- generate_trust_ping_message = function(to) {
193
- dido:generateMessage({
194
- "type": "https://didcomm.org/trust_ping/2.0/ping",
195
- "from": ent:didMap{to},
196
- "to": [to],
197
- "body": {
198
- "response_requested": true
199
- }
200
- })
201
- }
202
-
203
- /**
204
- * Creates a trust ping response message according to the DIDComm v2 protocol and returns it.
205
- * The thid parameter is the id of the ping that you are responding to, and the to parameter is the DID of the recipient.
206
- */
207
- generate_trust_ping_response = function(thid, to) {
208
- dido:generateMessage({
209
- "type": "https://didcomm.org/trust_ping/2.0/ping_response",
210
- "thid": thid,
211
- "from": ent:didMap{to},
212
- "to": [to],
213
- "body": {}
214
- })
215
- }
216
- }
217
-
218
- ///////////////////////////////////////////// INITIAILIZATION //////////////////////////////////////////////
219
-
220
- /**
221
- * The initialize rule subscribes to the wrangler:ruleset_installed event and is called when the ruleset is installed and initializes the routes.
222
- */
223
- rule intialize {
224
- select when wrangler ruleset_installed where event:attrs{"rids"} >< meta:rid
225
- pre {
226
- ping = dido:addRoute("https://didcomm.org/trust_ping/2.0/ping", "dido", "receive_trust_ping")
227
- ping_response = dido:addRoute("https://didcomm.org/trust_ping/2.0/ping_response", "dido", "receive_trust_ping_response")
228
- }
229
- }
230
-
231
- /**
232
- * The pico_root_created rule subscribes to the engine_ui:setup event and is called when the engine starts and initializes the routes.
233
- * This is used in addition to the initialize rule to verify routes exist when a new engine is started.
234
- */
235
- rule pico_root_created {
236
- select when engine_ui setup
237
- if ent:routes.isnull() then noop()
238
- fired {
239
- ping = dido:addRoute("https://didcomm.org/trust_ping/2.0/ping", "dido", "receive_trust_ping")
240
- ping_response = dido:addRoute("https://didcomm.org/trust_ping/2.0/ping_response", "dido", "receive_trust_ping_response")
241
- }
242
- }
243
-
244
- ///////////////////////////////////////////// ROUTING //////////////////////////////////////////////
245
-
246
- /**
247
- * The route_message rule subscribes to the dido:didcommv2_message event. It calls the dido library,
248
- * unpacks the message, and looks for the proper route based on the message type. It then raises the
249
- * appropriate event and passes along the unpacked message.
250
- */
251
- rule route_message {
252
- select when dido didcommv2_message
253
- pre {
254
- response = dido:route(event:attrs.delete("_headers"))
255
- }
256
- if response then send_directive("response", {}.put(response))
257
- }
258
-
259
- ///////////////////////////////////////////// INVITATIONS //////////////////////////////////////////////
260
-
261
- /**
262
- * The receive_invite rule subscribes to the dido:receive_invite event and receives an invite URL (example.com/invite?_oob=abc...123)
263
- * from event:attrs{"invite"}. The invite URL is a base 64 encoded invite. The rule then creates a new DID and channel.
264
- * After that, it raises the dido:send_trust_ping event.
265
- */
266
- rule receive_invite {
267
- select when dido receive_invite
268
- pre {
269
- url = event:attrs{"invite"}
270
- base64 = url.split("_oob=")[1]
271
- invite = math:base64decode(base64).decode()
272
- new_did = dido:generateDID()
273
- didMap = dido:mapDid(invite{"from"}, new_did{"id"})
274
- stored_doc = dido:storeDidDoc(invite{"from"})
275
- }
276
- fired {
277
- raise dido event "send_trust_ping" attributes event:attrs.put("did", invite{"from"})
278
- }
279
- }
280
-
281
- ///////////////////////////////////////////// TRUST PING //////////////////////////////////////////////
282
-
283
- /**
284
- * The send_trust_ping rule subscribes to the dido:send_trust_ping event and requires the DID of the recipient
285
- * from event:attrs{"did"}. It then sends a generated trust ping message to the provided DID.
286
- */
287
- rule send_trust_ping {
288
- select when dido send_trust_ping
289
- pre {
290
- their_did = event:attrs{"did"}
291
- message = generate_trust_ping_message(their_did)
292
- send = dido:send(their_did, message)
293
- }
294
- }
295
-
296
- /**
297
- * The receive_trust_ping rule subscibes to the did:receive_trust_ping event and requires the ping message from
298
- * event:attrs{"message"}. It then checks if the message was received from an invite. If it was, it rotates the
299
- * invite DID. Then it generates the response and sends it back.
300
- */
301
- rule receive_trust_ping {
302
- select when dido receive_trust_ping
303
- pre {
304
- message = event:attrs{"message"}
305
- their_did = message{"from"}
306
- needsRotation = dido:rotateInviteDID(message{"to"}[0], message{"from"})
307
- response = generate_trust_ping_response(message{"id"}, their_did)
308
- send = dido:send(their_did, response)
309
- }
310
- }
311
- }
312
-
313
-
314
- /*
315
- DID-O - V 1.0.0
316
- ,--._
317
- | `...
318
- ,.-------" `.
319
- / " `-.__
320
- . " _, `._
321
- | __..-" `.
322
- | ''"' `._
323
- | `"-.
324
- ' `.
325
- . |
326
- / |
327
- _,' ,'
328
- ," /
329
- . /
330
- | /
331
- | .
332
- ' |
333
- `. |
334
- `. |
335
- `. '
336
- . .
337
- | `.
338
- ' |
339
- ,' |
340
- ,' '
341
- / _...._ /
342
- . ,-' `"'--'
343
- | ,'
344
- .' ,'
345
- / _,....__ _,'
346
- | ,.' `---'
347
- '_ ,--`
348
- `---'
349
- */