@stackbone/sdk 0.1.0-alpha.4 → 0.1.0-alpha.5

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PublishJobResponse, ScheduleJobResponse, UnscheduleJobResponse, ListSchedulesResponse, ContractResponse } from '@stackbone/validators';
1
+ import { AgentConnectionListResponse, InvokeConnectorActionResponse, PublishJobResponse, ScheduleJobResponse, UnscheduleJobResponse, ListSchedulesResponse, ContractResponse } from '@stackbone/validators';
2
2
  import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
3
3
  import { Sql } from 'postgres';
4
4
  import { IngestJobWriter, IngestRequest, IngestResponse, RagIngestProgress, DeleteOptions, DeleteResponse, RetrieveRequest, RetrieveHit, ChunkOptions, ParseInput, ParseOptions } from '@stackbone/rag-core';
@@ -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
@@ -1180,124 +1192,6 @@ declare class StorageBucket {
1180
1192
  private resolve;
1181
1193
  }
1182
1194
 
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
1195
  /** Subset of `RequestInit['body']` we serialize without modification. */
1302
1196
  type SerializedBody = NonNullable<RequestInit['body']>;
1303
1197
  /**
@@ -1432,6 +1326,176 @@ declare class HttpClient {
1432
1326
  private computeBackoff;
1433
1327
  }
1434
1328
 
1329
+ /** Options for `invoke`. */
1330
+ interface InvokeOptions {
1331
+ /**
1332
+ * Selector to disambiguate when the workspace holds several connections of the
1333
+ * same connector. Accepts a connection **id** or a unique **name** (both are
1334
+ * returned by `list()`). Omitted → the proxy resolves the sole connection, or
1335
+ * fails `connections_ambiguous` when there is more than one.
1336
+ */
1337
+ connection?: string;
1338
+ }
1339
+ /**
1340
+ * `client.connections` — the agent's handle on the workspace's connector
1341
+ * connections. The credentials never enter the agent container: each method
1342
+ * makes an authenticated call to the control plane (the connector executor owns
1343
+ * the resolved credential, in a platform process).
1344
+ *
1345
+ * - `list` returns the workspace's connections (connector id, label, auth kind,
1346
+ * health) — never any credential material — so the agent can adapt to what the
1347
+ * customer has connected.
1348
+ * - `invoke(connector, action, args)` runs a connector action imperatively. The
1349
+ * control plane resolves the workspace's connection for `connector`, validates
1350
+ * `args` against the action's input schema, executes it, and returns the
1351
+ * validated output verbatim. `args` is opaque — the SDK forwards it untouched.
1352
+ *
1353
+ * Authentication reuses the existing `STACKBONE_AGENT_JWT` channel injected at
1354
+ * provisioning (the `HttpClient` attaches the bearer + install header), so the
1355
+ * control plane scopes every call to the agent's own install → organization.
1356
+ *
1357
+ * Contract gating: every method awaits the `connections.actions` module gate
1358
+ * before touching the network, so a stale datapath / missing capability surfaces
1359
+ * as a gating error rather than a failed request.
1360
+ */
1361
+ declare class ConnectionsModule {
1362
+ private readonly _http;
1363
+ private readonly _gate;
1364
+ constructor(resolved: ResolvedConfig, _http: HttpClient,
1365
+ /** Test seam — see `ModuleGate`. Defaults to the lazy contract gate. */
1366
+ gate?: ModuleGate);
1367
+ /** List the workspace's connections (no credentials). */
1368
+ list(): Promise<Result<AgentConnectionListResponse>>;
1369
+ /**
1370
+ * Invoke a connector action against the workspace's connection for that
1371
+ * connector. `args` is forwarded opaquely; the control plane validates it
1372
+ * against the action's own input schema and returns the validated output.
1373
+ *
1374
+ * When the workspace holds several connections of the same connector, pass
1375
+ * `{ connection }` (a connection id or unique name) to pick one; omitting it
1376
+ * with more than one connection fails `connections_ambiguous`.
1377
+ */
1378
+ invoke(connector: string, action: string, args: unknown, opts?: InvokeOptions): Promise<Result<InvokeConnectorActionResponse>>;
1379
+ }
1380
+
1381
+ /**
1382
+ * Where a memory lives. Default `'user'`. `'session'` is short-lived and
1383
+ * collapsed (or dropped) by `endSession()`; `'agent'` is shared across every
1384
+ * user of the agent.
1385
+ */
1386
+ type MemoryScope = 'user' | 'session' | 'agent';
1387
+ /**
1388
+ * Either raw text or an OpenAI-shaped conversation. The future mem0 backend
1389
+ * accepts both: strings ingest verbatim, message arrays are summarised into
1390
+ * one or more facts.
1391
+ */
1392
+ type MemoryContent = string | ChatCompletionMessageParam[];
1393
+ interface AddMemoryRequest {
1394
+ userId: string;
1395
+ /** Conversation/session bucket. Required when `scope: 'session'`. */
1396
+ sessionId?: string;
1397
+ /** Default `'user'`. */
1398
+ scope?: MemoryScope;
1399
+ metadata?: Record<string, unknown>;
1400
+ }
1401
+ interface MemoryItem {
1402
+ id: string;
1403
+ content: string;
1404
+ userId: string;
1405
+ sessionId?: string;
1406
+ scope: MemoryScope;
1407
+ metadata?: Record<string, unknown>;
1408
+ /** ISO 8601 UTC timestamp. */
1409
+ createdAt: string;
1410
+ updatedAt: string;
1411
+ }
1412
+ interface SearchMemoryOptions {
1413
+ userId?: string;
1414
+ sessionId?: string;
1415
+ /** 1..100. Default 10. */
1416
+ limit?: number;
1417
+ /** Minimum cosine similarity in [0, 1]. Hits below this are dropped. */
1418
+ threshold?: number;
1419
+ /** Metadata predicates AND-ed to the semantic match. */
1420
+ filters?: Record<string, unknown>;
1421
+ /** Restrict the search to a subset of scopes. Default: every scope. */
1422
+ includeScopes?: readonly MemoryScope[];
1423
+ }
1424
+ interface MemoryHit extends MemoryItem {
1425
+ /** Cosine similarity in [0, 1]. */
1426
+ score: number;
1427
+ }
1428
+ interface ListMemoryRequest {
1429
+ userId: string;
1430
+ /** 1..100. Default 50. */
1431
+ limit?: number;
1432
+ cursor?: string;
1433
+ }
1434
+ interface ListMemoryResult {
1435
+ items: readonly MemoryItem[];
1436
+ nextCursor?: string;
1437
+ }
1438
+ interface UpdateMemoryOptions {
1439
+ content?: string;
1440
+ /** Shallow-merged onto the existing metadata (mem0 semantics). */
1441
+ metadata?: Record<string, unknown>;
1442
+ }
1443
+ interface DeleteAllMemoryRequest {
1444
+ userId: string;
1445
+ }
1446
+ type MemoryHistoryEvent = 'created' | 'updated' | 'accessed' | 'deleted';
1447
+ interface MemoryHistoryEntry {
1448
+ id: string;
1449
+ memoryId: string;
1450
+ event: MemoryHistoryEvent;
1451
+ /** ISO 8601 UTC timestamp. */
1452
+ at: string;
1453
+ /** Identifier of who triggered the event (user id, agent id, etc.). */
1454
+ actor?: string;
1455
+ /** Content snapshot before the event. Only set for `updated`/`deleted`. */
1456
+ before?: string;
1457
+ /** Content snapshot after the event. Only set for `created`/`updated`. */
1458
+ after?: string;
1459
+ metadata?: Record<string, unknown>;
1460
+ }
1461
+ interface EndSessionOptions {
1462
+ /** Persist session-scoped facts to long-term (`'user'`) memory before closing. Default `true`. */
1463
+ persist?: boolean;
1464
+ }
1465
+ interface EndSessionResult {
1466
+ sessionId: string;
1467
+ /** Number of session memories promoted to long-term storage. `0` when `persist: false`. */
1468
+ persisted: number;
1469
+ }
1470
+ /**
1471
+ * `client.memory` — long-term memory for the agent. The first iteration is a
1472
+ * scaffolding placeholder: every method returns `not_implemented`. The real
1473
+ * backend will be mem0 (`mem0ApiKey` / `MEM0_API_KEY`) and the public surface
1474
+ * defined here is the contract callers can already type against.
1475
+ *
1476
+ * Contract gating: not gated. Memory targets mem0 (a non-Stackbone partner),
1477
+ * so there is no Stackbone Agent Protocol capability to assert against. No
1478
+ * entry in `MODULE_CAPABILITIES` per the rule documented in
1479
+ * `contract/capability-registry.ts`. When/if the runtime moves to a
1480
+ * Stackbone-served backend we add the capability and wire the gate.
1481
+ */
1482
+ declare class MemoryModule {
1483
+ constructor(_resolved: ResolvedConfig);
1484
+ add(_content: MemoryContent, _request: AddMemoryRequest): Promise<Result<MemoryItem>>;
1485
+ search(_query: string, _options?: SearchMemoryOptions): Promise<Result<readonly MemoryHit[]>>;
1486
+ delete(_memoryId: string): Promise<Result<{
1487
+ id: string;
1488
+ }>>;
1489
+ deleteAll(_request: DeleteAllMemoryRequest): Promise<Result<{
1490
+ deleted: number;
1491
+ }>>;
1492
+ get(_memoryId: string): Promise<Result<MemoryItem>>;
1493
+ list(_request: ListMemoryRequest): Promise<Result<ListMemoryResult>>;
1494
+ update(_memoryId: string, _options: UpdateMemoryOptions): Promise<Result<MemoryItem>>;
1495
+ history(_memoryId: string): Promise<Result<readonly MemoryHistoryEntry[]>>;
1496
+ endSession(_sessionId: string, _options?: EndSessionOptions): Promise<Result<EndSessionResult>>;
1497
+ }
1498
+
1435
1499
  /**
1436
1500
  * Enqueue a one-shot (or deferred) job. The opaque `payload` is whatever the
1437
1501
  * agent's `receive` handler expects — the core never inspects it.
@@ -1541,6 +1605,7 @@ declare class StackboneClient {
1541
1605
  private _secrets?;
1542
1606
  private _config?;
1543
1607
  private _queues?;
1608
+ private _connections?;
1544
1609
  private _memory?;
1545
1610
  private _prompts?;
1546
1611
  private _httpClient?;
@@ -1563,6 +1628,15 @@ declare class StackboneClient {
1563
1628
  * as the other gated surfaces.
1564
1629
  */
1565
1630
  get queues(): QueuesModule;
1631
+ /**
1632
+ * Live surface — the agent's handle on the workspace's connector connections.
1633
+ * `list` / `invoke` make authenticated calls to the control-plane connectors
1634
+ * proxy (`/api/v1/agent/connections/*`); the credentials never enter the agent
1635
+ * container. Gated against `connections.actions` so the handshake-blocked /
1636
+ * capability-missing paths are exercised the same way as the other gated
1637
+ * surfaces.
1638
+ */
1639
+ get connections(): ConnectionsModule;
1566
1640
  /**
1567
1641
  * Pending surface — runtime not built. Every method returns
1568
1642
  * `not_implemented`. Mem0 is a third-party integration, not a Stackbone
@@ -2046,4 +2120,4 @@ interface JsonSchemaDocument {
2046
2120
  */
2047
2121
  declare const analyzeAgentSchemas: (pair: AgentSchemaPair) => SchemaIntrospectionResult;
2048
2122
 
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 };
2123
+ 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 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 };