effect 4.1.3 → 4.1.4

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.
Files changed (109) hide show
  1. package/dist/SchemaRepresentation.d.ts +17 -3
  2. package/dist/SchemaRepresentation.d.ts.map +1 -1
  3. package/dist/SchemaRepresentation.js +4 -2
  4. package/dist/SchemaRepresentation.js.map +1 -1
  5. package/dist/ai/Chat.d.ts +1 -1
  6. package/dist/ai/Chat.d.ts.map +1 -1
  7. package/dist/ai/Chat.js.map +1 -1
  8. package/dist/ai/LanguageModel.d.ts +23 -4
  9. package/dist/ai/LanguageModel.d.ts.map +1 -1
  10. package/dist/ai/LanguageModel.js +8 -4
  11. package/dist/ai/LanguageModel.js.map +1 -1
  12. package/dist/ai/McpClient.d.ts +0 -5
  13. package/dist/ai/McpClient.d.ts.map +1 -1
  14. package/dist/ai/McpClient.js +1 -11
  15. package/dist/ai/McpClient.js.map +1 -1
  16. package/dist/ai/McpSchema.d.ts +110 -110
  17. package/dist/ai/McpSchema.d.ts.map +1 -1
  18. package/dist/ai/McpServer.d.ts +1 -3
  19. package/dist/ai/McpServer.d.ts.map +1 -1
  20. package/dist/ai/McpServer.js +1 -3
  21. package/dist/ai/McpServer.js.map +1 -1
  22. package/dist/ai/WorkloadIdentity.d.ts +111 -0
  23. package/dist/ai/WorkloadIdentity.d.ts.map +1 -0
  24. package/dist/ai/WorkloadIdentity.js +227 -0
  25. package/dist/ai/WorkloadIdentity.js.map +1 -0
  26. package/dist/ai/index.d.ts +5 -0
  27. package/dist/ai/index.d.ts.map +1 -1
  28. package/dist/ai/index.js +5 -0
  29. package/dist/ai/index.js.map +1 -1
  30. package/dist/ai/internal/mcpProtocol/v2024_11_05.js +3 -1
  31. package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
  32. package/dist/ai/internal/mcpProtocol/v2025_03_26.js +3 -1
  33. package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
  34. package/dist/ai/internal/mcpProtocol/v2025_06_18.js +3 -1
  35. package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
  36. package/dist/ai/internal/mcpProtocol/v2025_11_25.js +3 -1
  37. package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
  38. package/dist/ai/internal/mcpRuntime.js +2 -4
  39. package/dist/ai/internal/mcpRuntime.js.map +1 -1
  40. package/dist/ai/internal/mcpSkills.js +80 -2
  41. package/dist/ai/internal/mcpSkills.js.map +1 -1
  42. package/dist/ai/internal/structured-output.js +5 -1
  43. package/dist/ai/internal/structured-output.js.map +1 -1
  44. package/dist/cli/Command.d.ts.map +1 -1
  45. package/dist/cli/Command.js +3 -1
  46. package/dist/cli/Command.js.map +1 -1
  47. package/dist/cli/internal/lexer.js +13 -0
  48. package/dist/cli/internal/lexer.js.map +1 -1
  49. package/dist/cli/internal/parser.js +23 -16
  50. package/dist/cli/internal/parser.js.map +1 -1
  51. package/dist/cli/internal/wizard.d.ts.map +1 -1
  52. package/dist/cli/internal/wizard.js +4 -0
  53. package/dist/cli/internal/wizard.js.map +1 -1
  54. package/dist/http/HttpMiddleware.d.ts.map +1 -1
  55. package/dist/http/HttpMiddleware.js +4 -2
  56. package/dist/http/HttpMiddleware.js.map +1 -1
  57. package/dist/http/internal/requestState.js +15 -0
  58. package/dist/http/internal/requestState.js.map +1 -1
  59. package/dist/http-api/HttpApi.d.ts +47 -0
  60. package/dist/http-api/HttpApi.d.ts.map +1 -1
  61. package/dist/http-api/HttpApi.js +66 -0
  62. package/dist/http-api/HttpApi.js.map +1 -1
  63. package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
  64. package/dist/http-api/HttpApiBuilder.js +9 -1
  65. package/dist/http-api/HttpApiBuilder.js.map +1 -1
  66. package/dist/http-api/HttpApiClient.d.ts +1 -1
  67. package/dist/http-api/HttpApiClient.d.ts.map +1 -1
  68. package/dist/http-api/HttpApiClient.js +5 -1
  69. package/dist/http-api/HttpApiClient.js.map +1 -1
  70. package/dist/http-api/HttpApiSchema.d.ts +66 -0
  71. package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
  72. package/dist/http-api/HttpApiSchema.js +66 -1
  73. package/dist/http-api/HttpApiSchema.js.map +1 -1
  74. package/dist/internal/schema/fromJsonSchemaDocument.js +141 -35
  75. package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
  76. package/dist/internal/schema/toCodeDocument.js +3 -0
  77. package/dist/internal/schema/toCodeDocument.js.map +1 -1
  78. package/dist/internal/version.js +1 -1
  79. package/dist/testing/TestClock.js +3 -1
  80. package/dist/testing/TestClock.js.map +1 -1
  81. package/package.json +1 -1
  82. package/src/SchemaRepresentation.ts +18 -3
  83. package/src/ai/Chat.ts +9 -3
  84. package/src/ai/LanguageModel.ts +70 -14
  85. package/src/ai/McpClient.ts +1 -11
  86. package/src/ai/McpServer.ts +1 -3
  87. package/src/ai/WorkloadIdentity.ts +318 -0
  88. package/src/ai/index.ts +6 -0
  89. package/src/ai/internal/mcpProtocol/v2024_11_05.ts +3 -1
  90. package/src/ai/internal/mcpProtocol/v2025_03_26.ts +3 -1
  91. package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -1
  92. package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -1
  93. package/src/ai/internal/mcpRuntime.ts +2 -6
  94. package/src/ai/internal/mcpSkills.ts +70 -2
  95. package/src/ai/internal/structured-output.ts +6 -1
  96. package/src/cli/Command.ts +5 -1
  97. package/src/cli/internal/lexer.ts +14 -0
  98. package/src/cli/internal/parser.ts +28 -20
  99. package/src/cli/internal/wizard.ts +4 -0
  100. package/src/http/HttpMiddleware.ts +13 -2
  101. package/src/http/internal/requestState.ts +20 -0
  102. package/src/http-api/HttpApi.ts +80 -0
  103. package/src/http-api/HttpApiBuilder.ts +9 -1
  104. package/src/http-api/HttpApiClient.ts +13 -2
  105. package/src/http-api/HttpApiSchema.ts +68 -2
  106. package/src/internal/schema/fromJsonSchemaDocument.ts +154 -34
  107. package/src/internal/schema/toCodeDocument.ts +8 -0
  108. package/src/internal/version.ts +1 -1
  109. package/src/testing/TestClock.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TestClock.js","names":[],"sources":["../../src/testing/TestClock.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;AAaA,OAAO,KAAK,GAAG,MAAM,aAAa;AAClC,OAAO,KAAK,KAAK,MAAM,aAAa;AACpC,OAAO,KAAK,OAAO,MAAM,eAAe;AACxC,OAAO,KAAK,OAAO,MAAM,eAAe;AACxC,OAAO,KAAK,IAAI,MAAM,YAAY;AAClC,OAAO,KAAK,QAAQ,MAAM,gBAAgB;AAC1C,OAAO,KAAK,MAAM,MAAM,cAAc;AACtC,OAAO,KAAK,KAAK,MAAM,aAAa;AACpC,SAAS,iBAAiB,QAAQ,mBAAmB;AACrD,OAAO,KAAK,KAAK,MAAM,aAAa;AACpC,OAAO,KAAK,KAAK,MAAM,aAAa;AACpC,OAAO,KAAK,SAAS,MAAM,iBAAiB;AAE5C,OAAO,KAAK,SAAS,MAAM,iBAAiB;AA6K5C;;;;AAIA,MAAM,cAAc,GAAG,sDAAsD,GAC3E,uEAAuE,GACvE,4BAA4B;AAE9B;;;;AAIA,MAAM,kBAAkB,GAAG,mDAAmD,GAC5E,0EAA0E,GAC1E,yDAAyD;AAE3D;;;;;AAKA,MAAM,UAAU,gBAAG,IAAI,OAAO,EAA4B;AAO1D,MAAM,cAAc,GAAgC;EAClD,YAAY,EAAE;CACf;AAED,MAAM,aAAa,gBAAG,MAAM,CAAC,SAAS,CAAC;AAEvC,MAAM,aAAa,GAAI,MAAc,IAAY;EAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;EACtC,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,WAAW,IAAI,SAAS,CAAC;EACtE,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,aAAa,GAAG,MAAM,CA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AAK,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAiC1D,MAAM,YAAY,gBAAG,IAAI,CAAC,UAAU,EAAgB","ignoreList":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "effect",
