@bluecopa/harness 2.0.1-snapshot.1 → 2.0.1-snapshot.3

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,6 +1,7 @@
1
1
  import { A as AnyTool, T as ToolProvider, a as ToolResult, M as ModelFactory, b as ToolResultArtifact } from '../shared-types-vZuVoy_H.js';
2
2
  export { c as ActionType, B as BashOptions, d as BatchOp, e as BatchResult, G as GlobOptions, f as GrepOptions, R as ReadOptions, g as TextEditorRequest, h as ThreadStatus, i as ToolProviderCapabilities, W as WebFetchOptions } from '../shared-types-vZuVoy_H.js';
3
3
  import { HarnessTelemetry } from '../observability/otel.js';
4
+ export { MetricRecord, SpanHandle, SpanRecord } from '../observability/otel.js';
4
5
  import 'ai';
5
6
 
6
7
  /** Long-running job orchestration primitives. Generic; no coding-agent assumptions. */
@@ -1104,4 +1105,4 @@ declare class MemoryJobRegistry implements JobRegistry {
1104
1105
  private emit;
1105
1106
  }
1106
1107
 
1107
- export { ABSOLUTE_MAX_WORKER_STEPS, AnyTool, type ArcConfig, type ArcEvent, ArcLoop, type ArcRunResult, type ArcTraceEvent, type Artifact, type ArtifactStore, DEFAULT_MAX_STEPS_PER_WORKER, DEFAULT_WORKER_STEP_BUDGETS, type DispatchRecord, type DispatchTier, type ExpectedArtifact, type ExpectedOutputContract, FsArtifactStore, FsTranscriptStore, type JobEvent, type JobKind, type JobRegistry, type JobSpec, type JobStartOptions, type JobState, type JobStatus, type JobTransport, MemoryArtifactStore, MemoryJobRegistry, MemoryMessageStore, MemoryScratchPad, MemorySessionStore, MemorySummaryDAG, MemoryTranscriptStore, MemoryVectorIndex, type MessageStore, ModelFactory, type OodaSnapshot, type OrchestratorContext, type PushResult, REQUEST_MORE_STEPS_INCREMENT, type ReadEpisodeArgs, type ReadEpisodeDetail, type RunWorkerConfig, type ScratchPad, type SessionMeta, type SessionSnapshot, type SessionStore, type StoredAttachment, type StoredMessage, type SummaryDAG, type SummaryNode, type Tool, type ToolExecutionMode, ToolProvider, ToolResult, ToolResultArtifact, type TraceToolCall, type Transcript, type TranscriptStore, type Tuple, type VectorIndex, type WorkerProgressEvent, type WorkerResult, cloneForTrace, formatDispatchForPrompt };
1108
+ export { ABSOLUTE_MAX_WORKER_STEPS, AnyTool, type ArcConfig, type ArcEvent, ArcLoop, type ArcRunResult, type ArcTraceEvent, type Artifact, type ArtifactStore, DEFAULT_MAX_STEPS_PER_WORKER, DEFAULT_WORKER_STEP_BUDGETS, type DispatchRecord, type DispatchTier, type ExpectedArtifact, type ExpectedOutputContract, FsArtifactStore, FsTranscriptStore, HarnessTelemetry, type HookCallback, type HookContext, type HookDecision, type HookEventName, HookRunner, type JobEvent, type JobKind, type JobRegistry, type JobSpec, type JobStartOptions, type JobState, type JobStatus, type JobTransport, MemoryArtifactStore, MemoryJobRegistry, MemoryMessageStore, MemoryScratchPad, MemorySessionStore, MemorySummaryDAG, MemoryTranscriptStore, MemoryVectorIndex, type MessageStore, ModelFactory, type OodaSnapshot, type OrchestratorContext, type PushResult, REQUEST_MORE_STEPS_INCREMENT, type ReadEpisodeArgs, type ReadEpisodeDetail, type RunWorkerConfig, type ScratchPad, type SessionMeta, type SessionSnapshot, type SessionStore, type StoredAttachment, type StoredMessage, type SummaryDAG, type SummaryNode, type Tool, type ToolExecutionMode, ToolProvider, ToolResult, ToolResultArtifact, type TraceToolCall, type Transcript, type TranscriptStore, type Tuple, type VectorIndex, type WorkerProgressEvent, type WorkerResult, cloneForTrace, formatDispatchForPrompt };
package/dist/arc/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { tool, generateText, stepCountIs, streamText } from 'ai';
2
2
  import { anthropic } from '@ai-sdk/anthropic';
3
3
  import { z } from 'zod';
4
- import { createHash, randomUUID } from 'crypto';
4
+ import { randomUUID, createHash } from 'crypto';
5
+ import { AsyncLocalStorage } from 'async_hooks';
5
6
  import * as fs from 'fs/promises';
6
7
  import * as path from 'path';
