apps 0.0.1-beta.43 → 0.0.1-beta.46

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 (54) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/{chunk-XSD3RZFX.js → chunk-3B2JAOSE.js} +23 -12
  3. package/js/{chunk-KTPKTBKZ.js → chunk-3UGDI2UI.js} +5 -5
  4. package/js/chunk-5FHWNLCI.js +88 -0
  5. package/js/{chunk-MSDGZ7FA.js → chunk-6QXPBJ5T.js} +14 -13
  6. package/js/{chunk-Z3S2IVI3.js → chunk-7LGRK7TP.js} +2 -2
  7. package/js/{chunk-T65AFHU3.js → chunk-7UUHJR2Q.js} +1 -1
  8. package/js/{chunk-4ZTVLEN6.js → chunk-CDXQDN7W.js} +1 -1
  9. package/js/{chunk-OBXHQNWC.js → chunk-CVAJ4F6O.js} +16 -3
  10. package/js/{chunk-KBIKBWSS.js → chunk-H72MEDMN.js} +4 -3
  11. package/js/{chunk-VU6GQ2SH.js → chunk-JM7LOD2W.js} +212 -22
  12. package/js/{chunk-EJUK2NK5.js → chunk-KLYSEHUD.js} +1 -1
  13. package/js/{chunk-ILYK7BQG.js → chunk-LHCGND3R.js} +12 -46
  14. package/js/{chunk-EMHFXFTJ.js → chunk-LTDHQJ2Z.js} +53 -0
  15. package/js/{chunk-47BLLMRQ.js → chunk-OJ47HQVJ.js} +143 -65
  16. package/js/{chunk-MZH4J2PO.js → chunk-PD6I2SDG.js} +1 -1
  17. package/js/{chunk-KSGYJV46.js → chunk-TUMGL2OC.js} +1 -1
  18. package/js/{chunk-5GLC42LK.js → chunk-UM62MBJQ.js} +42 -24
  19. package/js/{chunk-IN2WIN7I.js → chunk-XBG7HHXC.js} +1 -1
  20. package/js/{chunk-RIKH5H2X.js → chunk-XK5I2XOI.js} +39 -29
  21. package/js/client.js +9 -9
  22. package/js/contracts.js +9 -5
  23. package/js/effect.js +14 -14
  24. package/js/graphql.js +23 -21
  25. package/js/host.js +79 -54
  26. package/js/index.js +23 -18
  27. package/js/mcp/effect.js +16 -16
  28. package/js/mcp/stdio.js +30 -25
  29. package/js/mcp.js +23 -21
  30. package/js/openapi.js +106 -80
  31. package/js/skills/effect.js +5 -5
  32. package/js/skills.js +53 -36
  33. package/js/ui/auth.js +3 -3
  34. package/js/ui/contracts.js +3 -3
  35. package/js/ui/serving.js +7 -7
  36. package/package.json +1 -1
  37. package/runtime.json +1 -1
  38. package/types/apps/src/contracts/host.d.ts +15 -0
  39. package/types/apps/src/host.d.ts +5 -0
  40. package/types/apps/src/implementation/authoring.d.ts +25 -5
  41. package/types/apps/src/implementation/cache.d.ts +4 -0
  42. package/types/apps/src/implementation/elicitation.d.ts +6 -3
  43. package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
  44. package/types/apps/src/implementation/operations.d.ts +2 -2
  45. package/types/apps/src/implementation/router-catalog.d.ts +4 -4
  46. package/types/apps/src/implementation/workflows.d.ts +1 -1
  47. package/types/telemetry/src/index.d.ts +1 -0
  48. package/types/telemetry/src/ownership.d.ts +56 -0
  49. package/types/telemetry/src/recorded-failure.d.ts +20 -11
  50. package/types/utils/src/api-error.d.ts +4 -2
  51. package/types/utils/src/recorded-message.d.ts +7 -4
  52. package/types/utils/src/user-facing-error.d.ts +4 -2
  53. package/js/chunk-EG72MSVK.js +0 -16
  54. package/js/{chunk-LNSVJS2Q.js → chunk-EOPQ727L.js} +2 -2