3
3
  "type": "module",
4
- "version": "4.1.3",
4
+ "version": "4.1.4",
5
5
  "license": "MIT",
6
6
  "description": "The missing standard library for TypeScript, for writing production-grade software.",
7
7
  "homepage": "https://effect.website",
@@ -2426,6 +2426,19 @@ export const MutableJsonReviver: DeclarationReviver<null> = makeFixedDeclaration
2426
2426
  Schema.MutableJson
2427
2427
  )
2428
2428
 
2429
+ interface FromJsonSchemaExperimentalOptions {
2430
+ /**
2431
+ * Closes objects with declared properties when every contributing object schema omits `additionalProperties`.
2432
+ * Closing happens after composition is normalized, preserving inherited fields.
2433
+ * Explicit additional-property declarations and free-form objects are preserved.
2434
+ * Closed objects strip excess keys by default; use `onExcessProperty: "error"` to reject them.
2435
+ *
2436
+ * @default false
2437
+ * @stability experimental
2438
+ */
2439
+ readonly closeObjects?: boolean | undefined
2440
+ }
2441
+
2429
2442
  /**
2430
2443
  * Options for importing JSON Schema Draft 2020-12 documents.
2431
2444
  *
@@ -2459,7 +2472,7 @@ export const MutableJsonReviver: DeclarationReviver<null> = makeFixedDeclaration
2459
2472
  * @category models
2460
2473
  * @since 4.0.0
2461
2474
  */
