@sonzai-labs/agents 1.0.1 → 1.0.3
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/index.cjs +179 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +197 -1
- package/dist/index.d.ts +197 -1
- package/dist/index.js +179 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1464,6 +1464,50 @@ var Agents = class {
|
|
|
1464
1464
|
async deleteCustomTool(agentId, toolName) {
|
|
1465
1465
|
return this.http.delete(`/api/v1/agents/${agentId}/tools/${toolName}`);
|
|
1466
1466
|
}
|
|
1467
|
+
// -- Process (full pipeline) --
|
|
1468
|
+
/**
|
|
1469
|
+
* Run the full Context Engine pipeline on conversation messages without
|
|
1470
|
+
* generating a chat response. Extracts side effects via LLM, processes
|
|
1471
|
+
* behavioral updates (mood, personality, habits, interests, relationships),
|
|
1472
|
+
* stores memories, and runs session-end analysis.
|
|
1473
|
+
*/
|
|
1474
|
+
async process(agentId, options) {
|
|
1475
|
+
requireNonEmpty(agentId, "agentId");
|
|
1476
|
+
requireNonEmpty(options.userId, "options.userId");
|
|
1477
|
+
const body = {
|
|
1478
|
+
userId: options.userId,
|
|
1479
|
+
messages: options.messages
|
|
1480
|
+
};
|
|
1481
|
+
if (options.sessionId) body.sessionId = options.sessionId;
|
|
1482
|
+
if (options.instanceId) body.instanceId = options.instanceId;
|
|
1483
|
+
if (options.provider) body.provider = options.provider;
|
|
1484
|
+
if (options.model) body.model = options.model;
|
|
1485
|
+
return this.http.post(`/api/v1/agents/${agentId}/process`, body);
|
|
1486
|
+
}
|
|
1487
|
+
/** Get available LLM providers and models for the /process endpoint. */
|
|
1488
|
+
async getModels(agentId) {
|
|
1489
|
+
return this.http.get(`/api/v1/agents/${agentId}/models`);
|
|
1490
|
+
}
|
|
1491
|
+
// -- Context (single-call enriched context) --
|
|
1492
|
+
/**
|
|
1493
|
+
* Get the full enriched agent context in a single call.
|
|
1494
|
+
* Returns all 7 layers (personality, mood, memory, relationships, goals, etc.)
|
|
1495
|
+
* This replaces multiple individual API calls with one round-trip.
|
|
1496
|
+
*/
|
|
1497
|
+
async getContext(agentId, options) {
|
|
1498
|
+
requireNonEmpty(agentId, "agentId");
|
|
1499
|
+
requireNonEmpty(options.userId, "options.userId");
|
|
1500
|
+
const params = { userId: options.userId };
|
|
1501
|
+
if (options.sessionId) params.sessionId = options.sessionId;
|
|
1502
|
+
if (options.instanceId) params.instanceId = options.instanceId;
|
|
1503
|
+
if (options.query) params.query = options.query;
|
|
1504
|
+
if (options.language) params.language = options.language;
|
|
1505
|
+
if (options.timezone) params.timezone = options.timezone;
|
|
1506
|
+
return this.http.get(
|
|
1507
|
+
`/api/v1/agents/${agentId}/context`,
|
|
1508
|
+
params
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1467
1511
|
// -- Consolidation --
|
|
1468
1512
|
/** Trigger memory consolidation for an agent. */
|
|
1469
1513
|
async consolidate(agentId, options) {
|
|
@@ -1510,6 +1554,30 @@ var Agents = class {
|
|
|
1510
1554
|
}
|
|
1511
1555
|
};
|
|
1512
1556
|
|
|
1557
|
+
// src/resources/custom-llm.ts
|
|
1558
|
+
var CustomLLM = class {
|
|
1559
|
+
constructor(http) {
|
|
1560
|
+
this.http = http;
|
|
1561
|
+
}
|
|
1562
|
+
/** Get the custom LLM config for a project. */
|
|
1563
|
+
async get(projectId) {
|
|
1564
|
+
return this.http.get(
|
|
1565
|
+
`/api/v1/projects/${projectId}/custom-llm`
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
/** Set or update the custom LLM config. */
|
|
1569
|
+
async set(projectId, options) {
|
|
1570
|
+
return this.http.put(
|
|
1571
|
+
`/api/v1/projects/${projectId}/custom-llm`,
|
|
1572
|
+
options
|
|
1573
|
+
);
|
|
1574
|
+
}
|
|
1575
|
+
/** Delete the custom LLM config. */
|
|
1576
|
+
async delete(projectId) {
|
|
1577
|
+
await this.http.delete(`/api/v1/projects/${projectId}/custom-llm`);
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
|
|
1513
1581
|
// src/resources/eval-runs.ts
|
|
1514
1582
|
var EvalRuns = class {
|
|
1515
1583
|
constructor(http) {
|
|
@@ -1814,6 +1882,72 @@ var Knowledge = class {
|
|
|
1814
1882
|
}
|
|
1815
1883
|
};
|
|
1816
1884
|
|
|
1885
|
+
// src/resources/project-config.ts
|
|
1886
|
+
var ProjectConfig = class {
|
|
1887
|
+
constructor(http) {
|
|
1888
|
+
this.http = http;
|
|
1889
|
+
}
|
|
1890
|
+
/** List all config entries for a project. */
|
|
1891
|
+
async list(projectId) {
|
|
1892
|
+
return this.http.get(
|
|
1893
|
+
`/api/v1/projects/${projectId}/config`
|
|
1894
|
+
);
|
|
1895
|
+
}
|
|
1896
|
+
/** Get a config value by key. Returns the raw JSON value. */
|
|
1897
|
+
async get(projectId, key) {
|
|
1898
|
+
return this.http.get(
|
|
1899
|
+
`/api/v1/projects/${projectId}/config/${key}`
|
|
1900
|
+
);
|
|
1901
|
+
}
|
|
1902
|
+
/** Set a config value. Body must be valid JSON. */
|
|
1903
|
+
async set(projectId, key, value) {
|
|
1904
|
+
return this.http.put(
|
|
1905
|
+
`/api/v1/projects/${projectId}/config/${key}`,
|
|
1906
|
+
value
|
|
1907
|
+
);
|
|
1908
|
+
}
|
|
1909
|
+
/** Delete a config entry. */
|
|
1910
|
+
async delete(projectId, key) {
|
|
1911
|
+
await this.http.delete(`/api/v1/projects/${projectId}/config/${key}`);
|
|
1912
|
+
}
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1915
|
+
// src/resources/project-notifications.ts
|
|
1916
|
+
var ProjectNotifications = class {
|
|
1917
|
+
constructor(http) {
|
|
1918
|
+
this.http = http;
|
|
1919
|
+
}
|
|
1920
|
+
/** List pending notifications for a project. */
|
|
1921
|
+
async list(projectId, options = {}) {
|
|
1922
|
+
const params = {};
|
|
1923
|
+
if (options.agentId) params.agent_id = options.agentId;
|
|
1924
|
+
if (options.eventType) params.event_type = options.eventType;
|
|
1925
|
+
if (options.limit) params.limit = String(options.limit);
|
|
1926
|
+
return this.http.get(
|
|
1927
|
+
`/api/v1/projects/${projectId}/notifications`,
|
|
1928
|
+
params
|
|
1929
|
+
);
|
|
1930
|
+
}
|
|
1931
|
+
/** Acknowledge specific notifications by ID. */
|
|
1932
|
+
async acknowledge(projectId, options) {
|
|
1933
|
+
return this.http.post(
|
|
1934
|
+
`/api/v1/projects/${projectId}/notifications/acknowledge`,
|
|
1935
|
+
{ notification_ids: options.notificationIds }
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1938
|
+
/** Acknowledge all pending notifications for a project. */
|
|
1939
|
+
async acknowledgeAll(projectId, options = {}) {
|
|
1940
|
+
const params = {};
|
|
1941
|
+
if (options.agentId) params.agent_id = options.agentId;
|
|
1942
|
+
if (options.eventType) params.event_type = options.eventType;
|
|
1943
|
+
return this.http.post(
|
|
1944
|
+
`/api/v1/projects/${projectId}/notifications/acknowledge-all`,
|
|
1945
|
+
{},
|
|
1946
|
+
params
|
|
1947
|
+
);
|
|
1948
|
+
}
|
|
1949
|
+
};
|
|
1950
|
+
|
|
1817
1951
|
// src/resources/webhooks.ts
|
|
1818
1952
|
var Webhooks = class {
|
|
1819
1953
|
constructor(http) {
|
|
@@ -1850,6 +1984,42 @@ var Webhooks = class {
|
|
|
1850
1984
|
`/api/v1/webhooks/${eventType}/rotate-secret`
|
|
1851
1985
|
);
|
|
1852
1986
|
}
|
|
1987
|
+
// -- Project-scoped webhooks --
|
|
1988
|
+
/** Register (or update) a webhook for a specific project and event type. */
|
|
1989
|
+
async registerForProject(projectId, eventType, options) {
|
|
1990
|
+
const body = {
|
|
1991
|
+
webhook_url: options.webhookUrl
|
|
1992
|
+
};
|
|
1993
|
+
if (options.authHeader) body.auth_header = options.authHeader;
|
|
1994
|
+
return this.http.put(
|
|
1995
|
+
`/api/v1/projects/${projectId}/webhooks/${eventType}`,
|
|
1996
|
+
body
|
|
1997
|
+
);
|
|
1998
|
+
}
|
|
1999
|
+
/** List all webhooks for a project. */
|
|
2000
|
+
async listForProject(projectId) {
|
|
2001
|
+
return this.http.get(
|
|
2002
|
+
`/api/v1/projects/${projectId}/webhooks`
|
|
2003
|
+
);
|
|
2004
|
+
}
|
|
2005
|
+
/** Delete a webhook for a project event type. */
|
|
2006
|
+
async deleteForProject(projectId, eventType) {
|
|
2007
|
+
await this.http.delete(
|
|
2008
|
+
`/api/v1/projects/${projectId}/webhooks/${eventType}`
|
|
2009
|
+
);
|
|
2010
|
+
}
|
|
2011
|
+
/** List delivery attempts for a project webhook event type. */
|
|
2012
|
+
async listDeliveryAttemptsForProject(projectId, eventType) {
|
|
2013
|
+
return this.http.get(
|
|
2014
|
+
`/api/v1/projects/${projectId}/webhooks/${eventType}/attempts`
|
|
2015
|
+
);
|
|
2016
|
+
}
|
|
2017
|
+
/** Rotate the signing secret for a project webhook event type. */
|
|
2018
|
+
async rotateSecretForProject(projectId, eventType) {
|
|
2019
|
+
return this.http.post(
|
|
2020
|
+
`/api/v1/projects/${projectId}/webhooks/${eventType}/rotate-secret`
|
|
2021
|
+
);
|
|
2022
|
+
}
|
|
1853
2023
|
};
|
|
1854
2024
|
|
|
1855
2025
|
// src/client.ts
|
|
@@ -1896,6 +2066,12 @@ var Sonzai = class {
|
|
|
1896
2066
|
evalRuns;
|
|
1897
2067
|
voices;
|
|
1898
2068
|
webhooks;
|
|
2069
|
+
/** Project-scoped configuration (key-value store). */
|
|
2070
|
+
projectConfig;
|
|
2071
|
+
/** Project-scoped custom LLM provider configuration. */
|
|
2072
|
+
customLLM;
|
|
2073
|
+
/** Project-scoped notification polling for game backends. */
|
|
2074
|
+
projectNotifications;
|
|
1899
2075
|
http;
|
|
1900
2076
|
constructor(config) {
|
|
1901
2077
|
const apiKey = resolveApiKey(config);
|
|
@@ -1912,6 +2088,9 @@ var Sonzai = class {
|
|
|
1912
2088
|
this.evalRuns = new EvalRuns(this.http);
|
|
1913
2089
|
this.voices = new Voices(this.http);
|
|
1914
2090
|
this.webhooks = new Webhooks(this.http);
|
|
2091
|
+
this.projectConfig = new ProjectConfig(this.http);
|
|
2092
|
+
this.customLLM = new CustomLLM(this.http);
|
|
2093
|
+
this.projectNotifications = new ProjectNotifications(this.http);
|
|
1915
2094
|
}
|
|
1916
2095
|
};
|
|
1917
2096
|
|