@@ -1,12 +1,15 @@
1
1
  import {
2
2
  declaredOperations,
3
- fromPromise,
4
3
  nativeOperation,
5
4
  nativeRouter
6
- } from "./chunk-ILYK7BQG.js";
5
+ } from "./chunk-LHCGND3R.js";
6
+ import {
7
+ fromPromise,
8
+ method
9
+ } from "./chunk-LTDHQJ2Z.js";
7
10
  import {
8
11
  ScheduleTiming
9
- } from "./chunk-OBXHQNWC.js";
12
+ } from "./chunk-CVAJ4F6O.js";
10
13
  import {
11
14
  decoderOf,
12
15
  isSchema,
@@ -45,11 +48,8 @@ var workflow = (options, run) => ({
45
48
  input: decoderOf(schemaArgument(options.input, "The workflow input")),
46
49
  ...options.output === void 0 ? {} : { output: decoderOf(schemaArgument(options.output, "The workflow output")) },
47
50
  ...options.description === void 0 ? {} : { description: options.description },
48
- run: (context, input) => Effect_exports.tryPromise({
49
- // SAFETY: defineApp checks required context; the host supplies the pinned run's capabilities.
50
- try: () => run(context, input),
51
- catch: (error) => error
52
- })
51
+ // SAFETY: defineApp checks required context; the host supplies the pinned run's capabilities.
52
+ run: (context, input) => fromPromise(run, "workflow")(context, input)
53
53
  }
54
54
  });
