@canonmsg/backend-contracts 1.8.1 → 2.0.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/dist/agentBehaviorPolicy.d.ts +45 -86
- package/dist/agentBehaviorPolicy.js +0 -53
- package/dist/cjs/agentBehaviorPolicy.js +1 -54
- package/dist/cjs/contactRequest.js +0 -30
- package/dist/cjs/index.js +0 -8
- package/dist/cjs/media.js +0 -13
- package/dist/cjs/message.js +0 -64
- package/dist/cjs/runtimeCardFields.js +1 -58
- package/dist/cjs/turnProtocol.js +1 -41
- package/dist/contactRequest.d.ts +23 -42
- package/dist/contactRequest.js +0 -29
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/media.d.ts +11 -24
- package/dist/media.js +0 -12
- package/dist/message.d.ts +50 -133
- package/dist/message.js +1 -64
- package/dist/runtimeCardFields.d.ts +39 -112
- package/dist/runtimeCardFields.js +0 -57
- package/dist/turnProtocol.d.ts +24 -91
- package/dist/turnProtocol.js +0 -40
- package/package.json +5 -8
- package/dist/bridgeLocal.d.ts +0 -1729
- package/dist/bridgeLocal.js +0 -673
- package/dist/cjs/bridgeLocal.js +0 -676
- package/dist/cjs/controlSignals.js +0 -44
- package/dist/cjs/endpointRegistry.js +0 -264
- package/dist/cjs/hitl.js +0 -0
- package/dist/cjs/inboundFrame.js +0 -92
- package/dist/cjs/restEndpoints.js +0 -237
- package/dist/cjs/sendContextual.js +0 -92
- package/dist/cjs/sseEvents.js +0 -298
- package/dist/controlSignals.d.ts +0 -55
- package/dist/controlSignals.js +0 -41
- package/dist/endpointRegistry.d.ts +0 -13
- package/dist/endpointRegistry.js +0 -261
- package/dist/hitl.d.ts +0 -303
- package/dist/hitl.js +0 -168
- package/dist/inboundFrame.d.ts +0 -229
- package/dist/inboundFrame.js +0 -89
- package/dist/restEndpoints.d.ts +0 -531
- package/dist/restEndpoints.js +0 -234
- package/dist/schemas/agent-behavior-settings-record.schema.json +0 -48
- package/dist/schemas/bridge-connection-state-notification.schema.json +0 -19
- package/dist/schemas/bridge-get-attachment-params.schema.json +0 -24
- package/dist/schemas/bridge-get-attachment-result.schema.json +0 -20
- package/dist/schemas/bridge-hello-params.schema.json +0 -42
- package/dist/schemas/bridge-hello-result.schema.json +0 -105
- package/dist/schemas/bridge-hitl-state.schema.json +0 -38
- package/dist/schemas/bridge-ok-result.schema.json +0 -15
- package/dist/schemas/bridge-ready-notification.schema.json +0 -79
- package/dist/schemas/bridge-resync-reason.schema.json +0 -9
- package/dist/schemas/bridge-resync.schema.json +0 -18
- package/dist/schemas/bridge-rpc-error.schema.json +0 -19
- package/dist/schemas/bridge-rpc-id.schema.json +0 -12
- package/dist/schemas/bridge-rpc-notification.schema.json +0 -20
- package/dist/schemas/bridge-rpc-request.schema.json +0 -31
- package/dist/schemas/bridge-rpc-response.schema.json +0 -81
- package/dist/schemas/bridge-status-result.schema.json +0 -76
- package/dist/schemas/bridge-upload-media-params.schema.json +0 -28
- package/dist/schemas/bridge-upstream-state.schema.json +0 -10
- package/dist/schemas/contacts-response.schema.json +0 -52
- package/dist/schemas/control-channel-key.schema.json +0 -10
- package/dist/schemas/control-primitive-event.schema.json +0 -30
- package/dist/schemas/control-primitive-map.schema.json +0 -15
- package/dist/schemas/control-session-event.schema.json +0 -26
- package/dist/schemas/control-session-node.schema.json +0 -11
- package/dist/schemas/control-signal-event.schema.json +0 -35
- package/dist/schemas/control-signal-node.schema.json +0 -22
- package/dist/schemas/control-signal-type.schema.json +0 -10
- package/dist/schemas/conversations-response.schema.json +0 -167
- package/dist/schemas/create-contact-request-request.schema.json +0 -17
- package/dist/schemas/create-contact-request-response.schema.json +0 -51
- package/dist/schemas/create-conversation-request.schema.json +0 -82
- package/dist/schemas/create-conversation-response.schema.json +0 -29
- package/dist/schemas/delete-message-response.schema.json +0 -11
- package/dist/schemas/delivery-intent.schema.json +0 -11
- package/dist/schemas/forward-message-request.schema.json +0 -25
- package/dist/schemas/forward-message-response.schema.json +0 -35
- package/dist/schemas/forwarded-from.schema.json +0 -18
- package/dist/schemas/get-messages-query.schema.json +0 -17
- package/dist/schemas/hitl-approval-category.schema.json +0 -15
- package/dist/schemas/hitl-approval-detail.schema.json +0 -21
- package/dist/schemas/hitl-approval-outcome-record.schema.json +0 -33
- package/dist/schemas/hitl-approval-reply-record.schema.json +0 -57
- package/dist/schemas/hitl-approval-request-record.schema.json +0 -105
- package/dist/schemas/hitl-approval-risk.schema.json +0 -11
- package/dist/schemas/hitl-card-outcome-record.schema.json +0 -48
- package/dist/schemas/hitl-card-reply-record.schema.json +0 -46
- package/dist/schemas/hitl-card-request-record.schema.json +0 -73
- package/dist/schemas/hitl-input-answers.schema.json +0 -23
- package/dist/schemas/hitl-input-kind.schema.json +0 -10
- package/dist/schemas/hitl-input-outcome-record.schema.json +0 -46
- package/dist/schemas/hitl-input-question.schema.json +0 -54
- package/dist/schemas/hitl-input-reply-record.schema.json +0 -44
- package/dist/schemas/hitl-input-request-record.schema.json +0 -134
- package/dist/schemas/hitl-pending.schema.json +0 -31
- package/dist/schemas/hitl-request-accepted.schema.json +0 -18
- package/dist/schemas/hitl-request-kind.schema.json +0 -10
- package/dist/schemas/hitl-resolution-status.schema.json +0 -10
- package/dist/schemas/hitl-resolution.schema.json +0 -38
- package/dist/schemas/hitl-session-rule.schema.json +0 -32
- package/dist/schemas/inbound-disposition.schema.json +0 -13
- package/dist/schemas/inbound-frame-attachment-v1.schema.json +0 -94
- package/dist/schemas/inbound-frame-contact-card-v1.schema.json +0 -59
- package/dist/schemas/inbound-frame-group-context-v1.schema.json +0 -96
- package/dist/schemas/inbound-frame-reply-context-v1.schema.json +0 -261
- package/dist/schemas/inbound-frame-shape-v1.schema.json +0 -12
- package/dist/schemas/inbound-frame-v1.schema.json +0 -506
- package/dist/schemas/mark-read-response.schema.json +0 -11
- package/dist/schemas/media-attachment-kind.schema.json +0 -11
- package/dist/schemas/media-attachment.schema.json +0 -42
- package/dist/schemas/messages-page-response.schema.json +0 -290
- package/dist/schemas/participation-decision-input.schema.json +0 -44
- package/dist/schemas/participation-history-message.schema.json +0 -23
- package/dist/schemas/participation-history-snapshot.schema.json +0 -37
- package/dist/schemas/participation-style.schema.json +0 -13
- package/dist/schemas/react-request.schema.json +0 -22
- package/dist/schemas/react-response.schema.json +0 -35
- package/dist/schemas/resolve-admission-request.schema.json +0 -30
- package/dist/schemas/resolve-admission-response.schema.json +0 -129
- package/dist/schemas/resolved-agent-behavior-policy-record.schema.json +0 -81
- package/dist/schemas/rest-contact.schema.json +0 -40
- package/dist/schemas/rest-conversation-last-message.schema.json +0 -77
- package/dist/schemas/rest-conversation.schema.json +0 -155
- package/dist/schemas/rest-message.schema.json +0 -252
- package/dist/schemas/rest-ok-response.schema.json +0 -11
- package/dist/schemas/rest-session-selection.schema.json +0 -40
- package/dist/schemas/runtime-card-field-choice.schema.json +0 -23
- package/dist/schemas/runtime-card-field-type.schema.json +0 -17
- package/dist/schemas/runtime-card-field.schema.json +0 -180
- package/dist/schemas/runtime-card-line-item-column-type.schema.json +0 -12
- package/dist/schemas/runtime-card-line-item-column.schema.json +0 -74
- package/dist/schemas/send-contextual-deferred-response.schema.json +0 -39
- package/dist/schemas/send-contextual-messaged-response.schema.json +0 -42
- package/dist/schemas/send-contextual-request.schema.json +0 -103
- package/dist/schemas/send-contextual-response.schema.json +0 -105
- package/dist/schemas/send-contextual-self-context.schema.json +0 -19
- package/dist/schemas/send-contextual-state-response.schema.json +0 -24
- package/dist/schemas/send-message-request.schema.json +0 -106
- package/dist/schemas/send-message-response.schema.json +0 -14
- package/dist/schemas/sender-type.schema.json +0 -9
- package/dist/schemas/serialize-message-input.schema.json +0 -29
- package/dist/schemas/serialized-agent-client-type.schema.json +0 -12
- package/dist/schemas/serialized-contact-card.schema.json +0 -65
- package/dist/schemas/serialized-contact-request-status.schema.json +0 -11
- package/dist/schemas/serialized-contact-request.schema.json +0 -157
- package/dist/schemas/serialized-content-type.schema.json +0 -13
- package/dist/schemas/serialized-message.schema.json +0 -249
- package/dist/schemas/serialized-reactions.schema.json +0 -14
- package/dist/schemas/serialized-sender-type.schema.json +0 -9
- package/dist/schemas/set-streaming-request.schema.json +0 -67
- package/dist/schemas/set-typing-request.schema.json +0 -25
- package/dist/schemas/sse-access-policy.schema.json +0 -10
- package/dist/schemas/sse-agent-context-payload.schema.json +0 -57
- package/dist/schemas/sse-connected-payload.schema.json +0 -18
- package/dist/schemas/sse-contact-payload.schema.json +0 -40
- package/dist/schemas/sse-contact-removed-payload.schema.json +0 -14
- package/dist/schemas/sse-contact-request-payload.schema.json +0 -157
- package/dist/schemas/sse-conversation-updated-payload.schema.json +0 -48
- package/dist/schemas/sse-error-payload.schema.json +0 -23
- package/dist/schemas/sse-event-envelope.schema.json +0 -42
- package/dist/schemas/sse-event-family.schema.json +0 -12
- package/dist/schemas/sse-event-type.schema.json +0 -28
- package/dist/schemas/sse-heartbeat-payload.schema.json +0 -14
- package/dist/schemas/sse-membership-change.schema.json +0 -28
- package/dist/schemas/sse-message-created-payload.schema.json +0 -414
- package/dist/schemas/sse-message-deleted-payload.schema.json +0 -18
- package/dist/schemas/sse-message-updated-payload.schema.json +0 -46
- package/dist/schemas/sse-presence-payload.schema.json +0 -21
- package/dist/schemas/sse-provenance.schema.json +0 -64
- package/dist/schemas/sse-replay-expired-payload.schema.json +0 -21
- package/dist/schemas/sse-runtime-control-kind.schema.json +0 -13
- package/dist/schemas/sse-runtime-control-payload.schema.json +0 -44
- package/dist/schemas/sse-runtime-updated-payload.schema.json +0 -78
- package/dist/schemas/sse-self-context.schema.json +0 -45
- package/dist/schemas/sse-turn-dispatch.schema.json +0 -29
- package/dist/schemas/sse-turn-updated-payload.schema.json +0 -33
- package/dist/schemas/sse-typing-payload.schema.json +0 -32
- package/dist/schemas/sse-voice-session-event-payload.schema.json +0 -170
- package/dist/schemas/sse-voice-session.schema.json +0 -157
- package/dist/schemas/trigger-decision.schema.json +0 -27
- package/dist/schemas/turn-lifecycle-state.schema.json +0 -14
- package/dist/schemas/turn-message-semantics.schema.json +0 -10
- package/dist/schemas/turn-metadata.schema.json +0 -56
- package/dist/schemas/turn-state-like.schema.json +0 -39
- package/dist/schemas/update-disposition-request.schema.json +0 -22
- package/dist/schemas/upload-media-request.schema.json +0 -25
- package/dist/schemas/upload-media-response.schema.json +0 -55
- package/dist/sendContextual.d.ts +0 -114
- package/dist/sendContextual.js +0 -89
- package/dist/sseEvents.d.ts +0 -494
- package/dist/sseEvents.js +0 -295
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$id": "canon:UpdateDispositionRequestSchema",
|
|
3
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"inboundDisposition": {
|
|
7
|
-
"type": "string",
|
|
8
|
-
"enum": [
|
|
9
|
-
"queued",
|
|
10
|
-
"accepted_now",
|
|
11
|
-
"interleaved",
|
|
12
|
-
"trigger_suppressed",
|
|
13
|
-
"rejected",
|
|
14
|
-
"cancelled"
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"required": [
|
|
19
|
-
"inboundDisposition"
|
|
20
|
-
],
|
|
21
|
-
"additionalProperties": false
|
|
22
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$id": "canon:UploadMediaRequestSchema",
|
|
3
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"conversationId": {
|
|
7
|
-
"type": "string"
|
|
8
|
-
},
|
|
9
|
-
"mimeType": {
|
|
10
|
-
"type": "string"
|
|
11
|
-
},
|
|
12
|
-
"data": {
|
|
13
|
-
"type": "string"
|
|
14
|
-
},
|
|
15
|
-
"fileName": {
|
|
16
|
-
"type": "string"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"required": [
|
|
20
|
-
"conversationId",
|
|
21
|
-
"mimeType",
|
|
22
|
-
"data"
|
|
23
|
-
],
|
|
24
|
-
"additionalProperties": false
|
|
25
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$id": "canon:UploadMediaResponseSchema",
|
|
3
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"properties": {
|
|
6
|
-
"url": {
|
|
7
|
-
"type": "string"
|
|
8
|
-
},
|
|
9
|
-
"attachment": {
|
|
10
|
-
"type": "object",
|
|
11
|
-
"properties": {
|
|
12
|
-
"kind": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"enum": [
|
|
15
|
-
"image",
|
|
16
|
-
"audio",
|
|
17
|
-
"video",
|
|
18
|
-
"file"
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
"url": {
|
|
22
|
-
"type": "string"
|
|
23
|
-
},
|
|
24
|
-
"mimeType": {
|
|
25
|
-
"type": "string"
|
|
26
|
-
},
|
|
27
|
-
"fileName": {
|
|
28
|
-
"type": "string"
|
|
29
|
-
},
|
|
30
|
-
"sizeBytes": {
|
|
31
|
-
"type": "number"
|
|
32
|
-
},
|
|
33
|
-
"width": {
|
|
34
|
-
"type": "number"
|
|
35
|
-
},
|
|
36
|
-
"height": {
|
|
37
|
-
"type": "number"
|
|
38
|
-
},
|
|
39
|
-
"durationMs": {
|
|
40
|
-
"type": "number"
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"required": [
|
|
44
|
-
"kind",
|
|
45
|
-
"url"
|
|
46
|
-
],
|
|
47
|
-
"additionalProperties": false
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"required": [
|
|
51
|
-
"url",
|
|
52
|
-
"attachment"
|
|
53
|
-
],
|
|
54
|
-
"additionalProperties": false
|
|
55
|
-
}
|
package/dist/sendContextual.d.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const SendContextualSelfContextSchema: z.ZodObject<{
|
|
3
|
-
type: z.ZodLiteral<"cross_session">;
|
|
4
|
-
context: z.ZodString;
|
|
5
|
-
}, z.core.$strip>;
|
|
6
|
-
export type SendContextualSelfContext = z.infer<typeof SendContextualSelfContextSchema>;
|
|
7
|
-
/**
|
|
8
|
-
* Request body. Exactly ONE of targetConversationId (existing conversation) or
|
|
9
|
-
* targetUserId (open/reuse a direct conversation, contact-request fallback)
|
|
10
|
-
* must be present — the refinement enforces the handler's rule.
|
|
11
|
-
*/
|
|
12
|
-
export declare const SendContextualRequestSchema: z.ZodObject<{
|
|
13
|
-
sourceConversationId: z.ZodString;
|
|
14
|
-
targetConversationId: z.ZodOptional<z.ZodString>;
|
|
15
|
-
targetUserId: z.ZodOptional<z.ZodString>;
|
|
16
|
-
text: z.ZodOptional<z.ZodString>;
|
|
17
|
-
selfContext: z.ZodObject<{
|
|
18
|
-
type: z.ZodLiteral<"cross_session">;
|
|
19
|
-
context: z.ZodString;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
|
-
sessionConfig: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
22
|
-
sessionSelection: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
23
|
-
mode: z.ZodEnum<{
|
|
24
|
-
new: "new";
|
|
25
|
-
continue_latest: "continue_latest";
|
|
26
|
-
continue_or_create: "continue_or_create";
|
|
27
|
-
}>;
|
|
28
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
29
|
-
mode: z.ZodLiteral<"specific">;
|
|
30
|
-
conversationId: z.ZodString;
|
|
31
|
-
}, z.core.$strip>]>>;
|
|
32
|
-
requestMessage: z.ZodOptional<z.ZodString>;
|
|
33
|
-
messageOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
34
|
-
}, z.core.$strip>;
|
|
35
|
-
export type SendContextualRequest = z.infer<typeof SendContextualRequestSchema>;
|
|
36
|
-
/** HTTP 201 — message persisted (or idempotent replay) with self-context linked. */
|
|
37
|
-
export declare const SendContextualMessagedResponseSchema: z.ZodObject<{
|
|
38
|
-
status: z.ZodLiteral<"messaged">;
|
|
39
|
-
messageId: z.ZodString;
|
|
40
|
-
conversationId: z.ZodString;
|
|
41
|
-
selfContextId: z.ZodString;
|
|
42
|
-
created: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
-
reused: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
-
sessionSelection: z.ZodOptional<z.ZodEnum<{
|
|
45
|
-
new: "new";
|
|
46
|
-
continue_latest: "continue_latest";
|
|
47
|
-
continue_or_create: "continue_or_create";
|
|
48
|
-
specific: "specific";
|
|
49
|
-
}>>;
|
|
50
|
-
}, z.core.$strip>;
|
|
51
|
-
export type SendContextualMessagedResponse = z.infer<typeof SendContextualMessagedResponseSchema>;
|
|
52
|
-
/**
|
|
53
|
-
* HTTP 202 — admission requires approval: a contact request was created
|
|
54
|
-
* (`requested`) or already pending (`pending`); the message is deferred as a
|
|
55
|
-
* contextual intent when a request id exists.
|
|
56
|
-
*/
|
|
57
|
-
export declare const SendContextualDeferredResponseSchema: z.ZodObject<{
|
|
58
|
-
status: z.ZodEnum<{
|
|
59
|
-
pending: "pending";
|
|
60
|
-
requested: "requested";
|
|
61
|
-
}>;
|
|
62
|
-
requestId: z.ZodNullable<z.ZodString>;
|
|
63
|
-
deferredIntentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
64
|
-
}, z.core.$strip>;
|
|
65
|
-
export type SendContextualDeferredResponse = z.infer<typeof SendContextualDeferredResponseSchema>;
|
|
66
|
-
/**
|
|
67
|
-
* Terminal / retryable states:
|
|
68
|
-
* - setup_required (HTTP 202) — agent session setup must complete first.
|
|
69
|
-
* - blocked (HTTP 200) — admission denied (block or policy).
|
|
70
|
-
* - unavailable (HTTP 200) — target cannot be reached right now.
|
|
71
|
-
* - no_session (HTTP 404) — session selection matched nothing.
|
|
72
|
-
*/
|
|
73
|
-
export declare const SendContextualStateResponseSchema: z.ZodObject<{
|
|
74
|
-
status: z.ZodEnum<{
|
|
75
|
-
blocked: "blocked";
|
|
76
|
-
setup_required: "setup_required";
|
|
77
|
-
unavailable: "unavailable";
|
|
78
|
-
no_session: "no_session";
|
|
79
|
-
}>;
|
|
80
|
-
reason: z.ZodString;
|
|
81
|
-
}, z.core.$strip>;
|
|
82
|
-
export type SendContextualStateResponse = z.infer<typeof SendContextualStateResponseSchema>;
|
|
83
|
-
export declare const SendContextualResponseSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
84
|
-
status: z.ZodLiteral<"messaged">;
|
|
85
|
-
messageId: z.ZodString;
|
|
86
|
-
conversationId: z.ZodString;
|
|
87
|
-
selfContextId: z.ZodString;
|
|
88
|
-
created: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
-
reused: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
-
sessionSelection: z.ZodOptional<z.ZodEnum<{
|
|
91
|
-
new: "new";
|
|
92
|
-
continue_latest: "continue_latest";
|
|
93
|
-
continue_or_create: "continue_or_create";
|
|
94
|
-
specific: "specific";
|
|
95
|
-
}>>;
|
|
96
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
97
|
-
status: z.ZodEnum<{
|
|
98
|
-
pending: "pending";
|
|
99
|
-
requested: "requested";
|
|
100
|
-
}>;
|
|
101
|
-
requestId: z.ZodNullable<z.ZodString>;
|
|
102
|
-
deferredIntentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
103
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
104
|
-
status: z.ZodEnum<{
|
|
105
|
-
blocked: "blocked";
|
|
106
|
-
setup_required: "setup_required";
|
|
107
|
-
unavailable: "unavailable";
|
|
108
|
-
no_session: "no_session";
|
|
109
|
-
}>;
|
|
110
|
-
reason: z.ZodString;
|
|
111
|
-
}, z.core.$strip>]>;
|
|
112
|
-
export type SendContextualResponse = z.infer<typeof SendContextualResponseSchema>;
|
|
113
|
-
/** HTTP status the handler pairs with each response status. */
|
|
114
|
-
export declare const SEND_CONTEXTUAL_HTTP_STATUS: Record<SendContextualResponse['status'], number>;
|
package/dist/sendContextual.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// Wire contract v1 — POST /messages/send-contextual as a FIRST-CLASS contract
|
|
2
|
-
// (bridge-execution-plan Phase 3; owner decision 2026-07-03: the re-spec rides
|
|
3
|
-
// contract v1, the transport stays as-is and the Bridge proxies it unchanged
|
|
4
|
-
// in Phase 4).
|
|
5
|
-
//
|
|
6
|
-
// Grounded in functions/src/api/sendContextualMessage.ts (the handler's actual
|
|
7
|
-
// parse + emissions) and @canonmsg/core's SendContextualMessageOptions/Result.
|
|
8
|
-
// This mirrors CURRENT behavior — a re-spec, not a redesign.
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
import { RestSessionSelectionSchema } from './restEndpoints.js';
|
|
11
|
-
export const SendContextualSelfContextSchema = z.object({
|
|
12
|
-
type: z.literal('cross_session'),
|
|
13
|
-
/** Private agent self-context; server caps at 1000 chars. */
|
|
14
|
-
context: z.string(),
|
|
15
|
-
});
|
|
16
|
-
/**
|
|
17
|
-
* Request body. Exactly ONE of targetConversationId (existing conversation) or
|
|
18
|
-
* targetUserId (open/reuse a direct conversation, contact-request fallback)
|
|
19
|
-
* must be present — the refinement enforces the handler's rule.
|
|
20
|
-
*/
|
|
21
|
-
export const SendContextualRequestSchema = z.object({
|
|
22
|
-
sourceConversationId: z.string(),
|
|
23
|
-
/** Target arm 1: send into an existing conversation. */
|
|
24
|
-
targetConversationId: z.string().optional(),
|
|
25
|
-
/** Target arm 2: resolve/create a direct conversation with this user. */
|
|
26
|
-
targetUserId: z.string().optional(),
|
|
27
|
-
text: z.string().optional(),
|
|
28
|
-
selfContext: SendContextualSelfContextSchema,
|
|
29
|
-
/** Initial agent session config (agent targets) — opaque pass-through. */
|
|
30
|
-
sessionConfig: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
31
|
-
sessionSelection: RestSessionSelectionSchema.optional(),
|
|
32
|
-
/** Contact-request message when admission requires approval. */
|
|
33
|
-
requestMessage: z.string().optional(),
|
|
34
|
-
/**
|
|
35
|
-
* SendMessageOptions passthrough (attachments, replyTo, metadata, …).
|
|
36
|
-
* May NOT carry selfContextId/selfContext — the handler rejects overrides
|
|
37
|
-
* of the self-context linkage fields.
|
|
38
|
-
*/
|
|
39
|
-
messageOptions: z.record(z.string(), z.unknown()).optional(),
|
|
40
|
-
}).refine((body) => (body.targetConversationId ? 1 : 0) + (body.targetUserId ? 1 : 0) === 1, { message: 'Provide exactly one targetConversationId or targetUserId' }).refine((body) => !body.messageOptions
|
|
41
|
-
|| (!('selfContextId' in body.messageOptions) && !('selfContext' in body.messageOptions)), { message: 'messageOptions may not override self-context linkage fields' });
|
|
42
|
-
// ── Response arms (exactly what the handler emits today) ───────────────
|
|
43
|
-
/** HTTP 201 — message persisted (or idempotent replay) with self-context linked. */
|
|
44
|
-
export const SendContextualMessagedResponseSchema = z.object({
|
|
45
|
-
status: z.literal('messaged'),
|
|
46
|
-
messageId: z.string(),
|
|
47
|
-
conversationId: z.string(),
|
|
48
|
-
selfContextId: z.string(),
|
|
49
|
-
/** Present when the target conversation was opened by this call. */
|
|
50
|
-
created: z.boolean().optional(),
|
|
51
|
-
reused: z.boolean().optional(),
|
|
52
|
-
sessionSelection: z.enum(['new', 'continue_latest', 'continue_or_create', 'specific']).optional(),
|
|
53
|
-
});
|
|
54
|
-
/**
|
|
55
|
-
* HTTP 202 — admission requires approval: a contact request was created
|
|
56
|
-
* (`requested`) or already pending (`pending`); the message is deferred as a
|
|
57
|
-
* contextual intent when a request id exists.
|
|
58
|
-
*/
|
|
59
|
-
export const SendContextualDeferredResponseSchema = z.object({
|
|
60
|
-
status: z.enum(['requested', 'pending']),
|
|
61
|
-
requestId: z.string().nullable(),
|
|
62
|
-
deferredIntentId: z.string().nullable().optional(),
|
|
63
|
-
});
|
|
64
|
-
/**
|
|
65
|
-
* Terminal / retryable states:
|
|
66
|
-
* - setup_required (HTTP 202) — agent session setup must complete first.
|
|
67
|
-
* - blocked (HTTP 200) — admission denied (block or policy).
|
|
68
|
-
* - unavailable (HTTP 200) — target cannot be reached right now.
|
|
69
|
-
* - no_session (HTTP 404) — session selection matched nothing.
|
|
70
|
-
*/
|
|
71
|
-
export const SendContextualStateResponseSchema = z.object({
|
|
72
|
-
status: z.enum(['setup_required', 'blocked', 'unavailable', 'no_session']),
|
|
73
|
-
reason: z.string(),
|
|
74
|
-
});
|
|
75
|
-
export const SendContextualResponseSchema = z.union([
|
|
76
|
-
SendContextualMessagedResponseSchema,
|
|
77
|
-
SendContextualDeferredResponseSchema,
|
|
78
|
-
SendContextualStateResponseSchema,
|
|
79
|
-
]);
|
|
80
|
-
/** HTTP status the handler pairs with each response status. */
|
|
81
|
-
export const SEND_CONTEXTUAL_HTTP_STATUS = {
|
|
82
|
-
messaged: 201,
|
|
83
|
-
requested: 202,
|
|
84
|
-
pending: 202,
|
|
85
|
-
setup_required: 202,
|
|
86
|
-
blocked: 200,
|
|
87
|
-
unavailable: 200,
|
|
88
|
-
no_session: 404,
|
|
89
|
-
};
|