@nylorun/core 0.19.0-beta → 0.21.0-beta

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 (98) hide show
  1. package/CHANGELOG.md +191 -0
  2. package/README.md +2 -2
  3. package/dist/compatibility.d.ts +148 -32
  4. package/dist/compatibility.js +154 -33
  5. package/dist/contracts.d.ts +2714 -495
  6. package/dist/contracts.js +1395 -493
  7. package/dist/define.d.ts +15 -12
  8. package/dist/define.js +11 -7
  9. package/dist/definition/approval.d.ts +16 -0
  10. package/dist/definition/approval.js +33 -0
  11. package/dist/definition/assemble.d.ts +6 -10
  12. package/dist/definition/assemble.js +48 -105
  13. package/dist/definition/bind-agent.d.ts +3 -4
  14. package/dist/definition/bind-agent.js +12 -30
  15. package/dist/definition/binding.d.ts +2 -2
  16. package/dist/definition/bound.d.ts +10 -10
  17. package/dist/definition/builder.d.ts +16 -20
  18. package/dist/definition/builder.js +29 -81
  19. package/dist/definition/code-tools.d.ts +4 -4
  20. package/dist/definition/code-tools.js +7 -22
  21. package/dist/definition/declaration.d.ts +4 -7
  22. package/dist/definition/declaration.js +29 -99
  23. package/dist/definition/{tools-capability.d.ts → deferred-tools.d.ts} +3 -13
  24. package/dist/definition/{tools-capability.js → deferred-tools.js} +2 -18
  25. package/dist/definition/delegate.d.ts +2 -4
  26. package/dist/definition/delegate.js +8 -10
  27. package/dist/definition/flow/compile.js +0 -2
  28. package/dist/definition/from.d.ts +7 -4
  29. package/dist/definition/from.js +72 -117
  30. package/dist/definition/helpers.d.ts +0 -7
  31. package/dist/definition/helpers.js +0 -5
  32. package/dist/definition/http-tool.d.ts +7 -4
  33. package/dist/definition/http-tool.js +6 -10
  34. package/dist/definition/implementations.d.ts +6 -8
  35. package/dist/definition/manifest.d.ts +11 -5
  36. package/dist/definition/manifest.js +27 -26
  37. package/dist/definition/mcp.d.ts +1 -52
  38. package/dist/definition/mcp.js +11 -60
  39. package/dist/definition/media-reference.d.ts +23 -0
  40. package/dist/definition/media-reference.js +26 -0
  41. package/dist/definition/removed.d.ts +3 -10
  42. package/dist/definition/removed.js +10 -17
  43. package/dist/definition/runtime-manifest.d.ts +30 -0
  44. package/dist/definition/runtime-manifest.js +132 -0
  45. package/dist/definition/sandbox-tools.d.ts +1 -1
  46. package/dist/definition/sandbox-tools.js +1 -1
  47. package/dist/definition/skill-tools.d.ts +13 -7
  48. package/dist/definition/skill-tools.js +23 -10
  49. package/dist/definition/trace.d.ts +18 -0
  50. package/dist/definition/trace.js +42 -0
  51. package/dist/definition/variant.d.ts +5 -4
  52. package/dist/definition/variant.js +23 -55
  53. package/dist/definition/workflow/runnable.js +1 -1
  54. package/dist/errors.d.ts +1 -1
  55. package/dist/harness-api/entries.d.ts +242 -0
  56. package/dist/harness-api/entries.js +118 -0
  57. package/dist/harness-api/gates.d.ts +167 -0
  58. package/dist/harness-api/gates.js +117 -0
  59. package/dist/harness-api/harness-api.schema.json +4975 -0
  60. package/dist/harness-api/index.d.ts +19 -3
  61. package/dist/harness-api/index.js +16 -3
  62. package/dist/harness-api/json-schema.d.ts +12 -0
  63. package/dist/harness-api/json-schema.js +61 -0
  64. package/dist/harness-api/mcp.d.ts +57 -0
  65. package/dist/harness-api/mcp.js +39 -0
  66. package/dist/harness-api/messages.d.ts +11 -5
  67. package/dist/harness-api/messages.js +5 -3
  68. package/dist/harness-api/schema.d.ts +346 -36
  69. package/dist/harness-api/schema.js +143 -22
  70. package/dist/harness-api/transport.d.ts +55 -0
  71. package/dist/harness-api/transport.js +61 -0
  72. package/dist/index.d.ts +1 -1
  73. package/dist/manifest-schemas.d.ts +6 -0
  74. package/dist/manifest-schemas.js +34 -0
  75. package/dist/schemas/agent-manifest.schema.json +897 -0
  76. package/dist/schemas/environment-manifest.schema.json +329 -0
  77. package/dist/types/agent.d.ts +1 -1
  78. package/dist/types/manifest.d.ts +48 -28
  79. package/dist/types/model.d.ts +2 -2
  80. package/dist/types/observe.d.ts +8 -20
  81. package/dist/types/part.d.ts +25 -0
  82. package/dist/types/tool.d.ts +1 -1
  83. package/dist/types/transcript.d.ts +5 -0
  84. package/dist/utils/definition-files.d.ts +11 -6
  85. package/dist/utils/definition-files.js +19 -9
  86. package/dist/utils/harness-id.d.ts +9 -0
  87. package/dist/utils/harness-id.js +11 -0
  88. package/dist/utils/runtime-tools.d.ts +19 -0
  89. package/dist/utils/runtime-tools.js +30 -0
  90. package/dist/utils/sandbox.d.ts +1 -1
  91. package/dist/utils/sandbox.js +1 -1
  92. package/package.json +11 -4
  93. package/dist/definition/capability.d.ts +0 -43
  94. package/dist/definition/capability.js +0 -82
  95. package/dist/definition/sandbox-capability.d.ts +0 -44
  96. package/dist/definition/sandbox-capability.js +0 -139
  97. package/dist/types/middleware.d.ts +0 -94
  98. /package/dist/types/{middleware.js → part.js} +0 -0
