@dxos/functions 0.8.4-main.03d5cd7b56 → 0.8.4-main.05e74ebcff
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/index.mjs +20 -11
- package/dist/lib/neutral/index.mjs.map +3 -3
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/types/src/protocol/protocol.d.ts +6 -1
- package/dist/types/src/protocol/protocol.d.ts.map +1 -1
- package/dist/types/src/services/credentials.d.ts.map +1 -1
- package/dist/types/src/services/function-invocation-service.d.ts +3 -0
- package/dist/types/src/services/function-invocation-service.d.ts.map +1 -1
- package/dist/types/src/services/queues.d.ts +1 -1
- package/dist/types/src/services/queues.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -16
- package/src/protocol/protocol.ts +28 -1
- package/src/services/credentials.ts +1 -2
- package/src/services/function-invocation-service.ts +3 -0
- package/src/services/queues.ts +1 -1
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -80,4 +80,4 @@ curl http://localhost:7001/dev/hello -X POST -H 'Content-Type: application/json'
|
|
|
80
80
|
|
|
81
81
|
Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
|
|
82
82
|
|
|
83
|
-
License: [
|
|
83
|
+
License: [FSL-1.1-Apache-2.0](./LICENSE) Copyright 2022 © DXOS
|
|
@@ -5,8 +5,7 @@ import * as Effect from "effect/Effect";
|
|
|
5
5
|
import * as Layer from "effect/Layer";
|
|
6
6
|
import * as Redacted from "effect/Redacted";
|
|
7
7
|
import { Credential } from "@dxos/compute";
|
|
8
|
-
import { Query } from "@dxos/echo";
|
|
9
|
-
import { Database } from "@dxos/echo";
|
|
8
|
+
import { Database, Query } from "@dxos/echo";
|
|
10
9
|
import { AccessToken } from "@dxos/types";
|
|
11
10
|
var ConfiguredCredentialsService = class {
|
|
12
11
|
credentials;
|
|
@@ -88,7 +87,7 @@ var FunctionInvocationService = class _FunctionInvocationService extends Context
|
|
|
88
87
|
};
|
|
89
88
|
|
|
90
89
|
// src/services/queues.ts
|
|
91
|
-
import {
|
|
90
|
+
import { QueueService, feedServiceFromQueueServiceLayer } from "@dxos/echo-db";
|
|
92
91
|
|
|
93
92
|
// src/services/tracing.ts
|
|
94
93
|
var MESSAGE_PROPERTY_TOOL_CALL_ID = "toolCallId";
|
|
@@ -122,7 +121,7 @@ import * as Schema from "effect/Schema";
|
|
|
122
121
|
import * as SchemaAST from "effect/SchemaAST";
|
|
123
122
|
import { AiModelResolver, AiService, OpaqueToolkit } from "@dxos/ai";
|
|
124
123
|
import { AnthropicResolver } from "@dxos/ai/resolvers";
|
|
125
|
-
import { FunctionError, InvalidOperationInputError, InvalidOperationOutputError, Operation, OperationRegistry, Trace } from "@dxos/compute";
|
|
124
|
+
import { Blueprint, FunctionError, InvalidOperationInputError, InvalidOperationOutputError, Operation, OperationRegistry, Trace } from "@dxos/compute";
|
|
126
125
|
import { LifecycleState, Resource } from "@dxos/context";
|
|
127
126
|
import { Database as Database2, Feed, JsonSchema, Ref } from "@dxos/echo";
|
|
128
127
|
import { createFeedServiceLayer, EchoClient } from "@dxos/echo-db";
|
|
@@ -348,6 +347,12 @@ var wrapFunctionHandler = (func, opts = {}) => {
|
|
|
348
347
|
if (Effect4.isEffect(result)) {
|
|
349
348
|
result = await runAndForwardErrors(result.pipe(Effect4.orDie, Effect4.provide(funcContext.createLayer())));
|
|
350
349
|
}
|
|
350
|
+
if (serviceTags.includes(Database2.Service.key) && funcContext.db) {
|
|
351
|
+
await funcContext.db.flush({
|
|
352
|
+
disk: true,
|
|
353
|
+
indexes: false
|
|
354
|
+
});
|
|
355
|
+
}
|
|
351
356
|
if (func.output && !SchemaAST.isAnyKeyword(func.output.ast)) {
|
|
352
357
|
try {
|
|
353
358
|
Schema.validateSync(func.output, {
|
|
@@ -428,7 +433,8 @@ var FunctionContext = class extends Resource {
|
|
|
428
433
|
spaceRootUrl: this.context.spaceRootUrl,
|
|
429
434
|
toolkits: this.opts.toolkits?.length ?? 0,
|
|
430
435
|
types: this.opts.types?.length ?? 0
|
|
431
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L:
|
|
436
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 234, S: this });
|
|
437
|
+
const blueprintRegistryLayer = this.opts.blueprintRegistry ? Layer4.succeed(Blueprint.RegistryService, this.opts.blueprintRegistry) : Blueprint.RegistryService.notAvailable;
|
|
432
438
|
return Layer4.mergeAll(
|
|
433
439
|
dbLayer,
|
|
434
440
|
queuesLayer,
|
|
@@ -439,6 +445,7 @@ var FunctionContext = class extends Resource {
|
|
|
439
445
|
aiLayer,
|
|
440
446
|
OpaqueToolkit.providerLayer(OpaqueToolkit.merge(...this.opts.toolkits ?? [])),
|
|
441
447
|
traceWriterLayer,
|
|
448
|
+
blueprintRegistryLayer,
|
|
442
449
|
// `FunctionInvocationService` is deprecated; new code should yield `Operation.Service`.
|
|
443
450
|
// The cloudflare wrapper provides only the unavailable layer to satisfy the (still-present)
|
|
444
451
|
// type union — handlers that yield it will die at invocation time.
|
|
@@ -450,7 +457,7 @@ var makeTraceWriterLayer = (traceService) => Layer4.succeed(Trace.TraceService,
|
|
|
450
457
|
write: (eventType, payload) => {
|
|
451
458
|
log2("Writing trace event", {
|
|
452
459
|
eventType: eventType.key
|
|
453
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L:
|
|
460
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 255, S: void 0 });
|
|
454
461
|
traceService.write([
|
|
455
462
|
{
|
|
456
463
|
key: eventType.key,
|
|
@@ -466,9 +473,12 @@ var InternalAiServiceLayer = (functionsAiService) => AiModelResolver.AiModelReso
|
|
|
466
473
|
}).pipe(Layer4.provide(FunctionsAiHttpClient.layer(functionsAiService)))))));
|
|
467
474
|
var makeOperationServiceLayer = (functionsService) => {
|
|
468
475
|
const invokeRemote = async (op, input, options) => {
|
|
469
|
-
invariant(op.meta.deployedId, `Operation '${op.meta.key}' has no deployedId; cannot invoke remotely.`, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L:
|
|
476
|
+
invariant(op.meta.deployedId, `Operation '${op.meta.key}' has no deployedId; cannot invoke remotely.`, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 279, S: void 0, A: ["op.meta.deployedId", "`Operation '${op.meta.key}' has no deployedId; cannot invoke remotely.`"] });
|
|
470
477
|
const result = await functionsService.invoke(op.meta.deployedId, input, {
|
|
471
|
-
spaceId: options?.spaceId
|
|
478
|
+
spaceId: options?.spaceId,
|
|
479
|
+
// Forward the conversation DXN so the remote runtime can rebuild conversation-scoped
|
|
480
|
+
// services (e.g. `AiContext.Service`) needed by operations like `GetContext`.
|
|
481
|
+
conversation: options?.conversation
|
|
472
482
|
});
|
|
473
483
|
if (result._kind === "success") {
|
|
474
484
|
return {
|
|
@@ -482,7 +492,7 @@ var makeOperationServiceLayer = (functionsService) => {
|
|
|
482
492
|
return Layer4.succeed(Operation.Service, {
|
|
483
493
|
invoke: (op, input, options) => Effect4.tryPromise(() => invokeRemote(op, input, options)).pipe(Effect4.orDie, Effect4.flatMap((outcome) => outcome.error ? Effect4.die(outcome.error) : Effect4.succeed(outcome.data))),
|
|
484
494
|
schedule: (op, input) => Effect4.sync(() => {
|
|
485
|
-
invariant(op.meta.deployedId, `Operation '${op.meta.key}' has no deployedId; cannot schedule remotely.`, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L:
|
|
495
|
+
invariant(op.meta.deployedId, `Operation '${op.meta.key}' has no deployedId; cannot schedule remotely.`, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 298, S: void 0, A: ["op.meta.deployedId", "`Operation '${op.meta.key}' has no deployedId; cannot schedule remotely.`"] });
|
|
486
496
|
void functionsService.invoke(op.meta.deployedId, input).catch(() => {
|
|
487
497
|
});
|
|
488
498
|
}),
|
|
@@ -503,7 +513,7 @@ var makeOperationRegistryLayer = (functionsService, spaceId) => Layer4.succeed(O
|
|
|
503
513
|
const records = yield* Effect4.tryPromise(() => functionsService.query({
|
|
504
514
|
spaceId
|
|
505
515
|
})).pipe(Effect4.orDie);
|
|
506
|
-
const match = records.find((record) => record
|
|
516
|
+
const match = records.find((record) => Operation.getKey(record) === key);
|
|
507
517
|
return match ? Option.some(Operation.deserialize(match)) : Option.none();
|
|
508
518
|
})
|
|
509
519
|
});
|
|
@@ -575,7 +585,6 @@ var decodeRefsFromSchema = (ast, value2, db) => {
|
|
|
575
585
|
};
|
|
576
586
|
export {
|
|
577
587
|
ConfiguredCredentialsService,
|
|
578
|
-
ContextQueueService,
|
|
579
588
|
FUNCTIONS_META_KEY,
|
|
580
589
|
FUNCTIONS_PRESET_META_KEY,
|
|
581
590
|
FunctionInvocationService,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/services/credentials.ts", "../../../src/services/function-invocation-service.ts", "../../../src/services/queues.ts", "../../../src/services/tracing.ts", "../../../src/types/url.ts", "../../../src/protocol/protocol.ts", "../../../src/protocol/functions-ai-http-client.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientRequest from '@effect/platform/HttpClientRequest';\nimport type * as Config from 'effect/Config';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Redacted from 'effect/Redacted';\n\nimport { Credential } from '@dxos/compute';\nimport { Query } from '@dxos/echo';\nimport { Database } from '@dxos/echo';\nimport { AccessToken } from '@dxos/types';\n\nexport class ConfiguredCredentialsService implements Context.Tag.Service<Credential.CredentialsService> {\n constructor(private readonly credentials: Credential.ServiceCredential[] = []) {}\n\n addCredentials(credentials: Credential.ServiceCredential[]): ConfiguredCredentialsService {\n this.credentials.push(...credentials);\n return this;\n }\n\n async queryCredentials(query: Credential.CredentialQuery): Promise<Credential.ServiceCredential[]> {\n return this.credentials.filter((credential) => credential.service === query.service);\n }\n\n async getCredential(query: Credential.CredentialQuery): Promise<Credential.ServiceCredential> {\n const credential = this.credentials.find((credential) => credential.service === query.service);\n if (!credential) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n\n return credential;\n }\n}\n\n/**\n * Maps the request to include the given token in the Authorization header.\n */\nexport const withAuthorization = (token: string, kind?: 'Bearer' | 'Basic') =>\n HttpClient.mapRequest((request) => {\n const authorization = kind ? `${kind} ${token}` : token;\n return HttpClientRequest.setHeader(request, 'Authorization', authorization);\n });\n\nexport const configuredCredentialsLayer = (credentials: Credential.ServiceCredential[]) =>\n Layer.succeed(Credential.CredentialsService, new ConfiguredCredentialsService(credentials));\n\nexport const credentialsLayerConfig = (\n credentials: {\n service: string;\n apiKey: Config.Config<Redacted.Redacted<string>>;\n }[],\n) =>\n Layer.effect(\n Credential.CredentialsService,\n Effect.gen(function* () {\n const serviceCredentials = yield* Effect.forEach(credentials, ({ service, apiKey }) =>\n Effect.gen(function* () {\n return {\n service,\n apiKey: Redacted.value(yield* apiKey),\n };\n }),\n );\n\n return new ConfiguredCredentialsService(serviceCredentials);\n }),\n );\n\nexport const credentialsLayerFromDatabase = ({ caching = false }: { caching?: boolean } = {}) =>\n Layer.effect(\n Credential.CredentialsService,\n Effect.gen(function* () {\n const dbService = yield* Database.Service;\n const cache = new Map<string, Credential.ServiceCredential[]>();\n\n const queryCredentials = async (query: Credential.CredentialQuery): Promise<Credential.ServiceCredential[]> => {\n const cacheKey = JSON.stringify(query);\n if (caching && cache.has(cacheKey)) {\n return cache.get(cacheKey)!;\n }\n\n const accessTokens = await dbService.db.query(Query.type(AccessToken.AccessToken)).run();\n const credentials = accessTokens\n .filter((accessToken) => accessToken.source === query.service)\n .map((accessToken) => ({\n service: accessToken.source,\n apiKey: accessToken.token,\n }));\n\n if (caching) {\n cache.set(cacheKey, credentials);\n }\n\n return credentials;\n };\n\n return {\n getCredential: async (query) => {\n const credentials = await queryCredentials(query);\n if (credentials.length === 0) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n\n return credentials[0];\n },\n queryCredentials: async (query) => {\n return queryCredentials(query);\n },\n };\n }),\n );\n", "//\n// Copyright 2025 DXOS.org\n//\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport { type FunctionNotFoundError, Operation } from '@dxos/compute';\n\nexport class FunctionInvocationService extends Context.Tag('@dxos/functions/FunctionInvocationService')<\n FunctionInvocationService,\n {\n invokeFunction<I, O>(functionDef: Operation.Definition<I, O, any>, input: I): Effect.Effect<O>;\n\n resolveFunction(key: string): Effect.Effect<Operation.Definition.Any, FunctionNotFoundError>;\n }\n>() {\n static layerNotAvailable = Layer.succeed(FunctionInvocationService, {\n invokeFunction: () => Effect.die('FunctionInvocationService is not avaialble.'),\n resolveFunction: () => Effect.die('FunctionInvocationService is not available.'),\n });\n\n static invokeFunction = <I, O>(\n functionDef: Operation.Definition<I, O, any>,\n input: I,\n ): Effect.Effect<O, never, FunctionInvocationService> =>\n Effect.serviceFunctionEffect(FunctionInvocationService, (service) => service.invokeFunction)(functionDef, input);\n\n static resolveFunction = (\n key: string,\n ): Effect.Effect<Operation.Definition.Any, FunctionNotFoundError, FunctionInvocationService> =>\n Effect.serviceFunctionEffect(FunctionInvocationService, (service) => service.resolveFunction)(key);\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport { ContextQueueService, QueueService, feedServiceFromQueueServiceLayer } from '@dxos/echo-db';\n", "//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Goes into {@link Message['properties']}\n */\nexport const MESSAGE_PROPERTY_TOOL_CALL_ID = 'toolCallId' as const;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Obj } from '@dxos/echo';\n\n// TODO: use URL scheme for source?\nexport const FUNCTIONS_META_KEY = 'org.dxos.service.function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'org.dxos.service.function-preset';\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const getUserFunctionIdInMetadata = (meta: Obj.ReadonlyMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n * Must be called inside Obj.update() since it mutates the meta.\n */\nexport const setUserFunctionIdInMetadata = (meta: Obj.Meta, functionId: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionId) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionId });\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as AnthropicClient from '@effect/ai-anthropic/AnthropicClient';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { AiModelResolver, AiService, OpaqueToolkit } from '@dxos/ai';\nimport { AnthropicResolver } from '@dxos/ai/resolvers';\nimport {\n FunctionError,\n InvalidOperationInputError,\n InvalidOperationOutputError,\n Operation,\n OperationRegistry,\n Trace,\n} from '@dxos/compute';\nimport { LifecycleState, Resource } from '@dxos/context';\nimport { Database, Feed, JsonSchema, Ref, type Type } from '@dxos/echo';\nimport { createFeedServiceLayer, EchoClient, type EchoDatabaseImpl, type QueueFactory } from '@dxos/echo-db';\nimport { refFromEncodedReference } from '@dxos/echo/internal';\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { assertState, failedInvariant, invariant } from '@dxos/invariant';\nimport { PublicKey, type SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { EdgeFunctionEnv, ErrorCodec, type FunctionProtocol, type TraceProtocol } from '@dxos/protocols';\n\nimport { type FunctionServices } from '../sdk';\nimport {\n configuredCredentialsLayer,\n credentialsLayerFromDatabase,\n FunctionInvocationService,\n QueueService,\n} from '../services';\nimport { FunctionsAiHttpClient } from './functions-ai-http-client';\n\nexport interface FunctionWrappingOptions {\n /**\n * Additional types to register with the database.\n */\n types?: Type.AnyEntity[];\n\n /**\n * Toolkits to make available via the `OpaqueToolkitProvider`.\n */\n toolkits?: OpaqueToolkit.OpaqueToolkit[];\n}\n\n/**\n * Wraps a function handler made with `defineFunction` to a protocol that the functions-runtime expects.\n */\nexport const wrapFunctionHandler = (\n func: Operation.WithHandler<Operation.Definition.Any>,\n opts: FunctionWrappingOptions = {},\n): FunctionProtocol.Func => {\n if (!Operation.isOperationWithHandler(func)) {\n throw new TypeError('Expected operation with handler');\n }\n\n const serviceTags = func.services.map((service) => service.key);\n\n return {\n meta: {\n key: func.meta.key,\n name: func.meta.name,\n description: func.meta.description,\n inputSchema: JsonSchema.toJsonSchema(func.input),\n outputSchema: func.output === undefined ? undefined : JsonSchema.toJsonSchema(func.output),\n services: func.services.map((service) => service.key),\n },\n handler: async ({ data, context }) => {\n if (\n (serviceTags.includes(Database.Service.key) ||\n serviceTags.includes(QueueService.key) ||\n serviceTags.includes(Feed.FeedService.key)) &&\n (!context.services.dataService || !context.services.queryService)\n ) {\n throw new FunctionError({\n message: 'Services not provided: dataService, queryService',\n });\n }\n\n // eslint-disable-next-line no-useless-catch\n try {\n if (!SchemaAST.isAnyKeyword(func.input.ast)) {\n try {\n Schema.validateSync(func.input, { onExcessProperty: 'error' })(data);\n } catch (error: any) {\n throw new InvalidOperationInputError({\n message: `Operation input did not match schema (${func.meta.key}): ${error.message}`,\n cause: error,\n });\n }\n }\n\n await using funcContext = await new FunctionContext(context, opts).open();\n\n const types = [...(opts.types ?? []), ...(func.types ?? [])];\n if (types.length > 0) {\n invariant(funcContext.db, 'Database is required for functions with types');\n await funcContext.db.graph.schemaRegistry.register(types as Type.AnyEntity[]);\n }\n\n const dataWithDecodedRefs =\n funcContext.db && !SchemaAST.isAnyKeyword(func.input.ast)\n ? decodeRefsFromSchema(func.input.ast, data, funcContext.db)\n : data;\n\n let result: any = await func.handler(dataWithDecodedRefs);\n\n if (Effect.isEffect(result)) {\n result = await runAndForwardErrors(\n (result as Effect.Effect<unknown, unknown, FunctionServices>).pipe(\n Effect.orDie,\n Effect.provide(funcContext.createLayer()),\n ),\n );\n }\n\n if (func.output && !SchemaAST.isAnyKeyword(func.output.ast)) {\n try {\n Schema.validateSync(func.output, { onExcessProperty: 'error' })(result);\n } catch (error: any) {\n throw new InvalidOperationOutputError({\n message: `Operation output did not match schema (${func.meta.key}): ${error.message}`,\n cause: error,\n });\n }\n }\n\n return result;\n } catch (error) {\n // TODO(dmaretskyi): We might do error wrapping here and add extra context.\n throw error;\n }\n },\n };\n};\n\n/**\n * Container for services and context for a function.\n */\nclass FunctionContext extends Resource {\n readonly context: FunctionProtocol.Context;\n readonly client: EchoClient | undefined;\n db: EchoDatabaseImpl | undefined;\n queues: QueueFactory | undefined;\n readonly opts: FunctionWrappingOptions;\n\n constructor(context: FunctionProtocol.Context, opts: FunctionWrappingOptions) {\n super();\n this.context = context;\n this.opts = opts;\n if (context.services.dataService && context.services.queryService) {\n this.client = new EchoClient().connectToService({\n dataService: context.services.dataService,\n queryService: context.services.queryService,\n queueService: context.services.queueService,\n });\n }\n }\n\n override async _open() {\n await this.client?.open();\n this.db =\n this.client && this.context.spaceId\n ? this.client.constructDatabase({\n spaceId: this.context.spaceId ?? failedInvariant(),\n spaceKey: PublicKey.fromHex(this.context.spaceKey ?? failedInvariant('spaceKey missing in context')),\n reactiveSchemaQuery: false,\n preloadSchemaOnOpen: false,\n })\n : undefined;\n\n await this.db?.setSpaceRoot(this.context.spaceRootUrl ?? failedInvariant('spaceRootUrl missing in context'));\n await this.db?.open();\n this.queues =\n this.client && this.context.spaceId ? this.client.constructQueueFactory(this.context.spaceId) : undefined;\n }\n\n override async _close() {\n await this.db?.close();\n await this.client?.close();\n }\n\n createLayer(): Layer.Layer<FunctionServices> {\n assertState(this._lifecycleState === LifecycleState.OPEN, 'FunctionContext is not open');\n\n const dbLayer = this.db ? Database.layer(this.db) : Database.notAvailable;\n const queuesLayer = this.queues ? QueueService.layer(this.queues) : QueueService.notAvailable;\n const feedLayer = this.queues ? createFeedServiceLayer(this.queues) : Feed.notAvailable;\n const credentials = dbLayer\n ? credentialsLayerFromDatabase({ caching: true }).pipe(Layer.provide(dbLayer))\n : configuredCredentialsLayer([]);\n\n const aiLayer = this.context.services.functionsAiService\n ? InternalAiServiceLayer(this.context.services.functionsAiService)\n : AiService.notAvailable;\n\n const operationServiceLayer = this.context.services.functionsService\n ? makeOperationServiceLayer(this.context.services.functionsService)\n : unavailableOperationServiceLayer;\n\n const operationRegistryLayer = this.context.services.functionsService\n ? makeOperationRegistryLayer(this.context.services.functionsService, this.context.spaceId as SpaceId | undefined)\n : emptyOperationRegistryLayer;\n\n const traceWriterLayer = this.context.services.traceService\n ? makeTraceWriterLayer(this.context.services.traceService)\n : Trace.writerLayerNoop;\n\n log('Creating function context layer', {\n traceService: !!this.context.services.traceService,\n functionsService: !!this.context.services.functionsService,\n functionsAiService: !!this.context.services.functionsAiService,\n spaceId: this.context.spaceId,\n spaceRootUrl: this.context.spaceRootUrl,\n toolkits: this.opts.toolkits?.length ?? 0,\n types: this.opts.types?.length ?? 0,\n });\n\n return Layer.mergeAll(\n dbLayer,\n queuesLayer,\n feedLayer,\n credentials,\n operationServiceLayer,\n operationRegistryLayer,\n aiLayer,\n OpaqueToolkit.providerLayer(OpaqueToolkit.merge(...(this.opts.toolkits ?? []))),\n traceWriterLayer,\n\n // `FunctionInvocationService` is deprecated; new code should yield `Operation.Service`.\n // The cloudflare wrapper provides only the unavailable layer to satisfy the (still-present)\n // type union — handlers that yield it will die at invocation time.\n FunctionInvocationService.layerNotAvailable,\n );\n }\n}\n\n/**\n * Backs `Trace.TraceService` with the EDGE-provided `TraceService` so that operation\n * handlers can write trace events that are forwarded to the runtime's trace sink.\n */\nconst makeTraceWriterLayer = (traceService: TraceProtocol.TraceService): Layer.Layer<Trace.TraceService> =>\n Layer.succeed(Trace.TraceService, {\n write: (eventType, payload) => {\n log('Writing trace event', {\n eventType: eventType.key,\n });\n traceService.write([\n {\n key: eventType.key,\n isEphemeral: eventType.isEphemeral,\n data: payload,\n },\n ]);\n },\n });\n\n/**\n * AI service layer that proxies HTTP requests through the EDGE-provided `FunctionsAiService`.\n */\nconst InternalAiServiceLayer = (functionsAiService: EdgeFunctionEnv.FunctionsAiService) =>\n AiModelResolver.AiModelResolver.buildAiService.pipe(\n Layer.provide(\n AnthropicResolver.make().pipe(\n Layer.provide(\n AnthropicClient.layer({\n // Note: It doesn't matter what is base url here, it will be proxied to ai gateway in edge.\n apiUrl: 'http://internal/provider/anthropic',\n }).pipe(Layer.provide(FunctionsAiHttpClient.layer(functionsAiService))),\n ),\n ),\n ),\n );\n\n/**\n * Backs `Operation.Service` with the EDGE-provided `FunctionsService` so that operation\n * handlers can invoke other deployed operations remotely. The `deployedId` on the operation\n * definition is used as the routing key.\n */\nconst makeOperationServiceLayer = (\n functionsService: EdgeFunctionEnv.FunctionsService,\n): Layer.Layer<Operation.Service> => {\n const invokeRemote = async (\n op: Operation.Definition.Any,\n input: unknown,\n options?: Operation.InvokeOptions,\n ): Promise<{ data?: unknown; error?: Error }> => {\n invariant(op.meta.deployedId, `Operation '${op.meta.key}' has no deployedId; cannot invoke remotely.`);\n const result = await functionsService.invoke(op.meta.deployedId, input, {\n spaceId: options?.spaceId,\n });\n if (result._kind === 'success') {\n return { data: result.data };\n }\n return { error: ErrorCodec.decode(result.error) };\n };\n\n return Layer.succeed(Operation.Service, {\n invoke: ((op: Operation.Definition.Any, input: unknown, options?: Operation.InvokeOptions) =>\n Effect.tryPromise(() => invokeRemote(op, input, options)).pipe(\n Effect.orDie,\n Effect.flatMap((outcome) =>\n outcome.error ? Effect.die(outcome.error) : Effect.succeed(outcome.data as never),\n ),\n )) as Operation.OperationService['invoke'],\n schedule: ((op: Operation.Definition.Any, input: unknown) =>\n Effect.sync(() => {\n invariant(op.meta.deployedId, `Operation '${op.meta.key}' has no deployedId; cannot schedule remotely.`);\n // Fire and forget — schedule is intentionally non-awaiting.\n void functionsService.invoke(op.meta.deployedId, input).catch(() => {\n // Swallow errors — schedule is observability-only.\n });\n })) as Operation.OperationService['schedule'],\n invokePromise: ((op: Operation.Definition.Any, input: unknown, options?: Operation.InvokeOptions) =>\n invokeRemote(op, input, options).catch((error: unknown) => ({\n error: error instanceof Error ? error : new Error(String(error)),\n }))) as Operation.OperationService['invokePromise'],\n } satisfies Operation.OperationService);\n};\n\nconst unavailableOperationServiceLayer = Layer.succeed(Operation.Service, {\n invoke: () => Effect.die('Operation.Service is not available: missing functionsService in EDGE context.'),\n schedule: () => Effect.die('Operation.Service is not available: missing functionsService in EDGE context.'),\n invokePromise: async () => ({\n error: new Error('Operation.Service is not available: missing functionsService in EDGE context.'),\n }),\n} as Operation.OperationService);\n\n/**\n * Backs `OperationRegistry.Service` with the EDGE-provided `FunctionsService.query`. Returns\n * the first persistent operation matching the requested key, or `Option.none()` when not found.\n */\nconst makeOperationRegistryLayer = (\n functionsService: EdgeFunctionEnv.FunctionsService,\n spaceId: SpaceId | undefined,\n): Layer.Layer<OperationRegistry.Service> =>\n Layer.succeed(OperationRegistry.Service, {\n resolve: (key: string) =>\n Effect.gen(function* () {\n const records = yield* Effect.tryPromise(() => functionsService.query({ spaceId })).pipe(Effect.orDie);\n const match = (records as Operation.PersistentOperation[]).find((record) => record.key === key);\n return match ? Option.some(Operation.deserialize(match)) : Option.none();\n }),\n });\n\nconst emptyOperationRegistryLayer = Layer.succeed(OperationRegistry.Service, {\n resolve: () => Effect.succeed(Option.none()),\n});\n\nconst decodeRefsFromSchema = (ast: SchemaAST.AST, value: unknown, db: EchoDatabaseImpl): unknown => {\n if (value == null) {\n return value;\n }\n\n const encoded = SchemaAST.encodedBoundAST(ast);\n if (Ref.isRefType(encoded)) {\n if (Ref.isRef(value)) {\n return value;\n }\n\n if (typeof value === 'object' && value !== null && typeof (value as any)['/'] === 'string') {\n const resolver = db.graph.createRefResolver({ context: { space: db.spaceId } });\n return refFromEncodedReference(value as any, resolver);\n }\n\n return value;\n }\n\n switch (encoded._tag) {\n case 'TypeLiteral': {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return value;\n }\n const result: Record<string, unknown> = { ...(value as any) };\n for (const prop of SchemaAST.getPropertySignatures(encoded)) {\n const key = prop.name.toString();\n if (key in result) {\n result[key] = decodeRefsFromSchema(prop.type, (result as any)[key], db);\n }\n }\n return result;\n }\n\n case 'TupleType': {\n if (!Array.isArray(value)) {\n return value;\n }\n\n // For arrays, effect uses TupleType with empty elements and a single rest element.\n if (encoded.elements.length === 0 && encoded.rest.length === 1) {\n const elementType = encoded.rest[0].type;\n return (value as unknown[]).map((item) => decodeRefsFromSchema(elementType, item, db));\n }\n\n return value;\n }\n\n case 'Union': {\n // Optional values are represented as union with undefined.\n const nonUndefined = encoded.types.filter((t) => !SchemaAST.isUndefinedKeyword(t));\n if (nonUndefined.length === 1) {\n return decodeRefsFromSchema(nonUndefined[0], value, db);\n }\n\n // For other unions we can't safely pick a branch without validating.\n return value;\n }\n\n case 'Suspend': {\n return decodeRefsFromSchema(encoded.f(), value, db);\n }\n\n case 'Refinement': {\n return decodeRefsFromSchema(encoded.from, value, db);\n }\n\n default: {\n return value;\n }\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Headers from '@effect/platform/Headers';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientError from '@effect/platform/HttpClientError';\nimport * as HttpClientResponse from '@effect/platform/HttpClientResponse';\nimport * as Effect from 'effect/Effect';\nimport * as FiberRef from 'effect/FiberRef';\nimport * as Layer from 'effect/Layer';\nimport * as Stream from 'effect/Stream';\n\nimport { FunctionsAiMemoizationMissError, FunctionsAiUpstreamError } from '@dxos/compute';\nimport { log } from '@dxos/log';\nimport { type EdgeFunctionEnv, ErrorCodec } from '@dxos/protocols';\n\n/**\n * Copy pasted from https://github.com/Effect-TS/effect/blob/main/packages/platform/src/internal/fetchHttpClient.ts\n */\nexport const requestInitTagKey = '@effect/platform/FetchHttpClient/FetchOptions';\n\n/**\n * Shape of the JSON error envelope emitted by the upstream AI gateway (and by the memoization\n * layer that fronts it in test environments).\n *\n * @example\n * ```json\n * {\n * \"type\": \"error\",\n * \"error\": {\n * \"type\": \"memoization_miss\",\n * \"message\": \"No memoized Anthropic conversation found for ...\",\n * \"cacheKey\": \"114dae3db8fe60...\"\n * }\n * }\n * ```\n */\ntype UpstreamErrorEnvelope = {\n type?: string;\n error?: {\n type?: string;\n message?: string;\n cacheKey?: string;\n };\n};\n\nexport class FunctionsAiHttpClient {\n static make = (service: EdgeFunctionEnv.FunctionsAiService) =>\n HttpClient.make((request, url, signal, fiber) => {\n const context = fiber.getFiberRef(FiberRef.currentContext);\n const options: RequestInit = context.unsafeMap.get(requestInitTagKey) ?? {};\n const headers = options.headers\n ? Headers.merge(Headers.fromInput(options.headers), request.headers)\n : request.headers;\n\n const send = (body: BodyInit | undefined) =>\n Effect.tryPromise({\n try: () =>\n service.fetch(\n new Request(url, {\n ...options,\n method: request.method,\n headers,\n body,\n // Note: Don't pass signal - it can't be serialized through RPC\n }),\n ),\n catch: (cause) => {\n log.error('Failed to fetch', { errorSerialized: ErrorCodec.encode(cause as Error) });\n return new HttpClientError.RequestError({\n request,\n reason: 'Transport',\n cause,\n });\n },\n }).pipe(\n Effect.flatMap((response) =>\n // Inspect the body before handing the response to `@effect/ai` so that structured\n // upstream errors surface as typed defects (`FunctionsAiUpstreamError` and friends)\n // rather than as the generic `HttpResponseError` from `@effect/ai/AiError`.\n Effect.flatMap(\n Effect.promise(() => parseUpstreamError(response)),\n (typedError) =>\n typedError ? Effect.die(typedError) : Effect.succeed(HttpClientResponse.fromWeb(request, response)),\n ),\n ),\n );\n\n switch (request.body._tag) {\n case 'Raw':\n case 'Uint8Array':\n return send(request.body.body as any);\n case 'FormData':\n return send(request.body.formData);\n case 'Stream':\n return Stream.toReadableStreamEffect(request.body.stream).pipe(Effect.flatMap(send));\n }\n\n return send(undefined);\n });\n\n static layer = (service: EdgeFunctionEnv.FunctionsAiService) =>\n Layer.succeed(HttpClient.HttpClient, FunctionsAiHttpClient.make(service));\n}\n\n/**\n * Returns a typed error if the response is a non-2xx JSON payload matching\n * {@link UpstreamErrorEnvelope}; otherwise returns `undefined` and the response is forwarded\n * unchanged.\n */\nconst parseUpstreamError = async (response: Response): Promise<Error | undefined> => {\n if (response.ok) {\n return undefined;\n }\n const contentType = response.headers.get('content-type') ?? '';\n if (!contentType.toLowerCase().includes('application/json')) {\n return undefined;\n }\n let body: UpstreamErrorEnvelope;\n try {\n body = (await response.clone().json()) as UpstreamErrorEnvelope;\n } catch {\n return undefined;\n }\n if (!body || body.type !== 'error' || typeof body.error !== 'object' || body.error === null) {\n return undefined;\n }\n const inner = body.error;\n const message = inner.message ?? `Upstream AI service responded with HTTP ${response.status}`;\n if (inner.type === 'memoization_miss' && typeof inner.cacheKey === 'string') {\n return new FunctionsAiMemoizationMissError({\n message,\n context: { cacheKey: inner.cacheKey, status: response.status },\n });\n }\n return new FunctionsAiUpstreamError({\n message,\n context: { type: inner.type, status: response.status, ...(inner.cacheKey ? { cacheKey: inner.cacheKey } : {}) },\n });\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,YAAYA,gBAAgB;AAC5B,YAAYC,uBAAuB;AAGnC,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAE1B,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAErB,IAAMC,+BAAN,MAAMA;;EACX,YAA6BC,cAA8C,CAAA,GAAI;SAAlDA,cAAAA;EAAmD;EAEhFC,eAAeD,aAA2E;AACxF,SAAKA,YAAYE,KAAI,GAAIF,WAAAA;AACzB,WAAO;EACT;EAEA,MAAMG,iBAAiBC,OAA4E;AACjG,WAAO,KAAKJ,YAAYK,OAAO,CAACC,eAAeA,WAAWC,YAAYH,MAAMG,OAAO;EACrF;EAEA,MAAMC,cAAcJ,OAA0E;AAC5F,UAAME,aAAa,KAAKN,YAAYS,KAAK,CAACH,gBAAeA,YAAWC,YAAYH,MAAMG,OAAO;AAC7F,QAAI,CAACD,YAAY;AACf,YAAM,IAAII,MAAM,qCAAqCN,MAAMG,OAAO,EAAE;IACtE;AAEA,WAAOD;EACT;AACF;AAKO,IAAMK,oBAAoB,CAACC,OAAeC,SACpCC,sBAAW,CAACC,YAAAA;AACrB,QAAMC,gBAAgBH,OAAO,GAAGA,IAAAA,IAAQD,KAAAA,KAAUA;AAClD,SAAyBK,4BAAUF,SAAS,iBAAiBC,aAAAA;AAC/D,CAAA;AAEK,IAAME,6BAA6B,CAAClB,gBACnCmB,cAAQxB,WAAWyB,oBAAoB,IAAIrB,6BAA6BC,WAAAA,CAAAA;AAEzE,IAAMqB,yBAAyB,CACpCrB,g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A,GAAA,EAAA;QACF;MACA;AACF,aAAA;IAEA;SAAkB;UAEd,CAAA,MAAOP,QAAAA,MAAAA,GAAAA;AACT,eAAAA;MAEA;UAEE,QAAMQ,SAAAA,WAAsBC,KAAK,QAAO,KAAA,WAAA,GAAA;AACxC,cAAA,cAAiCC,QAASH,KAAAA,CAAAA,EAAAA;AAC5C,eAAAP,OAAA,IAAA,CAAA,SAAA,qBAAA,aAAA,MAAA,EAAA,CAAA;MAEA;AACF,aAAAA;IAEA;SAAc;AAGZ,YAAIW,eAAarC,QAAW,MAAG,OAAA,CAAA,MAAA,CAAA,6BAAA,CAAA,CAAA;UAC7B,aAAOiC,WAAAA,GAAAA;AACT,eAAA,qBAAA,aAAA,CAAA,GAAAP,QAAA,EAAA;MAEA;AAEF,aAAAA;IAEA;SAAgB;AAEhB,aAAA,qBAAA,QAAA,EAAA,GAAAA,QAAA,EAAA;IAEA;SAAmB;AAEnB,aAAA,qBAAA,QAAA,MAAAA,QAAA,EAAA;IAEA;;AAEA,aAAAA;IACF;EACF;;",
|
|
6
|
-
"names": ["HttpClient", "HttpClientRequest", "Effect", "Layer", "Redacted", "Credential", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientRequest from '@effect/platform/HttpClientRequest';\nimport type * as Config from 'effect/Config';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Redacted from 'effect/Redacted';\n\nimport { Credential } from '@dxos/compute';\nimport { Database, Query } from '@dxos/echo';\nimport { AccessToken } from '@dxos/types';\n\nexport class ConfiguredCredentialsService implements Context.Tag.Service<Credential.CredentialsService> {\n constructor(private readonly credentials: Credential.ServiceCredential[] = []) {}\n\n addCredentials(credentials: Credential.ServiceCredential[]): ConfiguredCredentialsService {\n this.credentials.push(...credentials);\n return this;\n }\n\n async queryCredentials(query: Credential.CredentialQuery): Promise<Credential.ServiceCredential[]> {\n return this.credentials.filter((credential) => credential.service === query.service);\n }\n\n async getCredential(query: Credential.CredentialQuery): Promise<Credential.ServiceCredential> {\n const credential = this.credentials.find((credential) => credential.service === query.service);\n if (!credential) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n\n return credential;\n }\n}\n\n/**\n * Maps the request to include the given token in the Authorization header.\n */\nexport const withAuthorization = (token: string, kind?: 'Bearer' | 'Basic') =>\n HttpClient.mapRequest((request) => {\n const authorization = kind ? `${kind} ${token}` : token;\n return HttpClientRequest.setHeader(request, 'Authorization', authorization);\n });\n\nexport const configuredCredentialsLayer = (credentials: Credential.ServiceCredential[]) =>\n Layer.succeed(Credential.CredentialsService, new ConfiguredCredentialsService(credentials));\n\nexport const credentialsLayerConfig = (\n credentials: {\n service: string;\n apiKey: Config.Config<Redacted.Redacted<string>>;\n }[],\n) =>\n Layer.effect(\n Credential.CredentialsService,\n Effect.gen(function* () {\n const serviceCredentials = yield* Effect.forEach(credentials, ({ service, apiKey }) =>\n Effect.gen(function* () {\n return {\n service,\n apiKey: Redacted.value(yield* apiKey),\n };\n }),\n );\n\n return new ConfiguredCredentialsService(serviceCredentials);\n }),\n );\n\nexport const credentialsLayerFromDatabase = ({ caching = false }: { caching?: boolean } = {}) =>\n Layer.effect(\n Credential.CredentialsService,\n Effect.gen(function* () {\n const dbService = yield* Database.Service;\n const cache = new Map<string, Credential.ServiceCredential[]>();\n\n const queryCredentials = async (query: Credential.CredentialQuery): Promise<Credential.ServiceCredential[]> => {\n const cacheKey = JSON.stringify(query);\n if (caching && cache.has(cacheKey)) {\n return cache.get(cacheKey)!;\n }\n\n const accessTokens = await dbService.db.query(Query.type(AccessToken.AccessToken)).run();\n const credentials = accessTokens\n .filter((accessToken) => accessToken.source === query.service)\n .map((accessToken) => ({\n service: accessToken.source,\n apiKey: accessToken.token,\n }));\n\n if (caching) {\n cache.set(cacheKey, credentials);\n }\n\n return credentials;\n };\n\n return {\n getCredential: async (query) => {\n const credentials = await queryCredentials(query);\n if (credentials.length === 0) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n\n return credentials[0];\n },\n queryCredentials: async (query) => {\n return queryCredentials(query);\n },\n };\n }),\n );\n", "//\n// Copyright 2025 DXOS.org\n//\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport { type FunctionNotFoundError, Operation } from '@dxos/compute';\n\n/**\n * @deprecated\n */\nexport class FunctionInvocationService extends Context.Tag('@dxos/functions/FunctionInvocationService')<\n FunctionInvocationService,\n {\n invokeFunction<I, O>(functionDef: Operation.Definition<I, O, any>, input: I): Effect.Effect<O>;\n\n resolveFunction(key: string): Effect.Effect<Operation.Definition.Any, FunctionNotFoundError>;\n }\n>() {\n static layerNotAvailable = Layer.succeed(FunctionInvocationService, {\n invokeFunction: () => Effect.die('FunctionInvocationService is not avaialble.'),\n resolveFunction: () => Effect.die('FunctionInvocationService is not available.'),\n });\n\n static invokeFunction = <I, O>(\n functionDef: Operation.Definition<I, O, any>,\n input: I,\n ): Effect.Effect<O, never, FunctionInvocationService> =>\n Effect.serviceFunctionEffect(FunctionInvocationService, (service) => service.invokeFunction)(functionDef, input);\n\n static resolveFunction = (\n key: string,\n ): Effect.Effect<Operation.Definition.Any, FunctionNotFoundError, FunctionInvocationService> =>\n Effect.serviceFunctionEffect(FunctionInvocationService, (service) => service.resolveFunction)(key);\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport { QueueService, feedServiceFromQueueServiceLayer } from '@dxos/echo-db';\n", "//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Goes into {@link Message['properties']}\n */\nexport const MESSAGE_PROPERTY_TOOL_CALL_ID = 'toolCallId' as const;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Obj } from '@dxos/echo';\n\n// TODO: use URL scheme for source?\nexport const FUNCTIONS_META_KEY = 'org.dxos.service.function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'org.dxos.service.function-preset';\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const getUserFunctionIdInMetadata = (meta: Obj.ReadonlyMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n * Must be called inside Obj.update() since it mutates the meta.\n */\nexport const setUserFunctionIdInMetadata = (meta: Obj.Meta, functionId: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionId) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionId });\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as AnthropicClient from '@effect/ai-anthropic/AnthropicClient';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { AiModelResolver, AiService, OpaqueToolkit } from '@dxos/ai';\nimport { AnthropicResolver } from '@dxos/ai/resolvers';\nimport {\n Blueprint,\n FunctionError,\n InvalidOperationInputError,\n InvalidOperationOutputError,\n Operation,\n OperationRegistry,\n Trace,\n} from '@dxos/compute';\nimport { LifecycleState, Resource } from '@dxos/context';\nimport { Database, Feed, JsonSchema, Ref, type Type } from '@dxos/echo';\nimport { createFeedServiceLayer, EchoClient, type EchoDatabaseImpl, type QueueFactory } from '@dxos/echo-db';\nimport { refFromEncodedReference } from '@dxos/echo/internal';\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { assertState, failedInvariant, invariant } from '@dxos/invariant';\nimport { PublicKey, type SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { EdgeFunctionEnv, ErrorCodec, type FunctionProtocol, type TraceProtocol } from '@dxos/protocols';\n\nimport { type FunctionServices } from '../sdk';\nimport {\n configuredCredentialsLayer,\n credentialsLayerFromDatabase,\n FunctionInvocationService,\n QueueService,\n} from '../services';\nimport { FunctionsAiHttpClient } from './functions-ai-http-client';\n\nexport interface FunctionWrappingOptions {\n /**\n * Additional types to register with the database.\n */\n types?: Type.AnyEntity[];\n\n /**\n * Toolkits to make available via the `OpaqueToolkitProvider`.\n */\n toolkits?: OpaqueToolkit.OpaqueToolkit[];\n\n /**\n * Blueprint registry to expose as `Blueprint.RegistryService` inside handler Effects.\n * Required for operations that declare `Blueprint.RegistryService` in their `services` list.\n */\n blueprintRegistry?: Blueprint.Registry;\n}\n\n/**\n * Wraps a function handler made with `defineFunction` to a protocol that the functions-runtime expects.\n */\nexport const wrapFunctionHandler = (\n func: Operation.WithHandler<Operation.Definition.Any>,\n opts: FunctionWrappingOptions = {},\n): FunctionProtocol.Func => {\n if (!Operation.isOperationWithHandler(func)) {\n throw new TypeError('Expected operation with handler');\n }\n\n const serviceTags = func.services.map((service) => service.key);\n\n return {\n meta: {\n key: func.meta.key,\n name: func.meta.name,\n description: func.meta.description,\n inputSchema: JsonSchema.toJsonSchema(func.input),\n outputSchema: func.output === undefined ? undefined : JsonSchema.toJsonSchema(func.output),\n services: func.services.map((service) => service.key),\n },\n handler: async ({ data, context }) => {\n if (\n (serviceTags.includes(Database.Service.key) ||\n serviceTags.includes(QueueService.key) ||\n serviceTags.includes(Feed.FeedService.key)) &&\n (!context.services.dataService || !context.services.queryService)\n ) {\n throw new FunctionError({\n message: 'Services not provided: dataService, queryService',\n });\n }\n\n // eslint-disable-next-line no-useless-catch\n try {\n if (!SchemaAST.isAnyKeyword(func.input.ast)) {\n try {\n Schema.validateSync(func.input, { onExcessProperty: 'error' })(data);\n } catch (error: any) {\n throw new InvalidOperationInputError({\n message: `Operation input did not match schema (${func.meta.key}): ${error.message}`,\n cause: error,\n });\n }\n }\n\n await using funcContext = await new FunctionContext(context, opts).open();\n\n const types = [...(opts.types ?? []), ...(func.types ?? [])];\n if (types.length > 0) {\n invariant(funcContext.db, 'Database is required for functions with types');\n await funcContext.db.graph.schemaRegistry.register(types as Type.AnyEntity[]);\n }\n\n const dataWithDecodedRefs =\n funcContext.db && !SchemaAST.isAnyKeyword(func.input.ast)\n ? decodeRefsFromSchema(func.input.ast, data, funcContext.db)\n : data;\n\n let result: any = await func.handler(dataWithDecodedRefs);\n\n if (Effect.isEffect(result)) {\n result = await runAndForwardErrors(\n (result as Effect.Effect<unknown, unknown, FunctionServices>).pipe(\n Effect.orDie,\n Effect.provide(funcContext.createLayer()),\n ),\n );\n }\n\n // Flush in-memory ECHO writes before the function scope closes.\n // Writes performed by `db.add` / `db.remove` are buffered in the in-memory\n // `EchoDatabaseImpl` and only pushed across the `DataService` binding when\n // `db.flush({ disk })` is called. `FunctionContext._close` (invoked by the\n // `await using` above) calls `db.close()` but does NOT flush, so mutations\n // performed by handlers that declare `Database.Service` (e.g. `object-create`,\n // `object-update`, `relation-create`) would be silently dropped before reaching\n // the edge `AutomergeReplicator`. Flushing here closes that hole.\n if (serviceTags.includes(Database.Service.key) && funcContext.db) {\n await funcContext.db.flush({ disk: true, indexes: false });\n }\n\n if (func.output && !SchemaAST.isAnyKeyword(func.output.ast)) {\n try {\n Schema.validateSync(func.output, { onExcessProperty: 'error' })(result);\n } catch (error: any) {\n throw new InvalidOperationOutputError({\n message: `Operation output did not match schema (${func.meta.key}): ${error.message}`,\n cause: error,\n });\n }\n }\n\n return result;\n } catch (error) {\n // TODO(dmaretskyi): We might do error wrapping here and add extra context.\n throw error;\n }\n },\n };\n};\n\n/**\n * Container for services and context for a function.\n */\nclass FunctionContext extends Resource {\n readonly context: FunctionProtocol.Context;\n readonly client: EchoClient | undefined;\n db: EchoDatabaseImpl | undefined;\n queues: QueueFactory | undefined;\n readonly opts: FunctionWrappingOptions;\n\n constructor(context: FunctionProtocol.Context, opts: FunctionWrappingOptions) {\n super();\n this.context = context;\n this.opts = opts;\n if (context.services.dataService && context.services.queryService) {\n this.client = new EchoClient().connectToService({\n dataService: context.services.dataService,\n queryService: context.services.queryService,\n queueService: context.services.queueService,\n });\n }\n }\n\n override async _open() {\n await this.client?.open();\n this.db =\n this.client && this.context.spaceId\n ? this.client.constructDatabase({\n spaceId: this.context.spaceId ?? failedInvariant(),\n spaceKey: PublicKey.fromHex(this.context.spaceKey ?? failedInvariant('spaceKey missing in context')),\n reactiveSchemaQuery: false,\n preloadSchemaOnOpen: false,\n })\n : undefined;\n\n await this.db?.setSpaceRoot(this.context.spaceRootUrl ?? failedInvariant('spaceRootUrl missing in context'));\n await this.db?.open();\n this.queues =\n this.client && this.context.spaceId ? this.client.constructQueueFactory(this.context.spaceId) : undefined;\n }\n\n override async _close() {\n await this.db?.close();\n await this.client?.close();\n }\n\n createLayer(): Layer.Layer<FunctionServices> {\n assertState(this._lifecycleState === LifecycleState.OPEN, 'FunctionContext is not open');\n\n const dbLayer = this.db ? Database.layer(this.db) : Database.notAvailable;\n const queuesLayer = this.queues ? QueueService.layer(this.queues) : QueueService.notAvailable;\n const feedLayer = this.queues ? createFeedServiceLayer(this.queues) : Feed.notAvailable;\n const credentials = dbLayer\n ? credentialsLayerFromDatabase({ caching: true }).pipe(Layer.provide(dbLayer))\n : configuredCredentialsLayer([]);\n\n const aiLayer = this.context.services.functionsAiService\n ? InternalAiServiceLayer(this.context.services.functionsAiService)\n : AiService.notAvailable;\n\n const operationServiceLayer = this.context.services.functionsService\n ? makeOperationServiceLayer(this.context.services.functionsService)\n : unavailableOperationServiceLayer;\n\n const operationRegistryLayer = this.context.services.functionsService\n ? makeOperationRegistryLayer(this.context.services.functionsService, this.context.spaceId as SpaceId | undefined)\n : emptyOperationRegistryLayer;\n\n const traceWriterLayer = this.context.services.traceService\n ? makeTraceWriterLayer(this.context.services.traceService)\n : Trace.writerLayerNoop;\n\n log('Creating function context layer', {\n traceService: !!this.context.services.traceService,\n functionsService: !!this.context.services.functionsService,\n functionsAiService: !!this.context.services.functionsAiService,\n spaceId: this.context.spaceId,\n spaceRootUrl: this.context.spaceRootUrl,\n toolkits: this.opts.toolkits?.length ?? 0,\n types: this.opts.types?.length ?? 0,\n });\n\n const blueprintRegistryLayer = this.opts.blueprintRegistry\n ? Layer.succeed(Blueprint.RegistryService, this.opts.blueprintRegistry)\n : Blueprint.RegistryService.notAvailable;\n\n return Layer.mergeAll(\n dbLayer,\n queuesLayer,\n feedLayer,\n credentials,\n operationServiceLayer,\n operationRegistryLayer,\n aiLayer,\n OpaqueToolkit.providerLayer(OpaqueToolkit.merge(...(this.opts.toolkits ?? []))),\n traceWriterLayer,\n blueprintRegistryLayer,\n\n // `FunctionInvocationService` is deprecated; new code should yield `Operation.Service`.\n // The cloudflare wrapper provides only the unavailable layer to satisfy the (still-present)\n // type union — handlers that yield it will die at invocation time.\n FunctionInvocationService.layerNotAvailable,\n );\n }\n}\n\n/**\n * Backs `Trace.TraceService` with the EDGE-provided `TraceService` so that operation\n * handlers can write trace events that are forwarded to the runtime's trace sink.\n */\nconst makeTraceWriterLayer = (traceService: TraceProtocol.TraceService): Layer.Layer<Trace.TraceService> =>\n Layer.succeed(Trace.TraceService, {\n write: (eventType, payload) => {\n log('Writing trace event', {\n eventType: eventType.key,\n });\n traceService.write([\n {\n key: eventType.key,\n isEphemeral: eventType.isEphemeral,\n data: payload,\n },\n ]);\n },\n });\n\n/**\n * AI service layer that proxies HTTP requests through the EDGE-provided `FunctionsAiService`.\n */\nconst InternalAiServiceLayer = (functionsAiService: EdgeFunctionEnv.FunctionsAiService) =>\n AiModelResolver.AiModelResolver.buildAiService.pipe(\n Layer.provide(\n AnthropicResolver.make().pipe(\n Layer.provide(\n AnthropicClient.layer({\n // Note: It doesn't matter what is base url here, it will be proxied to ai gateway in edge.\n apiUrl: 'http://internal/provider/anthropic',\n }).pipe(Layer.provide(FunctionsAiHttpClient.layer(functionsAiService))),\n ),\n ),\n ),\n );\n\n/**\n * Backs `Operation.Service` with the EDGE-provided `FunctionsService` so that operation\n * handlers can invoke other deployed operations remotely. The `deployedId` on the operation\n * definition is used as the routing key.\n */\nconst makeOperationServiceLayer = (\n functionsService: EdgeFunctionEnv.FunctionsService,\n): Layer.Layer<Operation.Service> => {\n const invokeRemote = async (\n op: Operation.Definition.Any,\n input: unknown,\n options?: Operation.InvokeOptions,\n ): Promise<{ data?: unknown; error?: Error }> => {\n invariant(op.meta.deployedId, `Operation '${op.meta.key}' has no deployedId; cannot invoke remotely.`);\n const result = await functionsService.invoke(op.meta.deployedId, input, {\n spaceId: options?.spaceId,\n // Forward the conversation DXN so the remote runtime can rebuild conversation-scoped\n // services (e.g. `AiContext.Service`) needed by operations like `GetContext`.\n conversation: options?.conversation,\n });\n if (result._kind === 'success') {\n return { data: result.data };\n }\n return { error: ErrorCodec.decode(result.error) };\n };\n\n return Layer.succeed(Operation.Service, {\n invoke: ((op: Operation.Definition.Any, input: unknown, options?: Operation.InvokeOptions) =>\n Effect.tryPromise(() => invokeRemote(op, input, options)).pipe(\n Effect.orDie,\n Effect.flatMap((outcome) =>\n outcome.error ? Effect.die(outcome.error) : Effect.succeed(outcome.data as never),\n ),\n )) as Operation.OperationService['invoke'],\n schedule: ((op: Operation.Definition.Any, input: unknown) =>\n Effect.sync(() => {\n invariant(op.meta.deployedId, `Operation '${op.meta.key}' has no deployedId; cannot schedule remotely.`);\n // Fire and forget — schedule is intentionally non-awaiting.\n void functionsService.invoke(op.meta.deployedId, input).catch(() => {\n // Swallow errors — schedule is observability-only.\n });\n })) as Operation.OperationService['schedule'],\n invokePromise: ((op: Operation.Definition.Any, input: unknown, options?: Operation.InvokeOptions) =>\n invokeRemote(op, input, options).catch((error: unknown) => ({\n error: error instanceof Error ? error : new Error(String(error)),\n }))) as Operation.OperationService['invokePromise'],\n } satisfies Operation.OperationService);\n};\n\nconst unavailableOperationServiceLayer = Layer.succeed(Operation.Service, {\n invoke: () => Effect.die('Operation.Service is not available: missing functionsService in EDGE context.'),\n schedule: () => Effect.die('Operation.Service is not available: missing functionsService in EDGE context.'),\n invokePromise: async () => ({\n error: new Error('Operation.Service is not available: missing functionsService in EDGE context.'),\n }),\n} as Operation.OperationService);\n\n/**\n * Backs `OperationRegistry.Service` with the EDGE-provided `FunctionsService.query`. Returns\n * the first persistent operation matching the requested key, or `Option.none()` when not found.\n */\nconst makeOperationRegistryLayer = (\n functionsService: EdgeFunctionEnv.FunctionsService,\n spaceId: SpaceId | undefined,\n): Layer.Layer<OperationRegistry.Service> =>\n Layer.succeed(OperationRegistry.Service, {\n resolve: (key: string) =>\n Effect.gen(function* () {\n const records = yield* Effect.tryPromise(() => functionsService.query({ spaceId })).pipe(Effect.orDie);\n const match = (records as Operation.PersistentOperation[]).find((record) => Operation.getKey(record) === key);\n return match ? Option.some(Operation.deserialize(match)) : Option.none();\n }),\n });\n\nconst emptyOperationRegistryLayer = Layer.succeed(OperationRegistry.Service, {\n resolve: () => Effect.succeed(Option.none()),\n});\n\nconst decodeRefsFromSchema = (ast: SchemaAST.AST, value: unknown, db: EchoDatabaseImpl): unknown => {\n if (value == null) {\n return value;\n }\n\n const encoded = SchemaAST.encodedBoundAST(ast);\n if (Ref.isRefType(encoded)) {\n if (Ref.isRef(value)) {\n return value;\n }\n\n if (typeof value === 'object' && value !== null && typeof (value as any)['/'] === 'string') {\n const resolver = db.graph.createRefResolver({ context: { space: db.spaceId } });\n return refFromEncodedReference(value as any, resolver);\n }\n\n return value;\n }\n\n switch (encoded._tag) {\n case 'TypeLiteral': {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return value;\n }\n const result: Record<string, unknown> = { ...(value as any) };\n for (const prop of SchemaAST.getPropertySignatures(encoded)) {\n const key = prop.name.toString();\n if (key in result) {\n result[key] = decodeRefsFromSchema(prop.type, (result as any)[key], db);\n }\n }\n return result;\n }\n\n case 'TupleType': {\n if (!Array.isArray(value)) {\n return value;\n }\n\n // For arrays, effect uses TupleType with empty elements and a single rest element.\n if (encoded.elements.length === 0 && encoded.rest.length === 1) {\n const elementType = encoded.rest[0].type;\n return (value as unknown[]).map((item) => decodeRefsFromSchema(elementType, item, db));\n }\n\n return value;\n }\n\n case 'Union': {\n // Optional values are represented as union with undefined.\n const nonUndefined = encoded.types.filter((t) => !SchemaAST.isUndefinedKeyword(t));\n if (nonUndefined.length === 1) {\n return decodeRefsFromSchema(nonUndefined[0], value, db);\n }\n\n // For other unions we can't safely pick a branch without validating.\n return value;\n }\n\n case 'Suspend': {\n return decodeRefsFromSchema(encoded.f(), value, db);\n }\n\n case 'Refinement': {\n return decodeRefsFromSchema(encoded.from, value, db);\n }\n\n default: {\n return value;\n }\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Headers from '@effect/platform/Headers';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientError from '@effect/platform/HttpClientError';\nimport * as HttpClientResponse from '@effect/platform/HttpClientResponse';\nimport * as Effect from 'effect/Effect';\nimport * as FiberRef from 'effect/FiberRef';\nimport * as Layer from 'effect/Layer';\nimport * as Stream from 'effect/Stream';\n\nimport { FunctionsAiMemoizationMissError, FunctionsAiUpstreamError } from '@dxos/compute';\nimport { log } from '@dxos/log';\nimport { type EdgeFunctionEnv, ErrorCodec } from '@dxos/protocols';\n\n/**\n * Copy pasted from https://github.com/Effect-TS/effect/blob/main/packages/platform/src/internal/fetchHttpClient.ts\n */\nexport const requestInitTagKey = '@effect/platform/FetchHttpClient/FetchOptions';\n\n/**\n * Shape of the JSON error envelope emitted by the upstream AI gateway (and by the memoization\n * layer that fronts it in test environments).\n *\n * @example\n * ```json\n * {\n * \"type\": \"error\",\n * \"error\": {\n * \"type\": \"memoization_miss\",\n * \"message\": \"No memoized Anthropic conversation found for ...\",\n * \"cacheKey\": \"114dae3db8fe60...\"\n * }\n * }\n * ```\n */\ntype UpstreamErrorEnvelope = {\n type?: string;\n error?: {\n type?: string;\n message?: string;\n cacheKey?: string;\n };\n};\n\nexport class FunctionsAiHttpClient {\n static make = (service: EdgeFunctionEnv.FunctionsAiService) =>\n HttpClient.make((request, url, signal, fiber) => {\n const context = fiber.getFiberRef(FiberRef.currentContext);\n const options: RequestInit = context.unsafeMap.get(requestInitTagKey) ?? {};\n const headers = options.headers\n ? Headers.merge(Headers.fromInput(options.headers), request.headers)\n : request.headers;\n\n const send = (body: BodyInit | undefined) =>\n Effect.tryPromise({\n try: () =>\n service.fetch(\n new Request(url, {\n ...options,\n method: request.method,\n headers,\n body,\n // Note: Don't pass signal - it can't be serialized through RPC\n }),\n ),\n catch: (cause) => {\n log.error('Failed to fetch', { errorSerialized: ErrorCodec.encode(cause as Error) });\n return new HttpClientError.RequestError({\n request,\n reason: 'Transport',\n cause,\n });\n },\n }).pipe(\n Effect.flatMap((response) =>\n // Inspect the body before handing the response to `@effect/ai` so that structured\n // upstream errors surface as typed defects (`FunctionsAiUpstreamError` and friends)\n // rather than as the generic `HttpResponseError` from `@effect/ai/AiError`.\n Effect.flatMap(\n Effect.promise(() => parseUpstreamError(response)),\n (typedError) =>\n typedError ? Effect.die(typedError) : Effect.succeed(HttpClientResponse.fromWeb(request, response)),\n ),\n ),\n );\n\n switch (request.body._tag) {\n case 'Raw':\n case 'Uint8Array':\n return send(request.body.body as any);\n case 'FormData':\n return send(request.body.formData);\n case 'Stream':\n return Stream.toReadableStreamEffect(request.body.stream).pipe(Effect.flatMap(send));\n }\n\n return send(undefined);\n });\n\n static layer = (service: EdgeFunctionEnv.FunctionsAiService) =>\n Layer.succeed(HttpClient.HttpClient, FunctionsAiHttpClient.make(service));\n}\n\n/**\n * Returns a typed error if the response is a non-2xx JSON payload matching\n * {@link UpstreamErrorEnvelope}; otherwise returns `undefined` and the response is forwarded\n * unchanged.\n */\nconst parseUpstreamError = async (response: Response): Promise<Error | undefined> => {\n if (response.ok) {\n return undefined;\n }\n const contentType = response.headers.get('content-type') ?? '';\n if (!contentType.toLowerCase().includes('application/json')) {\n return undefined;\n }\n let body: UpstreamErrorEnvelope;\n try {\n body = (await response.clone().json()) as UpstreamErrorEnvelope;\n } catch {\n return undefined;\n }\n if (!body || body.type !== 'error' || typeof body.error !== 'object' || body.error === null) {\n return undefined;\n }\n const inner = body.error;\n const message = inner.message ?? `Upstream AI service responded with HTTP ${response.status}`;\n if (inner.type === 'memoization_miss' && typeof inner.cacheKey === 'string') {\n return new FunctionsAiMemoizationMissError({\n message,\n context: { cacheKey: inner.cacheKey, status: response.status },\n });\n }\n return new FunctionsAiUpstreamError({\n message,\n context: { type: inner.type, status: response.status, ...(inner.cacheKey ? { cacheKey: inner.cacheKey } : {}) },\n });\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,YAAYA,gBAAgB;AAC5B,YAAYC,uBAAuB;AAGnC,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAE1B,SAASC,kBAAkB;AAC3B,SAASC,UAAUC,aAAa;AAChC,SAASC,mBAAmB;AAErB,IAAMC,+BAAN,MAAMA;;EACX,YAA6BC,cAA8C,CAAA,GAAI;SAAlDA,cAAAA;EAAmD;EAEhFC,eAAeD,aAA2E;AACxF,SAAKA,YAAYE,KAAI,GAAIF,WAAAA;AACzB,WAAO;EACT;EAEA,MAAMG,iBAAiBC,OAA4E;AACjG,WAAO,KAAKJ,YAAYK,OAAO,CAACC,eAAeA,WAAWC,YAAYH,MAAMG,OAAO;EACrF;EAEA,MAAMC,cAAcJ,OAA0E;AAC5F,UAAME,aAAa,KAAKN,YAAYS,KAAK,CAACH,gBAAeA,YAAWC,YAAYH,MAAMG,OAAO;AAC7F,QAAI,CAACD,YAAY;AACf,YAAM,IAAII,MAAM,qCAAqCN,MAAMG,OAAO,EAAE;IACtE;AAEA,WAAOD;EACT;AACF;AAKO,IAAMK,oBAAoB,CAACC,OAAeC,SACpCC,sBAAW,CAACC,YAAAA;AACrB,QAAMC,gBAAgBH,OAAO,GAAGA,IAAAA,IAAQD,KAAAA,KAAUA;AAClD,SAAyBK,4BAAUF,SAAS,iBAAiBC,aAAAA;AAC/D,CAAA;AAEK,IAAME,6BAA6B,CAAClB,gBACnCmB,cAAQxB,WAAWyB,oBAAoB,IAAIrB,6BAA6BC,WAAAA,CAAAA;AAEzE,IAAMqB,yBAAyB,CACpCrB,gBAKMsB,a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AAAA,QAAAA,MAAAA,QAAAA,MAAAA,GAAAA;AACT,eAAAA;MACA;YAA0C,SAAS;QAAS,GAAAA;MAC5D;iBACQlH,QAAgBwH,gCAAQ,OAAA,GAAA;AAC9B,cAAIxH,MAAO0B,KAAAA,KAAQ,SAAA;YACjBA,OAAO1B,QAAOyH;AAChB,iBAAA,GAAA,IAAA,qBAAA,KAAA,MAAA,OAAA,GAAA,GAAA,EAAA;QACF;MACA;AACF,aAAA;IAEA;SAAkB;UAEd,CAAA,MAAOP,QAAAA,MAAAA,GAAAA;AACT,eAAAA;MAEA;UAEE,QAAMQ,SAAAA,WAAsBC,KAAK,QAAO,KAAA,WAAA,GAAA;AACxC,cAAA,cAAiCC,QAASH,KAAAA,CAAAA,EAAAA;AAC5C,eAAAP,OAAA,IAAA,CAAA,SAAA,qBAAA,aAAA,MAAA,EAAA,CAAA;MAEA;AACF,aAAAA;IAEA;SAAc;AAGZ,YAAIW,eAAa1C,QAAW,MAAG,OAAA,CAAA,MAAA,CAAA,6BAAA,CAAA,CAAA;UAC7B,aAAOsC,WAAAA,GAAAA;AACT,eAAA,qBAAA,aAAA,CAAA,GAAAP,QAAA,EAAA;MAEA;AAEF,aAAAA;IAEA;SAAgB;AAEhB,aAAA,qBAAA,QAAA,EAAA,GAAAA,QAAA,EAAA;IAEA;SAAmB;AAEnB,aAAA,qBAAA,QAAA,MAAAA,QAAA,EAAA;IAEA;;AAEA,aAAAA;IACF;EACF;;",
|
|
6
|
+
"names": ["HttpClient", "HttpClientRequest", "Effect", "Layer", "Redacted", "Credential", "Database", "Query", "AccessToken", "ConfiguredCredentialsService", "credentials", "addCredentials", "push", "queryCredentials", "query", "filter", "credential", "service", "getCredential", "find", "Error", "withAuthorization", "token", "kind", "mapRequest", "request", "authorization", "setHeader", "configuredCredentialsLayer", "succeed", "CredentialsService", "credentialsLayerConfig", "effect", "gen", "serviceCredentials", "forEach", "apiKey", "value", "credentialsLayerFromDatabase", "caching", "dbService", "Service", "cache", "Map", "cacheKey", "JSON", "stringify", "has", "get", "accessTokens", "db", "type", "run", "accessToken", "source", "map", "set", "length", "Context", "Effect", "Layer", "FunctionInvocationService", "Tag", "layerNotAvailable", "succeed", "invokeFunction", "die", "resolveFunction", "functionDef", "input", "serviceFunctionEffect", "service", "key", "QueueService", "feedServiceFromQueueServiceLayer", "MESSAGE_PROPERTY_TOOL_CALL_ID", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "getUserFunctionIdInMetadata", "meta", "keys", "find", "key", "source", "id", "setUserFunctionIdInMetadata", "functionId", "Error", "push", "Effect", "Layer", "Option", "Schema", "SchemaAST", "AiModelResolver", "AiService", "AnthropicResolver", "Blueprint", "LifecycleState", "Database", "JsonSchema", "createFeedServiceLayer", "EchoClient", "refFromEncodedReference", "runAndForwardErrors", "assertState", "failedInvariant", "PublicKey", "log", "ErrorCodec", "configuredCredentialsLayer", "Headers", "HttpClient", "HttpClientError", "HttpClientResponse", "Effect", "FiberRef", "Layer", "Stream", "FunctionsAiMemoizationMissError", "FunctionsAiUpstreamError", "log", "ErrorCodec", "make", "getFiberRef", "options", "unsafeMap", "get", "requestInitTagKey", "headers", "merge", "fromInput", "send", "body", "tryPromise", "service", "Request", "method", "request", "cause", "errorSerialized", "RequestError", "reason", "formData", "toReadableStreamEffect", "undefined", "layer", "contentType", "inner", "message", "context", "status", "cacheKey", "Operation", "isOperationWithHandler", "func", "TypeError", "meta", "key", "name", "description", "inputSchema", "JsonSchema", "outputSchema", "output", "undefined", "services", "service", "handler", "serviceTags", "includes", "Database", "FunctionError", "message", "Schema", "onExcessProperty", "data", "error", "InvalidOperationInputError", "cause", "types", "invariant", "funcContext", "graph", "result", "dataWithDecodedRefs", "Effect", "isEffect", "runAndForwardErrors", "flush", "disk", "indexes", "InvalidOperationOutputError", "context", "client", "db", "queues", "opts", "connectToService", "dataService", "queryService", "queueService", "spaceId", "failedInvariant", "spaceKey", "PublicKey", "fromHex", "reactiveSchemaQuery", "preloadSchemaOnOpen", "open", "close", "createLayer", "assertState", "dbLayer", "layer", "queuesLayer", "QueueService", "feedLayer", "createFeedServiceLayer", "notAvailable", "credentials", "credentialsLayerFromDatabase", "caching", "pipe", "Layer", "aiLayer", "InternalAiServiceLayer", "operationServiceLayer", "functionsService", "makeOperationServiceLayer", "operationRegistryLayer", "makeOperationRegistryLayer", "traceWriterLayer", "traceService", "makeTraceWriterLayer", "Trace", "writerLayerNoop", "log", "functionsAiService", "spaceRootUrl", "toolkits", "length", "blueprintRegistryLayer", "blueprintRegistry", "OpaqueToolkit", "providerLayer", "write", "payload", "eventType", "__dxlog_file", "isEphemeral", "invokeRemote", "input", "options", "deployedId", "op", "ErrorCodec", "schedule", "invokePromise", "Error", "String", "invoke", "die", "resolve", "records", "tryPromise", "match", "find", "some", "deserialize", "Option", "none", "value", "Ref", "encoded", "resolver", "createRefResolver", "space", "toString", "decodeRefsFromSchema", "elementType", "rest", "item", "nonUndefined"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/sdk.ts":{"bytes":2251,"imports":[],"format":"esm"},"src/services/credentials.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/sdk.ts":{"bytes":2251,"imports":[],"format":"esm"},"src/services/credentials.ts":{"bytes":12961,"imports":[{"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/Layer","kind":"import-statement","external":true},{"path":"effect/Redacted","kind":"import-statement","external":true},{"path":"@dxos/compute","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true}],"format":"esm"},"src/services/function-invocation-service.ts":{"bytes":3812,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true}],"format":"esm"},"src/services/queues.ts":{"bytes":600,"imports":[{"path":"@dxos/echo-db","kind":"import-statement","external":true}],"format":"esm"},"src/services/tracing.ts":{"bytes":662,"imports":[],"format":"esm"},"src/services/index.ts":{"bytes":823,"imports":[{"path":"src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"src/services/function-invocation-service.ts","kind":"import-statement","original":"./function-invocation-service"},{"path":"src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"src/services/tracing.ts","kind":"import-statement","original":"./tracing"}],"format":"esm"},"src/types/url.ts":{"bytes":3289,"imports":[],"format":"esm"},"src/types/index.ts":{"bytes":363,"imports":[{"path":"src/types/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"},"src/protocol/functions-ai-http-client.ts":{"bytes":15950,"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/compute","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true}],"format":"esm"},"src/protocol/protocol.ts":{"bytes":61791,"imports":[{"path":"@effect/ai-anthropic/AnthropicClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/ai/resolvers","kind":"import-statement","external":true},{"path":"@dxos/compute","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"},{"path":"src/protocol/functions-ai-http-client.ts","kind":"import-statement","original":"./functions-ai-http-client"}],"format":"esm"},"src/protocol/index.ts":{"bytes":376,"imports":[{"path":"src/protocol/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"src/index.ts":{"bytes":620,"imports":[{"path":"src/sdk.ts","kind":"import-statement","original":"./sdk"},{"path":"src/services/index.ts","kind":"import-statement","original":"./services"},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"},{"path":"src/protocol/index.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":46084},"dist/lib/neutral/index.mjs":{"imports":[{"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/Layer","kind":"import-statement","external":true},{"path":"effect/Redacted","kind":"import-statement","external":true},{"path":"@dxos/compute","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@effect/ai-anthropic/AnthropicClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/ai/resolvers","kind":"import-statement","external":true},{"path":"@dxos/compute","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","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/compute","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true}],"exports":["ConfiguredCredentialsService","FUNCTIONS_META_KEY","FUNCTIONS_PRESET_META_KEY","FunctionInvocationService","MESSAGE_PROPERTY_TOOL_CALL_ID","QueueService","configuredCredentialsLayer","credentialsLayerConfig","credentialsLayerFromDatabase","feedServiceFromQueueServiceLayer","getUserFunctionIdInMetadata","setUserFunctionIdInMetadata","withAuthorization","wrapFunctionHandler"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0},"src/services/credentials.ts":{"bytesInOutput":2907},"src/services/index.ts":{"bytesInOutput":0},"src/services/function-invocation-service.ts":{"bytesInOutput":818},"src/services/queues.ts":{"bytesInOutput":80},"src/services/tracing.ts":{"bytesInOutput":50},"src/types/url.ts":{"bytesInOutput":576},"src/protocol/protocol.ts":{"bytesInOutput":16002},"src/protocol/functions-ai-http-client.ts":{"bytesInOutput":3695}},"bytes":24823}}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpaqueToolkit } from '@dxos/ai';
|
|
2
|
-
import { Operation } from '@dxos/compute';
|
|
2
|
+
import { Blueprint, Operation } from '@dxos/compute';
|
|
3
3
|
import { type Type } from '@dxos/echo';
|
|
4
4
|
import { type FunctionProtocol } from '@dxos/protocols';
|
|
5
5
|
export interface FunctionWrappingOptions {
|
|
@@ -11,6 +11,11 @@ export interface FunctionWrappingOptions {
|
|
|
11
11
|
* Toolkits to make available via the `OpaqueToolkitProvider`.
|
|
12
12
|
*/
|
|
13
13
|
toolkits?: OpaqueToolkit.OpaqueToolkit[];
|
|
14
|
+
/**
|
|
15
|
+
* Blueprint registry to expose as `Blueprint.RegistryService` inside handler Effects.
|
|
16
|
+
* Required for operations that declare `Blueprint.RegistryService` in their `services` list.
|
|
17
|
+
*/
|
|
18
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
21
|
* Wraps a function handler made with `defineFunction` to a protocol that the functions-runtime expects.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/protocol/protocol.ts"],"names":[],"mappings":"AAWA,OAAO,EAA8B,aAAa,EAAE,MAAM,UAAU,CAAC;AAErE,OAAO,
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/protocol/protocol.ts"],"names":[],"mappings":"AAWA,OAAO,EAA8B,aAAa,EAAE,MAAM,UAAU,CAAC;AAErE,OAAO,EACL,SAAS,EAIT,SAAS,EAGV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAmC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAOxE,OAAO,EAA+B,KAAK,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;AAWzG,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC,aAAa,EAAE,CAAC;IAEzC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC;CACxC;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,SACxB,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,SAC/C,uBAAuB,KAC5B,gBAAgB,CAAC,IA+FnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../src/services/credentials.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAC;AAE1D,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../src/services/credentials.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAC;AAE1D,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAS,MAAM,YAAY,CAAC;AAG7C,qBAAa,4BAA6B,YAAW,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC;IACzF,OAAO,CAAC,QAAQ,CAAC,WAAW;IAAxC,YAA6B,WAAW,GAAE,UAAU,CAAC,iBAAiB,EAAO,EAAI;IAEjF,cAAc,CAAC,WAAW,EAAE,UAAU,CAAC,iBAAiB,EAAE,GAAG,4BAA4B,CAGxF;IAEK,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAEjG;IAEK,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAO5F;CACF;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,MAAM,SAAS,QAAQ,GAAG,OAAO,uFAItE,CAAC;AAEL,eAAO,MAAM,0BAA0B,gBAAiB,UAAU,CAAC,iBAAiB,EAAE,6DACO,CAAC;AAE9F,eAAO,MAAM,sBAAsB,gBACpB;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;CAClD,EAAE,gGAgBF,CAAC;AAEJ,eAAO,MAAM,4BAA4B,iBAAyB;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,wEA0CpF,CAAC"}
|
|
@@ -6,6 +6,9 @@ declare const FunctionInvocationService_base: Context.TagClass<FunctionInvocatio
|
|
|
6
6
|
invokeFunction<I, O>(functionDef: Operation.Definition<I, O, any>, input: I): Effect.Effect<O>;
|
|
7
7
|
resolveFunction(key: string): Effect.Effect<Operation.Definition.Any, FunctionNotFoundError>;
|
|
8
8
|
}>;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
9
12
|
export declare class FunctionInvocationService extends FunctionInvocationService_base {
|
|
10
13
|
static layerNotAvailable: Layer.Layer<FunctionInvocationService, never, never>;
|
|
11
14
|
static invokeFunction: <I, O>(functionDef: Operation.Definition<I, O, any>, input: I) => Effect.Effect<O, never, FunctionInvocationService>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-invocation-service.d.ts","sourceRoot":"","sources":["../../../../src/services/function-invocation-service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,KAAK,qBAAqB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;;
|
|
1
|
+
{"version":3,"file":"function-invocation-service.d.ts","sourceRoot":"","sources":["../../../../src/services/function-invocation-service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,KAAK,qBAAqB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;;mBAQnD,CAAC,EAAE,CAAC,eAAe,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;yBAEzE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,qBAAqB,CAAC;;AARhG;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,8BAO5C;IACD,MAAM,CAAC,iBAAiB,uDAGrB;IAEH,MAAM,CAAC,cAAc,GAAI,CAAC,EAAE,CAAC,eACd,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,SACrC,CAAC,KACP,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAC8D;IAEnH,MAAM,CAAC,eAAe,QACf,MAAM,KACV,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,qBAAqB,EAAE,yBAAyB,CAAC,CACS;CACtG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { QueueService, feedServiceFromQueueServiceLayer } from '@dxos/echo-db';
|
|
2
2
|
//# sourceMappingURL=queues.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queues.d.ts","sourceRoot":"","sources":["../../../../src/services/queues.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"queues.d.ts","sourceRoot":"","sources":["../../../../src/services/queues.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC"}
|