@the-open-engine/zeroshot 6.35.3 → 6.37.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 (68) hide show
  1. package/cli/index.js +99 -29
  2. package/lib/agent-cli-provider/adapters/omp.js +1 -1
  3. package/lib/agent-cli-provider/adapters/omp.js.map +1 -1
  4. package/lib/hosted-target/adapter-types.d.cts +0 -8
  5. package/lib/hosted-target/adapter-types.d.mts +0 -8
  6. package/lib/hosted-target/adapter-types.d.ts +0 -8
  7. package/lib/hosted-target/index.d.cts +1 -1
  8. package/lib/hosted-target/index.d.mts +1 -1
  9. package/lib/hosted-target/index.d.ts +1 -1
  10. package/lib/hosted-target/retry-executor.d.cts +1 -1
  11. package/lib/hosted-target/retry-executor.d.mts +1 -1
  12. package/lib/hosted-target/retry-executor.d.ts +1 -1
  13. package/lib/hosted-target/target-adapter.d.cts +1 -1
  14. package/lib/hosted-target/target-adapter.d.mts +1 -1
  15. package/lib/hosted-target/target-adapter.d.ts +1 -1
  16. package/lib/hosted-target/zero-cloud-v1-adapter.cjs +0 -29
  17. package/lib/hosted-target/zero-cloud-v1-adapter.d.cts +0 -2
  18. package/lib/hosted-target/zero-cloud-v1-adapter.d.mts +0 -2
  19. package/lib/hosted-target/zero-cloud-v1-adapter.d.ts +0 -2
  20. package/lib/hosted-target/zero-cloud-v1-adapter.mjs +0 -29
  21. package/lib/target/discovery-sections.cjs +2 -21
  22. package/lib/target/discovery-sections.d.cts +0 -2
  23. package/lib/target/discovery-sections.d.mts +0 -2
  24. package/lib/target/discovery-sections.d.ts +0 -2
  25. package/lib/target/discovery-sections.js +2 -21
  26. package/lib/target/discovery-sections.mjs +3 -22
  27. package/lib/target/discovery-validation.cjs +4 -28
  28. package/lib/target/discovery-validation.d.cts +0 -10
  29. package/lib/target/discovery-validation.d.mts +0 -10
  30. package/lib/target/discovery-validation.d.ts +0 -10
  31. package/lib/target/discovery-validation.js +4 -28
  32. package/lib/target/discovery-validation.mjs +4 -27
  33. package/lib/target/discovery.cjs +0 -1
  34. package/lib/target/discovery.d.cts +0 -3
  35. package/lib/target/discovery.d.mts +0 -3
  36. package/lib/target/discovery.d.ts +0 -3
  37. package/lib/target/discovery.js +0 -1
  38. package/lib/target/discovery.mjs +1 -2
  39. package/lib/target/index.d.ts +1 -1
  40. package/lib/target/run-intent-discovery.cjs +3 -1
  41. package/lib/target/run-intent-discovery.js +3 -1
  42. package/lib/target/run-intent-discovery.mjs +4 -2
  43. package/npm-shrinkwrap.json +2 -2
  44. package/package.json +1 -1
  45. package/src/agent/agent-lifecycle.js +25 -76
  46. package/src/agent/agent-liveness-poll.js +93 -0
  47. package/src/agent/agent-task-executor.js +19 -3
  48. package/src/agent-cli-provider/adapters/omp.ts +1 -1
  49. package/src/foreground-benchmark-files.js +81 -0
  50. package/src/foreground-benchmark-result.js +233 -0
  51. package/src/foreground-benchmark-run.js +72 -0
  52. package/src/hosted-target/adapter-types.ts +0 -14
  53. package/src/hosted-target/index.ts +0 -1
  54. package/src/hosted-target/retry-executor.ts +12 -14
  55. package/src/hosted-target/target-adapter.ts +1 -5
  56. package/src/hosted-target/zero-cloud-v1-adapter.ts +0 -37
  57. package/src/target/discovery-sections.ts +3 -28
  58. package/src/target/discovery-validation.ts +15 -61
  59. package/src/target/discovery.ts +1 -9
  60. package/src/target/index.ts +0 -1
  61. package/src/target/run-intent-discovery.ts +3 -2
  62. package/task-lib/runner.js +7 -0
  63. package/lib/hosted-target/runtime-install.cjs +0 -45
  64. package/lib/hosted-target/runtime-install.d.cts +0 -14
  65. package/lib/hosted-target/runtime-install.d.mts +0 -14
  66. package/lib/hosted-target/runtime-install.d.ts +0 -14
  67. package/lib/hosted-target/runtime-install.mjs +0 -42
  68. package/src/hosted-target/runtime-install.ts +0 -83
