@agentjam/sdk 0.8.0 → 0.10.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.
Files changed (178) hide show
  1. package/README.md +3 -2
  2. package/dist/agent.d.ts +52 -16
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +211 -70
  5. package/dist/agent.js.map +1 -1
  6. package/dist/anyOf.d.ts +2 -0
  7. package/dist/anyOf.d.ts.map +1 -1
  8. package/dist/anyOf.js +3 -0
  9. package/dist/anyOf.js.map +1 -1
  10. package/dist/artifacts.d.ts +8 -9
  11. package/dist/artifacts.d.ts.map +1 -1
  12. package/dist/artifacts.js +40 -76
  13. package/dist/artifacts.js.map +1 -1
  14. package/dist/attachments.d.ts +30 -5
  15. package/dist/attachments.d.ts.map +1 -1
  16. package/dist/attachments.js +53 -8
  17. package/dist/attachments.js.map +1 -1
  18. package/dist/connections.d.ts +3 -1
  19. package/dist/connections.d.ts.map +1 -1
  20. package/dist/connections.js +1 -0
  21. package/dist/connections.js.map +1 -1
  22. package/dist/content.d.ts +3 -9
  23. package/dist/content.d.ts.map +1 -1
  24. package/dist/content.js +0 -9
  25. package/dist/content.js.map +1 -1
  26. package/dist/definitions.d.ts +20 -0
  27. package/dist/definitions.d.ts.map +1 -0
  28. package/dist/definitions.js +28 -0
  29. package/dist/definitions.js.map +1 -0
  30. package/dist/errors.d.ts +24 -0
  31. package/dist/errors.d.ts.map +1 -1
  32. package/dist/errors.js +28 -0
  33. package/dist/errors.js.map +1 -1
  34. package/dist/files.d.ts +16 -4
  35. package/dist/files.d.ts.map +1 -1
  36. package/dist/files.js +26 -11
  37. package/dist/files.js.map +1 -1
  38. package/dist/index.d.ts +6 -4
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +3 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/inputs.d.ts +14 -0
  43. package/dist/inputs.d.ts.map +1 -1
  44. package/dist/inputs.js +59 -12
  45. package/dist/inputs.js.map +1 -1
  46. package/dist/managedWebhooks.d.ts.map +1 -1
  47. package/dist/managedWebhooks.js +2 -0
  48. package/dist/managedWebhooks.js.map +1 -1
  49. package/dist/platforms/datadog.d.ts +2 -2
  50. package/dist/platforms/datadog.d.ts.map +1 -1
  51. package/dist/platforms/discord.d.ts +59 -54
  52. package/dist/platforms/discord.d.ts.map +1 -1
  53. package/dist/platforms/discord.js +4 -0
  54. package/dist/platforms/discord.js.map +1 -1
  55. package/dist/platforms/discordEvents.d.ts.map +1 -1
  56. package/dist/platforms/discordEvents.js +2 -0
  57. package/dist/platforms/discordEvents.js.map +1 -1
  58. package/dist/platforms/discordInteractions.d.ts.map +1 -1
  59. package/dist/platforms/discordInteractions.js +2 -0
  60. package/dist/platforms/discordInteractions.js.map +1 -1
  61. package/dist/platforms/github.d.ts +37 -34
  62. package/dist/platforms/github.d.ts.map +1 -1
  63. package/dist/platforms/github.js +4 -0
  64. package/dist/platforms/github.js.map +1 -1
  65. package/dist/platforms/githubEvents.d.ts.map +1 -1
  66. package/dist/platforms/githubEvents.js +2 -0
  67. package/dist/platforms/githubEvents.js.map +1 -1
  68. package/dist/platforms/grafana.d.ts +2 -2
  69. package/dist/platforms/grafana.d.ts.map +1 -1
  70. package/dist/platforms/microsoft.d.ts +6 -3
  71. package/dist/platforms/microsoft.d.ts.map +1 -1
  72. package/dist/platforms/microsoft.js +4 -0
  73. package/dist/platforms/microsoft.js.map +1 -1
  74. package/dist/platforms/pagerduty.d.ts +2 -2
  75. package/dist/platforms/pagerduty.d.ts.map +1 -1
  76. package/dist/platforms/sentry.d.ts +8 -7
  77. package/dist/platforms/sentry.d.ts.map +1 -1
  78. package/dist/platforms/sentry.js +2 -0
  79. package/dist/platforms/sentry.js.map +1 -1
  80. package/dist/platforms/sentryEvents.d.ts.map +1 -1
  81. package/dist/platforms/sentryEvents.js +2 -0
  82. package/dist/platforms/sentryEvents.js.map +1 -1
  83. package/dist/platforms/slack.d.ts +54 -54
  84. package/dist/platforms/slack.d.ts.map +1 -1
  85. package/dist/platforms/slackEvents.d.ts.map +1 -1
  86. package/dist/platforms/slackEvents.js +2 -0
  87. package/dist/platforms/slackEvents.js.map +1 -1
  88. package/dist/platforms/slackInteractions.d.ts.map +1 -1
  89. package/dist/platforms/slackInteractions.js +2 -0
  90. package/dist/platforms/slackInteractions.js.map +1 -1
  91. package/dist/principals.d.ts +9 -0
  92. package/dist/principals.d.ts.map +1 -0
  93. package/dist/principals.js +9 -0
  94. package/dist/principals.js.map +1 -0
  95. package/dist/profile.d.ts +7 -7
  96. package/dist/profile.d.ts.map +1 -1
  97. package/dist/profile.js +11 -7
  98. package/dist/profile.js.map +1 -1
  99. package/dist/protocol.d.ts +19 -7
  100. package/dist/protocol.d.ts.map +1 -1
  101. package/dist/recaps.d.ts +12 -2
  102. package/dist/recaps.d.ts.map +1 -1
  103. package/dist/recaps.js +12 -1
  104. package/dist/recaps.js.map +1 -1
  105. package/dist/relay/chains.d.ts +6 -1
  106. package/dist/relay/chains.d.ts.map +1 -1
  107. package/dist/relay/chains.js +16 -1
  108. package/dist/relay/chains.js.map +1 -1
  109. package/dist/relay/frames.d.ts +3 -2
  110. package/dist/relay/frames.d.ts.map +1 -1
  111. package/dist/relay/frames.js +8 -2
  112. package/dist/relay/frames.js.map +1 -1
  113. package/dist/relay/history.d.ts +45 -0
  114. package/dist/relay/history.d.ts.map +1 -0
  115. package/dist/relay/history.js +235 -0
  116. package/dist/relay/history.js.map +1 -0
  117. package/dist/relay/memory.d.ts +34 -10
  118. package/dist/relay/memory.d.ts.map +1 -1
  119. package/dist/relay/memory.js +180 -36
  120. package/dist/relay/memory.js.map +1 -1
  121. package/dist/relay/relay.d.ts +2 -0
  122. package/dist/relay/relay.d.ts.map +1 -1
  123. package/dist/relay/remote.d.ts +1 -1
  124. package/dist/relay/remote.d.ts.map +1 -1
  125. package/dist/relay/remote.js +4 -2
  126. package/dist/relay/remote.js.map +1 -1
  127. package/dist/relay/resumes.d.ts +40 -0
  128. package/dist/relay/resumes.d.ts.map +1 -0
  129. package/dist/relay/resumes.js +75 -0
  130. package/dist/relay/resumes.js.map +1 -0
  131. package/dist/relay/schedules.d.ts.map +1 -1
  132. package/dist/relay/schedules.js +3 -2
  133. package/dist/relay/schedules.js.map +1 -1
  134. package/dist/relay/sessions.d.ts +14 -4
  135. package/dist/relay/sessions.d.ts.map +1 -1
  136. package/dist/relay/sessions.js +30 -8
  137. package/dist/relay/sessions.js.map +1 -1
  138. package/dist/relay/subscriptions.d.ts.map +1 -1
  139. package/dist/relay/subscriptions.js +2 -1
  140. package/dist/relay/subscriptions.js.map +1 -1
  141. package/dist/secrets.js +1 -0
  142. package/dist/secrets.js.map +1 -1
  143. package/dist/skillChecks.d.ts +58 -0
  144. package/dist/skillChecks.d.ts.map +1 -0
  145. package/dist/skillChecks.js +173 -0
  146. package/dist/skillChecks.js.map +1 -0
  147. package/dist/subscriptions.d.ts +4 -2
  148. package/dist/subscriptions.d.ts.map +1 -1
  149. package/dist/subscriptions.js +20 -7
  150. package/dist/subscriptions.js.map +1 -1
  151. package/dist/tasks/incoming.d.ts +78 -34
  152. package/dist/tasks/incoming.d.ts.map +1 -1
  153. package/dist/tasks/incoming.js +75 -32
  154. package/dist/tasks/incoming.js.map +1 -1
  155. package/dist/tasks/triggers.d.ts +2 -2
  156. package/dist/tasks/triggers.d.ts.map +1 -1
  157. package/dist/tasks/triggers.js +11 -1
  158. package/dist/tasks/triggers.js.map +1 -1
  159. package/dist/tools/network.js +1 -1
  160. package/dist/tools/network.js.map +1 -1
  161. package/dist/tools/shared.d.ts +3 -3
  162. package/dist/types.d.ts +219 -63
  163. package/dist/types.d.ts.map +1 -1
  164. package/dist/vaults/local.d.ts +1 -0
  165. package/dist/vaults/local.d.ts.map +1 -1
  166. package/dist/vaults/local.js +13 -0
  167. package/dist/vaults/local.js.map +1 -1
  168. package/dist/vaults/remote.d.ts +2 -0
  169. package/dist/vaults/remote.d.ts.map +1 -1
  170. package/dist/vaults/remote.js +2 -0
  171. package/dist/vaults/remote.js.map +1 -1
  172. package/dist/vaults/vault.d.ts.map +1 -1
  173. package/dist/vaults/vault.js.map +1 -1
  174. package/dist/verdicts.d.ts +4 -2
  175. package/dist/verdicts.d.ts.map +1 -1
  176. package/dist/verdicts.js +4 -2
  177. package/dist/verdicts.js.map +1 -1
  178. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAW5C,kFAAkF;AAClF,MAAM,UAAU,GAAG;IACjB,MAAM,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC7B,MAAM,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;CACmC,CAAC;AA4CnE,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAE7C,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAEpE,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAM,iBAAiB,GAAG,sCAAsC,CAAC;AAEjE,MAAM,WAAW,GAA0B;IACzC,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;IACL,OAAO;IACP,QAAQ;CACT,CAAC;AAEF,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AAE1D,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAC9B,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEjE,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAkB,EAAE,EAAE;IAC9D,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,OAAO,mCAAmC,WAAW,CAAC,IAAI,CAAC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AAC,OAAO,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;KAC5D,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,58 @@
