@midsummer-ai/sdk 0.1.0-staging.5411 → 0.1.0-staging.5417
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/agents/index.d.mts +14 -1
- package/agents/index.mjs +14 -0
- package/agents/stand-in.d.mts +1 -0
- package/agents/stand-in.mjs +8 -0
- package/here-BO-wQDjz.mjs +1 -1
- package/package.json +1 -1
package/agents/index.d.mts
CHANGED
|
@@ -46,6 +46,15 @@ interface AgentContext {
|
|
|
46
46
|
* as JSON fitting that schema; without, as the engine's words. A loop that couldn't finish throws its reason.
|
|
47
47
|
*/
|
|
48
48
|
loop(loop: Loop): Promise<unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* Runs another agent of the project, by name, on what it runs in this run's environment, and returns its output.
|
|
51
|
+
* It's a durable call: asked again on resume, it's the same run. While it works, this run waits without holding
|
|
52
|
+
* anything open, as with a loop; `Promise.all` over calls runs them all at once. It spends from this run's budget.
|
|
53
|
+
* An agent that couldn't finish throws its reason.
|
|
54
|
+
*
|
|
55
|
+
* const [a, b] = await Promise.all([agent.call("researcher", { site: "a.example" }), agent.call("researcher", { site: "b.example" })])
|
|
56
|
+
*/
|
|
57
|
+
call(name: string, input?: unknown): Promise<unknown>;
|
|
49
58
|
/**
|
|
50
59
|
* Asks a person on the team to approve before the code goes on, and returns their answer: `approved`, who, and their
|
|
51
60
|
* note. While it waits the run holds nothing open, for as long as the version's time limit allows; it is shown in
|
|
@@ -186,7 +195,11 @@ type AgentCall = {
|
|
|
186
195
|
readonly prompt?: string;
|
|
187
196
|
} & Omit<Question, "prompt">) | ({
|
|
188
197
|
readonly kind: "loop";
|
|
189
|
-
} & Loop) |
|
|
198
|
+
} & Loop) | {
|
|
199
|
+
readonly kind: "agent";
|
|
200
|
+
readonly name: string;
|
|
201
|
+
readonly input?: unknown;
|
|
202
|
+
} | ({
|
|
190
203
|
readonly kind: "approve";
|
|
191
204
|
} & Approval);
|
|
192
205
|
type RunStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
|
package/agents/index.mjs
CHANGED
|
@@ -208,6 +208,20 @@ async function execute(agent, wire, env = {}) {
|
|
|
208
208
|
},
|
|
209
209
|
ask,
|
|
210
210
|
loop,
|
|
211
|
+
call: async (name, input) => {
|
|
212
|
+
const kept = await call(nextId(), {
|
|
213
|
+
kind: "agent",
|
|
214
|
+
name,
|
|
215
|
+
...input === void 0 ? {} : { input }
|
|
216
|
+
});
|
|
217
|
+
if (!kept.done) {
|
|
218
|
+
waiting++;
|
|
219
|
+
idle();
|
|
220
|
+
return new Promise(() => {});
|
|
221
|
+
}
|
|
222
|
+
if (kept.error !== void 0) throw new AgentError("failed", `${name} couldn't finish: ${kept.error}`);
|
|
223
|
+
return kept.value;
|
|
224
|
+
},
|
|
211
225
|
approve
|
|
212
226
|
};
|
|
213
227
|
let output;
|
package/agents/stand-in.d.mts
CHANGED
|
@@ -32,6 +32,7 @@ declare function agentStandIn(options?: {
|
|
|
32
32
|
readonly ask?: (prompt: string, question: Question) => Promise<string | Answer> | string | Answer;
|
|
33
33
|
readonly loop?: (loop: Loop) => Promise<string> | string;
|
|
34
34
|
readonly approve?: (approval: Approval) => Promise<Decision> | Decision;
|
|
35
|
+
readonly agents?: Readonly<Record<string, (input: unknown) => Promise<unknown> | unknown>>;
|
|
35
36
|
}): AgentStandIn;
|
|
36
37
|
//#endregion
|
|
37
38
|
export { AgentStandIn, StandInEvent, agentStandIn };
|
package/agents/stand-in.mjs
CHANGED
|
@@ -120,6 +120,14 @@ function agentStandIn(options = {}) {
|
|
|
120
120
|
toolCalls: []
|
|
121
121
|
} : said, { prompt: call.prompt ?? "" });
|
|
122
122
|
}
|
|
123
|
+
case "agent": {
|
|
124
|
+
const other = options.agents?.[call.name];
|
|
125
|
+
if (!other) throw new AgentError("not-found", `There is no agent ${call.name} in this Stand-in: give it under \`agents\`.`);
|
|
126
|
+
return keep("step", {
|
|
127
|
+
done: true,
|
|
128
|
+
value: clone(await other(clone(call.input))) ?? null
|
|
129
|
+
}, { agent: call.name });
|
|
130
|
+
}
|
|
123
131
|
case "approve": {
|
|
124
132
|
if (!options.approve) throw new AgentError("invalid", "Approvals are not set up in this Stand-in: give it `approve`.");
|
|
125
133
|
const { kind: _kind, ...asked } = call;
|
package/here-BO-wQDjz.mjs
CHANGED
|
@@ -21,7 +21,7 @@ function processEnv() {
|
|
|
21
21
|
* This package's version: `0.0.0-dev` here, and in a published package the version it was published at, which the
|
|
22
22
|
* release writes in its place as it stages the package (`stampSdk` in `scripts/release/packages.ts`).
|
|
23
23
|
*/
|
|
24
|
-
const SDK_VERSION = "0.1.0-staging.
|
|
24
|
+
const SDK_VERSION = "0.1.0-staging.5417";
|
|
25
25
|
/**
|
|
26
26
|
* The header that tells Midsummer which client made each of this package's calls: `Midsummer-Client: sdk/<version>
|
|
27
27
|
* <part>`, `part` the product whose client it is (`database`, `storage`, `queues`, ...), so the platform counts which
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midsummer-ai/sdk",
|
|
3
|
-
"version": "0.1.0-staging.
|
|
3
|
+
"version": "0.1.0-staging.5417",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Midsummer's handles for an app's code: its Database, Storage, Queues, Vector DB, AI, Email and Agents, with stand-ins for tests.",
|