@@ -0,0 +1,117 @@
1
+ /**
2
+ * The gates a harness calls (R4.5): the Model Gate and the Tool Gate, on the gateway's port. A
3
+ * harness never holds a model or tool credential: it presents the run token of the run it holds
4
+ * (`RunGrant.token`) as `Authorization: Bearer`, and the gate takes the session, turn and agent
5
+ * from the token. Every call is keyed by its effect id, sent as `Idempotency-Key`: a re-send
6
+ * with the same key and body joins the call or gets its outcome, so a harness that lost an
7
+ * answer sends the call again instead of guessing.
8
+ *
9
+ * Model Gate. `POST /nylorun/v1/model-calls` with a `ModelCallBody`: `200 {outcome}` once the
10
+ * call has finished, a model candidate or a failure outcome. `POST
11
+ * /nylorun/v1/model-calls/{key}/cancel` aborts a keyed call (`204`).
12
+ *
13
+ * Tool Gate. Remote MCP servers by name (`mcp/connect`, `mcp/list`, `tool-calls`, `mcp/close`)
14
+ * and HTTP tools by tool (`http-calls`); `tool-calls/{key}/cancel` aborts either. Each answers
15
+ * `200 {ok: true, result}` or `200 {ok: false, error}`: a tool's failure is an answer, not a
16
+ * gate error.
17
+ *
18
+ * A gate error is `{error: {code, message}}` with one of `GATE_ERROR_CODES`: `401
19
+ * gate_unauthorized` (missing, malformed, expired or foreign token), `403 gate_forbidden`
20
+ * (another session's call), `409 run_stale` (the token's lease is no longer the session's),
21
+ * `400 invalid_request`, `409 gate_conflict` (another request runs under the same key). A run's
22
+ * tool call must be journaled first (`effect.intent` answered `execute`) and keyed by its effect
23
+ * id: else `400 key_required` or `409 effect_not_journaled`.
24
+ */
25
+ import { z } from "zod";
26
+ export const MODEL_CALLS_PATH = "/nylorun/v1/model-calls";
27
+ export const MCP_CONNECT_PATH = "/nylorun/v1/mcp/connect";
28
+ export const MCP_LIST_PATH = "/nylorun/v1/mcp/list";
29
+ export const MCP_CLOSE_PATH = "/nylorun/v1/mcp/close";
30
+ export const TOOL_CALLS_PATH = "/nylorun/v1/tool-calls";
31
+ export const HTTP_CALLS_PATH = "/nylorun/v1/http-calls";
32
+ /** Largest model call body the gate reads: one `ModelCall` with its whole projected history. */
33
+ export const MAX_MODEL_CALL_BYTES = 32 * 1024 * 1024;
34
+ /** Largest tool call body the gate reads. */
35
+ export const MAX_TOOL_BODY_BYTES = 8 * 1024 * 1024;
36
+ /**
37
+ * One model call. It names no session, turn or agent: the gate takes them from the run token,
38
+ * and refuses a body that names them. `call` is the engine's `ModelCall`.
39
+ */
40
+ export const ModelCallBodySchema = z.strictObject({
41
+ effectId: z.string().min(1),
42
+ invocationId: z.string().min(1),
43
+ call: z.looseObject({
44
+ prompt: z.array(z.unknown()),
45
+ tools: z.array(z.looseObject({ name: z.string() })),
46
+ }),
47
+ });
48
+ export const GATE_ERROR_CODES = [
49
+ "gate_unauthorized",
50
+ "gate_forbidden",
51
+ "run_stale",
52
+ "invalid_request",
53
+ "gate_conflict",
54
+ /** A run's tool call without its effect id as `Idempotency-Key`. */
55
+ "key_required",
56
+ /** A run's tool call the effect journal does not hold, running, as sent: journal it first. */
57
+ "effect_not_journaled",
58
+ ];
59
+ /** An error answer: `{error: {code, message}}`. */
60
+ export const GateErrorBodySchema = z.strictObject({
61
+ error: z.strictObject({ code: z.enum(GATE_ERROR_CODES), message: z.string() }),
62
+ });
63
+ /** A remote MCP server of the session's pinned manifest, by name. */
64
+ export const McpServerRefSchema = z.object({
65
+ /** Required with core's credential; a run token names the session itself. */
66
+ sessionId: z.string().min(1).optional(),
67
+ /** The agent used as a tool that declares the server; absent for the session's root agent. */
68
+ agentId: z.string().min(1).optional(),
69
+ serverName: z.string().min(1),
70
+ });
71
+ /** `mcp/connect` and `mcp/close`. */
72
+ export const McpServerBodySchema = z.object({ server: McpServerRefSchema });
73
+ /** `mcp/list`: one page of `tools/list`. */
74
+ export const McpListBodySchema = z.object({
75
+ server: McpServerRefSchema,
76
+ cursor: z.string().optional(),
77
+ });
78
+ /** `tool-calls`: one `tools/call`, keyed by its effect id. */
79
+ export const ToolCallBodySchema = z.object({
80
+ server: McpServerRefSchema,
81
+ effectId: z.string().min(1),
82
+ name: z.string().min(1),
83
+ arguments: z.record(z.string(), z.unknown()),
84
+ });
85
+ /**
86
+ * `http-calls`: one call of an HTTP tool, named by its agent and tool, or a flow's
87
+ * HTTP stage or verifier by its stage key. The gate finds its URL, method and credential in the
88
+ * session's pinned manifest. A run token's turn is the call's; `turnId` counts only under core's
89
+ * credential.
90
+ */
91
+ export const HttpCallBodySchema = z.object({
92
+ tool: z.union([
93
+ z.object({
94
+ sessionId: z.string().min(1).optional(),
95
+ agentId: z.string().min(1).optional(),
96
+ toolName: z.string().min(1),
97
+ }),
98
+ z.object({
99
+ sessionId: z.string().min(1).optional(),
100
+ /** A flow's HTTP stage or HTTP verifier. */
101
+ stage: z.string().min(1),
102
+ }),
103
+ ]),
104
+ effectId: z.string().min(1),
105
+ turnId: z.string().min(1),
106
+ input: z.unknown(),
107
+ });
108
+ /** How an MCP tool call failed, coded; the failed outcome the model sees carries the code. */
109
+ export const MCP_FAILURE_CODES = [
110
+ "mcp.unreachable",
111
+ "credential_rejected",
112
+ "mcp.forbidden",
113
+ "mcp.error",
114
+ "mcp.status",
115
+ "mcp.lost",
116
+ "mcp.too-large",
117
+ ];