replicas-cli 0.2.119 → 0.2.121

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,255 @@
1
+ #!/usr/bin/env bun
2
+ import {
3
+ fromUtf8,
4
+ toUtf8
5
+ } from "./chunk-S6VA5TIO.mjs";
6
+ import {
7
+ __publicField
8
+ } from "./chunk-FFDYI4OH.mjs";
9
+
10
+ // ../node_modules/.bun/@smithy+core@3.23.17/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js
11
+ var EventStreamSerde = class {
12
+ constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType }) {
13
+ __publicField(this, "marshaller");
14
+ __publicField(this, "serializer");
15
+ __publicField(this, "deserializer");
16
+ __publicField(this, "serdeContext");
17
+ __publicField(this, "defaultContentType");
18
+ this.marshaller = marshaller;
19
+ this.serializer = serializer;
20
+ this.deserializer = deserializer;
21
+ this.serdeContext = serdeContext;
22
+ this.defaultContentType = defaultContentType;
23
+ }
24
+ async serializeEventStream({ eventStream, requestSchema, initialRequest }) {
25
+ const marshaller = this.marshaller;
26
+ const eventStreamMember = requestSchema.getEventStreamMember();
27
+ const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
28
+ const serializer = this.serializer;
29
+ const defaultContentType = this.defaultContentType;
30
+ const initialRequestMarker = /* @__PURE__ */ Symbol("initialRequestMarker");
31
+ const eventStreamIterable = {
32
+ async *[Symbol.asyncIterator]() {
33
+ if (initialRequest) {
34
+ const headers = {
35
+ ":event-type": { type: "string", value: "initial-request" },
36
+ ":message-type": { type: "string", value: "event" },
37
+ ":content-type": { type: "string", value: defaultContentType }
38
+ };
39
+ serializer.write(requestSchema, initialRequest);
40
+ const body = serializer.flush();
41
+ yield {
42
+ [initialRequestMarker]: true,
43
+ headers,
44
+ body
45
+ };
46
+ }
47
+ for await (const page of eventStream) {
48
+ yield page;
49
+ }
50
+ }
51
+ };
52
+ return marshaller.serialize(eventStreamIterable, (event) => {
53
+ if (event[initialRequestMarker]) {
54
+ return {
55
+ headers: event.headers,
56
+ body: event.body
57
+ };
58
+ }
59
+ let unionMember = "";
60
+ for (const key in event) {
61
+ if (key !== "__type") {
62
+ unionMember = key;
63
+ break;
64
+ }
65
+ }
66
+ const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
67
+ const headers = {
68
+ ":event-type": { type: "string", value: eventType },
69
+ ":message-type": { type: "string", value: "event" },
70
+ ":content-type": { type: "string", value: explicitPayloadContentType ?? defaultContentType },
71
+ ...additionalHeaders
72
+ };
73
+ return {
74
+ headers,
75
+ body
76
+ };
77
+ });
78
+ }
79
+ async deserializeEventStream({ response, responseSchema, initialResponseContainer }) {
80
+ const marshaller = this.marshaller;
81
+ const eventStreamMember = responseSchema.getEventStreamMember();
82
+ const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
83
+ const memberSchemas = unionSchema.getMemberSchemas();
84
+ const initialResponseMarker = /* @__PURE__ */ Symbol("initialResponseMarker");
85
+ const asyncIterable = marshaller.deserialize(response.body, async (event) => {
86
+ let unionMember = "";
87
+ for (const key in event) {
88
+ if (key !== "__type") {
89
+ unionMember = key;
90
+ break;
91
+ }
92
+ }
93
+ const body = event[unionMember].body;
94
+ if (unionMember === "initial-response") {
95
+ const dataObject = await this.deserializer.read(responseSchema, body);
96
+ delete dataObject[eventStreamMember];
97
+ return {
98
+ [initialResponseMarker]: true,
99
+ ...dataObject
100
+ };
101
+ } else if (unionMember in memberSchemas) {
102
+ const eventStreamSchema = memberSchemas[unionMember];
103
+ if (eventStreamSchema.isStructSchema()) {
104
+ const out = {};
105
+ let hasBindings = false;
106
+ for (const [name, member] of eventStreamSchema.structIterator()) {
107
+ const { eventHeader, eventPayload } = member.getMergedTraits();
108
+ hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
109
+ if (eventPayload) {
110
+ if (member.isBlobSchema()) {
111
+ out[name] = body;
112
+ } else if (member.isStringSchema()) {
113
+ out[name] = (this.serdeContext?.utf8Encoder ?? toUtf8)(body);
114
+ } else if (member.isStructSchema()) {
115
+ out[name] = await this.deserializer.read(member, body);
116
+ }
117
+ } else if (eventHeader) {
118
+ const value = event[unionMember].headers[name]?.value;
119
+ if (value != null) {
120
+ if (member.isNumericSchema()) {
121
+ if (value && typeof value === "object" && "bytes" in value) {
122
+ out[name] = BigInt(value.toString());
123
+ } else {
124
+ out[name] = Number(value);
125
+ }
126
+ } else {
127
+ out[name] = value;
128
+ }
129
+ }
130
+ }
131
+ }
132
+ if (hasBindings) {
133
+ return {
134
+ [unionMember]: out
135
+ };
136
+ }
137
+ if (body.byteLength === 0) {
138
+ return {
139
+ [unionMember]: {}
140
+ };
141
+ }
142
+ }
143
+ return {
144
+ [unionMember]: await this.deserializer.read(eventStreamSchema, body)
145
+ };
146
+ } else {
147
+ return {
148
+ $unknown: event
149
+ };
150
+ }
151
+ });
152
+ const asyncIterator = asyncIterable[Symbol.asyncIterator]();
153
+ const firstEvent = await asyncIterator.next();
154
+ if (firstEvent.done) {
155
+ return asyncIterable;
156
+ }
157
+ if (firstEvent.value?.[initialResponseMarker]) {
158
+ if (!responseSchema) {
159
+ throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
160
+ }
161
+ for (const key in firstEvent.value) {
162
+ initialResponseContainer[key] = firstEvent.value[key];
163
+ }
164
+ }
165
+ return {
166
+ async *[Symbol.asyncIterator]() {
167
+ if (!firstEvent?.value?.[initialResponseMarker]) {
168
+ yield firstEvent.value;
169
+ }
170
+ while (true) {
171
+ const { done, value } = await asyncIterator.next();
172
+ if (done) {
173
+ break;
174
+ }
175
+ yield value;
176
+ }
177
+ }
178
+ };
179
+ }
180
+ writeEventBody(unionMember, unionSchema, event) {
181
+ const serializer = this.serializer;
182
+ let eventType = unionMember;
183
+ let explicitPayloadMember = null;
184
+ let explicitPayloadContentType;
185
+ const isKnownSchema = (() => {
186
+ const struct = unionSchema.getSchema();
187
+ return struct[4].includes(unionMember);
188
+ })();
189
+ const additionalHeaders = {};
190
+ if (!isKnownSchema) {
191
+ const [type, value] = event[unionMember];
192
+ eventType = type;
193
+ serializer.write(15, value);
194
+ } else {
195
+ const eventSchema = unionSchema.getMemberSchema(unionMember);
196
+ if (eventSchema.isStructSchema()) {
197
+ for (const [memberName, memberSchema] of eventSchema.structIterator()) {
198
+ const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
199
+ if (eventPayload) {
200
+ explicitPayloadMember = memberName;
201
+ } else if (eventHeader) {
202
+ const value = event[unionMember][memberName];
203
+ let type = "binary";
204
+ if (memberSchema.isNumericSchema()) {
205
+ if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
206
+ type = "integer";
207
+ } else {
208
+ type = "long";
209
+ }
210
+ } else if (memberSchema.isTimestampSchema()) {
211
+ type = "timestamp";
212
+ } else if (memberSchema.isStringSchema()) {
213
+ type = "string";
214
+ } else if (memberSchema.isBooleanSchema()) {
215
+ type = "boolean";
216
+ }
217
+ if (value != null) {
218
+ additionalHeaders[memberName] = {
219
+ type,
220
+ value
221
+ };
222
+ delete event[unionMember][memberName];
223
+ }
224
+ }
225
+ }
226
+ if (explicitPayloadMember !== null) {
227
+ const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
228
+ if (payloadSchema.isBlobSchema()) {
229
+ explicitPayloadContentType = "application/octet-stream";
230
+ } else if (payloadSchema.isStringSchema()) {
231
+ explicitPayloadContentType = "text/plain";
232
+ }
233
+ serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
234
+ } else {
235
+ serializer.write(eventSchema, event[unionMember]);
236
+ }
237
+ } else if (eventSchema.isUnitSchema()) {
238
+ serializer.write(eventSchema, {});
239
+ } else {
240
+ throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
241
+ }
242
+ }
243
+ const messageSerialization = serializer.flush() ?? new Uint8Array();
244
+ const body = typeof messageSerialization === "string" ? (this.serdeContext?.utf8Decoder ?? fromUtf8)(messageSerialization) : messageSerialization;
245
+ return {
246
+ body,
247
+ eventType,
248
+ explicitPayloadContentType,
249
+ additionalHeaders
250
+ };
251
+ }
252
+ };
253
+ export {
254
+ EventStreamSerde
255
+ };
@@ -0,0 +1,247 @@
1
+ #!/usr/bin/env bun
2
+ import {
3
+ fromUtf8,
4
+ toUtf8
5
+ } from "./chunk-S6VA5TIO.mjs";
6
+ import {
7
+ __publicField
8
+ } from "./chunk-FFDYI4OH.mjs";
9
+
10
+ // ../node_modules/.bun/@smithy+core@3.23.13/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js
11
+ var EventStreamSerde = class {
12
+ constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType }) {
13
+ __publicField(this, "marshaller");
14
+ __publicField(this, "serializer");
15
+ __publicField(this, "deserializer");
16
+ __publicField(this, "serdeContext");
17
+ __publicField(this, "defaultContentType");
18
+ this.marshaller = marshaller;
19
+ this.serializer = serializer;
20
+ this.deserializer = deserializer;
21
+ this.serdeContext = serdeContext;
22
+ this.defaultContentType = defaultContentType;
23
+ }
24
+ async serializeEventStream({ eventStream, requestSchema, initialRequest }) {
25
+ const marshaller = this.marshaller;
26
+ const eventStreamMember = requestSchema.getEventStreamMember();
27
+ const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
28
+ const serializer = this.serializer;
29
+ const defaultContentType = this.defaultContentType;
30
+ const initialRequestMarker = /* @__PURE__ */ Symbol("initialRequestMarker");
31
+ const eventStreamIterable = {
32
+ async *[Symbol.asyncIterator]() {
33
+ if (initialRequest) {
34
+ const headers = {
35
+ ":event-type": { type: "string", value: "initial-request" },
36
+ ":message-type": { type: "string", value: "event" },
37
+ ":content-type": { type: "string", value: defaultContentType }
38
+ };
39
+ serializer.write(requestSchema, initialRequest);
40
+ const body = serializer.flush();
41
+ yield {
42
+ [initialRequestMarker]: true,
43
+ headers,
44
+ body
45
+ };
46
+ }
47
+ for await (const page of eventStream) {
48
+ yield page;
49
+ }
50
+ }
51
+ };
52
+ return marshaller.serialize(eventStreamIterable, (event) => {
53
+ if (event[initialRequestMarker]) {
54
+ return {
55
+ headers: event.headers,
56
+ body: event.body
57
+ };
58
+ }
59
+ const unionMember = Object.keys(event).find((key) => {
60
+ return key !== "__type";
61
+ }) ?? "";
62
+ const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
63
+ const headers = {
64
+ ":event-type": { type: "string", value: eventType },
65
+ ":message-type": { type: "string", value: "event" },
66
+ ":content-type": { type: "string", value: explicitPayloadContentType ?? defaultContentType },
67
+ ...additionalHeaders
68
+ };
69
+ return {
70
+ headers,
71
+ body
72
+ };
73
+ });
74
+ }
75
+ async deserializeEventStream({ response, responseSchema, initialResponseContainer }) {
76
+ const marshaller = this.marshaller;
77
+ const eventStreamMember = responseSchema.getEventStreamMember();
78
+ const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
79
+ const memberSchemas = unionSchema.getMemberSchemas();
80
+ const initialResponseMarker = /* @__PURE__ */ Symbol("initialResponseMarker");
81
+ const asyncIterable = marshaller.deserialize(response.body, async (event) => {
82
+ const unionMember = Object.keys(event).find((key) => {
83
+ return key !== "__type";
84
+ }) ?? "";
85
+ const body = event[unionMember].body;
86
+ if (unionMember === "initial-response") {
87
+ const dataObject = await this.deserializer.read(responseSchema, body);
88
+ delete dataObject[eventStreamMember];
89
+ return {
90
+ [initialResponseMarker]: true,
91
+ ...dataObject
92
+ };
93
+ } else if (unionMember in memberSchemas) {
94
+ const eventStreamSchema = memberSchemas[unionMember];
95
+ if (eventStreamSchema.isStructSchema()) {
96
+ const out = {};
97
+ let hasBindings = false;
98
+ for (const [name, member] of eventStreamSchema.structIterator()) {
99
+ const { eventHeader, eventPayload } = member.getMergedTraits();
100
+ hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
101
+ if (eventPayload) {
102
+ if (member.isBlobSchema()) {
103
+ out[name] = body;
104
+ } else if (member.isStringSchema()) {
105
+ out[name] = (this.serdeContext?.utf8Encoder ?? toUtf8)(body);
106
+ } else if (member.isStructSchema()) {
107
+ out[name] = await this.deserializer.read(member, body);
108
+ }
109
+ } else if (eventHeader) {
110
+ const value = event[unionMember].headers[name]?.value;
111
+ if (value != null) {
112
+ if (member.isNumericSchema()) {
113
+ if (value && typeof value === "object" && "bytes" in value) {
114
+ out[name] = BigInt(value.toString());
115
+ } else {
116
+ out[name] = Number(value);
117
+ }
118
+ } else {
119
+ out[name] = value;
120
+ }
121
+ }
122
+ }
123
+ }
124
+ if (hasBindings) {
125
+ return {
126
+ [unionMember]: out
127
+ };
128
+ }
129
+ if (body.byteLength === 0) {
130
+ return {
131
+ [unionMember]: {}
132
+ };
133
+ }
134
+ }
135
+ return {
136
+ [unionMember]: await this.deserializer.read(eventStreamSchema, body)
137
+ };
138
+ } else {
139
+ return {
140
+ $unknown: event
141
+ };
142
+ }
143
+ });
144
+ const asyncIterator = asyncIterable[Symbol.asyncIterator]();
145
+ const firstEvent = await asyncIterator.next();
146
+ if (firstEvent.done) {
147
+ return asyncIterable;
148
+ }
149
+ if (firstEvent.value?.[initialResponseMarker]) {
150
+ if (!responseSchema) {
151
+ throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
152
+ }
153
+ for (const [key, value] of Object.entries(firstEvent.value)) {
154
+ initialResponseContainer[key] = value;
155
+ }
156
+ }
157
+ return {
158
+ async *[Symbol.asyncIterator]() {
159
+ if (!firstEvent?.value?.[initialResponseMarker]) {
160
+ yield firstEvent.value;
161
+ }
162
+ while (true) {
163
+ const { done, value } = await asyncIterator.next();
164
+ if (done) {
165
+ break;
166
+ }
167
+ yield value;
168
+ }
169
+ }
170
+ };
171
+ }
172
+ writeEventBody(unionMember, unionSchema, event) {
173
+ const serializer = this.serializer;
174
+ let eventType = unionMember;
175
+ let explicitPayloadMember = null;
176
+ let explicitPayloadContentType;
177
+ const isKnownSchema = (() => {
178
+ const struct = unionSchema.getSchema();
179
+ return struct[4].includes(unionMember);
180
+ })();
181
+ const additionalHeaders = {};
182
+ if (!isKnownSchema) {
183
+ const [type, value] = event[unionMember];
184
+ eventType = type;
185
+ serializer.write(15, value);
186
+ } else {
187
+ const eventSchema = unionSchema.getMemberSchema(unionMember);
188
+ if (eventSchema.isStructSchema()) {
189
+ for (const [memberName, memberSchema] of eventSchema.structIterator()) {
190
+ const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
191
+ if (eventPayload) {
192
+ explicitPayloadMember = memberName;
193
+ } else if (eventHeader) {
194
+ const value = event[unionMember][memberName];
195
+ let type = "binary";
196
+ if (memberSchema.isNumericSchema()) {
197
+ if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
198
+ type = "integer";
199
+ } else {
200
+ type = "long";
201
+ }
202
+ } else if (memberSchema.isTimestampSchema()) {
203
+ type = "timestamp";
204
+ } else if (memberSchema.isStringSchema()) {
205
+ type = "string";
206
+ } else if (memberSchema.isBooleanSchema()) {
207
+ type = "boolean";
208
+ }
209
+ if (value != null) {
210
+ additionalHeaders[memberName] = {
211
+ type,
212
+ value
213
+ };
214
+ delete event[unionMember][memberName];
215
+ }
216
+ }
217
+ }
218
+ if (explicitPayloadMember !== null) {
219
+ const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
220
+ if (payloadSchema.isBlobSchema()) {
221
+ explicitPayloadContentType = "application/octet-stream";
222
+ } else if (payloadSchema.isStringSchema()) {
223
+ explicitPayloadContentType = "text/plain";
224
+ }
225
+ serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
226
+ } else {
227
+ serializer.write(eventSchema, event[unionMember]);
228
+ }
229
+ } else if (eventSchema.isUnitSchema()) {
230
+ serializer.write(eventSchema, {});
231
+ } else {
232
+ throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
233
+ }
234
+ }
235
+ const messageSerialization = serializer.flush() ?? new Uint8Array();
236
+ const body = typeof messageSerialization === "string" ? (this.serdeContext?.utf8Decoder ?? fromUtf8)(messageSerialization) : messageSerialization;
237
+ return {
238
+ body,
239
+ eventType,
240
+ explicitPayloadContentType,
241
+ additionalHeaders
242
+ };
243
+ }
244
+ };
245
+ export {
246
+ EventStreamSerde
247
+ };
package/dist/index.mjs CHANGED
@@ -16,7 +16,8 @@ import {
16
16
  setIdeCommand,
17
17
  setOrganizationId,
18
18
  writeConfig
19
- } from "./chunk-HOO346QO.mjs";
19
+ } from "./chunk-CPVJVKSG.mjs";
20
+ import "./chunk-FFDYI4OH.mjs";
20
21
 
