@runtypelabs/cloudflare-agents 0.1.3 → 0.1.5

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,4 +1,4 @@
1
- //#region src/identity.ts
1
+ // src/identity.ts
2
2
  function requireIdentity(value) {
3
3
  if (typeof value !== "string" || value.trim().length === 0 || new TextEncoder().encode(value).length > 256) throw new Error("Adapter identity must be a nonempty string of at most 256 UTF-8 bytes");
4
4
  }
@@ -37,7 +37,6 @@ async function operationSpanId(traceId, operationId) {
37
37
  operationId
38
38
  ])).slice(0, 16);
39
39
  }
40
- //#endregion
41
40
  Object.defineProperty(exports, "createRunIdentity", {
42
41
  enumerable: true,
43
42
  get: function() {
@@ -1,4 +1,4 @@
1
- //#region src/identity.ts
1
+ // src/identity.ts
2
2
  function requireIdentity(value) {
3
3
  if (typeof value !== "string" || value.trim().length === 0 || new TextEncoder().encode(value).length > 256) throw new Error("Adapter identity must be a nonempty string of at most 256 UTF-8 bytes");
4
4
  }
@@ -37,6 +37,5 @@ async function operationSpanId(traceId, operationId) {
37
37
  operationId
38
38
  ])).slice(0, 16);
39
39
  }
40
- //#endregion
41
40
  export { operationSpanId as n, createRunIdentity as t };
42
41
 
@@ -1,10 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_identity = require("./chunk-DBVUQIKL.cjs");
2
+ const require_identity = require("./chunk-C3x60FnC.cjs");
3
3
  let cloudflare_workers = require("cloudflare:workers");
4
- //#region package.json
5
- var version = "0.1.3";
6
- //#endregion
7
- //#region src/otlp.ts
4
+ // package.json
5
+ var version = "0.1.5";
6
+ // src/otlp.ts
8
7
  function otlpValue(value) {
9
8
  if (typeof value === "string") return { stringValue: value };
10
9
  if (typeof value === "boolean") return { boolValue: value };
@@ -45,8 +44,7 @@ function encodeTraceBatch(spans, identity) {
45
44
  }]
46
45
  }] });
47
46
  }
48
- //#endregion
49
- //#region src/sender.ts
47
+ // src/sender.ts
50
48
  /** Builds the one outbound OTLP request without exposing delivery state. */
51
49
  function createOtlpDeliveryRequest(options) {
52
50
  return new Request(`${options.baseUrl}/v1/otel/v1/traces`, {
@@ -61,8 +59,7 @@ function createOtlpDeliveryRequest(options) {
61
59
  body: options.body.slice().buffer
62
60
  });
63
61
  }
64
- //#endregion
65
- //#region src/session.ts
62
+ // src/session.ts
66
63
  const MAX_MODEL_STEPS = 128;
67
64
  const MAX_TOOL_CALLS = 256;
68
65
  function nanos(timestamp) {
@@ -273,8 +270,7 @@ async function reduceObservation(previous, observation, now) {
273
270
  spans: [root]
274
271
  };
275
272
  }
276
- //#endregion
277
- //#region src/outbox.ts
273
+ // src/outbox.ts
278
274
  const OUTBOX_RETENTION_MS = 6048e5;
279
275
  const OUTBOX_LEASE_MS = 6e4;
280
276
  const outboxStatsKey = "outbox:stats";
@@ -609,8 +605,7 @@ async function classifyDeliveryResponse(response) {
609
605
  };
610
606
  }
611
607
  }
612
- //#endregion
613
- //#region src/durable-object.ts
608
+ // src/durable-object.ts
614
609
  const SESSION_RETENTION_MS = OUTBOX_RETENTION_MS;
615
610
  const SESSION_MAX_BYTES = 65536;
616
611
  const SESSION_MAX_ROWS = 1e3;
