@vellumai/assistant 0.11.7-dev.202608311912.62d3bb8 → 0.11.7-dev.202608312114.5fab2e2
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/docs/guardian-request-flow.md +35 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +1 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/no-response.ts +84 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +1 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/no-response.ts +84 -0
- package/node_modules/@vellumai/gateway-client/src/gateway-ipc-contracts.ts +46 -0
- package/node_modules/@vellumai/gateway-client/src/guardian-request-contract.ts +17 -0
- package/node_modules/@vellumai/gateway-client/src/index.ts +2 -0
- package/node_modules/@vellumai/service-contracts/package.json +1 -0
- package/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/service-contracts/src/no-response.ts +84 -0
- package/openapi.yaml +215 -0
- package/package.json +1 -1
- package/src/__tests__/compactor-call-site-logging.test.ts +7 -1
- package/src/__tests__/config-schema.test.ts +1 -0
- package/src/__tests__/contacts-write.test.ts +141 -3
- package/src/__tests__/conversation-agent-loop.test.ts +91 -0
- package/src/__tests__/conversation-load-history-repair.test.ts +59 -0
- package/src/__tests__/conversation-retry-route.test.ts +5 -0
- package/src/__tests__/conversation-summarize-route.test.ts +5 -0
- package/src/__tests__/guardian-gateway-sim.ts +15 -0
- package/src/__tests__/guardian-reply-router-answer-mode.test.ts +6 -0
- package/src/__tests__/guardian-wait-controller.test.ts +6 -0
- package/src/__tests__/list-messages-system-card.test.ts +70 -0
- package/src/__tests__/media-stream-server-integration.test.ts +6 -0
- package/src/__tests__/terminal-tools.test.ts +9 -9
- package/src/__tests__/usage-attribution.test.ts +26 -0
- package/src/api/index.ts +8 -0
- package/src/api/responses/conversation-message.ts +20 -0
- package/src/api/responses/home.ts +101 -0
- package/src/approvals/guardian-card-withdrawal.ts +22 -2
- package/src/approvals/guardian-request-status-sync.ts +9 -0
- package/src/channels/gateway-guardian-requests.ts +19 -1
- package/src/config/feature-flag-registry.json +8 -0
- package/src/config/schemas/__tests__/live-voice.test.ts +13 -0
- package/src/config/schemas/live-voice.ts +7 -0
- package/src/contacts/__tests__/mirror-reconciler.test.ts +352 -0
- package/src/contacts/contact-store.ts +47 -4
- package/src/contacts/contacts-write.ts +5 -2
- package/src/contacts/mirror-reconciler.ts +210 -0
- package/src/contacts/mirror-tombstones.ts +42 -0
- package/src/contacts/notify-contacts-changed.ts +11 -2
- package/src/context/compactor.ts +35 -19
- package/src/conversations/message-consolidation.ts +2 -2
- package/src/daemon/conversation-agent-loop-handlers.ts +2 -2
- package/src/daemon/conversation-agent-loop.ts +86 -0
- package/src/daemon/conversation.ts +17 -2
- package/src/daemon/handlers/conversations.ts +2 -0
- package/src/daemon/reaction-history-render.test.ts +33 -0
- package/src/daemon/reaction-history-render.ts +36 -5
- package/src/daemon/reaction-record.test.ts +162 -0
- package/src/daemon/reaction-record.ts +83 -0
- package/src/daemon/shutdown-handlers.ts +0 -2
- package/src/home/feed-types.ts +4 -0
- package/src/home/feed-writer.ts +25 -0
- package/src/live-voice/__tests__/live-voice-vad.test.ts +109 -0
- package/src/live-voice/live-voice-session.ts +70 -6
- package/src/messaging/reaction-envelopes.ts +79 -0
- package/src/notifications/__tests__/guardian-feed-projection.test.ts +360 -0
- package/src/notifications/__tests__/home-feed-side-effect.test.ts +8 -0
- package/src/notifications/conversation-pairing.ts +23 -0
- package/src/notifications/emit-signal.ts +8 -5
- package/src/notifications/guardian-feed-projection.ts +492 -0
- package/src/notifications/home-feed-side-effect.ts +59 -11
- package/src/permissions/question-guardian-request.test.ts +6 -0
- package/src/persistence/conversation-crud.ts +12 -2
- package/src/persistence/conversation-types.ts +39 -0
- package/src/persistence/llm-request-log-store.ts +1 -1
- package/src/plugins/defaults/compaction/window-manager.ts +2 -0
- package/src/runtime/__tests__/agent-wake.test.ts +5 -6
- package/src/runtime/agent-wake.ts +3 -3
- package/src/runtime/no-response.ts +13 -74
- package/src/runtime/routes/conversation-routes.ts +32 -6
- package/src/runtime/routes/guardian-expiry-sweep.ts +9 -0
- package/src/runtime/routes/inbound-message-handler.ts +17 -0
- package/src/runtime/routes/inbound-stages/guardian-reply-intercept.test.ts +6 -0
- package/src/runtime/routes/inbound-stages/reaction-intercept.ts +19 -53
- package/src/stt/__tests__/room-noise-floor.test.ts +108 -0
- package/src/stt/room-noise-floor.ts +140 -0
- package/src/tools/channel/react-to-message.test.ts +71 -0
- package/src/tools/channel/react-to-message.ts +32 -0
- package/src/tools/host-terminal/host-shell.test.ts +24 -0
- package/src/tools/host-terminal/host-shell.ts +9 -38
- package/src/tools/shared/shell-output.test.ts +104 -0
- package/src/tools/shared/shell-output.ts +112 -39
- package/src/tools/terminal/shell.test.ts +63 -0
- package/src/tools/terminal/shell.ts +10 -44
- package/src/usage/attribution.ts +12 -4
|
@@ -54,6 +54,41 @@ anti-pattern was retired in #35642 and again in the ask_question redesign).
|
|
|
54
54
|
| Kind-specific follow-through | resolver registry (`kind` → resolver) | switch statements in the router |
|
|
55
55
|
| Reply understanding | guardian reply router (codes, buttons, reactions, modes) | per-feature inbound intercepts |
|
|
56
56
|
|
|
57
|
+
## The canonical home-feed projection
|
|
58
|
+
|
|
59
|
+
Every pending request is also exactly one home-feed item, the bell's
|
|
60
|
+
"Needs attention" row. `notifications/guardian-feed-projection.ts` owns
|
|
61
|
+
it end to end:
|
|
62
|
+
|
|
63
|
+
- The pipeline's feed side effect writes it keyed
|
|
64
|
+
`guardian:<requestId>`, so the feed's replace-in-place merge keeps one
|
|
65
|
+
item per request. Its typed `guardianRequest` field
|
|
66
|
+
(`FeedItemGuardianRequestSchema` in `api/responses/home.ts`) is a read
|
|
67
|
+
projection of the gateway row: intent, status, requester, tool, source
|
|
68
|
+
reference, and the Slack-DM card deep links. It is never a delivery
|
|
69
|
+
row of its own; clients derive every affordance from `status`.
|
|
70
|
+
- `withdrawGuardianRequestCards` rewrites it into a terminal receipt as
|
|
71
|
+
one of the surfaces it settles, and its failure gates `complete` the
|
|
72
|
+
same way a failed card edit does. The write-vs-resolve race converges
|
|
73
|
+
from the other side too: the feed writer re-checks canonical status
|
|
74
|
+
after its append.
|
|
75
|
+
- The feed writer's bulk-dismiss pass skips pending guardian items
|
|
76
|
+
(`isPendingGuardianFeedItem`), so "Clear all" can never retire an
|
|
77
|
+
unresolved request; only its receipt is clearable.
|
|
78
|
+
- The guardian expiry sweep runs `reconcileGuardianFeedProjections()`
|
|
79
|
+
each round: pending requests missing an item are backfilled from the
|
|
80
|
+
request row (no conversation is generated), and an item still
|
|
81
|
+
actionable for a terminal request is receipted with a loud log line.
|
|
82
|
+
|
|
83
|
+
Routing policy for the Slack guardian DM: the card message there is a
|
|
84
|
+
delivery projection, not conversation content. Its delivery is not
|
|
85
|
+
paired with any conversation (`conversation-pairing.ts` skips
|
|
86
|
+
guardian.question Slack deliveries), and the Slack DM cold backfill
|
|
87
|
+
skips messages whose ts matches a recorded guardian delivery for the
|
|
88
|
+
chat (`guardian_requests_list_deliveries_by_chat`), so the card never
|
|
89
|
+
enters a Vellum transcript. The in-app homes of a request are the feed
|
|
90
|
+
item and the source conversation's pinned vellum card.
|
|
91
|
+
|
|
57
92
|
## Cards are not conversation history
|
|
58
93
|
|
|
59
94
|
`pairDeliveryWithConversation` persists one message row per delivery so the
|
package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"./client-metadata": "./src/client-metadata.ts",
|
|
12
12
|
"./credential-rpc": "./src/credential-rpc.ts",
|
|
13
13
|
"./ingress": "./src/ingress.ts",
|
|
14
|
+
"./no-response": "./src/no-response.ts",
|
|
14
15
|
"./remote-web-pairing": "./src/remote-web-pairing.ts",
|
|
15
16
|
"./twilio-ingress": "./src/twilio-ingress.ts",
|
|
16
17
|
"./trust-rules": "./src/trust-rules.ts",
|
package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from "./handles.js";
|
|
|
27
27
|
export * from "./rpc.js";
|
|
28
28
|
export * from "./trust-rules.js";
|
|
29
29
|
export * from "./ingress.js";
|
|
30
|
+
export * from "./no-response.js";
|
|
30
31
|
export * from "./remote-web-pairing.js";
|
|
31
32
|
export * from "./twilio-ingress.js";
|
|
32
33
|
export * from "./url-normalization.js";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `<no_response/>` sentinel: the cross-service convention for a turn
|
|
3
|
+
* that deliberately produces no user-visible reply.
|
|
4
|
+
*
|
|
5
|
+
* The model emits it, the daemon stamps and strips it, channel delivery
|
|
6
|
+
* suppresses it, and clients hold live-streamed prefixes of it back from
|
|
7
|
+
* display. One definition here keeps every consumer's parsing identical;
|
|
8
|
+
* a hand-rolled copy in any one of them is how the case-sensitivity of a
|
|
9
|
+
* regex drifts.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Matches a message whose entire content is the sentinel. */
|
|
13
|
+
const NO_RESPONSE_ONLY_RE = /^\s*<no_response\s*\/?>\s*$/i;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Whether `text` is nothing but the sentinel: the whole reply is a
|
|
17
|
+
* deliberate non-response, as opposed to real content with an inline
|
|
18
|
+
* sentinel mixed in.
|
|
19
|
+
*/
|
|
20
|
+
export function isNoResponseOnlyText(text: string): boolean {
|
|
21
|
+
return NO_RESPONSE_ONLY_RE.test(text);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Matches every sentinel occurrence for stripping it out of mixed content. */
|
|
25
|
+
export const NO_RESPONSE_INLINE_RE = /<no_response\s*\/?>/gi;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Detection variant without the `g` flag: a `g`-flagged regex is stateful
|
|
29
|
+
* under `.test()` (it resumes from `lastIndex`), so reusing
|
|
30
|
+
* {@link NO_RESPONSE_INLINE_RE} for detection would alternate between
|
|
31
|
+
* matches and misses across calls.
|
|
32
|
+
*/
|
|
33
|
+
const NO_RESPONSE_MARKER_RE = new RegExp(NO_RESPONSE_INLINE_RE.source, "i");
|
|
34
|
+
|
|
35
|
+
/** Whether `text` contains the sentinel anywhere. */
|
|
36
|
+
export function containsNoResponseMarker(text: string): boolean {
|
|
37
|
+
return NO_RESPONSE_MARKER_RE.test(text);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Removes every sentinel occurrence, trimming the leftover whitespace. */
|
|
41
|
+
export function stripNoResponseMarkers(text: string): string {
|
|
42
|
+
return text.replace(NO_RESPONSE_INLINE_RE, "").trim();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const NO_RESPONSE_SENTINEL_FORMS = [
|
|
46
|
+
"<no_response/>",
|
|
47
|
+
"<no_response />",
|
|
48
|
+
"<no_response>",
|
|
49
|
+
] as const;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether `text` could still grow into the sentinel, i.e. it is a leading
|
|
53
|
+
* substring of one of its forms. Holding on these keeps a slowly-streamed
|
|
54
|
+
* `<no_response/>` from surfacing as visible partial content.
|
|
55
|
+
*/
|
|
56
|
+
export function isPotentialNoResponsePrefix(text: string): boolean {
|
|
57
|
+
const lower = text.trim().toLowerCase();
|
|
58
|
+
if (lower.length === 0) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return NO_RESPONSE_SENTINEL_FORMS.some((sentinel) =>
|
|
62
|
+
sentinel.startsWith(lower),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Whether `text` carries user-visible content worth acting on now. Returns
|
|
68
|
+
* `false` for empty text, the standalone sentinel, and any prefix that could
|
|
69
|
+
* still complete into one; returns `true` once real content remains after
|
|
70
|
+
* stripping inline sentinels.
|
|
71
|
+
*/
|
|
72
|
+
export function hasDeliverableAssistantText(text: string): boolean {
|
|
73
|
+
const trimmed = text.trim();
|
|
74
|
+
if (trimmed.length === 0) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (NO_RESPONSE_ONLY_RE.test(trimmed)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (isPotentialNoResponsePrefix(trimmed)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return stripNoResponseMarkers(trimmed).length > 0;
|
|
84
|
+
}
|
package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"./client-metadata": "./src/client-metadata.ts",
|
|
12
12
|
"./credential-rpc": "./src/credential-rpc.ts",
|
|
13
13
|
"./ingress": "./src/ingress.ts",
|
|
14
|
+
"./no-response": "./src/no-response.ts",
|
|
14
15
|
"./remote-web-pairing": "./src/remote-web-pairing.ts",
|
|
15
16
|
"./twilio-ingress": "./src/twilio-ingress.ts",
|
|
16
17
|
"./trust-rules": "./src/trust-rules.ts",
|
package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from "./handles.js";
|
|
|
27
27
|
export * from "./rpc.js";
|
|
28
28
|
export * from "./trust-rules.js";
|
|
29
29
|
export * from "./ingress.js";
|
|
30
|
+
export * from "./no-response.js";
|
|
30
31
|
export * from "./remote-web-pairing.js";
|
|
31
32
|
export * from "./twilio-ingress.js";
|
|
32
33
|
export * from "./url-normalization.js";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `<no_response/>` sentinel: the cross-service convention for a turn
|
|
3
|
+
* that deliberately produces no user-visible reply.
|
|
4
|
+
*
|
|
5
|
+
* The model emits it, the daemon stamps and strips it, channel delivery
|
|
6
|
+
* suppresses it, and clients hold live-streamed prefixes of it back from
|
|
7
|
+
* display. One definition here keeps every consumer's parsing identical;
|
|
8
|
+
* a hand-rolled copy in any one of them is how the case-sensitivity of a
|
|
9
|
+
* regex drifts.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Matches a message whose entire content is the sentinel. */
|
|
13
|
+
const NO_RESPONSE_ONLY_RE = /^\s*<no_response\s*\/?>\s*$/i;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Whether `text` is nothing but the sentinel: the whole reply is a
|
|
17
|
+
* deliberate non-response, as opposed to real content with an inline
|
|
18
|
+
* sentinel mixed in.
|
|
19
|
+
*/
|
|
20
|
+
export function isNoResponseOnlyText(text: string): boolean {
|
|
21
|
+
return NO_RESPONSE_ONLY_RE.test(text);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Matches every sentinel occurrence for stripping it out of mixed content. */
|
|
25
|
+
export const NO_RESPONSE_INLINE_RE = /<no_response\s*\/?>/gi;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Detection variant without the `g` flag: a `g`-flagged regex is stateful
|
|
29
|
+
* under `.test()` (it resumes from `lastIndex`), so reusing
|
|
30
|
+
* {@link NO_RESPONSE_INLINE_RE} for detection would alternate between
|
|
31
|
+
* matches and misses across calls.
|
|
32
|
+
*/
|
|
33
|
+
const NO_RESPONSE_MARKER_RE = new RegExp(NO_RESPONSE_INLINE_RE.source, "i");
|
|
34
|
+
|
|
35
|
+
/** Whether `text` contains the sentinel anywhere. */
|
|
36
|
+
export function containsNoResponseMarker(text: string): boolean {
|
|
37
|
+
return NO_RESPONSE_MARKER_RE.test(text);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Removes every sentinel occurrence, trimming the leftover whitespace. */
|
|
41
|
+
export function stripNoResponseMarkers(text: string): string {
|
|
42
|
+
return text.replace(NO_RESPONSE_INLINE_RE, "").trim();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const NO_RESPONSE_SENTINEL_FORMS = [
|
|
46
|
+
"<no_response/>",
|
|
47
|
+
"<no_response />",
|
|
48
|
+
"<no_response>",
|
|
49
|
+
] as const;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether `text` could still grow into the sentinel, i.e. it is a leading
|
|
53
|
+
* substring of one of its forms. Holding on these keeps a slowly-streamed
|
|
54
|
+
* `<no_response/>` from surfacing as visible partial content.
|
|
55
|
+
*/
|
|
56
|
+
export function isPotentialNoResponsePrefix(text: string): boolean {
|
|
57
|
+
const lower = text.trim().toLowerCase();
|
|
58
|
+
if (lower.length === 0) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return NO_RESPONSE_SENTINEL_FORMS.some((sentinel) =>
|
|
62
|
+
sentinel.startsWith(lower),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Whether `text` carries user-visible content worth acting on now. Returns
|
|
68
|
+
* `false` for empty text, the standalone sentinel, and any prefix that could
|
|
69
|
+
* still complete into one; returns `true` once real content remains after
|
|
70
|
+
* stripping inline sentinels.
|
|
71
|
+
*/
|
|
72
|
+
export function hasDeliverableAssistantText(text: string): boolean {
|
|
73
|
+
const trimmed = text.trim();
|
|
74
|
+
if (trimmed.length === 0) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (NO_RESPONSE_ONLY_RE.test(trimmed)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (isPotentialNoResponsePrefix(trimmed)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return stripNoResponseMarkers(trimmed).length > 0;
|
|
84
|
+
}
|
|
@@ -355,6 +355,52 @@ export type GetGuardianContactIpcResponse = z.infer<
|
|
|
355
355
|
typeof GetGuardianContactIpcResponseSchema
|
|
356
356
|
>;
|
|
357
357
|
|
|
358
|
+
// ── contacts_identity_snapshot ───────────────────────────────────────────────
|
|
359
|
+
// Lean identity projection of every gateway contact + channel, for the
|
|
360
|
+
// daemon's mirror reconciler: enough to converge the assistant identity
|
|
361
|
+
// mirror onto gateway truth (ids, ownership, addresses), nothing more. No
|
|
362
|
+
// ACL columns (the mirror never carries them) and no assistant-info join
|
|
363
|
+
// (the daemon IS the assistant), so the read is uncapped and cheap.
|
|
364
|
+
|
|
365
|
+
export const ContactsIdentitySnapshotIpcParamsSchema = z
|
|
366
|
+
.object({})
|
|
367
|
+
.strict()
|
|
368
|
+
.default({});
|
|
369
|
+
|
|
370
|
+
export type ContactsIdentitySnapshotIpcParams = z.infer<
|
|
371
|
+
typeof ContactsIdentitySnapshotIpcParamsSchema
|
|
372
|
+
>;
|
|
373
|
+
|
|
374
|
+
export const ContactIdentityChannelSchema = z.object({
|
|
375
|
+
id: z.string(),
|
|
376
|
+
contactId: z.string(),
|
|
377
|
+
type: z.string(),
|
|
378
|
+
address: z.string(),
|
|
379
|
+
externalChatId: z.string().nullable(),
|
|
380
|
+
isPrimary: z.boolean(),
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
export type ContactIdentityChannel = z.infer<
|
|
384
|
+
typeof ContactIdentityChannelSchema
|
|
385
|
+
>;
|
|
386
|
+
|
|
387
|
+
export const ContactIdentitySchema = z.object({
|
|
388
|
+
id: z.string(),
|
|
389
|
+
displayName: z.string(),
|
|
390
|
+
channels: z.array(ContactIdentityChannelSchema),
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
export type ContactIdentity = z.infer<typeof ContactIdentitySchema>;
|
|
394
|
+
|
|
395
|
+
export const ContactsIdentitySnapshotIpcResponseSchema = z.object({
|
|
396
|
+
ok: z.boolean(),
|
|
397
|
+
contacts: z.array(ContactIdentitySchema),
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
export type ContactsIdentitySnapshotIpcResponse = z.infer<
|
|
401
|
+
typeof ContactsIdentitySnapshotIpcResponseSchema
|
|
402
|
+
>;
|
|
403
|
+
|
|
358
404
|
// ── classify_risk ────────────────────────────────────────────────────────────
|
|
359
405
|
// Risk classification is gateway-owned; the assistant sends one request per
|
|
360
406
|
// tool invocation and reads the whole answer back. The gateway validates the
|
|
@@ -193,6 +193,7 @@ export const GUARDIAN_REQUESTS_IPC_METHODS = {
|
|
|
193
193
|
createDelivery: "guardian_requests_create_delivery",
|
|
194
194
|
updateDelivery: "guardian_requests_update_delivery",
|
|
195
195
|
listDeliveries: "guardian_requests_list_deliveries",
|
|
196
|
+
listDeliveriesByChat: "guardian_requests_list_deliveries_by_chat",
|
|
196
197
|
getByDestinationMessage: "guardian_requests_get_by_destination_message",
|
|
197
198
|
listPendingByDestination: "guardian_requests_list_pending_by_destination",
|
|
198
199
|
listPendingByScope: "guardian_requests_list_pending_by_scope",
|
|
@@ -597,6 +598,22 @@ export type ListGuardianRequestDeliveriesIpcParams = z.infer<
|
|
|
597
598
|
typeof ListGuardianRequestDeliveriesIpcParamsSchema
|
|
598
599
|
>;
|
|
599
600
|
|
|
601
|
+
/**
|
|
602
|
+
* Request for `guardian_requests_list_deliveries_by_chat`: every
|
|
603
|
+
* delivery row addressed to one channel-native chat, whatever request it
|
|
604
|
+
* belongs to. Lets transcript importers recognize guardian card
|
|
605
|
+
* messages (by their recorded message id) as delivery projections
|
|
606
|
+
* rather than conversation content.
|
|
607
|
+
*/
|
|
608
|
+
export const ListGuardianRequestDeliveriesByChatIpcParamsSchema = z.object({
|
|
609
|
+
channel: z.string().min(1),
|
|
610
|
+
chatId: z.string().min(1),
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
export type ListGuardianRequestDeliveriesByChatIpcParams = z.infer<
|
|
614
|
+
typeof ListGuardianRequestDeliveriesByChatIpcParamsSchema
|
|
615
|
+
>;
|
|
616
|
+
|
|
600
617
|
/** Response for `guardian_requests_list_deliveries`. */
|
|
601
618
|
export const GuardianRequestDeliveryListIpcResponseSchema = z.array(
|
|
602
619
|
GuardianRequestDeliverySchema,
|
|
@@ -264,6 +264,7 @@ export {
|
|
|
264
264
|
GuardianRequestSourceTypeSchema,
|
|
265
265
|
GuardianRequestStatusSchema,
|
|
266
266
|
isGuardianRequestExpired,
|
|
267
|
+
ListGuardianRequestDeliveriesByChatIpcParamsSchema,
|
|
267
268
|
ListGuardianRequestDeliveriesIpcParamsSchema,
|
|
268
269
|
ListGuardianRequestsIpcParamsSchema,
|
|
269
270
|
ListPendingGuardianRequestsByDestinationIpcParamsSchema,
|
|
@@ -303,6 +304,7 @@ export type {
|
|
|
303
304
|
GuardianRequestSourceType,
|
|
304
305
|
GuardianRequestStatus,
|
|
305
306
|
GuardianRequestWire,
|
|
307
|
+
ListGuardianRequestDeliveriesByChatIpcParams,
|
|
306
308
|
ListGuardianRequestDeliveriesIpcParams,
|
|
307
309
|
ListGuardianRequestsIpcParams,
|
|
308
310
|
ListPendingGuardianRequestsByDestinationIpcParams,
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"./client-metadata": "./src/client-metadata.ts",
|
|
12
12
|
"./credential-rpc": "./src/credential-rpc.ts",
|
|
13
13
|
"./ingress": "./src/ingress.ts",
|
|
14
|
+
"./no-response": "./src/no-response.ts",
|
|
14
15
|
"./remote-web-pairing": "./src/remote-web-pairing.ts",
|
|
15
16
|
"./twilio-ingress": "./src/twilio-ingress.ts",
|
|
16
17
|
"./trust-rules": "./src/trust-rules.ts",
|
|
@@ -27,6 +27,7 @@ export * from "./handles.js";
|
|
|
27
27
|
export * from "./rpc.js";
|
|
28
28
|
export * from "./trust-rules.js";
|
|
29
29
|
export * from "./ingress.js";
|
|
30
|
+
export * from "./no-response.js";
|
|
30
31
|
export * from "./remote-web-pairing.js";
|
|
31
32
|
export * from "./twilio-ingress.js";
|
|
32
33
|
export * from "./url-normalization.js";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `<no_response/>` sentinel: the cross-service convention for a turn
|
|
3
|
+
* that deliberately produces no user-visible reply.
|
|
4
|
+
*
|
|
5
|
+
* The model emits it, the daemon stamps and strips it, channel delivery
|
|
6
|
+
* suppresses it, and clients hold live-streamed prefixes of it back from
|
|
7
|
+
* display. One definition here keeps every consumer's parsing identical;
|
|
8
|
+
* a hand-rolled copy in any one of them is how the case-sensitivity of a
|
|
9
|
+
* regex drifts.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Matches a message whose entire content is the sentinel. */
|
|
13
|
+
const NO_RESPONSE_ONLY_RE = /^\s*<no_response\s*\/?>\s*$/i;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Whether `text` is nothing but the sentinel: the whole reply is a
|
|
17
|
+
* deliberate non-response, as opposed to real content with an inline
|
|
18
|
+
* sentinel mixed in.
|
|
19
|
+
*/
|
|
20
|
+
export function isNoResponseOnlyText(text: string): boolean {
|
|
21
|
+
return NO_RESPONSE_ONLY_RE.test(text);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Matches every sentinel occurrence for stripping it out of mixed content. */
|
|
25
|
+
export const NO_RESPONSE_INLINE_RE = /<no_response\s*\/?>/gi;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Detection variant without the `g` flag: a `g`-flagged regex is stateful
|
|
29
|
+
* under `.test()` (it resumes from `lastIndex`), so reusing
|
|
30
|
+
* {@link NO_RESPONSE_INLINE_RE} for detection would alternate between
|
|
31
|
+
* matches and misses across calls.
|
|
32
|
+
*/
|
|
33
|
+
const NO_RESPONSE_MARKER_RE = new RegExp(NO_RESPONSE_INLINE_RE.source, "i");
|
|
34
|
+
|
|
35
|
+
/** Whether `text` contains the sentinel anywhere. */
|
|
36
|
+
export function containsNoResponseMarker(text: string): boolean {
|
|
37
|
+
return NO_RESPONSE_MARKER_RE.test(text);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Removes every sentinel occurrence, trimming the leftover whitespace. */
|
|
41
|
+
export function stripNoResponseMarkers(text: string): string {
|
|
42
|
+
return text.replace(NO_RESPONSE_INLINE_RE, "").trim();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const NO_RESPONSE_SENTINEL_FORMS = [
|
|
46
|
+
"<no_response/>",
|
|
47
|
+
"<no_response />",
|
|
48
|
+
"<no_response>",
|
|
49
|
+
] as const;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether `text` could still grow into the sentinel, i.e. it is a leading
|
|
53
|
+
* substring of one of its forms. Holding on these keeps a slowly-streamed
|
|
54
|
+
* `<no_response/>` from surfacing as visible partial content.
|
|
55
|
+
*/
|
|
56
|
+
export function isPotentialNoResponsePrefix(text: string): boolean {
|
|
57
|
+
const lower = text.trim().toLowerCase();
|
|
58
|
+
if (lower.length === 0) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return NO_RESPONSE_SENTINEL_FORMS.some((sentinel) =>
|
|
62
|
+
sentinel.startsWith(lower),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Whether `text` carries user-visible content worth acting on now. Returns
|
|
68
|
+
* `false` for empty text, the standalone sentinel, and any prefix that could
|
|
69
|
+
* still complete into one; returns `true` once real content remains after
|
|
70
|
+
* stripping inline sentinels.
|
|
71
|
+
*/
|
|
72
|
+
export function hasDeliverableAssistantText(text: string): boolean {
|
|
73
|
+
const trimmed = text.trim();
|
|
74
|
+
if (trimmed.length === 0) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (NO_RESPONSE_ONLY_RE.test(trimmed)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (isPotentialNoResponsePrefix(trimmed)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return stripNoResponseMarkers(trimmed).length > 0;
|
|
84
|
+
}
|