@the-open-engine/zeroshot 6.17.0 → 6.18.0

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 (76) hide show
  1. package/cli/index.js +9 -13
  2. package/lib/agent-cli-provider/adapters/claude.d.ts +2 -2
  3. package/lib/agent-cli-provider/adapters/claude.d.ts.map +1 -1
  4. package/lib/agent-cli-provider/adapters/claude.js +30 -0
  5. package/lib/agent-cli-provider/adapters/claude.js.map +1 -1
  6. package/lib/agent-cli-provider/adapters/codex.d.ts +2 -2
  7. package/lib/agent-cli-provider/adapters/codex.d.ts.map +1 -1
  8. package/lib/agent-cli-provider/adapters/codex.js +37 -0
  9. package/lib/agent-cli-provider/adapters/codex.js.map +1 -1
  10. package/lib/agent-cli-provider/adapters/gemini.d.ts +2 -2
  11. package/lib/agent-cli-provider/adapters/gemini.d.ts.map +1 -1
  12. package/lib/agent-cli-provider/adapters/gemini.js +115 -4
  13. package/lib/agent-cli-provider/adapters/gemini.js.map +1 -1
  14. package/lib/agent-cli-provider/adapters/opencode.d.ts +2 -2
  15. package/lib/agent-cli-provider/adapters/opencode.d.ts.map +1 -1
  16. package/lib/agent-cli-provider/adapters/opencode.js +108 -0
  17. package/lib/agent-cli-provider/adapters/opencode.js.map +1 -1
  18. package/lib/agent-cli-provider/contract-options.d.ts.map +1 -1
  19. package/lib/agent-cli-provider/contract-options.js +12 -0
  20. package/lib/agent-cli-provider/contract-options.js.map +1 -1
  21. package/lib/agent-cli-provider/index.d.ts +2 -2
  22. package/lib/agent-cli-provider/index.d.ts.map +1 -1
  23. package/lib/agent-cli-provider/index.js +2 -1
  24. package/lib/agent-cli-provider/index.js.map +1 -1
  25. package/lib/agent-cli-provider/provider-registry.d.ts +19 -7
  26. package/lib/agent-cli-provider/provider-registry.d.ts.map +1 -1
  27. package/lib/agent-cli-provider/provider-registry.js +4 -0
  28. package/lib/agent-cli-provider/provider-registry.js.map +1 -1
  29. package/lib/agent-cli-provider/single-agent-runtime.d.ts.map +1 -1
  30. package/lib/agent-cli-provider/single-agent-runtime.js +35 -4
  31. package/lib/agent-cli-provider/single-agent-runtime.js.map +1 -1
  32. package/lib/agent-cli-provider/types.d.ts +30 -3
  33. package/lib/agent-cli-provider/types.d.ts.map +1 -1
  34. package/lib/agent-cli-provider/types.js.map +1 -1
  35. package/lib/cluster/errors.cjs +4 -1
  36. package/lib/cluster/errors.d.ts +2 -0
  37. package/lib/cluster/errors.mjs +2 -0
  38. package/lib/cluster/index.cjs +8 -1
  39. package/lib/cluster/index.d.ts +4 -1
  40. package/lib/cluster/index.mjs +4 -1
  41. package/lib/cluster/json-source.cjs +61 -0
  42. package/lib/cluster/json-source.d.ts +4 -0
  43. package/lib/cluster/json-source.mjs +55 -0
  44. package/lib/cluster/payload-value.cjs +76 -0
  45. package/lib/cluster/payload-value.d.ts +7 -0
  46. package/lib/cluster/payload-value.mjs +72 -0
  47. package/lib/cluster/validators.cjs +21 -0
  48. package/lib/cluster/validators.d.ts +4 -1
  49. package/lib/cluster/validators.mjs +19 -1
  50. package/lib/provider-names.js +5 -0
  51. package/package.json +2 -2
  52. package/src/agent/agent-task-executor.js +194 -410
  53. package/src/agent/output-extraction.js +39 -14
  54. package/src/agent/output-reformatter.js +154 -111
  55. package/src/agent-cli-provider/adapters/claude.ts +39 -2
  56. package/src/agent-cli-provider/adapters/codex.ts +56 -2
  57. package/src/agent-cli-provider/adapters/gemini.ts +102 -6
  58. package/src/agent-cli-provider/adapters/opencode.ts +85 -2
  59. package/src/agent-cli-provider/contract-options.ts +16 -0
  60. package/src/agent-cli-provider/index.ts +4 -0
  61. package/src/agent-cli-provider/provider-registry.ts +23 -3
  62. package/src/agent-cli-provider/single-agent-runtime.ts +50 -4
  63. package/src/agent-cli-provider/types.ts +36 -2
  64. package/src/agent-wrapper.js +2 -2
  65. package/src/cluster/errors.ts +1 -0
  66. package/src/cluster/index.ts +4 -0
  67. package/src/cluster/json-source.ts +71 -0
  68. package/src/cluster/payload-value.ts +84 -0
  69. package/src/cluster/validators.ts +31 -2
  70. package/src/orchestrator.js +33 -13
  71. package/task-lib/attachable-watcher.js +1 -0
  72. package/task-lib/command-spec-cleanup.js +57 -11
  73. package/task-lib/commands/run.js +1 -0
  74. package/task-lib/provider-session-capture.js +8 -0
  75. package/task-lib/runner.js +9 -6
  76. package/task-lib/watcher.js +1 -0
