@purista/harness 1.2.0 → 1.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.
@@ -5,6 +5,7 @@ import { createMetrics } from '../telemetry/index.js';
5
5
  import { buildSkillIndex, mountSkillsOnce } from '../skills/index.js';
6
6
  import { BUILTIN_ALIAS_TO_CANONICAL, getBuiltinToolSpecs, invokeBuiltinTool } from '../tools/index.js';
7
7
  import { getMcpToolSpecs, invokeMcpTool, isMcpToolDefinition } from '../tools/mcp/runner.js';
8
+ import { ulid } from '../ulid/index.js';
8
9
  function stringifyInput(input) { return typeof input === 'string' ? input : JSON.stringify(input); }
9
10
  function isReadonlyBuiltin(name) { return ['read', 'list', 'glob', 'grep'].includes(name); }
10
11
  async function checkPermission(agentId, runId, sessionId, def, toolName, input) {
@@ -90,7 +91,7 @@ async function runDefaultAgentInner(args) {
90
91
  metrics: args.metrics
91
92
  });
92
93
  const validated = parseAgentSchema(outputSchema, output, 'agent_output');
93
- return { output: validated, emitted: [{ id: `msg_${Date.now()}_a`, sessionId: args.sessionId, runId: args.runId, role: 'assistant', content: JSON.stringify(validated), timestamp: new Date().toISOString() }] };
94
+ return { output: validated, emitted: [{ id: `msg_${ulid()}_a`, sessionId: args.sessionId, runId: args.runId, role: 'assistant', content: JSON.stringify(validated), timestamp: new Date().toISOString() }] };
94
95
  }
95
96
  const baseInstructions = typeof args.agent.instructions === 'function'
96
97
  ? args.agent.instructions({ input: parsedInput, runId: args.runId, sessionId: args.sessionId, history: { list: async () => args.history }, memory: args.memory, metadata: args.metadata ?? {}, metrics: args.metrics })
@@ -153,13 +154,13 @@ async function runDefaultAgentInner(args) {
153
154
  const toolCalls = response.toolCalls ?? [];
154
155
  if (toolCalls.length === 0) {
155
156
  const validated = parseAgentSchema(outputSchema, response.object, 'agent_output');
156
- emitted.push({ id: `msg_${Date.now()}_a`, sessionId: args.sessionId, runId: args.runId, role: 'assistant', content: JSON.stringify(validated), timestamp: new Date().toISOString() });
157
+ emitted.push({ id: `msg_${ulid()}_a`, sessionId: args.sessionId, runId: args.runId, role: 'assistant', content: JSON.stringify(validated), timestamp: new Date().toISOString() });
157
158
  await args.emitEvent?.({ type: 'model.object', runId: args.runId, agentId: args.agentId, object: validated, usage: response.usage });
158
159
  await args.emitEvent?.({ type: 'agent.finished', runId: args.runId, agentId: args.agentId, at: new Date().toISOString(), output: validated });
159
160
  return { output: validated, emitted };
160
161
  }
161
162
  const assistantMsg = {
162
- id: `msg_${Date.now()}_assistant`, sessionId: args.sessionId, runId: args.runId, role: 'assistant', content: '', toolCalls,
163
+ id: `msg_${ulid()}_assistant`, sessionId: args.sessionId, runId: args.runId, role: 'assistant', content: '', toolCalls,
163
164
  timestamp: new Date().toISOString()
164
165
  };
165
166
  emitted.push(assistantMsg);
@@ -227,7 +228,7 @@ async function runDefaultAgentInner(args) {
227
228
  }
228
229
  await args.emitEvent?.({ type: 'tool.finished', runId: args.runId, agentId: args.agentId, toolId: canonical, callId: call.id, ...(result.output !== undefined ? { output: result.output } : {}), ...(result.error ? { error: result.error } : {}) });
229
230
  const toolMessage = {
230
- id: `msg_${Date.now()}_${call.id}`,
231
+ id: `msg_${ulid()}_${call.id}`,
231
232
  sessionId: args.sessionId,
232
233
  runId: args.runId,
233
234
  role: 'tool',
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { SandboxNoExecutorError, ToolNotFoundError, ValidationError, serializeError } from '../errors/index.js';
3
+ import { ulid } from '../ulid/index.js';
3
4
  export const BUILTIN_ALIAS_TO_CANONICAL = {
4
5
  bash: 'bash', Bash: 'bash',
5
6
  read: 'read', Read: 'read',
@@ -113,7 +114,7 @@ export async function invokeBuiltinTool(nameOrAlias, input, session, signal) {
113
114
  }
114
115
  export function toToolErrorMessage(toolCallId, error) {
115
116
  return {
116
- id: `msg_${Date.now()}`,
117
+ id: `msg_${ulid()}`,
117
118
  sessionId: '',
118
119
  role: 'tool',
119
120
  content: '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purista/harness",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Self-hosted enterprise agent harness for typed tools, agents, workflows, state, sandboxing, and telemetry.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",