@coasys/ad4m 0.13.0-test-interpretation-2 → 0.13.0-test-model-layer
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 +1982 -498
- package/lib/index.js +1982 -499
- package/lib/src/ai/AIClient.js +6 -3
- package/lib/src/apiClient.d.ts +40 -4
- package/lib/src/apiClient.js +149 -9
- package/lib/src/index.d.ts +3 -1
- package/lib/src/index.js +2 -0
- package/lib/src/model/Ad4mModel.d.ts +6 -5
- package/lib/src/model/Ad4mModel.js +246 -29
- package/lib/src/model/Ad4mModel.test.js +480 -735
- package/lib/src/model/decorators.d.ts +147 -4
- package/lib/src/model/decorators.js +70 -24
- package/lib/src/model/model-manifest.d.ts +41 -0
- package/lib/src/model/model-manifest.js +11 -0
- package/lib/src/model/query-sparql.test.js +92 -10
- package/lib/src/model/shacl-gen.js +33 -0
- package/lib/src/model/types.d.ts +9 -0
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +33 -33
- package/lib/src/perspectives/AutoProcessor.d.ts +90 -24
- package/lib/src/perspectives/FlowInstance.d.ts +187 -0
- package/lib/src/perspectives/FlowInstance.js +336 -0
- package/lib/src/perspectives/FlowModels.d.ts +94 -0
- package/lib/src/perspectives/FlowModels.js +182 -0
- package/lib/src/perspectives/InterpretationModels.d.ts +12 -22
- package/lib/src/perspectives/InterpretationModels.js +2 -6
- package/lib/src/perspectives/PerspectiveClient.d.ts +68 -7
- package/lib/src/perspectives/PerspectiveClient.js +105 -10
- package/lib/src/perspectives/PerspectiveProxy.d.ts +142 -57
- package/lib/src/perspectives/PerspectiveProxy.js +388 -274
- package/lib/src/shacl/SHACLFlow.d.ts +273 -47
- package/lib/src/shacl/SHACLFlow.js +397 -88
- package/lib/src/shacl/SHACLShape.d.ts +8 -0
- package/lib/src/shacl/SHACLShape.js +17 -0
- package/lib/src/shacl/SHACLShape.test.js +82 -0
- package/package.json +2 -2
- package/src/ai/AIClient.ts +6 -3
- package/src/apiClient.test.ts +227 -0
- package/src/apiClient.ts +185 -9
- package/src/index.ts +3 -1
- package/src/model/Ad4mModel.test.ts +645 -0
- package/src/model/Ad4mModel.ts +245 -26
- package/src/model/decorators.ts +216 -35
- package/src/model/relation-filtering.test.ts +70 -20
- package/src/model/shacl-gen.ts +36 -0
- package/src/model/shacl-roundtrip.test.ts +130 -0
- package/src/model/types.ts +7 -0
- package/src/perspectives/AutoProcessor.ts +94 -24
- package/src/perspectives/FlowInstance.ts +369 -0
- package/src/perspectives/FlowModels.ts +157 -0
- package/src/perspectives/InterpretationModels.ts +13 -25
- package/src/perspectives/PerspectiveClient.test.ts +67 -6
- package/src/perspectives/PerspectiveClient.ts +142 -12
- package/src/perspectives/PerspectiveProxy.test.ts +406 -0
- package/src/perspectives/PerspectiveProxy.ts +459 -289
- package/src/perspectives/shacl-rpc.test.ts +258 -0
- package/src/shacl/SHACLFlow.test.ts +762 -35
- package/src/shacl/SHACLFlow.ts +680 -112
- package/src/shacl/SHACLShape.ts +31 -0
- package/lib/src/generated/rest/AIModelLoadingStatus.d.ts +0 -7
- package/lib/src/generated/rest/AIModelLoadingStatus.js +0 -2
- package/lib/src/generated/rest/AddAgentInfosRequest.d.ts +0 -3
- package/lib/src/generated/rest/AddAgentInfosRequest.js +0 -2
- package/lib/src/generated/rest/AddLinkExpressionRequest.d.ts +0 -6
- package/lib/src/generated/rest/AddLinkExpressionRequest.js +0 -1
- package/lib/src/generated/rest/AddLinkRequest.d.ts +0 -6
- package/lib/src/generated/rest/AddLinkRequest.js +0 -1
- package/lib/src/generated/rest/AddLinksBulkRequest.d.ts +0 -6
- package/lib/src/generated/rest/AddLinksBulkRequest.js +0 -1
- package/lib/src/generated/rest/AddSdnaRequest.d.ts +0 -6
- package/lib/src/generated/rest/AddSdnaRequest.js +0 -2
- package/lib/src/generated/rest/ApplyTemplateRequest.d.ts +0 -4
- package/lib/src/generated/rest/ApplyTemplateRequest.js +0 -2
- package/lib/src/generated/rest/AuthInfoInput.d.ts +0 -10
- package/lib/src/generated/rest/AuthInfoInput.js +0 -1
- package/lib/src/generated/rest/BroadcastRequest.d.ts +0 -6
- package/lib/src/generated/rest/BroadcastRequest.js +0 -1
- package/lib/src/generated/rest/CapabilityInput.d.ts +0 -5
- package/lib/src/generated/rest/CapabilityInput.js +0 -1
- package/lib/src/generated/rest/CommitBatchRequest.d.ts +0 -3
- package/lib/src/generated/rest/CommitBatchRequest.js +0 -2
- package/lib/src/generated/rest/ComputeLogEntry.d.ts +0 -9
- package/lib/src/generated/rest/ComputeLogEntry.js +0 -2
- package/lib/src/generated/rest/CreateExpressionRequest.d.ts +0 -4
- package/lib/src/generated/rest/CreateExpressionRequest.js +0 -2
- package/lib/src/generated/rest/CreatePerspectiveRequest.d.ts +0 -3
- package/lib/src/generated/rest/CreatePerspectiveRequest.js +0 -2
- package/lib/src/generated/rest/CreateSubjectRequest.d.ts +0 -6
- package/lib/src/generated/rest/CreateSubjectRequest.js +0 -2
- package/lib/src/generated/rest/CreateUserRequest.d.ts +0 -4
- package/lib/src/generated/rest/CreateUserRequest.js +0 -2
- package/lib/src/generated/rest/CreateUserResponse.d.ts +0 -5
- package/lib/src/generated/rest/CreateUserResponse.js +0 -2
- package/lib/src/generated/rest/DecoratedExpressionProof.d.ts +0 -6
- package/lib/src/generated/rest/DecoratedExpressionProof.js +0 -2
- package/lib/src/generated/rest/DecoratedLinkExpression.d.ts +0 -10
- package/lib/src/generated/rest/DecoratedLinkExpression.js +0 -1
- package/lib/src/generated/rest/DisposeQueryRequest.d.ts +0 -3
- package/lib/src/generated/rest/DisposeQueryRequest.js +0 -2
- package/lib/src/generated/rest/EmailTestRequest.d.ts +0 -6
- package/lib/src/generated/rest/EmailTestRequest.js +0 -2
- package/lib/src/generated/rest/EmbedRequest.d.ts +0 -4
- package/lib/src/generated/rest/EmbedRequest.js +0 -2
- package/lib/src/generated/rest/EntanglementProofInput.d.ts +0 -6
- package/lib/src/generated/rest/EntanglementProofInput.js +0 -2
- package/lib/src/generated/rest/EntanglementProofPreflightRequest.d.ts +0 -4
- package/lib/src/generated/rest/EntanglementProofPreflightRequest.js +0 -2
- package/lib/src/generated/rest/ExecuteCommandsRequest.d.ts +0 -4
- package/lib/src/generated/rest/ExecuteCommandsRequest.js +0 -2
- package/lib/src/generated/rest/ExportRequest.d.ts +0 -5
- package/lib/src/generated/rest/ExportRequest.js +0 -2
- package/lib/src/generated/rest/ExpressionManyRequest.d.ts +0 -3
- package/lib/src/generated/rest/ExpressionManyRequest.js +0 -2
- package/lib/src/generated/rest/ExpressionProof.d.ts +0 -4
- package/lib/src/generated/rest/ExpressionProof.js +0 -2
- package/lib/src/generated/rest/ExpressionProofInput.d.ts +0 -6
- package/lib/src/generated/rest/ExpressionProofInput.js +0 -2
- package/lib/src/generated/rest/FriendSendMessageRequest.d.ts +0 -3
- package/lib/src/generated/rest/FriendSendMessageRequest.js +0 -2
- package/lib/src/generated/rest/FriendsListRequest.d.ts +0 -3
- package/lib/src/generated/rest/FriendsListRequest.js +0 -2
- package/lib/src/generated/rest/GenerateAgentRequest.d.ts +0 -3
- package/lib/src/generated/rest/GenerateAgentRequest.js +0 -2
- package/lib/src/generated/rest/GenerateJwtRequest.d.ts +0 -4
- package/lib/src/generated/rest/GenerateJwtRequest.js +0 -2
- package/lib/src/generated/rest/GetSubjectDataRequest.d.ts +0 -4
- package/lib/src/generated/rest/GetSubjectDataRequest.js +0 -2
- package/lib/src/generated/rest/HostingInfoResponse.d.ts +0 -5
- package/lib/src/generated/rest/HostingInfoResponse.js +0 -2
- package/lib/src/generated/rest/HostingWalletResponse.d.ts +0 -4
- package/lib/src/generated/rest/HostingWalletResponse.js +0 -2
- package/lib/src/generated/rest/ImportAgentRequest.d.ts +0 -6
- package/lib/src/generated/rest/ImportAgentRequest.js +0 -2
- package/lib/src/generated/rest/ImportRequest.d.ts +0 -4
- package/lib/src/generated/rest/ImportRequest.js +0 -2
- package/lib/src/generated/rest/JoinNeighbourhoodRequest.d.ts +0 -3
- package/lib/src/generated/rest/JoinNeighbourhoodRequest.js +0 -2
- package/lib/src/generated/rest/KeepAliveQueryRequest.d.ts +0 -3
- package/lib/src/generated/rest/KeepAliveQueryRequest.js +0 -2
- package/lib/src/generated/rest/LanguageMetaInput.d.ts +0 -6
- package/lib/src/generated/rest/LanguageMetaInput.js +0 -2
- package/lib/src/generated/rest/Link.d.ts +0 -5
- package/lib/src/generated/rest/Link.js +0 -2
- package/lib/src/generated/rest/LinkExpression.d.ts +0 -10
- package/lib/src/generated/rest/LinkExpression.js +0 -1
- package/lib/src/generated/rest/LinkExpressionInput.d.ts +0 -10
- package/lib/src/generated/rest/LinkExpressionInput.js +0 -1
- package/lib/src/generated/rest/LinkInput.d.ts +0 -5
- package/lib/src/generated/rest/LinkInput.js +0 -2
- package/lib/src/generated/rest/LinkLanguageTemplatesRequest.d.ts +0 -3
- package/lib/src/generated/rest/LinkLanguageTemplatesRequest.js +0 -2
- package/lib/src/generated/rest/LinkMutationRequest.d.ts +0 -12
- package/lib/src/generated/rest/LinkMutationRequest.js +0 -1
- package/lib/src/generated/rest/LinkMutationResponse.d.ts +0 -9
- package/lib/src/generated/rest/LinkMutationResponse.js +0 -1
- package/lib/src/generated/rest/LinkMutations.d.ts +0 -6
- package/lib/src/generated/rest/LinkMutations.js +0 -1
- package/lib/src/generated/rest/LinkMutationsRequest.d.ts +0 -5
- package/lib/src/generated/rest/LinkMutationsRequest.js +0 -1
- package/lib/src/generated/rest/LinkStatus.d.ts +0 -1
- package/lib/src/generated/rest/LinkStatus.js +0 -2
- package/lib/src/generated/rest/LinkUpdateInput.d.ts +0 -5
- package/lib/src/generated/rest/LinkUpdateInput.js +0 -1
- package/lib/src/generated/rest/LockAgentRequest.d.ts +0 -3
- package/lib/src/generated/rest/LockAgentRequest.js +0 -2
- package/lib/src/generated/rest/LoginUserRequest.d.ts +0 -5
- package/lib/src/generated/rest/LoginUserRequest.js +0 -2
- package/lib/src/generated/rest/ModelType.d.ts +0 -1
- package/lib/src/generated/rest/ModelType.js +0 -2
- package/lib/src/generated/rest/NotificationGrantRequest.d.ts +0 -3
- package/lib/src/generated/rest/NotificationGrantRequest.js +0 -2
- package/lib/src/generated/rest/NotificationInput.d.ts +0 -10
- package/lib/src/generated/rest/NotificationInput.js +0 -2
- package/lib/src/generated/rest/OpenLinkRequest.d.ts +0 -3
- package/lib/src/generated/rest/OpenLinkRequest.js +0 -2
- package/lib/src/generated/rest/PermitCapabilityRequest.d.ts +0 -3
- package/lib/src/generated/rest/PermitCapabilityRequest.js +0 -2
- package/lib/src/generated/rest/PerspectiveInput.d.ts +0 -4
- package/lib/src/generated/rest/PerspectiveInput.js +0 -1
- package/lib/src/generated/rest/PromptRequest.d.ts +0 -4
- package/lib/src/generated/rest/PromptRequest.js +0 -2
- package/lib/src/generated/rest/PublicPerspectiveInput.d.ts +0 -4
- package/lib/src/generated/rest/PublicPerspectiveInput.js +0 -1
- package/lib/src/generated/rest/PublishLanguageRequest.d.ts +0 -5
- package/lib/src/generated/rest/PublishLanguageRequest.js +0 -1
- package/lib/src/generated/rest/PublishNeighbourhoodRequest.d.ts +0 -6
- package/lib/src/generated/rest/PublishNeighbourhoodRequest.js +0 -1
- package/lib/src/generated/rest/QueryRequest.d.ts +0 -7
- package/lib/src/generated/rest/QueryRequest.js +0 -2
- package/lib/src/generated/rest/RemoveLinkRequest.d.ts +0 -5
- package/lib/src/generated/rest/RemoveLinkRequest.js +0 -1
- package/lib/src/generated/rest/RemoveLinksBulkRequest.d.ts +0 -5
- package/lib/src/generated/rest/RemoveLinksBulkRequest.js +0 -1
- package/lib/src/generated/rest/RequestCapabilityRequest.d.ts +0 -4
- package/lib/src/generated/rest/RequestCapabilityRequest.js +0 -1
- package/lib/src/generated/rest/RequestPaymentRequest.d.ts +0 -3
- package/lib/src/generated/rest/RequestPaymentRequest.js +0 -2
- package/lib/src/generated/rest/RequestVerificationRequest.d.ts +0 -4
- package/lib/src/generated/rest/RequestVerificationRequest.js +0 -2
- package/lib/src/generated/rest/ResourceInput.d.ts +0 -4
- package/lib/src/generated/rest/ResourceInput.js +0 -2
- package/lib/src/generated/rest/SetDefaultModelRequest.d.ts +0 -4
- package/lib/src/generated/rest/SetDefaultModelRequest.js +0 -1
- package/lib/src/generated/rest/SetFreeHostingEnabledRequest.d.ts +0 -3
- package/lib/src/generated/rest/SetFreeHostingEnabledRequest.js +0 -2
- package/lib/src/generated/rest/SetHotWalletAddressRequest.d.ts +0 -3
- package/lib/src/generated/rest/SetHotWalletAddressRequest.js +0 -2
- package/lib/src/generated/rest/SetMultiUserRequest.d.ts +0 -3
- package/lib/src/generated/rest/SetMultiUserRequest.js +0 -2
- package/lib/src/generated/rest/SetOnlineStatusRequest.d.ts +0 -5
- package/lib/src/generated/rest/SetOnlineStatusRequest.js +0 -1
- package/lib/src/generated/rest/SetStatusRequest.d.ts +0 -3
- package/lib/src/generated/rest/SetStatusRequest.js +0 -2
- package/lib/src/generated/rest/SetUserFreeAccessRequest.d.ts +0 -4
- package/lib/src/generated/rest/SetUserFreeAccessRequest.js +0 -2
- package/lib/src/generated/rest/SignMessageRequest.d.ts +0 -3
- package/lib/src/generated/rest/SignMessageRequest.js +0 -2
- package/lib/src/generated/rest/SignalRequest.d.ts +0 -6
- package/lib/src/generated/rest/SignalRequest.js +0 -1
- package/lib/src/generated/rest/SubscribeQueryRequest.d.ts +0 -3
- package/lib/src/generated/rest/SubscribeQueryRequest.js +0 -2
- package/lib/src/generated/rest/SubscribeQueryResponse.d.ts +0 -4
- package/lib/src/generated/rest/SubscribeQueryResponse.js +0 -2
- package/lib/src/generated/rest/TrustedAgentsRequest.d.ts +0 -3
- package/lib/src/generated/rest/TrustedAgentsRequest.js +0 -2
- package/lib/src/generated/rest/UnlockAgentRequest.d.ts +0 -4
- package/lib/src/generated/rest/UnlockAgentRequest.js +0 -2
- package/lib/src/generated/rest/UpdateLinkRequest.d.ts +0 -7
- package/lib/src/generated/rest/UpdateLinkRequest.js +0 -1
- package/lib/src/generated/rest/UpdatePerspectiveRequest.d.ts +0 -3
- package/lib/src/generated/rest/UpdatePerspectiveRequest.js +0 -2
- package/lib/src/generated/rest/UpdateProfileRequest.d.ts +0 -5
- package/lib/src/generated/rest/UpdateProfileRequest.js +0 -1
- package/lib/src/generated/rest/UserStatistics.d.ts +0 -9
- package/lib/src/generated/rest/UserStatistics.js +0 -2
- package/lib/src/generated/rest/VerificationRequestResult.d.ts +0 -6
- package/lib/src/generated/rest/VerificationRequestResult.js +0 -2
- package/lib/src/generated/rest/VerifyEmailRequest.d.ts +0 -6
- package/lib/src/generated/rest/VerifyEmailRequest.js +0 -2
- package/lib/src/generated/rest/VerifySignatureRequest.d.ts +0 -5
- package/lib/src/generated/rest/VerifySignatureRequest.js +0 -2
- package/lib/src/generated/rest/WriteSettingsRequest.d.ts +0 -3
- package/lib/src/generated/rest/WriteSettingsRequest.js +0 -2
- package/lib/src/generated/rest/index.d.ts +0 -73
- package/lib/src/generated/rest/index.js +0 -8
- package/lib/src/generated/rest/routes.d.ts +0 -587
- package/lib/src/generated/rest/routes.js +0 -3
- package/lib/src/model/query-surreal.d.ts +0 -44
- package/lib/src/model/query-surreal.js +0 -249
- package/lib/src/model/surreal-utils.d.ts +0 -42
- package/lib/src/model/surreal-utils.js +0 -128
- package/lib/src/perspectives/PerspectiveProxy.test.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveProxy.test.js +0 -34
- package/lib/src/restClient.d.ts +0 -52
- package/lib/src/restClient.js +0 -227
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { NeighbourhoodClient } from "./NeighbourhoodClient";
|
|
2
2
|
import { NeighbourhoodProxy } from "./NeighbourhoodProxy";
|
|
3
|
-
// Mock RestClient's subscribe to avoid real WebSocket connections
|
|
4
|
-
jest.mock('../restClient', () => {
|
|
5
|
-
return {
|
|
6
|
-
RestClient: jest.fn().mockImplementation(() => ({
|
|
7
|
-
get: jest.fn(),
|
|
8
|
-
post: jest.fn(),
|
|
9
|
-
put: jest.fn(),
|
|
10
|
-
delete: jest.fn(),
|
|
11
|
-
subscribe: jest.fn().mockReturnValue(() => { }),
|
|
12
|
-
}))
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
3
|
describe("NeighbourhoodProxy", () => {
|
|
16
4
|
it("should add multiple signal handlers", async () => {
|
|
17
5
|
const neighbourhoodURI = "did://123";
|
|
18
|
-
const
|
|
6
|
+
const mockApolloClient = {
|
|
7
|
+
subscribe: () => ({
|
|
8
|
+
subscribe: () => new Promise((resolve) => {
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
resolve({});
|
|
11
|
+
}, 10);
|
|
12
|
+
}),
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
const neighbourhoodClient = new NeighbourhoodClient(mockApolloClient);
|
|
19
16
|
const neighbourhoodProxy = new NeighbourhoodProxy(neighbourhoodClient, neighbourhoodURI);
|
|
20
17
|
let callbacks = 0;
|
|
21
18
|
const handler1 = () => {
|
|
@@ -24,7 +21,7 @@ describe("NeighbourhoodProxy", () => {
|
|
|
24
21
|
const handler2 = () => {
|
|
25
22
|
callbacks++;
|
|
26
23
|
};
|
|
27
|
-
// Add multiple signal handlers in
|
|
24
|
+
// Add multiple signal handlers in paralell
|
|
28
25
|
const promise = neighbourhoodProxy.addSignalHandler(handler1);
|
|
29
26
|
neighbourhoodProxy.addSignalHandler(handler2);
|
|
30
27
|
await promise;
|
|
@@ -33,20 +30,21 @@ describe("NeighbourhoodProxy", () => {
|
|
|
33
30
|
});
|
|
34
31
|
it("should not add multiple subscriptions when removing and adding another signal handler", async () => {
|
|
35
32
|
const neighbourhoodURI = "did://123";
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
const subscriptions = [];
|
|
34
|
+
const subscribe = (args) => {
|
|
35
|
+
subscriptions.push(args);
|
|
36
|
+
new Promise((resolve) => {
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
resolve({});
|
|
39
|
+
}, 10);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const mockApolloClient = {
|
|
43
|
+
subscribe: () => ({
|
|
44
|
+
subscribe,
|
|
47
45
|
}),
|
|
48
|
-
}
|
|
49
|
-
const neighbourhoodClient = new NeighbourhoodClient(
|
|
46
|
+
};
|
|
47
|
+
const neighbourhoodClient = new NeighbourhoodClient(mockApolloClient);
|
|
50
48
|
const neighbourhoodProxy = new NeighbourhoodProxy(neighbourhoodClient, neighbourhoodURI);
|
|
51
49
|
let callbacks1 = 0;
|
|
52
50
|
let callbacks2 = 0;
|
|
@@ -58,15 +56,17 @@ describe("NeighbourhoodProxy", () => {
|
|
|
58
56
|
};
|
|
59
57
|
// Add signal handler 1
|
|
60
58
|
await neighbourhoodProxy.addSignalHandler(handler1);
|
|
61
|
-
// Remove signal handler
|
|
59
|
+
// Remove signal handler 2
|
|
62
60
|
neighbourhoodProxy.removeSignalHandler(handler1);
|
|
63
61
|
// Add signal handler 2
|
|
64
62
|
await neighbourhoodProxy.addSignalHandler(handler2);
|
|
65
|
-
// Check that only one subscription was added
|
|
66
|
-
expect(
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
// Check that only one subscription was added
|
|
64
|
+
expect(subscriptions.length).toBe(1);
|
|
65
|
+
// mock trigger signal event
|
|
66
|
+
for (const subscription of subscriptions) {
|
|
67
|
+
subscription.next({ data: { signal: { neighbourhoodSignal: true } } });
|
|
68
|
+
}
|
|
69
|
+
// Check that only our second callback was called
|
|
70
70
|
expect(callbacks1).toBe(0);
|
|
71
71
|
expect(callbacks2).toBe(1);
|
|
72
72
|
});
|
|
@@ -37,19 +37,40 @@ export type RawScope = {
|
|
|
37
37
|
* - `batchReady` → `notCandidate` — this peer stood down for an earlier author
|
|
38
38
|
* - `claimed` → `shapesMissing` — a configured class shape hasn't synced
|
|
39
39
|
* - `claimed` → `emptyTranscript` — the batch drained empty
|
|
40
|
+
* - any → `failed` — the model errored or timed out;
|
|
41
|
+
* `detail` carries why. Distinct from the two above, which are the pass
|
|
42
|
+
* correctly finding nothing to do — reporting "nothing to extract" when
|
|
43
|
+
* the LLM endpoint was unreachable points someone at their transcript
|
|
44
|
+
* instead of at their model settings.
|
|
45
|
+
*
|
|
46
|
+
* ## Lifecycle (one-shot `runInterpretation`)
|
|
47
|
+
*
|
|
48
|
+
* A one-shot pass emits nothing unless the caller passes `observe` (see
|
|
49
|
+
* {@link PerspectiveProxy.runInterpretation}). With it:
|
|
50
|
+
*
|
|
51
|
+
* `runningInterpretation` → [`llmRequestSent` → `llmResponseReceived`] →
|
|
52
|
+
* `processed` | `failed`
|
|
53
|
+
*
|
|
54
|
+
* — plus `claimed` → `finished`/`abandoned` on the neighbourhood stream, so
|
|
55
|
+
* one-shot and watch passes render through the same consumer code. There is
|
|
56
|
+
* no `batchReady`, `gatheringTranscript` or claim: the caller supplied the
|
|
57
|
+
* transcript, and `processorId`/`batchKey` both carry the caller's own
|
|
58
|
+
* `observationId`.
|
|
40
59
|
*
|
|
41
60
|
* ## Payload fields per step
|
|
42
61
|
*
|
|
43
|
-
* All steps carry `perspectiveUuid`, `processorId`, `agentDid`, `itemIds[]
|
|
62
|
+
* All steps carry `perspectiveUuid`, `processorId`, `agentDid`, `itemIds[]`
|
|
63
|
+
* and `batchKey` (the join key to the neighbourhood-state stream).
|
|
44
64
|
* Additional payload:
|
|
45
65
|
*
|
|
46
66
|
* - `backedOff`, `notCandidate` → `detail` = holder / elected-author DID
|
|
47
67
|
* - `shapesMissing` → `detail` = comma-joined missing class URIs
|
|
68
|
+
* - `failed` → `detail` = the error
|
|
48
69
|
* - `llmRequestSent` → `llmInput` = raw prompt
|
|
49
70
|
* - `llmResponseReceived` → `llmOutput` = raw LLM response
|
|
50
71
|
* - `processed` → `bases[]` = new/updated instance URIs
|
|
51
72
|
*/
|
|
52
|
-
export type AutoProcessorStep = "batchReady" | "claimed" | "backedOff" | "awaitingAuthor" | "notCandidate" | "gatheringTranscript" | "runningInterpretation" | "llmRequestSent" | "llmResponseReceived" | "processed" | "shapesMissing" | "emptyTranscript";
|
|
73
|
+
export type AutoProcessorStep = "batchReady" | "claimed" | "backedOff" | "awaitingAuthor" | "notCandidate" | "gatheringTranscript" | "runningInterpretation" | "llmRequestSent" | "llmResponseReceived" | "toolCall" | "toolResult" | "processed" | "shapesMissing" | "emptyTranscript" | "failed";
|
|
53
74
|
/** A single step-signal from one auto-processor pass on one perspective. */
|
|
54
75
|
export interface AutoProcessorEvent {
|
|
55
76
|
type: "auto-processor-event";
|
|
@@ -60,6 +81,24 @@ export interface AutoProcessorEvent {
|
|
|
60
81
|
step: AutoProcessorStep;
|
|
61
82
|
/** The batch's source item ids (present from `batchReady` onward). */
|
|
62
83
|
itemIds: string[];
|
|
84
|
+
/**
|
|
85
|
+
* Content hash of the batch — the same value
|
|
86
|
+
* {@link AutoProcessorNeighbourhoodStateEvent.batchKey} carries, and the
|
|
87
|
+
* key that joins the two streams.
|
|
88
|
+
*
|
|
89
|
+
* A UI that renders one row per pass subscribes to both: the
|
|
90
|
+
* perspective-scoped neighbourhood stream opens the row (and names the
|
|
91
|
+
* claimant), while this DID-scoped stream fills in the fine-grained
|
|
92
|
+
* steps and LLM I/O for the pass this agent is running. Matching them on
|
|
93
|
+
* `processorId` alone breaks as soon as a processor runs a second pass;
|
|
94
|
+
* matching on `itemIds` means re-implementing the Rust SHA-256 and its
|
|
95
|
+
* exact serialization. So both streams carry the same key.
|
|
96
|
+
*
|
|
97
|
+
* Present from `batchReady` onward. Optional on the type because a
|
|
98
|
+
* pre-#903 executor does not send it — treat its absence as "cannot
|
|
99
|
+
* correlate", not as an error.
|
|
100
|
+
*/
|
|
101
|
+
batchKey?: string;
|
|
63
102
|
/** Instance base URIs written by the pass (present on `processed`). */
|
|
64
103
|
bases: string[];
|
|
65
104
|
/** Free-form context for the step (a holder/elected DID, an error, …). */
|
|
@@ -72,6 +111,24 @@ export interface AutoProcessorEvent {
|
|
|
72
111
|
* `llmResponseReceived` events, and only when the processor was
|
|
73
112
|
* configured with `emitDebugEvents: true`. Never carried on `processed`. */
|
|
74
113
|
llmOutput?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Name of the tool the harness LLM invoked (or that just returned).
|
|
116
|
+
* Present on `toolCall` + `toolResult` events (harness path only).
|
|
117
|
+
*/
|
|
118
|
+
toolName?: string;
|
|
119
|
+
/**
|
|
120
|
+
* JSON-encoded arguments the LLM sent to the tool. Present ONLY on
|
|
121
|
+
* `toolCall`; absent on `toolResult` where {@link toolResult} carries
|
|
122
|
+
* the return text instead.
|
|
123
|
+
*/
|
|
124
|
+
toolArgsJson?: string;
|
|
125
|
+
/**
|
|
126
|
+
* The tool's return text. Present ONLY on `toolResult`; may be
|
|
127
|
+
* pre-truncated by the emitter with an `…[truncated for event]`
|
|
128
|
+
* marker when the tool returns a large payload (e.g. a `_query`
|
|
129
|
+
* result). Consumers wanting the full text can re-run the tool.
|
|
130
|
+
*/
|
|
131
|
+
toolResult?: string;
|
|
75
132
|
}
|
|
76
133
|
/**
|
|
77
134
|
* Coarse-grained phase of a neighbourhood-state event.
|
|
@@ -103,6 +160,33 @@ export interface AutoProcessorNeighbourhoodStateEvent {
|
|
|
103
160
|
batchKey: string;
|
|
104
161
|
phase: NeighbourhoodPhase;
|
|
105
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Opt a one-shot `runInterpretation` call into the same event streams a
|
|
165
|
+
* standing watch produces.
|
|
166
|
+
*
|
|
167
|
+
* Without it the call is silent until it resolves — which, on a local model,
|
|
168
|
+
* is minutes of a UI having nothing to say. With it the pass reports
|
|
169
|
+
* `runningInterpretation` → `processed`/`failed` on the DID-scoped stream and
|
|
170
|
+
* `claimed` → `finished`/`abandoned` on the perspective-scoped one.
|
|
171
|
+
*/
|
|
172
|
+
export interface RunInterpretationObserveOptions {
|
|
173
|
+
/**
|
|
174
|
+
* The caller's own id for this pass, echoed back as both `processorId` and
|
|
175
|
+
* `batchKey` on every event it emits.
|
|
176
|
+
*
|
|
177
|
+
* Supplied by the caller rather than minted by the executor because
|
|
178
|
+
* `runInterpretation` is a single blocking call: there is no earlier
|
|
179
|
+
* response that could hand back a server-side id, so the events would
|
|
180
|
+
* arrive with nothing to match them against. Any value unique among this
|
|
181
|
+
* client's in-flight passes will do.
|
|
182
|
+
*/
|
|
183
|
+
observationId: string;
|
|
184
|
+
/**
|
|
185
|
+
* Also emit `llmRequestSent` / `llmResponseReceived` with the raw prompt
|
|
186
|
+
* and response. Default `false`.
|
|
187
|
+
*/
|
|
188
|
+
emitDebugEvents?: boolean;
|
|
189
|
+
}
|
|
106
190
|
/** Configuration for `perspective.addAutoProcessor` (everything but `uuid`). */
|
|
107
191
|
export interface AddAutoProcessorConfig {
|
|
108
192
|
/** Human-meaningful processor id (unique per perspective). */
|
|
@@ -175,30 +259,12 @@ export interface AddAutoProcessorConfig {
|
|
|
175
259
|
*/
|
|
176
260
|
mintScope?: RawScope;
|
|
177
261
|
/**
|
|
178
|
-
*
|
|
179
|
-
* (`debugPrompt` / `debugResponse`)
|
|
180
|
-
*
|
|
181
|
-
* can
|
|
182
|
-
* only) or emit without persisting (live observability, no graph-sync
|
|
183
|
-
* payload). Default `false` — LLM I/O is 10s of KB per pass and every
|
|
184
|
-
* enabled peer syncs it.
|
|
185
|
-
*/
|
|
186
|
-
persistDebug?: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* Emit `LlmRequestSent` and `LlmResponseReceived` `auto-processor-event`s
|
|
189
|
-
* mid-pass, so a subscribed UI can render "waiting on LLM" between
|
|
190
|
-
* prompt-send and response-receive. See `persistDebug` for the split
|
|
191
|
-
* rationale. Default `false`.
|
|
262
|
+
* Enable full debug observability: persists the raw LLM prompt + response
|
|
263
|
+
* on the pass's `InterpretationRun` (`debugPrompt` / `debugResponse`) AND
|
|
264
|
+
* emits `LlmRequestSent` / `LlmResponseReceived` mid-pass events so a
|
|
265
|
+
* subscribed UI can render "waiting on LLM". Default `false`.
|
|
192
266
|
*/
|
|
193
267
|
emitDebugEvents?: boolean;
|
|
194
|
-
/**
|
|
195
|
-
* Legacy backwards-compat alias — pre-split callers set `debugMode` as a
|
|
196
|
-
* single coupled flag. When present and both `persistDebug` +
|
|
197
|
-
* `emitDebugEvents` are absent, its value is expanded to both. The two
|
|
198
|
-
* specific fields take precedence when present. Prefer the split fields;
|
|
199
|
-
* this alias is retained so pre-split clients still work.
|
|
200
|
-
*/
|
|
201
|
-
debugMode?: boolean;
|
|
202
268
|
}
|
|
203
269
|
/**
|
|
204
270
|
* Raw REST-API response shape for a pending interpretation overlay.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `FlowInstance` — object-oriented wrapper for a running flow.
|
|
3
|
+
*
|
|
4
|
+
* Design authority: `docs/flow-interpretation-hints-design.md` §4.3.
|
|
5
|
+
*
|
|
6
|
+
* Wraps two on-graph objects:
|
|
7
|
+
*
|
|
8
|
+
* - `FlowInstanceRecord` — the raw @Model row minted by
|
|
9
|
+
* {@link FlowInstance.start}; carries `flow`, `subject`, `currentState`,
|
|
10
|
+
* and Ad4mModel's synthesised `createdAt`.
|
|
11
|
+
* - `SHACLFlow` — the flow definition the record is bound to. Held so
|
|
12
|
+
* `availableTransitions` / `currentState` object lookups don't require
|
|
13
|
+
* a per-call round-trip.
|
|
14
|
+
*
|
|
15
|
+
* Construct via the class factories — {@link FlowInstance.start} for the
|
|
16
|
+
* mint path and {@link FlowInstance.findAll} for the read path — rather
|
|
17
|
+
* than the `wrap` escape hatch, which exists for tests that already own
|
|
18
|
+
* a matched (record, shape) pair.
|
|
19
|
+
*
|
|
20
|
+
* # What's here vs. what's coming in §7 / slice 10.6
|
|
21
|
+
*
|
|
22
|
+
* Read surface (implemented today, PR #929):
|
|
23
|
+
* - `uri`, `subject`, `flowName`, `currentStateName`, `startedAtMillis`
|
|
24
|
+
* accessors.
|
|
25
|
+
* - `currentState` — resolves the `FlowState` on the shape whose name
|
|
26
|
+
* matches `record.currentState`.
|
|
27
|
+
* - `availableTransitions` — filters `shape.transitions` by `fromState`.
|
|
28
|
+
* - `proposals()` — queries `FlowTransitionProposal` records that
|
|
29
|
+
* target this instance's URI.
|
|
30
|
+
*
|
|
31
|
+
* Mutations + subscriptions (`proposeTransition`, `accept`, `reject`,
|
|
32
|
+
* `fireAction`, `onStateChange`, `onProposalAdded`, `onProposalResolved`)
|
|
33
|
+
* land with the consensus-engine slice (§4.3 / slice 10.6). Rather than
|
|
34
|
+
* ship them as `throw new Error("not yet")` stubs — which is a type-level
|
|
35
|
+
* lie the caller only discovers at runtime — they are simply absent from
|
|
36
|
+
* this class until the engine is wired.
|
|
37
|
+
*/
|
|
38
|
+
import { PerspectiveProxy } from "./PerspectiveProxy";
|
|
39
|
+
import { FlowInstanceRecord, FlowTransitionProposal } from "./FlowModels";
|
|
40
|
+
import { SHACLFlow, FlowState, FlowTransition } from "../shacl/SHACLFlow";
|
|
41
|
+
export declare class FlowInstance {
|
|
42
|
+
private readonly perspective;
|
|
43
|
+
/** The flow definition this instance was minted against. */
|
|
44
|
+
readonly shape: SHACLFlow;
|
|
45
|
+
/**
|
|
46
|
+
* The on-graph record — carries `flow`, `subject`, `currentState`
|
|
47
|
+
* and Ad4mModel's synthesised `createdAt`. Callers can reach into it
|
|
48
|
+
* for anything the wrapper doesn't expose directly, but should prefer
|
|
49
|
+
* the wrapper accessors so future refactors of the underlying shape
|
|
50
|
+
* don't ripple through their code.
|
|
51
|
+
*/
|
|
52
|
+
readonly record: FlowInstanceRecord;
|
|
53
|
+
/**
|
|
54
|
+
* Private constructor — construct via {@link FlowInstance.start} or
|
|
55
|
+
* {@link FlowInstance.findAll}. {@link FlowInstance.wrap} is the
|
|
56
|
+
* escape hatch for tests / direct construction cases.
|
|
57
|
+
*/
|
|
58
|
+
private constructor();
|
|
59
|
+
/**
|
|
60
|
+
* Escape hatch used by {@link FlowInstance.start} and
|
|
61
|
+
* {@link FlowInstance.findAll} — not meant for general use, but public
|
|
62
|
+
* so tests that already own a `FlowInstanceRecord + SHACLFlow` pair
|
|
63
|
+
* (e.g. from pre-populated fixtures) can build a wrapper without
|
|
64
|
+
* going through the mint path.
|
|
65
|
+
*/
|
|
66
|
+
static wrap(perspective: PerspectiveProxy, shape: SHACLFlow, record: FlowInstanceRecord): FlowInstance;
|
|
67
|
+
/**
|
|
68
|
+
* Mint a new `FlowInstance` on the given perspective (design doc §4.3).
|
|
69
|
+
*
|
|
70
|
+
* Idempotently registers the hardwired `FlowInstanceRecord` +
|
|
71
|
+
* `FlowTransitionProposal` @Model classes on first call — the on-graph
|
|
72
|
+
* shape matches the Rust-side hardwired SDNA (parity-locked in
|
|
73
|
+
* `flow-instance.test.ts` / `flow-transition-proposal.test.ts`).
|
|
74
|
+
*
|
|
75
|
+
* The returned wrapper carries the parsed `SHACLFlow` alongside the
|
|
76
|
+
* on-graph record, so `currentState` / `availableTransitions` /
|
|
77
|
+
* `proposals` accessors work without further round-trips. The consensus
|
|
78
|
+
* engine (slice 10.6) will read the record's `currentState` when it
|
|
79
|
+
* fires transitions.
|
|
80
|
+
*
|
|
81
|
+
* @param perspective - The perspective the flow instance lives on
|
|
82
|
+
* @param flowName - Name of a `SHACLFlow` already registered on the perspective
|
|
83
|
+
* @param baseExpression - URI of the subject expression the flow runs on
|
|
84
|
+
* @throws When the flow is unknown or has zero declared states (zero-state
|
|
85
|
+
* flows fire via the forthcoming atomic-action path, §6.3).
|
|
86
|
+
*/
|
|
87
|
+
static start(perspective: PerspectiveProxy, flowName: string, baseExpression: string): Promise<FlowInstance>;
|
|
88
|
+
/**
|
|
89
|
+
* Return every live `FlowInstance` on the perspective (design doc §4.3).
|
|
90
|
+
*
|
|
91
|
+
* Read-only path: never registers classes. On a perspective that has
|
|
92
|
+
* never minted a flow instance, the `FlowInstanceRecord` SHACL shape
|
|
93
|
+
* isn't installed yet — this returns `[]` in that case rather than
|
|
94
|
+
* mutating the perspective. Registration is the responsibility of
|
|
95
|
+
* {@link FlowInstance.start}, which is the write path. (Registering on
|
|
96
|
+
* a read would sync a write to every peer in the neighbourhood —
|
|
97
|
+
* exactly what a query must not do — James PR #929 R7.)
|
|
98
|
+
*
|
|
99
|
+
* Filter surface (all optional, all combinable):
|
|
100
|
+
* - **`flowName`** — narrows by flow-name discriminator (e.g. "Delivery")
|
|
101
|
+
* - **`subject`** — narrows by base-expression URI, i.e. "give me every
|
|
102
|
+
* flow running on THIS expression"
|
|
103
|
+
*
|
|
104
|
+
* Both filters translate to a single SHACL `where`-filter round-trip
|
|
105
|
+
* (no client-side filtering); combining them AND-joins server-side.
|
|
106
|
+
* The string-arg shape (`FlowInstance.findAll(p, "Delivery")`) is
|
|
107
|
+
* shorthand for `{ flowName: "Delivery" }`.
|
|
108
|
+
*
|
|
109
|
+
* Records whose `flow` value has no matching `SHACLFlow` on the
|
|
110
|
+
* perspective (e.g. the flow was unregistered) are silently skipped —
|
|
111
|
+
* the wrapper can't answer `currentState` / `availableTransitions`
|
|
112
|
+
* without the shape, and callers routinely iterate the returned array
|
|
113
|
+
* without null-checks.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* const all = await FlowInstance.findAll(perspective);
|
|
118
|
+
* const deliveries = await FlowInstance.findAll(perspective, "Delivery");
|
|
119
|
+
* const onThisTask = await FlowInstance.findAll(perspective, {
|
|
120
|
+
* subject: "ad4m://task/1",
|
|
121
|
+
* });
|
|
122
|
+
* const deliveriesOnTask = await FlowInstance.findAll(perspective, {
|
|
123
|
+
* flowName: "Delivery",
|
|
124
|
+
* subject: "ad4m://task/1",
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
static findAll(perspective: PerspectiveProxy, filter?: string | {
|
|
129
|
+
flowName?: string;
|
|
130
|
+
subject?: string;
|
|
131
|
+
}): Promise<FlowInstance[]>;
|
|
132
|
+
/**
|
|
133
|
+
* URI of the on-graph `FlowInstance` node — `ad4m://flow/instance/{id}`.
|
|
134
|
+
*
|
|
135
|
+
* Sourced from `Ad4mModel`'s synthesised `baseExpression`, which for
|
|
136
|
+
* `FlowInstanceRecord` *is* the instance's own URI (the value
|
|
137
|
+
* `FlowTransitionProposal.flowInstance` references).
|
|
138
|
+
*/
|
|
139
|
+
get uri(): string;
|
|
140
|
+
/**
|
|
141
|
+
* URI of the base expression this flow runs on — matches the
|
|
142
|
+
* `SHACLFlow.inputTypes` that {@link PerspectiveProxy.availableFlows}
|
|
143
|
+
* would greenlight for this expression.
|
|
144
|
+
*/
|
|
145
|
+
get subject(): string;
|
|
146
|
+
/**
|
|
147
|
+
* Human-readable flow name — the display label. Sourced from the paired
|
|
148
|
+
* `SHACLFlow.name`, not from the record (which stores the URI as its
|
|
149
|
+
* canonical identity — see FlowInstanceRecord's docstring for why).
|
|
150
|
+
*/
|
|
151
|
+
get flowName(): string;
|
|
152
|
+
/** Flow URI — the on-graph discriminator, collision-free across modules. */
|
|
153
|
+
get flowUri(): string;
|
|
154
|
+
/** Name of the state this instance is currently in. */
|
|
155
|
+
get currentStateName(): string;
|
|
156
|
+
/**
|
|
157
|
+
* ISO-8601 (epoch millis after Ad4mModel hydration) start time.
|
|
158
|
+
* Returns `undefined` when hydration didn't produce a `createdAt`
|
|
159
|
+
* — rare, but not fatal.
|
|
160
|
+
*/
|
|
161
|
+
get startedAtMillis(): number | undefined;
|
|
162
|
+
/**
|
|
163
|
+
* The `FlowState` object on the shape matching `currentStateName`.
|
|
164
|
+
* Throws when the record's state name is not declared on the flow —
|
|
165
|
+
* that's a "stale FlowInstance whose flow was edited under it" bug,
|
|
166
|
+
* not a silent-fail case.
|
|
167
|
+
*/
|
|
168
|
+
get currentState(): FlowState;
|
|
169
|
+
/**
|
|
170
|
+
* Every `FlowTransition` on the shape whose `fromState` matches
|
|
171
|
+
* `currentStateName`. Order preserved from the shape.
|
|
172
|
+
*
|
|
173
|
+
* Empty when the current state is terminal (no outgoing transitions).
|
|
174
|
+
*/
|
|
175
|
+
get availableTransitions(): FlowTransition[];
|
|
176
|
+
/**
|
|
177
|
+
* All `FlowTransitionProposal` records targeting this instance's URI.
|
|
178
|
+
*
|
|
179
|
+
* Uses the SDNA identity discriminator (`ad4m://flow/instance` predicate)
|
|
180
|
+
* for the where-filter — one SPARQL round-trip, no client-side
|
|
181
|
+
* filtering.
|
|
182
|
+
*
|
|
183
|
+
* Note: the consensus engine (slice 10.6) will start writing these; today
|
|
184
|
+
* they only exist when a client wrote one directly (or a test seeded one).
|
|
185
|
+
*/
|
|
186
|
+
proposals(): Promise<FlowTransitionProposal[]>;
|
|
187
|
+
}
|