@stackbone/sdk 0.1.0-alpha.6 → 0.1.0-alpha.7

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.cjs CHANGED
@@ -2373,7 +2373,7 @@ var require_luxon = __commonJS({
2373
2373
  return new Formatter2(locale, opts);
2374
2374
  }
2375
2375
  static parseFormat(fmt) {
2376
- let current = null, currentFull = "", bracketed = false;
2376
+ let current3 = null, currentFull = "", bracketed = false;
2377
2377
  const splits = [];
2378
2378
  for (let i2 = 0; i2 < fmt.length; i2++) {
2379
2379
  const c2 = fmt.charAt(i2);
@@ -2384,12 +2384,12 @@ var require_luxon = __commonJS({
2384
2384
  val: currentFull === "" ? "'" : currentFull
2385
2385
  });
2386
2386
  }
2387
- current = null;
2387
+ current3 = null;
2388
2388
  currentFull = "";
2389
2389
  bracketed = !bracketed;
2390
2390
  } else if (bracketed) {
2391
2391
  currentFull += c2;
2392
- } else if (c2 === current) {
2392
+ } else if (c2 === current3) {
2393
2393
  currentFull += c2;
2394
2394
  } else {
2395
2395
  if (currentFull.length > 0) {
@@ -2399,7 +2399,7 @@ var require_luxon = __commonJS({
2399
2399
  });
2400
2400
  }
2401
2401
  currentFull = c2;
2402
- current = c2;
2402
+ current3 = c2;
2403
2403
  }
2404
2404
  }