@@ -0,0 +1,72 @@
1
+ import { ClusterRequestError } from './errors.mjs';
2
+ function isJsonInteger(value) {
3
+ return typeof value === 'number' && Number.isFinite(value) && Number.isInteger(value);
4
+ }
5
+ function evaluate(type, value, path) {
6
+ switch (type.kind) {
7
+ case 'null':
8
+ return value === null ? null : { path, code: 'TYPE_MISMATCH', expectedKind: 'null' };
9
+ case 'boolean':
10
+ return typeof value === 'boolean' ? null : { path, code: 'TYPE_MISMATCH', expectedKind: 'boolean' };
11
+ case 'integer':
12
+ return isJsonInteger(value) ? null : { path, code: 'TYPE_MISMATCH', expectedKind: 'integer' };
13
+ case 'number':
14
+ return typeof value === 'number' && Number.isFinite(value)
15
+ ? null
16
+ : { path, code: 'TYPE_MISMATCH', expectedKind: 'number' };
17
+ case 'string':
18
+ return typeof value === 'string' ? null : { path, code: 'TYPE_MISMATCH', expectedKind: 'string' };
19
+ case 'enum':
20
+ if (typeof value !== 'string')
21
+ return { path, code: 'TYPE_MISMATCH', expectedKind: 'enum' };
22
+ return type.values.includes(value)
23
+ ? null
24
+ : { path, code: 'UNKNOWN_ENUM_LABEL', expectedKind: 'enum' };
25
+ case 'array': {
26
+ if (!Array.isArray(value))
27
+ return { path, code: 'TYPE_MISMATCH', expectedKind: 'array' };
28
+ for (let index = 0; index < value.length; index += 1) {
29
+ const issue = evaluate(type.items, value[index], `${path}/${index}`);
30
+ if (issue)
31
+ return issue;
32
+ }
33
+ return null;
34
+ }
35
+ case 'record': {
36
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
37
+ return { path, code: 'TYPE_MISMATCH', expectedKind: 'record' };
38
+ }
39
+ const record = value;
40
+ const fieldNames = Object.keys(type.fields).sort();
41
+ for (const name of fieldNames) {
42
+ const field = type.fields[name];
43
+ if (!field)
44
+ continue;
45
+ const fieldPath = `${path}/${name}`;
46
+ if (Object.prototype.hasOwnProperty.call(record, name)) {
47
+ const issue = evaluate(field.type, record[name], fieldPath);
48
+ if (issue)
49
+ return issue;
50
+ }
51
+ else if (field.required) {
52
+ return { path: fieldPath, code: 'MISSING_REQUIRED_FIELD', expectedKind: field.type.kind };
53
+ }
54
+ }
55
+ const declared = new Set(fieldNames);
56
+ const unknownField = Object.keys(record).sort().find((name) => !declared.has(name));
57
+ return unknownField
58
+ ? { path: `${path}/${unknownField}`, code: 'UNKNOWN_FIELD', expectedKind: 'record' }
59
+ : null;
60
+ }
61
+ }
62
+ }
63
+ export function firstInputValidationIssue(type, value, path = '') {
64
+ const issue = evaluate(type, value, path);
65
+ return issue ? { path: issue.path, code: issue.code } : null;
66
+ }
67
+ export function assertInputValue(type, value) {
68
+ const issue = evaluate(type, value, '');
69
+ if (!issue)
70
+ return;
71
+ throw new ClusterRequestError(`input value at '${issue.path || '/'}' failed validation: ${issue.code}, expected ${issue.expectedKind}`, 'INVALID_INPUT');
72
+ }
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertDefinition = assertDefinition;
4
4
  exports.assertMethodResult = assertMethodResult;
