@probelabs/probe 0.6.0-rc137 → 0.6.0-rc139

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.
@@ -3088,22 +3088,13 @@ var require_dist_cjs18 = __commonJS({
3088
3088
  var sdkStreamMixin2 = require_sdk_stream_mixin();
3089
3089
  var splitStream = require_splitStream();
3090
3090
  var streamTypeCheck = require_stream_type_check();
3091
- function transformToString(payload2, encoding = "utf-8") {
3092
- if (encoding === "base64") {
3093
- return utilBase64.toBase64(payload2);
3094
- }
3095
- return utilUtf8.toUtf8(payload2);
3096
- }
3097
- function transformFromString(str, encoding) {
3098
- if (encoding === "base64") {
3099
- return Uint8ArrayBlobAdapter2.mutate(utilBase64.fromBase64(str));
3100
- }
3101
- return Uint8ArrayBlobAdapter2.mutate(utilUtf8.fromUtf8(str));
3102
- }
3103
3091
  var Uint8ArrayBlobAdapter2 = class _Uint8ArrayBlobAdapter extends Uint8Array {
3104
3092
  static fromString(source, encoding = "utf-8") {
3105
3093
  if (typeof source === "string") {
3106
- return transformFromString(source, encoding);
3094
+ if (encoding === "base64") {
3095
+ return _Uint8ArrayBlobAdapter.mutate(utilBase64.fromBase64(source));
3096
+ }
3097
+ return _Uint8ArrayBlobAdapter.mutate(utilUtf8.fromUtf8(source));
3107
3098
  }
3108
3099
  throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
3109
3100
  }
@@ -3112,7 +3103,10 @@ var require_dist_cjs18 = __commonJS({
3112
3103
  return source;
3113
3104
  }
3114
3105
  transformToString(encoding = "utf-8") {
3115
- return transformToString(this, encoding);
3106
+ if (encoding === "base64") {
3107
+ return utilBase64.toBase64(this);
3108
+ }
3109
+ return utilUtf8.toUtf8(this);
3116
3110
  }
3117
3111
  };
3118
3112
  exports2.Uint8ArrayBlobAdapter = Uint8ArrayBlobAdapter2;
@@ -3225,6 +3219,138 @@ var init_deref = __esm({
3225
3219
  }
3226
3220
  });
3227
3221
 
3222
+ // node_modules/@smithy/core/dist-es/submodules/schema/schemas/operation.js
3223
+ var operation;
3224
+ var init_operation = __esm({
3225
+ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/operation.js"() {
3226
+ operation = (namespace, name14, traits, input, output) => ({
3227
+ name: name14,
3228
+ namespace,
3229
+ traits,
3230
+ input,
3231
+ output
3232
+ });
3233
+ }
3234
+ });
3235
+
3236
+ // node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js
3237
+ var import_protocol_http2, import_util_middleware3, schemaDeserializationMiddleware, findHeader;
3238
+ var init_schemaDeserializationMiddleware = __esm({
3239
+ "node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js"() {
3240
+ import_protocol_http2 = __toESM(require_dist_cjs2());
3241
+ import_util_middleware3 = __toESM(require_dist_cjs7());
3242
+ init_operation();
3243
+ schemaDeserializationMiddleware = (config) => (next, context3) => async (args) => {
3244
+ const { response } = await next(args);
3245
+ const { operationSchema } = (0, import_util_middleware3.getSmithyContext)(context3);
3246
+ const [, ns, n3, t3, i3, o3] = operationSchema ?? [];
3247
+ try {
3248
+ const parsed = await config.protocol.deserializeResponse(operation(ns, n3, t3, i3, o3), {
3249
+ ...config,
3250
+ ...context3
3251
+ }, response);
3252
+ return {
3253
+ response,
3254
+ output: parsed
3255
+ };
3256
+ } catch (error2) {
3257
+ Object.defineProperty(error2, "$response", {
3258
+ value: response
3259
+ });
3260
+ if (!("$metadata" in error2)) {
3261
+ const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
3262
+ try {
3263
+ error2.message += "\n " + hint;
3264
+ } catch (e3) {
3265
+ if (!context3.logger || context3.logger?.constructor?.name === "NoOpLogger") {
3266
+ console.warn(hint);
3267
+ } else {
3268
+ context3.logger?.warn?.(hint);
3269
+ }
3270
+ }
3271
+ if (typeof error2.$responseBodyText !== "undefined") {
3272
+ if (error2.$response) {
3273
+ error2.$response.body = error2.$responseBodyText;
3274
+ }
3275
+ }
3276
+ try {
3277
+ if (import_protocol_http2.HttpResponse.isInstance(response)) {
3278
+ const { headers = {} } = response;
3279
+ const headerEntries = Object.entries(headers);
3280
+ error2.$metadata = {
3281
+ httpStatusCode: response.statusCode,
3282
+ requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries),
3283
+ extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries),
3284
+ cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries)
3285
+ };
3286
+ }
3287
+ } catch (e3) {
3288
+ }
3289
+ }
3290
+ throw error2;
3291
+ }
3292
+ };
3293
+ findHeader = (pattern, headers) => {
3294
+ return (headers.find(([k3]) => {
3295
+ return k3.match(pattern);
3296
+ }) || [void 0, void 0])[1];
3297
+ };
3298
+ }
3299
+ });
3300
+
3301
+ // node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js
3302
+ var import_util_middleware4, schemaSerializationMiddleware;
3303
+ var init_schemaSerializationMiddleware = __esm({
3304
+ "node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js"() {
3305
+ import_util_middleware4 = __toESM(require_dist_cjs7());
3306
+ init_operation();
3307
+ schemaSerializationMiddleware = (config) => (next, context3) => async (args) => {
3308
+ const { operationSchema } = (0, import_util_middleware4.getSmithyContext)(context3);
3309
+ const [, ns, n3, t3, i3, o3] = operationSchema ?? [];
3310
+ const endpoint = context3.endpointV2?.url && config.urlParser ? async () => config.urlParser(context3.endpointV2.url) : config.endpoint;
3311
+ const request = await config.protocol.serializeRequest(operation(ns, n3, t3, i3, o3), args.input, {
3312
+ ...config,
3313
+ ...context3,
3314
+ endpoint
3315
+ });
3316
+ return next({
3317
+ ...args,
3318
+ request
3319
+ });
3320
+ };
3321
+ }
3322
+ });
3323
+
3324
+ // node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js
3325
+ function getSchemaSerdePlugin(config) {
3326
+ return {
3327
+ applyToStack: (commandStack) => {
3328
+ commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption2);
3329
+ commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption);
3330
+ config.protocol.setSerdeContext(config);
3331
+ }
3332
+ };
3333
+ }
3334
+ var deserializerMiddlewareOption, serializerMiddlewareOption2;
3335
+ var init_getSchemaSerdePlugin = __esm({
3336
+ "node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js"() {
3337
+ init_schemaDeserializationMiddleware();
3338
+ init_schemaSerializationMiddleware();
3339
+ deserializerMiddlewareOption = {
3340
+ name: "deserializerMiddleware",
3341
+ step: "deserialize",
3342
+ tags: ["DESERIALIZER"],
3343
+ override: true
3344
+ };
3345
+ serializerMiddlewareOption2 = {
3346
+ name: "serializerMiddleware",
3347
+ step: "serialize",
3348
+ tags: ["SERIALIZER"],
3349
+ override: true
3350
+ };
3351
+ }
3352
+ });
3353
+
3228
3354
  // node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js
