@coasys/ad4m 0.13.0-test-9 → 0.13.0-test-interpretation-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +370 -8
- package/lib/index.js +371 -9
- package/lib/src/ai/AIClient.js +3 -1
- package/lib/src/apiClient.d.ts +4 -1
- package/lib/src/apiClient.js +7 -3
- package/lib/src/generated/api/RunInterpretationRequest.d.ts +19 -0
- package/lib/src/generated/api/RunInterpretationRequest.js +1 -0
- package/lib/src/generated/api/TranscriptTurn.d.ts +7 -0
- package/lib/src/generated/api/TranscriptTurn.js +2 -0
- package/lib/src/generated/api/index.d.ts +2 -0
- package/lib/src/index.d.ts +2 -0
- package/lib/src/index.js +2 -0
- package/lib/src/model/ModelQueryBuilder.js +1 -1
- package/lib/src/model/decorators.d.ts +25 -0
- package/lib/src/model/decorators.js +1 -1
- package/lib/src/model/shacl-gen.d.ts +8 -1
- package/lib/src/model/shacl-gen.js +21 -1
- package/lib/src/perspectives/AutoProcessor.d.ts +89 -0
- package/lib/src/perspectives/AutoProcessor.js +5 -0
- package/lib/src/perspectives/InterpretationModels.d.ts +71 -0
- package/lib/src/perspectives/InterpretationModels.js +190 -0
- package/lib/src/perspectives/PerspectiveClient.d.ts +37 -0
- package/lib/src/perspectives/PerspectiveClient.js +54 -0
- package/lib/src/perspectives/PerspectiveProxy.d.ts +43 -1
- package/lib/src/perspectives/PerspectiveProxy.js +53 -1
- package/lib/src/shacl/SHACLShape.d.ts +14 -0
- package/lib/src/shacl/SHACLShape.js +45 -0
- package/package.json +6 -2
- package/src/ai/AIClient.ts +3 -1
- package/src/apiClient.ts +7 -3
- package/src/generated/api/RunInterpretationRequest.ts +18 -0
- package/src/generated/api/TranscriptTurn.ts +6 -0
- package/src/generated/api/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/model/ModelQueryBuilder.ts +1 -1
- package/src/model/decorators.ts +29 -0
- package/src/model/shacl-gen.ts +22 -0
- package/src/model/shacl-roundtrip.test.ts +76 -0
- package/src/perspectives/AutoProcessor.ts +107 -0
- package/src/perspectives/InterpretationModels.ts +145 -0
- package/src/perspectives/PerspectiveClient.ts +75 -0
- package/src/perspectives/PerspectiveProxy.ts +61 -1
- package/src/shacl/SHACLShape.test.ts +26 -0
- package/src/shacl/SHACLShape.ts +82 -4
package/lib/index.js
CHANGED
|
@@ -163,20 +163,24 @@ class ApiClient {
|
|
|
163
163
|
* Send an RPC call over the WebSocket connection.
|
|
164
164
|
* @param type - The operation type (e.g. 'agent.get', 'perspective.all')
|
|
165
165
|
* @param params - Optional parameters to include in the message
|
|
166
|
+
* @param timeoutMs - Optional per-call timeout override in ms. Defaults to
|
|
167
|
+
* [[DEFAULT_TIMEOUT_MS]]. Use for long-running calls (LLM prompts,
|
|
168
|
+
* holochain ops) that legitimately exceed the default.
|
|
166
169
|
* @returns Promise that resolves with the result from the server
|
|
167
170
|
*/
|
|
168
|
-
async call(type, params) {
|
|
171
|
+
async call(type, params, timeoutMs) {
|
|
169
172
|
await this._ready();
|
|
170
173
|
const id = nextId();
|
|
171
174
|
// Put params under a "params" key to avoid collision with
|
|
172
175
|
// protocol fields "id" and "type" (e.g. params might contain
|
|
173
176
|
// { id: modelId } or { type: "db" }).
|
|
174
177
|
const message = { id, type, params: params || {} };
|
|
178
|
+
const effectiveTimeout = timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
175
179
|
return new Promise((resolve, reject) => {
|
|
176
180
|
const timer = setTimeout(() => {
|
|
177
181
|
this._pendingCalls.delete(id);
|
|
178
|
-
reject(new RpcError(408, `RPC call '${type}' timed out after ${
|
|
179
|
-
},
|
|
182
|
+
reject(new RpcError(408, `RPC call '${type}' timed out after ${effectiveTimeout}ms`));
|
|
183
|
+
}, effectiveTimeout);
|
|
180
184
|
this._pendingCalls.set(id, {
|
|
181
185
|
resolve: resolve,
|
|
182
186
|
reject,
|
|
@@ -1229,6 +1233,15 @@ class SHACLShape {
|
|
|
1229
1233
|
target: `literal:string:${JSON.stringify(this.destructor_actions)}`
|
|
1230
1234
|
});
|
|
1231
1235
|
}
|
|
1236
|
+
// Class-level interpretation hint — read by the Rust model query as
|
|
1237
|
+
// `ModelShape.interpretation_hint` and fed to the generic LLM extractor.
|
|
1238
|
+
if (this.interpretationHint) {
|
|
1239
|
+
links.push({
|
|
1240
|
+
source: this.nodeShapeUri,
|
|
1241
|
+
predicate: "ad4m://interpretation_hint",
|
|
1242
|
+
target: `literal:string:${this.interpretationHint}`
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1232
1245
|
// Property shapes (each gets a named URI: {namespace}/{ClassName}.{propertyName})
|
|
1233
1246
|
for (let i = 0; i < this.properties.length; i++) {
|
|
1234
1247
|
const prop = this.properties[i];
|
|
@@ -1428,6 +1441,20 @@ class SHACLShape {
|
|
|
1428
1441
|
target: `literal:string:${JSON.stringify(prop.transform)}`
|
|
1429
1442
|
});
|
|
1430
1443
|
}
|
|
1444
|
+
if (prop.interpretationHint) {
|
|
1445
|
+
links.push({
|
|
1446
|
+
source: propShapeId,
|
|
1447
|
+
predicate: "ad4m://interpretation_hint",
|
|
1448
|
+
target: `literal:string:${prop.interpretationHint}`
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
if (prop.identity) {
|
|
1452
|
+
links.push({
|
|
1453
|
+
source: propShapeId,
|
|
1454
|
+
predicate: "ad4m://identity",
|
|
1455
|
+
target: `literal:string:true`
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1431
1458
|
}
|
|
1432
1459
|
return links;
|
|
1433
1460
|
}
|
|
@@ -1460,6 +1487,11 @@ class SHACLShape {
|
|
|
1460
1487
|
// Ignore parse errors
|
|
1461
1488
|
}
|
|
1462
1489
|
}
|
|
1490
|
+
// Class-level interpretation hint (mirror of the emit in toLinks())
|
|
1491
|
+
const classHintLink = links.find(l => l.source === shapeUri && l.predicate === "ad4m://interpretation_hint");
|
|
1492
|
+
if (classHintLink) {
|
|
1493
|
+
shape.interpretationHint = classHintLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
|
|
1494
|
+
}
|
|
1463
1495
|
// Find all property shapes
|
|
1464
1496
|
const propShapeLinks = links.filter(l => l.source === shapeUri && l.predicate === "sh://property");
|
|
1465
1497
|
for (const propLink of propShapeLinks) {
|
|
@@ -1647,6 +1679,15 @@ class SHACLShape {
|
|
|
1647
1679
|
val = val.substring(8);
|
|
1648
1680
|
prop.filter = val === 'true';
|
|
1649
1681
|
}
|
|
1682
|
+
const interpretationHintLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://interpretation_hint");
|
|
1683
|
+
if (interpretationHintLink) {
|
|
1684
|
+
prop.interpretationHint = interpretationHintLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
|
|
1685
|
+
}
|
|
1686
|
+
const identityLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://identity");
|
|
1687
|
+
if (identityLink) {
|
|
1688
|
+
prop.identity =
|
|
1689
|
+
identityLink.target.replace(/^literal:\/\/string:|^literal:string:/, '') === 'true';
|
|
1690
|
+
}
|
|
1650
1691
|
const transformLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://transform");
|
|
1651
1692
|
if (transformLink) {
|
|
1652
1693
|
const jsonStr = transformLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
|
|
@@ -1678,6 +1719,7 @@ class SHACLShape {
|
|
|
1678
1719
|
node_shape_uri: this.nodeShapeUri,
|
|
1679
1720
|
target_class: this.targetClass,
|
|
1680
1721
|
parent_shapes: this.parentShapes.length > 0 ? this.parentShapes : undefined,
|
|
1722
|
+
interpretation_hint: this.interpretationHint,
|
|
1681
1723
|
properties: this.properties.map(p => ({
|
|
1682
1724
|
path: p.path,
|
|
1683
1725
|
name: p.name,
|
|
@@ -1705,6 +1747,8 @@ class SHACLShape {
|
|
|
1705
1747
|
where_predicates: p.wherePredicates,
|
|
1706
1748
|
filter: p.filter,
|
|
1707
1749
|
transform: p.transform,
|
|
1750
|
+
interpretation_hint: p.interpretationHint,
|
|
1751
|
+
identity: p.identity,
|
|
1708
1752
|
})),
|
|
1709
1753
|
constructor_actions: this.constructor_actions,
|
|
1710
1754
|
destructor_actions: this.destructor_actions,
|
|
@@ -1750,6 +1794,8 @@ class SHACLShape {
|
|
|
1750
1794
|
wherePredicates: p.where_predicates,
|
|
1751
1795
|
filter: p.filter,
|
|
1752
1796
|
transform: p.transform,
|
|
1797
|
+
interpretationHint: p.interpretation_hint,
|
|
1798
|
+
identity: p.identity,
|
|
1753
1799
|
});
|
|
1754
1800
|
}
|
|
1755
1801
|
if (json.constructor_actions) {
|
|
@@ -1763,6 +1809,9 @@ class SHACLShape {
|
|
|
1763
1809
|
shape.addParentShape(ps);
|
|
1764
1810
|
}
|
|
1765
1811
|
}
|
|
1812
|
+
if (json.interpretation_hint) {
|
|
1813
|
+
shape.interpretationHint = json.interpretation_hint;
|
|
1814
|
+
}
|
|
1766
1815
|
return shape;
|
|
1767
1816
|
}
|
|
1768
1817
|
}
|
|
@@ -1797,7 +1846,14 @@ function buildSHACL(subjectName, target, properties, allRelationsMeta, conforman
|
|
|
1797
1846
|
* `getMemoizedSHACL`; safe to omit when calling `buildSHACL`
|
|
1798
1847
|
* directly (e.g. from a one-off SDNA build tool).
|
|
1799
1848
|
*/
|
|
1800
|
-
seedCache
|
|
1849
|
+
seedCache,
|
|
1850
|
+
/**
|
|
1851
|
+
* Natural-language hint declared on the `@Model` decorator that
|
|
1852
|
+
* steers the generic LLM extractor when producing instances of
|
|
1853
|
+
* this class. Attached to the SHACL shape node and re-emitted as
|
|
1854
|
+
* an `ad4m://interpretation_hint` link by `SHACLShape.toLinks()`.
|
|
1855
|
+
*/
|
|
1856
|
+
interpretationHint) {
|
|
1801
1857
|
const obj = target.prototype;
|
|
1802
1858
|
// ── Determine namespace from first property or relation ─────────────
|
|
1803
1859
|
let namespace = "ad4m://";
|
|
@@ -1825,6 +1881,9 @@ seedCache) {
|
|
|
1825
1881
|
const shapeUri = `${namespace}${subjectName}Shape`;
|
|
1826
1882
|
const targetClass = `${namespace}${subjectName}`;
|
|
1827
1883
|
const shape = new SHACLShape(shapeUri, targetClass);
|
|
1884
|
+
if (interpretationHint) {
|
|
1885
|
+
shape.interpretationHint = interpretationHint;
|
|
1886
|
+
}
|
|
1828
1887
|
// ── Seed the memoisation cache while we keep building ──────────────
|
|
1829
1888
|
// Any subsequent `target.generateSHACL()` call from inside this
|
|
1830
1889
|
// function (typically when walking a self-referential or
|
|
@@ -1911,6 +1970,16 @@ seedCache) {
|
|
|
1911
1970
|
if (propMeta.transform) {
|
|
1912
1971
|
propShape.transform = propMeta.transform;
|
|
1913
1972
|
}
|
|
1973
|
+
// Natural-language interpretation hint (read by the generic LLM
|
|
1974
|
+
// extractor via ShapeProperty.interpretation_hint).
|
|
1975
|
+
if (propMeta.interpretationHint) {
|
|
1976
|
+
propShape.interpretationHint = propMeta.interpretationHint;
|
|
1977
|
+
}
|
|
1978
|
+
// Declared-identity dedup key for the generic LLM interpreter
|
|
1979
|
+
// (emitted as `ad4m://identity` by SHACLShape.toLinks()).
|
|
1980
|
+
if (propMeta.identity) {
|
|
1981
|
+
propShape.identity = true;
|
|
1982
|
+
}
|
|
1914
1983
|
// ── Setter actions ──────────────────────────────────────────────
|
|
1915
1984
|
if (propMeta.prologSetter) {
|
|
1916
1985
|
console.warn(`[SHACL Generation] Custom Prolog setter for property '${propName}' in class '${subjectName}' is not yet supported. ` +
|
|
@@ -2555,7 +2624,7 @@ function Model$1(opts) {
|
|
|
2555
2624
|
return buildSDNA(opts.name, target.prototype, getPropertiesMetadata(target), getRelationsMetadata(target));
|
|
2556
2625
|
};
|
|
2557
2626
|
target.generateSHACL = function () {
|
|
2558
|
-
return getMemoizedSHACL(target, (seed) => buildSHACL(opts.name, target, getPropertiesMetadata(target), getRelationsMetadata(target), buildConformanceFilter, seed));
|
|
2627
|
+
return getMemoizedSHACL(target, (seed) => buildSHACL(opts.name, target, getPropertiesMetadata(target), getRelationsMetadata(target), buildConformanceFilter, seed, opts.interpretationHint));
|
|
2559
2628
|
};
|
|
2560
2629
|
Object.defineProperty(target, 'type', { configurable: true });
|
|
2561
2630
|
};
|
|
@@ -3781,6 +3850,58 @@ class PerspectiveProxy {
|
|
|
3781
3850
|
async get(query) {
|
|
3782
3851
|
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
|
|
3783
3852
|
}
|
|
3853
|
+
/**
|
|
3854
|
+
* Runs generic LLM interpretation over a conversation transcript, turning it
|
|
3855
|
+
* into typed instances of this perspective's own SHACL subject classes
|
|
3856
|
+
* (steered by each class's `@InterpretationHint`). The target shapes are
|
|
3857
|
+
* resolved automatically from the perspective's registered classes, so you
|
|
3858
|
+
* pass only the transcript. New instances are written as links into this
|
|
3859
|
+
* perspective; the returned placements list each instance's base URI and
|
|
3860
|
+
* the links written for it.
|
|
3861
|
+
*
|
|
3862
|
+
* @param transcript ordered `{ speaker, text }` turns
|
|
3863
|
+
* @param basePrefix URI namespace for new instance identities, e.g. `soa://ext/`
|
|
3864
|
+
* @param classes local names of the subject classes to extract into; omit for all
|
|
3865
|
+
*/
|
|
3866
|
+
async runInterpretation(transcript, basePrefix, classes) {
|
|
3867
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").runInterpretation(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, classes);
|
|
3868
|
+
}
|
|
3869
|
+
/**
|
|
3870
|
+
* Register a neighbourhood auto-processor on this perspective. The executor
|
|
3871
|
+
* then runs interpretation automatically over new source items (like Flux
|
|
3872
|
+
* per channel), coordinating which peer processes each batch. Returns the
|
|
3873
|
+
* processor id. Subscribe to progress via {@link addAutoProcessorEventListener}.
|
|
3874
|
+
*/
|
|
3875
|
+
async addAutoProcessor(config) {
|
|
3876
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addAutoProcessor(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, config);
|
|
3877
|
+
}
|
|
3878
|
+
/**
|
|
3879
|
+
* Pending interpretation overlays on this perspective — LLM suggestions the
|
|
3880
|
+
* §4 divergence gate staged rather than applied, awaiting human accept/reject.
|
|
3881
|
+
*/
|
|
3882
|
+
async interpretationOverlays() {
|
|
3883
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").interpretationOverlays(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3884
|
+
}
|
|
3885
|
+
/**
|
|
3886
|
+
* Accept an interpretation overlay's suggestion(s): the LLM's staged value
|
|
3887
|
+
* becomes the real, human-owned value and the overlay is deleted. Pass
|
|
3888
|
+
* `property` to accept a single predicate; omit it for the whole base.
|
|
3889
|
+
*/
|
|
3890
|
+
async acceptInterpretation(base, property) {
|
|
3891
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").acceptInterpretation(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, base, property);
|
|
3892
|
+
}
|
|
3893
|
+
/**
|
|
3894
|
+
* Reject an interpretation overlay's suggestion(s). Omit `property` to reject
|
|
3895
|
+
* the whole base — a rejected `create` deletes the suggested instance, a
|
|
3896
|
+
* rejected `update` drops the overlay and keeps the real value.
|
|
3897
|
+
*/
|
|
3898
|
+
async rejectInterpretation(base, property) {
|
|
3899
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").rejectInterpretation(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, base, property);
|
|
3900
|
+
}
|
|
3901
|
+
/** Subscribe to this perspective's auto-processor step signals. */
|
|
3902
|
+
async addAutoProcessorEventListener(cb) {
|
|
3903
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addAutoProcessorEventListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, cb);
|
|
3904
|
+
}
|
|
3784
3905
|
/**
|
|
3785
3906
|
* Executes a Prolog query against the perspective's knowledge base.
|
|
3786
3907
|
* This is a powerful way to find complex patterns in the graph.
|
|
@@ -3865,7 +3986,7 @@ class PerspectiveProxy {
|
|
|
3865
3986
|
* internally in Rust, registers a subscription, runs the initial query, and
|
|
3866
3987
|
* pushes updated results when relevant links change.
|
|
3867
3988
|
*
|
|
3868
|
-
* The subscription reuses the same
|
|
3989
|
+
* The subscription reuses the same WS-RPC subscription channel as subscribeQuery().
|
|
3869
3990
|
* Use keepAliveQuery() / disposeQuerySubscription() with the returned subscriptionId.
|
|
3870
3991
|
*
|
|
3871
3992
|
* @param className - The model class name
|
|
@@ -5611,6 +5732,60 @@ class PerspectiveClient {
|
|
|
5611
5732
|
async linkMutations(uuid, mutations, status) {
|
|
5612
5733
|
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.linkMutations', { uuid, mutations, status });
|
|
5613
5734
|
}
|
|
5735
|
+
/**
|
|
5736
|
+
* Run generic LLM interpretation over a transcript into this perspective's own
|
|
5737
|
+
* SHACL subject classes. The target shapes are resolved server-side from the
|
|
5738
|
+
* perspective's registered subject classes, so you pass only the transcript.
|
|
5739
|
+
* Returns the freshly minted instances (their base URIs + the links written).
|
|
5740
|
+
*
|
|
5741
|
+
* The server-side call prompts an LLM (up to `INTERPRETATION_MAX_ATTEMPTS`
|
|
5742
|
+
* retries on parse failure), so it can legitimately take minutes on slower
|
|
5743
|
+
* or CPU-only models. We raise the default 30s RPC timeout here to 20 min
|
|
5744
|
+
* (matches the CI `--timeout 1200000` for the interpretation tests).
|
|
5745
|
+
*/
|
|
5746
|
+
async runInterpretation(uuid, transcript, basePrefix, classes) {
|
|
5747
|
+
const RUN_INTERPRETATION_TIMEOUT_MS = 20 * 60 * 1000;
|
|
5748
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.runInterpretation', { uuid, transcript, basePrefix, classes }, RUN_INTERPRETATION_TIMEOUT_MS);
|
|
5749
|
+
}
|
|
5750
|
+
/**
|
|
5751
|
+
* Register a neighbourhood auto-processor on this perspective. The executor's
|
|
5752
|
+
* watch loop then runs interpretation automatically over new source items
|
|
5753
|
+
* (like Flux per channel), coordinating which peer processes each batch via
|
|
5754
|
+
* the shared-graph ProcessingClaim, and emits step signals on the events
|
|
5755
|
+
* WebSocket (subscribe via {@link addAutoProcessorEventListener}).
|
|
5756
|
+
* Returns the processor id.
|
|
5757
|
+
*/
|
|
5758
|
+
async addAutoProcessor(uuid, config) {
|
|
5759
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addAutoProcessor', { uuid, ...config });
|
|
5760
|
+
}
|
|
5761
|
+
/** Pending interpretation overlays (LLM suggestions awaiting human accept/reject). */
|
|
5762
|
+
async interpretationOverlays(uuid) {
|
|
5763
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.interpretationOverlays', { uuid });
|
|
5764
|
+
}
|
|
5765
|
+
/** Accept an overlay's suggestion(s): the LLM value becomes the real value and
|
|
5766
|
+
* the overlay is deleted. Omit `property` to accept the whole base. */
|
|
5767
|
+
async acceptInterpretation(uuid, base, property) {
|
|
5768
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.acceptInterpretation', { uuid, base, property });
|
|
5769
|
+
}
|
|
5770
|
+
/** Reject an overlay's suggestion(s). Omit `property` to reject the whole base
|
|
5771
|
+
* (a rejected `create` deletes the suggested instance). */
|
|
5772
|
+
async rejectInterpretation(uuid, base, property) {
|
|
5773
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.rejectInterpretation', { uuid, base, property });
|
|
5774
|
+
}
|
|
5775
|
+
/**
|
|
5776
|
+
* Subscribe to auto-processor step signals. `cb` fires for every
|
|
5777
|
+
* `auto-processor-event` on `uuid` (BatchReady → Claimed/BackedOff/… →
|
|
5778
|
+
* Processed), letting a UI show progress and await the next batch.
|
|
5779
|
+
*/
|
|
5780
|
+
async addAutoProcessorEventListener(uuid, cb) {
|
|
5781
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
|
|
5782
|
+
if (data.type === 'auto-processor-event' && data.perspectiveUuid === uuid) {
|
|
5783
|
+
cb(data);
|
|
5784
|
+
}
|
|
5785
|
+
});
|
|
5786
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
|
|
5787
|
+
await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
|
|
5788
|
+
}
|
|
5614
5789
|
async addLinkExpression(uuid, link, status = 'shared', batchId) {
|
|
5615
5790
|
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinkExpression', { uuid, link, status, batchId });
|
|
5616
5791
|
}
|
|
@@ -13938,7 +14113,9 @@ class AIClient {
|
|
|
13938
14113
|
async embed(modelId, text) {
|
|
13939
14114
|
const aiEmbed = await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.embed', { modelId, text });
|
|
13940
14115
|
const compressed = base64Js.toByteArray(aiEmbed);
|
|
13941
|
-
|
|
14116
|
+
// Decode to a string via TextDecoder rather than pako's `{ to: 'string' }`
|
|
14117
|
+
// option: newer @types/pako dropped that overload, which broke the build.
|
|
14118
|
+
const decompressed = JSON.parse(new TextDecoder().decode(pako.inflate(compressed)));
|
|
13942
14119
|
return decompressed;
|
|
13943
14120
|
}
|
|
13944
14121
|
async openTranscriptionStream(modelId, streamCallback, params) {
|
|
@@ -15171,7 +15348,7 @@ class ModelQueryBuilder {
|
|
|
15171
15348
|
return JSON.stringify(results, (_, v) => typeof v === 'function' ? undefined : v);
|
|
15172
15349
|
};
|
|
15173
15350
|
lastResultFingerprint = buildFingerprint(initialResults);
|
|
15174
|
-
// Listen for subscription updates via the same
|
|
15351
|
+
// Listen for subscription updates via the same WS-RPC subscription channel.
|
|
15175
15352
|
// When Rust re-runs the model query and finds changed results, it pushes them.
|
|
15176
15353
|
const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
|
|
15177
15354
|
try {
|
|
@@ -17544,6 +17721,191 @@ class PerspectiveHandle {
|
|
|
17544
17721
|
}
|
|
17545
17722
|
}
|
|
17546
17723
|
|
|
17724
|
+
/**
|
|
17725
|
+
* TypeScript @Model classes mirroring the Rust-side SDNA for the generic
|
|
17726
|
+
* interpretation subsystem. Apps can import these to query the perspective
|
|
17727
|
+
* graph for interpretation history and pending overlay proposals without
|
|
17728
|
+
* knowing the raw link predicates.
|
|
17729
|
+
*
|
|
17730
|
+
* Registration:
|
|
17731
|
+
* await InterpretationOverlay.register(perspective);
|
|
17732
|
+
* await InterpretationRun.register(perspective);
|
|
17733
|
+
* await AutoProcessorConfig.register(perspective);
|
|
17734
|
+
*
|
|
17735
|
+
* Querying:
|
|
17736
|
+
* const pending = await InterpretationOverlay.findAll(perspective);
|
|
17737
|
+
* const runs = await InterpretationRun.findAll(perspective);
|
|
17738
|
+
* const configs = await AutoProcessorConfig.findAll(perspective);
|
|
17739
|
+
*/
|
|
17740
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
17741
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17742
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17743
|
+
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;
|
|
17744
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17745
|
+
};
|
|
17746
|
+
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
|
|
17747
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
17748
|
+
};
|
|
17749
|
+
// ── AutoProcessorConfig ─────────────────────────────────────────────────────
|
|
17750
|
+
// Mirrors the Rust `auto_processor::config::AutoProcessorConfig` SDNA.
|
|
17751
|
+
// One node per registered processor; the node URI is
|
|
17752
|
+
// `ad4m://autoprocessor/<processorId>`.
|
|
17753
|
+
let AutoProcessorConfig = class AutoProcessorConfig extends Ad4mModel {
|
|
17754
|
+
constructor() {
|
|
17755
|
+
super(...arguments);
|
|
17756
|
+
this.type = "ad4m://AutoProcessor";
|
|
17757
|
+
/** Unique processor id — the dedup key for auto-processor instances. */
|
|
17758
|
+
this.processorId = "";
|
|
17759
|
+
/** SPARQL SELECT that gathers source items each pass. */
|
|
17760
|
+
this.sourceScopeQuery = "";
|
|
17761
|
+
/** Class URIs (SHACL targetClass) to materialise each pass. */
|
|
17762
|
+
this.interpretationClasses = [];
|
|
17763
|
+
/** Quiet-window (ms) after the last new item before a pass runs. */
|
|
17764
|
+
this.debounceMs = "200";
|
|
17765
|
+
/** Maximum items per pass. */
|
|
17766
|
+
this.batchMax = "32";
|
|
17767
|
+
/** How long a won claim is authoritative before peers may re-claim (ms). */
|
|
17768
|
+
this.claimTtlMs = "60000";
|
|
17769
|
+
}
|
|
17770
|
+
};
|
|
17771
|
+
__decorate([
|
|
17772
|
+
Flag({ through: "rdf://type", value: "ad4m://AutoProcessor" }),
|
|
17773
|
+
__metadata("design:type", String)
|
|
17774
|
+
], AutoProcessorConfig.prototype, "type", void 0);
|
|
17775
|
+
__decorate([
|
|
17776
|
+
Property({ through: "ad4m://processor_id", required: true, identity: true }),
|
|
17777
|
+
__metadata("design:type", String)
|
|
17778
|
+
], AutoProcessorConfig.prototype, "processorId", void 0);
|
|
17779
|
+
__decorate([
|
|
17780
|
+
Property({ through: "ad4m://source_scope_query", required: true }),
|
|
17781
|
+
__metadata("design:type", String)
|
|
17782
|
+
], AutoProcessorConfig.prototype, "sourceScopeQuery", void 0);
|
|
17783
|
+
__decorate([
|
|
17784
|
+
Optional({ through: "ad4m://base_prefix", resolveLanguage: "literal" }),
|
|
17785
|
+
__metadata("design:type", String)
|
|
17786
|
+
], AutoProcessorConfig.prototype, "basePrefix", void 0);
|
|
17787
|
+
__decorate([
|
|
17788
|
+
HasMany({ through: "ad4m://interpretation_class" }),
|
|
17789
|
+
__metadata("design:type", Array)
|
|
17790
|
+
], AutoProcessorConfig.prototype, "interpretationClasses", void 0);
|
|
17791
|
+
__decorate([
|
|
17792
|
+
Property({ through: "ad4m://debounce_ms", required: true }),
|
|
17793
|
+
__metadata("design:type", String)
|
|
17794
|
+
], AutoProcessorConfig.prototype, "debounceMs", void 0);
|
|
17795
|
+
__decorate([
|
|
17796
|
+
Optional({ through: "ad4m://batch_min", resolveLanguage: "literal" }),
|
|
17797
|
+
__metadata("design:type", String)
|
|
17798
|
+
], AutoProcessorConfig.prototype, "batchMin", void 0);
|
|
17799
|
+
__decorate([
|
|
17800
|
+
Property({ through: "ad4m://batch_max", required: true }),
|
|
17801
|
+
__metadata("design:type", String)
|
|
17802
|
+
], AutoProcessorConfig.prototype, "batchMax", void 0);
|
|
17803
|
+
__decorate([
|
|
17804
|
+
Optional({ through: "ad4m://max_wait_ms", resolveLanguage: "literal" }),
|
|
17805
|
+
__metadata("design:type", String)
|
|
17806
|
+
], AutoProcessorConfig.prototype, "maxWaitMs", void 0);
|
|
17807
|
+
__decorate([
|
|
17808
|
+
Property({ through: "ad4m://claim_ttl_ms", required: true }),
|
|
17809
|
+
__metadata("design:type", String)
|
|
17810
|
+
], AutoProcessorConfig.prototype, "claimTtlMs", void 0);
|
|
17811
|
+
__decorate([
|
|
17812
|
+
Optional({ through: "ad4m://source_window_ms", resolveLanguage: "literal" }),
|
|
17813
|
+
__metadata("design:type", String)
|
|
17814
|
+
], AutoProcessorConfig.prototype, "sourceWindowMs", void 0);
|
|
17815
|
+
__decorate([
|
|
17816
|
+
Optional({ through: "ad4m://dedup_strategy", resolveLanguage: "literal" }),
|
|
17817
|
+
__metadata("design:type", String)
|
|
17818
|
+
], AutoProcessorConfig.prototype, "dedupStrategy", void 0);
|
|
17819
|
+
AutoProcessorConfig = __decorate([
|
|
17820
|
+
Model$1({ name: "AutoProcessorConfig" })
|
|
17821
|
+
], AutoProcessorConfig);
|
|
17822
|
+
// ── InterpretationRun ───────────────────────────────────────────────────────
|
|
17823
|
+
// Mirrors the Rust `interpretation::overlay::InterpretationRun` SDNA.
|
|
17824
|
+
// One node per completed pass; the node URI is `ad4m://interp/run/<runId>`.
|
|
17825
|
+
let InterpretationRun = class InterpretationRun extends Ad4mModel {
|
|
17826
|
+
constructor() {
|
|
17827
|
+
super(...arguments);
|
|
17828
|
+
this.type = "ad4m://interpretation-run";
|
|
17829
|
+
/** UUID for this run — the dedup key across run nodes. */
|
|
17830
|
+
this.runId = "";
|
|
17831
|
+
/**
|
|
17832
|
+
* Source item IDs consumed by this pass.
|
|
17833
|
+
* Stored as multiple links with the same predicate; the processed-turn
|
|
17834
|
+
* cursor uses these to avoid re-interpreting a turn.
|
|
17835
|
+
*/
|
|
17836
|
+
this.sources = [];
|
|
17837
|
+
}
|
|
17838
|
+
};
|
|
17839
|
+
__decorate([
|
|
17840
|
+
Flag({ through: "ad4m://type", value: "ad4m://interpretation-run" }),
|
|
17841
|
+
__metadata("design:type", String)
|
|
17842
|
+
], InterpretationRun.prototype, "type", void 0);
|
|
17843
|
+
__decorate([
|
|
17844
|
+
Property({ through: "ad4m://interp/run_id", required: true, identity: true }),
|
|
17845
|
+
__metadata("design:type", String)
|
|
17846
|
+
], InterpretationRun.prototype, "runId", void 0);
|
|
17847
|
+
__decorate([
|
|
17848
|
+
Optional({ through: "ad4m://interp/model", resolveLanguage: "literal" }),
|
|
17849
|
+
__metadata("design:type", String)
|
|
17850
|
+
], InterpretationRun.prototype, "model", void 0);
|
|
17851
|
+
__decorate([
|
|
17852
|
+
Optional({ through: "ad4m://interp/prompt_version", resolveLanguage: "literal" }),
|
|
17853
|
+
__metadata("design:type", String)
|
|
17854
|
+
], InterpretationRun.prototype, "promptVersion", void 0);
|
|
17855
|
+
__decorate([
|
|
17856
|
+
Optional({ through: "ad4m://interp/ran_at", resolveLanguage: "literal" }),
|
|
17857
|
+
__metadata("design:type", String)
|
|
17858
|
+
], InterpretationRun.prototype, "ranAt", void 0);
|
|
17859
|
+
__decorate([
|
|
17860
|
+
Optional({ through: "ad4m://interp/processor", resolveLanguage: "literal" }),
|
|
17861
|
+
__metadata("design:type", String)
|
|
17862
|
+
], InterpretationRun.prototype, "processor", void 0);
|
|
17863
|
+
__decorate([
|
|
17864
|
+
HasMany({ through: "ad4m://interp/sources" }),
|
|
17865
|
+
__metadata("design:type", Array)
|
|
17866
|
+
], InterpretationRun.prototype, "sources", void 0);
|
|
17867
|
+
InterpretationRun = __decorate([
|
|
17868
|
+
Model$1({ name: "InterpretationRun" })
|
|
17869
|
+
], InterpretationRun);
|
|
17870
|
+
// ── InterpretationOverlay ───────────────────────────────────────────────────
|
|
17871
|
+
// Mirrors the Rust `interpretation::overlay::InterpretationOverlay` SDNA.
|
|
17872
|
+
// An overlay sits on the *same* base URI as the proposed instance — it is a
|
|
17873
|
+
// pending LLM suggestion awaiting human accept/reject.
|
|
17874
|
+
//
|
|
17875
|
+
// The dynamic "inferred" values are stored as links with predicates of the
|
|
17876
|
+
// form `ad4m://interp/inferred/<realPredicate>` and are NOT captured here as
|
|
17877
|
+
// fixed @Property fields because the predicates vary per class. Read them
|
|
17878
|
+
// directly via perspective.get({ source: overlay.baseExpression }).
|
|
17879
|
+
//
|
|
17880
|
+
// Accept → perspective.acceptInterpretationOverlay(base) [deletes the overlay]
|
|
17881
|
+
// Reject → perspective.rejectInterpretationOverlay(base) [drops the suggestion]
|
|
17882
|
+
//
|
|
17883
|
+
// Note: `findAll` finds ALL nodes that currently carry a `kind` link, i.e.
|
|
17884
|
+
// all pending proposals. Accepted/rejected overlays are removed from the
|
|
17885
|
+
// graph and will not appear.
|
|
17886
|
+
let InterpretationOverlay = class InterpretationOverlay extends Ad4mModel {
|
|
17887
|
+
constructor() {
|
|
17888
|
+
super(...arguments);
|
|
17889
|
+
/**
|
|
17890
|
+
* Whether the LLM authored the whole instance (`"create"`) or proposed
|
|
17891
|
+
* changes to an existing one (`"update"`). This is the discriminator link
|
|
17892
|
+
* that makes a node identifiable as an overlay.
|
|
17893
|
+
*/
|
|
17894
|
+
this.kind = "";
|
|
17895
|
+
}
|
|
17896
|
+
};
|
|
17897
|
+
__decorate([
|
|
17898
|
+
Property({ through: "ad4m://interp/kind", required: true, resolveLanguage: "literal" }),
|
|
17899
|
+
__metadata("design:type", String)
|
|
17900
|
+
], InterpretationOverlay.prototype, "kind", void 0);
|
|
17901
|
+
__decorate([
|
|
17902
|
+
Optional({ through: "ad4m://interp/run", resolveLanguage: "literal" }),
|
|
17903
|
+
__metadata("design:type", String)
|
|
17904
|
+
], InterpretationOverlay.prototype, "run", void 0);
|
|
17905
|
+
InterpretationOverlay = __decorate([
|
|
17906
|
+
Model$1({ name: "InterpretationOverlay" })
|
|
17907
|
+
], InterpretationOverlay);
|
|
17908
|
+
|
|
17547
17909
|
/**
|
|
17548
17910
|
* SPARQL binding helpers — typed shapes and parsers for `querySparql<T>()`.
|
|
17549
17911
|
*
|
|
@@ -18222,4 +18584,4 @@ const fileToDataUri = ifExpr(exists(path('file_storage://data_base64')))
|
|
|
18222
18584
|
.then(concat(literal('data:'), coalesce(path('file_storage://file_type'), literal('image/png')), literal(';base64,'), path('file_storage://data_base64')))
|
|
18223
18585
|
.else(focus());
|
|
18224
18586
|
|
|
18225
|
-
export { AIClient, Model as AIModel, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, BelongsToMany, BelongsToOne, Capability, CapabilityInput, ComputeLogEntry, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, HasMany, HasOne, HostingUserInfo, IDBCache, Icon, ImportResult, ImportStats, InteractionCall, InteractionMeta, InteractionParameter, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, LocalModel, LocalModelInput, Model$1 as Model, ModelApi, ModelApiInput, ModelInput, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, NullCache, OnlineAgent, Optional, PaymentRequestResult, Perspective, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, ReadOnly, Resource, ResourceInput, RpcError as RestError, RpcError, RuntimeInfo, SHACLFlow, SHACLShape, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, TokenizerSource, TokenizerSourceInput, TriggeredNotification, UserCreationResult, UserStatistics, VerificationRequestResult, VoiceActivityParamsInput, WakerSubscriptionManager, buildConformanceFilter, buildModelFromJSONSchema, buildPaginationSubquery, buildSDNA, buildSHACL, buildSPARQLQuery, buildWhereCondition, capSentence, clearQueryCache, coalesce, compileWhereClause, concat, createPersistentCache, determineNamespace, determinePredicate, escapeQueryString, exists, exprRef2String, fileToDataUri, fn, focus, formatList, formatQueryValue, formatSPARQLValue, getCachedResult, getDefaultValueForType, getMemoizedSHACL, getPropertiesMetadata, getPropertyOption, getRelationsMetadata, hasJsOnlyWhereFilters, ifExpr, invalidatePerspectiveCache, isArrayType, isExpression, isIncludeProjection, isLink, isNodeExpression, isNumericType, isObjectType, isSchemaType, linkEqual, literal, normalizeNamespaceString, normalizeSchemaType, normalizeValue, parseExprUrl, parseLit, parseLitBoolean, parseLitNumber, parseSparqlCount, path, queryCacheSize, resolveParentPredicate, setCachedResult, setPropertyRegistryEntry, setRelationRegistryEntry, typeDefsString };
|
|
18587
|
+
export { AIClient, Model as AIModel, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, AutoProcessorConfig, BelongsToMany, BelongsToOne, Capability, CapabilityInput, ComputeLogEntry, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, HasMany, HasOne, HostingUserInfo, IDBCache, Icon, ImportResult, ImportStats, InteractionCall, InteractionMeta, InteractionParameter, InterpretationOverlay, InterpretationRun, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, LocalModel, LocalModelInput, Model$1 as Model, ModelApi, ModelApiInput, ModelInput, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, NullCache, OnlineAgent, Optional, PaymentRequestResult, Perspective, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, ReadOnly, Resource, ResourceInput, RpcError as RestError, RpcError, RuntimeInfo, SHACLFlow, SHACLShape, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, TokenizerSource, TokenizerSourceInput, TriggeredNotification, UserCreationResult, UserStatistics, VerificationRequestResult, VoiceActivityParamsInput, WakerSubscriptionManager, buildConformanceFilter, buildModelFromJSONSchema, buildPaginationSubquery, buildSDNA, buildSHACL, buildSPARQLQuery, buildWhereCondition, capSentence, clearQueryCache, coalesce, compileWhereClause, concat, createPersistentCache, determineNamespace, determinePredicate, escapeQueryString, exists, exprRef2String, fileToDataUri, fn, focus, formatList, formatQueryValue, formatSPARQLValue, getCachedResult, getDefaultValueForType, getMemoizedSHACL, getPropertiesMetadata, getPropertyOption, getRelationsMetadata, hasJsOnlyWhereFilters, ifExpr, invalidatePerspectiveCache, isArrayType, isExpression, isIncludeProjection, isLink, isNodeExpression, isNumericType, isObjectType, isSchemaType, linkEqual, literal, normalizeNamespaceString, normalizeSchemaType, normalizeValue, parseExprUrl, parseLit, parseLitBoolean, parseLitNumber, parseSparqlCount, path, queryCacheSize, resolveParentPredicate, setCachedResult, setPropertyRegistryEntry, setRelationRegistryEntry, typeDefsString };
|
package/lib/src/ai/AIClient.js
CHANGED
|
@@ -77,7 +77,9 @@ export class AIClient {
|
|
|
77
77
|
async embed(modelId, text) {
|
|
78
78
|
const aiEmbed = await __classPrivateFieldGet(this, _AIClient_apiClient, "f").call('ai.embed', { modelId, text });
|
|
79
79
|
const compressed = base64js.toByteArray(aiEmbed);
|
|
80
|
-
|
|
80
|
+
// Decode to a string via TextDecoder rather than pako's `{ to: 'string' }`
|
|
81
|
+
// option: newer @types/pako dropped that overload, which broke the build.
|
|
82
|
+
const decompressed = JSON.parse(new TextDecoder().decode(pako.inflate(compressed)));
|
|
81
83
|
return decompressed;
|
|
82
84
|
}
|
|
83
85
|
async openTranscriptionStream(modelId, streamCallback, params) {
|
package/lib/src/apiClient.d.ts
CHANGED
|
@@ -42,9 +42,12 @@ export declare class ApiClient {
|
|
|
42
42
|
* Send an RPC call over the WebSocket connection.
|
|
43
43
|
* @param type - The operation type (e.g. 'agent.get', 'perspective.all')
|
|
44
44
|
* @param params - Optional parameters to include in the message
|
|
45
|
+
* @param timeoutMs - Optional per-call timeout override in ms. Defaults to
|
|
46
|
+
* [[DEFAULT_TIMEOUT_MS]]. Use for long-running calls (LLM prompts,
|
|
47
|
+
* holochain ops) that legitimately exceed the default.
|
|
45
48
|
* @returns Promise that resolves with the result from the server
|
|
46
49
|
*/
|
|
47
|
-
call<T>(type: string, params?: Record<string, unknown
|
|
50
|
+
call<T>(type: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<T>;
|
|
48
51
|
subscribe<T = WsEvent>(callback: (data: T) => void): () => void;
|
|
49
52
|
/** Wait until the WebSocket connection is established. */
|
|
50
53
|
waitForSubscription(): Promise<void>;
|
package/lib/src/apiClient.js
CHANGED
|
@@ -163,20 +163,24 @@ export class ApiClient {
|
|
|
163
163
|
* Send an RPC call over the WebSocket connection.
|
|
164
164
|
* @param type - The operation type (e.g. 'agent.get', 'perspective.all')
|
|
165
165
|
* @param params - Optional parameters to include in the message
|
|
166
|
+
* @param timeoutMs - Optional per-call timeout override in ms. Defaults to
|
|
167
|
+
* [[DEFAULT_TIMEOUT_MS]]. Use for long-running calls (LLM prompts,
|
|
168
|
+
* holochain ops) that legitimately exceed the default.
|
|
166
169
|
* @returns Promise that resolves with the result from the server
|
|
167
170
|
*/
|
|
168
|
-
async call(type, params) {
|
|
171
|
+
async call(type, params, timeoutMs) {
|
|
169
172
|
await this._ready();
|
|
170
173
|
const id = nextId();
|
|
171
174
|
// Put params under a "params" key to avoid collision with
|
|
172
175
|
// protocol fields "id" and "type" (e.g. params might contain
|
|
173
176
|
// { id: modelId } or { type: "db" }).
|
|
174
177
|
const message = { id, type, params: params || {} };
|
|
178
|
+
const effectiveTimeout = timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
175
179
|
return new Promise((resolve, reject) => {
|
|
176
180
|
const timer = setTimeout(() => {
|
|
177
181
|
this._pendingCalls.delete(id);
|
|
178
|
-
reject(new RpcError(408, `RPC call '${type}' timed out after ${
|
|
179
|
-
},
|
|
182
|
+
reject(new RpcError(408, `RPC call '${type}' timed out after ${effectiveTimeout}ms`));
|
|
183
|
+
}, effectiveTimeout);
|
|
180
184
|
this._pendingCalls.set(id, {
|
|
181
185
|
resolve: resolve,
|
|
182
186
|
reject,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TranscriptTurn } from "./TranscriptTurn";
|
|
2
|
+
/**
|
|
3
|
+
* Run generic LLM interpretation over a transcript into the perspective's own
|
|
4
|
+
* SHACL subject classes. Shapes are resolved server-side from the
|
|
5
|
+
* perspective's registered classes, so callers pass only the transcript.
|
|
6
|
+
*/
|
|
7
|
+
export type RunInterpretationRequest = {
|
|
8
|
+
uuid: string;
|
|
9
|
+
transcript: Array<TranscriptTurn>;
|
|
10
|
+
/**
|
|
11
|
+
* URI namespace new instance identities are minted under, e.g. `soa://ext/`.
|
|
12
|
+
*/
|
|
13
|
+
basePrefix: string;
|
|
14
|
+
/**
|
|
15
|
+
* Local names of the subject classes to extract into (e.g. `["Task","Belief"]`).
|
|
16
|
+
* `None`/empty selects all subject classes registered in the perspective.
|
|
17
|
+
*/
|
|
18
|
+
classes: Array<string> | null;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -29,11 +29,13 @@ export type { PublishNeighbourhoodRequest } from "./PublishNeighbourhoodRequest"
|
|
|
29
29
|
export type { QueryRequest } from "./QueryRequest";
|
|
30
30
|
export type { RemoveLinkRequest } from "./RemoveLinkRequest";
|
|
31
31
|
export type { RemoveLinksBulkRequest } from "./RemoveLinksBulkRequest";
|
|
32
|
+
export type { RunInterpretationRequest } from "./RunInterpretationRequest";
|
|
32
33
|
export type { SetDefaultModelRequest } from "./SetDefaultModelRequest";
|
|
33
34
|
export type { SetFreeHostingEnabledRequest } from "./SetFreeHostingEnabledRequest";
|
|
34
35
|
export type { SetMultiUserRequest } from "./SetMultiUserRequest";
|
|
35
36
|
export type { SetStatusRequest } from "./SetStatusRequest";
|
|
36
37
|
export type { SignMessageRequest } from "./SignMessageRequest";
|
|
38
|
+
export type { TranscriptTurn } from "./TranscriptTurn";
|
|
37
39
|
export type { TrustedAgentsRequest } from "./TrustedAgentsRequest";
|
|
38
40
|
export type { UnlockAgentRequest } from "./UnlockAgentRequest";
|
|
39
41
|
export type { UpdateLinkRequest } from "./UpdateLinkRequest";
|
package/lib/src/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export * from "./Literal";
|
|
|
16
16
|
export * from "./perspectives/Perspective";
|
|
17
17
|
export * from "./perspectives/PerspectiveHandle";
|
|
18
18
|
export * from "./perspectives/PerspectiveProxy";
|
|
19
|
+
export * from "./perspectives/AutoProcessor";
|
|
20
|
+
export * from "./perspectives/InterpretationModels";
|
|
19
21
|
export * from "./perspectives/SparqlBindings";
|
|
20
22
|
export * from "./perspectives/WakerSubscriptionManager";
|
|
21
23
|
export * from "./perspectives/PerspectiveDiff";
|