raindrop-ai 0.2.4 → 0.3.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.
package/dist/index.mjs CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  stringifyBounded,
22
22
  tracing,
23
23
  withRoutingContext
24
- } from "./chunk-XLEPN7ZO.mjs";
24
+ } from "./chunk-5Y3LWBKV.mjs";
25
25
  import {
26
26
  __commonJS,
27
27
  __toESM
@@ -10304,6 +10304,65 @@ var Raindrop = class {
10304
10304
  resumeInteraction(eventId) {
10305
10305
  return this._tracing.getActiveInteraction(eventId);
10306
10306
  }
10307
+ /**
10308
+ * Opens the child's own event for a launched detached sub-agent.
10309
+ *
10310
+ * Sibling to {@link resumeInteraction}, and deliberately not the same thing:
10311
+ * a resumed interaction JOINS the caller's event, while a detached sub-agent
10312
+ * reports as its OWN event under the id the launcher minted, linked back only
10313
+ * by the hand-off attributes both sides write. Every span the run emits
10314
+ * carries the reverse reference until it reports a result.
10315
+ *
10316
+ * Pass the headers the request arrived with. A missing carrier is a
10317
+ * legitimate state — the sub-agent was invoked directly rather than
10318
+ * dispatched — so this always returns a usable run and leaves `parent` null;
10319
+ * call sites stay unconditional. A malformed carrier costs the link, never
10320
+ * the request.
10321
+ *
10322
+ * The carrier is authoritative for every identity field it supplies. The
10323
+ * options are fallbacks for the direct-invocation case, not overrides: each
10324
+ * field names something the launcher already recorded, so a locally minted
10325
+ * value winning would strand the child outside the link.
10326
+ *
10327
+ * > **Trust boundary.** A carrier names the event the child will be
10328
+ * > attributed to, so accepting one from an untrusted caller lets that caller
10329
+ * > write into another tenant's trace. Only read carriers that came from
10330
+ * > inside your own trust boundary.
10331
+ *
10332
+ * @example
10333
+ * ```typescript
10334
+ * const run = raindrop.resumeSubagent(request.headers);
10335
+ * try {
10336
+ * const answer = await doTheWork();
10337
+ * await run.finish({ output: answer });
10338
+ * } catch (error) {
10339
+ * await run.fail(error);
10340
+ * }
10341
+ * ```
10342
+ */
10343
+ resumeSubagent(headers, options) {
10344
+ return this._tracing.resumeSubagent(headers, options);
10345
+ }
10346
+ /**
10347
+ * Runs `fn` as a detached sub-agent and guarantees the run reports an
10348
+ * outcome, mirroring the Python SDK's `with rd.resume_subagent(...) as run:`.
10349
+ *
10350
+ * A run that returns without reporting output is closed with an abort reason,
10351
+ * and one that throws is failed with it. That is not cosmetic: an event is
10352
+ * created only from a run with non-empty output, so a child that dies
10353
+ * silently produces no event at all and its launcher stays on `queued`
10354
+ * forever — indistinguishable from a job that never started.
10355
+ *
10356
+ * @example
10357
+ * ```typescript
10358
+ * await raindrop.withSubagentRun(request.headers, async (run) => {
10359
+ * await run.finish({ output: await doTheWork() });
10360
+ * });
10361
+ * ```
10362
+ */
10363
+ withSubagentRun(headers, fn, options) {
10364
+ return this._tracing.withSubagentRun(headers, fn, options);
10365
+ }
10307
10366
  /**
10308
10367
  * Creates a framework-agnostic self-diagnostics tool definition.
10309
10368
  *
@@ -1,4 +1,4 @@
1
- import { Raindrop, RaindropSpanProcessor, PartialAiTrackEvent, Interaction, Tracer } from '../index.mjs';
1
+ import { R as Raindrop, a as RaindropSpanProcessor, P as PartialAiTrackEvent, I as Interaction, C as CarrierHeaders, T as TraceCarrier, S as SubagentResumeOptions, b as SubagentRun, c as Tracer } from '../index-DBdUrUXc.mjs';
2
2
  import { Instrumentation } from '@opentelemetry/instrumentation';
3
3
  import * as traceloop from '@traceloop/node-server-sdk';
4
4
  import '@opentelemetry/api';
@@ -103,6 +103,8 @@ declare const tracing: (analytics: Raindrop, apiUrl: string, writeKey: string, o
103
103
  */
104
104
  createSpanProcessor(processorOptions?: traceloop.SpanProcessorOptions): RaindropSpanProcessor;
105
105
  begin(traceContext: PartialAiTrackEvent): Interaction;
106
+ resumeSubagent(carrierOrHeaders: CarrierHeaders | TraceCarrier | null | undefined, options?: SubagentResumeOptions): SubagentRun;
107
+ withSubagentRun<T>(carrierOrHeaders: CarrierHeaders | TraceCarrier | null | undefined, fn: (run: SubagentRun) => Promise<T> | T, options?: SubagentResumeOptions): Promise<T>;
106
108
  getActiveInteraction(eventId: string): Interaction;
107
109
  tracer(globalProperties?: Record<string, string>): Tracer;
108
110
  /**
@@ -1,4 +1,4 @@
1
- import { Raindrop, RaindropSpanProcessor, PartialAiTrackEvent, Interaction, Tracer } from '../index.js';
1
+ import { R as Raindrop, a as RaindropSpanProcessor, P as PartialAiTrackEvent, I as Interaction, C as CarrierHeaders, T as TraceCarrier, S as SubagentResumeOptions, b as SubagentRun, c as Tracer } from '../index-DBdUrUXc.js';
2
2
  import { Instrumentation } from '@opentelemetry/instrumentation';
3
3
  import * as traceloop from '@traceloop/node-server-sdk';
4
4
  import '@opentelemetry/api';
@@ -103,6 +103,8 @@ declare const tracing: (analytics: Raindrop, apiUrl: string, writeKey: string, o
103
103
  */
104
104
  createSpanProcessor(processorOptions?: traceloop.SpanProcessorOptions): RaindropSpanProcessor;
105
105
  begin(traceContext: PartialAiTrackEvent): Interaction;
106
+ resumeSubagent(carrierOrHeaders: CarrierHeaders | TraceCarrier | null | undefined, options?: SubagentResumeOptions): SubagentRun;
107
+ withSubagentRun<T>(carrierOrHeaders: CarrierHeaders | TraceCarrier | null | undefined, fn: (run: SubagentRun) => Promise<T> | T, options?: SubagentResumeOptions): Promise<T>;
106
108
  getActiveInteraction(eventId: string): Interaction;
107
109
  tracer(globalProperties?: Record<string, string>): Tracer;
108
110
  /**