3229
3355
  var Schema;
3230
3356
  var init_Schema = __esm({
@@ -3252,51 +3378,6 @@ var init_Schema = __esm({
3252
3378
  }
3253
3379
  });
3254
3380
 
3255
- // node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js
3256
- var StructureSchema, struct;
3257
- var init_StructureSchema = __esm({
3258
- "node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js"() {
3259
- init_Schema();
3260
- StructureSchema = class _StructureSchema extends Schema {
3261
- static symbol = Symbol.for("@smithy/str");
3262
- name;
3263
- traits;
3264
- memberNames;
3265
- memberList;
3266
- symbol = _StructureSchema.symbol;
3267
- };
3268
- struct = (namespace, name14, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), {
3269
- name: name14,
3270
- namespace,
3271
- traits,
3272
- memberNames,
3273
- memberList
3274
- });
3275
- }
3276
- });
3277
-
3278
- // node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js
3279
- var ErrorSchema, error;
3280
- var init_ErrorSchema = __esm({
3281
- "node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js"() {
3282
- init_Schema();
3283
- init_StructureSchema();
3284
- ErrorSchema = class _ErrorSchema extends StructureSchema {
3285
- static symbol = Symbol.for("@smithy/err");
3286
- ctor;
3287
- symbol = _ErrorSchema.symbol;
3288
- };
3289
- error = (namespace, name14, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), {
3290
- name: name14,
3291
- namespace,
3292
- traits,
3293
- memberNames,
3294
- memberList,
3295
- ctor: null
3296
- });
3297
- }
3298
- });
3299
-
3300
3381
  // node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js
3301
3382
  var ListSchema, list;