21
22
  // src/index.ts
22
23
  import "dotenv/config";
@@ -2420,12 +2421,12 @@ async function interactiveCommand() {
2420
2421
  );
2421
2422
  }
2422
2423
  console.log(chalk18.gray("Starting interactive mode..."));
2423
- const { launchInteractive } = await import("./interactive-V22J5FZI.mjs");
2424
+ const { launchInteractive } = await import("./interactive-P7CS3HLU.mjs");
2424
2425
  await launchInteractive();
2425
2426
  }
2426
2427
 
2427
2428
  // src/index.ts
2428
- var CLI_VERSION = "0.2.119";
2429
+ var CLI_VERSION = "0.2.121";
2429
2430
  var program = new Command();
2430
2431
  program.name("replicas").description("CLI for managing Replicas workspaces").version(CLI_VERSION);
2431
2432
  program.command("login").description("Authenticate with your Replicas account").action(async () => {
@@ -12,7 +12,8 @@ import {
12
12
  isAgentBackendEvent,
13
13
  parseAgentEvents,
14
14
  parseUserMessage
15
- } from "./chunk-HOO346QO.mjs";
15
+ } from "./chunk-CPVJVKSG.mjs";
16
+ import "./chunk-FFDYI4OH.mjs";
16
17
 
17
18
  // src/interactive/index.tsx
18
19
  import { createCliRenderer } from "@opentui/core";