@arki-moe/agent-ts 2.2.3 → 3.0.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/README.md +0 -16
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,7 +54,6 @@ When `apiKey` is not provided in config, adapters read from the corresponding en
|
|
|
54
54
|
- `agent.context` - Public property, complete conversation history
|
|
55
55
|
- `agent.registerTool(tool)` - Register tool
|
|
56
56
|
- `agent.run(message, options?)` - Execute tool chain automatically, returns all new `Message[]`
|
|
57
|
-
- `agent.fork()` - Create a new agent with a copied context
|
|
58
57
|
|
|
59
58
|
### Config
|
|
60
59
|
|
|
@@ -72,21 +71,6 @@ When `apiKey` is not provided in config, adapters read from the corresponding en
|
|
|
72
71
|
|
|
73
72
|
`onToolCall` receives parsed JSON args and can mutate them before execution. Returning `false` skips the tool call and does not emit a `ToolResult` message.
|
|
74
73
|
|
|
75
|
-
`agent.fork()` shallow-copies the context array, but message objects are shared. This means:
|
|
76
|
-
- Shallow copy: `forked.context !== agent.context`, so pushing new messages does not affect the other agent.
|
|
77
|
-
- Shared messages: modifying a message object in one context will be visible in the other.
|
|
78
|
-
|
|
79
|
-
Example:
|
|
80
|
-
|
|
81
|
-
```ts
|
|
82
|
-
const forked = agent.fork();
|
|
83
|
-
forked.context.push({ role: Role.User, content: "hi" });
|
|
84
|
-
// agent.context length is unchanged
|
|
85
|
-
|
|
86
|
-
forked.context[0].content = "changed";
|
|
87
|
-
// agent.context[0].content is also "changed" because messages are shared
|
|
88
|
-
```
|
|
89
|
-
|
|
90
74
|
## Scripts
|
|
91
75
|
|
|
92
76
|
| Command | Description |
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -103,12 +103,5 @@ class Agent {
|
|
|
103
103
|
msgs = await runAdapter();
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
fork() {
|
|
107
|
-
const agent = new Agent(this.adapterName, this.config);
|
|
108
|
-
agent.adapter = this.adapter;
|
|
109
|
-
agent.tools = [...this.tools];
|
|
110
|
-
agent.context = [...this.context];
|
|
111
|
-
return agent;
|
|
112
|
-
}
|
|
113
106
|
}
|
|
114
107
|
exports.Agent = Agent;
|