@openwop/openwop 1.1.3 → 1.1.6

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/src/types.ts CHANGED
@@ -32,6 +32,10 @@ export interface Capabilities {
32
32
  schemaRounds: number;
33
33
  envelopesPerTurn: number;
34
34
  maxNodeExecutions?: number;
35
+ /** RFC 0058. Engine-side wall-clock ceiling per run (ms); upper bound for `RunConfigurable.runTimeoutMs`. */
36
+ maxRunDurationMs?: number;
37
+ /** RFC 0058. Engine-side agent-loop iteration ceiling; upper bound for `RunConfigurable.maxLoopIterations`. */
38
+ maxLoopIterations?: number;
35
39
  };
36
40
  extensions?: Record<string, unknown>;
37
41
  // Network-handshake superset (all `(future)` fields per capabilities.md)
@@ -44,6 +48,22 @@ export interface Capabilities {
44
48
  minClientVersion?: string;
45
49
  }
46
50
 
51
+ /**
52
+ * The `kind` discriminator on a `cap.breached` event payload
53
+ * (`run-event-payloads.schema.json#capBreached`). The four engine kinds, the
54
+ * RFC 0008 §K `wasm-*` runtime caps, and the RFC 0058 run-scoped bounds.
55
+ */
56
+ export type CapBreachedKind =
57
+ | 'clarification'
58
+ | 'schema'
59
+ | 'envelopes'
60
+ | 'node-executions'
61
+ | 'wasm-memory'
62
+ | 'wasm-fuel'
63
+ | 'wasm-execution-time'
64
+ | 'run-duration'
65
+ | 'loop-iterations';
66
+
47
67
  export interface RunSnapshot {
48
68
  runId: string;
49
69
  workflowId: string;
@@ -83,6 +103,15 @@ export interface RunSnapshot {
83
103
  export interface RunConfigurable {
84
104
  /** Override the per-run node-execution ceiling. Clamped server-side. */
85
105
  recursionLimit?: number;
106
+ /** RFC 0058. Wall-clock run deadline (ms from `run.started`); clamped to
107
+ * `Capabilities.limits.maxRunDurationMs`. Breach → `cap.breached
108
+ * { kind: 'run-duration' }` + `run_timeout`. */
109
+ runTimeoutMs?: number;
110
+ /** RFC 0058. Agent-loop iteration ceiling (one per orchestrator turn);
111
+ * clamped to `Capabilities.limits.maxLoopIterations`. Breach →
112
+ * `cap.breached { kind: 'loop-iterations' }` + `loop_limit_exceeded`.
113
+ * Ignored unless the host advertises `capabilities.agents.loop.supported`. */
114
+ maxLoopIterations?: number;
86
115
  /** Override AI model for nodes that consume `ctx.config.configurable.model`. */
87
116
  model?: string;
88
117
  /** Override AI temperature (server SHOULD enforce 0..2). */
@@ -96,7 +125,12 @@ export interface RunConfigurable {
96
125
  }
97
126
 
98
127
  export interface CreateRunRequest {
99
- workflowId: string;
128
+ /**
129
+ * The workflow to run. Required for a normal run; OMITTED for an eval run
130
+ * (`mode: 'eval'`), which targets `agentId` + `evalSuiteRef` instead
131
+ * (RFC 0081 §B). The server enforces the conditional requirement.
132
+ */
133
+ workflowId?: string;
100
134
  inputs?: Record<string, unknown>;
101
135
  tenantId?: string;
102
136
  scopeId?: string;
@@ -104,6 +138,12 @@ export interface CreateRunRequest {
104
138
  configurable?: RunConfigurable;
105
139
  tags?: readonly string[];
106
140
  metadata?: Record<string, unknown>;
141
+ /** RFC 0081 §B. `'eval'` makes this run an eval-suite projection (see `evalSuiteRef` + `agentId`). Omit for a normal workflow run. */
142
+ mode?: 'eval';
143
+ /** RFC 0081. URI of the `AgentEvalSuite` to run. Required when `mode === 'eval'`. */
144
+ evalSuiteRef?: string;
145
+ /** RFC 0081. The manifest agent the eval suite targets. Required when `mode === 'eval'`. */
146
+ agentId?: string;
107
147
  }
108
148
 
109
149
  export interface CreateRunResponse {
@@ -254,6 +294,99 @@ export interface ForkRunResponse {
254
294
  eventsUrl: string;
255
295
  }
256
296
 
297
+ /** RFC 0056 — a non-blocking quality signal on a run/event/node. */
298
+ export type AnnotationSignal =
299
+ | { kind: 'rating'; rating: number }
300
+ | { kind: 'flag' }
301
+ | { kind: 'label'; label: string }
302
+ | { kind: 'correction'; correction: string };
303
+
304
+ /** RFC 0056 persisted annotation (`annotation.schema.json`). A side-resource —
305
+ * not a replayable run-event-log entry. */
306
+ export interface Annotation {
307
+ annotationId: string;
308
+ target: { runId: string; eventId?: string; nodeId?: string };
309
+ signal: AnnotationSignal;
310
+ actor: { principalRef: string };
311
+ note?: string;
312
+ createdAt: string;
313
+ }
314
+
315
+ /** RFC 0056 request body for `createAnnotation` (`annotation-create.schema.json`).
316
+ * The host assigns `annotationId`/`createdAt`/`actor` and binds `target.runId`. */
317
+ export interface CreateAnnotationRequest {
318
+ target?: { eventId?: string; nodeId?: string };
319
+ signal: AnnotationSignal;
320
+ note?: string;
321
+ }
322
+
323
+ /** RFC 0059 versioned, tenant·workspace-scoped ground-truth file
324
+ * (`workspace-file.schema.json`). The `list` endpoint returns this shape
325
+ * minus `content` (metadata only). */
326
+ export interface WorkspaceFile {
327
+ path: string;
328
+ content: string;
329
+ contentType?: string;
330
+ version: number;
331
+ etag?: string;
332
+ updatedAt: string;
333
+ }
334
+
335
+ /** RFC 0059 request body for `putWorkspaceFile` (`workspace-file-create.schema.json`).
336
+ * `path` is URL-bound; the host assigns `version`/`etag`/`updatedAt`.
337
+ * Optimistic concurrency is expressed via the `If-Match` header, not the body. */
338
+ export interface PutWorkspaceFileRequest {
339
+ content: string;
340
+ contentType?: string;
341
+ }
342
+
343
+ /**
344
+ * Response from `GET /v1/runs/{runId}/ancestry` — RFC 0040 §C cross-host
345
+ * composition parent. `parent: null` for top-level runs (not dispatched
346
+ * from any other run); otherwise `parent.wellKnownUrl` is set when the
347
+ * parent is on a different host so callers can walk the chain.
348
+ *
349
+ * Capability-gated: hosts not advertising
350
+ * `capabilities.multiAgent.executionModel.crossHostCausation.ancestryEndpointSupported: true`
351
+ * return 404; the SDK surfaces that as `null` via `runs.ancestry()`.
352
+ */
353
+ export interface RunAncestryResponse {
354
+ runId: string;
355
+ hostId: string;
356
+ parent: null | {
357
+ runId: string;
358
+ hostId: string;
359
+ wellKnownUrl?: string;
360
+ cause: 'mcp-tool-call' | 'a2a-message' | 'core.subWorkflow' | 'core.dispatch';
361
+ };
362
+ }
363
+
364
+ /** RFC 0054 — response from `GET /v1/runs/{runId}:diff?against={otherRunId}`.
365
+ * Mirror of `run-diff-response.schema.json`. Deterministic, replay-aware
366
+ * structured diff of two runs' event sequences + terminal states. */
367
+ export interface RunDiffEventDiff {
368
+ seq: number;
369
+ op: 'added' | 'removed' | 'changed';
370
+ /** Present unless `op === 'added'`. */
371
+ aEvent?: RunEventDoc;
372
+ /** Present unless `op === 'removed'`. */
373
+ bEvent?: RunEventDoc;
374
+ }
375
+
376
+ export interface RunDiffResponse {
377
+ /** The `{runId}` run. */
378
+ a: string;
379
+ /** The `against` run. */
380
+ b: string;
381
+ /** Sequence at which the logs first diverge; null if identical. */
382
+ divergedAtSeq: number | null;
383
+ eventDiffs: RunDiffEventDiff[];
384
+ /** Diff of terminal RunSnapshot states (redaction-safe). */
385
+ stateDiff: Record<string, unknown>;
386
+ /** True if either run was in-flight and only a prefix was compared. */
387
+ truncated?: boolean;
388
+ }
389
+
257
390
  export interface ResolveInterruptRequest {
258
391
  resumeValue: unknown;
259
392
  }
@@ -568,6 +701,19 @@ export interface AgentDecidedPayload {
568
701
  [key: string]: unknown;
569
702
  }
570
703
 
704
+ /** `memory.written` payload (RFC 0057). Content-free per-write attribution:
705
+ * identifiers + non-secret tags only — never the entry content (the read
706
+ * side serves that, already SR-1-redacted). `nodeId` is omitted for host
707
+ * session-end writes with no node attribution. */
708
+ export interface MemoryWrittenPayload {
709
+ memoryRef: string;
710
+ memoryId: string;
711
+ nodeId?: string;
712
+ agentId?: string;
713
+ tags?: string[];
714
+ [key: string]: unknown;
715
+ }
716
+
571
717
  /** A `RunEventDoc` narrowed to a specific event-type discriminator +
572
718
  * payload shape. Returned by the `isAgent*` type guards in
573
719
  * `event-helpers.ts`. */
@@ -892,3 +1038,271 @@ function extractTraceId(traceparent: string): string | undefined {
892
1038
  if (!traceId || !/^[0-9a-f]{32}$/i.test(traceId)) return undefined;
893
1039
  return traceId;
894
1040
  }
1041
+
1042
+ /**
1043
+ * One installed manifest agent, as projected by `GET /v1/agents` /
1044
+ * `GET /v1/agents/{agentId}` (RFC 0072 §A). Read-only — never carries the
1045
+ * system-prompt body, resolved handoff schemas, or credential material (SR-1).
1046
+ */
1047
+ export interface AgentInventoryEntry {
1048
+ agentId: string;
1049
+ persona: string;
1050
+ label: string;
1051
+ description?: string;
1052
+ modelClass: string;
1053
+ packName: string;
1054
+ packVersion: string;
1055
+ toolAllowlist: string[];
1056
+ hasHandoffSchemas: boolean;
1057
+ memoryShape?: { scratchpad?: boolean; conversation?: boolean; longTerm?: boolean };
1058
+ confidenceThreshold?: number;
1059
+ /** RFC 0072 §C — optional capability tiers this host does not satisfy, inert here. */
1060
+ degraded?: string[];
1061
+ }
1062
+
1063
+ /** Response body for `GET /v1/agents` (RFC 0072 §A). */
1064
+ export interface AgentInventoryResponse {
1065
+ agents: AgentInventoryEntry[];
1066
+ total: number;
1067
+ }
1068
+
1069
+ /* ── Standing agent roster + org-chart (RFC 0086 / 0087) ──────────────── */
1070
+
1071
+ /** RFC 0086 §A — a standing agent INSTANCE: a `host:<id>` AgentRef that
1072
+ * references a manifest/deployment and owns a workflow portfolio. */
1073
+ export interface AgentRosterEntry {
1074
+ rosterId: string;
1075
+ persona: string;
1076
+ agentRef: { agentId: string; version?: string; channel?: string };
1077
+ workflows?: string[];
1078
+ owner: { tenantId: string; workspaceId?: string };
1079
+ enabled?: boolean;
1080
+ label?: string;
1081
+ description?: string;
1082
+ }
1083
+
1084
+ /** Response for `GET /v1/agents/roster` (RFC 0086 §B). */
1085
+ export interface AgentRosterResponse {
1086
+ roster: AgentRosterEntry[];
1087
+ total: number;
1088
+ }
1089
+
1090
+ /** RFC 0087 §A — an org-chart department (a tree node via `parentDepartmentId`). */
1091
+ export interface OrgChartDepartment {
1092
+ departmentId: string;
1093
+ name: string;
1094
+ parentDepartmentId: string | null;
1095
+ roles: { roleId: string; name: string }[];
1096
+ }
1097
+
1098
+ /** RFC 0087 §A — an org-chart member (a roster instance placed in a dept/role). */
1099
+ export interface OrgChartMember {
1100
+ rosterId: string;
1101
+ departmentId: string;
1102
+ roleId: string;
1103
+ reportsTo: string | null;
1104
+ }
1105
+
1106
+ /** RFC 0087 §A — the descriptive org-chart over roster members. Carries no
1107
+ * authority-bearing field by design (§B `org-position-no-authority-escalation`). */
1108
+ export interface AgentOrgChart {
1109
+ owner: { tenantId: string; workspaceId?: string };
1110
+ departments: OrgChartDepartment[];
1111
+ members: OrgChartMember[];
1112
+ }
1113
+
1114
+ /** Response for `GET /v1/agents/org-chart/{departmentId}` (RFC 0087 §D) — the
1115
+ * department subtree + the responsibility roll-up (union of member portfolios). */
1116
+ export interface OrgChartResponsibilityView {
1117
+ department: OrgChartDepartment;
1118
+ members: OrgChartMember[];
1119
+ responsibilities: string[];
1120
+ }
1121
+
1122
+ /* ── User-authored agents (sample-extension; non-normative) ─────────────
1123
+ * Backs the workflow-engine sample app's Agents tab. Pack-installed
1124
+ * agents come through `AgentInventoryEntry` above (RFC 0072 §A
1125
+ * normative inventory). The types below mirror the sample-host
1126
+ * `POST /v1/host/sample/agents` create surface — they're scoped to
1127
+ * the sample-extension and may evolve independently of the
1128
+ * normative agent surface. Future RFC promotion would migrate these
1129
+ * to the normative wire shape.
1130
+ */
1131
+
1132
+ /** Body for `POST /v1/host/sample/agents`. The server synthesises
1133
+ * the agentId as `user.<tenantId>.<persona-slug>`. */
1134
+ export interface CreateUserAgentRequest {
1135
+ /** Short name; becomes the `@`-mention slug and chat panel label.
1136
+ * Required, ≤64 chars. */
1137
+ persona: string;
1138
+ /** Longer display name; defaults to the persona when omitted. */
1139
+ label?: string;
1140
+ description?: string;
1141
+ /** One of: `chat`, `reasoning`, `coding`, `extraction`. */
1142
+ modelClass: string;
1143
+ /** Inline system prompt body; ≤16 000 chars. The sample-host stores
1144
+ * it directly (no pack-file ref). */
1145
+ systemPrompt: string;
1146
+ /** Capability ids the agent is allowed to call; ≤32 entries. */
1147
+ toolAllowlist?: string[];
1148
+ memoryShape?: {
1149
+ scratchpad?: boolean;
1150
+ conversation?: boolean;
1151
+ longTerm?: boolean;
1152
+ };
1153
+ /** 0.0-1.0; decisions below this are surfaced as low-confidence. */
1154
+ confidenceThreshold?: number;
1155
+ }
1156
+
1157
+ /** Response body for `POST /v1/host/sample/agents` — shaped to
1158
+ * match `AgentInventoryEntry` minus normative-only fields, so a
1159
+ * follow-up `GET /v1/agents` returns a row of the same shape. */
1160
+ export interface UserAgentRecord {
1161
+ agentId: string;
1162
+ persona: string;
1163
+ label: string;
1164
+ description?: string;
1165
+ modelClass: string;
1166
+ packName: string;
1167
+ packVersion: string;
1168
+ toolAllowlist: string[];
1169
+ memoryShape: {
1170
+ scratchpad: boolean;
1171
+ conversation: boolean;
1172
+ longTerm: boolean;
1173
+ };
1174
+ confidenceThreshold?: number;
1175
+ hasHandoffSchemas: false;
1176
+ }
1177
+
1178
+ /** One installable agent-pack summary from the sample host's local
1179
+ * registry mirror (`GET /v1/host/sample/registry/agent-packs`). */
1180
+ export interface AgentPackSummary {
1181
+ /** Pack name, e.g. `core.openwop.agents.code-reviewer`. */
1182
+ name: string;
1183
+ version: string;
1184
+ description?: string;
1185
+ /** Personas declared by the pack's `agents[]` (per RFC 0003). */
1186
+ personas: string[];
1187
+ /** True when at least one of the pack's agents is registered in
1188
+ * this host's in-process AgentRegistry. */
1189
+ installed: boolean;
1190
+ }
1191
+
1192
+ export interface AgentPackRegistryResponse {
1193
+ packs: AgentPackSummary[];
1194
+ total: number;
1195
+ }
1196
+
1197
+ export interface InstallAgentPackRequest {
1198
+ /** Must start with `core.openwop.agents.` — the sample's install
1199
+ * route filters to that namespace. */
1200
+ name: string;
1201
+ /** Defaults to `1.0.0` when omitted. */
1202
+ version?: string;
1203
+ }
1204
+
1205
+ export interface InstallAgentPackResponse {
1206
+ name: string;
1207
+ version: string;
1208
+ /** True when the pack was newly installed; false when it was
1209
+ * already present in the registry. */
1210
+ installed: boolean;
1211
+ alreadyInstalled: boolean;
1212
+ }
1213
+
1214
+ // ── RFC 0081 — Agent evaluation (eval-summary.schema.json) ─────────────
1215
+
1216
+ /** Abstract model class (RFC 0002 / RFC 0003 manifest vocabulary). */
1217
+ export type AgentModelClass =
1218
+ | 'reasoning'
1219
+ | 'writing'
1220
+ | 'coding'
1221
+ | 'research'
1222
+ | 'classification'
1223
+ | 'general';
1224
+
1225
+ /** A redaction-safe safety finding ({kind, severity} descriptor — never excerpted content). */
1226
+ export interface EvalSafetyFinding {
1227
+ kind: string;
1228
+ severity: 'low' | 'medium' | 'high' | 'critical';
1229
+ }
1230
+
1231
+ /** Per-task result on an `EvalSummary` (content-free: scores + scalars + ids). */
1232
+ export interface EvalTaskResult {
1233
+ taskId: string;
1234
+ score: number;
1235
+ passed: boolean;
1236
+ costUsd?: number;
1237
+ latencyMs?: number;
1238
+ schemaValid?: boolean;
1239
+ safetyFindings?: readonly EvalSafetyFinding[];
1240
+ }
1241
+
1242
+ /** The regression block on an `EvalSummary` (RFC 0081 §D `regression` mode). */
1243
+ export interface EvalRegression {
1244
+ baselineRunId: string;
1245
+ scoreDelta: number;
1246
+ diffRef?: string;
1247
+ }
1248
+
1249
+ /**
1250
+ * RFC 0081 §C — the terminal scorecard of an eval run, read via
1251
+ * `client.runs.evalSummary(runId)`. Content-free: scores, scalars, ids, and
1252
+ * redaction-safe safety descriptors only (`eval-summary-no-content-leak`).
1253
+ */
1254
+ export interface EvalSummary {
1255
+ suiteId: string;
1256
+ suiteVersion: string;
1257
+ evaluatedModelClass?: AgentModelClass;
1258
+ aggregateScore: number;
1259
+ passed: boolean;
1260
+ taskCount: number;
1261
+ passedCount: number;
1262
+ totalCostUsd?: number;
1263
+ tasks: readonly EvalTaskResult[];
1264
+ regression?: EvalRegression;
1265
+ }
1266
+
1267
+ // ── RFC 0082 — Agent deployment lifecycle ─────────────────────────────
1268
+
1269
+ /** The seven-state deployment lifecycle (RFC 0082 §C). */
1270
+ export type DeploymentState =
1271
+ | 'draft'
1272
+ | 'test'
1273
+ | 'staged'
1274
+ | 'active'
1275
+ | 'paused'
1276
+ | 'deprecated'
1277
+ | 'rolled-back';
1278
+
1279
+ /**
1280
+ * RFC 0082 §C — a per-(agentId, version) deployment record, returned by
1281
+ * `client.agents.listDeployments` / `transitionDeployment`. Host-runtime state
1282
+ * distinct from the immutable manifest and the registry's published tags.
1283
+ */
1284
+ export interface AgentDeployment {
1285
+ agentId: string;
1286
+ version: string;
1287
+ state: DeploymentState;
1288
+ canaryPercent?: number;
1289
+ rollbackPointer?: string;
1290
+ channels?: readonly string[];
1291
+ evalRunId?: string;
1292
+ approvalGateId?: string;
1293
+ }
1294
+
1295
+ /**
1296
+ * RFC 0082 §E — the `transitionDeployment` request body. The host authorizes it
1297
+ * fail-closed (RFC 0049 `deploy:*`), runs any RFC 0051 approvalGate, and enforces
1298
+ * RFC 0081 `requiredEval` before emitting `deployment.promoted`.
1299
+ */
1300
+ export interface AgentDeploymentTransition {
1301
+ version: string;
1302
+ transition: 'promote' | 'pause' | 'deprecate' | 'rollback' | 'adjust-canary';
1303
+ toState?: DeploymentState;
1304
+ channel?: string;
1305
+ canaryPercent?: number;
1306
+ evalRunId?: string;
1307
+ reason?: string;
1308
+ }