@rowan-agent/agent 0.8.5 → 0.8.7
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/README.md +124 -8
- package/dist/index.d.ts +457 -21
- package/dist/index.js +1462 -611
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,24 +11,39 @@ import {
|
|
|
11
11
|
AgentRuntime,
|
|
12
12
|
createCoreTools,
|
|
13
13
|
InMemoryStore,
|
|
14
|
+
loadPhases,
|
|
15
|
+
loadSkills,
|
|
14
16
|
} from "@rowan-agent/agent";
|
|
15
17
|
|
|
18
|
+
const skills = await loadSkills("./.rowan/skills");
|
|
19
|
+
const phases = await loadPhases("./.rowan/phases");
|
|
16
20
|
const runtime = await AgentRuntime.init({
|
|
17
21
|
store: new InMemoryStore(),
|
|
18
22
|
});
|
|
19
23
|
|
|
20
24
|
const agentId = await runtime.createAgent({
|
|
21
25
|
identity: "example:v1", // Stable config snapshot identity, not the Agent ID
|
|
22
|
-
model: {
|
|
23
|
-
|
|
26
|
+
model: {
|
|
27
|
+
provider: "openai",
|
|
28
|
+
id: "gpt-4o",
|
|
29
|
+
protocol: "openai-responses",
|
|
30
|
+
baseUrl: "https://api.openai.com/v1",
|
|
31
|
+
apiKey: process.env.OPENAI_API_KEY!,
|
|
32
|
+
},
|
|
24
33
|
definition: {
|
|
25
34
|
name: "workspace-assistant",
|
|
26
35
|
description: "Assist with the current workspace.",
|
|
27
|
-
|
|
36
|
+
prompt: "You are helpful.",
|
|
37
|
+
contexts: ["workspace"],
|
|
28
38
|
},
|
|
29
39
|
resources: {
|
|
30
40
|
tools: createCoreTools({ root: process.cwd() }),
|
|
31
|
-
skills
|
|
41
|
+
skills,
|
|
42
|
+
contexts: [{
|
|
43
|
+
name: "workspace",
|
|
44
|
+
value: { root: process.cwd() },
|
|
45
|
+
}],
|
|
46
|
+
phases,
|
|
32
47
|
},
|
|
33
48
|
});
|
|
34
49
|
|
|
@@ -106,7 +121,108 @@ checkpoints; transient events never enter the Durable Store.
|
|
|
106
121
|
|
|
107
122
|
## Resources
|
|
108
123
|
|
|
109
|
-
`
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
`AgentRuntime` owns a Resource Registry. Register Agent Definitions, Tools,
|
|
125
|
+
Skills, and Phases under stable `sourceId` values, then select the sources for
|
|
126
|
+
an Agent through `resourceView`:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
const runtime = await AgentRuntime.init({
|
|
130
|
+
store: new InMemoryStore(),
|
|
131
|
+
bootstrap: async (registry) => {
|
|
132
|
+
await registry.loadExtensions({
|
|
133
|
+
sourceId: "workspace.extensions",
|
|
134
|
+
directory: "./extensions",
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
await runtime.loadAgents({
|
|
140
|
+
sourceId: "workspace",
|
|
141
|
+
values: [{
|
|
142
|
+
name: "workspace-assistant",
|
|
143
|
+
description: "Assist with the current workspace.",
|
|
144
|
+
prompt: "You are helpful.",
|
|
145
|
+
}],
|
|
146
|
+
});
|
|
147
|
+
await runtime.loadTools({
|
|
148
|
+
sourceId: "workspace",
|
|
149
|
+
values: createCoreTools({ root: process.cwd() }),
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const agentId = await runtime.createAgent({
|
|
153
|
+
identity: "workspace:v1",
|
|
154
|
+
definition: { name: "workspace-assistant" },
|
|
155
|
+
resourceView: {
|
|
156
|
+
agents: ["workspace"],
|
|
157
|
+
tools: ["workspace"],
|
|
158
|
+
skills: [],
|
|
159
|
+
phases: [],
|
|
160
|
+
},
|
|
161
|
+
model: {
|
|
162
|
+
provider: "openai",
|
|
163
|
+
id: "gpt-4o",
|
|
164
|
+
protocol: "openai-responses",
|
|
165
|
+
baseUrl: "https://api.openai.com/v1",
|
|
166
|
+
apiKey: process.env.OPENAI_API_KEY!,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Each `load*()` call replaces one source atomically; use `directory` or inline
|
|
172
|
+
`values`. `resourceView` controls visibility, so same-name resources can live
|
|
173
|
+
in isolated sources but collide when selected together. The built-in `route`
|
|
174
|
+
Tool and `default` Phase are always available and cannot be overridden.
|
|
175
|
+
|
|
176
|
+
Extensions are Runtime-global. Load them only during `AgentRuntime.init()` via
|
|
177
|
+
`bootstrap`; after initialization they are frozen until the Runtime closes.
|
|
178
|
+
Definition name lists narrow the selected Tools, Skills, and Phases: omission
|
|
179
|
+
inherits all candidates, `[]` selects none, and missing names are skipped. The
|
|
180
|
+
same rule applies to `definition.contexts`.
|
|
181
|
+
|
|
182
|
+
### Resources and Definition
|
|
183
|
+
|
|
184
|
+
`resources` and `definition` have different jobs:
|
|
185
|
+
|
|
186
|
+
- `resources` supplies the concrete candidates available to one Agent. Its
|
|
187
|
+
Tools contain executable `execute()` functions; Skills and Phases contain
|
|
188
|
+
their loaded content; Contexts contain JSON-safe values.
|
|
189
|
+
- `definition` declares which candidates this Agent uses. `tools`, `skills`,
|
|
190
|
+
`contexts`, and `phases` are name-based selectors; they cannot create a
|
|
191
|
+
resource that is absent from `resources`.
|
|
192
|
+
|
|
193
|
+
For a single-process embedding, provide concrete resources directly and omit
|
|
194
|
+
the selectors when the Agent should use everything:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
const agentId = await runtime.createAgent({
|
|
198
|
+
identity: "workspace:v1",
|
|
199
|
+
definition: {
|
|
200
|
+
name: "workspace-assistant",
|
|
201
|
+
description: "Assist with the current workspace.",
|
|
202
|
+
prompt: "You are helpful.",
|
|
203
|
+
},
|
|
204
|
+
resources: { tools, skills, contexts, phases },
|
|
205
|
+
model,
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Use selectors when several Agents share a candidate pool:
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
definition: {
|
|
213
|
+
name: "read-only-assistant",
|
|
214
|
+
description: "Inspect the workspace without changing it.",
|
|
215
|
+
prompt: "You are helpful.",
|
|
216
|
+
tools: ["read"],
|
|
217
|
+
contexts: ["workspace"],
|
|
218
|
+
phases: { entryPhaseId: "review", phaseIds: ["review"] },
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
For process-boundary persistence, use the Resource Registry form shown above:
|
|
223
|
+
`resourceView` stores stable source IDs instead of executable resource
|
|
224
|
+
closures, and the Runtime resolves those sources into an immutable
|
|
225
|
+
Configuration Snapshot. This lets a restarted Runtime resolve the same
|
|
226
|
+
resource revisions while keeping each Run pinned to the snapshot that created
|
|
227
|
+
it. Direct `resources` are simpler for embedding; `resourceView` is the
|
|
228
|
+
declarative form for shared, reloadable, and restart-resolvable resources.
|