3302
3383
  var init_ListSchema = __esm({
@@ -3364,29 +3445,47 @@ var init_OperationSchema = __esm({
3364
3445
  }
3365
3446
  });
3366
3447
 
3367
- // node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js
3368
- var SimpleSchema, sim, simAdapter;
3369
- var init_SimpleSchema = __esm({
3370
- "node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js"() {
3448
+ // node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js
3449
+ var StructureSchema, struct;
3450
+ var init_StructureSchema = __esm({
3451
+ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js"() {
3371
3452
  init_Schema();
3372
- SimpleSchema = class _SimpleSchema extends Schema {
3373
- static symbol = Symbol.for("@smithy/sim");
3453
+ StructureSchema = class _StructureSchema extends Schema {
3454
+ static symbol = Symbol.for("@smithy/str");
3374
3455
  name;
3375
- schemaRef;
3376
3456
  traits;
3377
- symbol = _SimpleSchema.symbol;
3457
+ memberNames;
3458
+ memberList;
3459
+ symbol = _StructureSchema.symbol;
3378
3460
  };
3379
- sim = (namespace, name14, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
3461
+ struct = (namespace, name14, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), {
3380
3462
  name: name14,
3381
3463
  namespace,
3382
3464
  traits,
3383
- schemaRef
3465
+ memberNames,
3466
+ memberList
3384
3467
  });
3385
- simAdapter = (namespace, name14, traits, schemaRef) => Schema.assign(new SimpleSchema(), {
3468
+ }
3469
+ });
3470
+
3471
+ // node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js
3472
+ var ErrorSchema, error;
3473
+ var init_ErrorSchema = __esm({
3474
+ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js"() {
3475
+ init_Schema();
3476
+ init_StructureSchema();
3477
+ ErrorSchema = class _ErrorSchema extends StructureSchema {
3478
+ static symbol = Symbol.for("@smithy/err");
3479
+ ctor;
3480
+ symbol = _ErrorSchema.symbol;
3481
+ };
3482
+ error = (namespace, name14, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), {
3386
3483
  name: name14,
3387
3484
  namespace,
3388
3485
  traits,
3389
- schemaRef
3486
+ memberNames,
3487
+ memberList,
3488
+ ctor: null
3390
3489
  });
3391
3490
  }
3392
3491
  });
@@ -3430,28 +3529,10 @@ function member(memberSchema, memberName) {
3430
3529
  const internalCtorAccess = NormalizedSchema;
3431
3530
  return new internalCtorAccess(memberSchema, memberName);
3432
3531
  }
3433
- function hydrate(ss) {
3434
- const [id, ...rest] = ss;
3435
- return {
3436
- [0]: simAdapter,
3437
- [1]: list,
3438
- [2]: map,
3439
- [3]: struct,
3440
- [-3]: error,
3441
- [9]: op
3442
- }[id].call(null, ...rest);
3443
- }
3444
3532
  var NormalizedSchema, isMemberSchema, isStaticSchema;
3445
3533
  var init_NormalizedSchema = __esm({
3446
3534
  "node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js"() {
3447
3535
  init_deref();
3448
- init_ErrorSchema();
3449
- init_ListSchema();
3450
- init_MapSchema();
3451
- init_OperationSchema();
3452
- init_Schema();
3453
- init_SimpleSchema();
3454
- init_StructureSchema();
3455
3536
  init_translateTraits();
3456
3537
  NormalizedSchema = class _NormalizedSchema {
3457
3538
  ref;
@@ -3477,8 +3558,6 @@ var init_NormalizedSchema = __esm({
3477
3558
  schema = deref(_ref);
3478
3559
  this._isMemberSchema = true;
3479
3560
  }
3480
- if (isStaticSchema(schema))
3481
- schema = hydrate(schema);
3482
3561
  if (traitStack.length > 0) {
3483
3562
  this.memberTraits = {};
3484
3563
  for (let i3 = traitStack.length - 1; i3 >= 0; --i3) {
@@ -3497,18 +3576,24 @@ var init_NormalizedSchema = __esm({
3497
3576
  return;
3498
3577
  }
3499
3578
  this.schema = deref(schema);
3500
- if (this.schema && typeof this.schema === "object") {
3501
- this.traits = this.schema?.traits ?? {};
3579
+ if (isStaticSchema(this.schema)) {
3580
+ this.name = `${this.schema[1]}#${this.schema[2]}`;
3581
+ this.traits = this.schema[3];
3502
3582
  } else {
3583
+ this.name = this.memberName ?? String(schema);
3503
3584
  this.traits = 0;
3504
3585
  }
3505
- this.name = (this.schema instanceof Schema ? this.schema.getName?.() : void 0) ?? this.memberName ?? String(schema);
3506
3586
  if (this._isMemberSchema && !memberName) {
3507
3587
  throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(true)} missing member name.`);
3508
3588
  }
3509
3589
  }
3510
3590
  static [Symbol.hasInstance](lhs) {
3511
- return Schema[Symbol.hasInstance].bind(this)(lhs);
3591
+ const isPrototype2 = this.prototype.isPrototypeOf(lhs);
3592
+ if (!isPrototype2 && typeof lhs === "object" && lhs !== null) {
3593
+ const ns = lhs;
3594
+ return ns.symbol === this.symbol;
3595
+ }
3596
+ return isPrototype2;
3512
3597
  }
3513
3598
  static of(ref) {
3514
3599
  const sc = deref(ref);
@@ -3526,7 +3611,11 @@ var init_NormalizedSchema = __esm({
3526
3611
  return new _NormalizedSchema(sc);
3527
3612
  }
3528
3613
  getSchema() {
3529
- return deref(this.schema?.schemaRef ?? this.schema);
3614
+ const sc = this.schema;
3615
+ if (sc[0] === 0) {
3616
+ return sc[4];
3617
+ }
3618
+ return sc;
3530
3619
  }
3531
3620
  getName(withNamespace = false) {
3532
3621
  const { name: name14 } = this;
@@ -3541,15 +3630,15 @@ var init_NormalizedSchema = __esm({
3541
3630
  }
3542
3631
  isListSchema() {
3543
3632
  const sc = this.getSchema();
3544
- return typeof sc === "number" ? sc >= 64 && sc < 128 : sc instanceof ListSchema;
3633
+ return typeof sc === "number" ? sc >= 64 && sc < 128 : sc[0] === 1;
3545
3634
  }
3546
3635
  isMapSchema() {
3547
3636
  const sc = this.getSchema();
3548
- return typeof sc === "number" ? sc >= 128 && sc <= 255 : sc instanceof MapSchema;
3637
+ return typeof sc === "number" ? sc >= 128 && sc <= 255 : sc[0] === 2;
3549
3638
  }
3550
3639
  isStructSchema() {
3551
3640
  const sc = this.getSchema();
3552
- return sc !== null && typeof sc === "object" && "members" in sc || sc instanceof StructureSchema;
3641
+ return sc[0] === 3 || sc[0] === -3;
3553
3642
  }
3554
3643
  isBlobSchema() {
3555
3644
  const sc = this.getSchema();
@@ -3607,13 +3696,13 @@ var init_NormalizedSchema = __esm({
3607
3696
  throw new Error(`@smithy/core/schema - cannot get key for non-map: ${this.getName(true)}`);
3608
3697
  }
3609
3698
  const schema = this.getSchema();
3610
- const memberSchema = isDoc ? 15 : schema?.keySchema ?? 0;
3699
+ const memberSchema = isDoc ? 15 : schema[4] ?? 0;
3611
3700
  return member([memberSchema, 0], "key");
3612
3701
  }
3613
3702
  getValueSchema() {
3614
3703
  const sc = this.getSchema();
3615
3704
  const [isDoc, isMap2, isList] = [this.isDocumentSchema(), this.isMapSchema(), this.isListSchema()];
3616
- const memberSchema = typeof sc === "number" ? 63 & sc : sc && typeof sc === "object" && (isMap2 || isList) ? sc.valueSchema : isDoc ? 15 : void 0;
3705
+ const memberSchema = typeof sc === "number" ? 63 & sc : sc && typeof sc === "object" && (isMap2 || isList) ? sc[3 + sc[0]] : isDoc ? 15 : void 0;
3617
3706
  if (memberSchema != null) {
3618
3707
  return member([memberSchema, 0], isMap2 ? "value" : "member");
3619
3708
  }
@@ -3621,9 +3710,9 @@ var init_NormalizedSchema = __esm({
3621
3710
  }
3622
3711
  getMemberSchema(memberName) {
3623
3712
  const struct2 = this.getSchema();
3624
- if (this.isStructSchema() && struct2.memberNames.includes(memberName)) {
3625
- const i3 = struct2.memberNames.indexOf(memberName);
3626
- const memberSchema = struct2.memberList[i3];
3713
+ if (this.isStructSchema() && struct2[4].includes(memberName)) {
3714
+ const i3 = struct2[4].indexOf(memberName);
3715
+ const memberSchema = struct2[5][i3];
3627
3716
  return member(isMemberSchema(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
3628
3717
  }
3629
3718
  if (this.isDocumentSchema()) {
@@ -3659,8 +3748,8 @@ var init_NormalizedSchema = __esm({
3659
3748
  throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");
3660
3749
  }
3661
3750
  const struct2 = this.getSchema();
3662
- for (let i3 = 0; i3 < struct2.memberNames.length; ++i3) {
3663
- yield [struct2.memberNames[i3], member([struct2.memberList[i3], 0], struct2.memberNames[i3])];
3751
+ for (let i3 = 0; i3 < struct2[4].length; ++i3) {
3752
+ yield [struct2[4][i3], member([struct2[5][i3], 0], struct2[4][i3])];
3664
3753
  }
3665
3754
  }
3666
3755
  };
@@ -3669,125 +3758,30 @@ var init_NormalizedSchema = __esm({
3669
3758
  }
3670
3759
  });
3671
3760
 
3672
- // node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js
3673
- var import_protocol_http2, import_util_middleware3, schemaDeserializationMiddleware, findHeader;
3674
- var init_schemaDeserializationMiddleware = __esm({
3675
- "node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js"() {
3676
- import_protocol_http2 = __toESM(require_dist_cjs2());
3677
- import_util_middleware3 = __toESM(require_dist_cjs7());
3678
- init_NormalizedSchema();
3679
- schemaDeserializationMiddleware = (config) => (next, context3) => async (args) => {
3680
- const { response } = await next(args);
3681
- let { operationSchema } = (0, import_util_middleware3.getSmithyContext)(context3);
3682
- if (isStaticSchema(operationSchema)) {
3683
- operationSchema = hydrate(operationSchema);
3684
- }
3685
- try {
3686
- const parsed = await config.protocol.deserializeResponse(operationSchema, {
3687
- ...config,
3688
- ...context3
3689
- }, response);
3690
- return {
3691
- response,
3692
- output: parsed
3693
- };
3694
- } catch (error2) {
3695
- Object.defineProperty(error2, "$response", {
3696
- value: response
3697
- });
3698
- if (!("$metadata" in error2)) {
3699
- const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
3700
- try {
3701
- error2.message += "\n " + hint;
3702
- } catch (e3) {
3703
- if (!context3.logger || context3.logger?.constructor?.name === "NoOpLogger") {
3704
- console.warn(hint);
3705
- } else {
3706
- context3.logger?.warn?.(hint);
3707
- }
3708
- }
3709
- if (typeof error2.$responseBodyText !== "undefined") {
3710
- if (error2.$response) {
3711
- error2.$response.body = error2.$responseBodyText;
3712
- }
3713
- }
3714
- try {
3715
- if (import_protocol_http2.HttpResponse.isInstance(response)) {
3716
- const { headers = {} } = response;
3717
- const headerEntries = Object.entries(headers);
3718
- error2.$metadata = {
3719
- httpStatusCode: response.statusCode,
3720
- requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries),
3721
- extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries),
3722
- cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries)
3723
- };
3724
- }
3725
- } catch (e3) {
3726
- }
3727
- }
3728
- throw error2;
3729
- }
3730
- };
3731
- findHeader = (pattern, headers) => {
3732
- return (headers.find(([k3]) => {
3733
- return k3.match(pattern);
3734
- }) || [void 0, void 0])[1];
3735
- };
3736
- }
3737
- });
3738
-
3739
- // node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js
3740
- var import_util_middleware4, schemaSerializationMiddleware;
3741
- var init_schemaSerializationMiddleware = __esm({
3742
- "node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js"() {
3743
- import_util_middleware4 = __toESM(require_dist_cjs7());
3744
- init_NormalizedSchema();
3745
- schemaSerializationMiddleware = (config) => (next, context3) => async (args) => {
3746
- let { operationSchema } = (0, import_util_middleware4.getSmithyContext)(context3);
3747
- if (isStaticSchema(operationSchema)) {
3748
- operationSchema = hydrate(operationSchema);
3749
- }
3750
- const endpoint = context3.endpointV2?.url && config.urlParser ? async () => config.urlParser(context3.endpointV2.url) : config.endpoint;
3751
- const request = await config.protocol.serializeRequest(operationSchema, args.input, {
3752
- ...config,
3753
- ...context3,
3754
- endpoint
3755
- });
3756
- return next({
3757
- ...args,
3758
- request
3759
- });
3760
- };
3761
- }
3762
- });
3763
-
3764
- // node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js
3765
- function getSchemaSerdePlugin(config) {
3766
- return {
3767
- applyToStack: (commandStack) => {
3768
- commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption2);
3769
- commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption);
3770
- config.protocol.setSerdeContext(config);
3771
- }
3772
- };
3773
- }
3774
- var deserializerMiddlewareOption, serializerMiddlewareOption2;
3775
- var init_getSchemaSerdePlugin = __esm({
3776
- "node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js"() {
3777
- init_schemaDeserializationMiddleware();
3778
- init_schemaSerializationMiddleware();
3779
- deserializerMiddlewareOption = {
3780
- name: "deserializerMiddleware",
3781
- step: "deserialize",
3782
- tags: ["DESERIALIZER"],
3783
- override: true
3784
- };
3785
- serializerMiddlewareOption2 = {
3786
- name: "serializerMiddleware",
3787
- step: "serialize",
3788
- tags: ["SERIALIZER"],
3789
- override: true
3761
+ // node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js
3762
+ var SimpleSchema, sim, simAdapter;
3763
+ var init_SimpleSchema = __esm({
3764
+ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js"() {
3765
+ init_Schema();
3766
+ SimpleSchema = class _SimpleSchema extends Schema {
3767
+ static symbol = Symbol.for("@smithy/sim");
3768
+ name;
3769
+ schemaRef;
3770
+ traits;
3771
+ symbol = _SimpleSchema.symbol;
3790
3772
  };
3773
+ sim = (namespace, name14, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
3774
+ name: name14,
3775
+ namespace,
3776
+ traits,
3777
+ schemaRef
3778
+ });
3779
+ simAdapter = (namespace, name14, traits, schemaRef) => Schema.assign(new SimpleSchema(), {
3780
+ name: name14,
3781
+ namespace,
3782
+ traits,
3783
+ schemaRef
3784
+ });
3791
3785
  }
3792
3786
  });
3793
3787
 
@@ -3855,7 +3849,7 @@ var init_TypeRegistry = __esm({
3855
3849
  getErrorCtor(es) {
3856
3850
  const $error = es;
3857
3851
  const registry = _TypeRegistry.for($error[1]);
3858
- return registry.exceptions.get(es);
3852
+ return registry.exceptions.get($error);
3859
3853
  }
3860
3854
  getBaseException() {
3861
3855
  for (const exceptionKey of this.exceptions.keys()) {
@@ -3903,11 +3897,11 @@ __export(schema_exports, {
3903
3897
  deserializerMiddlewareOption: () => deserializerMiddlewareOption,
3904
3898
  error: () => error,
3905
3899
  getSchemaSerdePlugin: () => getSchemaSerdePlugin,
3906
- hydrate: () => hydrate,
3907
3900
  isStaticSchema: () => isStaticSchema,
3908
3901
  list: () => list,
3909
3902
  map: () => map,
3910
3903
  op: () => op,
3904
+ operation: () => operation,
3911
3905
  serializerMiddlewareOption: () => serializerMiddlewareOption2,
3912
3906
  sim: () => sim,
3913
3907
  simAdapter: () => simAdapter,
@@ -3921,6 +3915,7 @@ var init_schema = __esm({
3921
3915
  init_ListSchema();
3922
3916
  init_MapSchema();
3923
3917
  init_OperationSchema();
3918
+ init_operation();
3924
3919
  init_ErrorSchema();
3925
3920
  init_NormalizedSchema();
3926
3921
  init_Schema();
@@ -5287,7 +5282,6 @@ var init_EventStreamSerde = __esm({
5287
5282
  const marshaller = this.marshaller;
5288
5283
  const eventStreamMember = requestSchema.getEventStreamMember();
5289
5284
  const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
5290
- const memberSchemas = unionSchema.getMemberSchemas();
5291
5285
  const serializer = this.serializer;
5292
5286
  const defaultContentType = this.defaultContentType;
5293
5287
  const initialRequestMarker = Symbol("initialRequestMarker");
@@ -5398,7 +5392,7 @@ var init_EventStreamSerde = __esm({
5398
5392
  let explicitPayloadContentType;
5399
5393
  const isKnownSchema = (() => {
5400
5394
  const struct2 = unionSchema.getSchema();
5401
- return struct2.memberNames.includes(unionMember);
5395
+ return struct2[4].includes(unionMember);
5402
5396
  })();
5403
5397
  const additionalHeaders = {};
5404
5398
  if (!isKnownSchema) {
@@ -5532,10 +5526,10 @@ var init_HttpProtocol = __esm({
5532
5526
  }
5533
5527
  }
5534
5528
  setHostPrefix(request, operationSchema, input) {
5535
- const operationNs = NormalizedSchema.of(operationSchema);
5536
5529
  const inputNs = NormalizedSchema.of(operationSchema.input);
5537
- if (operationNs.getMergedTraits().endpoint) {
5538
- let hostPrefix = operationNs.getMergedTraits().endpoint?.[0];
5530
+ const opTraits = translateTraits(operationSchema.traits ?? {});
5531
+ if (opTraits.endpoint) {
5532
+ let hostPrefix = opTraits.endpoint?.[0];
5539
5533
  if (typeof hostPrefix === "string") {
5540
5534
  const hostLabelInputs = [...inputNs.structIterator()].filter(([, member2]) => member2.getMergedTraits().hostLabel);
5541
5535
  for (const [name14] of hostLabelInputs) {
@@ -6814,20 +6808,24 @@ var require_dist_cjs20 = __commonJS({
6814
6808
  if (typeof obj === "string") {
6815
6809
  return evaluateTemplate(obj, options);
6816
6810
  } else if (obj["fn"]) {
6817
- return callFunction(obj, options);
6811
+ return group$2.callFunction(obj, options);
6818
6812
  } else if (obj["ref"]) {
6819
6813
  return getReferenceValue(obj, options);
6820
6814
  }
6821
6815
  throw new EndpointError(`'${keyName}': ${String(obj)} is not a string, function or reference.`);
6822
6816
  };
6823
6817
  var callFunction = ({ fn, argv }, options) => {
6824
- const evaluatedArgs = argv.map((arg) => ["boolean", "number"].includes(typeof arg) ? arg : evaluateExpression(arg, "arg", options));
6818
+ const evaluatedArgs = argv.map((arg) => ["boolean", "number"].includes(typeof arg) ? arg : group$2.evaluateExpression(arg, "arg", options));
6825
6819
  const fnSegments = fn.split(".");
6826
6820
  if (fnSegments[0] in customEndpointFunctions3 && fnSegments[1] != null) {
6827
6821
  return customEndpointFunctions3[fnSegments[0]][fnSegments[1]](...evaluatedArgs);
6828
6822
  }
6829
6823
  return endpointFunctions[fn](...evaluatedArgs);
6830
6824
  };
6825
+ var group$2 = {
6826
+ evaluateExpression,
6827
+ callFunction
6828
+ };
6831
6829
  var evaluateCondition = ({ assign: assign2, ...fnArgs }, options) => {
6832
6830
  if (assign2 && assign2 in options.referenceRecord) {
6833
6831
  throw new EndpointError(`'${assign2}' is already defined in Reference Record.`);
@@ -6869,6 +6867,10 @@ var require_dist_cjs20 = __commonJS({
6869
6867
  return processedExpr;
6870
6868
  })
6871
6869
  }), {});
6870
+ var getEndpointProperties = (properties, options) => Object.entries(properties).reduce((acc, [propertyKey, propertyVal]) => ({
6871
+ ...acc,
6872
+ [propertyKey]: group$1.getEndpointProperty(propertyVal, options)
6873
+ }), {});
6872
6874
  var getEndpointProperty = (property2, options) => {
6873
6875
  if (Array.isArray(property2)) {
6874
6876
  return property2.map((propertyEntry) => getEndpointProperty(propertyEntry, options));
@@ -6880,17 +6882,17 @@ var require_dist_cjs20 = __commonJS({
6880
6882
  if (property2 === null) {
6881
6883
  throw new EndpointError(`Unexpected endpoint property: ${property2}`);
6882
6884
  }
6883
- return getEndpointProperties(property2, options);
6885
+ return group$1.getEndpointProperties(property2, options);
6884
6886
  case "boolean":
6885
6887
  return property2;
6886
6888
  default:
6887
6889
  throw new EndpointError(`Unexpected endpoint property type: ${typeof property2}`);
6888
6890
  }
6889
6891
  };
6890
- var getEndpointProperties = (properties, options) => Object.entries(properties).reduce((acc, [propertyKey, propertyVal]) => ({
6891
- ...acc,
6892
- [propertyKey]: getEndpointProperty(propertyVal, options)
6893
- }), {});
6892
+ var group$1 = {
6893
+ getEndpointProperty,
6894
+ getEndpointProperties
6895
+ };
6894
6896
  var getEndpointUrl = (endpointUrl, options) => {
6895
6897
  const expression = evaluateExpression(endpointUrl, "Endpoint URL", options);
6896
6898
  if (typeof expression === "string") {
@@ -6936,17 +6938,6 @@ var require_dist_cjs20 = __commonJS({
6936
6938
  referenceRecord: { ...options.referenceRecord, ...referenceRecord }
6937
6939
  }));
6938
6940
  };
6939
- var evaluateTreeRule = (treeRule, options) => {
6940
- const { conditions, rules } = treeRule;
6941
- const { result, referenceRecord } = evaluateConditions(conditions, options);
6942
- if (!result) {
6943
- return;
6944
- }
6945
- return evaluateRules(rules, {
6946
- ...options,
6947
- referenceRecord: { ...options.referenceRecord, ...referenceRecord }
6948
- });
6949
- };
6950
6941
  var evaluateRules = (rules, options) => {
6951
6942
  for (const rule of rules) {
6952
6943
  if (rule.type === "endpoint") {
@@ -6957,7 +6948,7 @@ var require_dist_cjs20 = __commonJS({
6957
6948
  } else if (rule.type === "error") {
6958
6949
  evaluateErrorRule(rule, options);
6959
6950
  } else if (rule.type === "tree") {
6960
- const endpointOrUndefined = evaluateTreeRule(rule, options);
6951
+ const endpointOrUndefined = group.evaluateTreeRule(rule, options);
6961
6952
  if (endpointOrUndefined) {
6962
6953
  return endpointOrUndefined;
6963
6954
  }
@@ -6967,6 +6958,21 @@ var require_dist_cjs20 = __commonJS({
6967
6958
  }
6968
6959
  throw new EndpointError(`Rules evaluation failed`);
6969
6960
  };
6961
+ var evaluateTreeRule = (treeRule, options) => {
6962
+ const { conditions, rules } = treeRule;
6963
+ const { result, referenceRecord } = evaluateConditions(conditions, options);
6964
+ if (!result) {
6965
+ return;
6966
+ }
6967
+ return group.evaluateRules(rules, {
6968
+ ...options,
6969
+ referenceRecord: { ...options.referenceRecord, ...referenceRecord }
6970
+ });
6971
+ };
6972
+ var group = {
6973
+ evaluateRules,
6974
+ evaluateTreeRule
6975
+ };
6970
6976
  var resolveEndpoint3 = (ruleSetObject, options) => {
6971
6977
  const { endpointParams, logger: logger2 } = options;
6972
6978
  const { parameters, rules } = ruleSetObject;
@@ -9489,8 +9495,8 @@ var init_SmithyRpcV2CborProtocol = __esm({
9489
9495
  } catch (e3) {
9490
9496
  }
9491
9497
  }
9492
- const { service, operation } = (0, import_util_middleware5.getSmithyContext)(context3);
9493
- const path7 = `/service/${service}/operation/${operation}`;
9498
+ const { service, operation: operation2 } = (0, import_util_middleware5.getSmithyContext)(context3);
9499
+ const path7 = `/service/${service}/operation/${operation2}`;
9494
9500
  if (request.path.endsWith("/")) {
9495
9501
  request.path += path7.slice(1);
9496
9502
  } else {
@@ -10195,10 +10201,10 @@ var require_dist_cjs27 = __commonJS({
10195
10201
  this._middlewareFn = middlewareSupplier;
10196
10202
  return this;
10197
10203
  }
10198
- s(service, operation, smithyContext = {}) {
10204
+ s(service, operation2, smithyContext = {}) {
10199
10205
  this._smithyContext = {
10200
10206
  service,
10201
- operation,
10207
+ operation: operation2,
10202
10208
  ...smithyContext
10203
10209
  };
10204
10210
  return this;
@@ -10225,9 +10231,9 @@ var require_dist_cjs27 = __commonJS({
10225
10231
  this._deserializer = deserializer;
10226
10232
  return this;
10227
10233
  }
10228
- sc(operation) {
10229
- this._operationSchema = operation;
10230
- this._smithyContext.operationSchema = operation;
10234
+ sc(operation2) {
10235
+ this._operationSchema = operation2;
10236
+ this._smithyContext.operationSchema = operation2;
10231
10237
  return this;
10232
10238
  }
10233
10239
  build() {
@@ -11079,7 +11085,7 @@ var init_AwsJsonRpcProtocol = __esm({
11079
11085
  }
11080
11086
  Object.assign(request.headers, {
11081
11087
  "content-type": `application/x-amz-json-${this.getJsonRpcVersion()}`,
11082
- "x-amz-target": `${this.serviceTarget}.${NormalizedSchema.of(operationSchema).getName()}`
11088
+ "x-amz-target": `${this.serviceTarget}.${operationSchema.name}`
11083
11089
  });
11084
11090
  if (this.awsQueryCompatible) {
11085
11091
  request.headers["x-amzn-query-mode"] = "true";
@@ -15202,6 +15208,7 @@ var require_dist_cjs42 = __commonJS({
15202
15208
  var ENV_PROFILE = "AWS_PROFILE";
15203
15209
  var DEFAULT_PROFILE = "default";
15204
15210
  var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
15211
+ var CONFIG_PREFIX_SEPARATOR = ".";
15205
15212
  var getConfigData = (data2) => Object.entries(data2).filter(([key]) => {
15206
15213
  const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
15207
15214
  if (indexOfSeparator === -1) {
@@ -15268,7 +15275,6 @@ var require_dist_cjs42 = __commonJS({
15268
15275
  return map4;
15269
15276
  };
15270
15277
  var swallowError$1 = () => ({});
15271
- var CONFIG_PREFIX_SEPARATOR = ".";
15272
15278
  var loadSharedConfigFiles = async (init = {}) => {
15273
15279
  const { filepath = getCredentialsFilepath(), configFilepath = getConfigFilepath() } = init;
15274
15280
  const homeDir = getHomeDir.getHomeDir();
@@ -16473,7 +16479,7 @@ var require_package = __commonJS({
16473
16479
  module2.exports = {
16474
16480
  name: "@aws-sdk/client-bedrock-runtime",
16475
16481
  description: "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native",
16476
- version: "3.910.0",
16482
+ version: "3.911.0",
16477
16483
  scripts: {
16478
16484
  build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
16479
16485
  "build:cjs": "node ../../scripts/compilation/inline client-bedrock-runtime",
@@ -16492,21 +16498,21 @@ var require_package = __commonJS({
16492
16498
  dependencies: {
16493
16499
  "@aws-crypto/sha256-browser": "5.2.0",
16494
16500
  "@aws-crypto/sha256-js": "5.2.0",
16495
- "@aws-sdk/core": "3.910.0",
16496
- "@aws-sdk/credential-provider-node": "3.910.0",
16501
+ "@aws-sdk/core": "3.911.0",
16502
+ "@aws-sdk/credential-provider-node": "3.911.0",
16497
16503
  "@aws-sdk/eventstream-handler-node": "3.910.0",
16498
16504
  "@aws-sdk/middleware-eventstream": "3.910.0",
16499
16505
  "@aws-sdk/middleware-host-header": "3.910.0",
16500
16506
  "@aws-sdk/middleware-logger": "3.910.0",
16501
16507
  "@aws-sdk/middleware-recursion-detection": "3.910.0",
16502
- "@aws-sdk/middleware-user-agent": "3.910.0",
16508
+ "@aws-sdk/middleware-user-agent": "3.911.0",
16503
16509
  "@aws-sdk/middleware-websocket": "3.910.0",
16504
16510
  "@aws-sdk/region-config-resolver": "3.910.0",
16505
- "@aws-sdk/token-providers": "3.910.0",
16511
+ "@aws-sdk/token-providers": "3.911.0",
16506
16512
  "@aws-sdk/types": "3.910.0",
16507
16513
  "@aws-sdk/util-endpoints": "3.910.0",
16508
16514
  "@aws-sdk/util-user-agent-browser": "3.910.0",
16509
- "@aws-sdk/util-user-agent-node": "3.910.0",
16515
+ "@aws-sdk/util-user-agent-node": "3.911.0",
16510
16516
  "@smithy/config-resolver": "^4.3.2",
16511
16517
  "@smithy/core": "^3.16.1",
16512
16518
  "@smithy/eventstream-serde-browser": "^4.2.2",
@@ -17254,7 +17260,7 @@ var init_package = __esm({
17254
17260
  "node_modules/@aws-sdk/nested-clients/package.json"() {
17255
17261
  package_default = {
17256
17262
  name: "@aws-sdk/nested-clients",
17257
- version: "3.910.0",
17263
+ version: "3.911.0",
17258
17264
  description: "Nested clients for AWS SDK packages.",
17259
17265
  main: "./dist-cjs/index.js",
17260
17266
  module: "./dist-es/index.js",
@@ -17283,16 +17289,16 @@ var init_package = __esm({
17283
17289
  dependencies: {
17284
17290
  "@aws-crypto/sha256-browser": "5.2.0",
17285
17291
  "@aws-crypto/sha256-js": "5.2.0",
17286
- "@aws-sdk/core": "3.910.0",
17292
+ "@aws-sdk/core": "3.911.0",
17287
17293
  "@aws-sdk/middleware-host-header": "3.910.0",
17288
17294
  "@aws-sdk/middleware-logger": "3.910.0",
17289
17295
  "@aws-sdk/middleware-recursion-detection": "3.910.0",
17290
- "@aws-sdk/middleware-user-agent": "3.910.0",
17296
+ "@aws-sdk/middleware-user-agent": "3.911.0",
17291
17297
  "@aws-sdk/region-config-resolver": "3.910.0",
17292
17298
  "@aws-sdk/types": "3.910.0",
17293
17299
  "@aws-sdk/util-endpoints": "3.910.0",
17294
17300
  "@aws-sdk/util-user-agent-browser": "3.910.0",
17295
- "@aws-sdk/util-user-agent-node": "3.910.0",
17301
+ "@aws-sdk/util-user-agent-node": "3.911.0",
17296
17302
  "@smithy/config-resolver": "^4.3.2",
17297
17303
  "@smithy/core": "^3.16.1",
17298
17304
  "@smithy/fetch-http-handler": "^5.3.3",
@@ -18707,7 +18713,7 @@ var require_package2 = __commonJS({
18707
18713
  module2.exports = {
18708
18714
  name: "@aws-sdk/client-sso",
18709
18715
  description: "AWS SDK for JavaScript Sso Client for Node.js, Browser and React Native",
18710
- version: "3.910.0",
18716
+ version: "3.911.0",
18711
18717
  scripts: {
18712
18718
  build: "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
18713
18719
  "build:cjs": "node ../../scripts/compilation/inline client-sso",
@@ -18726,16 +18732,16 @@ var require_package2 = __commonJS({
18726
18732
  dependencies: {
18727
18733
  "@aws-crypto/sha256-browser": "5.2.0",
18728
18734
  "@aws-crypto/sha256-js": "5.2.0",
18729
- "@aws-sdk/core": "3.910.0",
18735
+ "@aws-sdk/core": "3.911.0",
18730
18736
  "@aws-sdk/middleware-host-header": "3.910.0",
18731
18737
  "@aws-sdk/middleware-logger": "3.910.0",
18732
18738
  "@aws-sdk/middleware-recursion-detection": "3.910.0",
18733
- "@aws-sdk/middleware-user-agent": "3.910.0",
18739
+ "@aws-sdk/middleware-user-agent": "3.911.0",
18734
18740
  "@aws-sdk/region-config-resolver": "3.910.0",
18735
18741
  "@aws-sdk/types": "3.910.0",
18736
18742
  "@aws-sdk/util-endpoints": "3.910.0",
18737
18743
  "@aws-sdk/util-user-agent-browser": "3.910.0",
18738
- "@aws-sdk/util-user-agent-node": "3.910.0",
18744
+ "@aws-sdk/util-user-agent-node": "3.911.0",
18739
18745
  "@smithy/config-resolver": "^4.3.2",
18740
18746
  "@smithy/core": "^3.16.1",
18741
18747
  "@smithy/fetch-http-handler": "^5.3.3",
@@ -28088,15 +28094,20 @@ async function extract(options) {
28088
28094
  if (!options) {
28089
28095
  throw new Error("Options object is required");
28090
28096
  }
28091
- if ((!options.files || !Array.isArray(options.files) || options.files.length === 0) && !options.inputFile) {
28092
- throw new Error("Either files array or inputFile must be provided");
28097
+ const hasFiles = options.files && Array.isArray(options.files) && options.files.length > 0;
28098
+ const hasInputFile = !!options.inputFile;
28099
+ const hasContent = options.content !== void 0 && options.content !== null;
28100
+ if (!hasFiles && !hasInputFile && !hasContent) {
28101
+ throw new Error("Either files array, inputFile, or content must be provided");
28093
28102
  }
28094
28103
  const binaryPath = await getBinaryPath(options.binaryOptions || {});
28095
- const cliArgs = buildCliArgs(options, EXTRACT_FLAG_MAP);
28104
+ const filteredOptions = { ...options };
28105
+ delete filteredOptions.content;
28106
+ const cliArgs = buildCliArgs(filteredOptions, EXTRACT_FLAG_MAP);
28096
28107
  if (options.json && !options.format) {
28097
28108
  cliArgs.push("--format", "json");
28098
28109
  }
28099
- if (options.files && Array.isArray(options.files) && options.files.length > 0) {
28110
+ if (hasFiles) {
28100
28111
  for (const file of options.files) {
28101
28112
  cliArgs.push(escapeString(file));
28102
28113
  }
@@ -28108,66 +28119,115 @@ Extract:`;
28108
28119
  logMessage += ` files="${options.files.join(", ")}"`;
28109
28120
  }
28110
28121
  if (options.inputFile) logMessage += ` inputFile="${options.inputFile}"`;
28122
+ if (options.content) logMessage += ` content=(${typeof options.content === "string" ? options.content.length : options.content.byteLength} bytes)`;
28111
28123
  if (options.allowTests) logMessage += " allowTests=true";
28112
28124
  if (options.contextLines) logMessage += ` contextLines=${options.contextLines}`;
28113
28125
  if (options.format) logMessage += ` format=${options.format}`;
28114
28126
  if (options.json) logMessage += " json=true";
28115
28127
  console.error(logMessage);
28116
28128
  }
28129
+ if (hasContent) {
28130
+ return extractWithStdin(binaryPath, cliArgs, options.content, options);
28131
+ }
28117
28132
  const command = `${binaryPath} extract ${cliArgs.join(" ")}`;
28118
28133
  try {
28119
28134
  const { stdout, stderr } = await execAsync3(command);
28120
28135
  if (stderr) {
28121
28136
  console.error(`stderr: ${stderr}`);
28122
28137
  }
28123
- let tokenUsage = {
28124
- requestTokens: 0,
28125
- responseTokens: 0,
28126
- totalTokens: 0
28127
- };
28128
- if (options.files && Array.isArray(options.files)) {
28129
- tokenUsage.requestTokens = options.files.join(" ").length / 4;
28130
- } else if (options.inputFile) {
28131
- tokenUsage.requestTokens = options.inputFile.length / 4;
28132
- }
28133
- if (stdout.includes("Total tokens returned:")) {
28134
- const tokenMatch = stdout.match(/Total tokens returned: (\d+)/);
28135
- if (tokenMatch && tokenMatch[1]) {
28136
- tokenUsage.responseTokens = parseInt(tokenMatch[1], 10);
28137
- tokenUsage.totalTokens = tokenUsage.requestTokens + tokenUsage.responseTokens;
28138
+ return processExtractOutput(stdout, options);
28139
+ } catch (error2) {
28140
+ const errorMessage = `Error executing extract command: ${error2.message}
28141
+ Command: ${command}`;
28142
+ throw new Error(errorMessage);
28143
+ }
28144
+ }
28145
+ function extractWithStdin(binaryPath, cliArgs, content, options) {
28146
+ return new Promise((resolve4, reject2) => {
28147
+ const process2 = (0, import_child_process4.spawn)(binaryPath, ["extract", ...cliArgs], {
28148
+ stdio: ["pipe", "pipe", "pipe"]
28149
+ });
28150
+ let stdout = "";
28151
+ let stderr = "";
28152
+ process2.stdout.on("data", (data2) => {
28153
+ stdout += data2.toString();
28154
+ });
28155
+ process2.stderr.on("data", (data2) => {
28156
+ stderr += data2.toString();
28157
+ });
28158
+ process2.on("close", (code) => {
28159
+ if (stderr && process2.env.DEBUG === "1") {
28160
+ console.error(`stderr: ${stderr}`);
28161
+ }
28162
+ if (code !== 0) {
28163
+ reject2(new Error(`Extract command failed with exit code ${code}: ${stderr}`));
28164
+ return;
28165
+ }
28166
+ try {
28167
+ const result = processExtractOutput(stdout, options);
28168
+ resolve4(result);
28169
+ } catch (error2) {
28170
+ reject2(error2);
28138
28171
  }
28172
+ });
28173
+ process2.on("error", (error2) => {
28174
+ reject2(new Error(`Failed to spawn extract process: ${error2.message}`));
28175
+ });
28176
+ if (typeof content === "string") {
28177
+ process2.stdin.write(content);
28178
+ } else {
28179
+ process2.stdin.write(content);
28139
28180
  }
28140
- let output = stdout;
28141
- if (!output.includes("Token Usage:")) {
28142
- output += `
28181
+ process2.stdin.end();
28182
+ });
28183
+ }
28184
+ function processExtractOutput(stdout, options) {
28185
+ let tokenUsage = {
28186
+ requestTokens: 0,
28187
+ responseTokens: 0,
28188
+ totalTokens: 0
28189
+ };
28190
+ if (options.files && Array.isArray(options.files)) {
28191
+ tokenUsage.requestTokens = options.files.join(" ").length / 4;
28192
+ } else if (options.inputFile) {
28193
+ tokenUsage.requestTokens = options.inputFile.length / 4;
28194
+ } else if (options.content) {
28195
+ const contentLength = typeof options.content === "string" ? options.content.length : options.content.byteLength;
28196
+ tokenUsage.requestTokens = contentLength / 4;
28197
+ }
28198
+ if (stdout.includes("Total tokens returned:")) {
28199
+ const tokenMatch = stdout.match(/Total tokens returned: (\d+)/);
28200
+ if (tokenMatch && tokenMatch[1]) {
28201
+ tokenUsage.responseTokens = parseInt(tokenMatch[1], 10);
28202
+ tokenUsage.totalTokens = tokenUsage.requestTokens + tokenUsage.responseTokens;
28203
+ }
28204
+ }
28205
+ let output = stdout;
28206
+ if (!output.includes("Token Usage:")) {
28207
+ output += `
28143
28208
  Token Usage:
28144
28209
  Request tokens: ${tokenUsage.requestTokens}
28145
28210
  Response tokens: ${tokenUsage.responseTokens}
28146
28211
  Total tokens: ${tokenUsage.totalTokens}
28147
28212
  `;
28148
- }
28149
- if (options.json || options.format === "json") {
28150
- try {
28151
- const jsonOutput = JSON.parse(stdout);
28152
- if (!jsonOutput.token_usage) {
28153
- jsonOutput.token_usage = {
28154
- request_tokens: tokenUsage.requestTokens,
28155
- response_tokens: tokenUsage.responseTokens,
28156
- total_tokens: tokenUsage.totalTokens
28157
- };
28158
- }
28159
- return jsonOutput;
28160
- } catch (error2) {
28161
- console.error("Error parsing JSON output:", error2);
28162
- return output;
28213
+ }
28214
+ if (options.json || options.format === "json") {
28215
+ try {
28216
+ const jsonOutput = JSON.parse(stdout);
28217
+ if (!jsonOutput.token_usage) {
28218
+ jsonOutput.token_usage = {
28219
+ request_tokens: tokenUsage.requestTokens,
28220
+ response_tokens: tokenUsage.responseTokens,
28221
+ total_tokens: tokenUsage.totalTokens
28222
+ };
28163
28223
  }
28224
+ return jsonOutput;
28225
+ } catch (error2) {
28226
+ console.error("Error parsing JSON output:", error2);
28227
+ return output;
28164
28228
  }
28165
- return output;
28166
- } catch (error2) {
28167
- const errorMessage = `Error executing extract command: ${error2.message}
28168
- Command: ${command}`;
28169
- throw new Error(errorMessage);
28170
28229
  }
28230
+ return output;
28171
28231
  }
28172
28232
  var import_child_process4, import_util6, execAsync3, EXTRACT_FLAG_MAP;
28173
28233
  var init_extract = __esm({
@@ -74587,13 +74647,14 @@ You are working with a repository located at: ${searchDirectory}
74587
74647
  maxTokens: maxResponseTokens,
74588
74648
  temperature: 0.3
74589
74649
  });
74650
+ const usagePromise = result.usage;
74590
74651
  for await (const delta of result.textStream) {
74591
74652
  assistantResponseContent += delta;
74592
74653
  if (options.onStream) {
74593
74654
  options.onStream(delta);
74594
74655
  }
74595
74656
  }
74596
- const usage = await result.usage;
74657
+ const usage = await usagePromise;
74597
74658
  if (usage) {
74598
74659
  this.tokenCounter.recordUsage(usage, result.experimental_providerMetadata);
74599
74660
  }