55
55
  var nativeWorkflow = (value) => {
@@ -68,14 +68,25 @@ function rejectCatalogs(definition) {
68
68
  function adaptDefinition(definition) {
69
69
  rejectCatalogs(definition);
70
70
  const webhooks = definition.webhooks === void 0 ? {} : {
71
+ // SAFETY: `Required` only where the optional method was just checked to be present.
71
72
  webhooks: Object.fromEntries(
72
73
  Object.entries(definition.webhooks).map(([name, webhook]) => [
73
74
  name,
74
75
  {
75
76
  ...webhook,
76
- ...webhook.register === void 0 ? {} : { register: fromPromise(webhook.register) },
77
- handle: fromPromise(webhook.handle),
78
- ...webhook.unregister === void 0 ? {} : { unregister: fromPromise(webhook.unregister) },
77
+ ...webhook.register === void 0 ? {} : {
78
+ register: fromPromise(
79
+ method(webhook, "register"),
80
+ "webhook"
81
+ )
82
+ },
83
+ handle: fromPromise(method(webhook, "handle"), "webhook"),
84
+ ...webhook.unregister === void 0 ? {} : {
85
+ unregister: fromPromise(
86
+ method(webhook, "unregister"),
87
+ "webhook"
88
+ )
89
+ },
79
90
  ..."config" in webhook && isSchema(webhook.config) ? { config: decoderOf(webhook.config) } : {},
80
91
  ..."state" in webhook && isSchema(webhook.state) ? { state: decoderOf(webhook.state) } : {}
81
92
  }
@@ -134,7 +145,7 @@ function adaptDefinition(definition) {
134
145
  var defineApp = (requirements, definition) => {
135
146
  if (typeof definition !== "function") rejectCatalogs(definition);
136
147
  const evaluate = typeof definition === "function" ? definition : async () => definition;
137
- const factory = fromPromise(evaluate);
148
+ const factory = fromPromise(evaluate, "factory");
138
149
  const native = {
139
150
  accounts: requirements.accounts,
140
151
  evaluate: (context) => factory(context).pipe(Effect_exports.map((value) => adaptDefinition(value)))
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  skillFromFiles
3
- } from "./chunk-IN2WIN7I.js";
3
+ } from "./chunk-XBG7HHXC.js";
4
4
  import {
5
5
  joinPath,
6
6
  mergeMeta
7
- } from "./chunk-ILYK7BQG.js";
7
+ } from "./chunk-LHCGND3R.js";
8
8
  import {
9
9
  isShortenedUpstream,
10
10
  parseProviderError,
11
11
  providerError
12
- } from "./chunk-EMHFXFTJ.js";
12
+ } from "./chunk-LTDHQJ2Z.js";
13
13
  import {
14
14
  ApiErrorResponse,
15
15
  HostDeclarationInvalid,
@@ -21,7 +21,7 @@ import {
21
21
  McpError,
22
22
  McpError2,
23
23
  SkillLoadFailed as SkillLoadFailed2
24
- } from "./chunk-OBXHQNWC.js";
24
+ } from "./chunk-CVAJ4F6O.js";
25
25
  import {
26
26
  CacheError,
27
27
  FailureCode,
@@ -36,7 +36,7 @@ import {
36
36
  import {
37
37
  SkillLoadFailed,
38
38
  skillFormatLimits
39
- } from "./chunk-KBIKBWSS.js";
39
+ } from "./chunk-H72MEDMN.js";
40
40
  import {
41
41
  jsonSchemaDocument
42
42
  } from "./chunk-KGCTYL2S.js";
@@ -0,0 +1,88 @@
1
+ import {
2
+ Predicate_exports
3
+ } from "./chunk-IFJU5SYQ.js";
4
+
5
+ // ../utils/src/recorded-message.ts
6
+ var RecordedMessage = /* @__PURE__ */ Symbol.for("@executor-js/utils/RecordedMessage");
7
+ var recordedMessage = (error) => {
8
+ if (Predicate_exports.hasProperty(error, RecordedMessage)) {
9
+ const message = error[RecordedMessage];
10
+ return typeof message === "string" ? message : void 0;
11
+ }
12
+ return protocolErrorMessage(error) ?? sqlErrorMessage(error);
13
+ };
14
+ var jsonRpcMeanings = {
15
+ [-32700]: "Parse error",
16
+ [-32600]: "Invalid request",
17
+ [-32601]: "Method not found",
18
+ [-32602]: "Invalid params",
19
+ [-32603]: "Internal error",
20
+ [-32002]: "Resource not found"
21
+ };
22
+ var protocolErrorMessage = (error) => {
23
+ if (!Predicate_exports.isTagged(error, "ProtocolError") || !Predicate_exports.hasProperty(error, "code") || typeof error.code !== "number" || !Predicate_exports.hasProperty(error, "message") || !Predicate_exports.isString(error.message))
24
+ return void 0;
25
+ const code = error.code;
26
+ const refusal = /^Tool '.*' not found$/s.test(error.message) ? ": the requested tool does not exist" : error.message.startsWith("Invalid parameters for tool '") ? ": the tool's arguments failed validation" : "";
27
+ const meaning = jsonRpcMeanings[code];
28
+ const kind = meaning === void 0 ? "JSON-RPC error with an unlisted code" : `${meaning} (${code})`;
29
+ return kind + refusal;
30
+ };
31
+ var sqlReasons = /* @__PURE__ */ new Set([
32
+ "ConnectionError",
33
+ "AuthenticationError",
34
+ "AuthorizationError",
35
+ "SqlSyntaxError",
36
+ "UniqueViolation",
37
+ "ConstraintError",
38
+ "DeadlockError",
39
+ "SerializationError",
40
+ "LockTimeoutError",
41
+ "StatementTimeoutError",
42
+ "UnknownError"
43
+ ]);
44
+ var sqlMessages = new Set(
45
+ [
46
+ "A pipelined query completed out of order",
47
+ "Connection closed",
48
+ "Connection closed during startup",
49
+ "Connection is closed",
50
+ "Connection timed out",
51
+ "Failed to connect",
52
+ "Failed to decode row",
53
+ "Failed to encode query",
54
+ "Failed to negotiate TLS",
55
+ "Failed to parse SSLRequest error response",
56
+ "Failed to parse server messages",
57
+ "Failed to parse server response",
58
+ "Failed to write query",
59
+ "Failed to write query batch",
60
+ "Invalid SSLRequest response",
61
+ "MD5 authentication failed",
62
+ "No password configured",
63
+ "Protocol desync",
64
+ "Query cancellation timed out",
65
+ "Query failed",
66
+ "SCRAM authentication failed",
67
+ "SCRAM exchange did not complete",
68
+ "SCRAM server verification failed",
69
+ "Server refused TLS",
70
+ "Socket error",
71
+ "Stream cancellation timed out",
72
+ "The server reported an error",
73
+ "Unsupported authentication method"
74
+ ].map((message) => `PgConnection: ${message}`)
75
+ );
76
+ var sqlErrorMessage = (error) => {
77
+ if (!Predicate_exports.isTagged(error, "SqlError") || !Predicate_exports.hasProperty(error, "reason"))
78
+ return void 0;
79
+ const reason = error.reason;
80
+ const kind = Predicate_exports.hasProperty(reason, "_tag") && Predicate_exports.isString(reason._tag) && sqlReasons.has(reason._tag) ? reason._tag : "an unlisted kind";
81
+ const message = Predicate_exports.hasProperty(reason, "message") && Predicate_exports.isString(reason.message) && sqlMessages.has(reason.message) ? `: ${reason.message}` : "";
82
+ return `The database failed (${kind})${message}`;
83
+ };
84
+
85
+ export {
86
+ RecordedMessage,
87
+ recordedMessage
88
+ };
@@ -3,16 +3,16 @@ import {
3
3
  answeredError,
4
4
  mcpClient,
5
5
  mcpJsonSchemaValidator
6
- } from "./chunk-RIKH5H2X.js";
6
+ } from "./chunk-XK5I2XOI.js";
7
7
  import {
8
8
  failOnNetworkRefusal
9
- } from "./chunk-T65AFHU3.js";
9
+ } from "./chunk-7UUHJR2Q.js";
10
10
  import {
11
11
  accountProviderError,
12
12
  bodyUpstreamError,
13
13
  httpProviderError,
14
14
  providerErrorDetail
15
- } from "./chunk-EMHFXFTJ.js";
15
+ } from "./chunk-LTDHQJ2Z.js";
16
16
  import {
17
17
  McpCredentialsUnverified,
18
18
  McpError,
@@ -20,21 +20,22 @@ import {
20
20
  McpToolsOptions,
21
21
  defaultMcpClientLimits,
22
22
  mcpHealthReserveMs
23
- } from "./chunk-OBXHQNWC.js";
23
+ } from "./chunk-CVAJ4F6O.js";
24
24
  import {
25
25
  NetworkRefused,
26
26
  ProviderError
27
27
  } from "./chunk-MWKHKOTL.js";
28
28
  import {
29
- captureTelemetry
30
- } from "./chunk-VU6GQ2SH.js";
29
+ captureTelemetry,
30
+ owned
31
+ } from "./chunk-JM7LOD2W.js";
31
32
  import {
32
33
  FetchHttpClient_exports
33
- } from "./chunk-MZH4J2PO.js";
34
+ } from "./chunk-PD6I2SDG.js";
34
35
  import {
35
36
  HttpClientRequest_exports,
36
37
  HttpClient_exports
37
- } from "./chunk-LNSVJS2Q.js";
38
+ } from "./chunk-EOPQ727L.js";
38
39
  import {
39
40
  Clock_exports,
40
41
  Deferred_exports,
@@ -236,7 +237,7 @@ function withClient(connection, mode, use, changed) {
236
237
  Effect_exports.timeout(defaultMcpClientLimits.cleanupTimeoutMs),
237
238
  Effect_exports.ignore
238
239
  );
239
- }).pipe(Effect_exports.withSpan("provider.mcp.close"))
240
+ }).pipe(owned("upstream", "provider.mcp.close"))
240
241
  );
