@agentjam/sdk 0.5.0 → 0.6.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.
- package/dist/adapters/ai.d.ts +1 -1
- package/dist/adapters/ai.d.ts.map +1 -1
- package/dist/adapters/anthropic.d.ts +1 -1
- package/dist/adapters/anthropic.d.ts.map +1 -1
- package/dist/adapters/openai.d.ts +1 -1
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openaiAgents.d.ts +1 -1
- package/dist/adapters/openaiAgents.d.ts.map +1 -1
- package/dist/adapters/shared.d.ts +2 -2
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/adapters/shared.js +6 -2
- package/dist/adapters/shared.js.map +1 -1
- package/dist/agent.d.ts +73 -5
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +140 -10
- package/dist/agent.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +163 -6
- package/dist/protocol.d.ts.map +1 -1
- package/dist/relay/frames.d.ts +52 -2
- package/dist/relay/frames.d.ts.map +1 -1
- package/dist/relay/frames.js +2 -0
- package/dist/relay/frames.js.map +1 -1
- package/dist/relay/payments.d.ts +8 -3
- package/dist/relay/payments.d.ts.map +1 -1
- package/dist/relay/payments.js +20 -2
- package/dist/relay/payments.js.map +1 -1
- package/dist/relay/relay.d.ts +44 -5
- package/dist/relay/relay.d.ts.map +1 -1
- package/dist/relay/remote.d.ts.map +1 -1
- package/dist/relay/remote.js +65 -8
- package/dist/relay/remote.js.map +1 -1
- package/dist/relay/schedules.d.ts +2 -1
- package/dist/relay/schedules.d.ts.map +1 -1
- package/dist/relay/schedules.js +13 -3
- package/dist/relay/schedules.js.map +1 -1
- package/dist/tasks/outgoing.d.ts.map +1 -1
- package/dist/tasks/outgoing.js +1 -0
- package/dist/tasks/outgoing.js.map +1 -1
- package/dist/tasks/scheduled.d.ts +18 -8
- package/dist/tasks/scheduled.d.ts.map +1 -1
- package/dist/tasks/scheduled.js +77 -20
- package/dist/tasks/scheduled.js.map +1 -1
- package/dist/tasks/triggers.d.ts +11 -3
- package/dist/tasks/triggers.d.ts.map +1 -1
- package/dist/tasks/triggers.js +30 -11
- package/dist/tasks/triggers.js.map +1 -1
- package/dist/tools/delegations.d.ts +17 -0
- package/dist/tools/delegations.d.ts.map +1 -0
- package/dist/tools/delegations.js +67 -0
- package/dist/tools/delegations.js.map +1 -0
- package/dist/tools/inputs.d.ts +62 -0
- package/dist/tools/inputs.d.ts.map +1 -0
- package/dist/tools/inputs.js +143 -0
- package/dist/tools/inputs.js.map +1 -0
- package/dist/tools/network.d.ts +10 -0
- package/dist/tools/network.d.ts.map +1 -0
- package/dist/tools/network.js +435 -0
- package/dist/tools/network.js.map +1 -0
- package/dist/tools/schedules.d.ts +43 -0
- package/dist/tools/schedules.d.ts.map +1 -0
- package/dist/tools/schedules.js +337 -0
- package/dist/tools/schedules.js.map +1 -0
- package/dist/tools/shared.d.ts +152 -0
- package/dist/tools/shared.d.ts.map +1 -0
- package/dist/tools/shared.js +151 -0
- package/dist/tools/shared.js.map +1 -0
- package/package.json +1 -1
package/dist/adapters/ai.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LanguageModel, ModelMessage, TextStreamPart, ToolLoopAgentSettings, ToolSet } from "ai";
|
|
2
2
|
import type { AdapterHandlers, Agent } from "../agent.js";
|
|
3
3
|
import type { ContentOptions, LabeledContent } from "../content.js";
|
|
4
|
-
import type { ToolName } from "../tools.js";
|
|
4
|
+
import type { ToolName } from "../tools/shared.js";
|
|
5
5
|
import type { IncomingMessage } from "../types.js";
|
|
6
6
|
import type { AdapterScreen } from "./shared.js";
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/adapters/ai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,OAAO,EACR,MAAM,IAAI,CAAC;AASZ,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/adapters/ai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,OAAO,EACR,MAAM,IAAI,CAAC;AASZ,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAA6B,MAAM,aAAa,CAAC;AAU5E;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,UAAW,KAAK,SAAS,QAAQ,EAAE,KAAG,OAgBvD,CAAC;AA2CJ;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,YACjB,eAAe,KACvB,OAAO,CAAC,YAAY,EAAE,CAGxB,CAAC;AAkBF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,SAAS,OAAO,UACtC,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,YAClC,cAAc,KACvB,cAAuD,CAAC;AA2C3D,iCAAiC;AACjC,MAAM,MAAM,YAAY,GAAG;IACzB,gHAAgH;IAChH,MAAM,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;CACvC,CAAC;AAwBF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,SAAS,OAAO,YACnC,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,eACjC,YAAY,KACvB,eAsCF,CAAC"}
|
|
@@ -4,7 +4,7 @@ import type { BetaToolRunnerParams } from "@anthropic-ai/sdk/lib/tools/BetaToolR
|
|
|
4
4
|
import type { BetaMessageParam } from "@anthropic-ai/sdk/resources/beta/messages/messages";
|
|
5
5
|
import type { Tool, ToolResultBlockParam, ToolUseBlock } from "@anthropic-ai/sdk/resources/messages/messages";
|
|
6
6
|
import type { AdapterHandlers, Agent } from "../agent.js";
|
|
7
|
-
import type { ToolCallOptions, ToolName } from "../tools.js";
|
|
7
|
+
import type { ToolCallOptions, ToolName } from "../tools/shared.js";
|
|
8
8
|
import type { IncomingMessage } from "../types.js";
|
|
9
9
|
import type { AdapterScreen } from "./shared.js";
|
|
10
10
|
/** Everything `client.beta.messages.toolRunner()` accepts except the messages, which come from the network. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/adapters/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAEV,oBAAoB,EACrB,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,KAAK,EAGV,IAAI,EACJ,oBAAoB,EACpB,YAAY,EACb,MAAM,+CAA+C,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAK1D,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","s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AQ,EAAE,KAChB,gBAAgB,EAchB,CAAC;AAOJ;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,YACrB,eAAe,KACvB,OAAO,CAAC,gBAAgB,EAAE,CAG5B,CAAC;AA2DF,qCAAqC;AACrC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gHAAgH;IAChH,MAAM,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;CAClD,CAAC;AAuCF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,WAChB,SAAS,UACT,eAAe,eACX,gBAAgB,KAC3B,eAoCF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EasyInputMessage, FunctionTool, ResponseFunctionToolCall, ResponseInputItem } from "openai/resources/responses/responses";
|
|
2
2
|
import type { Agent } from "../agent.js";
|
|
3
|
-
import type { ToolCallOptions, ToolName } from "../tools.js";
|
|
3
|
+
import type { ToolCallOptions, ToolName } from "../tools/shared.js";
|
|
4
4
|
import type { IncomingMessage } from "../types.js";
|
|
5
5
|
/** The network tools as Responses API function definitions, plus a dispatcher for the model's calls to them. */
|
|
6
6
|
export type OpenAITools = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAUnD,gHAAgH;AAChH,MAAM,MAAM,WAAW,GAAG;IACxB,2DAA2D;IAC3D,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B;;;;;;OAMG;IACH,OAAO,EAAE,CACP,IAAI,EAAE,wBAAwB,EAC9B,OAAO,CAAC,EAAE,eAAe,KACtB,OAAO,CAAC,iBAAiB,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CAChE,CAAC;AA+CF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,UAAW,KAAK,SAAS,QAAQ,EAAE,KAAG,WA6B7D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,YAClB,eAAe,KACvB,OAAO,CAAC,gBAAgB,EAAE,CAG5B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentInputItem, AgentOutputType, Tool } from "@openai/agents";
|
|
2
2
|
import { Agent as OpenAIAgent } from "@openai/agents";
|
|
3
3
|
import type { AdapterHandlers, Agent } from "../agent.js";
|
|
4
|
-
import type { ToolName } from "../tools.js";
|
|
4
|
+
import type { ToolName } from "../tools/shared.js";
|
|
5
5
|
import type { IncomingMessage } from "../types.js";
|
|
6
6
|
import type { AdapterScreen } from "./shared.js";
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openaiAgents.d.ts","sourceRoot":"","sources":["../../src/adapters/openaiAgents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAGf,IAAI,EAEL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,KAAK,IAAI,WAAW,EAIrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAK1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"openaiAgents.d.ts","sourceRoot":"","sources":["../../src/adapters/openaiAgents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EAGf,IAAI,EAEL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,KAAK,IAAI,WAAW,EAIrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAK1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAA6B,MAAM,aAAa,CAAC;AAW5E;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,SACjC,KAAK,SACL,QAAQ,EAAE,KAChB,IAAI,CAAC,QAAQ,CAAC,EAYd,CAAC;AAwDJ;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,YACd,eAAe,KACvB,OAAO,CAAC,cAAc,EAAE,CAK1B,CAAC;AAyCF,wCAAwC;AACxC,MAAM,MAAM,mBAAmB,GAAG;IAChC,gHAAgH;IAChH,MAAM,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;CAC9C,CAAC;AAoBF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,EAAE,OAAO,SAAS,eAAe,QAClE,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,eACxB,mBAAmB,KAC9B,eAiCF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AdapterHandlers, Agent } from "../agent.js";
|
|
2
2
|
import type { Judge, ScreenSettings } from "../screening.js";
|
|
3
3
|
import type { IncomingTask } from "../tasks/incoming.js";
|
|
4
|
-
import type { NetworkTool, ToolCallOptions, ToolName } from "../tools.js";
|
|
4
|
+
import type { NetworkTool, ToolCallOptions, ToolName } from "../tools/shared.js";
|
|
5
5
|
import type { Attachment, IncomingMessage, RemoteFile } from "../types.js";
|
|
6
6
|
export declare const maxShownFiles = 20;
|
|
7
7
|
export declare const maxShownBytes: number;
|
|
@@ -46,7 +46,7 @@ export declare const constructModelContent: (source: {
|
|
|
46
46
|
text: string;
|
|
47
47
|
attachments: Attachment[];
|
|
48
48
|
}) => Promise<ModelContent>;
|
|
49
|
-
/** Builds what the model sees of a task: its text, structured input and a recap of the task it follows up on. */
|
|
49
|
+
/** Builds what the model sees of a task: its text, structured input, its files' ids and a recap of the task it follows up on. */
|
|
50
50
|
export declare const constructTaskContent: ({ text, input, previous, attachments, }: Pick<IncomingTask, "text" | "input" | "previous" | "attachments">) => Promise<ModelContent>;
|
|
51
51
|
/**
|
|
52
52
|
* Maps the earlier turns of a message's conversation, which keep no files, from the receiver's point of view,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/adapters/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/adapters/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EACV,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/dist/adapters/shared.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
import { AgentJamError } from "../errors.js";
|
|
3
|
-
import { pickTools } from "../tools.js";
|
|
3
|
+
import { pickTools } from "../tools/network.js";
|
|
4
4
|
const mebibyte = 1024 * 1024;
|
|
5
5
|
export const maxShownFiles = 20;
|
|
6
6
|
export const maxShownBytes = 20 * mebibyte;
|
|
@@ -133,11 +133,15 @@ export const constructModelContent = async (source) => ({
|
|
|
133
133
|
text: source.text,
|
|
134
134
|
files: await convertFiles(source.attachments),
|
|
135
135
|
});
|
|
136
|
-
/** Builds what the model sees of a task: its text, structured input and a recap of the task it follows up on. */
|
|
136
|
+
/** Builds what the model sees of a task: its text, structured input, its files' ids and a recap of the task it follows up on. */
|
|
137
137
|
export const constructTaskContent = ({ text, input, previous, attachments, }) => {
|
|
138
|
+
const files = attachments.map(({ id, name }) => ({ fileId: id, name }));
|
|
138
139
|
const sections = [
|
|
139
140
|
text,
|
|
140
141
|
...(input ? [`Input: ${JSON.stringify(input)}`] : []),
|
|
142
|
+
...(files.length > 0
|
|
143
|
+
? [`The task's files, which you can attach: ${JSON.stringify(files)}`]
|
|
144
|
+
: []),
|
|
141
145
|
...(previous
|
|
142
146
|
? [
|
|
143
147
|
`This task follows up on task ${previous.id}, which you ran for ${previous.requester}. Its recap: ${JSON.stringify(previous)}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/adapters/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/adapters/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAA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GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAElE,OAAO;QACL,MAAM,EAAE;YACN,GAAG,QAAQ;YACX,GAAG,CAAC,MAAM,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;YACvC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC;SACzB;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnyOfConnection, AnyOfCredentials } from "./anyOf.js";
|
|
2
2
|
import type { ConnectionGrant, ConnectionHolder, CredentialSource } from "./connections.js";
|
|
3
3
|
import type { EventSource, SourceRequest, SourceResponse } from "./events.js";
|
|
4
|
-
import type { TaskRef } from "./protocol.js";
|
|
4
|
+
import type { ListedSchedule, ScheduleAmendment, ScheduleReport, TaskRef, TaskView } from "./protocol.js";
|
|
5
5
|
import type { Account } from "./providers.js";
|
|
6
6
|
import type { Payments } from "./relay/payments.js";
|
|
7
7
|
import type { Relay } from "./relay/relay.js";
|
|
@@ -9,8 +9,8 @@ import type { ProposalScreen } from "./screening.js";
|
|
|
9
9
|
import type { IncomingTask, TaskOutput } from "./tasks/incoming.js";
|
|
10
10
|
import type { OutgoingTask } from "./tasks/outgoing.js";
|
|
11
11
|
import type { Schedule } from "./tasks/scheduled.js";
|
|
12
|
-
import type { NetworkTool, ToolName } from "./tools.js";
|
|
13
|
-
import type { ActionRequest, AgentCard, AgentQuery, AutoReloadSettings, Awaitable, CreditAccount, DispatchedEvent, Dispute, DrainOptions, IncomingMessage, MessageReply, Proposal, ProposeOptions, ReplyOutput, Review, ReviewPage, ReviewQuery, ScheduleOptions, SendOptions, SkillHandler, TaskOutcome, TaskPage, TaskQuery, TaskRecap, Verdict } from "./types.js";
|
|
12
|
+
import type { NetworkTool, ToolName } from "./tools/shared.js";
|
|
13
|
+
import type { ActionRequest, AgentCard, AgentQuery, AutoReloadSettings, Awaitable, CreditAccount, DispatchedEvent, Dispute, DrainOptions, HistoryPage, HistoryQuery, IncomingMessage, MessageReply, Proposal, ProposeOptions, ReplyOutput, Review, ReviewPage, ReviewQuery, ScheduleFollowUp, ScheduleOptions, SendOptions, SkillHandler, TaskOutcome, TaskPage, TaskQuery, TaskRecap, Verdict } from "./types.js";
|
|
14
14
|
export declare const warnPayouts: (name: string, payoutsUrl: string) => void;
|
|
15
15
|
/** Where an agent lives on the network, which `create()`, `update()` and `connect()` all take. */
|
|
16
16
|
export type AgentIdentity = {
|
|
@@ -34,9 +34,9 @@ export type AgentHandlers = {
|
|
|
34
34
|
onTask?: (task: IncomingTask, agent: Agent) => Awaitable<TaskOutput>;
|
|
35
35
|
/** Handles an error that can't be reported back to another agent, such as a lost connection. Defaults to `console.error`. */
|
|
36
36
|
onError?: (error: unknown) => void;
|
|
37
|
-
/** Handles a run of one of this agent's schedules that
|
|
37
|
+
/** Handles a run of one of this agent's schedules that nothing in this process reads from its `Schedule.runs()`, such as after a restart. Defaults to logging the run's outcome. */
|
|
38
38
|
onRun?: (run: OutgoingTask, agent: Agent) => Awaitable<void>;
|
|
39
|
-
/** Handles a follow-up the relay proposed after a run of one of this agent's schedules that
|
|
39
|
+
/** Handles a follow-up the relay proposed after a run of one of this agent's schedules that nothing in this process reads from its `Schedule.followUps()`. Defaults to logging the follow-up's outcome. */
|
|
40
40
|
onFollowUp?: (task: OutgoingTask, agent: Agent) => Awaitable<void>;
|
|
41
41
|
/** Handles a delegated task or schedule that waits for your human to act, such as connecting an account at a link. Defaults to `console.warn`. */
|
|
42
42
|
onActionRequired?: (request: ActionRequest, agent: Agent) => Awaitable<void>;
|
|
@@ -196,6 +196,27 @@ export declare class Agent {
|
|
|
196
196
|
* @throws {TimeoutError} If no response arrives within the timeout.
|
|
197
197
|
*/
|
|
198
198
|
schedule(to: string, text: string, { cron, trigger, budget, skill, input, maxPriceCents, expiresAt, attachments, then, idempotencyKey, ...options }: ScheduleOptions): Promise<Schedule>;
|
|
199
|
+
/**
|
|
200
|
+
* Ends a schedule this agent proposed or runs so no more runs start, leaving a run in progress to finish. Unlike
|
|
201
|
+
* `Schedule.end()`, it needs no handle, so it also ends schedules from before a restart, such as the one a run names.
|
|
202
|
+
*
|
|
203
|
+
* @param to The address of the other party: the agent running the schedule, or its requester when this agent runs it.
|
|
204
|
+
* @param scheduleId The schedule's `id`, which each of its runs carries as `scheduleId`.
|
|
205
|
+
* @param reason Why the schedule is ending, shown to the other party.
|
|
206
|
+
* @returns Resolves once the ending has been sent.
|
|
207
|
+
*/
|
|
208
|
+
endSchedule(to: string, scheduleId: string, reason?: string): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Cancels a task this agent delegated that's still running, such as a schedule's run. Unlike
|
|
211
|
+
* `OutgoingTask.cancel()`, it needs no handle, so it also cancels tasks from before a restart.
|
|
212
|
+
*
|
|
213
|
+
* @param taskId The `id` of the delegated task.
|
|
214
|
+
* @param reason Why the task is no longer needed, shown to the executor.
|
|
215
|
+
* @returns Resolves once the cancellation has been sent, or at once if the task already ended.
|
|
216
|
+
* @throws {TaskCommittedError} If the task's agent committed to an action it can't undo, or sent part of a flat-priced result.
|
|
217
|
+
* @throws {AgentJamError} If the relay doesn't keep tasks, or this agent delegated no such task.
|
|
218
|
+
*/
|
|
219
|
+
cancelTask(taskId: string, reason?: string): Promise<void>;
|
|
199
220
|
/**
|
|
200
221
|
* Rates the agent that performed a task this agent delegated. A task can be rated once, after it
|
|
201
222
|
* completed with at least one artifact.
|
|
@@ -243,6 +264,50 @@ export declare class Agent {
|
|
|
243
264
|
* @throws {AgentJamError} If the relay doesn't keep tasks, or this agent didn't execute the task.
|
|
244
265
|
*/
|
|
245
266
|
recallTask(task: TaskRef): Promise<TaskRecap>;
|
|
267
|
+
/**
|
|
268
|
+
* Reports a task this agent delegated as the relay keeps it, with its log, subtasks and unanswered
|
|
269
|
+
* questions. Once an ended task that isn't a schedule's run is reported, it no longer counts as unread.
|
|
270
|
+
*
|
|
271
|
+
* @param taskId The `id` of the delegated task.
|
|
272
|
+
* @returns The task, with its log so far.
|
|
273
|
+
* @throws {AgentJamError} If the relay doesn't keep tasks, or this agent delegated no such task.
|
|
274
|
+
*/
|
|
275
|
+
inspectTask(taskId: string): Promise<TaskView>;
|
|
276
|
+
/**
|
|
277
|
+
* Reports a schedule this agent requested, with up to 20 of the runs that finished since it last
|
|
278
|
+
* checked, which then count as checked.
|
|
279
|
+
*
|
|
280
|
+
* @param scheduleId The `id` of the schedule.
|
|
281
|
+
* @returns The schedule and its newly finished runs.
|
|
282
|
+
* @throws {AgentJamError} If the relay doesn't keep schedules, or this agent requested no such schedule.
|
|
283
|
+
*/
|
|
284
|
+
inspectSchedule(scheduleId: string): Promise<ScheduleReport>;
|
|
285
|
+
/**
|
|
286
|
+
* Lists the schedules this agent requested, with how many of each one's finished runs it hasn't checked.
|
|
287
|
+
*
|
|
288
|
+
* @returns The schedules.
|
|
289
|
+
* @throws {AgentJamError} If the relay doesn't keep schedules.
|
|
290
|
+
*/
|
|
291
|
+
listSchedules(): Promise<ListedSchedule[]>;
|
|
292
|
+
/**
|
|
293
|
+
* Lists the runs of a schedule this agent requested, newest first, without marking them as checked.
|
|
294
|
+
*
|
|
295
|
+
* @param scheduleId The `id` of the schedule.
|
|
296
|
+
* @param query The page size, and the `next` cursor of an earlier page to continue from.
|
|
297
|
+
* @returns A page of runs, with `next` set when older ones remain.
|
|
298
|
+
* @throws {AgentJamError} If the relay doesn't keep schedules, this agent requested no such schedule, or `query` is invalid.
|
|
299
|
+
*/
|
|
300
|
+
listRuns(scheduleId: string, query?: HistoryQuery): Promise<HistoryPage>;
|
|
301
|
+
/**
|
|
302
|
+
* Replaces the follow-up of a schedule this agent requested, or removes it. A follow-up that needs
|
|
303
|
+
* actions first waits on a preparation task before it replaces the old one.
|
|
304
|
+
*
|
|
305
|
+
* @param scheduleId The `id` of the schedule.
|
|
306
|
+
* @param then The new follow-up, or null to remove it.
|
|
307
|
+
* @returns The changed schedule, and the preparation the new follow-up waits on.
|
|
308
|
+
* @throws {AgentJamError} If the relay doesn't keep schedules, this agent requested no such schedule, or the relay refuses the follow-up.
|
|
309
|
+
*/
|
|
310
|
+
updateFollowUp(scheduleId: string, then: ScheduleFollowUp | null): Promise<ScheduleAmendment>;
|
|
246
311
|
/**
|
|
247
312
|
* Buys AgentJam credits for this agent's owner, paying over MPP with its `payments`. Cards buy at
|
|
248
313
|
* least $5 at a time, and stablecoin any amount from 1 cent.
|
|
@@ -438,6 +503,7 @@ export declare class Agent {
|
|
|
438
503
|
private orphan;
|
|
439
504
|
private abandonWork;
|
|
440
505
|
private listDelegated;
|
|
506
|
+
private findOutgoing;
|
|
441
507
|
private reattach;
|
|
442
508
|
private listEvery;
|
|
443
509
|
private withdraw;
|
|
@@ -447,6 +513,8 @@ export declare class Agent {
|
|
|
447
513
|
private stopSchedule;
|
|
448
514
|
private notice;
|
|
449
515
|
private followUp;
|
|
516
|
+
private handRun;
|
|
517
|
+
private handFollowUp;
|
|
450
518
|
private collectAfter;
|
|
451
519
|
private track;
|
|
452
520
|
private linkFile;
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AASpE,OAAO,KAAK,EAEV,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAiB1B,OAAO,KAAK,EACV,WAAW,EAEX,aAAa,EACb,cAAc,EACf,MAAM,aAAa,CAAC;AAMrB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AASpE,OAA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pB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,MAAM;YAWA,QAAQ;IAoBtB,mFAAmF;YACrE,eAAe;IAM7B,OAAO,CAAC,OAAO;IAmBf,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,YAAY;YAIN,QAAQ;YAYR,SAAS;IAkBvB,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,MAAM;YAyBA,aAAa;IAe3B,0GAA0G;YAC5F,YAAY;IAU1B,OAAO,CAAC,MAAM;IAqBd,OAAO,CAAC,QAAQ;IAkBhB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,KAAK;YAkDC,QAAQ;IAWtB,OAAO,CAAC,OAAO;IAqBf,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAO7B;IAEF,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,UAAU;YAMJ,IAAI;YAKJ,iBAAiB;CAwBhC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,YAAa,cAAc,KAAG,OAAO,CAAC,KAAK,CAC1C,CAAC"}
|
package/dist/agent.js
CHANGED
|
@@ -20,7 +20,7 @@ import { TaskHandle } from "./tasks/outgoing.js";
|
|
|
20
20
|
import { ScheduleHandle } from "./tasks/scheduled.js";
|
|
21
21
|
import { TriggerRunner } from "./tasks/triggers.js";
|
|
22
22
|
import { TaskWatches } from "./tasks/watches.js";
|
|
23
|
-
import { createNetworkTools, pickTools } from "./tools.js";
|
|
23
|
+
import { createNetworkTools, pickTools } from "./tools/network.js";
|
|
24
24
|
import { lostGrant, requestersOf } from "./vaults/vault.js";
|
|
25
25
|
import { accept, reject } from "./verdicts.js";
|
|
26
26
|
const defaultTimeout = 30_000;
|
|
@@ -35,6 +35,8 @@ const noDisputes = "This relay doesn't support disputes";
|
|
|
35
35
|
const noTaskList = "This relay doesn't list tasks";
|
|
36
36
|
const noRecall = "This relay doesn't recall tasks";
|
|
37
37
|
const noHistory = "This relay doesn't keep task history";
|
|
38
|
+
const noTasks = "This relay doesn't keep tasks";
|
|
39
|
+
const noSchedules = "This relay doesn't keep schedules";
|
|
38
40
|
const steered = "Passed your message to the running task, which reads it before its next step.";
|
|
39
41
|
const noUploads = "This relay doesn't take attachments";
|
|
40
42
|
const maxAttachments = 10;
|
|
@@ -519,7 +521,7 @@ export class Agent {
|
|
|
519
521
|
};
|
|
520
522
|
const id = key(to, idempotencyKey);
|
|
521
523
|
this.scheduling.add(id);
|
|
522
|
-
|
|
524
|
+
const schedule = await this.request(draft, options, (response) => {
|
|
523
525
|
if (response.type === "task.reject") {
|
|
524
526
|
this.scheduling.delete(id);
|
|
525
527
|
throw new TaskRejectedError(to, response.reason);
|
|
@@ -532,6 +534,52 @@ export class Agent {
|
|
|
532
534
|
this.require(to, response);
|
|
533
535
|
return this.follow(to, idempotencyKey, actionsOf(response), parent);
|
|
534
536
|
});
|
|
537
|
+
// WARNING: Runs can arrive before the caller gets the handle, so they're held until its code after `schedule()`
|
|
538
|
+
// has had the chance to start reading them.
|
|
539
|
+
setTimeout(() => schedule.stopHolding(), 0);
|
|
540
|
+
return schedule;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Ends a schedule this agent proposed or runs so no more runs start, leaving a run in progress to finish. Unlike
|
|
544
|
+
* `Schedule.end()`, it needs no handle, so it also ends schedules from before a restart, such as the one a run names.
|
|
545
|
+
*
|
|
546
|
+
* @param to The address of the other party: the agent running the schedule, or its requester when this agent runs it.
|
|
547
|
+
* @param scheduleId The schedule's `id`, which each of its runs carries as `scheduleId`.
|
|
548
|
+
* @param reason Why the schedule is ending, shown to the other party.
|
|
549
|
+
* @returns Resolves once the ending has been sent.
|
|
550
|
+
*/
|
|
551
|
+
async endSchedule(to, scheduleId, reason) {
|
|
552
|
+
const schedule = this.schedules.get(key(to, scheduleId));
|
|
553
|
+
if (schedule)
|
|
554
|
+
return schedule.end(reason);
|
|
555
|
+
await this.postTo(to)({
|
|
556
|
+
type: "schedule.end",
|
|
557
|
+
scheduleId,
|
|
558
|
+
...(reason === undefined ? {} : { reason }),
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Cancels a task this agent delegated that's still running, such as a schedule's run. Unlike
|
|
563
|
+
* `OutgoingTask.cancel()`, it needs no handle, so it also cancels tasks from before a restart.
|
|
564
|
+
*
|
|
565
|
+
* @param taskId The `id` of the delegated task.
|
|
566
|
+
* @param reason Why the task is no longer needed, shown to the executor.
|
|
567
|
+
* @returns Resolves once the cancellation has been sent, or at once if the task already ended.
|
|
568
|
+
* @throws {TaskCommittedError} If the task's agent committed to an action it can't undo, or sent part of a flat-priced result.
|
|
569
|
+
* @throws {AgentJamError} If the relay doesn't keep tasks, or this agent delegated no such task.
|
|
570
|
+
*/
|
|
571
|
+
async cancelTask(taskId, reason) {
|
|
572
|
+
const task = this.findOutgoing(taskId);
|
|
573
|
+
if (task)
|
|
574
|
+
return task.cancel(reason);
|
|
575
|
+
const { executor, status } = await this.inspectTask(taskId);
|
|
576
|
+
if (!openStatuses.includes(status))
|
|
577
|
+
return;
|
|
578
|
+
await this.postTo(executor)({
|
|
579
|
+
type: "task.cancel",
|
|
580
|
+
taskId,
|
|
581
|
+
...(reason === undefined ? {} : { reason }),
|
|
582
|
+
});
|
|
535
583
|
}
|
|
536
584
|
/**
|
|
537
585
|
* Rates the agent that performed a task this agent delegated. A task can be rated once, after it
|
|
@@ -609,6 +657,75 @@ export class Agent {
|
|
|
609
657
|
throw new AgentJamError(noRecall);
|
|
610
658
|
return recapFromWire(await connection.recall(task), this.files);
|
|
611
659
|
}
|
|
660
|
+
/**
|
|
661
|
+
* Reports a task this agent delegated as the relay keeps it, with its log, subtasks and unanswered
|
|
662
|
+
* questions. Once an ended task that isn't a schedule's run is reported, it no longer counts as unread.
|
|
663
|
+
*
|
|
664
|
+
* @param taskId The `id` of the delegated task.
|
|
665
|
+
* @returns The task, with its log so far.
|
|
666
|
+
* @throws {AgentJamError} If the relay doesn't keep tasks, or this agent delegated no such task.
|
|
667
|
+
*/
|
|
668
|
+
async inspectTask(taskId) {
|
|
669
|
+
const connection = await this.connection;
|
|
670
|
+
if (!connection.inspectTask)
|
|
671
|
+
throw new AgentJamError(noTasks);
|
|
672
|
+
return connection.inspectTask(taskId);
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Reports a schedule this agent requested, with up to 20 of the runs that finished since it last
|
|
676
|
+
* checked, which then count as checked.
|
|
677
|
+
*
|
|
678
|
+
* @param scheduleId The `id` of the schedule.
|
|
679
|
+
* @returns The schedule and its newly finished runs.
|
|
680
|
+
* @throws {AgentJamError} If the relay doesn't keep schedules, or this agent requested no such schedule.
|
|
681
|
+
*/
|
|
682
|
+
async inspectSchedule(scheduleId) {
|
|
683
|
+
const connection = await this.connection;
|
|
684
|
+
if (!connection.inspectSchedule)
|
|
685
|
+
throw new AgentJamError(noSchedules);
|
|
686
|
+
return connection.inspectSchedule(scheduleId);
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Lists the schedules this agent requested, with how many of each one's finished runs it hasn't checked.
|
|
690
|
+
*
|
|
691
|
+
* @returns The schedules.
|
|
692
|
+
* @throws {AgentJamError} If the relay doesn't keep schedules.
|
|
693
|
+
*/
|
|
694
|
+
async listSchedules() {
|
|
695
|
+
const connection = await this.connection;
|
|
696
|
+
if (!connection.listSchedules)
|
|
697
|
+
throw new AgentJamError(noSchedules);
|
|
698
|
+
return connection.listSchedules();
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Lists the runs of a schedule this agent requested, newest first, without marking them as checked.
|
|
702
|
+
*
|
|
703
|
+
* @param scheduleId The `id` of the schedule.
|
|
704
|
+
* @param query The page size, and the `next` cursor of an earlier page to continue from.
|
|
705
|
+
* @returns A page of runs, with `next` set when older ones remain.
|
|
706
|
+
* @throws {AgentJamError} If the relay doesn't keep schedules, this agent requested no such schedule, or `query` is invalid.
|
|
707
|
+
*/
|
|
708
|
+
async listRuns(scheduleId, query = {}) {
|
|
709
|
+
const connection = await this.connection;
|
|
710
|
+
if (!connection.listRuns)
|
|
711
|
+
throw new AgentJamError(noSchedules);
|
|
712
|
+
return connection.listRuns(scheduleId, query);
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Replaces the follow-up of a schedule this agent requested, or removes it. A follow-up that needs
|
|
716
|
+
* actions first waits on a preparation task before it replaces the old one.
|
|
717
|
+
*
|
|
718
|
+
* @param scheduleId The `id` of the schedule.
|
|
719
|
+
* @param then The new follow-up, or null to remove it.
|
|
720
|
+
* @returns The changed schedule, and the preparation the new follow-up waits on.
|
|
721
|
+
* @throws {AgentJamError} If the relay doesn't keep schedules, this agent requested no such schedule, or the relay refuses the follow-up.
|
|
722
|
+
*/
|
|
723
|
+
async updateFollowUp(scheduleId, then) {
|
|
724
|
+
const connection = await this.connection;
|
|
725
|
+
if (!connection.updateFollowUp)
|
|
726
|
+
throw new AgentJamError(noSchedules);
|
|
727
|
+
return connection.updateFollowUp(scheduleId, then);
|
|
728
|
+
}
|
|
612
729
|
/**
|
|
613
730
|
* Buys AgentJam credits for this agent's owner, paying over MPP with its `payments`. Cards buy at
|
|
614
731
|
* least $5 at a time, and stablecoin any amount from 1 cent.
|
|
@@ -1193,7 +1310,11 @@ export class Agent {
|
|
|
1193
1310
|
async restartTriggers(connection) {
|
|
1194
1311
|
if (!this.triggers.declared)
|
|
1195
1312
|
return;
|
|
1196
|
-
await this.triggers.sync(async () => (await connection).triggers?.());
|
|
1313
|
+
const ended = await this.triggers.sync(async () => (await connection).triggers?.(this.triggers.listWatched()));
|
|
1314
|
+
// WARNING: awaiting these stops would deadlock the first connect, since their posts wait for it to finish.
|
|
1315
|
+
for (const { requester, scheduleId } of ended) {
|
|
1316
|
+
void this.stopSchedule(requester, scheduleId).catch(this.onError);
|
|
1317
|
+
}
|
|
1197
1318
|
}
|
|
1198
1319
|
perform(recur) {
|
|
1199
1320
|
const { from, principal, scheduleId, run, taskId, text, skill, input } = recur;
|
|
@@ -1665,6 +1786,9 @@ export class Agent {
|
|
|
1665
1786
|
listDelegated() {
|
|
1666
1787
|
return Array.from(this.outgoing.values()).filter((task) => !isRun(task));
|
|
1667
1788
|
}
|
|
1789
|
+
findOutgoing(taskId) {
|
|
1790
|
+
return Array.from(this.outgoing.values()).find(({ id }) => id === taskId);
|
|
1791
|
+
}
|
|
1668
1792
|
async reattach(task) {
|
|
1669
1793
|
try {
|
|
1670
1794
|
await this.postTo(task.to)({ type: "task.reattach", taskId: task.id });
|
|
@@ -1708,7 +1832,9 @@ export class Agent {
|
|
|
1708
1832
|
const id = key(to, scheduleId);
|
|
1709
1833
|
const schedule = new ScheduleHandle(scheduleId, to, {
|
|
1710
1834
|
post: this.postTo(to),
|
|
1711
|
-
|
|
1835
|
+
collect: (run, handled) => this.collectAfter(run, scheduleId, handled),
|
|
1836
|
+
handRun: (run) => this.handRun(run, scheduleId),
|
|
1837
|
+
handFollowUp: (task) => this.handFollowUp(task),
|
|
1712
1838
|
release: () => this.schedules.delete(id),
|
|
1713
1839
|
}, actions, parent);
|
|
1714
1840
|
this.schedules.set(id, schedule);
|
|
@@ -1744,13 +1870,10 @@ export class Agent {
|
|
|
1744
1870
|
run: { scheduleId, event: eventOf(notice) },
|
|
1745
1871
|
...(schedule?.parent && { parent: schedule.parent }),
|
|
1746
1872
|
});
|
|
1747
|
-
if (schedule)
|
|
1873
|
+
if (schedule)
|
|
1748
1874
|
schedule.add(run);
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
const handled = Promise.resolve(this.onRun(run, this)).catch(this.onError);
|
|
1752
|
-
this.collectAfter(run, scheduleId, handled);
|
|
1753
|
-
}
|
|
1875
|
+
else
|
|
1876
|
+
this.handRun(run, scheduleId);
|
|
1754
1877
|
return run;
|
|
1755
1878
|
}
|
|
1756
1879
|
followUp(notice) {
|
|
@@ -1762,6 +1885,13 @@ export class Agent {
|
|
|
1762
1885
|
const schedule = [...this.schedules.values()].find(({ id }) => id === scheduleId);
|
|
1763
1886
|
if (schedule)
|
|
1764
1887
|
return schedule.addFollowUp(task);
|
|
1888
|
+
this.handFollowUp(task);
|
|
1889
|
+
}
|
|
1890
|
+
handRun(run, scheduleId) {
|
|
1891
|
+
const handled = Promise.resolve(this.onRun(run, this)).catch(this.onError);
|
|
1892
|
+
this.collectAfter(run, scheduleId, handled);
|
|
1893
|
+
}
|
|
1894
|
+
handFollowUp(task) {
|
|
1765
1895
|
Promise.resolve(this.onFollowUp(task, this)).catch(this.onError);
|
|
1766
1896
|
}
|
|
1767
1897
|
collectAfter(run, scheduleId, handled) {
|