@dxos/edge-client 0.9.0 → 0.9.1-main.c7dcc2e112
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/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/cors-proxy.mjs +1 -0
- package/dist/lib/neutral/edge-ws-muxer.mjs +1 -0
- package/dist/lib/neutral/index.mjs +82 -7
- package/dist/lib/neutral/index.mjs.map +3 -3
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/service/index.mjs +134 -0
- package/dist/lib/neutral/service/index.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +1 -0
- package/dist/lib/neutral/testing/index.mjs.map +1 -1
- package/dist/types/src/edge-ai-http-client.d.ts +39 -0
- package/dist/types/src/edge-ai-http-client.d.ts.map +1 -1
- package/dist/types/src/edge-ai-http-client.test.d.ts +2 -0
- package/dist/types/src/edge-ai-http-client.test.d.ts.map +1 -0
- package/dist/types/src/edge-http-client.d.ts +17 -2
- package/dist/types/src/edge-http-client.d.ts.map +1 -1
- package/dist/types/src/hub-http-client.d.ts +8 -1
- package/dist/types/src/hub-http-client.d.ts.map +1 -1
- package/dist/types/src/service/Image.d.ts +25 -0
- package/dist/types/src/service/Image.d.ts.map +1 -0
- package/dist/types/src/service/edge-service.d.ts +36 -0
- package/dist/types/src/service/edge-service.d.ts.map +1 -0
- package/dist/types/src/service/edge-service.test.d.ts +2 -0
- package/dist/types/src/service/edge-service.test.d.ts.map +1 -0
- package/dist/types/src/service/image-service.e2e.test.d.ts +2 -0
- package/dist/types/src/service/image-service.e2e.test.d.ts.map +1 -0
- package/dist/types/src/service/index.d.ts +3 -0
- package/dist/types/src/service/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -15
- package/src/edge-ai-http-client.test.ts +37 -0
- package/src/edge-ai-http-client.ts +87 -2
- package/src/edge-http-client.ts +18 -6
- package/src/hub-http-client.ts +20 -0
- package/src/service/Image.ts +61 -0
- package/src/service/edge-service.test.ts +151 -0
- package/src/service/edge-service.ts +139 -0
- package/src/service/image-service.e2e.test.ts +53 -0
- package/src/service/index.ts +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/cors-proxy.ts":{"bytes":5060,"imports":[],"format":"esm"},"src/protocol.ts":{"bytes":9826,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/defs.ts":{"bytes":1470,"imports":[{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"src/edge-ws-muxer.ts":{"bytes":29236,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"}],"format":"esm"},"src/auth.ts":{"bytes":11980,"imports":[{"path":"@dxos/credentials","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"src/edge-identity.ts":{"bytes":3761,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true}],"format":"esm"},"src/edge-ws-connection.ts":{"bytes":36161,"imports":[{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"src/edge-ws-muxer.ts","kind":"import-statement","original":"./edge-ws-muxer"},{"path":"src/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"src/errors.ts":{"bytes":1106,"imports":[],"format":"esm"},"src/utils.ts":{"bytes":1317,"imports":[],"format":"esm"},"src/edge-client.ts":{"bytes":39693,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"src/edge-identity.ts","kind":"import-statement","original":"./edge-identity"},{"path":"src/edge-ws-connection.ts","kind":"import-statement","original":"./edge-ws-connection"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/http-client.ts":{"bytes":7215,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schedule","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/base-http-client.ts":{"bytes":27427,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"src/edge-identity.ts","kind":"import-statement","original":"./edge-identity"},{"path":"src/http-client.ts","kind":"import-statement","original":"./http-client"},{"path":"src/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/edge-ai-http-client.ts":{"bytes":16882,"imports":[{"path":"@effect/platform/Headers","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientError","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientResponse","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/FiberRef","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true}],"format":"esm"},"src/edge-http-client.ts":{"bytes":47558,"imports":[{"path":"@effect/platform/FetchHttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientRequest","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/base-http-client.ts","kind":"import-statement","original":"./base-http-client"},{"path":"src/cors-proxy.ts","kind":"import-statement","original":"./cors-proxy"},{"path":"src/http-client.ts","kind":"import-statement","original":"./http-client"}],"format":"esm"},"src/hub-http-client.ts":{"bytes":11880,"imports":[{"path":"src/base-http-client.ts","kind":"import-statement","original":"./base-http-client"}],"format":"esm"},"src/index.ts":{"bytes":1718,"imports":[{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/auth.ts","kind":"import-statement","original":"./auth"},{"path":"src/cors-proxy.ts","kind":"import-statement","original":"./cors-proxy"},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"src/edge-client.ts","kind":"import-statement","original":"./edge-client"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/protocol.ts","kind":"import-statement","original":"./protocol"},{"path":"src/base-http-client.ts","kind":"import-statement","original":"./base-http-client"},{"path":"src/edge-ai-http-client.ts","kind":"import-statement","original":"./edge-ai-http-client"},{"path":"src/edge-http-client.ts","kind":"import-statement","original":"./edge-http-client"},{"path":"src/hub-http-client.ts","kind":"import-statement","original":"./hub-http-client"},{"path":"src/edge-identity.ts","kind":"import-statement","original":"./edge-identity"},{"path":"src/edge-ws-muxer.ts","kind":"import-statement","original":"./edge-ws-muxer"},{"path":"src/http-client.ts","kind":"import-statement","original":"./http-client"}],"format":"esm"},"src/testing/test-server.ts":{"bytes":4454,"imports":[{"path":"@dxos/node-std/http","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/testing/test-utils.ts":{"bytes":13633,"imports":[{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"../defs"},{"path":"src/edge-ws-muxer.ts","kind":"import-statement","original":"../edge-ws-muxer"},{"path":"src/protocol.ts","kind":"import-statement","original":"../protocol"}],"format":"esm"},"src/testing/index.ts":{"bytes":477,"imports":[{"path":"src/testing/test-server.ts","kind":"import-statement","original":"./test-server"},{"path":"src/testing/test-utils.ts","kind":"import-statement","original":"./test-utils"}],"format":"esm"}},"outputs":{"dist/lib/neutral/cors-proxy.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/cors-proxy.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-WQKMEZJR.mjs","kind":"import-statement"}],"exports":["proxyFetchLegacy"],"entryPoint":"src/cors-proxy.ts","inputs":{},"bytes":130},"dist/lib/neutral/edge-ws-muxer.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/edge-ws-muxer.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-L5ZHLJ4B.mjs","kind":"import-statement"}],"exports":["CLOUDFLARE_MESSAGE_MAX_BYTES","CLOUDFLARE_RPC_MAX_BYTES","WebSocketMuxer"],"entryPoint":"src/edge-ws-muxer.ts","inputs":{},"bytes":249},"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":97880},"dist/lib/neutral/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-WQKMEZJR.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-L5ZHLJ4B.mjs","kind":"import-statement"},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/credentials","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schedule","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@effect/platform/Headers","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientError","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientResponse","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/FiberRef","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@effect/platform/FetchHttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientRequest","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["BaseHttpClient","ByokError","CLOUDFLARE_MESSAGE_MAX_BYTES","CLOUDFLARE_RPC_MAX_BYTES","EdgeAiHttpClient","EdgeClient","EdgeConnectionClosedError","EdgeHttpClient","EdgeIdentityChangedError","HttpConfig","HubHttpClient","Protocol","WebSocketMuxer","createChainEdgeIdentity","createDeviceEdgeIdentity","createEphemeralEdgeIdentity","createStubEdgeIdentity","createTestHaloEdgeIdentity","encodeAuthHeader","getTypename","handleAuthChallenge","protocol","proxyFetchLegacy","requestInitTagKey","toUint8Array","withLogging","withRetry","withRetryConfig"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":60},"src/auth.ts":{"bytesInOutput":2919},"src/edge-client.ts":{"bytesInOutput":10071},"src/edge-identity.ts":{"bytesInOutput":1120},"src/edge-ws-connection.ts":{"bytesInOutput":9708},"src/errors.ts":{"bytesInOutput":232},"src/utils.ts":{"bytesInOutput":244},"src/base-http-client.ts":{"bytesInOutput":6930},"src/http-client.ts":{"bytesInOutput":1536},"src/edge-ai-http-client.ts":{"bytesInOutput":3218},"src/edge-http-client.ts":{"bytesInOutput":10298},"src/hub-http-client.ts":{"bytesInOutput":2147}},"bytes":49671},"dist/lib/neutral/chunk-WQKMEZJR.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2574},"dist/lib/neutral/chunk-WQKMEZJR.mjs":{"imports":[],"exports":["proxyFetchLegacy"],"inputs":{"src/cors-proxy.ts":{"bytesInOutput":868}},"bytes":965},"dist/lib/neutral/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":8926},"dist/lib/neutral/testing/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-L5ZHLJ4B.mjs","kind":"import-statement"},{"path":"@dxos/node-std/http","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true}],"exports":["DEFAULT_PORT","createTestEdgeWsServer","createTestServer","responseHandler"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/test-server.ts":{"bytesInOutput":1115},"src/testing/index.ts":{"bytesInOutput":0},"src/testing/test-utils.ts":{"bytesInOutput":3534}},"bytes":4923},"dist/lib/neutral/chunk-L5ZHLJ4B.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18947},"dist/lib/neutral/chunk-L5ZHLJ4B.mjs":{"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["CLOUDFLARE_MESSAGE_MAX_BYTES","CLOUDFLARE_RPC_MAX_BYTES","Protocol","WebSocketMuxer","getTypename","protocol","toUint8Array"],"inputs":{"src/edge-ws-muxer.ts":{"bytesInOutput":7443},"src/defs.ts":{"bytesInOutput":298},"src/protocol.ts":{"bytesInOutput":2520}},"bytes":10551}}}
|
|
1
|
+
{"inputs":{"src/cors-proxy.ts":{"bytes":5060,"imports":[],"format":"esm"},"src/protocol.ts":{"bytes":9826,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/defs.ts":{"bytes":1470,"imports":[{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"src/edge-ws-muxer.ts":{"bytes":29236,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"}],"format":"esm"},"src/auth.ts":{"bytes":11980,"imports":[{"path":"@dxos/credentials","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"src/edge-identity.ts":{"bytes":3761,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true}],"format":"esm"},"src/edge-ws-connection.ts":{"bytes":36161,"imports":[{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"src/edge-ws-muxer.ts","kind":"import-statement","original":"./edge-ws-muxer"},{"path":"src/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"src/errors.ts":{"bytes":1106,"imports":[],"format":"esm"},"src/utils.ts":{"bytes":1317,"imports":[],"format":"esm"},"src/edge-client.ts":{"bytes":39693,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"src/edge-identity.ts","kind":"import-statement","original":"./edge-identity"},{"path":"src/edge-ws-connection.ts","kind":"import-statement","original":"./edge-ws-connection"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/http-client.ts":{"bytes":7215,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schedule","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/base-http-client.ts":{"bytes":27427,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"src/edge-identity.ts","kind":"import-statement","original":"./edge-identity"},{"path":"src/http-client.ts","kind":"import-statement","original":"./http-client"},{"path":"src/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/edge-ai-http-client.ts":{"bytes":25932,"imports":[{"path":"@effect/platform/Headers","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientError","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientResponse","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/FiberRef","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true}],"format":"esm"},"src/edge-http-client.ts":{"bytes":48288,"imports":[{"path":"@effect/platform/FetchHttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientRequest","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/base-http-client.ts","kind":"import-statement","original":"./base-http-client"},{"path":"src/cors-proxy.ts","kind":"import-statement","original":"./cors-proxy"},{"path":"src/http-client.ts","kind":"import-statement","original":"./http-client"}],"format":"esm"},"src/hub-http-client.ts":{"bytes":13661,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/base-http-client.ts","kind":"import-statement","original":"./base-http-client"}],"format":"esm"},"src/index.ts":{"bytes":1718,"imports":[{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/auth.ts","kind":"import-statement","original":"./auth"},{"path":"src/cors-proxy.ts","kind":"import-statement","original":"./cors-proxy"},{"path":"src/defs.ts","kind":"import-statement","original":"./defs"},{"path":"src/edge-client.ts","kind":"import-statement","original":"./edge-client"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/protocol.ts","kind":"import-statement","original":"./protocol"},{"path":"src/base-http-client.ts","kind":"import-statement","original":"./base-http-client"},{"path":"src/edge-ai-http-client.ts","kind":"import-statement","original":"./edge-ai-http-client"},{"path":"src/edge-http-client.ts","kind":"import-statement","original":"./edge-http-client"},{"path":"src/hub-http-client.ts","kind":"import-statement","original":"./hub-http-client"},{"path":"src/edge-identity.ts","kind":"import-statement","original":"./edge-identity"},{"path":"src/edge-ws-muxer.ts","kind":"import-statement","original":"./edge-ws-muxer"},{"path":"src/http-client.ts","kind":"import-statement","original":"./http-client"}],"format":"esm"},"src/service/edge-service.ts":{"bytes":17547,"imports":[{"path":"effect/Data","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true}],"format":"esm"},"src/service/Image.ts":{"bytes":5369,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true}],"format":"esm"},"src/service/index.ts":{"bytes":522,"imports":[{"path":"src/service/edge-service.ts","kind":"import-statement","original":"./edge-service"},{"path":"src/service/Image.ts","kind":"import-statement","original":"./Image"}],"format":"esm"},"src/testing/test-server.ts":{"bytes":4454,"imports":[{"path":"@dxos/node-std/http","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/testing/test-utils.ts":{"bytes":13633,"imports":[{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"src/defs.ts","kind":"import-statement","original":"../defs"},{"path":"src/edge-ws-muxer.ts","kind":"import-statement","original":"../edge-ws-muxer"},{"path":"src/protocol.ts","kind":"import-statement","original":"../protocol"}],"format":"esm"},"src/testing/index.ts":{"bytes":477,"imports":[{"path":"src/testing/test-server.ts","kind":"import-statement","original":"./test-server"},{"path":"src/testing/test-utils.ts","kind":"import-statement","original":"./test-utils"}],"format":"esm"}},"outputs":{"dist/lib/neutral/cors-proxy.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/cors-proxy.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-WQKMEZJR.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"}],"exports":["proxyFetchLegacy"],"entryPoint":"src/cors-proxy.ts","inputs":{},"bytes":161},"dist/lib/neutral/edge-ws-muxer.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/edge-ws-muxer.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-L5ZHLJ4B.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"}],"exports":["CLOUDFLARE_MESSAGE_MAX_BYTES","CLOUDFLARE_RPC_MAX_BYTES","WebSocketMuxer"],"entryPoint":"src/edge-ws-muxer.ts","inputs":{},"bytes":280},"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":103446},"dist/lib/neutral/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-WQKMEZJR.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-L5ZHLJ4B.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/credentials","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keyring","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schedule","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@effect/platform/Headers","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientError","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientResponse","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/FiberRef","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@effect/platform/FetchHttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientRequest","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["BaseHttpClient","ByokError","CLOUDFLARE_MESSAGE_MAX_BYTES","CLOUDFLARE_RPC_MAX_BYTES","EdgeAiHttpClient","EdgeClient","EdgeConnectionClosedError","EdgeHttpClient","EdgeIdentityChangedError","HttpConfig","HubHttpClient","Protocol","UsageQuotaExceededError","WebSocketMuxer","createChainEdgeIdentity","createDeviceEdgeIdentity","createEphemeralEdgeIdentity","createStubEdgeIdentity","createTestHaloEdgeIdentity","encodeAuthHeader","getTypename","handleAuthChallenge","patchAnthropicMessagesRequestBody","protocol","proxyFetchLegacy","requestInitTagKey","toUint8Array","withLogging","withRetry","withRetryConfig"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":60},"src/auth.ts":{"bytesInOutput":2919},"src/edge-client.ts":{"bytesInOutput":10071},"src/edge-identity.ts":{"bytesInOutput":1120},"src/edge-ws-connection.ts":{"bytesInOutput":9708},"src/errors.ts":{"bytesInOutput":232},"src/utils.ts":{"bytesInOutput":244},"src/base-http-client.ts":{"bytesInOutput":6930},"src/http-client.ts":{"bytesInOutput":1536},"src/edge-ai-http-client.ts":{"bytesInOutput":5001},"src/edge-http-client.ts":{"bytesInOutput":10562},"src/hub-http-client.ts":{"bytesInOutput":2632}},"bytes":52298},"dist/lib/neutral/chunk-WQKMEZJR.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2574},"dist/lib/neutral/chunk-WQKMEZJR.mjs":{"imports":[],"exports":["proxyFetchLegacy"],"inputs":{"src/cors-proxy.ts":{"bytesInOutput":868}},"bytes":965},"dist/lib/neutral/service/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":11386},"dist/lib/neutral/service/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"effect/Data","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true}],"exports":["EdgeServiceClient","EdgeServiceError","Image"],"entryPoint":"src/service/index.ts","inputs":{"src/service/edge-service.ts":{"bytesInOutput":3307},"src/service/index.ts":{"bytesInOutput":0},"src/service/Image.ts":{"bytesInOutput":782}},"bytes":4311},"dist/lib/neutral/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":8927},"dist/lib/neutral/testing/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-L5ZHLJ4B.mjs","kind":"import-statement"},{"path":"dist/lib/neutral/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"@dxos/node-std/http","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"isomorphic-ws","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true}],"exports":["DEFAULT_PORT","createTestEdgeWsServer","createTestServer","responseHandler"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/test-server.ts":{"bytesInOutput":1115},"src/testing/index.ts":{"bytesInOutput":0},"src/testing/test-utils.ts":{"bytesInOutput":3534}},"bytes":4955},"dist/lib/neutral/chunk-L5ZHLJ4B.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18947},"dist/lib/neutral/chunk-L5ZHLJ4B.mjs":{"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf","kind":"import-statement","external":true},{"path":"@dxos/protocols/buf/dxos/edge/messenger_pb","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["CLOUDFLARE_MESSAGE_MAX_BYTES","CLOUDFLARE_RPC_MAX_BYTES","Protocol","WebSocketMuxer","getTypename","protocol","toUint8Array"],"inputs":{"src/edge-ws-muxer.ts":{"bytesInOutput":7443},"src/defs.ts":{"bytesInOutput":298},"src/protocol.ts":{"bytesInOutput":2520}},"bytes":10551},"dist/lib/neutral/chunk-J5LGTIGS.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/chunk-J5LGTIGS.mjs":{"imports":[],"exports":["__export"],"inputs":{},"bytes":235}}}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "../chunk-J5LGTIGS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/service/edge-service.ts
|
|
6
|
+
import * as Data from "effect/Data";
|
|
7
|
+
import * as Duration from "effect/Duration";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
var EDGE_CLIENT_TAG_HEADER = "X-DXOS-Client-Tag";
|
|
11
|
+
var DEFAULT_TIMEOUT = Duration.seconds(15);
|
|
12
|
+
var ERROR_BODY_LIMIT = 512;
|
|
13
|
+
var EdgeServiceError = class extends Data.TaggedError("EdgeServiceError") {
|
|
14
|
+
};
|
|
15
|
+
var EdgeServiceClient = class {
|
|
16
|
+
#baseUrl;
|
|
17
|
+
#clientTag;
|
|
18
|
+
#timeout;
|
|
19
|
+
#fetch;
|
|
20
|
+
#authHeaders;
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.#baseUrl = options.baseUrl;
|
|
23
|
+
this.#clientTag = options.clientTag;
|
|
24
|
+
this.#timeout = Duration.decode(options.timeout ?? DEFAULT_TIMEOUT);
|
|
25
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
26
|
+
this.#fetch = fetchImpl.bind(globalThis);
|
|
27
|
+
this.#authHeaders = options.authHeaders;
|
|
28
|
+
}
|
|
29
|
+
get baseUrl() {
|
|
30
|
+
return this.#baseUrl;
|
|
31
|
+
}
|
|
32
|
+
/** POST a `FormData` (multipart) body and decode the JSON response. */
|
|
33
|
+
postForm(path, form, schema) {
|
|
34
|
+
return this.#request(path, schema, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
body: form
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** POST a JSON body and decode the JSON response. */
|
|
40
|
+
postJson(path, body, schema) {
|
|
41
|
+
return Effect.try({
|
|
42
|
+
try: () => JSON.stringify(body),
|
|
43
|
+
catch: (cause) => new EdgeServiceError({
|
|
44
|
+
message: "Failed to serialize JSON request body",
|
|
45
|
+
cause
|
|
46
|
+
})
|
|
47
|
+
}).pipe(Effect.flatMap((json) => this.#request(path, schema, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
body: json,
|
|
50
|
+
headers: {
|
|
51
|
+
"Content-Type": "application/json"
|
|
52
|
+
}
|
|
53
|
+
})));
|
|
54
|
+
}
|
|
55
|
+
#request(path, schema, init) {
|
|
56
|
+
return Effect.gen(this, function* () {
|
|
57
|
+
const url = new URL(path, this.#baseUrl);
|
|
58
|
+
const headers = new Headers(init.headers ?? void 0);
|
|
59
|
+
if (this.#clientTag) {
|
|
60
|
+
headers.set(EDGE_CLIENT_TAG_HEADER, this.#clientTag);
|
|
61
|
+
}
|
|
62
|
+
if (this.#authHeaders) {
|
|
63
|
+
const auth = yield* this.#authHeaders();
|
|
64
|
+
for (const [key, value] of Object.entries(auth)) {
|
|
65
|
+
headers.set(key, value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const response = yield* Effect.tryPromise({
|
|
69
|
+
try: (signal) => this.#fetch(url, {
|
|
70
|
+
...init,
|
|
71
|
+
headers,
|
|
72
|
+
signal
|
|
73
|
+
}),
|
|
74
|
+
catch: (cause) => new EdgeServiceError({
|
|
75
|
+
message: `Request to ${url.pathname} failed`,
|
|
76
|
+
cause
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
const detail = yield* Effect.promise(() => response.text().catch(() => "")).pipe(Effect.map((text) => text.slice(0, ERROR_BODY_LIMIT)));
|
|
81
|
+
return yield* new EdgeServiceError({
|
|
82
|
+
message: `Service responded ${response.status}${detail ? `: ${detail}` : ""}`,
|
|
83
|
+
status: response.status
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const json = yield* Effect.tryPromise({
|
|
87
|
+
try: () => response.json(),
|
|
88
|
+
catch: (cause) => new EdgeServiceError({
|
|
89
|
+
message: "Failed to parse JSON response",
|
|
90
|
+
status: response.status,
|
|
91
|
+
cause
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
return yield* Schema.decodeUnknown(schema)(json).pipe(Effect.mapError((cause) => new EdgeServiceError({
|
|
95
|
+
message: "Response did not match expected schema",
|
|
96
|
+
status: response.status,
|
|
97
|
+
cause
|
|
98
|
+
})));
|
|
99
|
+
}).pipe(Effect.timeoutFail({
|
|
100
|
+
duration: this.#timeout,
|
|
101
|
+
onTimeout: () => new EdgeServiceError({
|
|
102
|
+
message: `Request to ${path} timed out`
|
|
103
|
+
})
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// src/service/Image.ts
|
|
109
|
+
var Image_exports = {};
|
|
110
|
+
__export(Image_exports, {
|
|
111
|
+
DEFAULT_IMAGE_SERVICE_URL: () => DEFAULT_IMAGE_SERVICE_URL,
|
|
112
|
+
Result: () => Result,
|
|
113
|
+
thumbnail: () => thumbnail,
|
|
114
|
+
upload: () => upload
|
|
115
|
+
});
|
|
116
|
+
import * as Schema2 from "effect/Schema";
|
|
117
|
+
var DEFAULT_IMAGE_SERVICE_URL = "https://image-service-main.dxos.workers.dev";
|
|
118
|
+
var Result = Schema2.Struct({
|
|
119
|
+
id: Schema2.optional(Schema2.String),
|
|
120
|
+
url: Schema2.String
|
|
121
|
+
});
|
|
122
|
+
var upload = (client, blob, opts) => uploadToPath(client, blob, "/upload", opts);
|
|
123
|
+
var thumbnail = (client, blob, opts) => uploadToPath(client, blob, "/thumbnail", opts);
|
|
124
|
+
var uploadToPath = (client, blob, path, opts) => {
|
|
125
|
+
const form = new FormData();
|
|
126
|
+
form.append(opts?.field ?? "file", blob, opts?.filename ?? "image");
|
|
127
|
+
return client.postForm(path, form, Result);
|
|
128
|
+
};
|
|
129
|
+
export {
|
|
130
|
+
EdgeServiceClient,
|
|
131
|
+
EdgeServiceError,
|
|
132
|
+
Image_exports as Image
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/service/edge-service.ts", "../../../../src/service/Image.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\n// Lightweight client for EDGE-hosted HTTP services — intentionally free of the\n// heavy transitive dependencies (`@dxos/context`, `@dxos/protocols`) that\n// `BaseHttpClient` pulls in, so it bundles cleanly into browser / workerd. The\n// only runtime dependencies are `effect` and `@dxos/log`.\n\nimport * as Data from 'effect/Data';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\n// Matches EDGE_CLIENT_TAG_HEADER from @dxos/protocols. Duplicated here (as in\n// `cors-proxy`) to avoid importing the heavy protocols bundle.\nconst EDGE_CLIENT_TAG_HEADER = 'X-DXOS-Client-Tag';\n\nconst DEFAULT_TIMEOUT = Duration.seconds(15);\n\n/** Number of body characters retained for the error message on a non-2xx response. */\nconst ERROR_BODY_LIMIT = 512;\n\nexport type EdgeServiceClientOptions = {\n /** Base URL the service is hosted at; request paths resolve against it. */\n baseUrl: string;\n /** Tag included in the {@link EDGE_CLIENT_TAG_HEADER} header for metering. */\n clientTag?: string;\n /** Per-request timeout. */\n timeout?: Duration.DurationInput;\n /** Injectable for deterministic tests; defaults to `globalThis.fetch`. */\n fetch?: typeof globalThis.fetch;\n /** Auth seam invoked per request; unused by the image service today. */\n authHeaders?: () => Effect.Effect<Record<string, string>>;\n};\n\n/** Single failure type for every transport, status, and decode error. */\nexport class EdgeServiceError extends Data.TaggedError('EdgeServiceError')<{\n message: string;\n status?: number;\n cause?: unknown;\n}> {}\n\nexport class EdgeServiceClient {\n readonly #baseUrl: string;\n readonly #clientTag: string | undefined;\n readonly #timeout: Duration.Duration;\n readonly #fetch: typeof globalThis.fetch;\n readonly #authHeaders: (() => Effect.Effect<Record<string, string>>) | undefined;\n\n constructor(options: EdgeServiceClientOptions) {\n this.#baseUrl = options.baseUrl;\n this.#clientTag = options.clientTag;\n this.#timeout = Duration.decode(options.timeout ?? DEFAULT_TIMEOUT);\n // Bind so `fetch` keeps its expected `this` when injected as a method reference.\n const fetchImpl = options.fetch ?? globalThis.fetch;\n this.#fetch = fetchImpl.bind(globalThis);\n this.#authHeaders = options.authHeaders;\n }\n\n get baseUrl(): string {\n return this.#baseUrl;\n }\n\n /** POST a `FormData` (multipart) body and decode the JSON response. */\n postForm<A>(path: string, form: FormData, schema: Schema.Schema<A>): Effect.Effect<A, EdgeServiceError> {\n // The runtime sets `Content-Type: multipart/form-data` with the boundary;\n // setting it manually here would omit the boundary and break parsing.\n return this.#request(path, schema, { method: 'POST', body: form });\n }\n\n /** POST a JSON body and decode the JSON response. */\n postJson<A>(path: string, body: unknown, schema: Schema.Schema<A>): Effect.Effect<A, EdgeServiceError> {\n // Serialize inside the Effect so a circular/non-serializable body surfaces as\n // EdgeServiceError rather than throwing synchronously from the call site.\n return Effect.try({\n try: () => JSON.stringify(body),\n catch: (cause) => new EdgeServiceError({ message: 'Failed to serialize JSON request body', cause }),\n }).pipe(\n Effect.flatMap((json) =>\n this.#request(path, schema, {\n method: 'POST',\n body: json,\n headers: { 'Content-Type': 'application/json' },\n }),\n ),\n );\n }\n\n #request<A>(path: string, schema: Schema.Schema<A>, init: RequestInit): Effect.Effect<A, EdgeServiceError> {\n return Effect.gen(this, function* () {\n const url = new URL(path, this.#baseUrl);\n const headers = new Headers(init.headers ?? undefined);\n if (this.#clientTag) {\n headers.set(EDGE_CLIENT_TAG_HEADER, this.#clientTag);\n }\n if (this.#authHeaders) {\n const auth = yield* this.#authHeaders();\n for (const [key, value] of Object.entries(auth)) {\n headers.set(key, value);\n }\n }\n\n const response = yield* Effect.tryPromise({\n try: (signal) => this.#fetch(url, { ...init, headers, signal }),\n catch: (cause) => new EdgeServiceError({ message: `Request to ${url.pathname} failed`, cause }),\n });\n\n if (!response.ok) {\n // Body text aids debugging but may be large; truncate and never throw on read.\n const detail = yield* Effect.promise(() => response.text().catch(() => '')).pipe(\n Effect.map((text) => text.slice(0, ERROR_BODY_LIMIT)),\n );\n return yield* new EdgeServiceError({\n message: `Service responded ${response.status}${detail ? `: ${detail}` : ''}`,\n status: response.status,\n });\n }\n\n const json = yield* Effect.tryPromise({\n try: () => response.json(),\n catch: (cause) =>\n new EdgeServiceError({ message: 'Failed to parse JSON response', status: response.status, cause }),\n });\n\n return yield* Schema.decodeUnknown(schema)(json).pipe(\n Effect.mapError(\n (cause) =>\n new EdgeServiceError({ message: 'Response did not match expected schema', status: response.status, cause }),\n ),\n );\n }).pipe(\n Effect.timeoutFail({\n duration: this.#timeout,\n onTimeout: () => new EdgeServiceError({ message: `Request to ${path} timed out` }),\n }),\n );\n }\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\n// Image service helpers built on the generic {@link EdgeServiceClient}. The\n// worker exposes two contract-identical routes (`/upload` and `/thumbnail`,\n// both returning `{ id, url }`); we mirror them so callers stay on whichever\n// route they already use.\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { type EdgeServiceClient, type EdgeServiceError } from './edge-service';\n\n/**\n * Default Composer image-service base URL — the Cloudflare Worker used in\n * production. Override per-environment via the client's `baseUrl`.\n */\n// TODO(burdon): Get from config.\nexport const DEFAULT_IMAGE_SERVICE_URL = 'https://image-service-main.dxos.workers.dev';\n\n/** Hosted image returned by the service: a CDN `url` and its storage `id`. */\nexport const Result = Schema.Struct({\n id: Schema.optional(Schema.String),\n url: Schema.String,\n});\nexport type Result = typeof Result.Type;\n\nexport type UploadOptions = {\n /** Multipart field name. */\n field?: string;\n /** Upload filename. */\n filename?: string;\n};\n\n/** Store an image and return its hosted CDN URL (POST `/upload`). */\nexport const upload = (\n client: EdgeServiceClient,\n blob: Blob,\n opts?: UploadOptions,\n): Effect.Effect<Result, EdgeServiceError> => uploadToPath(client, blob, '/upload', opts);\n\n/** Store an image and create a thumbnail, returning its hosted CDN URL (POST `/thumbnail`). */\nexport const thumbnail = (\n client: EdgeServiceClient,\n blob: Blob,\n opts?: UploadOptions,\n): Effect.Effect<Result, EdgeServiceError> => uploadToPath(client, blob, '/thumbnail', opts);\n\nconst uploadToPath = (\n client: EdgeServiceClient,\n blob: Blob,\n path: string,\n opts?: UploadOptions,\n): Effect.Effect<Result, EdgeServiceError> => {\n const form = new FormData();\n form.append(opts?.field ?? 'file', blob, opts?.filename ?? 'image');\n return client.postForm(path, form, Result);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AASA,YAAYA,UAAU;AACtB,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,YAAY;AAIxB,IAAMC,yBAAyB;AAE/B,IAAMC,kBAA2BC,iBAAQ,EAAA;AAGzC,IAAMC,mBAAmB;AAgBlB,IAAMC,mBAAN,cAAoCC,iBAAY,kBAAA,EAAA;AAInD;AAEG,IAAMC,oBAAN,MAAMA;EACF;EACA;EACA;EACA;EACA;EAET,YAAYC,SAAmC;AAC7C,SAAK,WAAWA,QAAQC;AACxB,SAAK,aAAaD,QAAQE;AAC1B,SAAK,WAAoBC,gBAAOH,QAAQI,WAAWV,eAAAA;AAEnD,UAAMW,YAAYL,QAAQM,SAASC,WAAWD;AAC9C,SAAK,SAASD,UAAUG,KAAKD,UAAAA;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;AACjBD,OAAKE,OAAON,MAAMO,SAAS,QAAQR,MAAMC,MAAMQ,YAAY,OAAA;AAC3D,SAAOV,OAAOW,SAASN,MAAMC,MAAMb,MAAAA;AACrC;",
|
|
6
|
+
"names": ["Data", "Duration", "Effect", "Schema", "EDGE_CLIENT_TAG_HEADER", "DEFAULT_TIMEOUT", "seconds", "ERROR_BODY_LIMIT", "EdgeServiceError", "TaggedError", "EdgeServiceClient", "options", "baseUrl", "clientTag", "decode", "timeout", "fetchImpl", "fetch", "globalThis", "bind", "authHeaders", "postForm", "path", "form", "schema", "method", "body", "postJson", "try", "JSON", "stringify", "catch", "cause", "message", "pipe", "flatMap", "json", "headers", "init", "gen", "url", "URL", "Headers", "undefined", "set", "auth", "key", "value", "Object", "entries", "response", "tryPromise", "signal", "pathname", "ok", "detail", "promise", "text", "map", "slice", "status", "decodeUnknown", "mapError", "timeoutFail", "duration", "onTimeout", "Schema", "DEFAULT_IMAGE_SERVICE_URL", "Result", "Struct", "id", "optional", "String", "url", "upload", "client", "blob", "opts", "uploadToPath", "thumbnail", "path", "form", "FormData", "append", "field", "filename", "postForm"]
|
|
7
|
+
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/testing/test-server.ts", "../../../../src/testing/test-utils.ts"],
|
|
4
4
|
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport http from 'node:http';\n\nimport { log } from '@dxos/log';\n\nexport type TestServer = {\n url: string;\n close: () => void;\n};\n\nexport type ResponseHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void;\n\nexport const createTestServer = (responseHandler: ResponseHandler) => {\n const server = http.createServer(responseHandler);\n\n return new Promise<TestServer>((resolve) => {\n server.listen(0, () => {\n const address = server.address();\n const port = typeof address === 'object' && address ? address.port : 0;\n resolve({\n url: `http://localhost:${port}`,\n close: () => server.close(),\n });\n });\n });\n};\n\nexport const responseHandler = (cb: (attempt: number) => false | object): ResponseHandler => {\n let attempt = 0;\n return (req, res) => {\n const data = cb(++attempt) ?? {};\n if (data === false) {\n log('simulating failure', { attempt });\n res.statusCode = 500;\n res.statusMessage = 'Simulating failure';\n res.end('');\n } else {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ success: true, data }));\n }\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport WebSocket from 'isomorphic-ws';\n\nimport { Trigger } from '@dxos/async';\nimport { log } from '@dxos/log';\nimport { EdgeWebsocketProtocol } from '@dxos/protocols';\nimport { buf } from '@dxos/protocols/buf';\nimport { type Message, MessageSchema, TextMessageSchema } from '@dxos/protocols/buf/dxos/edge/messenger_pb';\n\nimport { protocol } from '../defs';\nimport { WebSocketMuxer } from '../edge-ws-muxer';\nimport { toUint8Array } from '../protocol';\n\nexport const DEFAULT_PORT = 8080;\n\ntype TestEdgeWsServerProps = {\n admitConnection?: Trigger;\n payloadDecoder?: (payload: Uint8Array) => any;\n messageHandler?: (payload: any) => Promise<Uint8Array | undefined>;\n};\n\nexport const createTestEdgeWsServer = async (port = DEFAULT_PORT, params?: TestEdgeWsServerProps) => {\n const wsServer = new WebSocket.Server({\n port,\n verifyClient: createConnectionDelayHandler(params),\n handleProtocols: () => EdgeWebsocketProtocol.V1,\n });\n\n let connection: { ws: WebSocket; muxer: WebSocketMuxer } | undefined;\n\n const messageSink: any[] = [];\n const messageSourceLog: any[] = [];\n const closeTrigger = new Trigger();\n const sendResponseMessage = createResponseSender(() => connection!.muxer);\n\n wsServer.on('connection', (ws: WebSocket) => {\n const muxer = new WebSocketMuxer(ws);\n connection = { ws, muxer };\n ws.on('error', (err: Error) => log.catch(err));\n ws.on('message', async (data: any) => {\n if (String(data) === '__ping__') {\n ws.send('__pong__');\n return;\n }\n const message = muxer.receiveData(await toUint8Array(data));\n if (!message) {\n return;\n }\n const { request, requestPayload } = await decodePayload(message, params);\n messageSourceLog.push(request.source);\n if (params?.messageHandler) {\n const responsePayload = await params.messageHandler(requestPayload);\n if (responsePayload && connection) {\n sendResponseMessage(request, responsePayload);\n }\n }\n log('message', { payload: requestPayload });\n messageSink.push(requestPayload);\n });\n\n ws.on('close', () => {\n connection = undefined;\n closeTrigger.wake();\n });\n });\n\n return {\n server: wsServer,\n messageSink,\n messageSourceLog,\n endpoint: `ws://127.0.0.1:${port}`,\n cleanup: () => wsServer.close(),\n currentConnection: () => connection,\n sendResponseMessage,\n sendMessage: (msg: Message) => {\n return connection!.muxer.send(msg);\n },\n closeConnection: () => {\n closeTrigger.reset();\n connection!.ws.close(1011);\n return closeTrigger.wait();\n },\n };\n};\n\nconst createConnectionDelayHandler = (params: TestEdgeWsServerProps | undefined) => {\n return (_: any, callback: (admit: boolean) => void) => {\n if (params?.admitConnection) {\n log('delaying edge connection admission');\n void params.admitConnection.wait().then(() => {\n callback(true);\n log('edge connection admitted');\n });\n } else {\n callback(true);\n }\n };\n};\n\nconst createResponseSender = (connection: () => WebSocketMuxer) => {\n return (request: Message, responsePayload: Uint8Array) => {\n const recipient = request.source!;\n void connection().send(\n buf.create(MessageSchema, {\n source: {\n identityKey: recipient.identityKey,\n peerKey: recipient.peerKey,\n },\n serviceId: request.serviceId!,\n payload: { value: responsePayload },\n }),\n );\n };\n};\n\nconst decodePayload = async (request: Message, params: TestEdgeWsServerProps | undefined) => {\n const requestPayload = params?.payloadDecoder\n ? params.payloadDecoder(request.payload!.value!)\n : protocol.getPayload(request, TextMessageSchema);\n return { request, requestPayload };\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;AAIA,OAAOA,UAAU;AAEjB,SAASC,WAAW;AASpB,IAAA,eAAaC;AAGX,IAAO,mBAAyBC,CAAAA,qBAAAA;QAC9BC,SAAOC,KAAO,aAAGC,gBAAA;aACf,QAAMC,CAAAA,YAAUH;WAChB,OAAMI,GAAO,MAAA;AACbL,YAAAA,UAAQ,OAAA,QAAA;YACNM,OAAM,OAAA,YAAmBD,YAAM,UAAA,QAAA,OAAA;cA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AA,SAAKZ,oBACC0B;UACFC,YAAQ,QAAA;oBACNC,EAAAA,KAAaC,IAAAA,OAAUD,eAAW;cAClCE;QACF,aAAA,UAAA;QACAC,SAAWnB,UAAQmB;MACnBC;iBAAkBrB,QAAAA;MAAgB,SAAA;QACpC,OAAA;MAEJ;IACF,CAAA,CAAA;EAEA;;IAIE,gBAAO,OAAA,SAAA,WAAA;QAAEC,iBAAAA,QAAAA,iBAAAA,OAAAA,eAAAA,QAAAA,QAAAA,KAAAA,IAAAA,SAAAA,WAAAA,SAAAA,iBAAAA;SAASqB;IAAe;IACnC;;;",
|
|
6
6
|
"names": ["http", "log", "createTestServer", "resolve", "server", "listen", "responseHandler", "address", "port", "url", "close", "req", "res", "data", "attempt", "statusCode", "statusMessage", "end", "writeHead", "stringify", "WebSocket", "Trigger", "log", "EdgeWebsocketProtocol", "buf", "MessageSchema", "TextMessageSchema", "__dxlog_file", "DEFAULT_PORT", "wsServer", "WebSocket", "port", "verifyClient", "createConnectionDelayHandler", "handleProtocols", "connection", "closeTrigger", "sendResponseMessage", "ws", "WebSocketMuxer", "muxer", "on", "data", "messageSourceLog", "params", "messageHandler", "responsePayload", "request", "log", "messageSink", "push", "wake", "endpoint", "cleanup", "currentConnection", "sendMessage", "msg", "closeConnection", "close", "admitConnection", "callback", "create", "source", "identityKey", "recipient", "peerKey", "serviceId", "payload", "requestPayload"]
|
|
7
7
|
}
|
|
@@ -42,10 +42,49 @@ export declare class ByokError extends ByokError_base {
|
|
|
42
42
|
provider: string;
|
|
43
43
|
} & BaseErrorOptions);
|
|
44
44
|
}
|
|
45
|
+
declare const UsageQuotaExceededError_base: {
|
|
46
|
+
new (options?: BaseErrorOptions): {
|
|
47
|
+
cause?: unknown;
|
|
48
|
+
stack?: string;
|
|
49
|
+
name: "UsageQuotaExceededError";
|
|
50
|
+
context: Record<string, unknown>;
|
|
51
|
+
readonly message: string;
|
|
52
|
+
readonly _tag: "UsageQuotaExceededError";
|
|
53
|
+
};
|
|
54
|
+
isError(error: unknown): error is Error;
|
|
55
|
+
name: "UsageQuotaExceededError";
|
|
56
|
+
is(error: unknown): error is BaseError;
|
|
57
|
+
wrap(options?: Omit<BaseErrorOptions, 'cause'> & {
|
|
58
|
+
ifTypeDiffers?: boolean;
|
|
59
|
+
}): (error: unknown) => {
|
|
60
|
+
cause?: unknown;
|
|
61
|
+
stack?: string;
|
|
62
|
+
name: "UsageQuotaExceededError";
|
|
63
|
+
context: Record<string, unknown>;
|
|
64
|
+
readonly message: string;
|
|
65
|
+
readonly _tag: "UsageQuotaExceededError";
|
|
66
|
+
};
|
|
67
|
+
extend<Name extends string = string>(name: Name, message?: string): any;
|
|
68
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
69
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
70
|
+
stackTraceLimit: number;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Thrown by {@link EdgeAiHttpClient} when EDGE rejects an AI request with 429 because the
|
|
74
|
+
* authenticated profile exceeded a metering limit. Wrapped as the `cause` of an
|
|
75
|
+
* {@link HttpClientError.ResponseError} so it survives `@effect/ai`'s error mapping.
|
|
76
|
+
*/
|
|
77
|
+
export declare class UsageQuotaExceededError extends UsageQuotaExceededError_base {
|
|
78
|
+
}
|
|
45
79
|
/**
|
|
46
80
|
* Copy pasted from https://github.com/Effect-TS/effect/blob/main/packages/platform/src/internal/fetchHttpClient.ts
|
|
47
81
|
*/
|
|
48
82
|
export declare const requestInitTagKey = "@effect/platform/FetchHttpClient/FetchOptions";
|
|
83
|
+
/**
|
|
84
|
+
* Enables Anthropic fine-grained tool input streaming for client-defined tools.
|
|
85
|
+
* Provider tools (bash, web_search, etc.) are left unchanged.
|
|
86
|
+
*/
|
|
87
|
+
export declare const patchAnthropicMessagesRequestBody: (body: BodyInit | undefined) => BodyInit | undefined;
|
|
49
88
|
/**
|
|
50
89
|
* An `@effect/platform` {@link HttpClient.HttpClient} that routes requests through the
|
|
51
90
|
* authenticated EDGE AI endpoint via {@link EdgeHttpClient.anthropicAiRequest}, instead of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-ai-http-client.d.ts","sourceRoot":"","sources":["../../../src/edge-ai-http-client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAC;AAK1D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,MAAM,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD;;;;;GAKG;AACH,qBAAa,SAAU,SAAQ,cAA2D;IACxF,YAAY,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,gBAAgB,EAE3E;CACF;
|
|
1
|
+
{"version":3,"file":"edge-ai-http-client.d.ts","sourceRoot":"","sources":["../../../src/edge-ai-http-client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAC;AAK1D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,MAAM,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD;;;;;GAKG;AACH,qBAAa,SAAU,SAAQ,cAA2D;IACxF,YAAY,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,gBAAgB,EAE3E;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAED;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,4BAAmE;CAAG;AAEnH;;GAEG;AACH,eAAO,MAAM,iBAAiB,kDAAkD,CAAC;AASjF;;;GAGG;AACH,eAAO,MAAM,iCAAiC,SAAU,QAAQ,GAAG,SAAS,KAAG,QAAQ,GAAG,SAmCzF,CAAC;AAQF;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,IAAI,cAAe,iBAAiB,2BAkGtC;IAEL,MAAM,CAAC,KAAK,cAAe,iBAAiB,sDAC6B;CAC1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-ai-http-client.test.d.ts","sourceRoot":"","sources":["../../../src/edge-ai-http-client.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Context } from '@dxos/context';
|
|
2
2
|
import { type PublicKey, type SpaceId } from '@dxos/keys';
|
|
3
|
-
import { type CompleteOAuthRegistrationRequest, type CompleteOAuthRegistrationResponse, type CreateAgentRequestBody, type CreateAgentResponseBody, type CreateSpaceRequest, type CreateSpaceResponseBody, type EdgeStatus, type ExecuteWorkflowResponseBody, type ExportBundleRequest, type ExportBundleResponse, type FeedProtocol, type GetAgentStatusResponseBody, type GetNotarizationResponseBody, type
|
|
3
|
+
import { type CompleteOAuthRegistrationRequest, type CompleteOAuthRegistrationResponse, type CreateAgentRequestBody, type CreateAgentResponseBody, type CreateSpaceRequest, type CreateSpaceResponseBody, type EdgeStatus, type ExecuteWorkflowResponseBody, type ExportBundleRequest, type ExportBundleResponse, type FeedProtocol, type GetAgentStatusResponseBody, type GetNotarizationResponseBody, type GetPluginsResponseBody, type ImportBundleRequest, type InitiateOAuthFlowRequest, type InitiateOAuthFlowResponse, type JoinSpaceRequest, type JoinSpaceResponseBody, type ObjectId, type PostNotarizationRequestBody, type RecoverIdentityRequest, type RecoverIdentityResponseBody, type UploadFunctionRequest, type UploadFunctionResponseBody } from '@dxos/protocols';
|
|
4
4
|
import { type QueryRequest as QueryRequestProto, type QueryResponse as QueryResponseProto } from '@dxos/protocols/proto/dxos/echo/query';
|
|
5
5
|
import { BaseHttpClient, type BaseHttpClientOptions, type EdgeHttpCallArgs } from './base-http-client';
|
|
6
6
|
export type { EdgeHttpCallArgs, RetryConfig } from './base-http-client';
|
|
@@ -12,6 +12,14 @@ export type EdgeQueryQueueResponse = {
|
|
|
12
12
|
nextCursor?: string;
|
|
13
13
|
prevCursor?: string;
|
|
14
14
|
};
|
|
15
|
+
export type UploadPluginBundleRequest = {
|
|
16
|
+
slug: string;
|
|
17
|
+
version: string;
|
|
18
|
+
files: {
|
|
19
|
+
path: string;
|
|
20
|
+
content: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
15
23
|
export type TriggersDispatcherStatus = {
|
|
16
24
|
isActive: boolean;
|
|
17
25
|
nextCronTaskRunTimestamp?: number;
|
|
@@ -64,7 +72,14 @@ export declare class EdgeHttpClient extends BaseHttpClient {
|
|
|
64
72
|
forceRunCronTrigger(ctx: Context, spaceId: SpaceId, triggerId: ObjectId): Promise<unknown>;
|
|
65
73
|
execQuery(ctx: Context, spaceId: SpaceId, body: QueryRequestProto, args?: EdgeHttpCallArgs): Promise<QueryResponseProto>;
|
|
66
74
|
getRegistryPlugins(ctx: Context, args?: EdgeHttpCallArgs): Promise<GetPluginsResponseBody>;
|
|
67
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Uploads a built plugin bundle to the registry's R2-backed hosting. Authenticated
|
|
77
|
+
* with the caller's hub identity (verifiable presentation) — `setIdentity` must
|
|
78
|
+
* have been called. Returns the canonical `moduleUrl` (the hosted `manifest.json`).
|
|
79
|
+
*/
|
|
80
|
+
uploadPluginBundle(ctx: Context, request: UploadPluginBundleRequest, args?: EdgeHttpCallArgs): Promise<{
|
|
81
|
+
moduleUrl: string;
|
|
82
|
+
}>;
|
|
68
83
|
importBundle(ctx: Context, spaceId: SpaceId, body: ImportBundleRequest, args?: EdgeHttpCallArgs): Promise<void>;
|
|
69
84
|
exportBundle(ctx: Context, spaceId: SpaceId, body: ExportBundleRequest, args?: EdgeHttpCallArgs): Promise<ExportBundleResponse>;
|
|
70
85
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-http-client.d.ts","sourceRoot":"","sources":["../../../src/edge-http-client.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,iCAAiC,EACtC,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAE5B,KAAK,UAAU,EACf,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,
|
|
1
|
+
{"version":3,"file":"edge-http-client.d.ts","sourceRoot":"","sources":["../../../src/edge-http-client.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,iCAAiC,EACtC,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAE5B,KAAK,UAAU,EACf,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,E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E,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAOhC;IAMY,YAAY,CACvB,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,mBAAmB,EACzB,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,IAAI,CAAC,CAEf;IAEY,YAAY,CACvB,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,mBAAmB,EACzB,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,oBAAoB,CAAC,CAE/B;IAMD;;;OAGG;IACU,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE9E;IAMD;;;;;;;OAOG;IAGU,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqCnE;IAMY,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAUtE;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Context } from '@dxos/context';
|
|
2
|
-
import { type CheckEmailExistsResponse, type GetAccountResponse, type IssueInvitationResponse, type ListAccountInvitationsResponse, type LoginRequest, type LoginResponse, type RedeemInvitationCodeRequest, type RedeemInvitationCodeResponse, type RequestAccessRequest, type RequestAccessResponse, type ResendVerificationEmailResponse, type ValidateInvitationCodeResponse } from '@dxos/protocols';
|
|
2
|
+
import { type CheckEmailExistsResponse, type GetAccountResponse, type IssueInvitationResponse, type ListAccountInvitationsResponse, type LoginRequest, type LoginResponse, type RedeemInvitationCodeRequest, type RedeemInvitationCodeResponse, type RequestAccessRequest, type RequestAccessResponse, type GetProfileUsageResponse, type ResendVerificationEmailResponse, type ValidateInvitationCodeResponse } from '@dxos/protocols';
|
|
3
3
|
import { BaseHttpClient, type BaseHttpClientOptions, type EdgeHttpCallArgs } from './base-http-client';
|
|
4
4
|
/**
|
|
5
5
|
* HTTP client for the hub-service API (accounts, invitations, email verification).
|
|
@@ -35,5 +35,12 @@ export declare class HubHttpClient extends BaseHttpClient {
|
|
|
35
35
|
listAccountInvitations(ctx: Context, args?: EdgeHttpCallArgs): Promise<ListAccountInvitationsResponse>;
|
|
36
36
|
issueAccountInvitation(ctx: Context, args?: EdgeHttpCallArgs): Promise<IssueInvitationResponse>;
|
|
37
37
|
resendVerificationEmail(ctx: Context, args?: EdgeHttpCallArgs): Promise<ResendVerificationEmailResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Rolling-window usage and effective limits for the authenticated identity.
|
|
40
|
+
* Served from the per-user metering DO; optional `windowSeconds` defaults to the largest limit window.
|
|
41
|
+
*/
|
|
42
|
+
getProfileUsage(ctx: Context, query?: {
|
|
43
|
+
windowSeconds?: number;
|
|
44
|
+
}, args?: EdgeHttpCallArgs): Promise<GetProfileUsageResponse>;
|
|
38
45
|
}
|
|
39
46
|
//# sourceMappingURL=hub-http-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-http-client.d.ts","sourceRoot":"","sources":["../../../src/hub-http-client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACpC,KAAK,8BAA8B,EACpC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"hub-http-client.d.ts","sourceRoot":"","sources":["../../../src/hub-http-client.ts"],"names":[],"mappings":"AAIA,OAAO,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oBAAoB,EAC1B,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,qBAAqB,CAAC,CAEhC;IAMY,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAE1F;IAEY,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAE/F;IAEY,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAElH;IAEY,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAE3G;IAEY,uBAAuB,CAClC,GAAG,EAAE,OAAO,EACZ,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,+BAA+B,CAAC,CAE1C;IAED;;;OAGG;IACU,eAAe,CAC1B,GAAG,EAAE,OAAO,EACZ,KAAK,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,EAClC,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,uBAAuB,CAAC,CAQlC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as Effect from 'effect/Effect';
|
|
2
|
+
import * as Schema from 'effect/Schema';
|
|
3
|
+
import { type EdgeServiceClient, type EdgeServiceError } from './edge-service';
|
|
4
|
+
/**
|
|
5
|
+
* Default Composer image-service base URL — the Cloudflare Worker used in
|
|
6
|
+
* production. Override per-environment via the client's `baseUrl`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_IMAGE_SERVICE_URL = "https://image-service-main.dxos.workers.dev";
|
|
9
|
+
/** Hosted image returned by the service: a CDN `url` and its storage `id`. */
|
|
10
|
+
export declare const Result: Schema.Struct<{
|
|
11
|
+
id: Schema.optional<typeof Schema.String>;
|
|
12
|
+
url: typeof Schema.String;
|
|
13
|
+
}>;
|
|
14
|
+
export type Result = typeof Result.Type;
|
|
15
|
+
export type UploadOptions = {
|
|
16
|
+
/** Multipart field name. */
|
|
17
|
+
field?: string;
|
|
18
|
+
/** Upload filename. */
|
|
19
|
+
filename?: string;
|
|
20
|
+
};
|
|
21
|
+
/** Store an image and return its hosted CDN URL (POST `/upload`). */
|
|
22
|
+
export declare const upload: (client: EdgeServiceClient, blob: Blob, opts?: UploadOptions) => Effect.Effect<Result, EdgeServiceError>;
|
|
23
|
+
/** Store an image and create a thumbnail, returning its hosted CDN URL (POST `/thumbnail`). */
|
|
24
|
+
export declare const thumbnail: (client: EdgeServiceClient, blob: Blob, opts?: UploadOptions) => Effect.Effect<Result, EdgeServiceError>;
|
|
25
|
+
//# sourceMappingURL=Image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../src/service/Image.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE/E;;;GAGG;AAEH,eAAO,MAAM,yBAAyB,gDAAgD,CAAC;AAEvF,8EAA8E;AAC9E,eAAO,MAAM,MAAM;;;EAGjB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC;AAExC,MAAM,MAAM,aAAa,GAAG;IAC1B,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,MAAM,WACT,iBAAiB,QACnB,IAAI,SACH,aAAa,KACnB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAgD,CAAC;AAE1F,+FAA+F;AAC/F,eAAO,MAAM,SAAS,WACZ,iBAAiB,QACnB,IAAI,SACH,aAAa,KACnB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAmD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Duration from 'effect/Duration';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import * as Schema from 'effect/Schema';
|
|
4
|
+
export type EdgeServiceClientOptions = {
|
|
5
|
+
/** Base URL the service is hosted at; request paths resolve against it. */
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
/** Tag included in the {@link EDGE_CLIENT_TAG_HEADER} header for metering. */
|
|
8
|
+
clientTag?: string;
|
|
9
|
+
/** Per-request timeout. */
|
|
10
|
+
timeout?: Duration.DurationInput;
|
|
11
|
+
/** Injectable for deterministic tests; defaults to `globalThis.fetch`. */
|
|
12
|
+
fetch?: typeof globalThis.fetch;
|
|
13
|
+
/** Auth seam invoked per request; unused by the image service today. */
|
|
14
|
+
authHeaders?: () => Effect.Effect<Record<string, string>>;
|
|
15
|
+
};
|
|
16
|
+
declare const EdgeServiceError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
17
|
+
readonly _tag: "EdgeServiceError";
|
|
18
|
+
} & Readonly<A>;
|
|
19
|
+
/** Single failure type for every transport, status, and decode error. */
|
|
20
|
+
export declare class EdgeServiceError extends EdgeServiceError_base<{
|
|
21
|
+
message: string;
|
|
22
|
+
status?: number;
|
|
23
|
+
cause?: unknown;
|
|
24
|
+
}> {
|
|
25
|
+
}
|
|
26
|
+
export declare class EdgeServiceClient {
|
|
27
|
+
#private;
|
|
28
|
+
constructor(options: EdgeServiceClientOptions);
|
|
29
|
+
get baseUrl(): string;
|
|
30
|
+
/** POST a `FormData` (multipart) body and decode the JSON response. */
|
|
31
|
+
postForm<A>(path: string, form: FormData, schema: Schema.Schema<A>): Effect.Effect<A, EdgeServiceError>;
|
|
32
|
+
/** POST a JSON body and decode the JSON response. */
|
|
33
|
+
postJson<A>(path: string, body: unknown, schema: Schema.Schema<A>): Effect.Effect<A, EdgeServiceError>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=edge-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-service.d.ts","sourceRoot":"","sources":["../../../../src/service/edge-service.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAWxC,MAAM,MAAM,wBAAwB,GAAG;IACrC,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC3D,CAAC;;;;AAEF,yEAAyE;AACzE,qBAAa,gBAAiB,SAAQ,sBAAqC;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;CAAG;AAEL,qBAAa,iBAAiB;;IAO5B,YAAY,OAAO,EAAE,wBAAwB,EAQ5C;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,uEAAuE;IAC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