@dxos/functions 0.8.4-main.74a063c4e0 → 0.8.4-main.765dc60934
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 +261 -930
- package/dist/lib/neutral/index.mjs.map +4 -4
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/types/src/index.d.ts +0 -6
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -1
- package/dist/types/src/protocol/functions-ai-http-client.test.d.ts +2 -0
- package/dist/types/src/protocol/functions-ai-http-client.test.d.ts.map +1 -0
- package/dist/types/src/protocol/protocol.d.ts +14 -2
- package/dist/types/src/protocol/protocol.d.ts.map +1 -1
- package/dist/types/src/sdk.d.ts +3 -7
- package/dist/types/src/sdk.d.ts.map +1 -1
- package/dist/types/src/services/credentials.d.ts +15 -38
- package/dist/types/src/services/credentials.d.ts.map +1 -1
- package/dist/types/src/services/function-invocation-service.d.ts +3 -5
- package/dist/types/src/services/function-invocation-service.d.ts.map +1 -1
- package/dist/types/src/services/index.d.ts +1 -4
- package/dist/types/src/services/index.d.ts.map +1 -1
- package/dist/types/src/services/queues.d.ts +1 -49
- package/dist/types/src/services/queues.d.ts.map +1 -1
- package/dist/types/src/services/tracing.d.ts +1 -107
- package/dist/types/src/services/tracing.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -3
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/url.d.ts +1 -1
- package/dist/types/src/types/url.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -21
- package/src/index.ts +0 -6
- package/src/protocol/functions-ai-http-client.test.ts +105 -0
- package/src/protocol/functions-ai-http-client.ts +75 -1
- package/src/protocol/protocol.test.ts +10 -10
- package/src/protocol/protocol.ts +213 -40
- package/src/sdk.ts +7 -15
- package/src/services/credentials.ts +76 -120
- package/src/services/function-invocation-service.ts +3 -9
- package/src/services/index.ts +1 -4
- package/src/services/queues.ts +1 -87
- package/src/services/tracing.ts +0 -192
- package/src/types/index.ts +0 -3
- package/src/types/url.ts +1 -1
- package/dist/lib/neutral/Trace.mjs +0 -38
- package/dist/lib/neutral/Trace.mjs.map +0 -7
- package/dist/lib/neutral/chunk-5T7GOX2V.mjs +0 -149
- package/dist/lib/neutral/chunk-5T7GOX2V.mjs.map +0 -7
- package/dist/lib/neutral/chunk-IVDUS56O.mjs +0 -49
- package/dist/lib/neutral/chunk-IVDUS56O.mjs.map +0 -7
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/neutral/fib-N45KAC7C.mjs +0 -23
- package/dist/lib/neutral/fib-N45KAC7C.mjs.map +0 -7
- package/dist/lib/neutral/reply-EUEPKNJF.mjs +0 -19
- package/dist/lib/neutral/reply-EUEPKNJF.mjs.map +0 -7
- package/dist/lib/neutral/sleep-PUK3D4FF.mjs +0 -15
- package/dist/lib/neutral/sleep-PUK3D4FF.mjs.map +0 -7
- package/dist/types/src/Trace.d.ts +0 -155
- package/dist/types/src/Trace.d.ts.map +0 -1
- package/dist/types/src/errors.d.ts +0 -121
- package/dist/types/src/errors.d.ts.map +0 -1
- package/dist/types/src/example/definitions.d.ts +0 -11
- package/dist/types/src/example/definitions.d.ts.map +0 -1
- package/dist/types/src/example/fib.d.ts +0 -8
- package/dist/types/src/example/fib.d.ts.map +0 -1
- package/dist/types/src/example/forex-effect.d.ts +0 -3
- package/dist/types/src/example/forex-effect.d.ts.map +0 -1
- package/dist/types/src/example/index.d.ts +0 -4
- package/dist/types/src/example/index.d.ts.map +0 -1
- package/dist/types/src/example/reply.d.ts +0 -4
- package/dist/types/src/example/reply.d.ts.map +0 -1
- package/dist/types/src/example/sleep.d.ts +0 -6
- package/dist/types/src/example/sleep.d.ts.map +0 -1
- package/dist/types/src/process/Process.d.ts +0 -247
- package/dist/types/src/process/Process.d.ts.map +0 -1
- package/dist/types/src/process/ServiceResolver.d.ts +0 -74
- package/dist/types/src/process/ServiceResolver.d.ts.map +0 -1
- package/dist/types/src/process/StorageService.d.ts +0 -58
- package/dist/types/src/process/StorageService.d.ts.map +0 -1
- package/dist/types/src/services/event-logger.d.ts +0 -81
- package/dist/types/src/services/event-logger.d.ts.map +0 -1
- package/dist/types/src/types/Script.d.ts +0 -22
- package/dist/types/src/types/Script.d.ts.map +0 -1
- package/dist/types/src/types/Trigger.d.ts +0 -120
- package/dist/types/src/types/Trigger.d.ts.map +0 -1
- package/dist/types/src/types/TriggerEvent.d.ts +0 -75
- package/dist/types/src/types/TriggerEvent.d.ts.map +0 -1
- package/src/Trace.ts +0 -202
- package/src/errors.ts +0 -21
- package/src/example/definitions.ts +0 -49
- package/src/example/fib.ts +0 -23
- package/src/example/forex-effect.ts +0 -40
- package/src/example/index.ts +0 -12
- package/src/example/reply.ts +0 -19
- package/src/example/sleep.ts +0 -17
- package/src/process/Process.ts +0 -486
- package/src/process/ServiceResolver.ts +0 -174
- package/src/process/StorageService.ts +0 -99
- package/src/services/event-logger.ts +0 -127
- package/src/types/Script.ts +0 -38
- package/src/types/Trigger.ts +0 -154
- package/src/types/TriggerEvent.ts +0 -62
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import * as Schema from 'effect/Schema';
|
|
2
|
-
import { Obj, QueryAST, Type } from '@dxos/echo';
|
|
3
|
-
/**
|
|
4
|
-
* Type discriminator for TriggerType.
|
|
5
|
-
* Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.
|
|
6
|
-
* https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions
|
|
7
|
-
*/
|
|
8
|
-
export declare const Kinds: readonly ["email", "queue", "subscription", "timer", "webhook"];
|
|
9
|
-
export type Kind = (typeof Kinds)[number];
|
|
10
|
-
export declare const EmailSpec: Schema.Struct<{
|
|
11
|
-
kind: Schema.Literal<["email"]>;
|
|
12
|
-
}>;
|
|
13
|
-
export type EmailSpec = Schema.Schema.Type<typeof EmailSpec>;
|
|
14
|
-
export declare const QueueSpec: Schema.Struct<{
|
|
15
|
-
kind: Schema.Literal<["queue"]>;
|
|
16
|
-
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
17
|
-
}>;
|
|
18
|
-
export type QueueSpec = Schema.Schema.Type<typeof QueueSpec>;
|
|
19
|
-
/**
|
|
20
|
-
* Subscription.
|
|
21
|
-
*/
|
|
22
|
-
export declare const SubscriptionSpec: Schema.Struct<{
|
|
23
|
-
kind: Schema.Literal<["subscription"]>;
|
|
24
|
-
query: Schema.Struct<{
|
|
25
|
-
raw: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
26
|
-
ast: Schema.Schema<QueryAST.QuerySelectClause | QueryAST.QueryFilterClause | QueryAST.QueryReferenceTraversalClause | QueryAST.QueryIncomingReferencesClause | QueryAST.QueryRelationClause | QueryAST.QueryRelationTraversalClause | QueryAST.QueryHierarchyTraversalClause | QueryAST.QueryUnionClause | QueryAST.QuerySetDifferenceClause | QueryAST.QueryOrderClause | QueryAST.QueryOptionsClause | QueryAST.QueryLimitClause | QueryAST.QueryFromClause, QueryAST.QuerySelectClause | QueryAST.QueryFilterClause | QueryAST.QueryReferenceTraversalClause | QueryAST.QueryIncomingReferencesClause | QueryAST.QueryRelationClause | QueryAST.QueryRelationTraversalClause | QueryAST.QueryHierarchyTraversalClause | QueryAST.QueryUnionClause | QueryAST.QuerySetDifferenceClause | QueryAST.QueryOrderClause | QueryAST.QueryOptionsClause | QueryAST.QueryLimitClause | QueryAST.QueryFromClause, never>;
|
|
27
|
-
}>;
|
|
28
|
-
options: Schema.optional<Schema.Struct<{
|
|
29
|
-
deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
30
|
-
delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
31
|
-
}>>;
|
|
32
|
-
}>;
|
|
33
|
-
export type SubscriptionSpec = Schema.Schema.Type<typeof SubscriptionSpec>;
|
|
34
|
-
/**
|
|
35
|
-
* Cron timer.
|
|
36
|
-
*/
|
|
37
|
-
export declare const TimerSpec: Schema.Struct<{
|
|
38
|
-
kind: Schema.Literal<["timer"]>;
|
|
39
|
-
cron: Schema.SchemaClass<string, string, never>;
|
|
40
|
-
}>;
|
|
41
|
-
export type TimerSpec = Schema.Schema.Type<typeof TimerSpec>;
|
|
42
|
-
/**
|
|
43
|
-
* Webhook.
|
|
44
|
-
*/
|
|
45
|
-
export declare const WebhookSpec: Schema.Struct<{
|
|
46
|
-
kind: Schema.Literal<["webhook"]>;
|
|
47
|
-
method: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
48
|
-
port: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
49
|
-
}>;
|
|
50
|
-
export type WebhookSpec = Schema.Schema.Type<typeof WebhookSpec>;
|
|
51
|
-
/**
|
|
52
|
-
* Trigger schema.
|
|
53
|
-
*/
|
|
54
|
-
export declare const Spec: Schema.Union<[Schema.Struct<{
|
|
55
|
-
kind: Schema.Literal<["email"]>;
|
|
56
|
-
}>, Schema.Struct<{
|
|
57
|
-
kind: Schema.Literal<["queue"]>;
|
|
58
|
-
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
59
|
-
}>, Schema.Struct<{
|
|
60
|
-
kind: Schema.Literal<["subscription"]>;
|
|
61
|
-
query: Schema.Struct<{
|
|
62
|
-
raw: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
63
|
-
ast: Schema.Schema<QueryAST.QuerySelectClause | QueryAST.QueryFilterClause | QueryAST.QueryReferenceTraversalClause | QueryAST.QueryIncomingReferencesClause | QueryAST.QueryRelationClause | QueryAST.QueryRelationTraversalClause | QueryAST.QueryHierarchyTraversalClause | QueryAST.QueryUnionClause | QueryAST.QuerySetDifferenceClause | QueryAST.QueryOrderClause | QueryAST.QueryOptionsClause | QueryAST.QueryLimitClause | QueryAST.QueryFromClause, QueryAST.QuerySelectClause | QueryAST.QueryFilterClause | QueryAST.QueryReferenceTraversalClause | QueryAST.QueryIncomingReferencesClause | QueryAST.QueryRelationClause | QueryAST.QueryRelationTraversalClause | QueryAST.QueryHierarchyTraversalClause | QueryAST.QueryUnionClause | QueryAST.QuerySetDifferenceClause | QueryAST.QueryOrderClause | QueryAST.QueryOptionsClause | QueryAST.QueryLimitClause | QueryAST.QueryFromClause, never>;
|
|
64
|
-
}>;
|
|
65
|
-
options: Schema.optional<Schema.Struct<{
|
|
66
|
-
deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
67
|
-
delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
68
|
-
}>>;
|
|
69
|
-
}>, Schema.Struct<{
|
|
70
|
-
kind: Schema.Literal<["timer"]>;
|
|
71
|
-
cron: Schema.SchemaClass<string, string, never>;
|
|
72
|
-
}>, Schema.Struct<{
|
|
73
|
-
kind: Schema.Literal<["webhook"]>;
|
|
74
|
-
method: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
75
|
-
port: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
76
|
-
}>]>;
|
|
77
|
-
export type Spec = Schema.Schema.Type<typeof Spec>;
|
|
78
|
-
/**
|
|
79
|
-
* Function trigger.
|
|
80
|
-
* Function is invoked with the `payload` passed as input data.
|
|
81
|
-
* The event that triggers the function is available in the function context.
|
|
82
|
-
*/
|
|
83
|
-
declare const TriggerSchema: Type.Obj<{
|
|
84
|
-
readonly function?: import("@dxos/echo/internal").Ref<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown> | undefined;
|
|
85
|
-
readonly input?: {
|
|
86
|
-
readonly [x: string]: any;
|
|
87
|
-
} | undefined;
|
|
88
|
-
readonly inputNodeId?: string | undefined;
|
|
89
|
-
readonly enabled?: boolean | undefined;
|
|
90
|
-
readonly spec?: {
|
|
91
|
-
readonly kind: "email";
|
|
92
|
-
} | {
|
|
93
|
-
readonly queue: string;
|
|
94
|
-
readonly kind: "queue";
|
|
95
|
-
} | {
|
|
96
|
-
readonly kind: "subscription";
|
|
97
|
-
readonly query: {
|
|
98
|
-
readonly raw?: string | undefined;
|
|
99
|
-
readonly ast: QueryAST.QuerySelectClause | QueryAST.QueryFilterClause | QueryAST.QueryReferenceTraversalClause | QueryAST.QueryIncomingReferencesClause | QueryAST.QueryRelationClause | QueryAST.QueryRelationTraversalClause | QueryAST.QueryHierarchyTraversalClause | QueryAST.QueryUnionClause | QueryAST.QuerySetDifferenceClause | QueryAST.QueryOrderClause | QueryAST.QueryOptionsClause | QueryAST.QueryLimitClause | QueryAST.QueryFromClause;
|
|
100
|
-
};
|
|
101
|
-
readonly options?: {
|
|
102
|
-
readonly deep?: boolean | undefined;
|
|
103
|
-
readonly delay?: number | undefined;
|
|
104
|
-
} | undefined;
|
|
105
|
-
} | {
|
|
106
|
-
readonly kind: "timer";
|
|
107
|
-
readonly cron: string;
|
|
108
|
-
} | {
|
|
109
|
-
readonly kind: "webhook";
|
|
110
|
-
readonly method?: string | undefined;
|
|
111
|
-
readonly port?: number | undefined;
|
|
112
|
-
} | undefined;
|
|
113
|
-
readonly concurrency?: number | undefined;
|
|
114
|
-
}, Schema.Struct.Fields>;
|
|
115
|
-
export interface Trigger extends Schema.Schema.Type<typeof TriggerSchema> {
|
|
116
|
-
}
|
|
117
|
-
export declare const Trigger: Type.Obj<Trigger>;
|
|
118
|
-
export declare const make: (props: Obj.MakeProps<typeof Trigger>) => Obj.OfShape<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Trigger>;
|
|
119
|
-
export {};
|
|
120
|
-
//# sourceMappingURL=Trigger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Trigger.d.ts","sourceRoot":"","sources":["../../../../src/types/Trigger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAc,GAAG,EAAE,QAAQ,EAAO,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlE;;;;GAIG;AACH,eAAO,MAAM,KAAK,iEAAkE,CAAC;AACrF,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AAI1C,eAAO,MAAM,SAAS;;EAEpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC,CAAC;AAI7D,eAAO,MAAM,SAAS;;;EAKpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;EAc3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,SAAS;;;EAMpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,WAAW;;;;EAatB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;IAEf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnD;;;;GAIG;AACH,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgDlB,CAAC;AAEF,MAAM,WAAW,OAAQ,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,aAAa,CAAC;CAAG;AAC5E,eAAO,MAAM,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAwB,CAAC;AAE/D,eAAO,MAAM,IAAI,GAAI,OAAO,GAAG,CAAC,SAAS,CAAC,OAAO,OAAO,CAAC,+GAA6B,CAAC"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import * as Schema from 'effect/Schema';
|
|
2
|
-
import { Obj, Ref } from '@dxos/echo';
|
|
3
|
-
export declare const EmailEvent: Schema.Struct<{
|
|
4
|
-
from: typeof Schema.String;
|
|
5
|
-
to: typeof Schema.String;
|
|
6
|
-
subject: typeof Schema.String;
|
|
7
|
-
created: typeof Schema.String;
|
|
8
|
-
body: typeof Schema.String;
|
|
9
|
-
}>;
|
|
10
|
-
export type EmailEvent = Schema.Schema.Type<typeof EmailEvent>;
|
|
11
|
-
export declare const QueueEvent: Schema.Struct<{
|
|
12
|
-
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
13
|
-
item: typeof Schema.Any;
|
|
14
|
-
cursor: typeof Schema.String;
|
|
15
|
-
}>;
|
|
16
|
-
export type QueueEvent = Schema.Schema.Type<typeof QueueEvent>;
|
|
17
|
-
export declare const SubscriptionEvent: Schema.Struct<{
|
|
18
|
-
/**
|
|
19
|
-
* Type of the mutation.
|
|
20
|
-
*/
|
|
21
|
-
type: typeof Schema.String;
|
|
22
|
-
/**
|
|
23
|
-
* Reference to the object that was changed or created.
|
|
24
|
-
*/
|
|
25
|
-
subject: Ref.RefSchema<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated
|
|
28
|
-
*/
|
|
29
|
-
changedObjectId: Schema.optional<typeof Schema.String>;
|
|
30
|
-
}>;
|
|
31
|
-
export type SubscriptionEvent = Schema.Schema.Type<typeof SubscriptionEvent>;
|
|
32
|
-
export declare const TimerEvent: Schema.Struct<{
|
|
33
|
-
tick: typeof Schema.Number;
|
|
34
|
-
}>;
|
|
35
|
-
export type TimerEvent = Schema.Schema.Type<typeof TimerEvent>;
|
|
36
|
-
export declare const WebhookEvent: Schema.Struct<{
|
|
37
|
-
url: typeof Schema.String;
|
|
38
|
-
method: Schema.Literal<["GET", "POST"]>;
|
|
39
|
-
headers: Schema.Record$<typeof Schema.String, typeof Schema.String>;
|
|
40
|
-
bodyText: typeof Schema.String;
|
|
41
|
-
}>;
|
|
42
|
-
export type WebhookEvent = Schema.Schema.Type<typeof WebhookEvent>;
|
|
43
|
-
export declare const TriggerEvent: Schema.Union<[Schema.Struct<{
|
|
44
|
-
from: typeof Schema.String;
|
|
45
|
-
to: typeof Schema.String;
|
|
46
|
-
subject: typeof Schema.String;
|
|
47
|
-
created: typeof Schema.String;
|
|
48
|
-
body: typeof Schema.String;
|
|
49
|
-
}>, Schema.Struct<{
|
|
50
|
-
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
51
|
-
item: typeof Schema.Any;
|
|
52
|
-
cursor: typeof Schema.String;
|
|
53
|
-
}>, Schema.Struct<{
|
|
54
|
-
/**
|
|
55
|
-
* Type of the mutation.
|
|
56
|
-
*/
|
|
57
|
-
type: typeof Schema.String;
|
|
58
|
-
/**
|
|
59
|
-
* Reference to the object that was changed or created.
|
|
60
|
-
*/
|
|
61
|
-
subject: Ref.RefSchema<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated
|
|
64
|
-
*/
|
|
65
|
-
changedObjectId: Schema.optional<typeof Schema.String>;
|
|
66
|
-
}>, Schema.Struct<{
|
|
67
|
-
tick: typeof Schema.Number;
|
|
68
|
-
}>, Schema.Struct<{
|
|
69
|
-
url: typeof Schema.String;
|
|
70
|
-
method: Schema.Literal<["GET", "POST"]>;
|
|
71
|
-
headers: Schema.Record$<typeof Schema.String, typeof Schema.String>;
|
|
72
|
-
bodyText: typeof Schema.String;
|
|
73
|
-
}>]>;
|
|
74
|
-
export type TriggerEvent = Schema.Schema.Type<typeof TriggerEvent>;
|
|
75
|
-
//# sourceMappingURL=TriggerEvent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TriggerEvent.d.ts","sourceRoot":"","sources":["../../../../src/types/TriggerEvent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAO,GAAG,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAQ3C,eAAO,MAAM,UAAU;;;;;;EAMrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAE/D,eAAO,MAAM,UAAU;;;;EAIrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAE/D,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;;IAIH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE7E,eAAO,MAAM,UAAU;;EAAyC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAE/D,eAAO,MAAM,YAAY;;;;;EAKvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC;AAEnE,eAAO,MAAM,YAAY;;;;;;;;;;;IA7BvB;;OAEG;;IAIH;;OAEG;;IAGH;;OAEG;;;;;;;;;IAgBwG,CAAC;AAC9G,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
package/src/Trace.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2026 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// @import-as-namespace
|
|
6
|
-
|
|
7
|
-
import * as Context from 'effect/Context';
|
|
8
|
-
import * as Effect from 'effect/Effect';
|
|
9
|
-
import * as Layer from 'effect/Layer';
|
|
10
|
-
import * as Schema from 'effect/Schema';
|
|
11
|
-
|
|
12
|
-
import { Annotation, Obj, Type } from '@dxos/echo';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Writes ephemeral or persistent events to the trace.
|
|
16
|
-
* Exposed to processes and operations to record events to the trace.
|
|
17
|
-
*/
|
|
18
|
-
export interface TraceWriter {
|
|
19
|
-
write<T>(eventType: EventType<T>, payload: NoInfer<T>): void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Service that writes events to the trace.
|
|
24
|
-
* Exposed to processes and operations to record events to the trace.
|
|
25
|
-
*/
|
|
26
|
-
export class TraceService extends Context.Tag('@dxos/functions/TraceService')<TraceService, TraceWriter>() {}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Writes an event to the trace.
|
|
30
|
-
*/
|
|
31
|
-
export const write: <T>(eventType: EventType<T>, payload: NoInfer<T>) => Effect.Effect<void, never, TraceService> =
|
|
32
|
-
Effect.serviceFunction(TraceService, (_) => _.write);
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Defines an event type for the trace.
|
|
36
|
-
*/
|
|
37
|
-
export interface EventType<T> {
|
|
38
|
-
readonly key: string;
|
|
39
|
-
readonly schema: Schema.Schema<T, any>;
|
|
40
|
-
readonly isEphemeral: boolean;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const EventType = <T>(
|
|
44
|
-
key: string,
|
|
45
|
-
opts: { schema: Schema.Schema<T, any>; isEphemeral: boolean },
|
|
46
|
-
): EventType<T> => {
|
|
47
|
-
return {
|
|
48
|
-
key,
|
|
49
|
-
schema: opts.schema,
|
|
50
|
-
isEphemeral: opts.isEphemeral,
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Extracts the payload type from an event type.
|
|
56
|
-
*/
|
|
57
|
-
export type PayloadType<E extends EventType<any>> = E extends EventType<infer T> ? T : never;
|
|
58
|
-
|
|
59
|
-
export const Event = Schema.Struct({
|
|
60
|
-
timestamp: Schema.Number,
|
|
61
|
-
type: Schema.String,
|
|
62
|
-
data: Schema.Unknown, // Type-specific payload;
|
|
63
|
-
});
|
|
64
|
-
export interface Event extends Schema.Schema.Type<typeof Event> {}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Checks if an event is of a given type.
|
|
68
|
-
*/
|
|
69
|
-
export const isOfType = <T, E extends Event>(eventType: EventType<T>, event: E): event is E & { data: T } => {
|
|
70
|
-
return event.type === eventType.key;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Metadata on the context of a trace message.
|
|
75
|
-
*/
|
|
76
|
-
// TODO(dmaretskyi): Expand on this: conversation id, tool call id, etc.
|
|
77
|
-
export const Meta = Schema.Struct({
|
|
78
|
-
pid: Schema.optional(Schema.String), // NOTE: Not Process.ID to avoid circular dependency.
|
|
79
|
-
parentPid: Schema.optional(Schema.String),
|
|
80
|
-
processName: Schema.optional(Schema.String),
|
|
81
|
-
/**
|
|
82
|
-
* ID of the conversation feed object if present.
|
|
83
|
-
*/
|
|
84
|
-
conversationId: Schema.optional(Obj.ID),
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* ID of the trigger object if invocation resulted from a trigger.
|
|
88
|
-
*/
|
|
89
|
-
triggerId: Schema.optional(Obj.ID),
|
|
90
|
-
});
|
|
91
|
-
export interface Meta extends Schema.Schema.Type<typeof Meta> {}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Envelope for a set of events.
|
|
95
|
-
*/
|
|
96
|
-
export const MessageData = Schema.Struct({
|
|
97
|
-
meta: Meta,
|
|
98
|
-
|
|
99
|
-
isEphemeral: Schema.Boolean,
|
|
100
|
-
events: Schema.Array(Event),
|
|
101
|
-
});
|
|
102
|
-
export interface MessageData extends Schema.Schema.Type<typeof MessageData> {}
|
|
103
|
-
|
|
104
|
-
export const Message = MessageData.pipe(
|
|
105
|
-
Type.object({
|
|
106
|
-
typename: 'org.dxos.type.traceMessage',
|
|
107
|
-
version: '0.1.0',
|
|
108
|
-
}),
|
|
109
|
-
Annotation.IconAnnotation.set({
|
|
110
|
-
icon: 'ph--note--regular',
|
|
111
|
-
hue: 'rose',
|
|
112
|
-
}),
|
|
113
|
-
);
|
|
114
|
-
export interface Message extends Schema.Schema.Type<typeof Message> {}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Sink for complete trace messages.
|
|
118
|
-
*/
|
|
119
|
-
export interface Sink {
|
|
120
|
-
write(message: Message): void;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Sink for complete trace messages.
|
|
125
|
-
* The Process Manager forwards trace messages to it.
|
|
126
|
-
*/
|
|
127
|
-
// TODO(dmaretskyi): Consider moving sink to the Process Manager.
|
|
128
|
-
export class TraceSink extends Context.Tag('@dxos/functions/TraceSink')<TraceSink, Sink>() {}
|
|
129
|
-
|
|
130
|
-
export const noopWriter: TraceWriter = {
|
|
131
|
-
write: () => {},
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const writerLayerNoop: Layer.Layer<TraceService> = Layer.succeed(TraceService, noopWriter);
|
|
135
|
-
|
|
136
|
-
export const layerNoop: Layer.Layer<TraceSink> = Layer.succeed(TraceSink, {
|
|
137
|
-
write: () => {},
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
export const layerConsole: Layer.Layer<TraceSink> = Layer.succeed(TraceSink, {
|
|
141
|
-
write: (message) => {
|
|
142
|
-
console.log(message);
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
export const testTraceService = (opts: { meta?: Meta } = {}): Layer.Layer<TraceService, never, TraceSink> =>
|
|
147
|
-
Layer.effect(
|
|
148
|
-
TraceService,
|
|
149
|
-
Effect.gen(function* () {
|
|
150
|
-
const sink = yield* TraceSink;
|
|
151
|
-
return {
|
|
152
|
-
write: (event, data) => {
|
|
153
|
-
sink.write(
|
|
154
|
-
Obj.make(Message, {
|
|
155
|
-
meta: opts.meta ?? {},
|
|
156
|
-
isEphemeral: event.isEphemeral,
|
|
157
|
-
events: [{ type: event.key, timestamp: Date.now(), data }],
|
|
158
|
-
}),
|
|
159
|
-
);
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
}),
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
//
|
|
166
|
-
// Operation Trace Events
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Outcome of an operation invocation.
|
|
171
|
-
*/
|
|
172
|
-
export type OperationOutcome = 'success' | 'failure';
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Operation invocation started.
|
|
176
|
-
*/
|
|
177
|
-
export const OperationStart = EventType('operation.start', {
|
|
178
|
-
schema: Schema.Struct({
|
|
179
|
-
/** Operation key. */
|
|
180
|
-
key: Schema.String,
|
|
181
|
-
/** Human-readable operation name. */
|
|
182
|
-
name: Schema.optional(Schema.String),
|
|
183
|
-
}),
|
|
184
|
-
isEphemeral: false,
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Operation invocation ended.
|
|
189
|
-
*/
|
|
190
|
-
export const OperationEnd = EventType('operation.end', {
|
|
191
|
-
schema: Schema.Struct({
|
|
192
|
-
/** Operation key. */
|
|
193
|
-
key: Schema.String,
|
|
194
|
-
/** Human-readable operation name. */
|
|
195
|
-
name: Schema.optional(Schema.String),
|
|
196
|
-
/** Outcome of the operation. */
|
|
197
|
-
outcome: Schema.Literal('success', 'failure'),
|
|
198
|
-
/** Error message if the operation failed. */
|
|
199
|
-
error: Schema.optional(Schema.String),
|
|
200
|
-
}),
|
|
201
|
-
isEphemeral: false,
|
|
202
|
-
});
|
package/src/errors.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { BaseError, type BaseErrorOptions } from '@dxos/errors';
|
|
6
|
-
|
|
7
|
-
export class ServiceNotAvailableError extends BaseError.extend('ServiceNotAvailable', 'Service not available') {
|
|
8
|
-
constructor(service: string, options?: Omit<BaseErrorOptions, 'context'>) {
|
|
9
|
-
super({ context: { service }, ...options, message: `Service not available: ${service}` });
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class FunctionNotFoundError extends BaseError.extend('FunctionNotFound', 'Function not found') {
|
|
14
|
-
constructor(functionKey: string, options?: Omit<BaseErrorOptions, 'context'>) {
|
|
15
|
-
super({ context: { function: functionKey }, ...options });
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class FunctionError extends BaseError.extend('FunctionError', 'Function invocation error') {}
|
|
20
|
-
|
|
21
|
-
export class TriggerStateNotFoundError extends BaseError.extend('TriggerStateNotFound', 'Trigger state not found') {}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2026 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
|
-
|
|
7
|
-
import { Operation } from '@dxos/operation';
|
|
8
|
-
|
|
9
|
-
export const Fibonacci = Operation.make({
|
|
10
|
-
meta: {
|
|
11
|
-
key: 'example.org/function/fib',
|
|
12
|
-
name: 'Fibonacci',
|
|
13
|
-
description: 'Function that calculates a Fibonacci number',
|
|
14
|
-
},
|
|
15
|
-
input: Schema.Struct({
|
|
16
|
-
iterations: Schema.optional(Schema.Number).annotations({
|
|
17
|
-
description: 'Number of iterations',
|
|
18
|
-
default: 100_000,
|
|
19
|
-
}),
|
|
20
|
-
}),
|
|
21
|
-
output: Schema.Struct({
|
|
22
|
-
result: Schema.String,
|
|
23
|
-
}),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export const Reply = Operation.make({
|
|
27
|
-
meta: {
|
|
28
|
-
key: 'example.org/function/reply',
|
|
29
|
-
name: 'Reply',
|
|
30
|
-
description: 'Function that echoes the input',
|
|
31
|
-
},
|
|
32
|
-
input: Schema.Any,
|
|
33
|
-
output: Schema.Any,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export const Sleep = Operation.make({
|
|
37
|
-
meta: {
|
|
38
|
-
key: 'example.org/function/sleep',
|
|
39
|
-
name: 'Sleep',
|
|
40
|
-
description: 'Function that sleeps for a given amount of time',
|
|
41
|
-
},
|
|
42
|
-
input: Schema.Struct({
|
|
43
|
-
duration: Schema.optional(Schema.Number).annotations({
|
|
44
|
-
description: 'Milliseconds to sleep',
|
|
45
|
-
default: 100_000,
|
|
46
|
-
}),
|
|
47
|
-
}),
|
|
48
|
-
output: Schema.Void,
|
|
49
|
-
});
|
package/src/example/fib.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
|
|
7
|
-
import { Operation } from '@dxos/operation';
|
|
8
|
-
|
|
9
|
-
import { Fibonacci } from './definitions';
|
|
10
|
-
|
|
11
|
-
export default Fibonacci.pipe(
|
|
12
|
-
Operation.withHandler(
|
|
13
|
-
Effect.fn(function* ({ iterations = 100_000 }) {
|
|
14
|
-
let a = 0n;
|
|
15
|
-
let b = 1n;
|
|
16
|
-
for (let i = 0; i < iterations; i++) {
|
|
17
|
-
a += b;
|
|
18
|
-
b = a - b;
|
|
19
|
-
}
|
|
20
|
-
return { result: a.toString() };
|
|
21
|
-
}),
|
|
22
|
-
),
|
|
23
|
-
);
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
import { S, defineFunction } from 'dxos:functions';
|
|
7
|
-
import {
|
|
8
|
-
FetchHttpClient,
|
|
9
|
-
HttpClient,
|
|
10
|
-
HttpClientRequest,
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
} from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
import { Effect, Schedule } from 'https://esm.sh/effect@3.17.0?bundle=false';
|
|
15
|
-
|
|
16
|
-
export default defineFunction({
|
|
17
|
-
key: 'org.dxos.script.forex-effect',
|
|
18
|
-
name: 'Forex Effect',
|
|
19
|
-
description: 'Returns the exchange rate between two currencies.',
|
|
20
|
-
|
|
21
|
-
inputSchema: S.Struct({
|
|
22
|
-
from: S.String.annotations({ description: 'The source currency' }),
|
|
23
|
-
to: S.String.annotations({ description: 'The target currency' }),
|
|
24
|
-
}),
|
|
25
|
-
|
|
26
|
-
outputSchema: S.String.annotations({ description: 'The exchange rate between the two currencies' }),
|
|
27
|
-
|
|
28
|
-
handler: async ({ data: { from, to } }: any) =>
|
|
29
|
-
Effect.gen(function* () {
|
|
30
|
-
const res = yield* HttpClientRequest.get(`https://free.ratesdb.com/v1/rates?from=${from}&to=${to}`).pipe(
|
|
31
|
-
HttpClient.execute,
|
|
32
|
-
Effect.flatMap((res: any) => res.json),
|
|
33
|
-
Effect.timeout('1 second'),
|
|
34
|
-
Effect.retry(Schedule.exponential(1_000).pipe(Schedule.compose(Schedule.recurs(3)))),
|
|
35
|
-
Effect.scoped,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
return res.data.rates[to].toString();
|
|
39
|
-
}).pipe(Effect.provide(FetchHttpClient.layer)),
|
|
40
|
-
});
|
package/src/example/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { OperationHandlerSet } from '@dxos/operation';
|
|
6
|
-
export * from './definitions';
|
|
7
|
-
|
|
8
|
-
export const ExampleHandlers = OperationHandlerSet.lazy(
|
|
9
|
-
() => import('./fib'),
|
|
10
|
-
() => import('./reply'),
|
|
11
|
-
() => import('./sleep'),
|
|
12
|
-
);
|
package/src/example/reply.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Console from 'effect/Console';
|
|
6
|
-
import * as Effect from 'effect/Effect';
|
|
7
|
-
|
|
8
|
-
import { Operation } from '@dxos/operation';
|
|
9
|
-
|
|
10
|
-
import { Reply } from './definitions';
|
|
11
|
-
|
|
12
|
-
export default Reply.pipe(
|
|
13
|
-
Operation.withHandler(
|
|
14
|
-
Effect.fn(function* (input) {
|
|
15
|
-
yield* Console.log('reply', { input });
|
|
16
|
-
return input;
|
|
17
|
-
}),
|
|
18
|
-
),
|
|
19
|
-
);
|
package/src/example/sleep.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
|
|
7
|
-
import { Operation } from '@dxos/operation';
|
|
8
|
-
|
|
9
|
-
import { Sleep } from './definitions';
|
|
10
|
-
|
|
11
|
-
export default Sleep.pipe(
|
|
12
|
-
Operation.withHandler(
|
|
13
|
-
Effect.fn(function* ({ duration = 100_000 }) {
|
|
14
|
-
yield* Effect.sleep(duration);
|
|
15
|
-
}),
|
|
16
|
-
),
|
|
17
|
-
);
|