1
+ import type { AttachmentRef, TaskRecapRef } from "./protocol.js";
2
+ import type { AgentCard, AttachmentRequirement, AttachmentRequirements, RunMode, SkillCard } from "./types.js";
3
+ /** What the network checks a proposal against its executor's card by, whether it arrived as a proposal or an envelope. */
4
+ export type ProposedWork = {
5
+ from: string;
6
+ skill?: string | undefined;
7
+ cron?: unknown;
8
+ trigger?: unknown;
9
+ };
10
+ /** A file as attachment requirements match it, by its name and MIME type. */
11
+ export type NamedFile = {
12
+ name?: string | undefined;
13
+ mimeType?: string | undefined;
14
+ };
15
+ /** The files a proposal offers its skill's attachment requirements: the ones it attaches, and the file artifacts of the task it follows up on. */
16
+ export type OfferedFiles<File extends NamedFile = NamedFile> = {
17
+ attached: File[];
18
+ previous: File[];
19
+ };
20
+ /** Returns how proposed work runs: on a trigger, on a cron, or once. */
21
+ export declare const getRunMode: ({ cron, trigger }: ProposedWork) => RunMode;
22
+ /**
23
+ * Describes why a proposal must name one of an agent's skills, listing each with its description's first sentence.
24
+ *
25
+ * @param agent The agent the proposal is for.
26
+ * @param skills The skills the proposer can see.
27
+ * @returns The refusal the requester reads.
28
+ */
29
+ export declare const describeMissingSkill: (agent: string, skills: SkillCard[]) => string;
30
+ /** Returns the skills of the agent with `card` that `viewer` can see and propose, leaving out the private ones of other agents. */
31
+ export declare const listVisibleSkills: (card: AgentCard, viewer: string) => SkillCard[];
32
+ /**
33
+ * Matches each of a skill's attachment requirements to the first attached file that meets it, or else, when the
34
+ * requirement allows it, to the first file artifact of the followed-up task that does.
35
+ *
36
+ * @returns The file that met each requirement by key, and the requirements no file met.
37
+ */
38
+ export declare const matchRequirements: <File extends NamedFile>(requirements: AttachmentRequirements | undefined, { attached, previous }: OfferedFiles<File>) => {
39
+ included: Record<string, File>;
40
+ unmet: [string, AttachmentRequirement][];
41
+ };
42
+ /** Returns the files a proposal envelope offers its skill's attachment requirements. */
43
+ export declare const listOfferedFiles: ({ attachments, previous, }: {
44
+ attachments?: AttachmentRef[] | undefined;
45
+ previous?: TaskRecapRef | undefined;
46
+ }) => OfferedFiles;
47
+ /**
48
+ * Returns why the network refuses work proposed to the agent with `card` before the agent sees it, judged by the card
49
+ * and the files the proposal offers, or undefined when it doesn't.
50
+ */
51
+ export declare const findProposalProblem: (card: AgentCard, work: ProposedWork, offered: OfferedFiles) => string | undefined;
52
+ /**
53
+ * Checks the skills an agent publishes follow the network's rules.
54
+ *
55
+ * @throws {AgentJamError} If a skill breaks one, saying how.
56
+ */
57
+ export declare const assertSkillCards: (skills: SkillCard[]) => void;
58
+ //# sourceMappingURL=skillChecks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skillChecks.d.ts","sourceRoot":"","sources":["../src/skillChecks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,KAAK,EACV,SAAS,EAET,qBAAqB,EACrB,sBAAsB,EACtB,OAAO,EACP,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB,0HAA0H;AAC1H,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,kJAAkJ;AAClJ,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,SAAS,GAAG,SAAS,IAAI;IAC7D,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjB,QAAQ,EAAE,IAAI,EAAE,CAAC;CAClB,CAAC;AAgCF,wEAAwE;AACxE,eAAO,MAAM,UAAU,sBAAuB,YAAY,KAAG,OAI5D,CAAC;AAqBF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,UAAW,MAAM,UAAU,SAAS,EAAE,WACkD,CAAC;AAE1H,mIAAmI;AACnI,eAAO,MAAM,iBAAiB,SAAU,SAAS,UAAU,MAAM,gBAG9D,CAAC;AAmBJ;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,IAAI,SAAS,SAAS,gBACxC,sBAAsB,GAAG,SAAS,0BACxB,YAAY,CAAC,IAAI,CAAC;;;CAmB3C,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,+BAG1B;IACD,WAAW,CAAC,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACrC,KAAG,YAGF,CAAC;AAqBH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,SACxB,SAAS,QACT,YAAY,WACT,YAAY,KACpB,MAAM,GAAG,SAYX,CAAC;AAkEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAY,SAAS,EAAE,SAOnD,CAAC"}
@@ -0,0 +1,173 @@
1
+ import { AgentJamError } from "./errors.js";
2
+ import { assertSubscriptions } from "./subscriptions.js";
3
+ const requirementKey = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
4
+ const maxRequirements = 10;
5
+ const maxMatches = 20;
6
+ const maxDescription = 500;
7
+ const previousChoice = "a matching file the followed-up task delivered";
8
+ const runModes = {
9
+ oneOff: {
10
+ shape: "a one-off task",
11
+ refusal: "it can't run as a one-off task",
12
+ },
13
+ cron: {
14
+ shape: "a cron schedule",
15
+ refusal: "it can't be scheduled on a cron",
16
+ },
17
+ trigger: {
18
+ shape: "a triggered schedule",
19
+ refusal: "it can't be scheduled on a trigger",
20
+ },
21
+ };
22
+ const joinChoices = (choices) => choices.length < 2
23
+ ? choices.join("")
24
+ : `${choices.slice(0, -1).join(", ")} or ${choices.at(-1)}`;
25
+ /** Returns how proposed work runs: on a trigger, on a cron, or once. */
26
+ export const getRunMode = ({ cron, trigger }) => {
27
+ if (trigger)
28
+ return "trigger";
29
+ return cron ? "cron" : "oneOff";
30
+ };
31
+ const findRunModeProblem = ({ name, runsAs }, work) => {
32
+ const mode = getRunMode(work);
33
+ if (!runsAs || runsAs.includes(mode))
34
+ return undefined;
35
+ const shapes = runsAs.map((allowed) => runModes[allowed].shape);
36
+ return `The "${name}" skill runs only as ${joinChoices(shapes)}, so ${runModes[mode].refusal}`;
37
+ };
38
+ const describeSkill = ({ name, description }) => {
39
+ const sentence = /^.*?[.!?](?=\s|$)/s.exec(description.trim())?.[0];
40
+ const summary = sentence ?? description.trim();
41
+ return summary === "" ? `"${name}"` : `"${name}" (${summary})`;
42
+ };
43
+ /**
44
+ * Describes why a proposal must name one of an agent's skills, listing each with its description's first sentence.
45
+ *
46
+ * @param agent The agent the proposal is for.
47
+ * @param skills The skills the proposer can see.
48
+ * @returns The refusal the requester reads.
49
+ */
50
+ export const describeMissingSkill = (agent, skills) => `"${agent}" charges for its skills, so propose again with skill set to one of: ${skills.map(describeSkill).join(", ")}`;
51
+ /** Returns the skills of the agent with `card` that `viewer` can see and propose, leaving out the private ones of other agents. */
52
+ export const listVisibleSkills = (card, viewer) => card.skills.filter(({ visibility }) => visibility !== "private" || viewer === card.name);
53
+ const stripParameters = (mimeType) => mimeType.split(";")[0].trim().toLowerCase();
54
+ const isMimeTypeMatching = (mimeType, pattern) => {
55
+ const type = stripParameters(mimeType);
56
+ const wanted = stripParameters(pattern);
57
+ return wanted.endsWith("/*")
58
+ ? type.startsWith(wanted.slice(0, -1))
59
+ : type === wanted;
60
+ };
61
+ const isMatching = ({ name, mimeType }, match) => "extension" in match
62
+ ? (name ?? "").toLowerCase().endsWith(match.extension.toLowerCase())
63
+ : mimeType !== undefined && isMimeTypeMatching(mimeType, match.mimeType);
64
+ /**
65
+ * Matches each of a skill's attachment requirements to the first attached file that meets it, or else, when the
66
+ * requirement allows it, to the first file artifact of the followed-up task that does.
67
+ *
68
+ * @returns The file that met each requirement by key, and the requirements no file met.
69
+ */
70
+ export const matchRequirements = (requirements, { attached, previous }) => {
71
+ const included = {};
72
+ const unmet = [];
73
+ for (const [key, requirement] of Object.entries(requirements?.mustInclude ?? {})) {
74
+ const isMeeting = (file) => requirement.anyOf.some((match) => isMatching(file, match));
75
+ const file = attached.find(isMeeting) ??
76
+ (requirement.orPreviousArtifact ? previous.find(isMeeting) : undefined);
77
+ if (file)
78
+ included[key] = file;
79
+ else
80
+ unmet.push([key, requirement]);
81
+ }
82
+ return { included, unmet };
83
+ };
84
+ /** Returns the files a proposal envelope offers its skill's attachment requirements. */
85
+ export const listOfferedFiles = ({ attachments = [], previous, }) => ({
86
+ attached: attachments,
87
+ previous: previous?.artifacts.filter(({ kind }) => kind === "file") ?? [],
88
+ });
89
+ const describeRequirement = ([key, requirement]) => {
90
+ const choices = requirement.anyOf.map((match) => "extension" in match ? match.extension : match.mimeType);
91
+ if (requirement.orPreviousArtifact)
92
+ choices.push(previousChoice);
93
+ return `"${key}" (${requirement.description}), which accepts ${joinChoices(choices)}`;
94
+ };
95
+ const findAttachmentProblem = (skill, offered) => {
96
+ const { unmet } = matchRequirements(skill.attachments, offered);
97
+ if (unmet.length === 0)
98
+ return undefined;
99
+ return `The "${skill.name}" skill needs attachments the proposal doesn't include: ${unmet.map(describeRequirement).join("; ")}`;
100
+ };
101
+ /**
102
+ * Returns why the network refuses work proposed to the agent with `card` before the agent sees it, judged by the card
103
+ * and the files the proposal offers, or undefined when it doesn't.
104
+ */
105
+ export const findProposalProblem = (card, work, offered) => {
106
+ const skill = listVisibleSkills(card, work.from).find(({ name }) => name === work.skill);
107
+ if (work.skill !== undefined && !skill) {
108
+ return `"${card.name}" has no "${work.skill}" skill`;
109
+ }
110
+ return (skill &&
111
+ (findRunModeProblem(skill, work) ?? findAttachmentProblem(skill, offered)));
112
+ };
113
+ const findRunModesProblem = ({ name, runsAs, triggers }) => {
114
+ if (!runsAs)
115
+ return undefined;
116
+ if (runsAs.length === 0 || new Set(runsAs).size < runsAs.length) {
117
+ return `The "${name}" skill must list each of its run modes once`;
118
+ }
119
+ const unknown = runsAs.find((mode) => !Object.hasOwn(runModes, mode));
120
+ if (unknown !== undefined) {
121
+ return `The "${name}" skill lists the unknown run mode "${unknown}"`;
122
+ }
123
+ return runsAs.includes("trigger") && !triggers?.length
124
+ ? `The "${name}" skill runs on a trigger, so it must declare at least one`
125
+ : undefined;
126
+ };
127
+ const findMatchProblem = (name, key, match) => {
128
+ if ("extension" in match) {
129
+ return match.extension.startsWith(".") && match.extension.length > 1
130
+ ? undefined
131
+ : `The "${name}" skill's "${key}" attachment lists the extension "${match.extension}", which must start with a dot`;
132
+ }
133
+ return match.mimeType.includes("/")
134
+ ? undefined
135
+ : `The "${name}" skill's "${key}" attachment lists "${match.mimeType}", which isn't a MIME type`;
136
+ };
137
+ const findRequirementProblem = (name, [key, { description, anyOf }]) => {
138
+ if (!requirementKey.test(key)) {
139
+ return `The "${name}" skill's attachment key "${key}" must be 1 to 64 letters, digits, hyphens or underscores, starting with a letter or digit`;
140
+ }
141
+ if (description.length > maxDescription) {
142
+ return `The "${name}" skill's "${key}" attachment description must be at most ${maxDescription} characters`;
143
+ }
144
+ if (anyOf.length === 0 || anyOf.length > maxMatches) {
145
+ return `The "${name}" skill's "${key}" attachment must accept from 1 to ${maxMatches} file types`;
146
+ }
147
+ return anyOf
148
+ .map((match) => findMatchProblem(name, key, match))
149
+ .find((problem) => problem !== undefined);
150
+ };
151
+ const findRequirementsProblem = ({ name, attachments }) => {
152
+ const requirements = Object.entries(attachments?.mustInclude ?? {});
153
+ if (requirements.length > maxRequirements) {
154
+ return `The "${name}" skill must require at most ${maxRequirements} attachments`;
155
+ }
156
+ return requirements
157
+ .map((requirement) => findRequirementProblem(name, requirement))
158
+ .find((problem) => problem !== undefined);
159
+ };
160
+ /**
161
+ * Checks the skills an agent publishes follow the network's rules.
162
+ *
163
+ * @throws {AgentJamError} If a skill breaks one, saying how.
164
+ */
165
+ export const assertSkillCards = (skills) => {
166
+ for (const card of skills) {
167
+ const problem = findRunModesProblem(card) ?? findRequirementsProblem(card);
168
+ if (problem)
169
+ throw new AgentJamError(problem);
170
+ }
171
+ assertSubscriptions(skills);
172
+ };
173
+ //# sourceMappingURL=skillChecks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skillChecks.js","sourceRoot":"","sources":["../src/skillChecks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AA8BzD,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAE1D,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAM,cAAc,GAAG,gDAAgD,CAAC;AAExE,MAAM,QAAQ,GAAwD;IACpE,MAAM,EAAE;QACN,KAAK,EAAE,gBAAgB;QACvB,OAAO,EAAE,gCAAgC;KAC1C;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,iBAAiB;QACxB,OAAO,EAAE,iCAAiC;KAC3C;IACD,OAAO,EAAE;QACP,KAAK,EAAE,sBAAsB;QAC7B,OAAO,EAAE,oCAAoC;KAC9C;CACF,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,OAAiB,EAAE,EAAE,CACxC,OAAO,CAAC,MAAM,GAAG,CAAC;IAChB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;IAClB,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC,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AC;IACnF,CAAC;IAED,OAAO,YAAY;SAChB,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,sBAAsB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SAC/D,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAmB,EAAE,EAAE;IACtD,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAC3E,IAAI,OAAO;YAAE,MAAM,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC,CAAC"}
@@ -1,7 +1,9 @@
1
1
  import type { SkillCard } from "./types.js";
