@buildanagent/sdk 0.1.0-alpha.12 → 0.1.0-alpha.13

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.
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * `SafetyError`: the safety package's error for programmer errors, such as a write outcome with a malformed reason, an
3
3
  * input that has no canonical JSON form, a key ring that can't sign, or a model request that would use a credential
4
- * nobody configured.
4
+ * nobody configured. Its subclass `BudgetExceeded`, in the `./cost` subpath, is the refusal of a model call that would
5
+ * pass a USD cap.
5
6
  */
6
7
  /**
7
8
  * Why a `SafetyError` was thrown. `invalid_outcome`: a write outcome breaks a rule. `invalid_input`: a tool input has
@@ -10,12 +11,19 @@
10
11
  * model provider's key or base URL is empty, malformed or points at a gateway that may bill another credential.
11
12
  * `egress_refused`: a model request would leave for another host or carry another credential. `default_provider`: code
12
13
  * resolved a string model id, or another default provider is set, so a call could reach a gateway nobody configured.
13
- * `invalid_effect`: a guarded write's scope, business key or options break a rule.
14
+ * `invalid_effect`: a guarded write's scope, business key or options break a rule. `invalid_budget`: a cost guard's
15
+ * cap is not a finite number of dollars, 0 or more. `budget_exceeded`: a model call was refused before it was sent,
16
+ * because what the run or session has spent plus the call's projected cost would pass its USD cap. `unknown_price`: a
17
+ * model call was refused before it was sent, because the model has no catalog price or an earlier call reported no
18
+ * usage, so the cap can't be checked.
19
+ */
20
+ export type SafetyErrorCode = "invalid_outcome" | "invalid_input" | "invalid_key_ring" | "invalid_pending" | "invalid_byok_config" | "egress_refused" | "default_provider" | "invalid_effect" | "invalid_budget" | "budget_exceeded" | "unknown_price";
21
+ /**
22
+ * Thrown for a mistake in how the safety package is called, and, as its subclass `BudgetExceeded`, for a model call
23
+ * refused under a USD cap. A write that fails is an outcome, never this error.
14
24
  */
15
- export type SafetyErrorCode = "invalid_outcome" | "invalid_input" | "invalid_key_ring" | "invalid_pending" | "invalid_byok_config" | "egress_refused" | "default_provider" | "invalid_effect";
16
- /** Thrown for a mistake in how the safety package is called. A write that fails is an outcome, never this error. */
17
25
  export declare class SafetyError extends Error {
18
- readonly name = "SafetyError";
26
+ readonly name: string;
19
27
  readonly code: SafetyErrorCode;
20
28
  constructor(code: SafetyErrorCode, message: string, options?: ErrorOptions);
21
29
  }
@@ -1,11 +1,15 @@
1
1
  /**
2
2
  * `SafetyError`: the safety package's error for programmer errors, such as a write outcome with a malformed reason, an
3
3
  * input that has no canonical JSON form, a key ring that can't sign, or a model request that would use a credential
4
- * nobody configured.
4
+ * nobody configured. Its subclass `BudgetExceeded`, in the `./cost` subpath, is the refusal of a model call that would
5
+ * pass a USD cap.
5
6
  */
6
7
  // A registered symbol, so the guard still works when two copies of the package are bundled.
7
8
  const SAFETY_ERROR = Symbol.for("buildanagent.agent-safety.SafetyError");
