@segmentstream/ontology 0.124.0 → 0.126.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 +19 -0
- package/README.md +1 -0
- package/dist/agent-chat.d.ts +4 -0
- package/dist/agent-chat.js +33 -11
- package/dist/analyze.js +4 -17
- package/dist/index.d.ts +1 -1
- package/dist/manifest.d.ts +405 -9
- package/dist/manifest.js +29 -2
- package/dist/migrate/model.d.ts +230 -6
- package/dist/runtime/agents.js +62 -2
- package/dist/service/agent/protocol.d.ts +10 -0
- package/dist/service/agent/protocol.js +12 -0
- package/dist/service/agent/server.js +31 -1
- package/dist/service/runtime-contract.d.ts +24 -0
- package/dist/service/schemas.d.ts +56 -0
- package/dist/service/webhooks.d.ts +22 -6
- package/dist/service/webhooks.js +131 -50
- package/dist/service/workflows.js +8 -6
- package/dist/webhooks.d.ts +105 -2
- package/dist/webhooks.js +293 -2
- package/dist/workflow.d.ts +10 -5
- package/dist/workflows.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.126.0
|
|
4
|
+
|
|
5
|
+
A webhook trigger checks any provider's HMAC signature: `signature: { scheme: "hmac", secret,
|
|
6
|
+
algorithm, encoding, signatures, ... }` declares where the provider's signatures travel, how they
|
|
7
|
+
are written, which bytes it signs and an optional signed timestamp, so BTCPay Server, GitHub,
|
|
8
|
+
Shopify, Svix (Resend, Clerk), Paddle, Slack and others need no token URL. `algorithm` is `sha1`,
|
|
9
|
+
`sha256` or `sha512`; `encoding` is `hex` or `base64`; `key: { decode: "base64", prefix: "whsec_" }`
|
|
10
|
+
decodes a secret such as Svix's. The workspace secret still never leaves SegmentStream. `stripe`
|
|
11
|
+
and `meta` keep working as before.
|
|
12
|
+
|
|
13
|
+
## 0.125.0
|
|
14
|
+
|
|
15
|
+
The agent hands a person's private chat over to staff. `agent_chat` gains `handoffAt` and
|
|
16
|
+
`handoffReason`, set through the runtime route `POST /api/ontology/agent/chats/handoff` for a
|
|
17
|
+
registered private chat on a channel `inbox.takeover` lists, for its own person only; a second
|
|
18
|
+
handoff keeps the first one's time and reason. While a handoff waits, the report of the chat says
|
|
19
|
+
`handled: true`, so the agent answers none of the person's messages. `takeOver` answers the handoff
|
|
20
|
+
and clears both fields, as does `handBack`, which returns the chat to the agent.
|
|
21
|
+
|
|
3
22
|
## 0.124.0
|
|
4
23
|
|
|
5
24
|
Staff take an inbox chat over from the agent. `agent_chat.takeOver({ chat })` sets the record's new
|
package/README.md
CHANGED
|
@@ -1400,6 +1400,7 @@ Without either header the agent may call only the agent routes:
|
|
|
1400
1400
|
| `GET /api/ontology/agent/identities` | member | `{ identities }`: the member's live identities |
|
|
1401
1401
|
| `DELETE /api/ontology/agent/identities/{id}` | member | Revokes one of them: 204 |
|
|
1402
1402
|
| `POST /api/ontology/agent/chats/seen` | agent | `{ provider, externalId, title, memberId?, leftMemberId?, agentLeft?, migratedFrom? }` → `{ id, title, purpose, whenToUse, handled? }` |
|
|
1403
|
+
| `POST /api/ontology/agent/chats/handoff` | agent | `{ provider, externalId, memberId, reason }` → `{ id, handoffAt, handled? }`; 404 for a chat staff do not take over |
|
|
1403
1404
|
|
|
1404
1405
|
A pairing code is eight characters without look-alikes (no 0, O, 1, I or L), stored as its
|
|
1405
1406
|
SHA-256, valid ten minutes and used once. Each instance allows a client address 60 new
|
package/dist/agent-chat.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
|
|
|
9
9
|
readonly recipient: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
10
10
|
readonly threadId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
11
11
|
readonly lastMessageAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
12
|
+
readonly handoffAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
13
|
+
readonly handoffReason: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
12
14
|
readonly purpose: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
13
15
|
readonly whenToUse: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
14
16
|
}, {
|
|
@@ -58,6 +60,8 @@ export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
|
|
|
58
60
|
readonly recipient: string | null;
|
|
59
61
|
readonly threadId: string | null;
|
|
60
62
|
readonly lastMessageAt: string | null;
|
|
63
|
+
readonly handoffAt: string | null;
|
|
64
|
+
readonly handoffReason: string | null;
|
|
61
65
|
readonly purpose: string | null;
|
|
62
66
|
readonly whenToUse: string | null;
|
|
63
67
|
readonly handledById: string | null;
|
package/dist/agent-chat.js
CHANGED
|
@@ -50,6 +50,22 @@ export const AgentChat = entity("agent_chat", {
|
|
|
50
50
|
label: "Last message",
|
|
51
51
|
description: "When the agent last saw a message in the chat, recorded at most every 15 minutes.",
|
|
52
52
|
}),
|
|
53
|
+
handoffAt: p.timestamp({
|
|
54
|
+
optional: true,
|
|
55
|
+
managed: true,
|
|
56
|
+
label: "Handed off",
|
|
57
|
+
description: "When the agent handed the person over to staff: until a member takes the chat over or " +
|
|
58
|
+
"hands it back, the agent records the person's messages and answers none of them. Empty " +
|
|
59
|
+
"otherwise.",
|
|
60
|
+
}),
|
|
61
|
+
handoffReason: p.text({
|
|
62
|
+
optional: true,
|
|
63
|
+
managed: true,
|
|
64
|
+
maxLength: 1000,
|
|
65
|
+
display: "multiline",
|
|
66
|
+
label: "Handoff reason",
|
|
67
|
+
description: "What the agent said the person needs from staff when it handed them over.",
|
|
68
|
+
}),
|
|
53
69
|
purpose: p.text({
|
|
54
70
|
optional: true,
|
|
55
71
|
maxLength: 64,
|
|
@@ -84,11 +100,11 @@ export const AgentChat = entity("agent_chat", {
|
|
|
84
100
|
indexes: [{ properties: ["provider", "externalId"], unique: true }],
|
|
85
101
|
}).actions((self) => ({
|
|
86
102
|
takeOver: action({
|
|
87
|
-
description: "Take a person's private chat over from the agent, as yourself
|
|
88
|
-
"back, the agent records the person's messages
|
|
89
|
-
"with postMessage. Refused for a group chat,
|
|
90
|
-
"inbox.takeover does not list, and for a chat
|
|
91
|
-
"chat you hold changes nothing.",
|
|
103
|
+
description: "Take a person's private chat over from the agent, as yourself, also when the agent handed " +
|
|
104
|
+
"the person over: until a member hands it back, the agent records the person's messages " +
|
|
105
|
+
"and answers none of them, and staff answer with postMessage. Refused for a group chat, " +
|
|
106
|
+
"for a chat on a channel the ontology's inbox.takeover does not list, and for a chat " +
|
|
107
|
+
"another member took over; taking over a chat you hold changes nothing.",
|
|
92
108
|
hints: { destructive: false, irreversible: false, idempotent: true },
|
|
93
109
|
input: Schema.Struct({ chat: self.ref }),
|
|
94
110
|
handler: ({ input, principal }) => Effect.gen(function* () {
|
|
@@ -120,21 +136,27 @@ export const AgentChat = entity("agent_chat", {
|
|
|
120
136
|
message: "Another member has taken the chat over: hand it back first.",
|
|
121
137
|
});
|
|
122
138
|
}
|
|
123
|
-
|
|
124
|
-
|
|
139
|
+
// Taking the chat over answers the agent's handoff, if it handed the person over.
|
|
140
|
+
if (chat.handledById === null || chat.handoffAt !== null) {
|
|
141
|
+
yield* self.update(chat, {
|
|
142
|
+
handledBy: principal.id,
|
|
143
|
+
handoffAt: null,
|
|
144
|
+
handoffReason: null,
|
|
145
|
+
});
|
|
125
146
|
}
|
|
126
147
|
return { chat: chat.id, handled_by: principal.id };
|
|
127
148
|
}),
|
|
128
149
|
}),
|
|
129
150
|
handBack: action({
|
|
130
|
-
description: "Hand a chat a member took over
|
|
131
|
-
"message with what was said meanwhile in its context. A
|
|
151
|
+
description: "Hand a chat a member took over, or the agent handed over to staff, back to the agent, " +
|
|
152
|
+
"which answers the person's next message with what was said meanwhile in its context. A " +
|
|
153
|
+
"chat no one holds and no handoff waits on changes nothing.",
|
|
132
154
|
hints: { destructive: false, irreversible: false, idempotent: true },
|
|
133
155
|
input: Schema.Struct({ chat: self.ref }),
|
|
134
156
|
handler: ({ input }) => Effect.gen(function* () {
|
|
135
157
|
const chat = yield* self.get(input.chat, { forUpdate: true });
|
|
136
|
-
if (chat.handledById !== null) {
|
|
137
|
-
yield* self.update(chat, { handledBy: null });
|
|
158
|
+
if (chat.handledById !== null || chat.handoffAt !== null) {
|
|
159
|
+
yield* self.update(chat, { handledBy: null, handoffAt: null, handoffReason: null });
|
|
138
160
|
}
|
|
139
161
|
return { chat: chat.id, handled_by: null };
|
|
140
162
|
}),
|
package/dist/analyze.js
CHANGED
|
@@ -29,7 +29,7 @@ import { entityQuerySchemas, findEntityManifest, queryFields, queryLinks, } from
|
|
|
29
29
|
import { EARLIER_QUERY_METRICS_ROUTE, earlierNamesOf } from "./legacy.js";
|
|
30
30
|
import { resolveModelMetrics } from "./model-metrics.js";
|
|
31
31
|
import { cronNeverFires, cronProblem, isAsyncFunction, isWorkflow, isWorkflowTrigger, MAX_ACTION_TRIGGERS, MAX_WORKFLOWS, } from "./workflow.js";
|
|
32
|
-
import { MAX_WEBHOOK_HEADERS, MAX_WEBHOOKS,
|
|
32
|
+
import { MAX_WEBHOOK_HEADERS, MAX_WEBHOOKS, webhookDelivery, webhookHeaderProblem, webhookSignatureManifest, webhookSignatureProblems, WORKSPACE_SECRET_NAME, } from "./webhooks.js";
|
|
33
33
|
import { actionInputToWire } from "./authoring-input.js";
|
|
34
34
|
import { validate } from "./runtime/validation.js";
|
|
35
35
|
import { fixedArgumentsConflict, isToolset, MAXIMUM_TOOLSET_TOOLS, MCP_TOOL_NAME, toolHints, ToolsetLock, withoutFixedArguments, } from "./toolset.js";
|
|
@@ -774,21 +774,8 @@ function resolveWebhookTrigger(trigger, at, scope) {
|
|
|
774
774
|
let valid = true;
|
|
775
775
|
const signature = trigger.signature;
|
|
776
776
|
if (signature !== undefined) {
|
|
777
|
-
const
|
|
778
|
-
? signature.
|
|
779
|
-
: undefined;
|
|
780
|
-
const secret = typeof signature === "object" && signature !== null
|
|
781
|
-
? signature.secret
|
|
782
|
-
: undefined;
|
|
783
|
-
if (!WEBHOOK_SIGNATURE_SCHEMES.includes(scheme)) {
|
|
784
|
-
report("workflow_webhook_signature_invalid", `${at}.signature.scheme`, `${JSON.stringify(scheme) ?? "undefined"} is not a signature scheme; use one of ` +
|
|
785
|
-
`${WEBHOOK_SIGNATURE_SCHEMES.join(", ")}, or omit signature for a provider that signs ` +
|
|
786
|
-
"nothing.");
|
|
787
|
-
valid = false;
|
|
788
|
-
}
|
|
789
|
-
if (typeof secret !== "string" || !WORKSPACE_SECRET_NAME.test(secret)) {
|
|
790
|
-
report("workflow_webhook_signature_invalid", `${at}.signature.secret`, `${JSON.stringify(secret) ?? "undefined"} is not a workspace secret name; name the ` +
|
|
791
|
-
"secret that holds the provider's signing secret, such as stripe-webhook-signing-secret.");
|
|
777
|
+
for (const problem of webhookSignatureProblems(signature)) {
|
|
778
|
+
report("workflow_webhook_signature_invalid", problem.path === "" ? `${at}.signature` : `${at}.signature.${problem.path}`, problem.message);
|
|
792
779
|
valid = false;
|
|
793
780
|
}
|
|
794
781
|
}
|
|
@@ -848,7 +835,7 @@ function resolveWebhookTrigger(trigger, at, scope) {
|
|
|
848
835
|
description: trigger.description,
|
|
849
836
|
...(trigger.signature === undefined
|
|
850
837
|
? {}
|
|
851
|
-
: { signature:
|
|
838
|
+
: { signature: webhookSignatureManifest(trigger.signature) }),
|
|
852
839
|
...(trigger.verification === undefined ? {} : { verification: { ...trigger.verification } }),
|
|
853
840
|
...(listed.length === 0 ? {} : { headers: [...listed] }),
|
|
854
841
|
...(trigger.connection === undefined ? {} : { connection: trigger.connection.key }),
|
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export type { Role, RoleOptions, RolePermission } from "./role.js";
|
|
|
46
46
|
export type { FeedbackOptions, ResolvedFeedback } from "./feedback-config.js";
|
|
47
47
|
export { after, changed, cron, cronNeverFires, cronProblem, isWorkflow, isWorkflowTrigger, MAX_ACTION_TRIGGERS, MAX_WORKFLOWS, nextCronTime, webhook, workflow, } from "./workflow.js";
|
|
48
48
|
export { MAX_WEBHOOK_BODY_BYTES, MAX_META_WEBHOOK_BODY_BYTES, MAX_WEBHOOK_HEADERS, MAX_WEBHOOKS, WEBHOOK_BASE_PATH, WEBHOOK_SIGNATURE_SCHEMES, webhookDelivery, webhookHeaderProblem, webhookPath, } from "./webhooks.js";
|
|
49
|
-
export type { WebhookDelivery, WebhookSignatureScheme } from "./webhooks.js";
|
|
49
|
+
export type { WebhookDelivery, WebhookHmacFormat, WebhookSignatureScheme, WebhookSignedPart, } from "./webhooks.js";
|
|
50
50
|
export type { ActionEvent, ActionTrigger, AfterOptions, AnyActionHandle, AnyWorkflow, ChangedBounds, CronOptions, CronProblem, CronTrigger, TriggerFunction, TriggerRecord, WebhookOptions, WebhookSignature, WebhookVerification, WebhookTrigger, Workflow, WorkflowFunction, WorkflowOptions, WorkflowRunContext, WorkflowTrigger, } from "./workflow.js";
|
|
51
51
|
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, GUEST_BOT_CHECK_SCHEMES, GUEST_CHANNELS, matchesWebsite, signUpOrigin, websiteOrigin, } from "./sign-in.js";
|
|
52
52
|
export type { ChannelProvider, GuestBotCheck, GuestBotCheckScheme, GuestChannel, GuestOptions, ResolvedGuest, ResolvedSignInOptions, ResolvedSignUp, SignInCheck, SignInMethod, SignInOptions, SignInPolicy, SignUpChannel, SignUpOptions, } from "./sign-in.js";
|