@dxos/functions-testing 0.8.4-main.cb12b3f963 → 0.8.4-main.d05539e30a

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/functions-testing",
3
- "version": "0.8.4-main.cb12b3f963",
3
+ "version": "0.8.4-main.d05539e30a",
4
4
  "description": "Functions tests",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -8,7 +8,7 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/dxos/dxos"
10
10
  },
11
- "license": "MIT",
11
+ "license": "FSL-1.1-Apache-2.0",
12
12
  "author": "info@dxos.org",
13
13
  "sideEffects": true,
14
14
  "type": "module",
@@ -31,19 +31,22 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@effect/platform": "0.94.4",
34
- "@dxos/async": "0.8.4-main.cb12b3f963",
35
- "@dxos/compute": "0.8.4-main.cb12b3f963",
36
- "@dxos/client": "0.8.4-main.cb12b3f963",
37
- "@dxos/context": "0.8.4-main.cb12b3f963",
38
- "@dxos/echo": "0.8.4-main.cb12b3f963",
39
- "@dxos/config": "0.8.4-main.cb12b3f963",
40
- "@dxos/functions": "0.8.4-main.cb12b3f963",
41
- "@dxos/functions-runtime": "0.8.4-main.cb12b3f963",
42
- "@dxos/functions-runtime-cloudflare": "0.8.4-main.cb12b3f963",
43
- "@dxos/invariant": "0.8.4-main.cb12b3f963",
44
- "@dxos/log": "0.8.4-main.cb12b3f963",
45
- "@dxos/protocols": "0.8.4-main.cb12b3f963",
46
- "@dxos/operation": "0.8.4-main.cb12b3f963"
34
+ "@dxos/assistant-toolkit": "0.8.4-main.d05539e30a",
35
+ "@dxos/async": "0.8.4-main.d05539e30a",
36
+ "@dxos/client": "0.8.4-main.d05539e30a",
37
+ "@dxos/compute": "0.8.4-main.d05539e30a",
38
+ "@dxos/config": "0.8.4-main.d05539e30a",
39
+ "@dxos/context": "0.8.4-main.d05539e30a",
40
+ "@dxos/echo": "0.8.4-main.d05539e30a",
41
+ "@dxos/functions": "0.8.4-main.d05539e30a",
42
+ "@dxos/functions-runtime": "0.8.4-main.d05539e30a",
43
+ "@dxos/functions-runtime-cloudflare": "0.8.4-main.d05539e30a",
44
+ "@dxos/log": "0.8.4-main.d05539e30a",
45
+ "@dxos/invariant": "0.8.4-main.d05539e30a",
46
+ "@dxos/operation": "0.8.4-main.d05539e30a",
47
+ "@dxos/protocols": "0.8.4-main.d05539e30a",
48
+ "@dxos/schema": "0.8.4-main.d05539e30a",
49
+ "@dxos/util": "0.8.4-main.d05539e30a"
47
50
  },
