@agentshouse/kit-wire 0.0.0-stage → 0.1.0-c0f6ddeaad2f1

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.
@@ -0,0 +1,207 @@
1
+ import { z } from 'zod';
2
+ export const KIT_CONNECTION_PATH = '/kit/stream';
3
+ export const KIT_CONNECTION_PROTOCOL_PREFIX = 'house.kit.stream.';
4
+ const PROVIDER_SESSION_ID_MAX = 256;
5
+ const EXIT_STATUS_MAX = 255;
6
+ const TERMINAL_SIDE_MAX = 65_535;
7
+ export const KIT_CAUSE = z.string().min(1).max(4096);
8
+ const EXIT_CODE = z.int().min(0).max(EXIT_STATUS_MAX);
9
+ const KEPT_OUTPUT = { output: z.string(), cut: z.boolean() };
10
+ export const KIT_SETTINGS = z.strictObject({
11
+ skills: z.boolean(),
12
+ workspace: z.string().startsWith('/'),
13
+ });
14
+ export const KIT_CALL_RESULT = z.union([
15
+ z.strictObject({ provider_session_id: z.string().min(1).max(PROVIDER_SESSION_ID_MAX) }),
16
+ z.strictObject({ refused: KIT_CAUSE, resume_refused: z.literal(true).optional() }),
17
+ z.strictObject({ exit_code: EXIT_CODE }),
18
+ z.strictObject({ exit_code: EXIT_CODE, ...KEPT_OUTPUT }),
19
+ z.strictObject({ timed_out: z.literal(true), ...KEPT_OUTPUT }),
20
+ z.strictObject({ started: z.literal(true) }),
21
+ z.strictObject({ settings: KIT_SETTINGS }),
22
+ z.strictObject({}),
23
+ ]);
24
+ const CONVERSATION_CALL = {
25
+ type: z.literal('input'),
26
+ input_id: z.uuid(),
27
+ conversation_id: z.uuid(),
28
+ agent_id: z.uuid(),
29
+ provider_session_id: z.string().nullable(),
30
+ };
31
+ const ENVIRONMENT_CALL = {
32
+ type: z.literal('input'),
33
+ input_id: z.uuid(),
34
+ conversation_id: z.null(),
35
+ agent_id: z.null(),
36
+ provider_session_id: z.null(),
37
+ };
38
+ function conversationCall(kind, params) {
39
+ return z.strictObject({ ...CONVERSATION_CALL, kind: z.literal(kind), ...params });
40
+ }
41
+ function environmentCall(kind, params) {
42
+ return z.strictObject({ ...ENVIRONMENT_CALL, kind: z.literal(kind), ...params });
43
+ }
44
+ const AFK = z.literal(true).optional();
45
+ export const SESSION_CHOICE_BYTES_MAX = 128;
46
+ const SESSION_CHOICE = z
47
+ .string()
48
+ .min(1)
49
+ .refine((value) => new TextEncoder().encode(value).length <= SESSION_CHOICE_BYTES_MAX);
50
+ const STARTING_CHOICES = {
51
+ model: SESSION_CHOICE.optional().meta({
52
+ description: "Present only for a conversation with its own model: the model a session this call starts or resumes runs, in the Agent's place.",
53
+ }),
54
+ effort: SESSION_CHOICE.optional().meta({
55
+ description: "Present only for a conversation with its own effort: the effort a session this call starts or resumes runs, in the Agent's place.",
56
+ }),
57
+ };
58
+ export const KIT_CALLS = {
59
+ open: conversationCall('open', { afk: AFK, ...STARTING_CHOICES }),
60
+ kill: conversationCall('kill', {}),
61
+ done: conversationCall('done', {}),
62
+ message: conversationCall('message', {
63
+ message_id: z.uuid(),
64
+ text: z.string(),
65
+ first: z.boolean(),
66
+ at_once: z.literal(true).optional(),
67
+ recent: z.string().optional(),
68
+ afk: AFK,
69
+ ...STARTING_CHOICES,
70
+ }),
71
+ take_out: conversationCall('take_out', { message_id: z.uuid() }),
72
+ interrupt: conversationCall('interrupt', { turn_id: z.uuid() }),
73
+ answer: conversationCall('answer', {
74
+ interaction_id: z.uuid(),
75
+ response: z.unknown(),
76
+ request: z.unknown(),
77
+ ...STARTING_CHOICES,
78
+ }),
79
+ option: conversationCall('option', {
80
+ model: SESSION_CHOICE.optional().meta({
81
+ description: 'Present only for a change of the model: the model the running process takes.',
82
+ }),
83
+ effort: SESSION_CHOICE.optional().meta({
84
+ description: 'Present only for a change of the effort: the effort the running process takes.',
85
+ }),
86
+ }),
87
+ sign_in: environmentCall('sign_in', {
88
+ cli: z.string(),
89
+ ends_in: z.int().nonnegative(),
90
+ api_key: z.literal(true).optional().meta({
91
+ description: "Present only for a sign-in by API key in place of the CLI's own login.",
92
+ }),
93
+ }),
94
+ update: environmentCall('update', { release: z.string() }),
95
+ settings: environmentCall('settings', {
96
+ skills: z.boolean().optional(),
97
+ workspace: z.string().optional(),
98
+ }),
99
+ run_wizard: environmentCall('run_wizard', { script: z.string() }),
100
+ run_function: environmentCall('run_function', {
101
+ script: z.string(),
102
+ input: z.unknown(),
103
+ terminal: z.boolean(),
104
+ time_cap: z.int().positive(),
105
+ output_cap: z.int().positive(),
106
+ }),
107
+ };
108
+ export const KIT_CALL = z.discriminatedUnion('kind', [
109
+ KIT_CALLS.open,
110
+ KIT_CALLS.kill,
111
+ KIT_CALLS.done,
112
+ KIT_CALLS.message,
113
+ KIT_CALLS.take_out,
114
+ KIT_CALLS.interrupt,
115
+ KIT_CALLS.answer,
116
+ KIT_CALLS.option,
117
+ KIT_CALLS.sign_in,
118
+ KIT_CALLS.update,
119
+ KIT_CALLS.settings,
120
+ KIT_CALLS.run_wizard,
121
+ KIT_CALLS.run_function,
122
+ ]);
123
+ const WIZARD = z.uuid();
124
+ const SIDE = z.int().min(1).max(TERMINAL_SIDE_MAX);
125
+ export const HOUSE_ONE_WAY_CALLS = {
126
+ beat: z.strictObject({ type: z.literal('beat') }),
127
+ watching: z.strictObject({ type: z.literal('watching'), watching: z.boolean() }),
128
+ work_available: z.strictObject({
129
+ type: z.literal('work_available'),
130
+ subject: z.literal('agents'),
131
+ }),
132
+ wizard_input: z.strictObject({
133
+ type: z.literal('wizard_input'),
134
+ wizard: WIZARD,
135
+ data: z.string().min(1),
136
+ }),
137
+ wizard_size: z.strictObject({
138
+ type: z.literal('wizard_size'),
139
+ wizard: WIZARD,
140
+ cols: SIDE,
141
+ rows: SIDE,
142
+ }),
143
+ wizard_end: z.strictObject({ type: z.literal('wizard_end'), wizard: WIZARD }),
144
+ refused: z.strictObject({ type: z.literal('refused'), code: z.literal('invalid_message') }),
145
+ };
146
+ const CONVERSATION = { conversation_id: z.uuid() };
147
+ const COMMAND = z.looseObject({
148
+ name: z.string(),
149
+ description: z.string(),
150
+ input: z.looseObject({ hint: z.string() }).nullish(),
151
+ });
152
+ const SELECT_VALUE = z.looseObject({
153
+ value: z.string(),
154
+ name: z.string(),
155
+ description: z.string().nullish(),
156
+ });
157
+ const SELECT_GROUP = z.looseObject({
158
+ group: z.string(),
159
+ name: z.string(),
160
+ options: z.array(SELECT_VALUE),
161
+ });
162
+ const OPTION = {
163
+ id: z.string(),
164
+ name: z.string(),
165
+ description: z.string().nullish(),
166
+ category: z.string().nullish(),
167
+ };
168
+ const SESSION_OPTION = z.discriminatedUnion('type', [
169
+ z.looseObject({
170
+ ...OPTION,
171
+ type: z.literal('select'),
172
+ currentValue: z.string(),
173
+ options: z.union([z.array(SELECT_VALUE), z.array(SELECT_GROUP)]),
174
+ }),
175
+ z.looseObject({ ...OPTION, type: z.literal('boolean'), currentValue: z.boolean() }),
176
+ ]);
177
+ export const STARTING_STEPS = ['transcription', 'session'];
178
+ export const KIT_ONE_WAY_CALLS = {
179
+ turn: z.strictObject({
180
+ type: z.literal('turn'),
181
+ ...CONVERSATION,
182
+ turn_id: z.uuid(),
183
+ operation: z.unknown(),
184
+ }),
185
+ process: z.strictObject({ type: z.literal('process'), ...CONVERSATION, running: z.boolean() }),
186
+ commands: z.strictObject({
187
+ type: z.literal('commands'),
188
+ ...CONVERSATION,
189
+ commands: z.array(COMMAND),
190
+ }),
191
+ options: z.strictObject({
192
+ type: z.literal('options'),
193
+ ...CONVERSATION,
194
+ options: z.array(SESSION_OPTION),
195
+ }),
196
+ starting: z.strictObject({
197
+ type: z.literal('starting'),
198
+ ...CONVERSATION,
199
+ step: z.enum(STARTING_STEPS).nullable(),
200
+ }),
201
+ state: z.strictObject({ type: z.literal('state'), ...CONVERSATION, state: z.unknown() }),
202
+ wizard_output: z.strictObject({
203
+ type: z.literal('wizard_output'),
204
+ wizard: WIZARD,
205
+ data: z.string().min(1),
206
+ }),
207
+ };
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ export declare const ENVIRONMENT_REACHES: readonly ['all', 'all_but_private', 'selected'];
3
+ export type EnvironmentReach = (typeof ENVIRONMENT_REACHES)[number];
4
+ export declare const ENVIRONMENT_ROOM_LIMIT = 256;
5
+ export declare const ENVIRONMENT_ROOM_REFS: z.ZodArray<z.ZodString>;
6
+ export declare const ENVIRONMENT_ROOMS: z.ZodDiscriminatedUnion<[z.ZodObject<{
7
+ reach: z.ZodLiteral<"all">;
8
+ }, z.core.$strict>, z.ZodObject<{
9
+ reach: z.ZodLiteral<"all_but_private">;
10
+ }, z.core.$strict>, z.ZodObject<{
11
+ reach: z.ZodLiteral<"selected">;
12
+ refs: z.ZodArray<z.ZodString>;
13
+ }, z.core.$strict>], "reach">;
14
+ export type EnvironmentRooms = z.infer<typeof ENVIRONMENT_ROOMS>;
15
+ export declare const KIT_ENROLLMENT_ACTS: readonly ['new_environment', 'existing_environment'];
16
+ export type KitEnrollmentAct = (typeof KIT_ENROLLMENT_ACTS)[number];
17
+ export declare const KIT_LOGIN_START: z.ZodObject<{
18
+ act: z.ZodEnum<{
19
+ existing_environment: "existing_environment";
20
+ new_environment: "new_environment";
21
+ }>;
22
+ environment_id: z.ZodOptional<z.ZodUUID>;
23
+ headless: z.ZodOptional<z.ZodLiteral<true>>;
24
+ rooms: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
25
+ reach: z.ZodLiteral<"all">;
26
+ }, z.core.$strict>, z.ZodObject<{
27
+ reach: z.ZodLiteral<"all_but_private">;
28
+ }, z.core.$strict>, z.ZodObject<{
29
+ reach: z.ZodLiteral<"selected">;
30
+ refs: z.ZodArray<z.ZodString>;
31
+ }, z.core.$strict>], "reach">>;
32
+ code_challenge: z.ZodString;
33
+ }, z.core.$strict>;
34
+ export declare const KIT_LOGIN_STARTED: z.ZodObject<{
35
+ start_url: z.ZodURL;
36
+ login: z.ZodUUID;
37
+ }, z.core.$strict>;
38
+ export declare const KIT_LOGIN_POLL: z.ZodUnion<readonly [z.ZodObject<{
39
+ login: z.ZodUUID;
40
+ code_verifier: z.ZodString;
41
+ }, z.core.$strict>, z.ZodObject<{
42
+ code: z.ZodString;
43
+ }, z.core.$strict>]>;
44
+ export declare const KIT_LOGIN_ISSUED: z.ZodObject<{
45
+ credential: z.ZodString;
46
+ environment: z.ZodUUID;
47
+ user: z.ZodUUID;
48
+ headless_credential: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strict>;
50
+ export declare const KIT_LOGIN_PATHS: {
51
+ readonly start: '/kit';
52
+ readonly poll: '/kit/token';
53
+ };
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ export const ENVIRONMENT_REACHES = ['all', 'all_but_private', 'selected'];
3
+ export const ENVIRONMENT_ROOM_LIMIT = 256;
4
+ export const ENVIRONMENT_ROOM_REFS = z
5
+ .array(z.string().min(1))
6
+ .min(1)
7
+ .refine((refs) => new Set(refs).size === refs.length, 'list each Room once');
8
+ export const ENVIRONMENT_ROOMS = z.discriminatedUnion('reach', [
9
+ z.strictObject({ reach: z.literal('all') }),
10
+ z.strictObject({ reach: z.literal('all_but_private') }),
11
+ z.strictObject({
12
+ reach: z.literal('selected'),
13
+ refs: ENVIRONMENT_ROOM_REFS.max(ENVIRONMENT_ROOM_LIMIT),
14
+ }),
15
+ ]);
16
+ export const KIT_ENROLLMENT_ACTS = ['new_environment', 'existing_environment'];
17
+ export const KIT_LOGIN_START = z.strictObject({
18
+ act: z.enum(KIT_ENROLLMENT_ACTS),
19
+ environment_id: z.uuid().optional(),
20
+ headless: z.literal(true).optional(),
21
+ rooms: ENVIRONMENT_ROOMS.optional(),
22
+ code_challenge: z.string().regex(/^[A-Za-z0-9_-]{43}$/),
23
+ });
24
+ export const KIT_LOGIN_STARTED = z.strictObject({ start_url: z.url(), login: z.uuid() });
25
+ export const KIT_LOGIN_POLL = z.union([
26
+ z.strictObject({ login: z.uuid(), code_verifier: z.string().min(43).max(128) }),
27
+ z.strictObject({ code: z.string().max(128) }),
28
+ ]);
29
+ export const KIT_LOGIN_ISSUED = z.strictObject({
30
+ credential: z.string().min(1),
31
+ environment: z.uuid(),
32
+ user: z.uuid(),
33
+ headless_credential: z.string().min(1).optional(),
34
+ });
35
+ export const KIT_LOGIN_PATHS = { start: '/kit', poll: '/kit/token' };
@@ -0,0 +1,8 @@
1
+ export { HOUSE_ONE_WAY_CALLS, KIT_CALL, KIT_CALL_RESULT, KIT_CALLS, KIT_CAUSE, KIT_CONNECTION_PATH, KIT_CONNECTION_PROTOCOL_PREFIX, KIT_ONE_WAY_CALLS, KIT_SETTINGS, SESSION_CHOICE_BYTES_MAX, STARTING_STEPS, } from './connection.ts';
2
+ export type { HouseOneWayCall, HouseOneWayCallOf, KitCall, KitCallOf, KitCallResult, KitMethod, KitOneWayCall, KitOneWayCallOf, KitSettings, } from './connection.ts';
3
+ export { AGENT_CAPABILITY_DECLARATION, DECLARED_SECRET_CEREMONY, DESIRED_AGENT_ROUTE, DESIRED_AGENTS, ENVIRONMENT_FORMS, FILE_BYTES, FILE_NAME, FILE_NAME_MAX, FUNCTION_RUN_META_KEY, KIT_ACTS, KIT_BINARY_CHANGE, KIT_DOOR_ACTS, KIT_QUESTION, KIT_REINSTALLS, KIT_TURN_END, KIT_TURN_IMAGE, KIT_UPLOAD_FINISH, LOCAL_COPY_ROOM, MEDIA_TYPE, PART_SHA256, REPORTED_AGENT_KIND, SECRET_CEREMONY_STEPS_MAX, SECRET_RELAY_OUTCOME, SECRET_RELAY_RELEASES, SHA256, TRANSCRIPT, } from './acts.ts';
4
+ export type { AgentCapabilityDeclaration, DeclaredSecretCeremony, DesiredAgentRoute, KitActAnswer, KitActDeclaration, KitActName, KitActRequest, KitBinaryChange, KitDoorAct, KitDoorAnswer, KitQuestion, KitTurnEnd, KitTurnImage, LocalCopyRoom, ReportedAgentKind, SecretCeremonyStep, SecretRelayOutcome, Transcript, TranscriptionReport, } from './acts.ts';
5
+ export { ENVIRONMENT_REACHES, ENVIRONMENT_ROOM_LIMIT, ENVIRONMENT_ROOM_REFS, ENVIRONMENT_ROOMS, KIT_ENROLLMENT_ACTS, KIT_LOGIN_ISSUED, KIT_LOGIN_PATHS, KIT_LOGIN_POLL, KIT_LOGIN_START, KIT_LOGIN_STARTED, } from './enrollment.ts';
6
+ export type { EnvironmentReach, EnvironmentRooms, KitEnrollmentAct } from './enrollment.ts';
7
+ export { BUILDING_KIT, KIT_COMMANDS, KIT_DECLARATION, KIT_WIRE, KIT_WIRE_HEADER, kitWire, kitWireRefusal, } from './wire.ts';
8
+ export type { BuildingKit, KitCommands, KitWireRefusal } from './wire.ts';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { HOUSE_ONE_WAY_CALLS, KIT_CALL, KIT_CALL_RESULT, KIT_CALLS, KIT_CAUSE, KIT_CONNECTION_PATH, KIT_CONNECTION_PROTOCOL_PREFIX, KIT_ONE_WAY_CALLS, KIT_SETTINGS, SESSION_CHOICE_BYTES_MAX, STARTING_STEPS, } from './connection.js';
2
+ export { AGENT_CAPABILITY_DECLARATION, DECLARED_SECRET_CEREMONY, DESIRED_AGENT_ROUTE, DESIRED_AGENTS, ENVIRONMENT_FORMS, FILE_BYTES, FILE_NAME, FILE_NAME_MAX, FUNCTION_RUN_META_KEY, KIT_ACTS, KIT_BINARY_CHANGE, KIT_DOOR_ACTS, KIT_QUESTION, KIT_REINSTALLS, KIT_TURN_END, KIT_TURN_IMAGE, KIT_UPLOAD_FINISH, LOCAL_COPY_ROOM, MEDIA_TYPE, PART_SHA256, REPORTED_AGENT_KIND, SECRET_CEREMONY_STEPS_MAX, SECRET_RELAY_OUTCOME, SECRET_RELAY_RELEASES, SHA256, TRANSCRIPT, } from './acts.js';
3
+ export { ENVIRONMENT_REACHES, ENVIRONMENT_ROOM_LIMIT, ENVIRONMENT_ROOM_REFS, ENVIRONMENT_ROOMS, KIT_ENROLLMENT_ACTS, KIT_LOGIN_ISSUED, KIT_LOGIN_PATHS, KIT_LOGIN_POLL, KIT_LOGIN_START, KIT_LOGIN_STARTED, } from './enrollment.js';
4
+ export { BUILDING_KIT, KIT_COMMANDS, KIT_DECLARATION, KIT_WIRE, KIT_WIRE_HEADER, kitWire, kitWireRefusal, } from './wire.js';