@@ -887,6 +882,5 @@ var RuntypeOtlpOutbox = class extends cloudflare_workers.DurableObject {
887
882
  else await storage.setAlarm(Math.max(now + 1e3, due));
888
883
  }
889
884
  };
890
- //#endregion
891
885
  exports.RuntypeOtlpOutbox = RuntypeOtlpOutbox;
892
886
 
@@ -1,6 +1,5 @@
1
- import { a as AdapterToolStartedObservation, m as RunIdentity, n as AdapterModelStepObservation, r as AdapterObservation, t as AdapterModelInputObservation } from "./observer-DnEMHl8z.cjs";
1
+ import { a as AdapterToolStartedObservation, m as RunIdentity, n as AdapterModelStepObservation, r as AdapterObservation, t as AdapterModelInputObservation } from "./observer-BVnmkz4i.cjs";
2
2
  import { DurableObject } from "cloudflare:workers";
3
- //#region src/otlp.d.ts
4
3
  interface AdapterSpan {
5
4
  traceId: string;
6
5
  spanId: string;
@@ -14,8 +13,6 @@ interface AdapterSpan {
14
13
  message?: string;
15
14
  };
16
15
  }
17
- //#endregion
18
- //#region src/session.d.ts
19
16
  interface ModelState {
20
17
  index: number;
21
18
  startedAt: number;
@@ -43,8 +40,6 @@ interface SessionReduction {
43
40
  spans: AdapterSpan[];
44
41
  diagnostic?: 'identity_conflict' | 'session_limit' | 'missing_operation_start' | 'unsupported' | 'incomplete';
45
42
  }
46
- //#endregion
47
- //#region src/outbox.d.ts
48
43
  interface OtlpBatch {
49
44
  version: 1;
50
45
  deliveryId: string;
@@ -61,8 +56,6 @@ type OutboxReceipt = {
61
56
  queuedRows: number;
62
57
  queuedBytes: number;
63
58
  };
64
- //#endregion
65
- //#region src/durable-object.d.ts
66
59
  export interface CloudflareOtlpOutboxEnv {
67
60
  RUNTYPE_AGENT_ID: string;
68
61
  RUNTYPE_API_KEY: string;
@@ -110,5 +103,5 @@ export declare class RuntypeOtlpOutbox extends DurableObject<CloudflareOtlpOutbo
110
103
  private networkFailureCode;
111
104
  private armTransaction;
112
105
  }
113
- //#endregion
106
+ export {};
114
107
  export {}
@@ -1,6 +1,5 @@
1
- import { a as AdapterToolStartedObservation, m as RunIdentity, n as AdapterModelStepObservation, r as AdapterObservation, t as AdapterModelInputObservation } from "./observer-DnEMHl8z.js";
1
+ import { a as AdapterToolStartedObservation, m as RunIdentity, n as AdapterModelStepObservation, r as AdapterObservation, t as AdapterModelInputObservation } from "./observer-BVnmkz4i.js";
2
2
  import { DurableObject } from "cloudflare:workers";
3
- //#region src/otlp.d.ts
4
3
  interface AdapterSpan {
5
4
  traceId: string;
6
5
  spanId: string;
@@ -14,8 +13,6 @@ interface AdapterSpan {
14
13
  message?: string;
15
14
  };
16
15
  }
17
- //#endregion
18
- //#region src/session.d.ts
19
16
  interface ModelState {
20
17
  index: number;
21
18
  startedAt: number;
@@ -43,8 +40,6 @@ interface SessionReduction {
43
40
  spans: AdapterSpan[];
44
41
  diagnostic?: 'identity_conflict' | 'session_limit' | 'missing_operation_start' | 'unsupported' | 'incomplete';
45
42
  }
46
- //#endregion
47
- //#region src/outbox.d.ts
48
43
  interface OtlpBatch {
49
44
  version: 1;
50
45
  deliveryId: string;
@@ -61,8 +56,6 @@ type OutboxReceipt = {
61
56
  queuedRows: number;
62
57
  queuedBytes: number;
63
58
  };
64
- //#endregion
65
- //#region src/durable-object.d.ts
66
59
  export interface CloudflareOtlpOutboxEnv {
67
60
  RUNTYPE_AGENT_ID: string;
68
61
  RUNTYPE_API_KEY: string;
@@ -110,5 +103,5 @@ export declare class RuntypeOtlpOutbox extends DurableObject<CloudflareOtlpOutbo
110
103
  private networkFailureCode;
111
104
  private armTransaction;
112
105
  }
113
- //#endregion
106
+ export {};
114
107
  export {}
@@ -1,9 +1,8 @@
1
- import { n as operationSpanId, t as createRunIdentity } from "./chunk-BuRpWjxB.mjs";
1
+ import { n as operationSpanId, t as createRunIdentity } from "./chunk-CRTW4njP.mjs";
2
2
  import { DurableObject } from "cloudflare:workers";
3
- //#region package.json
4
- var version = "0.1.3";
5
- //#endregion
6
- //#region src/otlp.ts
3
+ // package.json
4
+ var version = "0.1.5";
5
+ // src/otlp.ts
7
6
  function otlpValue(value) {
8
7
  if (typeof value === "string") return { stringValue: value };
9
8
  if (typeof value === "boolean") return { boolValue: value };
@@ -44,8 +43,7 @@ function encodeTraceBatch(spans, identity) {
44
43
  }]
45
44
  }] });
