@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,4 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import { type AgentDraftFile } from "../../agent-draft.js";
|
|
2
3
|
import { type EmailRecipients } from "../../email.js";
|
|
3
4
|
import type { ReviewSendInput } from "../../chat.js";
|
|
4
5
|
import type { TelegramPreviewContext } from "../../telegram.js";
|
|
@@ -7,22 +8,16 @@ import type { Ontology } from "../../ontology.js";
|
|
|
7
8
|
import type { Principal } from "../../runtime.js";
|
|
8
9
|
import type { ConnectionTransportFactory } from "../connections.js";
|
|
9
10
|
import type { OntologyBackend } from "../runtime-contract.js";
|
|
10
|
-
import type { DeliveryArchive } from "./archive.js";
|
|
11
|
+
import type { DeliveryArchive, DeliveryEvent, DeliveryReceipt } from "./archive.js";
|
|
12
|
+
import type { ChatRequester } from "./attribution.js";
|
|
13
|
+
import type { ChatProvider } from "./providers/provider.js";
|
|
11
14
|
import type { AgentChannelTransport } from "./providers/provider.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* as the agent and without attribution. A reply to mail goes to the review's `to` and `cc`, or the
|
|
16
|
-
* addresses the member names in their place. The delivery's claim, on the reply's row of the
|
|
17
|
-
* workspace chat store, keyed by the review and not by the member, makes it at most once: a replay
|
|
18
|
-
* of the same approval returns the delivery, and a different approval, by another member, with
|
|
19
|
-
* another text or to other people, is refused. A provider that refused it consumes the claim: the
|
|
20
|
-
* reply is never sent again.
|
|
21
|
-
*/
|
|
22
|
-
export declare function reviewSender(input: {
|
|
15
|
+
import type { Destination } from "./resolve.js";
|
|
16
|
+
/** What the ontology sends the agent's replies with, as the agent and without attribution. */
|
|
17
|
+
export interface AgentReplyTransport {
|
|
23
18
|
readonly ontology: Ontology;
|
|
24
19
|
readonly connections: ConnectionTransportFactory;
|
|
25
|
-
/** The app's agent, which sends through a workspace channel. */
|
|
20
|
+
/** The app's agent, which sends through a workspace channel and an email channel. */
|
|
26
21
|
readonly agent?: AgentChannelTransport;
|
|
27
22
|
/**
|
|
28
23
|
* The chat archive in Cloud, where the delivery reserves its key while the workspace chat store
|
|
@@ -33,25 +28,137 @@ export declare function reviewSender(input: {
|
|
|
33
28
|
/** Link previews for the destination connection, as a chat post gets them. */
|
|
34
29
|
readonly previews?: TelegramPreviewContext;
|
|
35
30
|
readonly backend: OntologyBackend["Service"];
|
|
36
|
-
readonly principal: Principal;
|
|
37
31
|
readonly identityToken: string | undefined;
|
|
38
32
|
readonly requestId: string;
|
|
39
33
|
/** Reads a file's bytes by its download grant; `fetch` by default. */
|
|
40
34
|
readonly fetch?: typeof fetch;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* One reply of the agent's the ontology sends to a person's chat: a draft a member approved, or a
|
|
38
|
+
* reply the review let go when the agent proposed it.
|
|
39
|
+
*/
|
|
40
|
+
export interface AgentReply {
|
|
41
|
+
/** The channel the chat is on, by name. */
|
|
42
|
+
readonly channel: string;
|
|
43
|
+
/** The kind of channel the reply was written for, such as telegram. */
|
|
44
|
+
readonly channelKind: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the ontology's `chat` must declare the channel: an approved draft is sent through its
|
|
47
|
+
* connection. A proposed reply on a channel the agent sends through, as a workspace channel and an
|
|
48
|
+
* email channel are, needs no declaration.
|
|
49
|
+
*/
|
|
50
|
+
readonly declared: boolean;
|
|
51
|
+
readonly chatId: string;
|
|
52
|
+
/** Whom the provider sends to, where it differs from the chat's id. */
|
|
53
|
+
readonly recipient: string | null;
|
|
54
|
+
readonly chatKind: "private" | "group";
|
|
55
|
+
readonly threadId: string | null;
|
|
56
|
+
/** The person's message the reply answers, which only a group's reply quotes. */
|
|
57
|
+
readonly replyTo: string | null;
|
|
58
|
+
readonly text: string;
|
|
59
|
+
/**
|
|
60
|
+
* The most characters the text may have beside what the provider takes in one message: a
|
|
61
|
+
* draft's own length for an approved draft. A proposed reply is bounded by its provider alone.
|
|
62
|
+
*/
|
|
63
|
+
readonly textLimit?: number;
|
|
64
|
+
readonly files: ReadonlyArray<AgentDraftFile>;
|
|
65
|
+
/** A reply to mail: whom it goes to and copies. */
|
|
66
|
+
readonly recipients?: EmailRecipients;
|
|
67
|
+
/** The member the reply is for, as whom its files are read. */
|
|
68
|
+
readonly person: string | null;
|
|
69
|
+
/** The members who read it beside its person, in a chat several people share. */
|
|
70
|
+
readonly participants: ReadonlyArray<string>;
|
|
71
|
+
/** The agent's session the chat store gives it to as its own message; null for none. */
|
|
72
|
+
readonly sessionId: string | null;
|
|
73
|
+
readonly turnId: string | null;
|
|
74
|
+
/** Names the delivery: its claim's event, its receipt and a workspace channel's send. */
|
|
75
|
+
readonly operationId: string;
|
|
76
|
+
/** What the delivery's claim is keyed by: a delivery under the same subject is the same. */
|
|
77
|
+
readonly subject: string;
|
|
78
|
+
/** Who the archive records sent it; the person never sees it. */
|
|
79
|
+
readonly requester: Effect.Effect<ChatRequester, PermissionDenied>;
|
|
80
|
+
/** The action and principal the connection's audit names. */
|
|
81
|
+
readonly audit: {
|
|
82
|
+
readonly action: string;
|
|
83
|
+
readonly principalId: string;
|
|
84
|
+
};
|
|
85
|
+
/** The chat store's message an earlier reservation of the reply named, for a replay. */
|
|
86
|
+
readonly message?: string | null;
|
|
87
|
+
/**
|
|
88
|
+
* The whole reply a proposal's first message belongs to, which the chat store keeps with the
|
|
89
|
+
* message's delivery: another reply proposed under the key is refused by it.
|
|
90
|
+
*/
|
|
91
|
+
readonly binding?: string;
|
|
92
|
+
/** Why a reply that is empty, too long, or to no destination the provider takes is refused. */
|
|
93
|
+
readonly rejection: (provider: string, limit: number) => string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The workspace chat store's key of the agent's delivery under `subject`: the row its claim
|
|
97
|
+
* reserves, which a replay finds without the message it would send.
|
|
98
|
+
*/
|
|
99
|
+
export declare function agentReplyOperation(subject: string): string;
|
|
100
|
+
/** A reply ready to reserve and send: everything that can refuse it was checked. */
|
|
101
|
+
export interface PreparedAgentReply {
|
|
102
|
+
readonly reply: AgentReply;
|
|
103
|
+
readonly provider: ChatProvider;
|
|
104
|
+
readonly connection: string;
|
|
105
|
+
readonly target: Destination;
|
|
106
|
+
readonly finalText: string;
|
|
107
|
+
readonly plainText: string;
|
|
108
|
+
readonly replyTo: string | null;
|
|
109
|
+
readonly event: DeliveryEvent;
|
|
110
|
+
readonly scope: string;
|
|
111
|
+
readonly key: string;
|
|
112
|
+
readonly fingerprint: string;
|
|
113
|
+
readonly archive: DeliveryArchive;
|
|
114
|
+
readonly onStore: boolean;
|
|
115
|
+
}
|
|
116
|
+
/** What became of one delivery of the agent's reply. */
|
|
117
|
+
export interface AgentReplyDelivered {
|
|
118
|
+
readonly status: "sent" | "uncertain" | "failed";
|
|
119
|
+
readonly messageId: string | null;
|
|
120
|
+
readonly duplicate: boolean;
|
|
121
|
+
/** The reply's message in the workspace chat store, by its id; absent before the store held it. */
|
|
122
|
+
readonly message?: string;
|
|
123
|
+
/** Why the provider refused a `failed` reply, when it says. */
|
|
124
|
+
readonly refusal?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Checks a reply of the agent's before anything is reserved or sent: its channel and connection,
|
|
128
|
+
* its text as the provider renders it, its destination and files, and who sends it. Answers the
|
|
129
|
+
* delivery it would be, bound to its key, on the workspace chat store once it holds a message.
|
|
130
|
+
*/
|
|
131
|
+
export declare function prepareAgentReply(transport: AgentReplyTransport, reply: AgentReply): Effect.Effect<PreparedAgentReply, ActionRejected | PermissionDenied>;
|
|
132
|
+
/**
|
|
133
|
+
* The delivery a reply's key holds already, read without reserving anything: its receipt, or
|
|
134
|
+
* undefined when the key has none. Another request under the key is refused.
|
|
135
|
+
*/
|
|
136
|
+
export declare function earlierAgentReply(transport: AgentReplyTransport, prepared: PreparedAgentReply): Effect.Effect<DeliveryReceipt | undefined, ActionRejected>;
|
|
137
|
+
/**
|
|
138
|
+
* Sends a prepared reply of the agent's at most once: its key is claimed on the chat store, or the
|
|
139
|
+
* archive in Cloud before it, before the provider is called, and the provider's outcome is that
|
|
140
|
+
* claim's receipt. A replay of the same reply answers the delivery, and another under the key is
|
|
141
|
+
* refused. `reserve` runs the claim, as an approval runs it under its draft's lock.
|
|
142
|
+
*/
|
|
143
|
+
export declare function deliverAgentReply<E = never>(transport: AgentReplyTransport, prepared: PreparedAgentReply, reserve: (reservation: Effect.Effect<DeliveryReceipt, ActionRejected>, onStore: boolean) => Effect.Effect<DeliveryReceipt, ActionRejected | PermissionDenied | E>): Effect.Effect<AgentReplyDelivered, ActionRejected | PermissionDenied | E>;
|
|
144
|
+
/**
|
|
145
|
+
* Sends a reply the agent held for review, once a member approved it: the draft or the member's
|
|
146
|
+
* edit, to the person's chat through the ontology's chat connection of the channel the chat is on,
|
|
147
|
+
* as the agent and without attribution. A reply to mail goes to the review's `to` and `cc`, or the
|
|
148
|
+
* addresses the member names in their place. The delivery's claim, on the reply's row of the
|
|
149
|
+
* workspace chat store, keyed by the review and not by the member, makes it at most once: a replay
|
|
150
|
+
* of the same approval returns the delivery, and a different approval, by another member, with
|
|
151
|
+
* another text or to other people, is refused. A provider that refused it consumes the claim: the
|
|
152
|
+
* reply is never sent again.
|
|
153
|
+
*/
|
|
154
|
+
export declare function reviewSender(input: AgentReplyTransport & {
|
|
155
|
+
readonly principal: Principal;
|
|
41
156
|
}): (send: ReviewSendInput) => Effect.Effect<{
|
|
42
|
-
files?: readonly
|
|
43
|
-
recipients?: EmailRecipients | undefined;
|
|
44
|
-
message?: string | undefined;
|
|
45
|
-
status: "sent" | "failed" | "uncertain";
|
|
46
|
-
text: string;
|
|
47
|
-
messageId: string | null;
|
|
48
|
-
duplicate: true;
|
|
49
|
-
} | {
|
|
50
|
-
files?: readonly import("../../agent-draft.js").AgentDraftFile[] | undefined;
|
|
157
|
+
files?: readonly AgentDraftFile[] | undefined;
|
|
51
158
|
recipients?: EmailRecipients | undefined;
|
|
52
159
|
message?: string | undefined;
|
|
53
160
|
status: "sent" | "failed" | "uncertain";
|
|
54
161
|
text: string;
|
|
55
162
|
messageId: string | null;
|
|
56
|
-
duplicate:
|
|
163
|
+
duplicate: boolean;
|
|
57
164
|
}, ActionRejected | PermissionDenied, never>;
|