@effect-agent/platform-cloudflare 0.1.0-beta.76 → 0.1.0-beta.78
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/BrowserRestCapture.mjs +1 -1
- package/dist/CloudflareAiGateway.d.mts +64 -0
- package/dist/CloudflareAiGateway.mjs +70 -0
- package/dist/CloudflareAiGateway.mjs.map +1 -0
- package/dist/{CloudflareBrowser-Bj22nNUT.mjs → CloudflareBrowser-BSJRWmlW.mjs} +23 -7
- package/dist/CloudflareBrowser-BSJRWmlW.mjs.map +1 -0
- package/dist/CloudflareBrowser.mjs +1 -1
- package/dist/CloudflareMemory.d.mts +3 -1
- package/dist/CloudflareMemory.mjs +28 -1
- package/dist/CloudflareMemory.mjs.map +1 -1
- package/dist/CloudflareThreadClient.d.mts +62 -44
- package/dist/{ThreadObject-usUi-TqH.d.mts → ThreadObject-D7G1M59T.d.mts} +32 -32
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +3 -2
- package/package.json +1 -1
- package/src/CloudflareAiGateway.ts +170 -0
- package/src/CloudflareMemory.ts +48 -1
- package/src/index.ts +1 -0
- package/src/internal/browser-quick-action.ts +24 -7
- package/dist/CloudflareBrowser-Bj22nNUT.mjs.map +0 -1
|
@@ -340,13 +340,13 @@ declare const encodeUnknownResolutionCommand: (input: UnknownResolutionCommand,
|
|
|
340
340
|
readonly author: string;
|
|
341
341
|
readonly reason: string;
|
|
342
342
|
readonly resolution: {
|
|
343
|
+
readonly _tag: "SafeToRetry";
|
|
344
|
+
} | {
|
|
343
345
|
readonly _tag: "CompletedWithResult";
|
|
344
346
|
readonly result: Schema.Json;
|
|
345
347
|
readonly isFailure: boolean;
|
|
346
348
|
} | {
|
|
347
349
|
readonly _tag: "NeverHappened";
|
|
348
|
-
} | {
|
|
349
|
-
readonly _tag: "SafeToRetry";
|
|
350
350
|
} | {
|
|
351
351
|
readonly _tag: "AbortSubmission";
|
|
352
352
|
};
|
|
@@ -482,6 +482,11 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
482
482
|
readonly createdAt: string;
|
|
483
483
|
readonly deploymentId: string;
|
|
484
484
|
readonly payload: {
|
|
485
|
+
readonly _tag: "AbortRequested";
|
|
486
|
+
readonly submissionId: string;
|
|
487
|
+
readonly author: string;
|
|
488
|
+
readonly reason: string;
|
|
489
|
+
} | {
|
|
485
490
|
readonly _tag: "ThreadCreated";
|
|
486
491
|
readonly agentId: string;
|
|
487
492
|
readonly definitions: {
|
|
@@ -656,11 +661,6 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
656
661
|
readonly runDisposition?: Schema.Json | undefined;
|
|
657
662
|
readonly finishReason?: "budget-exhausted" | undefined;
|
|
658
663
|
readonly exhausted?: "tokens" | "tool-calls" | "turns" | undefined;
|
|
659
|
-
} | {
|
|
660
|
-
readonly _tag: "AbortRequested";
|
|
661
|
-
readonly submissionId: string;
|
|
662
|
-
readonly author: string;
|
|
663
|
-
readonly reason: string;
|
|
664
664
|
} | {
|
|
665
665
|
readonly _tag: "SubmissionSettled";
|
|
666
666
|
readonly submissionId: string;
|
|
@@ -806,6 +806,24 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
806
806
|
readonly childResultDigest: string;
|
|
807
807
|
readonly projectedResultDigest: string;
|
|
808
808
|
readonly usageSummary: Schema.Json;
|
|
809
|
+
readonly usage?: {
|
|
810
|
+
readonly modelCalls: number;
|
|
811
|
+
readonly inputTokens: number;
|
|
812
|
+
readonly outputTokens: number;
|
|
813
|
+
readonly costMicrousd: number;
|
|
814
|
+
readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
|
|
815
|
+
readonly pricingStatus?: "complete" | "partial" | "unknown" | undefined;
|
|
816
|
+
readonly unobservedModelCalls?: number | undefined;
|
|
817
|
+
} | undefined;
|
|
818
|
+
readonly delegatedUsage?: {
|
|
819
|
+
readonly modelCalls: number;
|
|
820
|
+
readonly inputTokens: number;
|
|
821
|
+
readonly outputTokens: number;
|
|
822
|
+
readonly costMicrousd: number;
|
|
823
|
+
readonly usageStatus?: "complete" | "partial" | "unknown" | undefined;
|
|
824
|
+
readonly pricingStatus?: "complete" | "partial" | "unknown" | undefined;
|
|
825
|
+
readonly unobservedModelCalls?: number | undefined;
|
|
826
|
+
} | undefined;
|
|
809
827
|
readonly reservationId: string;
|
|
810
828
|
readonly finalAccounting: Schema.Json;
|
|
811
829
|
} | {
|
|
@@ -1104,13 +1122,13 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1104
1122
|
readonly author: string;
|
|
1105
1123
|
readonly reason: string;
|
|
1106
1124
|
readonly resolution: {
|
|
1125
|
+
readonly _tag: "SafeToRetry";
|
|
1126
|
+
} | {
|
|
1107
1127
|
readonly _tag: "CompletedWithResult";
|
|
1108
1128
|
readonly result: Schema.Json;
|
|
1109
1129
|
readonly isFailure: boolean;
|
|
1110
1130
|
} | {
|
|
1111
1131
|
readonly _tag: "NeverHappened";
|
|
1112
|
-
} | {
|
|
1113
|
-
readonly _tag: "SafeToRetry";
|
|
1114
1132
|
} | {
|
|
1115
1133
|
readonly _tag: "AbortSubmission";
|
|
1116
1134
|
};
|
|
@@ -1120,33 +1138,8 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1120
1138
|
} | {
|
|
1121
1139
|
readonly _tag: "HostFailed";
|
|
1122
1140
|
readonly failure: {
|
|
1123
|
-
readonly _tag: "DurableAlarmError";
|
|
1124
|
-
readonly operation: string;
|
|
1125
|
-
readonly message: string;
|
|
1126
|
-
readonly cause?: Schema.Json | undefined;
|
|
1127
|
-
} | {
|
|
1128
|
-
readonly _tag: "ThreadNotMaterialized";
|
|
1129
|
-
readonly threadId: string;
|
|
1130
|
-
} | {
|
|
1131
|
-
readonly _tag: "ThreadStoreError";
|
|
1132
|
-
readonly operation: string;
|
|
1133
|
-
readonly message: string;
|
|
1134
|
-
readonly cause?: Schema.Json | undefined;
|
|
1135
|
-
} | {
|
|
1136
|
-
readonly _tag: "LedgerError";
|
|
1137
|
-
readonly operation: string;
|
|
1138
|
-
readonly message: string;
|
|
1139
|
-
readonly cause?: Schema.Json | undefined;
|
|
1140
|
-
} | {
|
|
1141
1141
|
readonly _tag: "HostProtocolError";
|
|
1142
1142
|
readonly message: string;
|
|
1143
|
-
} | {
|
|
1144
|
-
readonly _tag: "AgentInputError";
|
|
1145
|
-
readonly message: string;
|
|
1146
|
-
} | {
|
|
1147
|
-
readonly _tag: "DigestError";
|
|
1148
|
-
readonly message: string;
|
|
1149
|
-
readonly cause?: Schema.Json | undefined;
|
|
1150
1143
|
} | {
|
|
1151
1144
|
readonly _tag: "AdmissionConflict";
|
|
1152
1145
|
readonly threadId: string;
|
|
@@ -1162,19 +1155,23 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1162
1155
|
readonly _tag: "SettlementConflict";
|
|
1163
1156
|
readonly submissionId: string;
|
|
1164
1157
|
readonly existingOutcome: "aborted" | "completed" | "failed";
|
|
1165
|
-
} | {
|
|
1166
|
-
readonly _tag: "ApprovalConflict";
|
|
1167
|
-
readonly submissionId: string;
|
|
1168
|
-
readonly toolCallId: string;
|
|
1169
|
-
readonly existingDecision: "approved" | "denied";
|
|
1170
|
-
} | {
|
|
1171
|
-
readonly _tag: "UnknownResolutionConflict";
|
|
1172
|
-
readonly submissionId: string;
|
|
1173
|
-
readonly toolCallId: string;
|
|
1174
1158
|
} | {
|
|
1175
1159
|
readonly _tag: "JoinedToHost";
|
|
1176
1160
|
readonly submissionId: string;
|
|
1177
1161
|
readonly hostSubmissionId: string;
|
|
1162
|
+
} | {
|
|
1163
|
+
readonly _tag: "LedgerError";
|
|
1164
|
+
readonly operation: string;
|
|
1165
|
+
readonly message: string;
|
|
1166
|
+
readonly cause?: Schema.Json | undefined;
|
|
1167
|
+
} | {
|
|
1168
|
+
readonly _tag: "ThreadStoreError";
|
|
1169
|
+
readonly operation: string;
|
|
1170
|
+
readonly message: string;
|
|
1171
|
+
readonly cause?: Schema.Json | undefined;
|
|
1172
|
+
} | {
|
|
1173
|
+
readonly _tag: "ThreadNotMaterialized";
|
|
1174
|
+
readonly threadId: string;
|
|
1178
1175
|
} | {
|
|
1179
1176
|
readonly _tag: "AppendConflict";
|
|
1180
1177
|
readonly threadId: string;
|
|
@@ -1187,14 +1184,35 @@ declare const encodeHostResponse: (input: AbortRecorded | ApprovalRecorded | Hos
|
|
|
1187
1184
|
readonly threadId: string;
|
|
1188
1185
|
readonly actualEpoch: number;
|
|
1189
1186
|
readonly attemptedEpoch: number;
|
|
1187
|
+
} | {
|
|
1188
|
+
readonly _tag: "AgentInputError";
|
|
1189
|
+
readonly message: string;
|
|
1190
|
+
} | {
|
|
1191
|
+
readonly _tag: "DigestError";
|
|
1192
|
+
readonly message: string;
|
|
1193
|
+
readonly cause?: Schema.Json | undefined;
|
|
1194
|
+
} | {
|
|
1195
|
+
readonly _tag: "ApprovalConflict";
|
|
1196
|
+
readonly submissionId: string;
|
|
1197
|
+
readonly toolCallId: string;
|
|
1198
|
+
readonly existingDecision: "approved" | "denied";
|
|
1199
|
+
} | {
|
|
1200
|
+
readonly _tag: "UnknownResolutionConflict";
|
|
1201
|
+
readonly submissionId: string;
|
|
1202
|
+
readonly toolCallId: string;
|
|
1190
1203
|
} | {
|
|
1191
1204
|
readonly _tag: "DurableRuntimeFailpointError";
|
|
1192
|
-
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-start-append" | "run:before-start-append" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "tools:before-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-subtree-append";
|
|
1205
|
+
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-start-append" | "run:before-start-append" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "subagent:before-join-append" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "tools:before-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-subtree-append";
|
|
1193
1206
|
} | {
|
|
1194
1207
|
readonly _tag: "AdmissionLimitExceeded";
|
|
1195
1208
|
readonly limit: "database-bytes" | "input-bytes" | "queue-depth";
|
|
1196
1209
|
readonly actual: number;
|
|
1197
1210
|
readonly maximum: number;
|
|
1211
|
+
} | {
|
|
1212
|
+
readonly _tag: "DurableAlarmError";
|
|
1213
|
+
readonly operation: string;
|
|
1214
|
+
readonly message: string;
|
|
1215
|
+
readonly cause?: Schema.Json | undefined;
|
|
1198
1216
|
} | {
|
|
1199
1217
|
readonly _tag: "OperationDenied";
|
|
1200
1218
|
readonly operation: "abort" | "awaitSettlement" | "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
|
|
@@ -668,14 +668,38 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
668
668
|
} | {
|
|
669
669
|
readonly _tag: "AdminFailed";
|
|
670
670
|
readonly failure: {
|
|
671
|
-
readonly _tag: "
|
|
671
|
+
readonly _tag: "AdmissionPolicyError";
|
|
672
|
+
readonly reason: "occupied" | "refused" | "unavailable";
|
|
673
|
+
readonly code: string;
|
|
674
|
+
} | {
|
|
675
|
+
readonly _tag: "SettlementConflict";
|
|
676
|
+
readonly submissionId: string;
|
|
677
|
+
readonly existingOutcome: "aborted" | "completed" | "failed";
|
|
678
|
+
} | {
|
|
679
|
+
readonly _tag: "LedgerError";
|
|
672
680
|
readonly operation: string;
|
|
673
681
|
readonly message: string;
|
|
674
682
|
readonly cause?: Schema.Json | undefined;
|
|
675
683
|
} | {
|
|
676
|
-
readonly _tag: "
|
|
677
|
-
readonly
|
|
678
|
-
readonly
|
|
684
|
+
readonly _tag: "ThreadStoreError";
|
|
685
|
+
readonly operation: string;
|
|
686
|
+
readonly message: string;
|
|
687
|
+
readonly cause?: Schema.Json | undefined;
|
|
688
|
+
} | {
|
|
689
|
+
readonly _tag: "ThreadNotMaterialized";
|
|
690
|
+
readonly threadId: string;
|
|
691
|
+
} | {
|
|
692
|
+
readonly _tag: "AppendConflict";
|
|
693
|
+
readonly threadId: string;
|
|
694
|
+
readonly batchId: string;
|
|
695
|
+
readonly reason: "batch-digest" | "record-identity" | "tail";
|
|
696
|
+
readonly actualTailSequence?: number | undefined;
|
|
697
|
+
readonly actualTailDigest?: string | undefined;
|
|
698
|
+
} | {
|
|
699
|
+
readonly _tag: "FenceRejected";
|
|
700
|
+
readonly threadId: string;
|
|
701
|
+
readonly actualEpoch: number;
|
|
702
|
+
readonly attemptedEpoch: number;
|
|
679
703
|
} | {
|
|
680
704
|
readonly _tag: "OperationDenied";
|
|
681
705
|
readonly operation: "abort" | "awaitSettlement" | "explain" | "observe" | "resolveApproval" | "resolveUnknown" | "retry" | "scanObligations" | "verify" | "wake";
|
|
@@ -688,11 +712,6 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
688
712
|
readonly refusal: "await-approval-decision" | "await-unknown-resolution" | "settled";
|
|
689
713
|
readonly decisionTag: string;
|
|
690
714
|
readonly message: string;
|
|
691
|
-
} | {
|
|
692
|
-
readonly _tag: "LedgerError";
|
|
693
|
-
readonly operation: string;
|
|
694
|
-
readonly message: string;
|
|
695
|
-
readonly cause?: Schema.Json | undefined;
|
|
696
715
|
} | {
|
|
697
716
|
readonly _tag: "RunJournalError";
|
|
698
717
|
readonly message: string;
|
|
@@ -706,32 +725,13 @@ declare const encodeAdminResponse: (input: AdminFailed | ExplainedRecovery | Obl
|
|
|
706
725
|
readonly submissionId: string;
|
|
707
726
|
readonly actualEpoch: number;
|
|
708
727
|
} | {
|
|
709
|
-
readonly _tag: "
|
|
710
|
-
readonly
|
|
711
|
-
readonly existingOutcome: "aborted" | "completed" | "failed";
|
|
728
|
+
readonly _tag: "DurableRuntimeFailpointError";
|
|
729
|
+
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-start-append" | "run:before-start-append" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "subagent:before-join-append" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "tools:before-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-subtree-append";
|
|
712
730
|
} | {
|
|
713
|
-
readonly _tag: "
|
|
731
|
+
readonly _tag: "DurableAlarmError";
|
|
714
732
|
readonly operation: string;
|
|
715
733
|
readonly message: string;
|
|
716
734
|
readonly cause?: Schema.Json | undefined;
|
|
717
|
-
} | {
|
|
718
|
-
readonly _tag: "ThreadNotMaterialized";
|
|
719
|
-
readonly threadId: string;
|
|
720
|
-
} | {
|
|
721
|
-
readonly _tag: "AppendConflict";
|
|
722
|
-
readonly threadId: string;
|
|
723
|
-
readonly batchId: string;
|
|
724
|
-
readonly reason: "batch-digest" | "record-identity" | "tail";
|
|
725
|
-
readonly actualTailSequence?: number | undefined;
|
|
726
|
-
readonly actualTailDigest?: string | undefined;
|
|
727
|
-
} | {
|
|
728
|
-
readonly _tag: "FenceRejected";
|
|
729
|
-
readonly threadId: string;
|
|
730
|
-
readonly actualEpoch: number;
|
|
731
|
-
readonly attemptedEpoch: number;
|
|
732
|
-
} | {
|
|
733
|
-
readonly _tag: "DurableRuntimeFailpointError";
|
|
734
|
-
readonly location: "abort:after-intent" | "approval:after-request-append" | "approval:after-suspend" | "checkpoint:after-save" | "checkpoint:before-save" | "claim:after-claim" | "compaction:after-canonical-append" | "compaction:before-canonical-append" | "input:after-canonical-append" | "join:after-canonical-append" | "join:after-claim" | "policy:after-reservation-append" | "policy:before-reservation-append" | "resolve:after-intent" | "run:after-start-append" | "run:before-start-append" | "step:after-step-append" | "subagent:after-admit" | "subagent:after-child-abort-intent" | "subagent:after-child-ready" | "subagent:after-join-append" | "subagent:after-release" | "subagent:after-release-pending" | "subagent:after-request-append" | "subagent:after-reserve" | "subagent:after-sibling-settle" | "subagent:after-start-append" | "subagent:after-suspend" | "submit:after-admit" | "submit:after-materialize" | "terminalize:after-canonical-append" | "terminalize:after-reserve" | "tools:after-prepared-append" | "tools:before-prepared-append" | "turn:after-canonical-append" | "turn:after-response-append" | "turn:after-results-append" | "worker:after-completion-append" | "worker:after-origin-append" | "worker:after-report-append" | "worker:after-report-delivery" | "worker:after-source-append" | "worker:after-subtree-append" | "worker:before-completion-append" | "worker:before-origin-append" | "worker:before-report-append" | "worker:before-report-delivery" | "worker:before-source-append" | "worker:before-subtree-append";
|
|
735
735
|
} | {
|
|
736
736
|
readonly _tag: "HostProtocolError";
|
|
737
737
|
readonly message: string;
|
|
@@ -775,4 +775,4 @@ interface Class<EventServices = never> {
|
|
|
775
775
|
declare const make: <ApplicationServices, ApplicationError, EventServices = never, EventLayerError = never>(applicationLayer: Layer.Layer<CloudflareDurableRuntimeServices | ApplicationServices, ApplicationError, CloudflareBootstrapServices | DurableObjectState$1.DurableObjectState | WorkerEnvironment | DurableObjectContext | ThreadObjectNamespace>, options: Options<ApplicationServices, EventServices, EventLayerError>) => Class<ApplicationServices | EventServices>;
|
|
776
776
|
//#endregion
|
|
777
777
|
export { CloudflareDurableRuntimeOptions as C, layerConfig as D, layer as E, CloudflareDurableRuntimeInitializationError as S, ThreadPublicationOptions as T, decodeObligationThresholds as _, AdminVerifyRequest as a, make as b, Instance as c, RetryExecuted as d, ThreadObject_d_exports as f, decodeAdminVerifyRequest as g, decodeAdminResponse as h, AdminResponse as i, ObligationsScanned as l, decodeAdminExplainRequest as m, AdminFailed as n, Class as o, VerifiedIntegrity as p, AdminFailure as r, ExplainedRecovery as s, AdminExplainRequest as t, Options as u, decodeRetryCommand as v, CloudflareDurableRuntimeServices as w, CloudflareBootstrapServices as x, encodeAdminResponse as y };
|
|
778
|
-
//# sourceMappingURL=ThreadObject-
|
|
778
|
+
//# sourceMappingURL=ThreadObject-D7G1M59T.d.mts.map
|
package/dist/ThreadObject.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as CloudflareDurableRuntimeOptions, D as layerConfig, E as layer, S as CloudflareDurableRuntimeInitializationError, T as ThreadPublicationOptions, _ as decodeObligationThresholds, a as AdminVerifyRequest, b as make, c as Instance, d as RetryExecuted, g as decodeAdminVerifyRequest, h as decodeAdminResponse, i as AdminResponse, l as ObligationsScanned, m as decodeAdminExplainRequest, n as AdminFailed, o as Class, p as VerifiedIntegrity, r as AdminFailure, s as ExplainedRecovery, t as AdminExplainRequest, u as Options, v as decodeRetryCommand, w as CloudflareDurableRuntimeServices, x as CloudflareBootstrapServices, y as encodeAdminResponse } from "./ThreadObject-
|
|
1
|
+
import { C as CloudflareDurableRuntimeOptions, D as layerConfig, E as layer, S as CloudflareDurableRuntimeInitializationError, T as ThreadPublicationOptions, _ as decodeObligationThresholds, a as AdminVerifyRequest, b as make, c as Instance, d as RetryExecuted, g as decodeAdminVerifyRequest, h as decodeAdminResponse, i as AdminResponse, l as ObligationsScanned, m as decodeAdminExplainRequest, n as AdminFailed, o as Class, p as VerifiedIntegrity, r as AdminFailure, s as ExplainedRecovery, t as AdminExplainRequest, u as Options, v as decodeRetryCommand, w as CloudflareDurableRuntimeServices, x as CloudflareBootstrapServices, y as encodeAdminResponse } from "./ThreadObject-D7G1M59T.mjs";
|
|
2
2
|
export { AdminExplainRequest, AdminFailed, AdminFailure, AdminResponse, AdminVerifyRequest, type CloudflareBootstrapServices as BootstrapServices, Class, ExplainedRecovery, type CloudflareDurableRuntimeInitializationError as InitializationError, Instance, ObligationsScanned, Options, type ThreadPublicationOptions as PublicationOptions, RetryExecuted, type CloudflareDurableRuntimeOptions as RuntimeOptions, type CloudflareDurableRuntimeServices as Services, VerifiedIntegrity, decodeAdminExplainRequest, decodeAdminResponse, decodeAdminVerifyRequest, decodeObligationThresholds, decodeRetryCommand, encodeAdminResponse, layer, layerConfig, make };
|
package/dist/index.d.mts
CHANGED
|
@@ -2,11 +2,12 @@ import { t as CloudflareBindings_d_exports } from "./CloudflareBindings.mjs";
|
|
|
2
2
|
import { a as CloudflareConfig_d_exports } from "./CloudflareConfig-f3CqTel1.mjs";
|
|
3
3
|
import { t as Alarm_d_exports } from "./Alarm.mjs";
|
|
4
4
|
import { t as CloudflareBrowser_d_exports } from "./CloudflareBrowser-DJq53niJ.mjs";
|
|
5
|
+
import { t as CloudflareAiGateway_d_exports } from "./CloudflareAiGateway.mjs";
|
|
5
6
|
import { t as CloudflareCodeMode_d_exports } from "./CloudflareCodeMode.mjs";
|
|
6
7
|
import { t as CloudflareMemory_d_exports } from "./CloudflareMemory.mjs";
|
|
7
8
|
import { t as CloudflareScheduling_d_exports } from "./CloudflareScheduling.mjs";
|
|
8
9
|
import { t as CloudflareSubscriptions_d_exports } from "./CloudflareSubscriptions.mjs";
|
|
9
10
|
import { t as CloudflareThreadClient_d_exports } from "./CloudflareThreadClient.mjs";
|
|
10
|
-
import { f as ThreadObject_d_exports } from "./ThreadObject-
|
|
11
|
+
import { f as ThreadObject_d_exports } from "./ThreadObject-D7G1M59T.mjs";
|
|
11
12
|
import { t as WakeScheduler_d_exports } from "./WakeScheduler.mjs";
|
|
12
|
-
export { Alarm_d_exports as Alarm, CloudflareBindings_d_exports as CloudflareBindings, CloudflareBrowser_d_exports as CloudflareBrowser, CloudflareCodeMode_d_exports as CloudflareCodeMode, CloudflareConfig_d_exports as CloudflareConfig, CloudflareMemory_d_exports as CloudflareMemory, CloudflareScheduling_d_exports as CloudflareScheduling, CloudflareSubscriptions_d_exports as CloudflareSubscriptions, CloudflareThreadClient_d_exports as CloudflareThreadClient, ThreadObject_d_exports as ThreadObject, WakeScheduler_d_exports as WakeScheduler };
|
|
13
|
+
export { Alarm_d_exports as Alarm, CloudflareAiGateway_d_exports as CloudflareAiGateway, CloudflareBindings_d_exports as CloudflareBindings, CloudflareBrowser_d_exports as CloudflareBrowser, CloudflareCodeMode_d_exports as CloudflareCodeMode, CloudflareConfig_d_exports as CloudflareConfig, CloudflareMemory_d_exports as CloudflareMemory, CloudflareScheduling_d_exports as CloudflareScheduling, CloudflareSubscriptions_d_exports as CloudflareSubscriptions, CloudflareThreadClient_d_exports as CloudflareThreadClient, ThreadObject_d_exports as ThreadObject, WakeScheduler_d_exports as WakeScheduler };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as CloudflareBindings_exports } from "./CloudflareBindings.mjs";
|
|
2
2
|
import { t as CloudflareConfig_exports } from "./CloudflareConfig.mjs";
|
|
3
3
|
import { t as Alarm_exports } from "./Alarm.mjs";
|
|
4
|
-
import { t as CloudflareBrowser_exports } from "./CloudflareBrowser-
|
|
4
|
+
import { t as CloudflareBrowser_exports } from "./CloudflareBrowser-BSJRWmlW.mjs";
|
|
5
5
|
import { t as CloudflareCodeMode_exports } from "./CloudflareCodeMode.mjs";
|
|
6
6
|
import { t as CloudflareMemory_exports } from "./CloudflareMemory.mjs";
|
|
7
7
|
import { t as CloudflareThreadClient_exports } from "./CloudflareThreadClient.mjs";
|
|
@@ -9,4 +9,5 @@ import { t as CloudflareScheduling_exports } from "./CloudflareScheduling.mjs";
|
|
|
9
9
|
import { t as CloudflareSubscriptions_exports } from "./CloudflareSubscriptions.mjs";
|
|
10
10
|
import { t as WakeScheduler_exports } from "./WakeScheduler.mjs";
|
|
11
11
|
import { l as ThreadObject_exports } from "./ThreadObject-KJf_5Isr.mjs";
|
|
12
|
-
|
|
12
|
+
import { t as CloudflareAiGateway_exports } from "./CloudflareAiGateway.mjs";
|
|
13
|
+
export { Alarm_exports as Alarm, CloudflareAiGateway_exports as CloudflareAiGateway, CloudflareBindings_exports as CloudflareBindings, CloudflareBrowser_exports as CloudflareBrowser, CloudflareCodeMode_exports as CloudflareCodeMode, CloudflareConfig_exports as CloudflareConfig, CloudflareMemory_exports as CloudflareMemory, CloudflareScheduling_exports as CloudflareScheduling, CloudflareSubscriptions_exports as CloudflareSubscriptions, CloudflareThreadClient_exports as CloudflareThreadClient, ThreadObject_exports as ThreadObject, WakeScheduler_exports as WakeScheduler };
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@effect-agent/platform-cloudflare","version":"0.1.0-beta.
|
|
1
|
+
{"name":"@effect-agent/platform-cloudflare","version":"0.1.0-beta.78","dependencies":{"@effect-agent/core":"0.1.0-beta.78","@effect-agent/engine":"0.1.0-beta.78","@effect-agent/sandbox":"0.1.0-beta.78","@effect-agent/storage-cloudflare":"0.1.0-beta.78","@effect-agent/thread":"0.1.0-beta.78","@effect/platform-browser":"4.0.0-rc.112","@effect/sql-sqlite-do":"4.0.0-rc.112"},"devDependencies":{"@cloudflare/puppeteer":"1.1.0","@cloudflare/vitest-pool-workers":"0.21.3","@cloudflare/workers-types":"5.20260825.1","@effect-agent/capabilities":"0.1.0-beta.78","@effect-agent/testing":"0.1.0-beta.78","@effect/platform-node":"4.0.0-rc.112","@effect/sql-d1":"4.0.0-rc.112","@effect/vitest":"4.0.0-rc.112","effect":"4.0.0-rc.112","effect-cf":"0.40.0","esbuild":"0.28.1","miniflare":"5.20260811.1-alpha","typescript":"7.0.2","vite-plus":"0.3.0","vitest":"4.1.11"},"peerDependencies":{"@cloudflare/puppeteer":"^1.1.0","effect":"^4.0.0-rc.112","effect-cf":"^0.40.0"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./Alarm":{"types":"./dist/Alarm.d.mts","default":"./dist/Alarm.mjs"},"./BrowserRestCapture":{"types":"./dist/BrowserRestCapture.d.mts","default":"./dist/BrowserRestCapture.mjs"},"./BrowserRestCrawl":{"types":"./dist/BrowserRestCrawl.d.mts","default":"./dist/BrowserRestCrawl.mjs"},"./CloudflareBindings":{"types":"./dist/CloudflareBindings.d.mts","default":"./dist/CloudflareBindings.mjs"},"./CloudflareBrowser":{"types":"./dist/CloudflareBrowser.d.mts","default":"./dist/CloudflareBrowser.mjs"},"./CloudflareCodeMode":{"types":"./dist/CloudflareCodeMode.d.mts","default":"./dist/CloudflareCodeMode.mjs"},"./CloudflareConfig":{"types":"./dist/CloudflareConfig.d.mts","default":"./dist/CloudflareConfig.mjs"},"./CloudflareMemory":{"types":"./dist/CloudflareMemory.d.mts","default":"./dist/CloudflareMemory.mjs"},"./CloudflareScheduling":{"types":"./dist/CloudflareScheduling.d.mts","default":"./dist/CloudflareScheduling.mjs"},"./CloudflareSubscriptions":{"types":"./dist/CloudflareSubscriptions.d.mts","default":"./dist/CloudflareSubscriptions.mjs"},"./CloudflareThreadClient":{"types":"./dist/CloudflareThreadClient.d.mts","default":"./dist/CloudflareThreadClient.mjs"},"./InteractiveBrowser":{"types":"./dist/InteractiveBrowser.d.mts","default":"./dist/InteractiveBrowser.mjs"},"./ProtectedBrowser":{"types":"./dist/ProtectedBrowser.d.mts","default":"./dist/ProtectedBrowser.mjs"},"./ThreadObject":{"types":"./dist/ThreadObject.d.mts","default":"./dist/ThreadObject.mjs"},"./WakeScheduler":{"types":"./dist/WakeScheduler.d.mts","default":"./dist/WakeScheduler.mjs"},"./CloudflareAiGateway":{"types":"./dist/CloudflareAiGateway.d.mts","default":"./dist/CloudflareAiGateway.mjs"}},"description":"Cloudflare Layer assembly for Effect Agent: Durable Objects and Browser Run adapters.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/danieljvdm/effect-agent.git","directory":"packages/platform-cloudflare"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json"},"peerDependenciesMeta":{"@cloudflare/puppeteer":{"optional":true}}}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Option, Redactable, Redacted, Schema } from "effect";
|
|
2
|
+
import {
|
|
3
|
+
FetchHttpClient,
|
|
4
|
+
Headers,
|
|
5
|
+
HttpClient,
|
|
6
|
+
HttpClientError,
|
|
7
|
+
HttpClientRequest,
|
|
8
|
+
} from "effect/unstable/http";
|
|
9
|
+
|
|
10
|
+
const Segment = Schema.NonEmptyString.check(
|
|
11
|
+
Schema.isMaxLength(256),
|
|
12
|
+
Schema.isPattern(/^[a-zA-Z0-9_-]+$/),
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const decodeSegment = Schema.decodeUnknownSync(Segment);
|
|
16
|
+
|
|
17
|
+
/** Options understood by upstream Effect AI clients; no model or provider wrapper is created. */
|
|
18
|
+
export interface ClientOptions {
|
|
19
|
+
readonly apiUrl: string;
|
|
20
|
+
readonly transformClient: (client: HttpClient.HttpClient) => HttpClient.HttpClient;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ProviderOptions {
|
|
24
|
+
readonly accountId: string;
|
|
25
|
+
readonly gatewayId: string;
|
|
26
|
+
/** Cloudflare's provider path, such as openai, anthropic, google-ai-studio, or perplexity-ai. */
|
|
27
|
+
readonly provider: string;
|
|
28
|
+
/** Omit only for an unauthenticated gateway with a separately supplied provider key. */
|
|
29
|
+
readonly apiToken?: Redacted.Redacted<string>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RestOptions {
|
|
33
|
+
readonly accountId: string;
|
|
34
|
+
readonly gatewayId: string;
|
|
35
|
+
/** Cloudflare API token with Workers AI Read permission. */
|
|
36
|
+
readonly apiToken: Redacted.Redacted<string>;
|
|
37
|
+
/** Matches the paths appended by the upstream Effect client. */
|
|
38
|
+
readonly protocol: "responses" | "chat-completions" | "messages";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Choose exactly one route: a native provider path or an account REST protocol. */
|
|
42
|
+
export type RouteOptions =
|
|
43
|
+
| (ProviderOptions & { readonly protocol?: never })
|
|
44
|
+
| (RestOptions & { readonly provider?: never });
|
|
45
|
+
|
|
46
|
+
const redactGatewayToken = (headers: Headers.Headers, tokenHeader: string): void => {
|
|
47
|
+
// HTTP tracing can copy headers after preprocessing. Attach the public redaction
|
|
48
|
+
// protocol to the final request as well, before a provider builds error details.
|
|
49
|
+
Object.defineProperty(headers, Redactable.symbolRedactable, {
|
|
50
|
+
configurable: true,
|
|
51
|
+
value: (context: Context.Context<never>) =>
|
|
52
|
+
Headers.redact(headers, [...Context.get(context, Headers.CurrentRedactedNames), tokenHeader]),
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const clientOptions = (
|
|
57
|
+
apiUrl: string,
|
|
58
|
+
tokenHeader: "authorization" | "cf-aig-authorization",
|
|
59
|
+
apiToken: Redacted.Redacted<string> | undefined,
|
|
60
|
+
gatewayId?: string,
|
|
61
|
+
): ClientOptions =>
|
|
62
|
+
Object.freeze({
|
|
63
|
+
apiUrl,
|
|
64
|
+
transformClient: (client: HttpClient.HttpClient) =>
|
|
65
|
+
client.pipe(
|
|
66
|
+
HttpClient.mapRequestEffect((request) => {
|
|
67
|
+
const url = URL.parse(request.url);
|
|
68
|
+
|
|
69
|
+
// Check the normalized URL too: dot segments must not escape this account or gateway.
|
|
70
|
+
if (
|
|
71
|
+
url === null ||
|
|
72
|
+
url.username !== "" ||
|
|
73
|
+
url.password !== "" ||
|
|
74
|
+
!(url.href === apiUrl || url.href.startsWith(`${apiUrl}/`))
|
|
75
|
+
) {
|
|
76
|
+
return Effect.fail(
|
|
77
|
+
new HttpClientError.HttpClientError({
|
|
78
|
+
reason: new HttpClientError.InvalidUrlError({
|
|
79
|
+
request,
|
|
80
|
+
description: "Request is outside the configured Cloudflare AI Gateway endpoint",
|
|
81
|
+
}),
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
let prepared = request;
|
|
86
|
+
|
|
87
|
+
if (apiToken !== undefined) {
|
|
88
|
+
prepared = HttpClientRequest.setHeader(
|
|
89
|
+
prepared,
|
|
90
|
+
tokenHeader,
|
|
91
|
+
`Bearer ${Redacted.value(apiToken)}`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
if (gatewayId !== undefined) {
|
|
95
|
+
prepared = HttpClientRequest.setHeader(prepared, "cf-aig-gateway-id", gatewayId);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return Effect.succeed(prepared);
|
|
99
|
+
}),
|
|
100
|
+
HttpClient.transformResponse((effect) =>
|
|
101
|
+
Effect.gen(function* () {
|
|
102
|
+
const defaults = yield* Effect.serviceOption(FetchHttpClient.RequestInit);
|
|
103
|
+
|
|
104
|
+
return yield* effect.pipe(
|
|
105
|
+
Effect.provideService(FetchHttpClient.RequestInit, {
|
|
106
|
+
...Option.getOrElse(defaults, () => ({})),
|
|
107
|
+
redirect: "error",
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
}),
|
|
111
|
+
),
|
|
112
|
+
HttpClient.transformResponse((effect) =>
|
|
113
|
+
effect.pipe(
|
|
114
|
+
Effect.tap((response) =>
|
|
115
|
+
Effect.sync(() => redactGatewayToken(response.request.headers, tokenHeader)),
|
|
116
|
+
),
|
|
117
|
+
Effect.tapError((error) =>
|
|
118
|
+
Effect.sync(() => redactGatewayToken(error.reason.request.headers, tokenHeader)),
|
|
119
|
+
),
|
|
120
|
+
Effect.updateService(Headers.CurrentRedactedNames, (names) => [...names, tokenHeader]),
|
|
121
|
+
),
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Provider-native proxy for model calls, streaming, embeddings, and hosted tools supported
|
|
128
|
+
* by that provider. Pass the result to the upstream client's layer along with its apiKey
|
|
129
|
+
* for BYOK-in-request, or omit apiKey for Gateway stored keys / Unified Billing.
|
|
130
|
+
* Provider model names and request bodies pass through unchanged. This module is Node-safe.
|
|
131
|
+
* Custom transforms and redirect policies must retain this endpoint and credential boundary.
|
|
132
|
+
*/
|
|
133
|
+
export const provider = (options: ProviderOptions): ClientOptions =>
|
|
134
|
+
clientOptions(
|
|
135
|
+
`https://gateway.ai.cloudflare.com/v1/${decodeSegment(options.accountId)}/${decodeSegment(options.gatewayId)}/${decodeSegment(options.provider)}`,
|
|
136
|
+
"cf-aig-authorization",
|
|
137
|
+
options.apiToken,
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Cloudflare's account REST API (not the deprecated /compat API). Use provider-qualified
|
|
142
|
+
* model names, e.g. openai/gpt-4.1 or anthropic/claude-haiku-4.5, and omit provider apiKey.
|
|
143
|
+
* OpenAI clients append /responses or /chat/completions; Anthropic appends /v1/messages.
|
|
144
|
+
* Compatibility remains the responsibility of the selected upstream client and model.
|
|
145
|
+
*/
|
|
146
|
+
export const rest = (options: RestOptions): ClientOptions =>
|
|
147
|
+
clientOptions(
|
|
148
|
+
`https://api.cloudflare.com/client/v4/accounts/${decodeSegment(options.accountId)}/ai${options.protocol === "messages" ? "" : "/v1"}`,
|
|
149
|
+
"authorization",
|
|
150
|
+
options.apiToken,
|
|
151
|
+
decodeSegment(options.gatewayId),
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Provide a Gateway-configured upstream client directly in a Layer pipeline.
|
|
156
|
+
* Pass the client's `layer` factory, or a callback adding client-specific options.
|
|
157
|
+
* The factory's errors and remaining services (such as HttpClient) stay visible.
|
|
158
|
+
* Model selection and resource ownership remain with the supplied upstream Layers.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* AnthropicLanguageModel.model("claude-haiku-4-5").pipe(
|
|
163
|
+
* Gateway.provide(AnthropicClient.layer, { ...options, provider: "anthropic" }),
|
|
164
|
+
* )
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export const provide = <Client, E, R>(
|
|
168
|
+
clientLayer: (options: ClientOptions) => Layer.Layer<Client, E, R>,
|
|
169
|
+
options: RouteOptions,
|
|
170
|
+
) => Layer.provide(clientLayer(options.provider !== undefined ? provider(options) : rest(options)));
|
package/src/CloudflareMemory.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { MemoryAccess } from "@effect-agent/core/MemoryRevalidation";
|
|
|
6
6
|
import {
|
|
7
7
|
type MemoryReader,
|
|
8
8
|
type MemoryWrite,
|
|
9
|
+
MemoryKey,
|
|
9
10
|
MemoryDocument,
|
|
10
11
|
MemoryMutationFailpoint,
|
|
11
12
|
MemoryStorageError,
|
|
@@ -164,6 +165,52 @@ const makeMemoryClient = Effect.fn("CloudflareMemoryClient.make")(function* <
|
|
|
164
165
|
}).pipe((effect) => withinDeadline(effect, validated.timeoutMillis));
|
|
165
166
|
});
|
|
166
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Read one exact current document in one owner RPC. Null means absent; withdrawals return
|
|
170
|
+
* tombstones. Denial, unavailable storage and deadlines fail typed, never become absence.
|
|
171
|
+
* Reads begun after an acknowledged write observe it or a later revision. The owner checks
|
|
172
|
+
* exact-key authority and active document scopes; source-dependent provenance policy remains
|
|
173
|
+
* application-owned. No extraction, job draining, embedding, discovery or rendering occurs.
|
|
174
|
+
*/
|
|
175
|
+
const get = Effect.fn("CloudflareMemoryClient.get")(function* (key: MemoryKey<Namespace>) {
|
|
176
|
+
const decodedKey = yield* Schema.decodeUnknownEffect(MemoryKey.Wire)(key).pipe(
|
|
177
|
+
Effect.mapError(() => MemoryRpcError.make({ reason: "protocol" })),
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
if (!MemoryNamespace.equals(decodedKey.namespace, bound.namespace))
|
|
181
|
+
return yield* MemoryRpcError.make({ reason: "denied" });
|
|
182
|
+
|
|
183
|
+
return yield* Effect.gen(function* () {
|
|
184
|
+
const response = yield* call({
|
|
185
|
+
_tag: "Get",
|
|
186
|
+
version: 1,
|
|
187
|
+
access: bound,
|
|
188
|
+
principal,
|
|
189
|
+
key: decodedKey,
|
|
190
|
+
deadlineMillis: (yield* Clock.currentTimeMillis) + validated.timeoutMillis,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
if (
|
|
194
|
+
response._tag !== "Document" ||
|
|
195
|
+
!MemoryNamespace.equals(response.key.namespace, bound.namespace) ||
|
|
196
|
+
response.key.id !== decodedKey.id
|
|
197
|
+
)
|
|
198
|
+
return yield* MemoryRpcError.make({ reason: "protocol" });
|
|
199
|
+
if (response.document === null) return null;
|
|
200
|
+
if (
|
|
201
|
+
response.document.key.id !== decodedKey.id ||
|
|
202
|
+
response.document.source.id !== decodedKey.id ||
|
|
203
|
+
(response.document._tag === "ActiveMemoryDocument" &&
|
|
204
|
+
!response.document.scopes.includes(bound.scope))
|
|
205
|
+
)
|
|
206
|
+
return yield* MemoryRpcError.make({ reason: "protocol" });
|
|
207
|
+
|
|
208
|
+
yield* encodeMemoryWire(MemoryDocument.Wire, response.document, validated.maxSourceBytes);
|
|
209
|
+
|
|
210
|
+
return yield* MemoryDocument.restore(access.namespace, response.document);
|
|
211
|
+
}).pipe((effect) => withinDeadline(effect, validated.timeoutMillis));
|
|
212
|
+
});
|
|
213
|
+
|
|
167
214
|
const revalidateSemantic = Effect.fn("CloudflareMemoryClient.revalidateSemantic")(function* (
|
|
168
215
|
found: MemoryIndexSearch<Namespace>,
|
|
169
216
|
profile: SemanticMemoryProfile,
|
|
@@ -206,7 +253,7 @@ const makeMemoryClient = Effect.fn("CloudflareMemoryClient.make")(function* <
|
|
|
206
253
|
);
|
|
207
254
|
});
|
|
208
255
|
|
|
209
|
-
return { recall, revalidate, revalidateSemantic, change };
|
|
256
|
+
return { get, recall, revalidate, revalidateSemantic, change };
|
|
210
257
|
});
|
|
211
258
|
|
|
212
259
|
export const CloudflareMemoryClient = {
|
package/src/index.ts
CHANGED
|
@@ -9,3 +9,4 @@ export * as CloudflareSubscriptions from "./CloudflareSubscriptions.ts";
|
|
|
9
9
|
export * as CloudflareThreadClient from "./CloudflareThreadClient.ts";
|
|
10
10
|
export * as ThreadObject from "./ThreadObject.ts";
|
|
11
11
|
export * as WakeScheduler from "./WakeScheduler.ts";
|
|
12
|
+
export * as CloudflareAiGateway from "./CloudflareAiGateway.ts";
|