@boboddy/sdk 0.1.45-alpha → 0.2.1-alpha

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.
@@ -11235,7 +11235,7 @@ function finalize(ctx, schema) {
11235
11235
  result.$schema = "http://json-schema.org/draft-07/schema#";
11236
11236
  } else if (ctx.target === "draft-04") {
11237
11237
  result.$schema = "http://json-schema.org/draft-04/schema#";
11238
- } else if (ctx.target === "openapi-3.0") {} else {}
11238
+ } else if (ctx.target === "openapi-3.0") {}
11239
11239
  if (ctx.external?.uri) {
11240
11240
  const id = ctx.external.registry.get(schema)?.id;
11241
11241
  if (!id)
@@ -11479,7 +11479,7 @@ var literalProcessor = (schema, ctx, json, _params) => {
11479
11479
  if (val === undefined) {
11480
11480
  if (ctx.unrepresentable === "throw") {
11481
11481
  throw new Error("Literal `undefined` cannot be represented in JSON Schema");
11482
- } else {}
11482
+ }
11483
11483
  } else if (typeof val === "bigint") {
11484
11484
  if (ctx.unrepresentable === "throw") {
11485
11485
  throw new Error("BigInt literals cannot be represented in JSON Schema");
@@ -11984,29 +11984,29 @@ function renderPromptTemplate(template, contextJson) {
11984
11984
  }
11985
11985
 
11986
11986
  // src/definitions/steps/define-step.ts
11987
- var UNWRAP_TYPES = new Set(["optional", "nullable", "default"]);
11988
- function unwrapZodType(schema) {
11989
- while (UNWRAP_TYPES.has(schema._def.type)) {
11990
- const inner = schema._def.innerType;
11991
- if (!inner)
11992
- break;
11993
- schema = inner;
11987
+ function resolveZodSchemaAtPath(schema, path) {
11988
+ if (!schema)
11989
+ return;
11990
+ const segments = path.split(".");
11991
+ let current = schema;
11992
+ for (const segment of segments) {
11993
+ if (!current)
11994
+ return;
11995
+ current = unwrapZodWrappers(current);
11996
+ const def = current.def;
11997
+ if (!def || def.type !== "object" || !def.shape)
11998
+ return;
11999
+ current = def.shape[segment];
11994
12000
  }
11995
- return schema;
12001
+ return current;
11996
12002
  }
11997
- function deriveSignalType(schema, path) {
12003
+ function zodTypeToSignalType(schema) {
11998
12004
  if (!schema)
11999
- return "string";
12000
- let current = unwrapZodType(schema);
12001
- for (const part of path.split(".")) {
12002
- if (current._def.type !== "object")
12003
- return "string";
12004
- const next = current._def.shape?.[part];
12005
- if (!next)
12006
- return "string";
12007
- current = unwrapZodType(next);
12008
- }
12009
- switch (current._def.type) {
12005
+ return;
12006
+ const unwrapped = unwrapZodWrappers(schema);
12007
+ const def = unwrapped.def;
12008
+ const typeName = def?.type;
12009
+ switch (typeName) {
12010
12010
  case "string":
12011
12011
  return "string";
12012
12012
  case "number":
@@ -12016,11 +12016,20 @@ function deriveSignalType(schema, path) {
12016
12016
  case "array":
12017
12017
  return "array";
12018
12018
  case "object":
12019
- case "record":
12020
12019
  return "object";
12021
12020
  default:
12022
- return "string";
12021
+ return;
12022
+ }
12023
+ }
12024
+ function unwrapZodWrappers(schema) {
12025
+ const def = schema.def;
12026
+ if (!def)
12027
+ return schema;
12028
+ if (def.type === "optional" || def.type === "nullable" || def.type === "default" || def.type === "catch") {
12029
+ if (def.innerType)
12030
+ return unwrapZodWrappers(def.innerType);
12023
12031
  }
12032
+ return schema;
12024
12033
  }
12025
12034
  function defineStep(config2) {
12026
12035
  const features = config2.features ?? [];
@@ -12052,7 +12061,7 @@ ${feature._promptAddition}` : feature._promptAddition;
12052
12061
  ...(config2.signals ?? []).map((s) => ({
12053
12062
  key: s.key ?? s.sourcePath,
12054
12063
  sourcePath: s.sourcePath,
12055
- type: s.type ?? deriveSignalType(config2.result, s.sourcePath),
12064
+ type: s.type ?? zodTypeToSignalType(resolveZodSchemaAtPath(effectiveResult, s.sourcePath)) ?? "string",
12056
12065
  required: s.required ?? true,
12057
12066
  availableWhenResultStatusIn: s.availableWhenResultStatusIn ?? null
12058
12067
  })),
@@ -13064,6 +13073,22 @@ class StepExecutions extends HeyApiClient {
13064
13073
  getStepExecution(options) {
13065
13074
  return (options.client ?? this.client).get({ url: "/api/step-executions/{stepExecutionId}", ...options });
13066
13075
  }
13076
+ readStepExecutionLogs(options) {
13077
+ return (options.client ?? this.client).get({ url: "/api/step-executions/{stepExecutionId}/logs", ...options });
13078
+ }
13079
+ appendStepExecutionLogs(options) {
13080
+ return (options.client ?? this.client).post({
13081
+ url: "/api/step-executions/{stepExecutionId}/logs",
13082
+ ...options,
13083
+ headers: {
13084
+ "Content-Type": "application/json",
13085
+ ...options.headers
13086
+ }
13087
+ });
13088
+ }
13089
+ getStepExecutionLogArchive(options) {
13090
+ return (options.client ?? this.client).get({ url: "/api/step-executions/{stepExecutionId}/logs/archive", ...options });
13091
+ }
13067
13092
  }
13068
13093
 
13069
13094
  class PipelineDefinitions extends HeyApiClient {
@@ -13402,6 +13427,12 @@ class ProjectInvites extends HeyApiClient {
13402
13427
  }
13403
13428
  }
13404
13429
 
13430
+ class Billing extends HeyApiClient {
13431
+ getOrgUsage(options) {
13432
+ return (options.client ?? this.client).get({ url: "/api/orgs/{orgId}/usage", ...options });
13433
+ }
13434
+ }
13435
+
13405
13436
  class BoboddyClient extends HeyApiClient {
13406
13437
  static __registry = new HeyApiRegistry;
13407
13438
  constructor(args) {
@@ -13464,6 +13495,10 @@ class BoboddyClient extends HeyApiClient {
13464
13495
  get projectInvites() {
13465
13496
  return this._projectInvites ??= new ProjectInvites({ client: this.client });
13466
13497
  }
13498
+ _billing;
13499
+ get billing() {
13500
+ return this._billing ??= new Billing({ client: this.client });
13501
+ }
13467
13502
  }
13468
13503
 
13469
13504
  // src/definitions/steps/step-definitions-client.ts
@@ -15864,7 +15899,7 @@ var notificationItemSchema = exports_external.object({
15864
15899
  title: exports_external.string().describe("Short, human-readable notification title."),
15865
15900
  body: exports_external.string().describe("The notification body / details."),
15866
15901
  priority: exports_external.enum(["low", "normal", "high", "urgent"]).describe("How important this notification is for the user."),
15867
- suggestedChannels: exports_external.array(exports_external.enum(["in_app", "jira_comment", "email", "slack"])).optional().describe("Channels the agent thinks are worth using. The platform policy decides the final channels."),
15902
+ suggestedChannels: exports_external.array(exports_external.enum(["in_app", "work_item_platform_comment", "email", "slack"])).optional().describe("Channels the agent thinks are worth using. The platform policy decides the final channels."),
15868
15903
  payload: exports_external.record(exports_external.string(), exports_external.unknown()).optional().describe('Kind-specific structured data. For "feedback_request": { category, urgency, suggestedKey? }.')
15869
15904
  }).describe("A single user notification emitted by the agent.");
15870
15905
  var notificationsFeature = {
@@ -15880,7 +15915,7 @@ var notificationsFeature = {
15880
15915
  "- **title**: A short, human-readable title.",
15881
15916
  "- **body**: The details of the notification.",
15882
15917
  "- **priority**: One of `low`, `normal`, `high`, `urgent`.",
15883
- '- **suggestedChannels** *(optional)*: Channels you think are worth using (e.g. `["in_app", "jira_comment"]`).',
15918
+ '- **suggestedChannels** *(optional)*: Channels you think are worth using (e.g. `["in_app", "work_item_platform_comment"]`).',
15884
15919
  " You only *suggest* channels \u2014 the platform policy decides the final delivery channels.",
15885
15920
  '- **payload** *(optional)*: Kind-specific data. For `feedback_request`, include `{ "category": string, "urgency": "blocking"|"clarification"|"assumption"|"informational", "suggestedKey"?: string }`.'
15886
15921
  ].join(`
@@ -16266,6 +16301,82 @@ function materializeAccessor(accessor) {
16266
16301
  };
16267
16302
  }
16268
16303
 
16304
+ // src/definitions/pipelines/builder-helpers.ts
16305
+ var WORK_ITEM_ACCESSOR = Object.freeze({
16306
+ title: Object.freeze({ source: "work_item", field: "title" }),
16307
+ description: Object.freeze({
16308
+ source: "work_item",
16309
+ field: "description"
16310
+ }),
16311
+ field: (fieldName) => Object.freeze({ source: "work_item", field: `fields.${fieldName}` })
16312
+ });
16313
+ var WORK_ITEM_FIELD_BINDINGS = {
16314
+ workItemTitle: { source: "work_item", field: "title" },
16315
+ workItemDescription: { source: "work_item", field: "description" }
16316
+ };
16317
+ function makeStepInputCtx(inputSchema) {
16318
+ const baseAccessor = createInputAccessor(inputSchema);
16319
+ const input = new Proxy(baseAccessor, {
16320
+ get(target, prop) {
16321
+ if (typeof prop === "string" && prop in WORK_ITEM_FIELD_BINDINGS) {
16322
+ return WORK_ITEM_FIELD_BINDINGS[prop];
16323
+ }
16324
+ return target[prop];
16325
+ }
16326
+ });
16327
+ return {
16328
+ input,
16329
+ signal(step, key) {
16330
+ return { source: "step_signal", step, signalKey: key };
16331
+ },
16332
+ output(step) {
16333
+ return { source: "step_output", step };
16334
+ },
16335
+ literal: literal2
16336
+ };
16337
+ }
16338
+ function literal2(value) {
16339
+ return { source: "literal", value };
16340
+ }
16341
+ function normalizeInputMapping(mapping) {
16342
+ if (!mapping)
16343
+ return;
16344
+ const out = {};
16345
+ for (const [key, value] of Object.entries(mapping)) {
16346
+ if (value === undefined)
16347
+ continue;
16348
+ out[key] = isInputAccessor(value) ? materializeAccessor(value) : value;
16349
+ }
16350
+ return out;
16351
+ }
16352
+ function resolveAdditionalStepInputBindings(label, definition) {
16353
+ if (!definition) {
16354
+ return {};
16355
+ }
16356
+ const raw = definition.bindings({
16357
+ workItemField: (fieldName) => ({
16358
+ source: "work_item",
16359
+ field: `fields.${fieldName}`
16360
+ }),
16361
+ literal: literal2
16362
+ });
16363
+ if (definition.schema instanceof exports_external.ZodObject) {
16364
+ const validKeys = new Set(Object.keys(definition.schema.shape));
16365
+ const unknown2 = Object.keys(raw).filter((key) => !validKeys.has(key));
16366
+ if (unknown2.length > 0) {
16367
+ throw new Error(`${label}.bindings returned key${unknown2.length > 1 ? "s" : ""} not in schema: ${unknown2.map((key) => `"${key}"`).join(", ")}`);
16368
+ }
16369
+ }
16370
+ return normalizeInputMapping(raw) ?? {};
16371
+ }
16372
+ function mergeStepBindings(pipelineBindings, explicitBindings) {
16373
+ const merged = {
16374
+ ...pipelineBindings,
16375
+ ...explicitBindings ?? {}
16376
+ };
16377
+ return Object.keys(merged).length > 0 ? merged : undefined;
16378
+ }
16379
+
16269
16380
  // src/definitions/pipelines/builder.ts
16270
16381
  class PipelineStepAdvancementBuilder {
16271
16382
  inputSchema;
@@ -16282,6 +16393,8 @@ class PipelineStepAdvancementBuilder {
16282
16393
  }
16283
16394
  advance(callback) {
16284
16395
  const last = this.steps.at(-1);
16396
+ if (!last)
16397
+ throw new Error("Internal error: no steps available");
16285
16398
  const ctx = makeAdvanceCtx();
16286
16399
  const result = callback(ctx);
16287
16400
  const policy = {
@@ -16378,80 +16491,6 @@ class PipelineBuilder {
16378
16491
  return new PipelineStepAdvancementBuilder(this.inputSchema, this.meta, this.steps, this.pipelineInputBindings, this.pipelineStepInputBindings);
16379
16492
  }
16380
16493
  }
16381
- var WORK_ITEM_ACCESSOR = Object.freeze({
16382
- title: Object.freeze({ source: "work_item", field: "title" }),
16383
- description: Object.freeze({
16384
- source: "work_item",
16385
- field: "description"
16386
- }),
16387
- field: (fieldName) => Object.freeze({ source: "work_item", field: `fields.${fieldName}` })
16388
- });
16389
- var WORK_ITEM_FIELD_BINDINGS = {
16390
- workItemTitle: { source: "work_item", field: "title" },
16391
- workItemDescription: { source: "work_item", field: "description" }
16392
- };
16393
- function makeStepInputCtx(inputSchema) {
16394
- const baseAccessor = createInputAccessor(inputSchema);
16395
- const input = new Proxy(baseAccessor, {
16396
- get(target, prop) {
16397
- if (typeof prop === "string" && prop in WORK_ITEM_FIELD_BINDINGS) {
16398
- return WORK_ITEM_FIELD_BINDINGS[prop];
16399
- }
16400
- return target[prop];
16401
- }
16402
- });
16403
- return {
16404
- input,
16405
- signal(step, key) {
16406
- return { source: "step_signal", step, signalKey: key };
16407
- },
16408
- output(step) {
16409
- return { source: "step_output", step };
16410
- },
16411
- literal: literal2
16412
- };
16413
- }
16414
- function literal2(value) {
16415
- return { source: "literal", value };
16416
- }
16417
- function normalizeInputMapping(mapping) {
16418
- if (!mapping)
16419
- return;
16420
- const out = {};
16421
- for (const [key, value] of Object.entries(mapping)) {
16422
- if (value === undefined)
16423
- continue;
16424
- out[key] = isInputAccessor(value) ? materializeAccessor(value) : value;
16425
- }
16426
- return out;
16427
- }
16428
- function resolveAdditionalStepInputBindings(label, definition) {
16429
- if (!definition) {
16430
- return {};
16431
- }
16432
- const raw = definition.bindings({
16433
- workItemField: (fieldName) => ({
16434
- source: "work_item",
16435
- field: `fields.${fieldName}`
16436
- }),
16437
- literal: literal2
16438
- });
16439
- if (definition.schema instanceof exports_external.ZodObject) {
16440
- const validKeys = new Set(Object.keys(definition.schema.shape));
16441
- const unknown2 = Object.keys(raw).filter((key) => !validKeys.has(key));
16442
- if (unknown2.length > 0) {
16443
- throw new Error(`${label}.bindings returned key${unknown2.length > 1 ? "s" : ""} not in schema: ${unknown2.map((key) => `"${key}"`).join(", ")}`);
16444
- }
16445
- }
16446
- return normalizeInputMapping(raw) ?? {};
16447
- }
16448
- function mergeStepBindings(pipelineBindings, explicitBindings) {
16449
- const merged = {
16450
- ...pipelineBindings,
16451
- ...explicitBindings ?? {}
16452
- };
16453
- return Object.keys(merged).length > 0 ? merged : undefined;
16454
- }
16455
16494
  function pipeline(meta3) {
16456
16495
  return new PipelineBuilder(meta3);
16457
16496
  }
@@ -16469,7 +16508,7 @@ var buildPipelineDefinitionsClient = (pipelineDefinitions) => {
16469
16508
  });
16470
16509
  if (result.error)
16471
16510
  throw new Error(JSON.stringify(result.error));
16472
- return result.data ?? [];
16511
+ return result.data;
16473
16512
  },
16474
16513
  upsertFromSpec: async (projectId, spec, stepDefs, options) => {
16475
16514
  const stepDefMap = new Map;
@@ -16549,7 +16588,7 @@ function makeFieldRef(fact, path) {
16549
16588
  };
16550
16589
  }
16551
16590
  function makeAssign(pipeline2) {
16552
- if (typeof pipeline2 !== "object" || pipeline2 === null || typeof pipeline2["key"] !== "string" || !Array.isArray(pipeline2["steps"])) {
16591
+ if (typeof pipeline2 !== "object" || typeof pipeline2["key"] !== "string" || !Array.isArray(pipeline2["steps"])) {
16553
16592
  throw new Error("assign() requires a pipeline spec produced by pipeline().build(). " + "Pass the default-exported value from a pipeline definition file.");
16554
16593
  }
16555
16594
  return { _tag: "assign", pipeline: pipeline2 };
@@ -16598,13 +16637,10 @@ function serializeConditionNode(condition) {
16598
16637
  value: condition.value
16599
16638
  };
16600
16639
  }
16601
- if (condition._tag === "group") {
16602
- if (condition.mode === "all") {
16603
- return { all: condition.conditions.map(serializeConditionNode) };
16604
- }
16605
- return { any: condition.conditions.map(serializeConditionNode) };
16640
+ if (condition.mode === "all") {
16641
+ return { all: condition.conditions.map(serializeConditionNode) };
16606
16642
  }
16607
- throw new Error(`Unknown condition tag: ${JSON.stringify(condition["_tag"])}`);
16643
+ return { any: condition.conditions.map(serializeConditionNode) };
16608
16644
  }
16609
16645
  function serializeOutcome(outcome) {
16610
16646
  if (outcome._tag === "skip")
@@ -16682,7 +16718,9 @@ function extractRoutePipelineKeys(policy) {
16682
16718
  }
16683
16719
  var PUSH_SCRIPT_NAMES = new Set(["push.ts", "push.mjs", "push.js"]);
16684
16720
  async function pushFromDirectory(dir, opts) {
16685
- const log = opts.log ?? ((msg) => console.log(msg));
16721
+ const log = opts.log ?? ((msg) => {
16722
+ console.warn(msg);
16723
+ });
16686
16724
  const headers = { Authorization: `Bearer ${opts.accessToken}` };
16687
16725
  const absDir = resolve(dir);
16688
16726
  const allFiles = readdirSync(absDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
@@ -16740,7 +16778,7 @@ async function pushFromDirectory(dir, opts) {
16740
16778
  const serverSteps = await stepsClient.listByProjectId(opts.projectId, {
16741
16779
  headers
16742
16780
  });
16743
- const stepDefs = (serverSteps ?? []).map((s) => ({
16781
+ const stepDefs = serverSteps.map((s) => ({
16744
16782
  id: s.id,
16745
16783
  key: s.key,
16746
16784
  version: s.version
@@ -16791,6 +16829,9 @@ async function syncDefaultPipelineAssignment(spec, opts, headers, pipelinesClien
16791
16829
  }
16792
16830
  }
16793
16831
  const linearPipelineDefinitionId = pipelineKeyToId.get(serialized.linearPipelineDefinitionKey);
16832
+ if (!linearPipelineDefinitionId) {
16833
+ throw new Error(`Pipeline key "${serialized.linearPipelineDefinitionKey}" was not found on the server.`);
16834
+ }
16794
16835
  const resolvedRules = serialized.rulesJson.rules.map((rule) => {
16795
16836
  if (rule.event.type === "assign" && typeof rule.event.params?.["pipelineKey"] === "string") {
16796
16837
  const pKey = rule.event.params["pipelineKey"];
@@ -186,5 +186,16 @@ declare const buildStepExecutionPlaneClient: (stepExecutions: StepExecutions) =>
186
186
  resultJson: JsonValue;
187
187
  errorJson: JsonValue;
188
188
  }, options?: RequestOptions) => Promise<void>;
189
+ appendStepExecutionLogs: (stepExecutionId: string, body: {
190
+ claimToken: string;
191
+ lines: {
192
+ seq: number;
193
+ stream: "worker" | "ai-server" | "conversation";
194
+ ts: string;
195
+ content: string;
196
+ }[];
197
+ }, options?: RequestOptions) => Promise<{
198
+ nextOffset: number;
199
+ }>;
189
200
  };
190
201
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@boboddy/sdk",
4
- "version": "0.1.45-alpha",
4
+ "version": "0.2.1-alpha",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {