modal 0.3.11 → 0.3.12

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.
package/dist/index.cjs CHANGED
@@ -37891,6 +37891,7 @@ function imageBuilderVersion(version) {
37891
37891
 
37892
37892
  // src/client.ts
37893
37893
  var defaultProfile = getProfile(process.env["MODAL_PROFILE"]);
37894
+ var modalAuthToken;
37894
37895
  function authMiddleware(profile) {
37895
37896
  return async function* authMiddleware2(call, options) {
37896
37897
  if (!profile.tokenId || !profile.tokenSecret) {
@@ -37907,6 +37908,25 @@ function authMiddleware(profile) {
37907
37908
  options.metadata.set("x-modal-client-version", "1.0.0");
37908
37909
  options.metadata.set("x-modal-token-id", tokenId);
37909
37910
  options.metadata.set("x-modal-token-secret", tokenSecret);
37911
+ if (modalAuthToken) {
37912
+ options.metadata.set("x-modal-auth-token", modalAuthToken);
37913
+ }
37914
+ const prevOnHeader = options.onHeader;
37915
+ options.onHeader = (header) => {
37916
+ const token = header.get("x-modal-auth-token");
37917
+ if (token) {
37918
+ modalAuthToken = token;
37919
+ }
37920
+ prevOnHeader?.(header);
37921
+ };
37922
+ const prevOnTrailer = options.onTrailer;
37923
+ options.onTrailer = (trailer) => {
37924
+ const token = trailer.get("x-modal-auth-token");
37925
+ if (token) {
37926
+ modalAuthToken = token;
37927
+ }
37928
+ prevOnTrailer?.(trailer);
37929
+ };
37910
37930
  return yield* call.next(call.request, options);
37911
37931
  };
37912
37932
  }
@@ -38012,6 +38032,17 @@ var retryMiddleware = async function* retryMiddleware2(call, options) {
38012
38032
  }
38013
38033
  }
38014
38034
  };
38035
+ var inputPlaneClients = {};
38036
+ var getOrCreateInputPlaneClient = (serverUrl) => {
38037
+ const client2 = inputPlaneClients[serverUrl];
38038
+ if (client2) {
38039
+ return client2;
38040
+ }
38041
+ const profile = { ...clientProfile, serverUrl };
38042
+ const newClient = createClient(profile);
38043
+ inputPlaneClients[serverUrl] = newClient;
38044
+ return newClient;
38045
+ };
38015
38046
  function createClient(profile) {
38016
38047
  const channel = (0, import_nice_grpc.createChannel)(profile.serverUrl, void 0, {
38017
38048
  "grpc.max_receive_message_length": 100 * 1024 * 1024,
@@ -38669,8 +38700,20 @@ var App = class _App {
38669
38700
  });
38670
38701
  return new Sandbox2(createResp.sandboxId);
38671
38702
  }
38672
- async imageFromRegistry(tag) {
38673
- return await fromRegistryInternal(this.appId, tag);
38703
+ async imageFromRegistry(tag, secret) {
38704
+ let imageRegistryConfig;
38705
+ if (secret) {
38706
+ if (!(secret instanceof Secret)) {
38707
+ throw new TypeError(
38708
+ "secret must be a reference to an existing Secret, e.g. `await Secret.fromName('my_secret')`"
38709
+ );
38710
+ }
38711
+ imageRegistryConfig = {
38712
+ registryAuthType: 4 /* REGISTRY_AUTH_TYPE_STATIC_CREDS */,
38713
+ secretId: secret.secretId
38714
+ };
38715
+ }
38716
+ return await fromRegistryInternal(this.appId, tag, imageRegistryConfig);
38674
38717
  }
38675
38718
  async imageFromAwsEcr(tag, secret) {
38676
38719
  if (!(secret instanceof Secret)) {
@@ -38684,6 +38727,18 @@ var App = class _App {
38684
38727
  };
38685
38728
  return await fromRegistryInternal(this.appId, tag, imageRegistryConfig);
38686
38729
  }
38730
+ async imageFromGcpArtifactRegistry(tag, secret) {
38731
+ if (!(secret instanceof Secret)) {
38732
+ throw new TypeError(
38733
+ "secret must be a reference to an existing Secret, e.g. `await Secret.fromName('my_secret')`"
38734
+ );
38735
+ }
38736
+ const imageRegistryConfig = {
38737
+ registryAuthType: 2 /* REGISTRY_AUTH_TYPE_GCP */,
38738
+ secretId: secret.secretId
38739
+ };
38740
+ return await fromRegistryInternal(this.appId, tag, imageRegistryConfig);
38741
+ }
38687
38742
  };
38688
38743
 
38689
38744
  // src/cls.ts
@@ -39074,7 +39129,22 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
39074
39129
  return new _ControlPlaneInvocation(functionCallId);
39075
39130
  }
39076
39131
  async awaitOutput(timeout) {
39077
- return await pollFunctionOutput(this.functionCallId, timeout);
39132
+ return await pollFunctionOutput(
39133
+ (timeoutMillis) => this.#getOutput(timeoutMillis),
39134
+ timeout
39135
+ );
39136
+ }
39137
+ async #getOutput(timeoutMillis) {
39138
+ const response = await client.functionGetOutputs({
39139
+ functionCallId: this.functionCallId,
39140
+ maxValues: 1,
39141
+ timeout: timeoutMillis / 1e3,
39142
+ // Backend needs seconds
39143
+ lastEntryId: "0-0",
39144
+ clearOnSuccess: true,
39145
+ requestedAt: timeNowSeconds()
39146
+ });
39147
+ return response.outputs ? response.outputs[0] : void 0;
39078
39148
  }
39079
39149
  async retry(retryCount) {
39080
39150
  if (!this.input) {
@@ -39092,33 +39162,70 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
39092
39162
  this.inputJwt = functionRetryResponse.inputJwts[0];
39093
39163
  }
39094
39164
  };
39165
+ var InputPlaneInvocation = class _InputPlaneInvocation {
39166
+ client;
39167
+ functionId;
39168
+ input;
39169
+ attemptToken;
39170
+ constructor(client2, functionId, input, attemptToken) {
39171
+ this.client = client2;
39172
+ this.functionId = functionId;
39173
+ this.input = input;
39174
+ this.attemptToken = attemptToken;
39175
+ }
39176
+ static async create(inputPlaneUrl, functionId, input) {
39177
+ const functionPutInputsItem = {
39178
+ idx: 0,
39179
+ input
39180
+ };
39181
+ const client2 = getOrCreateInputPlaneClient(inputPlaneUrl);
39182
+ const attemptStartResponse = await client2.attemptStart({
39183
+ functionId,
39184
+ input: functionPutInputsItem
39185
+ });
39186
+ return new _InputPlaneInvocation(
39187
+ client2,
39188
+ functionId,
39189
+ functionPutInputsItem,
39190
+ attemptStartResponse.attemptToken
39191
+ );
39192
+ }
39193
+ async awaitOutput(timeout) {
39194
+ return await pollFunctionOutput(
39195
+ (timeoutMillis) => this.#getOutput(timeoutMillis),
39196
+ timeout
39197
+ );
39198
+ }
39199
+ async #getOutput(timeoutMillis) {
39200
+ const response = await this.client.attemptAwait({
39201
+ attemptToken: this.attemptToken,
39202
+ requestedAt: timeNowSeconds(),
39203
+ timeoutSecs: timeoutMillis / 1e3
39204
+ });
39205
+ return response.output;
39206
+ }
39207
+ async retry(_retryCount) {
39208
+ const attemptRetryResponse = await this.client.attemptRetry({
39209
+ functionId: this.functionId,
39210
+ input: this.input,
39211
+ attemptToken: this.attemptToken
39212
+ });
39213
+ this.attemptToken = attemptRetryResponse.attemptToken;
39214
+ }
39215
+ };
39095
39216
  function timeNowSeconds() {
39096
39217
  return Date.now() / 1e3;
39097
39218
  }