7
8
 
@@ -4896,6 +4897,91 @@ function extractReasoningText(result) {
4896
4897
  }
4897
4898
  return "";
4898
4899
  }
4900
+
4901
+ // src/hooks/hook-runner.ts
4902
+ var HookRunner = class {
4903
+ hooks = /* @__PURE__ */ new Map();
4904
+ register(event, callback) {
4905
+ const list = this.hooks.get(event) ?? [];
4906
+ list.push(callback);
4907
+ this.hooks.set(event, list);
4908
+ }
4909
+ async run(context) {
4910
+ const list = this.hooks.get(context.event) ?? [];
4911
+ for (const hook of list) {
4912
+ const result = await hook(context);
4913
+ if (result && result.allow === false) {
4914
+ return result;
4915
+ }
4916
+ }
4917
+ return { allow: true };
4918
+ }
4919
+ };
4920
+ var HarnessTelemetry = class {
4921
+ constructor(enabled = true) {
4922
+ this.enabled = enabled;
4923
+ }
4924
+ context = new AsyncLocalStorage();
4925
+ spans = [];
4926
+ metrics = [];
4927
+ isEnabled() {
4928
+ return this.enabled;
4929
+ }
4930
+ startSpan(name, attributes = {}) {
4931
+ const now = Date.now();
4932
+ const parent = this.context.getStore();
4933
+ const traceId = parent?.traceId ?? randomUUID().replace(/-/g, "");
4934
+ const spanId = randomUUID().replace(/-/g, "").slice(0, 16);
4935
+ const record = {
4936
+ traceId,
4937
+ spanId,
4938
+ parentSpanId: parent?.spanId,
4939
+ name,
4940
+ attributes: { ...attributes },
4941
+ startTime: now,
4942
+ endTime: now
4943
+ };
4944
+ this.spans.push(record);
4945
+ return {
4946
+ traceId,
4947
+ spanId,
4948
+ end: (extra = {}) => {
4949
+ record.endTime = Date.now();
4950
+ record.attributes = { ...record.attributes, ...extra };
4951
+ }
4952
+ };
4953
+ }
4954
+ async withSpan(name, attributes, fn) {
4955
+ if (!this.enabled) {
4956
+ return fn();
4957
+ }
4958
+ const span = this.startSpan(name, attributes);
4959
+ return this.context.run({ traceId: span.traceId, spanId: span.spanId }, async () => {
4960
+ try {
4961
+ const result = await fn();
4962
+ span.end({ success: true });
4963
+ return result;
4964
+ } catch (error) {
4965
+ span.end({ success: false, error: error instanceof Error ? error.message : "unknown" });
4966
+ throw error;
4967
+ }
4968
+ });
4969
+ }
4970
+ counter(name, value = 1, attributes = {}) {
4971
+ if (!this.enabled) return;
4972
+ this.metrics.push({ name, value, type: "counter", attributes });
4973
+ }
4974
+ histogram(name, value, attributes = {}) {
4975
+ if (!this.enabled) return;
4976
+ this.metrics.push({ name, value, type: "histogram", attributes });
4977
+ }
4978
+ getSpans() {
4979
+ return [...this.spans];
4980
+ }
4981
+ getMetrics() {
4982
+ return [...this.metrics];
4983
+ }
4984
+ };
4899
4985
  var FsTranscriptStore = class {
4900
4986
  dir;
4901
4987
  indexPath;
@@ -4981,6 +5067,6 @@ var FsArtifactStore = class {
4981
5067
  }
4982
5068
  };
4983
5069
 
4984
- export { ABSOLUTE_MAX_WORKER_STEPS, ArcLoop, DEFAULT_MAX_STEPS_PER_WORKER, DEFAULT_WORKER_STEP_BUDGETS, FsArtifactStore, FsTranscriptStore, MemoryArtifactStore, MemoryJobRegistry, MemoryMessageStore, MemoryScratchPad, MemorySessionStore, MemorySummaryDAG, MemoryTranscriptStore, MemoryVectorIndex, REQUEST_MORE_STEPS_INCREMENT, cloneForTrace, formatDispatchForPrompt };
5070
+ export { ABSOLUTE_MAX_WORKER_STEPS, ArcLoop, DEFAULT_MAX_STEPS_PER_WORKER, DEFAULT_WORKER_STEP_BUDGETS, FsArtifactStore, FsTranscriptStore, HarnessTelemetry, HookRunner, MemoryArtifactStore, MemoryJobRegistry, MemoryMessageStore, MemoryScratchPad, MemorySessionStore, MemorySummaryDAG, MemoryTranscriptStore, MemoryVectorIndex, REQUEST_MORE_STEPS_INCREMENT, cloneForTrace, formatDispatchForPrompt };
4985
5071
  //# sourceMappingURL=index.js.map
4986
5072
  //# sourceMappingURL=index.js.map