@boboddy/sdk 0.1.45-alpha → 0.2.3-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
  })),
@@ -12992,6 +13001,32 @@ class StepDefinitions extends HeyApiClient {
12992
13001
  }
12993
13002
 
12994
13003
  class StepExecutions extends HeyApiClient {
13004
+ createArtifactUploadUrl(options) {
13005
+ return (options.client ?? this.client).post({
13006
+ url: "/api/step-executions/{stepExecutionId}/artifact-upload-url",
13007
+ ...options,
13008
+ headers: {
13009
+ "Content-Type": "application/json",
13010
+ ...options.headers
13011
+ }
13012
+ });
13013
+ }
13014
+ listStepExecutionArtifacts(options) {
13015
+ return (options.client ?? this.client).get({ url: "/api/step-executions/{stepExecutionId}/artifacts", ...options });
13016
+ }
13017
+ recordStepExecutionArtifact(options) {
13018
+ return (options.client ?? this.client).post({
13019
+ url: "/api/step-executions/{stepExecutionId}/artifacts",
13020
+ ...options,
13021
+ headers: {
13022
+ "Content-Type": "application/json",
13023
+ ...options.headers
13024
+ }
13025
+ });
13026
+ }
13027
+ getArtifactDownloadUrl(options) {
13028
+ return (options.client ?? this.client).get({ url: "/api/step-executions/{stepExecutionId}/artifacts/{artifactId}/download-url", ...options });
13029
+ }
12995
13030
  claimStepExecutions(options) {
12996
13031
  return (options.client ?? this.client).post({
12997
13032
  url: "/api/step-executions/claims",
@@ -13064,6 +13099,22 @@ class StepExecutions extends HeyApiClient {
13064
13099
  getStepExecution(options) {
13065
13100
  return (options.client ?? this.client).get({ url: "/api/step-executions/{stepExecutionId}", ...options });
13066
13101
  }
13102
+ readStepExecutionLogs(options) {
13103
+ return (options.client ?? this.client).get({ url: "/api/step-executions/{stepExecutionId}/logs", ...options });
13104
+ }
13105
+ appendStepExecutionLogs(options) {
13106
+ return (options.client ?? this.client).post({
13107
+ url: "/api/step-executions/{stepExecutionId}/logs",
13108
+ ...options,
13109
+ headers: {
13110
+ "Content-Type": "application/json",
13111
+ ...options.headers
13112
+ }
13113
+ });
13114
+ }
13115
+ getStepExecutionLogArchive(options) {
13116
+ return (options.client ?? this.client).get({ url: "/api/step-executions/{stepExecutionId}/logs/archive", ...options });
13117
+ }
13067
13118
  }
13068
13119
 
13069
13120
  class PipelineDefinitions extends HeyApiClient {
@@ -13402,6 +13453,12 @@ class ProjectInvites extends HeyApiClient {
13402
13453
  }
13403
13454
  }
13404
13455
 
13456
+ class Billing extends HeyApiClient {
13457
+ getOrgUsage(options) {
13458
+ return (options.client ?? this.client).get({ url: "/api/orgs/{orgId}/usage", ...options });
13459
+ }
13460
+ }
13461
+
13405
13462
  class BoboddyClient extends HeyApiClient {
13406
13463
  static __registry = new HeyApiRegistry;
13407
13464
  constructor(args) {
@@ -13464,6 +13521,10 @@ class BoboddyClient extends HeyApiClient {
13464
13521
  get projectInvites() {
13465
13522
  return this._projectInvites ??= new ProjectInvites({ client: this.client });
13466
13523
  }
13524
+ _billing;
13525
+ get billing() {
13526
+ return this._billing ??= new Billing({ client: this.client });
13527
+ }
13467
13528
  }
13468
13529
 
13469
13530
  // src/definitions/steps/step-definitions-client.ts
@@ -15864,7 +15925,7 @@ var notificationItemSchema = exports_external.object({
15864
15925
  title: exports_external.string().describe("Short, human-readable notification title."),
15865
15926
  body: exports_external.string().describe("The notification body / details."),
15866
15927
  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."),
15928
+ 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
15929
  payload: exports_external.record(exports_external.string(), exports_external.unknown()).optional().describe('Kind-specific structured data. For "feedback_request": { category, urgency, suggestedKey? }.')
15869
15930
  }).describe("A single user notification emitted by the agent.");
15870
15931
  var notificationsFeature = {
@@ -15880,7 +15941,7 @@ var notificationsFeature = {
15880
15941
  "- **title**: A short, human-readable title.",
15881
15942
  "- **body**: The details of the notification.",
15882
15943
  "- **priority**: One of `low`, `normal`, `high`, `urgent`.",
15883
- '- **suggestedChannels** *(optional)*: Channels you think are worth using (e.g. `["in_app", "jira_comment"]`).',
15944
+ '- **suggestedChannels** *(optional)*: Channels you think are worth using (e.g. `["in_app", "work_item_platform_comment"]`).',
15884
15945
  " You only *suggest* channels \u2014 the platform policy decides the final delivery channels.",
15885
15946
  '- **payload** *(optional)*: Kind-specific data. For `feedback_request`, include `{ "category": string, "urgency": "blocking"|"clarification"|"assumption"|"informational", "suggestedKey"?: string }`.'
15886
15947
  ].join(`
@@ -16266,6 +16327,82 @@ function materializeAccessor(accessor) {
16266
16327
  };
16267
16328
  }
16268
16329
 
16330
+ // src/definitions/pipelines/builder-helpers.ts
16331
+ var WORK_ITEM_ACCESSOR = Object.freeze({
16332
+ title: Object.freeze({ source: "work_item", field: "title" }),
16333
+ description: Object.freeze({
16334
+ source: "work_item",
16335
+ field: "description"
16336
+ }),
16337
+ field: (fieldName) => Object.freeze({ source: "work_item", field: `fields.${fieldName}` })
16338
+ });
16339
+ var WORK_ITEM_FIELD_BINDINGS = {
16340
+ workItemTitle: { source: "work_item", field: "title" },
16341
+ workItemDescription: { source: "work_item", field: "description" }
16342
+ };
16343
+ function makeStepInputCtx(inputSchema) {
16344
+ const baseAccessor = createInputAccessor(inputSchema);
16345
+ const input = new Proxy(baseAccessor, {
16346
+ get(target, prop) {
16347
+ if (typeof prop === "string" && prop in WORK_ITEM_FIELD_BINDINGS) {
16348
+ return WORK_ITEM_FIELD_BINDINGS[prop];
16349
+ }
16350
+ return target[prop];
16351
+ }
16352
+ });
16353
+ return {
16354
+ input,
16355
+ signal(step, key) {
16356
+ return { source: "step_signal", step, signalKey: key };
16357
+ },
16358
+ output(step) {
16359
+ return { source: "step_output", step };
16360
+ },
16361
+ literal: literal2
16362
+ };
16363
+ }
16364
+ function literal2(value) {
16365
+ return { source: "literal", value };
16366
+ }
16367
+ function normalizeInputMapping(mapping) {
16368
+ if (!mapping)
16369
+ return;
16370
+ const out = {};
16371
+ for (const [key, value] of Object.entries(mapping)) {
16372
+ if (value === undefined)
16373
+ continue;
16374
+ out[key] = isInputAccessor(value) ? materializeAccessor(value) : value;
16375
+ }
16376
+ return out;
16377
+ }
16378
+ function resolveAdditionalStepInputBindings(label, definition) {
16379
+ if (!definition) {
16380
+ return {};
16381
+ }
16382
+ const raw = definition.bindings({
16383
+ workItemField: (fieldName) => ({
16384
+ source: "work_item",
16385
+ field: `fields.${fieldName}`
16386
+ }),
16387
+ literal: literal2
16388
+ });
16389
+ if (definition.schema instanceof exports_external.ZodObject) {
16390
+ const validKeys = new Set(Object.keys(definition.schema.shape));
16391
+ const unknown2 = Object.keys(raw).filter((key) => !validKeys.has(key));
16392
+ if (unknown2.length > 0) {
16393
+ throw new Error(`${label}.bindings returned key${unknown2.length > 1 ? "s" : ""} not in schema: ${unknown2.map((key) => `"${key}"`).join(", ")}`);
16394
+ }
16395
+ }
16396
+ return normalizeInputMapping(raw) ?? {};
16397
+ }
16398
+ function mergeStepBindings(pipelineBindings, explicitBindings) {
16399
+ const merged = {
16400
+ ...pipelineBindings,
16401
+ ...explicitBindings ?? {}
16402
+ };
16403
+ return Object.keys(merged).length > 0 ? merged : undefined;
16404
+ }
16405
+
16269
16406
  // src/definitions/pipelines/builder.ts
16270
16407
  class PipelineStepAdvancementBuilder {
16271
16408
  inputSchema;
@@ -16282,6 +16419,8 @@ class PipelineStepAdvancementBuilder {
16282
16419
  }
16283
16420
  advance(callback) {
16284
16421
  const last = this.steps.at(-1);
16422
+ if (!last)
16423
+ throw new Error("Internal error: no steps available");
16285
16424
  const ctx = makeAdvanceCtx();
16286
16425
  const result = callback(ctx);
16287
16426
  const policy = {
@@ -16378,80 +16517,6 @@ class PipelineBuilder {
16378
16517
  return new PipelineStepAdvancementBuilder(this.inputSchema, this.meta, this.steps, this.pipelineInputBindings, this.pipelineStepInputBindings);
16379
16518
  }
16380
16519
  }
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
16520
  function pipeline(meta3) {
16456
16521
  return new PipelineBuilder(meta3);
16457
16522
  }
@@ -16469,7 +16534,7 @@ var buildPipelineDefinitionsClient = (pipelineDefinitions) => {
16469
16534
  });
16470
16535
  if (result.error)
16471
16536
  throw new Error(JSON.stringify(result.error));
16472
- return result.data ?? [];
16537
+ return result.data;
16473
16538
  },
16474
16539
  upsertFromSpec: async (projectId, spec, stepDefs, options) => {
16475
16540
  const stepDefMap = new Map;
@@ -16549,7 +16614,7 @@ function makeFieldRef(fact, path) {
16549
16614
  };
16550
16615
  }
16551
16616
  function makeAssign(pipeline2) {
16552
- if (typeof pipeline2 !== "object" || pipeline2 === null || typeof pipeline2["key"] !== "string" || !Array.isArray(pipeline2["steps"])) {
16617
+ if (typeof pipeline2 !== "object" || typeof pipeline2["key"] !== "string" || !Array.isArray(pipeline2["steps"])) {
16553
16618
  throw new Error("assign() requires a pipeline spec produced by pipeline().build(). " + "Pass the default-exported value from a pipeline definition file.");
16554
16619
  }
16555
16620
  return { _tag: "assign", pipeline: pipeline2 };
@@ -16598,13 +16663,10 @@ function serializeConditionNode(condition) {
16598
16663
  value: condition.value
16599
16664
  };
16600
16665
  }
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) };
16666
+ if (condition.mode === "all") {
16667
+ return { all: condition.conditions.map(serializeConditionNode) };
16606
16668
  }
16607
- throw new Error(`Unknown condition tag: ${JSON.stringify(condition["_tag"])}`);
16669
+ return { any: condition.conditions.map(serializeConditionNode) };
16608
16670
  }
16609
16671
  function serializeOutcome(outcome) {
16610
16672
  if (outcome._tag === "skip")
@@ -16682,7 +16744,9 @@ function extractRoutePipelineKeys(policy) {
16682
16744
  }
16683
16745
  var PUSH_SCRIPT_NAMES = new Set(["push.ts", "push.mjs", "push.js"]);
16684
16746
  async function pushFromDirectory(dir, opts) {
16685
- const log = opts.log ?? ((msg) => console.log(msg));
16747
+ const log = opts.log ?? ((msg) => {
16748
+ console.warn(msg);
16749
+ });
16686
16750
  const headers = { Authorization: `Bearer ${opts.accessToken}` };
16687
16751
  const absDir = resolve(dir);
16688
16752
  const allFiles = readdirSync(absDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
@@ -16740,7 +16804,7 @@ async function pushFromDirectory(dir, opts) {
16740
16804
  const serverSteps = await stepsClient.listByProjectId(opts.projectId, {
16741
16805
  headers
16742
16806
  });
16743
- const stepDefs = (serverSteps ?? []).map((s) => ({
16807
+ const stepDefs = serverSteps.map((s) => ({
16744
16808
  id: s.id,
16745
16809
  key: s.key,
16746
16810
  version: s.version
@@ -16791,6 +16855,9 @@ async function syncDefaultPipelineAssignment(spec, opts, headers, pipelinesClien
16791
16855
  }
16792
16856
  }
16793
16857
  const linearPipelineDefinitionId = pipelineKeyToId.get(serialized.linearPipelineDefinitionKey);
16858
+ if (!linearPipelineDefinitionId) {
16859
+ throw new Error(`Pipeline key "${serialized.linearPipelineDefinitionKey}" was not found on the server.`);
16860
+ }
16794
16861
  const resolvedRules = serialized.rulesJson.rules.map((rule) => {
16795
16862
  if (rule.event.type === "assign" && typeof rule.event.params?.["pipelineKey"] === "string") {
16796
16863
  const pKey = rule.event.params["pipelineKey"];
@@ -1,4 +1,7 @@
1
1
  import { StepExecutions } from "./generated/sdk.gen";
2
+ import type { PostApiStepExecutionsByStepExecutionIdArtifactUploadUrlData, PostApiStepExecutionsByStepExecutionIdArtifactsData } from "./generated/types.gen";
3
+ type CreateArtifactUploadUrlInput = PostApiStepExecutionsByStepExecutionIdArtifactUploadUrlData["body"];
4
+ type RecordStepExecutionArtifactInput = PostApiStepExecutionsByStepExecutionIdArtifactsData["body"];
2
5
  type RequestOptions = {
3
6
  headers?: Record<string, unknown> | undefined;
4
7
  };
@@ -186,5 +189,51 @@ declare const buildStepExecutionPlaneClient: (stepExecutions: StepExecutions) =>
186
189
  resultJson: JsonValue;
187
190
  errorJson: JsonValue;
188
191
  }, options?: RequestOptions) => Promise<void>;
192
+ createArtifactUploadUrl: (stepExecutionId: string, body: CreateArtifactUploadUrlInput, options?: RequestOptions) => Promise<{
193
+ uploadUrl: string;
194
+ storeRef: string;
195
+ objectKey: string;
196
+ expiresInSeconds: number;
197
+ }>;
198
+ recordStepExecutionArtifact: (stepExecutionId: string, body: RecordStepExecutionArtifactInput, options?: RequestOptions) => Promise<{
199
+ id: string;
200
+ stepExecutionId: string;
201
+ relativeStorePath: string;
202
+ storeRef: string;
203
+ objectKey: string;
204
+ sizeBytes: number;
205
+ contentType: string | unknown;
206
+ kind: "generic" | "playwright-trace";
207
+ createdAt: string;
208
+ }>;
209
+ listStepExecutionArtifacts: (stepExecutionId: string, options?: RequestOptions) => Promise<{
210
+ id: string;
211
+ stepExecutionId: string;
212
+ relativeStorePath: string;
213
+ storeRef: string;
214
+ objectKey: string;
215
+ sizeBytes: number;
216
+ contentType: string | unknown;
217
+ kind: "generic" | "playwright-trace";
218
+ createdAt: string;
219
+ }[]>;
220
+ getArtifactDownloadUrl: (stepExecutionId: string, artifactId: string, options?: RequestOptions) => Promise<{
221
+ url: string | unknown;
222
+ sizeBytes: number;
223
+ contentType: string | unknown;
224
+ relativeStorePath: string;
225
+ }>;
226
+ appendStepExecutionLogs: (stepExecutionId: string, body: {
227
+ claimToken: string;
228
+ lines: {
229
+ seq: number;
230
+ stream: "worker" | "ai-server" | "conversation";
231
+ ts: string;
232
+ content: string;
233
+ level: "debug" | "info" | "warn" | "error";
234
+ }[];
235
+ }, options?: RequestOptions) => Promise<{
236
+ nextOffset: number;
237
+ }>;
189
238
  };
190
239
  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.3-alpha",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {