@botiverse/raft-sdk 0.4.0 → 0.4.1
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/README.md +13 -6
- package/dist/cjs/index.cjs +4 -29
- package/dist/esm/index.js +4 -29
- package/dist/index.d.ts +12 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -190,7 +190,7 @@ gateway can handle it without knowing the command (`isInterrupted(outcome)`):
|
|
|
190
190
|
interface RaftInterrupt {
|
|
191
191
|
reason: "unread_messages";
|
|
192
192
|
context: string; // what the model reads (the CLI's held text)
|
|
193
|
-
resume: { argv
|
|
193
|
+
resume: { argv?: string[]; idempotencyKey?: string }; // always present; argv absent for an in-process send
|
|
194
194
|
cancel?: { argv: string[] }; // only when there is something to clean up
|
|
195
195
|
target: string;
|
|
196
196
|
newMessageCount: number;
|
|
@@ -203,11 +203,16 @@ interface RaftInterrupt {
|
|
|
203
203
|
}
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
- A held send
|
|
206
|
+
- A held send run as a command (the CLI, or the hosted command endpoint,
|
|
207
|
+
which store the draft): `resume.argv` is
|
|
207
208
|
`["message", "send", "--send-draft", "--target", T, "--expected-draft-key", K]`
|
|
208
209
|
with `resume.idempotencyKey` = `K`, the original key; `cancel.argv` is the
|
|
209
210
|
same with `--discard-draft`, which clears the saved draft only if it still
|
|
210
211
|
carries `K`.
|
|
212
|
+
- A held send from this SDK in-process: the SDK stores no draft, so there is
|
|
213
|
+
**no argv and no `cancel`**. `resume` is `{ idempotencyKey: K }`: to go
|
|
214
|
+
ahead, call `messages.send` again with the same input and
|
|
215
|
+
`idempotencyKey: K`; to drop it, don't call it (nothing is left behind).
|
|
211
216
|
- A held claim or task write: `resume.argv` is the identical command; there is
|
|
212
217
|
no `cancel` (nothing was saved). An absent `cancel` means cancelling needs no
|
|
213
218
|
request: just don't execute `resume`.
|
|
@@ -215,10 +220,12 @@ interface RaftInterrupt {
|
|
|
215
220
|
`frontier.recordHeld(interrupt)` if it saw it (nothing is recorded when the
|
|
216
221
|
context was withheld or `contextComplete` is false; have it read the
|
|
217
222
|
conversation first), then resume or cancel.
|
|
218
|
-
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
223
|
+
- An absent `resume.argv` means: call the same SDK method again with the same
|
|
224
|
+
input and `resume.idempotencyKey`. Present argv are the exact command form a
|
|
225
|
+
gateway hands to the model.
|
|
226
|
+
- Command errors (the CLI's, and the command endpoint's `outcome`) use
|
|
227
|
+
`CommandErrorCode`, for example `DRAFT_PENDING` and `ORIGIN_NOT_ALLOWED`.
|
|
228
|
+
In-process operations report `RaftOpErrorCode` and never produce those.
|
|
222
229
|
|
|
223
230
|
Failures are outcomes too (`ok: false`) with a stable `error.code`, the
|
|
224
231
|
Server's `serverCode` when it sent one, `nextAction`, and `retryable`; raw
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -10966,34 +10966,9 @@ function unreadMessagesInterrupt(input) {
|
|
|
10966
10966
|
contextComplete: !withheld && heldMessages.length + omittedMessageCount >= newMessageCount
|
|
10967
10967
|
};
|
|
10968
10968
|
}
|
|
10969
|
-
/**
|
|
10970
|
-
function
|
|
10971
|
-
return {
|
|
10972
|
-
argv: [
|
|
10973
|
-
"message",
|
|
10974
|
-
"send",
|
|
10975
|
-
"--send-draft",
|
|
10976
|
-
"--target",
|
|
10977
|
-
target,
|
|
10978
|
-
"--expected-draft-key",
|
|
10979
|
-
idempotencyKey,
|
|
10980
|
-
...extraArgv
|
|
10981
|
-
],
|
|
10982
|
-
idempotencyKey
|
|
10983
|
-
};
|
|
10984
|
-
}
|
|
10985
|
-
/** `raft message send --discard-draft` for the draft a held send saved (compare-and-clear on its key). */
|
|
10986
|
-
function discardDraftCancel(target, idempotencyKey, extraArgv = []) {
|
|
10987
|
-
return { argv: [
|
|
10988
|
-
"message",
|
|
10989
|
-
"send",
|
|
10990
|
-
"--discard-draft",
|
|
10991
|
-
"--target",
|
|
10992
|
-
target,
|
|
10993
|
-
"--expected-draft-key",
|
|
10994
|
-
idempotencyKey,
|
|
10995
|
-
...extraArgv
|
|
10996
|
-
] };
|
|
10969
|
+
/** Resume of an in-process SDK send: no argv (the SDK stores no draft), only the original key to call again with. */
|
|
10970
|
+
function inProcessSendResume(idempotencyKey) {
|
|
10971
|
+
return { idempotencyKey };
|
|
10997
10972
|
}
|
|
10998
10973
|
/** `raft task claim` argv for a claim request (resume of a held claim). */
|
|
10999
10974
|
function taskClaimArgv(target, taskNumbers, messageIds, extraArgv = []) {
|
|
@@ -11555,7 +11530,7 @@ async function sendMessage(client, request, frontier) {
|
|
|
11555
11530
|
if (!result.ok) return failureFromClientResult(result);
|
|
11556
11531
|
const data = result.data;
|
|
11557
11532
|
if (isHeldResponse(data)) {
|
|
11558
|
-
const interrupt = heldInterrupt(request.target, data, "Your message was not sent.",
|
|
11533
|
+
const interrupt = heldInterrupt(request.target, data, "Your message was not sent.", inProcessSendResume(idempotencyKey));
|
|
11559
11534
|
return {
|
|
11560
11535
|
ok: true,
|
|
11561
11536
|
state: "interrupted",
|
package/dist/esm/index.js
CHANGED
|
@@ -10965,34 +10965,9 @@ function unreadMessagesInterrupt(input) {
|
|
|
10965
10965
|
contextComplete: !withheld && heldMessages.length + omittedMessageCount >= newMessageCount
|
|
10966
10966
|
};
|
|
10967
10967
|
}
|
|
10968
|
-
/**
|
|
10969
|
-
function
|
|
10970
|
-
return {
|
|
10971
|
-
argv: [
|
|
10972
|
-
"message",
|
|
10973
|
-
"send",
|
|
10974
|
-
"--send-draft",
|
|
10975
|
-
"--target",
|
|
10976
|
-
target,
|
|
10977
|
-
"--expected-draft-key",
|
|
10978
|
-
idempotencyKey,
|
|
10979
|
-
...extraArgv
|
|
10980
|
-
],
|
|
10981
|
-
idempotencyKey
|
|
10982
|
-
};
|
|
10983
|
-
}
|
|
10984
|
-
/** `raft message send --discard-draft` for the draft a held send saved (compare-and-clear on its key). */
|
|
10985
|
-
function discardDraftCancel(target, idempotencyKey, extraArgv = []) {
|
|
10986
|
-
return { argv: [
|
|
10987
|
-
"message",
|
|
10988
|
-
"send",
|
|
10989
|
-
"--discard-draft",
|
|
10990
|
-
"--target",
|
|
10991
|
-
target,
|
|
10992
|
-
"--expected-draft-key",
|
|
10993
|
-
idempotencyKey,
|
|
10994
|
-
...extraArgv
|
|
10995
|
-
] };
|
|
10968
|
+
/** Resume of an in-process SDK send: no argv (the SDK stores no draft), only the original key to call again with. */
|
|
10969
|
+
function inProcessSendResume(idempotencyKey) {
|
|
10970
|
+
return { idempotencyKey };
|
|
10996
10971
|
}
|
|
10997
10972
|
/** `raft task claim` argv for a claim request (resume of a held claim). */
|
|
10998
10973
|
function taskClaimArgv(target, taskNumbers, messageIds, extraArgv = []) {
|
|
@@ -11554,7 +11529,7 @@ async function sendMessage(client, request, frontier) {
|
|
|
11554
11529
|
if (!result.ok) return failureFromClientResult(result);
|
|
11555
11530
|
const data = result.data;
|
|
11556
11531
|
if (isHeldResponse(data)) {
|
|
11557
|
-
const interrupt = heldInterrupt(request.target, data, "Your message was not sent.",
|
|
11532
|
+
const interrupt = heldInterrupt(request.target, data, "Your message was not sent.", inProcessSendResume(idempotencyKey));
|
|
11558
11533
|
return {
|
|
11559
11534
|
ok: true,
|
|
11560
11535
|
state: "interrupted",
|
package/dist/index.d.ts
CHANGED
|
@@ -430,8 +430,14 @@ export declare function projectRaftMessages(envelopes: readonly AgentApiMessageE
|
|
|
430
430
|
/** Why the call stopped. */
|
|
431
431
|
type RaftInterruptReason = "unread_messages";
|
|
432
432
|
interface RaftInterruptResume {
|
|
433
|
-
/**
|
|
434
|
-
|
|
433
|
+
/**
|
|
434
|
+
* The exact `raft` argv that carries out the interrupted call (for example
|
|
435
|
+
* `["message", "send", "--send-draft", …]`), when the call ran as a command
|
|
436
|
+
* (CLI or command endpoint) and its input is stored. Absent for an
|
|
437
|
+
* in-process SDK call: then resuming means calling the same SDK method again
|
|
438
|
+
* with the same input and `idempotencyKey`.
|
|
439
|
+
*/
|
|
440
|
+
argv?: string[];
|
|
435
441
|
/** The interrupted call's original idempotency key, when it has one (a send); resuming reuses it. */
|
|
436
442
|
idempotencyKey?: string;
|
|
437
443
|
}
|
|
@@ -9250,4 +9256,7 @@ interface Raft {
|
|
|
9250
9256
|
}
|
|
9251
9257
|
export declare function createRaft(options: CreateRaftOptions): Raft;
|
|
9252
9258
|
//#endregion
|
|
9253
|
-
|
|
9259
|
+
//#region ../shared/src/agentOps/commands/errors.d.ts
|
|
9260
|
+
type CommandErrorCode = "MISSING_AGENT_ID" | "MISSING_SERVER_URL" | "MISSING_AGENT_PROXY_URL" | "MULTIPLE_AGENT_PROXY_TOKENS" | "MISSING_AGENT_PROXY_TOKEN" | "MISSING_TOKEN" | "CHECK_FAILED" | "ARCHIVE_FAILED" | "AMEND_FAILED" | "COMMENTS_FAILED" | "CREATE_FAILED" | "RECEIPT_FAILED" | "INBOX_CHECK_FAILED" | "INBOX_UNAVAILABLE" | "ORIGIN_NOT_ALLOWED" | "TOKEN_FILE_UNREADABLE" | "TOKEN_FILE_EMPTY" | "PROFILE_FILE_UNREADABLE" | "PROFILE_FILE_INVALID" | "PROFILE_MANAGED_CONTEXT_CONFLICT" | "MANAGED_WRAPPER_UNAVAILABLE" | "MANAGED_WRAPPER_REQUIRED" | "MANAGED_WRAPPER_FORWARD_FAILED" | "BRIDGE_EXPECTED_AGENT_REQUIRED" | "BRIDGE_IDENTITY_MISMATCH" | "SEND_HELD_AS_DRAFT" | "SEND_HELD" | "GUIDANCE_DELIVERED" | "SEND_DRAFT_NOT_FOUND" | "SEND_DRAFT_EXPIRED" | "SAVED_DRAFT_IDENTITY_CHANGED" | "DRAFT_PENDING" | "THREAD_CONTEXT_TARGET_CONFIRMATION_REQUIRED" | "INVALID_ARG" | "INVALID_SCOPE" | "INVALID_TARGET" | "INVALID_JSON_RESPONSE" | "IDENTITY_MISMATCH" | "PROMPT_UNAVAILABLE" | "WHOAMI_FAILED" | "INFO_FAILED" | "INTEGRATION_SESSION_HANDOFF_FAILED" | "HISTORY_FAILED" | "JOIN_FAILED" | "KNOWLEDGE_GET_FAILED" | "KNOWLEDGE_SEARCH_FAILED" | "KNOWLEDGE_CONTEXT_INVALID" | "LEAVE_FAILED" | "LIST_FAILED" | "MEMBERS_FAILED" | "MUTE_FAILED" | "MENTION_ACTION_FAILED" | "MENTION_DELIVERY_FAILED" | "AMBIGUOUS_ID" | "BRIDGE_ALREADY_RUNNING" | "BRIDGE_WAKE_HINTS_FAILED" | "BRIDGE_WAKE_STREAM_FAILED" | "BRIDGE_WAKE_STREAM_UNAVAILABLE" | "BRIDGE_ACTIVITY_DRAIN_FAILED" | "BRIDGE_ACTIVITY_FORWARD_FAILED" | "BRIDGE_REQUIRES_PROFILE" | "NOT_FOUND" | "PROFILE_SHOW_FAILED" | "READ_FAILED" | "SEARCH_FAILED" | "SCOPE_DENIED" | "QUERY_TOO_BROAD" | "SEARCH_TIMEOUT" | "SEARCH_UNAVAILABLE" | "SERVER_5XX" | "PROXY_5XX" | "UNFOLLOW_FAILED" | "UNARCHIVE_FAILED" | "UNMUTE_FAILED" | "UNCLAIM_FAILED" | "CLAIM_FAILED" | "CLAIM_CONFLICT" | "ASSIGN_FAILED" | "DELETE_FAILED" | "CONVERT_FAILED" | "UPDATE_FAILED" | "VIEW_FAILED" | "VERSION_UNAVAILABLE" | "WAIT_FAILED" | "LOCAL_WRITE_FAILED" | "LOCAL_WRITE_SOURCE_FAILED" | "LOCAL_WRITE_DESTINATION_FAILED" | "LOCAL_WRITE_PARTIAL_FAILED" | "LOCAL_WRITE_POST_COMMIT_FAILED" | "LOCAL_WRITE_SIZE_EXCEEDED" | "INTERNAL_BUG" | "knowledge_agent_missing" | "knowledge_internal_error" | "knowledge_intent_invalid" | "knowledge_language_unsupported" | "knowledge_not_found" | "knowledge_query_invalid" | "knowledge_reason_invalid" | "knowledge_scope_invalid" | "knowledge_source_invalid" | "knowledge_topic_invalid" | "knowledge_trace_id_invalid" | "knowledge_turn_id_invalid" | "unsupported_capability";
|
|
9261
|
+
//#endregion
|
|
9262
|
+
export type { AmendTaskOutcome, AmendTaskRequest, AssignTaskRequest, BootstrapRaftCredentialOptions, CheckInboxOutcome, CheckInboxRequest, ClaimTasksOutcome, ClaimTasksRequest, CommandErrorCode, CreateRaftClientFromStoreOptions, CreateRaftClientOptions, CreateRaftOptions, CreateRaftRoutesOptions, CreateTasksRequest, DrainInboxRequest, ExecuteMentionActionRequest, ListInboxRequest, ListTasksRequest, ManualContext, PrepareActionCardRequest, Raft, RaftAckMode, RaftActionPrepareRequest, RaftActionPrepared, RaftApiError, RaftApiResult, RaftAppConfig, RaftAppConfigPatch, RaftAttachmentBytes, RaftAttachmentUploaded, RaftAvatarUpload, RaftChannelJoinClient, RaftChannelJoinClientResult, RaftChannelJoinError, RaftChannelJoinFailure, RaftChannelJoinOperation, RaftChannelJoinRequest, RaftChannelJoinResult, RaftChannelJoinSuccess, RaftChannelJoinTransportError, RaftChannelMuteState, RaftChannelRef, RaftClaimResult, RaftClaimRow, RaftClaimRowState, RaftClient, RaftClientError, RaftClientFailure, RaftClientResult, RaftClientSuccess, RaftClientThrottleOptions, RaftClientTransportRequest, RaftContextAgent, RaftContextData, RaftContextError, RaftContextResult, RaftContextServer, RaftCredentialErrorCode, RaftCredentialIdentity, RaftCredentialStore, RaftEvent, RaftEventAttachment, RaftEventExternalMessage, RaftEventsReceiveData, RaftEventsReceiveError, RaftEventsReceiveRequest, RaftEventsReceiveResult, RaftFailure, RaftHistoryPage, RaftInboxBatch, RaftInboxCommitResult, RaftInboxConversation, RaftInboxDrainSummary, RaftInboxListing, RaftInboxNotice, RaftInterrupt, RaftInterruptCancel, RaftInterruptReason, RaftInterruptResume, RaftInterrupted, RaftLatestReadThread, RaftManageClient, RaftMessage, RaftMessageAttachment, RaftMessageTask, RaftNextStep, RaftNoticeFlag, RaftNoticeTarget, RaftOpError, RaftOpErrorCode, RaftOutcome, RaftPendingMentions, RaftPreparedCard, RaftProfile, RaftProfileUpdate, RaftRouteAnnotations, RaftRouteInfo, RaftRouteKey, RaftRouteMeta, RaftRouteResult, RaftRouteRetryPolicy, RaftRoutes, RaftSdkConfigurationErrorCode, RaftSearchPage, RaftSenderType, RaftSent, RaftServerInfo, RaftServerProfile, RaftServerUpdate, RaftState, RaftStateContinuation, RaftStateSaveErrorHandler, RaftStateStore, RaftTaskBoard, RaftTaskStatus, RaftTasksCreated, RaftWebhookStatus, ReactRequest, ReadHistoryRequest, ReadLatestReadThreadOptions, SearchMessagesRequest, SeenAttestation, SeenFrontierSnapshot, SendMessageOutcome, SendMessageRequest, ServerInfoRequest, ServerInfoSection, StoredRaftCredential, TaskRef, UpdateTaskStatusOutcome, UpdateTaskStatusRequest, UploadAttachmentRequest, VerifyNoticeInput, VerifyNoticeRejection, VerifyNoticeResult };
|