@beeos-ai/bma-sdk 0.4.2 → 1.0.0

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.
Files changed (51) hide show
  1. package/README.md +122 -34
  2. package/dist/core.d.ts +105 -0
  3. package/dist/core.js +406 -0
  4. package/dist/core.js.map +1 -0
  5. package/dist/errors.d.ts +77 -0
  6. package/dist/errors.js +109 -0
  7. package/dist/errors.js.map +1 -0
  8. package/dist/facade-extensions.d.ts +17 -61
  9. package/dist/facade-extensions.js +25 -112
  10. package/dist/facade-extensions.js.map +1 -1
  11. package/dist/generated/facade-extensions-operations.d.ts +133 -0
  12. package/dist/generated/facade-extensions-operations.js +11 -0
  13. package/dist/generated/facade-extensions-operations.js.map +1 -0
  14. package/dist/generated/facade-extensions-resources.d.ts +34 -0
  15. package/dist/generated/facade-extensions-resources.js +47 -0
  16. package/dist/generated/facade-extensions-resources.js.map +1 -0
  17. package/dist/generated/facade-extensions-types.d.ts +14 -0
  18. package/dist/generated/facade-extensions-types.js +2 -0
  19. package/dist/generated/facade-extensions-types.js.map +1 -0
  20. package/dist/generated/rest-operations.d.ts +4079 -0
  21. package/dist/generated/rest-operations.js +234 -0
  22. package/dist/generated/rest-operations.js.map +1 -0
  23. package/dist/generated/rest-resources.d.ts +666 -0
  24. package/dist/generated/rest-resources.js +1124 -0
  25. package/dist/generated/rest-resources.js.map +1 -0
  26. package/dist/generated/rest-types.d.ts +572 -0
  27. package/dist/generated/rest-types.js +2 -0
  28. package/dist/generated/rest-types.js.map +1 -0
  29. package/dist/generated/rest.d.ts +233 -10
  30. package/dist/index.d.ts +41 -76
  31. package/dist/index.js +49 -239
  32. package/dist/index.js.map +1 -1
  33. package/dist/lib/artifacts.d.ts +14 -0
  34. package/dist/lib/artifacts.js +56 -0
  35. package/dist/lib/artifacts.js.map +1 -0
  36. package/dist/lib/tool-runner.d.ts +99 -0
  37. package/dist/lib/tool-runner.js +140 -0
  38. package/dist/lib/tool-runner.js.map +1 -0
  39. package/dist/pagination.d.ts +31 -0
  40. package/dist/pagination.js +66 -0
  41. package/dist/pagination.js.map +1 -0
  42. package/dist/resource.d.ts +8 -0
  43. package/dist/resource.js +9 -0
  44. package/dist/resource.js.map +1 -0
  45. package/dist/streaming.d.ts +27 -0
  46. package/dist/streaming.js +89 -0
  47. package/dist/streaming.js.map +1 -0
  48. package/dist/version.d.ts +1 -0
  49. package/dist/version.js +4 -0
  50. package/dist/version.js.map +1 -0
  51. package/package.json +4 -2
@@ -2073,6 +2073,31 @@ export interface paths {
2073
2073
  patch?: never;
2074
2074
  trace?: never;
2075
2075
  };
