@finalai/agent-definition 0.1.0

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.

Potentially problematic release.


This version of @finalai/agent-definition might be problematic. Click here for more details.

Files changed (206) hide show
  1. package/README.md +16 -0
  2. package/THIRD_PARTY_NOTICES.md +303 -0
  3. package/dist/compiler-assets/chunk-2CZRHOLL.ts +10 -0
  4. package/dist/compiler-assets/chunk-32O3ODZE.ts +39 -0
  5. package/dist/compiler-assets/chunk-5BK6FVRE.ts +75 -0
  6. package/dist/compiler-assets/chunk-6WR3PGNF.ts +0 -0
  7. package/dist/compiler-assets/chunk-7QP2CKPI.ts +30 -0
  8. package/dist/compiler-assets/chunk-7VSSVZM4.ts +55 -0
  9. package/dist/compiler-assets/chunk-7WGYG73V.ts +42 -0
  10. package/dist/compiler-assets/chunk-BLB6JGLO.ts +481 -0
  11. package/dist/compiler-assets/chunk-CWWRTRWW.ts +76 -0
  12. package/dist/compiler-assets/chunk-EVQIK62B.ts +188 -0
  13. package/dist/compiler-assets/chunk-GNR7XBPN.ts +3364 -0
  14. package/dist/compiler-assets/chunk-GTUZOATD.ts +10 -0
  15. package/dist/compiler-assets/chunk-HFS4KLEL.ts +10 -0
  16. package/dist/compiler-assets/chunk-HGW4YHAY.ts +6865 -0
  17. package/dist/compiler-assets/chunk-HNPUTP35.ts +172 -0
  18. package/dist/compiler-assets/chunk-JIPNTA56.ts +59 -0
  19. package/dist/compiler-assets/chunk-JNJE72EH.ts +10 -0
  20. package/dist/compiler-assets/chunk-JPY4L2UJ.ts +349 -0
  21. package/dist/compiler-assets/chunk-JTGTLYDT.ts +0 -0
  22. package/dist/compiler-assets/chunk-LUSAAV4L.ts +33 -0
  23. package/dist/compiler-assets/chunk-MZMSKIKU.ts +472 -0
  24. package/dist/compiler-assets/chunk-NMYHO2QN.ts +25 -0
  25. package/dist/compiler-assets/chunk-NYTOYKKF.ts +28 -0
  26. package/dist/compiler-assets/chunk-OWC6SFFF.ts +295 -0
  27. package/dist/compiler-assets/chunk-QMKWAFVZ.ts +59 -0
  28. package/dist/compiler-assets/chunk-QMWTDPNT.ts +79 -0
  29. package/dist/compiler-assets/chunk-RWUIMTBI.ts +13 -0
  30. package/dist/compiler-assets/chunk-SKTNMUO7.ts +64 -0
  31. package/dist/compiler-assets/chunk-T6WG4L4M.ts +19 -0
  32. package/dist/compiler-assets/chunk-TATN3PYK.ts +81 -0
  33. package/dist/compiler-assets/chunk-VHXHUU7L.ts +16 -0
  34. package/dist/compiler-assets/chunk-WMXMVFHM.ts +121 -0
  35. package/dist/compiler-assets/chunk-XHKPWT3G.ts +55 -0
  36. package/dist/compiler-assets/chunk-ZDLVA6XF.ts +476 -0
  37. package/dist/compiler-assets/src/authoring/agent.ts +10 -0
  38. package/dist/compiler-assets/src/authoring/approval.ts +19 -0
  39. package/dist/compiler-assets/src/authoring/brand.ts +23 -0
  40. package/dist/compiler-assets/src/authoring/channels.ts +26 -0
  41. package/dist/compiler-assets/src/authoring/connections.ts +10 -0
  42. package/dist/compiler-assets/src/authoring/context.ts +7 -0
  43. package/dist/compiler-assets/src/authoring/credentials.ts +21 -0
  44. package/dist/compiler-assets/src/authoring/dynamic.ts +10 -0
  45. package/dist/compiler-assets/src/authoring/harness.ts +17 -0
  46. package/dist/compiler-assets/src/authoring/hooks.ts +28 -0
  47. package/dist/compiler-assets/src/authoring/index.ts +110 -0
  48. package/dist/compiler-assets/src/authoring/instructions.ts +14 -0
  49. package/dist/compiler-assets/src/authoring/sandbox.ts +25 -0
  50. package/dist/compiler-assets/src/authoring/schedules.ts +10 -0
  51. package/dist/compiler-assets/src/authoring/skills.ts +10 -0
  52. package/dist/compiler-assets/src/authoring/tools.ts +23 -0
  53. package/dist/compiler-assets/src/compatibility.ts +14810 -0
  54. package/dist/compiler-assets/src/compiler/evaluate-child.mjs +77 -0
  55. package/dist/compiler-assets/src/index.ts +195 -0
  56. package/dist/compiler-assets/src/manifest.ts +72 -0
  57. package/dist/compiler-assets/src/resolve.ts +19 -0
  58. package/dist/compiler-assets/src/runtime/bundle.ts +72 -0
  59. package/dist/compiler-assets/src/runtime/describe.ts +31 -0
  60. package/dist/compiler-assets/src/runtime/described.ts +142 -0
  61. package/dist/compiler-assets/src/runtime/isolate.ts +28 -0
  62. package/dist/compiler-assets/src/runtime/layout.ts +15 -0
  63. package/dist/compiler-assets/src/runtime/lower.ts +52 -0
  64. package/dist/compiler-assets/src/runtime/schema-validation.ts +21 -0
  65. package/dist/compiler-assets/src/runtime/values.ts +38 -0
  66. package/dist/modules/authoring/agent.d.mts +22 -0
  67. package/dist/modules/authoring/agent.mjs +6 -0
  68. package/dist/modules/authoring/agent.mjs.map +7 -0
  69. package/dist/modules/authoring/approval.d.mts +17 -0
  70. package/dist/modules/authoring/approval.mjs +42 -0
  71. package/dist/modules/authoring/approval.mjs.map +7 -0
  72. package/dist/modules/authoring/brand.d.mts +27 -0
  73. package/dist/modules/authoring/brand.mjs +51 -0
  74. package/dist/modules/authoring/brand.mjs.map +7 -0
  75. package/dist/modules/authoring/channels.d.mts +41 -0
  76. package/dist/modules/authoring/channels.mjs +65 -0
  77. package/dist/modules/authoring/channels.mjs.map +7 -0
  78. package/dist/modules/authoring/connections.d.mts +23 -0
  79. package/dist/modules/authoring/connections.mjs +6 -0
  80. package/dist/modules/authoring/connections.mjs.map +7 -0
  81. package/dist/modules/authoring/context.d.mts +83 -0
  82. package/dist/modules/authoring/context.mjs +12 -0
  83. package/dist/modules/authoring/context.mjs.map +7 -0
  84. package/dist/modules/authoring/credentials.d.mts +10 -0
  85. package/dist/modules/authoring/credentials.mjs +31 -0
  86. package/dist/modules/authoring/credentials.mjs.map +7 -0
  87. package/dist/modules/authoring/dynamic.d.mts +30 -0
  88. package/dist/modules/authoring/dynamic.mjs +15 -0
  89. package/dist/modules/authoring/dynamic.mjs.map +7 -0
  90. package/dist/modules/authoring/harness.d.mts +85 -0
  91. package/dist/modules/authoring/harness.mjs +55 -0
  92. package/dist/modules/authoring/harness.mjs.map +7 -0
  93. package/dist/modules/authoring/hooks.d.mts +120 -0
  94. package/dist/modules/authoring/hooks.mjs +72 -0
  95. package/dist/modules/authoring/hooks.mjs.map +7 -0
  96. package/dist/modules/authoring/index.d.mts +27 -0
  97. package/dist/modules/authoring/index.mjs +63 -0
  98. package/dist/modules/authoring/index.mjs.map +7 -0
  99. package/dist/modules/authoring/instructions.d.mts +13 -0
  100. package/dist/modules/authoring/instructions.mjs +15 -0
  101. package/dist/modules/authoring/instructions.mjs.map +7 -0
  102. package/dist/modules/authoring/sandbox.d.mts +21 -0
  103. package/dist/modules/authoring/sandbox.mjs +13 -0
  104. package/dist/modules/authoring/sandbox.mjs.map +7 -0
  105. package/dist/modules/authoring/schedules.d.mts +8 -0
  106. package/dist/modules/authoring/schedules.mjs +6 -0
  107. package/dist/modules/authoring/schedules.mjs.map +7 -0
  108. package/dist/modules/authoring/skills.d.mts +8 -0
  109. package/dist/modules/authoring/skills.mjs +6 -0
  110. package/dist/modules/authoring/skills.mjs.map +7 -0
  111. package/dist/modules/authoring/tools.d.mts +80 -0
  112. package/dist/modules/authoring/tools.mjs +70 -0
  113. package/dist/modules/authoring/tools.mjs.map +7 -0
  114. package/dist/modules/compatibility.d.mts +36 -0
  115. package/dist/modules/compatibility.mjs +536 -0
  116. package/dist/modules/compatibility.mjs.map +7 -0
  117. package/dist/modules/compiler/assemble.d.mts +30 -0
  118. package/dist/modules/compiler/assemble.mjs +923 -0
  119. package/dist/modules/compiler/assemble.mjs.map +7 -0
  120. package/dist/modules/compiler/bundle.d.mts +22 -0
  121. package/dist/modules/compiler/bundle.mjs +385 -0
  122. package/dist/modules/compiler/bundle.mjs.map +7 -0
  123. package/dist/modules/compiler/diagnostics.d.mts +40 -0
  124. package/dist/modules/compiler/diagnostics.mjs +38 -0
  125. package/dist/modules/compiler/diagnostics.mjs.map +7 -0
  126. package/dist/modules/compiler/discovery.d.mts +36 -0
  127. package/dist/modules/compiler/discovery.mjs +158 -0
  128. package/dist/modules/compiler/discovery.mjs.map +7 -0
  129. package/dist/modules/compiler/evaluate.d.mts +13 -0
  130. package/dist/modules/compiler/evaluate.mjs +194 -0
  131. package/dist/modules/compiler/evaluate.mjs.map +7 -0
  132. package/dist/modules/compiler/files.d.mts +19 -0
  133. package/dist/modules/compiler/files.mjs +90 -0
  134. package/dist/modules/compiler/files.mjs.map +7 -0
  135. package/dist/modules/compiler/frontmatter.d.mts +9 -0
  136. package/dist/modules/compiler/frontmatter.mjs +34 -0
  137. package/dist/modules/compiler/frontmatter.mjs.map +7 -0
  138. package/dist/modules/compiler/index.d.mts +49 -0
  139. package/dist/modules/compiler/index.mjs +244 -0
  140. package/dist/modules/compiler/index.mjs.map +7 -0
  141. package/dist/modules/compiler/load.d.mts +8 -0
  142. package/dist/modules/compiler/load.mjs +45 -0
  143. package/dist/modules/compiler/load.mjs.map +7 -0
  144. package/dist/modules/compiler/local-isolate.d.mts +20 -0
  145. package/dist/modules/compiler/local-isolate.mjs +93 -0
  146. package/dist/modules/compiler/local-isolate.mjs.map +7 -0
  147. package/dist/modules/compiler/packages.d.mts +66 -0
  148. package/dist/modules/compiler/packages.mjs +307 -0
  149. package/dist/modules/compiler/packages.mjs.map +7 -0
  150. package/dist/modules/index.d.mts +7 -0
  151. package/dist/modules/index.mjs +25 -0
  152. package/dist/modules/index.mjs.map +7 -0
  153. package/dist/modules/manifest.d.mts +2 -0
  154. package/dist/modules/manifest.mjs +67 -0
  155. package/dist/modules/manifest.mjs.map +7 -0
  156. package/dist/modules/resolve.d.mts +24 -0
  157. package/dist/modules/resolve.mjs +176 -0
  158. package/dist/modules/resolve.mjs.map +7 -0
  159. package/dist/modules/runtime/bundle.d.mts +12 -0
  160. package/dist/modules/runtime/bundle.mjs +48 -0
  161. package/dist/modules/runtime/bundle.mjs.map +7 -0
  162. package/dist/modules/runtime/describe.d.mts +19 -0
  163. package/dist/modules/runtime/describe.mjs +471 -0
  164. package/dist/modules/runtime/describe.mjs.map +7 -0
  165. package/dist/modules/runtime/described.d.mts +376 -0
  166. package/dist/modules/runtime/described.mjs +116 -0
  167. package/dist/modules/runtime/described.mjs.map +7 -0
  168. package/dist/modules/runtime/isolate.d.mts +70 -0
  169. package/dist/modules/runtime/isolate.mjs +454 -0
  170. package/dist/modules/runtime/isolate.mjs.map +7 -0
  171. package/dist/modules/runtime/layout.d.mts +21 -0
  172. package/dist/modules/runtime/layout.mjs +24 -0
  173. package/dist/modules/runtime/layout.mjs.map +7 -0
  174. package/dist/modules/runtime/lower.d.mts +73 -0
  175. package/dist/modules/runtime/lower.mjs +463 -0
  176. package/dist/modules/runtime/lower.mjs.map +7 -0
  177. package/dist/modules/runtime/schema-validation.d.mts +21 -0
  178. package/dist/modules/runtime/schema-validation.mjs +238 -0
  179. package/dist/modules/runtime/schema-validation.mjs.map +7 -0
  180. package/dist/modules/runtime/values.d.mts +20 -0
  181. package/dist/modules/runtime/values.mjs +48 -0
  182. package/dist/modules/runtime/values.mjs.map +7 -0
  183. package/fixtures/acme-fleet/agent/agent.ts +74 -0
  184. package/fixtures/acme-fleet/agent/instructions.md +1 -0
  185. package/fixtures/assistant/agent/agent.ts +16 -0
  186. package/fixtures/assistant/agent/instructions.md +1 -0
  187. package/fixtures/assistant/agent/tools/current_time.ts +9 -0
  188. package/fixtures/assistant-with-tools/agent/agent.ts +16 -0
  189. package/fixtures/assistant-with-tools/agent/instructions.md +1 -0
  190. package/fixtures/assistant-with-tools/agent/tools/current_time.ts +9 -0
  191. package/fixtures/final-connection/agent/agent.ts +15 -0
  192. package/fixtures/final-connection/agent/connections/final.ts +9 -0
  193. package/fixtures/release-scout/agent/agent.ts +22 -0
  194. package/fixtures/release-scout/agent/channels/github-signature.ts +27 -0
  195. package/fixtures/release-scout/agent/channels/github.ts +38 -0
  196. package/fixtures/release-scout/agent/connections/linear.ts +9 -0
  197. package/fixtures/release-scout/agent/hooks/audit.ts +24 -0
  198. package/fixtures/release-scout/agent/instructions/org-context.ts +26 -0
  199. package/fixtures/release-scout/agent/instructions.md +2 -0
  200. package/fixtures/release-scout/agent/sandbox.ts +20 -0
  201. package/fixtures/release-scout/agent/schedules/daily-digest.md +7 -0
  202. package/fixtures/release-scout/agent/skills/triage/SKILL.md +8 -0
  203. package/fixtures/release-scout/agent/skills/triage/checklist.md +3 -0
  204. package/fixtures/release-scout/agent/tools/lookup_release_notes.ts +24 -0
  205. package/fixtures/tsconfig.json +5 -0
  206. package/package.json +94 -0
