@ziggs-ai/agent-sdk 0.46.5 → 0.46.8
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/Agent.d.ts +2 -1
- package/dist/Agent.js +23 -10
- package/dist/brain/claudeSdkTools.js +5 -3
- package/package.json +2 -2
package/dist/Agent.d.ts
CHANGED
|
@@ -295,7 +295,8 @@ export declare class Agent {
|
|
|
295
295
|
private readonly wakeDestination;
|
|
296
296
|
private readonly outboundMessages;
|
|
297
297
|
private readonly confirmedPlanVersions;
|
|
298
|
-
|
|
298
|
+
/** Live connection providers, per execution: what a grant lists depends on the party the wake acts for. */
|
|
299
|
+
private readonly grantProviderCache;
|
|
299
300
|
/** The checkout box each lane holds while its wake runs. */
|
|
300
301
|
private checkoutByLane;
|
|
301
302
|
constructor(options?: AgentOptions);
|
package/dist/Agent.js
CHANGED
|
@@ -249,7 +249,8 @@ export class Agent {
|
|
|
249
249
|
wakeDestination = new AsyncLocalStorage();
|
|
250
250
|
outboundMessages = new SeenMessages();
|
|
251
251
|
confirmedPlanVersions = new SeenMessages();
|
|
252
|
-
|
|
252
|
+
/** Live connection providers, per execution: what a grant lists depends on the party the wake acts for. */
|
|
253
|
+
grantProviderCache = new Map();
|
|
253
254
|
/** The checkout box each lane holds while its wake runs. */
|
|
254
255
|
checkoutByLane = new Map();
|
|
255
256
|
constructor(options = {}) {
|
|
@@ -905,8 +906,12 @@ export class Agent {
|
|
|
905
906
|
return reported !== undefined && reported !== null && reported !== '';
|
|
906
907
|
}
|
|
907
908
|
/** Providers of this agent's live connection grants. Its own seam, so the gate below is testable without a backend. */
|
|
908
|
-
async _listGrantProviders(operatorKey, agentId) {
|
|
909
|
-
|
|
909
|
+
async _listGrantProviders(operatorKey, agentId, execution) {
|
|
910
|
+
// The server answers for the party this call acts for. Without the wake's
|
|
911
|
+
// execution it answers for the agent's own operator, so a grant a customer
|
|
912
|
+
// gave for a hire is never listed and every hired agent reads as unconnected.
|
|
913
|
+
const read = () => new ConnectionsClient(operatorKey, agentId).listForHolder();
|
|
914
|
+
const groups = execution ? await withWorkExecution(execution, read) : await read();
|
|
910
915
|
return groups.filter((g) => (g.grants ?? []).length > 0).map((g) => g.provider);
|
|
911
916
|
}
|
|
912
917
|
/**
|
|
@@ -914,13 +919,18 @@ export class Agent {
|
|
|
914
919
|
* several in seconds — but hire comes before grant, so a grant arriving
|
|
915
920
|
* mid-engagement has to take effect without a restart.
|
|
916
921
|
*/
|
|
917
|
-
async _grantProvidersCached(operatorKey, agentId) {
|
|
922
|
+
async _grantProvidersCached(operatorKey, agentId, execution) {
|
|
918
923
|
const now = Date.now();
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
+
const key = execution?.contextId ?? '';
|
|
925
|
+
const cached = this.grantProviderCache.get(key);
|
|
926
|
+
if (cached && now - cached.at < 30_000)
|
|
927
|
+
return cached.providers;
|
|
928
|
+
const providers = await this._listGrantProviders(operatorKey, agentId, execution);
|
|
929
|
+
this.grantProviderCache.set(key, { at: now, providers });
|
|
930
|
+
// One entry per live execution is enough; drop the stale ones as they pass.
|
|
931
|
+
for (const [k, v] of this.grantProviderCache)
|
|
932
|
+
if (now - v.at >= 30_000)
|
|
933
|
+
this.grantProviderCache.delete(k);
|
|
924
934
|
return providers;
|
|
925
935
|
}
|
|
926
936
|
/**
|
|
@@ -947,7 +957,10 @@ export class Agent {
|
|
|
947
957
|
return false;
|
|
948
958
|
let providers;
|
|
949
959
|
try {
|
|
950
|
-
|
|
960
|
+
// The grant a customer gave for a hire is listed to the wake that works that hire.
|
|
961
|
+
const execution = this.sessions?.get(_laneKey)?.executionContext ??
|
|
962
|
+
(_event?.executionContext);
|
|
963
|
+
providers = await this._grantProvidersCached(operatorKey, agentId, execution);
|
|
951
964
|
}
|
|
952
965
|
catch (err) {
|
|
953
966
|
// A grants read that failed is not proof the grant is missing, and failing
|
|
@@ -78,10 +78,12 @@ export const messageSendTool = defineTool('message_send', { command: { type: 'ob
|
|
|
78
78
|
export { listTasksTool, cancelTaskTool, delegateTaskTool };
|
|
79
79
|
/**
|
|
80
80
|
* A new conversation starts in a bucket made on purpose: the agent creates one
|
|
81
|
-
* with the people it is for and sends inside it.
|
|
82
|
-
*
|
|
81
|
+
* with the people it is for and sends inside it. A file reaches people the same
|
|
82
|
+
* way, by being put in a bucket with them: `bucket_create` takes items, and
|
|
83
|
+
* `bucket_insert` puts one in a bucket that exists. Every hosted agent has these
|
|
84
|
+
* three, the same tool objects `BUCKET_TOOLS` hands out.
|
|
83
85
|
*/
|
|
84
|
-
const BUCKET_DEFAULTS = BUCKET_TOOLS.filter((tool) => ['bucket_create', 'bucket_send'].includes(String(tool.schema.function.name)));
|
|
86
|
+
const BUCKET_DEFAULTS = BUCKET_TOOLS.filter((tool) => ['bucket_create', 'bucket_send', 'bucket_insert'].includes(String(tool.schema.function.name)));
|
|
85
87
|
export const CLAUDE_SDK_TOOLS = [
|
|
86
88
|
contextSnapshotTool,
|
|
87
89
|
messageSendTool,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ziggs-ai/agent-sdk",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.8",
|
|
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,7 +30,7 @@
|
|
|
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.40.
|
|
33
|
+
"@ziggs-ai/api-client": "0.40.9",
|
|
34
34
|
"@ziggs-ai/contracts": "0.48.1",
|
|
35
35
|
"ajv": "^8.17.1",
|
|
36
36
|
"dotenv": "^17.2.3",
|