2462
- export interface FromJsonSchemaOptions {
2475
+ export interface FromJsonSchemaOptions extends FromJsonSchemaExperimentalOptions {
2463
2476
  readonly onEnter?: ((schema: JsonSchema.JsonSchema) => JsonSchema.JsonSchema) | undefined
2464
2477
  /**
2465
2478
  * Controls how reached JSON Schema regular expression patterns are imported.
@@ -3214,7 +3227,8 @@ export function fromRepresentations(
3214
3227
  * conditional keywords and `minContains` / `maxContains` without `contains` have no validation effect and are ignored.
3215
3228
  * - Objects and arrays used as `const` values or `enum` members are rejected. Only strings, numbers, booleans, and null
3216
3229
  * are supported.
3217
- * - Intersections of overlapping unions are limited to disjoint root-type partitions and finite primitive `anyOf`
3230
+ * - Intersections of overlapping unions are limited to alternatives separated by root types or required literal
3231
+ * properties, and finite primitive `anyOf`
3218
3232
  * literal sets, which may also be duplicated across branches. Other union intersections, including cases that would
3219
3233
  * duplicate any other nested choice, are rejected.
3220
3234
  * - Unknown extension keywords are ignored and their semantics are not enforced.
@@ -3264,7 +3278,8 @@ export function fromJsonSchemaDocument(
3264
3278
  * extension keywords are ignored and their semantics are not enforced.
3265
3279
  * - Objects and arrays used as `const` values or `enum` members are rejected. Only strings, numbers, booleans, and null
3266
3280
  * are supported.
3267
- * - Intersections of overlapping unions are limited to disjoint root-type partitions and finite primitive `anyOf`
3281
+ * - Intersections of overlapping unions are limited to alternatives separated by root types or required literal
3282
+ * properties, and finite primitive `anyOf`
3268
3283
  * literal sets, which may also be duplicated across branches. Other union intersections, including cases that would
3269
3284
  * duplicate any other nested choice, are rejected.
3270
3285
  * - Only local references to top-level definitions in the form `#/$defs/<escaped-token>` are supported, optionally
package/src/ai/Chat.ts CHANGED
@@ -423,13 +423,19 @@ export interface Chat {
423
423
  readonly generateObject: <
424
424
  ObjectEncoded extends Record<string, any>,
425
425
  ObjectSchema extends Schema.Encoder<ObjectEncoded, unknown>,
426
- Options extends NoExcessProperties<LanguageModel.GenerateObjectOptions<any, ObjectSchema>, Options>
426
+ Options extends NoExcessProperties<LanguageModel.GenerateObjectOptions<any, ObjectSchema, boolean>, Options>
427
427
  >(
428
- options: Options & LanguageModel.GenerateObjectOptions<LanguageModel.ExtractTools<Options>, ObjectSchema>
428
+ options:
429
+ & Options
430
+ & LanguageModel.GenerateObjectOptions<
431
+ LanguageModel.ExtractTools<Options>,
432
+ ObjectSchema,
433
+ false | Extract<Options["allowEmpty" & keyof Options], boolean>
434
+ >
429
435
  ) => Effect.Effect<
430
436
  LanguageModel.GenerateObjectResponse<
431
437
  LanguageModel.ExtractTools<Options>,
432
- ObjectSchema["Type"],
438
+ LanguageModel.ExtractObjectValue<Options, ObjectSchema["Type"]>,
433
439
  LanguageModel.ExtractToolParametersMode<Options>
434
440
  >,
435
441
  LanguageModel.ExtractError<Options>,
@@ -161,14 +161,24 @@ export interface LanguageModel {
161
161
  ObjectEncoded extends Record<string, any>,
162
162
  StructuredOutputSchema extends Schema.Encoder<ObjectEncoded, unknown>,
163
163
  Options extends NoExcessProperties<
164
- GenerateObjectOptions<any, StructuredOutputSchema>,
164
+ GenerateObjectOptions<any, StructuredOutputSchema, boolean>,
165
165
  Options
166
166
  >,
167
167
  Tools extends Record<string, Tool.Any> = {}
168
168
  >(
169
- options: Options & GenerateObjectOptions<Tools, StructuredOutputSchema>
169
+ options:
170
+ & Options
171
+ & GenerateObjectOptions<
172
+ Tools,
173
+ StructuredOutputSchema,
174
+ false | Extract<Options["allowEmpty" & keyof Options], boolean>
175
+ >
170
176
  ) => Effect.Effect<
171
- GenerateObjectResponse<Tools, StructuredOutputSchema["Type"], ExtractToolParametersMode<Options>>,
177
+ GenerateObjectResponse<
178
+ Tools,
179
+ ExtractObjectValue<Options, StructuredOutputSchema["Type"]>,
180
+ ExtractToolParametersMode<Options>
181
+ >,
172
182
  ExtractError<Options>,
173
183
  ExtractServices<Options> | StructuredOutputSchema["DecodingServices"]
174
184
  >
@@ -343,7 +353,8 @@ type GenerateTextOptionsWithoutToolkit = Omit<GenerateTextOptions<{}>, "toolkit"
343
353
  */
344
354
  export interface GenerateObjectOptions<
345
355
  Tools extends Record<string, Tool.Any>,
346
- StructuredOutputSchema extends Schema.Top
356
+ StructuredOutputSchema extends Schema.Top,
357
+ AllowEmpty extends boolean = false
347
358
  > extends GenerateTextOptions<Tools> {
348
359
  /**
349
360
  * The name of the structured output that should be generated. Used by some
@@ -351,6 +362,14 @@ export interface GenerateObjectOptions<
351
362
  */
352
363
  readonly objectName?: string | undefined
353
364
 
365
+ /**
366
+ * Whether to return `None` for empty or whitespace-only text and `Some` for
367
+ * valid output. Defaults to `false`; invalid nonempty output still fails.
368
+ * Use literal `true` for an `Option<A>` value; a widened boolean yields
369
+ * `A | Option<A>`.
370
+ */
371
+ readonly allowEmpty?: AllowEmpty | undefined
372
+
354
373
  /**
355
374
  * The schema to be used to specify the structure of the object to generate.
356
375
  */
@@ -523,7 +542,7 @@ export class GenerateObjectResponse<
523
542
  ParametersMode extends Response.ToolParametersMode = "decoded"
524
543
  > extends GenerateTextResponse<Tools, ParametersMode> {
525
544
  /**
526
- * The parsed structured object that conforms to the provided schema.
545
+ * The decoded schema value, wrapped in an `Option` when `allowEmpty` is enabled.
527
546
  */
528
547
  readonly value: A
529
548
 
@@ -604,6 +623,18 @@ export type ExtractTools<Options> = Options extends {
604
623
  } ? ExtractToolsFromToolkitOption<Exclude<ToolkitValue, undefined>>
605
624
  : {}
606
625
 
626
+ /**
627
+ * Resolves to `Option<A>` when `allowEmpty` is true, `A` when false or absent,
628
+ * or their union when the flag may be enabled.
629
+ *
630
+ * @stability unstable
631
+ * @category utility types
632
+ * @since 4.1.4
633
+ */
634
+ export type ExtractObjectValue<Options, A> = Options extends { readonly allowEmpty: true } ? Option.Option<A>
635
+ : true extends Options["allowEmpty" & keyof Options] ? A | Option.Option<A>
636
+ : A
637
+
607
638
  /**
608
639
  * Resolves to `"deferred"` when tool call resolution may be disabled with
609
640
  * deferred tool call validation. Otherwise resolves to `"encoded"` when tool
@@ -953,14 +984,24 @@ export const make: (params: {
953
984
  ObjectEncoded extends Record<string, any>,
954
985
  StructuredOutputSchema extends Schema.Encoder<ObjectEncoded, unknown>,
955
986
  Options extends NoExcessProperties<
956
- GenerateObjectOptions<any, StructuredOutputSchema>,
987
+ GenerateObjectOptions<any, StructuredOutputSchema, boolean>,
957
988
  Options
958
989
  >,
959
990
  Tools extends Record<string, Tool.Any> = {}
960
991
  >(
961
- options: Options & GenerateObjectOptions<Tools, StructuredOutputSchema>
992
+ options:
993
+ & Options
994
+ & GenerateObjectOptions<
995
+ Tools,
996
+ StructuredOutputSchema,
997
+ false | Extract<Options["allowEmpty" & keyof Options], boolean>
998
+ >
962
999
  ): Effect.Effect<
963
- GenerateObjectResponse<Tools, StructuredOutputSchema["Type"], ExtractToolParametersMode<Options>>,
1000
+ GenerateObjectResponse<
1001
+ Tools,
1002
+ ExtractObjectValue<Options, StructuredOutputSchema["Type"]>,
1003
+ ExtractToolParametersMode<Options>
1004
+ >,
964
1005
  ExtractError<Options>,
965
1006
  ExtractServices<Options> | StructuredOutputSchema["DecodingServices"]
966
1007
  > => {
@@ -1009,7 +1050,7 @@ export const make: (params: {
1009
1050
  })
1010
1051
  })
1011
1052
 
1012
- const value = yield* resolveStructuredOutput(content as any, codec)
1053
+ const value = yield* resolveStructuredOutput(content as any, codec, options.allowEmpty ?? false)
1013
1054
 
1014
1055
  return new GenerateObjectResponse(value, content)
1015
1056
  },
@@ -1948,15 +1989,21 @@ export const generateObject = <
1948
1989
  ObjectEncoded extends Record<string, any>,
1949
1990
  StructuredOutputSchema extends Schema.Encoder<ObjectEncoded, unknown>,
1950
1991
  Options extends NoExcessProperties<
1951
- GenerateObjectOptions<any, StructuredOutputSchema>,
1992
+ GenerateObjectOptions<any, StructuredOutputSchema, boolean>,
1952
1993
  Options
1953
1994
  >
1954
1995
  >(
1955
- options: Options & GenerateObjectOptions<ExtractTools<Options>, StructuredOutputSchema>
1996
+ options:
1997
+ & Options
1998
+ & GenerateObjectOptions<
1999
+ ExtractTools<Options>,
2000
+ StructuredOutputSchema,
2001
+ false | Extract<Options["allowEmpty" & keyof Options], boolean>
2002
+ >
1956
2003
  ): Effect.Effect<
1957
2004
  GenerateObjectResponse<
1958
2005
  ExtractTools<Options>,
1959
- StructuredOutputSchema["Type"],
2006
+ ExtractObjectValue<Options, StructuredOutputSchema["Type"]>,
1960
2007
  ExtractToolParametersMode<Options>
1961
2008
  >,
1962
2009
  ExtractError<Options>,
@@ -2609,7 +2656,11 @@ export const getObjectName = <StructuredOutputSchema extends Schema.Constraint>(
2609
2656
 
2610
2657
  const resolveStructuredOutput = Effect.fnUntraced(function*<
2611
2658
  StructuredOutputSchema extends Schema.Constraint
2612
- >(response: ReadonlyArray<Response.AllParts<any>>, schema: StructuredOutputSchema) {
2659
+ >(
2660
+ response: ReadonlyArray<Response.AllParts<any>>,
2661
+ schema: StructuredOutputSchema,
2662
+ allowEmpty: boolean
2663
+ ) {
2613
2664
  const texts: Array<string> = []
2614
2665
  for (const part of response) {
2615
2666
  if (part.type === "text") {
@@ -2619,6 +2670,10 @@ const resolveStructuredOutput = Effect.fnUntraced(function*<
2619
2670
 
2620
2671
  const text = texts.join("")
2621
2672
 
2673
+ if (allowEmpty && text.trim().length === 0) {
2674
+ return Option.none()
2675
+ }
2676
+
2622
2677
  if (text.length === 0) {
2623
2678
  return yield* AiError.make({
2624
2679
  module: "LanguageModel",
@@ -2631,12 +2686,13 @@ const resolveStructuredOutput = Effect.fnUntraced(function*<
2631
2686
  }
2632
2687
 
2633
2688
  const decode = Schema.decodeEffect(Schema.fromJsonString(schema))
2634
- return yield* Effect.mapError(decode(text), (error) =>
2689
+ const value = yield* Effect.mapError(decode(text), (error) =>
2635
2690
  AiError.make({
2636
2691
  module: "LanguageModel",
2637
2692
  method: "generateObject",
2638
2693
  reason: AiError.StructuredOutputError.fromSchemaError(error, text)
2639
2694
  }))
2695
+ return allowEmpty ? Option.some(value) : value
2640
2696
  })
2641
2697
 
2642
2698
  const applySpanTransformer = (
@@ -259,11 +259,6 @@ export const isMcpClient = (value: unknown): value is McpClient => Predicate.has
259
259
  * `crypto.subtle`.
260
260
  * Schema decoding requires the schema's services from the caller.
261
261
  *
262
- * **Gotchas**
263
- *
264
- * The Skills extension requires protocol 2026-07-28. With `skills: true` on an
265
- * earlier protocol, construction fails with an `UnsupportedError`.
266
- *
267
262
  * @stability experimental
268
263
  * @category constructors
269
264
  * @since 4.0.6
@@ -296,12 +291,6 @@ export const make: (options: {
296
291
  const protocol = transport.protocol
297
292
  const version = protocol.protocolVersion
298
293
  const modern = version === "2026-07-28"
299
- const skillsEnabled = options.extensions?.skills === true
300
- if (skillsEnabled && !modern) {
301
- return yield* fail(
302
- new UnsupportedError({ description: "The MCP Skills extension requires at least protocol 2026-07-28" })
303
- )
304
- }
305
294
  const timeout = options.timeout ?? DEFAULT_TIMEOUT
306
295
  const discoveryLimits = yield* resolveDiscoveryLimits(options.discoveryLimits, DEFAULT_DISCOVERY_LIMITS)
307
296
  const closed = yield* Deferred.make<never, McpClientError>()
@@ -321,6 +310,7 @@ export const make: (options: {
321
310
 
322
311
  // Modern requests carry the client identity in every request.
323
312
  // https://modelcontextprotocol.io/specification/2026-07-28/basic/index
313
+ const skillsEnabled = options.extensions?.skills === true
324
314
  const clientCapabilities = skillsEnabled ? { extensions: { [McpSkills.EXTENSION_ID]: {} } } : {}
325
315
  const meta = {
326
316
  "io.modelcontextprotocol/protocolVersion": version,
@@ -3911,9 +3911,7 @@ const toSkillSourceFile = (path: string, file: SkillFile): McpSkills.SourceFile
3911
3911
  * `skills/list` and `skills/get` with a manifest of every file's SHA-256
3912
3912
  * digest and size, computed from the bytes served. Every directory of the
3913
3913
  * skill namespace is readable with `resources/directory/read`. The server
3914
- * declares the extension on protocol 2026-07-28 once any skill is registered.
3915
- * Earlier revisions neither declare it nor answer its methods, but still serve
3916
- * the skill's files through `resources/read`.
3914
+ * declares the extension once any skill is registered.
3917
3915
  *
3918
3916
  * Fails when the skill breaks the extension's rules: a name that does not
3919
3917
  * match the URI, a `SKILL.md` without YAML frontmatter, frontmatter that is
@@ -0,0 +1,318 @@
1
+ /**
2
+ * Authenticates an `HttpClient` by exchanging workload identity tokens for cached
3
+ * access tokens. For Anthropic, OpenAI or OpenRouter, use the provider package's
4
+ * `AnthropicWorkloadIdentity`, `OpenAiWorkloadIdentity` or
5
+ * `OpenRouterWorkloadIdentity` module.
6
+ *
7
+ * @stability unstable
8
+ * @since 4.1.3
9
+ */
10
+ import * as Cache from "../Cache.ts"
11
+ import * as Duration from "../Duration.ts"
12
+ import * as Effect from "../Effect.ts"
13
+ import * as Exit from "../Exit.ts"
14
+ import * as FetchHttpClient from "../http/FetchHttpClient.ts"
15
+ import * as HttpClient from "../http/HttpClient.ts"
16
+ import * as HttpClientError from "../http/HttpClientError.ts"
17
+ import * as HttpClientRequest from "../http/HttpClientRequest.ts"
18
+ import * as HttpClientResponse from "../http/HttpClientResponse.ts"
19
+ import * as Option from "../Option.ts"
20
+ import * as Redacted from "../Redacted.ts"
21
+ import * as Schema from "../Schema.ts"
22
+ import * as Stream from "../Stream.ts"
23
+
24
+ const MAX_RESPONSE_BYTES = 1024 * 1024
25
+ const cacheKey = "accessToken"
26
+
27
+ const decodeTokenResponse = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Struct({
28
+ // Printable ASCII only, so the token is safe to send in a header.
29
+ access_token: Schema.String.check(Schema.isPattern(/^[\x21-\x7E]+$/)),
30
+ expires_in: Schema.optional(Schema.Finite.check(Schema.isGreaterThan(0)))
31
+ })))
32
+
33
+ const checkTokenUrl = (url: string): Effect.Effect<void> =>
34
+ Effect.sync(() => {
35
+ const { hostname, protocol } = new URL(url)
36
+ if (protocol === "https:") return
37
+ if (protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(hostname)) return
38
+ throw new Error(`Refusing to send an identity token to the non-https token URL "${url}"`)
39
+ })
40
+
41
+ // Keep only messages: errors may reference requests containing the identity token.
42
+ const errorMessages = (error: unknown): Array<string> => {
43
+ const messages: Array<string> = []
44
+ for (let cause = error, depth = 0; cause instanceof Error && depth < 5; cause = cause.cause, depth++) {
45
+ if (cause.message !== "") messages.push(cause.message)
46
+ }
47
+ return messages
48
+ }
49
+
50
+ // Decode escaped tokens before redacting values; the second pass covers keys.
51
+ const redactBody = (body: string, redact: (text: string) => string): string => {
52
+ try {
53
+ return redact(JSON.stringify(JSON.parse(body, (_, value) => typeof value === "string" ? redact(value) : value)))
54
+ } catch {
55
+ return redact(body)
56
+ }
57
+ }
58
+
59
+ // Resolves to `undefined` when the body is missing, unreadable or over the limit.
60
+ const readBody = (response: HttpClientResponse.HttpClientResponse): Effect.Effect<string | undefined> =>
61
+ Effect.suspend(() => {
62
+ let size = 0
63
+ return response.stream.pipe(
64
+ Stream.takeWhile((chunk) => (size += chunk.length) <= MAX_RESPONSE_BYTES),
65
+ Stream.decodeText(),
66
+ Stream.mkString,
67
+ Effect.map((body) => size > MAX_RESPONSE_BYTES ? undefined : body),
68
+ Effect.orElseSucceed(() => undefined)
69
+ )
70
+ })
71
+
72
+ /**
73
+ * Creates an `HttpClient` transform that authenticates requests with an access
74
+ * token obtained by exchanging an identity token at a token endpoint.
75
+ *
76
+ * **When to use**
77
+ *
78
+ * Use to add workload identity federation to a provider client whose token
79
+ * endpoint answers a `POST` request with a JSON object holding an
80
+ * `access_token` and an `expires_in` number of seconds.
81
+ *
82
+ * **Details**
83
+ *
84
+ * Each exchange reruns `identityToken` and passes its trimmed value and a JSON-
85
+ * accepting `POST` request to `exchangeRequest`. The response's `access_token`
86
+ * is sent as `Authorization: Bearer`. Its lifetime is `expires_in` seconds,
87
+ * falling back to `defaultExpiresIn` when absent.
88
+ *
89
+ * Tokens are cached until 30 seconds before expiry or three quarters of their
90
+ * lifetime, whichever is later. Concurrent requests share one exchange;
91
+ * interrupting a waiter does not cancel it.
92
+ *
93
+ * Exchanges use the `HttpClient` captured by `make`, not the transformed client.
94
+ * Failures are `HttpClientError`s: `StatusCodeError` for rejected exchanges,
95
+ * `TransportError` for transport failures or redirects, `DecodeError` for
96
+ * invalid responses, and `EncodeError` for failing or empty identity tokens.
97
+ * Identity-token source failures are preserved as causes and must not contain
98
+ * secrets.
99
+ *
100
+ * Exchange errors omit the request body and retain only transport error
101
+ * messages. The literal identity token is redacted from those messages and
102
+ * rejection headers and bodies, including JSON-escaped occurrences.
103
+ *
104
+ * **Gotchas**
105
+ *
106
+ * - No background refresh: the next request after expiry waits for an exchange.
107
+ * - A 401 invalidates only the token used by that request, without replay.
108
+ * - The exchange is never retried.
109
+ * - Every request carries the access token regardless of URL.
110
+ * - The exchange client must not follow redirects or log request bodies.
111
+ * `FetchHttpClient` redirects are disabled; redirect responses fail the exchange.
112
+ * - `tokenUrl` must use `https`, or `http` on `localhost`, `127.0.0.1` or
113
+ * `::1`. Any other URL is a defect.
114
+ * - `exchangeRequest` may change only the body and headers; other changes are
115
+ * defects and send nothing. Put query parameters in `tokenUrl`.
116
+ * - `defaultExpiresIn` must be positive and finite or `make` defects.
117
+ * Numeric durations are milliseconds; response `expires_in` is seconds.
118
+ * - Only the literal identity token is redacted, after JSON decoding. A token
119
+ * endpoint that echoes it in another encoding is not covered.
120
+ * - The response is limited to 1 MiB, and the access token to printable ASCII.
121
+ *
122
+ * **Example** (Exchanging a token at an RFC 8693 style endpoint)
123
+ *
124
+ * ```ts
125
+ * import { Effect, FileSystem, Redacted } from "effect"
126
+ * import { WorkloadIdentity } from "effect/ai"
127
+ * import { HttpClientRequest } from "effect/http"
128
+ *
129
+ * // Requires an `HttpClient` for the exchange, and a `FileSystem`.
130
+ * const transformClient = WorkloadIdentity.make({
131
+ * tokenUrl: "https://auth.example.com/oauth/token",
132
+ * identityToken: Effect.gen(function*() {
133
+ * const fs = yield* FileSystem.FileSystem
134
+ * return Redacted.make(yield* fs.readFileString("/var/run/secrets/example.com/token"))
135
+ * }),
136
+ * exchangeRequest: (request, identityToken) =>
137
+ * request.pipe(HttpClientRequest.bodyJsonUnsafe({
138
+ * grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
139
+ * subject_token: identityToken,
140
+ * subject_token_type: "urn:ietf:params:oauth:token-type:jwt"
141
+ * })),
142
+ * defaultExpiresIn: "1 hour"
143
+ * })
144
+ * ```
145
+ *
146
+ * @stability unstable
147
+ * @category constructors
148
+ * @since 4.1.3
149
+ */
150
+ export const make = <E = never, R = never>(options: {
151
+ /**
152
+ * The URL of the token endpoint.
153
+ */
154
+ readonly tokenUrl: string
155
+ /**
156
+ * Produces the identity token to exchange. Runs again on every exchange.
157
+ */
158
+ readonly identityToken: Effect.Effect<Redacted.Redacted<string>, E, R>
159
+ /**
160
+ * Completes the exchange request with the identity token. `request` is a
161
+ * `POST` request to `tokenUrl` that accepts JSON, and `identityToken` is
162
+ * the trimmed token. Runs on every exchange.
163
+ *
164
+ * Set the body and headers only. Changing the method, URL, URL parameters or
165
+ * hash is a defect, so the identity token is only sent to `tokenUrl`.
166
+ */
167
+ readonly exchangeRequest: (
168
+ request: HttpClientRequest.HttpClientRequest,
169
+ identityToken: string
170
+ ) => HttpClientRequest.HttpClientRequest
171
+ /**
172
+ * The lifetime of an access token when the token response has no
173
+ * `expires_in`. Without it, such a response fails the exchange. An
174
+ * `expires_in` in the response takes precedence.
175
+ *
176
+ * Must be positive and finite. A number is milliseconds.
177
+ */
178
+ readonly defaultExpiresIn?: Duration.Input | undefined
179
+ }): Effect.Effect<
180
+ (client: HttpClient.HttpClient) => HttpClient.HttpClient,
181
+ never,
182
+ HttpClient.HttpClient | R
183
+ > =>
184
+ Effect.gen(function*() {
185
+ const tokenUrl = options.tokenUrl
186
+ yield* checkTokenUrl(tokenUrl)
187
+ const httpClient = yield* HttpClient.HttpClient
188
+ const defaultExpiresIn = options.defaultExpiresIn === undefined
189
+ ? undefined
190
+ : Duration.toSeconds(options.defaultExpiresIn)
191
+ if (defaultExpiresIn !== undefined && !(defaultExpiresIn > 0 && defaultExpiresIn < Infinity)) {
192
+ return yield* Effect.die(new Error("`defaultExpiresIn` must be a positive finite duration"))
193
+ }
194
+
195
+ // Errors must not retain the exchange request body.
196
+ const errorRequest = HttpClientRequest.post(tokenUrl)
197
+ const preparedRequest = HttpClientRequest.acceptJson(errorRequest)
198
+ const requestError = (description: string) =>
199
+ new HttpClientError.HttpClientError({
200
+ reason: new HttpClientError.TransportError({ request: errorRequest, description })
201
+ })
202
+ const identityTokenError = (description: string, cause?: unknown) =>
203
+ new HttpClientError.HttpClientError({
204
+ reason: new HttpClientError.EncodeError({ request: errorRequest, description, cause })
205
+ })
206
+
207
+ const exchange = Effect.gen(function*() {
208
+ const identityToken = Redacted.value(
209
+ yield* Effect.mapError(
210
+ options.identityToken,
211
+ (cause) => identityTokenError("Failed to load the identity token", cause)
212
+ )
213
+ ).trim()
214
+ if (identityToken === "") {
215
+ return yield* identityTokenError("The identity token is empty")
216
+ }
217
+ const redact = (text: string) => text.replaceAll(identityToken, "<redacted>")
218
+ const errorResponse = (response: HttpClientResponse.HttpClientResponse, body?: string) =>
219
+ HttpClientResponse.fromWeb(
220
+ errorRequest,
221
+ new Response(body === undefined ? null : redactBody(body, redact), {
222
+ status: response.status,
223
+ headers: Object.entries(response.headers).map(([name, value]): [string, string] => [name, redact(value)])
224
+ })
225
+ )
226
+ const invalidResponse = (response: HttpClientResponse.HttpClientResponse) =>
227
+ new HttpClientError.HttpClientError({
228
+ reason: new HttpClientError.DecodeError({
229
+ request: errorRequest,
230
+ response: errorResponse(response),
231
+ description: "The token endpoint returned an invalid token response"
232
+ })
233
+ })
234
+ const request = options.exchangeRequest(preparedRequest, identityToken)
235
+ // Keep the identity token confined to the validated endpoint.
236
+ if (
237
+ request.method !== preparedRequest.method || request.url !== preparedRequest.url ||
238
+ request.urlParams.params.length > 0 || Option.isSome(request.hash)
239
+ ) {
240
+ return yield* Effect.die(
241
+ new Error(
242
+ `\`exchangeRequest\` must keep the method, URL, URL parameters and hash of the "POST ${tokenUrl}" request`
243
+ )
244
+ )
245
+ }
246
+ const fetchInit = yield* Effect.serviceOption(FetchHttpClient.RequestInit)
247
+ const response = yield* httpClient.execute(request).pipe(
248
+ // Prevent redirects from forwarding the identity token.
249
+ Effect.provideService(FetchHttpClient.RequestInit, { ...Option.getOrUndefined(fetchInit), redirect: "manual" }),
250
+ Effect.catch((error) =>
251
+ error.response === undefined
252
+ ? Effect.fail(requestError(
253
+ redact([error.reason.description, ...errorMessages(error.cause)].filter(Boolean).join(": ")) ||
254
+ "Failed to reach the token endpoint"
255
+ ))
256
+ : Effect.succeed(error.response)
257
+ )
258
+ )
259
+ const status = response.status
260
+ // Fetch may report manual redirects as opaque responses with status 0.
261
+ if (status < 200 || status >= 600 || (status >= 300 && status < 400)) {
262
+ return yield* requestError(
263
+ `The token endpoint responded with the status ${status}. Redirects are not followed`
264
+ )
265
+ }
266
+ const body = yield* readBody(response)
267
+ if (status >= 300) {
268
+ return yield* new HttpClientError.HttpClientError({
269
+ reason: new HttpClientError.StatusCodeError({
270
+ request: errorRequest,
271
+ response: errorResponse(response, body)
272
+ })
273
+ })
274
+ }
275
+ const token = decodeTokenResponse(body)
276
+ if (Option.isNone(token)) {
277
+ return yield* invalidResponse(response)
278
+ }
279
+ const expiresIn = token.value.expires_in ?? defaultExpiresIn
280
+ if (expiresIn === undefined) {
281
+ return yield* invalidResponse(response)
282
+ }
283
+ return { value: Redacted.make(token.value.access_token), expiresIn }
284
+ })
285
+
286
+ const cache = yield* Cache.makeWith((_: typeof cacheKey) => exchange, {
287
+ capacity: 1,
288
+ // Stop using a token up to 30 seconds early to allow for clock differences
289
+ // and request latency. Failed exchanges are not cached.
290
+ timeToLive: (exit) =>
291
+ Exit.isSuccess(exit)
292
+ ? Duration.seconds(Math.max(exit.value.expiresIn - 30, exit.value.expiresIn * 0.75))
293
+ : Duration.zero
294
+ })
295
+
296
+ const invalidate = (request: HttpClientRequest.HttpClientRequest) =>
297
+ Cache.invalidateWhen(
298
+ cache,
299
+ cacheKey,
300
+ (token) => request.headers.authorization === `Bearer ${Redacted.value(token.value)}`
301
+ )
302
+
303
+ return (client) =>
304
+ client.pipe(
305
+ HttpClient.mapRequestEffect((request) =>
306
+ Effect.map(
307
+ Cache.get(cache, cacheKey),
308
+ (token) => HttpClientRequest.bearerToken(request, token.value)
309
+ )
310
+ ),
311
+ HttpClient.transformResponse((effect) =>
312
+ effect.pipe(
313
+ Effect.tap((response) => response.status === 401 ? invalidate(response.request) : Effect.void),
314
+ Effect.tapError((error) => error.response?.status === 401 ? invalidate(error.request) : Effect.void)
315
+ )
316
+ )
317
+ )
318
+ })