241
242
  const wire = transport;
242
243
  yield* Effect_exports.tryPromise({
@@ -246,7 +247,7 @@ function withClient(connection, mode, use, changed) {
246
247
  Effect_exports.raceFirst(Deferred_exports.await(rejected)),
247
248
  Effect_exports.catch(explained("connect", answered)),
248
249
  Effect_exports.timeout(connection.timeoutMs),
249
- Effect_exports.withSpan("provider.mcp.connect")
250
+ owned("upstream", "provider.mcp.connect")
250
251
  );
251
252
  return yield* use(client).pipe(
252
253
  Effect_exports.raceFirst(Deferred_exports.await(rejected)),
@@ -254,7 +255,7 @@ function withClient(connection, mode, use, changed) {
254
255
  );
255
256
  })
256
257
  ).pipe(
257
- Effect_exports.withSpan("provider.mcp.session", {
258
+ owned("upstream", "provider.mcp.session", {
258
259
  attributes: {
259
260
  "mcp.transport": kind,
260
261
  "mcp.operation": mode,
@@ -327,9 +328,9 @@ var mcpHealthEffect = (check, options) => Effect_exports.gen(function* () {
327
328
  // Executor's network refused the attempt, so the server never answered it.
328
329
  onFailure: (error) => Schema_exports.is(NetworkRefused)(error) ? Effect_exports.fail(error) : refusesCredentials(error) ? Effect_exports.void : Effect_exports.fail(new McpCredentialsUnverified({ anonymous: error }))
329
330
  }),
330
- Effect_exports.withSpan("provider.mcp.anonymous")
331
+ owned("upstream", "provider.mcp.anonymous")
331
332
  );
332
- }).pipe(Effect_exports.withSpan("provider.mcp.health"));
333
+ }).pipe(owned("upstream", "provider.mcp.health"));
333
334
  var mcpToolsEffect = (input) => mcpClientEffect(input).pipe(Effect_exports.flatMap(adaptMcpTools));
334
335
 
335
336
  export {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  fixedRouter
3
- } from "./chunk-KTPKTBKZ.js";
3
+ } from "./chunk-3UGDI2UI.js";
4
4
  import {
5
5
  nativeOperation,
6
6
  operationDeclaration,
7
7
  routerDeclaration
8
- } from "./chunk-ILYK7BQG.js";
8
+ } from "./chunk-LHCGND3R.js";
9
9
 