2076
+ "/orgs/{orgID}/projects/{projectID}/agent-sessions": {
2077
+ parameters: {
2078
+ query?: never;
2079
+ header?: never;
2080
+ path: {
2081
+ /** @description Organization ID (org_...). */
2082
+ orgID: string;
2083
+ /** @description Project ID (proj_...). */
2084
+ projectID: string;
2085
+ };
2086
+ cookie?: never;
2087
+ };
2088
+ /**
2089
+ * List the project's agent sessions
2090
+ * @description Lists the conversation sessions of every agent in the project, ordered by creation time. Each agent's default session (the legacy /api/v1 conversation), archived sessions and subagent sessions are left out unless requested. Pages are keyset pages: pass the last session of a page as `after_id` with the same `order` to read the next one.
2091
+ */
2092
+ get: operations["listProjectAgentSessions"];
2093
+ put?: never;
2094
+ post?: never;
2095
+ delete?: never;
2096
+ options?: never;
2097
+ head?: never;
2098
+ patch?: never;
2099
+ trace?: never;
2100
+ };
2076
2101
  "/orgs/{orgID}/projects/{projectID}/agent-sessions/{sessionID}": {
2077
2102
  parameters: {
2078
2103
  query?: never;
@@ -2127,6 +2152,35 @@ export interface paths {
2127
2152
  patch?: never;
2128
2153
  trace?: never;
2129
2154
  };
2155
+ "/orgs/{orgID}/projects/{projectID}/agents/{agentID}/tool-calls/{toolCallID}": {
2156
+ parameters: {
2157
+ query?: never;
2158
+ header?: never;
2159
+ path: {
2160
+ /** @description Organization ID (org_...). */
2161
+ orgID: string;
2162
+ /** @description Project ID (proj_...). */
2163
+ projectID: string;
2164
+ /** @description Agent ID (agt_...). */
2165
+ agentID: string;
2166
+ /** @description Tool call ID (tcl_...). */
2167
+ toolCallID: components["schemas"]["ToolCallID"];
2168
+ };
2169
+ cookie?: never;
2170
+ };
2171
+ /**
2172
+ * Get a tool call
2173
+ * @description Reads one tool call of this agent, including its type and current state. A consumer of custom tool calls uses it to tell whether a call still waits for a result.
2174
+ */
2175
+ get: operations["getToolCall"];
2176
+ put?: never;
2177
+ post?: never;
2178
+ delete?: never;
2179
+ options?: never;
2180
+ head?: never;
2181
+ patch?: never;
2182
+ trace?: never;
2183
+ };
2130
2184
  "/orgs/{orgID}/projects/{projectID}/agents/{agentID}/tool-calls/{toolCallID}/result": {
2131
2185
  parameters: {
2132
2186
  query?: never;
@@ -2555,7 +2609,7 @@ export interface paths {
2555
2609
  };
2556
2610
  /**
2557
2611
  * List files
2558
- * @description Lists the project's files, newest first. scope_id keeps the files scoped to one session (the files it produced); each metadata filter (key:value) must match a label of the file. Session instances created by mounting a file are never listed; read them through the session's resources.
2612
+ * @description Lists the project's files, newest first. scope_id keeps the files scoped to one session (the files it produced); each metadata filter (key:value) must match a label of the file. Session instances created by mounting a file are never listed; read them through the session's resources. A session output (a session-scoped file labelled output_path) written again at the same path is a new version of that output: only the newest version of each path is listed unless include_superseded is true. Older versions stay readable and downloadable by id.
2559
2613
  */
2560
2614
  get: operations["listFiles"];
2561
2615
  put?: never;
@@ -4137,7 +4191,10 @@ export interface paths {
4137
4191
  };
4138
4192
  cookie?: never;
4139
4193
  };
4140
- /** Download daemon file */
4194
+ /**
4195
+ * Download daemon file
4196
+ * @description For an edit_file process the answer is the replacement (application/vnd.bma.file-edit+json) for the executor to apply, and only to an executor that sends X-BMA-Accept-File-Edit; any other executor gets a 409 and leaves the file unchanged.
4197
+ */
4141
4198
  get: operations["downloadDaemonFile"];
4142
4199
  put?: never;
4143
4200
  /** Upload daemon file */
@@ -4234,7 +4291,7 @@ export interface paths {
4234
4291
  put?: never;
4235
4292
  /**
4236
4293
  * Store a session output file
4237
- * @description Stores a file the agent wrote below /mnt/session/outputs as a file scoped to the process's agent session (listed by GET /files with scope_id). The process must be running on the calling machine or have ended within the last 15 minutes. Uploading the same path with the same content again returns the existing file (200). An output the project file storage limit cannot hold is 422.
4294
+ * @description Stores a file the agent wrote below /mnt/session/outputs as a file scoped to the process's agent session (listed by GET /files with scope_id). The process must be running on the calling machine or have ended within the last 15 minutes. New content at a path is a new version of that output, which GET /files lists in place of the older ones. Uploading the content of the path's newest version again returns that file (200). An output the project file storage limit cannot hold is 422.
4238
4295
  */
4239
4296
  post: operations["uploadDaemonSessionOutput"];
4240
4297
  delete?: never;
@@ -4528,6 +4585,7 @@ export interface components {
4528
4585
  /** @description An agent config as a JSON object. This schema is the source of truth for agent configs: the server compiles YAML and JSON configs against it. */
4529
4586
  AgentConfigDefinition: {
4530
4587
  git_credentials?: components["schemas"]["AgentConfigDefinitionGitCredentials"];
4588
+ harness?: components["schemas"]["AgentConfigDefinitionHarness"];
4531
4589
  instruction: string;
4532
4590
  interaction_handlers?: components["schemas"]["AgentConfigDefinitionInteractionHandlers"];
4533
4591
  machine_sources?: components["schemas"]["AgentConfigDefinitionMachineSources"];
@@ -4644,6 +4702,12 @@ export interface components {
4644
4702
  /** @enum {string} */
4645
4703
  access: "read" | "read_write";
4646
4704
  };
4705
+ /** @description Experimental. Which brain runs the agent's sessions: what it is, not where it runs. Omitted, or kind bma, is the BMA harness, which always runs on the server. Kind acp runs an Agent Client Protocol agent (agent dsh) on the session's machine and requires machine_sources; where it runs follows the session's machine sources (a machine pool is a sandbox, a BYO machine is local). */
4706
+ AgentConfigDefinitionHarness: {
4707
+ /** @enum {unknown} */
4708
+ kind: "bma" | "acp";
4709
+ agent?: string;
4710
+ };
4647
4711
  AgentConfigDefinitionMemoryStores: components["schemas"]["AgentConfigDefinitionMemoryStore"][] | null;
4648
4712
  AgentConfigDefinitionModel: {
4649
4713
  /** @enum {unknown} */
@@ -6072,6 +6136,13 @@ export interface components {
6072
6136
  };
6073
6137
  max_subagents?: number;
6074
6138
  max_depth?: number;
6139
+ harness?: components["schemas"]["CompiledHarness"];
6140
+ };
6141
+ /** @description Experimental. A non-default harness; absent for the BMA harness on the server. Where it runs is not part of the agent config: it follows the session's machine sources. */
6142
+ CompiledHarness: {
6143
+ /** @enum {string} */
6144
+ kind: "acp";
6145
+ agent: string;
6075
6146
  };
6076
6147
  CompiledAgentModel: {
6077
6148
  configured_model_id: components["schemas"]["ConfiguredModelID"];
@@ -6254,6 +6325,13 @@ export interface components {
6254
6325
  CreateAgentProfileRequest: {
6255
6326
  name: components["schemas"]["ResourceName"];
6256
6327
  config: components["schemas"]["AgentConfigID"];
6328
+ /** @description Caller-owned free-text description of the profile. */
6329
+ description?: string | null;
6330
+ metadata?: components["schemas"]["AgentProfileMetadata"];
6331
+ };
6332
+ /** @description Caller-owned labels of an agent profile (string keys and values). */
6333
+ AgentProfileMetadata: {
6334
+ [key: string]: string;
6257
6335
  };
6258
6336
  UpdateAgentProfileRequest: {
6259
6337
  config: components["schemas"]["AgentConfigID"];
@@ -6261,6 +6339,10 @@ export interface components {
6261
6339
  };
6262
6340
  RenameAgentProfileRequest: {
6263
6341
  name: components["schemas"]["ResourceName"];
6342
+ /** @description Omit to keep the stored description; an empty string clears it. */
6343
+ description?: string | null;
6344
+ /** @description Omit to keep the stored metadata; an object replaces it. */
6345
+ metadata?: components["schemas"]["AgentProfileMetadata"];
6264
6346
  };
6265
6347
  AgentProfileSummary: {
6266
6348
  id: components["schemas"]["AgentProfileID"];
@@ -6270,6 +6352,9 @@ export interface components {
6270
6352
  current_config_id: components["schemas"]["AgentConfigID"];
6271
6353
  /** Format: int32 */
6272
6354
  current_generation: number;
6355
+ /** @description Caller-owned free-text description of the profile. */
6356
+ description?: string | null;
6357
+ metadata?: components["schemas"]["AgentProfileMetadata"];
6273
6358
  created_at: components["schemas"]["Timestamp"];
6274
6359
  updated_at: components["schemas"]["Timestamp"];
6275
6360
  current_config: components["schemas"]["AgentConfigSummary"];
@@ -6293,6 +6378,9 @@ export interface components {
6293
6378
  current_config_id: components["schemas"]["AgentConfigID"];
6294
6379
  /** Format: int32 */
6295
6380
  current_generation: number;
6381
+ /** @description Caller-owned free-text description of the profile. */
6382
+ description?: string | null;
6383
+ metadata?: components["schemas"]["AgentProfileMetadata"];
6296
6384
  created_at: components["schemas"]["Timestamp"];
6297
6385
  updated_at: components["schemas"]["Timestamp"];
6298
6386
  current_config: components["schemas"]["AgentConfig"];
@@ -6751,6 +6839,12 @@ export interface components {
6751
6839
  * @default false
6752
6840
  */
6753
6841
  expires_with_session: boolean;
6842
+ /** @description Model context window in tokens. When omitted, BMA reads it from the provider's models endpoint, then a public model catalog, and otherwise uses 128000. */
6843
+ context_window_tokens?: number;
6844
+ /** @description Maximum output tokens per response; must be below the context window. When omitted, BMA keeps its default output policy for the API format. */
6845
+ max_output_tokens?: number;
6846
+ /** @description Compact the session as if the context window were this size, to bound per-turn cost and latency on large-window models. Must not exceed the context window. */
6847
+ auto_compact_window_tokens?: number;
6754
6848
  };
6755
6849
  AgentModelOverridePatch: {
6756
6850
  model?: string;
@@ -6845,6 +6939,11 @@ export interface components {
6845
6939
  data: components["schemas"]["AgentSession"][];
6846
6940
  next_before_id?: string | null;
6847
6941
  };
6942
+ ListProjectAgentSessionsResponse: {
6943
+ data: components["schemas"]["AgentSession"][];
6944
+ /** @description The `after_id` of the next page, or null on the last page. */
6945
+ next_after_id: string | null;
6946
+ };
6848
6947
  CreateAgentSessionRequest: {
6849
6948
  agent_config_id?: string;
6850
6949
  /** @description Compiled and saved as this session's immutable config in the create transaction. The session's machine sources, model and instruction come from this source; they do not change the shared agent or its other sessions. */
@@ -6868,6 +6967,11 @@ export interface components {
6868
6967
  metadata?: {
6869
6968
  [key: string]: unknown;
6870
6969
  };
6970
+ /**
6971
+ * Format: date-time
6972
+ * @description Optimistic version check. The update applies only while the session's updated_at still equals this value; otherwise it answers 409 conflict. Anything that writes the session (an update, the automatic title) moves updated_at.
6973
+ */
6974
+ expected_updated_at?: string;
6871
6975
  };
6872
6976
  CreateAgentInputRequest: {
6873
6977
  /** @description At most 20 inline media blocks per submission, each holding up to 10 MiB of decoded media and up to 24 MiB decoded across the submission. Non-media blocks may hold up to 1 MiB combined. The whole request body is capped at 48 MiB. */
@@ -6902,6 +7006,8 @@ export interface components {
6902
7006
  ToolCall: {
6903
7007
  id: components["schemas"]["ToolCallID"];
6904
7008
  agent_id: components["schemas"]["AgentID"];
7009
+ /** @description Agent session (ses_...) whose turn made the call. */
7010
+ session_id: string;
6905
7011
  turn_id: components["schemas"]["AgentTurnID"];
6906
7012
  provider_call_id: string;
6907
7013
  name: string;
@@ -6947,6 +7053,9 @@ export interface components {
6947
7053
  content_blocks: components["schemas"]["ToolResultContentBlock"][];
6948
7054
  created_at: components["schemas"]["Timestamp"];
6949
7055
  };
7056
+ ToolCallEnvelope: {
7057
+ tool_call: components["schemas"]["ToolCall"];
7058
+ };
6950
7059
  SubmitToolCallResultResponse: {
6951
7060
  tool_call: components["schemas"]["ToolCall"];
6952
7061
  tool_result: components["schemas"]["ToolResult"];
@@ -7224,7 +7333,32 @@ export interface components {
7224
7333
  event: components["schemas"]["ModelOutputStreamDelta"];
7225
7334
  };
7226
7335
  /** @description One JSON payload from the event stream: an authoritative durable event, a best-effort tool-call update, a best-effort model-output preview, or a stream-closing error. The wire response ends after an error payload; `service_unavailable` is retryable and other current codes are terminal. */
7227
- AgentEventStreamData: components["schemas"]["AgentEvent"] | components["schemas"]["ToolCallUpdate"] | components["schemas"]["ModelOutputDelta"] | components["schemas"]["Error"];
7336
+ AgentEventStreamData: components["schemas"]["AgentEvent"] | components["schemas"]["ToolCallUpdate"] | components["schemas"]["ModelOutputDelta"] | components["schemas"]["ExecutorInteractionUpdate"] | components["schemas"]["AgentEventDelta"] | components["schemas"]["Error"];
7337
+ /** @description Best-effort stream frame of an agent executor session: an executor interaction (permission or question) opened or closed. tool_call_id is the agent.tool_use event ID for permissions and the interaction ID otherwise. */
7338
+ ExecutorInteractionUpdate: {
7339
+ /** @enum {string} */
7340
+ type: "executor_interaction_update";
7341
+ session_id: string;
7342
+ tool_call_id: string;
7343
+ state: components["schemas"]["AgentInteractionState"];
7344
+ interaction_update: {
7345
+ interaction_id: components["schemas"]["AgentInteractionID"];
7346
+ state: components["schemas"]["AgentInteractionState"];
7347
+ interaction_kind: components["schemas"]["AgentInteractionKind"];
7348
+ };
7349
+ };
7350
+ /** @description Best-effort preview frame of an agent executor session, sent only with stream_deltas: text appended to content block `index` of the executor event `event_id` before the durable executor_event arrives. */
7351
+ AgentEventDelta: {
7352
+ /** @enum {string} */
7353
+ type: "agent_event_delta";
7354
+ session_id: string;
7355
+ turn_id: string;
7356
+ event_id: string;
7357
+ event_type: string;
7358
+ /** Format: int64 */
7359
+ index: number;
7360
+ text: string;
7361
+ };
7228
7362
  ListAgentEventsResponse: {
7229
7363
  data: components["schemas"]["AgentEvent"][];
7230
7364
  /** @description Sequence to pass as after_sequence on the next request. Equals the request boundary when no events are returned. */
@@ -7912,7 +8046,7 @@ export interface components {
7912
8046
  archive_after_paused_days?: number;
7913
8047
  /**
7914
8048
  * Format: int32
7915
- * @description Delete a paused machine once it is this many days old, counted from the machine's creation (for a session machine, the session's start); activity does not extend it. A session that receives input after its machine was deleted gets a fresh machine. Requires pause_after_idle_minutes; cannot be combined with archive_after_paused_days.
8049
+ * @description Days a machine stays paused before it is deleted, counted from when it paused; a resume ends the paused period and the next pause starts a new one. A session that receives input after its machine was deleted gets a fresh machine. Machines kept for a person (idle deletion disabled with 0 on their binding or grant) are never deleted by it. Requires pause_after_idle_minutes; cannot be combined with archive_after_paused_days.
7916
8050
  */
7917
8051
  delete_after_paused_days?: number;
7918
8052
  metadata?: components["schemas"]["MachineMetadata"];
@@ -8004,7 +8138,7 @@ export interface components {
8004
8138
  archive_after_paused_days?: number | null;
8005
8139
  /**
8006
8140
  * Format: int32
8007
- * @description Delete a paused machine once it is this many days old, counted from the machine's creation. Null clears it; omitted leaves it unchanged. Requires pause_after_idle_minutes; cannot be combined with archive_after_paused_days.
8141
+ * @description Days a machine stays paused before it is deleted, counted from when it paused. Null clears it; omitted leaves it unchanged. Requires pause_after_idle_minutes; cannot be combined with archive_after_paused_days.
8008
8142
  */
8009
8143
  delete_after_paused_days?: number | null;
8010
8144
  metadata?: components["schemas"]["MachineMetadata"];
@@ -8078,7 +8212,7 @@ export interface components {
8078
8212
  archive_after_paused_days: number | null;
8079
8213
  /**
8080
8214
  * Format: int32
8081
- * @description Age in days, counted from the machine's creation, after which a paused machine is deleted, or null when the pool keeps paused machines.
8215
+ * @description Days a machine stays paused before it is deleted, counted from when it paused, or null when the pool keeps paused machines.
8082
8216
  */
8083
8217
  delete_after_paused_days: number | null;
8084
8218
  metadata: components["schemas"]["Metadata"];
@@ -8690,6 +8824,11 @@ export interface components {
8690
8824
  };
8691
8825
  ModelUsageTotals: {
8692
8826
  model: components["schemas"]["UsageModel"];
8827
+ /**
8828
+ * @description What the calls were for. `turn` is ordinary agent model calls; `title` is the automatic session-title request, made with the session's own model credentials; `harness` is the model requests of an ACP harness (agent config `harness.kind: acp`) through the platform's harness model endpoint. A model used for several appears once per purpose.
8829
+ * @enum {string}
8830
+ */
8831
+ purpose?: "turn" | "title" | "harness";
8693
8832
  /** Format: int64 */
8694
8833
  model_calls: number;
8695
8834
  tokens: components["schemas"]["UsageTokenTotals"];
@@ -8697,7 +8836,7 @@ export interface components {
8697
8836
  };
8698
8837
  UsageReport: {
8699
8838
  totals: components["schemas"]["UsageTotals"];
8700
- /** @description Per-model rows ordered by provider config name, configured model name, then provider model slug. Models with distinct provider slugs across revisions appear once per slug. */
8839
+ /** @description Per-model rows ordered by provider config name, configured model name, provider model slug, then purpose. Models with distinct provider slugs across revisions appear once per slug, and once per purpose. */
8701
8840
  by_model: components["schemas"]["ModelUsageTotals"][];
8702
8841
  };
8703
8842
  CurrentUserIdentity: {
@@ -13477,6 +13616,7 @@ export interface operations {
13477
13616
  403: components["responses"]["Forbidden"];
13478
13617
  404: components["responses"]["NotFound"];
13479
13618
  409: components["responses"]["Conflict"];
13619
+ 422: components["responses"]["UnprocessableEntity"];
13480
13620
  };
13481
13621
  };
13482
13622
  getAgentSession: {
@@ -13624,6 +13764,48 @@ export interface operations {
13624
13764
  "5XX": components["responses"]["ServerError"];
13625
13765
  };
13626
13766
  };
13767
+ listProjectAgentSessions: {
13768
+ parameters: {
13769
+ query?: {
13770
+ /** @description Only sessions of agents launched from this profile. */
13771
+ agent_profile_id?: components["schemas"]["AgentProfileID"];
13772
+ include_archived?: boolean;
13773
+ /** @description Also list each agent's default session. */
13774
+ include_default?: boolean;
13775
+ /** @description Also list the sessions of subagents. */
13776
+ include_subagents?: boolean;
13777
+ /** @description Sort direction by creation time. */
13778
+ order?: "asc" | "desc";
13779
+ /** @description Exclusive anchor: return the sessions that follow this session of the project in `order`. The anchor itself may be archived. */
13780
+ after_id?: string;
13781
+ limit?: number;
13782
+ };
13783
+ header?: never;
13784
+ path: {
13785
+ /** @description Organization ID (org_...). */
13786
+ orgID: string;
13787
+ /** @description Project ID (proj_...). */
13788
+ projectID: string;
13789
+ };
13790
+ cookie?: never;
13791
+ };
13792
+ requestBody?: never;
13793
+ responses: {
13794
+ /** @description Agent sessions. */
13795
+ 200: {
13796
+ headers: {
13797
+ [name: string]: unknown;
13798
+ };
13799
+ content: {
13800
+ "application/json": components["schemas"]["ListProjectAgentSessionsResponse"];
13801
+ };
13802
+ };
13803
+ 400: components["responses"]["BadRequest"];
13804
+ 401: components["responses"]["Unauthorized"];
13805
+ 403: components["responses"]["Forbidden"];
13806
+ 404: components["responses"]["NotFound"];
13807
+ };
13808
+ };
13627
13809
  getProjectAgentSession: {
13628
13810
  parameters: {
13629
13811
  query?: never;
@@ -13698,6 +13880,42 @@ export interface operations {
13698
13880
  "5XX": components["responses"]["ServerError"];
13699
13881
  };
13700
13882
  };
13883
+ getToolCall: {
13884
+ parameters: {
13885
+ query?: never;
13886
+ header?: never;
13887
+ path: {
13888
+ /** @description Organization ID (org_...). */
13889
+ orgID: string;
13890
+ /** @description Project ID (proj_...). */
13891
+ projectID: string;
13892
+ /** @description Agent ID (agt_...). */
13893
+ agentID: string;
13894
+ /** @description Tool call ID (tcl_...). */
13895
+ toolCallID: components["schemas"]["ToolCallID"];
13896
+ };
13897
+ cookie?: never;
13898
+ };
13899
+ requestBody?: never;
13900
+ responses: {
13901
+ /** @description Tool call. */
13902
+ 200: {
13903
+ headers: {
13904
+ [name: string]: unknown;
13905
+ };
13906
+ content: {
13907
+ "application/json": components["schemas"]["ToolCallEnvelope"];
13908
+ };
13909
+ };
13910
+ 400: components["responses"]["BadRequest"];
13911
+ 401: components["responses"]["Unauthorized"];
13912
+ 403: components["responses"]["Forbidden"];
13913
+ 404: components["responses"]["NotFound"];
13914
+ 503: components["responses"]["ServiceUnavailable"];
13915
+ "4XX": components["responses"]["ClientError"];
13916
+ "5XX": components["responses"]["ServerError"];
13917
+ };
13918
+ };
13701
13919
  submitToolCallResult: {
13702
13920
  parameters: {
13703
13921
  query?: never;
@@ -13890,7 +14108,7 @@ export interface operations {
13890
14108
  };
13891
14109
  requestBody?: never;
13892
14110
  responses: {
13893
- /** @description Server-sent event stream. Durable frames use `agent_input`, `model_output`, `tool_result`, or `context_checkpoint` as the SSE event name and set the SSE `id` field to the event's `sequence`, which reconnects can replay via `Last-Event-ID`. Best-effort tool lifecycle updates use `tool_call_update` and cover this agent and every subagent beneath it, model previews use `model_output_delta`, and stream-closing errors use `error`; none carries an SSE `id`, so reconnects resume from the last durable event. The response closes after every `error` frame. Raw clients reconnect when the error's stable code is `service_unavailable` and treat other current codes as terminal. Heartbeats are SSE comments and carry no JSON payload. */
14111
+ /** @description Server-sent event stream. Durable frames use `agent_input`, `model_output`, `tool_result`, or `context_checkpoint` as the SSE event name and set the SSE `id` field to the event's `sequence`, which reconnects can replay via `Last-Event-ID`. Best-effort tool lifecycle updates use `tool_call_update` and cover this agent and every subagent beneath it, model previews use `model_output_delta`, and stream-closing errors use `error`; none carries an SSE `id`, so reconnects resume from the last durable event. The response closes after every `error` frame. Raw clients reconnect when the error's stable code is `service_unavailable` and treat other current codes as terminal. Agent executor sessions also emit `executor_event` durable frames, best-effort `executor_interaction_update` frames, and, with `stream_deltas`, best-effort `agent_event_delta` frames. Heartbeats are SSE comments and carry no JSON payload. `x-sse-item-schema` maps every SSE event name to its JSON payload schema in the shape of the OpenAPI 3.2 `itemSchema`. */
13894
14112
  200: {
13895
14113
  headers: {
13896
14114
  [name: string]: unknown;
@@ -14372,6 +14590,8 @@ export interface operations {
14372
14590
  page?: string;
14373
14591
  /** @description Only files scoped to this session (ses_...). */
14374
14592
  scope_id?: string;
14593
+ /** @description Also list the older versions of session outputs. Defaults to false, so each session output path lists only its newest version. */
14594
+ include_superseded?: boolean;
14375
14595
  /** @description Label filter as key:value, for example beework_space_id:sp_123. Repeat to require several labels. */
14376
14596
  metadata?: string[];
14377
14597
  };
@@ -17467,7 +17687,10 @@ export interface operations {
17467
17687
  downloadDaemonFile: {
17468
17688
  parameters: {
17469
17689
  query?: never;
17470
- header?: never;
17690
+ header?: {
17691
+ /** @description The executor applies edit_file replacements itself. */
17692
+ "X-BMA-Accept-File-Edit"?: boolean;
17693
+ };
17471
17694
  path: {
17472
17695
  /** @description Process ID (prc_...). */
17473
17696
  processID: components["schemas"]["ProcessID"];
package/dist/index.d.ts CHANGED
@@ -1,90 +1,55 @@
1
1
  import { type Client } from "openapi-fetch";
2
2
  import type { components, operations, paths } from "./generated/rest.js";
3
+ import { RestClientBase } from "./generated/rest-resources.js";
4
+ import { SDK_VERSION } from "./version.js";
5
+ export { SDK_VERSION };
3
6
  export type { components, operations, paths };
4
- export type Schemas = components["schemas"];
5
- /** Hosted BMA API root, including the /v1 prefix. */
6
- export declare const DEFAULT_BASE_URL = "https://api.bma.beeos.ai/v1";
7
- export declare const SDK_VERSION = "0.4.2";
7
+ export type * from "./generated/rest-types.js";
8
+ export type * from "./generated/rest-operations.js";
9
+ export * as Resources from "./generated/rest-resources.js";
10
+ export { APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, AuthenticationError, BadRequestError, BmaApiError, BmaError, ConflictError, ContentTooLargeError, EventStreamError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, RequestTimeoutError, ServiceUnavailableError, UnprocessableEntityError, type ErrorCode, } from "./errors.js";
11
+ export { DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, type RequestOptions, type Uploadable } from "./core.js";
12
+ export { PagePromise, type CursorPageBody, type Page, type PageItem } from "./pagination.js";
13
+ export { Stream } from "./streaming.js";
14
+ export { defineTool, ToolError, type RunnableTool, type ToolOutput, type ToolRunContext, type ToolRunner, type ToolRunnerParams } from "./lib/tool-runner.js";
15
+ export type { DownloadArtifactOptions } from "./lib/artifacts.js";
16
+ export type { StreamEventsEvent as AgentStreamEvent } from "./generated/rest-operations.js";
17
+ /** Hosted BMA origin; the client adds the /api/v1 prefix. */
18
+ export declare const DEFAULT_BASE_URL = "https://api.bma.beeos.ai";
8
19
  export interface BmaClientOptions {
9
- /** BMA personal or organization bearer token. */
10
- token: string;
11
- /** API root, for example https://api.bma.beeos.ai/v1 or https://host/api/v1. */
20
+ /** BMA personal or organization bearer token; env BMA_TOKEN. */
21
+ token?: string;
22
+ /**
23
+ * Deployment origin, for example https://api.bma.beeos.ai; env BMA_BASE_URL.
24
+ * The client adds /api/v1; a value that already ends with /api/v1 is accepted.
25
+ */
12
26
  baseUrl?: string;
27
+ /** Default organization (org_...) for org- and project-scoped methods; env BMA_ORG_ID. */
28
+ orgId?: string;
29
+ /** Default project (prj_...) for project-scoped methods; env BMA_PROJECT_ID. */
30
+ projectId?: string;
31
+ /**
32
+ * Per-attempt timeout in milliseconds until the response headers arrive
33
+ * (default 60 000; 0 disables it). Uploads have no default timeout.
34
+ */
35
+ timeout?: number;
36
+ /** Retries after the first attempt (default 2). */
37
+ maxRetries?: number;
13
38
  /** Optional fetch implementation; defaults to globalThis.fetch. */
14
39
  fetch?: typeof globalThis.fetch;
15
40
  }
16
- /** A non-2xx response from the BMA API. */
17
- export declare class BmaApiError extends Error {
18
- readonly status: number;
19
- readonly code: string;
20
- readonly currentDigest?: string;
21
- readonly issues?: Schemas["AgentConfigErrorIssue"][];
22
- constructor(status: number, body: unknown);
23
- /** Whether a retry may succeed without changing the request. */
24
- get retryable(): boolean;
41
+ /** Authenticated BMA REST client. */
42
+ export declare class BmaClient extends RestClientBase {
43
+ /**
44
+ * Escape hatch: the openapi-fetch client typed by contract path, for
45
+ * operations without a resource method (Machine Daemon). Pair with unwrap().
46
+ */
47
+ readonly rest: Client<paths>;
48
+ constructor(options?: BmaClientOptions);
25
49
  }
26
- /**
27
- * Returns `data` from an openapi-fetch result or throws BmaApiError.
28
- *
29
- * ```ts
30
- * const agent = unwrap(await bma.rest.GET("/orgs/{orgID}/projects/{projectID}/agents/{agentID}", { params }));
31
- * ```
32
- */
50
+ /** Escape hatch companion of `bma.rest`: returns `data` or throws the typed error. */
33
51
  export declare function unwrap<T>(result: {
34
52
  data?: T;
35
53
  error?: unknown;
36
54
  response: Response;
37
55
  }): T;
38
- export interface StreamEventsOptions {
39
- orgID: string;
40
- projectID: string;
41
- agentID: string;
42
- /** Agent session (ses_...). Omit for the agent's default session. */
43
- sessionId?: string;
44
- afterSequence?: number;
45
- /** Resume after this durable sequence (sent as Last-Event-ID). */
46
- lastEventId?: number;
47
- streamDeltas?: boolean;
48
- signal?: AbortSignal;
49
- }
50
- /** One SSE data frame. `data` is the parsed JSON payload. */
51
- export interface StreamFrame {
52
- event: string;
53
- id?: string;
54
- /** Durable event sequence; set only for frames that carry an SSE id. */
55
- sequence?: number;
56
- data: Schemas["AgentEventStreamData"];
57
- }
58
- export interface DownloadArtifactOptions {
59
- /** Explicit product limit; artifacts larger than this are refused. */
60
- maxBytes: number;
61
- signal?: AbortSignal;
62
- }
63
- /** Authenticated BMA REST client. */
64
- export declare class BmaClient {
65
- /** Generated, fully typed openapi-fetch client for every contract operation. */
66
- readonly rest: Client<paths>;
67
- readonly baseUrl: string;
68
- private readonly token;
69
- private readonly fetchImpl;
70
- constructor(options: BmaClientOptions);
71
- private headers;
72
- private send;
73
- /**
74
- * Streams `GET .../agents/{agentID}/events/stream`. Heartbeat comments are
75
- * skipped; the iterator ends when the server closes the stream.
76
- */
77
- streamEvents(options: StreamEventsOptions): AsyncGenerator<StreamFrame>;
78
- /**
79
- * Downloads artifact content and verifies the size and sha256 digest
80
- * recorded on the artifact. The whole body is buffered, bounded by maxBytes.
81
- */
82
- downloadArtifact(artifact: Schemas["Artifact"], options: DownloadArtifactOptions): Promise<Uint8Array<ArrayBuffer>>;
83
- }
84
- interface RawSSEFrame {
85
- event: string;
86
- id?: string;
87
- data: string;
88
- }
89
- /** Minimal text/event-stream parser (WHATWG SSE field rules). */
90
- export declare function parseSSE(body: ReadableStream<Uint8Array>): AsyncGenerator<RawSSEFrame>;