39098
- async function pollFunctionOutput(functionCallId, timeout) {
39219
+ async function pollFunctionOutput(getOutput, timeout) {
39099
39220
  const startTime = Date.now();
39100
39221
  let pollTimeout = outputsTimeout;
39101
39222
  if (timeout !== void 0) {
39102
39223
  pollTimeout = Math.min(timeout, outputsTimeout);
39103
39224
  }
39104
39225
  while (true) {
39105
- let response;
39106
- try {
39107
- response = await client.functionGetOutputs({
39108
- functionCallId,
39109
- maxValues: 1,
39110
- timeout: pollTimeout / 1e3,
39111
- // Backend needs seconds
39112
- lastEntryId: "0-0",
39113
- clearOnSuccess: true,
39114
- requestedAt: timeNowSeconds()
39115
- });
39116
- } catch (err) {
39117
- throw new Error(`FunctionGetOutputs failed: ${err}`);
39118
- }
39119
- const outputs = response.outputs;
39120
- if (outputs.length > 0) {
39121
- return await processResult(outputs[0].result, outputs[0].dataFormat);
39226
+ const output = await getOutput(pollTimeout);
39227
+ if (output) {
39228
+ return await processResult(output.result, output.dataFormat);
39122
39229
  }
39123
39230
  if (timeout !== void 0) {
39124
39231
  const remainingTime = timeout - (Date.now() - startTime);
@@ -39212,10 +39319,12 @@ var maxSystemRetries = 8;
39212
39319
  var Function_ = class _Function_ {
39213
39320
  functionId;
39214
39321
  methodName;
39322
+ inputPlaneUrl;
39215
39323
  /** @ignore */
39216
- constructor(functionId, methodName) {
39324
+ constructor(functionId, methodName, inputPlaneUrl) {
39217
39325
  this.functionId = functionId;
39218
39326
  this.methodName = methodName;
39327
+ this.inputPlaneUrl = inputPlaneUrl;
39219
39328
  }
39220
39329
  static async lookup(appName, name, options = {}) {
39221
39330
  try {
@@ -39225,7 +39334,11 @@ var Function_ = class _Function_ {
39225
39334
  namespace: 1 /* DEPLOYMENT_NAMESPACE_WORKSPACE */,
39226
39335
  environmentName: environmentName(options.environment)
39227
39336
  });
39228
- return new _Function_(resp.functionId);
39337
+ return new _Function_(
39338
+ resp.functionId,
39339
+ void 0,
39340
+ resp.handleMetadata?.inputPlaneUrl
39341
+ );
39229
39342
  } catch (err) {
39230
39343
  if (err instanceof import_nice_grpc4.ClientError && err.code === import_nice_grpc4.Status.NOT_FOUND)
39231
39344
  throw new NotFoundError(`Function '${appName}/${name}' not found`);
@@ -39235,11 +39348,7 @@ var Function_ = class _Function_ {
39235
39348
  // Execute a single input into a remote Function.
39236
39349
  async remote(args = [], kwargs = {}) {
39237
39350
  const input = await this.#createInput(args, kwargs);
39238
- const invocation = await ControlPlaneInvocation.create(
39239
- this.functionId,
39240
- input,
39241
- 4 /* FUNCTION_CALL_INVOCATION_TYPE_SYNC */
39242
- );
39351
+ const invocation = await this.#createRemoteInvocation(input);
39243
39352
  let retryCount = 0;
39244
39353
  while (true) {
39245
39354
  try {
@@ -39254,6 +39363,20 @@ var Function_ = class _Function_ {
39254
39363
  }
39255
39364
  }
39256
39365
  }
39366
+ async #createRemoteInvocation(input) {
39367
+ if (this.inputPlaneUrl) {
39368
+ return await InputPlaneInvocation.create(
39369
+ this.inputPlaneUrl,
39370
+ this.functionId,
39371
+ input
39372
+ );
39373
+ }
39374
+ return await ControlPlaneInvocation.create(
39375
+ this.functionId,
39376
+ input,
39377
+ 4 /* FUNCTION_CALL_INVOCATION_TYPE_SYNC */
39378
+ );
39379
+ }
39257
39380
  // Spawn a single input into a remote function.
39258
39381
  async spawn(args = [], kwargs = {}) {
39259
39382
  const input = await this.#createInput(args, kwargs);
package/dist/index.d.cts CHANGED
@@ -235,8 +235,9 @@ declare class App {
235
235
  /** Lookup a deployed app by name, or create if it does not exist. */
236
236
  static lookup(name: string, options?: LookupOptions): Promise<App>;
237
237
  createSandbox(image: Image, options?: SandboxCreateOptions): Promise<Sandbox>;
238
- imageFromRegistry(tag: string): Promise<Image>;
238
+ imageFromRegistry(tag: string, secret?: Secret): Promise<Image>;
239
239
  imageFromAwsEcr(tag: string, secret: Secret): Promise<Image>;
240
+ imageFromGcpArtifactRegistry(tag: string, secret: Secret): Promise<Image>;
240
241
  }
241
242
 
242
243
  /** Options for initializing a client at runtime. */
@@ -283,8 +284,9 @@ declare class Function_ {
283
284
  #private;
284
285
  readonly functionId: string;
285
286
  readonly methodName: string | undefined;
287
+ readonly inputPlaneUrl: string | undefined;
286
288
  /** @ignore */
287
- constructor(functionId: string, methodName?: string);
289
+ constructor(functionId: string, methodName?: string, inputPlaneUrl?: string);
288
290
  static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
289
291
  remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
290
292
  spawn(args?: any[], kwargs?: Record<string, any>): Promise<FunctionCall>;
package/dist/index.d.ts CHANGED
@@ -235,8 +235,9 @@ declare class App {
235
235
  /** Lookup a deployed app by name, or create if it does not exist. */
236
236
  static lookup(name: string, options?: LookupOptions): Promise<App>;
237
237
  createSandbox(image: Image, options?: SandboxCreateOptions): Promise<Sandbox>;
238
- imageFromRegistry(tag: string): Promise<Image>;
238
+ imageFromRegistry(tag: string, secret?: Secret): Promise<Image>;
239
239
  imageFromAwsEcr(tag: string, secret: Secret): Promise<Image>;
240
+ imageFromGcpArtifactRegistry(tag: string, secret: Secret): Promise<Image>;
240
241
  }
241
242
 
242
243
  /** Options for initializing a client at runtime. */
@@ -283,8 +284,9 @@ declare class Function_ {
283
284
  #private;
284
285
  readonly functionId: string;
285
286
  readonly methodName: string | undefined;
287
+ readonly inputPlaneUrl: string | undefined;
286
288
  /** @ignore */
287
- constructor(functionId: string, methodName?: string);
289
+ constructor(functionId: string, methodName?: string, inputPlaneUrl?: string);
288
290
  static lookup(appName: string, name: string, options?: LookupOptions): Promise<Function_>;
289
291
  remote(args?: any[], kwargs?: Record<string, any>): Promise<any>;
290
292
  spawn(args?: any[], kwargs?: Record<string, any>): Promise<FunctionCall>;
package/dist/index.js CHANGED
@@ -37843,6 +37843,7 @@ function imageBuilderVersion(version) {
37843
37843
 
37844
37844
  // src/client.ts
37845
37845
  var defaultProfile = getProfile(process.env["MODAL_PROFILE"]);
37846
+ var modalAuthToken;
37846
37847
  function authMiddleware(profile) {
37847
37848
  return async function* authMiddleware2(call, options) {
37848
37849
  if (!profile.tokenId || !profile.tokenSecret) {
@@ -37859,6 +37860,25 @@ function authMiddleware(profile) {
37859
37860
  options.metadata.set("x-modal-client-version", "1.0.0");
37860
37861
  options.metadata.set("x-modal-token-id", tokenId);
37861
37862
  options.metadata.set("x-modal-token-secret", tokenSecret);
37863
+ if (modalAuthToken) {
37864
+ options.metadata.set("x-modal-auth-token", modalAuthToken);
37865
+ }
37866
+ const prevOnHeader = options.onHeader;
37867
+ options.onHeader = (header) => {
37868
+ const token = header.get("x-modal-auth-token");
37869
+ if (token) {
37870
+ modalAuthToken = token;
37871
+ }
37872
+ prevOnHeader?.(header);
37873
+ };
37874
+ const prevOnTrailer = options.onTrailer;
37875
+ options.onTrailer = (trailer) => {
37876
+ const token = trailer.get("x-modal-auth-token");
37877
+ if (token) {
37878
+ modalAuthToken = token;
37879
+ }
37880
+ prevOnTrailer?.(trailer);
37881
+ };
37862
37882
  return yield* call.next(call.request, options);
37863
37883
  };
37864
37884
  }
@@ -37964,6 +37984,17 @@ var retryMiddleware = async function* retryMiddleware2(call, options) {
37964
37984
  }
37965
37985
  }
37966
37986
  };
37987
+ var inputPlaneClients = {};
37988
+ var getOrCreateInputPlaneClient = (serverUrl) => {
37989
+ const client2 = inputPlaneClients[serverUrl];
37990
+ if (client2) {
37991
+ return client2;
37992
+ }
37993
+ const profile = { ...clientProfile, serverUrl };
37994
+ const newClient = createClient(profile);
37995
+ inputPlaneClients[serverUrl] = newClient;
37996
+ return newClient;
37997
+ };
37967
37998
  function createClient(profile) {
37968
37999
  const channel = createChannel(profile.serverUrl, void 0, {
37969
38000
  "grpc.max_receive_message_length": 100 * 1024 * 1024,
@@ -38621,8 +38652,20 @@ var App = class _App {
38621
38652
  });
38622
38653
  return new Sandbox2(createResp.sandboxId);
38623
38654
  }
38624
- async imageFromRegistry(tag) {
38625
- return await fromRegistryInternal(this.appId, tag);
38655
+ async imageFromRegistry(tag, secret) {
38656
+ let imageRegistryConfig;
38657
+ if (secret) {
38658
+ if (!(secret instanceof Secret)) {
38659
+ throw new TypeError(
38660
+ "secret must be a reference to an existing Secret, e.g. `await Secret.fromName('my_secret')`"
38661
+ );
38662
+ }
38663
+ imageRegistryConfig = {
38664
+ registryAuthType: 4 /* REGISTRY_AUTH_TYPE_STATIC_CREDS */,
38665
+ secretId: secret.secretId
38666
+ };
38667
+ }
38668
+ return await fromRegistryInternal(this.appId, tag, imageRegistryConfig);
38626
38669
  }
38627
38670
  async imageFromAwsEcr(tag, secret) {
38628
38671
  if (!(secret instanceof Secret)) {
@@ -38636,6 +38679,18 @@ var App = class _App {
38636
38679
  };
38637
38680
  return await fromRegistryInternal(this.appId, tag, imageRegistryConfig);
38638
38681
  }
38682
+ async imageFromGcpArtifactRegistry(tag, secret) {
38683
+ if (!(secret instanceof Secret)) {
38684
+ throw new TypeError(
38685
+ "secret must be a reference to an existing Secret, e.g. `await Secret.fromName('my_secret')`"
38686
+ );
38687
+ }
38688
+ const imageRegistryConfig = {
38689
+ registryAuthType: 2 /* REGISTRY_AUTH_TYPE_GCP */,
38690
+ secretId: secret.secretId
38691
+ };
38692
+ return await fromRegistryInternal(this.appId, tag, imageRegistryConfig);
38693
+ }
38639
38694
  };
38640
38695
 
38641
38696
  // src/cls.ts
@@ -39026,7 +39081,22 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
39026
39081
  return new _ControlPlaneInvocation(functionCallId);
39027
39082
  }
39028
39083
  async awaitOutput(timeout) {
39029
- return await pollFunctionOutput(this.functionCallId, timeout);
39084
+ return await pollFunctionOutput(
39085
+ (timeoutMillis) => this.#getOutput(timeoutMillis),
39086
+ timeout
39087
+ );
39088
+ }
39089
+ async #getOutput(timeoutMillis) {
39090
+ const response = await client.functionGetOutputs({
39091
+ functionCallId: this.functionCallId,
39092
+ maxValues: 1,
39093
+ timeout: timeoutMillis / 1e3,
39094
+ // Backend needs seconds
39095
+ lastEntryId: "0-0",
39096
+ clearOnSuccess: true,
39097
+ requestedAt: timeNowSeconds()
39098
+ });
39099
+ return response.outputs ? response.outputs[0] : void 0;
39030
39100
  }
39031
39101
  async retry(retryCount) {
39032
39102
  if (!this.input) {
@@ -39044,33 +39114,70 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
39044
39114
  this.inputJwt = functionRetryResponse.inputJwts[0];
39045
39115
  }
39046
39116
  };
39117
+ var InputPlaneInvocation = class _InputPlaneInvocation {
39118
+ client;
39119
+ functionId;
39120
+ input;
39121
+ attemptToken;
39122
+ constructor(client2, functionId, input, attemptToken) {
39123
+ this.client = client2;
39124
+ this.functionId = functionId;
39125
+ this.input = input;
39126
+ this.attemptToken = attemptToken;
39127
+ }
39128
+ static async create(inputPlaneUrl, functionId, input) {
39129
+ const functionPutInputsItem = {
39130
+ idx: 0,
39131
+ input
39132
+ };
39133
+ const client2 = getOrCreateInputPlaneClient(inputPlaneUrl);
39134
+ const attemptStartResponse = await client2.attemptStart({
39135
+ functionId,
39136
+ input: functionPutInputsItem
39137
+ });
39138
+ return new _InputPlaneInvocation(
39139
+ client2,
39140
+ functionId,
39141
+ functionPutInputsItem,
39142
+ attemptStartResponse.attemptToken
39143
+ );
39144
+ }
39145
+ async awaitOutput(timeout) {
39146
+ return await pollFunctionOutput(
39147
+ (timeoutMillis) => this.#getOutput(timeoutMillis),
39148
+ timeout
39149
+ );
39150
+ }
39151
+ async #getOutput(timeoutMillis) {
39152
+ const response = await this.client.attemptAwait({
39153
+ attemptToken: this.attemptToken,
39154
+ requestedAt: timeNowSeconds(),
39155
+ timeoutSecs: timeoutMillis / 1e3
39156
+ });
39157
+ return response.output;
39158
+ }
39159
+ async retry(_retryCount) {
39160
+ const attemptRetryResponse = await this.client.attemptRetry({
39161
+ functionId: this.functionId,
39162
+ input: this.input,
39163
+ attemptToken: this.attemptToken
39164
+ });
39165
+ this.attemptToken = attemptRetryResponse.attemptToken;
39166
+ }
39167
+ };
39047
39168
  function timeNowSeconds() {
39048
39169
  return Date.now() / 1e3;
39049
39170
  }
39050
- async function pollFunctionOutput(functionCallId, timeout) {
39171
+ async function pollFunctionOutput(getOutput, timeout) {
39051
39172
  const startTime = Date.now();
39052
39173
  let pollTimeout = outputsTimeout;
39053
39174
  if (timeout !== void 0) {
39054
39175
  pollTimeout = Math.min(timeout, outputsTimeout);
39055
39176
  }
39056
39177
  while (true) {
39057
- let response;
39058
- try {
39059
- response = await client.functionGetOutputs({
39060
- functionCallId,
39061
- maxValues: 1,
39062
- timeout: pollTimeout / 1e3,
39063
- // Backend needs seconds
39064
- lastEntryId: "0-0",
39065
- clearOnSuccess: true,
39066
- requestedAt: timeNowSeconds()
39067
- });
39068
- } catch (err) {
39069
- throw new Error(`FunctionGetOutputs failed: ${err}`);
39070
- }
39071
- const outputs = response.outputs;
39072
- if (outputs.length > 0) {
39073
- return await processResult(outputs[0].result, outputs[0].dataFormat);
39178
+ const output = await getOutput(pollTimeout);
39179
+ if (output) {
39180
+ return await processResult(output.result, output.dataFormat);
39074
39181
  }
39075
39182
  if (timeout !== void 0) {
39076
39183
  const remainingTime = timeout - (Date.now() - startTime);
@@ -39164,10 +39271,12 @@ var maxSystemRetries = 8;
39164
39271
  var Function_ = class _Function_ {
39165
39272
  functionId;
39166
39273
  methodName;
39274
+ inputPlaneUrl;
39167
39275
  /** @ignore */
39168
- constructor(functionId, methodName) {
39276
+ constructor(functionId, methodName, inputPlaneUrl) {
39169
39277
  this.functionId = functionId;
39170
39278
  this.methodName = methodName;
39279
+ this.inputPlaneUrl = inputPlaneUrl;
39171
39280
  }
39172
39281
  static async lookup(appName, name, options = {}) {
39173
39282
  try {
@@ -39177,7 +39286,11 @@ var Function_ = class _Function_ {
39177
39286
  namespace: 1 /* DEPLOYMENT_NAMESPACE_WORKSPACE */,
39178
39287
  environmentName: environmentName(options.environment)
39179
39288
  });
39180
- return new _Function_(resp.functionId);
39289
+ return new _Function_(
39290
+ resp.functionId,
39291
+ void 0,
39292
+ resp.handleMetadata?.inputPlaneUrl
39293
+ );
39181
39294
  } catch (err) {
39182
39295
  if (err instanceof ClientError4 && err.code === Status4.NOT_FOUND)
39183
39296
  throw new NotFoundError(`Function '${appName}/${name}' not found`);
@@ -39187,11 +39300,7 @@ var Function_ = class _Function_ {
39187
39300
  // Execute a single input into a remote Function.
39188
39301
  async remote(args = [], kwargs = {}) {
39189
39302
  const input = await this.#createInput(args, kwargs);
39190
- const invocation = await ControlPlaneInvocation.create(
39191
- this.functionId,
39192
- input,
39193
- 4 /* FUNCTION_CALL_INVOCATION_TYPE_SYNC */
39194
- );
39303
+ const invocation = await this.#createRemoteInvocation(input);
39195
39304
  let retryCount = 0;
39196
39305
  while (true) {
39197
39306
  try {
@@ -39206,6 +39315,20 @@ var Function_ = class _Function_ {
39206
39315
  }
39207
39316
  }
39208
39317
  }
39318
+ async #createRemoteInvocation(input) {
39319
+ if (this.inputPlaneUrl) {
39320
+ return await InputPlaneInvocation.create(
39321
+ this.inputPlaneUrl,
39322
+ this.functionId,
39323
+ input
39324
+ );
39325
+ }
39326
+ return await ControlPlaneInvocation.create(
39327
+ this.functionId,
39328
+ input,
39329
+ 4 /* FUNCTION_CALL_INVOCATION_TYPE_SYNC */
39330
+ );
39331
+ }
39209
39332
  // Spawn a single input into a remote function.
39210
39333
  async spawn(args = [], kwargs = {}) {
39211
39334
  const input = await this.#createInput(args, kwargs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modal",
3
- "version": "0.3.11",
3
+ "version": "0.3.12",
4
4
  "description": "Modal client library for JavaScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://modal.com/docs",