2
+ /** Returns the id of the schedule the subscription that the completed task `taskId` starts runs as. */
3
+ export declare const constructSubscriptionId: (taskId: string) => string;
2
4
  /**
3
- * Checks that each skill's `subscribes` names a trigger of another of the agent's skills, which has no connections,
4
- * and expires after 1 to 365 days, weeks or months, as the network requires.
5
+ * Checks that each skill's `subscribes` names a trigger of another of the agent's skills, whose every connection it
6
+ * declares too with at least the same scopes, and expires after 1 to 365 days, weeks or months, as the network requires.
5
7
  *
6
8
  * @throws {AgentJamError} If a skill's `subscribes` breaks one of those rules.
7
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../src/subscriptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAU,SAAS,EAAqB,MAAM,YAAY,CAAC;AAoCvE;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,WAAY,SAAS,EAAE,SAKtD,CAAC"}
1
+ {"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../src/subscriptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,SAAS,EAEV,MAAM,YAAY,CAAC;AAOpB,uGAAuG;AACvG,eAAO,MAAM,uBAAuB,WAAY,MAAM,WAC5B,CAAC;AAyD3B;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,WAAY,SAAS,EAAE,SAMtD,CAAC"}
@@ -1,11 +1,23 @@
1
1
  import { AgentJamError } from "./errors.js";
2
+ import { coversScopes } from "./vaults/vault.js";
2
3
  const periodUnits = ["day", "week", "month"];
4
+ /** Returns the id of the schedule the subscription that the completed task `taskId` starts runs as. */
5
+ export const constructSubscriptionId = (taskId) => `${taskId}:subscription`;
3
6
  const isExpiry = (period) => period !== undefined &&
