@finalai/agent-protocol 0.1.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.
Potentially problematic release.
This version of @finalai/agent-protocol might be problematic. Click here for more details.
- package/README.md +10 -0
- package/dist/modules/agent-platform/agents.d.mts +162 -0
- package/dist/modules/agent-platform/agents.mjs +91 -0
- package/dist/modules/agent-platform/agents.mjs.map +7 -0
- package/dist/modules/agent-platform/build.d.mts +678 -0
- package/dist/modules/agent-platform/build.mjs +348 -0
- package/dist/modules/agent-platform/build.mjs.map +7 -0
- package/dist/modules/agent-platform/common.d.mts +221 -0
- package/dist/modules/agent-platform/common.mjs +157 -0
- package/dist/modules/agent-platform/common.mjs.map +7 -0
- package/dist/modules/agent-platform/conversation-schedules.d.mts +98 -0
- package/dist/modules/agent-platform/conversation-schedules.mjs +70 -0
- package/dist/modules/agent-platform/conversation-schedules.mjs.map +7 -0
- package/dist/modules/agent-platform/conversations.d.mts +1024 -0
- package/dist/modules/agent-platform/conversations.mjs +378 -0
- package/dist/modules/agent-platform/conversations.mjs.map +7 -0
- package/dist/modules/agent-platform/enums.d.mts +231 -0
- package/dist/modules/agent-platform/enums.mjs +306 -0
- package/dist/modules/agent-platform/enums.mjs.map +7 -0
- package/dist/modules/agent-platform/index.d.mts +13 -0
- package/dist/modules/agent-platform/index.mjs +16 -0
- package/dist/modules/agent-platform/index.mjs.map +7 -0
- package/dist/modules/agent-platform/links.d.mts +77 -0
- package/dist/modules/agent-platform/links.mjs +34 -0
- package/dist/modules/agent-platform/links.mjs.map +7 -0
- package/dist/modules/agent-platform/people.d.mts +21 -0
- package/dist/modules/agent-platform/people.mjs +22 -0
- package/dist/modules/agent-platform/people.mjs.map +7 -0
- package/dist/modules/agent-platform/realtime.d.mts +713 -0
- package/dist/modules/agent-platform/realtime.mjs +185 -0
- package/dist/modules/agent-platform/realtime.mjs.map +7 -0
- package/dist/modules/agent-platform/sandboxes.d.mts +203 -0
- package/dist/modules/agent-platform/sandboxes.mjs +186 -0
- package/dist/modules/agent-platform/sandboxes.mjs.map +7 -0
- package/dist/modules/agent-platform/sessions.d.mts +494 -0
- package/dist/modules/agent-platform/sessions.mjs +242 -0
- package/dist/modules/agent-platform/sessions.mjs.map +7 -0
- package/dist/modules/base58.d.mts +2 -0
- package/dist/modules/base58.mjs +46 -0
- package/dist/modules/base58.mjs.map +7 -0
- package/dist/modules/index.d.mts +4 -0
- package/dist/modules/index.mjs +5 -0
- package/dist/modules/index.mjs.map +7 -0
- package/dist/modules/json-rpc.d.mts +15 -0
- package/dist/modules/json-rpc.mjs +20 -0
- package/dist/modules/json-rpc.mjs.map +7 -0
- package/dist/modules/json.d.mts +7 -0
- package/dist/modules/json.mjs +11 -0
- package/dist/modules/json.mjs.map +7 -0
- package/dist/modules/process-inspection.d.mts +177 -0
- package/dist/modules/process-inspection.mjs +83 -0
- package/dist/modules/process-inspection.mjs.map +7 -0
- package/dist/modules/tolerance.d.mts +18 -0
- package/dist/modules/tolerance.mjs +15 -0
- package/dist/modules/tolerance.mjs.map +7 -0
- package/package.json +121 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { jsonObjectSchema, jsonValueSchema } from "../json.mjs";
|
|
3
|
+
import { tolerantStringEnum } from "../tolerance.mjs";
|
|
4
|
+
import { acpWireMessageSchema, contentInputSchema, nullableNumber, nullableString } from "./common.mjs";
|
|
5
|
+
import {
|
|
6
|
+
AcpFrameDirection,
|
|
7
|
+
AcpPreviewKind,
|
|
8
|
+
AgentSessionState,
|
|
9
|
+
AgentTurnPolicy,
|
|
10
|
+
PendingEventState,
|
|
11
|
+
PendingRequestKind
|
|
12
|
+
} from "./enums.mjs";
|
|
13
|
+
const sessionConfigOptionSchema = z.looseObject({
|
|
14
|
+
id: z.string().optional(),
|
|
15
|
+
configId: z.string().optional(),
|
|
16
|
+
name: z.string().optional(),
|
|
17
|
+
category: z.string().nullable().optional(),
|
|
18
|
+
currentValue: jsonValueSchema.optional()
|
|
19
|
+
});
|
|
20
|
+
const sessionSchema = z.object({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
organizationId: z.string(),
|
|
23
|
+
agentId: z.string(),
|
|
24
|
+
revisionId: nullableString(),
|
|
25
|
+
ownerUserId: nullableString(),
|
|
26
|
+
conversationId: nullableString(),
|
|
27
|
+
participantId: nullableString(),
|
|
28
|
+
state: tolerantStringEnum(AgentSessionState),
|
|
29
|
+
turnPolicy: tolerantStringEnum(AgentTurnPolicy),
|
|
30
|
+
title: nullableString(),
|
|
31
|
+
/** Seq of the newest logged frame; 0 before the first frame. */
|
|
32
|
+
headSeq: z.number().default(0),
|
|
33
|
+
configOptions: z.array(sessionConfigOptionSchema).default([]),
|
|
34
|
+
lastPromptAt: nullableString(),
|
|
35
|
+
closedAt: nullableString(),
|
|
36
|
+
createdAt: z.string(),
|
|
37
|
+
updatedAt: nullableString()
|
|
38
|
+
});
|
|
39
|
+
const sessionManifestSchema = z.object({
|
|
40
|
+
sessionId: z.string(),
|
|
41
|
+
revisionId: nullableString(),
|
|
42
|
+
resolvedAt: nullableString(),
|
|
43
|
+
manifest: jsonObjectSchema.nullable().default(null),
|
|
44
|
+
report: jsonObjectSchema.nullable().default(null)
|
|
45
|
+
});
|
|
46
|
+
const turnSchema = z.object({
|
|
47
|
+
id: z.string(),
|
|
48
|
+
sessionId: z.string(),
|
|
49
|
+
promptMessageId: nullableString(),
|
|
50
|
+
startedAt: z.string(),
|
|
51
|
+
endedAt: nullableString(),
|
|
52
|
+
stopReason: nullableString(),
|
|
53
|
+
fromSeq: nullableNumber(),
|
|
54
|
+
toSeq: nullableNumber(),
|
|
55
|
+
inputTokens: nullableNumber(),
|
|
56
|
+
outputTokens: nullableNumber()
|
|
57
|
+
});
|
|
58
|
+
const promptAcceptedSchema = z.object({
|
|
59
|
+
messageId: z.string(),
|
|
60
|
+
turnId: z.string(),
|
|
61
|
+
/** Seq of the logged `session/prompt` frame; a turn-scoped stream starts here. */
|
|
62
|
+
fromSeq: nullableNumber()
|
|
63
|
+
});
|
|
64
|
+
const acpFrameEventSchema = z.object({
|
|
65
|
+
seq: z.number(),
|
|
66
|
+
frame: acpWireMessageSchema,
|
|
67
|
+
direction: tolerantStringEnum(AcpFrameDirection),
|
|
68
|
+
at: nullableString(),
|
|
69
|
+
/**
|
|
70
|
+
* The open pending request an agent request frame (`session/request_permission`,
|
|
71
|
+
* `elicitation/create`) raised: answer it with `respond({ pendingId })`. Replay
|
|
72
|
+
* pages set it; live frames precede their pending request, so the SDK joins
|
|
73
|
+
* them with the session's `acp.pending` events.
|
|
74
|
+
*/
|
|
75
|
+
pendingId: nullableString()
|
|
76
|
+
});
|
|
77
|
+
const acpLiveFrameEventSchema = acpFrameEventSchema.extend({ streamId: z.string() });
|
|
78
|
+
const acpLiveResetEventSchema = z.object({
|
|
79
|
+
streamId: nullableString(),
|
|
80
|
+
throughSeq: nullableNumber(),
|
|
81
|
+
reason: nullableString()
|
|
82
|
+
});
|
|
83
|
+
const acpPreviewEventSchema = z.object({
|
|
84
|
+
seq: z.number(),
|
|
85
|
+
text: z.string(),
|
|
86
|
+
// Not `kind`: realtime events are flattened under the envelope's kind.
|
|
87
|
+
previewKind: tolerantStringEnum(AcpPreviewKind).nullable().default(null),
|
|
88
|
+
messageId: nullableString(),
|
|
89
|
+
turnId: nullableString()
|
|
90
|
+
});
|
|
91
|
+
const permissionOptionSchema = z.object({
|
|
92
|
+
optionId: z.string(),
|
|
93
|
+
name: z.string(),
|
|
94
|
+
// ACP `PermissionOptionKind` (allow_once, allow_always, reject_once, ...); open.
|
|
95
|
+
kind: nullableString()
|
|
96
|
+
});
|
|
97
|
+
const pendingRequestDetailSchema = z.object({
|
|
98
|
+
title: nullableString(),
|
|
99
|
+
body: nullableString(),
|
|
100
|
+
options: z.array(permissionOptionSchema).default([]),
|
|
101
|
+
/** Elicitation `requestedSchema` (form mode). */
|
|
102
|
+
schema: jsonValueSchema.nullable().default(null),
|
|
103
|
+
/** Elicitation mode (`form`, `url`); open. */
|
|
104
|
+
mode: nullableString(),
|
|
105
|
+
url: nullableString(),
|
|
106
|
+
toolCall: jsonValueSchema.nullable().default(null)
|
|
107
|
+
});
|
|
108
|
+
const pendingRequestSchema = z.object({
|
|
109
|
+
id: z.string(),
|
|
110
|
+
sessionId: z.string(),
|
|
111
|
+
turnId: nullableString(),
|
|
112
|
+
conversationId: nullableString(),
|
|
113
|
+
kind: tolerantStringEnum(PendingRequestKind),
|
|
114
|
+
request: pendingRequestDetailSchema,
|
|
115
|
+
audienceParticipantIds: z.array(z.string()).default([]),
|
|
116
|
+
audienceUserIds: z.array(z.string()).default([]),
|
|
117
|
+
logSeq: nullableNumber(),
|
|
118
|
+
createdAt: nullableString(),
|
|
119
|
+
expiresAt: nullableString(),
|
|
120
|
+
resolvedAt: nullableString(),
|
|
121
|
+
resolvedByUserId: nullableString(),
|
|
122
|
+
outcome: jsonValueSchema.nullable().default(null)
|
|
123
|
+
});
|
|
124
|
+
const acpPendingEventSchema = z.object({
|
|
125
|
+
pending: pendingRequestSchema,
|
|
126
|
+
state: tolerantStringEnum(PendingEventState)
|
|
127
|
+
});
|
|
128
|
+
const sessionStateEventSchema = z.object({
|
|
129
|
+
state: tolerantStringEnum(AgentSessionState),
|
|
130
|
+
turnId: nullableString(),
|
|
131
|
+
stopReason: nullableString()
|
|
132
|
+
});
|
|
133
|
+
const createSessionResponseSchema = z.object({
|
|
134
|
+
session: sessionSchema,
|
|
135
|
+
turn: promptAcceptedSchema.nullable().default(null)
|
|
136
|
+
});
|
|
137
|
+
const FIRST_ACP_FRAME_SEQ = 1;
|
|
138
|
+
const sessionFramesPageSchema = z.object({
|
|
139
|
+
frames: z.array(acpFrameEventSchema),
|
|
140
|
+
headSeq: z.number().default(0),
|
|
141
|
+
hasMore: z.boolean().default(false)
|
|
142
|
+
});
|
|
143
|
+
const pendingRequestListSchema = z.object({
|
|
144
|
+
pending: z.array(pendingRequestSchema),
|
|
145
|
+
/** Pass as `cursor` for the next (older) page; null on the last page. */
|
|
146
|
+
nextCursor: nullableString()
|
|
147
|
+
});
|
|
148
|
+
const respondPendingResponseSchema = z.object({ resolved: z.boolean() });
|
|
149
|
+
const createSessionRequestSchema = z.strictObject({
|
|
150
|
+
/** Agent slug or id. */
|
|
151
|
+
agent: z.string().min(1),
|
|
152
|
+
/** An immutable revision for author test sessions; requires agents:write. */
|
|
153
|
+
revisionId: z.string().min(1).optional(),
|
|
154
|
+
message: contentInputSchema.optional(),
|
|
155
|
+
turnPolicy: z.enum(AgentTurnPolicy).optional(),
|
|
156
|
+
idempotencyKey: z.string().min(1).max(200).optional(),
|
|
157
|
+
title: z.string().max(200).optional(),
|
|
158
|
+
meta: jsonObjectSchema.optional(),
|
|
159
|
+
/** The client's clock when the person submitted `message` (prompt-to-inference trace). */
|
|
160
|
+
clientSubmittedAtMs: z.number().int().nonnegative().optional()
|
|
161
|
+
});
|
|
162
|
+
const forkSessionRequestSchema = z.strictObject({
|
|
163
|
+
idempotencyKey: z.string().min(1).max(200),
|
|
164
|
+
title: z.string().max(200).optional()
|
|
165
|
+
});
|
|
166
|
+
const promptSessionRequestSchema = z.strictObject({
|
|
167
|
+
content: contentInputSchema,
|
|
168
|
+
turnPolicy: z.enum(AgentTurnPolicy).optional(),
|
|
169
|
+
idempotencyKey: z.string().min(1).max(200),
|
|
170
|
+
meta: jsonObjectSchema.optional(),
|
|
171
|
+
/** The client's clock when the person submitted (prompt-to-inference trace). */
|
|
172
|
+
clientSubmittedAtMs: z.number().int().nonnegative().optional()
|
|
173
|
+
});
|
|
174
|
+
const observeSessionRequestSchema = z.strictObject({
|
|
175
|
+
content: contentInputSchema,
|
|
176
|
+
idempotencyKey: z.string().min(1).max(200).optional(),
|
|
177
|
+
/** The observe's `_meta` (e.g. `"final.ai".author`), as on prompt. */
|
|
178
|
+
meta: jsonObjectSchema.optional()
|
|
179
|
+
});
|
|
180
|
+
const cancelRequestSchema = z.strictObject({
|
|
181
|
+
reason: z.string().max(500).optional()
|
|
182
|
+
});
|
|
183
|
+
const cancelConversationRequestSchema = cancelRequestSchema.extend({
|
|
184
|
+
/** Retry the same Stop without interrupting messages posted after this sequence. */
|
|
185
|
+
throughMessageSeq: z.number().int().nonnegative().optional()
|
|
186
|
+
});
|
|
187
|
+
const pendingOutcomeInputSchema = z.union([
|
|
188
|
+
z.strictObject({ outcome: z.literal("selected"), optionId: z.string().min(1) }),
|
|
189
|
+
z.strictObject({ outcome: z.literal("cancelled") }),
|
|
190
|
+
z.strictObject({ action: z.literal("accept"), content: jsonObjectSchema.optional() }),
|
|
191
|
+
z.strictObject({ action: z.literal("decline") }),
|
|
192
|
+
z.strictObject({ action: z.literal("cancel") })
|
|
193
|
+
]);
|
|
194
|
+
const respondPendingRequestSchema = z.strictObject({
|
|
195
|
+
pendingId: z.string().min(1),
|
|
196
|
+
outcome: pendingOutcomeInputSchema
|
|
197
|
+
});
|
|
198
|
+
const setConfigOptionRequestSchema = z.strictObject({
|
|
199
|
+
configId: z.string().min(1),
|
|
200
|
+
value: jsonValueSchema
|
|
201
|
+
});
|
|
202
|
+
const listPendingQuerySchema = z.strictObject({
|
|
203
|
+
cursor: z.string().optional(),
|
|
204
|
+
limit: z.coerce.number().int().positive().max(200).optional()
|
|
205
|
+
});
|
|
206
|
+
const sessionFramesQuerySchema = z.strictObject({
|
|
207
|
+
fromSeq: z.coerce.number().int().nonnegative().default(0),
|
|
208
|
+
limit: z.coerce.number().int().positive().max(1e3).optional()
|
|
209
|
+
});
|
|
210
|
+
export {
|
|
211
|
+
FIRST_ACP_FRAME_SEQ,
|
|
212
|
+
acpFrameEventSchema,
|
|
213
|
+
acpLiveFrameEventSchema,
|
|
214
|
+
acpLiveResetEventSchema,
|
|
215
|
+
acpPendingEventSchema,
|
|
216
|
+
acpPreviewEventSchema,
|
|
217
|
+
cancelConversationRequestSchema,
|
|
218
|
+
cancelRequestSchema,
|
|
219
|
+
createSessionRequestSchema,
|
|
220
|
+
createSessionResponseSchema,
|
|
221
|
+
forkSessionRequestSchema,
|
|
222
|
+
listPendingQuerySchema,
|
|
223
|
+
observeSessionRequestSchema,
|
|
224
|
+
pendingOutcomeInputSchema,
|
|
225
|
+
pendingRequestDetailSchema,
|
|
226
|
+
pendingRequestListSchema,
|
|
227
|
+
pendingRequestSchema,
|
|
228
|
+
permissionOptionSchema,
|
|
229
|
+
promptAcceptedSchema,
|
|
230
|
+
promptSessionRequestSchema,
|
|
231
|
+
respondPendingRequestSchema,
|
|
232
|
+
respondPendingResponseSchema,
|
|
233
|
+
sessionConfigOptionSchema,
|
|
234
|
+
sessionFramesPageSchema,
|
|
235
|
+
sessionFramesQuerySchema,
|
|
236
|
+
sessionManifestSchema,
|
|
237
|
+
sessionSchema,
|
|
238
|
+
sessionStateEventSchema,
|
|
239
|
+
setConfigOptionRequestSchema,
|
|
240
|
+
turnSchema
|
|
241
|
+
};
|
|
242
|
+
//# sourceMappingURL=sessions.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/agent-platform/sessions.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\n\nimport { jsonObjectSchema, jsonValueSchema } from \"../json.mjs\";\n\nimport { tolerantStringEnum } from \"../tolerance.mjs\";\n\nimport { acpWireMessageSchema, contentInputSchema, nullableNumber, nullableString } from \"./common.mjs\";\n\nimport {\n AcpFrameDirection,\n AcpPreviewKind,\n AgentSessionState,\n AgentTurnPolicy,\n PendingEventState,\n PendingRequestKind,\n} from \"./enums.mjs\";\n\n// Sessions: direct ACP use of an agent (`/api/v1/sessions`) and the session\n// realtime topic `agent.session:<sessionId>`.\n\n/**\n * One ACP session config option (model, thought level, mode, ...). ACP v2 keys\n * options by `configId`; `id` is the older spelling. Every other field (type,\n * category, options) is kept loosely for clients to read.\n */\nexport const sessionConfigOptionSchema = z.looseObject({\n id: z.string().optional(),\n configId: z.string().optional(),\n name: z.string().optional(),\n category: z.string().nullable().optional(),\n currentValue: jsonValueSchema.optional(),\n});\n\nexport const sessionSchema = z.object({\n id: z.string(),\n organizationId: z.string(),\n agentId: z.string(),\n revisionId: nullableString(),\n ownerUserId: nullableString(),\n conversationId: nullableString(),\n participantId: nullableString(),\n state: tolerantStringEnum(AgentSessionState),\n turnPolicy: tolerantStringEnum(AgentTurnPolicy),\n title: nullableString(),\n /** Seq of the newest logged frame; 0 before the first frame. */\n headSeq: z.number().default(0),\n configOptions: z.array(sessionConfigOptionSchema).default([]),\n lastPromptAt: nullableString(),\n closedAt: nullableString(),\n createdAt: z.string(),\n updatedAt: nullableString(),\n});\n\nexport type AgentSessionIface = z.infer<typeof sessionSchema>;\n\n/**\n * `GET /v1/sessions/:id/manifest`: what the session was given: the\n * revision's manifest with its dynamic slots resolved, and the resolver\n * report (each slot's resolved value, compatibility notes). Null fields\n * before the session's first open resolved them.\n */\nexport const sessionManifestSchema = z.object({\n sessionId: z.string(),\n revisionId: nullableString(),\n resolvedAt: nullableString(),\n manifest: jsonObjectSchema.nullable().default(null),\n report: jsonObjectSchema.nullable().default(null),\n});\n\nexport type SessionManifestIface = z.infer<typeof sessionManifestSchema>;\n\nexport const turnSchema = z.object({\n id: z.string(),\n sessionId: z.string(),\n promptMessageId: nullableString(),\n startedAt: z.string(),\n endedAt: nullableString(),\n stopReason: nullableString(),\n fromSeq: nullableNumber(),\n toSeq: nullableNumber(),\n inputTokens: nullableNumber(),\n outputTokens: nullableNumber(),\n});\n\nexport type AgentTurnIface = z.infer<typeof turnSchema>;\n\n/** A prompt the session accepted (ACP insertion semantics: not the end of the turn). */\nexport const promptAcceptedSchema = z.object({\n messageId: z.string(),\n turnId: z.string(),\n /** Seq of the logged `session/prompt` frame; a turn-scoped stream starts here. */\n fromSeq: nullableNumber(),\n});\n\nexport type PromptAcceptedIface = z.infer<typeof promptAcceptedSchema>;\n\n/** One logged ACP frame: the `acp.frame` realtime payload and a replay row. */\nexport const acpFrameEventSchema = z.object({\n seq: z.number(),\n frame: acpWireMessageSchema,\n direction: tolerantStringEnum(AcpFrameDirection),\n at: nullableString(),\n /**\n * The open pending request an agent request frame (`session/request_permission`,\n * `elicitation/create`) raised: answer it with `respond({ pendingId })`. Replay\n * pages set it; live frames precede their pending request, so the SDK joins\n * them with the session's `acp.pending` events.\n */\n pendingId: nullableString(),\n});\n\nexport type AcpFrameEventIface = z.infer<typeof acpFrameEventSchema>;\n\n/** Provisional full frame; `streamId` scopes its seq until the durable stream confirms it. */\nexport const acpLiveFrameEventSchema = acpFrameEventSchema.extend({ streamId: z.string() });\n\nexport type AcpLiveFrameEventIface = z.infer<typeof acpLiveFrameEventSchema>;\n\n/** Discard provisional state after a lost writer/stream; null means the durable head is unknown. */\nexport const acpLiveResetEventSchema = z.object({\n streamId: nullableString(),\n throughSeq: nullableNumber(),\n reason: nullableString(),\n});\n\nexport type AcpLiveResetEventIface = z.infer<typeof acpLiveResetEventSchema>;\n\n/** `acp.preview`: low-latency text ahead of the durable frames (voice, typing previews). */\nexport const acpPreviewEventSchema = z.object({\n seq: z.number(),\n text: z.string(),\n // Not `kind`: realtime events are flattened under the envelope's kind.\n previewKind: tolerantStringEnum(AcpPreviewKind).nullable().default(null),\n messageId: nullableString(),\n turnId: nullableString(),\n});\n\nexport type AcpPreviewEventIface = z.infer<typeof acpPreviewEventSchema>;\n\nexport const permissionOptionSchema = z.object({\n optionId: z.string(),\n name: z.string(),\n // ACP `PermissionOptionKind` (allow_once, allow_always, reject_once, ...); open.\n kind: nullableString(),\n});\n\nexport type PermissionOptionIface = z.infer<typeof permissionOptionSchema>;\n\nexport const pendingRequestDetailSchema = z.object({\n title: nullableString(),\n body: nullableString(),\n options: z.array(permissionOptionSchema).default([]),\n /** Elicitation `requestedSchema` (form mode). */\n schema: jsonValueSchema.nullable().default(null),\n /** Elicitation mode (`form`, `url`); open. */\n mode: nullableString(),\n url: nullableString(),\n toolCall: jsonValueSchema.nullable().default(null),\n});\n\nexport const pendingRequestSchema = z.object({\n id: z.string(),\n sessionId: z.string(),\n turnId: nullableString(),\n conversationId: nullableString(),\n kind: tolerantStringEnum(PendingRequestKind),\n request: pendingRequestDetailSchema,\n audienceParticipantIds: z.array(z.string()).default([]),\n audienceUserIds: z.array(z.string()).default([]),\n logSeq: nullableNumber(),\n createdAt: nullableString(),\n expiresAt: nullableString(),\n resolvedAt: nullableString(),\n resolvedByUserId: nullableString(),\n outcome: jsonValueSchema.nullable().default(null),\n});\n\nexport type PendingRequestIface = z.infer<typeof pendingRequestSchema>;\n\nexport const acpPendingEventSchema = z.object({\n pending: pendingRequestSchema,\n state: tolerantStringEnum(PendingEventState),\n});\n\nexport type AcpPendingEventIface = z.infer<typeof acpPendingEventSchema>;\n\nexport const sessionStateEventSchema = z.object({\n state: tolerantStringEnum(AgentSessionState),\n turnId: nullableString(),\n stopReason: nullableString(),\n});\n\nexport type SessionStateEventIface = z.infer<typeof sessionStateEventSchema>;\n\nexport const createSessionResponseSchema = z.object({\n session: sessionSchema,\n turn: promptAcceptedSchema.nullable().default(null),\n});\n\nexport type CreateSessionResponseIface = z.infer<typeof createSessionResponseSchema>;\n\n/** Seq of a session's first logged frame; the log is dense from here. */\nexport const FIRST_ACP_FRAME_SEQ = 1;\n\n/**\n * `GET /sessions/:id/frames?fromSeq&limit`: `fromSeq` is inclusive and clamped\n * to `FIRST_ACP_FRAME_SEQ`; `hasMore` is set while the page is full and ends\n * before `headSeq`.\n */\nexport const sessionFramesPageSchema = z.object({\n frames: z.array(acpFrameEventSchema),\n headSeq: z.number().default(0),\n hasMore: z.boolean().default(false),\n});\n\nexport type SessionFramesPageIface = z.infer<typeof sessionFramesPageSchema>;\n\nexport const pendingRequestListSchema = z.object({\n pending: z.array(pendingRequestSchema),\n /** Pass as `cursor` for the next (older) page; null on the last page. */\n nextCursor: nullableString(),\n});\n\nexport type PendingRequestListIface = z.infer<typeof pendingRequestListSchema>;\n\nexport const respondPendingResponseSchema = z.object({ resolved: z.boolean() });\n\nexport type RespondPendingResponseIface = z.infer<typeof respondPendingResponseSchema>;\n\n// Client-to-server requests.\n\nexport const createSessionRequestSchema = z.strictObject({\n /** Agent slug or id. */\n agent: z.string().min(1),\n /** An immutable revision for author test sessions; requires agents:write. */\n revisionId: z.string().min(1).optional(),\n message: contentInputSchema.optional(),\n turnPolicy: z.enum(AgentTurnPolicy).optional(),\n idempotencyKey: z.string().min(1).max(200).optional(),\n title: z.string().max(200).optional(),\n meta: jsonObjectSchema.optional(),\n /** The client's clock when the person submitted `message` (prompt-to-inference trace). */\n clientSubmittedAtMs: z.number().int().nonnegative().optional(),\n});\n\nexport type CreateSessionRequestIface = z.infer<typeof createSessionRequestSchema>;\n\nexport const forkSessionRequestSchema = z.strictObject({\n idempotencyKey: z.string().min(1).max(200),\n title: z.string().max(200).optional(),\n});\n\nexport type ForkSessionRequestIface = z.infer<typeof forkSessionRequestSchema>;\n\nexport const promptSessionRequestSchema = z.strictObject({\n content: contentInputSchema,\n turnPolicy: z.enum(AgentTurnPolicy).optional(),\n idempotencyKey: z.string().min(1).max(200),\n meta: jsonObjectSchema.optional(),\n /** The client's clock when the person submitted (prompt-to-inference trace). */\n clientSubmittedAtMs: z.number().int().nonnegative().optional(),\n});\n\nexport type PromptSessionRequestIface = z.infer<typeof promptSessionRequestSchema>;\n\nexport const observeSessionRequestSchema = z.strictObject({\n content: contentInputSchema,\n idempotencyKey: z.string().min(1).max(200).optional(),\n /** The observe's `_meta` (e.g. `\"final.ai\".author`), as on prompt. */\n meta: jsonObjectSchema.optional(),\n});\n\nexport const cancelRequestSchema = z.strictObject({\n reason: z.string().max(500).optional(),\n});\n\nexport const cancelConversationRequestSchema = cancelRequestSchema.extend({\n /** Retry the same Stop without interrupting messages posted after this sequence. */\n throughMessageSeq: z.number().int().nonnegative().optional(),\n});\n\n/** ACP outcomes: `session/request_permission` and `elicitation/create` responses. */\nexport const pendingOutcomeInputSchema = z.union([\n z.strictObject({ outcome: z.literal('selected'), optionId: z.string().min(1) }),\n z.strictObject({ outcome: z.literal('cancelled') }),\n z.strictObject({ action: z.literal('accept'), content: jsonObjectSchema.optional() }),\n z.strictObject({ action: z.literal('decline') }),\n z.strictObject({ action: z.literal('cancel') }),\n]);\n\nexport type PendingOutcomeInput = z.infer<typeof pendingOutcomeInputSchema>;\n\nexport const respondPendingRequestSchema = z.strictObject({\n pendingId: z.string().min(1),\n outcome: pendingOutcomeInputSchema,\n});\n\nexport type RespondPendingRequestIface = z.infer<typeof respondPendingRequestSchema>;\n\nexport const setConfigOptionRequestSchema = z.strictObject({\n configId: z.string().min(1),\n value: jsonValueSchema,\n});\n\n/** `GET /pending`: newest first; `cursor` is a previous page's `nextCursor`. */\nexport const listPendingQuerySchema = z.strictObject({\n cursor: z.string().optional(),\n limit: z.coerce.number().int().positive().max(200).optional(),\n});\n\nexport const sessionFramesQuerySchema = z.strictObject({\n fromSeq: z.coerce.number().int().nonnegative().default(0),\n limit: z.coerce.number().int().positive().max(1000).optional(),\n});\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AAEnB,SAAS,kBAAkB,uBAAuB;AAElD,SAAS,0BAA0B;AAEnC,SAAS,sBAAsB,oBAAoB,gBAAgB,sBAAsB;AAEzF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUA,MAAM,4BAA4B,EAAE,YAAY;AAAA,EACrD,IAAI,EAAE,OAAO,EAAE,SAAS;AAAA,EACxB,UAAU,EAAE,OAAO,EAAE,SAAS;AAAA,EAC9B,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACzC,cAAc,gBAAgB,SAAS;AACzC,CAAC;AAEM,MAAM,gBAAgB,EAAE,OAAO;AAAA,EACpC,IAAI,EAAE,OAAO;AAAA,EACb,gBAAgB,EAAE,OAAO;AAAA,EACzB,SAAS,EAAE,OAAO;AAAA,EAClB,YAAY,eAAe;AAAA,EAC3B,aAAa,eAA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
+
const base58Encode = (bytes) => {
|
|
7
|
+
let num = 0n;
|
|
8
|
+
for (const b of bytes) {
|
|
9
|
+
num = num * 256n + BigInt(b);
|
|
10
|
+
}
|
|
11
|
+
let out = "";
|
|
12
|
+
while (num > 0n) {
|
|
13
|
+
out = ALPHABET[Number(num % BASE)] + out;
|
|
14
|
+
num /= BASE;
|
|
15
|
+
}
|
|
16
|
+
for (const b of bytes) {
|
|
17
|
+
if (b !== 0) break;
|
|
18
|
+
out = "1" + out;
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
};
|
|
22
|
+
const base58Decode = (str) => {
|
|
23
|
+
let num = 0n;
|
|
24
|
+
for (const ch of str) {
|
|
25
|
+
const value = VALUE_BY_CHAR[ch];
|
|
26
|
+
if (value === void 0) {
|
|
27
|
+
throw new Error(`invalid base58 character: ${ch}`);
|
|
28
|
+
}
|
|
29
|
+
num = num * BASE + BigInt(value);
|
|
30
|
+
}
|
|
31
|
+
const out = [];
|
|
32
|
+
while (num > 0n) {
|
|
33
|
+
out.unshift(Number(num % 256n));
|
|
34
|
+
num /= 256n;
|
|
35
|
+
}
|
|
36
|
+
for (const ch of str) {
|
|
37
|
+
if (ch !== "1") break;
|
|
38
|
+
out.unshift(0);
|
|
39
|
+
}
|
|
40
|
+
return new Uint8Array(out);
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
base58Decode,
|
|
44
|
+
base58Encode
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=base58.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/base58.ts"],
|
|
4
|
+
"sourcesContent": ["// Bitcoin-style base58: base64 without the ambiguous characters (0 O I l) and\n// without +/. Operates on raw bytes. Used to encode the 16 bytes of a uuid into\n// a short, URL-safe, copy-paste-safe token.\n//\n// We roll our own (rather than depend on a base58 package) because the surface\n// is tiny and fully pinned by the canonical test vectors in base58.test.ts.\n// This is not crypto: no checksum, no secrets, no constant-time requirement.\n\nconst ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\nconst BASE = 58n;\n\n// char -> value, for decode. Index into ALPHABET reversed.\nconst VALUE_BY_CHAR: Record<string, number> = Object.fromEntries(\n Array.from(ALPHABET, (ch, i) => [ch, i]),\n);\n\nexport const base58Encode = (bytes: Uint8Array): string => {\n let num = 0n;\n for (const b of bytes) {\n num = num * 256n + BigInt(b);\n }\n let out = '';\n while (num > 0n) {\n out = ALPHABET[Number(num % BASE)] + out;\n num /= BASE;\n }\n // base58 is not pure base conversion: a bignum can't distinguish a leading\n // 0x00 byte from no byte, so each leading zero byte maps to a leading '1'.\n for (const b of bytes) {\n if (b !== 0) break;\n out = '1' + out;\n }\n return out;\n};\n\nexport const base58Decode = (str: string): Uint8Array => {\n let num = 0n;\n for (const ch of str) {\n const value = VALUE_BY_CHAR[ch];\n if (value === undefined) {\n throw new Error(`invalid base58 character: ${ch}`);\n }\n num = num * BASE + BigInt(value);\n }\n const out: number[] = [];\n while (num > 0n) {\n out.unshift(Number(num % 256n));\n num /= 256n;\n }\n // Inverse of the encode side: each leading '1' restores a leading 0x00 byte.\n for (const ch of str) {\n if (ch !== '1') break;\n out.unshift(0);\n }\n return new Uint8Array(out);\n};\n"],
|
|
5
|
+
"mappings": "AAQA,MAAM,WAAW;AACjB,MAAM,OAAO;AAGb,MAAM,gBAAwC,OAAO;AAAA,EACnD,MAAM,KAAK,UAAU,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;AACzC;AAEO,MAAM,eAAe,CAAC,UAA8B;AACzD,MAAI,MAAM;AACV,aAAW,KAAK,OAAO;AACrB,UAAM,MAAM,OAAO,OAAO,CAAC;AAAA,EAC7B;AACA,MAAI,MAAM;AACV,SAAO,MAAM,IAAI;AACf,UAAM,SAAS,OAAO,MAAM,IAAI,CAAC,IAAI;AACrC,WAAO;AAAA,EACT;AAGA,aAAW,KAAK,OAAO;AACrB,QAAI,MAAM,EAAG;AACb,UAAM,MAAM;AAAA,EACd;AACA,SAAO;AACT;AAEO,MAAM,eAAe,CAAC,QAA4B;AACvD,MAAI,MAAM;AACV,aAAW,MAAM,KAAK;AACpB,UAAM,QAAQ,cAAc,EAAE;AAC9B,QAAI,UAAU,QAAW;AACvB,YAAM,IAAI,MAAM,6BAA6B,EAAE,EAAE;AAAA,IACnD;AACA,UAAM,MAAM,OAAO,OAAO,KAAK;AAAA,EACjC;AACA,QAAM,MAAgB,CAAC;AACvB,SAAO,MAAM,IAAI;AACf,QAAI,QAAQ,OAAO,MAAM,IAAI,CAAC;AAC9B,WAAO;AAAA,EACT;AAEA,aAAW,MAAM,KAAK;AACpB,QAAI,OAAO,IAAK;AAChB,QAAI,QAAQ,CAAC;AAAA,EACf;AACA,SAAO,IAAI,WAAW,GAAG;AAC3B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./json.mjs\";\nexport * from \"./json-rpc.mjs\";\nexport * from \"./process-inspection.mjs\";\nexport * from \"./tolerance.mjs\";\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const jsonRpcIdSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>;
|
|
3
|
+
export declare const jsonRpcMessageSchema: z.ZodObject<{
|
|
4
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
5
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
6
|
+
method: z.ZodOptional<z.ZodString>;
|
|
7
|
+
params: z.ZodOptional<z.ZodType<import("./json.mjs").JsonValue, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonValue, unknown>>>;
|
|
8
|
+
result: z.ZodOptional<z.ZodType<import("./json.mjs").JsonValue, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonValue, unknown>>>;
|
|
9
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
code: z.ZodNumber;
|
|
11
|
+
message: z.ZodString;
|
|
12
|
+
data: z.ZodOptional<z.ZodType<import("./json.mjs").JsonValue, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonValue, unknown>>>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type JsonRpcMessage = z.infer<typeof jsonRpcMessageSchema>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { jsonValueSchema } from "./json.mjs";
|
|
3
|
+
const jsonRpcIdSchema = z.union([z.string(), z.number(), z.null()]);
|
|
4
|
+
const jsonRpcMessageSchema = z.object({
|
|
5
|
+
jsonrpc: z.literal("2.0"),
|
|
6
|
+
id: jsonRpcIdSchema.optional(),
|
|
7
|
+
method: z.string().min(1).optional(),
|
|
8
|
+
params: jsonValueSchema.optional(),
|
|
9
|
+
result: jsonValueSchema.optional(),
|
|
10
|
+
error: z.object({
|
|
11
|
+
code: z.number().int(),
|
|
12
|
+
message: z.string(),
|
|
13
|
+
data: jsonValueSchema.optional()
|
|
14
|
+
}).optional()
|
|
15
|
+
});
|
|
16
|
+
export {
|
|
17
|
+
jsonRpcIdSchema,
|
|
18
|
+
jsonRpcMessageSchema
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=json-rpc.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/json-rpc.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\n\nimport { jsonValueSchema } from \"./json.mjs\";\n\nexport const jsonRpcIdSchema = z.union([z.string(), z.number(), z.null()]);\n\nexport const jsonRpcMessageSchema = z.object({\n jsonrpc: z.literal('2.0'),\n id: jsonRpcIdSchema.optional(),\n method: z.string().min(1).optional(),\n params: jsonValueSchema.optional(),\n result: jsonValueSchema.optional(),\n error: z\n .object({\n code: z.number().int(),\n message: z.string(),\n data: jsonValueSchema.optional(),\n })\n .optional(),\n});\n\nexport type JsonRpcMessage = z.infer<typeof jsonRpcMessageSchema>;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AAEnB,SAAS,uBAAuB;AAEzB,MAAM,kBAAkB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC;AAElE,MAAM,uBAAuB,EAAE,OAAO;AAAA,EAC3C,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,IAAI,gBAAgB,SAAS;AAAA,EAC7B,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACnC,QAAQ,gBAAgB,SAAS;AAAA,EACjC,QAAQ,gBAAgB,SAAS;AAAA,EACjC,OAAO,EACJ,OAAO;AAAA,IACN,MAAM,EAAE,OAAO,EAAE,IAAI;AAAA,IACrB,SAAS,EAAE,OAAO;AAAA,IAClB,MAAM,gBAAgB,SAAS;AAAA,EACjC,CAAC,EACA,SAAS;AACd,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export type JsonValue = boolean | number | string | null | JsonObjectIface | JsonValue[];
|
|
3
|
+
export interface JsonObjectIface {
|
|
4
|
+
[key: string]: JsonValue | undefined;
|
|
5
|
+
}
|
|
6
|
+
export declare const jsonValueSchema: z.ZodType<JsonValue>;
|
|
7
|
+
export declare const jsonObjectSchema: z.ZodType<JsonObjectIface>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/json.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\n\nexport type JsonValue = boolean | number | string | null | JsonObjectIface | JsonValue[];\n\nexport interface JsonObjectIface {\n [key: string]: JsonValue | undefined;\n}\n\nexport const jsonValueSchema: z.ZodType<JsonValue> = z.json();\n\nexport const jsonObjectSchema: z.ZodType<JsonObjectIface> = z.record(\n z.string(),\n jsonValueSchema.optional(),\n);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AAQZ,MAAM,kBAAwC,EAAE,KAAK;AAErD,MAAM,mBAA+C,EAAE;AAAA,EAC5D,EAAE,OAAO;AAAA,EACT,gBAAgB,SAAS;AAC3B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare enum ProcessInspectionOperation {
|
|
3
|
+
Available = "available",
|
|
4
|
+
List = "list",
|
|
5
|
+
Detail = "detail",
|
|
6
|
+
Stop = "stop"
|
|
7
|
+
}
|
|
8
|
+
export declare const processInspectionRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
|
+
operation: z.ZodLiteral<ProcessInspectionOperation.Available>;
|
|
10
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
11
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
12
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
operation: z.ZodLiteral<ProcessInspectionOperation.List>;
|
|
14
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
15
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
16
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
processId: z.ZodString;
|
|
18
|
+
bootId: z.ZodString;
|
|
19
|
+
operation: z.ZodLiteral<ProcessInspectionOperation.Detail>;
|
|
20
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
21
|
+
processId: z.ZodString;
|
|
22
|
+
bootId: z.ZodString;
|
|
23
|
+
operation: z.ZodLiteral<ProcessInspectionOperation.Stop>;
|
|
24
|
+
}, z.core.$strict>], "operation">;
|
|
25
|
+
export type ProcessInspectionRequestIface = z.infer<typeof processInspectionRequestSchema>;
|
|
26
|
+
export declare const inspectedProcessSchema: z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
bootId: z.ZodString;
|
|
29
|
+
command: z.ZodString;
|
|
30
|
+
leaderPid: z.ZodNullable<z.ZodNumber>;
|
|
31
|
+
state: z.ZodString;
|
|
32
|
+
keepsAwake: z.ZodBoolean;
|
|
33
|
+
createdAtMs: z.ZodNumber;
|
|
34
|
+
updatedAtMs: z.ZodNumber;
|
|
35
|
+
endedAtMs: z.ZodNullable<z.ZodNumber>;
|
|
36
|
+
cpuUsec: z.ZodNullable<z.ZodNumber>;
|
|
37
|
+
memoryBytes: z.ZodNullable<z.ZodNumber>;
|
|
38
|
+
memoryPeakBytes: z.ZodNullable<z.ZodNumber>;
|
|
39
|
+
ioReadBytes: z.ZodNullable<z.ZodNumber>;
|
|
40
|
+
ioWriteBytes: z.ZodNullable<z.ZodNumber>;
|
|
41
|
+
processCount: z.ZodNullable<z.ZodNumber>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type InspectedProcessIface = z.infer<typeof inspectedProcessSchema>;
|
|
44
|
+
export declare const inspectedProcessMemberSchema: z.ZodObject<{
|
|
45
|
+
pid: z.ZodNumber;
|
|
46
|
+
startTicks: z.ZodNullable<z.ZodNumber>;
|
|
47
|
+
ppid: z.ZodNumber;
|
|
48
|
+
executable: z.ZodString;
|
|
49
|
+
argumentPreview: z.ZodString;
|
|
50
|
+
state: z.ZodString;
|
|
51
|
+
startedAtMs: z.ZodNullable<z.ZodNumber>;
|
|
52
|
+
cpuUsec: z.ZodNullable<z.ZodNumber>;
|
|
53
|
+
memoryBytes: z.ZodNullable<z.ZodNumber>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export declare const processInspectionPageSchema: z.ZodObject<{
|
|
56
|
+
status: z.ZodString;
|
|
57
|
+
processes: z.ZodArray<z.ZodObject<{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
bootId: z.ZodString;
|
|
60
|
+
command: z.ZodString;
|
|
61
|
+
leaderPid: z.ZodNullable<z.ZodNumber>;
|
|
62
|
+
state: z.ZodString;
|
|
63
|
+
keepsAwake: z.ZodBoolean;
|
|
64
|
+
createdAtMs: z.ZodNumber;
|
|
65
|
+
updatedAtMs: z.ZodNumber;
|
|
66
|
+
endedAtMs: z.ZodNullable<z.ZodNumber>;
|
|
67
|
+
cpuUsec: z.ZodNullable<z.ZodNumber>;
|
|
68
|
+
memoryBytes: z.ZodNullable<z.ZodNumber>;
|
|
69
|
+
memoryPeakBytes: z.ZodNullable<z.ZodNumber>;
|
|
70
|
+
ioReadBytes: z.ZodNullable<z.ZodNumber>;
|
|
71
|
+
ioWriteBytes: z.ZodNullable<z.ZodNumber>;
|
|
72
|
+
processCount: z.ZodNullable<z.ZodNumber>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export declare const processInspectionDetailSchema: z.ZodObject<{
|
|
77
|
+
process: z.ZodObject<{
|
|
78
|
+
id: z.ZodString;
|
|
79
|
+
bootId: z.ZodString;
|
|
80
|
+
command: z.ZodString;
|
|
81
|
+
leaderPid: z.ZodNullable<z.ZodNumber>;
|
|
82
|
+
state: z.ZodString;
|
|
83
|
+
keepsAwake: z.ZodBoolean;
|
|
84
|
+
createdAtMs: z.ZodNumber;
|
|
85
|
+
updatedAtMs: z.ZodNumber;
|
|
86
|
+
endedAtMs: z.ZodNullable<z.ZodNumber>;
|
|
87
|
+
cpuUsec: z.ZodNullable<z.ZodNumber>;
|
|
88
|
+
memoryBytes: z.ZodNullable<z.ZodNumber>;
|
|
89
|
+
memoryPeakBytes: z.ZodNullable<z.ZodNumber>;
|
|
90
|
+
ioReadBytes: z.ZodNullable<z.ZodNumber>;
|
|
91
|
+
ioWriteBytes: z.ZodNullable<z.ZodNumber>;
|
|
92
|
+
processCount: z.ZodNullable<z.ZodNumber>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
descendants: z.ZodArray<z.ZodObject<{
|
|
95
|
+
pid: z.ZodNumber;
|
|
96
|
+
startTicks: z.ZodNullable<z.ZodNumber>;
|
|
97
|
+
ppid: z.ZodNumber;
|
|
98
|
+
executable: z.ZodString;
|
|
99
|
+
argumentPreview: z.ZodString;
|
|
100
|
+
state: z.ZodString;
|
|
101
|
+
startedAtMs: z.ZodNullable<z.ZodNumber>;
|
|
102
|
+
cpuUsec: z.ZodNullable<z.ZodNumber>;
|
|
103
|
+
memoryBytes: z.ZodNullable<z.ZodNumber>;
|
|
104
|
+
}, z.core.$strip>>;
|
|
105
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
106
|
+
logs: z.ZodObject<{
|
|
107
|
+
stdout: z.ZodString;
|
|
108
|
+
stderr: z.ZodString;
|
|
109
|
+
stdoutTruncated: z.ZodBoolean;
|
|
110
|
+
stderrTruncated: z.ZodBoolean;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
export declare const processInspectionResultSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
114
|
+
available: z.ZodBoolean;
|
|
115
|
+
canStop: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
117
|
+
status: z.ZodString;
|
|
118
|
+
processes: z.ZodArray<z.ZodObject<{
|
|
119
|
+
id: z.ZodString;
|
|
120
|
+
bootId: z.ZodString;
|
|
121
|
+
command: z.ZodString;
|
|
122
|
+
leaderPid: z.ZodNullable<z.ZodNumber>;
|
|
123
|
+
state: z.ZodString;
|
|
124
|
+
keepsAwake: z.ZodBoolean;
|
|
125
|
+
createdAtMs: z.ZodNumber;
|
|
126
|
+
updatedAtMs: z.ZodNumber;
|
|
127
|
+
endedAtMs: z.ZodNullable<z.ZodNumber>;
|
|
128
|
+
cpuUsec: z.ZodNullable<z.ZodNumber>;
|
|
129
|
+
memoryBytes: z.ZodNullable<z.ZodNumber>;
|
|
130
|
+
memoryPeakBytes: z.ZodNullable<z.ZodNumber>;
|
|
131
|
+
ioReadBytes: z.ZodNullable<z.ZodNumber>;
|
|
132
|
+
ioWriteBytes: z.ZodNullable<z.ZodNumber>;
|
|
133
|
+
processCount: z.ZodNullable<z.ZodNumber>;
|
|
134
|
+
}, z.core.$strip>>;
|
|
135
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
136
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
137
|
+
process: z.ZodObject<{
|
|
138
|
+
id: z.ZodString;
|
|
139
|
+
bootId: z.ZodString;
|
|
140
|
+
command: z.ZodString;
|
|
141
|
+
leaderPid: z.ZodNullable<z.ZodNumber>;
|
|
142
|
+
state: z.ZodString;
|
|
143
|
+
keepsAwake: z.ZodBoolean;
|
|
144
|
+
createdAtMs: z.ZodNumber;
|
|
145
|
+
updatedAtMs: z.ZodNumber;
|
|
146
|
+
endedAtMs: z.ZodNullable<z.ZodNumber>;
|
|
147
|
+
cpuUsec: z.ZodNullable<z.ZodNumber>;
|
|
148
|
+
memoryBytes: z.ZodNullable<z.ZodNumber>;
|
|
149
|
+
memoryPeakBytes: z.ZodNullable<z.ZodNumber>;
|
|
150
|
+
ioReadBytes: z.ZodNullable<z.ZodNumber>;
|
|
151
|
+
ioWriteBytes: z.ZodNullable<z.ZodNumber>;
|
|
152
|
+
processCount: z.ZodNullable<z.ZodNumber>;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
descendants: z.ZodArray<z.ZodObject<{
|
|
155
|
+
pid: z.ZodNumber;
|
|
156
|
+
startTicks: z.ZodNullable<z.ZodNumber>;
|
|
157
|
+
ppid: z.ZodNumber;
|
|
158
|
+
executable: z.ZodString;
|
|
159
|
+
argumentPreview: z.ZodString;
|
|
160
|
+
state: z.ZodString;
|
|
161
|
+
startedAtMs: z.ZodNullable<z.ZodNumber>;
|
|
162
|
+
cpuUsec: z.ZodNullable<z.ZodNumber>;
|
|
163
|
+
memoryBytes: z.ZodNullable<z.ZodNumber>;
|
|
164
|
+
}, z.core.$strip>>;
|
|
165
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
166
|
+
logs: z.ZodObject<{
|
|
167
|
+
stdout: z.ZodString;
|
|
168
|
+
stderr: z.ZodString;
|
|
169
|
+
stdoutTruncated: z.ZodBoolean;
|
|
170
|
+
stderrTruncated: z.ZodBoolean;
|
|
171
|
+
}, z.core.$strip>;
|
|
172
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
173
|
+
stopped: z.ZodBoolean;
|
|
174
|
+
}, z.core.$strip>]>;
|
|
175
|
+
export type ProcessInspectionResultIface = z.infer<typeof processInspectionResultSchema>;
|
|
176
|
+
export type ProcessInspectionPageIface = z.infer<typeof processInspectionPageSchema>;
|
|
177
|
+
export type ProcessInspectionDetailIface = z.infer<typeof processInspectionDetailSchema>;
|