@agentuity/server 1.0.32 → 1.0.33
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/api/api.d.ts +1 -227
- package/dist/api/api.d.ts.map +1 -1
- package/dist/api/api.js +1 -637
- package/dist/api/api.js.map +1 -1
- package/dist/api/index.d.ts +1 -17
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -17
- package/dist/api/index.js.map +1 -1
- package/dist/api/org/env-delete.d.ts +1 -22
- package/dist/api/org/env-delete.d.ts.map +1 -1
- package/dist/api/org/env-delete.js +1 -24
- package/dist/api/org/env-delete.js.map +1 -1
- package/dist/api/org/env-get.d.ts +1 -32
- package/dist/api/org/env-get.d.ts.map +1 -1
- package/dist/api/org/env-get.js +1 -25
- package/dist/api/org/env-get.js.map +1 -1
- package/dist/api/org/env-update.d.ts +1 -23
- package/dist/api/org/env-update.d.ts.map +1 -1
- package/dist/api/org/env-update.js +1 -25
- package/dist/api/org/env-update.js.map +1 -1
- package/dist/api/project/get.d.ts +1 -42
- package/dist/api/project/get.d.ts.map +1 -1
- package/dist/api/project/get.js +1 -35
- package/dist/api/project/get.js.map +1 -1
- package/dist/api/project/list.d.ts +1 -47
- package/dist/api/project/list.d.ts.map +1 -1
- package/dist/api/project/list.js +1 -37
- package/dist/api/project/list.js.map +1 -1
- package/dist/api/project/malware.d.ts +1 -70
- package/dist/api/project/malware.d.ts.map +1 -1
- package/dist/api/project/malware.js +1 -41
- package/dist/api/project/malware.js.map +1 -1
- package/dist/api/region/create.d.ts +1 -80
- package/dist/api/region/create.d.ts.map +1 -1
- package/dist/api/region/create.js +1 -176
- package/dist/api/region/create.js.map +1 -1
- package/dist/api/sandbox/client.d.ts +1 -190
- package/dist/api/sandbox/client.d.ts.map +1 -1
- package/dist/api/sandbox/client.js +1 -260
- package/dist/api/sandbox/client.js.map +1 -1
- package/dist/api/sandbox/pause.d.ts +1 -21
- package/dist/api/sandbox/pause.d.ts.map +1 -1
- package/dist/api/sandbox/pause.js +1 -24
- package/dist/api/sandbox/pause.js.map +1 -1
- package/dist/api/sandbox/resume.d.ts +1 -21
- package/dist/api/sandbox/resume.d.ts.map +1 -1
- package/dist/api/sandbox/resume.js +1 -24
- package/dist/api/sandbox/resume.js.map +1 -1
- package/dist/api/sandbox/util.d.ts +1 -284
- package/dist/api/sandbox/util.d.ts.map +1 -1
- package/dist/api/sandbox/util.js +1 -210
- package/dist/api/sandbox/util.js.map +1 -1
- package/dist/api/user/whoami.d.ts +1 -38
- package/dist/api/user/whoami.d.ts.map +1 -1
- package/dist/api/user/whoami.js +1 -26
- package/dist/api/user/whoami.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -12
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/api/api.ts +1 -936
- package/src/api/index.ts +1 -17
- package/src/api/org/env-delete.ts +1 -37
- package/src/api/org/env-get.ts +1 -43
- package/src/api/org/env-update.ts +1 -38
- package/src/api/project/get.ts +1 -49
- package/src/api/project/list.ts +1 -54
- package/src/api/project/malware.ts +1 -68
- package/src/api/region/create.ts +1 -207
- package/src/api/sandbox/client.ts +1 -460
- package/src/api/sandbox/pause.ts +1 -39
- package/src/api/sandbox/resume.ts +1 -39
- package/src/api/sandbox/util.ts +1 -276
- package/src/api/user/whoami.ts +1 -32
- package/src/index.ts +3 -30
- package/dist/api/apikey/create.d.ts +0 -33
- package/dist/api/apikey/create.d.ts.map +0 -1
- package/dist/api/apikey/create.js +0 -23
- package/dist/api/apikey/create.js.map +0 -1
- package/dist/api/apikey/delete.d.ts +0 -19
- package/dist/api/apikey/delete.d.ts.map +0 -1
- package/dist/api/apikey/delete.js +0 -19
- package/dist/api/apikey/delete.js.map +0 -1
- package/dist/api/apikey/get.d.ts +0 -45
- package/dist/api/apikey/get.d.ts.map +0 -1
- package/dist/api/apikey/get.js +0 -36
- package/dist/api/apikey/get.js.map +0 -1
- package/dist/api/apikey/index.d.ts +0 -6
- package/dist/api/apikey/index.d.ts.map +0 -1
- package/dist/api/apikey/index.js +0 -6
- package/dist/api/apikey/index.js.map +0 -1
- package/dist/api/apikey/list.d.ts +0 -64
- package/dist/api/apikey/list.d.ts.map +0 -1
- package/dist/api/apikey/list.js +0 -46
- package/dist/api/apikey/list.js.map +0 -1
- package/dist/api/apikey/util.d.ts +0 -23
- package/dist/api/apikey/util.d.ts.map +0 -1
- package/dist/api/apikey/util.js +0 -3
- package/dist/api/apikey/util.js.map +0 -1
- package/dist/api/db/index.d.ts +0 -5
- package/dist/api/db/index.d.ts.map +0 -1
- package/dist/api/db/index.js +0 -5
- package/dist/api/db/index.js.map +0 -1
- package/dist/api/db/logs.d.ts +0 -70
- package/dist/api/db/logs.d.ts.map +0 -1
- package/dist/api/db/logs.js +0 -59
- package/dist/api/db/logs.js.map +0 -1
- package/dist/api/db/query.d.ts +0 -39
- package/dist/api/db/query.d.ts.map +0 -1
- package/dist/api/db/query.js +0 -49
- package/dist/api/db/query.js.map +0 -1
- package/dist/api/db/tables.d.ts +0 -49
- package/dist/api/db/tables.d.ts.map +0 -1
- package/dist/api/db/tables.js +0 -59
- package/dist/api/db/tables.js.map +0 -1
- package/dist/api/db/util.d.ts +0 -31
- package/dist/api/db/util.d.ts.map +0 -1
- package/dist/api/db/util.js +0 -4
- package/dist/api/db/util.js.map +0 -1
- package/dist/api/eval/get.d.ts +0 -36
- package/dist/api/eval/get.d.ts.map +0 -1
- package/dist/api/eval/get.js +0 -23
- package/dist/api/eval/get.js.map +0 -1
- package/dist/api/eval/index.d.ts +0 -5
- package/dist/api/eval/index.d.ts.map +0 -1
- package/dist/api/eval/index.js +0 -5
- package/dist/api/eval/index.js.map +0 -1
- package/dist/api/eval/list.d.ts +0 -50
- package/dist/api/eval/list.d.ts.map +0 -1
- package/dist/api/eval/list.js +0 -32
- package/dist/api/eval/list.js.map +0 -1
- package/dist/api/eval/run-get.d.ts +0 -48
- package/dist/api/eval/run-get.d.ts.map +0 -1
- package/dist/api/eval/run-get.js +0 -29
- package/dist/api/eval/run-get.js.map +0 -1
- package/dist/api/eval/run-list.d.ts +0 -70
- package/dist/api/eval/run-list.d.ts.map +0 -1
- package/dist/api/eval/run-list.js +0 -42
- package/dist/api/eval/run-list.js.map +0 -1
- package/dist/api/machine/index.d.ts +0 -3
- package/dist/api/machine/index.d.ts.map +0 -1
- package/dist/api/machine/index.js +0 -3
- package/dist/api/machine/index.js.map +0 -1
- package/dist/api/machine/machine.d.ts +0 -192
- package/dist/api/machine/machine.d.ts.map +0 -1
- package/dist/api/machine/machine.js +0 -109
- package/dist/api/machine/machine.js.map +0 -1
- package/dist/api/machine/util.d.ts +0 -14
- package/dist/api/machine/util.d.ts.map +0 -1
- package/dist/api/machine/util.js +0 -3
- package/dist/api/machine/util.js.map +0 -1
- package/dist/api/org/index.d.ts +0 -7
- package/dist/api/org/index.d.ts.map +0 -1
- package/dist/api/org/index.js +0 -7
- package/dist/api/org/index.js.map +0 -1
- package/dist/api/org/list.d.ts +0 -27
- package/dist/api/org/list.d.ts.map +0 -1
- package/dist/api/org/list.js +0 -22
- package/dist/api/org/list.js.map +0 -1
- package/dist/api/org/resources.d.ts +0 -141
- package/dist/api/org/resources.d.ts.map +0 -1
- package/dist/api/org/resources.js +0 -97
- package/dist/api/org/resources.js.map +0 -1
- package/dist/api/org/util.d.ts +0 -45
- package/dist/api/org/util.d.ts.map +0 -1
- package/dist/api/org/util.js +0 -4
- package/dist/api/org/util.js.map +0 -1
- package/dist/api/project/agent.d.ts +0 -89
- package/dist/api/project/agent.d.ts.map +0 -1
- package/dist/api/project/agent.js +0 -60
- package/dist/api/project/agent.js.map +0 -1
- package/dist/api/project/create.d.ts +0 -37
- package/dist/api/project/create.d.ts.map +0 -1
- package/dist/api/project/create.js +0 -31
- package/dist/api/project/create.js.map +0 -1
- package/dist/api/project/delete.d.ts +0 -15
- package/dist/api/project/delete.d.ts.map +0 -1
- package/dist/api/project/delete.js +0 -13
- package/dist/api/project/delete.js.map +0 -1
- package/dist/api/project/deploy.d.ts +0 -490
- package/dist/api/project/deploy.d.ts.map +0 -1
- package/dist/api/project/deploy.js +0 -313
- package/dist/api/project/deploy.js.map +0 -1
- package/dist/api/project/deployment.d.ts +0 -237
- package/dist/api/project/deployment.d.ts.map +0 -1
- package/dist/api/project/deployment.js +0 -127
- package/dist/api/project/deployment.js.map +0 -1
- package/dist/api/project/env-delete.d.ts +0 -22
- package/dist/api/project/env-delete.d.ts.map +0 -1
- package/dist/api/project/env-delete.js +0 -29
- package/dist/api/project/env-delete.js.map +0 -1
- package/dist/api/project/env-update.d.ts +0 -31
- package/dist/api/project/env-update.d.ts.map +0 -1
- package/dist/api/project/env-update.js +0 -36
- package/dist/api/project/env-update.js.map +0 -1
- package/dist/api/project/exists.d.ts +0 -25
- package/dist/api/project/exists.d.ts.map +0 -1
- package/dist/api/project/exists.js +0 -45
- package/dist/api/project/exists.js.map +0 -1
- package/dist/api/project/hostname.d.ts +0 -25
- package/dist/api/project/hostname.d.ts.map +0 -1
- package/dist/api/project/hostname.js +0 -37
- package/dist/api/project/hostname.js.map +0 -1
- package/dist/api/project/index.d.ts +0 -14
- package/dist/api/project/index.d.ts.map +0 -1
- package/dist/api/project/index.js +0 -14
- package/dist/api/project/index.js.map +0 -1
- package/dist/api/project/update-region.d.ts +0 -27
- package/dist/api/project/update-region.d.ts.map +0 -1
- package/dist/api/project/update-region.js +0 -25
- package/dist/api/project/update-region.js.map +0 -1
- package/dist/api/project/util.d.ts +0 -62
- package/dist/api/project/util.d.ts.map +0 -1
- package/dist/api/project/util.js +0 -6
- package/dist/api/project/util.js.map +0 -1
- package/dist/api/queue/analytics.d.ts +0 -250
- package/dist/api/queue/analytics.d.ts.map +0 -1
- package/dist/api/queue/analytics.js +0 -233
- package/dist/api/queue/analytics.js.map +0 -1
- package/dist/api/queue/destinations.d.ts +0 -202
- package/dist/api/queue/destinations.d.ts.map +0 -1
- package/dist/api/queue/destinations.js +0 -168
- package/dist/api/queue/destinations.js.map +0 -1
- package/dist/api/queue/dlq.d.ts +0 -168
- package/dist/api/queue/dlq.d.ts.map +0 -1
- package/dist/api/queue/dlq.js +0 -166
- package/dist/api/queue/dlq.js.map +0 -1
- package/dist/api/queue/index.d.ts +0 -56
- package/dist/api/queue/index.d.ts.map +0 -1
- package/dist/api/queue/index.js +0 -90
- package/dist/api/queue/index.js.map +0 -1
- package/dist/api/queue/messages.d.ts +0 -503
- package/dist/api/queue/messages.d.ts.map +0 -1
- package/dist/api/queue/messages.js +0 -549
- package/dist/api/queue/messages.js.map +0 -1
- package/dist/api/queue/queues.d.ts +0 -226
- package/dist/api/queue/queues.d.ts.map +0 -1
- package/dist/api/queue/queues.js +0 -321
- package/dist/api/queue/queues.js.map +0 -1
- package/dist/api/queue/sources.d.ts +0 -202
- package/dist/api/queue/sources.d.ts.map +0 -1
- package/dist/api/queue/sources.js +0 -202
- package/dist/api/queue/sources.js.map +0 -1
- package/dist/api/queue/types.d.ts +0 -1218
- package/dist/api/queue/types.d.ts.map +0 -1
- package/dist/api/queue/types.js +0 -1002
- package/dist/api/queue/types.js.map +0 -1
- package/dist/api/queue/util.d.ts +0 -278
- package/dist/api/queue/util.d.ts.map +0 -1
- package/dist/api/queue/util.js +0 -235
- package/dist/api/queue/util.js.map +0 -1
- package/dist/api/queue/validation.d.ts +0 -247
- package/dist/api/queue/validation.d.ts.map +0 -1
- package/dist/api/queue/validation.js +0 -513
- package/dist/api/queue/validation.js.map +0 -1
- package/dist/api/queue/websocket.d.ts +0 -168
- package/dist/api/queue/websocket.d.ts.map +0 -1
- package/dist/api/queue/websocket.js +0 -394
- package/dist/api/queue/websocket.js.map +0 -1
- package/dist/api/region/delete.d.ts +0 -62
- package/dist/api/region/delete.d.ts.map +0 -1
- package/dist/api/region/delete.js +0 -37
- package/dist/api/region/delete.js.map +0 -1
- package/dist/api/region/index.d.ts +0 -5
- package/dist/api/region/index.d.ts.map +0 -1
- package/dist/api/region/index.js +0 -5
- package/dist/api/region/index.js.map +0 -1
- package/dist/api/region/list.d.ts +0 -27
- package/dist/api/region/list.d.ts.map +0 -1
- package/dist/api/region/list.js +0 -22
- package/dist/api/region/list.js.map +0 -1
- package/dist/api/region/resources.d.ts +0 -71
- package/dist/api/region/resources.d.ts.map +0 -1
- package/dist/api/region/resources.js +0 -53
- package/dist/api/region/resources.js.map +0 -1
- package/dist/api/region/util.d.ts +0 -23
- package/dist/api/region/util.d.ts.map +0 -1
- package/dist/api/region/util.js +0 -3
- package/dist/api/region/util.js.map +0 -1
- package/dist/api/sandbox/cli-list.d.ts +0 -114
- package/dist/api/sandbox/cli-list.d.ts.map +0 -1
- package/dist/api/sandbox/cli-list.js +0 -71
- package/dist/api/sandbox/cli-list.js.map +0 -1
- package/dist/api/sandbox/create.d.ts +0 -118
- package/dist/api/sandbox/create.d.ts.map +0 -1
- package/dist/api/sandbox/create.js +0 -211
- package/dist/api/sandbox/create.js.map +0 -1
- package/dist/api/sandbox/destroy.d.ts +0 -22
- package/dist/api/sandbox/destroy.d.ts.map +0 -1
- package/dist/api/sandbox/destroy.js +0 -25
- package/dist/api/sandbox/destroy.js.map +0 -1
- package/dist/api/sandbox/disk-checkpoint.d.ts +0 -104
- package/dist/api/sandbox/disk-checkpoint.d.ts.map +0 -1
- package/dist/api/sandbox/disk-checkpoint.js +0 -104
- package/dist/api/sandbox/disk-checkpoint.js.map +0 -1
- package/dist/api/sandbox/execute.d.ts +0 -69
- package/dist/api/sandbox/execute.d.ts.map +0 -1
- package/dist/api/sandbox/execute.js +0 -103
- package/dist/api/sandbox/execute.js.map +0 -1
- package/dist/api/sandbox/execution.d.ts +0 -169
- package/dist/api/sandbox/execution.d.ts.map +0 -1
- package/dist/api/sandbox/execution.js +0 -118
- package/dist/api/sandbox/execution.js.map +0 -1
- package/dist/api/sandbox/files.d.ts +0 -261
- package/dist/api/sandbox/files.d.ts.map +0 -1
- package/dist/api/sandbox/files.js +0 -386
- package/dist/api/sandbox/files.js.map +0 -1
- package/dist/api/sandbox/get.d.ts +0 -283
- package/dist/api/sandbox/get.d.ts.map +0 -1
- package/dist/api/sandbox/get.js +0 -215
- package/dist/api/sandbox/get.js.map +0 -1
- package/dist/api/sandbox/getStatus.d.ts +0 -16
- package/dist/api/sandbox/getStatus.d.ts.map +0 -1
- package/dist/api/sandbox/getStatus.js +0 -32
- package/dist/api/sandbox/getStatus.js.map +0 -1
- package/dist/api/sandbox/index.d.ts +0 -39
- package/dist/api/sandbox/index.d.ts.map +0 -1
- package/dist/api/sandbox/index.js +0 -20
- package/dist/api/sandbox/index.js.map +0 -1
- package/dist/api/sandbox/list.d.ts +0 -293
- package/dist/api/sandbox/list.d.ts.map +0 -1
- package/dist/api/sandbox/list.js +0 -191
- package/dist/api/sandbox/list.js.map +0 -1
- package/dist/api/sandbox/resolve.d.ts +0 -82
- package/dist/api/sandbox/resolve.d.ts.map +0 -1
- package/dist/api/sandbox/resolve.js +0 -71
- package/dist/api/sandbox/resolve.js.map +0 -1
- package/dist/api/sandbox/run.d.ts +0 -28
- package/dist/api/sandbox/run.d.ts.map +0 -1
- package/dist/api/sandbox/run.js +0 -342
- package/dist/api/sandbox/run.js.map +0 -1
- package/dist/api/sandbox/runtime.d.ts +0 -83
- package/dist/api/sandbox/runtime.d.ts.map +0 -1
- package/dist/api/sandbox/runtime.js +0 -78
- package/dist/api/sandbox/runtime.js.map +0 -1
- package/dist/api/sandbox/snapshot-build.d.ts +0 -48
- package/dist/api/sandbox/snapshot-build.d.ts.map +0 -1
- package/dist/api/sandbox/snapshot-build.js +0 -74
- package/dist/api/sandbox/snapshot-build.js.map +0 -1
- package/dist/api/sandbox/snapshot.d.ts +0 -595
- package/dist/api/sandbox/snapshot.d.ts.map +0 -1
- package/dist/api/sandbox/snapshot.js +0 -598
- package/dist/api/sandbox/snapshot.js.map +0 -1
- package/dist/api/services/index.d.ts +0 -2
- package/dist/api/services/index.d.ts.map +0 -1
- package/dist/api/services/index.js +0 -2
- package/dist/api/services/index.js.map +0 -1
- package/dist/api/services/stats.d.ts +0 -263
- package/dist/api/services/stats.d.ts.map +0 -1
- package/dist/api/services/stats.js +0 -144
- package/dist/api/services/stats.js.map +0 -1
- package/dist/api/session/get.d.ts +0 -169
- package/dist/api/session/get.d.ts.map +0 -1
- package/dist/api/session/get.js +0 -56
- package/dist/api/session/get.js.map +0 -1
- package/dist/api/session/index.d.ts +0 -4
- package/dist/api/session/index.d.ts.map +0 -1
- package/dist/api/session/index.js +0 -4
- package/dist/api/session/index.js.map +0 -1
- package/dist/api/session/list.d.ts +0 -143
- package/dist/api/session/list.d.ts.map +0 -1
- package/dist/api/session/list.js +0 -91
- package/dist/api/session/list.js.map +0 -1
- package/dist/api/session/logs.d.ts +0 -40
- package/dist/api/session/logs.d.ts.map +0 -1
- package/dist/api/session/logs.js +0 -28
- package/dist/api/session/logs.js.map +0 -1
- package/dist/api/session/util.d.ts +0 -23
- package/dist/api/session/util.d.ts.map +0 -1
- package/dist/api/session/util.js +0 -3
- package/dist/api/session/util.js.map +0 -1
- package/dist/api/storage/config.d.ts +0 -99
- package/dist/api/storage/config.d.ts.map +0 -1
- package/dist/api/storage/config.js +0 -61
- package/dist/api/storage/config.js.map +0 -1
- package/dist/api/storage/index.d.ts +0 -5
- package/dist/api/storage/index.d.ts.map +0 -1
- package/dist/api/storage/index.js +0 -5
- package/dist/api/storage/index.js.map +0 -1
- package/dist/api/storage/objects.d.ts +0 -155
- package/dist/api/storage/objects.d.ts.map +0 -1
- package/dist/api/storage/objects.js +0 -148
- package/dist/api/storage/objects.js.map +0 -1
- package/dist/api/storage/types.d.ts +0 -161
- package/dist/api/storage/types.d.ts.map +0 -1
- package/dist/api/storage/types.js +0 -141
- package/dist/api/storage/types.js.map +0 -1
- package/dist/api/storage/util.d.ts +0 -48
- package/dist/api/storage/util.d.ts.map +0 -1
- package/dist/api/storage/util.js +0 -8
- package/dist/api/storage/util.js.map +0 -1
- package/dist/api/stream/get.d.ts +0 -58
- package/dist/api/stream/get.d.ts.map +0 -1
- package/dist/api/stream/get.js +0 -40
- package/dist/api/stream/get.js.map +0 -1
- package/dist/api/stream/index.d.ts +0 -4
- package/dist/api/stream/index.d.ts.map +0 -1
- package/dist/api/stream/index.js +0 -4
- package/dist/api/stream/index.js.map +0 -1
- package/dist/api/stream/list.d.ts +0 -120
- package/dist/api/stream/list.d.ts.map +0 -1
- package/dist/api/stream/list.js +0 -77
- package/dist/api/stream/list.js.map +0 -1
- package/dist/api/stream/util.d.ts +0 -23
- package/dist/api/stream/util.d.ts.map +0 -1
- package/dist/api/stream/util.js +0 -3
- package/dist/api/stream/util.js.map +0 -1
- package/dist/api/thread/delete.d.ts +0 -23
- package/dist/api/thread/delete.d.ts.map +0 -1
- package/dist/api/thread/delete.js +0 -21
- package/dist/api/thread/delete.js.map +0 -1
- package/dist/api/thread/get.d.ts +0 -36
- package/dist/api/thread/get.d.ts.map +0 -1
- package/dist/api/thread/get.js +0 -23
- package/dist/api/thread/get.js.map +0 -1
- package/dist/api/thread/index.d.ts +0 -5
- package/dist/api/thread/index.d.ts.map +0 -1
- package/dist/api/thread/index.js +0 -5
- package/dist/api/thread/index.js.map +0 -1
- package/dist/api/thread/list.d.ts +0 -69
- package/dist/api/thread/list.d.ts.map +0 -1
- package/dist/api/thread/list.js +0 -51
- package/dist/api/thread/list.js.map +0 -1
- package/dist/api/thread/util.d.ts +0 -23
- package/dist/api/thread/util.d.ts.map +0 -1
- package/dist/api/thread/util.js +0 -3
- package/dist/api/thread/util.js.map +0 -1
- package/dist/api/user/index.d.ts +0 -2
- package/dist/api/user/index.d.ts.map +0 -1
- package/dist/api/user/index.js +0 -2
- package/dist/api/user/index.js.map +0 -1
- package/dist/api/user/util.d.ts +0 -23
- package/dist/api/user/util.d.ts.map +0 -1
- package/dist/api/user/util.js +0 -3
- package/dist/api/user/util.js.map +0 -1
- package/dist/api/webhook/deliveries.d.ts +0 -94
- package/dist/api/webhook/deliveries.d.ts.map +0 -1
- package/dist/api/webhook/deliveries.js +0 -79
- package/dist/api/webhook/deliveries.js.map +0 -1
- package/dist/api/webhook/destinations.d.ts +0 -136
- package/dist/api/webhook/destinations.d.ts.map +0 -1
- package/dist/api/webhook/destinations.js +0 -137
- package/dist/api/webhook/destinations.js.map +0 -1
- package/dist/api/webhook/index.d.ts +0 -41
- package/dist/api/webhook/index.d.ts.map +0 -1
- package/dist/api/webhook/index.js +0 -59
- package/dist/api/webhook/index.js.map +0 -1
- package/dist/api/webhook/receipts.d.ts +0 -77
- package/dist/api/webhook/receipts.d.ts.map +0 -1
- package/dist/api/webhook/receipts.js +0 -78
- package/dist/api/webhook/receipts.js.map +0 -1
- package/dist/api/webhook/types.d.ts +0 -249
- package/dist/api/webhook/types.d.ts.map +0 -1
- package/dist/api/webhook/types.js +0 -221
- package/dist/api/webhook/types.js.map +0 -1
- package/dist/api/webhook/util.d.ts +0 -202
- package/dist/api/webhook/util.d.ts.map +0 -1
- package/dist/api/webhook/util.js +0 -201
- package/dist/api/webhook/util.js.map +0 -1
- package/dist/api/webhook/webhooks.d.ts +0 -146
- package/dist/api/webhook/webhooks.d.ts.map +0 -1
- package/dist/api/webhook/webhooks.js +0 -165
- package/dist/api/webhook/webhooks.js.map +0 -1
- package/src/api/api-example.md +0 -164
- package/src/api/apikey/create.ts +0 -41
- package/src/api/apikey/delete.ts +0 -30
- package/src/api/apikey/get.ts +0 -48
- package/src/api/apikey/index.ts +0 -5
- package/src/api/apikey/list.ts +0 -64
- package/src/api/apikey/util.ts +0 -3
- package/src/api/db/index.ts +0 -27
- package/src/api/db/logs.ts +0 -75
- package/src/api/db/query.ts +0 -67
- package/src/api/db/tables.ts +0 -92
- package/src/api/db/util.ts +0 -9
- package/src/api/eval/get.ts +0 -33
- package/src/api/eval/index.ts +0 -28
- package/src/api/eval/list.ts +0 -49
- package/src/api/eval/run-get.ts +0 -39
- package/src/api/eval/run-list.ts +0 -59
- package/src/api/machine/index.ts +0 -2
- package/src/api/machine/machine.ts +0 -160
- package/src/api/machine/util.ts +0 -5
- package/src/api/org/index.ts +0 -6
- package/src/api/org/list.ts +0 -28
- package/src/api/org/resources.ts +0 -140
- package/src/api/org/util.ts +0 -4
- package/src/api/project/agent.ts +0 -86
- package/src/api/project/create.ts +0 -47
- package/src/api/project/delete.ts +0 -25
- package/src/api/project/deploy.ts +0 -458
- package/src/api/project/deployment.ts +0 -195
- package/src/api/project/env-delete.ts +0 -45
- package/src/api/project/env-update.ts +0 -55
- package/src/api/project/exists.ts +0 -58
- package/src/api/project/hostname.ts +0 -73
- package/src/api/project/index.ts +0 -13
- package/src/api/project/update-region.ts +0 -44
- package/src/api/project/util.ts +0 -8
- package/src/api/queue/analytics.ts +0 -311
- package/src/api/queue/destinations.ts +0 -259
- package/src/api/queue/dlq.ts +0 -243
- package/src/api/queue/index.ts +0 -308
- package/src/api/queue/messages.ts +0 -784
- package/src/api/queue/queues.ts +0 -460
- package/src/api/queue/sources.ts +0 -294
- package/src/api/queue/types.ts +0 -1325
- package/src/api/queue/util.ts +0 -278
- package/src/api/queue/validation.ts +0 -560
- package/src/api/queue/websocket.ts +0 -514
- package/src/api/region/delete.ts +0 -57
- package/src/api/region/index.ts +0 -4
- package/src/api/region/list.ts +0 -32
- package/src/api/region/resources.ts +0 -69
- package/src/api/region/util.ts +0 -3
- package/src/api/sandbox/cli-list.ts +0 -127
- package/src/api/sandbox/create.ts +0 -256
- package/src/api/sandbox/destroy.ts +0 -41
- package/src/api/sandbox/disk-checkpoint.ts +0 -179
- package/src/api/sandbox/execute.ts +0 -132
- package/src/api/sandbox/execution.ts +0 -183
- package/src/api/sandbox/files.ts +0 -596
- package/src/api/sandbox/get.ts +0 -249
- package/src/api/sandbox/getStatus.ts +0 -54
- package/src/api/sandbox/index.ts +0 -211
- package/src/api/sandbox/list.ts +0 -224
- package/src/api/sandbox/resolve.ts +0 -98
- package/src/api/sandbox/run.ts +0 -439
- package/src/api/sandbox/runtime.ts +0 -100
- package/src/api/sandbox/snapshot-build.ts +0 -98
- package/src/api/sandbox/snapshot.ts +0 -781
- package/src/api/services/index.ts +0 -1
- package/src/api/services/stats.ts +0 -213
- package/src/api/session/get.ts +0 -106
- package/src/api/session/index.ts +0 -3
- package/src/api/session/list.ts +0 -136
- package/src/api/session/logs.ts +0 -47
- package/src/api/session/util.ts +0 -3
- package/src/api/storage/config.ts +0 -111
- package/src/api/storage/index.ts +0 -4
- package/src/api/storage/objects.ts +0 -250
- package/src/api/storage/types.ts +0 -174
- package/src/api/storage/util.ts +0 -10
- package/src/api/stream/get.ts +0 -51
- package/src/api/stream/index.ts +0 -3
- package/src/api/stream/list.ts +0 -127
- package/src/api/stream/util.ts +0 -3
- package/src/api/thread/delete.ts +0 -31
- package/src/api/thread/get.ts +0 -34
- package/src/api/thread/index.ts +0 -4
- package/src/api/thread/list.ts +0 -76
- package/src/api/thread/util.ts +0 -3
- package/src/api/user/index.ts +0 -1
- package/src/api/user/util.ts +0 -3
- package/src/api/webhook/deliveries.ts +0 -129
- package/src/api/webhook/destinations.ts +0 -224
- package/src/api/webhook/index.ts +0 -133
- package/src/api/webhook/receipts.ts +0 -124
- package/src/api/webhook/types.ts +0 -309
- package/src/api/webhook/util.ts +0 -237
- package/src/api/webhook/webhooks.ts +0 -260
package/src/api/api.ts
CHANGED
|
@@ -1,936 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* API Client for Agentuity Platform
|
|
3
|
-
*
|
|
4
|
-
* Handles HTTP requests to the API with automatic error parsing and User-Agent headers.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
import type { Logger } from '@agentuity/core';
|
|
9
|
-
import { StructuredError } from '@agentuity/core';
|
|
10
|
-
import pkg from '../../package.json' with { type: 'json' };
|
|
11
|
-
|
|
12
|
-
// Cache the package data
|
|
13
|
-
let cachedPackage: typeof pkg | null = null;
|
|
14
|
-
|
|
15
|
-
export function getPackage(): typeof pkg {
|
|
16
|
-
if (!cachedPackage) {
|
|
17
|
-
cachedPackage = pkg;
|
|
18
|
-
}
|
|
19
|
-
return cachedPackage;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function getVersion(): string {
|
|
23
|
-
return process.env.AGENTUITY_CLI_VERSION || getPackage().version || 'dev';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getUserAgent(): string {
|
|
27
|
-
return `Agentuity SDK/${getVersion()}`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface APIClientConfig {
|
|
31
|
-
skipVersionCheck?: boolean;
|
|
32
|
-
userAgent?: string;
|
|
33
|
-
maxRetries?: number;
|
|
34
|
-
retryDelayMs?: number;
|
|
35
|
-
headers?: Record<string, string>;
|
|
36
|
-
/**
|
|
37
|
-
* Maximum time in milliseconds to keep retrying 502/503 responses.
|
|
38
|
-
* These indicate the service is restarting (hot-swap) and typically
|
|
39
|
-
* resolve within seconds. Defaults to 30000 (30 seconds).
|
|
40
|
-
*/
|
|
41
|
-
serviceUnavailableTimeoutMs?: number;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const ZodIssuesSchema = z.array(
|
|
45
|
-
z.object({
|
|
46
|
-
code: z.string(),
|
|
47
|
-
input: z.unknown().optional(),
|
|
48
|
-
path: z.array(z.union([z.string(), z.number()])),
|
|
49
|
-
message: z.string(),
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
export type IssuesType = z.infer<typeof ZodIssuesSchema>;
|
|
54
|
-
|
|
55
|
-
const toIssues = (issues: z.core.$ZodIssue[]): IssuesType => {
|
|
56
|
-
return issues.map((issue) => ({
|
|
57
|
-
code: issue.code,
|
|
58
|
-
input: issue.input,
|
|
59
|
-
path: issue.path.map((x) => (typeof x === 'number' ? x : String(x))),
|
|
60
|
-
message: issue.message,
|
|
61
|
-
}));
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const APIErrorSchema = z.object({
|
|
65
|
-
success: z.boolean(),
|
|
66
|
-
code: z.string().optional(),
|
|
67
|
-
message: z.string().optional(),
|
|
68
|
-
error: z
|
|
69
|
-
.union([
|
|
70
|
-
z.string(),
|
|
71
|
-
z.object({
|
|
72
|
-
name: z.string().optional(),
|
|
73
|
-
issues: ZodIssuesSchema.optional(),
|
|
74
|
-
}),
|
|
75
|
-
])
|
|
76
|
-
.optional(),
|
|
77
|
-
details: z.record(z.string(), z.unknown()).optional(),
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
export const APIError = StructuredError('APIErrorResponse')<{
|
|
81
|
-
url: string;
|
|
82
|
-
status: number;
|
|
83
|
-
sessionId?: string | null;
|
|
84
|
-
}>();
|
|
85
|
-
|
|
86
|
-
export const ValidationInputError = StructuredError(
|
|
87
|
-
'ValidationInputError',
|
|
88
|
-
'There was an error validating the API input data.'
|
|
89
|
-
)<{
|
|
90
|
-
url: string;
|
|
91
|
-
issues: IssuesType;
|
|
92
|
-
}>();
|
|
93
|
-
|
|
94
|
-
export const ValidationOutputError = StructuredError(
|
|
95
|
-
'ValidationOutputError',
|
|
96
|
-
'There was an unexpected error validating the API response data.'
|
|
97
|
-
)<{
|
|
98
|
-
url: string;
|
|
99
|
-
issues: IssuesType;
|
|
100
|
-
sessionId?: string | null;
|
|
101
|
-
}>();
|
|
102
|
-
|
|
103
|
-
export const UpgradeRequiredError = StructuredError(
|
|
104
|
-
'UpgradeRequiredError',
|
|
105
|
-
'Upgrade required to continue. Please run `agentuity upgrade` or see https://agentuity.dev/Get-Started/installation to download the latest version.'
|
|
106
|
-
)<{
|
|
107
|
-
sessionId?: string | null;
|
|
108
|
-
}>();
|
|
109
|
-
|
|
110
|
-
export const MaxRetriesError = StructuredError(
|
|
111
|
-
'MaxRetriesError',
|
|
112
|
-
'Max Retries attempted and continued failures exhausted.'
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
export const MisdirectedRequestError = StructuredError(
|
|
116
|
-
'MisdirectedRequestError',
|
|
117
|
-
'The request was sent to the wrong regional server.'
|
|
118
|
-
)<{
|
|
119
|
-
url: string;
|
|
120
|
-
region: string;
|
|
121
|
-
sessionId?: string | null;
|
|
122
|
-
}>();
|
|
123
|
-
|
|
124
|
-
export const PaymentRequiredError = StructuredError(
|
|
125
|
-
'PaymentRequiredError',
|
|
126
|
-
'This action requires a paid plan. Please upgrade your account to continue.'
|
|
127
|
-
)<{
|
|
128
|
-
url: string;
|
|
129
|
-
sessionId?: string | null;
|
|
130
|
-
upgradeUrl?: string;
|
|
131
|
-
}>();
|
|
132
|
-
|
|
133
|
-
export class APIClient {
|
|
134
|
-
#baseUrl: string;
|
|
135
|
-
#apiKey?: string;
|
|
136
|
-
#config?: APIClientConfig;
|
|
137
|
-
#logger: Logger;
|
|
138
|
-
|
|
139
|
-
constructor(baseUrl: string, logger: Logger, config?: APIClientConfig);
|
|
140
|
-
constructor(baseUrl: string, logger: Logger, apiKey: string, config?: APIClientConfig);
|
|
141
|
-
constructor(
|
|
142
|
-
baseUrl: string,
|
|
143
|
-
logger: Logger,
|
|
144
|
-
apiKeyOrConfig?: string | APIClientConfig,
|
|
145
|
-
config?: APIClientConfig
|
|
146
|
-
) {
|
|
147
|
-
this.#baseUrl = baseUrl;
|
|
148
|
-
this.#logger = logger;
|
|
149
|
-
|
|
150
|
-
// Detect if third parameter is apiKey (string) or config (object)
|
|
151
|
-
if (typeof apiKeyOrConfig === 'string') {
|
|
152
|
-
this.#apiKey = apiKeyOrConfig;
|
|
153
|
-
this.#config = config;
|
|
154
|
-
} else {
|
|
155
|
-
this.#apiKey = undefined;
|
|
156
|
-
this.#config = apiKeyOrConfig;
|
|
157
|
-
}
|
|
158
|
-
if (!this.#apiKey && process.env.AGENTUITY_SDK_KEY) {
|
|
159
|
-
this.#apiKey = process.env.AGENTUITY_SDK_KEY;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* GET request
|
|
165
|
-
*/
|
|
166
|
-
async get<TResponse = void>(
|
|
167
|
-
endpoint: string,
|
|
168
|
-
responseSchema?: z.ZodType<TResponse>,
|
|
169
|
-
signal?: AbortSignal,
|
|
170
|
-
extraHeaders?: Record<string, string>
|
|
171
|
-
): Promise<TResponse> {
|
|
172
|
-
return this.request(
|
|
173
|
-
'GET',
|
|
174
|
-
endpoint,
|
|
175
|
-
responseSchema,
|
|
176
|
-
undefined,
|
|
177
|
-
undefined,
|
|
178
|
-
signal,
|
|
179
|
-
extraHeaders
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* POST request with optional body
|
|
185
|
-
*/
|
|
186
|
-
async post<TResponse = void, TBody = unknown>(
|
|
187
|
-
endpoint: string,
|
|
188
|
-
body?: TBody,
|
|
189
|
-
responseSchema?: z.ZodType<TResponse>,
|
|
190
|
-
bodySchema?: z.ZodType<TBody>,
|
|
191
|
-
signal?: AbortSignal,
|
|
192
|
-
extraHeaders?: Record<string, string>
|
|
193
|
-
): Promise<TResponse> {
|
|
194
|
-
return this.request('POST', endpoint, responseSchema, body, bodySchema, signal, extraHeaders);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* PUT request with optional body
|
|
199
|
-
*/
|
|
200
|
-
async put<TResponse = void, TBody = unknown>(
|
|
201
|
-
endpoint: string,
|
|
202
|
-
body?: TBody,
|
|
203
|
-
responseSchema?: z.ZodType<TResponse>,
|
|
204
|
-
bodySchema?: z.ZodType<TBody>,
|
|
205
|
-
signal?: AbortSignal,
|
|
206
|
-
extraHeaders?: Record<string, string>
|
|
207
|
-
): Promise<TResponse> {
|
|
208
|
-
return this.request('PUT', endpoint, responseSchema, body, bodySchema, signal, extraHeaders);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* DELETE request
|
|
213
|
-
*/
|
|
214
|
-
async delete<TResponse = void>(
|
|
215
|
-
endpoint: string,
|
|
216
|
-
responseSchema?: z.ZodType<TResponse>,
|
|
217
|
-
signal?: AbortSignal,
|
|
218
|
-
extraHeaders?: Record<string, string>
|
|
219
|
-
): Promise<TResponse> {
|
|
220
|
-
return this.request(
|
|
221
|
-
'DELETE',
|
|
222
|
-
endpoint,
|
|
223
|
-
responseSchema,
|
|
224
|
-
undefined,
|
|
225
|
-
undefined,
|
|
226
|
-
signal,
|
|
227
|
-
extraHeaders
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* PATCH request with optional body
|
|
233
|
-
*/
|
|
234
|
-
async patch<TResponse = void, TBody = unknown>(
|
|
235
|
-
endpoint: string,
|
|
236
|
-
body?: TBody,
|
|
237
|
-
responseSchema?: z.ZodType<TResponse>,
|
|
238
|
-
bodySchema?: z.ZodType<TBody>,
|
|
239
|
-
signal?: AbortSignal,
|
|
240
|
-
extraHeaders?: Record<string, string>
|
|
241
|
-
): Promise<TResponse> {
|
|
242
|
-
return this.request(
|
|
243
|
-
'PATCH',
|
|
244
|
-
endpoint,
|
|
245
|
-
responseSchema,
|
|
246
|
-
body,
|
|
247
|
-
bodySchema,
|
|
248
|
-
signal,
|
|
249
|
-
extraHeaders
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Raw GET request that returns the Response object directly.
|
|
255
|
-
* Useful for streaming responses where you need access to the body stream.
|
|
256
|
-
*/
|
|
257
|
-
async rawGet(
|
|
258
|
-
endpoint: string,
|
|
259
|
-
signal?: AbortSignal,
|
|
260
|
-
extraHeaders?: Record<string, string>
|
|
261
|
-
): Promise<Response> {
|
|
262
|
-
return this.#makeRequest('GET', endpoint, undefined, signal, undefined, extraHeaders);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Raw POST request that returns the Response object directly.
|
|
267
|
-
* Useful for binary uploads where you need to pass raw body data.
|
|
268
|
-
*/
|
|
269
|
-
async rawPost(
|
|
270
|
-
endpoint: string,
|
|
271
|
-
body: Uint8Array | ArrayBuffer | ReadableStream<Uint8Array> | string,
|
|
272
|
-
contentType: string,
|
|
273
|
-
signal?: AbortSignal
|
|
274
|
-
): Promise<Response> {
|
|
275
|
-
return this.#makeRequest('POST', endpoint, body, signal, contentType);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Raw PUT request that returns the Response object directly.
|
|
280
|
-
* Useful for binary uploads where you need to pass raw body data.
|
|
281
|
-
*/
|
|
282
|
-
async rawPut(
|
|
283
|
-
endpoint: string,
|
|
284
|
-
body: Uint8Array | ArrayBuffer | ReadableStream<Uint8Array> | string | Blob,
|
|
285
|
-
contentType: string,
|
|
286
|
-
signal?: AbortSignal,
|
|
287
|
-
extraHeaders?: Record<string, string>
|
|
288
|
-
): Promise<Response> {
|
|
289
|
-
return this.#makeRequest('PUT', endpoint, body, signal, contentType, extraHeaders);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Generic request method (prefer HTTP verb methods: get, post, put, delete, patch)
|
|
294
|
-
*/
|
|
295
|
-
async request<TResponse = void, TBody = unknown>(
|
|
296
|
-
method: string,
|
|
297
|
-
endpoint: string,
|
|
298
|
-
responseSchema?: z.ZodType<TResponse>,
|
|
299
|
-
body?: TBody,
|
|
300
|
-
bodySchema?: z.ZodType<TBody>,
|
|
301
|
-
signal?: AbortSignal,
|
|
302
|
-
extraHeaders?: Record<string, string>
|
|
303
|
-
): Promise<TResponse> {
|
|
304
|
-
// Validate request body if schema provided
|
|
305
|
-
if (body !== undefined && bodySchema) {
|
|
306
|
-
const validationResult = bodySchema.safeParse(body);
|
|
307
|
-
if (!validationResult.success) {
|
|
308
|
-
throw new ValidationInputError({
|
|
309
|
-
url: endpoint,
|
|
310
|
-
issues: toIssues(validationResult.error.issues),
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const response = await this.#makeRequest(
|
|
316
|
-
method,
|
|
317
|
-
endpoint,
|
|
318
|
-
body,
|
|
319
|
-
signal,
|
|
320
|
-
undefined,
|
|
321
|
-
extraHeaders
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
// Handle empty responses (204 or zero-length body)
|
|
325
|
-
let data: unknown;
|
|
326
|
-
if (response.status === 204 || response.headers.get('content-length') === '0') {
|
|
327
|
-
data = null;
|
|
328
|
-
} else {
|
|
329
|
-
const text = await response.text();
|
|
330
|
-
if (text === '') {
|
|
331
|
-
data = null;
|
|
332
|
-
} else {
|
|
333
|
-
const contentType = response.headers.get('content-type');
|
|
334
|
-
if (contentType?.includes('application/json')) {
|
|
335
|
-
data = JSON.parse(text);
|
|
336
|
-
} else {
|
|
337
|
-
data = text;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if (responseSchema) {
|
|
343
|
-
// Validate response
|
|
344
|
-
const validationResult = responseSchema.safeParse(data);
|
|
345
|
-
if (!validationResult.success) {
|
|
346
|
-
throw new ValidationOutputError({
|
|
347
|
-
url: endpoint,
|
|
348
|
-
issues: toIssues(validationResult.error.issues),
|
|
349
|
-
sessionId: response.headers.get('x-session-id'),
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
return validationResult.data;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
return undefined as TResponse;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
async #makeRequest(
|
|
360
|
-
method: string,
|
|
361
|
-
endpoint: string,
|
|
362
|
-
body?: unknown,
|
|
363
|
-
signal?: AbortSignal,
|
|
364
|
-
contentType?: string,
|
|
365
|
-
extraHeaders?: Record<string, string>
|
|
366
|
-
): Promise<Response> {
|
|
367
|
-
this.#logger.trace('sending %s to %s%s', method, this.#baseUrl, endpoint);
|
|
368
|
-
|
|
369
|
-
const maxRetries = this.#config?.maxRetries ?? 3;
|
|
370
|
-
const baseDelayMs = this.#config?.retryDelayMs ?? 100;
|
|
371
|
-
const serviceUnavailableTimeoutMs = this.#config?.serviceUnavailableTimeoutMs ?? 30_000;
|
|
372
|
-
|
|
373
|
-
// Track when we first see a 502/503 so we can retry for up to the timeout
|
|
374
|
-
let serviceUnavailableStart: number | null = null;
|
|
375
|
-
|
|
376
|
-
const url = `${this.#baseUrl}${endpoint}`;
|
|
377
|
-
const headers: Record<string, string> = {
|
|
378
|
-
'Content-Type': contentType ?? 'application/json',
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
// Only set Accept header for JSON requests (not binary uploads)
|
|
382
|
-
if (!contentType || contentType === 'application/json') {
|
|
383
|
-
headers['Accept'] = 'application/json';
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
if (this.#config?.userAgent) {
|
|
387
|
-
headers['User-Agent'] = this.#config.userAgent;
|
|
388
|
-
} else {
|
|
389
|
-
headers['User-Agent'] = getUserAgent();
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
if (this.#apiKey) {
|
|
393
|
-
headers['Authorization'] = `Bearer ${this.#apiKey}`;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (this.#config?.headers) {
|
|
397
|
-
Object.keys(this.#config.headers).forEach((key) => {
|
|
398
|
-
const value = this.#config?.headers?.[key];
|
|
399
|
-
if (value !== undefined) {
|
|
400
|
-
headers[key] = value;
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// Apply per-request extra headers (e.g., x-agentuity-orgid for CLI auth)
|
|
406
|
-
if (extraHeaders) {
|
|
407
|
-
Object.keys(extraHeaders).forEach((key) => {
|
|
408
|
-
const value = extraHeaders[key];
|
|
409
|
-
if (value !== undefined) {
|
|
410
|
-
headers[key] = value;
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
const canRetry = !(body instanceof ReadableStream); // we cannot safely retry a ReadableStream as body
|
|
416
|
-
|
|
417
|
-
let attempt = 0;
|
|
418
|
-
while (true) {
|
|
419
|
-
try {
|
|
420
|
-
let response: Response;
|
|
421
|
-
|
|
422
|
-
try {
|
|
423
|
-
let requestBody:
|
|
424
|
-
| Uint8Array
|
|
425
|
-
| ArrayBuffer
|
|
426
|
-
| ReadableStream<Uint8Array>
|
|
427
|
-
| string
|
|
428
|
-
| Blob
|
|
429
|
-
| undefined;
|
|
430
|
-
if (body !== undefined) {
|
|
431
|
-
if (contentType && contentType !== 'application/json') {
|
|
432
|
-
requestBody = body as
|
|
433
|
-
| Uint8Array
|
|
434
|
-
| ArrayBuffer
|
|
435
|
-
| ReadableStream<Uint8Array>
|
|
436
|
-
| string
|
|
437
|
-
| Blob;
|
|
438
|
-
} else {
|
|
439
|
-
requestBody = JSON.stringify(body);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
response = await fetch(url, {
|
|
444
|
-
method,
|
|
445
|
-
headers,
|
|
446
|
-
body: requestBody,
|
|
447
|
-
signal,
|
|
448
|
-
});
|
|
449
|
-
} catch (ex) {
|
|
450
|
-
this.#logger.debug('fetch returned an error trying to access: %s. %s', url, ex);
|
|
451
|
-
const _ex = ex as { code?: string; name: string };
|
|
452
|
-
let retryable = false;
|
|
453
|
-
// Check for retryable network errors
|
|
454
|
-
if (_ex.code === 'ConnectionRefused' || _ex.code === 'ECONNREFUSED') {
|
|
455
|
-
retryable = true;
|
|
456
|
-
} else if (_ex.name === 'TypeError' || ex instanceof TypeError) {
|
|
457
|
-
// TypeError from fetch typically indicates network issues
|
|
458
|
-
retryable = true;
|
|
459
|
-
}
|
|
460
|
-
if (retryable) {
|
|
461
|
-
response = new Response(null, { status: 503 });
|
|
462
|
-
} else {
|
|
463
|
-
throw new APIError({
|
|
464
|
-
url,
|
|
465
|
-
status: 0,
|
|
466
|
-
cause: ex,
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
const sessionId = response.headers.get('x-session-id');
|
|
472
|
-
|
|
473
|
-
// Handle 421 Misdirected Request - the resource is in a different region
|
|
474
|
-
// We need to retry against the correct regional Catalyst
|
|
475
|
-
// Only handle this for Catalyst URLs (not the main API)
|
|
476
|
-
if (response.status === 421 && this.#isCatalystUrl()) {
|
|
477
|
-
const targetRegion = response.headers.get('x-agentuity-region');
|
|
478
|
-
if (targetRegion && canRetry) {
|
|
479
|
-
const regionalUrl = this.#buildRegionalUrl(targetRegion, endpoint);
|
|
480
|
-
this.#logger.debug(
|
|
481
|
-
`Got 421 Misdirected Request, resource is in region ${targetRegion}, retrying against ${regionalUrl} (sessionId: ${sessionId ?? null})`
|
|
482
|
-
);
|
|
483
|
-
|
|
484
|
-
// Retry the request against the correct regional Catalyst
|
|
485
|
-
let requestBody:
|
|
486
|
-
| Uint8Array
|
|
487
|
-
| ArrayBuffer
|
|
488
|
-
| ReadableStream<Uint8Array>
|
|
489
|
-
| string
|
|
490
|
-
| Blob
|
|
491
|
-
| undefined;
|
|
492
|
-
if (body !== undefined) {
|
|
493
|
-
if (contentType && contentType !== 'application/json') {
|
|
494
|
-
requestBody = body as
|
|
495
|
-
| Uint8Array
|
|
496
|
-
| ArrayBuffer
|
|
497
|
-
| ReadableStream<Uint8Array>
|
|
498
|
-
| string
|
|
499
|
-
| Blob;
|
|
500
|
-
} else {
|
|
501
|
-
requestBody = JSON.stringify(body);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
const regionalResponse = await fetch(regionalUrl, {
|
|
506
|
-
method,
|
|
507
|
-
headers,
|
|
508
|
-
body: requestBody,
|
|
509
|
-
signal,
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
// If the regional request also fails with 421, throw MisdirectedRequestError
|
|
513
|
-
if (regionalResponse.status === 421) {
|
|
514
|
-
throw new MisdirectedRequestError({
|
|
515
|
-
url: regionalUrl,
|
|
516
|
-
region: targetRegion,
|
|
517
|
-
sessionId: regionalResponse.headers.get('x-session-id'),
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
// For all other responses (success or error), assign to response
|
|
522
|
-
// and let the normal flow handle it (error handling, validation, etc.)
|
|
523
|
-
response = regionalResponse;
|
|
524
|
-
} else {
|
|
525
|
-
// No region header or can't retry - throw error
|
|
526
|
-
throw new MisdirectedRequestError({
|
|
527
|
-
url,
|
|
528
|
-
region: targetRegion ?? 'unknown',
|
|
529
|
-
sessionId,
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
// 502/503 indicate the service is restarting (hot-swap) — retry
|
|
535
|
-
// for up to serviceUnavailableTimeoutMs (default 30s) with a
|
|
536
|
-
// slower backoff (1s base) so we survive typical restart windows.
|
|
537
|
-
const isServiceUnavailable = response.status === 502 || response.status === 503;
|
|
538
|
-
|
|
539
|
-
if (isServiceUnavailable && canRetry) {
|
|
540
|
-
if (serviceUnavailableStart === null) {
|
|
541
|
-
serviceUnavailableStart = Date.now();
|
|
542
|
-
}
|
|
543
|
-
const elapsed = Date.now() - serviceUnavailableStart;
|
|
544
|
-
if (elapsed < serviceUnavailableTimeoutMs) {
|
|
545
|
-
// Use 1s base delay with exponential backoff, capped at 5s
|
|
546
|
-
const delayMs = Math.min(this.#getRetryDelay(attempt, 1000), 5000);
|
|
547
|
-
this.#logger.debug(
|
|
548
|
-
`Got ${response.status} sending to ${url}, service unavailable for ${Math.round(elapsed / 1000)}s, retrying (will delay ${delayMs}ms), sessionId: ${sessionId ?? null}`
|
|
549
|
-
);
|
|
550
|
-
await this.#sleep(delayMs);
|
|
551
|
-
attempt++;
|
|
552
|
-
continue;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// Check if we should retry on specific status codes (409, 501)
|
|
557
|
-
const retryableStatuses = [409, 501];
|
|
558
|
-
if (canRetry && retryableStatuses.includes(response.status) && attempt < maxRetries) {
|
|
559
|
-
let delayMs = this.#getRetryDelay(attempt, baseDelayMs);
|
|
560
|
-
|
|
561
|
-
// For 409, check for rate limit headers
|
|
562
|
-
if (response.status === 409) {
|
|
563
|
-
const rateLimitDelay = this.#getRateLimitDelay(response);
|
|
564
|
-
if (rateLimitDelay !== null) {
|
|
565
|
-
delayMs = rateLimitDelay;
|
|
566
|
-
this.#logger.debug(
|
|
567
|
-
`Got 409 sending to ${url} with rate limit headers, waiting ${delayMs}ms (attempt ${attempt + 1}/${maxRetries + 1}, will delay ${delayMs}ms), sessionId: ${sessionId ?? null}`
|
|
568
|
-
);
|
|
569
|
-
} else {
|
|
570
|
-
this.#logger.debug(
|
|
571
|
-
`Got 409 sending to ${url}, retrying with backoff ${delayMs}ms (attempt ${attempt + 1}/${maxRetries + 1}, will delay ${delayMs}ms), sessionId: ${sessionId ?? null}`
|
|
572
|
-
);
|
|
573
|
-
}
|
|
574
|
-
} else {
|
|
575
|
-
this.#logger.debug(
|
|
576
|
-
`Got ${response.status} sending to ${url}, retrying (attempt ${attempt + 1}/${maxRetries + 1}, will delay ${delayMs}ms), sessionId: ${sessionId ?? null}`
|
|
577
|
-
);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
await this.#sleep(delayMs);
|
|
581
|
-
|
|
582
|
-
this.#logger.debug(`after sleep for ${url}, sessionId: ${sessionId ?? null}`);
|
|
583
|
-
|
|
584
|
-
attempt++;
|
|
585
|
-
continue;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
// Handle error responses
|
|
589
|
-
if (!response.ok) {
|
|
590
|
-
const responseBody = await response.text();
|
|
591
|
-
const contentType = response.headers.get('content-type');
|
|
592
|
-
|
|
593
|
-
let errorData: z.infer<typeof APIErrorSchema> | undefined;
|
|
594
|
-
|
|
595
|
-
// Only attempt to parse as JSON if the content type indicates JSON
|
|
596
|
-
const isJsonResponse =
|
|
597
|
-
contentType?.includes('application/json') || contentType?.includes('+json');
|
|
598
|
-
|
|
599
|
-
if (isJsonResponse) {
|
|
600
|
-
try {
|
|
601
|
-
errorData = APIErrorSchema.parse(JSON.parse(responseBody));
|
|
602
|
-
} catch (parseEx) {
|
|
603
|
-
// Log at debug level since this is a contract violation from the server
|
|
604
|
-
this.#logger.debug(
|
|
605
|
-
'Failed to parse JSON error response from API: %s (url: %s, sessionId: %s)',
|
|
606
|
-
parseEx,
|
|
607
|
-
url,
|
|
608
|
-
sessionId
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
} else {
|
|
612
|
-
// Non-JSON response (e.g., HTML error page), skip structured error parsing
|
|
613
|
-
this.#logger.debug(
|
|
614
|
-
'Received non-JSON error response (content-type: %s), skipping structured error parsing (url: %s, sessionId: %s)',
|
|
615
|
-
contentType ?? 'unknown',
|
|
616
|
-
url,
|
|
617
|
-
sessionId
|
|
618
|
-
);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// Sanitize headers to avoid leaking API keys
|
|
622
|
-
const sanitizedHeaders = { ...headers };
|
|
623
|
-
for (const key in sanitizedHeaders) {
|
|
624
|
-
const lk = key.toLowerCase();
|
|
625
|
-
if (
|
|
626
|
-
lk === 'authorization' ||
|
|
627
|
-
lk === 'x-api-key' ||
|
|
628
|
-
lk.includes('secret') ||
|
|
629
|
-
lk.includes('key') ||
|
|
630
|
-
lk.includes('token')
|
|
631
|
-
) {
|
|
632
|
-
sanitizedHeaders[key] = 'REDACTED';
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
this.#logger.debug('API Error Details:');
|
|
637
|
-
this.#logger.debug(' URL:', url);
|
|
638
|
-
this.#logger.debug(' Method:', method);
|
|
639
|
-
this.#logger.debug(' Status:', response.status, response.statusText);
|
|
640
|
-
this.#logger.debug(' Headers:', JSON.stringify(sanitizedHeaders, null, 2));
|
|
641
|
-
this.#logger.debug(' Response:', responseBody);
|
|
642
|
-
|
|
643
|
-
// HTTP 426 always forces upgrade (cannot be skipped - emergency upgrade path)
|
|
644
|
-
if (response.status === 426) {
|
|
645
|
-
throw new UpgradeRequiredError({ sessionId });
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
// HTTP 402 Payment Required - user needs to upgrade their plan
|
|
649
|
-
if (response.status === 402) {
|
|
650
|
-
const upgradeUrl = response.headers.get('x-upgrade-url');
|
|
651
|
-
throw new PaymentRequiredError({
|
|
652
|
-
url,
|
|
653
|
-
sessionId,
|
|
654
|
-
upgradeUrl: upgradeUrl ?? undefined,
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
// Check for UPGRADE_REQUIRED error
|
|
659
|
-
if (errorData?.code === 'UPGRADE_REQUIRED') {
|
|
660
|
-
// Skip version check if configured
|
|
661
|
-
if (this.#config?.skipVersionCheck) {
|
|
662
|
-
this.#logger.debug('Skipping version check (configured to skip)');
|
|
663
|
-
// Request is still rejected, but throw UpgradeRequiredError so callers
|
|
664
|
-
// can detect it and handle UI behavior (e.g., suppress banner) based on skip flag
|
|
665
|
-
throw new UpgradeRequiredError({ sessionId });
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
throw new UpgradeRequiredError({ sessionId });
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
// Handle Zod validation errors from the API
|
|
672
|
-
if (
|
|
673
|
-
typeof errorData?.error === 'object' &&
|
|
674
|
-
errorData?.error?.name === 'ZodError' &&
|
|
675
|
-
errorData.error.issues
|
|
676
|
-
) {
|
|
677
|
-
throw new ValidationOutputError({
|
|
678
|
-
url,
|
|
679
|
-
issues: errorData.error.issues,
|
|
680
|
-
sessionId,
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
// Throw with message from API if available
|
|
685
|
-
if (errorData?.message) {
|
|
686
|
-
throw new APIError({
|
|
687
|
-
url,
|
|
688
|
-
status: response.status,
|
|
689
|
-
message:
|
|
690
|
-
typeof errorData.error === 'string'
|
|
691
|
-
? errorData.error
|
|
692
|
-
: (errorData.message ??
|
|
693
|
-
'The API encountered an unexpected error attempting to reach the service.'),
|
|
694
|
-
sessionId,
|
|
695
|
-
});
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
// Provide status-aware fallback messages when no structured error data is available
|
|
699
|
-
throw new APIError({
|
|
700
|
-
message: this.#getStatusAwareErrorMessage(
|
|
701
|
-
response.status,
|
|
702
|
-
isJsonResponse ?? false
|
|
703
|
-
),
|
|
704
|
-
url: url,
|
|
705
|
-
status: response.status,
|
|
706
|
-
sessionId,
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
this.#logger.debug('%s succeeded with status: %d', url, response.status);
|
|
711
|
-
|
|
712
|
-
// Successful response; handle empty bodies (e.g., 204 No Content)
|
|
713
|
-
if (response.status === 204 || response.headers.get('content-length') === '0') {
|
|
714
|
-
return new Response(null, { status: 204 });
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
return response;
|
|
718
|
-
} catch (error) {
|
|
719
|
-
this.#logger.debug('error sending to %s: %s', url, error);
|
|
720
|
-
|
|
721
|
-
// Check if it's a retryable connection error
|
|
722
|
-
const isRetryable = this.#isRetryableError(error);
|
|
723
|
-
|
|
724
|
-
if (isRetryable && attempt < maxRetries) {
|
|
725
|
-
this.#logger.debug(
|
|
726
|
-
`Connection error, retrying (attempt ${attempt + 1}/${maxRetries + 1}):`,
|
|
727
|
-
error
|
|
728
|
-
);
|
|
729
|
-
await this.#sleep(this.#getRetryDelay(attempt, baseDelayMs));
|
|
730
|
-
attempt++;
|
|
731
|
-
continue;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
throw error;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
#isRetryableError(error: unknown): boolean {
|
|
740
|
-
if (error && typeof error === 'object') {
|
|
741
|
-
const err = error as { code?: string; errno?: number };
|
|
742
|
-
// Retryable connection errors
|
|
743
|
-
return (
|
|
744
|
-
err.code === 'ECONNRESET' ||
|
|
745
|
-
err.code === 'ETIMEDOUT' ||
|
|
746
|
-
err.code === 'ECONNREFUSED' ||
|
|
747
|
-
err.code === 'ENOTFOUND'
|
|
748
|
-
);
|
|
749
|
-
}
|
|
750
|
-
return false;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
#getRetryDelay(attempt: number, baseDelayMs: number): number {
|
|
754
|
-
// Exponential backoff with jitter: delay = base * 2^attempt * (0.5 + random(0, 0.5))
|
|
755
|
-
const exponentialDelay = baseDelayMs * Math.pow(2, attempt);
|
|
756
|
-
const jitter = 0.5 + Math.random() * 0.5;
|
|
757
|
-
return Math.floor(exponentialDelay * jitter);
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
#sleep(ms: number): Promise<void> {
|
|
761
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
/**
|
|
765
|
-
* Check if the base URL is a Catalyst URL.
|
|
766
|
-
* We only handle 421 Misdirected Request for Catalyst URLs, not the main API.
|
|
767
|
-
*/
|
|
768
|
-
#isCatalystUrl(): boolean {
|
|
769
|
-
try {
|
|
770
|
-
const url = new URL(this.#baseUrl);
|
|
771
|
-
return url.hostname.includes('catalyst');
|
|
772
|
-
} catch {
|
|
773
|
-
return false;
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* Build a URL for a specific regional Catalyst instance.
|
|
779
|
-
* Used when retrying requests that received 421 Misdirected Request.
|
|
780
|
-
*/
|
|
781
|
-
#buildRegionalUrl(region: string, endpoint: string): string {
|
|
782
|
-
// Determine the domain suffix based on region
|
|
783
|
-
const isLocal = region === 'local' || region === 'l';
|
|
784
|
-
const domainSuffix = isLocal ? 'agentuity.io' : 'agentuity.cloud';
|
|
785
|
-
|
|
786
|
-
// Build the regional Catalyst URL
|
|
787
|
-
// For local: https://catalyst.agentuity.io
|
|
788
|
-
// For production: https://catalyst-{region}.agentuity.cloud
|
|
789
|
-
const baseUrl = isLocal
|
|
790
|
-
? `https://catalyst.${domainSuffix}`
|
|
791
|
-
: `https://catalyst-${region}.${domainSuffix}`;
|
|
792
|
-
|
|
793
|
-
return `${baseUrl}${endpoint}`;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
#getRateLimitDelay(response: Response): number | null {
|
|
797
|
-
// Check for Retry-After header (standard HTTP)
|
|
798
|
-
const retryAfter = response.headers.get('Retry-After');
|
|
799
|
-
if (retryAfter) {
|
|
800
|
-
// Can be either seconds or HTTP date
|
|
801
|
-
const seconds = parseInt(retryAfter, 10);
|
|
802
|
-
if (!Number.isNaN(seconds)) {
|
|
803
|
-
return seconds * 1000; // Convert to milliseconds
|
|
804
|
-
}
|
|
805
|
-
// Try parsing as HTTP date
|
|
806
|
-
const retryDate = new Date(retryAfter);
|
|
807
|
-
if (!Number.isNaN(retryDate.getTime())) {
|
|
808
|
-
const delayMs = retryDate.getTime() - Date.now();
|
|
809
|
-
return Math.max(0, delayMs);
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
// Check for X-RateLimit-Reset (Unix timestamp in seconds)
|
|
814
|
-
const rateLimitReset = response.headers.get('X-RateLimit-Reset');
|
|
815
|
-
if (rateLimitReset) {
|
|
816
|
-
const resetTime = parseInt(rateLimitReset, 10);
|
|
817
|
-
if (!Number.isNaN(resetTime)) {
|
|
818
|
-
const delayMs = resetTime * 1000 - Date.now();
|
|
819
|
-
return Math.max(0, delayMs);
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
// Check for X-RateLimit-Retry-After (seconds)
|
|
824
|
-
const rateLimitRetryAfter = response.headers.get('X-RateLimit-Retry-After');
|
|
825
|
-
if (rateLimitRetryAfter) {
|
|
826
|
-
const seconds = parseInt(rateLimitRetryAfter, 10);
|
|
827
|
-
if (!Number.isNaN(seconds)) {
|
|
828
|
-
return seconds * 1000;
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
return null;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
#getStatusAwareErrorMessage(status: number, isJsonResponse: boolean): string {
|
|
836
|
-
// Provide helpful, status-specific error messages
|
|
837
|
-
switch (status) {
|
|
838
|
-
case 400:
|
|
839
|
-
return 'The API request was invalid (HTTP 400). Please check your request parameters.';
|
|
840
|
-
case 401:
|
|
841
|
-
return 'Authentication failed (HTTP 401). Please check your credentials or try logging in again.';
|
|
842
|
-
case 402:
|
|
843
|
-
return 'This action requires a paid plan. Please upgrade your account at https://app.agentuity.com/billing to continue.';
|
|
844
|
-
case 403:
|
|
845
|
-
return 'Access denied (HTTP 403). You do not have permission to perform this action.';
|
|
846
|
-
case 404:
|
|
847
|
-
return isJsonResponse
|
|
848
|
-
? 'The requested resource was not found (HTTP 404).'
|
|
849
|
-
: 'The API endpoint was not found (HTTP 404). Please verify your API URL configuration is correct.';
|
|
850
|
-
case 409:
|
|
851
|
-
return 'A conflict occurred (HTTP 409). The resource may already exist or be in use.';
|
|
852
|
-
case 429:
|
|
853
|
-
return 'Too many requests (HTTP 429). Please wait a moment and try again.';
|
|
854
|
-
case 500:
|
|
855
|
-
return 'The API server encountered an internal error (HTTP 500). Please try again later.';
|
|
856
|
-
case 502:
|
|
857
|
-
return 'The API service is temporarily unavailable (HTTP 502). Please try again later.';
|
|
858
|
-
case 503:
|
|
859
|
-
return 'The API service is currently unavailable (HTTP 503). Please try again later.';
|
|
860
|
-
case 504:
|
|
861
|
-
return 'The API request timed out (HTTP 504). Please try again later.';
|
|
862
|
-
default:
|
|
863
|
-
return `The API returned an unexpected error (HTTP ${status}).`;
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
export function getAPIBaseURL(region?: string, overrides?: { api_url?: string }): string {
|
|
869
|
-
if (process.env.AGENTUITY_API_URL) {
|
|
870
|
-
return process.env.AGENTUITY_API_URL;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
if (overrides?.api_url) {
|
|
874
|
-
return overrides.api_url;
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
if (region === 'local') {
|
|
878
|
-
return 'https://api.agentuity.io';
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
return 'https://api.agentuity.com';
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
export function getAppBaseURL(region?: string, overrides?: { app_url?: string } | null): string {
|
|
885
|
-
if (process.env.AGENTUITY_APP_URL) {
|
|
886
|
-
return process.env.AGENTUITY_APP_URL;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
if (overrides?.app_url) {
|
|
890
|
-
return overrides.app_url;
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
if (region === 'local') {
|
|
894
|
-
return 'https://app.agentuity.io';
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
return 'https://app.agentuity.com';
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
export const APIResponseSchema = <T extends z.ZodType>(dataSchema: T) =>
|
|
901
|
-
z.discriminatedUnion('success', [
|
|
902
|
-
z.object({
|
|
903
|
-
success: z.literal<false>(false),
|
|
904
|
-
message: z.string().describe('the error message'),
|
|
905
|
-
code: z.string().optional().describe('machine-readable error code'),
|
|
906
|
-
}),
|
|
907
|
-
z.object({
|
|
908
|
-
success: z.literal<true>(true),
|
|
909
|
-
data: dataSchema,
|
|
910
|
-
}),
|
|
911
|
-
]);
|
|
912
|
-
|
|
913
|
-
export const APIResponseSchemaOptionalData = <T extends z.ZodType>(dataSchema: T) =>
|
|
914
|
-
z.discriminatedUnion('success', [
|
|
915
|
-
z.object({
|
|
916
|
-
success: z.literal<false>(false),
|
|
917
|
-
message: z.string().describe('the error message'),
|
|
918
|
-
code: z.string().optional().describe('machine-readable error code'),
|
|
919
|
-
}),
|
|
920
|
-
z.object({
|
|
921
|
-
success: z.literal<true>(true),
|
|
922
|
-
data: dataSchema.optional(),
|
|
923
|
-
}),
|
|
924
|
-
]);
|
|
925
|
-
|
|
926
|
-
export const APIResponseSchemaNoData = () =>
|
|
927
|
-
z.discriminatedUnion('success', [
|
|
928
|
-
z.object({
|
|
929
|
-
success: z.literal<false>(false),
|
|
930
|
-
message: z.string().describe('the error message'),
|
|
931
|
-
code: z.string().optional().describe('machine-readable error code'),
|
|
932
|
-
}),
|
|
933
|
-
z.object({
|
|
934
|
-
success: z.literal<true>(true),
|
|
935
|
-
}),
|
|
936
|
-
]);
|
|
1
|
+
export * from '@agentuity/core';
|