5
+ exports.assertGraphSpec = assertGraphSpec;
6
+ exports.assertGraphProfile = assertGraphProfile;
7
+ exports.assertGraphProfileSupported = assertGraphProfileSupported;
5
8
  const _2020_js_1 = require("ajv/dist/2020.js");
6
9
  const protocol_js_1 = require("./generated/protocol.cjs");
7
10
  const protocol_schema_js_1 = require("./generated/protocol-schema.cjs");
@@ -44,3 +47,21 @@ function assertMethodResult(method, value) {
44
47
  throw error;
45
48
  }
46
49
  }
50
+ function assertRequestDefinition(definition, value, code) {
51
+ const validate = validatorFor(definition);
52
+ if (validate(value))
53
+ return;
54
+ const details = (validate.errors ?? []).map((error) => `${error.instancePath || '/'} ${error.message ?? 'is invalid'}`).join('; ');
55
+ throw new errors_js_1.ClusterRequestError(`${definition} validation failed: ${details}`, code);
56
+ }
57
+ function assertGraphSpec(value) {
58
+ assertRequestDefinition('GraphSpec', value, 'INVALID_GRAPH');
59
+ }
60
+ function assertGraphProfile(value) {
61
+ assertRequestDefinition('GraphProfile', value, 'INVALID_GRAPH_PROFILE');
62
+ }
63
+ function assertGraphProfileSupported(profile, capabilities) {
64
+ if (!capabilities.graphProfiles?.includes(profile)) {
65
+ throw new errors_js_1.ClusterRequestError(`graph profile ${profile} is not among the server's advertised graphProfiles`, 'UNSUPPORTED_GRAPH_PROFILE');
66
+ }
67
+ }
@@ -1,3 +1,6 @@
1
- import type { ClusterMethod } from './generated/protocol.js';
1
+ import type { ClusterMethod, GraphProfile, GraphSpec, ServerCapabilities } from './generated/protocol.js';
2
2
  export declare function assertDefinition(definition: string, value: unknown): void;
3
3
  export declare function assertMethodResult(method: ClusterMethod, value: unknown): void;
4
+ export declare function assertGraphSpec(value: unknown): asserts value is GraphSpec;
5
+ export declare function assertGraphProfile(value: unknown): asserts value is GraphProfile;
6
+ export declare function assertGraphProfileSupported(profile: GraphProfile, capabilities: ServerCapabilities): void;
@@ -1,7 +1,7 @@
1
1
  import Ajv2020 from 'ajv/dist/2020.js';
