@skrr-ai/cli 0.1.207 → 0.1.209
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/commands/agent/message/no-reply.js +1 -1
- package/dist/commands/agent/message/react.d.ts +23 -0
- package/dist/commands/agent/message/react.js +125 -0
- package/dist/commands/agent/message/resolve.d.ts +31 -0
- package/dist/commands/agent/message/resolve.js +111 -0
- package/dist/commands/agent/message/retract.js +1 -1
- package/dist/commands/agent/message/send.d.ts +25 -6
- package/dist/commands/agent/message/send.js +135 -30
- package/dist/commands/agent/request/list.d.ts +15 -0
- package/dist/commands/agent/request/list.js +82 -0
- package/dist/commands/agent/request/send.d.ts +18 -0
- package/dist/commands/agent/request/send.js +56 -0
- package/dist/commands/agents/access/approve.d.ts +17 -0
- package/dist/commands/agents/access/approve.js +94 -0
- package/dist/commands/agents/access/deny.d.ts +10 -0
- package/dist/commands/agents/access/deny.js +36 -0
- package/dist/commands/agents/access/list.d.ts +10 -0
- package/dist/commands/agents/access/list.js +55 -0
- package/dist/commands/agents/access/reach.d.ts +13 -0
- package/dist/commands/agents/access/reach.js +53 -0
- package/dist/commands/agents/access/revoke.d.ts +13 -0
- package/dist/commands/agents/access/revoke.js +50 -0
- package/dist/commands/agents/always-on/recovery-review.d.ts +5 -0
- package/dist/commands/agents/always-on/recovery-review.js +16 -0
- package/dist/commands/agents/chat.d.ts +8 -0
- package/dist/commands/agents/chat.js +369 -90
- package/dist/commands/agents/import.d.ts +15 -1
- package/dist/commands/agents/import.js +212 -24
- package/dist/commands/agents/intuitions/accept.d.ts +0 -1
- package/dist/commands/agents/intuitions/accept.js +22 -7
- package/dist/commands/agents/intuitions/generate.d.ts +0 -1
- package/dist/commands/agents/intuitions/generate.js +4 -16
- package/dist/commands/agents/intuitions/list.js +9 -3
- package/dist/commands/agents/intuitions/resume.d.ts +11 -0
- package/dist/commands/agents/intuitions/resume.js +37 -0
- package/dist/commands/agents/manager/status.js +7 -6
- package/dist/commands/agents/not-for-task.d.ts +24 -0
- package/dist/commands/agents/not-for-task.js +60 -0
- package/dist/commands/agents/schedule-overview.d.ts +20 -0
- package/dist/commands/agents/schedule-overview.js +35 -2
- package/dist/commands/agents/shared-memory.d.ts +24 -0
- package/dist/commands/agents/shared-memory.js +67 -0
- package/dist/commands/agents/stop.d.ts +23 -0
- package/dist/commands/agents/stop.js +61 -0
- package/dist/commands/agents/update.d.ts +7 -0
- package/dist/commands/agents/update.js +45 -2
- package/dist/commands/agents/visibility.d.ts +1 -0
- package/dist/commands/agents/visibility.js +14 -0
- package/dist/commands/code/migrate.js +3 -1
- package/dist/commands/convos/messages.js +5 -0
- package/dist/commands/convos/transcript.js +2 -2
- package/dist/commands/daemon/logs.d.ts +3 -1
- package/dist/commands/daemon/logs.js +6 -2
- package/dist/commands/duties/advance-next.js +16 -7
- package/dist/commands/duties/preflight.js +17 -13
- package/dist/commands/followups/show.js +9 -0
- package/dist/commands/followups/watch-pr.d.ts +27 -0
- package/dist/commands/followups/watch-pr.js +124 -0
- package/dist/commands/harnesses/evaluations/evidence.js +2 -2
- package/dist/commands/harnesses/evaluations/grant.js +1 -1
- package/dist/commands/harnesses/evaluations/revoke.js +1 -1
- package/dist/commands/harnesses/evaluations/show.js +1 -1
- package/dist/commands/harnesses/rollouts/grant.js +1 -1
- package/dist/commands/harnesses/rollouts/revoke.js +1 -1
- package/dist/commands/machines/hosted/identity-evaluations/revoke.js +1 -1
- package/dist/commands/machines/hosted/identity-evaluations/show.js +1 -1
- package/dist/commands/memory/consolidation/index.d.ts +20 -0
- package/dist/commands/memory/consolidation/index.js +78 -0
- package/dist/commands/memory/consolidation/resume.d.ts +14 -0
- package/dist/commands/memory/consolidation/resume.js +46 -0
- package/dist/commands/memory/consolidation/undo.d.ts +18 -0
- package/dist/commands/memory/consolidation/undo.js +61 -0
- package/dist/commands/messages/list.js +9 -1
- package/dist/commands/slack/mutes.d.ts +10 -0
- package/dist/commands/slack/mutes.js +62 -0
- package/dist/commands/slack/unmute.d.ts +12 -0
- package/dist/commands/slack/unmute.js +44 -0
- package/dist/commands/tasks/actionability.js +10 -0
- package/dist/commands/tasks/ask.d.ts +50 -0
- package/dist/commands/tasks/ask.js +190 -0
- package/dist/commands/tasks/bulk-update.js +12 -0
- package/dist/commands/tasks/handover.js +14 -0
- package/dist/commands/tasks/input/answer.js +8 -2
- package/dist/commands/tasks/input/show.d.ts +26 -0
- package/dist/commands/tasks/input/show.js +185 -17
- package/dist/commands/tasks/list.d.ts +8 -0
- package/dist/commands/tasks/list.js +50 -9
- package/dist/commands/tasks/move.d.ts +3 -0
- package/dist/commands/tasks/move.js +71 -1
- package/dist/commands/tasks/result/show.js +19 -7
- package/dist/commands/tasks/result/submit.js +3 -0
- package/dist/commands/tasks/runs.d.ts +4 -1
- package/dist/commands/tasks/runs.js +22 -3
- package/dist/commands/tasks/show.d.ts +4 -3
- package/dist/commands/tasks/show.js +40 -7
- package/dist/commands/tasks/start.js +35 -16
- package/dist/commands/tasks/update.d.ts +1 -0
- package/dist/commands/tasks/update.js +55 -1
- package/dist/commands/tasks/updates/add.js +3 -0
- package/dist/commands/tasks/wait.d.ts +20 -0
- package/dist/commands/tasks/wait.js +103 -2
- package/dist/generated/agent-guides.json +892 -183
- package/dist/generated/managed-instruction-guides.json +1 -1
- package/dist/lib/agent-access-command.d.ts +19 -0
- package/dist/lib/agent-access-command.js +44 -0
- package/dist/lib/agent-access.d.ts +18 -0
- package/dist/lib/agent-access.js +48 -0
- package/dist/lib/agent-import/apply.d.ts +50 -0
- package/dist/lib/agent-import/apply.js +85 -0
- package/dist/lib/agent-import/plan.d.ts +132 -0
- package/dist/lib/agent-import/plan.js +504 -0
- package/dist/lib/agent-import/reader.d.ts +94 -0
- package/dist/lib/agent-import/reader.js +326 -0
- package/dist/lib/agent-import/schedule.d.ts +46 -0
- package/dist/lib/agent-import/schedule.js +220 -0
- package/dist/lib/agent-import/sources.d.ts +124 -0
- package/dist/lib/agent-import/sources.js +797 -0
- package/dist/lib/chat-stop.d.ts +17 -0
- package/dist/lib/chat-stop.js +70 -0
- package/dist/lib/cloud-reply.d.ts +21 -0
- package/dist/lib/cloud-reply.js +52 -0
- package/dist/lib/duties.js +24 -4
- package/dist/lib/duty-ledgers.js +19 -2
- package/dist/lib/file-mime.js +8 -0
- package/dist/lib/followups.d.ts +61 -0
- package/dist/lib/followups.js +39 -0
- package/dist/lib/handover-interview.d.ts +18 -0
- package/dist/lib/handover-interview.js +53 -0
- package/dist/lib/inbound-messages.d.ts +156 -0
- package/dist/lib/inbound-messages.js +375 -0
- package/dist/lib/input-queue.js +2 -1
- package/dist/lib/intuition-look.d.ts +10 -0
- package/dist/lib/intuition-look.js +64 -0
- package/dist/lib/message-intent.d.ts +18 -2
- package/dist/lib/message-intent.js +23 -1
- package/dist/lib/preflight-copy.d.ts +16 -1
- package/dist/lib/preflight-copy.js +33 -1
- package/dist/lib/record-output.d.ts +1 -1
- package/dist/lib/record-output.js +2 -0
- package/dist/lib/skill-import.d.ts +19 -0
- package/dist/lib/skill-import.js +34 -0
- package/dist/lib/slack-thread-mutes.d.ts +25 -0
- package/dist/lib/slack-thread-mutes.js +12 -0
- package/dist/lib/task-carriers.d.ts +18 -0
- package/dist/lib/task-carriers.js +43 -0
- package/dist/lib/task-extras.d.ts +5 -0
- package/dist/lib/task-extras.js +5 -0
- package/dist/lib/task-operations.d.ts +2 -0
- package/dist/lib/task-operations.js +28 -4
- package/dist/lib/task-preflight.js +1 -0
- package/dist/lib/task-recurrence-summary.d.ts +15 -0
- package/dist/lib/task-recurrence-summary.js +22 -0
- package/dist/lib/task-review-notice.d.ts +21 -0
- package/dist/lib/task-review-notice.js +46 -0
- package/dist/lib/task-version.d.ts +53 -0
- package/dist/lib/task-version.js +89 -0
- package/dist/lib/task-write-attribution.d.ts +7 -0
- package/dist/lib/task-write-attribution.js +14 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/credentialEnvelopeBridge.js +6 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.d.ts +75 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.js +124 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/credentialEnvelopeBridge.js +45 -15
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.d.ts +75 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.js +141 -0
- package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +13492 -12505
- package/oclif.manifest.json +2090 -132
- package/package.json +9 -2
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { dataService, type AgentReplyRefusal, type GlanceDecisionKind, type GlanceFallbackReason, type InboundMessageAccepted, type InboundMessageReturned, type InboundReturnRefusal, type InboundReturnTaskOutcome, type InboundRoute, type InboundSendIntent, type MessageDelivery, type MessageDeliveryHandling, type MessageDeliveryHeld, type MessageFailedReason, type MessageHeldReason, type MessageReactionEmoji, type MessageCloudReply } from '@skrr-ai/data-provider';
|
|
2
|
+
type AgenticChatParams = Parameters<typeof dataService.startAgenticChat>[0];
|
|
3
|
+
type HeldDetail = MessageDeliveryHeld['detail'];
|
|
4
|
+
export declare const HELD_COPY: Record<MessageHeldReason, (detail?: HeldDetail) => string>;
|
|
5
|
+
export declare const FAILED_COPY: Record<MessageFailedReason, string>;
|
|
6
|
+
/** What the route says the moment the message is kept, before anything read it. */
|
|
7
|
+
export declare const ROUTE_COPY: Record<InboundRoute, string>;
|
|
8
|
+
/** A glance's decision. `null` where the agent's own words are the whole answer. */
|
|
9
|
+
export declare const GLANCE_COPY: Record<GlanceDecisionKind, string | null>;
|
|
10
|
+
export declare const FALLBACK_COPY: Record<GlanceFallbackReason, string>;
|
|
11
|
+
/** A reply or reaction the server refused, in the CLI's words. */
|
|
12
|
+
export declare const AGENT_REPLY_REFUSAL_COPY: Record<AgentReplyRefusal, string>;
|
|
13
|
+
/**
|
|
14
|
+
* `--reply-to` (or a payload's `replyTo`): absent is `null`; otherwise 1-10 message ids, trimmed
|
|
15
|
+
* and without repeats. The server proves each one; this only refuses a list it could never accept.
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeReplyTo(value: unknown): string[] | null | 'invalid';
|
|
18
|
+
/**
|
|
19
|
+
* A reply or reaction the server refused, when it named a refusal this CLI knows: the code, and
|
|
20
|
+
* the ids a reply could not prove. The DM route names it `errorType`, the session gateway `reason`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function agentReplyRefusalOf(err: unknown): {
|
|
23
|
+
code: AgentReplyRefusal;
|
|
24
|
+
missing?: string[];
|
|
25
|
+
} | null;
|
|
26
|
+
/** A plain name for each reaction, so a terminal never has to type an emoji. */
|
|
27
|
+
export declare const REACTION_NAMES: Record<MessageReactionEmoji, string>;
|
|
28
|
+
/** An emoji, or its plain name, as one of the contract's reactions; null when it is neither. */
|
|
29
|
+
export declare function reactionFromInput(input: string): MessageReactionEmoji | null;
|
|
30
|
+
/** The one sentence for a message's delivery, as a surface draws it. */
|
|
31
|
+
export declare function deliverySentence(delivery: MessageDelivery | null | undefined): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* "Not for this Task" (Q6): the message is back in this conversation, and what became of the Task
|
|
34
|
+
* it had gone to. The web's words (`deliveryCopy.ts`, `RETURN_COPY`), with and without the title.
|
|
35
|
+
*/
|
|
36
|
+
export declare const RETURN_OUTCOME_COPY: Record<InboundReturnTaskOutcome, (title?: string) => string>;
|
|
37
|
+
/** Why "Not for this Task" was refused (`INBOUND_RETURN_REFUSALS`). */
|
|
38
|
+
export declare const RETURN_REFUSAL_COPY: Record<InboundReturnRefusal, string>;
|
|
39
|
+
/** The sentence for a message brought back from a Task: a `returned` handling, or the answer's. */
|
|
40
|
+
export declare function returnedSentence(returned: Pick<MessageDeliveryHandling, 'from'> & {
|
|
41
|
+
taskOutcome?: InboundReturnTaskOutcome | null;
|
|
42
|
+
}): string;
|
|
43
|
+
/** What a recorded handling says, or null when it adds nothing to the agent's own words. */
|
|
44
|
+
export declare function handlingSentence(handling: MessageDeliveryHandling | undefined): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* The message id for one invocation's start key. The ingress takes letters, digits, `_` and `-`;
|
|
47
|
+
* a key outside that becomes a hash of itself, so a replay of the same invocation names the same
|
|
48
|
+
* message and two different keys never share one.
|
|
49
|
+
*/
|
|
50
|
+
export declare function inboundMessageIdFor(startKey: string): string;
|
|
51
|
+
/** Whether a failed send came from a server that has no ingress (a 404 with no code of its own). */
|
|
52
|
+
export declare function ingressMissing(err: unknown): boolean;
|
|
53
|
+
export interface InboundSend {
|
|
54
|
+
answer: InboundMessageAccepted;
|
|
55
|
+
messageId: string;
|
|
56
|
+
/** The turn the message starts when it waits first: the CLI chooses its ids, so it can follow. */
|
|
57
|
+
sessionId: string;
|
|
58
|
+
responseMessageId: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Send the message `startAgenticChat(params)` would have started a turn with. The submission is
|
|
62
|
+
* the same body, frozen at send; the turn it starts (now or later) uses the ids chosen here.
|
|
63
|
+
*/
|
|
64
|
+
export declare function sendInboundMessage(params: AgenticChatParams & {
|
|
65
|
+
conversationId: string;
|
|
66
|
+
}, { messageId, intent, deps, }: {
|
|
67
|
+
messageId: string;
|
|
68
|
+
intent: InboundSendIntent;
|
|
69
|
+
deps?: {
|
|
70
|
+
send?: typeof dataService.sendConversationMessage;
|
|
71
|
+
};
|
|
72
|
+
}): Promise<InboundSend>;
|
|
73
|
+
/**
|
|
74
|
+
* "Not for this Task": bring back a message the platform or a glance passed to a Task, and have it
|
|
75
|
+
* delivered in this conversation again. The Task is told, and its response stopped when it was
|
|
76
|
+
* for this message alone. A retry, or a second call, answers with the message as it is.
|
|
77
|
+
*/
|
|
78
|
+
export declare function returnInboundMessage(conversationId: string, messageId: string, deps?: {
|
|
79
|
+
send?: typeof dataService.returnConversationMessage;
|
|
80
|
+
}): Promise<InboundMessageReturned>;
|
|
81
|
+
/**
|
|
82
|
+
* The next step a person may take when their message went to a Task, or null when it did not (or
|
|
83
|
+
* already came back): bring it back to the conversation.
|
|
84
|
+
*/
|
|
85
|
+
export declare function notForTaskHint(bin: string, conversationId: string, messageId: string, handling: MessageDeliveryHandling | null | undefined): string | null;
|
|
86
|
+
/** The words for a refusal of "Not for this Task", or null when it is not one of its codes. */
|
|
87
|
+
export declare function returnRefusalOf(err: unknown): string | null;
|
|
88
|
+
/**
|
|
89
|
+
* What the CLI does next with an accepted message.
|
|
90
|
+
* - `turn`: it started (or joined) a turn whose reply the CLI can stream.
|
|
91
|
+
* - `wait`: it waits for a turn of its own; follow its queue card, then stream that turn.
|
|
92
|
+
* - `glance`: the agent is reading it while it works; wait for what it decided.
|
|
93
|
+
* - `delivered`: it reached the agent and there is no reply of its own to stream.
|
|
94
|
+
* - `failed`: it will not be read as it is.
|
|
95
|
+
*/
|
|
96
|
+
export type InboundNext = {
|
|
97
|
+
kind: 'turn';
|
|
98
|
+
sessionId: string;
|
|
99
|
+
responseMessageId: string;
|
|
100
|
+
} | {
|
|
101
|
+
kind: 'wait';
|
|
102
|
+
} | {
|
|
103
|
+
kind: 'glance';
|
|
104
|
+
} | {
|
|
105
|
+
kind: 'delivered';
|
|
106
|
+
} | {
|
|
107
|
+
kind: 'failed';
|
|
108
|
+
};
|
|
109
|
+
export declare function nextAfterSend(answer: InboundMessageAccepted): InboundNext;
|
|
110
|
+
export interface GlanceOutcome {
|
|
111
|
+
/** The last handling a glance or its fallback recorded, or null when the wait ran out. */
|
|
112
|
+
handling: MessageDeliveryHandling | null;
|
|
113
|
+
/** The agent's reply to the message, when it wrote one; `cloudReply` when from the cloud. */
|
|
114
|
+
reply: {
|
|
115
|
+
messageId: string;
|
|
116
|
+
text: string;
|
|
117
|
+
cloudReply?: MessageCloudReply;
|
|
118
|
+
} | null;
|
|
119
|
+
}
|
|
120
|
+
type MessageRow = {
|
|
121
|
+
messageId?: string;
|
|
122
|
+
text?: string;
|
|
123
|
+
isCreatedByUser?: boolean;
|
|
124
|
+
delivery?: MessageDelivery | null;
|
|
125
|
+
metadata?: {
|
|
126
|
+
communication?: {
|
|
127
|
+
replyTo?: unknown;
|
|
128
|
+
cloudReply?: unknown;
|
|
129
|
+
};
|
|
130
|
+
} | null;
|
|
131
|
+
};
|
|
132
|
+
/** How long a glance can take to settle: its wall clock, its lease, and a margin. */
|
|
133
|
+
export declare const GLANCE_WAIT_MS: number;
|
|
134
|
+
/**
|
|
135
|
+
* Wait for what a glance decided about one message: read the conversation until the message
|
|
136
|
+
* carries a glance's handling (or the platform's fallback), and pick up the reply that names it.
|
|
137
|
+
*/
|
|
138
|
+
export declare function waitForGlance(conversationId: string, messageId: string, { timeoutMs, deps, }?: {
|
|
139
|
+
timeoutMs?: number;
|
|
140
|
+
deps?: {
|
|
141
|
+
messages?: (conversationId: string) => Promise<MessageRow[] | undefined>;
|
|
142
|
+
sleep?: (ms: number) => Promise<void>;
|
|
143
|
+
now?: () => number;
|
|
144
|
+
};
|
|
145
|
+
}): Promise<GlanceOutcome>;
|
|
146
|
+
/**
|
|
147
|
+
* A message's delivery now, read from the conversation, or `null` when the message is gone (it was
|
|
148
|
+
* taken back from another screen). Used when its card leaves the queue without a turn of its own:
|
|
149
|
+
* it may have been read with another message.
|
|
150
|
+
*/
|
|
151
|
+
export declare function readMessageDelivery(conversationId: string, messageId: string, deps?: {
|
|
152
|
+
messages?: (conversationId: string) => Promise<MessageRow[] | undefined>;
|
|
153
|
+
}): Promise<{
|
|
154
|
+
delivery: MessageDelivery | null;
|
|
155
|
+
} | null>;
|
|
156
|
+
export {};
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GLANCE_WAIT_MS = exports.RETURN_REFUSAL_COPY = exports.RETURN_OUTCOME_COPY = exports.REACTION_NAMES = exports.AGENT_REPLY_REFUSAL_COPY = exports.FALLBACK_COPY = exports.GLANCE_COPY = exports.ROUTE_COPY = exports.FAILED_COPY = exports.HELD_COPY = void 0;
|
|
4
|
+
exports.normalizeReplyTo = normalizeReplyTo;
|
|
5
|
+
exports.agentReplyRefusalOf = agentReplyRefusalOf;
|
|
6
|
+
exports.reactionFromInput = reactionFromInput;
|
|
7
|
+
exports.deliverySentence = deliverySentence;
|
|
8
|
+
exports.returnedSentence = returnedSentence;
|
|
9
|
+
exports.handlingSentence = handlingSentence;
|
|
10
|
+
exports.inboundMessageIdFor = inboundMessageIdFor;
|
|
11
|
+
exports.ingressMissing = ingressMissing;
|
|
12
|
+
exports.sendInboundMessage = sendInboundMessage;
|
|
13
|
+
exports.returnInboundMessage = returnInboundMessage;
|
|
14
|
+
exports.notForTaskHint = notForTaskHint;
|
|
15
|
+
exports.returnRefusalOf = returnRefusalOf;
|
|
16
|
+
exports.nextAfterSend = nextAfterSend;
|
|
17
|
+
exports.waitForGlance = waitForGlance;
|
|
18
|
+
exports.readMessageDelivery = readMessageDelivery;
|
|
19
|
+
/**
|
|
20
|
+
* A person's message to their agent, from the CLI (inbound messages, design record
|
|
21
|
+
* docs/architecture/agent-chat-inbound-messages-2026-11-26.zh-CN.md).
|
|
22
|
+
*
|
|
23
|
+
* The message is kept the moment it is sent (`202`), and the server decides how the agent sees
|
|
24
|
+
* it: it starts a turn, joins one that is starting, reaches the work in progress, is read by a
|
|
25
|
+
* short side turn of the agent (a glance), or waits with a reason. A busy agent is never a refusal.
|
|
26
|
+
*
|
|
27
|
+
* Every call goes through `dataService` (the CLI ↔ API parity rule). The sentences match the web's
|
|
28
|
+
* (`client/src/components/Chat/Messages/Delivery/deliveryCopy.ts`), and each table is a `Record`
|
|
29
|
+
* over the contract's closed list, so a new reason does not compile without a sentence here.
|
|
30
|
+
*/
|
|
31
|
+
const node_crypto_1 = require("node:crypto");
|
|
32
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
33
|
+
const agent_chat_start_1 = require("./agent-chat-start");
|
|
34
|
+
const cloud_reply_1 = require("./cloud-reply");
|
|
35
|
+
const http_error_1 = require("./http-error");
|
|
36
|
+
/* ── Words ─────────────────────────────────────────────────────────────── */
|
|
37
|
+
exports.HELD_COPY = {
|
|
38
|
+
machine_offline: (d) => d?.machineName
|
|
39
|
+
? `${d.machineName} is offline. Your agent will see this when it's back.`
|
|
40
|
+
: "Your agent's machine is offline. It will see this when the machine is back.",
|
|
41
|
+
machine_starting: (d) => d?.machineName
|
|
42
|
+
? `Your agent is starting ${d.machineName}. It will see this in a moment.`
|
|
43
|
+
: 'Your agent is starting its machine. It will see this in a moment.',
|
|
44
|
+
session_busy: (d) => d?.workTitle
|
|
45
|
+
? `Your agent is working on ${d.workTitle} and will see this after the current step.`
|
|
46
|
+
: 'Your agent will see this after the current step.',
|
|
47
|
+
deferred_by_user: (d) => d?.workTitle
|
|
48
|
+
? `Sends when your agent finishes ${d.workTitle}.`
|
|
49
|
+
: "Sends when your agent finishes what it's doing.",
|
|
50
|
+
long_step: (d) => d?.toolName
|
|
51
|
+
? `Your agent is waiting for ${d.toolName} to finish. It will see this then.`
|
|
52
|
+
: 'Your agent is in a long step. It will see this when the step ends.',
|
|
53
|
+
glance_unavailable: () => 'Your agent will see this at its next step.',
|
|
54
|
+
queue_paused: () => 'Paused. This sends when you resume.',
|
|
55
|
+
};
|
|
56
|
+
exports.FAILED_COPY = {
|
|
57
|
+
agent_unavailable: 'Not delivered: this agent is no longer available.',
|
|
58
|
+
permission_denied: 'Not delivered: you can no longer use this agent.',
|
|
59
|
+
usage_limit: "Not delivered yet: you're out of usage. Top up, then resume to send it.",
|
|
60
|
+
moderation_refused: "Not delivered: this message didn't pass content checks.",
|
|
61
|
+
conversation_unavailable: 'Not delivered: this conversation is no longer available.',
|
|
62
|
+
refused: 'Not delivered.',
|
|
63
|
+
};
|
|
64
|
+
/** What the route says the moment the message is kept, before anything read it. */
|
|
65
|
+
exports.ROUTE_COPY = {
|
|
66
|
+
command: "Sent. The command runs once your agent finishes what it's doing.",
|
|
67
|
+
addressed: 'Sent to what you addressed.',
|
|
68
|
+
answer: "Sent as the answer to your agent's question.",
|
|
69
|
+
merged: 'Sent. Your agent reads it with the message before it.',
|
|
70
|
+
new_turn: 'Sent. Your agent is starting on it.',
|
|
71
|
+
steer: 'Your agent took this into the work in progress.',
|
|
72
|
+
glance: 'Your agent is reading this while it works.',
|
|
73
|
+
hold: 'Sent. Your agent will see it soon.',
|
|
74
|
+
};
|
|
75
|
+
/** A glance's decision. `null` where the agent's own words are the whole answer. */
|
|
76
|
+
exports.GLANCE_COPY = {
|
|
77
|
+
replied: 'Your agent answered this while it worked.',
|
|
78
|
+
forwarded: 'Your agent took this into the work in progress.',
|
|
79
|
+
deferred: "Your agent will take this up when it finishes what it's doing.",
|
|
80
|
+
interrupted: 'Your agent stopped to take this first.',
|
|
81
|
+
no_reply: 'Seen.',
|
|
82
|
+
continued_work: null,
|
|
83
|
+
};
|
|
84
|
+
exports.FALLBACK_COPY = {
|
|
85
|
+
not_started: "Your agent couldn't look at this while it worked. It will see it when it finishes what it's doing.",
|
|
86
|
+
timed_out: "Your agent didn't get to this in time. It will see it when it finishes what it's doing.",
|
|
87
|
+
failed: "Something went wrong while your agent looked at this. It will see it when it finishes what it's doing.",
|
|
88
|
+
unreadable: "Your agent's decision about this couldn't be read. It will see it when it finishes what it's doing.",
|
|
89
|
+
undecided: "Your agent didn't decide what to do with this. It will see it when it finishes what it's doing.",
|
|
90
|
+
not_carried_out: "What your agent decided about this couldn't be done. It will see it when it finishes what it's doing.",
|
|
91
|
+
};
|
|
92
|
+
/** A reply or reaction the server refused, in the CLI's words. */
|
|
93
|
+
exports.AGENT_REPLY_REFUSAL_COPY = {
|
|
94
|
+
reply_to_invalid: '--reply-to takes 1-10 message ids.',
|
|
95
|
+
reply_to_not_found: "A message named with --reply-to is not one of the owner's messages in the chat this one lands in.",
|
|
96
|
+
reply_to_destination_unsupported: "--reply-to answers the owner's own messages, so it works only for a message to the owner's chat with the agent.",
|
|
97
|
+
reply_to_offline_unsupported: "This session sends through the daemon's offline queue, which cannot say which message it answers. Send it without --reply-to.",
|
|
98
|
+
reaction_invalid: 'An agent reacts with one of 👍 👀 ✅ ❤️ 🙏 😂 🎉 🤔, or their names: thumbs-up, eyes, done, ' +
|
|
99
|
+
'heart, thanks, laugh, tada, thinking.',
|
|
100
|
+
reaction_message_not_found: "That message is not one of the owner's messages in a chat with this agent.",
|
|
101
|
+
reaction_needs_interactive_session: 'Only an interactive session reacts to a message; an unattended run sends a message instead.',
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* `--reply-to` (or a payload's `replyTo`): absent is `null`; otherwise 1-10 message ids, trimmed
|
|
105
|
+
* and without repeats. The server proves each one; this only refuses a list it could never accept.
|
|
106
|
+
*/
|
|
107
|
+
function normalizeReplyTo(value) {
|
|
108
|
+
if (value === undefined || value === null)
|
|
109
|
+
return null;
|
|
110
|
+
const list = Array.isArray(value) ? value : [value];
|
|
111
|
+
const ids = [];
|
|
112
|
+
for (const entry of list) {
|
|
113
|
+
if (typeof entry !== 'string')
|
|
114
|
+
return 'invalid';
|
|
115
|
+
const id = entry.trim();
|
|
116
|
+
if (!id || id.length > 160 || /[\s]/.test(id))
|
|
117
|
+
return 'invalid';
|
|
118
|
+
if (!ids.includes(id))
|
|
119
|
+
ids.push(id);
|
|
120
|
+
}
|
|
121
|
+
if (ids.length === 0 || ids.length > data_provider_1.INBOUND_LIMITS.maxBatch)
|
|
122
|
+
return 'invalid';
|
|
123
|
+
return ids;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A reply or reaction the server refused, when it named a refusal this CLI knows: the code, and
|
|
127
|
+
* the ids a reply could not prove. The DM route names it `errorType`, the session gateway `reason`.
|
|
128
|
+
*/
|
|
129
|
+
function agentReplyRefusalOf(err) {
|
|
130
|
+
const response = err?.response?.data;
|
|
131
|
+
const bodies = [(0, agent_chat_start_1.bodyOf)(err), response].filter((body) => !!body && typeof body === 'object');
|
|
132
|
+
for (const body of bodies) {
|
|
133
|
+
for (const value of [body.errorType, body.reason, body.code]) {
|
|
134
|
+
if (typeof value === 'string' && value in exports.AGENT_REPLY_REFUSAL_COPY) {
|
|
135
|
+
const missing = Array.isArray(body.missing)
|
|
136
|
+
? body.missing.filter((id) => typeof id === 'string')
|
|
137
|
+
: undefined;
|
|
138
|
+
return { code: value, ...(missing ? { missing } : {}) };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
/** A plain name for each reaction, so a terminal never has to type an emoji. */
|
|
145
|
+
exports.REACTION_NAMES = {
|
|
146
|
+
'👍': 'thumbs-up',
|
|
147
|
+
'👀': 'eyes',
|
|
148
|
+
'✅': 'done',
|
|
149
|
+
'❤️': 'heart',
|
|
150
|
+
'🙏': 'thanks',
|
|
151
|
+
'😂': 'laugh',
|
|
152
|
+
'🎉': 'tada',
|
|
153
|
+
'🤔': 'thinking',
|
|
154
|
+
};
|
|
155
|
+
/** An emoji, or its plain name, as one of the contract's reactions; null when it is neither. */
|
|
156
|
+
function reactionFromInput(input) {
|
|
157
|
+
const value = input.trim();
|
|
158
|
+
// A heart typed without its variation selector is still the heart.
|
|
159
|
+
const glyph = value === '\u2764' ? '\u2764\uFE0F' : value;
|
|
160
|
+
if (data_provider_1.MESSAGE_REACTION_EMOJI.includes(glyph)) {
|
|
161
|
+
return glyph;
|
|
162
|
+
}
|
|
163
|
+
const named = Object.keys(exports.REACTION_NAMES).find((emoji) => exports.REACTION_NAMES[emoji] === value.toLowerCase());
|
|
164
|
+
return named ?? null;
|
|
165
|
+
}
|
|
166
|
+
/** The one sentence for a message's delivery, as a surface draws it. */
|
|
167
|
+
function deliverySentence(delivery) {
|
|
168
|
+
if (!delivery)
|
|
169
|
+
return null;
|
|
170
|
+
if (delivery.state === 'failed') {
|
|
171
|
+
const reason = delivery.failed?.reason;
|
|
172
|
+
const words = (reason && exports.FAILED_COPY[reason]) || exports.FAILED_COPY.refused;
|
|
173
|
+
return delivery.failed?.detail && reason === 'refused'
|
|
174
|
+
? `${words} ${delivery.failed.detail}`
|
|
175
|
+
: words;
|
|
176
|
+
}
|
|
177
|
+
if (delivery.state === 'held' && delivery.held?.reason && delivery.held.reason in exports.HELD_COPY) {
|
|
178
|
+
return exports.HELD_COPY[delivery.held.reason](delivery.held.detail);
|
|
179
|
+
}
|
|
180
|
+
const handled = handlingSentence(delivery.handling?.[delivery.handling.length - 1]);
|
|
181
|
+
if (handled)
|
|
182
|
+
return handled;
|
|
183
|
+
if (delivery.route)
|
|
184
|
+
return exports.ROUTE_COPY[delivery.route] ?? null;
|
|
185
|
+
return delivery.state === 'seen' ? 'Seen.' : 'Sent.';
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* "Not for this Task" (Q6): the message is back in this conversation, and what became of the Task
|
|
189
|
+
* it had gone to. The web's words (`deliveryCopy.ts`, `RETURN_COPY`), with and without the title.
|
|
190
|
+
*/
|
|
191
|
+
exports.RETURN_OUTCOME_COPY = {
|
|
192
|
+
withdrawn: (title) => `Back in this chat. ${title ?? 'The Task'} stopped working on it.`,
|
|
193
|
+
noted: (title) => `Back in this chat. ${title ?? 'The Task'} was told it wasn't for it.`,
|
|
194
|
+
untouched: (title) => `Back in this chat. It's still in ${title ?? 'the Task'} too.`,
|
|
195
|
+
};
|
|
196
|
+
/** Why "Not for this Task" was refused (`INBOUND_RETURN_REFUSALS`). */
|
|
197
|
+
exports.RETURN_REFUSAL_COPY = {
|
|
198
|
+
INBOUND_MESSAGE_NOT_FOUND: 'This message is no longer here.',
|
|
199
|
+
INBOUND_MESSAGE_NOT_FORWARDED: "This message isn't with a Task any more.",
|
|
200
|
+
INBOUND_MESSAGE_CHANGED: 'This message just changed. Try again.',
|
|
201
|
+
};
|
|
202
|
+
/** The sentence for a message brought back from a Task: a `returned` handling, or the answer's. */
|
|
203
|
+
function returnedSentence(returned) {
|
|
204
|
+
const copy = returned.taskOutcome ? exports.RETURN_OUTCOME_COPY[returned.taskOutcome] : undefined;
|
|
205
|
+
return copy ? copy(returned.from?.title) : 'Back in this chat.';
|
|
206
|
+
}
|
|
207
|
+
/** What a recorded handling says, or null when it adds nothing to the agent's own words. */
|
|
208
|
+
function handlingSentence(handling) {
|
|
209
|
+
if (!handling)
|
|
210
|
+
return null;
|
|
211
|
+
if (handling.kind === 'returned')
|
|
212
|
+
return returnedSentence(handling);
|
|
213
|
+
// Read from the cloud while the machine could not answer: what it left waits for the machine.
|
|
214
|
+
const cloud = (0, data_provider_1.messageCloudReply)({ communication: { cloudReply: handling.cloudReply } });
|
|
215
|
+
if (handling.kind === 'fallback') {
|
|
216
|
+
if (handling.target?.kind === 'session')
|
|
217
|
+
return exports.GLANCE_COPY.forwarded;
|
|
218
|
+
if (cloud && handling.reason === 'not_carried_out') {
|
|
219
|
+
return (0, cloud_reply_1.cloudHandlingSentence)(cloud, 'not_carried_out');
|
|
220
|
+
}
|
|
221
|
+
return (handling.reason && exports.FALLBACK_COPY[handling.reason]) || exports.FALLBACK_COPY.undecided;
|
|
222
|
+
}
|
|
223
|
+
if (handling.target?.kind === 'task') {
|
|
224
|
+
return handling.target.title ? `Sent to ${handling.target.title}.` : 'Sent to a Task.';
|
|
225
|
+
}
|
|
226
|
+
if (cloud && handling.by?.kind === 'glance' && handling.kind === 'deferred') {
|
|
227
|
+
return (0, cloud_reply_1.cloudHandlingSentence)(cloud, 'deferred');
|
|
228
|
+
}
|
|
229
|
+
if (handling.by?.kind === 'glance' && handling.kind in exports.GLANCE_COPY) {
|
|
230
|
+
return exports.GLANCE_COPY[handling.kind];
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
/* ── Sending ───────────────────────────────────────────────────────────── */
|
|
235
|
+
const MESSAGE_ID = /^[A-Za-z0-9_-]{8,200}$/;
|
|
236
|
+
/**
|
|
237
|
+
* The message id for one invocation's start key. The ingress takes letters, digits, `_` and `-`;
|
|
238
|
+
* a key outside that becomes a hash of itself, so a replay of the same invocation names the same
|
|
239
|
+
* message and two different keys never share one.
|
|
240
|
+
*/
|
|
241
|
+
function inboundMessageIdFor(startKey) {
|
|
242
|
+
if (MESSAGE_ID.test(startKey))
|
|
243
|
+
return startKey;
|
|
244
|
+
return `cli-${(0, node_crypto_1.createHash)('sha256').update(startKey).digest('hex').slice(0, 40)}`;
|
|
245
|
+
}
|
|
246
|
+
/** Whether a failed send came from a server that has no ingress (a 404 with no code of its own). */
|
|
247
|
+
function ingressMissing(err) {
|
|
248
|
+
if ((0, http_error_1.httpStatusOf)(err) !== 404)
|
|
249
|
+
return false;
|
|
250
|
+
const body = (0, agent_chat_start_1.bodyOf)(err);
|
|
251
|
+
const response = err?.response?.data;
|
|
252
|
+
return typeof body?.code !== 'string' && typeof response?.code !== 'string';
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Send the message `startAgenticChat(params)` would have started a turn with. The submission is
|
|
256
|
+
* the same body, frozen at send; the turn it starts (now or later) uses the ids chosen here.
|
|
257
|
+
*/
|
|
258
|
+
async function sendInboundMessage(params, { messageId, intent, deps = {}, }) {
|
|
259
|
+
const sessionId = (0, node_crypto_1.randomUUID)();
|
|
260
|
+
const responseMessageId = (0, node_crypto_1.randomUUID)();
|
|
261
|
+
const { clientRequestId: _key, ...body } = data_provider_1.dataService.buildAgenticChatBody(params);
|
|
262
|
+
void _key;
|
|
263
|
+
const send = deps.send ?? data_provider_1.dataService.sendConversationMessage;
|
|
264
|
+
const answer = await send(params.conversationId, {
|
|
265
|
+
capability: data_provider_1.INBOUND_MESSAGES_CAPABILITY,
|
|
266
|
+
clientMessageId: messageId,
|
|
267
|
+
text: params.text,
|
|
268
|
+
submission: { ...body, source: 'cli', sessionId, responseMessageId },
|
|
269
|
+
intent,
|
|
270
|
+
});
|
|
271
|
+
return { answer, messageId, sessionId, responseMessageId };
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* "Not for this Task": bring back a message the platform or a glance passed to a Task, and have it
|
|
275
|
+
* delivered in this conversation again. The Task is told, and its response stopped when it was
|
|
276
|
+
* for this message alone. A retry, or a second call, answers with the message as it is.
|
|
277
|
+
*/
|
|
278
|
+
async function returnInboundMessage(conversationId, messageId, deps = {}) {
|
|
279
|
+
const send = deps.send ?? data_provider_1.dataService.returnConversationMessage;
|
|
280
|
+
return send(conversationId, messageId, {
|
|
281
|
+
capability: data_provider_1.INBOUND_MESSAGES_CAPABILITY,
|
|
282
|
+
submission: { source: 'cli' },
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The next step a person may take when their message went to a Task, or null when it did not (or
|
|
287
|
+
* already came back): bring it back to the conversation.
|
|
288
|
+
*/
|
|
289
|
+
function notForTaskHint(bin, conversationId, messageId, handling) {
|
|
290
|
+
if (!handling || handling.kind === 'returned' || handling.target?.kind !== 'task')
|
|
291
|
+
return null;
|
|
292
|
+
return (`Not for that Task? \`${bin} agents not-for-task ${messageId} --conversation ` +
|
|
293
|
+
`${conversationId}\` brings it back here.`);
|
|
294
|
+
}
|
|
295
|
+
/** The words for a refusal of "Not for this Task", or null when it is not one of its codes. */
|
|
296
|
+
function returnRefusalOf(err) {
|
|
297
|
+
const code = (0, agent_chat_start_1.bodyOf)(err)?.code ??
|
|
298
|
+
err?.response?.data?.code;
|
|
299
|
+
return typeof code === 'string' && code in exports.RETURN_REFUSAL_COPY
|
|
300
|
+
? exports.RETURN_REFUSAL_COPY[code]
|
|
301
|
+
: null;
|
|
302
|
+
}
|
|
303
|
+
function nextAfterSend(answer) {
|
|
304
|
+
if (!answer.route || answer.delivery?.state === 'failed')
|
|
305
|
+
return { kind: 'failed' };
|
|
306
|
+
const turn = answer.turn;
|
|
307
|
+
switch (answer.route) {
|
|
308
|
+
case 'new_turn':
|
|
309
|
+
case 'merged':
|
|
310
|
+
if (turn?.sessionId && turn.responseMessageId) {
|
|
311
|
+
return {
|
|
312
|
+
kind: 'turn',
|
|
313
|
+
sessionId: turn.sessionId,
|
|
314
|
+
responseMessageId: turn.responseMessageId,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
// A merge whose reply row is not known yet is answered by that turn; a new turn that did
|
|
318
|
+
// not start at once waits for its card.
|
|
319
|
+
return answer.route === 'merged' ? { kind: 'delivered' } : { kind: 'wait' };
|
|
320
|
+
case 'glance':
|
|
321
|
+
return { kind: 'glance' };
|
|
322
|
+
case 'command':
|
|
323
|
+
case 'hold':
|
|
324
|
+
return { kind: 'wait' };
|
|
325
|
+
default:
|
|
326
|
+
return { kind: 'delivered' };
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** How long a glance can take to settle: its wall clock, its lease, and a margin. */
|
|
330
|
+
exports.GLANCE_WAIT_MS = data_provider_1.INBOUND_LIMITS.glanceWallClockMs + 15_000 + 10_000;
|
|
331
|
+
/**
|
|
332
|
+
* Wait for what a glance decided about one message: read the conversation until the message
|
|
333
|
+
* carries a glance's handling (or the platform's fallback), and pick up the reply that names it.
|
|
334
|
+
*/
|
|
335
|
+
async function waitForGlance(conversationId, messageId, { timeoutMs = exports.GLANCE_WAIT_MS, deps = {}, } = {}) {
|
|
336
|
+
const read = deps.messages ??
|
|
337
|
+
((id) => data_provider_1.dataService.getMessagesByConvoId(id));
|
|
338
|
+
const sleep = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
339
|
+
const now = deps.now ?? Date.now;
|
|
340
|
+
const deadline = now() + timeoutMs;
|
|
341
|
+
for (;;) {
|
|
342
|
+
const rows = (await read(conversationId)) ?? [];
|
|
343
|
+
const mine = rows.find((row) => row.messageId === messageId && row.isCreatedByUser);
|
|
344
|
+
const handlings = (mine?.delivery?.handling ?? []).filter((entry) => entry?.by?.kind === 'glance' || entry?.kind === 'fallback');
|
|
345
|
+
const handling = handlings.length > 0 ? handlings[handlings.length - 1] : null;
|
|
346
|
+
const replyRow = rows.find((row) => {
|
|
347
|
+
const replyTo = row.metadata?.communication?.replyTo;
|
|
348
|
+
return !row.isCreatedByUser && Array.isArray(replyTo) && replyTo.includes(messageId);
|
|
349
|
+
});
|
|
350
|
+
const cloudReply = replyRow ? (0, data_provider_1.messageCloudReply)(replyRow.metadata) : null;
|
|
351
|
+
const reply = replyRow?.messageId
|
|
352
|
+
? {
|
|
353
|
+
messageId: replyRow.messageId,
|
|
354
|
+
text: String(replyRow.text ?? ''),
|
|
355
|
+
...(cloudReply ? { cloudReply } : {}),
|
|
356
|
+
}
|
|
357
|
+
: null;
|
|
358
|
+
// A reply is sent before the rest of the decisions are carried out, so wait for the handling.
|
|
359
|
+
if (handling || now() >= deadline)
|
|
360
|
+
return { handling, reply };
|
|
361
|
+
await sleep(2_000);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* A message's delivery now, read from the conversation, or `null` when the message is gone (it was
|
|
366
|
+
* taken back from another screen). Used when its card leaves the queue without a turn of its own:
|
|
367
|
+
* it may have been read with another message.
|
|
368
|
+
*/
|
|
369
|
+
async function readMessageDelivery(conversationId, messageId, deps = {}) {
|
|
370
|
+
const read = deps.messages ??
|
|
371
|
+
((id) => data_provider_1.dataService.getMessagesByConvoId(id));
|
|
372
|
+
const rows = (await read(conversationId)) ?? [];
|
|
373
|
+
const row = rows.find((m) => m.messageId === messageId && m.isCreatedByUser);
|
|
374
|
+
return row ? { delivery: row.delivery ?? null } : null;
|
|
375
|
+
}
|
package/dist/lib/input-queue.js
CHANGED
|
@@ -6,7 +6,8 @@ exports.HOLD_REASON_COPY = {
|
|
|
6
6
|
conversation_outcome_unconfirmed: 'Waiting for the previous reply to be confirmed. It sends by itself once that clears; nothing to do.',
|
|
7
7
|
agent_unavailable: 'The agent was deleted or suspended after this message was queued.',
|
|
8
8
|
permission_denied: 'You no longer have access to this agent or conversation.',
|
|
9
|
-
|
|
9
|
+
// Says what lifts it, because nothing does by itself: no reset or top-up resends a held card.
|
|
10
|
+
usage_limit: 'A balance, plan or usage limit refused this turn. It does not send by itself: run `skrr agents queue resume` once credits are added, the allowance resets or the limit is raised.',
|
|
10
11
|
moderation_refused: 'Moderation refused this message.',
|
|
11
12
|
machine_unavailable: 'The machine this turn runs on is offline or paused for maintenance.',
|
|
12
13
|
conversation_unavailable: 'The conversation is no longer available.',
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the CLI says what an Agent's look around did (OSK-33157). The vocabulary is owned by
|
|
3
|
+
* `@skrr-ai/data-provider`; each map is keyed by its type, so a new value fails the build
|
|
4
|
+
* here until it has a sentence.
|
|
5
|
+
*/
|
|
6
|
+
import type { IntuitionLookAroundStatus, IntuitionLookSkipReason, IntuitionSuggestionSetAsideReason } from '@skrr-ai/data-provider';
|
|
7
|
+
export declare const LOOK_SKIP_SENTENCES: Record<IntuitionLookSkipReason, string>;
|
|
8
|
+
export declare const SET_ASIDE_SENTENCES: Record<IntuitionSuggestionSetAsideReason, string>;
|
|
9
|
+
/** Lines about the schedule; empty when there is nothing worth saying. */
|
|
10
|
+
export declare function describeLookAround(lookAround: IntuitionLookAroundStatus | null | undefined, agentId: string): string[];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* How the CLI says what an Agent's look around did (OSK-33157). The vocabulary is owned by
|
|
4
|
+
* `@skrr-ai/data-provider`; each map is keyed by its type, so a new value fails the build
|
|
5
|
+
* here until it has a sentence.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.SET_ASIDE_SENTENCES = exports.LOOK_SKIP_SENTENCES = void 0;
|
|
9
|
+
exports.describeLookAround = describeLookAround;
|
|
10
|
+
exports.LOOK_SKIP_SENTENCES = {
|
|
11
|
+
owner_inactive: 'you have not chatted with it lately; it looks again once you do',
|
|
12
|
+
billing_refused: 'your balance did not cover a look',
|
|
13
|
+
agent_unavailable: 'the agent could not be read',
|
|
14
|
+
already_looking: 'a look was already running',
|
|
15
|
+
quiet_hours: 'it fell in quiet hours',
|
|
16
|
+
runtime_unavailable: 'its machine could not be reached',
|
|
17
|
+
runtime_not_fenced: 'this agent runs on a machine where a look cannot be kept to reading only',
|
|
18
|
+
};
|
|
19
|
+
exports.SET_ASIDE_SENTENCES = {
|
|
20
|
+
ungrounded: 'no source it could point to',
|
|
21
|
+
invalid: 'incomplete or too long',
|
|
22
|
+
unsafe_reference: 'its source could not be opened safely',
|
|
23
|
+
secret_like: 'it looked like it contained a secret',
|
|
24
|
+
dismissed_recently: 'you dismissed it recently',
|
|
25
|
+
accepted_recently: 'you took it up recently',
|
|
26
|
+
repeated: 'already suggested in this look',
|
|
27
|
+
over_limit: 'more than one look shows',
|
|
28
|
+
};
|
|
29
|
+
/** Lines about the schedule; empty when there is nothing worth saying. */
|
|
30
|
+
function describeLookAround(lookAround, agentId) {
|
|
31
|
+
if (!lookAround)
|
|
32
|
+
return [];
|
|
33
|
+
if (lookAround.state === 'paused') {
|
|
34
|
+
return [
|
|
35
|
+
`Looking around is paused: the last ${lookAround.consecutiveFailures} looks did not finish.`,
|
|
36
|
+
`Resume it with: skrr agents intuitions resume ${agentId}`,
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
if (lookAround.state === 'looking')
|
|
40
|
+
return ['Looking around now.'];
|
|
41
|
+
const lines = [];
|
|
42
|
+
const last = lookAround.lastLook;
|
|
43
|
+
if (last) {
|
|
44
|
+
if (last.outcome === 'suggested')
|
|
45
|
+
lines.push(`Last look (${last.at}) found ${last.suggested}.`);
|
|
46
|
+
else if (last.outcome === 'nothing_to_suggest') {
|
|
47
|
+
lines.push(`Last look (${last.at}) found nothing worth suggesting.`);
|
|
48
|
+
}
|
|
49
|
+
else if (last.outcome === 'failed')
|
|
50
|
+
lines.push(`Last look (${last.at}) did not finish.`);
|
|
51
|
+
else if (last.skipReason) {
|
|
52
|
+
lines.push(`Last look (${last.at}) skipped: ${exports.LOOK_SKIP_SENTENCES[last.skipReason] ?? last.skipReason}.`);
|
|
53
|
+
}
|
|
54
|
+
for (const entry of last.setAside ?? []) {
|
|
55
|
+
const why = exports.SET_ASIDE_SENTENCES[entry.reason] ?? entry.reason;
|
|
56
|
+
lines.push(` Set aside${entry.title ? ` "${entry.title}"` : ''}: ${why}.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (lookAround.waitingForQuietHours)
|
|
60
|
+
lines.push('Next look waits for quiet hours to end.');
|
|
61
|
+
else if (lookAround.nextLookAt)
|
|
62
|
+
lines.push(`Next look: ${lookAround.nextLookAt}.`);
|
|
63
|
+
return lines;
|
|
64
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ResolvedCredential } from '@skrr-ai/auth-core';
|
|
2
|
-
import type { AgentMessageSequence, EntityEmbed, MessageOperation } from '@skrr-ai/data-provider';
|
|
2
|
+
import type { AgentMessageReactionAnswer, AgentMessageSequence, EntityEmbed, MessageOperation, MessageReactionEmoji } from '@skrr-ai/data-provider';
|
|
3
3
|
export declare const CANONICAL_DESTINATION_KINDS: readonly ["app_owner_dm", "slack_owner_dm", "slack_channel", "agent_email"];
|
|
4
4
|
export type CanonicalDestinationKind = (typeof CANONICAL_DESTINATION_KINDS)[number];
|
|
5
5
|
export type CanonicalMessageDestination = {
|
|
@@ -67,6 +67,11 @@ export type CanonicalMessageIntentRequest = {
|
|
|
67
67
|
notificationPolicy?: 'normal' | 'silent';
|
|
68
68
|
/** Root main-message id for an Agent Chat Thread (app_owner_dm only). */
|
|
69
69
|
threadRootMessageId?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The owner's messages this one answers (app_owner_dm only, 1-10 ids). The server proves each
|
|
72
|
+
* is the owner's own message in the conversation the reply lands in, or refuses the send.
|
|
73
|
+
*/
|
|
74
|
+
replyTo?: string[];
|
|
70
75
|
sequence?: AgentMessageSequence;
|
|
71
76
|
/** Optional work entities to render with an app-owner DM. */
|
|
72
77
|
context?: {
|
|
@@ -184,7 +189,17 @@ export declare function submitSessionMessageIntent({ context, request, env, boot
|
|
|
184
189
|
timeoutMs?: number;
|
|
185
190
|
fetchImpl?: typeof fetch;
|
|
186
191
|
}): Promise<CanonicalMessageIntentResponse>;
|
|
187
|
-
|
|
192
|
+
/**
|
|
193
|
+
* The Agent's emoji reaction to one of its owner's messages, from its own interactive session.
|
|
194
|
+
* Unlike a send, it never goes through the daemon's offline queue: a reaction that cannot reach
|
|
195
|
+
* the server now has nothing to keep, so it fails and the Agent can send a message instead.
|
|
196
|
+
*/
|
|
197
|
+
export declare function reactAsSession({ context, messageId, emoji, }: {
|
|
198
|
+
context: AgentSessionMessageContext;
|
|
199
|
+
messageId: string;
|
|
200
|
+
emoji: MessageReactionEmoji;
|
|
201
|
+
}): Promise<AgentMessageReactionAnswer>;
|
|
202
|
+
export declare function canonicalAppOwnerDmRequest({ agentId, embeds, text, idempotencyKey, taskId, spaceId, goalId, presentation, notificationPolicy, threadRootMessageId, replyTo, operation, }: {
|
|
188
203
|
agentId: string;
|
|
189
204
|
text: string;
|
|
190
205
|
idempotencyKey: string;
|
|
@@ -194,6 +209,7 @@ export declare function canonicalAppOwnerDmRequest({ agentId, embeds, text, idem
|
|
|
194
209
|
presentation?: CommunicationPresentation;
|
|
195
210
|
notificationPolicy?: 'normal' | 'silent';
|
|
196
211
|
threadRootMessageId?: string;
|
|
212
|
+
replyTo?: string[];
|
|
197
213
|
embeds?: EntityEmbed[];
|
|
198
214
|
operation?: MessageOperation;
|
|
199
215
|
}): CanonicalMessageIntentRequest;
|