@nylorun/runtime 0.27.0-beta → 0.29.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.
- package/CHANGELOG.md +67 -0
- package/README.md +1 -1
- package/dist/api/a2a/card.d.ts +4 -3
- package/dist/api/a2a/card.js +3 -3
- package/dist/api/a2a/routes.js +18 -7
- package/dist/api/ag-ui/routes.js +4 -7
- package/dist/api/components.d.ts +5854 -2718
- package/dist/api/components.js +39 -30
- package/dist/api/http/app.js +9 -4
- package/dist/api/http/body.d.ts +2 -0
- package/dist/api/http/body.js +20 -0
- package/dist/api/http/define.d.ts +4 -0
- package/dist/api/http/define.js +20 -9
- package/dist/api/http/routes/agent-manifests.d.ts +10 -0
- package/dist/api/http/routes/agent-manifests.js +135 -0
- package/dist/api/http/routes/agents.d.ts +11 -0
- package/dist/api/http/routes/agents.js +418 -0
- package/dist/api/http/routes/artifacts.js +2 -2
- package/dist/api/http/routes/coverage.d.ts +4 -4
- package/dist/api/http/routes/coverage.js +12 -6
- package/dist/api/http/routes/files.js +1 -1
- package/dist/api/http/routes/mcp.js +2 -2
- package/dist/api/http/routes/me.d.ts +1 -1
- package/dist/api/http/routes/me.js +1 -2
- package/dist/api/http/routes/memories.d.ts +9 -0
- package/dist/api/http/routes/memories.js +152 -0
- package/dist/api/http/routes/reads.d.ts +1 -137
- package/dist/api/http/routes/reads.js +31 -12
- package/dist/api/http/routes/sessions.js +21 -50
- package/dist/api/http/routes/tenant.js +13 -10
- package/dist/api/http/routes/triggers.d.ts +10 -0
- package/dist/api/http/routes/triggers.js +183 -0
- package/dist/api/openapi.js +69 -47
- package/dist/artifacts/disk.d.ts +10 -10
- package/dist/artifacts/disk.js +27 -27
- package/dist/artifacts/quota.d.ts +1 -1
- package/dist/artifacts/quota.js +2 -2
- package/dist/artifacts/service.js +2 -2
- package/dist/core/flow-host.d.ts +0 -1
- package/dist/gates/egress-credentials.js +1 -1
- package/dist/gates/egress.d.ts +5 -5
- package/dist/gates/egress.js +6 -6
- package/dist/gates/http-tool.js +2 -2
- package/dist/gates/meter.js +22 -5
- package/dist/gates/policy.d.ts +8 -3
- package/dist/gates/policy.js +7 -2
- package/dist/gates/tenant-vaults.d.ts +1 -1
- package/dist/harness/pod.d.ts +2 -0
- package/dist/harness/setup.js +17 -6
- package/dist/harness-api/record.js +11 -0
- package/dist/harness-api/server.js +4 -0
- package/dist/harness-api/start.d.ts +11 -7
- package/dist/harness-api/start.js +49 -5
- package/dist/harness-api/workspace.js +2 -2
- package/dist/host/config-for.d.ts +2 -0
- package/dist/host/config-for.js +1 -0
- package/dist/host/http.d.ts +2 -2
- package/dist/host/http.js +5 -2
- package/dist/host/main.js +1 -0
- package/dist/keys/keys.d.ts +15 -4
- package/dist/keys/keys.js +16 -0
- package/dist/keys/webhooks.d.ts +25 -0
- package/dist/keys/webhooks.js +62 -0
- package/dist/management-openapi.json +313 -133
- package/dist/mcp/connect.d.ts +2 -2
- package/dist/mcp/connect.js +3 -3
- package/dist/mcp/preview.js +7 -7
- package/dist/memory/service.d.ts +97 -0
- package/dist/memory/service.js +335 -0
- package/dist/memory/tool.d.ts +36 -0
- package/dist/memory/tool.js +84 -0
- package/dist/model/pi-model.js +7 -0
- package/dist/openapi.json +13120 -9034
- package/dist/reads/types.d.ts +3 -3
- package/dist/record/agent.d.ts +27 -0
- package/dist/record/agent.js +46 -0
- package/dist/record/index.d.ts +1 -1
- package/dist/record/index.js +1 -1
- package/dist/sandbox/join.js +5 -5
- package/dist/sandbox/placement.d.ts +1 -1
- package/dist/sandbox/placement.js +3 -3
- package/dist/sandbox/pods/lifecycle.d.ts +6 -6
- package/dist/sandbox/pods/lifecycle.js +6 -6
- package/dist/sandbox/pods/reconcile.js +10 -2
- package/dist/sandbox/resolve.d.ts +3 -3
- package/dist/sandbox/resolve.js +7 -7
- package/dist/sandbox/setup.d.ts +3 -1
- package/dist/sandbox/setup.js +14 -4
- package/dist/store/postgres/drizzle/0032_agents.sql +54 -0
- package/dist/store/postgres/drizzle/0033_agent_versions.sql +7 -0
- package/dist/store/postgres/drizzle/0034_protocol_17_session_queue.sql +13 -0
- package/dist/store/postgres/drizzle/0035_t4_triggers.sql +41 -0
- package/dist/store/postgres/drizzle/0036_t5_memories.sql +30 -0
- package/dist/store/postgres/drizzle/0037_model_usage_cost_split.sql +4 -0
- package/dist/store/postgres/drizzle/meta/_journal.json +42 -0
- package/dist/store/postgres/reads.js +44 -87
- package/dist/store/postgres/record-writer.d.ts +4 -4
- package/dist/store/postgres/record-writer.js +9 -9
- package/dist/store/postgres/schema.d.ts +1408 -123
- package/dist/store/postgres/schema.js +194 -38
- package/dist/store/postgres/store.js +329 -79
- package/dist/store/postgres/tenant.js +1 -2
- package/dist/store/types.d.ts +155 -50
- package/dist/store/types.js +0 -1
- package/dist/tenant/advance.js +20 -8
- package/dist/tenant/agent-manifests.d.ts +72 -0
- package/dist/tenant/agent-manifests.js +359 -0
- package/dist/tenant/agent-versions.d.ts +126 -0
- package/dist/tenant/agent-versions.js +389 -0
- package/dist/tenant/agents.d.ts +230 -0
- package/dist/tenant/{environments.js → agents.js} +464 -320
- package/dist/tenant/auth.d.ts +1 -1
- package/dist/tenant/auth.js +3 -3
- package/dist/tenant/commands.d.ts +63 -2
- package/dist/tenant/commands.js +240 -83
- package/dist/tenant/context.d.ts +46 -19
- package/dist/tenant/context.js +6 -2
- package/dist/tenant/effects.js +7 -16
- package/dist/tenant/identity-file.d.ts +6 -6
- package/dist/tenant/identity-file.js +12 -10
- package/dist/tenant/issuers.js +3 -3
- package/dist/tenant/limits.d.ts +0 -3
- package/dist/tenant/limits.js +0 -3
- package/dist/tenant/memories.d.ts +38 -0
- package/dist/tenant/memories.js +119 -0
- package/dist/tenant/reset.js +2 -2
- package/dist/tenant/run-grants.d.ts +6 -0
- package/dist/tenant/run-grants.js +4 -0
- package/dist/tenant/runtime.d.ts +1 -1
- package/dist/tenant/runtime.js +8 -0
- package/dist/tenant/sessions.d.ts +28 -45
- package/dist/tenant/sessions.js +85 -208
- package/dist/tenant/status.js +6 -7
- package/dist/tenant/sweep.js +12 -3
- package/dist/tenant/transcript.d.ts +16 -16
- package/dist/tenant/triggers.d.ts +143 -0
- package/dist/tenant/triggers.js +715 -0
- package/dist/tenant/turn-timing.d.ts +11 -1
- package/dist/tenant/turn-timing.js +3 -1
- package/dist/tenant/types.d.ts +5 -0
- package/dist/tenant/worker.d.ts +2 -0
- package/dist/tenant/worker.js +5 -0
- package/dist/traces/map.d.ts +1 -1
- package/dist/traces/map.js +7 -1
- package/dist/tuning.d.ts +7 -0
- package/dist/tuning.js +19 -0
- package/dist/vault/service.d.ts +13 -8
- package/dist/vault/service.js +61 -17
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -12
- package/dist/api/http/routes/environment-manifests.d.ts +0 -9
- package/dist/api/http/routes/environment-manifests.js +0 -118
- package/dist/api/http/routes/environments.d.ts +0 -11
- package/dist/api/http/routes/environments.js +0 -332
- package/dist/record/environment.d.ts +0 -27
- package/dist/record/environment.js +0 -46
- package/dist/tenant/environment-manifests.d.ts +0 -57
- package/dist/tenant/environment-manifests.js +0 -208
- package/dist/tenant/environments.d.ts +0 -172
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Cron } from "croner";
|
|
2
|
+
import { type RuntimeLimits, type Trigger, type TriggerRun, type TriggerView } from "@nylorun/core/contracts";
|
|
3
|
+
import type { AgentTriggerRow, Environment, TriggerRunRow, Tx } from "../store/types.js";
|
|
4
|
+
import type { Session, TenantContext } from "./context.js";
|
|
5
|
+
/** The durable timer key of an Agent's trigger. Agent ids hold no `:`. */
|
|
6
|
+
export declare const triggerTimerKey: (agentId: string, triggerId: string) => string;
|
|
7
|
+
/** A webhook trigger's endpoint id: `wh_` and 128 random bits, kept across moves (D75). */
|
|
8
|
+
export declare const newEndpointId: () => string;
|
|
9
|
+
/** A webhook endpoint's path, under the Runtime API's origin. */
|
|
10
|
+
export declare const webhookPath: (endpointId: string) => string;
|
|
11
|
+
/** A new run id: increasing with time, so runs list newest first by id. */
|
|
12
|
+
export declare function newRunId(now?: number): string;
|
|
13
|
+
/** A schedule's cron in its time zone (UTC by default); throws on a bad pattern or zone. */
|
|
14
|
+
export declare function cronOf(trigger: Pick<Trigger, "schedule" | "timezone">): Cron;
|
|
15
|
+
/**
|
|
16
|
+
* The fixed offset of a schedule's runs: from a hash of the Agent and trigger id, at most
|
|
17
|
+
* `triggerJitterPercent` of its interval and `triggerJitterMaxMs`, so a fleet of hourly Agents
|
|
18
|
+
* spreads out and none of them drifts.
|
|
19
|
+
*/
|
|
20
|
+
export declare function jitterMs(agentId: string, triggerId: string, intervalMs: number, limits: RuntimeLimits): number;
|
|
21
|
+
/**
|
|
22
|
+
* When trigger `trigger` of Agent `agentId` fires next after `after`, or `null` when it never
|
|
23
|
+
* does again (an `at` that passed, a webhook).
|
|
24
|
+
*/
|
|
25
|
+
export declare function nextFireAt(agentId: string, triggerId: string, trigger: Trigger, after: Date, limits: RuntimeLimits): Date | null;
|
|
26
|
+
/**
|
|
27
|
+
* Why `triggers` cannot be saved (D74): more than `triggersPerAgent`, a cron or time zone croner
|
|
28
|
+
* refuses, two runs closer than `triggerMinIntervalMs` over the next `triggers.intervalCheckFires`
|
|
29
|
+
* fires, an `at` that is not in the future, a prompt past `triggerPromptChars`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function triggerIssues(triggers: Readonly<Record<string, Trigger>> | undefined, limits: RuntimeLimits, now?: Date): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Writes the state of a new Agent's triggers (D74): every trigger of the version it is made from
|
|
34
|
+
* starts active, with its next time. Arm them after the commit (`armAgentTriggers`).
|
|
35
|
+
*/
|
|
36
|
+
export declare function createAgentTriggers(t: Tx, agent: Environment, now?: Date): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* After Agent `agent` (locked) moved from manifest version `from` to the version it now runs (track
|
|
39
|
+
* T3, D73), in the move's transaction: its triggers merge by id. One the new version adds arrives
|
|
40
|
+
* paused (`new`), one it drops loses its state (its runs stay), and one whose timing changed gets a
|
|
41
|
+
* new generation and next time; a changed prompt or session applies at the next fire. The sweep
|
|
42
|
+
* arms what changed (`reconcileTriggers`).
|
|
43
|
+
*/
|
|
44
|
+
export declare function mergeAgentTriggers(t: Tx, agent: Environment, from: number, now?: Date): Promise<void>;
|
|
45
|
+
/** Arms one trigger's timer for its next time, or the next step of a wait past `TIMER_MAX_MS`. */
|
|
46
|
+
export declare function armTrigger(ctx: TenantContext, row: Pick<AgentTriggerRow, "agentId" | "triggerId" | "status" | "nextFireAt">): Promise<void>;
|
|
47
|
+
/** Arms every active trigger of Agent `agentId`, after the commit that changed them. */
|
|
48
|
+
export declare function armAgentTriggers(ctx: TenantContext, agentId: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* The Tenant sweep's step (see the module comment): every active trigger on the first pass on
|
|
51
|
+
* this process, overdue ones after; and runs past `triggerRunRetentionMs` are deleted.
|
|
52
|
+
*/
|
|
53
|
+
export declare function reconcileTriggers(ctx: TenantContext, first: boolean): Promise<void>;
|
|
54
|
+
/** `DurableExecution.timer` fired for key `key` (`TenantWorker.fire`). */
|
|
55
|
+
export declare function fireTimer(ctx: TenantContext, key: string): Promise<void>;
|
|
56
|
+
/** What makes a run: its cause's key, when it was due, whether late. */
|
|
57
|
+
interface RunCause {
|
|
58
|
+
runKey: string;
|
|
59
|
+
dueAt: string;
|
|
60
|
+
late: boolean;
|
|
61
|
+
/** A webhook's delivery: its body, as data under the prompt (D75). */
|
|
62
|
+
payload?: WebhookPayload;
|
|
63
|
+
}
|
|
64
|
+
/** What a delivery brought, as the model sees it under the prompt. */
|
|
65
|
+
export interface WebhookPayload {
|
|
66
|
+
readonly body: string;
|
|
67
|
+
readonly contentType: string | undefined;
|
|
68
|
+
readonly receivedAt: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Runs trigger `triggerId` of `agent` (locked, with the trigger's row) in `t`: see the module
|
|
72
|
+
* comment. Returns the run; a cause already run returns that run.
|
|
73
|
+
*/
|
|
74
|
+
export declare function deliverRun(ctx: TenantContext, t: Tx, agent: Environment, triggerId: string, trigger: Trigger, row: Pick<AgentTriggerRow, "kind">, cause: RunCause): Promise<TriggerRunRow>;
|
|
75
|
+
/** A run as the API shows it. */
|
|
76
|
+
export declare function runView(row: TriggerRunRow): TriggerRun;
|
|
77
|
+
/** `GET /v1/agents/{id}/triggers`. */
|
|
78
|
+
export declare function listTriggers(ctx: TenantContext, agentId: string, origin?: string): Promise<{
|
|
79
|
+
triggers: TriggerView[];
|
|
80
|
+
}>;
|
|
81
|
+
/** `POST .../triggers/{triggerId}/pause` and `/resume`. */
|
|
82
|
+
export declare function setTriggerStatus(ctx: TenantContext, agentId: string, triggerId: string, action: "pause" | "resume", origin?: string): Promise<{
|
|
83
|
+
triggers: TriggerView[];
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* `POST .../triggers/{triggerId}/run`: runs it now, whatever its status, keyed by the request's
|
|
87
|
+
* `Idempotency-Key`, so a retried request makes one run.
|
|
88
|
+
*/
|
|
89
|
+
export declare function runTriggerNow(ctx: TenantContext, agentId: string, triggerId: string, idempotencyKey: string): Promise<TriggerRun>;
|
|
90
|
+
/** `GET /v1/agents/{id}/runs`: newest first, `limit` per page, after cursor `before`. */
|
|
91
|
+
export declare function listRuns(ctx: TenantContext, agentId: string, options: {
|
|
92
|
+
triggerId?: string;
|
|
93
|
+
cursor?: string;
|
|
94
|
+
limit: number;
|
|
95
|
+
}): Promise<{
|
|
96
|
+
runs: TriggerRun[];
|
|
97
|
+
nextCursor: string | null;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* `POST .../triggers/{triggerId}/secret`: a new signing secret for a webhook trigger, made and
|
|
101
|
+
* sealed in the keys service, shown this once. The one before stops working at once.
|
|
102
|
+
*/
|
|
103
|
+
export declare function rotateWebhookSecret(ctx: TenantContext, agentId: string, triggerId: string, origin: string): Promise<{
|
|
104
|
+
triggerId: string;
|
|
105
|
+
webhookUrl: string;
|
|
106
|
+
secret: string;
|
|
107
|
+
}>;
|
|
108
|
+
/** A delivery to a webhook endpoint, as it arrived. */
|
|
109
|
+
export interface InboundDelivery {
|
|
110
|
+
readonly id: string | undefined;
|
|
111
|
+
readonly timestamp: string | undefined;
|
|
112
|
+
readonly signature: string | undefined;
|
|
113
|
+
readonly contentType: string | undefined;
|
|
114
|
+
readonly body: Buffer;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* `POST /v1/webhooks/{endpointId}` (D75), after the route read the body within
|
|
118
|
+
* `webhookBodyBytes`: Standard Webhooks headers present, the timestamp within the Host's
|
|
119
|
+
* `triggers.webhookToleranceMs`, and a signature the keys service verifies with the sealed secret,
|
|
120
|
+
* or `401` and nothing is written. A paused trigger answers `409 trigger_paused` only after that,
|
|
121
|
+
* so an unsigned probe learns nothing about it. Then the run, keyed by the delivery id: a sender's
|
|
122
|
+
* retry answers the first run.
|
|
123
|
+
*/
|
|
124
|
+
export declare function receiveWebhook(ctx: TenantContext, endpointId: string, delivery: InboundDelivery): Promise<{
|
|
125
|
+
runId: string;
|
|
126
|
+
status: TriggerRun["status"];
|
|
127
|
+
reason: string | null;
|
|
128
|
+
}>;
|
|
129
|
+
/** The id of session `sessionId`'s booked wake among its Agent's triggers: one per session. */
|
|
130
|
+
export declare const wakeIdOf: (sessionId: string) => string;
|
|
131
|
+
/**
|
|
132
|
+
* `schedule_wake` (D77), served by the record in the call's transaction (a `runtime` effect): on
|
|
133
|
+
* session `s` (locked), when the version it runs sets `runtime.selfWake`. `{in | at, note}` books
|
|
134
|
+
* its next turn, replacing a booking before, at least `triggerMinIntervalMs` and at most
|
|
135
|
+
* `wakeMaxAheadMs` ahead, the note at most `wakeNoteChars`; `{cancel: true}` removes the booking.
|
|
136
|
+
* The booking is the session's Agent's trigger `wake:<sessionId>`, armed by the sweep's next pass.
|
|
137
|
+
*/
|
|
138
|
+
export declare function serveRuntimeTool(t: Tx, s: Session, request: {
|
|
139
|
+
effectId: string;
|
|
140
|
+
input?: unknown;
|
|
141
|
+
target?: unknown;
|
|
142
|
+
}): Promise<unknown>;
|
|
143
|
+
export {};
|