2
2
  import { METHOD_RESULT_DEFINITIONS, PROTOCOL_VERSION, } from './generated/protocol.mjs';
3
3
  import { CLUSTER_PROTOCOL_SCHEMA } from './generated/protocol-schema.mjs';
4
- import { ClusterProtocolError } from './errors.mjs';
4
+ import { ClusterProtocolError, ClusterRequestError } from './errors.mjs';
5
5
  const ajv = new Ajv2020({
6
6
  allErrors: true,
7
7
  strict: false,
@@ -40,3 +40,21 @@ export function assertMethodResult(method, value) {
40
40
  throw error;
41
41
  }
42
42
  }
43
+ function assertRequestDefinition(definition, value, code) {
44
+ const validate = validatorFor(definition);
45
+ if (validate(value))
46
+ return;
47
+ const details = (validate.errors ?? []).map((error) => `${error.instancePath || '/'} ${error.message ?? 'is invalid'}`).join('; ');
48
+ throw new ClusterRequestError(`${definition} validation failed: ${details}`, code);
49
+ }
50
+ export function assertGraphSpec(value) {
51
+ assertRequestDefinition('GraphSpec', value, 'INVALID_GRAPH');
52
+ }
53
+ export function assertGraphProfile(value) {
54
+ assertRequestDefinition('GraphProfile', value, 'INVALID_GRAPH_PROFILE');
55
+ }
56
+ export function assertGraphProfileSupported(profile, capabilities) {
57
+ if (!capabilities.graphProfiles?.includes(profile)) {
58
+ throw new ClusterRequestError(`graph profile ${profile} is not among the server's advertised graphProfiles`, 'UNSUPPORTED_GRAPH_PROFILE');
59
+ }
60
+ }
@@ -63,6 +63,10 @@ function providerSupportsCapability(name, capability) {
63
63
  return registry.supportsProviderCapability(name, capability);
64
64
  }
65
65
 
66
+ function providerSupportsOutputReformatting(name) {
67
+ return registry.supportsProviderOutputReformatting(name);
68
+ }
69
+
66
70
  module.exports = {
67
71
  KNOWN_PROVIDER_NAMES,
68
72
  PROVIDER_ALIASES,
@@ -73,5 +77,6 @@ module.exports = {
73
77
  normalizeProviderName,
74
78
  normalizeProviderSettings,
75
79
  providerSupportsCapability,
80
+ providerSupportsOutputReformatting,
76
81
  resolveProviderCommand,
77
82
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-open-engine/zeroshot",
3
- "version": "6.17.0",
3
+ "version": "6.18.0",
4
4
  "description": "Multi-agent orchestration engine for Claude, Codex, and Gemini",
5
5
  "main": "src/orchestrator.js",
6
6
  "bin": {
@@ -50,7 +50,7 @@
50
50
  "test:providers:live": "npm run build:agent-cli-provider && node scripts/live-provider-smoke.js",
51
51
  "check:agent-cli-provider": "npm run check:agent-cli-provider:ci",
52
52
  "check:agent-cli-provider:ci": "npm run typecheck:agent-cli-provider && npm run lint:agent-cli-provider && npm run build:agent-cli-provider && npm run test:agent-cli-provider",
53
- "test:cluster-client": "npm run build:cluster && node --test tests/cluster/client.test.js tests/cluster/parity.test.js tests/cluster/architecture.test.js tests/cluster/verifier-regressions.test.js",
53
+ "test:cluster-client": "npm run build:cluster && node --test tests/cluster/client.test.js tests/cluster/parity.test.js tests/cluster/architecture.test.js tests/cluster/verifier-regressions.test.js tests/cluster/request-validation.test.js",
54
54
  "test:cluster-package": "npm run build:cluster && node --test tests/cluster/package.test.js",
55
55
  "dev:link": "npm link",
56
56
  "lint": "eslint .",