8
- /** Thrown for a mistake in how the safety package is called. A write that fails is an outcome, never this error. */
9
+ /**
10
+ * Thrown for a mistake in how the safety package is called, and, as its subclass `BudgetExceeded`, for a model call
11
+ * refused under a USD cap. A write that fails is an outcome, never this error.
12
+ */
9
13
  export class SafetyError extends Error {
10
14
  name = "SafetyError";
11
15
  code;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/vendor/agent-safety/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqBH,4FAA4F;AAC5F,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;AAEzE,oHAAoH;AACpH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClB,IAAI,GAAG,aAAa,CAAC;IAC9B,IAAI,CAAkB;IAE/B,YAAY,IAAqB,EAAE,OAAe,EAAE,OAAsB;QACxE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AAED,gFAAgF;AAChF,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAAiC,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;AAClH,CAAC","sourcesContent":["/**\n * `SafetyError`: the safety package's error for programmer errors, such as a write outcome with a malformed reason, an\n * input that has no canonical JSON form, a key ring that can't sign, or a model request that would use a credential\n * nobody configured.\n */\n\n/**\n * Why a `SafetyError` was thrown. `invalid_outcome`: a write outcome breaks a rule. `invalid_input`: a tool input has\n * no canonical JSON form, or a tool's context fails its `contextSchema`. `invalid_key_ring`: a signer's keys or key\n * ids can't be used. `invalid_pending`: the fields of a pending request can't be signed. `invalid_byok_config`: a\n * model provider's key or base URL is empty, malformed or points at a gateway that may bill another credential.\n * `egress_refused`: a model request would leave for another host or carry another credential. `default_provider`: code\n * resolved a string model id, or another default provider is set, so a call could reach a gateway nobody configured.\n * `invalid_effect`: a guarded write's scope, business key or options break a rule.\n */\nexport type SafetyErrorCode =\n | \"invalid_outcome\"\n | \"invalid_input\"\n | \"invalid_key_ring\"\n | \"invalid_pending\"\n | \"invalid_byok_config\"\n | \"egress_refused\"\n | \"default_provider\"\n | \"invalid_effect\";\n\n// A registered symbol, so the guard still works when two copies of the package are bundled.\nconst SAFETY_ERROR = Symbol.for(\"buildanagent.agent-safety.SafetyError\");\n\n/** Thrown for a mistake in how the safety package is called. A write that fails is an outcome, never this error. */\nexport class SafetyError extends Error {\n override readonly name = \"SafetyError\";\n readonly code: SafetyErrorCode;\n\n constructor(code: SafetyErrorCode, message: string, options?: ErrorOptions) {\n super(message, options);\n this.code = code;\n Object.defineProperty(this, SAFETY_ERROR, { value: true });\n }\n}\n\n/** True for a `SafetyError`, including one from another copy of the package. */\nexport function isSafetyError(error: unknown): error is SafetyError {\n return typeof error === \"object\" && error !== null && (error as Record<symbol, unknown>)[SAFETY_ERROR] === true;\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/vendor/agent-safety/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH,4FAA4F;AAC5F,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;AAEzE;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClB,IAAI,GAAW,aAAa,CAAC;IACtC,IAAI,CAAkB;IAE/B,YAAY,IAAqB,EAAE,OAAe,EAAE,OAAsB;QACxE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AAED,gFAAgF;AAChF,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAAiC,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;AAClH,CAAC","sourcesContent":["/**\n * `SafetyError`: the safety package's error for programmer errors, such as a write outcome with a malformed reason, an\n * input that has no canonical JSON form, a key ring that can't sign, or a model request that would use a credential\n * nobody configured. Its subclass `BudgetExceeded`, in the `./cost` subpath, is the refusal of a model call that would\n * pass a USD cap.\n */\n\n/**\n * Why a `SafetyError` was thrown. `invalid_outcome`: a write outcome breaks a rule. `invalid_input`: a tool input has\n * no canonical JSON form, or a tool's context fails its `contextSchema`. `invalid_key_ring`: a signer's keys or key\n * ids can't be used. `invalid_pending`: the fields of a pending request can't be signed. `invalid_byok_config`: a\n * model provider's key or base URL is empty, malformed or points at a gateway that may bill another credential.\n * `egress_refused`: a model request would leave for another host or carry another credential. `default_provider`: code\n * resolved a string model id, or another default provider is set, so a call could reach a gateway nobody configured.\n * `invalid_effect`: a guarded write's scope, business key or options break a rule. `invalid_budget`: a cost guard's\n * cap is not a finite number of dollars, 0 or more. `budget_exceeded`: a model call was refused before it was sent,\n * because what the run or session has spent plus the call's projected cost would pass its USD cap. `unknown_price`: a\n * model call was refused before it was sent, because the model has no catalog price or an earlier call reported no\n * usage, so the cap can't be checked.\n */\nexport type SafetyErrorCode =\n | \"invalid_outcome\"\n | \"invalid_input\"\n | \"invalid_key_ring\"\n | \"invalid_pending\"\n | \"invalid_byok_config\"\n | \"egress_refused\"\n | \"default_provider\"\n | \"invalid_effect\"\n | \"invalid_budget\"\n | \"budget_exceeded\"\n | \"unknown_price\";\n\n// A registered symbol, so the guard still works when two copies of the package are bundled.\nconst SAFETY_ERROR = Symbol.for(\"buildanagent.agent-safety.SafetyError\");\n\n/**\n * Thrown for a mistake in how the safety package is called, and, as its subclass `BudgetExceeded`, for a model call\n * refused under a USD cap. A write that fails is an outcome, never this error.\n */\nexport class SafetyError extends Error {\n override readonly name: string = \"SafetyError\";\n readonly code: SafetyErrorCode;\n\n constructor(code: SafetyErrorCode, message: string, options?: ErrorOptions) {\n super(message, options);\n this.code = code;\n Object.defineProperty(this, SAFETY_ERROR, { value: true });\n }\n}\n\n/** True for a `SafetyError`, including one from another copy of the package. */\nexport function isSafetyError(error: unknown): error is SafetyError {\n return typeof error === \"object\" && error !== null && (error as Record<symbol, unknown>)[SAFETY_ERROR] === true;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildanagent/sdk",
3
- "version": "0.1.0-alpha.12",
3
+ "version": "0.1.0-alpha.13",
4
4
  "description": "The buildanagent SDK: the agent loop, tools, hooks, signed pauses and budgets over the gateway.",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@earendil-works/pi-schema": "1.5.2",
39
39
  "@standard-schema/spec": "1.1.0",
40
- "@buildanagent/gateway": "0.1.0-alpha.12"
40
+ "@buildanagent/gateway": "0.1.0-alpha.13"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@cfworker/json-schema": "4.1.6",