@stackbone/sdk 0.1.0-alpha.4 → 0.1.0-alpha.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 +12 -0
- package/index.cjs +9292 -363
- package/index.cjs.map +1 -1
- package/index.d.cts +319 -123
- package/index.d.ts +319 -123
- package/index.js +9293 -364
- package/index.js.map +1 -1
- package/observability/index.cjs +1 -1
- package/observability/index.cjs.map +1 -1
- package/observability/index.d.cts +1 -1
- package/observability/index.d.ts +1 -1
- package/observability/index.js +1 -1
- package/observability/index.js.map +1 -1
- package/package.json +2 -2
- package/stackbone-sdk-0.1.0-alpha.6.tgz +0 -0
- package/stackbone-sdk-0.1.0-alpha.4.tgz +0 -0
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PublishJobResponse, ScheduleJobResponse, UnscheduleJobResponse, ListSchedulesResponse, ContractResponse } from '@stackbone/validators';
|
|
2
|
-
import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
|
1
|
+
import { AgentConnectionListResponse, InvokeConnectorActionResponse, PublishJobResponse, ScheduleJobResponse, UnscheduleJobResponse, ListSchedulesResponse, ContractResponse } from '@stackbone/validators';
|
|
3
2
|
import { Sql } from 'postgres';
|
|
3
|
+
import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
|
4
4
|
import { IngestJobWriter, IngestRequest, IngestResponse, RagIngestProgress, DeleteOptions, DeleteResponse, RetrieveRequest, RetrieveHit, ChunkOptions, ParseInput, ParseOptions } from '@stackbone/rag-core';
|
|
5
5
|
export { ChunkOptions, ChunkStrategy, DeleteOptions, DeleteResponse, IngestChunk, IngestRequest, IngestRequestAutoEmbed, IngestRequestPrecomputed, IngestResponse, ParseInput, ParseOptions, RagIngestProgress, RetrieveHit, RetrieveRequest, RetrieveRequestAutoEmbed, RetrieveRequestPrecomputed } from '@stackbone/rag-core';
|
|
6
6
|
import OpenAI from 'openai';
|
|
@@ -77,7 +77,7 @@ interface ClientConfig {
|
|
|
77
77
|
* RAG-related defaults parsed from `agent.yaml.rag` by the CLI/orchestrator
|
|
78
78
|
* and forwarded here. The SDK never reads `agent.yaml` itself — keeping
|
|
79
79
|
* filesystem ownership in the CLI. Defaults follow ADR
|
|
80
|
-
* `2026-05-
|
|
80
|
+
* `2026-06-05-rag` (D2/D6).
|
|
81
81
|
*/
|
|
82
82
|
rag?: {
|
|
83
83
|
/**
|
|
@@ -267,6 +267,18 @@ declare const SDK_ERROR_CODE_PREFIXES: {
|
|
|
267
267
|
* only calls these endpoints.
|
|
268
268
|
*/
|
|
269
269
|
readonly queues: readonly ["forbidden", "invalid_request", "invalid_response", "not_found", "rate_limited", "timeout", "unauthorized", "unavailable"];
|
|
270
|
+
/**
|
|
271
|
+
* `client.connections` — the agent → control plane connectors proxy. Both
|
|
272
|
+
* methods (`list`, `invoke`) hit the `/api/v1/agent/connections/*` endpoints
|
|
273
|
+
* over `HttpClient`, so the full status→domain remap (`connections_unauthorized`,
|
|
274
|
+
* `connections_not_found`, `connections_unavailable`, …) is in play. The agent
|
|
275
|
+
* never holds a credential — it only calls these endpoints; the control plane
|
|
276
|
+
* resolves the workspace connection and runs the connector action. `ambiguous`
|
|
277
|
+
* is the 409 the proxy returns when the workspace holds several connections of
|
|
278
|
+
* the same connector and `invoke` carried no `{ connection }` selector to pick
|
|
279
|
+
* one — the error message lists the candidate names/ids so the author can.
|
|
280
|
+
*/
|
|
281
|
+
readonly connections: readonly ["ambiguous", "forbidden", "invalid_request", "invalid_response", "not_found", "rate_limited", "timeout", "unauthorized", "unavailable"];
|
|
270
282
|
/**
|
|
271
283
|
* `client.prompts` — AGENT-LOCAL facade. Reads
|
|
272
284
|
* `stackbone_platform.prompts` / `prompt_versions` over the shared
|
|
@@ -471,6 +483,43 @@ declare class DatabaseModule {
|
|
|
471
483
|
delete: DrizzleClient['delete'];
|
|
472
484
|
execute: DrizzleClient['execute'];
|
|
473
485
|
transaction: DrizzleClient['transaction'];
|
|
486
|
+
/**
|
|
487
|
+
* Cross-surface raw-SQL runner carrying the SAME cold-start resilience the
|
|
488
|
+
* query-builder verbs above get. Sibling agent-local surfaces (`approval`,
|
|
489
|
+
* `config`, `secrets`, `prompts`) that issue tagged-template queries over the
|
|
490
|
+
* shared postgres-js `Sql` MUST execute them through this instead of caching
|
|
491
|
+
* `shared().$client` once and calling it directly. Otherwise a dead pooled
|
|
492
|
+
* socket — Fly Machines suspending the Machine between invokes, or a
|
|
493
|
+
* WSL2/Docker localhost relay dropping an idle connection during a long LLM
|
|
494
|
+
* step — surfaces as an unretried `CONNECTION_ENDED`/`ECONNRESET`. That is
|
|
495
|
+
* exactly the asymmetry that let `client.approval.request` fail while the
|
|
496
|
+
* `client.database.insert` right before it recovered.
|
|
497
|
+
*
|
|
498
|
+
* `fn` receives a FRESH `$client` on each attempt, so the single retry runs
|
|
499
|
+
* against the rebuilt pool. Whole-operation granularity is replayed as a
|
|
500
|
+
* unit — pass a multi-statement `sql.begin(...)` transaction or a helper that
|
|
501
|
+
* fires several queries and the replay re-runs all of it; postgres-js never
|
|
502
|
+
* commits a half-applied tx, so that is safe. SQLSTATE application errors
|
|
503
|
+
* pass straight through without a retry. Like `shared()`/`raw()`, the
|
|
504
|
+
* contract gate is intentionally NOT consulted here — gating surfaces gate at
|
|
505
|
+
* their own call sites.
|
|
506
|
+
*/
|
|
507
|
+
runShared<T>(fn: (sql: Sql) => Promise<T> | T): Promise<T>;
|
|
508
|
+
/**
|
|
509
|
+
* `Result`-shaped sibling of `runShared` for surfaces whose driver swallows
|
|
510
|
+
* the dead-socket error into a returned `Result.err.cause` instead of
|
|
511
|
+
* throwing it — today only `client.rag`, whose `RagPipeline` returns a
|
|
512
|
+
* `Result` rather than throwing. `attempt` runs once; if it comes back with a
|
|
513
|
+
* pool-terminated `cause`, the pool is rebuilt and `attempt` replays exactly
|
|
514
|
+
* once, then its result (success or the fresh error) is returned verbatim.
|
|
515
|
+
* The `Result` contract is preserved end to end: a still-dead socket on the
|
|
516
|
+
* replay surfaces as the surface's own `Result.err`, never as a raw throw.
|
|
517
|
+
*/
|
|
518
|
+
runSharedResult<T extends {
|
|
519
|
+
error?: {
|
|
520
|
+
cause?: unknown;
|
|
521
|
+
} | null;
|
|
522
|
+
}>(attempt: () => Promise<T>): Promise<T>;
|
|
474
523
|
/**
|
|
475
524
|
* Canonical accessor for the **shared-handles pattern**. Returns the
|
|
476
525
|
* process-wide Drizzle handle backing `client.database`. Cross-surface
|
|
@@ -937,7 +986,7 @@ interface IngestAsyncHandle {
|
|
|
937
986
|
* Implementation note: `RagModule` is a thin facade over `RagPipeline`. The
|
|
938
987
|
* pipeline owns parse → chunk → embed → persist; the facade resolves the
|
|
939
988
|
* shared `client.database` pool, builds an `Embedder` on demand, and maps
|
|
940
|
-
* configuration errors. See ADR `2026-05-
|
|
989
|
+
* configuration errors. See ADR `2026-06-05-rag`.
|
|
941
990
|
*
|
|
942
991
|
* Connection ownership: this module never opens its own postgres pool. It
|
|
943
992
|
* reaches the underlying `postgres-js` `Sql` through the **shared-handles
|
|
@@ -1180,124 +1229,6 @@ declare class StorageBucket {
|
|
|
1180
1229
|
private resolve;
|
|
1181
1230
|
}
|
|
1182
1231
|
|
|
1183
|
-
/**
|
|
1184
|
-
* Where a memory lives. Default `'user'`. `'session'` is short-lived and
|
|
1185
|
-
* collapsed (or dropped) by `endSession()`; `'agent'` is shared across every
|
|
1186
|
-
* user of the agent.
|
|
1187
|
-
*/
|
|
1188
|
-
type MemoryScope = 'user' | 'session' | 'agent';
|
|
1189
|
-
/**
|
|
1190
|
-
* Either raw text or an OpenAI-shaped conversation. The future mem0 backend
|
|
1191
|
-
* accepts both: strings ingest verbatim, message arrays are summarised into
|
|
1192
|
-
* one or more facts.
|
|
1193
|
-
*/
|
|
1194
|
-
type MemoryContent = string | ChatCompletionMessageParam[];
|
|
1195
|
-
interface AddMemoryRequest {
|
|
1196
|
-
userId: string;
|
|
1197
|
-
/** Conversation/session bucket. Required when `scope: 'session'`. */
|
|
1198
|
-
sessionId?: string;
|
|
1199
|
-
/** Default `'user'`. */
|
|
1200
|
-
scope?: MemoryScope;
|
|
1201
|
-
metadata?: Record<string, unknown>;
|
|
1202
|
-
}
|
|
1203
|
-
interface MemoryItem {
|
|
1204
|
-
id: string;
|
|
1205
|
-
content: string;
|
|
1206
|
-
userId: string;
|
|
1207
|
-
sessionId?: string;
|
|
1208
|
-
scope: MemoryScope;
|
|
1209
|
-
metadata?: Record<string, unknown>;
|
|
1210
|
-
/** ISO 8601 UTC timestamp. */
|
|
1211
|
-
createdAt: string;
|
|
1212
|
-
updatedAt: string;
|
|
1213
|
-
}
|
|
1214
|
-
interface SearchMemoryOptions {
|
|
1215
|
-
userId?: string;
|
|
1216
|
-
sessionId?: string;
|
|
1217
|
-
/** 1..100. Default 10. */
|
|
1218
|
-
limit?: number;
|
|
1219
|
-
/** Minimum cosine similarity in [0, 1]. Hits below this are dropped. */
|
|
1220
|
-
threshold?: number;
|
|
1221
|
-
/** Metadata predicates AND-ed to the semantic match. */
|
|
1222
|
-
filters?: Record<string, unknown>;
|
|
1223
|
-
/** Restrict the search to a subset of scopes. Default: every scope. */
|
|
1224
|
-
includeScopes?: readonly MemoryScope[];
|
|
1225
|
-
}
|
|
1226
|
-
interface MemoryHit extends MemoryItem {
|
|
1227
|
-
/** Cosine similarity in [0, 1]. */
|
|
1228
|
-
score: number;
|
|
1229
|
-
}
|
|
1230
|
-
interface ListMemoryRequest {
|
|
1231
|
-
userId: string;
|
|
1232
|
-
/** 1..100. Default 50. */
|
|
1233
|
-
limit?: number;
|
|
1234
|
-
cursor?: string;
|
|
1235
|
-
}
|
|
1236
|
-
interface ListMemoryResult {
|
|
1237
|
-
items: readonly MemoryItem[];
|
|
1238
|
-
nextCursor?: string;
|
|
1239
|
-
}
|
|
1240
|
-
interface UpdateMemoryOptions {
|
|
1241
|
-
content?: string;
|
|
1242
|
-
/** Shallow-merged onto the existing metadata (mem0 semantics). */
|
|
1243
|
-
metadata?: Record<string, unknown>;
|
|
1244
|
-
}
|
|
1245
|
-
interface DeleteAllMemoryRequest {
|
|
1246
|
-
userId: string;
|
|
1247
|
-
}
|
|
1248
|
-
type MemoryHistoryEvent = 'created' | 'updated' | 'accessed' | 'deleted';
|
|
1249
|
-
interface MemoryHistoryEntry {
|
|
1250
|
-
id: string;
|
|
1251
|
-
memoryId: string;
|
|
1252
|
-
event: MemoryHistoryEvent;
|
|
1253
|
-
/** ISO 8601 UTC timestamp. */
|
|
1254
|
-
at: string;
|
|
1255
|
-
/** Identifier of who triggered the event (user id, agent id, etc.). */
|
|
1256
|
-
actor?: string;
|
|
1257
|
-
/** Content snapshot before the event. Only set for `updated`/`deleted`. */
|
|
1258
|
-
before?: string;
|
|
1259
|
-
/** Content snapshot after the event. Only set for `created`/`updated`. */
|
|
1260
|
-
after?: string;
|
|
1261
|
-
metadata?: Record<string, unknown>;
|
|
1262
|
-
}
|
|
1263
|
-
interface EndSessionOptions {
|
|
1264
|
-
/** Persist session-scoped facts to long-term (`'user'`) memory before closing. Default `true`. */
|
|
1265
|
-
persist?: boolean;
|
|
1266
|
-
}
|
|
1267
|
-
interface EndSessionResult {
|
|
1268
|
-
sessionId: string;
|
|
1269
|
-
/** Number of session memories promoted to long-term storage. `0` when `persist: false`. */
|
|
1270
|
-
persisted: number;
|
|
1271
|
-
}
|
|
1272
|
-
/**
|
|
1273
|
-
* `client.memory` — long-term memory for the agent. The first iteration is a
|
|
1274
|
-
* scaffolding placeholder: every method returns `not_implemented`. The real
|
|
1275
|
-
* backend will be mem0 (`mem0ApiKey` / `MEM0_API_KEY`) and the public surface
|
|
1276
|
-
* defined here is the contract callers can already type against.
|
|
1277
|
-
*
|
|
1278
|
-
* Contract gating: not gated. Memory targets mem0 (a non-Stackbone partner),
|
|
1279
|
-
* so there is no Stackbone Agent Protocol capability to assert against. No
|
|
1280
|
-
* entry in `MODULE_CAPABILITIES` per the rule documented in
|
|
1281
|
-
* `contract/capability-registry.ts`. When/if the runtime moves to a
|
|
1282
|
-
* Stackbone-served backend we add the capability and wire the gate.
|
|
1283
|
-
*/
|
|
1284
|
-
declare class MemoryModule {
|
|
1285
|
-
constructor(_resolved: ResolvedConfig);
|
|
1286
|
-
add(_content: MemoryContent, _request: AddMemoryRequest): Promise<Result<MemoryItem>>;
|
|
1287
|
-
search(_query: string, _options?: SearchMemoryOptions): Promise<Result<readonly MemoryHit[]>>;
|
|
1288
|
-
delete(_memoryId: string): Promise<Result<{
|
|
1289
|
-
id: string;
|
|
1290
|
-
}>>;
|
|
1291
|
-
deleteAll(_request: DeleteAllMemoryRequest): Promise<Result<{
|
|
1292
|
-
deleted: number;
|
|
1293
|
-
}>>;
|
|
1294
|
-
get(_memoryId: string): Promise<Result<MemoryItem>>;
|
|
1295
|
-
list(_request: ListMemoryRequest): Promise<Result<ListMemoryResult>>;
|
|
1296
|
-
update(_memoryId: string, _options: UpdateMemoryOptions): Promise<Result<MemoryItem>>;
|
|
1297
|
-
history(_memoryId: string): Promise<Result<readonly MemoryHistoryEntry[]>>;
|
|
1298
|
-
endSession(_sessionId: string, _options?: EndSessionOptions): Promise<Result<EndSessionResult>>;
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
1232
|
/** Subset of `RequestInit['body']` we serialize without modification. */
|
|
1302
1233
|
type SerializedBody = NonNullable<RequestInit['body']>;
|
|
1303
1234
|
/**
|
|
@@ -1432,6 +1363,176 @@ declare class HttpClient {
|
|
|
1432
1363
|
private computeBackoff;
|
|
1433
1364
|
}
|
|
1434
1365
|
|
|
1366
|
+
/** Options for `invoke`. */
|
|
1367
|
+
interface InvokeOptions {
|
|
1368
|
+
/**
|
|
1369
|
+
* Selector to disambiguate when the workspace holds several connections of the
|
|
1370
|
+
* same connector. Accepts a connection **id** or a unique **name** (both are
|
|
1371
|
+
* returned by `list()`). Omitted → the proxy resolves the sole connection, or
|
|
1372
|
+
* fails `connections_ambiguous` when there is more than one.
|
|
1373
|
+
*/
|
|
1374
|
+
connection?: string;
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* `client.connections` — the agent's handle on the workspace's connector
|
|
1378
|
+
* connections. The credentials never enter the agent container: each method
|
|
1379
|
+
* makes an authenticated call to the control plane (the connector executor owns
|
|
1380
|
+
* the resolved credential, in a platform process).
|
|
1381
|
+
*
|
|
1382
|
+
* - `list` returns the workspace's connections (connector id, label, auth kind,
|
|
1383
|
+
* health) — never any credential material — so the agent can adapt to what the
|
|
1384
|
+
* customer has connected.
|
|
1385
|
+
* - `invoke(connector, action, args)` runs a connector action imperatively. The
|
|
1386
|
+
* control plane resolves the workspace's connection for `connector`, validates
|
|
1387
|
+
* `args` against the action's input schema, executes it, and returns the
|
|
1388
|
+
* validated output verbatim. `args` is opaque — the SDK forwards it untouched.
|
|
1389
|
+
*
|
|
1390
|
+
* Authentication reuses the existing `STACKBONE_AGENT_JWT` channel injected at
|
|
1391
|
+
* provisioning (the `HttpClient` attaches the bearer + install header), so the
|
|
1392
|
+
* control plane scopes every call to the agent's own install → organization.
|
|
1393
|
+
*
|
|
1394
|
+
* Contract gating: every method awaits the `connections.actions` module gate
|
|
1395
|
+
* before touching the network, so a stale datapath / missing capability surfaces
|
|
1396
|
+
* as a gating error rather than a failed request.
|
|
1397
|
+
*/
|
|
1398
|
+
declare class ConnectionsModule {
|
|
1399
|
+
private readonly _http;
|
|
1400
|
+
private readonly _gate;
|
|
1401
|
+
constructor(resolved: ResolvedConfig, _http: HttpClient,
|
|
1402
|
+
/** Test seam — see `ModuleGate`. Defaults to the lazy contract gate. */
|
|
1403
|
+
gate?: ModuleGate);
|
|
1404
|
+
/** List the workspace's connections (no credentials). */
|
|
1405
|
+
list(): Promise<Result<AgentConnectionListResponse>>;
|
|
1406
|
+
/**
|
|
1407
|
+
* Invoke a connector action against the workspace's connection for that
|
|
1408
|
+
* connector. `args` is forwarded opaquely; the control plane validates it
|
|
1409
|
+
* against the action's own input schema and returns the validated output.
|
|
1410
|
+
*
|
|
1411
|
+
* When the workspace holds several connections of the same connector, pass
|
|
1412
|
+
* `{ connection }` (a connection id or unique name) to pick one; omitting it
|
|
1413
|
+
* with more than one connection fails `connections_ambiguous`.
|
|
1414
|
+
*/
|
|
1415
|
+
invoke(connector: string, action: string, args: unknown, opts?: InvokeOptions): Promise<Result<InvokeConnectorActionResponse>>;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
/**
|
|
1419
|
+
* Where a memory lives. Default `'user'`. `'session'` is short-lived and
|
|
1420
|
+
* collapsed (or dropped) by `endSession()`; `'agent'` is shared across every
|
|
1421
|
+
* user of the agent.
|
|
1422
|
+
*/
|
|
1423
|
+
type MemoryScope = 'user' | 'session' | 'agent';
|
|
1424
|
+
/**
|
|
1425
|
+
* Either raw text or an OpenAI-shaped conversation. The future mem0 backend
|
|
1426
|
+
* accepts both: strings ingest verbatim, message arrays are summarised into
|
|
1427
|
+
* one or more facts.
|
|
1428
|
+
*/
|
|
1429
|
+
type MemoryContent = string | ChatCompletionMessageParam[];
|
|
1430
|
+
interface AddMemoryRequest {
|
|
1431
|
+
userId: string;
|
|
1432
|
+
/** Conversation/session bucket. Required when `scope: 'session'`. */
|
|
1433
|
+
sessionId?: string;
|
|
1434
|
+
/** Default `'user'`. */
|
|
1435
|
+
scope?: MemoryScope;
|
|
1436
|
+
metadata?: Record<string, unknown>;
|
|
1437
|
+
}
|
|
1438
|
+
interface MemoryItem {
|
|
1439
|
+
id: string;
|
|
1440
|
+
content: string;
|
|
1441
|
+
userId: string;
|
|
1442
|
+
sessionId?: string;
|
|
1443
|
+
scope: MemoryScope;
|
|
1444
|
+
metadata?: Record<string, unknown>;
|
|
1445
|
+
/** ISO 8601 UTC timestamp. */
|
|
1446
|
+
createdAt: string;
|
|
1447
|
+
updatedAt: string;
|
|
1448
|
+
}
|
|
1449
|
+
interface SearchMemoryOptions {
|
|
1450
|
+
userId?: string;
|
|
1451
|
+
sessionId?: string;
|
|
1452
|
+
/** 1..100. Default 10. */
|
|
1453
|
+
limit?: number;
|
|
1454
|
+
/** Minimum cosine similarity in [0, 1]. Hits below this are dropped. */
|
|
1455
|
+
threshold?: number;
|
|
1456
|
+
/** Metadata predicates AND-ed to the semantic match. */
|
|
1457
|
+
filters?: Record<string, unknown>;
|
|
1458
|
+
/** Restrict the search to a subset of scopes. Default: every scope. */
|
|
1459
|
+
includeScopes?: readonly MemoryScope[];
|
|
1460
|
+
}
|
|
1461
|
+
interface MemoryHit extends MemoryItem {
|
|
1462
|
+
/** Cosine similarity in [0, 1]. */
|
|
1463
|
+
score: number;
|
|
1464
|
+
}
|
|
1465
|
+
interface ListMemoryRequest {
|
|
1466
|
+
userId: string;
|
|
1467
|
+
/** 1..100. Default 50. */
|
|
1468
|
+
limit?: number;
|
|
1469
|
+
cursor?: string;
|
|
1470
|
+
}
|
|
1471
|
+
interface ListMemoryResult {
|
|
1472
|
+
items: readonly MemoryItem[];
|
|
1473
|
+
nextCursor?: string;
|
|
1474
|
+
}
|
|
1475
|
+
interface UpdateMemoryOptions {
|
|
1476
|
+
content?: string;
|
|
1477
|
+
/** Shallow-merged onto the existing metadata (mem0 semantics). */
|
|
1478
|
+
metadata?: Record<string, unknown>;
|
|
1479
|
+
}
|
|
1480
|
+
interface DeleteAllMemoryRequest {
|
|
1481
|
+
userId: string;
|
|
1482
|
+
}
|
|
1483
|
+
type MemoryHistoryEvent = 'created' | 'updated' | 'accessed' | 'deleted';
|
|
1484
|
+
interface MemoryHistoryEntry {
|
|
1485
|
+
id: string;
|
|
1486
|
+
memoryId: string;
|
|
1487
|
+
event: MemoryHistoryEvent;
|
|
1488
|
+
/** ISO 8601 UTC timestamp. */
|
|
1489
|
+
at: string;
|
|
1490
|
+
/** Identifier of who triggered the event (user id, agent id, etc.). */
|
|
1491
|
+
actor?: string;
|
|
1492
|
+
/** Content snapshot before the event. Only set for `updated`/`deleted`. */
|
|
1493
|
+
before?: string;
|
|
1494
|
+
/** Content snapshot after the event. Only set for `created`/`updated`. */
|
|
1495
|
+
after?: string;
|
|
1496
|
+
metadata?: Record<string, unknown>;
|
|
1497
|
+
}
|
|
1498
|
+
interface EndSessionOptions {
|
|
1499
|
+
/** Persist session-scoped facts to long-term (`'user'`) memory before closing. Default `true`. */
|
|
1500
|
+
persist?: boolean;
|
|
1501
|
+
}
|
|
1502
|
+
interface EndSessionResult {
|
|
1503
|
+
sessionId: string;
|
|
1504
|
+
/** Number of session memories promoted to long-term storage. `0` when `persist: false`. */
|
|
1505
|
+
persisted: number;
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* `client.memory` — long-term memory for the agent. The first iteration is a
|
|
1509
|
+
* scaffolding placeholder: every method returns `not_implemented`. The real
|
|
1510
|
+
* backend will be mem0 (`mem0ApiKey` / `MEM0_API_KEY`) and the public surface
|
|
1511
|
+
* defined here is the contract callers can already type against.
|
|
1512
|
+
*
|
|
1513
|
+
* Contract gating: not gated. Memory targets mem0 (a non-Stackbone partner),
|
|
1514
|
+
* so there is no Stackbone Agent Protocol capability to assert against. No
|
|
1515
|
+
* entry in `MODULE_CAPABILITIES` per the rule documented in
|
|
1516
|
+
* `contract/capability-registry.ts`. When/if the runtime moves to a
|
|
1517
|
+
* Stackbone-served backend we add the capability and wire the gate.
|
|
1518
|
+
*/
|
|
1519
|
+
declare class MemoryModule {
|
|
1520
|
+
constructor(_resolved: ResolvedConfig);
|
|
1521
|
+
add(_content: MemoryContent, _request: AddMemoryRequest): Promise<Result<MemoryItem>>;
|
|
1522
|
+
search(_query: string, _options?: SearchMemoryOptions): Promise<Result<readonly MemoryHit[]>>;
|
|
1523
|
+
delete(_memoryId: string): Promise<Result<{
|
|
1524
|
+
id: string;
|
|
1525
|
+
}>>;
|
|
1526
|
+
deleteAll(_request: DeleteAllMemoryRequest): Promise<Result<{
|
|
1527
|
+
deleted: number;
|
|
1528
|
+
}>>;
|
|
1529
|
+
get(_memoryId: string): Promise<Result<MemoryItem>>;
|
|
1530
|
+
list(_request: ListMemoryRequest): Promise<Result<ListMemoryResult>>;
|
|
1531
|
+
update(_memoryId: string, _options: UpdateMemoryOptions): Promise<Result<MemoryItem>>;
|
|
1532
|
+
history(_memoryId: string): Promise<Result<readonly MemoryHistoryEntry[]>>;
|
|
1533
|
+
endSession(_sessionId: string, _options?: EndSessionOptions): Promise<Result<EndSessionResult>>;
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1435
1536
|
/**
|
|
1436
1537
|
* Enqueue a one-shot (or deferred) job. The opaque `payload` is whatever the
|
|
1437
1538
|
* agent's `receive` handler expects — the core never inspects it.
|
|
@@ -1541,6 +1642,7 @@ declare class StackboneClient {
|
|
|
1541
1642
|
private _secrets?;
|
|
1542
1643
|
private _config?;
|
|
1543
1644
|
private _queues?;
|
|
1645
|
+
private _connections?;
|
|
1544
1646
|
private _memory?;
|
|
1545
1647
|
private _prompts?;
|
|
1546
1648
|
private _httpClient?;
|
|
@@ -1563,6 +1665,15 @@ declare class StackboneClient {
|
|
|
1563
1665
|
* as the other gated surfaces.
|
|
1564
1666
|
*/
|
|
1565
1667
|
get queues(): QueuesModule;
|
|
1668
|
+
/**
|
|
1669
|
+
* Live surface — the agent's handle on the workspace's connector connections.
|
|
1670
|
+
* `list` / `invoke` make authenticated calls to the control-plane connectors
|
|
1671
|
+
* proxy (`/api/v1/agent/connections/*`); the credentials never enter the agent
|
|
1672
|
+
* container. Gated against `connections.actions` so the handshake-blocked /
|
|
1673
|
+
* capability-missing paths are exercised the same way as the other gated
|
|
1674
|
+
* surfaces.
|
|
1675
|
+
*/
|
|
1676
|
+
get connections(): ConnectionsModule;
|
|
1566
1677
|
/**
|
|
1567
1678
|
* Pending surface — runtime not built. Every method returns
|
|
1568
1679
|
* `not_implemented`. Mem0 is a third-party integration, not a Stackbone
|
|
@@ -1664,6 +1775,22 @@ declare const createStructuredLogger: (opts?: StructuredLoggerOptions) => Logger
|
|
|
1664
1775
|
* - `logger` is a child of the wrapper's structured logger already
|
|
1665
1776
|
* bound to `invocationId` and `runId`, so the handler does not have to
|
|
1666
1777
|
* pass them on every line. The actual JSON format lands in F6.
|
|
1778
|
+
* - `stream` is present **only** when the caller requested a streamed reply
|
|
1779
|
+
* (an SSE `/invoke`). The handler pushes incremental output through it —
|
|
1780
|
+
* `delta(text)` for token-by-token text and `event(name, data?)` for a
|
|
1781
|
+
* named structured event — and the wrapper relays each onto the open
|
|
1782
|
+
* socket as it is produced. On a plain (buffered) invoke `stream` is
|
|
1783
|
+
* `undefined`, so a handler that wants to stream guards on it and falls
|
|
1784
|
+
* back to returning its `output` normally.
|
|
1785
|
+
* - `progress` / `step` are the **live run progress** helpers (distinct from
|
|
1786
|
+
* token streaming): they record `run_steps` rows on the run so the Studio
|
|
1787
|
+
* runs timeline fills in as the handler works. `progress(message, data?)` is
|
|
1788
|
+
* a coarse, point-in-time note; `step({ type, name })` opens a span and
|
|
1789
|
+
* returns a handle whose `.finish()` closes it with a duration. Both are
|
|
1790
|
+
* runtime-injected and fire-and-forget — they are wired to the install's
|
|
1791
|
+
* Postgres by the wrapper, are absent (no-op) when no run writer is mounted
|
|
1792
|
+
* (e.g. plain unit tests), and the wrapper throttles `progress` so a hot
|
|
1793
|
+
* loop cannot flood the run with notes.
|
|
1667
1794
|
*/
|
|
1668
1795
|
interface InvokeContext<I extends z.ZodType> {
|
|
1669
1796
|
input: z.infer<I>;
|
|
@@ -1672,7 +1799,76 @@ interface InvokeContext<I extends z.ZodType> {
|
|
|
1672
1799
|
runId: string;
|
|
1673
1800
|
client: StackboneClient;
|
|
1674
1801
|
logger: Logger;
|
|
1802
|
+
stream?: InvokeStream;
|
|
1803
|
+
progress?: InvokeProgress;
|
|
1804
|
+
step?: InvokeStepFn;
|
|
1675
1805
|
}
|
|
1806
|
+
/**
|
|
1807
|
+
* The streaming sink handed to a handler as `ctx.stream` when the caller asked
|
|
1808
|
+
* for a streamed `/invoke`. Both methods are fire-and-forget — the handler
|
|
1809
|
+
* emits, the wrapper relays — so neither returns a promise the handler must
|
|
1810
|
+
* await.
|
|
1811
|
+
*/
|
|
1812
|
+
interface InvokeStream {
|
|
1813
|
+
/** Emit an incremental chunk of text (e.g. a model token). */
|
|
1814
|
+
delta(text: string): void;
|
|
1815
|
+
/** Emit a named structured event with an optional JSON-serialisable payload. */
|
|
1816
|
+
event(name: string, data?: unknown): void;
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* The closed set of step types `ctx.step` / `ctx.progress` may record. It
|
|
1820
|
+
* mirrors the CHECK constraint on `stackbone_platform.run_steps.type`; an
|
|
1821
|
+
* unknown type would be rejected by Postgres, so the contract enumerates the
|
|
1822
|
+
* allowed values at the type layer too. `agent` is the catch-all a coarse
|
|
1823
|
+
* `progress` note records under.
|
|
1824
|
+
*/
|
|
1825
|
+
type RunStepType = 'agent' | 'llm_call' | 'db_query' | 'http_fetch' | 'queue_publish' | 'hitl_pause' | 'tool_call' | 'rag_query' | 'storage_op';
|
|
1826
|
+
/**
|
|
1827
|
+
* `ctx.progress` — a coarse, point-in-time note on the run, distinct from the
|
|
1828
|
+
* token-level `ctx.stream`. The wrapper writes one `run_steps` row (type
|
|
1829
|
+
* `agent`) per call, opened and closed in place, so it shows up immediately on
|
|
1830
|
+
* the Studio timeline. Fire-and-forget: it returns nothing the handler must
|
|
1831
|
+
* await, and the wrapper throttles calls to ~1/s so a hot loop cannot flood the
|
|
1832
|
+
* run. `data` is an optional JSON-serialisable payload stored on the row.
|
|
1833
|
+
*/
|
|
1834
|
+
type InvokeProgress = (message: string, data?: unknown) => void;
|
|
1835
|
+
/** Opening descriptor for `ctx.step`. */
|
|
1836
|
+
interface StepOptions {
|
|
1837
|
+
/** One of the canonical `run_steps` types; defaults to `agent` when omitted. */
|
|
1838
|
+
type?: RunStepType;
|
|
1839
|
+
/** Human-readable label for the step (the `run_steps.name` column). */
|
|
1840
|
+
name: string;
|
|
1841
|
+
/** Optional JSON-serialisable payload stored on the opened row. */
|
|
1842
|
+
data?: unknown;
|
|
1843
|
+
}
|
|
1844
|
+
/** Closing descriptor for a `StepHandle.finish`. */
|
|
1845
|
+
interface StepFinishOptions {
|
|
1846
|
+
/** Terminal status; defaults to `ok`. */
|
|
1847
|
+
status?: 'ok' | 'error';
|
|
1848
|
+
/** Failure detail recorded on the row when the step errored. */
|
|
1849
|
+
error?: string;
|
|
1850
|
+
/** Optional JSON-serialisable payload merged onto the row at finish. */
|
|
1851
|
+
data?: unknown;
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* Handle returned by `ctx.step`. The handler calls `.finish()` when the work the
|
|
1855
|
+
* step represents completes, which closes the open `run_steps` row with a
|
|
1856
|
+
* duration and terminal status. Calling `.finish()` more than once is a no-op —
|
|
1857
|
+
* the first close wins.
|
|
1858
|
+
*/
|
|
1859
|
+
interface StepHandle {
|
|
1860
|
+
/** The id of the opened `run_steps` row (useful for nesting / correlation). */
|
|
1861
|
+
readonly id: string;
|
|
1862
|
+
/** Close the step. Idempotent: only the first call writes a terminal row. */
|
|
1863
|
+
finish(options?: StepFinishOptions): void;
|
|
1864
|
+
}
|
|
1865
|
+
/**
|
|
1866
|
+
* `ctx.step` — opens a span on the run and returns a handle to close it. The
|
|
1867
|
+
* wrapper writes a `run_steps` row in the `running` state on open and updates it
|
|
1868
|
+
* to `ok`/`error` with a duration on `.finish()`. Fire-and-forget like
|
|
1869
|
+
* `ctx.progress`; absent (no-op handle) when no run writer is mounted.
|
|
1870
|
+
*/
|
|
1871
|
+
type InvokeStepFn = (options: StepOptions) => StepHandle;
|
|
1676
1872
|
/**
|
|
1677
1873
|
* The synchronous `invoke` capability. Mirrors the wrapper's three HTTP verbs
|
|
1678
1874
|
* (`/invoke`, `/health`, `/schema`): `invoke` is the only request path, its
|
|
@@ -2046,4 +2242,4 @@ interface JsonSchemaDocument {
|
|
|
2046
2242
|
*/
|
|
2047
2243
|
declare const analyzeAgentSchemas: (pair: AgentSchemaPair) => SchemaIntrospectionResult;
|
|
2048
2244
|
|
|
2049
|
-
export { type AddMemoryRequest, type AgentSchemaPair, type AgentSpec, type AnyCapability, type ApprovalListOptions, type ApprovalListResult, type ApprovalRecord, type ApprovalRequest, type ApprovalRequestOptions, type ApprovalStatus, type ApprovalTool, type ApprovalToolSpec, type ApprovalTopic, type ApproverInfo, type ClientConfig, type CompilePromptResult, type ConsoleLike, type CreatePromptRequest, type Decision, type DecisionStatus, type DeleteAllMemoryRequest, type DeletePromptOptions, type DeletePromptResult, type EndSessionOptions, type EndSessionResult, type FatalConstruct, type GeneratedImage, type GetPromptOptions, INVOCATION_ID_HEADER, INVOKE_TIMEOUT_HARD_CAP_MS, type ImageGenerateParams, type ImagesResponse, type IngestAsyncHandle, type InstallConsoleCaptureOptions, type InvocationContext, type InvokeCapability, type InvokeContext, type InvokeEnvelopeError, type InvokeErrorEnvelope, type InvokeRequest, type InvokeResponse, type InvokeSuccessEnvelope, type JobCapability, type JsonSchemaDocument, type ListMemoryRequest, type ListMemoryResult, type ListOptions, type ListPromptsOptions, type ListPromptsResult, type LoadSystemSecretsArgs, type LogSink, type Logger, type LoggerBindings, type MemoryContent, type MemoryHistoryEntry, type MemoryHistoryEvent, type MemoryHit, type MemoryItem, type MemoryScope, type ModelsListResponse, type OpenRouterModel, type Prompt, type PublishRequest, RESERVED_ERROR_CODES, RESERVED_HANDLER_NAMES, RUN_ID_HEADER, type ReservedErrorCode, type Result, STORED_TO_SDK_ENV, type ScheduleRequest, type SchemaDiagnostic, type SchemaHalf, type SchemaIntrospectionResult, type SdkError, type SdkErrorCode, type SearchMemoryOptions, type SignedUrl, type SignedUrlOptions, StackboneClient, type StorageBody, type StorageObject, type StructuredLoggerOptions, type SystemSecretRow, type SystemSecretsReader, type UnscheduleRequest, type UpdateMemoryOptions, type UpdatePromptOptions, type UploadOptions, type VerifyOptions, type WarnConstruct, analyzeAgentSchemas, createClient, createStructuredLogger, defineAgent, getInvocationContext, installInvocationConsoleCapture, invokeRequestSchema, isReservedErrorCode, isSdkErrorCode, loadSystemSecretsIntoEnv, rehydrateSystemSecretsRows, runWithInvocationContext };
|
|
2245
|
+
export { type AddMemoryRequest, type AgentSchemaPair, type AgentSpec, type AnyCapability, type ApprovalListOptions, type ApprovalListResult, type ApprovalRecord, type ApprovalRequest, type ApprovalRequestOptions, type ApprovalStatus, type ApprovalTool, type ApprovalToolSpec, type ApprovalTopic, type ApproverInfo, type ClientConfig, type CompilePromptResult, type ConsoleLike, type CreatePromptRequest, type Decision, type DecisionStatus, type DeleteAllMemoryRequest, type DeletePromptOptions, type DeletePromptResult, type EndSessionOptions, type EndSessionResult, type FatalConstruct, type GeneratedImage, type GetPromptOptions, INVOCATION_ID_HEADER, INVOKE_TIMEOUT_HARD_CAP_MS, type ImageGenerateParams, type ImagesResponse, type IngestAsyncHandle, type InstallConsoleCaptureOptions, type InvocationContext, type InvokeCapability, type InvokeContext, type InvokeEnvelopeError, type InvokeErrorEnvelope, type InvokeOptions, type InvokeProgress, type InvokeRequest, type InvokeResponse, type InvokeStepFn, type InvokeStream, type InvokeSuccessEnvelope, type JobCapability, type JsonSchemaDocument, type ListMemoryRequest, type ListMemoryResult, type ListOptions, type ListPromptsOptions, type ListPromptsResult, type LoadSystemSecretsArgs, type LogSink, type Logger, type LoggerBindings, type MemoryContent, type MemoryHistoryEntry, type MemoryHistoryEvent, type MemoryHit, type MemoryItem, type MemoryScope, type ModelsListResponse, type OpenRouterModel, type Prompt, type PublishRequest, RESERVED_ERROR_CODES, RESERVED_HANDLER_NAMES, RUN_ID_HEADER, type ReservedErrorCode, type Result, type RunStepType, STORED_TO_SDK_ENV, type ScheduleRequest, type SchemaDiagnostic, type SchemaHalf, type SchemaIntrospectionResult, type SdkError, type SdkErrorCode, type SearchMemoryOptions, type SignedUrl, type SignedUrlOptions, StackboneClient, type StepFinishOptions, type StepHandle, type StepOptions, type StorageBody, type StorageObject, type StructuredLoggerOptions, type SystemSecretRow, type SystemSecretsReader, type UnscheduleRequest, type UpdateMemoryOptions, type UpdatePromptOptions, type UploadOptions, type VerifyOptions, type WarnConstruct, analyzeAgentSchemas, createClient, createStructuredLogger, defineAgent, getInvocationContext, installInvocationConsoleCapture, invokeRequestSchema, isReservedErrorCode, isSdkErrorCode, loadSystemSecretsIntoEnv, rehydrateSystemSecretsRows, runWithInvocationContext };
|