46
45
  }
47
- //#endregion
48
- //#region src/sender.ts
46
+ // src/sender.ts
49
47
  /** Builds the one outbound OTLP request without exposing delivery state. */
50
48
  function createOtlpDeliveryRequest(options) {
51
49
  return new Request(`${options.baseUrl}/v1/otel/v1/traces`, {
@@ -60,8 +58,7 @@ function createOtlpDeliveryRequest(options) {
60
58
  body: options.body.slice().buffer
61
59
  });
62
60
  }
63
- //#endregion
64
- //#region src/session.ts
61
+ // src/session.ts
65
62
  const MAX_MODEL_STEPS = 128;
66
63
  const MAX_TOOL_CALLS = 256;
67
64
  function nanos(timestamp) {
@@ -272,8 +269,7 @@ async function reduceObservation(previous, observation, now) {
272
269
  spans: [root]
273
270
  };
274
271
  }
275
- //#endregion
276
- //#region src/outbox.ts
272
+ // src/outbox.ts
277
273
  const OUTBOX_RETENTION_MS = 6048e5;
278
274
  const OUTBOX_LEASE_MS = 6e4;
279
275
  const outboxStatsKey = "outbox:stats";
@@ -608,8 +604,7 @@ async function classifyDeliveryResponse(response) {
608
604
  };
609
605
  }
610
606
  }
611
- //#endregion
612
- //#region src/durable-object.ts
607
+ // src/durable-object.ts
613
608
  const SESSION_RETENTION_MS = OUTBOX_RETENTION_MS;
614
609
  const SESSION_MAX_BYTES = 65536;
615
610
  const SESSION_MAX_ROWS = 1e3;
@@ -886,6 +881,5 @@ var RuntypeOtlpOutbox = class extends DurableObject {
886
881
  else await storage.setAlarm(Math.max(now + 1e3, due));
887
882
  }
888
883
  };
889
- //#endregion
890
884
  export { RuntypeOtlpOutbox };
891
885
 
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_identity = require("./chunk-DBVUQIKL.cjs");
3
- //#region src/content.ts
2
+ const require_identity = require("./chunk-C3x60FnC.cjs");
3
+ // src/content.ts
4
4
  const MAX_CONTENT_BYTES = 32768;
