@botiverse/raft-sdk 0.3.0 → 1.0.0-alpha.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 +6 -98
- package/dist/cjs/index.cjs +77 -2338
- package/dist/esm/index.js +78 -2333
- package/dist/index.d.ts +43 -442
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -444,8 +444,6 @@ export declare class SeenFrontier {
|
|
|
444
444
|
private readonly targets;
|
|
445
445
|
private readonly aliases;
|
|
446
446
|
static fromSnapshot(snapshot: SeenFrontierSnapshot | null | undefined): SeenFrontier;
|
|
447
|
-
/** Merge a snapshot into this frontier by the same monotonic rules (never lowers a mark). */
|
|
448
|
-
absorb(snapshot: SeenFrontierSnapshot | null | undefined): void;
|
|
449
447
|
/** Remember that the Server resolved `requested` to `canonical` (a thread spelling, a `~agent` suffix, …). */
|
|
450
448
|
recordAlias(requested: string, canonical: string): void;
|
|
451
449
|
canonical(target: string): string;
|
|
@@ -640,28 +638,6 @@ interface RaftHeld extends RaftHeldBase {
|
|
|
640
638
|
}
|
|
641
639
|
type SendMessageOutcome = RaftOutcome<RaftSent, "sent"> | RaftOutcome<RaftHeld, "held">;
|
|
642
640
|
//#endregion
|
|
643
|
-
//#region ../shared/src/agentText/tasks.d.ts
|
|
644
|
-
interface AgentClaimConflict {
|
|
645
|
-
kind: "claim_conflict";
|
|
646
|
-
conflictScope: "implementation_execution";
|
|
647
|
-
blockedActions: string[];
|
|
648
|
-
unblockedActionExamples: string[];
|
|
649
|
-
currentAssignee: {
|
|
650
|
-
type: "user" | "agent";
|
|
651
|
-
name: string | null;
|
|
652
|
-
} | null;
|
|
653
|
-
taskStatus: string | null;
|
|
654
|
-
claimedAt: string | null;
|
|
655
|
-
observedAt: string;
|
|
656
|
-
}
|
|
657
|
-
interface AgentClaimResult {
|
|
658
|
-
taskNumber?: number;
|
|
659
|
-
messageId?: string;
|
|
660
|
-
success: boolean;
|
|
661
|
-
reason?: string;
|
|
662
|
-
conflict?: AgentClaimConflict;
|
|
663
|
-
}
|
|
664
|
-
//#endregion
|
|
665
641
|
//#region ../shared/src/agentOps/tasks.d.ts
|
|
666
642
|
interface ClaimTasksRequest {
|
|
667
643
|
/** Channel target the tasks live in, for example `#proj-sdk`. */
|
|
@@ -684,8 +660,6 @@ interface RaftClaimRow {
|
|
|
684
660
|
name: string | null;
|
|
685
661
|
} | null;
|
|
686
662
|
conflict: AgentApiTaskClaimResult["conflict"] | null;
|
|
687
|
-
/** The Server's row, as the CLI formatter reads it. */
|
|
688
|
-
raw: AgentClaimResult;
|
|
689
663
|
}
|
|
690
664
|
interface RaftClaimResult {
|
|
691
665
|
target: string;
|
|
@@ -700,57 +674,6 @@ interface RaftClaimHeld extends Omit<RaftHeldBase, "idempotencyKey" | "continuat
|
|
|
700
674
|
retry(): Promise<ClaimTasksOutcome>;
|
|
701
675
|
}
|
|
702
676
|
type ClaimTasksOutcome = RaftOutcome<RaftClaimResult, "claimed" | "partial" | "refused"> | RaftOutcome<RaftClaimHeld, "held">;
|
|
703
|
-
type RaftTaskStatus = "todo" | "in_progress" | "in_review" | "done" | "closed";
|
|
704
|
-
interface ListTasksRequest {
|
|
705
|
-
/** Channel board, for example `#proj-sdk`; omit with `mine: true` for your own tasks across channels. */
|
|
706
|
-
target?: string;
|
|
707
|
-
mine?: boolean;
|
|
708
|
-
status?: RaftTaskStatus | "all";
|
|
709
|
-
}
|
|
710
|
-
interface RaftTaskBoard {
|
|
711
|
-
scope: "channel" | "mine";
|
|
712
|
-
target: string | null;
|
|
713
|
-
tasks: AgentApiTaskListResponse["tasks"];
|
|
714
|
-
coverage: AgentApiTaskListResponse["coverage"] | null;
|
|
715
|
-
}
|
|
716
|
-
interface CreateTasksRequest {
|
|
717
|
-
target: string;
|
|
718
|
-
tasks: Array<{
|
|
719
|
-
title: string;
|
|
720
|
-
createsResource?: boolean;
|
|
721
|
-
}>;
|
|
722
|
-
/** `@handle`; yourself to start in_progress, or (owner/admin) someone else to reserve a todo. */
|
|
723
|
-
assignee?: string;
|
|
724
|
-
}
|
|
725
|
-
type RaftTasksCreated = AgentApiTaskCreateResponse & {
|
|
726
|
-
target: string;
|
|
727
|
-
};
|
|
728
|
-
interface TaskRef {
|
|
729
|
-
target: string;
|
|
730
|
-
taskNumber: number;
|
|
731
|
-
}
|
|
732
|
-
interface AssignTaskRequest extends TaskRef {
|
|
733
|
-
/** `@handle`, or null to clear the assignment. */
|
|
734
|
-
assignee: string | null;
|
|
735
|
-
/** Optimistic-concurrency token from a task you just read; lose rather than clobber. */
|
|
736
|
-
expectedRevision?: number;
|
|
737
|
-
}
|
|
738
|
-
interface UpdateTaskStatusRequest extends TaskRef {
|
|
739
|
-
status: RaftTaskStatus;
|
|
740
|
-
}
|
|
741
|
-
type UpdateTaskStatusOutcome = RaftOutcome<UpdateTaskStatusRequest, "updated"> | RaftOutcome<RaftClaimHeldLike<UpdateTaskStatusRequest>, "held">;
|
|
742
|
-
/** A hold on a task write: the held context plus the request to repeat, as data. */
|
|
743
|
-
type RaftClaimHeldLike<TRequest> = Omit<RaftHeldBase, "idempotencyKey" | "continuation"> & {
|
|
744
|
-
request: TRequest;
|
|
745
|
-
};
|
|
746
|
-
interface AmendTaskRequest extends TaskRef {
|
|
747
|
-
title?: string;
|
|
748
|
-
/** New description; `null` clears it. */
|
|
749
|
-
description?: string | null;
|
|
750
|
-
}
|
|
751
|
-
type AmendTaskOutcome = RaftOutcome<AgentApiTaskAmendSuccessResponse & {
|
|
752
|
-
target: string;
|
|
753
|
-
}, "amended"> | RaftOutcome<RaftClaimHeldLike<AmendTaskRequest>, "held">;
|
|
754
677
|
//#endregion
|
|
755
678
|
//#region ../shared/src/agentOps/wake.d.ts
|
|
756
679
|
export declare const RAFT_INBOX_NOTICE_SCHEMA: "raft-agent-inbox-notice.v1";
|
|
@@ -807,187 +730,6 @@ interface VerifyNoticeInput {
|
|
|
807
730
|
export declare function verifyInboxNotice(input: VerifyNoticeInput): Promise<VerifyNoticeResult>;
|
|
808
731
|
type RaftWebhookStatus = AgentApiPushWebhookStatusResponse;
|
|
809
732
|
//#endregion
|
|
810
|
-
//#region ../shared/src/agentOps/channels.d.ts
|
|
811
|
-
interface RaftChannelRef {
|
|
812
|
-
target: string;
|
|
813
|
-
channelId: string;
|
|
814
|
-
}
|
|
815
|
-
interface RaftChannelMuteState extends RaftChannelRef {
|
|
816
|
-
activityMuted: boolean;
|
|
817
|
-
muteFromSeq: number | null;
|
|
818
|
-
stillArrives: string[];
|
|
819
|
-
}
|
|
820
|
-
//#endregion
|
|
821
|
-
//#region ../shared/src/agentText/server.d.ts
|
|
822
|
-
interface AgentPageInfo {
|
|
823
|
-
total: number;
|
|
824
|
-
offset: number;
|
|
825
|
-
limit: number;
|
|
826
|
-
nextCommand?: string;
|
|
827
|
-
}
|
|
828
|
-
//#endregion
|
|
829
|
-
//#region ../shared/src/agentOps/server.d.ts
|
|
830
|
-
type ServerInfoSection = "channels" | "agents" | "humans";
|
|
831
|
-
interface ServerInfoRequest {
|
|
832
|
-
/** Omit for the compact summary; `full` for the whole overview; a section for a paged listing. */
|
|
833
|
-
view?: "summary" | "full" | ServerInfoSection;
|
|
834
|
-
offset?: number;
|
|
835
|
-
/** Default 50. */
|
|
836
|
-
limit?: number;
|
|
837
|
-
/** Channels only: restrict to joined channels. */
|
|
838
|
-
joined?: boolean;
|
|
839
|
-
}
|
|
840
|
-
interface RaftServerInfo {
|
|
841
|
-
view: NonNullable<ServerInfoRequest["view"]>;
|
|
842
|
-
server: AgentApiServerInfoResponse;
|
|
843
|
-
/** Present for a paged section. */
|
|
844
|
-
page: (AgentPageInfo & {
|
|
845
|
-
section: ServerInfoSection;
|
|
846
|
-
}) | null;
|
|
847
|
-
}
|
|
848
|
-
//#endregion
|
|
849
|
-
//#region ../shared/src/agentOps/attachments.d.ts
|
|
850
|
-
/** Explicit type wins; otherwise sniff the bytes, then the filename extension, then octet-stream. */
|
|
851
|
-
export declare function inferAttachmentMimeType(filename: string, bytes: Uint8Array, explicit?: string | null): string;
|
|
852
|
-
interface UploadAttachmentRequest {
|
|
853
|
-
/** Conversation the attachment will be used in: `#channel`, `dm:@peer`, or a thread target. */
|
|
854
|
-
target: string;
|
|
855
|
-
filename: string;
|
|
856
|
-
bytes: Uint8Array;
|
|
857
|
-
/** Explicit MIME type; inferred from the bytes and filename when omitted. */
|
|
858
|
-
mimeType?: string;
|
|
859
|
-
}
|
|
860
|
-
type RaftAttachmentUploaded = AgentApiAttachmentUploadResponse & {
|
|
861
|
-
target: string;
|
|
862
|
-
mimeType: string | null;
|
|
863
|
-
};
|
|
864
|
-
interface RaftAttachmentBytes {
|
|
865
|
-
attachmentId: string;
|
|
866
|
-
bytes: Uint8Array;
|
|
867
|
-
}
|
|
868
|
-
//#endregion
|
|
869
|
-
//#region ../shared/src/agentOps/search.d.ts
|
|
870
|
-
interface SearchMessagesRequest {
|
|
871
|
-
/** Free-text query; may be omitted when filtering by target or sender only. */
|
|
872
|
-
query?: string;
|
|
873
|
-
/** Restrict to a channel, DM, or thread target. */
|
|
874
|
-
target?: string;
|
|
875
|
-
/** Restrict to a sender handle. */
|
|
876
|
-
sender?: string;
|
|
877
|
-
sort?: "relevance" | "recent";
|
|
878
|
-
/** ISO timestamps, both inclusive server-side. */
|
|
879
|
-
before?: string;
|
|
880
|
-
after?: string;
|
|
881
|
-
/** 1..50; Server default 20. */
|
|
882
|
-
limit?: number;
|
|
883
|
-
offset?: number;
|
|
884
|
-
}
|
|
885
|
-
interface RaftSearchPage {
|
|
886
|
-
query: string;
|
|
887
|
-
results: AgentApiMessageSearchResponse["results"];
|
|
888
|
-
/** Server-reported; `null` when an older Server did not say. */
|
|
889
|
-
hasMore: boolean | null;
|
|
890
|
-
}
|
|
891
|
-
interface ReactRequest {
|
|
892
|
-
messageId: string;
|
|
893
|
-
emoji: string;
|
|
894
|
-
}
|
|
895
|
-
//#endregion
|
|
896
|
-
//#region ../shared/src/agentText/mentions.d.ts
|
|
897
|
-
type AgentMentionActionKind = "notify" | "add";
|
|
898
|
-
interface AgentPendingMentionAction {
|
|
899
|
-
resolutionId: string;
|
|
900
|
-
messageId: string;
|
|
901
|
-
targetType: string;
|
|
902
|
-
targetHandle: string;
|
|
903
|
-
reason: string;
|
|
904
|
-
availableActions: string[];
|
|
905
|
-
expiresAt?: string | null;
|
|
906
|
-
}
|
|
907
|
-
type AgentMentionActionResultStatus = "queued" | "delivered" | "dropped" | "stale" | "expired" | "no_permission" | "not_found" | "ambiguous";
|
|
908
|
-
interface AgentMentionActionResult {
|
|
909
|
-
resolutionId: string;
|
|
910
|
-
status: AgentMentionActionResultStatus;
|
|
911
|
-
action?: AgentMentionActionKind | null;
|
|
912
|
-
messageId?: string | null;
|
|
913
|
-
channelId?: string | null;
|
|
914
|
-
targetType?: string | null;
|
|
915
|
-
targetId?: string | null;
|
|
916
|
-
targetHandle?: string | null;
|
|
917
|
-
message?: string | null;
|
|
918
|
-
reason?: string | null;
|
|
919
|
-
dedupedResolutionIds?: string[];
|
|
920
|
-
}
|
|
921
|
-
//#endregion
|
|
922
|
-
//#region ../shared/src/agentOps/mentions.d.ts
|
|
923
|
-
interface RaftPendingMentions {
|
|
924
|
-
actions: AgentPendingMentionAction[];
|
|
925
|
-
/** Server-reported; `null` when it did not say (completeness not asserted). */
|
|
926
|
-
hasMore: boolean | null;
|
|
927
|
-
limit: number | undefined;
|
|
928
|
-
}
|
|
929
|
-
interface ExecuteMentionActionRequest {
|
|
930
|
-
action: AgentMentionActionKind;
|
|
931
|
-
resolutionIds: string[];
|
|
932
|
-
}
|
|
933
|
-
//#endregion
|
|
934
|
-
//#region ../shared/src/agentOps/manual.d.ts
|
|
935
|
-
interface ManualContext {
|
|
936
|
-
intent: string;
|
|
937
|
-
reason: string;
|
|
938
|
-
}
|
|
939
|
-
//#endregion
|
|
940
|
-
//#region ../shared/src/agentOps/state.d.ts
|
|
941
|
-
export declare const RAFT_STATE_SCHEMA: "raft-sdk-state.v1";
|
|
942
|
-
interface RaftStateContinuation {
|
|
943
|
-
target: string;
|
|
944
|
-
idempotencyKey: string;
|
|
945
|
-
/** Hex SHA-256 of target, content and attachment ids; a resend with the same hash is the same logical message. */
|
|
946
|
-
contentHash: string;
|
|
947
|
-
/** ISO time the send was held. */
|
|
948
|
-
heldAt: string;
|
|
949
|
-
}
|
|
950
|
-
interface RaftState {
|
|
951
|
-
schema: typeof RAFT_STATE_SCHEMA;
|
|
952
|
-
/** Revision, incremented on every save by this SDK. Compare-and-set stores compare against it. */
|
|
953
|
-
version: number;
|
|
954
|
-
/** Last committed inbox cursor; the next pull passes it as `since`. */
|
|
955
|
-
cursor: number | null;
|
|
956
|
-
/** Cursor of the batch returned but not yet committed. */
|
|
957
|
-
pendingCursor: number | null;
|
|
958
|
-
frontier: SeenFrontierSnapshot;
|
|
959
|
-
continuations?: RaftStateContinuation[];
|
|
960
|
-
}
|
|
961
|
-
interface RaftStateStore {
|
|
962
|
-
load(): Promise<RaftState | null>;
|
|
963
|
-
/**
|
|
964
|
-
* Persist `state`. `expectedVersion` is the version this client loaded
|
|
965
|
-
* (`undefined` when the store was empty). Throw to reject a stale write;
|
|
966
|
-
* stores without compare-and-set may ignore it.
|
|
967
|
-
*/
|
|
968
|
-
save(state: RaftState, options: {
|
|
969
|
-
expectedVersion: number | undefined;
|
|
970
|
-
}): Promise<void>;
|
|
971
|
-
}
|
|
972
|
-
type RaftStateSaveErrorHandler = (error: unknown, context: {
|
|
973
|
-
phase: "load" | "save";
|
|
974
|
-
version: number | undefined;
|
|
975
|
-
}) => void;
|
|
976
|
-
export declare const RAFT_STATE_CONTINUATIONS_PER_TARGET = 3;
|
|
977
|
-
export declare const RAFT_STATE_CONTINUATIONS_TOTAL = 20;
|
|
978
|
-
/** Validate a loaded value; anything unrecognised is treated as an empty store (safe: see file header). */
|
|
979
|
-
export declare function parseRaftState(value: unknown): RaftState | null;
|
|
980
|
-
/** Hex SHA-256 identifying one logical message (WebCrypto; Workers-safe). */
|
|
981
|
-
export declare function hashRaftSendContent(target: string, content: string, attachmentIds?: readonly string[]): Promise<string>;
|
|
982
|
-
//#endregion
|
|
983
|
-
//#region ../shared/src/agentOps/actions.d.ts
|
|
984
|
-
type PrepareActionCardRequest = AgentApiActionPrepareBody;
|
|
985
|
-
interface RaftPreparedCard {
|
|
986
|
-
target: string;
|
|
987
|
-
/** The card message; a human commits it by clicking its action verb. */
|
|
988
|
-
messageId: string;
|
|
989
|
-
}
|
|
990
|
-
//#endregion
|
|
991
733
|
//#region ../shared/src/agentApiRawClient.d.ts
|
|
992
734
|
type AgentApiRawClientErrorReason = "missing_route" | "missing_path_param" | "request_contract_mismatch" | "transport_error" | "http_error" | "empty_response" | "response_contract_mismatch";
|
|
993
735
|
interface AgentApiRawTransportRequest<K extends AgentApiRouteKey = AgentApiRouteKey> {
|
|
@@ -996,6 +738,25 @@ interface AgentApiRawTransportRequest<K extends AgentApiRouteKey = AgentApiRoute
|
|
|
996
738
|
path: string;
|
|
997
739
|
body?: unknown;
|
|
998
740
|
}
|
|
741
|
+
type AgentApiRawSuccess<K extends AgentApiRouteKey> = {
|
|
742
|
+
ok: true;
|
|
743
|
+
routeKey: K;
|
|
744
|
+
status: number;
|
|
745
|
+
data: AgentApiResponseByRoute[K];
|
|
746
|
+
};
|
|
747
|
+
type AgentApiRawFailure<K extends AgentApiRouteKey = AgentApiRouteKey> = {
|
|
748
|
+
ok: false;
|
|
749
|
+
routeKey?: K;
|
|
750
|
+
status?: number;
|
|
751
|
+
reason: AgentApiRawClientErrorReason;
|
|
752
|
+
message: string;
|
|
753
|
+
errorCode?: string | null;
|
|
754
|
+
suggestedNextAction?: string | null;
|
|
755
|
+
proxy?: unknown;
|
|
756
|
+
cause?: unknown;
|
|
757
|
+
response?: unknown;
|
|
758
|
+
};
|
|
759
|
+
type AgentApiRawResult<K extends AgentApiRouteKey> = AgentApiRawSuccess<K> | AgentApiRawFailure<K>;
|
|
999
760
|
type AgentApiRawClientResource = AgentApiContract[AgentApiRouteKey]["client"]["resource"];
|
|
1000
761
|
type AgentApiRawClientResourceMethod<R extends AgentApiRawClientResource> = { [K in AgentApiRouteKey]: AgentApiContract[K]["client"] extends {
|
|
1001
762
|
resource: R;
|
|
@@ -1005,6 +766,9 @@ type AgentApiRouteKeyForClient<R extends AgentApiRawClientResource, M extends Ag
|
|
|
1005
766
|
resource: R;
|
|
1006
767
|
method: M;
|
|
1007
768
|
} ? K : never; }[AgentApiRouteKey];
|
|
769
|
+
type AgentApiRawClientMethodArgs<K extends AgentApiRouteKey> = [AgentApiRequestParamsByRoute[K]] extends [never] ? [AgentApiRequestQueryByRoute[K]] extends [never] ? [AgentApiRequestBodyByRoute[K]] extends [never] ? [] : [body: AgentApiRequestBodyByRoute[K]] : [query: AgentApiRequestQueryByRoute[K]] : [AgentApiRequestQueryByRoute[K]] extends [never] ? [AgentApiRequestBodyByRoute[K]] extends [never] ? [params: AgentApiRequestParamsByRoute[K]] : [params: AgentApiRequestParamsByRoute[K], body: AgentApiRequestBodyByRoute[K]] : [AgentApiRequestBodyByRoute[K]] extends [never] ? [params: AgentApiRequestParamsByRoute[K], query: AgentApiRequestQueryByRoute[K]] : [params: AgentApiRequestParamsByRoute[K], query: AgentApiRequestQueryByRoute[K], body: AgentApiRequestBodyByRoute[K]];
|
|
770
|
+
type AgentApiRawClientMethod<K extends AgentApiRouteKey> = (...args: AgentApiRawClientMethodArgs<K>) => Promise<AgentApiRawResult<K>>;
|
|
771
|
+
type AgentApiRawClient = { [R in AgentApiRawClientResource]: { [M in AgentApiRawClientResourceMethod<R>]: AgentApiRawClientMethod<AgentApiRouteKeyForClient<R, M>>; }; };
|
|
1008
772
|
//#endregion
|
|
1009
773
|
//#region ../shared/src/index.d.ts
|
|
1010
774
|
/**
|
|
@@ -1593,16 +1357,6 @@ declare const agentApiThreadUnfollowBodySchema: z.ZodObject<{
|
|
|
1593
1357
|
thread: z.ZodString;
|
|
1594
1358
|
reason: z.ZodOptional<z.ZodString>;
|
|
1595
1359
|
}, z.core.$loose>;
|
|
1596
|
-
declare const agentApiThreadListItemSchema: z.ZodObject<{
|
|
1597
|
-
target: z.ZodString;
|
|
1598
|
-
threadChannelId: z.ZodString;
|
|
1599
|
-
parentChannelRef: z.ZodString;
|
|
1600
|
-
parentMessageId: z.ZodString;
|
|
1601
|
-
parentMessageShortId: z.ZodString;
|
|
1602
|
-
followedAt: z.ZodString;
|
|
1603
|
-
reason: z.ZodString;
|
|
1604
|
-
doneAt: z.ZodNullable<z.ZodString>;
|
|
1605
|
-
}, z.core.$loose>;
|
|
1606
1360
|
declare const agentApiThreadListResponseSchema: z.ZodObject<{
|
|
1607
1361
|
threads: z.ZodArray<z.ZodObject<{
|
|
1608
1362
|
target: z.ZodString;
|
|
@@ -8334,7 +8088,6 @@ type AgentApiChannelLifecycleBody = z.infer<typeof agentApiChannelLifecycleBodyS
|
|
|
8334
8088
|
type AgentApiAttachmentDownloadParams = z.infer<typeof agentApiAttachmentDownloadParamsSchema>;
|
|
8335
8089
|
type AgentApiChannelMembersQuery = z.infer<typeof agentApiChannelMembersQuerySchema>;
|
|
8336
8090
|
type AgentApiThreadUnfollowBody = z.infer<typeof agentApiThreadUnfollowBodySchema>;
|
|
8337
|
-
type AgentApiThreadListItem = z.infer<typeof agentApiThreadListItemSchema>;
|
|
8338
8091
|
type AgentApiThreadListResponse = z.infer<typeof agentApiThreadListResponseSchema>;
|
|
8339
8092
|
type AgentApiInboxListQuery = z.infer<typeof agentApiInboxListQuerySchema>;
|
|
8340
8093
|
type AgentApiInboxListResponse = z.infer<typeof agentApiInboxListResponseSchema>;
|
|
@@ -8930,6 +8683,16 @@ interface AgentApiClientFailure<K extends AgentApiRouteKey = AgentApiRouteKey> {
|
|
|
8930
8683
|
error: AgentApiClientError;
|
|
8931
8684
|
}
|
|
8932
8685
|
type AgentApiClientResult<K extends AgentApiRouteKey> = AgentApiClientSuccess<K> | AgentApiClientFailure<K>;
|
|
8686
|
+
type AgentApiClientMethod<K extends AgentApiRouteKey> = (...args: Parameters<AgentApiRawClientMethod<K>>) => Promise<AgentApiClientResult<K>>;
|
|
8687
|
+
type AgentApiClientMethods = { [R in keyof AgentApiRawClient]: { [M in keyof AgentApiRawClient[R]]: AgentApiRawClient[R][M] extends AgentApiRawClientMethod<infer K> ? AgentApiClientMethod<K> : never; }; };
|
|
8688
|
+
interface AgentApiClientRequestOptions<K extends AgentApiRouteKey> {
|
|
8689
|
+
params?: AgentApiRequestParamsByRoute[K];
|
|
8690
|
+
query?: AgentApiRequestQueryByRoute[K];
|
|
8691
|
+
body?: AgentApiRequestBodyByRoute[K];
|
|
8692
|
+
}
|
|
8693
|
+
type AgentApiClient = AgentApiClientMethods & {
|
|
8694
|
+
request<K extends AgentApiRouteKey>(routeKey: K, options?: AgentApiClientRequestOptions<K>): Promise<AgentApiClientResult<K>>;
|
|
8695
|
+
};
|
|
8933
8696
|
type AgentApiAuthHeaders = Record<string, string>;
|
|
8934
8697
|
type AgentApiAuthStrategy = AgentApiAuthHeaders | ((request: AgentApiRawTransportRequest) => AgentApiAuthHeaders | Promise<AgentApiAuthHeaders>);
|
|
8935
8698
|
interface AgentApiFetchTransportOptions {
|
|
@@ -9044,24 +8807,12 @@ interface RaftRouteInfo extends RaftRouteMeta {
|
|
|
9044
8807
|
annotations: RaftRouteAnnotations;
|
|
9045
8808
|
}
|
|
9046
8809
|
/**
|
|
9047
|
-
* `routes.<resource>.<method>(
|
|
8810
|
+
* `routes.<resource>.<method>(params?, query?, body?)` for every route in the
|
|
9048
8811
|
* contract, plus route introspection. Reads retry (bounded); writes and
|
|
9049
8812
|
* destructive reads make exactly one attempt regardless of client retry
|
|
9050
8813
|
* settings, because the contract says repeating them is not safe.
|
|
9051
8814
|
*/
|
|
9052
|
-
type
|
|
9053
|
-
/**
|
|
9054
|
-
* The single input every route takes: `{ params, query, body }`, typed per
|
|
9055
|
-
* route. A part the route does not have is `never` (passing it is a compile
|
|
9056
|
-
* error); a part with required fields is a required property.
|
|
9057
|
-
*/
|
|
9058
|
-
type RaftRouteInput<K extends RaftRouteKey> = RoutePart<"params", AgentApiRequestParamsByRoute[K]> & RoutePart<"query", AgentApiRequestQueryByRoute[K]> & RoutePart<"body", AgentApiRequestBodyByRoute[K]>;
|
|
9059
|
-
type RaftRouteMethod<K extends RaftRouteKey> = {} extends RaftRouteInput<K> ? (input?: RaftRouteInput<K>) => Promise<RaftRouteResult<K>> : (input: RaftRouteInput<K>) => Promise<RaftRouteResult<K>>;
|
|
9060
|
-
/** `routes.<resource>.<method>({ params, query, body })` for every route in the contract. */
|
|
9061
|
-
type RaftRouteMethods = { [R in AgentApiRawClientResource]: { [M in AgentApiRawClientResourceMethod<R>]: RaftRouteMethod<AgentApiRouteKeyForClient<R, M>>; }; };
|
|
9062
|
-
type RaftRoutes = RaftRouteMethods & {
|
|
9063
|
-
/** The same call by route key: `request("actionPrepare", { body })`. */
|
|
9064
|
-
request<K extends RaftRouteKey>(routeKey: K, input?: RaftRouteInput<K>): Promise<RaftRouteResult<K>>;
|
|
8815
|
+
type RaftRoutes = AgentApiClient & {
|
|
9065
8816
|
/** Content hash of the route manifest this SDK was built against. */
|
|
9066
8817
|
manifestVersion: string;
|
|
9067
8818
|
/** Static description of one route: capability, side effect, idempotency, audience, retry policy. */
|
|
@@ -9082,7 +8833,12 @@ interface CreateRaftRoutesOptions {
|
|
|
9082
8833
|
beforeRequest?: infer F;
|
|
9083
8834
|
} | undefined ? F : never;
|
|
9084
8835
|
}
|
|
9085
|
-
/**
|
|
8836
|
+
/**
|
|
8837
|
+
* Build the routes layer over two transports: a retrying one for routes the
|
|
8838
|
+
* contract marks retry-safe, and a single-attempt one for everything else.
|
|
8839
|
+
* The split is decided per route from `AGENT_API_ROUTE_META`, never by the
|
|
8840
|
+
* caller and never by the HTTP method.
|
|
8841
|
+
*/
|
|
9086
8842
|
export declare function createRaftRoutes(options: CreateRaftRoutesOptions): RaftRoutes;
|
|
9087
8843
|
//#endregion
|
|
9088
8844
|
//#region src/context.d.ts
|
|
@@ -9192,7 +8948,7 @@ type RaftClient = AgentApiMessageClient & RaftManageClient & {
|
|
|
9192
8948
|
join(request: RaftChannelJoinRequest): Promise<RaftChannelJoinResult>;
|
|
9193
8949
|
};
|
|
9194
8950
|
/**
|
|
9195
|
-
* Every Agent API route as `routes.<resource>.<method>(
|
|
8951
|
+
* Every Agent API route as `routes.<resource>.<method>(params?, query?, body?)`,
|
|
9196
8952
|
* typed from the shared contract, with per-route metadata via `routes.describe`.
|
|
9197
8953
|
* Retry policy follows the contract: reads may retry, writes make one attempt.
|
|
9198
8954
|
*/
|
|
@@ -9327,22 +9083,6 @@ interface CreateRaftOptions {
|
|
|
9327
9083
|
* is held once and returns the unread context, which is the safe default.
|
|
9328
9084
|
*/
|
|
9329
9085
|
frontier?: SeenFrontierSnapshot | null;
|
|
9330
|
-
/**
|
|
9331
|
-
* Persist the client's state (committed and pending inbox cursors, the seen
|
|
9332
|
-
* frontier, held-send keys) across tool calls and processes. The store
|
|
9333
|
-
* implements `load()` and `save(state, { expectedVersion })`; the SDK loads
|
|
9334
|
-
* once before the first operation and saves after each successful operation
|
|
9335
|
-
* that changed the state (one attempt, never fails the operation).
|
|
9336
|
-
*/
|
|
9337
|
-
state?: RaftStateStore;
|
|
9338
|
-
/** Called when loading or saving the state fails or is rejected as stale. */
|
|
9339
|
-
onStateSaveError?: RaftStateSaveErrorHandler;
|
|
9340
|
-
}
|
|
9341
|
-
interface RaftInboxCommitResult {
|
|
9342
|
-
/** The committed cursor, or null when there was nothing to commit. */
|
|
9343
|
-
cursor: number | null;
|
|
9344
|
-
/** Whether the state was persisted (true when no store is configured). */
|
|
9345
|
-
saved: boolean;
|
|
9346
9086
|
}
|
|
9347
9087
|
interface Raft {
|
|
9348
9088
|
identity: {
|
|
@@ -9364,22 +9104,8 @@ interface Raft {
|
|
|
9364
9104
|
};
|
|
9365
9105
|
};
|
|
9366
9106
|
inbox: {
|
|
9367
|
-
/**
|
|
9368
|
-
* One bounded pull. Nothing is acknowledged by it. Without `since`, sends
|
|
9369
|
-
* the last committed cursor (from `state`), which is what acknowledges the
|
|
9370
|
-
* previously committed batch on the Server; the returned batch's cursor is
|
|
9371
|
-
* recorded as pending until you `commit()` it.
|
|
9372
|
-
*/
|
|
9107
|
+
/** One bounded pull. Nothing is acknowledged until the next call passes `data.cursor` as `since` (cursor mode). */
|
|
9373
9108
|
check(request?: CheckInboxRequest): Promise<CheckInboxOutcome>;
|
|
9374
|
-
/**
|
|
9375
|
-
* Mark a batch as processed. With no argument, commits the pending cursor
|
|
9376
|
-
* from the last `check()` (possibly in an earlier process, via `state`);
|
|
9377
|
-
* also accepts `{ cursor }` or a batch. Records only; the next `check()`
|
|
9378
|
-
* acknowledges it on the Server. The SDK never commits on its own.
|
|
9379
|
-
*/
|
|
9380
|
-
commit(target?: {
|
|
9381
|
-
cursor: number | null;
|
|
9382
|
-
}): Promise<RaftInboxCommitResult>;
|
|
9383
9109
|
/**
|
|
9384
9110
|
* Pull until the Server reports nothing more, like `raft message check`, as
|
|
9385
9111
|
* an async iterator: the pull that acknowledges a batch is only sent when
|
|
@@ -9397,141 +9123,16 @@ interface Raft {
|
|
|
9397
9123
|
send(request: SendMessageRequest): Promise<SendMessageOutcome>;
|
|
9398
9124
|
/** Reply where a received message came from. */
|
|
9399
9125
|
reply(message: Pick<RaftMessage, "target">, request: Omit<SendMessageRequest, "target">): Promise<SendMessageOutcome>;
|
|
9400
|
-
/** Find a specific message (`raft message search`); previews neutralise @handles and #channels. */
|
|
9401
|
-
search(request: SearchMessagesRequest): Promise<RaftOutcome<RaftSearchPage, "results" | "empty">>;
|
|
9402
|
-
/** Resolve one message id to its canonical form and reply target. */
|
|
9403
|
-
resolve(request: {
|
|
9404
|
-
messageId: string;
|
|
9405
|
-
}): Promise<RaftOutcome<RaftMessage, "message">>;
|
|
9406
|
-
react(request: ReactRequest): Promise<RaftOutcome<ReactRequest, "added" | "removed">>;
|
|
9407
|
-
unreact(request: ReactRequest): Promise<RaftOutcome<ReactRequest, "added" | "removed">>;
|
|
9408
|
-
};
|
|
9409
|
-
attachments: {
|
|
9410
|
-
/** Small-file multipart upload into a conversation; the upload alone posts nothing. */
|
|
9411
|
-
upload(request: UploadAttachmentRequest): Promise<RaftOutcome<RaftAttachmentUploaded, "uploaded">>;
|
|
9412
|
-
download(request: {
|
|
9413
|
-
attachmentId: string;
|
|
9414
|
-
}): Promise<RaftOutcome<RaftAttachmentBytes, "downloaded">>;
|
|
9415
|
-
comments(request: {
|
|
9416
|
-
attachmentId: string;
|
|
9417
|
-
limit?: number;
|
|
9418
|
-
}): Promise<RaftOutcome<AgentApiAttachmentCommentsResponse & {
|
|
9419
|
-
attachmentId: string;
|
|
9420
|
-
}, "comments" | "empty">>;
|
|
9421
|
-
};
|
|
9422
|
-
mentions: {
|
|
9423
|
-
/** @mentions you sent that reached nobody, with the recovery commands. */
|
|
9424
|
-
pending(request?: {
|
|
9425
|
-
limit?: number;
|
|
9426
|
-
}): Promise<RaftOutcome<RaftPendingMentions, "pending" | "empty">>;
|
|
9427
|
-
/** `notify` the target of an unreached mention, or `add` them to the conversation. */
|
|
9428
|
-
execute(request: ExecuteMentionActionRequest): Promise<RaftOutcome<{
|
|
9429
|
-
action: AgentMentionActionKind;
|
|
9430
|
-
results: AgentMentionActionResult[];
|
|
9431
|
-
}, "executed">>;
|
|
9432
|
-
/** Per-target delivery outcome for a message you sent. */
|
|
9433
|
-
deliveries(request: {
|
|
9434
|
-
messageId: string;
|
|
9435
|
-
}): Promise<RaftOutcome<AgentApiSenderMentionDeliveriesResponse, "deliveries" | "empty">>;
|
|
9436
|
-
};
|
|
9437
|
-
actions: {
|
|
9438
|
-
/**
|
|
9439
|
-
* Post an action card for a human to confirm (channel:create,
|
|
9440
|
-
* channel:add_member, agent:create, and the integration card types). The
|
|
9441
|
-
* human who clicks it executes it as themselves.
|
|
9442
|
-
*/
|
|
9443
|
-
prepare(request: PrepareActionCardRequest): Promise<RaftOutcome<RaftPreparedCard, "prepared">>;
|
|
9444
|
-
};
|
|
9445
|
-
manual: {
|
|
9446
|
-
/** Fetch a Manual topic; `intent` and `reason` are required and must never carry prompts, credentials, or message payloads. */
|
|
9447
|
-
get(request: {
|
|
9448
|
-
topic: string;
|
|
9449
|
-
} & ManualContext): Promise<RaftOutcome<AgentApiKnowledgeGetResponse, "topic">>;
|
|
9450
|
-
search(request: {
|
|
9451
|
-
query: string;
|
|
9452
|
-
scope?: string;
|
|
9453
|
-
} & ManualContext): Promise<RaftOutcome<AgentApiKnowledgeSearchResponse, "results" | "empty">>;
|
|
9454
9126
|
};
|
|
9455
9127
|
tasks: {
|
|
9456
9128
|
/** Claim before working. Refusals are rows, not exceptions; a hold comes back as `state: "held"` with `retry`. */
|
|
9457
9129
|
claim(request: ClaimTasksRequest): Promise<ClaimTasksOutcome>;
|
|
9458
|
-
/** A channel's task board, or your own tasks across channels with `mine: true`. */
|
|
9459
|
-
list(request: ListTasksRequest): Promise<RaftOutcome<RaftTaskBoard, "board" | "empty">>;
|
|
9460
|
-
create(request: CreateTasksRequest): Promise<RaftOutcome<RaftTasksCreated, "created">>;
|
|
9461
|
-
unclaim(request: TaskRef): Promise<RaftOutcome<TaskRef, "unclaimed">>;
|
|
9462
|
-
assign(request: AssignTaskRequest): Promise<RaftOutcome<{
|
|
9463
|
-
target: string;
|
|
9464
|
-
taskNumber: number;
|
|
9465
|
-
assignee: string | null;
|
|
9466
|
-
revision: number;
|
|
9467
|
-
}, "assigned" | "unassigned">>;
|
|
9468
|
-
/** todo → in_progress → in_review → done; `closed` from anywhere. A hold comes back as `state: "held"` with `data.request`. */
|
|
9469
|
-
updateStatus(request: UpdateTaskStatusRequest): Promise<UpdateTaskStatusOutcome>;
|
|
9470
|
-
amend(request: AmendTaskRequest): Promise<AmendTaskOutcome>;
|
|
9471
|
-
history(request: TaskRef): Promise<RaftOutcome<AgentApiTaskHistoryResponse & {
|
|
9472
|
-
target: string;
|
|
9473
|
-
}, "history">>;
|
|
9474
|
-
/** Convert a top-level message into an unassigned task. */
|
|
9475
|
-
convert(request: {
|
|
9476
|
-
target: string;
|
|
9477
|
-
messageId: string;
|
|
9478
|
-
}): Promise<RaftOutcome<{
|
|
9479
|
-
target: string;
|
|
9480
|
-
task: AgentApiTaskCreateResponse["tasks"][number];
|
|
9481
|
-
}, "converted">>;
|
|
9482
|
-
delete(request: TaskRef): Promise<RaftOutcome<TaskRef, "deleted">>;
|
|
9483
|
-
};
|
|
9484
|
-
channels: {
|
|
9485
|
-
/** Explicit, idempotent. Never a side effect of sending. */
|
|
9486
|
-
join(request: {
|
|
9487
|
-
target: string;
|
|
9488
|
-
}): Promise<RaftOutcome<RaftChannelRef, "joined" | "already_joined">>;
|
|
9489
|
-
leave(request: {
|
|
9490
|
-
target: string;
|
|
9491
|
-
}): Promise<RaftOutcome<RaftChannelRef, "left" | "not_joined">>;
|
|
9492
|
-
/** Mute ordinary Activity delivery; @mentions, DMs, and followed threads still arrive. */
|
|
9493
|
-
mute(request: {
|
|
9494
|
-
target: string;
|
|
9495
|
-
}): Promise<RaftOutcome<RaftChannelMuteState, "muted" | "unmuted">>;
|
|
9496
|
-
unmute(request: {
|
|
9497
|
-
target: string;
|
|
9498
|
-
}): Promise<RaftOutcome<RaftChannelMuteState, "muted" | "unmuted">>;
|
|
9499
|
-
members(request: {
|
|
9500
|
-
target: string;
|
|
9501
|
-
}): Promise<RaftOutcome<AgentApiChannelMembersResponse, "members">>;
|
|
9502
|
-
};
|
|
9503
|
-
threads: {
|
|
9504
|
-
list(): Promise<RaftOutcome<AgentApiThreadListItem[], "threads" | "empty">>;
|
|
9505
|
-
unfollow(request: {
|
|
9506
|
-
target: string;
|
|
9507
|
-
reason?: string;
|
|
9508
|
-
}): Promise<RaftOutcome<{
|
|
9509
|
-
target: string;
|
|
9510
|
-
}, "unfollowed">>;
|
|
9511
|
-
};
|
|
9512
|
-
server: {
|
|
9513
|
-
/** Summary by default; `view: "channels" | "agents" | "humans"` pages a section; `view: "full"` is the whole overview. */
|
|
9514
|
-
info(request?: ServerInfoRequest): Promise<RaftOutcome<RaftServerInfo, "info">>;
|
|
9515
|
-
};
|
|
9516
|
-
profile: {
|
|
9517
|
-
show(request?: {
|
|
9518
|
-
target?: string;
|
|
9519
|
-
}): Promise<RaftOutcome<AgentApiProfileView, "profile">>;
|
|
9520
|
-
update(request: AgentApiProfileUpdateBody): Promise<RaftOutcome<AgentApiProfileView, "updated">>;
|
|
9521
9130
|
};
|
|
9522
9131
|
/** What this process has shown its model, per target; export it to survive restarts. */
|
|
9523
9132
|
frontier: SeenFrontier;
|
|
9524
|
-
state: {
|
|
9525
|
-
/** Save now (for example after `frontier.recordHeld`). Best effort; returns whether it succeeded. */
|
|
9526
|
-
save(): Promise<boolean>;
|
|
9527
|
-
/** Load the persisted state now (operations do this automatically). */
|
|
9528
|
-
load(): Promise<void>;
|
|
9529
|
-
/** The current state value, as it would be saved. */
|
|
9530
|
-
snapshot(): RaftState;
|
|
9531
|
-
};
|
|
9532
9133
|
/** Every Agent API route, typed from the shared contract. */
|
|
9533
9134
|
routes: RaftRoutes;
|
|
9534
9135
|
}
|
|
9535
9136
|
export declare function createRaft(options: CreateRaftOptions): Raft;
|
|
9536
9137
|
//#endregion
|
|
9537
|
-
export type {
|
|
9138
|
+
export type { BootstrapRaftCredentialOptions, CheckInboxOutcome, CheckInboxRequest, ClaimTasksOutcome, ClaimTasksRequest, CreateRaftClientFromStoreOptions, CreateRaftClientOptions, CreateRaftOptions, CreateRaftRoutesOptions, DrainInboxRequest, ListInboxRequest, Raft, RaftAckMode, RaftActionPrepareRequest, RaftActionPrepared, RaftApiError, RaftApiResult, RaftAppConfig, RaftAppConfigPatch, RaftAvatarUpload, RaftChannelJoinClient, RaftChannelJoinClientResult, RaftChannelJoinError, RaftChannelJoinFailure, RaftChannelJoinOperation, RaftChannelJoinRequest, RaftChannelJoinResult, RaftChannelJoinSuccess, RaftChannelJoinTransportError, RaftClaimHeld, 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, RaftHeld, RaftHeldBase, RaftHistoryPage, RaftInboxBatch, RaftInboxConversation, RaftInboxDrainSummary, RaftInboxListing, RaftInboxNotice, RaftManageClient, RaftMessage, RaftMessageAttachment, RaftMessageTask, RaftNextStep, RaftNoticeFlag, RaftNoticeTarget, RaftOpError, RaftOpErrorCode, RaftOutcome, RaftProfile, RaftProfileUpdate, RaftRouteAnnotations, RaftRouteInfo, RaftRouteKey, RaftRouteMeta, RaftRouteResult, RaftRouteRetryPolicy, RaftRoutes, RaftSdkConfigurationErrorCode, RaftSendContinuation, RaftSenderType, RaftSent, RaftServerProfile, RaftServerUpdate, RaftWebhookStatus, ReadHistoryRequest, SeenAttestation, SeenFrontierSnapshot, SendMessageOutcome, SendMessageRequest, StoredRaftCredential, VerifyNoticeInput, VerifyNoticeRejection, VerifyNoticeResult };
|