@executor-js/sdk 1.5.14 → 1.5.16

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.
@@ -3018,6 +3018,21 @@ var ToolHttpMetaSchema = Schema.Struct({
3018
3018
  status: Schema.Number,
3019
3019
  headers: Schema.Record(Schema.String, Schema.String)
3020
3020
  });
3021
+ var ToolFileSchema = Schema.TaggedStruct("ToolFile", {
3022
+ name: Schema.optional(Schema.String),
3023
+ mimeType: Schema.String,
3024
+ encoding: Schema.Literal("base64"),
3025
+ data: Schema.String.annotate({
3026
+ description: "Base64-encoded file bytes.",
3027
+ contentEncoding: "base64"
3028
+ }),
3029
+ byteLength: Schema.Int.annotate({
3030
+ description: "Raw file size in bytes before base64 encoding."
3031
+ })
3032
+ });
3033
+ var ToolFileJsonSchema = Schema.toJsonSchemaDocument(ToolFileSchema).schema;
3034
+ var matchesToolFileSchema = Schema.is(ToolFileSchema);
3035
+ var isToolFile = (value) => matchesToolFileSchema(value);
3021
3036
  var ToolResult = {
3022
3037
  ok: (data, meta) => ({
3023
3038
  ok: true,
@@ -4026,6 +4041,13 @@ var looseDb = (db) => db;
4026
4041
  var accessItemId = (owner, integration, name) => `oauth:${owner}:${integration}:${name}`;
4027
4042
  var refreshItemIdFor = (accessId) => `${accessId}:refresh`;
4028
4043
  var dedupeScopes = (scopes) => [...new Set(scopes)];
4044
+ var recordedOAuthScope = (token, requestedScopes) => {
4045
+ if (token.scope == null) return requestedScopes.join(" ") || null;
4046
+ const granted = token.scope.split(/\s+/).filter(Boolean);
4047
+ const coveredByRefreshToken = token.refresh_token && requestedScopes.includes("offline_access") ? ["offline_access"] : [];
4048
+ const recorded = dedupeScopes([...granted, ...coveredByRefreshToken]);
4049
+ return recorded.join(" ") || null;
4050
+ };
4029
4051
  var decodeJsonPayload = Schema4.decodeUnknownOption(Schema4.UnknownFromJsonString);
4030
4052
  var requestedScopesFromPayload = (payload) => {
4031
4053
  const decoded = typeof payload === "string" ? decodeJsonPayload(payload).pipe(Option2.getOrElse(() => payload)) : payload;
@@ -4501,12 +4523,11 @@ var makeOAuthService = (deps) => {
4501
4523
  oauthClientOwner: clientOwner,
4502
4524
  refreshItemId,
4503
4525
  expiresAt: expiresAtFrom(token),
4504
- // Benign fallback (kept by design): record the granted scope the AS
4505
- // echoed back; when it omits `scope` (some servers do), fall back to the
4506
- // scopes we requested (declared client). This only affects the recorded
4507
- // scope label, not what the token can do, so a guess here masks no
4508
- // misconfiguration.
4509
- oauthScope: token.scope ?? (requestedScopes.join(" ") || null)
4526
+ // Record the granted scope the AS echoed back. Some providers, including
4527
+ // Microsoft, issue a refresh token for `offline_access` but omit that
4528
+ // non-resource scope from the token `scope` string, so preserve it when
4529
+ // the refresh token proves it was granted.
4530
+ oauthScope: recordedOAuthScope(token, requestedScopes)
4510
4531
  });
4511
4532
  });
4512
4533
  const deleteSession = (state) => deps.fuma.use(
@@ -4558,6 +4579,7 @@ var makeOAuthService = (deps) => {
4558
4579
 
4559
4580
  // src/executor.ts
4560
4581
  var PLUGIN_STORAGE_DELETE_KEY_BATCH_SIZE = 90;
4582
+ var PLUGIN_STORAGE_CREATE_ROW_BATCH_SIZE = 90;
4561
4583
  var MAX_APPROVAL_ARGUMENT_PREVIEW_CHARS = 4e3;
4562
4584
  var acceptAllHandler = () => Effect8.succeed(ElicitationResponse.make({ action: "accept" }));
4563
4585
  var resolveElicitationHandler = (onElicitation) => onElicitation === "accept-all" ? acceptAllHandler : onElicitation;
@@ -4955,20 +4977,26 @@ var makePluginStorageFacade = (input) => {
4955
4977
  if (uniqueEntries.length === 0) return;
4956
4978
  yield* deleteManyImpl(owner, os.subject, uniqueEntries);
4957
4979
  const now = /* @__PURE__ */ new Date();
4958
- yield* input.core.createMany(
4959
- "plugin_storage",
4960
- uniqueEntries.map((entry) => ({
4961
- tenant,
4962
- owner: os.owner,
4963
- subject: os.subject,
4964
- plugin_id: input.pluginId,
4965
- collection: entry.collection,
4966
- key: entry.key,
4967
- data: entry.data,
4968
- created_at: now,
4969
- updated_at: now
4970
- }))
4971
- );
4980
+ for (let offset = 0; offset < uniqueEntries.length; offset += PLUGIN_STORAGE_CREATE_ROW_BATCH_SIZE) {
4981
+ const batchEntries = uniqueEntries.slice(
4982
+ offset,
4983
+ offset + PLUGIN_STORAGE_CREATE_ROW_BATCH_SIZE
4984
+ );
4985
+ yield* input.core.createMany(
4986
+ "plugin_storage",
4987
+ batchEntries.map((entry) => ({
4988
+ tenant,
4989
+ owner: os.owner,
4990
+ subject: os.subject,
4991
+ plugin_id: input.pluginId,
4992
+ collection: entry.collection,
4993
+ key: entry.key,
4994
+ data: entry.data,
4995
+ created_at: now,
4996
+ updated_at: now
4997
+ }))
4998
+ );
4999
+ }
4972
5000
  });
4973
5001
  const removeManyImpl = (owner, entries) => Effect8.gen(function* () {
4974
5002
  const os = ownerSubject(owner);
@@ -6645,6 +6673,9 @@ export {
6645
6673
  definePluginStorageCollection,
6646
6674
  pluginStorageId,
6647
6675
  buildToolTypeScriptPreview,
6676
+ ToolFileSchema,
6677
+ ToolFileJsonSchema,
6678
+ isToolFile,
6648
6679
  ToolResult,
6649
6680
  isToolResult,
6650
6681
  annotateToolResultOutcome,
@@ -6654,4 +6685,4 @@ export {
6654
6685
  collectTables,
6655
6686
  createExecutor
6656
6687
  };
6657
- //# sourceMappingURL=chunk-WKKKHDH2.js.map
6688
+ //# sourceMappingURL=chunk-VICUTMT6.js.map