@dxos/assistant-toolkit 0.16.0 → 0.17.0
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/chunk-AgentOperation.mjs +5 -1
- package/dist/lib/chunk-AgentOperation.mjs.map +1 -1
- package/dist/lib/chunk-AgentOperationHandlerSet.mjs +1 -1
- package/dist/lib/chunk-AgentSkill.mjs +1 -1
- package/dist/lib/chunk-AlarmSkill.mjs +1 -1
- package/dist/lib/chunk-BrowserSkill.mjs +4 -6
- package/dist/lib/chunk-BrowserSkill.mjs.map +1 -1
- package/dist/lib/chunk-ChatContextSkill.mjs +1 -1
- package/dist/lib/chunk-DelegationSkill.mjs +2 -2
- package/dist/lib/chunk-DelegationSkill.mjs.map +1 -1
- package/dist/lib/chunk-DelegationStrategy.mjs +16 -30
- package/dist/lib/chunk-DelegationStrategy.mjs.map +1 -1
- package/dist/lib/chunk-PlanningSkill.mjs +12 -10
- package/dist/lib/chunk-PlanningSkill.mjs.map +1 -1
- package/dist/lib/chunk-SkillManagerSkill.mjs +62 -7
- package/dist/lib/chunk-SkillManagerSkill.mjs.map +1 -1
- package/dist/lib/chunk-SlashCommand.mjs +2 -2
- package/dist/lib/chunk-SlashCommand.mjs.map +1 -1
- package/dist/lib/chunk-add-mcp-connection.mjs +58 -0
- package/dist/lib/chunk-add-mcp-connection.mjs.map +1 -0
- package/dist/lib/chunk-ask-question.mjs.map +1 -1
- package/dist/lib/chunk-catalog.mjs +86 -0
- package/dist/lib/chunk-catalog.mjs.map +1 -0
- package/dist/lib/chunk-context-add.mjs +1 -1
- package/dist/lib/chunk-context-remove.mjs +1 -1
- package/dist/lib/chunk-delegate-task.mjs +2 -2
- package/dist/lib/chunk-delegate-task.mjs.map +1 -1
- package/dist/lib/chunk-delegate-tasks.mjs +2 -8
- package/dist/lib/chunk-delegate-tasks.mjs.map +1 -1
- package/dist/lib/chunk-enable-skills.mjs +1 -1
- package/dist/lib/chunk-get-context.mjs +1 -1
- package/dist/lib/chunk-get-current-date.mjs +1 -1
- package/dist/lib/chunk-mcp-connections.mjs +26 -0
- package/dist/lib/chunk-mcp-connections.mjs.map +1 -0
- package/dist/lib/chunk-operations.mjs +2 -2
- package/dist/lib/chunk-operations.mjs.map +1 -1
- package/dist/lib/chunk-operations2.mjs +144 -9
- package/dist/lib/chunk-operations2.mjs.map +1 -1
- package/dist/lib/chunk-operations3.mjs +6 -5
- package/dist/lib/chunk-operations3.mjs.map +1 -1
- package/dist/lib/chunk-operations4.mjs +30 -55
- package/dist/lib/chunk-operations4.mjs.map +1 -1
- package/dist/lib/chunk-operations5.mjs +28 -27
- package/dist/lib/chunk-operations5.mjs.map +1 -1
- package/dist/lib/chunk-operations6.mjs +64 -29
- package/dist/lib/chunk-operations6.mjs.map +1 -1
- package/dist/lib/chunk-operations7.mjs +4 -79
- package/dist/lib/chunk-operations7.mjs.map +1 -1
- package/dist/lib/chunk-plan-reminder.mjs +7 -12
- package/dist/lib/chunk-plan-reminder.mjs.map +1 -1
- package/dist/lib/chunk-query-mcp-connections.mjs +16 -0
- package/dist/lib/chunk-query-mcp-connections.mjs.map +1 -0
- package/dist/lib/chunk-query-operations.mjs +23 -0
- package/dist/lib/chunk-query-operations.mjs.map +1 -0
- package/dist/lib/chunk-query-skills.mjs +23 -3
- package/dist/lib/chunk-query-skills.mjs.map +1 -1
- package/dist/lib/chunk-query-types.mjs +24 -0
- package/dist/lib/chunk-query-types.mjs.map +1 -0
- package/dist/lib/chunk-relay.mjs +1 -1
- package/dist/lib/chunk-run-instructions.mjs +14 -10
- package/dist/lib/chunk-run-instructions.mjs.map +1 -1
- package/dist/lib/chunk-set-alarm.mjs +1 -1
- package/dist/lib/chunk-set-mcp-connection.mjs +18 -0
- package/dist/lib/chunk-set-mcp-connection.mjs.map +1 -0
- package/dist/lib/chunk-sync-automation.mjs +1 -1
- package/dist/lib/chunk-update-tasks.mjs +20 -3
- package/dist/lib/chunk-update-tasks.mjs.map +1 -1
- package/dist/lib/index.mjs +1 -3
- package/dist/lib/ns/AgentOperationHandlerSet.mjs +1 -1
- package/dist/lib/ns/AgentSkill.mjs +1 -1
- package/dist/lib/ns/AlarmSkill.mjs +1 -1
- package/dist/lib/ns/ChatContextSkill.mjs +1 -1
- package/dist/lib/ns/PlanningSkill.mjs +2 -2
- package/dist/lib/ns/SkillManagerSkill.mjs +3 -3
- package/dist/lib/testing.mjs +7 -10
- package/dist/lib/testing.mjs.map +1 -1
- package/dist/types/src/commands.d.ts +10 -0
- package/dist/types/src/commands.d.ts.map +1 -1
- package/dist/types/src/operations/run-instructions.d.ts.map +1 -1
- package/dist/types/src/skills/browser/BrowserSkill.d.ts.map +1 -1
- package/dist/types/src/skills/delegation/operations/delegate-task.d.ts +1 -1
- package/dist/types/src/skills/delegation/operations/delegate-tasks.d.ts +0 -6
- package/dist/types/src/skills/delegation/operations/delegate-tasks.d.ts.map +1 -1
- package/dist/types/src/skills/index.d.ts +0 -1
- package/dist/types/src/skills/index.d.ts.map +1 -1
- package/dist/types/src/skills/planning/PlanningSkill.d.ts +3 -0
- package/dist/types/src/skills/planning/PlanningSkill.d.ts.map +1 -1
- package/dist/types/src/skills/planning/operations/definitions.d.ts +3 -1
- package/dist/types/src/skills/planning/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/skills/planning/operations/plan-reminder.d.ts +6 -5
- package/dist/types/src/skills/planning/operations/plan-reminder.d.ts.map +1 -1
- package/dist/types/src/skills/planning/operations/update-tasks.d.ts +1 -1
- package/dist/types/src/skills/planning/operations/update-tasks.d.ts.map +1 -1
- package/dist/types/src/skills/skill-manager/SkillManagerSkill.d.ts +7 -0
- package/dist/types/src/skills/skill-manager/SkillManagerSkill.d.ts.map +1 -1
- package/dist/types/src/skills/skill-manager/lookup.test.d.ts +2 -0
- package/dist/types/src/skills/skill-manager/lookup.test.d.ts.map +1 -0
- package/dist/types/src/skills/skill-manager/operations/add-mcp-connection.d.ts +19 -0
- package/dist/types/src/skills/skill-manager/operations/add-mcp-connection.d.ts.map +1 -0
- package/dist/types/src/skills/skill-manager/operations/catalog.d.ts +36 -0
- package/dist/types/src/skills/skill-manager/operations/catalog.d.ts.map +1 -0
- package/dist/types/src/skills/skill-manager/operations/definitions.d.ts +116 -1
- package/dist/types/src/skills/skill-manager/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/skills/skill-manager/operations/index.d.ts.map +1 -1
- package/dist/types/src/skills/skill-manager/operations/mcp-connections.d.ts +15 -0
- package/dist/types/src/skills/skill-manager/operations/mcp-connections.d.ts.map +1 -0
- package/dist/types/src/skills/skill-manager/operations/query-mcp-connections.d.ts +11 -0
- package/dist/types/src/skills/skill-manager/operations/query-mcp-connections.d.ts.map +1 -0
- package/dist/types/src/skills/skill-manager/operations/query-operations.d.ts +17 -0
- package/dist/types/src/skills/skill-manager/operations/query-operations.d.ts.map +1 -0
- package/dist/types/src/skills/skill-manager/operations/query-skills.d.ts +20 -2
- package/dist/types/src/skills/skill-manager/operations/query-skills.d.ts.map +1 -1
- package/dist/types/src/skills/skill-manager/operations/query-types.d.ts +13 -0
- package/dist/types/src/skills/skill-manager/operations/query-types.d.ts.map +1 -0
- package/dist/types/src/skills/skill-manager/operations/set-mcp-connection.d.ts +14 -0
- package/dist/types/src/skills/skill-manager/operations/set-mcp-connection.d.ts.map +1 -0
- package/dist/types/src/supervisor/delegation-strategy.d.ts +2 -7
- package/dist/types/src/supervisor/delegation-strategy.d.ts.map +1 -1
- package/dist/types/src/testing/operations.d.ts.map +1 -1
- package/dist/types/src/types/AgentOperation.d.ts +2 -1
- package/dist/types/src/types/AgentOperation.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -40
- package/src/commands.test.ts +4 -0
- package/src/commands.ts +12 -2
- package/src/operations/run-instructions.test.ts +12 -6
- package/src/operations/run-instructions.ts +12 -2
- package/src/skills/browser/BrowserSkill.ts +3 -8
- package/src/skills/chat-context/operations/context-add.test.ts +6 -4
- package/src/skills/chat-context/operations/context-remove.test.ts +6 -4
- package/src/skills/delegation/DelegationSkill.ts +2 -2
- package/src/skills/delegation/operations/definitions.ts +2 -2
- package/src/skills/delegation/operations/delegate-task.test.ts +1 -2
- package/src/skills/delegation/operations/delegate-task.ts +2 -2
- package/src/skills/delegation/operations/delegate-tasks.ts +2 -8
- package/src/skills/index.ts +0 -1
- package/src/skills/planning/PlanningSkill.ts +8 -12
- package/src/skills/planning/operations/definitions.ts +5 -4
- package/src/skills/planning/operations/plan-reminder.test.ts +9 -15
- package/src/skills/planning/operations/plan-reminder.ts +7 -13
- package/src/skills/planning/operations/update-tasks.md +7 -5
- package/src/skills/planning/operations/update-tasks.model.test.ts +2 -2
- package/src/skills/planning/operations/update-tasks.test.ts +110 -10
- package/src/skills/planning/operations/update-tasks.ts +22 -10
- package/src/skills/planning/skill.test.ts +9 -7
- package/src/skills/skill-manager/SkillManagerSkill.ts +71 -5
- package/src/skills/skill-manager/lookup.test.ts +308 -0
- package/src/skills/skill-manager/operations/add-mcp-connection.ts +83 -0
- package/src/skills/skill-manager/operations/catalog.ts +140 -0
- package/src/skills/skill-manager/operations/definitions.ts +168 -6
- package/src/skills/skill-manager/operations/index.ts +14 -1
- package/src/skills/skill-manager/operations/mcp-connections.ts +29 -0
- package/src/skills/skill-manager/operations/query-mcp-connections.ts +22 -0
- package/src/skills/skill-manager/operations/query-operations.ts +50 -0
- package/src/skills/skill-manager/operations/query-skills.ts +43 -3
- package/src/skills/skill-manager/operations/query-types.ts +32 -0
- package/src/skills/skill-manager/operations/set-mcp-connection.ts +28 -0
- package/src/skills/skill-manager/skill.test.ts +172 -9
- package/src/supervisor/delegation-strategy.test.ts +55 -4
- package/src/supervisor/delegation-strategy.ts +13 -28
- package/src/testing/operations.ts +2 -6
- package/src/types/AgentOperation.ts +6 -1
- package/src/types/index.ts +0 -1
- package/dist/lib/Memory.mjs +0 -1
- package/dist/lib/chunk-Memory.mjs +0 -19
- package/dist/lib/chunk-Memory.mjs.map +0 -1
- package/dist/lib/chunk-MemorySkill.mjs +0 -39
- package/dist/lib/chunk-MemorySkill.mjs.map +0 -1
- package/dist/lib/chunk-delete.mjs +0 -14
- package/dist/lib/chunk-delete.mjs.map +0 -1
- package/dist/lib/chunk-operations8.mjs +0 -9
- package/dist/lib/chunk-operations8.mjs.map +0 -1
- package/dist/lib/chunk-query.mjs +0 -18
- package/dist/lib/chunk-query.mjs.map +0 -1
- package/dist/lib/chunk-save.mjs +0 -17
- package/dist/lib/chunk-save.mjs.map +0 -1
- package/dist/lib/ns/MemorySkill.mjs +0 -3
- package/dist/types/src/skills/memory/MemorySkill.d.ts +0 -6
- package/dist/types/src/skills/memory/MemorySkill.d.ts.map +0 -1
- package/dist/types/src/skills/memory/index.d.ts +0 -2
- package/dist/types/src/skills/memory/index.d.ts.map +0 -1
- package/dist/types/src/skills/memory/operations/definitions.d.ts +0 -15
- package/dist/types/src/skills/memory/operations/definitions.d.ts.map +0 -1
- package/dist/types/src/skills/memory/operations/delete.d.ts +0 -7
- package/dist/types/src/skills/memory/operations/delete.d.ts.map +0 -1
- package/dist/types/src/skills/memory/operations/delete.test.d.ts +0 -2
- package/dist/types/src/skills/memory/operations/delete.test.d.ts.map +0 -1
- package/dist/types/src/skills/memory/operations/index.d.ts +0 -4
- package/dist/types/src/skills/memory/operations/index.d.ts.map +0 -1
- package/dist/types/src/skills/memory/operations/query.d.ts +0 -8
- package/dist/types/src/skills/memory/operations/query.d.ts.map +0 -1
- package/dist/types/src/skills/memory/operations/query.test.d.ts +0 -2
- package/dist/types/src/skills/memory/operations/query.test.d.ts.map +0 -1
- package/dist/types/src/skills/memory/operations/save.d.ts +0 -8
- package/dist/types/src/skills/memory/operations/save.d.ts.map +0 -1
- package/dist/types/src/skills/memory/operations/save.test.d.ts +0 -2
- package/dist/types/src/skills/memory/operations/save.test.d.ts.map +0 -1
- package/dist/types/src/skills/memory/skill.test.d.ts +0 -2
- package/dist/types/src/skills/memory/skill.test.d.ts.map +0 -1
- package/dist/types/src/types/Memory.d.ts +0 -12
- package/dist/types/src/types/Memory.d.ts.map +0 -1
- package/src/skills/memory/MemorySkill.ts +0 -39
- package/src/skills/memory/index.ts +0 -5
- package/src/skills/memory/operations/definitions.ts +0 -72
- package/src/skills/memory/operations/delete.test.ts +0 -37
- package/src/skills/memory/operations/delete.ts +0 -20
- package/src/skills/memory/operations/index.ts +0 -16
- package/src/skills/memory/operations/query.test.ts +0 -76
- package/src/skills/memory/operations/query.ts +0 -32
- package/src/skills/memory/operations/save.test.ts +0 -43
- package/src/skills/memory/operations/save.ts +0 -20
- package/src/skills/memory/skill.test.ts +0 -147
- package/src/types/Memory.ts +0 -22
|
@@ -11,13 +11,21 @@ import { AssistantTestLayer } from '@dxos/agent-runtime/testing';
|
|
|
11
11
|
import { AiContext, Harness } from '@dxos/assistant';
|
|
12
12
|
import * as Operation from '@dxos/compute/Operation';
|
|
13
13
|
import * as Skill from '@dxos/compute/Skill';
|
|
14
|
-
import { Database, Feed, Obj } from '@dxos/echo';
|
|
14
|
+
import { Database, Feed, Filter, Obj, Registry } from '@dxos/echo';
|
|
15
15
|
import * as EffectEx from '@dxos/effect/EffectEx';
|
|
16
16
|
import { TestHelpers } from '@dxos/effect/testing';
|
|
17
17
|
import { EntityId, type URI } from '@dxos/keys';
|
|
18
|
+
import { AccessToken, Connection } from '@dxos/link';
|
|
19
|
+
import { startTestServer } from '@dxos/mcp-client/testing';
|
|
18
20
|
|
|
19
|
-
import { AutomationSkill, ChatContextSkill,
|
|
20
|
-
import {
|
|
21
|
+
import { AutomationSkill, ChatContextSkill, PlanningSkill } from '../index.ts';
|
|
22
|
+
import {
|
|
23
|
+
AddMcpConnection,
|
|
24
|
+
EnableSkills,
|
|
25
|
+
QueryMcpConnections,
|
|
26
|
+
QuerySkills,
|
|
27
|
+
SetMcpConnection,
|
|
28
|
+
} from './operations/definitions.ts';
|
|
21
29
|
import { SkillManagerHandlers } from './operations/index.ts';
|
|
22
30
|
|
|
23
31
|
EntityId.dangerouslyDisableRandomness();
|
|
@@ -25,8 +33,8 @@ EntityId.dangerouslyDisableRandomness();
|
|
|
25
33
|
const TestLayer = AssistantTestLayer({
|
|
26
34
|
aiServicePreset: 'edge-remote',
|
|
27
35
|
operationHandlers: SkillManagerHandlers,
|
|
28
|
-
types: [Skill.Skill],
|
|
29
|
-
skills: [ChatContextSkill.make(),
|
|
36
|
+
types: [AccessToken.AccessToken, Connection.Connection, Skill.Skill],
|
|
37
|
+
skills: [ChatContextSkill.make(), PlanningSkill.make(), AutomationSkill.make()],
|
|
30
38
|
tracing: 'pretty',
|
|
31
39
|
});
|
|
32
40
|
|
|
@@ -62,6 +70,144 @@ const getBoundSkills = Effect.gen(function* () {
|
|
|
62
70
|
});
|
|
63
71
|
|
|
64
72
|
describe('Skill Manager', () => {
|
|
73
|
+
it.effect(
|
|
74
|
+
'set-mcp-connection: turns a connection off for this conversation only',
|
|
75
|
+
Effect.fnUntraced(
|
|
76
|
+
function* (_) {
|
|
77
|
+
const conversation = yield* getConversationDXN;
|
|
78
|
+
const connection = yield* Database.add(Connection.make({ name: 'GitHub', connectorId: 'github-app' }));
|
|
79
|
+
|
|
80
|
+
const before = yield* Operation.invoke(QueryMcpConnections, {}, { conversation });
|
|
81
|
+
yield* Operation.invoke(SetMcpConnection, { id: connection.id, enabled: false }, { conversation });
|
|
82
|
+
const after = yield* Operation.invoke(QueryMcpConnections, {}, { conversation });
|
|
83
|
+
|
|
84
|
+
expect(before.map(({ enabled }) => enabled)).toEqual([true]);
|
|
85
|
+
expect(after.map(({ enabled }) => enabled)).toEqual([false]);
|
|
86
|
+
},
|
|
87
|
+
provideTestLayers,
|
|
88
|
+
TestHelpers.provideTestContext,
|
|
89
|
+
),
|
|
90
|
+
{ timeout: 30_000 },
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
it.effect(
|
|
94
|
+
'set-mcp-connection: turns a built-in server on by its key; it is listed off until then',
|
|
95
|
+
Effect.fnUntraced(
|
|
96
|
+
function* (_) {
|
|
97
|
+
const conversation = yield* getConversationDXN;
|
|
98
|
+
(yield* Registry.Service).add([
|
|
99
|
+
Connection.makeBuiltin({
|
|
100
|
+
key: 'org.dxos.mcp.test',
|
|
101
|
+
name: 'Test',
|
|
102
|
+
mcp: { url: 'https://mcp.example.com/mcp', protocol: 'http' },
|
|
103
|
+
}),
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
const before = yield* Operation.invoke(QueryMcpConnections, {}, { conversation });
|
|
107
|
+
yield* Operation.invoke(SetMcpConnection, { id: 'org.dxos.mcp.test', enabled: true }, { conversation });
|
|
108
|
+
const after = yield* Operation.invoke(QueryMcpConnections, {}, { conversation });
|
|
109
|
+
|
|
110
|
+
expect(before).toEqual([{ id: 'org.dxos.mcp.test', name: 'Test', enabled: false, builtin: true }]);
|
|
111
|
+
expect(after.map(({ enabled }) => enabled)).toEqual([true]);
|
|
112
|
+
},
|
|
113
|
+
provideTestLayers,
|
|
114
|
+
TestHelpers.provideTestContext,
|
|
115
|
+
),
|
|
116
|
+
{ timeout: 30_000 },
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
it.effect(
|
|
120
|
+
'add-mcp-connection: adding a server the space already has turns that connection on with the latest key',
|
|
121
|
+
Effect.fnUntraced(
|
|
122
|
+
function* (_) {
|
|
123
|
+
const conversation = yield* getConversationDXN;
|
|
124
|
+
const server = yield* Effect.acquireRelease(
|
|
125
|
+
Effect.promise(() => startTestServer()),
|
|
126
|
+
(server) => Effect.promise(() => server.close()),
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const added = yield* Operation.invoke(
|
|
130
|
+
AddMcpConnection,
|
|
131
|
+
{ url: server.urls.key, key: server.apiKey },
|
|
132
|
+
{ conversation },
|
|
133
|
+
);
|
|
134
|
+
yield* Operation.invoke(SetMcpConnection, { id: added.id, enabled: false }, { conversation });
|
|
135
|
+
|
|
136
|
+
// No key this time: the stored one answers the probe, and the connection is switched back on.
|
|
137
|
+
const again = yield* Operation.invoke(AddMcpConnection, { url: server.urls.key }, { conversation });
|
|
138
|
+
expect(again.id).toBe(added.id);
|
|
139
|
+
expect(again.enabled).toBe(true);
|
|
140
|
+
const listed = yield* Operation.invoke(QueryMcpConnections, {}, { conversation });
|
|
141
|
+
expect(listed.find(({ id }) => id === added.id)?.enabled).toBe(true);
|
|
142
|
+
|
|
143
|
+
// A new key replaces the old one rather than leaving it in the space.
|
|
144
|
+
yield* Operation.invoke(AddMcpConnection, { url: server.urls.key, key: server.apiKey }, { conversation });
|
|
145
|
+
const connections = yield* Database.query(Filter.type(Connection.Connection)).run;
|
|
146
|
+
expect(connections.map(({ mcp }) => mcp?.url)).toEqual([server.urls.key]);
|
|
147
|
+
expect(yield* Database.query(Filter.type(AccessToken.AccessToken)).run).toHaveLength(1);
|
|
148
|
+
},
|
|
149
|
+
provideTestLayers,
|
|
150
|
+
TestHelpers.provideTestContext,
|
|
151
|
+
),
|
|
152
|
+
{ timeout: 30_000 },
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
it.effect(
|
|
156
|
+
'add-mcp-connection: a re-add keeps the endpoint it probed',
|
|
157
|
+
Effect.fnUntraced(
|
|
158
|
+
function* (_) {
|
|
159
|
+
const conversation = yield* getConversationDXN;
|
|
160
|
+
const server = yield* Effect.acquireRelease(
|
|
161
|
+
Effect.promise(() => startTestServer()),
|
|
162
|
+
(server) => Effect.promise(() => server.close()),
|
|
163
|
+
);
|
|
164
|
+
const connection = yield* Database.add(
|
|
165
|
+
Connection.make({ connectorId: 'mcp', name: 'open', mcp: { url: server.urls.open, protocol: 'sse' } }),
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
// The reply describes the endpoint that answered, so the connection dials that one from now on.
|
|
169
|
+
yield* Operation.invoke(AddMcpConnection, { url: server.urls.open, protocol: 'http' }, { conversation });
|
|
170
|
+
expect(connection.mcp).toEqual({ url: server.urls.open, protocol: 'http' });
|
|
171
|
+
},
|
|
172
|
+
provideTestLayers,
|
|
173
|
+
TestHelpers.provideTestContext,
|
|
174
|
+
),
|
|
175
|
+
{ timeout: 30_000 },
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
it.effect(
|
|
179
|
+
'add-mcp-connection: adds a server that answers, and refuses one that needs sign-in',
|
|
180
|
+
Effect.fnUntraced(
|
|
181
|
+
function* (_) {
|
|
182
|
+
const conversation = yield* getConversationDXN;
|
|
183
|
+
const server = yield* Effect.acquireRelease(
|
|
184
|
+
Effect.promise(() => startTestServer()),
|
|
185
|
+
(server) => Effect.promise(() => server.close()),
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const open = yield* Operation.invoke(AddMcpConnection, { url: server.urls.open }, { conversation });
|
|
189
|
+
const keyed = yield* Operation.invoke(
|
|
190
|
+
AddMcpConnection,
|
|
191
|
+
{ url: server.urls.key, key: server.apiKey },
|
|
192
|
+
{ conversation },
|
|
193
|
+
);
|
|
194
|
+
const refused = yield* Operation.invoke(AddMcpConnection, { url: server.urls.oauth }, { conversation }).pipe(
|
|
195
|
+
Effect.exit,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
expect(open.tools).toContain('get_weather');
|
|
199
|
+
expect(keyed.problem).toBeUndefined();
|
|
200
|
+
expect(refused._tag).toBe('Failure');
|
|
201
|
+
const connections = yield* Database.query(Filter.type(Connection.Connection)).run;
|
|
202
|
+
expect(connections.map(({ mcp }) => mcp?.url)).toEqual([server.urls.open, server.urls.key]);
|
|
203
|
+
expect(connections[1].accessToken).toBeDefined();
|
|
204
|
+
},
|
|
205
|
+
provideTestLayers,
|
|
206
|
+
TestHelpers.provideTestContext,
|
|
207
|
+
),
|
|
208
|
+
{ timeout: 30_000 },
|
|
209
|
+
);
|
|
210
|
+
|
|
65
211
|
it.effect(
|
|
66
212
|
'query-skills: returns all registered skills',
|
|
67
213
|
Effect.fnUntraced(
|
|
@@ -69,9 +215,9 @@ describe('Skill Manager', () => {
|
|
|
69
215
|
const conversation = yield* getConversationDXN;
|
|
70
216
|
const result = yield* Operation.invoke(QuerySkills, {}, { conversation });
|
|
71
217
|
expect(result).toHaveLength(3);
|
|
72
|
-
const keys = result.map((
|
|
218
|
+
const keys = result.map(({ key }) => key);
|
|
73
219
|
expect(keys).toContain('org.dxos.skill.chatContext');
|
|
74
|
-
expect(keys).toContain('org.dxos.skill.
|
|
220
|
+
expect(keys).toContain('org.dxos.skill.planning');
|
|
75
221
|
expect(keys).toContain('org.dxos.skill.automation');
|
|
76
222
|
},
|
|
77
223
|
provideTestLayers,
|
|
@@ -80,6 +226,23 @@ describe('Skill Manager', () => {
|
|
|
80
226
|
{ timeout: 30_000 },
|
|
81
227
|
);
|
|
82
228
|
|
|
229
|
+
it.effect(
|
|
230
|
+
'query-skills: finds the skill providing a tool by words describing it',
|
|
231
|
+
Effect.fnUntraced(
|
|
232
|
+
function* (_) {
|
|
233
|
+
const conversation = yield* getConversationDXN;
|
|
234
|
+
const result = yield* Operation.invoke(QuerySkills, { query: 'checklist task' }, { conversation });
|
|
235
|
+
expect(result.map(({ key }) => key)[0]).toBe('org.dxos.skill.planning');
|
|
236
|
+
|
|
237
|
+
const none = yield* Operation.invoke(QuerySkills, { query: 'zzzz' }, { conversation });
|
|
238
|
+
expect(none).toHaveLength(0);
|
|
239
|
+
},
|
|
240
|
+
provideTestLayers,
|
|
241
|
+
TestHelpers.provideTestContext,
|
|
242
|
+
),
|
|
243
|
+
{ timeout: 30_000 },
|
|
244
|
+
);
|
|
245
|
+
|
|
83
246
|
it.effect(
|
|
84
247
|
'enable-skills: enables skills with agentCanEnable=true',
|
|
85
248
|
Effect.fnUntraced(
|
|
@@ -134,14 +297,14 @@ describe('Skill Manager', () => {
|
|
|
134
297
|
const { enabled, rejected } = yield* Operation.invoke(
|
|
135
298
|
EnableSkills,
|
|
136
299
|
{
|
|
137
|
-
keys: ['org.dxos.skill.chatContext', 'org.dxos.skill.
|
|
300
|
+
keys: ['org.dxos.skill.chatContext', 'org.dxos.skill.planning', 'org.dxos.skill.automation'],
|
|
138
301
|
},
|
|
139
302
|
{ conversation },
|
|
140
303
|
);
|
|
141
304
|
expect(enabled).toHaveLength(2);
|
|
142
305
|
const enabledKeys = enabled.map((bp: Skill.Skill) => Obj.getMeta(bp).key);
|
|
143
306
|
expect(enabledKeys).toContain('org.dxos.skill.chatContext');
|
|
144
|
-
expect(enabledKeys).toContain('org.dxos.skill.
|
|
307
|
+
expect(enabledKeys).toContain('org.dxos.skill.planning');
|
|
145
308
|
expect(rejected).toHaveLength(1);
|
|
146
309
|
expect(rejected[0].key).toBe('org.dxos.skill.automation');
|
|
147
310
|
},
|
|
@@ -6,6 +6,7 @@ import { describe, it } from '@effect/vitest';
|
|
|
6
6
|
import * as AiError from 'effect/ai/AiError';
|
|
7
7
|
import * as Cause from 'effect/Cause';
|
|
8
8
|
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Exit from 'effect/Exit';
|
|
9
10
|
import { test } from 'vitest';
|
|
10
11
|
|
|
11
12
|
import { AssistantTestLayer, collectEphemeral, messageTextIncludes, waitForMessage } from '@dxos/agent-runtime/testing';
|
|
@@ -153,11 +154,18 @@ const addChecklist = (chat: Chat.Chat) =>
|
|
|
153
154
|
);
|
|
154
155
|
// Not begun.
|
|
155
156
|
const queued = yield* Database.add(Task.make({ title: 'Send the notice', status: 'todo' }));
|
|
157
|
+
const elsewhere = yield* Database.add(
|
|
158
|
+
Task.make({
|
|
159
|
+
title: 'Book the venue',
|
|
160
|
+
status: 'started',
|
|
161
|
+
delegate: { role: 'assistant', name: 'Claude', identityDid: 'did:key:claude' },
|
|
162
|
+
}),
|
|
163
|
+
);
|
|
156
164
|
Obj.update(chat, (chat) => {
|
|
157
|
-
chat.tasks.push(Ref.make(held), Ref.make(delegated), Ref.make(queued));
|
|
165
|
+
chat.tasks.push(Ref.make(held), Ref.make(delegated), Ref.make(queued), Ref.make(elsewhere));
|
|
158
166
|
});
|
|
159
167
|
yield* Database.flush();
|
|
160
|
-
return { held, delegated, queued };
|
|
168
|
+
return { held, delegated, queued, elsewhere };
|
|
161
169
|
});
|
|
162
170
|
|
|
163
171
|
describe('makeDelegationStrategy', () => {
|
|
@@ -200,7 +208,7 @@ describe('makeDelegationStrategy', () => {
|
|
|
200
208
|
// DelegateTask promoted the work to a durable agent task on the chat's checklist.
|
|
201
209
|
const tasks = yield* Chat.loadTasks(chat);
|
|
202
210
|
expect(tasks).toHaveLength(1);
|
|
203
|
-
expect(tasks[0]).toMatchObject({ title: TASK_TITLE,
|
|
211
|
+
expect(tasks[0]).toMatchObject({ title: TASK_TITLE, delegate: { role: 'assistant' } });
|
|
204
212
|
|
|
205
213
|
// The post-turn reconcile spawned the sub-agent; its exit drives onComplete, which posts
|
|
206
214
|
// the fold-back message to the conversation feed out of band.
|
|
@@ -257,6 +265,35 @@ describe('makeDelegationStrategy', () => {
|
|
|
257
265
|
);
|
|
258
266
|
});
|
|
259
267
|
|
|
268
|
+
describe('makeDelegationStrategy.onComplete', () => {
|
|
269
|
+
it.effect(
|
|
270
|
+
"a sub-agent's finish on a task a person answers for waits on their review",
|
|
271
|
+
Effect.fnUntraced(
|
|
272
|
+
function* ({ expect }) {
|
|
273
|
+
const agent = yield* Agent.makeInitialized({ name: 'Supervisor', instructions: '' }, DelegationSkill.make());
|
|
274
|
+
yield* Database.flush();
|
|
275
|
+
const chat = yield* Agent.loadChat(agent);
|
|
276
|
+
invariant(chat, 'Agent chat not found.');
|
|
277
|
+
const task = yield* Database.add(
|
|
278
|
+
Task.make({
|
|
279
|
+
title: 'Compute 10 factorial',
|
|
280
|
+
status: 'started',
|
|
281
|
+
assignee: { name: 'Rich' },
|
|
282
|
+
delegate: { role: 'assistant' },
|
|
283
|
+
}),
|
|
284
|
+
);
|
|
285
|
+
yield* Database.flush();
|
|
286
|
+
|
|
287
|
+
yield* makeDelegationStrategy().onComplete(chat, task.id, Exit.succeed('3628800'));
|
|
288
|
+
|
|
289
|
+
expect(task.status).toBe('review');
|
|
290
|
+
},
|
|
291
|
+
Effect.provide(TestLayer),
|
|
292
|
+
TestHelpers.provideTestContext,
|
|
293
|
+
),
|
|
294
|
+
);
|
|
295
|
+
});
|
|
296
|
+
|
|
260
297
|
describe('makeDelegationStrategy.onTurnFailed', () => {
|
|
261
298
|
it.effect(
|
|
262
299
|
'fails the tasks the conversation holds, and leaves sub-agent and queued tasks alone',
|
|
@@ -266,7 +303,7 @@ describe('makeDelegationStrategy.onTurnFailed', () => {
|
|
|
266
303
|
yield* Database.flush();
|
|
267
304
|
const chat = yield* Agent.loadChat(agent);
|
|
268
305
|
invariant(chat, 'Agent chat not found.');
|
|
269
|
-
const { held, delegated, queued } = yield* addChecklist(chat);
|
|
306
|
+
const { held, delegated, queued, elsewhere } = yield* addChecklist(chat);
|
|
270
307
|
|
|
271
308
|
const strategy = makeDelegationStrategy();
|
|
272
309
|
invariant(strategy.onTurnFailed, 'Expected the supervisor to handle a failed turn.');
|
|
@@ -280,6 +317,15 @@ describe('makeDelegationStrategy.onTurnFailed', () => {
|
|
|
280
317
|
// A spawned sub-agent is still running; its own exit decides its task.
|
|
281
318
|
expect(delegated.status).toBe('started');
|
|
282
319
|
expect(queued.status).toBe('todo');
|
|
320
|
+
expect(elsewhere.status).toBe('started');
|
|
321
|
+
|
|
322
|
+
const plain = yield* Database.add(Chat.make({ feed: Ref.make(Feed.make()) }));
|
|
323
|
+
yield* Database.flush();
|
|
324
|
+
const checklist = yield* addChecklist(plain);
|
|
325
|
+
yield* strategy.onTurnFailed(plain, Cause.fail(new Error(USAGE_LIMIT)));
|
|
326
|
+
expect(checklist.held.status).toBe('failed');
|
|
327
|
+
expect(checklist.delegated.status).toBe('started');
|
|
328
|
+
expect(checklist.elsewhere.status).toBe('started');
|
|
283
329
|
},
|
|
284
330
|
Effect.provide(TestLayer),
|
|
285
331
|
TestHelpers.provideTestContext,
|
|
@@ -336,6 +382,11 @@ describe('isSubAgentTask', () => {
|
|
|
336
382
|
expect(isSubAgentTask(Task.make({ title: 'unassigned' }))).toBe(false);
|
|
337
383
|
expect(isSubAgentTask(Task.make({ title: 'person', assignee: { name: 'Alice' } }))).toBe(false);
|
|
338
384
|
expect(isSubAgentTask(Task.make({ title: 'delegated', assignee: { role: 'assistant' } }))).toBe(true);
|
|
385
|
+
expect(
|
|
386
|
+
isSubAgentTask(
|
|
387
|
+
Task.make({ title: 'named', delegate: { role: 'assistant', name: 'Claude', identityDid: 'did:key:claude' } }),
|
|
388
|
+
),
|
|
389
|
+
).toBe(false);
|
|
339
390
|
// The planning tool's self-assignment: started by this conversation's agent, not a spawn request.
|
|
340
391
|
expect(isSubAgentTask(Task.make({ title: 'self', assignee: { role: 'assistant', subject: Ref.make(chat) } }))).toBe(
|
|
341
392
|
false,
|
|
@@ -7,13 +7,13 @@ import * as Effect from 'effect/Effect';
|
|
|
7
7
|
import * as Exit from 'effect/Exit';
|
|
8
8
|
|
|
9
9
|
import { type Delegation, type DelegationStrategy } from '@dxos/agent-runtime';
|
|
10
|
-
import { AiContext } from '@dxos/assistant';
|
|
10
|
+
import { AiContext, TrajectoryStore } from '@dxos/assistant';
|
|
11
11
|
import * as Agent from '@dxos/assistant/Agent';
|
|
12
12
|
import * as Chat from '@dxos/assistant/Chat';
|
|
13
13
|
import { OperationProcess } from '@dxos/compute-runtime';
|
|
14
14
|
import * as Instructions from '@dxos/compute/Instructions';
|
|
15
15
|
import * as Process from '@dxos/compute/Process';
|
|
16
|
-
import { Database,
|
|
16
|
+
import { Database, Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
17
17
|
import * as EffectEx from '@dxos/effect/EffectEx';
|
|
18
18
|
import { EID, EntityId } from '@dxos/keys';
|
|
19
19
|
import { log } from '@dxos/log';
|
|
@@ -63,22 +63,9 @@ const extractArtifactIds = (value: unknown): string[] => {
|
|
|
63
63
|
return ids.filter((id): id is string => typeof id === 'string');
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
* nothing else. An assistant assignee carrying a `subject` names a concrete session that owns the
|
|
69
|
-
* task — the conversation's own agent starting it from the planning tool, or a remote session —
|
|
70
|
-
* so it is that session's work, not a spawn request for the supervisor.
|
|
71
|
-
*/
|
|
72
|
-
export const isSubAgentTask = (task: Task.Task): boolean =>
|
|
73
|
-
task.assignee?.role === 'assistant' && task.assignee.subject === undefined;
|
|
66
|
+
/** A task handed to a sub-agent by the delegation verbs (see `Task.isSubAgentRequest`). */
|
|
67
|
+
export const isSubAgentTask = (task: Task.Task): boolean => Task.isSubAgentRequest(Task.worker(task));
|
|
74
68
|
|
|
75
|
-
/**
|
|
76
|
-
* The durable agent tasks awaiting a sub-agent for this conversation: queued (`todo`) tasks of
|
|
77
|
-
* the chat's checklist whose assignee is an agent, all of whose dependencies are done. Ordinary
|
|
78
|
-
* (unassigned) tasks are never spawned — delegation happens only through the delegation verbs.
|
|
79
|
-
* `started` always means a live process (set at spawn), so a started agent task with no process
|
|
80
|
-
* is an orphan — {@link sweepOrphanedTasks}.
|
|
81
|
-
*/
|
|
82
69
|
const findPendingTasks = (
|
|
83
70
|
chat: Chat.Chat,
|
|
84
71
|
activeIds: ReadonlySet<string>,
|
|
@@ -120,14 +107,14 @@ const sweepOrphanedTasks = (
|
|
|
120
107
|
yield* Database.flush();
|
|
121
108
|
});
|
|
122
109
|
|
|
123
|
-
/**
|
|
124
|
-
* Fails the tasks the conversation's own agent holds when its turn fails — a model error ends the
|
|
125
|
-
* process before any reconcile, so a task left `started` would read as underway indefinitely.
|
|
126
|
-
* Sub-agent tasks are left to their own process's exit, which may still succeed.
|
|
127
|
-
*/
|
|
128
110
|
const failHeldTasks = (chat: Chat.Chat, cause: Cause.Cause<unknown>): Effect.Effect<void, never, Database.Service> =>
|
|
129
111
|
Effect.gen(function* () {
|
|
130
|
-
const
|
|
112
|
+
const agent = yield* Agent.loadForChat(chat);
|
|
113
|
+
const selves = new Set(agent ? [chat.id, agent.id] : [chat.id]);
|
|
114
|
+
const held = (yield* Chat.loadTasks(chat)).filter((task) => {
|
|
115
|
+
const worker = Task.refEntityId(Task.worker(task)?.subject);
|
|
116
|
+
return Task.isAgentWorking(task) && worker !== undefined && selves.has(worker);
|
|
117
|
+
});
|
|
131
118
|
if (held.length === 0) {
|
|
132
119
|
return;
|
|
133
120
|
}
|
|
@@ -148,7 +135,7 @@ const failHeldTasks = (chat: Chat.Chat, cause: Cause.Cause<unknown>): Effect.Eff
|
|
|
148
135
|
|
|
149
136
|
/**
|
|
150
137
|
* Supervisor behaviour for the conversational agent: after each turn, every queued agent task
|
|
151
|
-
* whose dependencies are
|
|
138
|
+
* whose dependencies are finished is run by a sub-agent (a synthesized minimal `Routine` executed via
|
|
152
139
|
* `RunInstructions`), marked started at spawn; on exit the task is marked done/failed and a
|
|
153
140
|
* templated message is posted back to the conversation, whose turn re-runs this reconcile — so a
|
|
154
141
|
* batch of delegated tasks drains in dependency order without further prompting.
|
|
@@ -229,9 +216,7 @@ export const makeDelegationStrategy = (): DelegationStrategy => ({
|
|
|
229
216
|
const tasks = yield* Database.query(Query.select(Filter.id(id))).run.pipe(Effect.orElseSucceed(() => []));
|
|
230
217
|
const task = tasks.find((candidate): candidate is Task.Task => Obj.instanceOf(Task.Task, candidate));
|
|
231
218
|
if (task) {
|
|
232
|
-
|
|
233
|
-
task.status = Exit.isSuccess(exit) ? 'done' : 'failed';
|
|
234
|
-
});
|
|
219
|
+
Task.setStatus(task, Exit.isSuccess(exit) ? 'done' : 'failed');
|
|
235
220
|
title = task.title;
|
|
236
221
|
}
|
|
237
222
|
|
|
@@ -271,6 +256,6 @@ export const makeDelegationStrategy = (): DelegationStrategy => ({
|
|
|
271
256
|
];
|
|
272
257
|
|
|
273
258
|
const feed = yield* Database.load(chat.feed).pipe(Effect.orDie);
|
|
274
|
-
yield*
|
|
259
|
+
yield* TrajectoryStore.appendMessages(feed, [Message.make({ sender: 'assistant', blocks })]);
|
|
275
260
|
}),
|
|
276
261
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { AssistantTestLayerWithTriggers } from '@dxos/agent-runtime/testing';
|
|
6
|
-
import {
|
|
6
|
+
import { TrajectoryStore } from '@dxos/assistant';
|
|
7
7
|
import * as Agent from '@dxos/assistant/Agent';
|
|
8
8
|
import * as Chat from '@dxos/assistant/Chat';
|
|
9
9
|
import { SpaceProperties } from '@dxos/client-protocol';
|
|
@@ -21,10 +21,8 @@ import { AgentSkillHandlers } from '../skills/agent/operations/index.ts';
|
|
|
21
21
|
import { AlarmHandlers } from '../skills/alarm/operations/index.ts';
|
|
22
22
|
import { ChatContextHandlers } from '../skills/chat-context/operations/index.ts';
|
|
23
23
|
import { DelegationSkillHandlers } from '../skills/delegation/operations/index.ts';
|
|
24
|
-
import { MemoryHandlers } from '../skills/memory/operations/index.ts';
|
|
25
24
|
import { PlanningHandlers } from '../skills/planning/operations/index.ts';
|
|
26
25
|
import { SkillManagerHandlers } from '../skills/skill-manager/operations/index.ts';
|
|
27
|
-
import * as Memory from '../types/Memory.ts';
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
* Shared layer for operation tests: every handler in the package plus the types those handlers
|
|
@@ -38,19 +36,17 @@ export const OperationTestLayer = AssistantTestLayerWithTriggers({
|
|
|
38
36
|
AlarmHandlers,
|
|
39
37
|
ChatContextHandlers,
|
|
40
38
|
DelegationSkillHandlers,
|
|
41
|
-
MemoryHandlers,
|
|
42
39
|
PlanningHandlers,
|
|
43
40
|
SkillManagerHandlers,
|
|
44
41
|
),
|
|
45
42
|
types: [
|
|
46
43
|
Agent.Agent,
|
|
47
|
-
|
|
44
|
+
...TrajectoryStore.types,
|
|
48
45
|
Chat.Chat,
|
|
49
46
|
Collection.Collection,
|
|
50
47
|
Employer.Employer,
|
|
51
48
|
Feed.Feed,
|
|
52
49
|
Instructions.Instructions,
|
|
53
|
-
Memory.Memory,
|
|
54
50
|
Organization.Organization,
|
|
55
51
|
Person.Person,
|
|
56
52
|
Outline.Outline,
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
import * as Schema from 'effect/Schema';
|
|
8
8
|
|
|
9
|
+
import { mcpServerTypes } from '@dxos/agent-runtime/mcp-server-types';
|
|
9
10
|
import { AiService, OpaqueToolkit } from '@dxos/ai';
|
|
10
11
|
import * as Chat from '@dxos/assistant/Chat';
|
|
12
|
+
import * as Credential from '@dxos/compute/Credential';
|
|
11
13
|
import * as Instructions from '@dxos/compute/Instructions';
|
|
12
14
|
import * as Operation from '@dxos/compute/Operation';
|
|
13
15
|
import * as Trace from '@dxos/compute/Trace';
|
|
@@ -48,9 +50,12 @@ export const RunInstructions = Operation.make({
|
|
|
48
50
|
output: Schema.Any,
|
|
49
51
|
// ECHO types that the handler loads via Database.load(). Declaring them here ensures the
|
|
50
52
|
// runtime registers their schema before remote invocation (e.g. via the EDGE function service).
|
|
51
|
-
|
|
53
|
+
// `mcpServerTypes` are read each step to connect the space's MCP servers.
|
|
54
|
+
types: [Instructions.Instructions, Text.Text, Feed.Feed, Chat.Chat, ...mcpServerTypes],
|
|
52
55
|
services: [
|
|
53
56
|
AiService.AiService,
|
|
57
|
+
// Resolves an MCP connection's key.
|
|
58
|
+
Credential.CredentialsService,
|
|
54
59
|
Database.Service,
|
|
55
60
|
OpaqueToolkit.OpaqueToolkitProvider,
|
|
56
61
|
Registry.Service,
|
package/src/types/index.ts
CHANGED
package/dist/lib/Memory.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { t as Memory } from "./chunk-Memory.mjs";
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
-
import { Annotation, DXN, Type } from "@dxos/echo";
|
|
3
|
-
import * as Schema from "effect/Schema";
|
|
4
|
-
//#region src/types/Memory.ts
|
|
5
|
-
var Memory_exports = /* @__PURE__ */ __exportAll({ Memory: () => Memory });
|
|
6
|
-
/**
|
|
7
|
-
* Unit of knowledge generated by an agent.
|
|
8
|
-
*/
|
|
9
|
-
var Memory = class extends Type.makeObject(DXN.make("org.dxos.type.memory", "0.1.0"))(Schema.Struct({
|
|
10
|
-
title: Schema.String,
|
|
11
|
-
content: Schema.String
|
|
12
|
-
}).pipe(Annotation.LabelAnnotation.set(["title"]), Annotation.IconAnnotation.set({
|
|
13
|
-
icon: "ph--brain--regular",
|
|
14
|
-
hue: "pink"
|
|
15
|
-
}))) {};
|
|
16
|
-
//#endregion
|
|
17
|
-
export { Memory_exports as n, Memory as t };
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=chunk-Memory.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-Memory.mjs","names":[],"sources":["../../src/types/Memory.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation, DXN, Type } from '@dxos/echo';\n\n/**\n * Unit of knowledge generated by an agent.\n */\nexport class Memory extends Type.makeObject<Memory>(DXN.make('org.dxos.type.memory', '0.1.0'))(\n Schema.Struct({\n title: Schema.String,\n content: Schema.String,\n }).pipe(\n Annotation.LabelAnnotation.set(['title']),\n Annotation.IconAnnotation.set({ icon: 'ph--brain--regular', hue: 'pink' }),\n ),\n) {}\n"],"mappings":";;;;;;;;AAaA,IAAa,SAAb,cAA4B,KAAK,WAAmB,IAAI,KAAK,wBAAwB,OAAO,CAAC,CAAC,CAC5F,OAAO,OAAO;CACZ,OAAO,OAAO;CACd,SAAS,OAAO;AAClB,CAAC,CAAC,CAAC,KACD,WAAW,gBAAgB,IAAI,CAAC,OAAO,CAAC,GACxC,WAAW,eAAe,IAAI;CAAE,MAAM;CAAsB,KAAK;AAAO,CAAC,CAC3E,CACF,CAAC,CAAC,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
-
import { a as definitions_exports, i as SaveMemory, n as DeleteMemory, r as QueryMemories, t as MemoryHandlers } from "./chunk-operations4.mjs";
|
|
3
|
-
import { Ref } from "@dxos/echo";
|
|
4
|
-
import { trim } from "@dxos/util";
|
|
5
|
-
import * as Skill from "@dxos/compute/Skill";
|
|
6
|
-
import { Text } from "@dxos/schema";
|
|
7
|
-
//#region src/skills/memory/MemorySkill.ts
|
|
8
|
-
var MemorySkill_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
-
Handlers: () => MemoryHandlers,
|
|
10
|
-
Operations: () => definitions_exports,
|
|
11
|
-
key: () => key,
|
|
12
|
-
make: () => make
|
|
13
|
-
});
|
|
14
|
-
var key = "org.dxos.skill.memory";
|
|
15
|
-
var instructions = trim`
|
|
16
|
-
You have the ability to save and recall memories.
|
|
17
|
-
Memories are persistent knowledge units stored in the database.
|
|
18
|
-
Use memories to remember facts, user preferences, decisions, and any knowledge that should persist across conversations.
|
|
19
|
-
|
|
20
|
-
When the user asks you to remember something, save it as a memory with a descriptive title.
|
|
21
|
-
When the user asks about something you might have stored, query your memories first.
|
|
22
|
-
You can also delete outdated or incorrect memories.
|
|
23
|
-
`;
|
|
24
|
-
var make = () => Skill.make({
|
|
25
|
-
key,
|
|
26
|
-
name: "Memory",
|
|
27
|
-
description: "Persistent memory storage and retrieval.",
|
|
28
|
-
agentCanEnable: true,
|
|
29
|
-
instructions: { source: Ref.make(Text.make({ content: instructions })) },
|
|
30
|
-
tools: Skill.toolDefinitions({ operations: [
|
|
31
|
-
SaveMemory,
|
|
32
|
-
QueryMemories,
|
|
33
|
-
DeleteMemory
|
|
34
|
-
] })
|
|
35
|
-
});
|
|
36
|
-
//#endregion
|
|
37
|
-
export { key as n, make as r, MemorySkill_exports as t };
|
|
38
|
-
|
|
39
|
-
//# sourceMappingURL=chunk-MemorySkill.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-MemorySkill.mjs","names":[],"sources":["../../src/skills/memory/MemorySkill.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Skill from '@dxos/compute/Skill';\nimport { Ref } from '@dxos/echo';\nimport { Text } from '@dxos/schema';\nimport { trim } from '@dxos/util';\n\nimport { DeleteMemory, QueryMemories, SaveMemory } from './operations/definitions.ts';\n\nexport const key = 'org.dxos.skill.memory';\n\nconst instructions = trim`\n You have the ability to save and recall memories.\n Memories are persistent knowledge units stored in the database.\n Use memories to remember facts, user preferences, decisions, and any knowledge that should persist across conversations.\n\n When the user asks you to remember something, save it as a memory with a descriptive title.\n When the user asks about something you might have stored, query your memories first.\n You can also delete outdated or incorrect memories.\n`;\n\nexport const make = () =>\n Skill.make({\n key,\n name: 'Memory',\n description: 'Persistent memory storage and retrieval.',\n agentCanEnable: true,\n instructions: {\n source: Ref.make(Text.make({ content: instructions })),\n },\n tools: Skill.toolDefinitions({ operations: [SaveMemory, QueryMemories, DeleteMemory] }),\n });\n\nexport { MemoryHandlers as Handlers } from './operations/index.ts';\nexport * as Operations from './operations/definitions.ts';\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAa,MAAM;AAEnB,IAAM,eAAe,IAAI;;;;;;;;;AAUzB,IAAa,aACX,MAAM,KAAK;CACT;CACA,MAAM;CACN,aAAa;CACb,gBAAgB;CAChB,cAAc,EACZ,QAAQ,IAAI,KAAK,KAAK,KAAK,EAAE,SAAS,aAAa,CAAC,CAAC,EACvD;CACA,OAAO,MAAM,gBAAgB,EAAE,YAAY;EAAC;EAAY;EAAe;CAAY,EAAE,CAAC;AACxF,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { n as DeleteMemory } from "./chunk-operations4.mjs";
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import { Database } from "@dxos/echo";
|
|
4
|
-
import * as Operation from "@dxos/compute/Operation";
|
|
5
|
-
//#region src/skills/memory/operations/delete.ts
|
|
6
|
-
var delete_default = DeleteMemory.pipe(Operation.withHandler(Effect.fn(function* ({ memory }) {
|
|
7
|
-
const memoryObj = yield* Database.load(memory);
|
|
8
|
-
yield* Database.remove(memoryObj);
|
|
9
|
-
yield* Database.flush();
|
|
10
|
-
})));
|
|
11
|
-
//#endregion
|
|
12
|
-
export { delete_default as default };
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=chunk-delete.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-delete.mjs","names":[],"sources":["../../src/skills/memory/operations/delete.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport * as Operation from '@dxos/compute/Operation';\nimport { Database } from '@dxos/echo';\n\nimport { DeleteMemory } from './definitions.ts';\n\nexport default DeleteMemory.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ memory }) {\n const memoryObj = yield* Database.load(memory);\n yield* Database.remove(memoryObj);\n yield* Database.flush();\n }),\n ),\n);\n"],"mappings":";;;;;AAWA,IAAA,iBAAe,aAAa,KAC1B,UAAU,YACR,OAAO,GAAG,WAAW,EAAE,UAAU;CAC/B,MAAM,YAAY,OAAO,SAAS,KAAK,MAAM;CAC7C,OAAO,SAAS,OAAO,SAAS;CAChC,OAAO,SAAS,MAAM;AACxB,CAAC,CACH,CACF"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { n as RunInstructions } from "./chunk-AgentOperation.mjs";
|
|
2
|
-
import * as Operation from "@dxos/compute/Operation";
|
|
3
|
-
import * as OperationHandlerSet from "@dxos/compute/OperationHandlerSet";
|
|
4
|
-
//#region src/operations/index.ts
|
|
5
|
-
var AgentHandlers = OperationHandlerSet.lazy([RunInstructions.pipe(Operation.lazyHandler(() => import("./chunk-run-instructions.mjs")))]);
|
|
6
|
-
//#endregion
|
|
7
|
-
export { AgentHandlers as t };
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=chunk-operations8.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-operations8.mjs","names":[],"sources":["../../src/operations/index.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Operation from '@dxos/compute/Operation';\nimport * as OperationHandlerSet from '@dxos/compute/OperationHandlerSet';\n\nimport * as AgentOperation from '../types/AgentOperation.ts';\n\nexport const AgentHandlers = OperationHandlerSet.lazy([\n AgentOperation.RunInstructions.pipe(Operation.lazyHandler(() => import('./run-instructions.ts'))),\n]);\n"],"mappings":";;;;AASA,IAAa,gBAAgB,oBAAoB,KAAK,CAAA,gBACrB,KAAK,UAAU,kBAAkB,OAAO,+BAAwB,CAAC,CAClG,CAAC"}
|
package/dist/lib/chunk-query.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { t as Memory } from "./chunk-Memory.mjs";
|
|
2
|
-
import { r as QueryMemories } from "./chunk-operations4.mjs";
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import { Database, Entity, Filter, Query } from "@dxos/echo";
|
|
5
|
-
import * as Operation from "@dxos/compute/Operation";
|
|
6
|
-
//#region src/skills/memory/operations/query.ts
|
|
7
|
-
var query_default = QueryMemories.pipe(Operation.withHandler(Effect.fn(function* ({ text, limit = 10 }) {
|
|
8
|
-
let query;
|
|
9
|
-
if (text) query = Query.all(...text.split(" ").map((term) => Query.select(Filter.text(term, { type: "full-text" })))).select(Filter.type(Memory));
|
|
10
|
-
else query = Query.select(Filter.type(Memory));
|
|
11
|
-
query = query.limit(limit);
|
|
12
|
-
yield* Database.flush();
|
|
13
|
-
return (yield* Database.query(query).run).map((obj) => Entity.toJSON(obj));
|
|
14
|
-
})));
|
|
15
|
-
//#endregion
|
|
16
|
-
export { query_default as default };
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=chunk-query.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-query.mjs","names":["Memory.Memory"],"sources":["../../src/skills/memory/operations/query.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport * as Operation from '@dxos/compute/Operation';\nimport { Database, Entity, Filter, Query } from '@dxos/echo';\n\nimport * as Memory from '../../../types/Memory.ts';\nimport { QueryMemories } from './definitions.ts';\n\nexport default QueryMemories.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ text, limit = 10 }) {\n let query: Query.Any;\n if (text) {\n query = Query.all(\n // TODO(dmaretskyi): We should move this to the query executor layer.\n ...text.split(' ').map((term) => Query.select(Filter.text(term, { type: 'full-text' }))),\n ).select(Filter.type(Memory.Memory));\n } else {\n query = Query.select(Filter.type(Memory.Memory));\n }\n query = query.limit(limit);\n\n yield* Database.flush();\n const results = yield* Database.query(query).run;\n return results.map((obj) => Entity.toJSON(obj));\n }),\n ),\n);\n"],"mappings":";;;;;;AAYA,IAAA,gBAAe,cAAc,KAC3B,UAAU,YACR,OAAO,GAAG,WAAW,EAAE,MAAM,QAAQ,MAAM;CACzC,IAAI;CACJ,IAAI,MACF,QAAQ,MAAM,IAEZ,GAAG,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,SAAS,MAAM,OAAO,OAAO,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC,CAAC,CAAC,CACzF,CAAC,CAAC,OAAO,OAAO,KAAKA,MAAa,CAAC;MAEnC,QAAQ,MAAM,OAAO,OAAO,KAAKA,MAAa,CAAC;CAEjD,QAAQ,MAAM,MAAM,KAAK;CAEzB,OAAO,SAAS,MAAM;CAEtB,QAAO,OADgB,SAAS,MAAM,KAAK,CAAC,CAAC,IAAA,CAC9B,KAAK,QAAQ,OAAO,OAAO,GAAG,CAAC;AAChD,CAAC,CACH,CACF"}
|