@@ -1,5 +1,5 @@
1
1
  import { TargetDiscoveryError } from './discovery-errors.mjs';
2
- import { closedRecord, exact, exactStringSet, integer, parseCredentialInstall, sameOriginUrl, stringField, } from './discovery-validation.mjs';
2
+ import { closedRecord, exact, exactStringSet, integer, record, sameOriginUrl, stringField, } from './discovery-validation.mjs';
3
3
  import { parseRunIntent } from './run-intent-discovery.mjs';
4
4
  import { routeTemplate } from './route-template.mjs';
5
5
  export function parseAdapter(discovery) {
@@ -40,29 +40,10 @@ export function parseSizes(discovery) {
40
40
  }
41
41
  export function parseExtensions(discovery, origin) {
42
42
  if (discovery.extensions === undefined || discovery.extensions === null) {
43
- return Object.freeze({ credentialInstall: null, runIntent: null });
43
+ return Object.freeze({ runIntent: null });
44
44
  }
45
- const extensions = closedRecord(discovery.extensions, 'extensions', [
46
- 'connections',
47
- 'credential_install',
48
- 'run_intent',
49
- ]);
50
- if (extensions.connections === undefined) {
51
- throw new TargetDiscoveryError('extensions.connections is required');
52
- }
53
- const connections = closedRecord(extensions.connections, 'extensions.connections', [
54
- 'kind',
55
- 'base_url',
56
- 'route_templates',
57
- ]);
58
- exact(connections.kind, 'zerocloud.connections/v1', 'extensions.connections.kind');
59
- sameOriginUrl(connections.base_url, 'extensions.connections.base_url', origin);
60
- const routes = closedRecord(connections.route_templates, 'extensions.connections.route_templates', ['list', 'create', 'update']);
61
- routeTemplate(routes.list, 'extensions.connections.route_templates.list', []);
62
- routeTemplate(routes.create, 'extensions.connections.route_templates.create', []);
63
- routeTemplate(routes.update, 'extensions.connections.route_templates.update', ['connection_id']);
45
+ const extensions = record(discovery.extensions, 'extensions');
64
46
  return Object.freeze({
65
- credentialInstall: parseCredentialInstall(extensions.credential_install),
66
47
  runIntent: parseRunIntent(extensions.run_intent, origin),
67
48
  });
68
49
  }
@@ -7,9 +7,7 @@ exports.exact = exact;
7
7
  exports.integer = integer;
8
8
  exports.exactStringSet = exactStringSet;
9
9
  exports.sameOriginUrl = sameOriginUrl;
10
- exports.parseCredentialInstall = parseCredentialInstall;
11
10
  const discovery_errors_js_1 = require("./discovery-errors.cjs");
12
- const route_template_js_1 = require("./route-template.cjs");
13
11
  function record(value, field) {
14
12
  if (value === null || typeof value !== 'object' || Array.isArray(value)) {
15
13
  throw new discovery_errors_js_1.TargetDiscoveryError(`${field} must be an object`);
@@ -44,19 +42,20 @@ function exactStringSet(value, field, expected) {
44
42
  if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) {
45
43
  throw new discovery_errors_js_1.TargetDiscoveryError(`${field} must be an array of strings`);
46
44
  }
47
- if (value.length !== expected.length || new Set(value).size !== value.length ||
45
+ if (value.length !== expected.length ||
46
+ new Set(value).size !== value.length ||
48
47
  expected.some((item) => !value.includes(item))) {
49
48
  throw new discovery_errors_js_1.TargetDiscoveryError(`${field} does not match the supported contract`);
50
49
  }
51
50
  return Object.freeze([...value]);
52
51
  }
53
52
  function hasForbiddenUrlComponent(url, value, protocols) {
54
- return !protocols.includes(url.protocol) ||
53
+ return (!protocols.includes(url.protocol) ||
55
54
  url.username !== '' ||
56
55
  url.password !== '' ||
57
56
  url.search !== '' ||
58
57
  url.hash !== '' ||
59
- url.href !== value;
58
+ url.href !== value);
60
59
  }
61
60
  function sameOriginUrl(value, field, origin, protocols = ['https:', 'http:']) {
62
61
  if (typeof value !== 'string' || /[\u0000-\u0020\u007f]|\s/u.test(value)) {
@@ -77,26 +76,3 @@ function sameOriginUrl(value, field, origin, protocols = ['https:', 'http:']) {
77
76
  }
78
77
  return url.href;
79
78
  }
80
- function parseCredentialInstall(value) {
81
- if (value === undefined || value === null)
82
- return null;
83
- const extension = closedRecord(value, 'extensions.credential_install', [
84
- 'kind',
85
- 'install',
86
- 'max_body_bytes',
87
- ]);
88
- exact(extension.kind, 'openengine.capsule-credential-install/v1', 'extensions.credential_install.kind');
89
- const install = closedRecord(extension.install, 'extensions.credential_install.install', [
90
- 'route_template',
91
- 'method',
92
- ]);
93
- exact(install.method, 'PUT', 'extensions.credential_install.install.method');
94
- return Object.freeze({
95
- kind: 'openengine.capsule-credential-install/v1',
96
- install: Object.freeze({
97
- routeTemplate: (0, route_template_js_1.routeTemplate)(install.route_template, 'extensions.credential_install.install.route_template', ['capsule_id']),
98
- method: 'PUT',
99
- }),
100
- maxBodyBytes: integer(extension.max_body_bytes, 'extensions.credential_install.max_body_bytes', 1, 4 * 1024 * 1024),
101
- });
102
- }
@@ -1,12 +1,3 @@
1
- import { type RouteTemplate } from './route-template.js';
2
- export interface CredentialInstallDescriptor {
3
- readonly kind: 'openengine.capsule-credential-install/v1';
4
- readonly install: {
5
- readonly routeTemplate: RouteTemplate;
6
- readonly method: 'PUT';
7
- };
8
- readonly maxBodyBytes: number;
9
- }
10
1
  export declare function record(value: unknown, field: string): Record<string, unknown>;
11
2
  export declare function closedRecord(value: unknown, field: string, fields: readonly string[]): Record<string, unknown>;
12
3
  export declare function stringField(source: Record<string, unknown>, field: string, parent?: string): string;
@@ -14,4 +5,3 @@ export declare function exact(value: unknown, expected: unknown, field: string):
14
5
  export declare function integer(value: unknown, field: string, min: number, max?: number): number;
15
6
  export declare function exactStringSet(value: unknown, field: string, expected: readonly string[]): readonly string[];
16
7
  export declare function sameOriginUrl(value: unknown, field: string, origin: string, protocols?: readonly string[]): string;
17
- export declare function parseCredentialInstall(value: unknown): CredentialInstallDescriptor | null;
@@ -1,12 +1,3 @@
1
- import { type RouteTemplate } from './route-template.js';
2
- export interface CredentialInstallDescriptor {
3
- readonly kind: 'openengine.capsule-credential-install/v1';
4
- readonly install: {
5
- readonly routeTemplate: RouteTemplate;
6
- readonly method: 'PUT';
7
- };
8
- readonly maxBodyBytes: number;
9
- }
10
1
  export declare function record(value: unknown, field: string): Record<string, unknown>;
11
2
  export declare function closedRecord(value: unknown, field: string, fields: readonly string[]): Record<string, unknown>;
12
3
  export declare function stringField(source: Record<string, unknown>, field: string, parent?: string): string;
@@ -14,4 +5,3 @@ export declare function exact(value: unknown, expected: unknown, field: string):
14
5
  export declare function integer(value: unknown, field: string, min: number, max?: number): number;
15
6
  export declare function exactStringSet(value: unknown, field: string, expected: readonly string[]): readonly string[];
16
7
  export declare function sameOriginUrl(value: unknown, field: string, origin: string, protocols?: readonly string[]): string;
17
- export declare function parseCredentialInstall(value: unknown): CredentialInstallDescriptor | null;
@@ -1,12 +1,3 @@
1
- import { type RouteTemplate } from './route-template.js';
2
- export interface CredentialInstallDescriptor {
3
- readonly kind: 'openengine.capsule-credential-install/v1';
4
- readonly install: {
5
- readonly routeTemplate: RouteTemplate;
6
- readonly method: 'PUT';
7
- };
8
- readonly maxBodyBytes: number;
9
- }
10
1
  export declare function record(value: unknown, field: string): Record<string, unknown>;
11
2
  export declare function closedRecord(value: unknown, field: string, fields: readonly string[]): Record<string, unknown>;
12
3
  export declare function stringField(source: Record<string, unknown>, field: string, parent?: string): string;
@@ -14,4 +5,3 @@ export declare function exact(value: unknown, expected: unknown, field: string):
14
5
  export declare function integer(value: unknown, field: string, min: number, max?: number): number;
15
6
  export declare function exactStringSet(value: unknown, field: string, expected: readonly string[]): readonly string[];
16
7
  export declare function sameOriginUrl(value: unknown, field: string, origin: string, protocols?: readonly string[]): string;
17
- export declare function parseCredentialInstall(value: unknown): CredentialInstallDescriptor | null;
@@ -7,9 +7,7 @@ exports.exact = exact;
7
7
  exports.integer = integer;
8
8
  exports.exactStringSet = exactStringSet;
9
9
  exports.sameOriginUrl = sameOriginUrl;
10
- exports.parseCredentialInstall = parseCredentialInstall;
11
10
  const discovery_errors_js_1 = require("./discovery-errors.js");
12
- const route_template_js_1 = require("./route-template.js");
13
11
  function record(value, field) {
14
12
  if (value === null || typeof value !== 'object' || Array.isArray(value)) {
15
13
  throw new discovery_errors_js_1.TargetDiscoveryError(`${field} must be an object`);
@@ -44,19 +42,20 @@ function exactStringSet(value, field, expected) {
44
42
  if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) {
45
43
  throw new discovery_errors_js_1.TargetDiscoveryError(`${field} must be an array of strings`);
46
44
  }
47
- if (value.length !== expected.length || new Set(value).size !== value.length ||
45
+ if (value.length !== expected.length ||
46
+ new Set(value).size !== value.length ||
48
47
  expected.some((item) => !value.includes(item))) {
49
48
  throw new discovery_errors_js_1.TargetDiscoveryError(`${field} does not match the supported contract`);
50
49
  }
51
50
  return Object.freeze([...value]);
52
51
  }
53
52
  function hasForbiddenUrlComponent(url, value, protocols) {
54
- return !protocols.includes(url.protocol) ||
53
+ return (!protocols.includes(url.protocol) ||
55
54
  url.username !== '' ||
56
55
  url.password !== '' ||
57
56
  url.search !== '' ||
58
57
  url.hash !== '' ||
59
- url.href !== value;
58
+ url.href !== value);
60
59
  }
61
60
  function sameOriginUrl(value, field, origin, protocols = ['https:', 'http:']) {
62
61
  if (typeof value !== 'string' || /[\u0000-\u0020\u007f]|\s/u.test(value)) {
@@ -77,26 +76,3 @@ function sameOriginUrl(value, field, origin, protocols = ['https:', 'http:']) {
77
76
  }
78
77
  return url.href;
79
78
  }
80
- function parseCredentialInstall(value) {
81
- if (value === undefined || value === null)
82
- return null;
83
- const extension = closedRecord(value, 'extensions.credential_install', [
84
- 'kind',
85
- 'install',
86
- 'max_body_bytes',
87
- ]);
88
- exact(extension.kind, 'openengine.capsule-credential-install/v1', 'extensions.credential_install.kind');
89
- const install = closedRecord(extension.install, 'extensions.credential_install.install', [
90
- 'route_template',
91
- 'method',
92
- ]);
93
- exact(install.method, 'PUT', 'extensions.credential_install.install.method');
94
- return Object.freeze({
95
- kind: 'openengine.capsule-credential-install/v1',
96
- install: Object.freeze({
97
- routeTemplate: (0, route_template_js_1.routeTemplate)(install.route_template, 'extensions.credential_install.install.route_template', ['capsule_id']),
98
- method: 'PUT',
99
- }),
100
- maxBodyBytes: integer(extension.max_body_bytes, 'extensions.credential_install.max_body_bytes', 1, 4 * 1024 * 1024),
101
- });
102
- }
@@ -1,5 +1,4 @@
1
1
  import { TargetDiscoveryError } from './discovery-errors.mjs';
2
- import { routeTemplate } from './route-template.mjs';
3
2
  export function record(value, field) {
4
3
  if (value === null || typeof value !== 'object' || Array.isArray(value)) {
5
4
  throw new TargetDiscoveryError(`${field} must be an object`);
@@ -34,19 +33,20 @@ export function exactStringSet(value, field, expected) {
34
33
  if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) {
35
34
  throw new TargetDiscoveryError(`${field} must be an array of strings`);
36
35
  }
37
- if (value.length !== expected.length || new Set(value).size !== value.length ||
36
+ if (value.length !== expected.length ||
37
+ new Set(value).size !== value.length ||
38
38
  expected.some((item) => !value.includes(item))) {
39
39
  throw new TargetDiscoveryError(`${field} does not match the supported contract`);
40
40
  }
41
41
  return Object.freeze([...value]);
42
42
  }
43
43
  function hasForbiddenUrlComponent(url, value, protocols) {
44
- return !protocols.includes(url.protocol) ||
44
+ return (!protocols.includes(url.protocol) ||
45
45
  url.username !== '' ||
46
46
  url.password !== '' ||
47
47
  url.search !== '' ||
48
48
  url.hash !== '' ||
49
- url.href !== value;
49
+ url.href !== value);
50
50
  }
51
51
  export function sameOriginUrl(value, field, origin, protocols = ['https:', 'http:']) {
52
52
  if (typeof value !== 'string' || /[\u0000-\u0020\u007f]|\s/u.test(value)) {
@@ -67,26 +67,3 @@ export function sameOriginUrl(value, field, origin, protocols = ['https:', 'http
67
67
  }
68
68
  return url.href;
69
69
  }
70
- export function parseCredentialInstall(value) {
71
- if (value === undefined || value === null)
72
- return null;
73
- const extension = closedRecord(value, 'extensions.credential_install', [
74
- 'kind',
75
- 'install',
76
- 'max_body_bytes',
77
- ]);
78
- exact(extension.kind, 'openengine.capsule-credential-install/v1', 'extensions.credential_install.kind');
79
- const install = closedRecord(extension.install, 'extensions.credential_install.install', [
80
- 'route_template',
81
- 'method',
82
- ]);
83
- exact(install.method, 'PUT', 'extensions.credential_install.install.method');
84
- return Object.freeze({
85
- kind: 'openengine.capsule-credential-install/v1',
86
- install: Object.freeze({
87
- routeTemplate: routeTemplate(install.route_template, 'extensions.credential_install.install.route_template', ['capsule_id']),
88
- method: 'PUT',
89
- }),
90
- maxBodyBytes: integer(extension.max_body_bytes, 'extensions.credential_install.max_body_bytes', 1, 4 * 1024 * 1024),
91
- });
92
- }
@@ -67,7 +67,6 @@ function parseDiscoveryDocument(discovery, origin) {
67
67
  capsule,
68
68
  transport,
69
69
  capabilityFlags,
70
- credentialInstall: extensions.credentialInstall,
71
70
  runIntent: extensions.runIntent,
72
71
  additional,
73
72
  });
@@ -1,8 +1,6 @@
1
1
  import type { HttpTransport } from './device-flow.js';
2
2
  import type { RouteTemplate } from './route-template.js';
3
- import { type CredentialInstallDescriptor } from './discovery-validation.js';
4
3
  import type { RunIntentDescriptor } from './run-intent-discovery.js';
5
- export type { CredentialInstallDescriptor } from './discovery-validation.js';
6
4
  export type { RunIntentDescriptor } from './run-intent-discovery.js';
7
5
  export { TargetDiscoveryError } from './discovery-errors.js';
8
6
  export { expandRoute, type RouteTemplate } from './route-template.js';
@@ -57,7 +55,6 @@ export interface TargetDiscoveryDescriptor {
57
55
  };
58
56
  };
59
57
  readonly capabilityFlags: readonly string[];
60
- readonly credentialInstall: CredentialInstallDescriptor | null;
61
58
  readonly runIntent: RunIntentDescriptor | null;
62
59
  readonly additional: Readonly<Record<string, unknown>>;
63
60
  }
@@ -1,8 +1,6 @@
1
1
  import type { HttpTransport } from './device-flow.js';
2
2
  import type { RouteTemplate } from './route-template.js';
3
- import { type CredentialInstallDescriptor } from './discovery-validation.js';
4
3
  import type { RunIntentDescriptor } from './run-intent-discovery.js';
5
- export type { CredentialInstallDescriptor } from './discovery-validation.js';
6
4
  export type { RunIntentDescriptor } from './run-intent-discovery.js';
7
5
  export { TargetDiscoveryError } from './discovery-errors.js';
8
6
  export { expandRoute, type RouteTemplate } from './route-template.js';
@@ -57,7 +55,6 @@ export interface TargetDiscoveryDescriptor {
57
55
  };
58
56
  };
59
57
  readonly capabilityFlags: readonly string[];
60
- readonly credentialInstall: CredentialInstallDescriptor | null;
61
58
  readonly runIntent: RunIntentDescriptor | null;
62
59
  readonly additional: Readonly<Record<string, unknown>>;
63
60
  }
@@ -1,8 +1,6 @@
1
1
  import type { HttpTransport } from './device-flow.js';
2
2
  import type { RouteTemplate } from './route-template.js';
3
- import { type CredentialInstallDescriptor } from './discovery-validation.js';
4
3
  import type { RunIntentDescriptor } from './run-intent-discovery.js';
5
- export type { CredentialInstallDescriptor } from './discovery-validation.js';
6
4
  export type { RunIntentDescriptor } from './run-intent-discovery.js';
7
5
  export { TargetDiscoveryError } from './discovery-errors.js';
8
6
  export { expandRoute, type RouteTemplate } from './route-template.js';
@@ -57,7 +55,6 @@ export interface TargetDiscoveryDescriptor {
57
55
  };
58
56
  };
59
57
  readonly capabilityFlags: readonly string[];
60
- readonly credentialInstall: CredentialInstallDescriptor | null;
61
58
  readonly runIntent: RunIntentDescriptor | null;
62
59
  readonly additional: Readonly<Record<string, unknown>>;
63
60
  }
@@ -67,7 +67,6 @@ function parseDiscoveryDocument(discovery, origin) {
67
67
  capsule,
68
68
  transport,
69
69
  capabilityFlags,
70
- credentialInstall: extensions.credentialInstall,
71
70
  runIntent: extensions.runIntent,
72
71
  additional,
73
72
  });
@@ -1,6 +1,6 @@
1
1
  import { readBoundedResponseJson } from './bounded-response.mjs';
2
2
  import { TargetDiscoveryError } from './discovery-errors.mjs';
3
- import { exact, exactStringSet, record, } from './discovery-validation.mjs';
3
+ import { exact, exactStringSet, record } from './discovery-validation.mjs';
4
4
  import { parseAdapter, parseCapsule, parseEndpoint, parseExtensions, parseOAuth, parseSession, parseSizes, parseTransport, validateOAuthMetadata, } from './discovery-sections.mjs';
5
5
  export { TargetDiscoveryError } from './discovery-errors.mjs';
6
6
  export { expandRoute } from './route-template.mjs';
@@ -60,7 +60,6 @@ function parseDiscoveryDocument(discovery, origin) {
60
60
  capsule,
61
61
  transport,
62
62
  capabilityFlags,
63
- credentialInstall: extensions.credentialInstall,
64
63
  runIntent: extensions.runIntent,
65
64
  additional,
66
65
  });
@@ -3,4 +3,4 @@ export { acquireTargetLock } from './credential-lock.js';
3
3
  export { requestDeviceCode, pollForToken, parseTokenResponse, DeviceFlowDeniedError, DeviceFlowExpiredError, UnboundSessionError, type DeviceCodeResponse, type DeviceExchangeContext, type TokenResponse, type HttpTransport, type Clock, } from './device-flow.js';
4
4
  export { addTarget, removeTarget, getTarget, listTargets, updateTargetOrganization, validateTargetName, normalizeAndValidateUrl, TargetNameInvalidError, TargetNameExistsError, TargetNotFoundError, TargetUrlInvalidError, type TargetRecord, type SettingsPort, } from './target-registry.js';
5
5
  export { TargetSessionManager, LoginRequiredError, type BrowserOpener, type TargetSessionDeps, type TargetSessionManagerInit, } from './target-session.js';
6
- export { discoverTarget, discoverTargetSessionEndpoints, expandRoute, TargetDiscoveryError, type CredentialInstallDescriptor, type RunIntentDescriptor, type RouteTemplate, type TargetDiscoveryDescriptor, type TargetSessionEndpoints, } from './discovery.js';
6
+ export { discoverTarget, discoverTargetSessionEndpoints, expandRoute, TargetDiscoveryError, type RunIntentDescriptor, type RouteTemplate, type TargetDiscoveryDescriptor, type TargetSessionEndpoints, } from './discovery.js';
@@ -6,12 +6,14 @@ const discovery_validation_js_1 = require("./discovery-validation.cjs");
6
6
  function parseRunIntent(value, origin) {
7
7
  if (value === undefined || value === null)
8
8
  return null;
9
+ const advertised = (0, discovery_validation_js_1.record)(value, 'extensions.run_intent');
10
+ if (advertised.kind !== 'zeroshot.run-intent/v2')
11
+ return null;
9
12
  const extension = (0, discovery_validation_js_1.closedRecord)(value, 'extensions.run_intent', [
10
13
  'kind',
11
14
  'base_url',
12
15
  'route_templates',
13
16
  ]);
14
- (0, discovery_validation_js_1.exact)(extension.kind, 'zeroshot.run-intent/v2', 'extensions.run_intent.kind');
15
17
  const routes = (0, discovery_validation_js_1.closedRecord)(extension.route_templates, 'extensions.run_intent.route_templates', [
16
18
  'submit',
17
19
  'status',
@@ -6,12 +6,14 @@ const discovery_validation_js_1 = require("./discovery-validation.js");
6
6
  function parseRunIntent(value, origin) {
7
7
  if (value === undefined || value === null)
8
8
  return null;
9
+ const advertised = (0, discovery_validation_js_1.record)(value, 'extensions.run_intent');
10
+ if (advertised.kind !== 'zeroshot.run-intent/v2')
11
+ return null;
9
12
  const extension = (0, discovery_validation_js_1.closedRecord)(value, 'extensions.run_intent', [
10
13
  'kind',
11
14
  'base_url',
12
15
  'route_templates',
13
16
  ]);
14
- (0, discovery_validation_js_1.exact)(extension.kind, 'zeroshot.run-intent/v2', 'extensions.run_intent.kind');
15
17
  const routes = (0, discovery_validation_js_1.closedRecord)(extension.route_templates, 'extensions.run_intent.route_templates', [
16
18
  'submit',
17
19
  'status',
@@ -1,14 +1,16 @@
1
1
  import { routeTemplate } from './route-template.mjs';
2
- import { closedRecord, exact, sameOriginUrl } from './discovery-validation.mjs';
2
+ import { closedRecord, record, sameOriginUrl } from './discovery-validation.mjs';
3
3
  export function parseRunIntent(value, origin) {
4
4
  if (value === undefined || value === null)
5
5
  return null;
6
+ const advertised = record(value, 'extensions.run_intent');
7
+ if (advertised.kind !== 'zeroshot.run-intent/v2')
8
+ return null;
6
9
  const extension = closedRecord(value, 'extensions.run_intent', [
7
10
  'kind',
8
11
  'base_url',
9
12
  'route_templates',
10
13
  ]);
11
- exact(extension.kind, 'zeroshot.run-intent/v2', 'extensions.run_intent.kind');
12
14
  const routes = closedRecord(extension.route_templates, 'extensions.run_intent.route_templates', [
13
15
  'submit',
14
16
  'status',
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@the-open-engine/zeroshot",
3
- "version": "6.35.3",
3
+ "version": "6.37.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@the-open-engine/zeroshot",
9
- "version": "6.35.3",
9
+ "version": "6.37.0",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-open-engine/zeroshot",
3
- "version": "6.35.3",
3
+ "version": "6.37.0",
4
4
  "description": "Independent executor–verifier orchestration for software changes.",
5
5
  "main": "src/orchestrator.js",
6
6
  "bin": {
@@ -17,7 +17,7 @@ const { executeHook } = require('./agent-hook-executor');
17
17
  const IsolationManager = require('../isolation-manager');
18
18
  const crypto = require('crypto');
19
19
  const { bufferMessage, scheduleDrain, drainBufferedMessages } = require('../message-buffer');
20
- const { isPlatformSupported } = require('./agent-stuck-detector');
20
+ const { createLivenessPoll } = require('./agent-liveness-poll');
21
21
  const { normalizeProviderName, getDefaultProviderId } = require('../../lib/provider-names');
22
22
  const { loadSettings } = require('../../lib/settings');
23
23
  const { findPlatformMismatchReason } = require('./validation-platform');
@@ -223,7 +223,7 @@ async function stop(agent) {
223
223
  stopLivenessCheck(agent);
224
224
 
225
225
  const hasNestedExecutions = agent.nestedExecutions?.hasActive === true;
226
- if (!agent.running && !agent.currentTask && !hasNestedExecutions) {
226
+ if (!agent.running && !agent.currentTask && !hasNestedExecutions && !agent._currentExecution) {
227
227
  return;
228
228
  }
229
229
 
@@ -242,26 +242,26 @@ async function stop(agent) {
242
242
  throw new Error(`Task shutdown could not confirm termination: ${termination.reason}`);
243
243
  }
244
244
  }
245
-
246
- // Wait for in-flight execution to complete (up to 5 seconds)
247
- // This prevents write-after-close race conditions
248
- if (agent._currentExecution) {
245
+ const currentExecution = agent._currentExecution;
246
+ if (currentExecution) {
249
247
  let executionTimeout = null;
250
248
  try {
251
- await Promise.race([
252
- agent._currentExecution,
249
+ const outcome = await Promise.race([
250
+ Promise.resolve(currentExecution).then(
251
+ () => 'settled',
252
+ () => 'settled'
253
+ ),
253
254
  new Promise((resolve) => {
254
- executionTimeout = setTimeout(resolve, 5000);
255
+ executionTimeout = setTimeout(() => resolve('timeout'), 5000);
255
256
  }),
256
257
  ]);
257
- } catch {
258
- // Ignore errors from cancelled execution
259
- } finally {
260
- if (executionTimeout) {
261
- clearTimeout(executionTimeout);
258
+ if (outcome === 'timeout') {
259
+ throw new Error(`Agent ${agent.id} execution did not settle after task termination`);
262
260
  }
263
- agent._currentExecution = null;
261
+ } finally {
262
+ if (executionTimeout) clearTimeout(executionTimeout);
264
263
  }
264
+ if (agent._currentExecution === currentExecution) agent._currentExecution = null;
265
265
  }
266
266
 
267
267
  agent._log(`Agent ${agent.id} stopped`);
@@ -1268,67 +1268,16 @@ function startLivenessCheck(agent) {
1268
1268
  agent.livenessTerminationAttempts = 0;
1269
1269
  agent.livenessTerminationRetryAt = 0;
1270
1270
 
1271
- agent.livenessCheckInterval = setInterval(() => {
1272
- const hasRecoverableTask =
1273
- Boolean(agent.currentTask) ||
1274
- Boolean(agent.isolation?.enabled && agent.currentTaskId) ||
1275
- agent.nestedExecutions?.hasActive === true;
1276
- if (!hasRecoverableTask || agent.livenessTerminationStarted) {
1277
- return;
1278
- }
1279
-
1280
- const now = Date.now();
1281
- if (agent.livenessTerminationContext) {
1282
- if (now >= agent.livenessTerminationRetryAt) {
1283
- attemptLivenessTermination(agent, settings);
1284
- }
1285
- return;
1286
- }
1287
-
1288
- const taskStartedAt = agent.taskStartedAt || agent.lastOutputTime || now;
1289
- const lastOutputTime = agent.lastOutputTime || taskStartedAt;
1290
- const taskRuntime = now - taskStartedAt;
1291
- const timeSinceLastOutput = now - lastOutputTime;
1292
-
1293
- if (configuredTimeout && taskRuntime >= configuredTimeout) {
1294
- const reason = `Task timed out after ${configuredTimeout}ms`;
1295
- beginLivenessTermination(agent, settings, reason, 'AGENT_TASK_TIMEOUT', {
1296
- taskId: agent.currentTaskId,
1297
- taskRuntime,
1298
- timeout: configuredTimeout,
1299
- });
1300
- return;
1301
- }
1302
-
1303
- if (timeSinceLastOutput < staleDuration) {
1304
- agent.consecutiveStaleWarnings = 0;
1305
- return;
1306
- }
1307
-
1308
- agent.consecutiveStaleWarnings += 1;
1309
- agent._publishLifecycle('AGENT_STALE_WARNING', {
1310
- taskId: agent.currentTaskId,
1311
- timeSinceLastOutput,
1312
- staleDuration,
1313
- lastOutputTime,
1314
- consecutiveWarnings: agent.consecutiveStaleWarnings,
1315
- warningsBeforeKill,
1316
- processDiagnosticsAvailable: isPlatformSupported(),
1317
- analysis: `Provider produced no output for ${timeSinceLastOutput}ms`,
1318
- });
1319
-
1320
- if (agent.consecutiveStaleWarnings < warningsBeforeKill) {
1321
- return;
1322
- }
1323
-
1324
- const reason = `Provider produced no output for ${timeSinceLastOutput}ms`;
1325
- beginLivenessTermination(agent, settings, reason, 'PROVIDER_INACTIVITY_TIMEOUT', {
1326
- taskId: agent.currentTaskId,
1327
- timeSinceLastOutput,
1328
- staleDuration,
1329
- consecutiveWarnings: agent.consecutiveStaleWarnings,
1330
- });
1331
- }, checkIntervalMs);
1271
+ const poll = createLivenessPoll({
1272
+ agent,
1273
+ settings,
1274
+ configuredTimeout,
1275
+ staleDuration,
1276
+ warningsBeforeKill,
1277
+ attemptTermination: attemptLivenessTermination,
1278
+ beginTermination: beginLivenessTermination,
1279
+ });
1280
+ agent.livenessCheckInterval = setInterval(poll, checkIntervalMs);
1332
1281
  }
1333
1282
 
1334
1283
  const MAX_LIVENESS_TERMINATION_ATTEMPTS = 3;