@segmentstream/ontology 0.180.0 → 0.182.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/dist/agent-chat.d.ts +2 -2
- package/dist/agent-chat.js +2 -1
- package/dist/agent-draft.d.ts +8 -8
- package/dist/analyze.d.ts +1 -8
- package/dist/analyze.js +108 -52
- package/dist/index.d.ts +1 -1
- package/dist/manifest.d.ts +110 -68
- package/dist/manifest.js +24 -2
- package/dist/migrate/model.d.ts +78 -50
- package/dist/review.d.ts +46 -0
- package/dist/review.js +47 -0
- package/dist/runtime/agent-web.js +47 -26
- package/dist/runtime/agents.js +53 -4
- package/dist/runtime/guests.d.ts +4 -1
- package/dist/runtime/guests.js +24 -5
- package/dist/service/agent/protocol.d.ts +51 -0
- package/dist/service/agent/protocol.js +66 -1
- package/dist/service/agent/server.d.ts +8 -2
- package/dist/service/agent/server.js +208 -48
- package/dist/service/authentication.js +14 -3
- package/dist/service/chat/archive.d.ts +8 -1
- package/dist/service/chat/delivery.js +3 -1
- package/dist/service/chat/envelope.d.ts +8 -8
- package/dist/service/chat/local-reads.d.ts +5 -5
- package/dist/service/chat/providers/custom.js +2 -0
- package/dist/service/chat/providers/provider.d.ts +5 -0
- package/dist/service/chat/reply-proposal.d.ts +122 -0
- package/dist/service/chat/reply-proposal.js +385 -0
- package/dist/service/chat/review-delivery.d.ts +131 -24
- package/dist/service/chat/review-delivery.js +393 -296
- package/dist/service/chat/store-delivery.d.ts +27 -5
- package/dist/service/chat/store-delivery.js +45 -33
- package/dist/service/discovery-search.d.ts +1 -1
- package/dist/service/operations.js +2 -1
- package/dist/service/runtime-contract.d.ts +33 -1
- package/dist/service/runtime-identity.d.ts +1 -0
- package/dist/service/runtime-identity.js +2 -0
- package/dist/service/schemas.d.ts +4 -0
- package/dist/service/service.js +12 -14
- package/dist/service/toolsets.d.ts +1 -1
- package/dist/service/toolsets.js +38 -4
- package/dist/sign-in.d.ts +14 -7
- package/dist/sign-in.js +4 -3
- package/dist/toolset.d.ts +17 -1
- package/dist/workspace-channel.d.ts +6 -0
- package/dist/workspace-channel.js +27 -0
- package/package.json +5 -1
- package/dist/service/agent/public-group-action.d.ts +0 -23
- package/dist/service/agent/public-group-action.js +0 -53
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { nameToWire } from "../../authoring-names.js";
|
|
4
|
-
import { principalScopes, isAllowed } from "../../permissions.js";
|
|
5
|
-
import { CurrentPrincipal } from "../authentication.js";
|
|
6
|
-
import { makeOperations, identityToken } from "../operations.js";
|
|
7
|
-
/** Stable UUID in the given namespace. A group action's sender is scoped to that chat. */
|
|
8
|
-
export function groupSubject(parts) {
|
|
9
|
-
const bytes = createHash("sha256").update(JSON.stringify(parts)).digest();
|
|
10
|
-
bytes[6] = (bytes[6] & 15) | 80;
|
|
11
|
-
bytes[8] = (bytes[8] & 63) | 128;
|
|
12
|
-
const hex = bytes.toString("hex");
|
|
13
|
-
return [
|
|
14
|
-
hex.slice(0, 8),
|
|
15
|
-
hex.slice(8, 12),
|
|
16
|
-
hex.slice(12, 16),
|
|
17
|
-
hex.slice(16, 20),
|
|
18
|
-
hex.slice(20, 32),
|
|
19
|
-
].join("-");
|
|
20
|
-
}
|
|
21
|
-
export function publicActionForGroup(backend, options) {
|
|
22
|
-
const { plan, binding } = options;
|
|
23
|
-
const entity = plan.entities.find((item) => item.name === nameToWire(binding.entity));
|
|
24
|
-
const action = entity?.actions.find((item) => !item.generated && item.name === nameToWire(binding.action));
|
|
25
|
-
const role = plan.ontology.roles.find((item) => item.name === nameToWire(binding.role));
|
|
26
|
-
const operations = makeOperations(backend, plan, options.hooks, options.connections, options.replicate);
|
|
27
|
-
return (request, source, input) => Effect.gen(function* () {
|
|
28
|
-
if (!entity || !action || action.action.confirm || !role) {
|
|
29
|
-
return yield* Effect.die(new Error("Invalid public group action."));
|
|
30
|
-
}
|
|
31
|
-
const permissions = action.permissions.filter((permission) => role.permissions.includes(permission));
|
|
32
|
-
const principal = {
|
|
33
|
-
kind: "guest",
|
|
34
|
-
id: groupSubject(["public-action", source.channel, source.chat, source.sender]),
|
|
35
|
-
roles: [role.name],
|
|
36
|
-
permissions,
|
|
37
|
-
...principalScopes([role], [role.name]),
|
|
38
|
-
chat: { provider: source.channel, chatId: source.chat },
|
|
39
|
-
};
|
|
40
|
-
if (!action.permissions.every((p) => isAllowed(p, principal))) {
|
|
41
|
-
return yield* Effect.die(new Error("Public group action denied."));
|
|
42
|
-
}
|
|
43
|
-
const answer = yield* operations
|
|
44
|
-
.runAction(entity, action, {
|
|
45
|
-
input,
|
|
46
|
-
options: {},
|
|
47
|
-
validateOnly: false,
|
|
48
|
-
identityToken: identityToken(request),
|
|
49
|
-
})
|
|
50
|
-
.pipe(Effect.provideService(CurrentPrincipal, principal));
|
|
51
|
-
return answer.result;
|
|
52
|
-
});
|
|
53
|
-
}
|