@amigo-ai/platform-sdk 0.1.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 (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +330 -0
  3. package/dist/core/auth.js +32 -0
  4. package/dist/core/auth.js.map +1 -0
  5. package/dist/core/branded-types.js +22 -0
  6. package/dist/core/branded-types.js.map +1 -0
  7. package/dist/core/errors.js +168 -0
  8. package/dist/core/errors.js.map +1 -0
  9. package/dist/core/openapi-client.js +66 -0
  10. package/dist/core/openapi-client.js.map +1 -0
  11. package/dist/core/retry.js +48 -0
  12. package/dist/core/retry.js.map +1 -0
  13. package/dist/core/utils.js +35 -0
  14. package/dist/core/utils.js.map +1 -0
  15. package/dist/index.cjs +1005 -0
  16. package/dist/index.cjs.map +7 -0
  17. package/dist/index.js +111 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/index.mjs +982 -0
  20. package/dist/index.mjs.map +7 -0
  21. package/dist/resources/agents.js +49 -0
  22. package/dist/resources/agents.js.map +1 -0
  23. package/dist/resources/analytics.js +54 -0
  24. package/dist/resources/analytics.js.map +1 -0
  25. package/dist/resources/api-keys.js +45 -0
  26. package/dist/resources/api-keys.js.map +1 -0
  27. package/dist/resources/base.js +50 -0
  28. package/dist/resources/base.js.map +1 -0
  29. package/dist/resources/billing.js +15 -0
  30. package/dist/resources/billing.js.map +1 -0
  31. package/dist/resources/calls.js +28 -0
  32. package/dist/resources/calls.js.map +1 -0
  33. package/dist/resources/context-graphs.js +44 -0
  34. package/dist/resources/context-graphs.js.map +1 -0
  35. package/dist/resources/data-sources.js +29 -0
  36. package/dist/resources/data-sources.js.map +1 -0
  37. package/dist/resources/integrations.js +45 -0
  38. package/dist/resources/integrations.js.map +1 -0
  39. package/dist/resources/memory.js +31 -0
  40. package/dist/resources/memory.js.map +1 -0
  41. package/dist/resources/phone-numbers.js +38 -0
  42. package/dist/resources/phone-numbers.js.map +1 -0
  43. package/dist/resources/services.js +30 -0
  44. package/dist/resources/services.js.map +1 -0
  45. package/dist/resources/settings.js +47 -0
  46. package/dist/resources/settings.js.map +1 -0
  47. package/dist/resources/simulations.js +50 -0
  48. package/dist/resources/simulations.js.map +1 -0
  49. package/dist/resources/skills.js +44 -0
  50. package/dist/resources/skills.js.map +1 -0
  51. package/dist/resources/workspaces.js +57 -0
  52. package/dist/resources/workspaces.js.map +1 -0
  53. package/dist/resources/world.js +131 -0
  54. package/dist/resources/world.js.map +1 -0
  55. package/dist/types/api.js +12 -0
  56. package/dist/types/api.js.map +1 -0
  57. package/dist/types/core/auth.d.ts +20 -0
  58. package/dist/types/core/auth.d.ts.map +1 -0
  59. package/dist/types/core/branded-types.d.ts +50 -0
  60. package/dist/types/core/branded-types.d.ts.map +1 -0
  61. package/dist/types/core/errors.d.ts +76 -0
  62. package/dist/types/core/errors.d.ts.map +1 -0
  63. package/dist/types/core/openapi-client.d.ts +14 -0
  64. package/dist/types/core/openapi-client.d.ts.map +1 -0
  65. package/dist/types/core/retry.d.ts +21 -0
  66. package/dist/types/core/retry.d.ts.map +1 -0
  67. package/dist/types/core/utils.d.ts +39 -0
  68. package/dist/types/core/utils.d.ts.map +1 -0
  69. package/dist/types/index.d.ts +114 -0
  70. package/dist/types/index.d.ts.map +1 -0
  71. package/dist/types/resources/agents.d.ts +32 -0
  72. package/dist/types/resources/agents.d.ts.map +1 -0
  73. package/dist/types/resources/analytics.d.ts +146 -0
  74. package/dist/types/resources/analytics.d.ts.map +1 -0
  75. package/dist/types/resources/api-keys.d.ts +28 -0
  76. package/dist/types/resources/api-keys.d.ts.map +1 -0
  77. package/dist/types/resources/base.d.ts +18 -0
  78. package/dist/types/resources/base.d.ts.map +1 -0
  79. package/dist/types/resources/billing.d.ts +19 -0
  80. package/dist/types/resources/billing.d.ts.map +1 -0
  81. package/dist/types/resources/calls.d.ts +50 -0
  82. package/dist/types/resources/calls.d.ts.map +1 -0
  83. package/dist/types/resources/context-graphs.d.ts +32 -0
  84. package/dist/types/resources/context-graphs.d.ts.map +1 -0
  85. package/dist/types/resources/data-sources.d.ts +24 -0
  86. package/dist/types/resources/data-sources.d.ts.map +1 -0
  87. package/dist/types/resources/integrations.d.ts +38 -0
  88. package/dist/types/resources/integrations.d.ts.map +1 -0
  89. package/dist/types/resources/memory.d.ts +99 -0
  90. package/dist/types/resources/memory.d.ts.map +1 -0
  91. package/dist/types/resources/phone-numbers.d.ts +26 -0
  92. package/dist/types/resources/phone-numbers.d.ts.map +1 -0
  93. package/dist/types/resources/services.d.ts +21 -0
  94. package/dist/types/resources/services.d.ts.map +1 -0
  95. package/dist/types/resources/settings.d.ts +102 -0
  96. package/dist/types/resources/settings.d.ts.map +1 -0
  97. package/dist/types/resources/simulations.d.ts +39 -0
  98. package/dist/types/resources/simulations.d.ts.map +1 -0
  99. package/dist/types/resources/skills.d.ts +31 -0
  100. package/dist/types/resources/skills.d.ts.map +1 -0
  101. package/dist/types/resources/workspaces.d.ts +28 -0
  102. package/dist/types/resources/workspaces.d.ts.map +1 -0
  103. package/dist/types/resources/world.d.ts +177 -0
  104. package/dist/types/resources/world.d.ts.map +1 -0
  105. package/dist/types/types/api.d.ts +739 -0
  106. package/dist/types/types/api.d.ts.map +1 -0
  107. package/package.json +82 -0
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Exponential backoff with full jitter and Retry-After header support.
3
+ */
4
+ const RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504]);
5
+ // POST is only retried on 429 with a Retry-After header (idempotency concern)
6
+ const POST_RETRYABLE_STATUS_CODES = new Set([429]);
7
+ export function shouldRetry(ctx) {
8
+ const { method, attempt, response, options } = ctx;
9
+ if (attempt >= options.maxAttempts)
10
+ return false;
11
+ const status = response.status;
12
+ if (method === 'GET' || method === 'HEAD') {
13
+ return RETRYABLE_STATUS_CODES.has(status);
14
+ }
15
+ if (method === 'POST' && POST_RETRYABLE_STATUS_CODES.has(status)) {
16
+ return response.headers.has('Retry-After');
17
+ }
18
+ return false;
19
+ }
20
+ export function computeDelay(attempt, response, options) {
21
+ const retryAfterHeader = response.headers.get('Retry-After');
22
+ if (retryAfterHeader) {
23
+ const seconds = parseRetryAfterHeader(retryAfterHeader);
24
+ if (seconds !== undefined)
25
+ return seconds * 1000;
26
+ }
27
+ // Exponential backoff with full jitter: random value in [0, min(maxDelay, base * 2^attempt)]
28
+ const exponential = Math.min(options.maxDelayMs, options.baseDelayMs * Math.pow(2, attempt));
29
+ return Math.random() * exponential;
30
+ }
31
+ function parseRetryAfterHeader(header) {
32
+ const seconds = Number(header);
33
+ if (!isNaN(seconds))
34
+ return seconds;
35
+ const date = new Date(header);
36
+ if (!isNaN(date.getTime())) {
37
+ return Math.max(0, Math.ceil((date.getTime() - Date.now()) / 1000));
38
+ }
39
+ return undefined;
40
+ }
41
+ export function resolveRetryOptions(opts) {
42
+ return {
43
+ maxAttempts: opts?.maxAttempts ?? 3,
44
+ baseDelayMs: opts?.baseDelayMs ?? 250,
45
+ maxDelayMs: opts?.maxDelayMs ?? 30_000,
46
+ };
47
+ }
48
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/core/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AACtE,8EAA8E;AAC9E,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AASlD,MAAM,UAAU,WAAW,CAAC,GAAiB;IAC3C,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;IAClD,IAAI,OAAO,IAAI,OAAO,CAAC,WAAW;QAAE,OAAO,KAAK,CAAA;IAEhD,MAAM,MAAM,GAAG,QAAQ,C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,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACrE,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAmB;IACrD,OAAO;QACL,WAAW,EAAE,IAAI,EAAE,WAAW,IAAI,CAAC;QACnC,WAAW,EAAE,IAAI,EAAE,WAAW,IAAI,GAAG;QACrC,UAAU,EAAE,IAAI,EAAE,UAAU,IAAI,MAAM;KACvC,CAAA;AACH,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Shared utilities: response extraction and pagination helpers.
3
+ */
4
+ import { ParseError } from './errors.js';
5
+ /**
6
+ * Extracts the data payload from an openapi-fetch response,
7
+ * throwing ParseError if the response is empty or unexpected.
8
+ */
9
+ export function extractData(result) {
10
+ if (result.data !== undefined)
11
+ return result.data;
12
+ throw new ParseError('Unexpected empty response from API', result.error !== undefined ? JSON.stringify(result.error) : undefined);
13
+ }
14
+ /**
15
+ * Async iterator that auto-paginates through all pages.
16
+ * Yields one item at a time.
17
+ *
18
+ * @example
19
+ * for await (const agent of paginate((token) => client.agents.list({ continuation_token: token }))) {
20
+ * console.log(agent)
21
+ * }
22
+ */
23
+ export async function* paginate(fetcher) {
24
+ let token = undefined;
25
+ while (true) {
26
+ const page = await fetcher(token);
27
+ for (const item of page.items) {
28
+ yield item;
29
+ }
30
+ if (!page.has_more || page.continuation_token === null)
31
+ break;
32
+ token = page.continuation_token;
33
+ }
34
+ }
35
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/core/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAI,MAAqC;IAClE,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,IAAI,CAAA;IACjD,MAAM,IAAI,UAAU,CAClB,oCAAoC,EACpC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CACtE,CAAA;AACH,CAAC;AAqBD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,QAAQ,CAC7B,OAAkE;IAElE,IAAI,KAAK,GAAuB,SAAS,CAAA;IACzC,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,CAAA;QACjC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,IAAI,CAAA;QACZ,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,kBAAkB,KAAK,IAAI;YAAE,MAAK;QAC7D,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAA;IACjC,CAAC;AACH,CAAC"}