pico-engine 1.6.4 → 1.8.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/README.md +13 -8
- package/dist/RulesetRegistryLoaderFs.js +14 -2
- package/dist/auth/cookies.js +32 -0
- package/dist/auth/index.js +6 -1
- package/dist/channelIdentityPolicy.js +22 -0
- package/dist/cli.js +104 -69
- package/dist/engineConfig.js +280 -0
- package/dist/identity/IdentityService.js +90 -0
- package/dist/identity/crossPico.js +24 -8
- package/dist/identity/didoModule.js +80 -18
- package/dist/identity/establishSubscription.js +2 -2
- package/dist/identity/identityPortable.js +92 -0
- package/dist/identity/index.js +10 -1
- package/dist/identity/localPeerReconcile.js +65 -0
- package/dist/identity/peerDid4.js +175 -0
- package/dist/identity/peerDid4Create.js +90 -0
- package/dist/identity/portableExportPrepare.js +196 -0
- package/dist/identity/portableMove.js +87 -0
- package/dist/identity/skyIntro.js +6 -3
- package/dist/identity/skyProtocol.js +26 -1
- package/dist/identity/skyRotation.js +121 -0
- package/dist/identity/store.js +5 -1
- package/dist/identity/subscriptionEntSync.js +72 -0
- package/dist/identity/veramoDidComm.js +41 -2
- package/dist/identity/webvh.js +4 -2
- package/dist/identity/webvhRelocation.js +115 -0
- package/dist/index.js +82 -22
- package/dist/logging.js +8 -12
- package/dist/oauth/OAuthService.js +6 -2
- package/dist/policyConfigFromJson.js +112 -0
- package/dist/runMcp.js +27 -0
- package/dist/server.js +56 -24
- package/dist/subtreeWrangler.js +180 -0
- package/dist/uiChannelPolicies.js +15 -0
- package/krl/io.picolabs.oauth.krl +41 -2
- package/krl/io.picolabs.pds.krl +131 -10
- package/krl/io.picolabs.pico-engine-ui.krl +209 -21
- package/krl/io.picolabs.portable_subtree.krl +97 -0
- package/krl/io.picolabs.subscription.krl +180 -72
- package/krl/io.picolabs.wrangler.krl +296 -57
- package/mcp/devResources.js +118 -0
- package/mcp/devTools.js +351 -0
- package/mcp/engineClient.js +133 -0
- package/mcp/meshHttp.js +137 -0
- package/mcp/meshTools.js +189 -0
- package/mcp/runStdio.js +34 -0
- package/mcp/schemaToZod.js +56 -0
- package/package.json +20 -8
- package/public/docs/_sidebar.md +2 -1
- package/public/docs/llms-full.txt +479 -0
- package/public/docs/llms.txt +37 -0
- package/public/docs/openapi.yaml +78 -0
- package/public/docs/pico-engine.md +235 -4
- package/public/docs/pico-overview.md +117 -0
- package/public/docs/pico.md +3 -1
- package/public/docs/rulesets/README.md +25 -0
- package/public/docs/rulesets/io.picolabs.oauth.md +71 -0
- package/public/docs/rulesets/io.picolabs.pds.md +327 -0
- package/public/docs/rulesets/io.picolabs.pico-engine-ui.md +65 -0
- package/public/docs/rulesets/io.picolabs.portable_subtree.md +94 -0
- package/public/docs/rulesets/io.picolabs.subscription.md +398 -0
- package/public/docs/rulesets/io.picolabs.wrangler.md +471 -0
- package/public/pico-engine-ui.css +1 -1
- package/public/pico-engine-ui.js +28 -26
- package/src/RulesetRegistryLoaderFs.ts +18 -3
- package/src/auth/cookies.ts +34 -0
- package/src/auth/index.ts +7 -0
- package/src/channelIdentityPolicy.ts +29 -0
- package/src/cli.ts +68 -37
- package/src/engineConfig.ts +345 -0
- package/src/identity/IdentityService.ts +189 -1
- package/src/identity/crossPico.ts +57 -8
- package/src/identity/didoModule.ts +140 -23
- package/src/identity/establishSubscription.ts +2 -2
- package/src/identity/identityPortable.ts +153 -0
- package/src/identity/index.ts +14 -0
- package/src/identity/localPeerReconcile.ts +97 -0
- package/src/identity/peerDid4.ts +197 -0
- package/src/identity/peerDid4Create.ts +121 -0
- package/src/identity/portableExportPrepare.ts +302 -0
- package/src/identity/portableMove.ts +193 -0
- package/src/identity/skyIntro.ts +11 -11
- package/src/identity/skyProtocol.ts +46 -0
- package/src/identity/skyRotation.ts +211 -0
- package/src/identity/store.ts +5 -1
- package/src/identity/subscriptionEntSync.ts +97 -0
- package/src/identity/veramoDidComm.ts +52 -2
- package/src/identity/webvh.ts +4 -4
- package/src/identity/webvhRelocation.ts +167 -0
- package/src/index.ts +119 -25
- package/src/logging.ts +8 -14
- package/src/oauth/OAuthService.ts +11 -3
- package/src/policyConfigFromJson.ts +131 -0
- package/src/runMcp.ts +30 -0
- package/src/server.ts +79 -26
- package/src/subtreeWrangler.ts +278 -0
- package/src/uiChannelPolicies.ts +15 -0
- package/krl/io.picolabs.did-o.krl +0 -349
|
@@ -5,7 +5,7 @@ ruleset io.picolabs.subscription {
|
|
|
5
5
|
Pico-to-pico relationships (Tx/Rx). User-facing term: relationship.
|
|
6
6
|
Ruleset RID io.picolabs.subscription is stable; prefer module alias relationship.
|
|
7
7
|
>>
|
|
8
|
-
author "
|
|
8
|
+
author "Picolabs"
|
|
9
9
|
use module io.picolabs.wrangler alias wrangler
|
|
10
10
|
provides established, outbound, inbound, wellKnown_Rx, autoAcceptConfig, queryOnSub
|
|
11
11
|
shares established, outbound, inbound, wellKnown_Rx, autoAcceptConfig, queryOnSub
|
|
@@ -13,42 +13,7 @@ ruleset io.picolabs.subscription {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
global{
|
|
16
|
-
|
|
17
|
-
.put("queries",__testing.get("queries").map(function(q){
|
|
18
|
-
q.delete("args")
|
|
19
|
-
}))
|
|
20
|
-
.put("events",[
|
|
21
|
-
{ "domain": "wrangler", "name": "subscription",
|
|
22
|
-
"attrs": [ "wellKnown_Tx","Rx_role","Tx_role","name","channel_type","Tx_host","password"] },
|
|
23
|
-
{ "domain": "wrangler", "name": "subscription",
|
|
24
|
-
"attrs": [ "wellKnown_Tx","Rx_role","Tx_role","name","channel_type","password"] },
|
|
25
|
-
{ "domain": "wrangler", "name": "subscription",
|
|
26
|
-
"attrs": [ "wellKnown_Tx","password"] },
|
|
27
|
-
{ "domain": "wrangler", "name": "subscription",
|
|
28
|
-
"attrs": [ "wellKnown_Tx"] },
|
|
29
|
-
{ "domain": "wrangler", "name": "relationship",
|
|
30
|
-
"attrs": [ "wellKnown_Tx","Rx_role","Tx_role","name","channel_type","Tx_host","password","layer2","target_did"] },
|
|
31
|
-
{ "domain": "wrangler", "name": "pending_subscription_approval",
|
|
32
|
-
"attrs": [ "Id" ] },
|
|
33
|
-
{ "domain": "wrangler", "name": "pending_relationship_approval",
|
|
34
|
-
"attrs": [ "Id" ] },
|
|
35
|
-
{ "domain": "wrangler", "name": "subscription_cancellation",
|
|
36
|
-
"attrs": [ "Id" ] },
|
|
37
|
-
{ "domain": "wrangler", "name": "relationship_cancellation",
|
|
38
|
-
"attrs": [ "Id" ] },
|
|
39
|
-
{ "domain": "wrangler", "name": "inbound_rejection",
|
|
40
|
-
"attrs": [ "Id" ] },
|
|
41
|
-
{ "domain": "wrangler", "name": "inbound_relationship_rejection",
|
|
42
|
-
"attrs": [ "Id" ] },
|
|
43
|
-
{ "domain": "wrangler", "name": "outbound_cancellation",
|
|
44
|
-
"attrs": [ "Id" ] },
|
|
45
|
-
{ "domain": "wrangler", "name": "outbound_relationship_cancellation",
|
|
46
|
-
"attrs": [ "Id" ] },
|
|
47
|
-
{ "domain": "wrangler", "name": "autoAcceptConfigUpdate",
|
|
48
|
-
"attrs": [ "configName", "password", "regexMap","delete" ] },
|
|
49
|
-
{ "domain": "wrangler", "name": "intent_to_delete",
|
|
50
|
-
"attrs": [ "Id" ] },
|
|
51
|
-
])
|
|
16
|
+
|
|
52
17
|
/*
|
|
53
18
|
ent:inbound [
|
|
54
19
|
{
|
|
@@ -100,6 +65,12 @@ ent:established [
|
|
|
100
65
|
"allow": [{"rid": ctx:rid, "name": "wellKnown_Rx"}],
|
|
101
66
|
"deny": []
|
|
102
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Auto-accept rules for incoming relationship requests, keyed by config name.
|
|
70
|
+
* A request is accepted automatically when any config's entries match: each
|
|
71
|
+
* entry maps an attr name to a list of regexes tested against that attr.
|
|
72
|
+
* @returns Map "{ <configName>: { configName, password, entries: { <attr>: [regex, …] } } }"
|
|
73
|
+
*/
|
|
103
74
|
autoAcceptConfig = function(){
|
|
104
75
|
ent:autoAcceptConfig.defaultsTo({})
|
|
105
76
|
}
|
|
@@ -110,13 +81,43 @@ ent:established [
|
|
|
110
81
|
doesntExist || passwordMatched
|
|
111
82
|
}
|
|
112
83
|
|
|
113
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Established relationships, optionally only those whose field `key` equals
|
|
86
|
+
* `value` (e.g. key "Tx_role", value "manifold_thing"). Each has Id, Rx (this
|
|
87
|
+
* pico's channel), Tx (the other pico's channel), roles, name, and, for Layer 2
|
|
88
|
+
* relationships, layer2 and the peer DIDs.
|
|
89
|
+
* @param key String "field to filter on, e.g. Id, Tx_role, Rx_role"
|
|
90
|
+
* @param value Any "value the field must equal"
|
|
91
|
+
* @returns Array
|
|
92
|
+
* @example "all" {}
|
|
93
|
+
* @example "by role" { "key": "Tx_role", "value": "<their role>" }
|
|
94
|
+
*/
|
|
95
|
+
established = function(key = null, value = null){
|
|
114
96
|
filterOn(ent:established, key, value)
|
|
115
97
|
}
|
|
116
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Relationship requests this pico has sent that are still waiting for the other
|
|
100
|
+
* side to approve. Optional filter as for established().
|
|
101
|
+
* @param key String "field to filter on"
|
|
102
|
+
* @param value Any "value the field must equal"
|
|
103
|
+
* @returns Array
|
|
104
|
+
* @example "all" {}
|
|
105
|
+
* @example "by id" { "key": "Id", "value": "<relationship id>" }
|
|
106
|
+
*/
|
|
107
|
+
outbound = function(key = null, value = null){//Tx_Pending
|
|
117
108
|
filterOn(ent:outbound, key, value)
|
|
118
109
|
}
|
|
119
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Relationship requests other picos have sent to this one that are waiting for
|
|
112
|
+
* approval (approve with wrangler:pending_relationship_approval). Optional filter
|
|
113
|
+
* as for established().
|
|
114
|
+
* @param key String "field to filter on"
|
|
115
|
+
* @param value Any "value the field must equal"
|
|
116
|
+
* @returns Array
|
|
117
|
+
* @example "all" {}
|
|
118
|
+
* @example "by id" { "key": "Id", "value": "<relationship id>" }
|
|
119
|
+
*/
|
|
120
|
+
inbound = function(key = null, value = null){//Rx_Pending
|
|
120
121
|
filterOn(ent:inbound, key, value)
|
|
121
122
|
}
|
|
122
123
|
|
|
@@ -127,27 +128,24 @@ ent:established [
|
|
|
127
128
|
|| ent:outbound.defaultsTo([]).length() > 0
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
@param [key], key in the map to filter on
|
|
133
|
-
@param [value], the value at the given key to filter on
|
|
134
|
-
@return an array of maps that contain the given key/value pair (if provided) from the array, defaulting to the original array if the key/value pair was not provided
|
|
135
|
-
*/
|
|
131
|
+
// The maps in array whose field key equals value. Returns the whole array
|
|
132
|
+
// (or [] if array is null) when key or value is not given.
|
|
136
133
|
filterOn = function(array, key, value){
|
|
137
134
|
defaultedArray = array.defaultsTo([]);
|
|
138
135
|
(key && value) => defaultedArray.filter(function(bus){ bus{key} == value}) | defaultedArray
|
|
139
136
|
}
|
|
140
137
|
|
|
138
|
+
/**
|
|
139
|
+
* This pico's well-known channel: the one other picos send relationship requests
|
|
140
|
+
* to (give its id as wellKnown_Tx when requesting a relationship with this pico).
|
|
141
|
+
* @returns Map "the channel, including its id"
|
|
142
|
+
*/
|
|
141
143
|
wellKnown_Rx = function(){
|
|
142
144
|
tags = ["wellKnown_Rx","Tx_Rx"]
|
|
143
145
|
return wrangler:channels(tags).head()
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
@param buses, an array of subscriptions
|
|
148
|
-
@param Id, a subscription id
|
|
149
|
-
@return the index of the subscription in the array with the given id. -1 if it does not exist
|
|
150
|
-
*/
|
|
148
|
+
// Index of the relationship with this Id in buses, or -1 if none has it.
|
|
151
149
|
indexOfId = function(buses, Id) {
|
|
152
150
|
buses.map(function(bus){
|
|
153
151
|
bus{"Id"}
|
|
@@ -162,8 +160,15 @@ ent:established [
|
|
|
162
160
|
}
|
|
163
161
|
|
|
164
162
|
/**
|
|
165
|
-
* Query a function on
|
|
166
|
-
* Layer 2
|
|
163
|
+
* Query a function on the pico at the other end of an established relationship.
|
|
164
|
+
* Layer 2 relationships go over DIDComm (or verified local dispatch); legacy ones
|
|
165
|
+
* query the other pico's Tx channel. Null if no relationship has that id.
|
|
166
|
+
* @param subId String "relationship id"
|
|
167
|
+
* @param rid String "ruleset id on the other pico"
|
|
168
|
+
* @param name String "shared function to call"
|
|
169
|
+
* @param args Map "arguments for the function"
|
|
170
|
+
* @returns Any "the function's result"
|
|
171
|
+
* @example "other pico's name" { "subId": "<relationship id>", "rid": "io.picolabs.wrangler", "name": "name" }
|
|
167
172
|
*/
|
|
168
173
|
queryOnSub = function(subId, rid, name, args) {
|
|
169
174
|
bus = established("Id", subId).head()
|
|
@@ -184,8 +189,11 @@ ent:established [
|
|
|
184
189
|
} | {};
|
|
185
190
|
_roles = event:attr("Tx_host") => // add possible host
|
|
186
191
|
roles.put(["Tx_host"] , host) | roles;
|
|
187
|
-
event:attr("Id") => // add subscription identifier
|
|
188
|
-
_roles.put(["Id"], event:attr("Id")) | _roles.put(["Id"], random:uuid())
|
|
192
|
+
withId = event:attr("Id") => // add subscription identifier
|
|
193
|
+
_roles.put(["Id"], event:attr("Id")) | _roles.put(["Id"], random:uuid());
|
|
194
|
+
// Manifold (and other apps) pass registry keys on wrangler:subscription; keep them on the bus.
|
|
195
|
+
picoID = event:attr("picoID");
|
|
196
|
+
picoID.isnull() == false && picoID != "" => withId.put("picoID", picoID) | withId
|
|
189
197
|
}
|
|
190
198
|
|
|
191
199
|
doesConfigMatch = function(config) {
|
|
@@ -249,6 +257,11 @@ ent:established [
|
|
|
249
257
|
}
|
|
250
258
|
}
|
|
251
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Cancel every relationship this pico has: established ones are cancelled,
|
|
262
|
+
* inbound requests rejected, and outbound requests withdrawn, notifying the other
|
|
263
|
+
* picos. Used before deleting a pico.
|
|
264
|
+
*/
|
|
252
265
|
rule cancel_all_subscriptions {
|
|
253
266
|
select when wrangler cancel_subscriptions
|
|
254
267
|
pre {
|
|
@@ -321,6 +334,30 @@ ent:established [
|
|
|
321
334
|
//START OF A SUBSCRIPTION'S CREATION
|
|
322
335
|
//For the following comments, consider picoA sending the request to picoB
|
|
323
336
|
|
|
337
|
+
/**
|
|
338
|
+
* Request a relationship with another pico. Legacy (default): give the other
|
|
339
|
+
* pico's well-known channel as wellKnown_Tx. Layer 2: set layer2 true and give the
|
|
340
|
+
* other pico's DID as target_did; the request goes over DIDComm. The request is
|
|
341
|
+
* recorded in outbound() until the other side approves (or auto-accepts), then
|
|
342
|
+
* moves to established() and wrangler:subscription_added is raised. A request to
|
|
343
|
+
* this pico itself, or one missing wellKnown_Tx / target_did, raises
|
|
344
|
+
* self_relationship_failure, wellKnown_Tx_format_failure, or
|
|
345
|
+
* target_did_format_failure instead.
|
|
346
|
+
* @attr wellKnown_Tx String optional "legacy: the other pico's well-known channel id (its wellKnown_Rx)"
|
|
347
|
+
* @attr layer2 Boolean optional "true for a DID-based Layer 2 relationship"
|
|
348
|
+
* @attr target_did String optional "Layer 2: the other pico's DID"
|
|
349
|
+
* @attr name String optional "relationship name (random word if omitted)"
|
|
350
|
+
* @attr Rx_role String optional "this pico's role in the relationship"
|
|
351
|
+
* @attr Tx_role String optional "the other pico's role"
|
|
352
|
+
* @attr channel_type String optional "channel type for the new channel (default Tx_Rx)"
|
|
353
|
+
* @attr Tx_host String optional "legacy: the other pico's engine URL, if on a different engine"
|
|
354
|
+
* @attr password String optional "for the other pico's auto-accept config"
|
|
355
|
+
* @example "same engine" { "wellKnown_Tx": "<eci>" }
|
|
356
|
+
* @example "same engine, with roles" { "wellKnown_Tx": "<eci>", "name": "<name>", "Rx_role": "<my role>", "Tx_role": "<their role>" }
|
|
357
|
+
* @example "another engine" { "wellKnown_Tx": "<eci>", "Tx_host": "https://other.example" }
|
|
358
|
+
* @example "auto-accept password" { "wellKnown_Tx": "<eci>", "password": "<password>" }
|
|
359
|
+
* @example "Layer 2" { "layer2": true, "target_did": "<did>" }
|
|
360
|
+
*/
|
|
324
361
|
rule createRxBus {
|
|
325
362
|
select when wrangler subscription
|
|
326
363
|
or wrangler relationship
|
|
@@ -348,11 +385,15 @@ ent:established [
|
|
|
348
385
|
}
|
|
349
386
|
}//end createMySubscription rule
|
|
350
387
|
|
|
388
|
+
// `where` binds to the event it follows, so each alternative needs its own;
|
|
389
|
+
// with one trailing `where`, every wrangler:subscription matched unguarded.
|
|
351
390
|
rule createRxBusLegacySelfFailure {
|
|
352
391
|
select when wrangler subscription
|
|
392
|
+
where not event:attr("layer2") == true
|
|
393
|
+
&& event:attr("wellKnown_Tx") == wellKnown_Rx(){"id"}
|
|
353
394
|
or wrangler relationship
|
|
354
|
-
|
|
355
|
-
|
|
395
|
+
where not event:attr("layer2") == true
|
|
396
|
+
&& event:attr("wellKnown_Tx") == wellKnown_Rx(){"id"}
|
|
356
397
|
fired {
|
|
357
398
|
raise wrangler event "self_relationship_failure" attributes event:attrs
|
|
358
399
|
}
|
|
@@ -401,9 +442,11 @@ ent:established [
|
|
|
401
442
|
|
|
402
443
|
rule createRxBusLayer2SelfFailure {
|
|
403
444
|
select when wrangler subscription
|
|
445
|
+
where event:attr("layer2") == true
|
|
446
|
+
&& event:attr("target_did") == wrangler:myDid()
|
|
404
447
|
or wrangler relationship
|
|
405
|
-
|
|
406
|
-
|
|
448
|
+
where event:attr("layer2") == true
|
|
449
|
+
&& event:attr("target_did") == wrangler:myDid()
|
|
407
450
|
fired {
|
|
408
451
|
raise wrangler event "self_relationship_failure" attributes event:attrs
|
|
409
452
|
}
|
|
@@ -519,6 +562,15 @@ ent:established [
|
|
|
519
562
|
}
|
|
520
563
|
}
|
|
521
564
|
|
|
565
|
+
/**
|
|
566
|
+
* Approve a pending inbound relationship request (one listed in inbound()). The
|
|
567
|
+
* requesting pico is notified, and both sides raise wrangler:subscription_added
|
|
568
|
+
* once it is established. Works for legacy and Layer 2 requests.
|
|
569
|
+
* @attr Id String optional "relationship id; or identify it by Rx or Tx instead"
|
|
570
|
+
* @attr Rx String optional "this pico's channel for the relationship"
|
|
571
|
+
* @attr Tx String optional "the other pico's channel for the relationship"
|
|
572
|
+
* @example "by id" { "Id": "<relationship id>" }
|
|
573
|
+
*/
|
|
522
574
|
rule approveInboundPendingSubscription {
|
|
523
575
|
select when wrangler pending_subscription_approval
|
|
524
576
|
or wrangler pending_relationship_approval
|
|
@@ -635,6 +687,16 @@ ent:established [
|
|
|
635
687
|
}
|
|
636
688
|
}
|
|
637
689
|
|
|
690
|
+
/**
|
|
691
|
+
* End an established relationship. It is removed on both picos, and the other
|
|
692
|
+
* pico is notified (over DIDComm for Layer 2). wrangler:subscription_removed is
|
|
693
|
+
* raised when done.
|
|
694
|
+
* @attr Id String optional "relationship id; or identify it by Rx or Tx instead"
|
|
695
|
+
* @attr Rx String optional "this pico's channel for the relationship"
|
|
696
|
+
* @attr Tx String optional "the other pico's channel for the relationship"
|
|
697
|
+
* @example "by id" { "Id": "<relationship id>" }
|
|
698
|
+
* @example "by this pico's channel" { "Rx": "<eci>" }
|
|
699
|
+
*/
|
|
638
700
|
rule cancelEstablished {
|
|
639
701
|
select when wrangler subscription_cancellation
|
|
640
702
|
or wrangler relationship_cancellation
|
|
@@ -691,6 +753,14 @@ ent:established [
|
|
|
691
753
|
}
|
|
692
754
|
}
|
|
693
755
|
|
|
756
|
+
/**
|
|
757
|
+
* Reject a pending inbound relationship request (one listed in inbound()). The
|
|
758
|
+
* requesting pico is notified and removes it from its outbound().
|
|
759
|
+
* @attr Id String optional "relationship id; or identify it by Rx or Tx instead"
|
|
760
|
+
* @attr Rx String optional "this pico's channel for the relationship"
|
|
761
|
+
* @attr Tx String optional "the other pico's channel for the relationship"
|
|
762
|
+
* @example "by id" { "Id": "<relationship id>" }
|
|
763
|
+
*/
|
|
694
764
|
rule cancelInbound {
|
|
695
765
|
select when wrangler inbound_rejection
|
|
696
766
|
or wrangler inbound_relationship_rejection
|
|
@@ -745,6 +815,15 @@ ent:established [
|
|
|
745
815
|
}
|
|
746
816
|
}
|
|
747
817
|
|
|
818
|
+
/**
|
|
819
|
+
* Withdraw a relationship request this pico sent that hasn't been approved yet
|
|
820
|
+
* (one listed in outbound()). The other pico is notified and removes it from its
|
|
821
|
+
* inbound().
|
|
822
|
+
* @attr Id String optional "relationship id; or identify it by Rx or Tx instead"
|
|
823
|
+
* @attr Rx String optional "this pico's channel for the relationship"
|
|
824
|
+
* @attr Tx String optional "the other pico's channel for the relationship"
|
|
825
|
+
* @example "by id" { "Id": "<relationship id>" }
|
|
826
|
+
*/
|
|
748
827
|
rule cancelOutbound {
|
|
749
828
|
select when wrangler outbound_cancellation
|
|
750
829
|
or wrangler outbound_relationship_cancellation
|
|
@@ -783,6 +862,20 @@ ent:established [
|
|
|
783
862
|
}
|
|
784
863
|
}
|
|
785
864
|
|
|
865
|
+
/**
|
|
866
|
+
* Send an event to the picos at the other end of established relationships,
|
|
867
|
+
* selected by relationship id and/or by role. Each match receives the event on
|
|
868
|
+
* its channel (over DIDComm for Layer 2). If nothing matches, or domain or type is
|
|
869
|
+
* missing, raises wrangler:failed_to_send_event_to_relationship instead.
|
|
870
|
+
* @attr domain String "domain of the event to send"
|
|
871
|
+
* @attr type String "type of the event to send"
|
|
872
|
+
* @attr attrs Map optional "attributes of the event to send"
|
|
873
|
+
* @attr subID String optional "send on this relationship"
|
|
874
|
+
* @attr Tx_role String optional "send on every relationship where the other pico has this role"
|
|
875
|
+
* @attr Rx_role String optional "send on every relationship where this pico has this role"
|
|
876
|
+
* @example "one relationship" { "subID": "<relationship id>", "domain": "<domain>", "type": "<type>", "attrs": {} }
|
|
877
|
+
* @example "everyone with a role" { "Tx_role": "<their role>", "domain": "<domain>", "type": "<type>", "attrs": {} }
|
|
878
|
+
*/
|
|
786
879
|
rule sendEventToSubCheck {
|
|
787
880
|
select when wrangler send_event_on_subs
|
|
788
881
|
or wrangler send_event_on_relationships
|
|
@@ -813,6 +906,21 @@ ent:established [
|
|
|
813
906
|
}
|
|
814
907
|
}
|
|
815
908
|
|
|
909
|
+
rule apply_webvh_peer_rotation {
|
|
910
|
+
select when wrangler webvh_peer_rotated
|
|
911
|
+
always {
|
|
912
|
+
subId = event:attr("Id")
|
|
913
|
+
newDid = event:attr("new_webvh_did")
|
|
914
|
+
ent:established := established().map(function(b){
|
|
915
|
+
b{"Id"} == subId => b
|
|
916
|
+
.put(["Tx_host"], event:attr("new_tx_host"))
|
|
917
|
+
.put(["Tx_did"], newDid)
|
|
918
|
+
.put(["layer2"], true)
|
|
919
|
+
| b
|
|
920
|
+
})
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
816
924
|
rule send_event_to_subs {
|
|
817
925
|
select when wrangler send_event_to_subs
|
|
818
926
|
foreach event:attr("subs") setting (sub)
|
|
@@ -862,19 +970,19 @@ ent:established [
|
|
|
862
970
|
}
|
|
863
971
|
|
|
864
972
|
/**
|
|
865
|
-
*
|
|
866
|
-
*
|
|
867
|
-
*
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
*
|
|
877
|
-
*
|
|
973
|
+
* Add, replace, or delete an auto-accept config. An incoming relationship request
|
|
974
|
+
* is approved automatically when, for any config, one of its entries matches:
|
|
975
|
+
* an entry maps an attr name to a list of regexes, and matches when the request's
|
|
976
|
+
* attr matches any of them. Give the whole config as config, or its parts as
|
|
977
|
+
* configName, regexMap, and password. Raises wrangler:auto_accept_config_updated,
|
|
978
|
+
* or autoAcceptConfigUpdate_failure when there is no config name.
|
|
979
|
+
* @attr configName String optional "name of the config to set or delete"
|
|
980
|
+
* @attr regexMap String optional "the entries, JSON-encoded: { <attr>: [regex, …] }"
|
|
981
|
+
* @attr config Map optional "the whole config instead: { configName, password, entries }"
|
|
982
|
+
* @attr password String optional "stored with the config; not currently checked"
|
|
983
|
+
* @attr delete Boolean optional "true to delete the named config"
|
|
984
|
+
* @example "accept a role" { "config": { "configName": "<name>", "entries": { "Tx_role": ["^<role>$"] } } }
|
|
985
|
+
* @example "delete" { "configName": "<name>", "delete": true }
|
|
878
986
|
*/
|
|
879
987
|
rule autoAcceptConfigUpdate {
|
|
880
988
|
select when wrangler autoAcceptConfigUpdate
|