@@ -0,0 +1,172 @@
1
+ import {
2
+ DynamicEvent
3
+ } from "./chunk-SKTNMUO7.ts";
4
+ import {
5
+ array,
6
+ literal,
7
+ nativeEnum,
8
+ object,
9
+ string,
10
+ union
11
+ } from "./chunk-HGW4YHAY.ts";
12
+
13
+ // ../agent-provider/src/credentials.ts
14
+ var CredentialPayer = /* @__PURE__ */ ((CredentialPayer2) => {
15
+ CredentialPayer2["AgentOwner"] = "agent-owner";
16
+ CredentialPayer2["Organization"] = "organization";
17
+ CredentialPayer2["PromptingUser"] = "prompting-user";
18
+ CredentialPayer2["ConversationOwner"] = "conversation-owner";
19
+ return CredentialPayer2;
20
+ })(CredentialPayer || {});
21
+ var CredentialOwner = /* @__PURE__ */ ((CredentialOwner2) => {
22
+ CredentialOwner2["Payer"] = "payer";
23
+ CredentialOwner2["Organization"] = "organization";
24
+ return CredentialOwner2;
25
+ })(CredentialOwner || {});
26
+ var InferenceCredentialKind = /* @__PURE__ */ ((InferenceCredentialKind2) => {
27
+ InferenceCredentialKind2["Subscription"] = "subscription";
28
+ InferenceCredentialKind2["ApiKey"] = "api-key";
29
+ InferenceCredentialKind2["Platform"] = "platform";
30
+ InferenceCredentialKind2["HarnessOwned"] = "harness-owned";
31
+ return InferenceCredentialKind2;
32
+ })(InferenceCredentialKind || {});
33
+ var CredentialDelivery = /* @__PURE__ */ ((CredentialDelivery2) => {
34
+ CredentialDelivery2["PerRequest"] = "per-request";
35
+ CredentialDelivery2["AtOpen"] = "at-open";
36
+ return CredentialDelivery2;
37
+ })(CredentialDelivery || {});
38
+ var subscriptionNodeSchema = object({
39
+ kind: literal("subscription" /* Subscription */),
40
+ owner: nativeEnum(CredentialOwner),
41
+ vendor: string().min(1).optional(),
42
+ pin: string().min(1).optional()
43
+ });
44
+ var apiKeyOwnerNodeSchema = object({
45
+ pin: string().min(1).optional(),
46
+ kind: literal("api-key" /* ApiKey */),
47
+ owner: nativeEnum(CredentialOwner),
48
+ vendor: string().min(1).optional()
49
+ });
50
+ var apiKeySecretNodeSchema = object({
51
+ kind: literal("api-key" /* ApiKey */),
52
+ secret: string().min(1),
53
+ baseUrl: string().url().optional(),
54
+ vendor: string().min(1).optional()
55
+ });
56
+ var platformNodeSchema = object({
57
+ kind: literal("platform" /* Platform */),
58
+ budget: string().min(1).optional()
59
+ });
60
+ var harnessNodeSchema = object({
61
+ kind: literal("harness-owned" /* HarnessOwned */)
62
+ });
63
+ var customNodeSchema = object({
64
+ kind: literal("custom" /* Custom */),
65
+ // Bundle export of a defineDynamic resolver returning one of the other nodes,
66
+ // or `{ kind: 'api-key', value }` held in memory by the broker.
67
+ resolver: string().min(1),
68
+ events: array(nativeEnum(DynamicEvent)).default(["session.started" /* SessionStarted */])
69
+ });
70
+ var credentialNodeSchema = union([
71
+ subscriptionNodeSchema,
72
+ apiKeySecretNodeSchema,
73
+ apiKeyOwnerNodeSchema,
74
+ platformNodeSchema,
75
+ harnessNodeSchema,
76
+ customNodeSchema
77
+ ]);
78
+ var credentialPolicySchema = object({
79
+ payer: nativeEnum(CredentialPayer),
80
+ tryInOrder: array(credentialNodeSchema).min(1)
81
+ });
82
+ var customResolverResultSchema = union([
83
+ credentialNodeSchema,
84
+ object({
85
+ kind: literal("api-key" /* ApiKey */),
86
+ value: string().min(1),
87
+ vendor: string().min(1).optional(),
88
+ baseUrl: string().url().optional()
89
+ })
90
+ ]);
91
+ var ownerSchema = nativeEnum(CredentialOwner);
92
+ var toOwner = (owner) => ownerSchema.parse(owner);
93
+ var payerSchema = nativeEnum(CredentialPayer);
94
+ var toPayer = (payer) => payerSchema.parse(payer);
95
+ var credentials = {
96
+ chain: (args) => credentialPolicySchema.parse({ payer: toPayer(args.payer), tryInOrder: args.tryInOrder }),
97
+ subscription: (args) => {
98
+ const node = {
99
+ kind: "subscription" /* Subscription */,
100
+ owner: toOwner(args.owner)
101
+ };
102
+ if (args.vendor != null) node.vendor = args.vendor;
103
+ if (args.pin != null) node.pin = args.pin;
104
+ return node;
105
+ },
106
+ apiKey: (args) => {
107
+ if ("secret" in args) {
108
+ const node2 = { kind: "api-key" /* ApiKey */, secret: args.secret };
109
+ if (args.baseUrl != null) node2.baseUrl = args.baseUrl;
110
+ if (args.vendor != null) node2.vendor = args.vendor;
111
+ return node2;
112
+ }
113
+ const node = {
114
+ kind: "api-key" /* ApiKey */,
115
+ owner: toOwner(args.owner)
116
+ };
117
+ if (args.vendor != null) node.vendor = args.vendor;
118
+ if (args.pin != null) node.pin = args.pin;
119
+ return node;
120
+ },
121
+ platform: (args) => {
122
+ const node = { kind: "platform" /* Platform */ };
123
+ if (args?.budget != null) node.budget = args.budget;
124
+ return node;
125
+ },
126
+ harness: () => ({ kind: "harness-owned" /* HarnessOwned */ }),
127
+ custom: (ref) => ({
128
+ kind: "custom" /* Custom */,
129
+ resolver: ref.resolverExport,
130
+ events: ref.events ?? ["session.started" /* SessionStarted */]
131
+ })
132
+ };
133
+ var defaultPersonalCredentialPolicy = () => credentials.chain({
134
+ payer: "agent-owner" /* AgentOwner */,
135
+ tryInOrder: [
136
+ credentials.subscription({ owner: "payer" /* Payer */ }),
137
+ credentials.platform()
138
+ ]
139
+ });
140
+ var defaultOrganizationCredentialPolicy = () => credentials.chain({
141
+ payer: "organization" /* Organization */,
142
+ tryInOrder: [
143
+ credentials.subscription({ owner: "organization" /* Organization */ }),
144
+ credentials.platform()
145
+ ]
146
+ });
147
+ var inferenceKindOfNode = (node) => {
148
+ switch (node.kind) {
149
+ case "subscription" /* Subscription */:
150
+ return "subscription" /* Subscription */;
151
+ case "api-key" /* ApiKey */:
152
+ return "api-key" /* ApiKey */;
153
+ case "platform" /* Platform */:
154
+ return "platform" /* Platform */;
155
+ case "harness-owned" /* HarnessOwned */:
156
+ return "harness-owned" /* HarnessOwned */;
157
+ case "custom" /* Custom */:
158
+ return null;
159
+ }
160
+ };
161
+
162
+ export {
163
+ CredentialPayer,
164
+ CredentialOwner,
165
+ InferenceCredentialKind,
166
+ CredentialDelivery,
167
+ credentialPolicySchema,
168
+ credentials,
169
+ defaultPersonalCredentialPolicy,
170
+ defaultOrganizationCredentialPolicy,
171
+ inferenceKindOfNode
172
+ };
@@ -0,0 +1,59 @@
1
+ import {
2
+ _function,
3
+ boolean,
4
+ custom,
5
+ looseObject,
6
+ number,
7
+ record,
8
+ string,
9
+ unknown
10
+ } from "./chunk-HGW4YHAY.ts";
11
+
12
+ // src/runtime/values.ts
13
+ var authoredValueSchema = unknown();
14
+ var optionalValueSchema = authoredValueSchema.optional();
15
+ var functionSchema = _function();
16
+ var callableSchema = custom(
17
+ (value) => functionSchema.safeParse(value).success
18
+ );
19
+ var authoredRecordSchema = record(string(), authoredValueSchema);
20
+ var isCallable = (value) => callableSchema.safeParse(value).success;
21
+ var isString = (value) => string().safeParse(value).success;
22
+ var isNumber = (value) => number().safeParse(value).success;
23
+ var isBoolean = (value) => boolean().safeParse(value).success;
24
+ var stringOrNull = (value) => isString(value) ? value : null;
25
+ var isObjectLike = (value) => value instanceof Object;
26
+ var isPlainObject = (value) => {
27
+ if (!isObjectLike(value) || Array.isArray(value) || isCallable(value)) return false;
28
+ const proto = Object.getPrototypeOf(value);
29
+ return proto == null || Object.getPrototypeOf(proto) == null;
30
+ };
31
+ var fieldOf = (value, key) => {
32
+ if (!isObjectLike(value) || !(key in value)) return void 0;
33
+ const parsed = looseObject({ [key]: optionalValueSchema }).safeParse(value);
34
+ if (parsed.success) return parsed.data[key];
35
+ return Object.getOwnPropertyDescriptor(value, key)?.value;
36
+ };
37
+ var entriesOf = (value) => isObjectLike(value) ? Object.entries(value) : [];
38
+ var isPromiseLike = (value) => isCallable(fieldOf(value, "then"));
39
+ var isAsyncIterable = (value) => isObjectLike(value) && Symbol.asyncIterator in value;
40
+ var messageOf = (cause) => cause instanceof Error ? cause.message : String(cause);
41
+
42
+ export {
43
+ authoredValueSchema,
44
+ optionalValueSchema,
45
+ callableSchema,
46
+ authoredRecordSchema,
47
+ isCallable,
48
+ isString,
49
+ isNumber,
50
+ isBoolean,
51
+ stringOrNull,
52
+ isObjectLike,
53
+ isPlainObject,
54
+ fieldOf,
55
+ entriesOf,
56
+ isPromiseLike,
57
+ isAsyncIterable,
58
+ messageOf
59
+ };
@@ -0,0 +1,10 @@
1
+ import {
2
+ stamp
3
+ } from "./chunk-XHKPWT3G.ts";
4
+
5
+ // src/authoring/connections.ts
6
+ var defineMcpClientConnection = (definition) => stamp({ ...definition }, "connection" /* Connection */);
7
+
8
+ export {
9
+ defineMcpClientConnection
10
+ };
@@ -0,0 +1,349 @@
1
+ import {
2
+ BaseCapability,
3
+ providerRefSchema
4
+ } from "./chunk-OWC6SFFF.ts";
5
+ import {
6
+ jsonObjectSchema,
7
+ jsonSchemaSchema
8
+ } from "./chunk-7QP2CKPI.ts";
9
+ import {
10
+ CredentialDelivery,
11
+ InferenceCredentialKind
12
+ } from "./chunk-HNPUTP35.ts";
13
+ import {
14
+ array,
15
+ boolean,
16
+ json,
17
+ literal,
18
+ nativeEnum,
19
+ number,
20
+ object,
21
+ partialRecord,
22
+ record,
23
+ string,
24
+ union
25
+ } from "./chunk-HGW4YHAY.ts";
26
+
27
+ // ../agent-provider/src/schemas.ts
28
+ var SCHEMA_IDS = {
29
+ modelPicker: "final://schemas/model-picker",
30
+ credentialPolicy: "final://schemas/credential-policy",
31
+ permissionMode: "final://schemas/permission-mode",
32
+ instructions: "final://schemas/instructions",
33
+ skills: "final://schemas/skills",
34
+ reasoning: "final://schemas/reasoning",
35
+ secretRef: "final://schemas/secret-ref"
36
+ };
37
+ var dynamicSlotJsonSchema = {
38
+ type: "object",
39
+ required: ["$dynamic"],
40
+ properties: {
41
+ $dynamic: {
42
+ type: "object",
43
+ required: ["resolver", "events"],
44
+ properties: {
45
+ resolver: { type: "string" },
46
+ events: { type: "array", items: { enum: ["session.started", "turn.started"] } },
47
+ description: { type: "string" },
48
+ preview: { type: "string" }
49
+ }
50
+ }
51
+ }
52
+ };
53
+ var credentialNodeJsonSchema = {
54
+ type: "object",
55
+ required: ["kind"],
56
+ properties: {
57
+ kind: { enum: ["subscription", "api-key", "platform", "harness-owned", "custom"] },
58
+ owner: { enum: ["payer", "organization"] },
59
+ vendor: { type: "string" },
60
+ pin: { type: "string" },
61
+ secret: { type: "string" },
62
+ baseUrl: { type: "string", format: "uri" },
63
+ budget: { type: "string" },
64
+ resolver: { type: "string" }
65
+ }
66
+ };
67
+ var SHARED_SCHEMAS = {
68
+ [SCHEMA_IDS.modelPicker]: {
69
+ $id: SCHEMA_IDS.modelPicker,
70
+ title: "Model",
71
+ // The harness supplies the enum: { $ref: model-picker, enum: [...] }.
72
+ type: "string",
73
+ "x-final-widget": "model-picker"
74
+ },
75
+ [SCHEMA_IDS.reasoning]: {
76
+ $id: SCHEMA_IDS.reasoning,
77
+ title: "Reasoning",
78
+ enum: ["none", "minimal", "low", "medium", "high", "max"],
79
+ "x-final-widget": "reasoning-picker"
80
+ },
81
+ [SCHEMA_IDS.credentialPolicy]: {
82
+ $id: SCHEMA_IDS.credentialPolicy,
83
+ title: "Credentials",
84
+ type: "object",
85
+ required: ["payer", "tryInOrder"],
86
+ properties: {
87
+ payer: { enum: ["agent-owner", "organization", "prompting-user", "conversation-owner"] },
88
+ tryInOrder: { type: "array", minItems: 1, items: credentialNodeJsonSchema }
89
+ },
90
+ "x-final-widget": "credential-policy"
91
+ },
92
+ [SCHEMA_IDS.permissionMode]: {
93
+ $id: SCHEMA_IDS.permissionMode,
94
+ title: "Permission mode",
95
+ // The harness supplies the enum of its own modes.
96
+ type: "string",
97
+ "x-final-widget": "permission-mode"
98
+ },
99
+ [SCHEMA_IDS.instructions]: {
100
+ $id: SCHEMA_IDS.instructions,
101
+ title: "Instructions",
102
+ type: "array",
103
+ items: {
104
+ anyOf: [
105
+ {
106
+ type: "object",
107
+ required: ["role", "content"],
108
+ properties: {
109
+ role: { enum: ["system", "user"] },
110
+ content: { type: "string" },
111
+ source: { type: "string" }
112
+ }
113
+ },
114
+ dynamicSlotJsonSchema
115
+ ]
116
+ },
117
+ "x-final-widget": "instructions"
118
+ },
119
+ [SCHEMA_IDS.skills]: {
120
+ $id: SCHEMA_IDS.skills,
121
+ title: "Skills",
122
+ type: "array",
123
+ items: {
124
+ anyOf: [
125
+ {
126
+ type: "object",
127
+ required: ["key", "files"],
128
+ properties: {
129
+ key: { type: "string" },
130
+ description: { type: "string" },
131
+ files: {
132
+ type: "array",
133
+ items: {
134
+ type: "object",
135
+ required: ["path", "content"],
136
+ properties: { path: { type: "string" }, content: { type: "string" } }
137
+ }
138
+ }
139
+ }
140
+ },
141
+ dynamicSlotJsonSchema
142
+ ]
143
+ },
144
+ "x-final-widget": "skills"
145
+ },
146
+ [SCHEMA_IDS.secretRef]: {
147
+ $id: SCHEMA_IDS.secretRef,
148
+ title: "Secret",
149
+ type: "object",
150
+ required: ["secretKey"],
151
+ properties: { secretKey: { type: "string" } },
152
+ "x-final-widget": "secret-picker"
153
+ }
154
+ };
155
+ var fieldRefSchema = object({ $ref: string().startsWith("final://schemas/") });
156
+ var propertiesSchema = object({ properties: record(string(), json()) });
157
+ var referencedSharedSchemas = (configSchema) => {
158
+ const parsed = propertiesSchema.safeParse(configSchema);
159
+ const out = {};
160
+ if (!parsed.success) return out;
161
+ for (const [field, fieldSchema] of Object.entries(parsed.data.properties)) {
162
+ const ref = fieldRefSchema.safeParse(fieldSchema);
163
+ if (ref.success) out[field] = ref.data.$ref;
164
+ }
165
+ return out;
166
+ };
167
+
168
+ // ../agent-provider/src/credential-routes.ts
169
+ var CredentialRoute = /* @__PURE__ */ ((CredentialRoute2) => {
170
+ CredentialRoute2["Model"] = "model";
171
+ CredentialRoute2["Mcp"] = "mcp";
172
+ CredentialRoute2["Sandbox"] = "sandbox";
173
+ CredentialRoute2["TranscriptStore"] = "transcript-store";
174
+ CredentialRoute2["SubscriptionRelay"] = "subscription-relay";
175
+ CredentialRoute2["FinalMcp"] = "final-mcp";
176
+ return CredentialRoute2;
177
+ })(CredentialRoute || {});
178
+ var routeGrantSchema = object({
179
+ route: nativeEnum(CredentialRoute),
180
+ token: string().min(1),
181
+ expiresAt: string()
182
+ });
183
+ var credentialRefreshRequestSchema = object({
184
+ harnessSessionId: string().uuid(),
185
+ routes: array(nativeEnum(CredentialRoute)).min(1).max(8)
186
+ });
187
+
188
+ // ../agent-provider/src/harness.ts
189
+ var AcpTransport = /* @__PURE__ */ ((AcpTransport2) => {
190
+ AcpTransport2["Relay"] = "relay";
191
+ AcpTransport2["Ws"] = "ws";
192
+ AcpTransport2["Http"] = "http";
193
+ AcpTransport2["Stdio"] = "stdio";
194
+ return AcpTransport2;
195
+ })(AcpTransport || {});
196
+ var McpTransportKind = /* @__PURE__ */ ((McpTransportKind2) => {
197
+ McpTransportKind2["Acp"] = "acp";
198
+ McpTransportKind2["Http"] = "http";
199
+ McpTransportKind2["Stdio"] = "stdio";
200
+ return McpTransportKind2;
201
+ })(McpTransportKind || {});
202
+ var BaseToolProvision = /* @__PURE__ */ ((BaseToolProvision2) => {
203
+ BaseToolProvision2["Bound"] = "bound";
204
+ BaseToolProvision2["HostDisableable"] = "host-disableable";
205
+ BaseToolProvision2["HostFixed"] = "host-fixed";
206
+ return BaseToolProvision2;
207
+ })(BaseToolProvision || {});
208
+ var SandboxWire = /* @__PURE__ */ ((SandboxWire2) => {
209
+ SandboxWire2["HandleRpc"] = "handle-rpc";
210
+ SandboxWire2["Mcp"] = "mcp";
211
+ return SandboxWire2;
212
+ })(SandboxWire || {});
213
+ var UserInstructionDelivery = /* @__PURE__ */ ((UserInstructionDelivery2) => {
214
+ UserInstructionDelivery2["History"] = "history";
215
+ UserInstructionDelivery2["System"] = "system";
216
+ return UserInstructionDelivery2;
217
+ })(UserInstructionDelivery || {});
218
+ var HarnessTrustClass = /* @__PURE__ */ ((HarnessTrustClass2) => {
219
+ HarnessTrustClass2["FirstParty"] = "first-party";
220
+ HarnessTrustClass2["ThirdParty"] = "third-party";
221
+ return HarnessTrustClass2;
222
+ })(HarnessTrustClass || {});
223
+ var PromptWhileRunning = /* @__PURE__ */ ((PromptWhileRunning2) => {
224
+ PromptWhileRunning2["Inject"] = "inject";
225
+ PromptWhileRunning2["Queue"] = "queue";
226
+ return PromptWhileRunning2;
227
+ })(PromptWhileRunning || {});
228
+ var DEFAULT_PROMPT_WHILE_RUNNING = "queue" /* Queue */;
229
+ var DEFAULT_SESSION_SURVIVES_DISCONNECT = false;
230
+ var baseToolDeclarationSchema = object({
231
+ provision: nativeEnum(BaseToolProvision),
232
+ nativeTools: array(string())
233
+ });
234
+ var harnessDescriptionSchema = object({
235
+ // Everything configurable about this harness (model, reasoning, credentials,
236
+ // permission mode, instructions, skills, cwd, ...). JSON Schema so Build can
237
+ // render it; may $ref the shared final://schemas/* fragments.
238
+ configSchema: jsonSchemaSchema,
239
+ // Absent: user fragments enter history. System-only programs declare their conversion.
240
+ userInstructionDelivery: nativeEnum(UserInstructionDelivery).optional(),
241
+ acp: object({
242
+ transports: array(nativeEnum(AcpTransport)).min(1),
243
+ mcp: array(nativeEnum(McpTransportKind))
244
+ }),
245
+ // A capability missing here is unavailable on this harness.
246
+ baseTools: partialRecord(nativeEnum(BaseCapability), baseToolDeclarationSchema),
247
+ consumes: array(nativeEnum(SandboxWire)),
248
+ inference: object({
249
+ vendors: array(string()),
250
+ kinds: array(nativeEnum(InferenceCredentialKind)),
251
+ delivery: nativeEnum(CredentialDelivery)
252
+ }),
253
+ // Absent: third-party.
254
+ trust: nativeEnum(HarnessTrustClass).optional(),
255
+ supports: object({
256
+ observe: boolean(),
257
+ resumeReplay: boolean(),
258
+ fork: boolean(),
259
+ // Renders _meta["final.ai"].author itself; otherwise the channel prepends
260
+ // the author's name to the text.
261
+ authorMeta: boolean(),
262
+ // Explicit false: native toolPolicy cannot be enforced by this adapter's public surface.
263
+ nativeToolPolicy: boolean().optional()
264
+ }),
265
+ promptWhileRunning: nativeEnum(PromptWhileRunning).default(DEFAULT_PROMPT_WHILE_RUNNING),
266
+ // Keeps the session, its running work and its open requests across a dropped
267
+ // connection, buffers updates for replay, and re-raises the open requests
268
+ // with the same JSON-RPC ids on the next session/resume. False:
269
+ // open turns end `harness_state_lost` after a reconnect.
270
+ sessionSurvivesDisconnect: boolean().default(DEFAULT_SESSION_SURVIVES_DISCONNECT)
271
+ });
272
+ var deliveredHarnessConfig = (args) => {
273
+ if (args.description.userInstructionDelivery !== "system" /* System */)
274
+ return args.config;
275
+ const config = jsonObjectSchema.safeParse(args.config);
276
+ if (!config.success) return args.config;
277
+ const fields = referencedSharedSchemas(args.description.configSchema);
278
+ const field = Object.entries(fields).find(([, schema]) => schema === SCHEMA_IDS.instructions)?.[0] ?? "instructions";
279
+ const instructions = config.data[field];
280
+ if (!Array.isArray(instructions)) return args.config;
281
+ return {
282
+ ...config.data,
283
+ [field]: instructions.map((value) => {
284
+ const fragment = jsonObjectSchema.safeParse(value);
285
+ return fragment.success && fragment.data["role"] === "user" /* User */ ? { ...fragment.data, role: "system" /* System */ } : value;
286
+ })
287
+ };
288
+ };
289
+ var harnessSessionRefSchema = object({
290
+ harness: providerRefSchema,
291
+ // Opaque to the session service; the harness's own id for the session.
292
+ harnessSessionRef: string().min(1),
293
+ // Bumped whenever the harness loses state; a mismatch on resume means the
294
+ // session service must re-seed with session/new.
295
+ generation: number().int().nonnegative()
296
+ });
297
+ var atOpenModelCredentialSchema = object({
298
+ vendor: string(),
299
+ kind: nativeEnum(InferenceCredentialKind),
300
+ baseUrl: string().min(1).nullable(),
301
+ apiKey: string().min(1).nullable(),
302
+ subscription: object({
303
+ format: union([literal("claude-setup-token"), literal("chatgpt-auth-tokens")]),
304
+ value: string().min(1)
305
+ }).nullable(),
306
+ fingerprint: string()
307
+ });
308
+ var credentialGrantRefreshSchema = object({
309
+ url: string().min(1),
310
+ token: string().min(1),
311
+ harnessSessionId: string().min(1),
312
+ expiresAt: string()
313
+ });
314
+ var credentialGrantSchema = object({
315
+ brokerUrl: string().min(1),
316
+ grants: array(routeGrantSchema),
317
+ atOpen: atOpenModelCredentialSchema.nullable(),
318
+ refresh: credentialGrantRefreshSchema.nullable()
319
+ });
320
+ var endpointTokenSchema = object({
321
+ url: string().min(1),
322
+ token: string(),
323
+ expiresAt: string()
324
+ });
325
+ var sandboxTargetEndpointSchema = object({
326
+ target: string().min(1),
327
+ bindingId: string().min(1),
328
+ capabilities: array(string()),
329
+ rpc: endpointTokenSchema.nullable(),
330
+ mcp: endpointTokenSchema.nullable()
331
+ });
332
+ var renewedMcpServerSchema = object({
333
+ name: string().min(1),
334
+ url: string().min(1),
335
+ headers: array(object({ name: string().min(1), value: string() }))
336
+ });
337
+ var credentialRefreshResultSchema = credentialGrantSchema.extend({
338
+ mcpServers: array(renewedMcpServerSchema).default([]),
339
+ sandboxes: record(string(), sandboxTargetEndpointSchema).default({})
340
+ });
341
+
342
+ export {
343
+ SCHEMA_IDS,
344
+ SHARED_SCHEMAS,
345
+ referencedSharedSchemas,
346
+ SandboxWire,
347
+ harnessDescriptionSchema,
348
+ deliveredHarnessConfig
349
+ };
File without changes
@@ -0,0 +1,33 @@
1
+ import {
2
+ awaitableOpenRequest
3
+ } from "./chunk-CWWRTRWW.ts";
4
+ import {
5
+ stamp
6
+ } from "./chunk-XHKPWT3G.ts";
7
+
8
+ // ../agent-provider/src/sandbox/types.ts
9
+ var defineSandboxProvider = (definition) => ({
10
+ definition,
11
+ name: definition.name,
12
+ environment: (options) => ({
13
+ providerName: definition.name,
14
+ options,
15
+ open: (openOptions) => awaitableOpenRequest({
16
+ providerName: definition.name,
17
+ environmentOptions: options,
18
+ openOptions
19
+ })
20
+ })
21
+ });
22
+
23
+ // src/authoring/sandbox.ts
24
+ var harnessHost = stamp({ harnessHost: true }, "harness-host" /* HarnessHost */);
25
+ var defineSandbox = (value) => value instanceof Function ? stamp(value, "sandbox-selector" /* SandboxSelector */) : value;
26
+ var baseTools = (base) => stamp({ base: { ...base } }, "base-tools" /* BaseTools */);
27
+
28
+ export {
29
+ defineSandboxProvider,
30
+ harnessHost,
31
+ defineSandbox,
32
+ baseTools
33
+ };