@coasys/ad4m 0.13.1-staging.4 → 0.13.1-staging.5
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/lib/index.cjs +387 -154
- package/lib/index.js +387 -155
- package/lib/src/generated/api/AgentMessage.d.ts +10 -0
- package/lib/src/generated/api/AgentMessage.js +2 -0
- package/lib/src/generated/api/AgentReply.d.ts +9 -0
- package/lib/src/generated/api/AgentReply.js +2 -0
- package/lib/src/generated/api/RpcMethods.d.ts +6 -0
- package/lib/src/generated/api/RpcMethods.js +1 -0
- package/lib/src/generated/api/RunAgentRequest.d.ts +26 -0
- package/lib/src/generated/api/RunAgentRequest.js +1 -0
- package/lib/src/generated/api/index.d.ts +3 -0
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.js +1 -0
- package/lib/src/model/types.d.ts +6 -0
- package/lib/src/neighbourhood/SfuManager.d.ts +15 -0
- package/lib/src/neighbourhood/SfuManager.js +39 -2
- package/lib/src/perspectives/Mentioning.d.ts +37 -0
- package/lib/src/perspectives/Mentioning.js +58 -0
- package/lib/src/perspectives/PerspectiveClient.d.ts +22 -0
- package/lib/src/perspectives/PerspectiveClient.js +13 -0
- package/lib/src/perspectives/PerspectiveProxy.d.ts +19 -0
- package/lib/src/perspectives/PerspectiveProxy.js +19 -0
- package/lib/src/perspectives/TextContent.d.ts +4 -0
- package/lib/src/perspectives/TextContent.js +4 -0
- package/lib/src/perspectives/WakerSubscriptionManager.d.ts +69 -10
- package/lib/src/perspectives/WakerSubscriptionManager.js +160 -58
- package/package.json +2 -2
- package/src/generated/api/AgentMessage.ts +10 -0
- package/src/generated/api/AgentReply.ts +10 -0
- package/src/generated/api/RpcMethods.ts +4 -0
- package/src/generated/api/RunAgentRequest.ts +26 -0
- package/src/generated/api/index.ts +3 -0
- package/src/index.ts +1 -0
- package/src/model/types.ts +6 -0
- package/src/neighbourhood/SfuManager.test.ts +151 -2
- package/src/neighbourhood/SfuManager.ts +38 -1
- package/src/perspectives/Mentioning.test.ts +78 -0
- package/src/perspectives/Mentioning.ts +42 -0
- package/src/perspectives/PerspectiveClient.ts +30 -0
- package/src/perspectives/PerspectiveProxy.ts +26 -0
- package/src/perspectives/TextContent.ts +4 -0
- package/src/perspectives/WakerSubscriptionManager.test.ts +383 -151
- package/src/perspectives/WakerSubscriptionManager.ts +217 -58
package/lib/index.js
CHANGED
|
@@ -105,6 +105,7 @@ const LONG_METHODS = new Set([
|
|
|
105
105
|
"language.publish",
|
|
106
106
|
"neighbourhood.join",
|
|
107
107
|
"neighbourhood.publish",
|
|
108
|
+
"perspective.runAgent",
|
|
108
109
|
"perspective.runInterpretation",
|
|
109
110
|
"perspective.runInterpretationWithHarness",
|
|
110
111
|
"runtime.restartHolochain",
|
|
@@ -1841,6 +1842,8 @@ class SfuManager {
|
|
|
1841
1842
|
this.rosterUnsubscribe = null;
|
|
1842
1843
|
this.dataChannelUnsubscribe = null;
|
|
1843
1844
|
this.disconnectedTimer = null;
|
|
1845
|
+
/** Running while the room's roster leaves this agent out: see `noticeRoster`. */
|
|
1846
|
+
this.unlistedTimer = null;
|
|
1844
1847
|
this.neighbourhood = neighbourhood;
|
|
1845
1848
|
this.neighbourhoodUrl = neighbourhoodUrl || "";
|
|
1846
1849
|
this.roomId = roomId;
|
|
@@ -2127,6 +2130,37 @@ class SfuManager {
|
|
|
2127
2130
|
this.renegotiationUnsubscribe = null;
|
|
2128
2131
|
this.rosterUnsubscribe?.();
|
|
2129
2132
|
this.rosterUnsubscribe = null;
|
|
2133
|
+
this.clearUnlistedTimer();
|
|
2134
|
+
}
|
|
2135
|
+
clearUnlistedTimer() {
|
|
2136
|
+
if (this.unlistedTimer) {
|
|
2137
|
+
clearTimeout(this.unlistedTimer);
|
|
2138
|
+
this.unlistedTimer = null;
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* The room's roster no longer lists this agent while `pc` is the call's:
|
|
2143
|
+
* the server has dropped this session, and ICE may not say so. In E6
|
|
2144
|
+
* (CI job 53158) one of six sessions never started a rebuild after a
|
|
2145
|
+
* 20 s outage the server had dropped it for. Rebuild once the roster has
|
|
2146
|
+
* left this agent out for `UNLISTED_GRACE_MS`; a roster that lists it
|
|
2147
|
+
* again in that time cancels, since one published just before this
|
|
2148
|
+
* join landed can arrive after it.
|
|
2149
|
+
*/
|
|
2150
|
+
noticeRoster(pc, dids) {
|
|
2151
|
+
if (dids.includes(this.agentDid)) {
|
|
2152
|
+
this.clearUnlistedTimer();
|
|
2153
|
+
return;
|
|
2154
|
+
}
|
|
2155
|
+
if (this.unlistedTimer)
|
|
2156
|
+
return;
|
|
2157
|
+
this.unlistedTimer = setTimeout(() => {
|
|
2158
|
+
this.unlistedTimer = null;
|
|
2159
|
+
if (this.state.peerConnection !== pc)
|
|
2160
|
+
return;
|
|
2161
|
+
console.info("SFU: the room no longer lists this session, rebuilding the call");
|
|
2162
|
+
void this.reconnect();
|
|
2163
|
+
}, SfuManager.UNLISTED_GRACE_MS);
|
|
2130
2164
|
}
|
|
2131
2165
|
/** Undo a join that failed part way: its subscription and its connection. */
|
|
2132
2166
|
abandon(pc) {
|
|
@@ -2161,8 +2195,10 @@ class SfuManager {
|
|
|
2161
2195
|
if (!ours(roster) || this.state.peerConnection !== pc)
|
|
2162
2196
|
return;
|
|
2163
2197
|
void joined.then(() => {
|
|
2164
|
-
if (this.state.peerConnection
|
|
2165
|
-
|
|
2198
|
+
if (this.state.peerConnection !== pc)
|
|
2199
|
+
return;
|
|
2200
|
+
this.applyRoster(roster.participants, true);
|
|
2201
|
+
this.noticeRoster(pc, roster.participants);
|
|
2166
2202
|
});
|
|
2167
2203
|
});
|
|
2168
2204
|
for (const unsubscribe of previous)
|
|
@@ -2376,6 +2412,8 @@ SfuManager.MAX_RECONNECTS = 3;
|
|
|
2376
2412
|
SfuManager.REJOIN_WINDOW_MS = 120000;
|
|
2377
2413
|
/** How long ICE may stay disconnected before a rebuild: the executor's `ICE_DISCONNECT_GRACE`. */
|
|
2378
2414
|
SfuManager.DISCONNECT_GRACE_MS = 10000;
|
|
2415
|
+
/** How long the roster may leave this agent out before the call is rebuilt. */
|
|
2416
|
+
SfuManager.UNLISTED_GRACE_MS = 3000;
|
|
2379
2417
|
|
|
2380
2418
|
/**
|
|
2381
2419
|
* Peer-to-peer WebRTC mesh transport for the AD4M SDK Session interface.
|
|
@@ -7879,6 +7917,19 @@ class PerspectiveProxy {
|
|
|
7879
7917
|
observationId, emitDebugEvents, options) {
|
|
7880
7918
|
return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").runInterpretationWithHarness(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, maxToolCalls, classes, modelOverride, undefined, observationId, emitDebugEvents, options);
|
|
7881
7919
|
}
|
|
7920
|
+
/**
|
|
7921
|
+
* Ask a model something about this perspective, or ask it to change something, with the
|
|
7922
|
+
* executor's own tools — including the tools apps install for their records. It reads freely;
|
|
7923
|
+
* it writes only with the tools named in `settings.writeTools`, as you. Answers with the
|
|
7924
|
+
* model's final reply.
|
|
7925
|
+
*
|
|
7926
|
+
* @param messages the conversation so far, the person's request last
|
|
7927
|
+
* @param settings `context` (what the person is looking at), `writeTools`, `model`, `maxToolCalls`
|
|
7928
|
+
* @param options `signal` / `timeoutMs` (default {@link LONG_TIMEOUT_MS})
|
|
7929
|
+
*/
|
|
7930
|
+
async runAgent(messages, settings, options) {
|
|
7931
|
+
return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").runAgent(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, messages, settings, options);
|
|
7932
|
+
}
|
|
7882
7933
|
/**
|
|
7883
7934
|
* Register a neighbourhood auto-processor on this perspective. The executor
|
|
7884
7935
|
* then runs interpretation automatically over new source items (like Flux
|
|
@@ -8253,6 +8304,12 @@ class PerspectiveProxy {
|
|
|
8253
8304
|
/**
|
|
8254
8305
|
* Adds a pre-signed LinkExpression to the perspective.
|
|
8255
8306
|
*
|
|
8307
|
+
* The executor checks the signature against `link.author` and stores the
|
|
8308
|
+
* verdict as `proof.valid`. If the same link (author, source, predicate,
|
|
8309
|
+
* target and timestamp) is already stored with a signature that verifies,
|
|
8310
|
+
* its stored proof is kept. The expression passed here is still returned
|
|
8311
|
+
* and, when Shared, committed to the neighbourhood as given.
|
|
8312
|
+
*
|
|
8256
8313
|
* @param link - The signed LinkExpression to add
|
|
8257
8314
|
* @param status - Whether the link should be shared
|
|
8258
8315
|
* @param batchId - Optional batch ID to group this operation with others
|
|
@@ -9769,6 +9826,19 @@ class PerspectiveClient {
|
|
|
9769
9826
|
emitDebugEvents,
|
|
9770
9827
|
}, options);
|
|
9771
9828
|
}
|
|
9829
|
+
/**
|
|
9830
|
+
* A conversation with a model in this perspective, using the executor's own tools: the tools
|
|
9831
|
+
* that read this perspective, and only the writing tools named in `writeTools`. Every tool a
|
|
9832
|
+
* session offers acts on this perspective alone, so tools about other perspectives, the agent
|
|
9833
|
+
* or the node (listing or publishing perspectives, the profile) are not available. Runs as the
|
|
9834
|
+
* caller, with the caller's capabilities, and answers with the model's final reply.
|
|
9835
|
+
*
|
|
9836
|
+
* Defaults to {@link LONG_TIMEOUT_MS}: an agent may read documentation and make many tool
|
|
9837
|
+
* calls before it answers.
|
|
9838
|
+
*/
|
|
9839
|
+
async runAgent(uuid, messages, settings, options) {
|
|
9840
|
+
return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.runAgent', { uuid, messages, ...settings }, options);
|
|
9841
|
+
}
|
|
9772
9842
|
/**
|
|
9773
9843
|
* Register a neighbourhood auto-processor on this perspective. The executor's
|
|
9774
9844
|
* watch loop then runs interpretation automatically over new source items
|
|
@@ -21835,13 +21905,13 @@ class LanguageLanguageInput {
|
|
|
21835
21905
|
* const runs = await InterpretationRun.findAll(perspective);
|
|
21836
21906
|
* const configs = await AutoProcessorConfig.findAll(perspective);
|
|
21837
21907
|
*/
|
|
21838
|
-
var __decorate$
|
|
21908
|
+
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
21839
21909
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
21840
21910
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21841
21911
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21842
21912
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21843
21913
|
};
|
|
21844
|
-
var __metadata$
|
|
21914
|
+
var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) {
|
|
21845
21915
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
21846
21916
|
};
|
|
21847
21917
|
// ── AutoProcessorConfig ─────────────────────────────────────────────────────
|
|
@@ -21882,71 +21952,71 @@ let AutoProcessorConfig = class AutoProcessorConfig extends Ad4mModel {
|
|
|
21882
21952
|
// `batchMax` + `claimTtlMs` — the Rust SDNA takes the same shape.
|
|
21883
21953
|
}
|
|
21884
21954
|
};
|
|
21885
|
-
__decorate$
|
|
21955
|
+
__decorate$4([
|
|
21886
21956
|
Property({ through: "ad4m://processor_id", required: true, identity: true }),
|
|
21887
|
-
__metadata$
|
|
21957
|
+
__metadata$4("design:type", String)
|
|
21888
21958
|
], AutoProcessorConfig.prototype, "processorId", void 0);
|
|
21889
|
-
__decorate$
|
|
21959
|
+
__decorate$4([
|
|
21890
21960
|
Property({ through: "ad4m://source_scope_query", required: true }),
|
|
21891
|
-
__metadata$
|
|
21961
|
+
__metadata$4("design:type", String)
|
|
21892
21962
|
], AutoProcessorConfig.prototype, "sourceScopeQuery", void 0);
|
|
21893
|
-
__decorate$
|
|
21963
|
+
__decorate$4([
|
|
21894
21964
|
Optional({ through: "ad4m://base_prefix" }),
|
|
21895
|
-
__metadata$
|
|
21965
|
+
__metadata$4("design:type", String)
|
|
21896
21966
|
], AutoProcessorConfig.prototype, "basePrefix", void 0);
|
|
21897
|
-
__decorate$
|
|
21967
|
+
__decorate$4([
|
|
21898
21968
|
HasMany({ through: "ad4m://interpretation_class", datatype: "xsd:string" }),
|
|
21899
|
-
__metadata$
|
|
21969
|
+
__metadata$4("design:type", Array)
|
|
21900
21970
|
], AutoProcessorConfig.prototype, "interpretationClasses", void 0);
|
|
21901
|
-
__decorate$
|
|
21971
|
+
__decorate$4([
|
|
21902
21972
|
HasMany({ through: "ad4m://flow", datatype: "xsd:string" }),
|
|
21903
|
-
__metadata$
|
|
21973
|
+
__metadata$4("design:type", Array)
|
|
21904
21974
|
], AutoProcessorConfig.prototype, "flows", void 0);
|
|
21905
|
-
__decorate$
|
|
21975
|
+
__decorate$4([
|
|
21906
21976
|
Property({ through: "ad4m://debounce_ms", required: true }),
|
|
21907
|
-
__metadata$
|
|
21977
|
+
__metadata$4("design:type", String)
|
|
21908
21978
|
], AutoProcessorConfig.prototype, "debounceMs", void 0);
|
|
21909
|
-
__decorate$
|
|
21979
|
+
__decorate$4([
|
|
21910
21980
|
Optional({ through: "ad4m://batch_min" }),
|
|
21911
|
-
__metadata$
|
|
21981
|
+
__metadata$4("design:type", String)
|
|
21912
21982
|
], AutoProcessorConfig.prototype, "batchMin", void 0);
|
|
21913
|
-
__decorate$
|
|
21983
|
+
__decorate$4([
|
|
21914
21984
|
Property({ through: "ad4m://batch_max", required: true }),
|
|
21915
|
-
__metadata$
|
|
21985
|
+
__metadata$4("design:type", String)
|
|
21916
21986
|
], AutoProcessorConfig.prototype, "batchMax", void 0);
|
|
21917
|
-
__decorate$
|
|
21987
|
+
__decorate$4([
|
|
21918
21988
|
Optional({ through: "ad4m://max_wait_ms" }),
|
|
21919
|
-
__metadata$
|
|
21989
|
+
__metadata$4("design:type", String)
|
|
21920
21990
|
], AutoProcessorConfig.prototype, "maxWaitMs", void 0);
|
|
21921
|
-
__decorate$
|
|
21991
|
+
__decorate$4([
|
|
21922
21992
|
Property({ through: "ad4m://claim_ttl_ms", required: true }),
|
|
21923
|
-
__metadata$
|
|
21993
|
+
__metadata$4("design:type", String)
|
|
21924
21994
|
], AutoProcessorConfig.prototype, "claimTtlMs", void 0);
|
|
21925
|
-
__decorate$
|
|
21995
|
+
__decorate$4([
|
|
21926
21996
|
Optional({ through: "ad4m://source_window_ms" }),
|
|
21927
|
-
__metadata$
|
|
21997
|
+
__metadata$4("design:type", String)
|
|
21928
21998
|
], AutoProcessorConfig.prototype, "sourceWindowMs", void 0);
|
|
21929
|
-
__decorate$
|
|
21999
|
+
__decorate$4([
|
|
21930
22000
|
Optional({ through: "ad4m://dedup_strategy" }),
|
|
21931
|
-
__metadata$
|
|
22001
|
+
__metadata$4("design:type", String)
|
|
21932
22002
|
], AutoProcessorConfig.prototype, "dedupStrategy", void 0);
|
|
21933
|
-
__decorate$
|
|
22003
|
+
__decorate$4([
|
|
21934
22004
|
Optional({ through: "ad4m://existing_scope" }),
|
|
21935
|
-
__metadata$
|
|
22005
|
+
__metadata$4("design:type", String)
|
|
21936
22006
|
], AutoProcessorConfig.prototype, "existingScope", void 0);
|
|
21937
|
-
__decorate$
|
|
22007
|
+
__decorate$4([
|
|
21938
22008
|
Optional({ through: "ad4m://mint_scope" }),
|
|
21939
|
-
__metadata$
|
|
22009
|
+
__metadata$4("design:type", String)
|
|
21940
22010
|
], AutoProcessorConfig.prototype, "mintScope", void 0);
|
|
21941
|
-
__decorate$
|
|
22011
|
+
__decorate$4([
|
|
21942
22012
|
Optional({ through: "ad4m://max_tool_calls" }),
|
|
21943
|
-
__metadata$
|
|
22013
|
+
__metadata$4("design:type", String)
|
|
21944
22014
|
], AutoProcessorConfig.prototype, "maxToolCalls", void 0);
|
|
21945
|
-
__decorate$
|
|
22015
|
+
__decorate$4([
|
|
21946
22016
|
Optional({ through: "ad4m://emit_debug_events", resolveLanguage: "literal" }),
|
|
21947
|
-
__metadata$
|
|
22017
|
+
__metadata$4("design:type", String)
|
|
21948
22018
|
], AutoProcessorConfig.prototype, "emitDebugEvents", void 0);
|
|
21949
|
-
AutoProcessorConfig = __decorate$
|
|
22019
|
+
AutoProcessorConfig = __decorate$4([
|
|
21950
22020
|
Model$1({ name: "AutoProcessor" })
|
|
21951
22021
|
], AutoProcessorConfig);
|
|
21952
22022
|
// ── InterpretationRun ───────────────────────────────────────────────────────
|
|
@@ -21970,39 +22040,39 @@ let InterpretationRun = class InterpretationRun extends Ad4mModel {
|
|
|
21970
22040
|
this.sources = [];
|
|
21971
22041
|
}
|
|
21972
22042
|
};
|
|
21973
|
-
__decorate$
|
|
22043
|
+
__decorate$4([
|
|
21974
22044
|
Property({ through: "ad4m://interp/run_id", required: true, identity: true }),
|
|
21975
|
-
__metadata$
|
|
22045
|
+
__metadata$4("design:type", String)
|
|
21976
22046
|
], InterpretationRun.prototype, "runId", void 0);
|
|
21977
|
-
__decorate$
|
|
22047
|
+
__decorate$4([
|
|
21978
22048
|
Optional({ through: "ad4m://interp/model" }),
|
|
21979
|
-
__metadata$
|
|
22049
|
+
__metadata$4("design:type", String)
|
|
21980
22050
|
], InterpretationRun.prototype, "model", void 0);
|
|
21981
|
-
__decorate$
|
|
22051
|
+
__decorate$4([
|
|
21982
22052
|
Optional({ through: "ad4m://interp/prompt_version" }),
|
|
21983
|
-
__metadata$
|
|
22053
|
+
__metadata$4("design:type", String)
|
|
21984
22054
|
], InterpretationRun.prototype, "promptVersion", void 0);
|
|
21985
|
-
__decorate$
|
|
22055
|
+
__decorate$4([
|
|
21986
22056
|
Optional({ through: "ad4m://interp/ran_at" }),
|
|
21987
|
-
__metadata$
|
|
22057
|
+
__metadata$4("design:type", String)
|
|
21988
22058
|
], InterpretationRun.prototype, "ranAt", void 0);
|
|
21989
|
-
__decorate$
|
|
22059
|
+
__decorate$4([
|
|
21990
22060
|
Optional({ through: "ad4m://interp/processor" }),
|
|
21991
|
-
__metadata$
|
|
22061
|
+
__metadata$4("design:type", String)
|
|
21992
22062
|
], InterpretationRun.prototype, "processor", void 0);
|
|
21993
|
-
__decorate$
|
|
22063
|
+
__decorate$4([
|
|
21994
22064
|
HasMany({ through: "ad4m://interp/sources", datatype: "xsd:string" }),
|
|
21995
|
-
__metadata$
|
|
22065
|
+
__metadata$4("design:type", Array)
|
|
21996
22066
|
], InterpretationRun.prototype, "sources", void 0);
|
|
21997
|
-
__decorate$
|
|
22067
|
+
__decorate$4([
|
|
21998
22068
|
Optional({ through: "ad4m://interp/debug_prompt", resolveLanguage: "literal" }),
|
|
21999
|
-
__metadata$
|
|
22069
|
+
__metadata$4("design:type", String)
|
|
22000
22070
|
], InterpretationRun.prototype, "debugPrompt", void 0);
|
|
22001
|
-
__decorate$
|
|
22071
|
+
__decorate$4([
|
|
22002
22072
|
Optional({ through: "ad4m://interp/debug_response", resolveLanguage: "literal" }),
|
|
22003
|
-
__metadata$
|
|
22073
|
+
__metadata$4("design:type", String)
|
|
22004
22074
|
], InterpretationRun.prototype, "debugResponse", void 0);
|
|
22005
|
-
InterpretationRun = __decorate$
|
|
22075
|
+
InterpretationRun = __decorate$4([
|
|
22006
22076
|
Model$1({ name: "InterpretationRun" })
|
|
22007
22077
|
], InterpretationRun);
|
|
22008
22078
|
// ── InterpretationOverlay ───────────────────────────────────────────────────
|
|
@@ -22032,15 +22102,15 @@ let InterpretationOverlay = class InterpretationOverlay extends Ad4mModel {
|
|
|
22032
22102
|
this.kind = "";
|
|
22033
22103
|
}
|
|
22034
22104
|
};
|
|
22035
|
-
__decorate$
|
|
22105
|
+
__decorate$4([
|
|
22036
22106
|
Property({ through: "ad4m://interp/kind", required: true }),
|
|
22037
|
-
__metadata$
|
|
22107
|
+
__metadata$4("design:type", String)
|
|
22038
22108
|
], InterpretationOverlay.prototype, "kind", void 0);
|
|
22039
|
-
__decorate$
|
|
22109
|
+
__decorate$4([
|
|
22040
22110
|
Optional({ through: "ad4m://interp/run" }),
|
|
22041
|
-
__metadata$
|
|
22111
|
+
__metadata$4("design:type", String)
|
|
22042
22112
|
], InterpretationOverlay.prototype, "run", void 0);
|
|
22043
|
-
InterpretationOverlay = __decorate$
|
|
22113
|
+
InterpretationOverlay = __decorate$4([
|
|
22044
22114
|
Model$1({ name: "InterpretationOverlay" })
|
|
22045
22115
|
], InterpretationOverlay);
|
|
22046
22116
|
|
|
@@ -22064,13 +22134,13 @@ InterpretationOverlay = __decorate$3([
|
|
|
22064
22134
|
* - the SDNA-parity test locks TS/Rust drift against
|
|
22065
22135
|
* `rust-executor/src/perspectives/hardwired_sdna/flow_transition_proposal.json`.
|
|
22066
22136
|
*/
|
|
22067
|
-
var __decorate$
|
|
22137
|
+
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
22068
22138
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22069
22139
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
22070
22140
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22071
22141
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22072
22142
|
};
|
|
22073
|
-
var __metadata$
|
|
22143
|
+
var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) {
|
|
22074
22144
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22075
22145
|
};
|
|
22076
22146
|
/**
|
|
@@ -22177,55 +22247,55 @@ let FlowTransitionProposal = class FlowTransitionProposal extends Ad4mModel {
|
|
|
22177
22247
|
// of the proposal's own links (all written together during create_subject).
|
|
22178
22248
|
}
|
|
22179
22249
|
};
|
|
22180
|
-
__decorate$
|
|
22250
|
+
__decorate$3([
|
|
22181
22251
|
Property({ through: "ad4m://flow/instance", required: true, identity: true }),
|
|
22182
|
-
__metadata$
|
|
22252
|
+
__metadata$3("design:type", String)
|
|
22183
22253
|
], FlowTransitionProposal.prototype, "flowInstance", void 0);
|
|
22184
|
-
__decorate$
|
|
22254
|
+
__decorate$3([
|
|
22185
22255
|
Property({ through: "ad4m://flow/from_state", required: true }),
|
|
22186
|
-
__metadata$
|
|
22256
|
+
__metadata$3("design:type", String)
|
|
22187
22257
|
], FlowTransitionProposal.prototype, "fromState", void 0);
|
|
22188
|
-
__decorate$
|
|
22258
|
+
__decorate$3([
|
|
22189
22259
|
Property({ through: "ad4m://flow/to_state", required: true }),
|
|
22190
|
-
__metadata$
|
|
22260
|
+
__metadata$3("design:type", String)
|
|
22191
22261
|
], FlowTransitionProposal.prototype, "toState", void 0);
|
|
22192
|
-
__decorate$
|
|
22262
|
+
__decorate$3([
|
|
22193
22263
|
Property({ through: "ad4m://flow/proposer", required: true, getter: PROPOSER_GETTER, datatype: "xsd:string" }),
|
|
22194
|
-
__metadata$
|
|
22264
|
+
__metadata$3("design:type", String)
|
|
22195
22265
|
], FlowTransitionProposal.prototype, "proposer", void 0);
|
|
22196
|
-
__decorate$
|
|
22266
|
+
__decorate$3([
|
|
22197
22267
|
HasMany({ through: "ad4m://flow/evidence", datatype: "xsd:string" }),
|
|
22198
|
-
__metadata$
|
|
22268
|
+
__metadata$3("design:type", Array)
|
|
22199
22269
|
], FlowTransitionProposal.prototype, "evidence", void 0);
|
|
22200
|
-
__decorate$
|
|
22270
|
+
__decorate$3([
|
|
22201
22271
|
Property({ through: "ad4m://flow/evidence_hashes", required: true }),
|
|
22202
|
-
__metadata$
|
|
22272
|
+
__metadata$3("design:type", String)
|
|
22203
22273
|
], FlowTransitionProposal.prototype, "evidenceHashes", void 0);
|
|
22204
|
-
__decorate$
|
|
22274
|
+
__decorate$3([
|
|
22205
22275
|
HasMany({ through: "ad4m://flow/output", datatype: "xsd:string" }),
|
|
22206
|
-
__metadata$
|
|
22276
|
+
__metadata$3("design:type", Array)
|
|
22207
22277
|
], FlowTransitionProposal.prototype, "outputs", void 0);
|
|
22208
|
-
__decorate$
|
|
22278
|
+
__decorate$3([
|
|
22209
22279
|
Property({ through: "ad4m://flow/outputs_hash" }),
|
|
22210
|
-
__metadata$
|
|
22280
|
+
__metadata$3("design:type", String)
|
|
22211
22281
|
], FlowTransitionProposal.prototype, "outputsHash", void 0);
|
|
22212
|
-
__decorate$
|
|
22282
|
+
__decorate$3([
|
|
22213
22283
|
Property({ through: "ad4m://flow/nonce" }),
|
|
22214
|
-
__metadata$
|
|
22284
|
+
__metadata$3("design:type", String)
|
|
22215
22285
|
], FlowTransitionProposal.prototype, "nonce", void 0);
|
|
22216
|
-
__decorate$
|
|
22286
|
+
__decorate$3([
|
|
22217
22287
|
Optional({ through: "ad4m://flow/run_uri" }),
|
|
22218
|
-
__metadata$
|
|
22288
|
+
__metadata$3("design:type", String)
|
|
22219
22289
|
], FlowTransitionProposal.prototype, "runUri", void 0);
|
|
22220
|
-
__decorate$
|
|
22290
|
+
__decorate$3([
|
|
22221
22291
|
Optional({ through: "ad4m://flow/rationale" }),
|
|
22222
|
-
__metadata$
|
|
22292
|
+
__metadata$3("design:type", String)
|
|
22223
22293
|
], FlowTransitionProposal.prototype, "rationale", void 0);
|
|
22224
|
-
__decorate$
|
|
22294
|
+
__decorate$3([
|
|
22225
22295
|
HasMany({ through: "ad4m://acceptedBy", getter: ACCEPTED_BY_GETTER, readOnly: true }),
|
|
22226
|
-
__metadata$
|
|
22296
|
+
__metadata$3("design:type", Array)
|
|
22227
22297
|
], FlowTransitionProposal.prototype, "acceptedBy", void 0);
|
|
22228
|
-
FlowTransitionProposal = __decorate$
|
|
22298
|
+
FlowTransitionProposal = __decorate$3([
|
|
22229
22299
|
Model$1({ name: "FlowTransitionProposal" })
|
|
22230
22300
|
], FlowTransitionProposal);
|
|
22231
22301
|
// ── FlowInstanceRecord ──────────────────────────────────────────────────────
|
|
@@ -22285,25 +22355,25 @@ let FlowInstanceRecord = class FlowInstanceRecord extends Ad4mModel {
|
|
|
22285
22355
|
// of the instance's own links (all written together during `mint_flow_instance`).
|
|
22286
22356
|
}
|
|
22287
22357
|
};
|
|
22288
|
-
__decorate$
|
|
22358
|
+
__decorate$3([
|
|
22289
22359
|
Property({ through: "ad4m://flow/flow_uri", required: true, identity: true }),
|
|
22290
|
-
__metadata$
|
|
22360
|
+
__metadata$3("design:type", String)
|
|
22291
22361
|
], FlowInstanceRecord.prototype, "flowUri", void 0);
|
|
22292
|
-
__decorate$
|
|
22362
|
+
__decorate$3([
|
|
22293
22363
|
Property({ through: "ad4m://flow/base", required: true }),
|
|
22294
|
-
__metadata$
|
|
22364
|
+
__metadata$3("design:type", String)
|
|
22295
22365
|
], FlowInstanceRecord.prototype, "subject", void 0);
|
|
22296
|
-
FlowInstanceRecord = __decorate$
|
|
22366
|
+
FlowInstanceRecord = __decorate$3([
|
|
22297
22367
|
Model$1({ name: "FlowInstance" })
|
|
22298
22368
|
], FlowInstanceRecord);
|
|
22299
22369
|
|
|
22300
|
-
var __decorate$
|
|
22370
|
+
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
22301
22371
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22302
22372
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
22303
22373
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22304
22374
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22305
22375
|
};
|
|
22306
|
-
var __metadata$
|
|
22376
|
+
var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) {
|
|
22307
22377
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22308
22378
|
};
|
|
22309
22379
|
/**
|
|
@@ -22329,6 +22399,10 @@ var __metadata$1 = (undefined && undefined.__metadata) || function (k, v) {
|
|
|
22329
22399
|
* reads it by its URI, `ad4m://TextContent`, so a perspective never stores it
|
|
22330
22400
|
* and an app class named `TextContent` does not replace it. `register()` on
|
|
22331
22401
|
* it writes nothing.
|
|
22402
|
+
*
|
|
22403
|
+
* The waker's mention subscription (`get_mention_waker_config`) reads it for
|
|
22404
|
+
* the agent's names in the text. Mention links it reads through
|
|
22405
|
+
* {@link Mentioning}, with text or without.
|
|
22332
22406
|
*/
|
|
22333
22407
|
let TextContent = class TextContent extends Ad4mModel {
|
|
22334
22408
|
constructor() {
|
|
@@ -22339,14 +22413,70 @@ let TextContent = class TextContent extends Ad4mModel {
|
|
|
22339
22413
|
};
|
|
22340
22414
|
/** The URI the executor reads it by. */
|
|
22341
22415
|
TextContent.builtinUri = "ad4m://TextContent";
|
|
22342
|
-
__decorate$
|
|
22416
|
+
__decorate$2([
|
|
22343
22417
|
Property({ through: "ad4m://text" }),
|
|
22344
|
-
__metadata$
|
|
22418
|
+
__metadata$2("design:type", String)
|
|
22345
22419
|
], TextContent.prototype, "text", void 0);
|
|
22346
|
-
TextContent = __decorate$
|
|
22420
|
+
TextContent = __decorate$2([
|
|
22347
22421
|
Model$1({ name: "TextContent", abstract: true })
|
|
22348
22422
|
], TextContent);
|
|
22349
22423
|
|
|
22424
|
+
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
22425
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22426
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
22427
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22428
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22429
|
+
};
|
|
22430
|
+
var __metadata$1 = (undefined && undefined.__metadata) || function (k, v) {
|
|
22431
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22432
|
+
};
|
|
22433
|
+
/**
|
|
22434
|
+
* The built-in abstract class `Mentioning { mentions }`: a record that
|
|
22435
|
+
* mentions agents — a post, a message, a block of a document. `mentions` is
|
|
22436
|
+
* a relation to their DIDs.
|
|
22437
|
+
*
|
|
22438
|
+
* Querying it reads every class that has a relation named `mentions`, or one
|
|
22439
|
+
* aliased to `mentions`, under any predicate, whether or not the class has
|
|
22440
|
+
* text. A class whose relation has another name aliases it:
|
|
22441
|
+
*
|
|
22442
|
+
* ```typescript
|
|
22443
|
+
* @Model({ name: "Note", implements: [Mentioning] })
|
|
22444
|
+
* class Note extends Ad4mModel {
|
|
22445
|
+
* @HasMany({ through: "app://cc", alias: { Mentioning: "mentions" } })
|
|
22446
|
+
* cc: string[] = [];
|
|
22447
|
+
* }
|
|
22448
|
+
*
|
|
22449
|
+
* const mentioningMe = await Mentioning.findAll(perspective, { where: { mentions: myDid } });
|
|
22450
|
+
* ```
|
|
22451
|
+
*
|
|
22452
|
+
* The waker's mention subscription (`get_mention_waker_config`) reads it: a
|
|
22453
|
+
* record whose `mentions` links the agent's DID, in a link another agent
|
|
22454
|
+
* wrote, wakes the agent whatever its text says. Names in text it reads
|
|
22455
|
+
* through {@link TextContent}.
|
|
22456
|
+
*
|
|
22457
|
+
* Built in: the executor declares it (mirrors
|
|
22458
|
+
* `rust-executor/src/perspectives/hardwired_sdna/mentioning.json`) and reads
|
|
22459
|
+
* it by its URI, `ad4m://Mentioning`, so a perspective never stores it and an
|
|
22460
|
+
* app class named `Mentioning` does not replace it. `register()` on it writes
|
|
22461
|
+
* nothing.
|
|
22462
|
+
*/
|
|
22463
|
+
let Mentioning = class Mentioning extends Ad4mModel {
|
|
22464
|
+
constructor() {
|
|
22465
|
+
super(...arguments);
|
|
22466
|
+
/** The agents (DIDs) the record mentions. */
|
|
22467
|
+
this.mentions = [];
|
|
22468
|
+
}
|
|
22469
|
+
};
|
|
22470
|
+
/** The URI the executor reads it by. */
|
|
22471
|
+
Mentioning.builtinUri = "ad4m://Mentioning";
|
|
22472
|
+
__decorate$1([
|
|
22473
|
+
HasMany({ through: "ad4m://mentions" }),
|
|
22474
|
+
__metadata$1("design:type", Array)
|
|
22475
|
+
], Mentioning.prototype, "mentions", void 0);
|
|
22476
|
+
Mentioning = __decorate$1([
|
|
22477
|
+
Model$1({ name: "Mentioning", abstract: true })
|
|
22478
|
+
], Mentioning);
|
|
22479
|
+
|
|
22350
22480
|
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
22351
22481
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22352
22482
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -22995,6 +23125,9 @@ function parseLitBoolean(val) {
|
|
|
22995
23125
|
* module (`plugins/ad4m/wakerSubscriptionManager.ts`) rather than carrying its
|
|
22996
23126
|
* own copy. Any behaviour change belongs here.
|
|
22997
23127
|
*/
|
|
23128
|
+
/** The built-in `Container` (`Container.builtinUri`; not imported, so the
|
|
23129
|
+
* plugin bundle does not pull in the model layer). */
|
|
23130
|
+
const CONTAINER = "ad4m://Container";
|
|
22998
23131
|
/** A letter, combining mark, digit or underscore: what a term must not touch. */
|
|
22999
23132
|
const WORD_CHAR = "[\\p{L}\\p{M}\\p{N}_]";
|
|
23000
23133
|
/**
|
|
@@ -23024,14 +23157,6 @@ const BREAKING_TAG = /^<\/?(?:p|div|br|hr|li|ul|ol|h[1-6]|blockquote|pre|tr|td|t
|
|
|
23024
23157
|
*/
|
|
23025
23158
|
const ATTRIBUTES = new RegExp(ATTRIBUTE, "g");
|
|
23026
23159
|
const MENTION_TARGET = /^\s+(?:href|data-id|data-did)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))$/i;
|
|
23027
|
-
/**
|
|
23028
|
-
* How much of a record's text the word check reads. Dropping markup costs time
|
|
23029
|
-
* quadratic in a run of unclosed `<script>`, `<style>` or `<!--` openers, so a
|
|
23030
|
-
* very long text could hold the event loop for seconds, and a row that holds
|
|
23031
|
-
* no term is checked again on every result while it is in the window. A term
|
|
23032
|
-
* past this many characters does not wake.
|
|
23033
|
-
*/
|
|
23034
|
-
const MENTION_TEXT_LIMIT = 16384;
|
|
23035
23160
|
const ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: " " };
|
|
23036
23161
|
function decodeEntities(s) {
|
|
23037
23162
|
return s.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z]+);/gi, (whole, ref) => {
|
|
@@ -23065,6 +23190,14 @@ function readableParts(text) {
|
|
|
23065
23190
|
});
|
|
23066
23191
|
return { visible: decodeEntities(visible), targets };
|
|
23067
23192
|
}
|
|
23193
|
+
/**
|
|
23194
|
+
* How much of a record's text the word check reads. Dropping markup costs time
|
|
23195
|
+
* quadratic in a run of unclosed `<script>`, `<style>` or `<!--` openers, so a
|
|
23196
|
+
* very long text could hold the event loop for seconds, and a row that holds
|
|
23197
|
+
* no term is checked again on every result while it is in the window. A term
|
|
23198
|
+
* past this many characters does not wake.
|
|
23199
|
+
*/
|
|
23200
|
+
const MENTION_TEXT_LIMIT = 16384;
|
|
23068
23201
|
/**
|
|
23069
23202
|
* Whether `text` holds one of `terms` as a whole word, case-insensitively:
|
|
23070
23203
|
* "Data" is in "hi Data!", "@data" and "Data's turn", not in "metadata" or
|
|
@@ -23079,7 +23212,9 @@ function readableParts(text) {
|
|
|
23079
23212
|
* is how a mention by DID is found when the DID is not in the visible text.
|
|
23080
23213
|
*
|
|
23081
23214
|
* The mention query's `contains` matches substrings (model query has no word
|
|
23082
|
-
* match); this is the check that keeps "data" from waking on "metadata"
|
|
23215
|
+
* match); this is the check that keeps "data" from waking on "metadata" when
|
|
23216
|
+
* a record is found through its text alone ({@link mentionOf}).
|
|
23217
|
+
*
|
|
23083
23218
|
* It reads the first {@link MENTION_TEXT_LIMIT} characters only.
|
|
23084
23219
|
*/
|
|
23085
23220
|
function holdsAWholeWordTerm(text, terms) {
|
|
@@ -23093,9 +23228,95 @@ function holdsAWholeWordTerm(text, terms) {
|
|
|
23093
23228
|
return new RegExp(`(?<!${WORD_CHAR})${escaped}(?!${WORD_CHAR})`, "iu").test(visible);
|
|
23094
23229
|
});
|
|
23095
23230
|
}
|
|
23096
|
-
/** The
|
|
23097
|
-
|
|
23098
|
-
const
|
|
23231
|
+
/** The provenance {@link MentionMessage} carries, from one link. */
|
|
23232
|
+
function provenanceOf(link, via) {
|
|
23233
|
+
const provenance = {
|
|
23234
|
+
verified: link?.proof?.valid === true,
|
|
23235
|
+
via,
|
|
23236
|
+
};
|
|
23237
|
+
if (typeof link?.author === "string")
|
|
23238
|
+
provenance.author = link.author;
|
|
23239
|
+
if (typeof link?.timestamp === "string")
|
|
23240
|
+
provenance.timestamp = link.timestamp;
|
|
23241
|
+
return provenance;
|
|
23242
|
+
}
|
|
23243
|
+
/** The links a model row carries for `key` under `__links`, oldest first. */
|
|
23244
|
+
function rowLinks(row, key) {
|
|
23245
|
+
const links = row?.__links?.[key];
|
|
23246
|
+
return Array.isArray(links) ? links : [];
|
|
23247
|
+
}
|
|
23248
|
+
/** `uri` URI-decoded, or as it is when it is not valid percent-encoding. */
|
|
23249
|
+
function decoded(uri) {
|
|
23250
|
+
try {
|
|
23251
|
+
return decodeURIComponent(uri);
|
|
23252
|
+
}
|
|
23253
|
+
catch {
|
|
23254
|
+
return uri;
|
|
23255
|
+
}
|
|
23256
|
+
}
|
|
23257
|
+
/**
|
|
23258
|
+
* The text a link's target holds, read as the executor reads a string property
|
|
23259
|
+
* (`parse_literal_value`): `literal:string:` decoded, `literal:json:` parsed (a signed
|
|
23260
|
+
* expression to its `data`), any other URI as it is. `undefined` when that is not a string.
|
|
23261
|
+
*/
|
|
23262
|
+
function textOf(target) {
|
|
23263
|
+
if (typeof target !== "string")
|
|
23264
|
+
return undefined;
|
|
23265
|
+
if (!target.startsWith("literal:"))
|
|
23266
|
+
return target;
|
|
23267
|
+
const body = target.slice("literal:".length);
|
|
23268
|
+
if (body.startsWith("string:"))
|
|
23269
|
+
return decoded(body.slice("string:".length));
|
|
23270
|
+
if (body.startsWith("json:")) {
|
|
23271
|
+
const json = decoded(body.slice("json:".length));
|
|
23272
|
+
let value;
|
|
23273
|
+
try {
|
|
23274
|
+
value = JSON.parse(json);
|
|
23275
|
+
}
|
|
23276
|
+
catch {
|
|
23277
|
+
return json;
|
|
23278
|
+
}
|
|
23279
|
+
if (value && typeof value === "object" && "data" in value && "author" in value && "proof" in value) {
|
|
23280
|
+
value = value.data;
|
|
23281
|
+
}
|
|
23282
|
+
return typeof value === "string" ? value : undefined;
|
|
23283
|
+
}
|
|
23284
|
+
if (/^(?:number|boolean):/.test(body))
|
|
23285
|
+
return undefined;
|
|
23286
|
+
return target;
|
|
23287
|
+
}
|
|
23288
|
+
/**
|
|
23289
|
+
* Whether a row of one of the mention subscription's two model queries mentions the
|
|
23290
|
+
* subscription's agent, and the provenance of the link it does so in; `null` when it does not.
|
|
23291
|
+
*
|
|
23292
|
+
* - A row of the query over Mentioning: a verified link to the agent's DID that another agent
|
|
23293
|
+
* wrote, in the row's `__links.mentions`. It wakes whatever the record's text says, or
|
|
23294
|
+
* whether it has any: WE's chip label may run into the next word ("@Datai have…"), and a WE
|
|
23295
|
+
* post's mention sits on its root, which has no text. Its provenance is that link's (the
|
|
23296
|
+
* newest such).
|
|
23297
|
+
* - A row of the query over TextContent: the query matched a substring, so the text must hold
|
|
23298
|
+
* a term as a whole word ({@link holdsAWholeWordTerm}), and so must the text of a verified
|
|
23299
|
+
* link another agent wrote, in `__links.text`. Its provenance is that link's (the newest
|
|
23300
|
+
* such). The row's `text` is the newest text link's, whoever wrote it, so it does not say
|
|
23301
|
+
* whose words they are.
|
|
23302
|
+
*
|
|
23303
|
+
* `via` says which it was. A record both queries find wakes once, through the query that
|
|
23304
|
+
* reports it first ({@link WakerSubscriptionManager}).
|
|
23305
|
+
*/
|
|
23306
|
+
function mentionOf(row, sub) {
|
|
23307
|
+
const did = sub.did;
|
|
23308
|
+
const byOthers = (links) => links.filter((l) => typeof l.author === "string" && l.author !== did);
|
|
23309
|
+
const linked = byOthers(rowLinks(row, "mentions")).filter((l) => l.data?.target === did && l.proof?.valid === true);
|
|
23310
|
+
if (did && linked.length)
|
|
23311
|
+
return provenanceOf(linked[linked.length - 1], "mentions");
|
|
23312
|
+
const terms = sub.terms ?? [];
|
|
23313
|
+
const names = (text) => typeof text === "string" && holdsAWholeWordTerm(text, terms);
|
|
23314
|
+
const text = Array.isArray(row?.text) ? row.text.join(" ") : row?.text;
|
|
23315
|
+
if (!names(text))
|
|
23316
|
+
return null;
|
|
23317
|
+
const naming = byOthers(rowLinks(row, "text")).filter((l) => l.proof?.valid === true && names(textOf(l.data?.target)));
|
|
23318
|
+
return naming.length ? provenanceOf(naming[naming.length - 1], "text") : null;
|
|
23319
|
+
}
|
|
23099
23320
|
/**
|
|
23100
23321
|
* Add a short cause hint to known subscription failures.
|
|
23101
23322
|
* The executor needs its main key to register a live query; on a restarted
|
|
@@ -23141,6 +23362,7 @@ async function withTimeout(promise, ms, message) {
|
|
|
23141
23362
|
}
|
|
23142
23363
|
class WakerSubscriptionManager {
|
|
23143
23364
|
constructor(options) {
|
|
23365
|
+
/** Per subscription its proxies: one, or a mention subscription's text and mention queries. */
|
|
23144
23366
|
this.proxies = new Map();
|
|
23145
23367
|
this.activeSubscriptions = new Map();
|
|
23146
23368
|
/** Subscriptions the executor rejected, waiting to be re-attempted. */
|
|
@@ -23210,21 +23432,40 @@ class WakerSubscriptionManager {
|
|
|
23210
23432
|
throw new Error("WakerSubscriptionManager: QuerySubscriptionProxy must be provided via constructor options");
|
|
23211
23433
|
}
|
|
23212
23434
|
const QuerySubscriptionProxy = this.QuerySubscriptionProxyCtor;
|
|
23213
|
-
if (sub.type === "mention" &&
|
|
23214
|
-
|
|
23215
|
-
//
|
|
23216
|
-
|
|
23435
|
+
if (sub.type === "mention" &&
|
|
23436
|
+
(!sub.className || !sub.terms?.length || !sub.did || !sub.mentionQuery || !sub.mentionClass)) {
|
|
23437
|
+
// Without terms the whole-word check cannot run, so every substring
|
|
23438
|
+
// ("metadata" for "data") would wake the agent; without the DID no link
|
|
23439
|
+
// can be told to be someone else's; without the mention query a mention
|
|
23440
|
+
// link on a record with no text (a WE post's root) never wakes it.
|
|
23441
|
+
throw new Error(`Waker subscription ${sub.id}: a mention subscription needs its TextContent class, terms, DID and Mentioning query (get_mention_waker_config returns them)`);
|
|
23217
23442
|
}
|
|
23218
23443
|
this.logger.info(`[waker] ${sub.id}: creating subscription (perspective=${sub.perspective}, type=${sub.type})`);
|
|
23219
23444
|
this.logger.info(`[waker] ${sub.id}: ${sub.className ? `model query over ${sub.className}` : "SPARQL query"}:\n${sub.query}`);
|
|
23445
|
+
if (sub.mentionQuery) {
|
|
23446
|
+
this.logger.info(`[waker] ${sub.id}: model query over ${sub.mentionClass}:\n${sub.mentionQuery}`);
|
|
23447
|
+
}
|
|
23220
23448
|
const proxy = sub.className
|
|
23221
23449
|
? new QuerySubscriptionProxy(sub.perspective, sub.query, this.perspectiveClient, sub.className)
|
|
23222
23450
|
: new QuerySubscriptionProxy(sub.perspective, sub.query, this.perspectiveClient);
|
|
23451
|
+
const mentionProxy = sub.mentionQuery
|
|
23452
|
+
? new QuerySubscriptionProxy(sub.perspective, sub.mentionQuery, this.perspectiveClient, sub.mentionClass)
|
|
23453
|
+
: undefined;
|
|
23454
|
+
const proxies = mentionProxy ? [proxy, mentionProxy] : [proxy];
|
|
23455
|
+
const disposeProxies = () => {
|
|
23456
|
+
for (const p of proxies) {
|
|
23457
|
+
try {
|
|
23458
|
+
p.dispose();
|
|
23459
|
+
}
|
|
23460
|
+
catch { }
|
|
23461
|
+
}
|
|
23462
|
+
};
|
|
23223
23463
|
// Suppress unhandled rejection from proxy.initialized — QuerySubscriptionProxy
|
|
23224
23464
|
// rejects this promise internally when subscribe() fails, and if nobody catches
|
|
23225
23465
|
// it before the next microtask it crashes the process.
|
|
23226
|
-
|
|
23227
|
-
|
|
23466
|
+
for (const p of proxies) {
|
|
23467
|
+
if (p.initialized && typeof p.initialized.catch === "function")
|
|
23468
|
+
p.initialized.catch(() => { });
|
|
23228
23469
|
}
|
|
23229
23470
|
// One deadline for the whole handshake: `proxy.subscribe()` and the
|
|
23230
23471
|
// `initialized` promise it resolves share the budget, so a hang in either
|
|
@@ -23235,23 +23476,17 @@ class WakerSubscriptionManager {
|
|
|
23235
23476
|
? withTimeout(step, Math.max(0, budgetMs - (Date.now() - startedAt)), `${what} timed out after ${budgetMs}ms`)
|
|
23236
23477
|
: step;
|
|
23237
23478
|
try {
|
|
23238
|
-
await bounded(
|
|
23479
|
+
await bounded(Promise.all(proxies.map((p) => p.subscribe())), "subscribe handshake");
|
|
23239
23480
|
if (this.isStale(sub.id, token)) {
|
|
23240
|
-
|
|
23241
|
-
proxy.dispose();
|
|
23242
|
-
}
|
|
23243
|
-
catch { }
|
|
23481
|
+
disposeProxies();
|
|
23244
23482
|
return;
|
|
23245
23483
|
}
|
|
23246
|
-
await bounded(
|
|
23484
|
+
await bounded(Promise.all(proxies.map((p) => p.initialized)), "subscription initialization");
|
|
23247
23485
|
}
|
|
23248
23486
|
catch (err) {
|
|
23249
23487
|
const msg = err?.message ?? String(err);
|
|
23250
23488
|
this.logger.warn(`[waker] ${sub.id}: subscription failed — ${msg}`);
|
|
23251
|
-
|
|
23252
|
-
proxy.dispose();
|
|
23253
|
-
}
|
|
23254
|
-
catch { }
|
|
23489
|
+
disposeProxies();
|
|
23255
23490
|
// A dispose that landed mid-attempt wins: don't re-queue something the
|
|
23256
23491
|
// caller has since asked us to forget.
|
|
23257
23492
|
if (this.isStale(sub.id, token))
|
|
@@ -23276,10 +23511,7 @@ class WakerSubscriptionManager {
|
|
|
23276
23511
|
: ""));
|
|
23277
23512
|
}
|
|
23278
23513
|
if (this.isStale(sub.id, token)) {
|
|
23279
|
-
|
|
23280
|
-
proxy.dispose();
|
|
23281
|
-
}
|
|
23282
|
-
catch { }
|
|
23514
|
+
disposeProxies();
|
|
23283
23515
|
return;
|
|
23284
23516
|
}
|
|
23285
23517
|
this.pendingSubscriptions.delete(sub.id);
|
|
@@ -23294,8 +23526,9 @@ class WakerSubscriptionManager {
|
|
|
23294
23526
|
}
|
|
23295
23527
|
// `opening` is the result the subscription holds when it opens (`proxy.result`): `onResult`
|
|
23296
23528
|
// only reports later changes, so this is the one chance to see what was written meanwhile.
|
|
23297
|
-
|
|
23298
|
-
|
|
23529
|
+
// `of`: the query the result is from, for the log (a mention subscription has two).
|
|
23530
|
+
const handleResult = async (result, opening = false, of = "") => {
|
|
23531
|
+
this.logger.info(`[waker] ${sub.id}: ${opening ? "opening result" : "onResult fired"}${of} — type=${typeof result}, isArray=${Array.isArray(result)}, value=${String(JSON.stringify(result)).substring(0, 500)}`);
|
|
23299
23532
|
// A model subscription delivers `{ instances }`, SPARQL an array of
|
|
23300
23533
|
// rows. Anything else (e.g. `false` on a disconnect/reconnect) is
|
|
23301
23534
|
// ignored.
|
|
@@ -23305,26 +23538,25 @@ class WakerSubscriptionManager {
|
|
|
23305
23538
|
return;
|
|
23306
23539
|
}
|
|
23307
23540
|
if (sub.type === "mention") {
|
|
23308
|
-
// For mention subscriptions: track seen record ids
|
|
23309
|
-
//
|
|
23541
|
+
// For mention subscriptions: track seen record ids, across both queries, and wake only
|
|
23542
|
+
// for records not seen before, so a record both find wakes once, through the query that
|
|
23543
|
+
// reports it first.
|
|
23310
23544
|
const currentSeen = this.seenMessages.get(sub.id) ?? new Set();
|
|
23311
23545
|
const newMessages = [];
|
|
23312
|
-
const
|
|
23546
|
+
const provenance = new Map();
|
|
23313
23547
|
for (const item of rows) {
|
|
23314
|
-
|
|
23315
|
-
const address = sub.className ? item?.id : item?.source;
|
|
23548
|
+
const address = item?.id;
|
|
23316
23549
|
if (typeof address !== "string" || !address || currentSeen.has(address))
|
|
23317
23550
|
continue;
|
|
23318
|
-
|
|
23319
|
-
|
|
23320
|
-
|
|
23321
|
-
|
|
23322
|
-
|
|
23323
|
-
continue;
|
|
23324
|
-
}
|
|
23551
|
+
// A mention link as it is; the text, a whole word only.
|
|
23552
|
+
const mention = mentionOf(item, sub);
|
|
23553
|
+
if (!mention) {
|
|
23554
|
+
this.logger.debug(`[waker] ${sub.id}: ${address} has no verified mention link and no term as a whole word, skipping`);
|
|
23555
|
+
continue;
|
|
23325
23556
|
}
|
|
23326
23557
|
currentSeen.add(address);
|
|
23327
23558
|
newMessages.push(address);
|
|
23559
|
+
provenance.set(address, mention);
|
|
23328
23560
|
}
|
|
23329
23561
|
if (newMessages.length === 0) {
|
|
23330
23562
|
this.logger.info(`[waker] ${sub.id}: no new mention among ${rows.length} items, skipping`);
|
|
@@ -23349,7 +23581,7 @@ class WakerSubscriptionManager {
|
|
|
23349
23581
|
const ancestors = await this.ancestorsOf(sub, msgAddr, parents);
|
|
23350
23582
|
this.logger.info(`[waker] ${sub.id}: message ${msgAddr} has ${parents.length} parent(s): ${parents.join(", ")}` +
|
|
23351
23583
|
(ancestors.length ? `; ancestors: ${ancestors.join(", ")}` : ""));
|
|
23352
|
-
mentions.push({ address: msgAddr, parents, ancestors });
|
|
23584
|
+
mentions.push({ address: msgAddr, parents, ancestors, ...provenance.get(msgAddr) });
|
|
23353
23585
|
}
|
|
23354
23586
|
this.seenMessages.set(sub.id, currentSeen);
|
|
23355
23587
|
const pending = this.undelivered.get(sub.id) ?? new Map();
|
|
@@ -23375,20 +23607,21 @@ class WakerSubscriptionManager {
|
|
|
23375
23607
|
}
|
|
23376
23608
|
};
|
|
23377
23609
|
proxy.onResult((result) => handleResult(result));
|
|
23610
|
+
mentionProxy?.onResult((result) => handleResult(result, false, " (mention query)"));
|
|
23378
23611
|
if (this.isStale(sub.id, token)) {
|
|
23379
|
-
|
|
23380
|
-
proxy.dispose();
|
|
23381
|
-
}
|
|
23382
|
-
catch { }
|
|
23612
|
+
disposeProxies();
|
|
23383
23613
|
return;
|
|
23384
23614
|
}
|
|
23385
|
-
this.proxies.set(sub.id,
|
|
23615
|
+
this.proxies.set(sub.id, proxies);
|
|
23386
23616
|
this.activeSubscriptions.set(sub.id, sub);
|
|
23387
23617
|
// After a restart this wakes on mentions written while the waker was down; on a new
|
|
23388
|
-
// subscription it records the existing ones as history.
|
|
23389
|
-
|
|
23618
|
+
// subscription it records the existing ones as history. The mention query's first, so a
|
|
23619
|
+
// record both hold wakes through its mention link.
|
|
23620
|
+
for (const [p, of] of [[mentionProxy, " (mention query)"], [proxy, ""]]) {
|
|
23621
|
+
if (p?.result === undefined)
|
|
23622
|
+
continue;
|
|
23390
23623
|
try {
|
|
23391
|
-
await handleResult(
|
|
23624
|
+
await handleResult(p.result, true, of);
|
|
23392
23625
|
}
|
|
23393
23626
|
catch (e) {
|
|
23394
23627
|
this.logger.warn(`[waker] ${sub.id}: reading the opening result failed: ${e?.message ?? e}`);
|
|
@@ -23451,16 +23684,15 @@ class WakerSubscriptionManager {
|
|
|
23451
23684
|
dispose(id, persist = true) {
|
|
23452
23685
|
// Invalidate any subscribe() for this id that is still awaiting.
|
|
23453
23686
|
this.generations.set(id, (this.generations.get(id) ?? 0) + 1);
|
|
23454
|
-
const proxy
|
|
23455
|
-
if (proxy) {
|
|
23687
|
+
for (const proxy of this.proxies.get(id) ?? []) {
|
|
23456
23688
|
try {
|
|
23457
23689
|
proxy.dispose();
|
|
23458
23690
|
}
|
|
23459
23691
|
catch {
|
|
23460
23692
|
/* ignore */
|
|
23461
23693
|
}
|
|
23462
|
-
this.proxies.delete(id);
|
|
23463
23694
|
}
|
|
23695
|
+
this.proxies.delete(id);
|
|
23464
23696
|
const timer = this.debounceTimers.get(id);
|
|
23465
23697
|
if (timer) {
|
|
23466
23698
|
clearTimeout(timer);
|
|
@@ -24037,4 +24269,4 @@ const SCOPED_EVENTS = new Set([
|
|
|
24037
24269
|
"flow-state-changed",
|
|
24038
24270
|
]);
|
|
24039
24271
|
|
|
24040
|
-
export { ACCEPTED_BY_GETTER, AIClient, Model as AIModel, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, AutoProcessorConfig, BelongsToMany, BelongsToOne, CALL_PROTOCOL_VERSION, Capability, CapabilityInput, ComputeLogEntry, Container, DEFAULT_ICE_SERVERS, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, FlowInstance, FlowInstanceRecord, FlowTransitionProposal, HasMany, HasOne, HostingUserInfo, IDBCache, Icon, ImportResult, ImportStats, InteractionCall, InteractionMeta, InteractionParameter, InterpretationOverlay, InterpretationRun, LONG_METHODS, LONG_TIMEOUT_MS, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, LiveQuery, LocalModel, LocalModelInput, MENTION_TEXT_LIMIT, MeshManager, Model$1 as Model, ModelApi, ModelApiInput, ModelInput, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, NullCache, OnlineAgent, Optional, PROPOSER_GETTER, PaymentRequestResult, Perspective, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, READ_METHODS, ReadOnly, Resource, ResourceInput, RpcError, RuntimeInfo, SCOPED_EVENTS, SHACLFlow, SHACLShape, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, TextContent, TokenizerSource, TokenizerSourceInput, TriggeredNotification, UserCreationResult, UserStatistics, VerificationRequestResult, VoiceActivityParamsInput, WakerSubscriptionManager, applyUpdate, buildConformanceFilter, buildModelFromJSONSchema, buildPaginationSubquery, buildSDNA, buildSHACL, buildSPARQLQuery, buildWhereCondition, capSentence, clearQueryCache, coalesce, compileWhereClause, concat, createPersistentCache, createTelepresenceChannel, determineNamespace, determinePredicate, effectiveLiteralStorage, escapeQueryString, exists, exprRef2String, fileToDataUri, fn, focus, formatList, formatQueryValue, formatSPARQLValue, getCachedResult, getDefaultValueForType, getMemoizedSHACL, getPropertiesMetadata, getPropertyOption, getRelationsMetadata, hasJsOnlyWhereFilters, hintFor, holdsAWholeWordTerm, ifExpr, invalidatePerspectiveCache, isArrayType, isContainedScope, isContainmentTraversal, isExpression, isIncludeProjection, isLink, isNodeExpression, isNumericType, isObjectType, isSchemaType, isTraverseScope, linkEqual, linkExpressionInputToWire, linkExpressionToWire, linkMutationsToWire, literal, looksLikeUri, neighbourhoodExpressionFromWire, normalizeNamespaceString, normalizeSchemaType, normalizeValue, normalizeWhereForSparql, parseCallMessage, parseExprUrl, parseLit, parseLitBoolean, parseLitNumber, parseSparqlCount, path, queryCacheSize, requireSingleParent, resolveParentPredicate, setCachedResult, setPropertyRegistryEntry, setRelationRegistryEntry, typeDefsString, valueToLiteralIri };
|
|
24272
|
+
export { ACCEPTED_BY_GETTER, AIClient, Model as AIModel, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, AutoProcessorConfig, BelongsToMany, BelongsToOne, CALL_PROTOCOL_VERSION, Capability, CapabilityInput, ComputeLogEntry, Container, DEFAULT_ICE_SERVERS, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, FlowInstance, FlowInstanceRecord, FlowTransitionProposal, HasMany, HasOne, HostingUserInfo, IDBCache, Icon, ImportResult, ImportStats, InteractionCall, InteractionMeta, InteractionParameter, InterpretationOverlay, InterpretationRun, LONG_METHODS, LONG_TIMEOUT_MS, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, LiveQuery, LocalModel, LocalModelInput, MENTION_TEXT_LIMIT, Mentioning, MeshManager, Model$1 as Model, ModelApi, ModelApiInput, ModelInput, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, NullCache, OnlineAgent, Optional, PROPOSER_GETTER, PaymentRequestResult, Perspective, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, READ_METHODS, ReadOnly, Resource, ResourceInput, RpcError, RuntimeInfo, SCOPED_EVENTS, SHACLFlow, SHACLShape, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, TextContent, TokenizerSource, TokenizerSourceInput, TriggeredNotification, UserCreationResult, UserStatistics, VerificationRequestResult, VoiceActivityParamsInput, WakerSubscriptionManager, applyUpdate, buildConformanceFilter, buildModelFromJSONSchema, buildPaginationSubquery, buildSDNA, buildSHACL, buildSPARQLQuery, buildWhereCondition, capSentence, clearQueryCache, coalesce, compileWhereClause, concat, createPersistentCache, createTelepresenceChannel, determineNamespace, determinePredicate, effectiveLiteralStorage, escapeQueryString, exists, exprRef2String, fileToDataUri, fn, focus, formatList, formatQueryValue, formatSPARQLValue, getCachedResult, getDefaultValueForType, getMemoizedSHACL, getPropertiesMetadata, getPropertyOption, getRelationsMetadata, hasJsOnlyWhereFilters, hintFor, holdsAWholeWordTerm, ifExpr, invalidatePerspectiveCache, isArrayType, isContainedScope, isContainmentTraversal, isExpression, isIncludeProjection, isLink, isNodeExpression, isNumericType, isObjectType, isSchemaType, isTraverseScope, linkEqual, linkExpressionInputToWire, linkExpressionToWire, linkMutationsToWire, literal, looksLikeUri, mentionOf, neighbourhoodExpressionFromWire, normalizeNamespaceString, normalizeSchemaType, normalizeValue, normalizeWhereForSparql, parseCallMessage, parseExprUrl, parseLit, parseLitBoolean, parseLitNumber, parseSparqlCount, path, queryCacheSize, requireSingleParent, resolveParentPredicate, setCachedResult, setPropertyRegistryEntry, setRelationRegistryEntry, typeDefsString, valueToLiteralIri };
|