4
7
  Number.isInteger(period.count) &&
5
8
  period.count >= 1 &&
6
9
  period.count <= 365 &&
7
10
  periodUnits.includes(period.unit);
8
- const describeProblem = (name, { skill, trigger, expiresAfter }, skills) => {
11
+ const kindOf = ({ kind = "oauth" }) => kind;
12
+ /** Whether `offered` is for `needed`'s provider with every scope it needs, counting no implied scopes, as the network does. */
13
+ const coversProvider = (offered, needed) => offered.provider === needed.provider &&
14
+ coversScopes(offered.scopes, needed.scopes, {});
15
+ /** Whether each option a task may be pinned to through `offered` is one `needed` takes. */
16
+ const coversOptions = (offered = [], needed = []) => offered.every((option) => needed.some((wanted) => coversProvider(option, wanted)));
17
+ const servesConnection = (offered, needed) => kindOf(offered) === kindOf(needed) &&
18
+ coversProvider(offered, needed) &&
19
+ coversOptions(offered.options, needed.options);
20
+ const describeProblem = ({ name, connections = [] }, { skill, trigger, expiresAfter }, skills) => {
9
21
  if (skill === name) {
10
22
  return `The "${name}" skill can't subscribe its requesters to a trigger of its own`;
11
23
  }
@@ -16,22 +28,23 @@ const describeProblem = (name, { skill, trigger, expiresAfter }, skills) => {
16
28
  if (!target.triggers?.some((card) => card.name === trigger)) {
17
29
  return `The "${name}" skill subscribes to the "${trigger}" trigger, which the "${skill}" skill doesn't declare`;
18
30
  }
19
- if (target.connections?.length) {
20
- return `${subscribed}, which can't have connections`;
31
+ const isServed = (needed) => connections.some((offered) => servesConnection(offered, needed));
32
+ if (!(target.connections ?? []).every(isServed)) {
33
+ return `${subscribed}, so it must declare every connection the "${skill}" skill needs`;
21
34
  }
22
35
  return isExpiry(expiresAfter)
23
36
  ? undefined
24
37
  : `The "${name}" skill's subscription must expire after a whole number from 1 to 365 days, weeks or months`;
25
38
  };
26
39
  /**
27
- * Checks that each skill's `subscribes` names a trigger of another of the agent's skills, which has no connections,
28
- * and expires after 1 to 365 days, weeks or months, as the network requires.
40
+ * Checks that each skill's `subscribes` names a trigger of another of the agent's skills, whose every connection it
41
+ * declares too with at least the same scopes, and expires after 1 to 365 days, weeks or months, as the network requires.
29
42
  *
30
43
  * @throws {AgentJamError} If a skill's `subscribes` breaks one of those rules.
31
44
  */
32
45
  export const assertSubscriptions = (skills) => {
33
- for (const { name, subscribes } of skills) {
34
- const problem = subscribes && describeProblem(name, subscribes, skills);
46
+ for (const card of skills) {
47
+ const problem = card.subscribes && describeProblem(card, card.subscribes, skills);
35
48
  if (problem)
36
49
  throw new AgentJamError(problem);
37
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../src/subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,WAAW,GAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAEhE,MAAM,QAAQ,GAAG,CAAC,MAA0B,EAAE,EAAE,CAC9C,MAAM,KAAK,SAAS;IACpB,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;IAC9B,MAAM,CAAC,KAAK,IAAI,CAAC;IACjB,MAAM,CAAC,KAAK,IAAI,GAAG;IACnB,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAEpC,MAAM,eAAe,GAAG,CACtB,IAAY,EACZ,EAA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C;QAC3B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,QAAQ,IAAI,6FAA6F,CAAC;AAChH,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAmB,EAAE,EAAE;IACzD,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,OAAO,GACX,IAAI,CAAC,UAAU,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACpE,IAAI,OAAO;YAAE,MAAM,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC"}
@@ -2,41 +2,57 @@ import type { AnyOfConnection, AnyOfCredentials } from "../anyOf.js";
2
2
  import type { ArtifactSource } from "../artifacts.js";
3
3
  import type { CredentialSource } from "../connections.js";
4
4
  import { AgentJamError } from "../errors.js";
5
- import type { Body, CostReport, TaskEndCode, TaskEnvelope } from "../protocol.js";
5
+ import type { Body, CostReport, TaskEndCode, TaskEnvelope, TaskRef } from "../protocol.js";
6
6
  import type { Account } from "../providers.js";
7
7
  import type { UploadSource } from "../relay/uploads.js";
8
- import type { Attachment, Awaitable, ConnectionFetch, DeclaredConnection, Delegate, HistoryPage, HistoryQuery, IncomingMessage, InferInput, InferOutput, InputSchema, JsonObject, MessageReply, Price, SecretConnection, SendOptions, SkillCard, TaskInbox, TaskRecap, TriggerCard, TriggerEvent } from "../types.js";
8
+ import type { Attachment, Awaitable, ConnectionFetch, DeclaredConnection, Delegate, FiredEvent, HistoryPage, HistoryQuery, IncludedFiles, IncomingMessage, InferInput, InputSchema, JsonObject, MessageReply, Price, SecretConnection, SendOptions, SkillCard, TaskEnding, TaskInbox, TaskRecap, TriggerCard } from "../types.js";
9
9
  import type { AccessOptions } from "./access.js";
10
10
  /** What `onTask` may return: nothing, one artifact source, or several to send in order. */
11
11
  export type TaskOutput = ArtifactSource | ArtifactSource[] | void;
12
12
  /** A task this agent accepted. It's passed to `onTask` and available through `currentTask()`. */
13
- export interface IncomingTask {
13
+ export interface IncomingTask<Input = unknown, Event = FiredEvent | undefined, Included = IncludedFiles> {
14
14
  /** The task's unique id. */
15
15
  readonly id: string;
16
16
  /** The agent that proposed the task. */
17
17
  readonly from: string;
18
- /** The human whose request started the task's chain, as their email or `guest:<agent>`, or `undefined` on relays that don't track one. */
19
- readonly principal: string | undefined;
18
+ /** The human whose request started the task's chain, as their email or `guest:<agent>` for a chain no human started. */
19
+ readonly principal: string;
20
20
  /** The requester's description of the task. */
21
21
  readonly text: string;
22
22
  /** The name of the skill the task calls for, if the requester named one. */
23
23
  readonly skill: string | undefined;
24
- /** The requester's structured input, which the relay validated against the skill's input schema. */
25
- readonly input: JsonObject | undefined;
24
+ /**
25
+ * The requester's structured input. For a skill with an `input` schema, it's the schema's parsed output, so its
26
+ * refinements held and its transforms applied.
27
+ */
28
+ readonly input: Input;
26
29
  /** The files the requester attached, already downloaded. */
27
30
  readonly attachments: Attachment[];
31
+ /**
32
+ * The file that met each of the skill's attachment requirements, by requirement key: the first attached file that
33
+ * matches it, or else the first matching file artifact of the task this one follows up on.
34
+ */
35
+ readonly included: Included;
28
36
  /** What the earlier task this one follows up on asked for and produced, when the requester proposed it as a follow-up. */
29
37
  readonly previous: TaskRecap | undefined;
38
+ /** The follow-up chain the task belongs to. */
39
+ readonly chain: TaskChain;
30
40
  /** The schedule this task is a run of, if any. */
31
41
  readonly scheduleId: string | undefined;
32
42
  /** The run's number, starting from 1, if the task is a run of a schedule. */
33
43
  readonly run: number | undefined;
34
- /** The trigger event that started this run, if it's a run of a trigger schedule. */
35
- readonly event: TriggerEvent | undefined;
44
+ /** The trigger event that started this run, with its trigger's name and parsed data, if it's a run of a trigger schedule. */
45
+ readonly event: Event;
36
46
  /** Whether another session of this agent started the task before it left, so the work may be partly done. */
37
47
  readonly resumed: boolean;
38
48
  /** Which attempt at the task this is: 1 for the first, plus one for each time it resumed. */
39
49
  readonly attempt: number;
50
+ /**
51
+ * Whether this attempt left the session for another session to resume, because the task moved or this session left
52
+ * it running when it drained or closed. Check it to keep what the resumed attempt needs alive, such as not closing a
53
+ * sandbox in `finally`. It stays false for cancellations, failures and disconnects.
54
+ */
55
+ readonly handedOver: boolean;
40
56
  /**
41
57
  * Aborts when the requester cancels, the task fails, or this agent disconnects. It aborts with a `ReassignedError` once
42
58
  * the task moved to another session of this agent, after which nothing this session sends for it reaches the requester.
@@ -57,15 +73,32 @@ export interface IncomingTask {
57
73
  /**
58
74
  * Sends the requester a message about this task and resolves with its reply, waiting until the task
59
75
  * ends since a human may need to answer. It reaches the session that proposed the task, in a
60
- * conversation named after the task unless `options` names another.
76
+ * conversation named after the task unless `options` names another. Use `sendWithDefault()` for a
77
+ * reply the task can do without.
61
78
  *
62
79
  * @param text The message to send.
63
80
  * @param options The conversation to continue and the files to attach, plus per-call request overrides.
64
81
  * @returns The requester's reply, with its files downloaded.
65
82
  * @throws {AgentNotFoundError} If the session that proposed the task is gone.
83
+ * @throws {MessagesNotAcceptedError} If the requester connected without `onMessage`.
66
84
  * @throws {TimeoutError} If `options` sets a timeout and no reply arrives within it.
67
85
  */
68
86
  send(text: string, options?: RequesterMessageOptions): Promise<MessageReply>;
87
+ /**
88
+ * Sends the requester a message about this task like `send()`, but resolves with `fallback` instead
89
+ * of throwing when no reply can come: the reply takes longer than `timeoutMs`, the session that
90
+ * proposed the task is gone, or the requester takes no messages. It's a shorthand for wrapping
91
+ * `send()` in a try/catch for those errors, for a task that can go on without an answer. Use `send()`
92
+ * when the task can't go on without one.
93
+ *
94
+ * @param text The message to send.
95
+ * @param timeoutMs How long to wait for the reply, in milliseconds.
96
+ * @param fallback What to resolve with when no reply can come.
97
+ * @param options The conversation to continue and the files to attach, plus per-call request overrides.
98
+ * @returns The requester's reply, with its files downloaded, or `fallback`.
99
+ * @throws The task's abort reason, once the task is canceled, fails or moves to another session.
100
+ */
101
+ sendWithDefault<T>(text: string, timeoutMs: number, fallback: T, options?: Omit<RequesterMessageOptions, "timeoutMs">): Promise<MessageReply | T>;
69
102
  /**
70
103
  * Opens the task's inbox, so the requester's messages about the task queue up for the work in progress
71
104
  * instead of reaching `onMessage`, each answered right away with an acknowledgement. It closes once the task ends.
@@ -83,10 +116,12 @@ export interface IncomingTask {
83
116
  */
84
117
  deliver(source: ArtifactSource): Promise<void>;
85
118
  /**
86
- * Adds to the task's running cost, which a `cost_plus` skill charges plus its markup once the
87
- * task completes or its requester cancels it. A `cost_plus` task that never calls this fails instead of completing.
119
+ * Adds to the task's running cost, which a `cost_plus` skill charges plus its markup once the task
120
+ * completes or its requester cancels it. Call it as each cost is incurred, such as after every model
121
+ * step: the SDK adds up the increments and reports the running total to the relay in batches, so
122
+ * there's no need to round or accumulate costs first. A task that never calls it costs nothing.
88
123
  *
89
- * @param costCents The cost to add in cents, at least 0 and as precise as a millionth of a cent, such as 0.0137.
124
+ * @param costCents The cost to add, in cents, which may be fractional down to a millionth of a cent, such as 0.0137.
90
125
  * @throws {AgentJamError} If `costCents` isn't a finite number of at least 0.
91
126
  */
92
127
  incrementCost(costCents: number): void;
@@ -182,17 +217,13 @@ export interface IncomingTask {
182
217
  */
183
218
  listHistory(query?: HistoryQuery): Promise<HistoryPage>;
184
219
  /**
185
- * Gets the task's input as the skill's input schema parsed it before the task was accepted, so its
186
- * refinements held and its transforms applied.
220
+ * Recaps the most recent run of this task's schedule that completed before this one, such as to pick up where it
221
+ * left off, by paging through `listHistory()` and recalling the run it finds.
187
222
  *
188
- * @param skill The skill the task calls for, with its `input` schema.
189
- * @returns The requester's input, parsed.
190
- * @throws {AgentJamError} If the task calls for another skill, or this process wasn't connected with the skill's input schema.
223
+ * @returns What the run asked for and produced, or `undefined` when no earlier run completed or the task isn't a run.
224
+ * @throws {AgentJamError} If the relay doesn't keep tasks.
191
225
  */
192
- getInput<Schema extends InputSchema>(skill: {
193
- name: string;
194
- input: Schema;
195
- }): InferOutput<Schema>;
226
+ lastRun(): Promise<TaskRecap | undefined>;
196
227
  /**
197
228
  * Sets the task's structured output, which the requester reads with `getOutput()` once the task completes.
198
229
  * A task whose skill has an output schema must set it before it completes, and setting it again replaces it.
@@ -215,6 +246,11 @@ export interface IncomingTask {
215
246
  */
216
247
  subscribe(config: Record<string, unknown>): void;
217
248
  }
249
+ /** The follow-up chain a task belongs to. */
250
+ export type TaskChain = {
251
+ /** The id of the chain's first task, which is the task's own id when it follows up on nothing. */
252
+ readonly root: string;
253
+ };
218
254
  /** Options for a task's `send()`, which is always about that task. */
219
255
  export type TaskMessageOptions = Omit<SendOptions, "taskId">;
220
256
  /** Options for a running task's `send()` to its requester, which only the requester can steer. */
@@ -233,7 +269,7 @@ type TaskDetails = Pick<IncomingTask, "id" | "from" | "text" | "skill" | "attach
233
269
  previous?: TaskRecap | undefined;
234
270
  scheduleId?: string | undefined;
235
271
  run?: number | undefined;
236
- event?: TriggerEvent | undefined;
272
+ event?: FiredEvent | undefined;
237
273
  attempt?: number | undefined;
238
274
  resumable?: boolean;
239
275
  price?: Price | undefined;
@@ -250,10 +286,11 @@ export type ConnectionAccess = Pick<IncomingTask, "credentials" | "account" | "c
250
286
  type ExecutionLink = {
251
287
  post: (body: Body<TaskEnvelope> | CostReport) => Promise<void>;
252
288
  send: (text: string, options: TaskMessageOptions) => Promise<MessageReply>;
253
- /** Uploads a file artifact, resolving with `undefined` when the relay can't store files. */
254
- upload: (source: UploadSource, signal: AbortSignal) => Promise<string | undefined>;
289
+ /** Uploads a file artifact, rejecting when the relay can't store files. */
290
+ upload: (source: UploadSource, signal: AbortSignal) => Promise<string>;
255
291
  prepare: (delegates: Delegate[]) => Promise<void>;
256
292
  listHistory: (query: HistoryQuery) => Promise<HistoryPage>;
293
+ recall: (task: TaskRef) => Promise<TaskRecap>;
257
294
  requireAccess: (connection: DeclaredConnection, options: AccessOptions, signal: AbortSignal) => Promise<void>;
258
295
  };
259
296
  /**
@@ -271,15 +308,17 @@ export declare class TaskExecution implements IncomingTask {
271
308
  private readonly link;
272
309
  readonly id: string;
273
310
  readonly from: string;
274
- readonly principal: string | undefined;
311
+ readonly principal: string;
275
312
  readonly text: string;
276
313
  readonly skill: string | undefined;
277
- readonly input: JsonObject | undefined;
314
+ readonly input: unknown;
278
315
  readonly attachments: Attachment[];
316
+ readonly included: IncludedFiles;
279
317
  readonly previous: TaskRecap | undefined;
318
+ readonly chain: TaskChain;
280
319
  readonly scheduleId: string | undefined;
281
320
  readonly run: number | undefined;
282
- readonly event: TriggerEvent | undefined;
321
+ readonly event: FiredEvent | undefined;
283
322
  readonly attempt: number;
284
323
  /** Whether another session of this agent picks the task up once this one leaves, rather than it failing. */
285
324
  readonly resumable: boolean;
@@ -292,6 +331,8 @@ export declare class TaskExecution implements IncomingTask {
292
331
  private readonly backlogs;
293
332
  private readonly outcome;
294
333
  private ended;
334
+ private isHandedOver;
335
+ private result;
295
336
  private costCents;
296
337
  private reportedCents;
297
338
  private reportedAt;
@@ -300,7 +341,6 @@ export declare class TaskExecution implements IncomingTask {
300
341
  private readonly price;
301
342
  private readonly card;
302
343
  private readonly isSelf;
303
- private readonly parsedInput;
304
344
  private readonly subscribedTrigger;
305
345
  private readonly isOptedOut;
306
346
  private inbox;
@@ -314,20 +354,20 @@ export declare class TaskExecution implements IncomingTask {
314
354
  setHeldCents(heldCents: number): void;
315
355
  /** Resolves once the task has ended and its terminal envelope, if any, has been sent. */
316
356
  get settled(): Promise<void>;
357
+ /** How the task ended in this session, once `settled` resolved. */
358
+ get ending(): TaskEnding;
317
359
  update(text: string): Promise<void>;
318
360
  send(text: string, options?: RequesterMessageOptions): Promise<MessageReply>;
361
+ sendWithDefault<T>(text: string, timeoutMs: number, fallback: T, options?: Omit<RequesterMessageOptions, "timeoutMs">): Promise<T | MessageReply>;
319
362
  openInbox(): TaskInbox;
320
363
  /** Queues a requester's message about the task for the work in progress, returning whether its open inbox took it. */
321
364
  queueMessage(message: IncomingMessage): boolean;
322
365
  prepare(delegates: Delegate[]): Promise<void>;
323
366
  listHistory(query?: HistoryQuery): Promise<HistoryPage>;
367
+ lastRun(): Promise<TaskRecap | undefined>;
324
368
  requireAccess(connection: DeclaredConnection, options: AccessOptions): Promise<void>;
325
369
  incrementCost(costCents: number): void;
326
370
  commit({ costCents }?: CommitOptions): Promise<void>;
327
- getInput<Schema extends InputSchema>({ name, }: {
328
- name: string;
329
- input: Schema;
330
- }): InferOutput<Schema>;
331
371
  setOutput<Schema extends InputSchema>({ name, output }: {
332
372
  name: string;
333
373
  output: Schema;
@@ -338,8 +378,12 @@ export declare class TaskExecution implements IncomingTask {
338
378
  perform(work: (task: IncomingTask) => Awaitable<TaskOutput>): Promise<void>;
339
379
  fail(error: unknown): Promise<void>;
340
380
  cancel(reason: string | undefined, code?: TaskEndCode): void;
381
+ get handedOver(): boolean;
341
382
  /** Ends the task in this session without telling the requester, aborting its signal with `error`. */
342
383
  abandon(error: AgentJamError): void;
384
+ /** Leaves the task for another session to resume, aborting its signal with `error`. */
385
+ handOver(error: AgentJamError): void;
386
+ private stop;
343
387
  private settle;
344
388
  private post;
345
389
  /** Abandons the task once the relay refuses `request` because the task moved to another session. */
@@ -357,7 +401,7 @@ export declare class TaskExecution implements IncomingTask {
357
401
  private assertSkill;
358
402
  private finish;
359
403
  private stream;
360
- /** Uploads a stream of bytes as a file, or hands back the content to stream live when it's text or can't upload. */
404
+ /** Uploads a stream of bytes as a file, or hands back text to stream live. */
361
405
  private uploadBytes;
362
406
  private sendUpload;
363
407
  }