10
10
  // src/implementation/protocol-operations.ts
11
11
  var protocolOperations = (operations, kinds = {}) => {
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-MWKHKOTL.js";
9
9
  import {
10
10
  invocationFetch
11
- } from "./chunk-VU6GQ2SH.js";
11
+ } from "./chunk-JM7LOD2W.js";
12
12
  import {
13
13
  Effect_exports,
14
14
  Schema_exports
@@ -6,7 +6,7 @@ import {
6
6
  HttpApiGroup_exports,
7
7
  HttpApiSchema_exports,
8
8
  HttpApi_exports
9
- } from "./chunk-KSGYJV46.js";
9
+ } from "./chunk-TUMGL2OC.js";
10
10
  import {
11
11
  Schema_exports
12
12
  } from "./chunk-IFJU5SYQ.js";
@@ -12,10 +12,10 @@ import {
12
12
  import {
13
13
  AppSkillName,
14
14
  AppSkills
15
- } from "./chunk-KBIKBWSS.js";
15
+ } from "./chunk-H72MEDMN.js";
16
16
  import {
17
17
  RecordedMessage
18
- } from "./chunk-EG72MSVK.js";
18
+ } from "./chunk-5FHWNLCI.js";
19
19
  import {
20
20
  AccountId,
21
21
  HttpUrl,
@@ -3253,6 +3253,17 @@ var ToolResultObservation = Context_exports.Reference(
3253
3253
  { defaultValue: () => ({ failed: () => {
3254
3254
  } }) }
3255
3255
  );
3256
+ var InvocationTiming = Schema_exports.Struct({
3257
+ elapsedMs: Schema_exports.Finite,
3258
+ upstreamMs: Schema_exports.Finite,
3259
+ elicitationMs: Schema_exports.Finite,
3260
+ authoredMs: Schema_exports.Finite
3261
+ });
3262
+ var InvocationTimingSink = Context_exports.Reference(
3263
+ "apps/InvocationTimingSink",
3264
+ { defaultValue: () => () => {
3265
+ } }
3266
+ );
3256
3267
 
3257
3268
  export {
3258
3269
  SecretsMethod,
@@ -3395,5 +3406,7 @@ export {
3395
3406
  HostCallError,
3396
3407
  HostAccountCheckError,
3397
3408
  HostDataError,
3398
- ToolResultObservation
3409
+ ToolResultObservation,
3410
+ InvocationTiming,
3411
+ InvocationTimingSink
3399
3412
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RecordedMessage
3
- } from "./chunk-EG72MSVK.js";
3
+ } from "./chunk-5FHWNLCI.js";
4
4
  import {
5
5
  SchemaGetter_exports,
6
6
  Schema_exports
@@ -23,7 +23,7 @@ function withFields(definition) {
23
23
  ),
24
24
  { httpApiStatus: definition.status, ...documentation }
25
25
  );
26
- const recorded = definition.recorded;
26
+ const recorded = definition.recorded ?? (typeof message === "string" ? () => message : void 0);
27
27
  Object.defineProperties(DefinedError.prototype, {
28
28
  message: {
29
29
  get() {
@@ -110,7 +110,8 @@ var SkillDefinitionInvalid = ApiError.define({
110
110
  "name-mismatch"
111
111
  ])
112
112
  },
113
- message: ({ file, reason }) => skillDefinitionFailures[reason](file)
113
+ message: ({ file, reason }) => skillDefinitionFailures[reason](file),
114
+ recorded: ({ reason }) => `The app's skill definition is invalid (${reason})`
114
115
  });
115
116
  var AppSkills = Schema_exports.Array(AppSkillSource).check(
116
117
  Schema_exports.makeFilter((skills) => new Set(skills.map((skill) => skill.name)).size === skills.length)