@prefactor/core 0.1.1 → 0.2.1

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 (77) hide show
  1. package/README.md +35 -2
  2. package/dist/agent/instance-manager.d.ts +16 -0
  3. package/dist/agent/instance-manager.d.ts.map +1 -0
  4. package/dist/agent/instance-manager.js +50 -0
  5. package/dist/agent/instance-manager.js.map +1 -0
  6. package/dist/config.d.ts +28 -52
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +33 -18
  9. package/dist/config.js.map +1 -1
  10. package/dist/create-core.d.ts +10 -0
  11. package/dist/create-core.d.ts.map +1 -0
  12. package/dist/create-core.js +31 -0
  13. package/dist/create-core.js.map +1 -0
  14. package/dist/index.cjs +632 -256
  15. package/dist/index.cjs.map +18 -11
  16. package/dist/index.d.ts +3 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +633 -257
  19. package/dist/index.js.map +18 -11
  20. package/dist/queue/actions.d.ts +24 -0
  21. package/dist/queue/actions.d.ts.map +1 -0
  22. package/dist/queue/actions.js +2 -0
  23. package/dist/queue/actions.js.map +1 -0
  24. package/dist/queue/base.d.ts +19 -0
  25. package/dist/queue/base.d.ts.map +1 -0
  26. package/dist/{transport → queue}/base.js.map +1 -1
  27. package/dist/queue/in-memory-queue.d.ts +11 -0
  28. package/dist/queue/in-memory-queue.d.ts.map +1 -0
  29. package/dist/queue/in-memory-queue.js +46 -0
  30. package/dist/queue/in-memory-queue.js.map +1 -0
  31. package/dist/queue/task-executor.d.ts +18 -0
  32. package/dist/queue/task-executor.d.ts.map +1 -0
  33. package/dist/queue/task-executor.js +77 -0
  34. package/dist/queue/task-executor.js.map +1 -0
  35. package/dist/tracing/context.d.ts +12 -0
  36. package/dist/tracing/context.d.ts.map +1 -1
  37. package/dist/tracing/context.js +41 -5
  38. package/dist/tracing/context.js.map +1 -1
  39. package/dist/tracing/span.d.ts +7 -9
  40. package/dist/tracing/span.d.ts.map +1 -1
  41. package/dist/tracing/span.js +6 -8
  42. package/dist/tracing/span.js.map +1 -1
  43. package/dist/tracing/tracer.d.ts +5 -16
  44. package/dist/tracing/tracer.d.ts.map +1 -1
  45. package/dist/tracing/tracer.js +22 -26
  46. package/dist/tracing/tracer.js.map +1 -1
  47. package/dist/transport/http/agent-instance-client.d.ts +23 -0
  48. package/dist/transport/http/agent-instance-client.d.ts.map +1 -0
  49. package/dist/transport/http/agent-instance-client.js +25 -0
  50. package/dist/transport/http/agent-instance-client.js.map +1 -0
  51. package/dist/transport/http/agent-span-client.d.ts +25 -0
  52. package/dist/transport/http/agent-span-client.d.ts.map +1 -0
  53. package/dist/transport/http/agent-span-client.js +37 -0
  54. package/dist/transport/http/agent-span-client.js.map +1 -0
  55. package/dist/transport/http/http-client.d.ts +43 -0
  56. package/dist/transport/http/http-client.d.ts.map +1 -0
  57. package/dist/transport/http/http-client.js +127 -0
  58. package/dist/transport/http/http-client.js.map +1 -0
  59. package/dist/transport/http/retry-policy.d.ts +4 -0
  60. package/dist/transport/http/retry-policy.d.ts.map +1 -0
  61. package/dist/transport/http/retry-policy.js +10 -0
  62. package/dist/transport/http/retry-policy.js.map +1 -0
  63. package/dist/transport/http.d.ts +30 -72
  64. package/dist/transport/http.d.ts.map +1 -1
  65. package/dist/transport/http.js +146 -269
  66. package/dist/transport/http.js.map +1 -1
  67. package/dist/utils/logging.d.ts.map +1 -1
  68. package/dist/utils/logging.js +7 -1
  69. package/dist/utils/logging.js.map +1 -1
  70. package/package.json +1 -1
  71. package/dist/transport/base.d.ts +0 -38
  72. package/dist/transport/base.d.ts.map +0 -1
  73. package/dist/transport/stdio.d.ts +0 -48
  74. package/dist/transport/stdio.d.ts.map +0 -1
  75. package/dist/transport/stdio.js +0 -71
  76. package/dist/transport/stdio.js.map +0 -1
  77. /package/dist/{transport → queue}/base.js +0 -0
