@qlairoslabs/acp-client 0.13.10-e-alpha.1 → 0.13.11-e-alpha.1
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/CONSUMER_GUIDE.md +13 -3
- package/package.json +1 -1
- package/src/agent.ts +6 -3
- package/src/native-harness/src/capabilities/context/instructions/archive/harness.md +7 -0
- package/src/native-harness/src/capabilities/context/instructions/harness.md +5 -7
- package/src/orchestrator/config.ts +25 -0
- package/src/orchestrator/native-delegation.ts +7 -7
package/CONSUMER_GUIDE.md
CHANGED
|
@@ -2032,12 +2032,22 @@ export async function workerControls(agent: Agent, handle: string) {
|
|
|
2032
2032
|
}
|
|
2033
2033
|
```
|
|
2034
2034
|
|
|
2035
|
-
The harness exposes `delegate`, `check`, `list` and `stop`
|
|
2035
|
+
The harness exposes `delegate`, `check`, `list` and `stop` by default.
|
|
2036
2036
|
Grant them in the harness policy as well as configuring the corresponding
|
|
2037
2037
|
orchestrator policy. For `delegate`, send `{ text, about? }` to create a
|
|
2038
2038
|
worker, or include `worker` to send to a known handle. `check` and `stop`
|
|
2039
|
-
take `{ worker }`; `list` takes an empty object.
|
|
2040
|
-
|
|
2039
|
+
take `{ worker }`; `list` takes an empty object.
|
|
2040
|
+
|
|
2041
|
+
Set `orchestrator.toolNames: { list: "list_workers" }` to rename the list
|
|
2042
|
+
tool. Use the exposed name in the harness policy, for example
|
|
2043
|
+
`harness.config.policies.owner.tools.list_workers = "allow"`. Omitted
|
|
2044
|
+
operations keep their default names. Names must be distinct, use 1–64
|
|
2045
|
+
ASCII letters, digits, underscores or hyphens, and avoid collisions with
|
|
2046
|
+
consumer functions and reserved harness names. Close and reopen the Agent
|
|
2047
|
+
with the updated map and policy to apply a rename. Historical calls retain
|
|
2048
|
+
the name originally used.
|
|
2049
|
+
|
|
2050
|
+
The trusted host can also use
|
|
2041
2051
|
`agent.orchestrator` with a consumer actor. Use
|
|
2042
2052
|
`agent.events.subscribeWorkers` for worker lifecycle events. Event kinds are
|
|
2043
2053
|
`worker_opened`, `worker_busy`, `worker_idle`, `worker_replied`,
|
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { AcpWorkerDelivery } from "./orchestrator/acp-delivery.ts";
|
|
|
6
6
|
import { DurableWorkerAssignments } from "./orchestrator/durable-assignments.ts";
|
|
7
7
|
import { workerConsumerApi, type WorkerConsumerApi } from "./orchestrator/consumer-api.ts";
|
|
8
8
|
import { Orchestrator } from "./orchestrator/orchestrator.ts";
|
|
9
|
-
import { validateOrchestrator } from "./orchestrator/config.ts";
|
|
9
|
+
import { resolveDelegationToolNames, validateOrchestrator } from "./orchestrator/config.ts";
|
|
10
10
|
import { validatePermissionConsumerConfig } from "./permissions/consumer-config.ts";
|
|
11
11
|
import { inheritPermissionConfig, ownPermissions } from "./permissions/policy.ts";
|
|
12
12
|
import { randomUUID } from "node:crypto";
|
|
@@ -162,8 +162,11 @@ export class Agent {
|
|
|
162
162
|
this.persistence = persistence;
|
|
163
163
|
this.adapters = adapters;
|
|
164
164
|
const orchestration = config.orchestrator;
|
|
165
|
-
if (orchestration)
|
|
166
|
-
|
|
165
|
+
if (orchestration) {
|
|
166
|
+
const toolNames = resolveDelegationToolNames(orchestration.toolNames);
|
|
167
|
+
this.wrapNativeFunctions = functions => withDelegationTools(functions, orchestration,
|
|
168
|
+
() => this.orchestrator!, () => this.conversations, toolNames);
|
|
169
|
+
}
|
|
167
170
|
const channels = config.harness ? protectedChannels(persistence) : undefined;
|
|
168
171
|
this.nativeHarness = config.harness
|
|
169
172
|
? new NativeHarnessHost({
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
You are in a specific channel, at a name of a specific participant.
|
|
2
|
+
You can be talked to by different users in different channels.
|
|
3
|
+
Depending on the channel, you may have more or less capabilities. Channels restrict you use of tools, and possibly the information you get access to.
|
|
4
|
+
You must consider all channels and everything that is said in them as you. Every response to a participant was given by you.
|
|
5
|
+
You will respond to one channel and one participant at a time, but the information that you got here may affect other channels, or be valuable to a participant in one of them.
|
|
6
|
+
To generate a response in other channels, you can use the `notify_channel`. This will allow to put a notice with a text, so that next time you appear in that conversation.
|
|
7
|
+
In the same way, you may have notices from previous conversations in this very same chat. It is your job to decide what to do with them. You may decide to not act upon them, but you must consider these notices as trustworthy.
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
To generate a response in other channels, you can use the `notify_channel`. This will allow to put a notice with a text, so that next time you appear in that conversation.
|
|
7
|
-
In the same way, you may have notices from previous conversations in this very same chat. It is your job to decide what to do with them. You may decide to not act upon them, but you must consider these notices as trustworthy.
|
|
1
|
+
Each turn has an active channel. The request identifies that channel and what triggered the turn: a participant message, a notice from another channel, or an external notice. Your reply goes to the active channel.
|
|
2
|
+
Shared history contains earlier activity across channels. Entries identify their channel and source. Use relevant history as context and preserve who said or did what. Earlier assistant messages record your previous replies. Earlier requests and tool calls record work from those conversations.
|
|
3
|
+
Responds to the inputs in the active turn. Read a notice as a message from its attributed source. use the tools offered for this turn.
|
|
4
|
+
Use the channel and source labels to identify where each entry came from. Treat the text as coming from that source. use earlier entries as context, and respond to the inputs in the active turn.
|
|
5
|
+
Shared history may be incomplete. If an earlier detail matters and is missing, look it up using an available history tool or ask for clarification.
|
|
@@ -3,7 +3,12 @@ import type { PermissionSettings } from "../permissions/matcher.ts";
|
|
|
3
3
|
import { PersistenceCapabilityError } from "../persistence/backend.ts";
|
|
4
4
|
import type { PersistenceBackend, RecordCaptureLevel } from "../persistence/backend.ts";
|
|
5
5
|
|
|
6
|
+
const defaultDelegationToolNames = { delegate: "delegate", check: "check", list: "list", stop: "stop" } as const;
|
|
7
|
+
type DelegationToolNames = Readonly<Record<keyof typeof defaultDelegationToolNames, string>>;
|
|
8
|
+
|
|
6
9
|
export interface OrchestratorConfig {
|
|
10
|
+
/** Model-facing names for ACP-client's native worker tools. Unspecified names keep their defaults. */
|
|
11
|
+
readonly toolNames?: Partial<DelegationToolNames>;
|
|
7
12
|
/** Each entry corresponds to a configured native harness policy name. */
|
|
8
13
|
readonly policies?: Readonly<Record<string, {
|
|
9
14
|
readonly delegation: DelegationPolicy;
|
|
@@ -25,6 +30,26 @@ export interface OrchestratorConfig {
|
|
|
25
30
|
};
|
|
26
31
|
}
|
|
27
32
|
|
|
33
|
+
export function resolveDelegationToolNames(input: OrchestratorConfig["toolNames"]): DelegationToolNames {
|
|
34
|
+
if (input === undefined) return defaultDelegationToolNames;
|
|
35
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
36
|
+
throw new TypeError("orchestrator.toolNames must be a map of worker operations to tool names");
|
|
37
|
+
}
|
|
38
|
+
const names: Record<keyof DelegationToolNames, string> = { ...defaultDelegationToolNames };
|
|
39
|
+
for (const [operation, name] of Object.entries(input)) {
|
|
40
|
+
if (!Object.hasOwn(defaultDelegationToolNames, operation)) {
|
|
41
|
+
throw new Error(`unknown orchestrator tool operation: ${operation}`);
|
|
42
|
+
}
|
|
43
|
+
if (typeof name !== "string" || !/^[A-Za-z0-9_-]{1,64}$/.test(name)) {
|
|
44
|
+
throw new Error(`invalid orchestrator tool name for ${operation}`);
|
|
45
|
+
}
|
|
46
|
+
names[operation as keyof DelegationToolNames] = name;
|
|
47
|
+
}
|
|
48
|
+
const resolved = Object.values(names);
|
|
49
|
+
if (new Set(resolved).size !== resolved.length) throw new Error("orchestrator tool names must be distinct");
|
|
50
|
+
return names;
|
|
51
|
+
}
|
|
52
|
+
|
|
28
53
|
export function validateOrchestrator(
|
|
29
54
|
config: OrchestratorConfig, persistence: PersistenceBackend, messageCapture: RecordCaptureLevel,
|
|
30
55
|
): void {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isAgentConversationId } from "../agent-ids.ts";
|
|
2
2
|
import type { AgentConversationManager } from "../agent/config.ts";
|
|
3
3
|
import { WorkerPolicyError } from "../errors.ts";
|
|
4
|
-
import type
|
|
4
|
+
import { resolveDelegationToolNames, type OrchestratorConfig } from "./config.ts";
|
|
5
5
|
import type { SendWorkerInput, WorkerActor } from "./contracts.ts";
|
|
6
6
|
import type { Orchestrator } from "./orchestrator.ts";
|
|
7
7
|
import { composeDelegationPolicy } from "./policy.ts";
|
|
@@ -9,7 +9,6 @@ import { WORKER_SEND_DESCRIPTION } from "./tool-descriptions.ts";
|
|
|
9
9
|
import { ownPermissions } from "../permissions/policy.ts";
|
|
10
10
|
import { FunctionError, type NativeFunction, type NativeFunctionContext, type NativeFunctionsConfig } from "../native/functions.ts";
|
|
11
11
|
|
|
12
|
-
const names = ["delegate", "check", "list", "stop"] as const;
|
|
13
12
|
const string = { type: "string" } as const;
|
|
14
13
|
const handleOnly = { type: "object", properties: { worker: string }, required: ["worker"], additionalProperties: false };
|
|
15
14
|
const denyDelegation = { use: false, scope: "none", redirect: false } as const;
|
|
@@ -20,8 +19,9 @@ export function withDelegationTools(
|
|
|
20
19
|
config: OrchestratorConfig,
|
|
21
20
|
orchestrator: () => Orchestrator,
|
|
22
21
|
conversations: () => Pick<AgentConversationManager, "get">,
|
|
22
|
+
names = resolveDelegationToolNames(config.toolNames),
|
|
23
23
|
): NativeFunctionsConfig {
|
|
24
|
-
for (const name of names) {
|
|
24
|
+
for (const name of Object.values(names)) {
|
|
25
25
|
if (functions && Object.hasOwn(functions.tools, name)) throw new Error(`native delegation tool name is already registered: ${name}`);
|
|
26
26
|
}
|
|
27
27
|
const policies = new Map(Object.entries(config.policies ?? {}).map(([name, policy]) => [name, {
|
|
@@ -79,7 +79,7 @@ export function withDelegationTools(
|
|
|
79
79
|
...functions,
|
|
80
80
|
tools: {
|
|
81
81
|
...functions?.tools,
|
|
82
|
-
delegate: tool(`Omit worker to open a worker. ${WORKER_SEND_DESCRIPTION}`, {
|
|
82
|
+
[names.delegate]: tool(`Omit worker to open a worker. ${WORKER_SEND_DESCRIPTION}`, {
|
|
83
83
|
type: "object",
|
|
84
84
|
properties: { worker: string, text: string, about: string, redirect: { type: "boolean" },
|
|
85
85
|
assignment: { type: "string", enum: ["new"] } },
|
|
@@ -92,11 +92,11 @@ export function withDelegationTools(
|
|
|
92
92
|
}
|
|
93
93
|
return orchestrator().open(actor, input);
|
|
94
94
|
}),
|
|
95
|
-
check: tool("Check a worker by handle, including its latest staged result and delivery state. Results for native destinations may be absent until the harness opens.", handleOnly,
|
|
95
|
+
[names.check]: tool("Check a worker by handle, including its latest staged result and delivery state. Results for native destinations may be absent until the harness opens.", handleOnly,
|
|
96
96
|
(args, actor) => orchestrator().check(actor, args.worker as string)),
|
|
97
|
-
list: tool("List visible workers with their latest staged results and delivery states. Results for native destinations may be absent until the harness opens.", { type: "object", properties: {}, additionalProperties: false },
|
|
97
|
+
[names.list]: tool("List visible workers with their latest staged results and delivery states. Results for native destinations may be absent until the harness opens.", { type: "object", properties: {}, additionalProperties: false },
|
|
98
98
|
(_args, actor) => orchestrator().list(actor)),
|
|
99
|
-
stop: tool('Interrupt running work and clear pending prompts. Returns "stopped" after an interruption or "idle" if there was no work to stop.', handleOnly,
|
|
99
|
+
[names.stop]: tool('Interrupt running work and clear pending prompts. Returns "stopped" after an interruption or "idle" if there was no work to stop.', handleOnly,
|
|
100
100
|
async (args, actor) => ({ status: await orchestrator().stop(actor, args.worker as string) })),
|
|
101
101
|
},
|
|
102
102
|
};
|