@dxos/functions-testing 0.9.1-main.c7dcc2e112 → 0.9.1-staging.ee54ba693a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +2 -2
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/testing/util.d.ts +1 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/src/cpu-limit.test.ts +20 -4
- package/src/edge-routine.test.ts +20 -25
- package/src/functions/query.ts +1 -1
- package/src/testing/util.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/functions-testing",
|
|
3
|
-
"version": "0.9.1-
|
|
3
|
+
"version": "0.9.1-staging.ee54ba693a",
|
|
4
4
|
"description": "Functions tests",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -30,24 +30,24 @@
|
|
|
30
30
|
"src"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@effect/platform": "0.96.
|
|
34
|
-
"@dxos/assistant-toolkit": "0.9.1-
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/context": "0.9.1-
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/functions": "0.9.1-
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/functions-runtime": "0.9.1-
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/protocols": "0.9.1-
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
33
|
+
"@effect/platform": "0.96.2",
|
|
34
|
+
"@dxos/assistant-toolkit": "0.9.1-staging.ee54ba693a",
|
|
35
|
+
"@dxos/async": "0.9.1-staging.ee54ba693a",
|
|
36
|
+
"@dxos/compute": "0.9.1-staging.ee54ba693a",
|
|
37
|
+
"@dxos/client": "0.9.1-staging.ee54ba693a",
|
|
38
|
+
"@dxos/config": "0.9.1-staging.ee54ba693a",
|
|
39
|
+
"@dxos/context": "0.9.1-staging.ee54ba693a",
|
|
40
|
+
"@dxos/echo": "0.9.1-staging.ee54ba693a",
|
|
41
|
+
"@dxos/functions": "0.9.1-staging.ee54ba693a",
|
|
42
|
+
"@dxos/invariant": "0.9.1-staging.ee54ba693a",
|
|
43
|
+
"@dxos/functions-runtime": "0.9.1-staging.ee54ba693a",
|
|
44
|
+
"@dxos/keys": "0.9.1-staging.ee54ba693a",
|
|
45
|
+
"@dxos/log": "0.9.1-staging.ee54ba693a",
|
|
46
|
+
"@dxos/protocols": "0.9.1-staging.ee54ba693a",
|
|
47
|
+
"@dxos/operation": "0.9.1-staging.ee54ba693a",
|
|
48
|
+
"@dxos/schema": "0.9.1-staging.ee54ba693a",
|
|
49
|
+
"@dxos/functions-runtime-cloudflare": "0.9.1-staging.ee54ba693a",
|
|
50
|
+
"@dxos/util": "0.9.1-staging.ee54ba693a"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
package/src/cpu-limit.test.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Trigger } from '@dxos/compute';
|
|
|
8
8
|
import { configPreset } from '@dxos/config';
|
|
9
9
|
import { Context } from '@dxos/context';
|
|
10
10
|
import { Obj, Ref } from '@dxos/echo';
|
|
11
|
+
import { invariant } from '@dxos/invariant';
|
|
11
12
|
import { FunctionRuntimeKind } from '@dxos/protocols';
|
|
12
13
|
|
|
13
14
|
import { deployFunction, observeInvocations, setup, sync } from './testing';
|
|
@@ -20,11 +21,14 @@ describe('CPU limit', { tags: ['functions-e2e'] }, () => {
|
|
|
20
21
|
|
|
21
22
|
test('invoke directly', { timeout: 120_000 }, async ({ expect }) => {
|
|
22
23
|
const { client, space, functionsServiceClient } = await setup(config);
|
|
24
|
+
const identity = client.halo.identity.get();
|
|
25
|
+
invariant(identity, 'Identity must exist after createIdentity.');
|
|
23
26
|
const func = await deployFunction(
|
|
24
27
|
space,
|
|
25
28
|
functionsServiceClient,
|
|
26
29
|
FIB_FUNCTION_PATH,
|
|
27
30
|
FunctionRuntimeKind.enums.WORKERS_FOR_PLATFORMS,
|
|
31
|
+
identity.did,
|
|
28
32
|
);
|
|
29
33
|
const result = await functionsServiceClient.invoke(
|
|
30
34
|
Context.default(),
|
|
@@ -41,16 +45,19 @@ describe('CPU limit', { tags: ['functions-e2e'] }, () => {
|
|
|
41
45
|
|
|
42
46
|
test('force-trigger', { timeout: 120_000 }, async ({ expect }) => {
|
|
43
47
|
const { client, space, functionsServiceClient } = await setup(config);
|
|
48
|
+
const identity = client.halo.identity.get();
|
|
49
|
+
invariant(identity, 'Identity must exist after createIdentity.');
|
|
44
50
|
const func = await deployFunction(
|
|
45
51
|
space,
|
|
46
52
|
functionsServiceClient,
|
|
47
53
|
FIB_FUNCTION_PATH,
|
|
48
54
|
FunctionRuntimeKind.enums.WORKERS_FOR_PLATFORMS,
|
|
55
|
+
identity.did,
|
|
49
56
|
);
|
|
50
57
|
const trigger = space.db.add(
|
|
51
58
|
Obj.make(Trigger.Trigger, {
|
|
52
59
|
enabled: true,
|
|
53
|
-
|
|
60
|
+
runnable: Ref.make(func),
|
|
54
61
|
spec: Trigger.specTimer('* */30 * * * *'),
|
|
55
62
|
input: { iterations: 100 },
|
|
56
63
|
}),
|
|
@@ -62,16 +69,19 @@ describe('CPU limit', { tags: ['functions-e2e'] }, () => {
|
|
|
62
69
|
|
|
63
70
|
test('break CPU limit', { timeout: 120_000 }, async ({ expect }) => {
|
|
64
71
|
const { client, space, functionsServiceClient } = await setup(config);
|
|
72
|
+
const identity = client.halo.identity.get();
|
|
73
|
+
invariant(identity, 'Identity must exist after createIdentity.');
|
|
65
74
|
const func = await deployFunction(
|
|
66
75
|
space,
|
|
67
76
|
functionsServiceClient,
|
|
68
77
|
FIB_FUNCTION_PATH,
|
|
69
78
|
FunctionRuntimeKind.enums.WORKERS_FOR_PLATFORMS,
|
|
79
|
+
identity.did,
|
|
70
80
|
);
|
|
71
81
|
const trigger = space.db.add(
|
|
72
82
|
Obj.make(Trigger.Trigger, {
|
|
73
83
|
enabled: true,
|
|
74
|
-
|
|
84
|
+
runnable: Ref.make(func),
|
|
75
85
|
spec: Trigger.specTimer('* */30 * * * *'),
|
|
76
86
|
input: { iterations: 1_000_000_000 },
|
|
77
87
|
}),
|
|
@@ -99,16 +109,19 @@ describe('CPU limit', { tags: ['functions-e2e'] }, () => {
|
|
|
99
109
|
|
|
100
110
|
test('observe invocations', { timeout: 520_000 }, async ({ expect }) => {
|
|
101
111
|
const { client, space, functionsServiceClient } = await setup(config);
|
|
112
|
+
const identity = client.halo.identity.get();
|
|
113
|
+
invariant(identity, 'Identity must exist after createIdentity.');
|
|
102
114
|
const func = await deployFunction(
|
|
103
115
|
space,
|
|
104
116
|
functionsServiceClient,
|
|
105
117
|
FIB_FUNCTION_PATH,
|
|
106
118
|
FunctionRuntimeKind.enums.WORKERS_FOR_PLATFORMS,
|
|
119
|
+
identity.did,
|
|
107
120
|
);
|
|
108
121
|
const trigger = space.db.add(
|
|
109
122
|
Obj.make(Trigger.Trigger, {
|
|
110
123
|
enabled: true,
|
|
111
|
-
|
|
124
|
+
runnable: Ref.make(func),
|
|
112
125
|
spec: Trigger.specTimer('* * * * * *'),
|
|
113
126
|
input: { iterations: 1_000_000 },
|
|
114
127
|
}),
|
|
@@ -119,16 +132,19 @@ describe('CPU limit', { tags: ['functions-e2e'] }, () => {
|
|
|
119
132
|
|
|
120
133
|
test('break CPU limit through natural exection', { timeout: 520_000 }, async ({ expect }) => {
|
|
121
134
|
const { client, space, functionsServiceClient } = await setup(config);
|
|
135
|
+
const identity = client.halo.identity.get();
|
|
136
|
+
invariant(identity, 'Identity must exist after createIdentity.');
|
|
122
137
|
const func = await deployFunction(
|
|
123
138
|
space,
|
|
124
139
|
functionsServiceClient,
|
|
125
140
|
FIB_FUNCTION_PATH,
|
|
126
141
|
FunctionRuntimeKind.enums.WORKERS_FOR_PLATFORMS,
|
|
142
|
+
identity.did,
|
|
127
143
|
);
|
|
128
144
|
const trigger = space.db.add(
|
|
129
145
|
Obj.make(Trigger.Trigger, {
|
|
130
146
|
enabled: true,
|
|
131
|
-
|
|
147
|
+
runnable: Ref.make(func),
|
|
132
148
|
spec: Trigger.specTimer('* * * * * *'),
|
|
133
149
|
input: { iterations: 100 },
|
|
134
150
|
}),
|
package/src/edge-routine.test.ts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// Copyright 2026 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
5
|
import { describe, test } from 'vitest';
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { Chat, DatabaseSkill, RunInstructions } from '@dxos/assistant-toolkit';
|
|
9
8
|
import { Client } from '@dxos/client';
|
|
10
|
-
import {
|
|
9
|
+
import { Instructions, Operation, Skill, Trigger } from '@dxos/compute';
|
|
11
10
|
import { configPreset } from '@dxos/config';
|
|
12
11
|
import { Context } from '@dxos/context';
|
|
13
12
|
import { Feed, Obj, Ref, Type } from '@dxos/echo';
|
|
14
13
|
import { TestSchema } from '@dxos/echo/testing';
|
|
14
|
+
import { DXN } from '@dxos/keys';
|
|
15
15
|
import { dbg, log } from '@dxos/log';
|
|
16
16
|
import { ErrorCodec } from '@dxos/protocols';
|
|
17
17
|
import { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
@@ -21,23 +21,23 @@ import { trim } from '@dxos/util';
|
|
|
21
21
|
import { sync } from './testing';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Cron trigger on EDGE runs {@link
|
|
25
|
-
*
|
|
24
|
+
* Cron trigger on EDGE runs {@link RunInstructions} for a {@link Routine} that uses the Database
|
|
25
|
+
* skill Query tool against replicated ECHO documents.
|
|
26
26
|
*
|
|
27
27
|
* Prereq: local EDGE (`configPreset({ edge: 'local' })` → `http://localhost:8787`) with LLM
|
|
28
28
|
* available (API key and/or memo replay under `conversationsCache/`).
|
|
29
29
|
*/
|
|
30
|
-
describe('Edge
|
|
30
|
+
describe('Edge instructions', { tags: ['functions-e2e'] }, () => {
|
|
31
31
|
const config = configPreset({ edge: 'local' });
|
|
32
32
|
|
|
33
|
-
test('timer trigger runs
|
|
33
|
+
test('timer trigger runs instructions with database skill on edge', { timeout: 420_000 }, async ({ expect }) => {
|
|
34
34
|
await using client = await new Client({
|
|
35
35
|
config,
|
|
36
36
|
types: [
|
|
37
37
|
Operation.PersistentOperation,
|
|
38
38
|
Trigger.Trigger,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
Instructions.Instructions,
|
|
40
|
+
Skill.Skill,
|
|
41
41
|
Feed.Feed,
|
|
42
42
|
Text.Text,
|
|
43
43
|
Chat.Chat,
|
|
@@ -59,38 +59,33 @@ describe('Edge routine', { tags: ['functions-e2e'] }, () => {
|
|
|
59
59
|
space.db.add(Obj.make(TestSchema.Organization, { name: 'Globex Industries' }));
|
|
60
60
|
space.db.add(Obj.make(TestSchema.Organization, { name: 'Initech' }));
|
|
61
61
|
|
|
62
|
-
const
|
|
62
|
+
const databaseSkill = space.db.add(DatabaseSkill.make());
|
|
63
63
|
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
name: 'edge-e2e-count-orgs-db-
|
|
67
|
-
|
|
68
|
-
You have access to the Database
|
|
64
|
+
const instructions = space.db.add(
|
|
65
|
+
Instructions.make({
|
|
66
|
+
name: 'edge-e2e-count-orgs-db-skill',
|
|
67
|
+
text: trim`
|
|
68
|
+
You have access to the Database skill tools.
|
|
69
69
|
Use the Query tool exactly once with typename "${Type.getTypename(TestSchema.Organization)}" and no other arguments.
|
|
70
70
|
Then call completeJob with the output object { "count": <number of rows returned by Query> }.
|
|
71
71
|
If you are unable to query -- fail.
|
|
72
72
|
Do not list schemas first.
|
|
73
73
|
`,
|
|
74
|
-
|
|
75
|
-
output: Schema.Struct({
|
|
76
|
-
count: Schema.Number,
|
|
77
|
-
}),
|
|
78
|
-
blueprints: [Ref.make(databaseBlueprint)],
|
|
79
|
-
context: [],
|
|
74
|
+
skills: [Ref.make(databaseSkill)],
|
|
80
75
|
}),
|
|
81
76
|
);
|
|
82
|
-
const fn = Operation.serialize(
|
|
77
|
+
const fn = Operation.serialize(RunInstructions);
|
|
83
78
|
dbg(Obj.toJSON(fn));
|
|
84
79
|
|
|
85
80
|
const trigger = space.db.add(
|
|
86
81
|
Obj.make(Trigger.Trigger, {
|
|
87
82
|
enabled: true,
|
|
88
|
-
|
|
83
|
+
runnable: Ref.make(fn),
|
|
89
84
|
spec: Trigger.specTimer('* * * * * *'),
|
|
90
85
|
input: {
|
|
91
|
-
|
|
86
|
+
instructions: Ref.make(instructions),
|
|
92
87
|
input: {},
|
|
93
|
-
model: '
|
|
88
|
+
model: DXN.make('com.anthropic.model.claude-haiku-4-5.default'),
|
|
94
89
|
},
|
|
95
90
|
}),
|
|
96
91
|
);
|
package/src/functions/query.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
7
|
import { Operation } from '@dxos/compute';
|
|
8
|
-
import { Database,
|
|
8
|
+
import { Database, Query as EchoQuery, Filter } from '@dxos/echo';
|
|
9
9
|
|
|
10
10
|
import { QueryDb } from './definitions';
|
|
11
11
|
|
package/src/testing/util.ts
CHANGED
|
@@ -53,6 +53,7 @@ export const deployFunction = async (
|
|
|
53
53
|
functionsServiceClient: FunctionsServiceClient,
|
|
54
54
|
entryPoint: string,
|
|
55
55
|
runtime: FunctionRuntimeKind,
|
|
56
|
+
ownerUri: string,
|
|
56
57
|
): Promise<Operation.PersistentOperation> => {
|
|
57
58
|
const artifact = await bundleFunction({
|
|
58
59
|
entryPoint,
|
|
@@ -60,7 +61,7 @@ export const deployFunction = async (
|
|
|
60
61
|
});
|
|
61
62
|
const func = await functionsServiceClient.deploy(Context.default(), {
|
|
62
63
|
version: '0.0.1',
|
|
63
|
-
|
|
64
|
+
ownerUri,
|
|
64
65
|
entryPoint: artifact.entryPoint,
|
|
65
66
|
assets: artifact.assets,
|
|
66
67
|
runtime,
|