@@ -1,38 +0,0 @@
1
- import type { Span } from '../tracing/span.js';
2
- /**
3
- * Transport interface for emitting spans to different backends
4
- *
5
- * Transports are responsible for sending span data to a destination
6
- * (e.g., stdout, HTTP API). They implement the strategy pattern to allow
7
- * pluggable backends.
8
- */
9
- export interface Transport {
10
- /**
11
- * Emit a span to the transport destination
12
- *
13
- * @param span - The span to emit
14
- */
15
- emit(span: Span): void;
16
- /**
17
- * Finish a previously emitted span (for long-running spans like AGENT spans)
18
- *
19
- * @param spanId - ID of the span to finish
20
- * @param endTime - End time in milliseconds since Unix epoch
21
- */
22
- finishSpan(spanId: string, endTime: number): void;
23
- /**
24
- * Signal the start of an agent instance execution
25
- */
26
- startAgentInstance(): void;
27
- /**
28
- * Signal the completion of an agent instance execution
29
- */
30
- finishAgentInstance(): void;
31
- /**
32
- * Close the transport and flush any pending data
33
- *
34
- * @returns Promise that resolves when the transport is fully closed
35
- */
36
- close(): void | Promise<void>;
37
- }
38
- //# sourceMappingURL=base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/transport/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAEvB;;;;;OAKG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAElD;;OAEG;IACH,kBAAkB,IAAI,IAAI,CAAC;IAE3B;;OAEG;IACH,mBAAmB,IAAI,IAAI,CAAC;IAE5B;;;;OAIG;IACH,KAAK,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B"}
@@ -1,48 +0,0 @@
1
- import type { Span } from '../tracing/span.js';
2
- import type { Transport } from './base.js';
3
- /**
4
- * STDIO transport emits spans as newline-delimited JSON to stdout.
5
- *
6
- * This is the default transport and requires no configuration.
7
- * It's useful for local development and for piping span data to other tools.
8
- *
9
- * Features:
10
- * - Newline-delimited JSON output
11
- * - Promise-based write locking for ordering
12
- * - Graceful error handling
13
- *
14
- * @example
15
- * ```typescript
16
- * const transport = new StdioTransport();
17
- * const tracer = new Tracer(transport);
18
- * ```
19
- */
20
- export declare class StdioTransport implements Transport {
21
- private closed;
22
- private writeLock;
23
- /**
24
- * Emit a span to stdout as JSON
25
- *
26
- * @param span - The span to emit
27
- */
28
- emit(span: Span): void;
29
- /**
30
- * No-op for stdio transport (not applicable)
31
- */
32
- finishSpan(): void;
33
- /**
34
- * No-op for stdio transport (not applicable)
35
- */
36
- startAgentInstance(): void;
37
- /**
38
- * No-op for stdio transport (not applicable)
39
- */
40
- finishAgentInstance(): void;
41
- /**
42
- * Close the transport and wait for pending writes to complete
43
- *
44
- * @returns Promise that resolves when all writes are complete
45
- */
46
- close(): Promise<void>;
47
- }
48
- //# sourceMappingURL=stdio.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../src/transport/stdio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,YAAW,SAAS;IAC9C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAqB;IAEtC;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAiBtB;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAI1B;;OAEG;IACH,mBAAmB,IAAI,IAAI;IAI3B;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
@@ -1,71 +0,0 @@
1
- import { serializeValue } from '../utils/serialization.js';
2
- /**
3
- * STDIO transport emits spans as newline-delimited JSON to stdout.
4
- *
5
- * This is the default transport and requires no configuration.
6
- * It's useful for local development and for piping span data to other tools.
7
- *
8
- * Features:
9
- * - Newline-delimited JSON output
10
- * - Promise-based write locking for ordering
11
- * - Graceful error handling
12
- *
13
- * @example
14
- * ```typescript
15
- * const transport = new StdioTransport();
16
- * const tracer = new Tracer(transport);
17
- * ```
18
- */
19
- export class StdioTransport {
20
- closed = false;
21
- writeLock = Promise.resolve();
22
- /**
23
- * Emit a span to stdout as JSON
24
- *
25
- * @param span - The span to emit
26
- */
27
- emit(span) {
28
- if (this.closed) {
29
- return;
30
- }
31
- // Queue write to maintain ordering
32
- this.writeLock = this.writeLock.then(async () => {
33
- try {
34
- const serialized = serializeValue(span);
35
- const json = JSON.stringify(serialized);
36
- await Bun.write(Bun.stdout, `${json}\n`);
37
- }
38
- catch (error) {
39
- console.error('Failed to emit span to stdout:', error);
40
- }
41
- });
42
- }
43
- /**
44
- * No-op for stdio transport (not applicable)
45
- */
46
- finishSpan() {
47
- // No-op for stdio transport
48
- }
49
- /**
50
- * No-op for stdio transport (not applicable)
51
- */
52
- startAgentInstance() {
53
- // No-op for stdio transport
54
- }
55
- /**
56
- * No-op for stdio transport (not applicable)
57
- */
58
- finishAgentInstance() {
59
- // No-op for stdio transport
60
- }
61
- /**
62
- * Close the transport and wait for pending writes to complete
63
- *
64
- * @returns Promise that resolves when all writes are complete
65
- */
66
- async close() {
67
- this.closed = true;
68
- await this.writeLock;
69
- }
70
- }
71
- //# sourceMappingURL=stdio.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/transport/stdio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,cAAc;IACjB,MAAM,GAAG,KAAK,CAAC;IACf,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAEtC;;;;OAIG;IACH,IAAI,CAAC,IAAU;QACb,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,mCAAmC;QACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YAC9C,IAAI,CAAC;gBACH,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;gBACxC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBACxC,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC;YAC3C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACzD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,UAAU;QACR,4BAA4B;IAC9B,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,4BAA4B;IAC9B,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,4BAA4B;IAC9B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,MAAM,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;CACF"}
File without changes