@coasys/ad4m 0.13.0-test-9 → 0.13.0-test-interpretation
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 +368 -8
- package/lib/index.js +369 -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 +43 -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.ts +80 -4
package/lib/index.cjs
CHANGED
|
@@ -167,20 +167,24 @@ class ApiClient {
|
|
|
167
167
|
* Send an RPC call over the WebSocket connection.
|
|
168
168
|
* @param type - The operation type (e.g. 'agent.get', 'perspective.all')
|
|
169
169
|
* @param params - Optional parameters to include in the message
|
|
170
|
+
* @param timeoutMs - Optional per-call timeout override in ms. Defaults to
|
|
171
|
+
* [[DEFAULT_TIMEOUT_MS]]. Use for long-running calls (LLM prompts,
|
|
172
|
+
* holochain ops) that legitimately exceed the default.
|
|
170
173
|
* @returns Promise that resolves with the result from the server
|
|
171
174
|
*/
|
|
172
|
-
async call(type, params) {
|
|
175
|
+
async call(type, params, timeoutMs) {
|
|
173
176
|
await this._ready();
|
|
174
177
|
const id = nextId();
|
|
175
178
|
// Put params under a "params" key to avoid collision with
|
|
176
179
|
// protocol fields "id" and "type" (e.g. params might contain
|
|
177
180
|
// { id: modelId } or { type: "db" }).
|
|
178
181
|
const message = { id, type, params: params || {} };
|
|
182
|
+
const effectiveTimeout = timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
179
183
|
return new Promise((resolve, reject) => {
|
|
180
184
|
const timer = setTimeout(() => {
|
|
181
185
|
this._pendingCalls.delete(id);
|
|
182
|
-
reject(new RpcError(408, `RPC call '${type}' timed out after ${
|
|
183
|
-
},
|
|
186
|
+
reject(new RpcError(408, `RPC call '${type}' timed out after ${effectiveTimeout}ms`));
|
|
187
|
+
}, effectiveTimeout);
|
|
184
188
|
this._pendingCalls.set(id, {
|
|
185
189
|
resolve: resolve,
|
|
186
190
|
reject,
|
|
@@ -1233,6 +1237,15 @@ class SHACLShape {
|
|
|
1233
1237
|
target: `literal:string:${JSON.stringify(this.destructor_actions)}`
|
|
1234
1238
|
});
|
|
1235
1239
|
}
|
|
1240
|
+
// Class-level interpretation hint — read by the Rust model query as
|
|
1241
|
+
// `ModelShape.interpretation_hint` and fed to the generic LLM extractor.
|
|
1242
|
+
if (this.interpretationHint) {
|
|
1243
|
+
links.push({
|
|
1244
|
+
source: this.nodeShapeUri,
|
|
1245
|
+
predicate: "ad4m://interpretation_hint",
|
|
1246
|
+
target: `literal:string:${this.interpretationHint}`
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1236
1249
|
// Property shapes (each gets a named URI: {namespace}/{ClassName}.{propertyName})
|
|
1237
1250
|
for (let i = 0; i < this.properties.length; i++) {
|
|
1238
1251
|
const prop = this.properties[i];
|
|
@@ -1432,6 +1445,20 @@ class SHACLShape {
|
|
|
1432
1445
|
target: `literal:string:${JSON.stringify(prop.transform)}`
|
|
1433
1446
|
});
|
|
1434
1447
|
}
|
|
1448
|
+
if (prop.interpretationHint) {
|
|
1449
|
+
links.push({
|
|
1450
|
+
source: propShapeId,
|
|
1451
|
+
predicate: "ad4m://interpretation_hint",
|
|
1452
|
+
target: `literal:string:${prop.interpretationHint}`
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
if (prop.identity) {
|
|
1456
|
+
links.push({
|
|
1457
|
+
source: propShapeId,
|
|
1458
|
+
predicate: "ad4m://identity",
|
|
1459
|
+
target: `literal:string:true`
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1435
1462
|
}
|
|
1436
1463
|
return links;
|
|
1437
1464
|
}
|
|
@@ -1464,6 +1491,11 @@ class SHACLShape {
|
|
|
1464
1491
|
// Ignore parse errors
|
|
1465
1492
|
}
|
|
1466
1493
|
}
|
|
1494
|
+
// Class-level interpretation hint (mirror of the emit in toLinks())
|
|
1495
|
+
const classHintLink = links.find(l => l.source === shapeUri && l.predicate === "ad4m://interpretation_hint");
|
|
1496
|
+
if (classHintLink) {
|
|
1497
|
+
shape.interpretationHint = classHintLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
|
|
1498
|
+
}
|
|
1467
1499
|
// Find all property shapes
|
|
1468
1500
|
const propShapeLinks = links.filter(l => l.source === shapeUri && l.predicate === "sh://property");
|
|
1469
1501
|
for (const propLink of propShapeLinks) {
|
|
@@ -1651,6 +1683,15 @@ class SHACLShape {
|
|
|
1651
1683
|
val = val.substring(8);
|
|
1652
1684
|
prop.filter = val === 'true';
|
|
1653
1685
|
}
|
|
1686
|
+
const interpretationHintLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://interpretation_hint");
|
|
1687
|
+
if (interpretationHintLink) {
|
|
1688
|
+
prop.interpretationHint = interpretationHintLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
|
|
1689
|
+
}
|
|
1690
|
+
const identityLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://identity");
|
|
1691
|
+
if (identityLink) {
|
|
1692
|
+
prop.identity =
|
|
1693
|
+
identityLink.target.replace(/^literal:\/\/string:|^literal:string:/, '') === 'true';
|
|
1694
|
+
}
|
|
1654
1695
|
const transformLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://transform");
|
|
1655
1696
|
if (transformLink) {
|
|
1656
1697
|
const jsonStr = transformLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
|
|
@@ -1682,6 +1723,7 @@ class SHACLShape {
|
|
|
1682
1723
|
node_shape_uri: this.nodeShapeUri,
|
|
1683
1724
|
target_class: this.targetClass,
|
|
1684
1725
|
parent_shapes: this.parentShapes.length > 0 ? this.parentShapes : undefined,
|
|
1726
|
+
interpretation_hint: this.interpretationHint,
|
|
1685
1727
|
properties: this.properties.map(p => ({
|
|
1686
1728
|
path: p.path,
|
|
1687
1729
|
name: p.name,
|
|
@@ -1709,6 +1751,7 @@ class SHACLShape {
|
|
|
1709
1751
|
where_predicates: p.wherePredicates,
|
|
1710
1752
|
filter: p.filter,
|
|
1711
1753
|
transform: p.transform,
|
|
1754
|
+
interpretation_hint: p.interpretationHint,
|
|
1712
1755
|
})),
|
|
1713
1756
|
constructor_actions: this.constructor_actions,
|
|
1714
1757
|
destructor_actions: this.destructor_actions,
|
|
@@ -1754,6 +1797,7 @@ class SHACLShape {
|
|
|
1754
1797
|
wherePredicates: p.where_predicates,
|
|
1755
1798
|
filter: p.filter,
|
|
1756
1799
|
transform: p.transform,
|
|
1800
|
+
interpretationHint: p.interpretation_hint,
|
|
1757
1801
|
});
|
|
1758
1802
|
}
|
|
1759
1803
|
if (json.constructor_actions) {
|
|
@@ -1767,6 +1811,9 @@ class SHACLShape {
|
|
|
1767
1811
|
shape.addParentShape(ps);
|
|
1768
1812
|
}
|
|
1769
1813
|
}
|
|
1814
|
+
if (json.interpretation_hint) {
|
|
1815
|
+
shape.interpretationHint = json.interpretation_hint;
|
|
1816
|
+
}
|
|
1770
1817
|
return shape;
|
|
1771
1818
|
}
|
|
1772
1819
|
}
|
|
@@ -1801,7 +1848,14 @@ function buildSHACL(subjectName, target, properties, allRelationsMeta, conforman
|
|
|
1801
1848
|
* `getMemoizedSHACL`; safe to omit when calling `buildSHACL`
|
|
1802
1849
|
* directly (e.g. from a one-off SDNA build tool).
|
|
1803
1850
|
*/
|
|
1804
|
-
seedCache
|
|
1851
|
+
seedCache,
|
|
1852
|
+
/**
|
|
1853
|
+
* Natural-language hint declared on the `@Model` decorator that
|
|
1854
|
+
* steers the generic LLM extractor when producing instances of
|
|
1855
|
+
* this class. Attached to the SHACL shape node and re-emitted as
|
|
1856
|
+
* an `ad4m://interpretation_hint` link by `SHACLShape.toLinks()`.
|
|
1857
|
+
*/
|
|
1858
|
+
interpretationHint) {
|
|
1805
1859
|
const obj = target.prototype;
|
|
1806
1860
|
// ── Determine namespace from first property or relation ─────────────
|
|
1807
1861
|
let namespace = "ad4m://";
|
|
@@ -1829,6 +1883,9 @@ seedCache) {
|
|
|
1829
1883
|
const shapeUri = `${namespace}${subjectName}Shape`;
|
|
1830
1884
|
const targetClass = `${namespace}${subjectName}`;
|
|
1831
1885
|
const shape = new SHACLShape(shapeUri, targetClass);
|
|
1886
|
+
if (interpretationHint) {
|
|
1887
|
+
shape.interpretationHint = interpretationHint;
|
|
1888
|
+
}
|
|
1832
1889
|
// ── Seed the memoisation cache while we keep building ──────────────
|
|
1833
1890
|
// Any subsequent `target.generateSHACL()` call from inside this
|
|
1834
1891
|
// function (typically when walking a self-referential or
|
|
@@ -1915,6 +1972,16 @@ seedCache) {
|
|
|
1915
1972
|
if (propMeta.transform) {
|
|
1916
1973
|
propShape.transform = propMeta.transform;
|
|
1917
1974
|
}
|
|
1975
|
+
// Natural-language interpretation hint (read by the generic LLM
|
|
1976
|
+
// extractor via ShapeProperty.interpretation_hint).
|
|
1977
|
+
if (propMeta.interpretationHint) {
|
|
1978
|
+
propShape.interpretationHint = propMeta.interpretationHint;
|
|
1979
|
+
}
|
|
1980
|
+
// Declared-identity dedup key for the generic LLM interpreter
|
|
1981
|
+
// (emitted as `ad4m://identity` by SHACLShape.toLinks()).
|
|
1982
|
+
if (propMeta.identity) {
|
|
1983
|
+
propShape.identity = true;
|
|
1984
|
+
}
|
|
1918
1985
|
// ── Setter actions ──────────────────────────────────────────────
|
|
1919
1986
|
if (propMeta.prologSetter) {
|
|
1920
1987
|
console.warn(`[SHACL Generation] Custom Prolog setter for property '${propName}' in class '${subjectName}' is not yet supported. ` +
|
|
@@ -2559,7 +2626,7 @@ function Model$1(opts) {
|
|
|
2559
2626
|
return buildSDNA(opts.name, target.prototype, getPropertiesMetadata(target), getRelationsMetadata(target));
|
|
2560
2627
|
};
|
|
2561
2628
|
target.generateSHACL = function () {
|
|
2562
|
-
return getMemoizedSHACL(target, (seed) => buildSHACL(opts.name, target, getPropertiesMetadata(target), getRelationsMetadata(target), buildConformanceFilter, seed));
|
|
2629
|
+
return getMemoizedSHACL(target, (seed) => buildSHACL(opts.name, target, getPropertiesMetadata(target), getRelationsMetadata(target), buildConformanceFilter, seed, opts.interpretationHint));
|
|
2563
2630
|
};
|
|
2564
2631
|
Object.defineProperty(target, 'type', { configurable: true });
|
|
2565
2632
|
};
|
|
@@ -3785,6 +3852,58 @@ class PerspectiveProxy {
|
|
|
3785
3852
|
async get(query) {
|
|
3786
3853
|
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
|
|
3787
3854
|
}
|
|
3855
|
+
/**
|
|
3856
|
+
* Runs generic LLM interpretation over a conversation transcript, turning it
|
|
3857
|
+
* into typed instances of this perspective's own SHACL subject classes
|
|
3858
|
+
* (steered by each class's `@InterpretationHint`). The target shapes are
|
|
3859
|
+
* resolved automatically from the perspective's registered classes, so you
|
|
3860
|
+
* pass only the transcript. New instances are written as links into this
|
|
3861
|
+
* perspective; the returned placements list each instance's base URI and
|
|
3862
|
+
* the links written for it.
|
|
3863
|
+
*
|
|
3864
|
+
* @param transcript ordered `{ speaker, text }` turns
|
|
3865
|
+
* @param basePrefix URI namespace for new instance identities, e.g. `soa://ext/`
|
|
3866
|
+
* @param classes local names of the subject classes to extract into; omit for all
|
|
3867
|
+
*/
|
|
3868
|
+
async runInterpretation(transcript, basePrefix, classes) {
|
|
3869
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").runInterpretation(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, classes);
|
|
3870
|
+
}
|
|
3871
|
+
/**
|
|
3872
|
+
* Register a neighbourhood auto-processor on this perspective. The executor
|
|
3873
|
+
* then runs interpretation automatically over new source items (like Flux
|
|
3874
|
+
* per channel), coordinating which peer processes each batch. Returns the
|
|
3875
|
+
* processor id. Subscribe to progress via {@link addAutoProcessorEventListener}.
|
|
3876
|
+
*/
|
|
3877
|
+
async addAutoProcessor(config) {
|
|
3878
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addAutoProcessor(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, config);
|
|
3879
|
+
}
|
|
3880
|
+
/**
|
|
3881
|
+
* Pending interpretation overlays on this perspective — LLM suggestions the
|
|
3882
|
+
* §4 divergence gate staged rather than applied, awaiting human accept/reject.
|
|
3883
|
+
*/
|
|
3884
|
+
async interpretationOverlays() {
|
|
3885
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").interpretationOverlays(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3886
|
+
}
|
|
3887
|
+
/**
|
|
3888
|
+
* Accept an interpretation overlay's suggestion(s): the LLM's staged value
|
|
3889
|
+
* becomes the real, human-owned value and the overlay is deleted. Pass
|
|
3890
|
+
* `property` to accept a single predicate; omit it for the whole base.
|
|
3891
|
+
*/
|
|
3892
|
+
async acceptInterpretation(base, property) {
|
|
3893
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").acceptInterpretation(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, base, property);
|
|
3894
|
+
}
|
|
3895
|
+
/**
|
|
3896
|
+
* Reject an interpretation overlay's suggestion(s). Omit `property` to reject
|
|
3897
|
+
* the whole base — a rejected `create` deletes the suggested instance, a
|
|
3898
|
+
* rejected `update` drops the overlay and keeps the real value.
|
|
3899
|
+
*/
|
|
3900
|
+
async rejectInterpretation(base, property) {
|
|
3901
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").rejectInterpretation(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, base, property);
|
|
3902
|
+
}
|
|
3903
|
+
/** Subscribe to this perspective's auto-processor step signals. */
|
|
3904
|
+
async addAutoProcessorEventListener(cb) {
|
|
3905
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addAutoProcessorEventListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, cb);
|
|
3906
|
+
}
|
|
3788
3907
|
/**
|
|
3789
3908
|
* Executes a Prolog query against the perspective's knowledge base.
|
|
3790
3909
|
* This is a powerful way to find complex patterns in the graph.
|
|
@@ -3869,7 +3988,7 @@ class PerspectiveProxy {
|
|
|
3869
3988
|
* internally in Rust, registers a subscription, runs the initial query, and
|
|
3870
3989
|
* pushes updated results when relevant links change.
|
|
3871
3990
|
*
|
|
3872
|
-
* The subscription reuses the same
|
|
3991
|
+
* The subscription reuses the same WS-RPC subscription channel as subscribeQuery().
|
|
3873
3992
|
* Use keepAliveQuery() / disposeQuerySubscription() with the returned subscriptionId.
|
|
3874
3993
|
*
|
|
3875
3994
|
* @param className - The model class name
|
|
@@ -5615,6 +5734,60 @@ class PerspectiveClient {
|
|
|
5615
5734
|
async linkMutations(uuid, mutations, status) {
|
|
5616
5735
|
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.linkMutations', { uuid, mutations, status });
|
|
5617
5736
|
}
|
|
5737
|
+
/**
|
|
5738
|
+
* Run generic LLM interpretation over a transcript into this perspective's own
|
|
5739
|
+
* SHACL subject classes. The target shapes are resolved server-side from the
|
|
5740
|
+
* perspective's registered subject classes, so you pass only the transcript.
|
|
5741
|
+
* Returns the freshly minted instances (their base URIs + the links written).
|
|
5742
|
+
*
|
|
5743
|
+
* The server-side call prompts an LLM (up to `INTERPRETATION_MAX_ATTEMPTS`
|
|
5744
|
+
* retries on parse failure), so it can legitimately take minutes on slower
|
|
5745
|
+
* or CPU-only models. We raise the default 30s RPC timeout here to 20 min
|
|
5746
|
+
* (matches the CI `--timeout 1200000` for the interpretation tests).
|
|
5747
|
+
*/
|
|
5748
|
+
async runInterpretation(uuid, transcript, basePrefix, classes) {
|
|
5749
|
+
const RUN_INTERPRETATION_TIMEOUT_MS = 20 * 60 * 1000;
|
|
5750
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.runInterpretation', { uuid, transcript, basePrefix, classes }, RUN_INTERPRETATION_TIMEOUT_MS);
|
|
5751
|
+
}
|
|
5752
|
+
/**
|
|
5753
|
+
* Register a neighbourhood auto-processor on this perspective. The executor's
|
|
5754
|
+
* watch loop then runs interpretation automatically over new source items
|
|
5755
|
+
* (like Flux per channel), coordinating which peer processes each batch via
|
|
5756
|
+
* the shared-graph ProcessingClaim, and emits step signals on the events
|
|
5757
|
+
* WebSocket (subscribe via {@link addAutoProcessorEventListener}).
|
|
5758
|
+
* Returns the processor id.
|
|
5759
|
+
*/
|
|
5760
|
+
async addAutoProcessor(uuid, config) {
|
|
5761
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addAutoProcessor', { uuid, ...config });
|
|
5762
|
+
}
|
|
5763
|
+
/** Pending interpretation overlays (LLM suggestions awaiting human accept/reject). */
|
|
5764
|
+
async interpretationOverlays(uuid) {
|
|
5765
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.interpretationOverlays', { uuid });
|
|
5766
|
+
}
|
|
5767
|
+
/** Accept an overlay's suggestion(s): the LLM value becomes the real value and
|
|
5768
|
+
* the overlay is deleted. Omit `property` to accept the whole base. */
|
|
5769
|
+
async acceptInterpretation(uuid, base, property) {
|
|
5770
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.acceptInterpretation', { uuid, base, property });
|
|
5771
|
+
}
|
|
5772
|
+
/** Reject an overlay's suggestion(s). Omit `property` to reject the whole base
|
|
5773
|
+
* (a rejected `create` deletes the suggested instance). */
|
|
5774
|
+
async rejectInterpretation(uuid, base, property) {
|
|
5775
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.rejectInterpretation', { uuid, base, property });
|
|
5776
|
+
}
|
|
5777
|
+
/**
|
|
5778
|
+
* Subscribe to auto-processor step signals. `cb` fires for every
|
|
5779
|
+
* `auto-processor-event` on `uuid` (BatchReady → Claimed/BackedOff/… →
|
|
5780
|
+
* Processed), letting a UI show progress and await the next batch.
|
|
5781
|
+
*/
|
|
5782
|
+
async addAutoProcessorEventListener(uuid, cb) {
|
|
5783
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
|
|
5784
|
+
if (data.type === 'auto-processor-event' && data.perspectiveUuid === uuid) {
|
|
5785
|
+
cb(data);
|
|
5786
|
+
}
|
|
5787
|
+
});
|
|
5788
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
|
|
5789
|
+
await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
|
|
5790
|
+
}
|
|
5618
5791
|
async addLinkExpression(uuid, link, status = 'shared', batchId) {
|
|
5619
5792
|
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinkExpression', { uuid, link, status, batchId });
|
|
5620
5793
|
}
|
|
@@ -13942,7 +14115,9 @@ class AIClient {
|
|
|
13942
14115
|
async embed(modelId, text) {
|
|
13943
14116
|
const aiEmbed = await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.embed', { modelId, text });
|
|
13944
14117
|
const compressed = base64Js.toByteArray(aiEmbed);
|
|
13945
|
-
|
|
14118
|
+
// Decode to a string via TextDecoder rather than pako's `{ to: 'string' }`
|
|
14119
|
+
// option: newer @types/pako dropped that overload, which broke the build.
|
|
14120
|
+
const decompressed = JSON.parse(new TextDecoder().decode(pako.inflate(compressed)));
|
|
13946
14121
|
return decompressed;
|
|
13947
14122
|
}
|
|
13948
14123
|
async openTranscriptionStream(modelId, streamCallback, params) {
|
|
@@ -15175,7 +15350,7 @@ class ModelQueryBuilder {
|
|
|
15175
15350
|
return JSON.stringify(results, (_, v) => typeof v === 'function' ? undefined : v);
|
|
15176
15351
|
};
|
|
15177
15352
|
lastResultFingerprint = buildFingerprint(initialResults);
|
|
15178
|
-
// Listen for subscription updates via the same
|
|
15353
|
+
// Listen for subscription updates via the same WS-RPC subscription channel.
|
|
15179
15354
|
// When Rust re-runs the model query and finds changed results, it pushes them.
|
|
15180
15355
|
const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
|
|
15181
15356
|
try {
|
|
@@ -17548,6 +17723,191 @@ class PerspectiveHandle {
|
|
|
17548
17723
|
}
|
|
17549
17724
|
}
|
|
17550
17725
|
|
|
17726
|
+
/**
|
|
17727
|
+
* TypeScript @Model classes mirroring the Rust-side SDNA for the generic
|
|
17728
|
+
* interpretation subsystem. Apps can import these to query the perspective
|
|
17729
|
+
* graph for interpretation history and pending overlay proposals without
|
|
17730
|
+
* knowing the raw link predicates.
|
|
17731
|
+
*
|
|
17732
|
+
* Registration:
|
|
17733
|
+
* await InterpretationOverlay.register(perspective);
|
|
17734
|
+
* await InterpretationRun.register(perspective);
|
|
17735
|
+
* await AutoProcessorConfig.register(perspective);
|
|
17736
|
+
*
|
|
17737
|
+
* Querying:
|
|
17738
|
+
* const pending = await InterpretationOverlay.findAll(perspective);
|
|
17739
|
+
* const runs = await InterpretationRun.findAll(perspective);
|
|
17740
|
+
* const configs = await AutoProcessorConfig.findAll(perspective);
|
|
17741
|
+
*/
|
|
17742
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
17743
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
17744
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17745
|
+
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;
|
|
17746
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17747
|
+
};
|
|
17748
|
+
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
|
|
17749
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
17750
|
+
};
|
|
17751
|
+
// ── AutoProcessorConfig ─────────────────────────────────────────────────────
|
|
17752
|
+
// Mirrors the Rust `auto_processor::config::AutoProcessorConfig` SDNA.
|
|
17753
|
+
// One node per registered processor; the node URI is
|
|
17754
|
+
// `ad4m://autoprocessor/<processorId>`.
|
|
17755
|
+
exports.AutoProcessorConfig = class AutoProcessorConfig extends Ad4mModel {
|
|
17756
|
+
constructor() {
|
|
17757
|
+
super(...arguments);
|
|
17758
|
+
this.type = "ad4m://AutoProcessor";
|
|
17759
|
+
/** Unique processor id — the dedup key for auto-processor instances. */
|
|
17760
|
+
this.processorId = "";
|
|
17761
|
+
/** SPARQL SELECT that gathers source items each pass. */
|
|
17762
|
+
this.sourceScopeQuery = "";
|
|
17763
|
+
/** Class URIs (SHACL targetClass) to materialise each pass. */
|
|
17764
|
+
this.interpretationClasses = [];
|
|
17765
|
+
/** Quiet-window (ms) after the last new item before a pass runs. */
|
|
17766
|
+
this.debounceMs = "200";
|
|
17767
|
+
/** Maximum items per pass. */
|
|
17768
|
+
this.batchMax = "32";
|
|
17769
|
+
/** How long a won claim is authoritative before peers may re-claim (ms). */
|
|
17770
|
+
this.claimTtlMs = "60000";
|
|
17771
|
+
}
|
|
17772
|
+
};
|
|
17773
|
+
__decorate([
|
|
17774
|
+
Flag({ through: "rdf://type", value: "ad4m://AutoProcessor" }),
|
|
17775
|
+
__metadata("design:type", String)
|
|
17776
|
+
], exports.AutoProcessorConfig.prototype, "type", void 0);
|
|
17777
|
+
__decorate([
|
|
17778
|
+
Property({ through: "ad4m://processor_id", required: true, identity: true }),
|
|
17779
|
+
__metadata("design:type", String)
|
|
17780
|
+
], exports.AutoProcessorConfig.prototype, "processorId", void 0);
|
|
17781
|
+
__decorate([
|
|
17782
|
+
Property({ through: "ad4m://source_scope_query", required: true }),
|
|
17783
|
+
__metadata("design:type", String)
|
|
17784
|
+
], exports.AutoProcessorConfig.prototype, "sourceScopeQuery", void 0);
|
|
17785
|
+
__decorate([
|
|
17786
|
+
Optional({ through: "ad4m://base_prefix", resolveLanguage: "literal" }),
|
|
17787
|
+
__metadata("design:type", String)
|
|
17788
|
+
], exports.AutoProcessorConfig.prototype, "basePrefix", void 0);
|
|
17789
|
+
__decorate([
|
|
17790
|
+
HasMany({ through: "ad4m://interpretation_class" }),
|
|
17791
|
+
__metadata("design:type", Array)
|
|
17792
|
+
], exports.AutoProcessorConfig.prototype, "interpretationClasses", void 0);
|
|
17793
|
+
__decorate([
|
|
17794
|
+
Property({ through: "ad4m://debounce_ms", required: true }),
|
|
17795
|
+
__metadata("design:type", String)
|
|
17796
|
+
], exports.AutoProcessorConfig.prototype, "debounceMs", void 0);
|
|
17797
|
+
__decorate([
|
|
17798
|
+
Optional({ through: "ad4m://batch_min", resolveLanguage: "literal" }),
|
|
17799
|
+
__metadata("design:type", String)
|
|
17800
|
+
], exports.AutoProcessorConfig.prototype, "batchMin", void 0);
|
|
17801
|
+
__decorate([
|
|
17802
|
+
Property({ through: "ad4m://batch_max", required: true }),
|
|
17803
|
+
__metadata("design:type", String)
|
|
17804
|
+
], exports.AutoProcessorConfig.prototype, "batchMax", void 0);
|
|
17805
|
+
__decorate([
|
|
17806
|
+
Optional({ through: "ad4m://max_wait_ms", resolveLanguage: "literal" }),
|
|
17807
|
+
__metadata("design:type", String)
|
|
17808
|
+
], exports.AutoProcessorConfig.prototype, "maxWaitMs", void 0);
|
|
17809
|
+
__decorate([
|
|
17810
|
+
Property({ through: "ad4m://claim_ttl_ms", required: true }),
|
|
17811
|
+
__metadata("design:type", String)
|
|
17812
|
+
], exports.AutoProcessorConfig.prototype, "claimTtlMs", void 0);
|
|
17813
|
+
__decorate([
|
|
17814
|
+
Optional({ through: "ad4m://source_window_ms", resolveLanguage: "literal" }),
|
|
17815
|
+
__metadata("design:type", String)
|
|
17816
|
+
], exports.AutoProcessorConfig.prototype, "sourceWindowMs", void 0);
|
|
17817
|
+
__decorate([
|
|
17818
|
+
Optional({ through: "ad4m://dedup_strategy", resolveLanguage: "literal" }),
|
|
17819
|
+
__metadata("design:type", String)
|
|
17820
|
+
], exports.AutoProcessorConfig.prototype, "dedupStrategy", void 0);
|
|
17821
|
+
exports.AutoProcessorConfig = __decorate([
|
|
17822
|
+
Model$1({ name: "AutoProcessorConfig" })
|
|
17823
|
+
], exports.AutoProcessorConfig);
|
|
17824
|
+
// ── InterpretationRun ───────────────────────────────────────────────────────
|
|
17825
|
+
// Mirrors the Rust `interpretation::overlay::InterpretationRun` SDNA.
|
|
17826
|
+
// One node per completed pass; the node URI is `ad4m://interp/run/<runId>`.
|
|
17827
|
+
exports.InterpretationRun = class InterpretationRun extends Ad4mModel {
|
|
17828
|
+
constructor() {
|
|
17829
|
+
super(...arguments);
|
|
17830
|
+
this.type = "ad4m://interpretation-run";
|
|
17831
|
+
/** UUID for this run — the dedup key across run nodes. */
|
|
17832
|
+
this.runId = "";
|
|
17833
|
+
/**
|
|
17834
|
+
* Source item IDs consumed by this pass.
|
|
17835
|
+
* Stored as multiple links with the same predicate; the processed-turn
|
|
17836
|
+
* cursor uses these to avoid re-interpreting a turn.
|
|
17837
|
+
*/
|
|
17838
|
+
this.sources = [];
|
|
17839
|
+
}
|
|
17840
|
+
};
|
|
17841
|
+
__decorate([
|
|
17842
|
+
Flag({ through: "ad4m://type", value: "ad4m://interpretation-run" }),
|
|
17843
|
+
__metadata("design:type", String)
|
|
17844
|
+
], exports.InterpretationRun.prototype, "type", void 0);
|
|
17845
|
+
__decorate([
|
|
17846
|
+
Property({ through: "ad4m://interp/run_id", required: true, identity: true }),
|
|
17847
|
+
__metadata("design:type", String)
|
|
17848
|
+
], exports.InterpretationRun.prototype, "runId", void 0);
|
|
17849
|
+
__decorate([
|
|
17850
|
+
Optional({ through: "ad4m://interp/model", resolveLanguage: "literal" }),
|
|
17851
|
+
__metadata("design:type", String)
|
|
17852
|
+
], exports.InterpretationRun.prototype, "model", void 0);
|
|
17853
|
+
__decorate([
|
|
17854
|
+
Optional({ through: "ad4m://interp/prompt_version", resolveLanguage: "literal" }),
|
|
17855
|
+
__metadata("design:type", String)
|
|
17856
|
+
], exports.InterpretationRun.prototype, "promptVersion", void 0);
|
|
17857
|
+
__decorate([
|
|
17858
|
+
Optional({ through: "ad4m://interp/ran_at", resolveLanguage: "literal" }),
|
|
17859
|
+
__metadata("design:type", String)
|
|
17860
|
+
], exports.InterpretationRun.prototype, "ranAt", void 0);
|
|
17861
|
+
__decorate([
|
|
17862
|
+
Optional({ through: "ad4m://interp/processor", resolveLanguage: "literal" }),
|
|
17863
|
+
__metadata("design:type", String)
|
|
17864
|
+
], exports.InterpretationRun.prototype, "processor", void 0);
|
|
17865
|
+
__decorate([
|
|
17866
|
+
HasMany({ through: "ad4m://interp/sources" }),
|
|
17867
|
+
__metadata("design:type", Array)
|
|
17868
|
+
], exports.InterpretationRun.prototype, "sources", void 0);
|
|
17869
|
+
exports.InterpretationRun = __decorate([
|
|
17870
|
+
Model$1({ name: "InterpretationRun" })
|
|
17871
|
+
], exports.InterpretationRun);
|
|
17872
|
+
// ── InterpretationOverlay ───────────────────────────────────────────────────
|
|
17873
|
+
// Mirrors the Rust `interpretation::overlay::InterpretationOverlay` SDNA.
|
|
17874
|
+
// An overlay sits on the *same* base URI as the proposed instance — it is a
|
|
17875
|
+
// pending LLM suggestion awaiting human accept/reject.
|
|
17876
|
+
//
|
|
17877
|
+
// The dynamic "inferred" values are stored as links with predicates of the
|
|
17878
|
+
// form `ad4m://interp/inferred/<realPredicate>` and are NOT captured here as
|
|
17879
|
+
// fixed @Property fields because the predicates vary per class. Read them
|
|
17880
|
+
// directly via perspective.get({ source: overlay.baseExpression }).
|
|
17881
|
+
//
|
|
17882
|
+
// Accept → perspective.acceptInterpretationOverlay(base) [deletes the overlay]
|
|
17883
|
+
// Reject → perspective.rejectInterpretationOverlay(base) [drops the suggestion]
|
|
17884
|
+
//
|
|
17885
|
+
// Note: `findAll` finds ALL nodes that currently carry a `kind` link, i.e.
|
|
17886
|
+
// all pending proposals. Accepted/rejected overlays are removed from the
|
|
17887
|
+
// graph and will not appear.
|
|
17888
|
+
exports.InterpretationOverlay = class InterpretationOverlay extends Ad4mModel {
|
|
17889
|
+
constructor() {
|
|
17890
|
+
super(...arguments);
|
|
17891
|
+
/**
|
|
17892
|
+
* Whether the LLM authored the whole instance (`"create"`) or proposed
|
|
17893
|
+
* changes to an existing one (`"update"`). This is the discriminator link
|
|
17894
|
+
* that makes a node identifiable as an overlay.
|
|
17895
|
+
*/
|
|
17896
|
+
this.kind = "";
|
|
17897
|
+
}
|
|
17898
|
+
};
|
|
17899
|
+
__decorate([
|
|
17900
|
+
Property({ through: "ad4m://interp/kind", required: true, resolveLanguage: "literal" }),
|
|
17901
|
+
__metadata("design:type", String)
|
|
17902
|
+
], exports.InterpretationOverlay.prototype, "kind", void 0);
|
|
17903
|
+
__decorate([
|
|
17904
|
+
Optional({ through: "ad4m://interp/run", resolveLanguage: "literal" }),
|
|
17905
|
+
__metadata("design:type", String)
|
|
17906
|
+
], exports.InterpretationOverlay.prototype, "run", void 0);
|
|
17907
|
+
exports.InterpretationOverlay = __decorate([
|
|
17908
|
+
Model$1({ name: "InterpretationOverlay" })
|
|
17909
|
+
], exports.InterpretationOverlay);
|
|
17910
|
+
|
|
17551
17911
|
/**
|
|
17552
17912
|
* SPARQL binding helpers — typed shapes and parsers for `querySparql<T>()`.
|
|
17553
17913
|
*
|