stable-harness 0.0.136 → 0.0.138
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/workspace/compile.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/adapter.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/index.d.ts +2 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/index.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin/agent-tool-visibility.d.ts +23 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin/agent-tool-visibility.js +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin/permissions.d.ts +0 -8
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin/permissions.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin/task-inventory.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin-tool-policy.d.ts +1 -0
- package/node_modules/@stable-harness/adapter-deepagents/dist/src/internal/builtin-tool-policy.js +1 -1
- package/node_modules/@stable-harness/adapter-deepagents/package.json +2 -2
- package/node_modules/@stable-harness/adapter-langgraph/package.json +2 -2
- package/node_modules/@stable-harness/core/dist/index.d.ts +2 -0
- package/node_modules/@stable-harness/core/dist/index.js +1 -1
- package/node_modules/@stable-harness/core/dist/quality/event-evidence.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/completion.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/events.d.ts +21 -0
- package/node_modules/@stable-harness/core/dist/runtime/output/deliverables.d.ts +2 -0
- package/node_modules/@stable-harness/core/dist/runtime/output/deliverables.js +1 -0
- package/node_modules/@stable-harness/core/dist/runtime/policy/projection.js +1 -1
- package/node_modules/@stable-harness/core/dist/runtime/recovery/focused-text-recovery.js +1 -1
- package/node_modules/@stable-harness/core/dist/trace-types.d.ts +26 -0
- package/node_modules/@stable-harness/core/dist/trace-types.js +1 -0
- package/node_modules/@stable-harness/core/dist/trace.d.ts +3 -26
- package/node_modules/@stable-harness/core/dist/trace.js +1 -1
- package/node_modules/@stable-harness/core/package.json +3 -3
- package/node_modules/@stable-harness/governance/package.json +1 -1
- package/node_modules/@stable-harness/memory/package.json +1 -1
- package/node_modules/@stable-harness/protocols/package.json +2 -2
- package/node_modules/@stable-harness/tool-gateway/package.json +1 -1
- package/node_modules/@stable-harness/workspace-yaml/dist/discovery.js +1 -1
- package/node_modules/@stable-harness/workspace-yaml/package.json +2 -2
- package/package.json +10 -10
- package/packages/adapter-deepagents/dist/src/adapter.js +1 -1
- package/packages/adapter-deepagents/dist/src/index.d.ts +2 -0
- package/packages/adapter-deepagents/dist/src/index.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/builtin/agent-tool-visibility.d.ts +23 -0
- package/packages/adapter-deepagents/dist/src/internal/builtin/agent-tool-visibility.js +1 -0
- package/packages/adapter-deepagents/dist/src/internal/builtin/permissions.d.ts +0 -8
- package/packages/adapter-deepagents/dist/src/internal/builtin/permissions.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/builtin/task-inventory.js +1 -1
- package/packages/adapter-deepagents/dist/src/internal/builtin-tool-policy.d.ts +1 -0
- package/packages/adapter-deepagents/dist/src/internal/builtin-tool-policy.js +1 -1
- package/packages/adapter-deepagents/package.json +2 -2
- package/packages/adapter-langgraph/package.json +2 -2
- package/packages/cli/package.json +8 -8
- package/packages/core/dist/index.d.ts +2 -0
- package/packages/core/dist/index.js +1 -1
- package/packages/core/dist/quality/event-evidence.js +1 -1
- package/packages/core/dist/runtime/completion.js +1 -1
- package/packages/core/dist/runtime/events.d.ts +21 -0
- package/packages/core/dist/runtime/output/deliverables.d.ts +2 -0
- package/packages/core/dist/runtime/output/deliverables.js +1 -0
- package/packages/core/dist/runtime/policy/projection.js +1 -1
- package/packages/core/dist/runtime/recovery/focused-text-recovery.js +1 -1
- package/packages/core/dist/trace-types.d.ts +26 -0
- package/packages/core/dist/trace-types.js +1 -0
- package/packages/core/dist/trace.d.ts +3 -26
- package/packages/core/dist/trace.js +1 -1
- package/packages/core/package.json +3 -3
- package/packages/evaluation/package.json +2 -2
- package/packages/governance/package.json +1 -1
- package/packages/memory/package.json +1 -1
- package/packages/protocols/package.json +2 -2
- package/packages/tool-gateway/package.json +1 -1
- package/packages/workspace-yaml/dist/discovery.js +1 -1
- package/packages/workspace-yaml/package.json +2 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RuntimeEvent } from "./types.js";
|
|
2
|
+
export type RuntimeTraceSpanKind = "run" | "tool" | "workflow" | "spec" | "adapter" | "memory" | "artifact" | "deliverable" | "progress" | "plan" | "delegation" | "approval" | "quality";
|
|
3
|
+
export type RuntimeTraceSpanStatus = "running" | "completed" | "failed" | "blocked" | "event";
|
|
4
|
+
export type RuntimeTraceSpanEventRef = {
|
|
5
|
+
index: number;
|
|
6
|
+
eventId: string;
|
|
7
|
+
type: RuntimeEvent["type"];
|
|
8
|
+
emittedAt?: string;
|
|
9
|
+
};
|
|
10
|
+
export type RuntimeTraceSpan = {
|
|
11
|
+
spanId: string;
|
|
12
|
+
parentSpanId?: string;
|
|
13
|
+
requestId: string;
|
|
14
|
+
sessionId: string;
|
|
15
|
+
agentId: string;
|
|
16
|
+
kind: RuntimeTraceSpanKind;
|
|
17
|
+
name: string;
|
|
18
|
+
status: RuntimeTraceSpanStatus;
|
|
19
|
+
startedAt?: string;
|
|
20
|
+
completedAt?: string;
|
|
21
|
+
startEventIndex: number;
|
|
22
|
+
endEventIndex?: number;
|
|
23
|
+
durationMs?: number;
|
|
24
|
+
attributes?: Record<string, unknown>;
|
|
25
|
+
events: RuntimeTraceSpanEventRef[];
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { RuntimeEvent, RuntimeRunRecord } from "./types.js";
|
|
2
|
+
import type { RuntimeTraceSpan } from "./trace-types.js";
|
|
3
|
+
export type { RuntimeTraceSpan, RuntimeTraceSpanEventRef, RuntimeTraceSpanKind, RuntimeTraceSpanStatus } from "./trace-types.js";
|
|
2
4
|
export type PlanTodoItem = {
|
|
3
5
|
content: string;
|
|
4
6
|
status: string;
|
|
5
7
|
};
|
|
6
8
|
export type RuntimeTraceEntry = {
|
|
7
|
-
type: "request" | "tool" | "workflow" | "spec" | "adapter" | "memory" | "artifact" | "progress" | "plan" | "delegation" | "quality";
|
|
9
|
+
type: "request" | "tool" | "workflow" | "spec" | "adapter" | "memory" | "artifact" | "deliverable" | "progress" | "plan" | "delegation" | "quality";
|
|
8
10
|
label: string;
|
|
9
11
|
agentId: string;
|
|
10
12
|
requestId: string;
|
|
@@ -14,31 +16,6 @@ export type RuntimeAdapterTraceProjection = {
|
|
|
14
16
|
traceType: RuntimeTraceEntry["type"];
|
|
15
17
|
traceLabel: string;
|
|
16
18
|
} & Record<string, unknown>;
|
|
17
|
-
export type RuntimeTraceSpanKind = "run" | "tool" | "workflow" | "spec" | "adapter" | "memory" | "artifact" | "progress" | "plan" | "delegation" | "approval" | "quality";
|
|
18
|
-
export type RuntimeTraceSpanStatus = "running" | "completed" | "failed" | "blocked" | "event";
|
|
19
|
-
export type RuntimeTraceSpanEventRef = {
|
|
20
|
-
index: number;
|
|
21
|
-
eventId: string;
|
|
22
|
-
type: RuntimeEvent["type"];
|
|
23
|
-
emittedAt?: string;
|
|
24
|
-
};
|
|
25
|
-
export type RuntimeTraceSpan = {
|
|
26
|
-
spanId: string;
|
|
27
|
-
parentSpanId?: string;
|
|
28
|
-
requestId: string;
|
|
29
|
-
sessionId: string;
|
|
30
|
-
agentId: string;
|
|
31
|
-
kind: RuntimeTraceSpanKind;
|
|
32
|
-
name: string;
|
|
33
|
-
status: RuntimeTraceSpanStatus;
|
|
34
|
-
startedAt?: string;
|
|
35
|
-
completedAt?: string;
|
|
36
|
-
startEventIndex: number;
|
|
37
|
-
endEventIndex?: number;
|
|
38
|
-
durationMs?: number;
|
|
39
|
-
attributes?: Record<string, unknown>;
|
|
40
|
-
events: RuntimeTraceSpanEventRef[];
|
|
41
|
-
};
|
|
42
19
|
export declare function createDelegationTraceProjection(label: "delegation.start" | "delegation.completed", detail?: Record<string, unknown>): RuntimeAdapterTraceProjection;
|
|
43
20
|
export declare function createPlanTraceProjection(label: "plan.updated", detail?: Record<string, unknown>): RuntimeAdapterTraceProjection;
|
|
44
21
|
export declare function projectRuntimeTrace(run: RuntimeRunRecord): RuntimeTraceEntry[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function createDelegationTraceProjection(t,e={}){return{traceType:"delegation",traceLabel:t,...e}}export function createPlanTraceProjection(t,e={}){return{traceType:"plan",traceLabel:t,...e}}export function projectRuntimeTrace(t){return t.events.map(projectEvent).filter(isTraceEntry)}export function projectRuntimeTraceSpans(t){const e=function createSpanBuilder(t){const e=`run:${t.requestId}`,r=[],n=new Map;return{ensureRoot(){if(n.has(e))return;const o={spanId:e,requestId:t.requestId,sessionId:t.sessionId,agentId:t.agentId,kind:"run",name:t.agentId,status:(a=t.state,"completed"===a?"completed":"failed"===a?"failed":"cancelled"===a?"blocked":"running"),startedAt:t.startedAt,completedAt:t.completedAt,startEventIndex:0,...t.parentRunId?{parentSpanId:`run:${t.parentRunId}`}:{},events:[]};var a;r.push(o),n.set(e,o)},markRoot(t,r,o,a){const i=n.get(e);i&&(addEvent(i,t,r),i.status=o,i.attributes=merge(i.attributes,a),"running"!==o&&close(i,t,r))},start(t,o,a,i,s,p){const d=createSpan(`${e}/${t}:${s}`,e,o,a,i,s,p);r.push(d),n.set(t,d)},complete(t,o,a,i){const s=n.get(t)??createSpan(`${e}/${t}:${a}`,e,"adapter",t,o,a);return n.has(t)||r.push(s),addEvent(s,o,a),s.attributes=merge(s.attributes,i),close(s,o,a),n.delete(t),s},fail(t,e,r,n){this.complete(t,e,r,n).status="failed"},event(t,n,o,a,i){const s=createSpan(`${e}/event:${a}`,e,t,n,o,a,i);s.status=function readBlockedStatus(t){return t.type.endsWith(".blocked")||t.type.includes(".approval.")?"blocked":void 0}(o)??"event",close(s,o,a),r.push(s)},closeRoot(){const r=n.get(e);r&&t.completedAt&&(r.completedAt=t.completedAt)},spans:()=>r}}(t);return e.ensureRoot(),t.events.forEach((t,r)=>function projectSpanEvent(t,e,r){return e.type.startsWith("runtime.request.")?function projectRequestSpanEvent(t,e,r){return"runtime.request.started"===e.type?t.markRoot(e,r,"running",{input:e.input}):"runtime.request.completed"===e.type?t.markRoot(e,r,"completed",{output:e.output}):"runtime.request.failed"===e.type?t.markRoot(e,r,"failed",{error:e.error}):"runtime.request.cancelled"===e.type?t.markRoot(e,r,"blocked",{reason:e.reason}):"runtime.execution.contract.failed"===e.type?projectSingleSpan(t,e,r,"quality",e.type,{reason:e.reason,missingEvidenceTools:e.missingEvidenceTools}):void 0}(t,e,r):"runtime.tool.direct.started"===e.type?t.start(`tool:${e.toolId}`,"tool",e.toolId,e,r,{toolId:e.toolId}):"runtime.tool.direct.completed"===e.type?t.complete(`tool:${e.toolId}`,e,r,{toolId:e.toolId,output:e.output}):"runtime.workflow.started"===e.type?t.start(`workflow:${e.workflowId}`,"workflow",e.workflowId,e,r,{workflowId:e.workflowId,adapter:e.adapter}):"runtime.workflow.completed"===e.type?t.complete(`workflow:${e.workflowId}`,e,r,{workflowId:e.workflowId,adapter:e.adapter}):e.type.startsWith("runtime.approval.")||e.type.startsWith("runtime.memory.approval.")?projectSingleSpan(t,e,r,"approval",e.type):e.type.startsWith("runtime.specDriven.phase.")?projectSingleSpan(t,e,r,"spec",function readPhaseName(t,e){return"phaseId"in t&&"string"==typeof t.phaseId?t.phaseId:e}(e,"phase")):e.type.startsWith("runtime.memory.")?projectSingleSpan(t,e,r,"memory",e.type):e.type.startsWith("runtime.quality.")?projectSingleSpan(t,e,r,"quality",e.type):"runtime.failure.classified"===e.type?projectSingleSpan(t,e,r,"quality",e.type,e.classification):e.type.startsWith("runtime.improvement.")||e.type.startsWith("runtime.verification.")?projectSingleSpan(t,e,r,"quality",e.type):e.type.startsWith("runtime.context.")?projectSingleSpan(t,e,r,"artifact",e.type):e.type.startsWith("runtime.repair.")?projectSingleSpan(t,e,r,"adapter",e.type):"runtime.artifact.created"===e.type?projectSingleSpan(t,e,r,"artifact",e.artifact.id,{artifact:e.artifact}):"runtime.progress.narration"===e.type?projectSingleSpan(t,e,r,"progress",e.message,{provider:e.provider}):"runtime.adapter.event"===e.type?function projectAdapterSpanEvent(t,e,r){const n=isRecord(e.event)?e.event:void 0,o=readString(n?.phase)??"runtime.adapter.event",a=readTraceType(n?.traceType),i=readString(n?.traceLabel);return"delegation"===a&&i?.endsWith(".start")?t.start(delegationKey(n),"delegation",readString(n?.subagentType)??i,e,r,n):"delegation"===a&&i?.endsWith(".completed")?t.complete(delegationKey(n),e,r,n):"plan"===a&&i?projectSingleSpan(t,e,r,"plan",i,n):function isToolStartEvent(t){return"deepagents.tool_execution.start"===t?.eventType||"agent.tool.start"===t?.phase}(n)?t.start(`agent-tool:${readString(n?.toolId)??"unknown"}`,"tool",readString(n?.toolId)??o,e,r,n):function isToolResultEvent(t){return"deepagents.tool_execution.result"===t?.eventType||"agent.tool.result"===t?.phase}(n)?t.complete(`agent-tool:${readString(n?.toolId)??"unknown"}`,e,r,n):projectSingleSpan(t,e,r,"adapter",o,n)}(t,e,r):"runtime.inventory.repair"===e.type?projectSingleSpan(t,e,r,"adapter","runtime.inventory.repair",{status:e.status,...e.diagnostic}):"runtime.sandbox.decision"===e.type?projectSingleSpan(t,e,r,"tool",`sandbox:${e.toolId}`,{toolId:e.toolId,...e.decision}):"runtime.tool.failure"===e.type?t.fail(`tool:${e.toolId}`,e,r,{toolId:e.toolId,...e.failure}):"runtime.tool.circuit.opened"===e.type?projectSingleSpan(t,e,r,"tool",`circuit:${e.toolId}`,{toolId:e.toolId,reason:e.reason}):void 0}(e,t,r)),e.closeRoot(),e.spans()}export function projectEvent(t){return"runtime.request.started"===t.type||"runtime.request.completed"===t.type||"runtime.request.failed"===t.type?base(t,"request",t.type):"runtime.request.cancelled"===t.type?base(t,"request",t.type,{reason:t.reason}):"runtime.failure.classified"===t.type?base(t,"quality",t.type,t.classification):"runtime.execution.contract.failed"===t.type?base(t,"request",t.type,{reason:t.reason,missingEvidenceTools:t.missingEvidenceTools}):"runtime.inventory.repair"===t.type?base(t,"adapter","runtime.inventory.repair",{status:t.status,...t.diagnostic}):"runtime.repair.started"===t.type||"runtime.repair.completed"===t.type?base(t,"adapter",t.type,{layer:t.layer,..."outcome"in t?{outcome:t.outcome}:{},..."attempt"in t?{attempt:t.attempt}:{},..."reason"in t?{reason:t.reason}:{},...t.diagnostics?{diagnostics:t.diagnostics}:{}}):"runtime.tool.direct.started"===t.type?base(t,"tool","runtime.tool.direct.started",{toolId:t.toolId}):"runtime.tool.direct.completed"===t.type?base(t,"tool","runtime.tool.direct.completed",{toolId:t.toolId,...outputTraceDetail(t.output)}):"runtime.sandbox.decision"===t.type?base(t,"tool","runtime.sandbox.decision",{toolId:t.toolId,...t.decision}):"runtime.tool.failure"===t.type?base(t,"tool","runtime.tool.failure",{toolId:t.toolId,...t.failure}):"runtime.tool.circuit.opened"===t.type?base(t,"tool","runtime.tool.circuit.opened",{toolId:t.toolId,reason:t.reason}):"runtime.workflow.started"===t.type||"runtime.workflow.completed"===t.type?base(t,"workflow",t.type,{workflowId:t.workflowId,adapter:t.adapter}):function isSpecDrivenPhaseEvent(t){return t.type.startsWith("runtime.specDriven.phase.")}(t)?base(t,"spec",t.type,{phaseId:t.phaseId,..."workflowId"in t&&t.workflowId?{workflowId:t.workflowId}:{},..."reason"in t?{reason:t.reason}:{},..."artifact"in t&&t.artifact?{artifact:t.artifact}:{}}):"runtime.adapter.event"===t.type?function adapterTrace(t){const e=t.event;if(isRecord(e)&&"string"==typeof e.phase){const r=function semanticAdapterTrace(t,e){if("inventory.repair"===e.phase)return base(t,"adapter","runtime.inventory.repair",{status:e.status,...isRecord(e.diagnostic)?e.diagnostic:{}});const r=readTraceType(e.traceType),n=readString(e.traceLabel);return r&&n?base(t,r,n,e):void 0}(t,e);return r||base(t,"adapter",e.phase.startsWith("agent.")?e.phase:`adapter.${e.phase}`,e)}return base(t,"adapter","runtime.adapter.event",{event:e})}(t):"runtime.artifact.created"===t.type?base(t,"artifact","runtime.artifact.created",{artifact:t.artifact}):t.type.startsWith("runtime.memory.")?base(t,"memory",t.type):t.type.startsWith("runtime.improvement.")||t.type.startsWith("runtime.verification.")?base(t,"quality",t.type):t.type.startsWith("runtime.context.")?base(t,"artifact",t.type):"runtime.progress.narration"===t.type?base(t,"progress",t.type,{message:t.message,provider:t.provider,sourceEventTypes:t.sourceEventTypes}):void 0}export function readPlanTodos(t){const e=function readPlanRecord(t){if(isRecord(t))return t;if("string"==typeof t)try{const e=JSON.parse(t);return isRecord(e)?e:void 0}catch{return}}(t),r=function readTodosArray(t){const e=isRecord(t?.args)?t.args:void 0;return Array.isArray(t?.todos)?t.todos:Array.isArray(e?.todos)?e.todos:[]}(e);return r.map(readTodo).filter(isPlanTodoItem)}function readTodo(t){if(isRecord(t)&&"string"==typeof t.content)return{content:t.content,status:"string"==typeof t.status?t.status:"pending"}}function isPlanTodoItem(t){return void 0!==t}function base(t,e,r,n){return{type:e,label:r,agentId:t.agentId,requestId:t.requestId,detail:n}}function isTraceEntry(t){return void 0!==t}function outputTraceDetail(t){const e="string"==typeof t?t:function serializeOutput(t){try{return void 0===t?"":JSON.stringify(t)}catch{return String(t)}}(t),r=e.slice(0,1200);return{outputType:Array.isArray(t)?"array":null===t?"null":typeof t,outputLength:e.length,outputPreview:r,...e.length>r.length?{outputTail:e.slice(-1200)}:{}}}function projectSingleSpan(t,e,r,n,o,a){return t.event(n,o,e,r,a)}function delegationKey(t){return`delegation:${readString(t?.subagentType)??readString(t?.toolId)??"task"}`}function createSpan(t,e,r,n,o,a,i){const s={spanId:t,parentSpanId:e,requestId:o.requestId,sessionId:o.sessionId,agentId:o.agentId,kind:r,name:n,status:"running",startedAt:o.emittedAt,startEventIndex:a,attributes:i,events:[]};return addEvent(s,o,a),s}function addEvent(t,e,r){t.events.push({index:r,eventId:e.eventId??`${e.requestId}:${r}`,type:e.type,emittedAt:e.emittedAt})}function close(t,e,r){t.status="failed"===t.status||"blocked"===t.status?t.status:"completed",t.completedAt=e.emittedAt,t.endEventIndex=r,t.durationMs=function durationMs(t,e){if(!t||!e)return;const r=Date.parse(e)-Date.parse(t);return Number.isFinite(r)&&r>=0?r:void 0}(t.startedAt,t.completedAt)}function merge(t,e){return e?{...t,...e}:t}function isRecord(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function readTraceType(t){const e=readString(t);return"request"===e||"tool"===e||"workflow"===e||"spec"===e||"adapter"===e||"memory"===e||"artifact"===e||"progress"===e||"plan"===e||"delegation"===e?e:void 0}function readString(t){return"string"==typeof t&&t.trim()?t:void 0}
|
|
1
|
+
export function createDelegationTraceProjection(e,t={}){return{traceType:"delegation",traceLabel:e,...t}}export function createPlanTraceProjection(e,t={}){return{traceType:"plan",traceLabel:e,...t}}export function projectRuntimeTrace(e){return e.events.map(projectEvent).filter(isTraceEntry)}export function projectRuntimeTraceSpans(e){const t=function createSpanBuilder(e){const t=`run:${e.requestId}`,r=[],n=new Map;return{ensureRoot(){if(n.has(t))return;const o={spanId:t,requestId:e.requestId,sessionId:e.sessionId,agentId:e.agentId,kind:"run",name:e.agentId,status:(a=e.state,"completed"===a?"completed":"failed"===a?"failed":"cancelled"===a?"blocked":"running"),startedAt:e.startedAt,completedAt:e.completedAt,startEventIndex:0,...e.parentRunId?{parentSpanId:`run:${e.parentRunId}`}:{},events:[]};var a;r.push(o),n.set(t,o)},markRoot(e,r,o,a){const i=n.get(t);i&&(addEvent(i,e,r),i.status=o,i.attributes=merge(i.attributes,a),"running"!==o&&close(i,e,r))},start(e,o,a,i,s,d){const p=createSpan(`${t}/${e}:${s}`,t,o,a,i,s,d);r.push(p),n.set(e,p)},complete(e,o,a,i){const s=n.get(e)??createSpan(`${t}/${e}:${a}`,t,"adapter",e,o,a);return n.has(e)||r.push(s),addEvent(s,o,a),s.attributes=merge(s.attributes,i),close(s,o,a),n.delete(e),s},fail(e,t,r,n){this.complete(e,t,r,n).status="failed"},event(e,n,o,a,i){const s=createSpan(`${t}/event:${a}`,t,e,n,o,a,i);s.status=function readBlockedStatus(e){return e.type.endsWith(".blocked")||e.type.includes(".approval.")?"blocked":void 0}(o)??"event",close(s,o,a),r.push(s)},closeRoot(){const r=n.get(t);r&&e.completedAt&&(r.completedAt=e.completedAt)},spans:()=>r}}(e);return t.ensureRoot(),e.events.forEach((e,r)=>function projectSpanEvent(e,t,r){return t.type.startsWith("runtime.request.")?function projectRequestSpanEvent(e,t,r){return"runtime.request.started"===t.type?e.markRoot(t,r,"running",{input:t.input}):"runtime.request.completed"===t.type?e.markRoot(t,r,"completed",{output:t.output}):"runtime.request.failed"===t.type?e.markRoot(t,r,"failed",{error:t.error}):"runtime.request.cancelled"===t.type?e.markRoot(t,r,"blocked",{reason:t.reason}):"runtime.execution.contract.failed"===t.type?projectSingleSpan(e,t,r,"quality",t.type,{reason:t.reason,missingEvidenceTools:t.missingEvidenceTools}):void 0}(e,t,r):"runtime.tool.direct.started"===t.type?e.start(`tool:${t.toolId}`,"tool",t.toolId,t,r,{toolId:t.toolId}):"runtime.tool.direct.completed"===t.type?e.complete(`tool:${t.toolId}`,t,r,{toolId:t.toolId,output:t.output}):"runtime.workflow.started"===t.type?e.start(`workflow:${t.workflowId}`,"workflow",t.workflowId,t,r,{workflowId:t.workflowId,adapter:t.adapter}):"runtime.workflow.completed"===t.type?e.complete(`workflow:${t.workflowId}`,t,r,{workflowId:t.workflowId,adapter:t.adapter}):t.type.startsWith("runtime.approval.")||t.type.startsWith("runtime.memory.approval.")?projectSingleSpan(e,t,r,"approval",t.type):t.type.startsWith("runtime.specDriven.phase.")?projectSingleSpan(e,t,r,"spec",function readPhaseName(e,t){return"phaseId"in e&&"string"==typeof e.phaseId?e.phaseId:t}(t,"phase")):t.type.startsWith("runtime.memory.")?projectSingleSpan(e,t,r,"memory",t.type):t.type.startsWith("runtime.quality.")?projectSingleSpan(e,t,r,"quality",t.type):"runtime.failure.classified"===t.type?projectSingleSpan(e,t,r,"quality",t.type,t.classification):t.type.startsWith("runtime.improvement.")||t.type.startsWith("runtime.verification.")?projectSingleSpan(e,t,r,"quality",t.type):t.type.startsWith("runtime.context.")?projectSingleSpan(e,t,r,"artifact",t.type):t.type.startsWith("runtime.repair.")?projectSingleSpan(e,t,r,"adapter",t.type):"runtime.artifact.created"===t.type?projectSingleSpan(e,t,r,"artifact",t.artifact.id,{artifact:t.artifact}):"runtime.deliverable.created"===t.type?projectSingleSpan(e,t,r,"deliverable",t.deliverable.id,{deliverable:t.deliverable,kind:t.deliverable.kind,status:t.deliverable.status,source:t.deliverable.source}):"runtime.progress.narration"===t.type?projectSingleSpan(e,t,r,"progress",t.message,{provider:t.provider}):"runtime.adapter.event"===t.type?function projectAdapterSpanEvent(e,t,r){const n=isRecord(t.event)?t.event:void 0,o=readString(n?.phase)??"runtime.adapter.event",a=readTraceType(n?.traceType),i=readString(n?.traceLabel);return"delegation"===a&&i?.endsWith(".start")?e.start(delegationKey(n),"delegation",readString(n?.subagentType)??i,t,r,n):"delegation"===a&&i?.endsWith(".completed")?e.complete(delegationKey(n),t,r,n):"plan"===a&&i?projectSingleSpan(e,t,r,"plan",i,n):function isToolStartEvent(e){return"deepagents.tool_execution.start"===e?.eventType||"agent.tool.start"===e?.phase}(n)?e.start(`agent-tool:${readString(n?.toolId)??"unknown"}`,"tool",readString(n?.toolId)??o,t,r,n):function isToolResultEvent(e){return"deepagents.tool_execution.result"===e?.eventType||"agent.tool.result"===e?.phase}(n)?e.complete(`agent-tool:${readString(n?.toolId)??"unknown"}`,t,r,n):projectSingleSpan(e,t,r,"adapter",o,n)}(e,t,r):"runtime.inventory.repair"===t.type?projectSingleSpan(e,t,r,"adapter","runtime.inventory.repair",{status:t.status,...t.diagnostic}):"runtime.sandbox.decision"===t.type?projectSingleSpan(e,t,r,"tool",`sandbox:${t.toolId}`,{toolId:t.toolId,...t.decision}):"runtime.tool.failure"===t.type?e.fail(`tool:${t.toolId}`,t,r,{toolId:t.toolId,...t.failure}):"runtime.tool.circuit.opened"===t.type?projectSingleSpan(e,t,r,"tool",`circuit:${t.toolId}`,{toolId:t.toolId,reason:t.reason}):void 0}(t,e,r)),t.closeRoot(),t.spans()}export function projectEvent(e){return"runtime.request.started"===e.type||"runtime.request.completed"===e.type||"runtime.request.failed"===e.type?base(e,"request",e.type):"runtime.request.cancelled"===e.type?base(e,"request",e.type,{reason:e.reason}):"runtime.failure.classified"===e.type?base(e,"quality",e.type,e.classification):"runtime.execution.contract.failed"===e.type?base(e,"request",e.type,{reason:e.reason,missingEvidenceTools:e.missingEvidenceTools}):"runtime.inventory.repair"===e.type?base(e,"adapter","runtime.inventory.repair",{status:e.status,...e.diagnostic}):"runtime.repair.started"===e.type||"runtime.repair.completed"===e.type?base(e,"adapter",e.type,{layer:e.layer,..."outcome"in e?{outcome:e.outcome}:{},..."attempt"in e?{attempt:e.attempt}:{},..."reason"in e?{reason:e.reason}:{},...e.diagnostics?{diagnostics:e.diagnostics}:{}}):"runtime.tool.direct.started"===e.type?base(e,"tool","runtime.tool.direct.started",{toolId:e.toolId}):"runtime.tool.direct.completed"===e.type?base(e,"tool","runtime.tool.direct.completed",{toolId:e.toolId,...outputTraceDetail(e.output)}):"runtime.sandbox.decision"===e.type?base(e,"tool","runtime.sandbox.decision",{toolId:e.toolId,...e.decision}):"runtime.tool.failure"===e.type?base(e,"tool","runtime.tool.failure",{toolId:e.toolId,...e.failure}):"runtime.tool.circuit.opened"===e.type?base(e,"tool","runtime.tool.circuit.opened",{toolId:e.toolId,reason:e.reason}):"runtime.workflow.started"===e.type||"runtime.workflow.completed"===e.type?base(e,"workflow",e.type,{workflowId:e.workflowId,adapter:e.adapter}):function isSpecDrivenPhaseEvent(e){return e.type.startsWith("runtime.specDriven.phase.")}(e)?base(e,"spec",e.type,{phaseId:e.phaseId,..."workflowId"in e&&e.workflowId?{workflowId:e.workflowId}:{},..."reason"in e?{reason:e.reason}:{},..."artifact"in e&&e.artifact?{artifact:e.artifact}:{}}):"runtime.adapter.event"===e.type?function adapterTrace(e){const t=e.event;if(isRecord(t)&&"string"==typeof t.phase){const r=function semanticAdapterTrace(e,t){if("inventory.repair"===t.phase)return base(e,"adapter","runtime.inventory.repair",{status:t.status,...isRecord(t.diagnostic)?t.diagnostic:{}});const r=readTraceType(t.traceType),n=readString(t.traceLabel);return r&&n?base(e,r,n,t):void 0}(e,t);return r||base(e,"adapter",t.phase.startsWith("agent.")?t.phase:`adapter.${t.phase}`,t)}return base(e,"adapter","runtime.adapter.event",{event:t})}(e):"runtime.artifact.created"===e.type?base(e,"artifact","runtime.artifact.created",{artifact:e.artifact}):"runtime.deliverable.created"===e.type?base(e,"deliverable","runtime.deliverable.created",{deliverable:e.deliverable,kind:e.deliverable.kind,status:e.deliverable.status,source:e.deliverable.source}):e.type.startsWith("runtime.memory.")?base(e,"memory",e.type):e.type.startsWith("runtime.improvement.")||e.type.startsWith("runtime.verification.")?base(e,"quality",e.type):e.type.startsWith("runtime.context.")?base(e,"artifact",e.type):"runtime.progress.narration"===e.type?base(e,"progress",e.type,{message:e.message,provider:e.provider,sourceEventTypes:e.sourceEventTypes}):void 0}export function readPlanTodos(e){const t=function readPlanRecord(e){if(isRecord(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);return isRecord(t)?t:void 0}catch{return}}(e),r=function readTodosArray(e){const t=isRecord(e?.args)?e.args:void 0;return Array.isArray(e?.todos)?e.todos:Array.isArray(t?.todos)?t.todos:[]}(t);return r.map(readTodo).filter(isPlanTodoItem)}function readTodo(e){if(isRecord(e)&&"string"==typeof e.content)return{content:e.content,status:"string"==typeof e.status?e.status:"pending"}}function isPlanTodoItem(e){return void 0!==e}function base(e,t,r,n){return{type:t,label:r,agentId:e.agentId,requestId:e.requestId,detail:n}}function isTraceEntry(e){return void 0!==e}function outputTraceDetail(e){const t="string"==typeof e?e:function serializeOutput(e){try{return void 0===e?"":JSON.stringify(e)}catch{return String(e)}}(e),r=t.slice(0,1200);return{outputType:Array.isArray(e)?"array":null===e?"null":typeof e,outputLength:t.length,outputPreview:r,...t.length>r.length?{outputTail:t.slice(-1200)}:{}}}function projectSingleSpan(e,t,r,n,o,a){return e.event(n,o,t,r,a)}function delegationKey(e){return`delegation:${readString(e?.subagentType)??readString(e?.toolId)??"task"}`}function createSpan(e,t,r,n,o,a,i){const s={spanId:e,parentSpanId:t,requestId:o.requestId,sessionId:o.sessionId,agentId:o.agentId,kind:r,name:n,status:"running",startedAt:o.emittedAt,startEventIndex:a,attributes:i,events:[]};return addEvent(s,o,a),s}function addEvent(e,t,r){e.events.push({index:r,eventId:t.eventId??`${t.requestId}:${r}`,type:t.type,emittedAt:t.emittedAt})}function close(e,t,r){e.status="failed"===e.status||"blocked"===e.status?e.status:"completed",e.completedAt=t.emittedAt,e.endEventIndex=r,e.durationMs=function durationMs(e,t){if(!e||!t)return;const r=Date.parse(t)-Date.parse(e);return Number.isFinite(r)&&r>=0?r:void 0}(e.startedAt,e.completedAt)}function merge(e,t){return t?{...e,...t}:e}function isRecord(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function readTraceType(e){const t=readString(e);return"request"===t||"tool"===t||"workflow"===t||"spec"===t||"adapter"===t||"memory"===t||"artifact"===t||"deliverable"===t||"progress"===t||"plan"===t||"delegation"===t?t:void 0}function readString(e){return"string"==typeof e&&e.trim()?e:void 0}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stable-harness/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.138",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
".": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@stable-harness/governance": "0.0.
|
|
16
|
-
"@stable-harness/memory": "0.0.
|
|
15
|
+
"@stable-harness/governance": "0.0.138",
|
|
16
|
+
"@stable-harness/memory": "0.0.138"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stable-harness/evaluation",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.138",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"main": "dist/src/index.js",
|
|
12
12
|
"types": "dist/src/index.d.ts",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@stable-harness/core": "0.0.
|
|
14
|
+
"@stable-harness/core": "0.0.138"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stable-harness/protocols",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.138",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"main": "dist/src/index.js",
|
|
12
12
|
"types": "dist/src/index.d.ts",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@stable-harness/core": "0.0.
|
|
14
|
+
"@stable-harness/core": "0.0.138"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdir as t,readFile as e}from"node:fs/promises";import r from"node:path";import{parseAllDocuments as
|
|
1
|
+
import{readdir as t,readFile as e}from"node:fs/promises";import r from"node:path";import{parseAllDocuments as o}from"yaml";export async function listYamlFiles(e){const o=await t(e,{withFileTypes:!0});return(await Promise.all(o.map(async t=>{const o=r.join(e,t.name);return t.isDirectory()?listYamlFiles(o):t.isFile()&&/\.ya?ml$/iu.test(t.name)?[o]:[]}))).flat().sort()}export async function discoverModuleTools(t){const o=r.join(t,"resources","tools");let i;try{i=await listModuleToolFiles(o)}catch{return[]}return(await Promise.all(i.map(t=>async function discoverModuleToolFile(t){const o=await e(t,"utf8"),i=[...o.matchAll(/export\s+const\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*tool\s*\(/gu)].map(t=>t[1]).filter(t=>"default"!==t);return(i.length>0?i:[r.basename(t,".mjs")]).map(e=>({id:e,sourcePath:t,...readModuleToolDescription(o,e)}))}(t)))).flat()}async function listModuleToolFiles(e){const o=await t(e,{withFileTypes:!0});return(await Promise.all(o.map(async t=>{const o=r.join(e,t.name);return t.isDirectory()&&!t.name.startsWith("_")?listModuleToolFiles(o):t.isFile()&&t.name.endsWith(".mjs")&&!t.name.startsWith("_")?[o]:[]}))).flat().sort()}export async function discoverSkills(i){const s=r.join(i,"resources","skills");let n;try{n=await t(s,{withFileTypes:!0})}catch{return[]}return(await Promise.all(n.filter(t=>t.isDirectory()).map(t=>async function readSkill(t,i){const s=r.join(t,"SKILL.md");let n;try{n=await e(s,"utf8")}catch{return}const a=function readFrontMatter(t){const e=t.match(/^---\n([\s\S]*?)\n---/u);if(!e)return{};const r=o(e[1]).at(0)?.toJSON();return"object"!=typeof r||null===r||Array.isArray(r)?{}:r}(n);return{id:readOptionalString(a.name)??i,path:s,...readOptionalString(a.description)?{description:readOptionalString(a.description)}:{},allowedTools:(l=a["allowed-tools"],Array.isArray(l)?l.filter(t=>"string"==typeof t&&t.trim().length>0):[])};var l}(r.join(s,t.name),t.name)))).filter(t=>Boolean(t))}function readModuleToolDescription(t,e){const r=t.match(new RegExp(`export\\s+const\\s+${function escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}(e)}\\s*=\\s*tool\\s*\\(\\s*\\{[\\s\\S]{0,4000}?description\\s*:\\s*(["'\`])([\\s\\S]*?)\\1`,"u")),o=t.match(/description\s*:\s*(["'`])([\s\S]*?)\1/u),i=function normalizeDescription(t){const e=t?.replace(/\\n/gu," ").replace(/\s+/gu," ").trim();return e||void 0}(r?.[2]??o?.[2]);return i?{description:i}:{}}function readOptionalString(t){return"string"==typeof t&&t.trim()?t.trim():void 0}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stable-harness/workspace-yaml",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.138",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
".": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@stable-harness/core": "0.0.
|
|
15
|
+
"@stable-harness/core": "0.0.138"
|
|
16
16
|
}
|
|
17
17
|
}
|