@ziggs-ai/agent-sdk 0.48.4 → 0.48.6
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/CHANGELOG.md +4 -0
- package/dist/Agent.d.ts +7 -0
- package/dist/Agent.js +40 -3
- package/dist/platform/laneKey.d.ts +4 -3
- package/dist/platform/laneKey.js +4 -3
- package/dist/tools/defineTool.js +12 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.48.6
|
|
6
|
+
|
|
7
|
+
## 0.48.5
|
|
8
|
+
|
|
5
9
|
## 0.48.3
|
|
6
10
|
|
|
7
11
|
- A task an agent opens for itself is taken up at once. The server never rings an agent with its own write, so the inbox's held read used to wait for unrelated mail before the task woke the agent (minutes in practice). The inbox loop now reads again as soon as `task_create` opens a task assigned to the agent. `InboxLoopHandle.rereadNow()` does the same for any host.
|
package/dist/Agent.d.ts
CHANGED
|
@@ -361,6 +361,13 @@ export declare class Agent {
|
|
|
361
361
|
* marked rather than repeated.
|
|
362
362
|
*/
|
|
363
363
|
private bucketContents;
|
|
364
|
+
/**
|
|
365
|
+
* Keeps a bucket's notes honest across revisions. The notes carry over a
|
|
366
|
+
* join or a leave. When an item the notes were written under is no longer
|
|
367
|
+
* readable in the bucket, the notes are cleared, since they may hold what
|
|
368
|
+
* came from it. The items seen are kept beside the notes.
|
|
369
|
+
*/
|
|
370
|
+
private syncBucketNotes;
|
|
364
371
|
private memoryForWake;
|
|
365
372
|
/**
|
|
366
373
|
* A chat-lane session that still carries a cancelled hire from a previous
|
package/dist/Agent.js
CHANGED
|
@@ -56,6 +56,7 @@ async function loadConnectionPool() {
|
|
|
56
56
|
const mod = await import(/* @vite-ignore */ modPath);
|
|
57
57
|
return mod.ConnectionPool;
|
|
58
58
|
}
|
|
59
|
+
const BUCKET_MARKER_KEY = '__bucket_items';
|
|
59
60
|
const DEFAULT_SESSION_RESOLVER = (normalized) => normalized.event.agreementId ? `agrn-${normalized.event.agreementId}`
|
|
60
61
|
: normalized.event.bucket ? `bkt-${normalized.event.bucket.bucketId}`
|
|
61
62
|
: normalized.event.messageId ? `msgn-${normalized.event.messageId}` : null;
|
|
@@ -776,12 +777,46 @@ export class Agent {
|
|
|
776
777
|
...(action?.kind === 'message' ? { current: action.id } : {}),
|
|
777
778
|
});
|
|
778
779
|
}
|
|
780
|
+
/**
|
|
781
|
+
* Keeps a bucket's notes honest across revisions. The notes carry over a
|
|
782
|
+
* join or a leave. When an item the notes were written under is no longer
|
|
783
|
+
* readable in the bucket, the notes are cleared, since they may hold what
|
|
784
|
+
* came from it. The items seen are kept beside the notes.
|
|
785
|
+
*/
|
|
786
|
+
async syncBucketNotes(bucket) {
|
|
787
|
+
const notes = partitionMemoryStore(this.memory, `bucket:${bucket.bucketId}`);
|
|
788
|
+
const marker = (await notes.get(BUCKET_MARKER_KEY));
|
|
789
|
+
if (marker && marker.revision === bucket.revision)
|
|
790
|
+
return;
|
|
791
|
+
let items;
|
|
792
|
+
try {
|
|
793
|
+
const c = await this.bucketContents(bucket);
|
|
794
|
+
items = [
|
|
795
|
+
...c.threads.map((t) => `thread:${t.rootMessageId}`),
|
|
796
|
+
...c.artifacts.map((a) => `artifact:${a.artifactId}`),
|
|
797
|
+
...c.tasks.map((t) => `task:${t.taskId}`),
|
|
798
|
+
];
|
|
799
|
+
}
|
|
800
|
+
catch {
|
|
801
|
+
items = undefined;
|
|
802
|
+
}
|
|
803
|
+
const itemLeft = !items || (marker ? marker.items.some((i) => !items.includes(i)) : false);
|
|
804
|
+
if (itemLeft) {
|
|
805
|
+
for (const row of await notes.list(''))
|
|
806
|
+
if (row.key !== BUCKET_MARKER_KEY)
|
|
807
|
+
await notes.delete?.(row.key);
|
|
808
|
+
}
|
|
809
|
+
if (items)
|
|
810
|
+
await notes.put(BUCKET_MARKER_KEY, { revision: bucket.revision, items });
|
|
811
|
+
else
|
|
812
|
+
await notes.delete?.(BUCKET_MARKER_KEY);
|
|
813
|
+
}
|
|
779
814
|
memoryForWake(session, event) {
|
|
780
815
|
const execution = currentWorkExecution();
|
|
781
|
-
// A bucket
|
|
782
|
-
//
|
|
816
|
+
// A bucket keeps its notes across revisions: someone joining or leaving
|
|
817
|
+
// does not empty them. `syncBucketNotes` clears them when an item left.
|
|
783
818
|
if (execution && session.bucket)
|
|
784
|
-
return partitionMemoryStore(this.memory, `bucket:${session.bucket.bucketId}
|
|
819
|
+
return partitionMemoryStore(this.memory, `bucket:${session.bucket.bucketId}`);
|
|
785
820
|
if (execution)
|
|
786
821
|
return partitionMemoryStore(this.memory, `execution:${execution.contextId}`);
|
|
787
822
|
const fromEvent = hireIdsFromEvent(event);
|
|
@@ -1216,6 +1251,8 @@ export class Agent {
|
|
|
1216
1251
|
}
|
|
1217
1252
|
if (runnable.length !== frames.length)
|
|
1218
1253
|
frame = runnable.length === 1 ? runnable[0] : { type: 'batch', events: runnable };
|
|
1254
|
+
if (session.bucket && currentWorkExecution())
|
|
1255
|
+
await this.syncBucketNotes(session.bucket);
|
|
1219
1256
|
const memory = this.memoryForWake(session, frame);
|
|
1220
1257
|
const wakeTaskId = workScopeFromWake(frame, session.sessionId).taskId;
|
|
1221
1258
|
// A checkout agent gets its box before the brain runs: the task names the
|
|
@@ -21,9 +21,10 @@ export interface LaneWake {
|
|
|
21
21
|
* A wake whose action is a message or a task in a bucket the agent is in gets
|
|
22
22
|
* one; a task wake is a message wake with a bucket. Wakes in one bucket run
|
|
23
23
|
* on its lane one at a time, in order, and the agent's notes for the bucket
|
|
24
|
-
* carry over between them. The revision goes up
|
|
25
|
-
* changes or an item leaves, which starts a new
|
|
26
|
-
* only
|
|
24
|
+
* carry over between them, and over a join or a leave. The revision goes up
|
|
25
|
+
* when the bucket's audience changes or an item leaves, which starts a new
|
|
26
|
+
* lane. The notes are cleared only when an item they were written under is
|
|
27
|
+
* no longer readable in the bucket.
|
|
27
28
|
*/
|
|
28
29
|
export declare function bucketLaneId(execution: LaneExecution | undefined, bucket: LaneBucket | undefined): string | undefined;
|
|
29
30
|
/** Run `work` as the wake of `laneKey`, so a lane named inside it names this one. */
|
package/dist/platform/laneKey.js
CHANGED
|
@@ -7,9 +7,10 @@ import { currentWorkExecution } from '@ziggs-ai/api-client';
|
|
|
7
7
|
* A wake whose action is a message or a task in a bucket the agent is in gets
|
|
8
8
|
* one; a task wake is a message wake with a bucket. Wakes in one bucket run
|
|
9
9
|
* on its lane one at a time, in order, and the agent's notes for the bucket
|
|
10
|
-
* carry over between them. The revision goes up
|
|
11
|
-
* changes or an item leaves, which starts a new
|
|
12
|
-
* only
|
|
10
|
+
* carry over between them, and over a join or a leave. The revision goes up
|
|
11
|
+
* when the bucket's audience changes or an item leaves, which starts a new
|
|
12
|
+
* lane. The notes are cleared only when an item they were written under is
|
|
13
|
+
* no longer readable in the bucket.
|
|
13
14
|
*/
|
|
14
15
|
export function bucketLaneId(execution, bucket) {
|
|
15
16
|
const kind = execution?.action?.kind;
|
package/dist/tools/defineTool.js
CHANGED
|
@@ -19,6 +19,15 @@ function convertField(value) {
|
|
|
19
19
|
const { required: isReq, ...rest } = v;
|
|
20
20
|
return { schema: rest, required: !!isReq };
|
|
21
21
|
}
|
|
22
|
+
// An object whose fields are named (a capability param with `properties`):
|
|
23
|
+
// convert each field the same way, and take no other key.
|
|
24
|
+
if (v['type'] === 'object' && v['properties'] && typeof v['properties'] === 'object') {
|
|
25
|
+
const { required: isReq, properties, type: _type, ...rest } = v;
|
|
26
|
+
return {
|
|
27
|
+
schema: { ...rest, ...convertObject(properties), additionalProperties: false },
|
|
28
|
+
required: !!isReq,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
22
31
|
if (v['type'] === 'array' || v['type'] === 'object') {
|
|
23
32
|
const { required: isReq, ...rest } = v;
|
|
24
33
|
return { schema: rest, required: !!isReq };
|
|
@@ -66,7 +75,9 @@ export function defineTool(name, params, handler, options = {}) {
|
|
|
66
75
|
// passed while the handler quietly ignored what the model asked for.
|
|
67
76
|
// Nested objects stay open: the typo class this guards against is at the
|
|
68
77
|
// call surface the model writes, and closing nested payloads (task result,
|
|
69
|
-
// plan) would reject shapes the backend accepts.
|
|
78
|
+
// plan) would reject shapes the backend accepts. The exception is a param
|
|
79
|
+
// that names its fields (`properties`): it lists exactly the keys the
|
|
80
|
+
// backend accepts, so it is closed too.
|
|
70
81
|
const parameters = { ...convertObject(params || {}), additionalProperties: false };
|
|
71
82
|
const fn = { name, parameters };
|
|
72
83
|
if (options.description)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ziggs-ai/agent-sdk",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.6",
|
|
4
4
|
"description": "Agent framework SDK for building autonomous agents on the Ziggs platform",
|
|
5
5
|
"homepage": "https://ziggsai.com/docs",
|
|
6
6
|
"bugs": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@anthropic-ai/claude-agent-sdk": "^0.3.284",
|
|
31
31
|
"@anthropic-ai/sdk": "^0.110.0",
|
|
32
32
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
33
|
-
"@ziggs-ai/api-client": "0.42.
|
|
34
|
-
"@ziggs-ai/contracts": "0.
|
|
33
|
+
"@ziggs-ai/api-client": "0.42.5",
|
|
34
|
+
"@ziggs-ai/contracts": "0.50.1",
|
|
35
35
|
"ajv": "^8.17.1",
|
|
36
36
|
"dotenv": "^17.2.3",
|
|
37
37
|
"openai": "^4.0.0",
|