5
5
  function diagnose$1(policy, code) {
6
6
  try {
@@ -53,8 +53,7 @@ function captureContent(policy, kind, value) {
53
53
  return;
54
54
  }
55
55
  }
56
- //#endregion
57
- //#region src/observer.ts
56
+ // src/observer.ts
58
57
  /** Adds bounded observation callbacks without reading or replacing the response stream. */
59
58
  async function observeStreamTextOptions(options, observation) {
60
59
  const destination = observation.observer;
@@ -324,8 +323,7 @@ function usage(value) {
324
323
  if (!value || typeof value !== "object") return {};
325
324
  return Object.fromEntries(Object.entries(value).filter(([, amount]) => typeof amount === "number" && Number.isFinite(amount) && amount >= 0));
326
325
  }
327
- //#endregion
328
- //#region src/durable-observer.ts
326
+ // src/durable-observer.ts
329
327
  /** Bridges a companion Durable Object receipt to the observer's delivery diagnostic. */
330
328
  function createDurableObserver(sink, onDiagnostic) {
331
329
  return {
@@ -335,7 +333,6 @@ function createDurableObserver(sink, onDiagnostic) {
335
333
  }
336
334
  };
337
335
  }
338
- //#endregion
339
336
  exports.captureContent = captureContent;
340
337
  exports.createDurableObserver = createDurableObserver;
341
338
  exports.createRunIdentity = require_identity.createRunIdentity;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,4 @@
1
- import { _ as operationSpanId, c as observeStreamTextOptions, d as ContentKind, f as ContentPolicy, g as createRunIdentity, h as SubmissionIdentity, i as AdapterObserver, l as CapturedJson, m as RunIdentity, o as AdapterTurn, p as captureContent, r as AdapterObservation, s as ObserveStreamTextOptions, u as ContentDiagnostic } from "./observer-DnEMHl8z.cjs";
2
- //#region src/durable-observer.d.ts
1
+ import { _ as operationSpanId, c as observeStreamTextOptions, d as ContentKind, f as ContentPolicy, g as createRunIdentity, h as SubmissionIdentity, i as AdapterObserver, l as CapturedJson, m as RunIdentity, o as AdapterTurn, p as captureContent, r as AdapterObservation, s as ObserveStreamTextOptions, u as ContentDiagnostic } from "./observer-BVnmkz4i.cjs";
3
2
  interface DurableObservationSink {
4
3
  observe(observation: AdapterObservation): Promise<{
5
4
  accepted: boolean;
@@ -8,6 +7,5 @@ interface DurableObservationSink {
8
7
  }
9
8
  /** Bridges a companion Durable Object receipt to the observer's delivery diagnostic. */
10
9
  export declare function createDurableObserver(sink: DurableObservationSink, onDiagnostic?: AdapterObserver['onDiagnostic']): AdapterObserver;
11
- //#endregion
12
10
  export { type AdapterObservation, type AdapterObserver, type AdapterTurn, type CapturedJson, type ContentDiagnostic, type ContentKind, type ContentPolicy, type DurableObservationSink, type ObserveStreamTextOptions, type RunIdentity, type SubmissionIdentity, captureContent, createRunIdentity, observeStreamTextOptions, operationSpanId };
13
11
  export {}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { _ as operationSpanId, c as observeStreamTextOptions, d as ContentKind, f as ContentPolicy, g as createRunIdentity, h as SubmissionIdentity, i as AdapterObserver, l as CapturedJson, m as RunIdentity, o as AdapterTurn, p as captureContent, r as AdapterObservation, s as ObserveStreamTextOptions, u as ContentDiagnostic } from "./observer-DnEMHl8z.js";
2
- //#region src/durable-observer.d.ts
1
+ import { _ as operationSpanId, c as observeStreamTextOptions, d as ContentKind, f as ContentPolicy, g as createRunIdentity, h as SubmissionIdentity, i as AdapterObserver, l as CapturedJson, m as RunIdentity, o as AdapterTurn, p as captureContent, r as AdapterObservation, s as ObserveStreamTextOptions, u as ContentDiagnostic } from "./observer-BVnmkz4i.js";
3
2
  interface DurableObservationSink {
4
3
  observe(observation: AdapterObservation): Promise<{
5
4
  accepted: boolean;
@@ -8,6 +7,5 @@ interface DurableObservationSink {
8
7
  }
9
8
  /** Bridges a companion Durable Object receipt to the observer's delivery diagnostic. */
10
9
  export declare function createDurableObserver(sink: DurableObservationSink, onDiagnostic?: AdapterObserver['onDiagnostic']): AdapterObserver;
11
- //#endregion
12
10
  export { type AdapterObservation, type AdapterObserver, type AdapterTurn, type CapturedJson, type ContentDiagnostic, type ContentKind, type ContentPolicy, type DurableObservationSink, type ObserveStreamTextOptions, type RunIdentity, type SubmissionIdentity, captureContent, createRunIdentity, observeStreamTextOptions, operationSpanId };
13
11
  export {}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { n as operationSpanId, t as createRunIdentity } from "./chunk-BuRpWjxB.mjs";
2
- //#region src/content.ts
1
+ import { n as operationSpanId, t as createRunIdentity } from "./chunk-CRTW4njP.mjs";
2
+ // src/content.ts
3
3
  const MAX_CONTENT_BYTES = 32768;
4
4
  function diagnose$1(policy, code) {
5
5
  try {
@@ -52,8 +52,7 @@ function captureContent(policy, kind, value) {
52
52
  return;
53
53
  }
54
54
  }
55
- //#endregion
56
- //#region src/observer.ts
55
+ // src/observer.ts
57
56
  /** Adds bounded observation callbacks without reading or replacing the response stream. */
58
57
  async function observeStreamTextOptions(options, observation) {
59
58
  const destination = observation.observer;
@@ -323,8 +322,7 @@ function usage(value) {
323
322
  if (!value || typeof value !== "object") return {};
324
323
  return Object.fromEntries(Object.entries(value).filter(([, amount]) => typeof amount === "number" && Number.isFinite(amount) && amount >= 0));
325
324
  }
326
- //#endregion
327
- //#region src/durable-observer.ts
325
+ // src/durable-observer.ts
328
326
  /** Bridges a companion Durable Object receipt to the observer's delivery diagnostic. */
329
327
  function createDurableObserver(sink, onDiagnostic) {
330
328
  return {
@@ -334,6 +332,5 @@ function createDurableObserver(sink, onDiagnostic) {
334
332
  }
335
333
  };
336
334
  }
337
- //#endregion
338
335
  export { captureContent, createDurableObserver, createRunIdentity, observeStreamTextOptions, operationSpanId };
339
336
 
@@ -1,5 +1,4 @@
1
1
  import { streamText } from "ai";
2
- //#region src/identity.d.ts
3
2
  interface SubmissionIdentity {
4
3
  agentId: string;
5
4
  submissionId: string;
@@ -13,8 +12,6 @@ interface RunIdentity extends SubmissionIdentity {
13
12
  declare function createRunIdentity(input: SubmissionIdentity): Promise<RunIdentity>;
14
13
  /** The same operation is encoded with the same span ID on every delivery attempt. */
15
14
  declare function operationSpanId(traceId: string, operationId: string): Promise<string>;
16
- //#endregion
17
- //#region src/content.d.ts
18
15
  type ContentKind = 'messages' | 'instructions' | 'tools' | 'error';
19
16
  type CapturedJson = null | boolean | number | string | CapturedJson[] | {
20
17
  [key: string]: CapturedJson;
@@ -34,8 +31,6 @@ interface ContentPolicy {
34
31
  }
35
32
  /** Applies privacy policy before a content value can enter telemetry storage. */
36
33
  declare function captureContent(policy: ContentPolicy, kind: ContentKind, value: unknown): CapturedJson | undefined;
37
- //#endregion
38
- //#region src/observer.d.ts
39
34
  interface AdapterTurn {
40
35
  submissionId: string;
41
36
  conversationId: string;
@@ -116,6 +111,5 @@ interface ObserveStreamTextOptions {
116
111
  }
117
112
  /** Adds bounded observation callbacks without reading or replacing the response stream. */
118
113
  declare function observeStreamTextOptions<Options extends StreamTextOptions>(options: Options, observation: ObserveStreamTextOptions): Promise<Options>;
119
- //#endregion
120
114
  export { operationSpanId as _, AdapterToolStartedObservation as a, observeStreamTextOptions as c, ContentKind as d, ContentPolicy as f, createRunIdentity as g, SubmissionIdentity as h, AdapterObserver as i, CapturedJson as l, RunIdentity as m, AdapterModelStepObservation as n, AdapterTurn as o, captureContent as p, AdapterObservation as r, ObserveStreamTextOptions as s, AdapterModelInputObservation as t, ContentDiagnostic as u };
121
115
  export {}
@@ -1,5 +1,4 @@
1
1
  import { streamText } from "ai";
2
- //#region src/identity.d.ts
3
2
  interface SubmissionIdentity {
4
3
  agentId: string;
5
4
  submissionId: string;
@@ -13,8 +12,6 @@ interface RunIdentity extends SubmissionIdentity {
13
12
  declare function createRunIdentity(input: SubmissionIdentity): Promise<RunIdentity>;
14
13
  /** The same operation is encoded with the same span ID on every delivery attempt. */
15
14
  declare function operationSpanId(traceId: string, operationId: string): Promise<string>;
16
- //#endregion
17
- //#region src/content.d.ts
18
15
  type ContentKind = 'messages' | 'instructions' | 'tools' | 'error';
19
16
  type CapturedJson = null | boolean | number | string | CapturedJson[] | {
20
17
  [key: string]: CapturedJson;
@@ -34,8 +31,6 @@ interface ContentPolicy {
34
31
  }
35
32
  /** Applies privacy policy before a content value can enter telemetry storage. */
36
33
  declare function captureContent(policy: ContentPolicy, kind: ContentKind, value: unknown): CapturedJson | undefined;
37
- //#endregion
38
- //#region src/observer.d.ts
39
34
  interface AdapterTurn {
40
35
  submissionId: string;
41
36
  conversationId: string;
@@ -116,6 +111,5 @@ interface ObserveStreamTextOptions {
116
111
  }
117
112
  /** Adds bounded observation callbacks without reading or replacing the response stream. */
118
113
  declare function observeStreamTextOptions<Options extends StreamTextOptions>(options: Options, observation: ObserveStreamTextOptions): Promise<Options>;
119
- //#endregion
120
114
  export { operationSpanId as _, AdapterToolStartedObservation as a, observeStreamTextOptions as c, ContentKind as d, ContentPolicy as f, createRunIdentity as g, SubmissionIdentity as h, AdapterObserver as i, CapturedJson as l, RunIdentity as m, AdapterModelStepObservation as n, AdapterTurn as o, captureContent as p, AdapterObservation as r, ObserveStreamTextOptions as s, AdapterModelInputObservation as t, ContentDiagnostic as u };
121
115
  export {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/cloudflare-agents",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Durable application telemetry for Cloudflare Agents SDK runs in Runtype.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -30,9 +30,9 @@
30
30
  "devDependencies": {
31
31
  "@cloudflare/workers-types": "^5.20260804.1",
32
32
  "ai": "6.0.277",
33
- "tsdown": "^0.23.0",
33
+ "tsdown": "^0.23.2",
34
34
  "typescript": "^6.0.3",
35
- "vitest": "^5.0.2"
35
+ "vitest": "^5.0.5"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "ai": "6.0.277"
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsdown",
52
- "typecheck": "bun check && bun check -p tsconfig.tests.json",
52
+ "typecheck": "tsrs --noEmit && tsrs -p tsconfig.tests.json --noEmit",
53
53
  "test": "vitest run",
54
54
  "lint": "oxlint . --max-warnings 0"
55
55
  }