2405
2405
  if (currentFull.length > 0) {
@@ -3129,28 +3129,28 @@ var require_luxon = __commonJS({
3129
3129
  __name(durationToMillis, "durationToMillis");
3130
3130
  function normalizeValues(matrix, vals) {
3131
3131
  const factor = durationToMillis(matrix, vals) < 0 ? -1 : 1;
3132
- orderedUnits$1.reduceRight((previous, current) => {
3133
- if (!isUndefined(vals[current])) {
3132
+ orderedUnits$1.reduceRight((previous, current3) => {
3133
+ if (!isUndefined(vals[current3])) {
3134
3134
  if (previous) {
3135
3135
  const previousVal = vals[previous] * factor;
3136
- const conv = matrix[current][previous];
3136
+ const conv = matrix[current3][previous];
3137
3137
  const rollUp = Math.floor(previousVal / conv);
3138
- vals[current] += rollUp * factor;
3138
+ vals[current3] += rollUp * factor;
3139
3139
  vals[previous] -= rollUp * conv * factor;
3140
3140
  }
3141
- return current;
3141
+ return current3;
3142
3142
  } else {
3143
3143
  return previous;
3144
3144
  }
3145
3145
  }, null);
3146
- orderedUnits$1.reduce((previous, current) => {
3147
- if (!isUndefined(vals[current])) {
3146
+ orderedUnits$1.reduce((previous, current3) => {
3147
+ if (!isUndefined(vals[current3])) {
3148
3148
  if (previous) {
3149
3149
  const fraction = vals[previous] % 1;
3150
3150
  vals[previous] -= fraction;
3151
- vals[current] += fraction * matrix[previous][current];
3151
+ vals[current3] += fraction * matrix[previous][current3];
3152
3152
  }
3153
- return current;
3153
+ return current3;
3154
3154
  } else {
3155
3155
  return previous;
3156
3156
  }
@@ -4263,21 +4263,21 @@ var require_luxon = __commonJS({
4263
4263
  * @return {Array}
4264
4264
  */
4265
4265
  static merge(intervals) {
4266
- const [found, final] = intervals.sort((a2, b2) => a2.s - b2.s).reduce(([sofar, current], item) => {
4267
- if (!current) {
4266
+ const [found, final] = intervals.sort((a2, b2) => a2.s - b2.s).reduce(([sofar, current3], item) => {
4267
+ if (!current3) {
4268
4268
  return [
4269
4269
  sofar,
4270
4270
  item
4271
4271
  ];
4272
- } else if (current.overlaps(item) || current.abutsStart(item)) {
4272
+ } else if (current3.overlaps(item) || current3.abutsStart(item)) {
4273
4273
  return [
4274
4274
  sofar,
4275
- current.union(item)
4275
+ current3.union(item)
4276
4276
  ];
4277
4277
  } else {
4278
4278
  return [
4279
4279
  sofar.concat([
4280
- current
4280
+ current3
4281
4281
  ]),
4282
4282
  item
4283
4283
  ];
@@ -5209,7 +5209,7 @@ var require_luxon = __commonJS({
5209
5209
  }
5210
5210
  __name(possiblyCachedLocalWeekData, "possiblyCachedLocalWeekData");
5211
5211
  function clone(inst, alts) {
5212
- const current = {
5212
+ const current3 = {
5213
5213
  ts: inst.ts,
5214
5214
  zone: inst.zone,
5215
5215
  c: inst.c,
@@ -5218,9 +5218,9 @@ var require_luxon = __commonJS({
5218
5218
  invalid: inst.invalid
5219
5219
  };
5220
5220
  return new DateTime({
5221
- ...current,
5221
+ ...current3,
5222
5222
  ...alts,
5223
- old: current
5223
+ old: current3
5224
5224
  });
5225
5225
  }
5226
5226
  __name(clone, "clone");
@@ -8225,7 +8225,7 @@ var require_expression = __commonJS({
8225
8225
  return schedule;
8226
8226
  }, "prev");
8227
8227
  CronExpression.prototype.hasNext = function() {
8228
- var current = this._currentDate;
8228
+ var current3 = this._currentDate;
8229
8229
  var hasIterated = this._hasIterated;
8230
8230
  try {
8231
8231
  this._findSchedule();
@@ -8233,12 +8233,12 @@ var require_expression = __commonJS({
8233
8233
  } catch (err3) {
8234
8234
  return false;
8235
8235
  } finally {
8236
- this._currentDate = current;
8236
+ this._currentDate = current3;
8237
8237
  this._hasIterated = hasIterated;
8238
8238
  }
8239
8239
  };
8240
8240
  CronExpression.prototype.hasPrev = function() {
8241
- var current = this._currentDate;
8241
+ var current3 = this._currentDate;
8242
8242
  var hasIterated = this._hasIterated;
8243
8243
  try {
8244
8244
  this._findSchedule(true);
@@ -8246,7 +8246,7 @@ var require_expression = __commonJS({
8246
8246
  } catch (err3) {
8247
8247
  return false;
8248
8248
  } finally {
8249
- this._currentDate = current;
8249
+ this._currentDate = current3;
8250
8250
  this._hasIterated = hasIterated;
8251
8251
  }
8252
8252
  };
@@ -8753,9 +8753,11 @@ var CAPABILITIES = [
8753
8753
  "prompts.basic",
8754
8754
  // `connections.actions`: the agent → control-plane connectors proxy
8755
8755
  // (feature connectors-connections-automations). Role-based naming per repo
8756
- // convention. `client.connections.list()` / `.invoke(connector, action, args)`
8756
+ // convention. `client.legacyConnections.list()` / `.invoke(connector, action, args)`
8757
8757
  // run against the proxy; the agent container never sees a credential. The
8758
- // v13 bump reintroduces this capability after v12 removed it.
8758
+ // v13 bump reintroduces this capability after v12 removed it. The capability
8759
+ // string stays `connections.actions` (it names the wire domain, not the
8760
+ // renamed SDK accessor).
8759
8761
  "connections.actions"
8760
8762
  ];
8761
8763
  var MODULE_CAPABILITIES = {
@@ -8772,10 +8774,11 @@ var MODULE_CAPABILITIES = {
8772
8774
  // row is still declared here because the table is shared with the cloud
8773
8775
  // contract / Studio capability advertisement.
8774
8776
  prompts: "prompts.basic",
8775
- // `client.connections` is a control-plane PROXY surface (like queues): the
8776
- // agent POSTs to `/api/v1/agent/connections/*` with its agent JWT and the
8777
+ // `client.legacyConnections` is a control-plane PROXY surface (like queues):
8778
+ // the agent POSTs to `/api/v1/agent/connections/*` with its agent JWT and the
8777
8779
  // control plane runs the connector action with credentials resolved in
8778
- // memory. Gated against `connections.actions`.
8780
+ // memory. Gated against `connections.actions`. The map key stays `connections`
8781
+ // (it is the module id shared with the cloud contract, not the SDK accessor).
8779
8782
  connections: "connections.actions"
8780
8783
  };
8781
8784
  var contractBuildNameSchema = zod.z.enum([
@@ -9194,9 +9197,9 @@ function createContractStore(resolved = resolveConfig({})) {
9194
9197
  function peek(baseUrl) {
9195
9198
  if (!baseUrl || baseUrl.trim() === "") return null;
9196
9199
  const key = normaliseBaseUrl(baseUrl);
9197
- const cached = lastResolved.get(key);
9198
- if (!cached || cached.error) return null;
9199
- return cached.data;
9200
+ const cached2 = lastResolved.get(key);
9201
+ if (!cached2 || cached2.error) return null;
9202
+ return cached2.data;
9200
9203
  }
9201
9204
  __name(peek, "peek");
9202
9205
  function gatingEnabled() {
@@ -9462,9 +9465,9 @@ var HttpClient = class {
9462
9465
  if (jwt && !requestHeaders.has("Authorization")) {
9463
9466
  requestHeaders.set("Authorization", `Bearer ${jwt}`);
9464
9467
  }
9465
- const installationId = resolveInstallationId(this.resolved);
9466
- if (installationId && !requestHeaders.has("X-Stackbone-Installation-Id")) {
9467
- requestHeaders.set("X-Stackbone-Installation-Id", installationId);
9468
+ const installationId2 = resolveInstallationId(this.resolved);
9469
+ if (installationId2 && !requestHeaders.has("X-Stackbone-Installation-Id")) {
9470
+ requestHeaders.set("X-Stackbone-Installation-Id", installationId2);
9468
9471
  }
9469
9472
  const body = serializeBody(method, options.body, requestHeaders);
9470
9473
  let lastError = null;
@@ -9962,7 +9965,7 @@ var ApprovalFacade = class {
9962
9965
  const rows = await this._getDatabase().runShared((db) => db`
9963
9966
  INSERT INTO stackbone_platform.approvals (
9964
9967
  topic, payload, callback_url, idempotency_key,
9965
- fallback, metadata, timeout_at
9968
+ fallback, metadata, run_id, requested_by_step_id, timeout_at
9966
9969
  ) VALUES (
9967
9970
  ${options.topic},
9968
9971
  ${JSON.stringify(options.payload ?? {})}::jsonb,
@@ -9970,6 +9973,8 @@ var ApprovalFacade = class {
9970
9973
  ${options.idempotencyKey ?? null},
9971
9974
  ${fallback},
9972
9975
  ${JSON.stringify(options.metadata ?? {})}::jsonb,
9976
+ ${options.runId ?? null}::uuid,
9977
+ ${options.requestedByStepId ?? null}::uuid,
9973
9978
  now() + (${timeoutMs}::int * interval '1 millisecond')
9974
9979
  )
9975
9980
  ON CONFLICT (workspace_id, topic, idempotency_key)
@@ -10202,7 +10207,7 @@ var ConfigFacade = class {
10202
10207
  void this._resolved;
10203
10208
  }
10204
10209
  async get(key) {
10205
- if (!key.trim()) {
10210
+ if (!String(key).trim()) {
10206
10211
  return err({
10207
10212
  code: "config_invalid_request",
10208
10213
  message: "`key` is required."
@@ -10213,7 +10218,7 @@ var ConfigFacade = class {
10213
10218
  if (!payload.data || !(key in payload.data)) {
10214
10219
  return err({
10215
10220
  code: "config_not_found",
10216
- message: `Config key \`${key}\` is not set for this agent.`,
10221
+ message: `Config key \`${String(key)}\` is not set for this agent.`,
10217
10222
  meta: {
10218
10223
  key
10219
10224
  }
@@ -10242,6 +10247,17 @@ var ConfigFacade = class {
10242
10247
  }
10243
10248
  return ok(out);
10244
10249
  }
10250
+ /**
10251
+ * Returns the agent's entire config payload as one typed object. An
10252
+ * absent/null `agent_config` row resolves to `ok({})` — an empty config is
10253
+ * "no config set", consistent with the facade reading the singleton row.
10254
+ * Reads stay an unvalidated SELECT (no AJV on the read path).
10255
+ */
10256
+ async getAll() {
10257
+ const payload = await this.loadPayload();
10258
+ if (payload.error) return err(payload.error);
10259
+ return ok(payload.data ?? {});
10260
+ }
10245
10261
  async loadPayload() {
10246
10262
  const sql = this.sql();
10247
10263
  if (sql.error) return err(sql.error);
@@ -10427,21 +10443,21 @@ function buildProxy(steps, seed, rootCall, gate) {
10427
10443
  }
10428
10444
  __name(buildProxy, "buildProxy");
10429
10445
  function replayChain(seed, steps) {
10430
- let current = seed;
10446
+ let current3 = seed;
10431
10447
  for (const step of steps) {
10432
- if (current === null || current === void 0) return current;
10448
+ if (current3 === null || current3 === void 0) return current3;
10433
10449
  if (step.kind === "get") {
10434
- current = current[step.key];
10450
+ current3 = current3[step.key];
10435
10451
  continue;
10436
10452
  }
10437
- const parent = current;
10453
+ const parent = current3;
10438
10454
  const fn = parent[step.key];
10439
10455
  if (typeof fn !== "function") {
10440
10456
  throw new TypeError(`[stackbone/sdk] cold-start retry could not replay "${step.key}": not a function on the rebuilt handle`);
10441
10457
  }
10442
- current = fn.apply(parent, step.args);
10458
+ current3 = fn.apply(parent, step.args);
10443
10459
  }
10444
- return current;
10460
+ return current3;
10445
10461
  }
10446
10462
  __name(replayChain, "replayChain");
10447
10463
 
@@ -10801,11 +10817,11 @@ var PromptsFacade = class {
10801
10817
  WHERE p.key = ${key} AND p.deleted_at IS NULL
10802
10818
  LIMIT 1
10803
10819
  `;
10804
- const current = existing[0];
10805
- if (!current) return null;
10806
- let nextVersion = current.current_version;
10820
+ const current3 = existing[0];
10821
+ if (!current3) return null;
10822
+ let nextVersion = current3.current_version;
10807
10823
  if (options.template !== void 0) {
10808
- nextVersion = current.current_version + 1;
10824
+ nextVersion = current3.current_version + 1;
10809
10825
  const variables = extractVars(options.template);
10810
10826
  await tx`
10811
10827
  INSERT INTO stackbone_platform.prompt_versions
@@ -10819,8 +10835,8 @@ var PromptsFacade = class {
10819
10835
  await tx`
10820
10836
  UPDATE stackbone_platform.prompts
10821
10837
  SET current_version = ${nextVersion},
10822
- name = ${options.name ?? current.name},
10823
- description = ${options.description !== void 0 ? options.description : current.description},
10838
+ name = ${options.name ?? current3.name},
10839
+ description = ${options.description !== void 0 ? options.description : current3.description},
10824
10840
  metadata = COALESCE(${options.metadata !== void 0 ? JSON.stringify(options.metadata) : null}::jsonb, metadata),
10825
10841
  updated_at = now()
10826
10842
  WHERE key = ${key}
@@ -11242,7 +11258,7 @@ async function createDocument(sql, args) {
11242
11258
  `;
11243
11259
  const insertedDoc = await tx`
11244
11260
  INSERT INTO stackbone_platform.rag_documents (collection_id, source, content_hash, metadata)
11245
- VALUES (${collectionId}, ${args.source}, ${args.contentHash}, ${tx.json(args.metadata)})
11261
+ VALUES (${collectionId}, ${args.source}, ${args.contentHash}, ${JSON.stringify(args.metadata)}::jsonb)
11246
11262
  RETURNING id
11247
11263
  `;
11248
11264
  const documentId = insertedDoc[0]?.id;
@@ -16001,6 +16017,99 @@ var SecretsFacade = class {
16001
16017
  }
16002
16018
  }
16003
16019
  };
16020
+ function agentRegistry() {
16021
+ const raw = process.env["AGENT_URLS"];
16022
+ if (!raw) {
16023
+ throw new Error("AGENT_URLS is not set. The emulator injects it; run this workflow through `stackbone dev`.");
16024
+ }
16025
+ return JSON.parse(raw);
16026
+ }
16027
+ __name(agentRegistry, "agentRegistry");
16028
+ function resolveAgentHost(name) {
16029
+ const registry = agentRegistry();
16030
+ const host = registry[name];
16031
+ if (!host) {
16032
+ throw new Error(`Unknown agent "${name}". Known agents: ${Object.keys(registry).join(", ")}`);
16033
+ }
16034
+ return host;
16035
+ }
16036
+ __name(resolveAgentHost, "resolveAgentHost");
16037
+ function signWorkflowHeaders() {
16038
+ const secret = process.env["HMAC_SECRET"] ?? "";
16039
+ const timestamp = String(Date.now());
16040
+ const signature = crypto$1.createHmac("sha256", secret).update(timestamp).digest("hex");
16041
+ return {
16042
+ "x-stackbone-timestamp": timestamp,
16043
+ "x-stackbone-workflow-signature": signature
16044
+ };
16045
+ }
16046
+ __name(signWorkflowHeaders, "signWorkflowHeaders");
16047
+
16048
+ // src/surfaces/external/agents/lazy-agent.ts
16049
+ var EVE_CLIENT_MODULE = "eve/client";
16050
+ async function buildEveClient(name) {
16051
+ const host = resolveAgentHost(name);
16052
+ const { Client } = await import(EVE_CLIENT_MODULE);
16053
+ return new Client({
16054
+ host,
16055
+ headers: /* @__PURE__ */ __name(() => signWorkflowHeaders(), "headers")
16056
+ });
16057
+ }
16058
+ __name(buildEveClient, "buildEveClient");
16059
+ function seedSessionState(seed) {
16060
+ if (typeof seed === "string") return {
16061
+ continuationToken: seed,
16062
+ streamIndex: 0
16063
+ };
16064
+ return seed ?? {
16065
+ streamIndex: 0
16066
+ };
16067
+ }
16068
+ __name(seedSessionState, "seedSessionState");
16069
+ function lazyAgentSession(getClient, seed) {
16070
+ const seededState = seedSessionState(seed);
16071
+ let real;
16072
+ let opened;
16073
+ const session = /* @__PURE__ */ __name(() => {
16074
+ real ??= getClient().then((client) => client.session(seed)).then((s2) => {
16075
+ opened = s2;
16076
+ return s2;
16077
+ }).catch((error) => {
16078
+ real = void 0;
16079
+ throw error;
16080
+ });
16081
+ return real;
16082
+ }, "session");
16083
+ return {
16084
+ get state() {
16085
+ return opened ? opened.state : seededState;
16086
+ },
16087
+ async send(input) {
16088
+ return (await session()).send(input);
16089
+ },
16090
+ async *stream(options) {
16091
+ yield* (await session()).stream(options);
16092
+ }
16093
+ };
16094
+ }
16095
+ __name(lazyAgentSession, "lazyAgentSession");
16096
+ function lazyAgent(name) {
16097
+ let client;
16098
+ const getClient = /* @__PURE__ */ __name(() => {
16099
+ client ??= buildEveClient(name).catch((error) => {
16100
+ client = void 0;
16101
+ throw error;
16102
+ });
16103
+ return client;
16104
+ }, "getClient");
16105
+ return {
16106
+ session(state) {
16107
+ return lazyAgentSession(getClient, state);
16108
+ }
16109
+ };
16110
+ }
16111
+ __name(lazyAgent, "lazyAgent");
16112
+ var agent = /* @__PURE__ */ __name((name) => lazyAgent(name), "agent");
16004
16113
  var AiModule = class {
16005
16114
  static {
16006
16115
  __name(this, "AiModule");
@@ -16331,6 +16440,95 @@ function mapApiError(raw, model) {
16331
16440
  };
16332
16441
  }
16333
16442
  __name(mapApiError, "mapApiError");
16443
+ var TIMESTAMP_HEADER = "x-stackbone-timestamp";
16444
+ var SIGNATURE_HEADER2 = "x-stackbone-workflow-signature";
16445
+ function signBrokerHeaders() {
16446
+ const secret = process.env["HMAC_SECRET"] ?? "";
16447
+ const timestamp = String(Date.now());
16448
+ const signature = crypto$1.createHmac("sha256", secret).update(timestamp).digest("hex");
16449
+ return {
16450
+ [TIMESTAMP_HEADER]: timestamp,
16451
+ [SIGNATURE_HEADER2]: signature
16452
+ };
16453
+ }
16454
+ __name(signBrokerHeaders, "signBrokerHeaders");
16455
+ function brokerBaseUrl() {
16456
+ const url = process.env["STACKBONE_API_URL"];
16457
+ if (!url) {
16458
+ throw new Error("STACKBONE_API_URL is not set. The Stackbone runtime injects the broker base URL; run this agent through `stackbone dev`.");
16459
+ }
16460
+ return url.replace(/\/+$/, "");
16461
+ }
16462
+ __name(brokerBaseUrl, "brokerBaseUrl");
16463
+ function installationId() {
16464
+ const id = process.env["STACKBONE_INSTALLATION_ID"];
16465
+ if (!id) {
16466
+ throw new Error("STACKBONE_INSTALLATION_ID is not set. The Stackbone runtime injects it; run this agent through `stackbone dev`.");
16467
+ }
16468
+ return id;
16469
+ }
16470
+ __name(installationId, "installationId");
16471
+
16472
+ // src/surfaces/external/connect/call-connector.ts
16473
+ var EXECUTE_PATH = "/api/connect/execute";
16474
+ function connectorCallError(code, message) {
16475
+ const error = new Error(message);
16476
+ error.code = code;
16477
+ return error;
16478
+ }
16479
+ __name(connectorCallError, "connectorCallError");
16480
+ function errorFromBody(status, body) {
16481
+ if (body && body.ok === false && body.error && typeof body.error.code === "string") {
16482
+ return connectorCallError(body.error.code, body.error.message ?? `Stackbone Connect broker rejected the call (code "${body.error.code}").`);
16483
+ }
16484
+ return connectorCallError("credential_error", `Stackbone Connect broker responded ${status}.`);
16485
+ }
16486
+ __name(errorFromBody, "errorFromBody");
16487
+ async function callConnector(connector, operation, args, opts) {
16488
+ const principal = opts?.principal ?? {
16489
+ type: "app"
16490
+ };
16491
+ const url = `${brokerBaseUrl()}${EXECUTE_PATH}`;
16492
+ const body = JSON.stringify({
16493
+ connector,
16494
+ operation,
16495
+ args: args ?? {},
16496
+ principal,
16497
+ installationId: installationId()
16498
+ });
16499
+ let response;
16500
+ try {
16501
+ response = await fetch(url, {
16502
+ method: "POST",
16503
+ headers: {
16504
+ "content-type": "application/json",
16505
+ ...signBrokerHeaders()
16506
+ },
16507
+ body
16508
+ });
16509
+ } catch (cause) {
16510
+ throw connectorCallError("execute_failed", `Stackbone Connect broker is unreachable: ${cause instanceof Error ? cause.message : String(cause)}`);
16511
+ }
16512
+ const parsed = await response.json().catch(() => null);
16513
+ if (!response.ok || parsed && parsed.ok === false) {
16514
+ throw errorFromBody(response.status, parsed ?? null);
16515
+ }
16516
+ if (!parsed || parsed.ok !== true) {
16517
+ throw connectorCallError("invalid_output", "Stackbone Connect broker returned a malformed execute response.");
16518
+ }
16519
+ return parsed.output;
16520
+ }
16521
+ __name(callConnector, "callConnector");
16522
+ var connectorHandle = /* @__PURE__ */ __name((id) => new Proxy(/* @__PURE__ */ Object.create(null), {
16523
+ get(_target, prop) {
16524
+ if (typeof prop !== "string" || prop === "then") return void 0;
16525
+ if (prop === "call") {
16526
+ return (operation, args, opts) => callConnector(id, operation, args, opts);
16527
+ }
16528
+ return (args, opts) => callConnector(id, prop, args, opts);
16529
+ }
16530
+ }), "connectorHandle");
16531
+ var connection = /* @__PURE__ */ __name((id) => connectorHandle(id), "connection");
16334
16532
  var R2_ENDPOINT_HOST_SUFFIX = ".r2.cloudflarestorage.com";
16335
16533
  function createS3CompatClient(options) {
16336
16534
  return new clientS3.S3Client({
@@ -16760,6 +16958,8 @@ var QueuesModule = class {
16760
16958
  this._http = _http;
16761
16959
  this._gate = gate ?? createModuleGate("queues", resolved);
16762
16960
  }
16961
+ /** @deprecated Classic v2 only. Prefer `startWorkflow(name, input)` from
16962
+ * `@stackbone/sdk/workflow` (a job → a workflow run on the World). */
16763
16963
  async publish(request) {
16764
16964
  return withGate(this._gate, async () => {
16765
16965
  const body = {
@@ -16778,6 +16978,8 @@ var QueuesModule = class {
16778
16978
  });
16779
16979
  });
16780
16980
  }
16981
+ /** @deprecated Classic v2 only. Prefer `scheduleWorkflow(name, input, cron)`
16982
+ * from `@stackbone/sdk/workflow` (a cron → a workflow run on the World). */
16781
16983
  async schedule(request) {
16782
16984
  return withGate(this._gate, async () => {
16783
16985
  const body = {
@@ -16796,6 +16998,8 @@ var QueuesModule = class {
16796
16998
  });
16797
16999
  });
16798
17000
  }
17001
+ /** @deprecated Classic v2 only. Prefer `unschedule(name)` from
17002
+ * `@stackbone/sdk/workflow`. */
16799
17003
  async unschedule(request) {
16800
17004
  return withGate(this._gate, async () => this._http.request({
16801
17005
  method: "POST",
@@ -16807,6 +17011,8 @@ var QueuesModule = class {
16807
17011
  errorMapping: ERROR_MAPPING2
16808
17012
  }));
16809
17013
  }
17014
+ /** @deprecated Classic v2 only. Prefer `listSchedules()` from
17015
+ * `@stackbone/sdk/workflow`. */
16810
17016
  async listSchedules() {
16811
17017
  return withGate(this._gate, async () => this._http.request({
16812
17018
  method: "GET",
@@ -16831,7 +17037,7 @@ var StackboneClient = class {
16831
17037
  _secrets;
16832
17038
  _config;
16833
17039
  _queues;
16834
- _connections;
17040
+ _legacyConnections;
16835
17041
  _memory;
16836
17042
  _prompts;
16837
17043
  _httpClient;
@@ -16885,16 +17091,59 @@ var StackboneClient = class {
16885
17091
  return this._queues;
16886
17092
  }
16887
17093
  /**
16888
- * Live surface — the agent's handle on the workspace's connector connections.
16889
- * `list` / `invoke` make authenticated calls to the control-plane connectors
16890
- * proxy (`/api/v1/agent/connections/*`); the credentials never enter the agent
17094
+ * Legacy surface — the agent's handle on the workspace's connector connections
17095
+ * under the OLD connector model. `list` / `invoke(connector, action, args)` make
17096
+ * authenticated calls to the control-plane connectors proxy
17097
+ * (`/api/v1/agent/connections/*`); the credentials never enter the agent
16891
17098
  * container. Gated against `connections.actions` so the handshake-blocked /
16892
17099
  * capability-missing paths are exercised the same way as the other gated
16893
17100
  * surfaces.
17101
+ *
17102
+ * Named `legacyConnections` (not `connections`) so it no longer sits one letter
17103
+ * from the new peer-free `connection(id)` entrypoint above — the two connector
17104
+ * entrypoints are now unambiguous. Behaviour is unchanged from the old
17105
+ * `connections` member.
17106
+ */
17107
+ get legacyConnections() {
17108
+ this._legacyConnections ??= new ConnectionsModule(this.resolved, this.http(), createModuleGate("connections", this.resolved, this._contractStore));
17109
+ return this._legacyConnections;
17110
+ }
17111
+ /**
17112
+ * Peer-free connector entrypoint — `stackbone.connection(id)` selects a Stackbone
17113
+ * Connect connector by its verbatim id and returns a typed handle whose generated
17114
+ * operations (`.sendMail({ ... })`, typed via the `StackboneConnections` registry)
17115
+ * and dynamic `.call(operation, args)` escape hatch both resolve to the same broker
17116
+ * call (`POST /api/connect/execute`, HMAC scheme A). It is a plain HMAC fetch — it
17117
+ * imports NO `eve` peer — so it is wired directly onto the client with no lazy
17118
+ * loading and pulls no new peer into the main barrel.
17119
+ *
17120
+ * This is the namespaced form of the top-level `connection(...)` export (now
17121
+ * `@deprecated`); both delegate to the same implementation. Distinct from the
17122
+ * plural `connections` surface above, which is the control-plane connectors proxy
17123
+ * (`list` / `invoke`).
17124
+ */
17125
+ get connection() {
17126
+ return connection;
17127
+ }
17128
+ /**
17129
+ * Namespaced sibling-agent entrypoint — `stackbone.agent(id)` selects a sibling
17130
+ * eve agent by its verbatim name and returns a lazy eve `Client`, so a workflow
17131
+ * step delegates with `stackbone.agent('support').session().send({ ... })`. The
17132
+ * name is typed against the augmentable `AgentRegistry` (declared names
17133
+ * autocomplete, a typo is a compile error).
17134
+ *
17135
+ * Peer isolation is load-bearing: selecting the agent and opening a session are
17136
+ * synchronous and import NO `eve` peer — only the session's already-async leaves
17137
+ * (`send` / `stream`) resolve `eve/client` via dynamic import on first use. So a
17138
+ * tool-only agent that imports `@stackbone/sdk` and never calls `agent(...)` never
17139
+ * eager-loads the optional `eve` peer and cannot crash-loop on a missing dep.
17140
+ *
17141
+ * This is the namespaced form of the top-level `eveAgent(...)` export (now
17142
+ * `@deprecated`) on the `@stackbone/sdk/workflow` subpath; both produce the same
17143
+ * signed workflow→agent call and the same eve `Client` API.
16894
17144
  */
16895
- get connections() {
16896
- this._connections ??= new ConnectionsModule(this.resolved, this.http(), createModuleGate("connections", this.resolved, this._contractStore));
16897
- return this._connections;
17145
+ get agent() {
17146
+ return agent;
16898
17147
  }
16899
17148
  /**
16900
17149
  * Pending surface — runtime not built. Every method returns
@@ -17063,7 +17312,9 @@ var SDK_ERROR_CODE_PREFIXES = {
17063
17312
  "unavailable"
17064
17313
  ],
17065
17314
  /**
17066
- * `client.connections` — the agent → control plane connectors proxy. Both
17315
+ * `client.legacyConnections` — the agent → control plane connectors proxy
17316
+ * (legacy connector model). The `connections_*` code prefix stays stable (it
17317
+ * names the wire domain, not the client accessor). Both
17067
17318
  * methods (`list`, `invoke`) hit the `/api/v1/agent/connections/*` endpoints
17068
17319
  * over `HttpClient`, so the full status→domain remap (`connections_unauthorized`,
17069
17320
  * `connections_not_found`, `connections_unavailable`, …) is in play. The agent
@@ -17244,6 +17495,9 @@ function assertCapabilityShape(name, capability) {
17244
17495
  }
17245
17496
  __name(assertCapabilityShape, "assertCapabilityShape");
17246
17497
 
17498
+ // src/runtime/define-workspace.ts
17499
+ var defineWorkspace = /* @__PURE__ */ __name((workspace) => workspace, "defineWorkspace");
17500
+
17247
17501
  // src/runtime/logger.ts
17248
17502
  var writeLine = /* @__PURE__ */ __name((stream, level, msg, bindings, meta, now) => {
17249
17503
  const record = {
@@ -17281,6 +17535,65 @@ function getInvocationContext() {
17281
17535
  return storage.getStore();
17282
17536
  }
17283
17537
  __name(getInvocationContext, "getInvocationContext");
17538
+ function runWithCallerId(id, fn, options) {
17539
+ const context = {
17540
+ runId: id,
17541
+ invocationId: options?.invocationId ?? id,
17542
+ // Only attach `handler` when supplied: `exactOptionalPropertyTypes` forbids
17543
+ // an explicit `undefined` on an optional property.
17544
+ ...options?.handler !== void 0 ? {
17545
+ handler: options.handler
17546
+ } : {}
17547
+ };
17548
+ return runWithInvocationContext(context, fn);
17549
+ }
17550
+ __name(runWithCallerId, "runWithCallerId");
17551
+
17552
+ // src/runtime/workflow-starter.ts
17553
+ var current;
17554
+ function setWorkflowStarter(starter) {
17555
+ current = starter;
17556
+ }
17557
+ __name(setWorkflowStarter, "setWorkflowStarter");
17558
+ function getWorkflowStarter() {
17559
+ if (!current) {
17560
+ throw new Error("No workflow starter is bound. `startWorkflow` / `startWorkflowAndWait` can only be called from inside a running workflow \u2014 the runtime binds the starter on its first dispatch.");
17561
+ }
17562
+ return current;
17563
+ }
17564
+ __name(getWorkflowStarter, "getWorkflowStarter");
17565
+
17566
+ // src/runtime/workflow-scheduler.ts
17567
+ var current2;
17568
+ function setWorkflowScheduler(scheduler) {
17569
+ current2 = scheduler;
17570
+ }
17571
+ __name(setWorkflowScheduler, "setWorkflowScheduler");
17572
+ function getWorkflowScheduler() {
17573
+ if (!current2) {
17574
+ throw new Error("No workflow scheduler is bound. `scheduleWorkflow` / `unschedule` / `listSchedules` can only be called inside a running workflow runtime \u2014 the runtime binds the scheduler on its first dispatch.");
17575
+ }
17576
+ return current2;
17577
+ }
17578
+ __name(getWorkflowScheduler, "getWorkflowScheduler");
17579
+
17580
+ // src/runtime/ambient-client.ts
17581
+ var cached;
17582
+ function resolveAmbientClient() {
17583
+ cached ??= createClient();
17584
+ return cached;
17585
+ }
17586
+ __name(resolveAmbientClient, "resolveAmbientClient");
17587
+ var stackbone = new Proxy({}, {
17588
+ get(_target, prop) {
17589
+ const client = resolveAmbientClient();
17590
+ const value = Reflect.get(client, prop, client);
17591
+ return typeof value === "function" ? value.bind(client) : value;
17592
+ },
17593
+ has(_target, prop) {
17594
+ return Reflect.has(resolveAmbientClient(), prop);
17595
+ }
17596
+ });
17284
17597
  var patched = /* @__PURE__ */ new WeakSet();
17285
17598
  function installInvocationConsoleCapture(options = {}) {
17286
17599
  const target = options.console ?? console;
@@ -17590,13 +17903,20 @@ exports.analyzeAgentSchemas = analyzeAgentSchemas;
17590
17903
  exports.createClient = createClient;
17591
17904
  exports.createStructuredLogger = createStructuredLogger;
17592
17905
  exports.defineAgent = defineAgent;
17906
+ exports.defineWorkspace = defineWorkspace;
17593
17907
  exports.getInvocationContext = getInvocationContext;
17908
+ exports.getWorkflowScheduler = getWorkflowScheduler;
17909
+ exports.getWorkflowStarter = getWorkflowStarter;
17594
17910
  exports.installInvocationConsoleCapture = installInvocationConsoleCapture;
17595
17911
  exports.invokeRequestSchema = invokeRequestSchema;
17596
17912
  exports.isReservedErrorCode = isReservedErrorCode;
17597
17913
  exports.isSdkErrorCode = isSdkErrorCode;
17598
17914
  exports.loadSystemSecretsIntoEnv = loadSystemSecretsIntoEnv;
17599
17915
  exports.rehydrateSystemSecretsRows = rehydrateSystemSecretsRows;
17916
+ exports.runWithCallerId = runWithCallerId;
17600
17917
  exports.runWithInvocationContext = runWithInvocationContext;
17918
+ exports.setWorkflowScheduler = setWorkflowScheduler;
17919
+ exports.setWorkflowStarter = setWorkflowStarter;
17920
+ exports.stackbone = stackbone;
17601
17921
  //# sourceMappingURL=index.cjs.map
17602
17922
  //# sourceMappingURL=index.cjs.map