48
51
  "publishConfig": {
49
52
  "access": "public"
@@ -117,7 +117,7 @@ describe('CPU limit', { tags: ['functions-e2e'] }, () => {
117
117
  await observeInvocations(space, 100);
118
118
  });
119
119
 
120
- test.only('break CPU limit through natural exection', { timeout: 520_000 }, async ({ expect }) => {
120
+ test('break CPU limit through natural exection', { timeout: 520_000 }, async ({ expect }) => {
121
121
  const { client, space, functionsServiceClient } = await setup(config);
122
122
  const func = await deployFunction(
123
123
  space,
@@ -0,0 +1,110 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+ import { describe, test } from 'vitest';
7
+
8
+ import { AgentPrompt, DatabaseBlueprint, Chat } from '@dxos/assistant-toolkit';
9
+ import { Client } from '@dxos/client';
10
+ import { Blueprint, Operation, Routine, Trigger } from '@dxos/compute';
11
+ import { configPreset } from '@dxos/config';
12
+ import { Context } from '@dxos/context';
13
+ import { Feed, Obj, Ref } from '@dxos/echo';
14
+ import { TestSchema } from '@dxos/echo/testing';
15
+ import { dbg, log } from '@dxos/log';
16
+ import { ErrorCodec } from '@dxos/protocols';
17
+ import { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';
18
+ import { Text } from '@dxos/schema';
19
+ import { trim } from '@dxos/util';
20
+
21
+ import { sync } from './testing';
22
+
23
+ /**
24
+ * Cron trigger on EDGE runs {@link AgentPrompt} for a {@link Routine} that uses the Database
25
+ * blueprint Query tool against replicated ECHO documents.
26
+ *
27
+ * Prereq: local EDGE (`configPreset({ edge: 'local' })` → `http://localhost:8787`) with LLM
28
+ * available (API key and/or memo replay under `conversationsCache/`).
29
+ */
30
+ describe('Edge routine', { tags: ['functions-e2e'] }, () => {
31
+ const config = configPreset({ edge: 'local' });
32
+
33
+ test('timer trigger runs routine with database blueprint on edge', { timeout: 420_000 }, async ({ expect }) => {
34
+ await using client = await new Client({
35
+ config,
36
+ types: [
37
+ Operation.PersistentOperation,
38
+ Trigger.Trigger,
39
+ Routine.Routine,
40
+ Blueprint.Blueprint,
41
+ Feed.Feed,
42
+ Text.Text,
43
+ Chat.Chat,
44
+ TestSchema.Organization,
45
+ ],
46
+ }).initialize();
47
+
48
+ await client.halo.createIdentity();
49
+ const space = await client.spaces.create();
50
+ await space.waitUntilReady();
51
+
52
+ await space.internal.setEdgeReplicationPreference(EdgeReplicationSetting.ENABLED);
53
+
54
+ Obj.update(space.properties, (properties) => {
55
+ properties.computeEnvironment = 'edge';
56
+ });
57
+
58
+ space.db.add(Obj.make(TestSchema.Organization, { name: 'Acme Corp' }));
59
+ space.db.add(Obj.make(TestSchema.Organization, { name: 'Globex Industries' }));
60
+ space.db.add(Obj.make(TestSchema.Organization, { name: 'Initech' }));
61
+
62
+ const databaseBlueprint = space.db.add(DatabaseBlueprint.make());
63
+
64
+ const routine = space.db.add(
65
+ Routine.make({
66
+ name: 'edge-e2e-count-orgs-db-blueprint',
67
+ instructions: trim`
68
+ You have access to the Database blueprint tools.
69
+ Use the Query tool exactly once with typename "${TestSchema.Organization.typename}" and no other arguments.
70
+ Then call completeJob with the output object { "count": <number of rows returned by Query> }.
71
+ If you are unable to query -- fail.
72
+ Do not list schemas first.
73
+ `,
74
+ input: Schema.Struct({}),
75
+ output: Schema.Struct({
76
+ count: Schema.Number,
77
+ }),
78
+ blueprints: [Ref.make(databaseBlueprint)],
79
+ context: [],
80
+ }),
81
+ );
82
+ const fn = Operation.serialize(AgentPrompt);
83
+ dbg(Obj.toJSON(fn));
84
+
85
+ const trigger = space.db.add(
86
+ Obj.make(Trigger.Trigger, {
87
+ enabled: true,
88
+ function: Ref.make(fn),
89
+ spec: Trigger.specTimer('* * * * * *'),
90
+ input: {
91
+ prompt: Ref.make(routine),
92
+ input: {},
93
+ model: '@anthropic/claude-haiku-4-5',
94
+ },
95
+ }),
96
+ );
97
+
98
+ await sync(space);
99
+
100
+ log('trigger created and synced');
101
+ log.break();
102
+
103
+ const runResult: any = await client.edge.http.forceRunCronTrigger(Context.default(), space.id, trigger.id);
104
+ if (runResult._kind === 'error') {
105
+ throw ErrorCodec.decode(runResult.error);
106
+ }
107
+ log('trigger ran', { runResult });
108
+ expect(runResult.result.count).toBe(3);
109
+ });
110
+ });
@@ -84,8 +84,8 @@ export const observeInvocations = async (space: Space, maxCount: number | null)
84
84
  while (true) {
85
85
  try {
86
86
  const traceFeed = space.properties.invocationTraceFeed?.target;
87
- const traceQueueDxn = traceFeed ? Feed.getQueueDxn(traceFeed) : undefined;
88
- const invocations = traceQueueDxn ? ((await space.queues.get(traceQueueDxn).queryObjects()) ?? []) : [];
87
+ const traceFeedDXN = traceFeed ? Feed.getQueueDxn(traceFeed) : undefined;
88
+ const invocations = traceFeedDXN ? ((await space.queues.get(traceFeedDXN).queryObjects()) ?? []) : [];
89
89
 
90
90
  for (const invocation of invocations) {
91
91
  if (Obj.instanceOf(InvocationTraceStartEvent, invocation)) {